Repository navigation
fix(plugins): retain service cleanup through late startup - #140132
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. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 9:53 AM ET / 13:53 UTC. ClawSweeper reviewWhat this changesThe PR retains plugin service cleanup until startup settles, preserves retry order after failed reloads, and updates regression tests and lifecycle documentation. Merge readiness✅ Ready for maintainer review This remains a useful, focused repair: current main still permits premature cleanup and loses pending restart registrations after a failed reload. No blocking introduced defect was found, and the latest Gateway test correction matches the repaired lifecycle. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway starts background services registered by plugins and owns their reload and shutdown. This lifecycle coordinates resource cleanup, capability revocation, and diagnostic exporter shutdown. flowchart TD
A[Plugin registrations] --> B[Service startup]
B --> C[Retained startup and cleanup owner]
D[Reload or shutdown request] --> C
C --> E[Caller deadline]
E --> F[Timeout revokes capabilities]
C --> G[Cleanup after startup settles]
G --> H[Diagnostic drain and exporter stop]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +13, Tests +180, Docs 0. Total +193 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one cleanup owner per startup attempt, preserve registration order across retries, and retain deadline-based capability fencing. Do we have a high-confidence way to reproduce the issue? Yes, from source: hold service startup past a strict stop deadline, then acquire a listener before startup settles; main has already memoized cleanup. A failed first restart also leaves later selected registrations absent. This review did not execute either scenario. Is this the best way to solve the issue? Yes. Retaining settlement and cleanup at the service owner repairs both lifecycle failures without adding a parallel API, configuration option, or persistent state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ba457124711d. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…40132) * fix(plugins): retain service cleanup through late startup * test(gateway): assert deferred service cleanup ordering
Strict plugin-service shutdown could call and memoize
stop()while startup was still pending. If startup later acquired native listeners, final shutdown reused the completed cleanup and left those listeners registered. Failed partial reloads could also lose an unstarted sibling or reverse the next retry's startup order.Keep each issued startup attempt and its one cleanup operation owned independently of caller deadlines. Healthy services clean up without waiting for unrelated startup; exporters follow actual producer cleanup and the bounded diagnostic drain. Replacements occupy the prior registration's slot, preserving retry order. Existing ordinary versus strict error handling and separate one-shot drain/flush windows remain intact.
Validated with causal failures followed by 66 passing service checks, including actual native listeners, dependency-ordered retries, concurrent deadlines, and one-shot exporter flush windows. The full changed-file gate passed. Independent P2 review findings were reproduced and fixed where actionable. The remaining overlap finding was rejected after an isolated main/candidate comparison confirmed the same existing exporter-only reload boundary: an exporter can already stop before later shutdown events, with exactly one cleanup in both versions. The current trace implementation also has no yielding prelude before invoking startup.
Production: +13 lines after removing the global startup/reload wait and duplicate mutation path. Tests: +180 lines. Documentation clarifies retained cleanup and explicit reload retries.
Split from the restart-free plugin lifecycle work in #135599. This PR fixes existing service ownership; it does not introduce the Gateway reload interface.
CI follow-through corrected the Gateway caller test that still expected cleanup before its held startup completed. All 117 Gateway startup tests pass, including cleanup already queued before final stop. A separate profiler invalid-option test timed out in the initial CI run; the exact case and its full 34-case file passed unchanged locally, so no speculative timeout or code change was made.
Exact-head CI passed at
8f26125d1b13d2e1d565be8b86c070dd869c4b7a, including the corrected startup-order case and unchanged profiler tests.