feat(worker): 接线恢复派发台账并按激活登记启用

为什么:派发协议只在 worker 里装配却没人接,就等于只写了 store
mock。同步失败的自动 rollback 与维护恢复都必须拿到同一份台账;
baseline 只读装配永远不传,避免建基线顺带获得恢复写许可。

开关 LIBRARY_RESTORE_DISPATCH_V2 默认关闭,且只是"允许装配":
治理库没有该目标的未撤销激活登记时,Prepare/Acquire 直接 fail closed。

验证:cmd/worker 单测覆盖默认关闭/显式开启/无台账三态;
v071 真 ES 用例里自动 rollback 与手动恢复走的是同一个 Restore。
This commit is contained in:
姚章浩
2026-11-02 16:28:01 +08:00
parent e09fddcb74
commit 0a7c9f8510
7 changed files with 80 additions and 16 deletions
+13 -2
View File
@@ -23,8 +23,11 @@ type Config struct {
ReleaseConfigFile string
ProductionReleaseRequestsEnabled bool
ProductionBackupRestoreVerified bool
ProductionReleaseAuthorizerRef string
ProductionReleaseAuthTokenFile string
// LibraryRestoreDispatchEnabled 允许 worker 装配 DS01 派发台账;默认 false。
// 它不能单独证明独占:治理库里的目标激活登记同样必需。
LibraryRestoreDispatchEnabled bool
ProductionReleaseAuthorizerRef string
ProductionReleaseAuthTokenFile string
// Production WeKnora endpoint: the release target itself stays declared in
// the release runtime config (RELEASE_CONFIG_FILE); these settings only let
// the API probe that endpoint so the console can show its real state.
@@ -304,6 +307,14 @@ func Load(getenv func(string) string) (Config, error) {
return Config{}, fmt.Errorf("PRODUCTION_BACKUP_RESTORE_VERIFIED: %w", err)
}
}
// DS01 恢复标记派发协议:默认关闭。开关只是"允许装配"的意思,不是独占证明——
// 真正发放许可还要求治理库里对该目标存在未撤销的激活登记。
if raw := getenv("LIBRARY_RESTORE_DISPATCH_V2"); raw != "" {
config.LibraryRestoreDispatchEnabled, err = strconv.ParseBool(raw)
if err != nil {
return Config{}, fmt.Errorf("LIBRARY_RESTORE_DISPATCH_V2: %w", err)
}
}
if raw := getenv("PRODUCTION_WEKNORA_ALLOW_DOCKER_HTTP"); raw != "" {
config.ProductionWeKnoraAllowDockerHTTP, err = strconv.ParseBool(raw)
if err != nil {