Repository navigation
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. |
Cancel in-flight device observations at restart drain, pause reconciliation during suspension, and bound native computer cleanup with the worker shutdown deadline. Capture completed disposal before final publication errors wrap its receipt; preserve unfinished source cleanup and report live custody counts.
e59a899 to
5d15b8d
Compare
|
Codex review: needs maintainer review before merge. What this changesThis PR cancels stalled device observations during drain, pauses reconciliation during suspension, bounds native computer cleanup, and correctly acknowledges completed runtime disposal. Example: Restart begins while device reconciliation awaits an 85-second pairing read.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses shutdown failures still present on current main, and review found no actionable introduced defect. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway shutdown coordinates session sources, worker reconciliation, and node transports; it must stop optional observations while joining accepted writes and unfinished resource cleanup. flowchart TD
A[Gateway suspension or restart] --> B[Work admission and drain signals]
B --> C[Worker reconciliation]
C --> D[Device pairing and presence reads]
B --> E[Node cleanup deadline]
E --> F[Native computer close]
A --> G[Session source settlement]
G --> H[Runtime disposal receipt]
Technical reviewBest possible solution: Keep cancellation and cleanup acknowledgement in the existing lifecycle owners while preserving accepted-write settlement and unfinished-resource custody. Do we have a high-confidence way to reproduce the issue? Base source exposes both uncancelable device waits and the outer-only disposal-receipt check; supplied regressions and paired measurements support those paths, but this read-only review executed no target code. Is this the best way to solve the issue? The invariant is that observations may cancel while accepted writes and unfinished cleanup remain owned; the patch uses existing signals, disposal receipts, and shutdown instrumentation without adding a competing lifecycle owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d0254a628b2a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +80, Tests +275, Docs +10, Other +92. Total +457 across 20 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 Reviewed October 19, 2026, 6:14 PM ET / 22:14 UTC. |
* fix(gateway): settle pre-existing work during shutdown Cancel in-flight device observations at restart drain, pause reconciliation during suspension, and bound native computer cleanup with the worker shutdown deadline. Capture completed disposal before final publication errors wrap its receipt; preserve unfinished source cleanup and report live custody counts. * test(gateway): expect recovery to pause during shutdown
What Problem This Solves
Fixes shutdown stalls when worker reconciliation was already waiting on device inspection before restart, or a completed agent runtime disposal coincides with a failed final response.
User Impact
Restarts stop waiting on abandoned device observations and bound native computer cleanup by the existing worker shutdown deadline. Suspension pauses periodic reconciliation and releasing it resumes the next sweep. No configuration, schema, or protocol changes are required; unfinished producer/write cleanup remains joined.
Why This Change Was Made
Reconciliation already avoided new work after shutdown, but suspension still admitted sweeps and existing device pairing/presence reads ignored cancellation. Environment and placement maintenance have independent periodic sweeps; startup and session-identity replacement also request reconciliation. The incident shows overlap with drain, not proof that drain directly started the stalled pass. Inspection now receives the restart-drain signal, and the device provider stops awaiting those read-only operations. Native computer close requests share the node tunnel's existing five-second cleanup signal, including requests started before shutdown.
The session-admission wait also joins source cleanup. If final publication and completed runtime disposal both throw,
await usingwraps the disposal receipt inSuppressedError; the previous outer handler missed it and retained the source indefinitely. Record that receipt inside the disposer and remove the superseded outer interpretation. Execution must still have settled, and genuinely unfinished cleanup retains custody. Pending diagnostics distinguish source cleanup from effect admission and report live source/operation/work counts.Evidence
device-provider.test.ts,computer-transport.test.ts,server-worker-placement-startup-cleanup.test.ts,agent-run-execution-phase.owner.test.ts,server-close.test.ts,restart-trace.test.ts, andserver-worker-placement-provision-cancellation.test.ts, usingnode scripts/run-vitest.mjs <files> --maxWorkers=1. Initial provider assertions expected an unwrapped abort reason; corrected to the shared helper’sAbortError/cause contract, then the provider file passed 11/11. Changed-file formatting and core/script lint passed;pnpm tsgo:core(tsrs) passed. Broad gates delegated to PR CI; no Testbox allocation.GatewayDrainingErrorafter shutdown. Reproduced locally (30 pass, 1 fail), updated it to expect reconciliation to skip before session admission while retaining every lease/placement and no-provider-call assertion, then reran the whole file: 31/31 passed.Paired sandbox measurement
A real environment service, placement sidecar, SQLite owner and device provider wait on a real loopback HTTP-backed device pairing read delayed by 85 seconds. Synthetic node acknowledgments and separate state/ports are used. Both variants run concurrently under the exclusive measurement lock on two 16-core CPU halves, swapped for the second pair. Baseline:
08e32fdb4df002c9d4eea158b855d6521dd1e916.Shutdown starts differed by 3 ms and 2 ms within the pairs; observed CPU utilization was 2.89% and 4.92%. Median duration: 85,010.273 ms before, 9.074 ms after. The measured candidate predates a behavior-preserving signal variable rename and parameter-type consolidation; subsequent source-cleanup edits are outside this measured path.
Both variants retain placement rows/manifests and produce a clean-close receipt. The candidate closes while the delayed read remains pending; the baseline waits for it. This measures the owning shutdown boundary, not a whole-Gateway restart or real model/remote worker processes.
Runtime source delta is +80 lines; tests/support +275; measurement script +92; docs +10. Growth supplies missing cancellation wiring and live retained-custody diagnostics; the duplicate outer receipt handler is deleted. There is no new cache, manager, configuration, or alternate shutdown path.
Incident attribution remains limited: effect admission handles released promptly after abort, and the reported six-admission count was a stale pre-abort snapshot. The exact retained production source is unproven. The next production restart remains the end-to-end confirmation; no production deployment/restart was performed. The background-effect regression does not launch an OS process.