Repository navigation
fix(cron): remove deleted job sessions - #119520
Conversation
1cc79fa to
f21b978
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 3:43 AM ET / 07:43 UTC. ClawSweeper reviewWhat this changesRemoves an isolated or current cron job’s reusable base session after the job is durably deleted, while preserving active runs, shared sessions, and retained run history. Merge readinessKeep open: current main still leaves an isolated cron job’s base session after deletion, while this PR repairs that lifecycle boundary with focused concurrency coverage and sufficient runtime proof. Priority: P2 Review scores
Verification
How this fits togetherCron deletion removes durable job definitions and their isolated-agent session state. The resulting session store feeds session-management surfaces such as the Control UI. flowchart LR
A[Operator deletes cron job] --> B[Durable cron deletion]
B --> C[Active-run and same-ID fence]
C --> D[Canonical session lifecycle]
D --> E[Session store]
E --> F[Control UI session list]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +184, Tests +408. Total +592 across 7 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land a current-main merge candidate that deletes only the deleted job’s isolated base session through the canonical lifecycle path while preserving replacement and active-run state. Do we have a high-confidence way to reproduce the issue? Yes—source inspection of current main shows cron deletion does not invoke base-session cleanup, while the durable session entry remains eligible to appear in session-management surfaces. Is this the best way to solve the issue? Yes—the cleanup belongs to the cron deletion owner and delegates row removal to the canonical session lifecycle accessor rather than broadening retention cleanup or adding a second session path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 484765582656. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
f21b978 to
ee789bb
Compare
a7b6701 to
17ae337
Compare
17ae337 to
205ba34
Compare
|
@clawsweeper re-review The head moved to address the remaining cross-service concurrency boundary. The same-ID cleanup fence is now owned by the shared cron store partition rather than one |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
066a467 to
b8e3c03
Compare
|
@clawsweeper re-review Exact head |
|
🦞👀 Command router queued. I will update this comment with the next step. |
Co-authored-by: Goutam Adwant <[email protected]>
Co-authored-by: Goutam Adwant <[email protected]>
Co-authored-by: Goutam Adwant <[email protected]>
Co-authored-by: Goutam Adwant <[email protected]>
b8e3c03 to
7ff55d5
Compare
|
Exact-head refresh: Fresh proof on this head:
The private Gateway/SQLite runtime proof remains applicable because the cron patch is unchanged: removing the disposable cron changed its base-session count from 1 to 0 and the Gateway shut down cleanly. @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
* fix(cron): remove deleted job sessions * fix(cron): guard deferred session cleanup * test(cron): remove invalid cleanup await * fix(cron): fence deferred session cleanup * fix(cron): share removal cleanup fence Co-authored-by: Goutam Adwant <[email protected]> * fix(cron): preserve stored add result type Co-authored-by: Goutam Adwant <[email protected]> * fix(cron): release lock before session cleanup Co-authored-by: Goutam Adwant <[email protected]> * fix(cron): avoid materializing cleanup store Co-authored-by: Goutam Adwant <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where operators deleting an isolated cron job would still see its reusable
agent:<agent>:cron:<jobId>base session in session-management surfaces.Closes #46369.
Why This Change Was Made
Cleanup now runs after the cron definition is durably removed and uses the canonical session lifecycle mutation, including transcript archival. If a run was already admitted, deletion waits for that exact active marker to clear, preserving the run's lifecycle claim.
A per-store, per-job cleanup fence makes same-ID creation release the shared cron-store lock, wait through the asynchronous session mutation, and retry afterward. The fence lives beside the canonical store-partition operation queue, so sibling
CronServiceinstances cannot overtake each other's cleanup or make the remover trust a stale service-local job snapshot. Cleanup reacquires that lock and reloads committed cron state before deleting the guarded session row.Per-run history remains owned by cron retention, and shared
mainsessions are not removed.User Impact
Deleted isolated/current cron jobs no longer leave ghost base sessions in the session store or Control UI. Active-run deletion, same-ID job replacement, sibling service instances, unrelated jobs, shared sessions, and retained run history preserve their existing behavior.
Evidence
Real behavior proof on implementation head
ee789bbused an isolated loopback gateway and its SQLite-backed session store:The disposable job was created and removed through the real CLI/gateway flow. Its canonical base-session fixture was inserted through the runtime session accessor before removal; this proof does not depend on an external model or channel provider.
Fresh final-head proof on
066a4673ae81e4f07beb38b18bd6f702441c08f2repeated that flow against an isolated dev Gateway and SQLite state directory:The final-head run also used the runtime session accessor to seed the canonical row, invoked no provider or channel, and retained private mode-0600 raw artifacts locally.
The current head
b8e3c03d77f76e97b2dba6dd9cce1b321c620627is a patch-identical rebase of that reviewed cron repair onto main after CI fixture fix #120847; no cron/session runtime content changed after the trace.The final concurrency regression uses two
CronServiceinstances sharing one SQLite cron partition. It removes an active job through one service, attempts a same-ID replacement through the other, proves creation remains fenced until exact-marker cleanup finishes, then verifies the replacement session survives.Validation on final source head
b8e3c03d77f76e97b2dba6dd9cce1b321c620627, rebased onto current main with CI watchdog fix #120700 and config-recovery fixture fix #120847:Exact-head hosted CI is required before landing. Per-run session rows intentionally remain governed by cron retention. A session-cleanup failure is logged and does not roll back an already-durable job deletion, preventing retry ambiguity.
Contributor Credit
The original repair and concurrency coverage are by @goutamadwant. The maintainer follow-up keeps the contributor's four authored commits and credits Goutam on every maintainer-authored repair commit.
Disclosure: AI was used to understand the codebase and review the fix.