Repository navigation
fix(gateway): avoid shutdown stalls with paired workers - #132877
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 6:55 PM ET / 22:55 UTC. ClawSweeper reviewWhat this changesThe PR lets authenticated paired-worker replies settle pending shutdown-cleanup commands during Gateway restart draining, adds lifecycle/socket regression coverage, and drains one deferred UI test callback before teardown. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessNo introduced correctness finding was identified. Keep this maintainer-labelled PR open for the normal maintainer merge decision after its exact-head checks complete. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway sends private cleanup commands to paired worker nodes and receives progress or result frames on their sockets. During restart drain, an exact live pending invocation must be allowed to settle so cleanup and shutdown can finish, while unrelated work remains refused. flowchart LR
A[Gateway restart drain] --> B[Pending worker cleanup command]
C[Paired worker result or progress] --> D[Invocation, connection, pairing, and owner checks]
B --> D
D --> E[Settle cleanup]
E --> F[Gateway shutdown completes]
D --> G[Reject stale or unrelated reply]
Decision needed
Why: The patch has no supported blocking finding, but the maintainer label requires explicit maintainer handling rather than automated closure or repair routing. Before merge
Agent review detailsSecurityNone. PR surfaceSource +12, Tests +458, Docs +6. Total +476 across 8 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Preserve the single stream-controller settlement path and land it only once the remaining exact-head CI gates are green. Do we have a high-confidence way to reproduce the issue? Yes: the source baseline excludes restart drain from node completion continuations, and the introduced socket regression exercises the paired-worker shutdown sequence. The PR body also supplies an isolated before/after SIGTERM trace. Is this the best way to solve the issue? Yes: centralizing identity and lifecycle validation at the pending-invocation owner repairs the denied completion without admitting a new request root or broadening node RPC access. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 90c1d798cad4. LabelsLabel changes:
Label 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.
|
Closes #132819
What Problem This Solves
Fixes an issue where operators stopping or restarting a Gateway with paired workers could wait through node-command deadlines even though the node had already replied. Shutdown rejected the completion frames that its own maintenance and worker cleanup were waiting for.
Why This Change Was Made
The RPC router now lets an exact pending node owner execute its completion handler during restart without recursively requesting new root admission. The invocation-stream owner centralizes connection, deadline, and lifecycle checks for admission, progress, and result settlement. Private worker commands retain their existing live lifecycle predicate and recheck it after asynchronous handler dispatch; cleanup never mints a request root or revives a released one. Duplicate validation in the registry and stream handlers is removed.
New work remains fenced. Unrelated, replayed, disconnected, re-paired, expired, and owner-revoked replies cannot settle another invocation. Approval/question continuation policy remains suspension-only. No configuration, database schema, protocol version, or worker timeout changes.
Provenance: the suspension-only continuation path was introduced in #130003 (093166c, August 26), and worker environment-stop replies made the shutdown gap visible in #130733 (e4d602c, August 27). Both were authored and merged by @steipete. The focused reproduction is against current main at 10da9ac; this does not establish an older stable-release regression.
Production LOC: +68/-56 (net +12). The added capability is closure-bound completion for rootless private lifecycle cleanup; consolidating existing validation absorbs the rest of the repair. Tests and documentation are separate.
User Impact
Responsive paired workers can complete Gateway shutdown without waiting out their command budgets. Cleanup still targets the exact environment/session/owner epoch, and node-side physical teardown remains authoritative. The same private node transport serves device and cloud workers; remote-exec process ownership is unchanged.
Evidence
node.invoke.result unavailable during gateway restartwhile shutdown awaited its rootless environment-stop reply.Sanitized process-probe results (same fixture and shutdown order):
The initial CI run found a return-style lint error in the new test helper (fixed; no runtime change) and an unrelated Codex child-startup diagnostic race, tracked separately in #132884. The latter is in unchanged code; no startup retry assertions or process inspection policy were relaxed here. The 15 tests in the two edited Gateway test files passed again after the lint correction. A subsequent UI shard passed all4,094 assertions but reported a deferred clipboard-focus callback after jsdom teardown. This PR includes a bounded test-only cleanup: drain that callback before restoring DOM mocks. Both clipboard/task-suggestion suites pass(12 tests); no UI production behavior or assertion changed.
Latest ClawSweeper review and rank-up moves read: its exact pending/lifecycle boundary is retained, and the +12 production lines are justified above. The maintainer-directed repair preserves that boundary. Required exact-head checks are green; both rank-up moves are satisfied and there are no outstanding review findings.