Repository navigation
fix: clear pending delivery when background tasks are cancelled - #153226
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: needs maintainer review before merge. Reviewed September 19, 2026, 9:30 PM ET / September 20, 2026, 01:30 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR gives final background-task corrections newer update timestamps so cancellation clears stale delivery labels, with regression tests and task documentation. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix absent from fetched main. The inspected proof supports the visible improvement, and no actionable correctness or security findings remain. Priority: P2 Review scores
Verification
How this fits togetherThe task registry records background execution and delivery outcomes, then publishes summaries through the Gateway. The Control UI uses those timestamps to reject stale updates and display task status. flowchart LR
A[Background task cancellation] --> B[Task registry]
C[Final outcome correction] --> B
B --> D[Advance update timestamp]
D --> E[Persist task record]
E --> F[Gateway task event]
F --> G[Control UI freshness check]
G --> H[Updated delivery label]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +14, Tests +187, Docs 0. Total +201 across 7 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep timestamp freshness in the shared task owner while preserving execution duration, retention, idempotence, and the UI’s stale-update protection. Do we have a high-confidence way to reproduce the issue? Yes: provisional cancellation followed by an earlier-timestamp finalization reaches the UI’s stale-update rejection path on fetched main; supplied screenshots corroborate the symptom. This review did not execute the application. Is this the best way to solve the issue? Yes: repairing the shared producer fixes both transition paths without weakening UI freshness checks or adding configuration or migration machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a0ec9f5c09d8. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
93794fe to
b946825
Compare
b946825 to
09b2d6b
Compare
|
Merged via squash.
|
Resolve the real main conflict with its complete held-terminal-write fixture from #153226. Drop the superseded pre-grace await, which cannot be combined with a write deliberately held through abandonment. Placement source and tests remain unchanged. Qualify the canonical timeout, prepared binding, and cleanup contracts with 77 controls, core types, import checks, review, and compiled startup retirement proof.
…read (#152319) * refactor(skills): move usage and curator status SQL off the caller thread * fix(skills): preserve worker errors and await usage test persistence * fix: drain delivery queue maintenance during shutdown * fix: keep Workshop event reads off the Gateway request thread * test: isolate retired agent cleanup transport fixture (#153286) * test(gateway): align curator checks with canonical lifecycle fixtures Reuse the isolated cleanup fixture from #153286 and the held-terminal-write private completion fixture from #153226. Retain the curator cleanup await. The combined 36-case proof, targeted types/lint, and independent review pass; production is unchanged. * test(outbound): clean up ACK fixtures with their owner * test(outbound): clean up ACK fixtures with their captured owner Carry the exact reviewed cleanup line from #153367, now covered by main #153296. Preserve the negative null and undefined ownership assertions. The postimage matches the canonical reviewed fixture and all four focused cases pass. * test: join Doctor database cleanup before snapshots * refactor(skills): consolidate workshop worker dispatch
…read (openclaw#152319) * refactor(skills): move usage and curator status SQL off the caller thread * fix(skills): preserve worker errors and await usage test persistence * fix: drain delivery queue maintenance during shutdown * fix: keep Workshop event reads off the Gateway request thread * test: isolate retired agent cleanup transport fixture (openclaw#153286) * test(gateway): align curator checks with canonical lifecycle fixtures Reuse the isolated cleanup fixture from openclaw#153286 and the held-terminal-write private completion fixture from openclaw#153226. Retain the curator cleanup await. The combined 36-case proof, targeted types/lint, and independent review pass; production is unchanged. * test(outbound): clean up ACK fixtures with their owner * test(outbound): clean up ACK fixtures with their captured owner Carry the exact reviewed cleanup line from openclaw#153367, now covered by main openclaw#153296. Preserve the negative null and undefined ownership assertions. The postimage matches the canonical reviewed fixture and all four focused cases pass. * test: join Doctor database cleanup before snapshots * refactor(skills): consolidate workshop worker dispatch
What Problem This Solves
Fixes cancelled background tasks remaining labeled “Waiting to send to parent” until the operator refreshes the task list.
User Impact
The live Control UI receives the final cancellation and delivery state immediately. Execution duration and task cleanup deadlines remain unchanged; no configuration or migration is needed.
Why This Change Was Made
Cancellation can publish a provisional terminal update before finalization arrives with an earlier execution timestamp. The shared task transition owner now gives substantive terminal corrections a newer publication timestamp while preserving their execution timestamps. Repeating the same finalization remains a no-op. Cleanup-only bookkeeping still persists without advancing activity or reordering the task list. This preserves the UI’s protection against stale responses.
Evidence
Reproduced through a real Gateway and the shared Chrome profile: cancel an OpenClaw-created child and observe “Cancelled” alongside “Waiting to send to parent.” The durable row already had delivery disabled, but its older timestamp caused the UI to reject the correction.
Regression cases fail on the original source and pass with the fix for earlier and equal timestamps. The synchronous registry/publication path and worker transition path are covered, including persistence, unchanged cleanup deadlines, and duplicate-finalization idempotence. The selected sibling run passed 291 cases; the final extracted timestamp and worker run passed 18 cases. CI exposed a cleanup-only ordering regression and two retirement assertions that needed to protect the new freshness contract. The correction passes 254 selected cases, including the unchanged Gateway pagination test and both rotated-parent cases. Production and selected test type checks, scoped lint/format, ratchets, docs sanity, and diff checks passed. Independent Codex reviews found no actionable issues.
Live after-fix proof passed on the same local Gateway and shared Chrome profile with the final reviewed source integrated onto main. With the Tasks panel already open, one click on Stop cancelled a newly spawned child; the card changed to “Cancelled” and “No delivery required” without refreshing or reopening the panel. The persisted publication timestamp advanced 437 ms beyond the cancellation timestamp while execution duration remained unchanged. Both screenshots were inspected and delivered in the originating chat.
The earlier Codex orphan-reaping failure was repaired in #153282, and shared-worker cleanup fixture isolation was repaired in #153286. This branch now includes both landed fixes through main at
044f78e; the six task-clock files remain unchanged. An earlier integration run passed 362 tests across 14 files.CI also exposed a private-completion test race: its abandoned-run scenario intentionally removes a controller while its terminal write is still pending, then incorrectly waits for registration removal to prove persistence. The test now waits on the captured terminal-persistence owner in that case. A deferred real write reproduces the original failure deterministically; the repair passes 72 cases across three files, the owning Gateway test typegraph, scoped lint/format, and independent review. Existing timeout and durable-outcome assertions remain. These local checks ran against the prior CI merge context; relevant task-clock and persistence owners are unchanged in the new base. Exact-head hosted CI passed all 156 jobs, including the repaired private-completion scenario. All required status contexts are also successful.
Before
After