feat(library): 人工恢复后按证据收尾维护窗口
build / build (push) Successful in 1m15s

回滚失败会按设计保持维护,但此前没有任何"人工确认后收尾"的路径:
journal 一直非终态,之后所有窗口都会被拦住。新增 libraryctl finalize:
不启动服务、不释放治理占用,只核对原本在跑的服务与入口是否真的在服务,
通过才把 journal 标成 operator_recovered。
This commit is contained in:
姚章浩
2026-10-28 23:42:28 +08:00
parent 38d04488de
commit 962bed8f53
4 changed files with 123 additions and 1 deletions
+30 -1
View File
@@ -90,6 +90,8 @@ func main() {
runErr = runVerify(opts)
case "recover":
runErr = runRecover(ctx, opts)
case "finalize":
runErr = runFinalize(ctx, opts)
default:
usage()
os.Exit(2)
@@ -101,7 +103,7 @@ func main() {
}
func usage() {
fmt.Fprint(os.Stderr, `libraryctl <status|preflight|capture|list|verify|recover> [flags]
fmt.Fprint(os.Stderr, `libraryctl <status|preflight|capture|list|verify|recover|finalize> [flags]
status probe the real source and print what is configured / blocked
preflight read the source, run settlement + candidate validation (no writes, no stop)
@@ -109,6 +111,8 @@ func usage() {
list list sealed candidates and stored bytes
verify re-verify one sealed candidate (digests, coverage, identity)
recover restore writers from an interrupted freeze journal
finalize close a held window after an operator recovered the target by hand
(verifies services + ingress are really serving; starts nothing)
Flags (defaults target the local WKNFull test stack):
-source-app WKNFull-app container whose env describes the source
@@ -817,6 +821,31 @@ func runVerify(opts options) error {
return nil
}
func runFinalize(ctx context.Context, opts options) error {
if opts.job == "" {
return errors.New("finalize requires -job")
}
coordinator, control, err := openFreeze(ctx, opts)
if err != nil {
return err
}
defer coordinator.Close()
defer control.Close()
if err := coordinator.FinalizeAfterOperatorRecovery(ctx, opts.job); err != nil {
return err
}
items, err := control.Inventory(ctx)
if err != nil {
return err
}
group := []map[string]any{}
for _, item := range items {
group = append(group, map[string]any{"id": item.ID, "running": item.Running, "healthy": item.Healthy})
}
printJSON(map[string]any{"finalized": opts.job, "code": "operator_recovered", "writers": group})
return nil
}
func runRecover(ctx context.Context, opts options) error {
coordinator, control, err := openFreeze(ctx, opts)
if err != nil {