Repository navigation
fix(gateway): prevent plugin rollback from hanging shutdown - #158194
Conversation
Restore configured context limits synchronously during uncommitted secret publication rollback, so model catalog replacement can settle without a circular wait. Preserve generation fencing and normal committed catalog refresh. Strengthen the existing rollback regression with a real pending model replacement and cold candidate limits.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: blocked before merge. Reviewed September 25, 2026, 12:40 PM ET / 16:40 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch makes failed plugin replacement restore configured model context limits synchronously, expands the rollback regression, and documents the behavior. Merge readiness⛔ Blocked before merge - 2 items remain Current main still contains the rollback wait implicated in the shutdown hang, so this PR remains useful. The focused regression supports the repair, but the previously requested after-fix run of the original ordered Gateway flow is still pending. Priority: P1 Review scores
Verification
How this fits togetherGateway configuration reload replaces plugin runtime state and publishes a secrets snapshot. If replacement fails, rollback restores the previous snapshot and model limits before the Gateway can finish recovery or shutdown. flowchart LR
A[Saved configuration edit] --> B[Plugin replacement]
B --> C{Runtime commit succeeds?}
C -- No --> D[Restore previous secrets snapshot]
D --> E[Reset configured model limits]
E --> F[Recovery or shutdown completes]
C -- Yes --> G[Refresh model catalog]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +6, Tests +45, Docs +2. Total +53 across 5 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep rollback's configured-limit restoration synchronous and retain catalog discovery under the model owner's replacement lifecycle. Do we have a high-confidence way to reproduce the issue? Yes. Current main shows rollback awaiting catalog discovery while replacement can hold its gate, and the captured PR evidence reports a before-fix timeout. I did not execute the flow in this read-only review. Is this the best way to solve the issue? Yes at the rollback owner boundary: the synchronous reset removes the circular wait while retaining generation fencing. The original ordered Gateway flow still needs an after-fix observation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 368163b4c148. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Use a single const promise for rollback assertions while retaining independent gate release and the full verification join before model-owner cleanup. This resolves the prefer-const CI failure without changing the production fix or weakening the regression.
|
Merged via squash.
|
Incorporate the shared Gateway rollback repair from #158194 and current main without changing the composer feature scope. Co-authored-by: IWhatsskill <[email protected]>
Backport #157979: 3932ca0 Backport heartbeat/cron ordering: 24babfe Backport #158047: f2a2b9c Backport #158194: 905d371 Separate admission fencing from final retirement, retain cleanup outcomes, stop heartbeat wakes before joining cron, cancel acquisition only once all Gateways fence admission, and avoid awaiting catalog replacement on rollback. Keep the frozen lifetime owner, schema and configured limits unchanged. Co-authored-by: IWhatsskill <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vyctorbrzezowski <[email protected]> Co-authored-by: steipete <[email protected]> Co-authored-by: jalehman <[email protected]>
…#158194) Restore configured model context limits synchronously when an uncommitted plugin replacement rolls back. Keep committed catalog acquisition and owned cleanup intact, without waiting on the replacement gate from inside rollback. Exact-head CI passed, including all 81 original ordered Gateway config-patch cases in job108159864988. Independent review found no actionable P0–P2 issues after verifying the model-gate and context-generation contracts. Additional diagnosis and verification: https://team.openclaw.ai/chat/roboclaw/~key/dashboard/9b49d3c6-fd54-4ceb-941a-50f80013a743 Co-authored-by: IWhatsskill <[email protected]>
Related: #157819, #157886, #158047
What Problem This Solves
Fixes Gateway shutdown hanging when a plugin replacement fails while publishing its configuration.
User Impact
Failed, uncommitted plugin replacement can restore the previous runtime and configured model context limits, propagate the original error, and finish shutdown. Existing configuration and stored data need no migration.
Why This Change Was Made
Plugin replacement gates model-catalog readers until activation or rollback finishes. On publication failure, secret rollback awaited catalog discovery inside the callback that the enclosing plugin rollback was waiting to finish.
Rollback now uses the context owner's existing synchronous reset steps: advance the generation, remove candidate configured limits, and prime the restored configuration. Snapshot ownership checks, discovered-metadata ownership, and generation fencing remain intact. Normal committed refresh still loads the catalog.
Evidence
node scripts/check-changed.mjs --base origin/mainpassed in 1,735.807 s, including all 25 test type graphs and the selected lint, dependency, API, storage, and architecture guards.pnpm buildpassed in 658.039 s; the complete tracked source tree was verified unchanged afterward.pnpm test src/gateway/server.config-patch.test.ts --maxWorkers=1 --bail=1passed all 81 cases each: 1,620 passes, zero failures, zero skips. Original order, direct-to-file stdout, and deadlines were preserved. Combined test-command wall was 2,262.574 s; every run verified the same candidate tree.0b56977bfd72cfa8bbd756322f60593325e8c328: 121 successful jobs, 19 expected skips.Measured test cost:
src/gateway/server-reload-managed-secrets.test.tssrc/gateway/server-reload-handlers.test.tsCommand wall uses
pnpm test <file> --maxWorkers=1. CI timing is the sum of reported case durations, separate from process startup. Two successful handler-case durations were redacted in the hosted log, so its full sum is unavailable. Both files shared a 555-second CI job that also includes setup and other shard work. No test cases or assertions were removed, and no deadlines, retries, or skips were added.Validation caught a handler-file growth limit, a fixture union-array type error, and a
prefer-constlint error. Two redundant mock forwarders were removed, the fixture now uses its canonical provider type, and the assertion task is immutable. Initial CI stopped at that lint failure and cancelled sibling jobs; the corrected head passed its fresh CI run.Heavy proof ran through the repository wrapper with provider blacksmith-testbox, exact source checks, frozen dependencies, and one active command per lease. The earlier lease became unreachable during a broad gate; that partial gate was not counted as passing. Final complete proof used lease
tbx_01m3cpjer3j5w7jppjne03cztd(bootstrap); its validation command exited 0 and native stop confirmed it completed. All task leases are stopped. Bootstrap workflow cancellation during lease cleanup is separate from the recorded command outcomes.