Repository navigation
fix: keep task retention from blocking the gateway - #158235
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: blocked before merge. Reviewed September 25, 2026, 11:59 PM ET / September 26, 2026, 03:59 UTC (Revision 9). ClawSweeper reviewWhat this changesMoves task-retention reads and writes to SQLite workers and reconciles committed pruning or cleanup stamps with Gateway task and parent-flow state. Merge readiness⛔ Blocked before merge - 3 items remain Keep this PR open. Current main and the latest release still use synchronous task retention, so the change remains useful. The prior review’s blocker remains: a second managed-cancellation failure after a committed cleanup stamp can lose the retained flow retry. Priority: P1 Review scores
Verification
How this fits togetherGateway task maintenance selects completed tasks from the registry and applies retention to their SQLite records. The registry then updates its in-memory indexes and notifies task observers and parent flows. flowchart LR
A[Gateway task maintenance] --> B[Select completed task]
B --> C[Read worker prepares task]
C --> D[Write worker checks owner and commits]
D --> E[Registry reconciles task state]
E --> F[Task observers]
E --> G[Parent flow effects]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +315, Tests +652, Docs +12, Other -1. Total +978 across 62 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep worker-owned retention and make an unfinished managed-cancellation callback preserve the bounded retry obligation, with a two-failure regression that verifies the eventual durable flow state. Do we have a high-confidence way to reproduce the issue? Yes. Holding the SQLite coordinator while running task maintenance gives a high-confidence path to check Gateway responsiveness and durable retention; the PR reports a failing baseline and passing worker-path result, though this read-only review did not execute it. Is this the best way to solve the issue? No, not yet. Moving retention to the existing read and write workers fits the storage owner, but the retained flow callback must continue retrying when managed cancellation remains unfinished. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4363d7d55bdd. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What 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 (8 earlier review cycles)
|
Integrate the canonical restart-drain fixture extraction from main and remove the duplicate test edit. Preserve the flow retry when a committed retention stamp leaves managed cancellation unfinished.
Integrate main's final authority checks for run-owner binding and task settlement while preserving ordered retention admission and joined cleanup.
Bring in the canonical async harness task projection fix from #158520. The task-retention patch and its frozen proof inputs remain unchanged.
Preserve the same in-memory store and the existing held-read race while removing rows through the current asynchronous retention contract.
|
Merged via squash.
|
* fix: keep task retention from blocking the gateway * fix: keep task activity cleanup in the registry state owner * test: preserve native retention timestamps in memory fixtures * test: join restarted subagent completion * test(tasks): use retention commands in selection races Preserve the same in-memory store and the existing held-read race while removing rows through the current asynchronous retention contract.
What Problem This Solves
Task-retention maintenance could block the Gateway event loop while waiting for SQLite write coordination. It now uses the existing read and write workers so unrelated Gateway work can continue.
User Impact
Retention deadlines, cron-history limits, stored formats, and update behavior are unchanged. No operator migration is required.
Why This Change Was Made
The read worker prepares the selected task and fingerprint; the write worker revalidates that source and live authority inside the transaction. A compact commit receipt settles a lost reply without replaying the write. The publication owner reconciles indexes, activity, and flow effects before notifying observers, preserving newer owners and unknown outcomes. The superseded synchronous retention APIs and callers are removed.
Evidence
The real coordinator-contention regression passes with this cutover and fails on the original synchronous path at the responsiveness assertion. Retained proof covers retention, publication, delivery, restore and replacement races, shutdown, and lost-result settlement. The full build, benchmark flow, production types, all 25 test-type graphs, script types and selected guards passed. Counts from the successive proof batches overlap and are not a unique-test total.
CI exposed an import cycle, variable shadowing, and fixture timestamp parity; these were corrected at their existing owners. The unchanged paging RPC reproduced its ordering failure before the fixture normalization fix; afterward it passed with its original 27-file cohort and 139 siblings.
The later asynchronous terminal writer exposed an unjoined restart-drain test. Its correction passed 20 full-file runs (188 cases each), three original 38-file cohorts (785 cases each), 59 completion/sweeper cases, and lint/format/owning test types on Linux/Node24.21. Neither bounded original-source probe reproduced that intermittent CI failure. The final size guard rejected the five-line addition to the oversized test file; main subsequently landed the canonical joined helper and extraction in #158344. This candidate adopts that existing version and removes the duplicate fixture edit. No size limit, assertion, or deadline was weakened.
Integration review also found that a committed cleanup stamp could lose its flow retry when managed cancellation returned an unfinished result. The retention owner now preserves that result and retains the existing retry obligation. The original module failed the new current-owner regression at the missing retry; the repaired row and all 128 cases across six owner/sibling files passed. The injected cancellation failure uses the in-memory command adapter; the separate retention, Gateway dispatch, and run-owner suites exercise native SQLite.
The subsequent main integration preserves #156919's final commit admissions for run-owner binding and task settlement alongside retention's ordered admission stages. Fresh focused review is clean, and the native Gateway dispatch and run-owner cases passed in the combined proof.
The earlier bacc head passed CI. The combined isolated run also passed lint and formatting, then stopped at main's two missing SDK projector calls; its later type-graph, size, and diff checks did not run. The published branch integrates the canonical #158520 repair while preserving all 199 pinned runtime-proof inputs. No overall success is claimed for that isolated run.
Fresh CI then found a newer SDK selection fixture still calling the retired synchronous deletion API. That fixture now uses the existing asynchronous retention command on the same store, preserving its held-read removal/replacement sequence and assertions. No production alias or new test seam was added. Managed review is clean. All 19 selection cases passed in the
agentic-plugin-sdk-hosted-2group, and exact-head CI fordd00fe76e46bsucceeded across 173 jobs, including conditional skips.Synthetic 64 KiB and 1 MiB profiles measured warm maintenance/publication timer gaps of 7–11 ms. Replies still use whole-object structured cloning; cold initialization was outside those probe windows, and peak process RSS includes fixtures, imports, and workers. These measurements establish neither deployed gains nor a per-message memory bound.
Test cost
Each measurement selects one file per invocation. Node24.19 used a worker upper bound of two and reported one file; Node24.21 explicitly used one worker on a four-CPU Linux allocation. Wall time includes compiled-worker preparation, imports, and tests. The slower cases retain real database/worker or Gateway boundary coverage; replacing those paths with mocks would lose the contract this change protects. Retained CI output also reports 7.611 seconds summed across 49 registry-store cases, which is not file or job wall time.
The latest flow-effects measurement covers 47 cases and reuses the same lease's compilation caches after the focused negative/fixed probes. The SDK selection fixture migration adds no cases; its 19 existing cases passed in final-head CI. Their reported case times sum to 116 ms, which is not standalone file or job wall time.
task-registry.maintenance-retention.test.tstask-registry-worker-publication.test.tstask-executor-create.flow-effects.test.tstask-registry-query.test.tstask-registry-state-notification.test.tsserver.tasks-list-performance.test.tstasks.access.test.tstask-registry-projection-read.test.tstask-registry-refresh.test.tstask-registry-session-index.test.tstask-registry.async-restore.test.tstask-registry.maintenance-projection.test.tstask-registry.store.test.tstask-run-owner.test.tsRelease-note context: task-retention maintenance no longer waits synchronously for SQLite coordination on the Gateway event loop.