Repository navigation
refactor: simplify plugin reload ownership and tests - #146072
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 12, 2026, 11:14 AM ET / 15:14 UTC (Revision 2). ClawSweeper reviewWhat this changesConsolidates plugin reload, startup, shutdown, and module-resolution helpers and shared test fixtures while preserving existing behavior. Merge readiness✅ Ready for maintainer review This remains a useful, distinct cleanup of the merged plugin-reload work. No actionable correctness or security defect was found, and the maintainer-authored PR is protected from automatic closure. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway coordinates plugin changes requested through management commands and APIs. Its lifecycle owners prepare replacements, stop affected resources, publish the new generation, and recover from failed activation. flowchart TD
A[Plugin management request] --> B[Current ownership checks]
B --> C[Prepare plugin replacement]
C --> D[Drain affected resources]
D --> E{Activation succeeds?}
E -->|Yes| F[Publish generation and receipt]
E -->|No| G[Recover previous generation]
F --> H[Retire owned resources]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -84, Tests -214. Total -298 across 26 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep lifecycle decisions with the existing Gateway and service owners while sharing equivalent mechanics and preserving recovery contracts. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes behavior-preserving cleanup, and source review found no introduced failure to reproduce. Is this the best way to solve the issue? Yes: the patch reuses existing timeout, deferred, guard-composition, and fixture owners without adding competing policy or public API surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 99be6bd6a27b. 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.
|
Related: #145484, #145816
What Problem This Solves
Plugin reload and recovery accumulated duplicated lifecycle dispatch, resolver handling, and regression fixtures. This cleanup makes the existing ownership rules easier to follow while retaining the recovery fixes from #145816.
Why This Change Was Made
Use the existing timeout and deferred owners, share the captured-module resolver loop and Gateway runtime-application guard composition, and remove one-use adapters and duplicated traversal. Consolidate repeated CLI TTY, channel, and service fixtures while preserving behavioral assertions.
The diff removes 298 lines overall: 107 production lines and 191 test/support lines. It retains the older-Node diagnostic fallback and both Bun resolver paths because they serve real runtime contracts.
User Impact
No intended behavior change. Plugin replacement, cancellation, shutdown deadlines, cleanup ownership, warnings, and runtime receipts retain their existing semantics. No configuration, schema, dependency, or public SDK changes.
Evidence
The focused baseline and final runs preserve all 1,118 tests across CLI, scheduler/spawn, Gateway admission/reload, module resolution, and plugin services.
Actual Bun 1.4.0 and 1.4.2 resolver fixtures verify aliases, identity, deferred dependencies, and captured generations.
Independent full-diff review through P2 found no actionable issues.
Full
pnpm buildpassed, including native loading of 52 built plugin control-plane modules and Doctor import checks. Build metadata matches commit93eb12ecbf473b31f3f4da7479cf7606ca021950.Five isolated live Gateway cells passed on Node 26.5.0 and actual Bun 1.4.2/1.4.0: source/helper reload, rejected replacement retaining the working generation, successful retry, disabled plugins, read-only refresh, late-start cleanup, watcher contention, and pending old-stop rollback/retry. Contention returned in 20 ms; the pending-stop timeout retained its original owner and the next replacement succeeded. All five Gateway processes exited and all seven ports were rebound successfully.
Complete
check:changedpassed locally with all selected checks enabled. The initial standalone Testbox attempt ended with exit 255 during test-type checks without a diagnostic; it is not counted as passing.Exact-head CI passed on
93eb12ecbf473b31f3f4da7479cf7606ca021950. ClawSweeper also found no actionable defect on this head.Post-merge verification on main
6a6f500613c93c2fe26e13708c34f9ca63a186a3: all 26 changed files match the reviewed candidate, and 119 focused scheduler, mutation, native-loader, and service tests passed.The live cells use synthetic plugins and isolated state. Pre-readiness ownership, internal shutdown-hook deadlines, SDK alias boundaries, and swarm membership remain covered by focused owner tests; external provider inference is outside this cleanup's scope.