Repository navigation
fix(gateway): avoid failed worker cleanup blocking startup - #128103
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 8:23 AM ET / 12:23 UTC. ClawSweeper reviewWhat this changesThe PR makes Gateway readiness wait for placements that retain worker authority, while terminal failed-worker cleanup continues through the tracked post-readiness environment reconciliation path. Merge readinessNo blocking correctness finding. The PR’s authority-free cleanup split is coherent and its new transport proof addresses the prior final-effect gap; it remains open for explicit maintainer handling because it carries the protected Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherGateway startup reconciles persisted worker placements before serving requests. Worker-environment reconciliation can invoke the Crabbox provider process transport, and shutdown drains outstanding cleanup before stopping environment services. flowchart LR
A[Persisted worker placements] --> B[Gateway startup]
B --> C{Placement retains authority?}
C -->|Yes| D[Recover or fence before ready]
C -->|No, terminal failure| E[Post-ready environment reconciliation]
D --> F[Gateway ready]
F --> E
E --> G[Provider process transport]
G --> H[Shutdown drain]
Decision needed
Why: The patch changes when provider-facing teardown can run relative to durable placement authority, and the protected maintainer label requires an explicit human merge decision. Before merge
Agent review detailsSecurityNone. PR surfaceSource +24, Tests +462. Total +486 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the explicit startup-only mode: recover or fence placements that retain authority before readiness, and let the environment-service owner perform authority-free terminal teardown after readiness with shutdown draining. Do we have a high-confidence way to reproduce the issue? Yes: current main awaits the environment-wide reconciliation and failed teardown before readiness, while the PR’s focused regression describes that same pre-fix ordering. Is this the best way to solve the issue? Yes: reusing the environment-service reconciliation owner after readiness avoids both the blocking full startup sweep and a duplicate cleanup owner, while retaining fencing for nonterminal authority. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7d816a2a065b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
@clawsweeper re-review The head changed after the previous review because its only failed CI shard exposed a real duplicate reconciliation owner. The correction removes the new immediate full placement sweep; environment-owned failed cleanup still starts after readiness and remains shutdown-drained, while placement recovery/events keep their established periodic cadence. The corrected focused suite passes 414 tests and fresh autoreview is clean. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Addressed the final-effect proof request on head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Added the requested real provider-transport proof to the PR Evidence section. At exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…128103) * fix(gateway): defer failed worker cleanup after readiness * test(gateway): preserve periodic worker recovery ordering * fix(gateway): track post-ready session retirement * fix(gateway): defer failed teardown past readiness
What Problem This Solves
Fixes an issue where a Gateway restart could remain unready while retrying cleanup for an already-failed cloud worker. If provider allocation had an indeterminate result, startup synchronously replayed the durable operation and waited for teardown even though that failed placement no longer held serving authority.
Why This Change Was Made
Startup now waits only for nonterminal placement authority that must be recovered or fenced before serving. Failed-placement cleanup keeps its existing provider lease-adoption safety, but begins immediately after readiness through the existing tracked reconciliation owner and is still drained during shutdown.
The guard permits this deferred cleanup only for one exact failed placement with no turn claim, no active owner epoch, and durable destruction intent. Ambiguous or authority-retaining states remain fenced.
AI-assisted; the implementation was independently reviewed and the final rebased patch was unchanged from the reviewed diff.
User Impact
Gateway restarts no longer remain unavailable while a terminal cloud-worker cleanup waits on a slow provider. Potentially live paid leases are still adopted and destroyed rather than being hidden or abandoned.
Evidence
expected 'provision' to be 'ready'.git diff --check origin/main...HEADpassed.Real provider-transport proof
At exact head
e3278e24860cc5b831b85e5e3c44b4274c29d583, I ran a local, secretless provider-transport proof twice using the actual bundled Crabbox plugin through its public top-level entry, the productionrunCommandWithTimeoutOS-process path, the real SQLite-backed worker environment service/store, and the real Gateway placement startup runtime. Both runs passed and produced byte-identical sanitized artifacts (SHA-2567a94cf634455579395c0c78b1fa5d952738336c14f4f5501cc858fea06f671f1).gateway-ready -> immediate-reconcile-complete; zero Crabboxwarmup/inspect/run/stopprocess invocations.gateway-ready -> immediate-reconcile-complete; zero Crabbox process invocations.warmup -> inspect -> run (node enrollment via stdin) -> inspect -> stop.sidecar.stop()remained pending while warmup was held and completed only after provider stop; the SQLite environment finisheddestroyedwith the adopted fixed lease.The proof used a deterministic local fake Crabbox executable as the process transport peer; it created no network or paid cloud lease. Temporary paths, IDs, hostnames, and credentials were redacted. Runs completed as 6/6 tests in 18.95s and 17.48s.