Repository navigation
fix(cron): fence executions with durable receipts - #122948
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 13, 2026, 6:16 AM ET / 10:16 UTC. ClawSweeper reviewWhat this changesThis PR adds durable SQLite receipts that fence scheduled, startup, stream, and manual cron runs so concurrent gateways and stale job owners cannot apply duplicate or obsolete effects. Merge readiness⛔ Blocked by patch quality or review findings - 10 items remain Keep open: the prior P1 remains on the exact head—native Windows cannot obtain the required process-start identity, so every cron admission aborts before executing its payload. The PR also needs persistent-schema upgrade proof and removal of its release-owned changelog edit. Priority: P1 Review scores
Verification
How this fits togetherCron turns scheduled and manual job requests into agent, command, script, and webhook effects. The proposed receipt sits between admission and execution, then records the terminal outcome alongside the job’s next schedule. flowchart LR
A[Scheduled or manual cron request] --> B[Durable receipt claim]
B --> C{Owner identity and receipt current?}
C -->|yes| D[Execute payload or webhook]
C -->|no| E[Skip or supersede run]
D --> F[Atomic job and receipt finalization]
F --> G[Notify and schedule next run]
Decision needed
Why: The durable receipt design changes shared persisted state and requires maintainer judgment on the approved upgrade contract after the concrete platform bug is repaired. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +1652, Tests +1399, Docs +1, Generated +16. Total +3068 across 57 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use the existing Windows creation-time reader for receipt identity, add a native-Windows admission regression and an older-reader reopen/use test for the lazy table, remove the changelog line, then rebase and publish exact-head cron proof. Do we have a high-confidence way to reproduce the issue? Yes. On native Windows, Is this the best way to solve the issue? No. A durable per-run receipt is a plausible owner boundary, but the current implementation regresses native Windows and lacks the required persisted-state upgrade proof. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2278ca6952ea. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
ad5ddb5 to
0b152be
Compare
3240e17 to
1d6cb07
Compare
|
Merged via squash.
|
* fix(cron): fence concurrent executions durably * refactor(cron): keep receipt hooks internal * refactor(cron): hide internal save hooks * test(cron): inspect receipts through SQLite * test(cron): auto-clean process fixtures * refactor(cron): avoid receipt service cycle * fix(cron): harden receipt cleanup and retention * refactor(cron): simplify receipt cleanup * fix(cron): serialize owner updates with run leases * fix(cron): hold run leases through settlement * fix(cron): recover stale foreign run receipts * fix(cron): complete durable receipt recovery * fix(cron): preserve foreign handoff transitions * fix(cron): make owner recovery atomic * fix(cron): isolate reservation retries * refactor(cron): scope runtime writes by job * fix(cron): harden lazy receipts and reservations * fix(cron): close startup recovery races * fix(cron): make queued leases atomic * fix(cron): unify receipt lifecycle recovery * fix(cron): adjudicate stale receipts before fencing * fix(cron): close terminal consistency gaps * fix(cron): preserve terminal publication ordering * fix(cron): break rebased store import cycles * fix(cron): reconcile rebased finalization contracts * fix(cron): type unavailable-owner settlement
What Problem This Solves
Cron previously combined process-local locks with persisted
queuedAtMs/runningAtMsmarkers. Two gateways could load the same runnable job, execute it twice, or let a stale run mutate a job after ownership changed. Operators then had to infer whether a job ran from logs and best-effort task history.This is the multi-gateway cron ownership hardening follow-up split from parent program #114388.
Why This Change Was Made
The change adds a lazy, additive SQLite
cron_run_receiptstable without a schema-version bump. Each reservation records the exact store/job, config revision, effective agent, PID/process-start incarnation, start time, and terminal result. The receipt is both the durable execution fact and the cross-process lease.The implementation is organized around four lifecycle invariants:
Scheduler runtime writes are row-scoped, so gateway B cannot replay stale state for gateway A's job. Claims use PID-safe incarnation identity, including the existing Windows process-start reader. Owner/config changes and dispatch admission share the durable fence; stale runs are superseded before effects or final state can cross revisions. Notifications and completion events publish only after committed state, and startup repair buffers notifications until its transaction succeeds.
The archive was mined rather than transplanted. The final design keeps durable receipts, exact-owner liveness recovery, config-revision adjudication, and the small current-main rollback seam. It drops the archive's aggregate runtime revision, baseline/delta merge, expanded rollback snapshots, live-service registry, and config-owner handoff receipts because #114388 now owns those roster/owner transitions and row-scoped receipt transactions close the remaining concurrency invariant directly.
User Impact
Release-note context: Cron execution ownership: record durable SQLite run receipts, fence overlapping gateway schedulers by exact process ownership, and supersede live results when the job's effective agent changes.
Evidence
80bafb0f7a9c95ba84fa58dce5c45d690703535f, run 31734932917, green.pnpm check:architecture, allpnpm tsgo:alllanes,pnpm check:test-types, targeted oxlint/oxfmt, dead-code export checks, andgit diff --checkpassed.tbx_01kzwgh4ewf7cqekrhtab1s55kin run 31662123279; full TypeScript lanes ontbx_01kzwbz89eyrnxjkqpqh5b83sein run 31658015925; broad receipt/cron tests in run 31655061953. The final follow-up round used local unfiltered/type proof, with exact-head PR CI as the hosted final gate.Rank-up moves:list. Its concrete before-merge moves were all applied: native-Windows process identity, older-reader database reopen/use proof, release-owned changelog removal, conflict resolution, and refreshed exact-head CI. No move was skipped.