Repository navigation
Conversation
Forward typed restart interruption through active request custody so yielded exec commands begin their existing graceful cancellation while other accepted work drains. Keep physical process settlement, finalizer writes, database sealing, and restart recovery ordered.
|
🦞👀 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 Summary: ✅ CompletedThis 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR starts request-owned command cleanup when restart interrupts an active turn, allowing cleanup to overlap request draining. Example: A yielded command ignores SIGTERM while its request has 2.2 seconds of other accepted work.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current restart delay through the existing cancellation owner, and review found no actionable introduced defect. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway shutdown records restart markers and interrupts active requests; request custody forwards cancellation to supervised commands, whose physical cleanup and finalizers settle before database retirement. flowchart TD
A[Gateway shutdown] --> B[Persist restart markers]
B --> C[Interrupt active requests]
C --> D[Request custody]
D --> E[Supervised command cleanup]
E --> F[Accepted finalizer writes]
F --> G[Database retirement]
Technical reviewBest possible solution: Forward restart interruption through existing request custody while retaining physical cleanup, accepted finalizer writes, and the late supervisor/database ordering. Do we have a high-confidence way to reproduce the issue? Current main visibly filters out the typed restart reason, and the supplied baseline regression and owner measurements exercise that path; this read-only review ran no target code. Is this the best way to solve the issue? The patch is the smallest complete runtime repair: extend the existing cancellation predicate rather than move supervisor shutdown earlier or weaken finalizer settlement. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cb8c84949925. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests +4, Docs 0, Other +315. Total +325 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label 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 November 11, 2026, 9:06 PM ET / November 12, 2026, 02:06 UTC. |
|
Merged via squash.
|
…197457) Forward typed restart interruption through active request custody so yielded exec commands begin their existing graceful cancellation while other accepted work drains. Keep physical process settlement, finalizer writes, database sealing, and restart recovery ordered.
What Problem This Solves
Gateway restart can wait an extra child-cancellation grace after draining an active turn that has yielded an ordinary exec command.
User Impact
Active requests signal their ordinary commands as soon as restart interrupts the turn. The existing five-second child grace, physical cleanup, accepted finalizer writes, and restart recovery remain intact. Independent services and idle commands without a live request turn retain their existing owners. No configuration or schema changes.
Why This Change Was Made
Request custody forwarded explicit Stop but filtered out the typed restart-abort reason. A yielded command therefore missed cancellation and survived until the late process-supervisor join immediately before agent-database retirement. Forward restart interruption through the same owner so child cleanup overlaps the other accepted work. Keep leases through finalization and retain the late supervisor/database ordering; closing the entire supervisor earlier would also reject cleanup commands.
A seal arriving immediately after supervisor shutdown establishes ordering, not which process held a lease. The change makes no claim that ordinary exec children themselves open agent databases. Likewise, two pipe/socket handles may be Gateway stdout/stderr; a child TLS connection cannot appear in the Gateway handle inventory. The existing detailed exit diagnostics remain the attribution path.
Production confirmation requires the handoff after deployment carrying this fix, because the outgoing Gateway executes shutdown.
Evidence
Acceptance: a real supervised child ignores SIGTERM, a request has 2.2 seconds of independent accepted work, its exec finalizer retains a native database borrow and writes before close. Five serial interleaved baseline/candidate pairs must reduce median/p95 shutdown while preserving every finalizer write, physical child cleanup and
writtenclean-close receipt. Separate allocation samples and identical-source A/A controls are reported separately.All ten paired runs preserved the write and seal. CPU is neutral within observed spread; the single allocation sample increased 6.11%, so no allocation improvement is claimed. Identical-source direct-Stop A/A controls sealed in 5,064.10/5,111.38 ms (0.93% spread); the baseline/candidate direct-Stop negative control was 5,055.98/5,040.77 ms. These are owner-level macOS measurements with one database, not whole-Gateway/btrfs attribution.
Commands:
node --import ./scripts/tsx.mjs scripts/perf/exec-restart-shutdown-measure.ts --state-dir /absolute/new-fixture # Baseline: add --source /saved/exec-request-context.ts; controls: --control; allocation: --allocation. node scripts/run-vitest.mjs src/agents/bash-tools.exec.background-abort.test.ts src/agents/bash-tools.exec-runtime.cleanup.test.ts --maxWorkers=1The restart row fails on the original implementation (
[]cancellation instead of the command ID); all 27 focused tests pass with the fix. Test wrapper wall time: 51.61 seconds including cold worker compilation; behavior-test time was about two seconds. The existing table gained four lines, recorded in its own allocation file. Production runtime delta is +6 lines for the imported typed predicate and condition; no new state, API, timeout, cache, or owner.The built Gateway also passed a local scale/recovery run using a synthetic 37,694,242,816-byte database with 5,000 seeded sessions and a 62,000-file / 1,100,004,000-byte workspace. A real yielded child ignored SIGTERM. Shutdown took 5,680.72 ms; the late supervisor join took 0.2 ms; the actual Gateway published
written, exited cleanly, left no child alive, and resumed both interrupted runs exactly once with durable replies and tool receipts. Offline full integrity verification of each copied destination precedes startup, outside timing, to model an already verified long-lived database. Two serial full Linux/btrfs A/B pairs passed. This synthetic database has compressible padding; it models logical scale and ownership, not production disk saturation.The median reduction is 2,065.98 ms (27.55%). Identical baseline A/A controls were 7,668.13 / 7,686.98 ms (18.85 ms, 0.246% spread). Separate allocation/CPU-profile samples were excluded from those timing statistics; their CPU was 696.00 / 650.31 ms. CPU excludes workers/children, and two timing pairs plus one allocation sample per arm do not establish a robust CPU or allocation improvement.
All eight Linux runs published
written, exited cleanly with no surviving child, retained the seeded session scale, and resumed both interrupted runs exactly once with durable replies. In the first pair, supervisor completion moved from +7,273.5 to +5,154.4 ms after the received-SIGTERM trace, and agent-database close finished at +7,277.8 / +5,158.7 ms. The actual written receipt is asserted inside that close phase; merged stdout/stderr does not support a finer receipt timestamp. Every initial-exit resource sample contained only three pipes, with no TCP socket, timer, or exit-margin diagnostic; this does not identify the production TLS client.Reproduce each full-Gateway arm with its independently built revision and a fresh output directory:
pnpm check:changed, the fullpnpm build:ci-artifacts, final script typecheck/lint andgit diff --checkpassed. Codex autoreview of the complete local change againste0dd0206412af448b324387435dd8fed6575fd7bat P0–P2 found no actionable findings. Hosted Codex review completed without findings and exact-head CI is green. No UI-imported production module changed.