Repository navigation
fix(gateway): prevent shutdown stalls during plugin reloads - #157979
Conversation
|
🦞👀 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. |
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs changes before merge. Reviewed September 25, 2026, 3:10 AM ET / 07:10 UTC. ClawSweeper reviewWhat this changesThe branch lets plugin reload publication finish during Gateway shutdown while final close joins retained cleanup and reports failures, with regression tests and documentation. Merge readiness⛔ Needs changes before merge - 2 items remain Current main still has the reload and shutdown wait cycle, so this focused repair remains useful. The new regression test needs deterministic waits before merge. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway publishes plugin metadata when plugins reload. Retired plugin resources may remain in use by existing consumers, so shutdown must drain reload work before joining their final cleanup. flowchart LR
A[Plugin reload] --> B[Metadata publication]
B --> C[Retired plugin cache]
C --> D{Consumers retained?}
D -->|Yes| E[Deferred retirement]
D -->|No| F[Cleanup result]
E --> G[Final Gateway close]
H[Shutdown admission fence] --> G
G --> F
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +5, Tests +66, Docs +2. Total +73 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the metadata lifecycle as the single owner of deferred retirement, with final close joining its result and deterministic tests guarding both consumer release orders. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source shows shutdown fencing metadata admission before reload drains, while the reload's retirement wait can join consumers released later in shutdown; this read-only review did not execute that path. Is this the best way to solve the issue? Yes. The branch changes the existing metadata lifecycle owner's phase decision and preserves the final cleanup join; its regression test needs completion signals in place of polling. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 04fb3c8e35b3. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What 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
|
|
Addressed the lifecycle-wait finding in 1cd1496. The test now awaits publication and the cache's owned retirement promise directly. The existing timeout helper is only a bounded failure deadline, so the original deadlock can fail while The revised test still fails on both original defects: two publication-deadline failures against the original owner, and one missing cleanup-failure assertion against the intermediate implementation. With the repaired owner restored, all 12 cases pass on one worker in 215 ms of test execution (42.87 s including compiler preparation and the maintained runner). Fresh independent P2 review is clean. Production is unchanged from the fully green 4a653eef CI run, which also passed the uninstrumented original config file, 81/81. The historical intermittent hook timeout remains unlocalized and is not claimed fixed by this PR. |
|
Merged via squash auto-merge.
|
Compose the reviewed metadata retirement, shared model acquisition shutdown, and catalog provenance repairs with the repair-turn worker candidate. Preserve first-discovery starter models and explicit no-discovery outcomes. Sources: #157979, #158047, #158113, and 36def8b. The historical include-only CI hook timeout remains unattributed. Co-authored-by: Dallin Romney <[email protected]>
* feat(update): accept owner-bound repair turns * fix(update): harden delegated repair authority * fix(update): keep repair worker schema private * test(update): retain released worker protocol coverage * fix(update): terminate failed repair result delivery * fix(update): exit idle repair worker on disconnect * test(update): retain repair worker timeout diagnostics * test(update): surface diagnostics in silent E2E runs * test(update): capture repair worker startup logs * fix(update): share fresh authority snapshots per repair check Keep requester policy and update-run checks on one fresh synchronous snapshot of the original installation. Do not inherit discovery snapshots or reuse authority across callbacks. Preserve every executor, requester, IPC and run-phase check and keep source SQLite artifacts untouched. The real Windows repair turn previously exhausted its budget while repeatedly spawning snapshot readers. Real-WAL regressions cover fresh commits, inherited-scope restoration and closed-scope refusal; preserve the existing worker deadlines and behavior. * chore(update): trace repair authority timing Measure cumulative executor, requester-policy, update-row and total assertion elapsed time under the existing trace log level. Record synchronous snapshot subprocess elapsed time to distinguish guard work from launch and copy costs. Preserve checks, error propagation and deadlines. * test(gateway): complete lifecycle logger fixture * fix(skills): filter selection before probing binaries * fix(update): bind delegated repair to its recorded requester Compare the IPC requester with the original update row before preparing inference and at every fresh authority assertion. Reuse the existing managed requester resolver and profile continuation owner so internal/operator update routes keep their admitted authority while chat identity cannot be omitted or substituted. Cover the worker boundary with inert inference and real isolated ledger/config state, including post-await origin/policy changes. Record the admitted requester in the existing positive delegated E2E fixture. * fix(update): integrate catalog and Gateway lifecycle repairs Compose the reviewed metadata retirement, shared model acquisition shutdown, and catalog provenance repairs with the repair-turn worker candidate. Preserve first-discovery starter models and explicit no-discovery outcomes. Sources: #157979, #158047, #158113, and 36def8b. The historical include-only CI hook timeout remains unattributed. Co-authored-by: Dallin Romney <[email protected]> * fix(update): retain only required canonical integrations Remove the imported catalog inference and marker adaptations so omitted outcomes retain their existing contract. Keep the worker and reviewed Gateway shutdown changes, captured provider-alias normalization, first-discovery starter handling, and explicit HTTP-success lifecycle fixtures. Preserve the native augmentation assertions and existing deadlines. The new legacy-retention work in #158113 is independent of this repair-turn worker. Co-authored-by: Dallin Romney <[email protected]> * test(update): initialize survivor registry fixture baseline Reuse canonical 4fa09e9 so the extracted registry-order orchestration receives the baseline version that the real runner has already resolved. Keep production code, ordering assertions, and timeouts unchanged. The ten-case file, root-test types, lint, and fresh P2 review pass. --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Dallin Romney <[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]>
…#157979) * fix(gateway): prevent metadata retirement stalls during reload shutdown * fix(plugins): retain deferred cleanup outcomes until joined * test(plugins): await metadata retirement completion directly
* feat(update): accept owner-bound repair turns * fix(update): harden delegated repair authority * fix(update): keep repair worker schema private * test(update): retain released worker protocol coverage * fix(update): terminate failed repair result delivery * fix(update): exit idle repair worker on disconnect * test(update): retain repair worker timeout diagnostics * test(update): surface diagnostics in silent E2E runs * test(update): capture repair worker startup logs * fix(update): share fresh authority snapshots per repair check Keep requester policy and update-run checks on one fresh synchronous snapshot of the original installation. Do not inherit discovery snapshots or reuse authority across callbacks. Preserve every executor, requester, IPC and run-phase check and keep source SQLite artifacts untouched. The real Windows repair turn previously exhausted its budget while repeatedly spawning snapshot readers. Real-WAL regressions cover fresh commits, inherited-scope restoration and closed-scope refusal; preserve the existing worker deadlines and behavior. * chore(update): trace repair authority timing Measure cumulative executor, requester-policy, update-row and total assertion elapsed time under the existing trace log level. Record synchronous snapshot subprocess elapsed time to distinguish guard work from launch and copy costs. Preserve checks, error propagation and deadlines. * test(gateway): complete lifecycle logger fixture * fix(skills): filter selection before probing binaries * fix(update): bind delegated repair to its recorded requester Compare the IPC requester with the original update row before preparing inference and at every fresh authority assertion. Reuse the existing managed requester resolver and profile continuation owner so internal/operator update routes keep their admitted authority while chat identity cannot be omitted or substituted. Cover the worker boundary with inert inference and real isolated ledger/config state, including post-await origin/policy changes. Record the admitted requester in the existing positive delegated E2E fixture. * fix(update): integrate catalog and Gateway lifecycle repairs Compose the reviewed metadata retirement, shared model acquisition shutdown, and catalog provenance repairs with the repair-turn worker candidate. Preserve first-discovery starter models and explicit no-discovery outcomes. Sources: openclaw#157979, openclaw#158047, openclaw#158113, and 3cb4c86. The historical include-only CI hook timeout remains unattributed. Co-authored-by: Dallin Romney <[email protected]> * fix(update): retain only required canonical integrations Remove the imported catalog inference and marker adaptations so omitted outcomes retain their existing contract. Keep the worker and reviewed Gateway shutdown changes, captured provider-alias normalization, first-discovery starter handling, and explicit HTTP-success lifecycle fixtures. Preserve the native augmentation assertions and existing deadlines. The new legacy-retention work in openclaw#158113 is independent of this repair-turn worker. Co-authored-by: Dallin Romney <[email protected]> * test(update): initialize survivor registry fixture baseline Reuse canonical d2295c6 so the extracted registry-order orchestration receives the baseline version that the real runner has already resolved. Keep production code, ordering assertions, and timeouts unchanged. The ten-case file, root-test types, lint, and fresh P2 review pass. --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
Related: #155982, #151608
What Problem This Solves
Fixes a metadata-retirement cycle that can stall Gateway shutdown when a plugin reload overlaps retained consumers.
User Impact
Shutdown can finish admitted reload work before releasing its retained consumers. Final close still joins actual cleanup and reports failures. No configuration changes or data migration are required.
Why This Change Was Made
The early shutdown admission fence was also switching publication waits into final retirement waits. Those consumers can be released later in shutdown, after the reloader has drained. Use the existing final-close promise to distinguish those phases while preserving the admission fence and final cleanup ownership. Keep deferred retirement outcomes until a caller joins the full result, so cleanup failures cannot disappear when a consumer finishes before final close.
Evidence
1cd1496d10a544645ee95703f5f10091f796c3df. Production-parent CI also passed, including the uninstrumented original config file: 81/81 in 136.44 s through the maintained runner, with include-only completing in 1.75 s.