Repository navigation
fix: shutdown waits on optional worker reconciliation - #180841
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a848219915
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs maintainer review before merge. What this changesThis PR cancels optional worker-reconciliation waits during shutdown while retaining admitted mutations and adding attributable pending-operation diagnostics. Example: Allocation lookup for worker-startup-indeterminate never returns during cleanup.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses concrete shutdown cancellation gaps, and the previous inventory-recovery finding is fixed; no actionable introduced defect remains in the reviewed diff. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway placement reconciliation calls the environment service, which serializes provider operations and persists lifecycle outcomes; shutdown must release optional observations while joining accepted mutations. flowchart TD
A[Gateway shutdown] --> B[Placement reconciliation]
B --> C[Environment service]
C --> D[Environment lock]
D --> E[Provider operation queue]
E --> F[Read-only observations]
E --> G[Admitted mutations]
G --> H[Durable lifecycle state]
Technical reviewBest possible solution: Keep cancellation at the existing environment and provider owners, preserving durable intent and joining every admitted mutation. Do we have a high-confidence way to reproduce the issue? Current-main source shows allocation lookup without reconciliation cancellation and queued lock waits that retain observers; committed owner regressions and reported base failures support reproduction, but no code was executed during this read-only review. Is this the best way to solve the issue? The patch repairs cancellation at the existing owners, retains mutation serialization and settlement, and avoids new configuration, persistence, or public provider contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8e1fafd407fd. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +91, Tests +54, Docs +10. Total +155 across 10 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 22, 2026, 2:15 PM ET / 18:15 UTC (Revision 2). |
|
Fixed the inventory-recovery finding in ec774ce. Direct reconciliation now captures the provider only after Pending provider diagnostics also retain their captured identity after inventory closure. Both inventory tests and all nine placement shutdown tests pass; core and affected test typechecks, targeted lint, formatting, and fresh independent review are clean. CI is running on the new head. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash auto-merge.
|
* fix(gateway): release optional reconciliation during shutdown * fix(gateway): retain provider diagnostics after inventory closure * fix(gateway): recover inventory before reconcile diagnostics
Related: #178538, #176777, #172971
What Problem This Solves
Fixes shutdown waiting indefinitely for optional worker reconciliation when an allocation lookup never returns or reconciliation is queued behind an admitted provider mutation.
User Impact
A stopped Gateway can leave optional reconciliation without discarding the durable allocation or cleanup intent. Existing explicit destroys and admitted provider mutations still settle before their owner closes. Pending shutdown diagnostics now identify the environment, provider, and operation.
Why This Change Was Made
The affected Team deployment included #178538. That change bounded inspection, but the allocation lookup in
provider-owner-lifecycle.ts:313still entered the provider queue without the reconciliation cancellation signal. The environment lock also admitted an uncancellable observer wait, and placement joined the whole shared sweep.The environment owner now passes reconciliation cancellation into read-only allocation lookup and checks it before recording errors or publishing a late allocation identity. Queued reconciliation can stop waiting before it acquires the lock; its retained callback checks shutdown before doing work. The shared sweep exposes a shutdown-cancellable observation while retaining actual work in the existing owner joins. Provider queue ownership for mutations is unchanged. No schema or public provider contract changes.
The complete incident journal does not identify an environment, provider, or leaf call. This fixes reproducible remaining cancellation gaps and adds bounded diagnostics, without claiming to have identified the production leaf. Pending traces name lock/inventory, installation/credential, and provider-call stages (inspect, resolve-allocation, provision, destroy, SSH identity). Provider identity is captured at call admission, so formatting still identifies the call after inventory reads are closed. Direct reconciliation preserves inventory recovery by awaiting readiness before reading diagnostic provider identity.
Accepted limitation: a provider mutation or admitted durable effect still has to settle; shutdown cannot safely abandon it or fabricate its receipt. Providers without a cancellation API may finish a read-only request later; its result cannot resume the cancelled reconciliation or cause destruction.
Evidence
Sanitized Team journal,
team-20261022-full-1638-1647.log.gz, decompressed line 1435:Those repeated counters put the two reconciles at approximately 16:42:57 and 16:43:16, before the 16:46 shutdown. The supplied journal records main-process
9/KILLat 16:47:30; it does not identify the sender or attribute later SSH children to this reconcile.The regression uses the real placement/environment owners with a provider allocation lookup that never returns. Close must finish within the test's 10-second limit before releasing that lookup, preserve the exact saved intent, avoid provision/bootstrap/destroy, and expose attributable diagnostics. A second owner regression releases queued reconciliation while retaining an admitted destroy until its actual completion.
Validation: 88 focused tests passed across the placement-startup cleanup, service inventory/lifetime, provider reconciliation, allocation cleanup, and destroy-timeout suites. The latest rerun passed both inventory tests in 1.5 seconds of test time (36.7 seconds including compilation) and all nine sidecar tests in 3.6 seconds (11.1 seconds total); the stalled-lookup regression completed in 232 ms. Core and affected test typechecks, targeted oxlint, formatting, and docs link audit passed. Both cancellation regressions fail on unchanged main. The diagnostic regression also fails when formatting tries to read an unavailable inventory, and passes with the captured call identity. GitHub review identified an eager diagnostic read that blocked direct inventory recovery; the extended seal/reopen test failed before that correction and now passes. Independent local and final committed-branch Codex reviews returned scoped-clean with no actionable P0–P2 findings. Exact-head CI run 39828882493 completed with 57 successful jobs, 27 conditional skips, and zero failures on
ec774ce617dde37bca4cd267801d5c36a2ab1d31, with no rerun or inherited-failure exception.Production: +161/-70 (net +91). Tests: +68/-14 (net +54). Docs: +10/-0. The production growth is cancellation boundaries and bounded diagnostic context, with the existing provider queue moved intact into its owning helper; no new scheduler or state owner.
Focused proof commands
The final allocation-lookup regression times out at 10 seconds on unchanged main, and passes in 793 ms with the fix. The queued-reconcile regression also fails on unchanged main and passes with the fix. Tests use synthetic external I/O and real owners; no live Gateway was touched.
Initial CI on
a848219915e31f14ca334f423f625277caf07bc0reported a skill-library worker E2E timing failure: the assertion received the legitimatepending/queue observation before provider start. The test andagent.waitowner are unchanged from main; the isolated test passed on both that PR head and the exact main base. A cancelled Security Review attempt was also reported by the rollup watcher; the independent security-sensitive status was successful. The final-head run passed, including the skill-library test; no rerun was required.