Repository navigation
fix(gateway): await cron exit watcher drain - #126963
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
To use Codex here, create a Codex account and connect to github. |
|
Codex review: needs maintainer review before merge. Reviewed August 20, 2026, 11:46 PM ET / August 21, 2026, 03:46 UTC. ClawSweeper reviewWhat this changesThe PR makes Gateway cron shutdown wait for cancelled on-exit watcher lifecycles, including child exit and completion persistence, before restart or replacement scheduling proceeds. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open: this active maintainer-authored draft repairs a real Gateway shutdown gap, and source review found no patch defect. It still needs the stated exact-head Gateway validation before becoming ready to merge. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherGateway cron owns scheduled work and process watchers. A stop or reload cancels watcher children, drains their lifecycle work, and only then permits a replacement cron service to reconcile jobs. flowchart LR
A[Gateway stop or reload] --> B[Cron service]
B --> C[Cancel exit watchers]
C --> D[Wait for child exit and persistence]
D --> E[Complete cron drain]
E --> F[Start replacement scheduler]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +18, Tests +105. Total +123 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one explicit exit-watcher settlement barrier at the cron-service shutdown owner, with restart admission behind that barrier and focused lifecycle regressions proving the order. Do we have a high-confidence way to reproduce the issue? Yes—current main omits the exit-watcher await, and the PR supplies deterministic boundary tests for child exit, persistence, restart, and later-stop ordering; this read-only review did not execute them. Is this the best way to solve the issue? Yes—the existing cron stop-and-drain owner is the narrowest canonical place to join watcher settlement, matching the sibling stream-watcher shutdown barrier rather than adding a replacement-side workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 579f9b8a8a5e. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* origin/main: (107 commits) perf(test): speed up Agents page observation polling (#127063) fix(android): explicitly target notification intents (#127055) fix(agents): preserve literal Unicode-space paths (#126797) fix(agents): distinguish review routing from enforcement (#126216) fix(ui): associate steering work by target run (#126997) fix(ui): collapse completed pre-steer work fix(codex): preserve steering transcript order fix(gateway): retain Bonjour cleanup on startup failure (#127062) fix(release): require concrete validation retry groups (#127012) fix(file-transfer): expose directory page tokens (#127051) perf: trim setup detection worker imports (#127053) fix(onboard): make --auth-choice help match the accepted set (#127030) fix(gateway): await cron exit watcher drain (#126963) fix(telegram): preserve direct-topic self-history (#127050) fix: dismiss sidebar session menu tooltip (#127044) perf(test): speed up pairing access polling (#127047) perf(cli): remove ineffective dynamic imports (#127046) fix(gateway): recover credential-file accounts after secrets reload (#126999) fix(gateway): restore scheduler-owned Gateway context (#126640) fix(macos): keep first-run onboarding visible after Gateway changes (#127038) ... # Conflicts: # .github/workflows/full-release-validation.yml # test/scripts/full-release-validation-at-sha.test.ts
* fix(gateway): await cron exit watcher drain Amp-Thread-ID: https://ampcode.com/threads/T-01a0220d-d77f-73fb-a791-cbfb09be7d07 * fix(gateway): drain exit watchers before cron restart Amp-Thread-ID: https://ampcode.com/threads/T-01a0220d-d77f-73fb-a791-cbfb09be7d07 * fix(gateway): fence cron restart after later stop Amp-Thread-ID: https://ampcode.com/threads/T-01a0220d-d77f-73fb-a791-cbfb09be7d07 --------- Co-authored-by: Amp <[email protected]>
Summary
CronExitWatchers.cancelAll()await every cancelled watcher lifecycle, including supervised child exit and terminal persistencestopAndDrain()owner boundaryRoot cause
cancelAll()synchronously requested cancellation but returned while cancelled slots remained insettlingCancelledSlots.buildGatewayCronService.stopAndDrain()awaited active cron task runs and stream watchers only, so hot reload could start a replacement cron service while predecessor exit watchers were still settling.The new boundary test fails on frozen base
ab2bbd42dfafb1da9ecad901caa8d2d32e3cd251withexpected true to be false: the owner drain completed before the exit-watcher drain promise. It passes with this change.Validation
node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-core.config.ts src/gateway/cron-exit-watchers.test.ts— 17/17 passednode scripts/run-vitest.mjs run --config test/vitest/vitest.gateway-server.config.ts src/gateway/server-cron.test.ts src/gateway/server-cron.drain.test.ts src/gateway/server-reload-handlers.test.ts src/gateway/server-cron-lazy.test.ts src/gateway/server-close.test.ts— 370/370 passednode scripts/check-changed.mjs -- src/gateway/cron-exit-watchers.ts src/gateway/server-cron.ts src/gateway/cron-exit-watchers.test.ts src/gateway/server-cron.drain.test.ts— passed all production/test typechecks, lint, format, policy, dead-export, and import-cycle checksReview status
2dc5dd8cadd2eb8205c62715f480a6ab38d4073d: TruffleHog clean;patch is correct; confidence 0.94; findings[]