Skip to content

fix(cron): cancellation reason survives late delivery finalization - #129331

Merged
roboclaw-bot merged 1 commit into
mainfrom
roboclaw/pr-125397-cron-cancellation-reason
Aug 26, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
roboclaw/pr-125397-cron-cancellation-reason

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #125397
Related: #117425

What Problem This Solves

Fixes an issue where operators who cancel or disable a running cron task can lose the recorded cancellation reason when a later cron completion event attaches execution and delivery history.

This replaces the stale, conflicting implementation in #125397 while preserving its original author and current completionStatus semantics.

Why This Change Was Made

The generic task lifecycle remains authoritative for cancellation status and reason, while cron-owned detail remains authoritative for execution, completion, and delivery outcomes. Late cron finalization can therefore attach accurate history without clearing an accepted operator cancellation reason.

The replacement retains current main's required-delivery completion contract and implements both Rank-up moves from ClawSweeper's latest #125397 review: preserve completionStatus during rebase and prove cancelled task state together with failed required delivery.

Production LOC: +16/-8 (net +8) in the existing task-finalization/detail codec; tests: +32/-8 (net +24). The production growth records the otherwise-lost cron-owned execution error/summary in the existing detail object while leaving generic cancellation fields authoritative. No config, schema, protocol, or parallel persistence path is added.

Maintainer decision: accept the additive cron-detail contract for this repair. It is the owner-authored design from #125397, uses only the existing JSON detail object, preserves the generic cancellation contract, and is necessary to retain cron-native execution/completion/delivery facts without erasing the operator cancellation reason. Older readers continue to open the row and retain their prior projection; the tested legacy fallback remains intact.

User Impact

Cancelled or disabled cron task records keep the operator-visible cancellation reason, while cron history still reports the underlying execution, failed completion, and interrupted delivery accurately.

Evidence

  • Pre-fix reproduction on base 13934fef3d77: applying only the new regression test and running node scripts/run-vitest.mjs src/cron/service/task-runs.test.ts -t 'keeps operator cancellation reason when required delivery is interrupted' failed at src/cron/service/task-runs.test.ts:483; the persisted cancelled task was missing error: "Cancelled by operator.".
  • Exact replacement head 4ef16a512172: node scripts/run-vitest.mjs src/cron/service/task-runs.test.ts src/cron/service/timer-job-runner.interruption.test.ts src/cron/task-run-history.test.ts src/cron/service.persists-delivered-status.test.ts src/cron/service/timer.regression.test.ts — 140 passed. This covers the original cancellation/finalization order, the completionStatus: "failed" history projection, interruption mapping, a real hanging webhook cancellation, and timeout-disabled operator cancellation.
  • Exact replacement head: node scripts/check-changed.mjs -- src/cron/service/task-runs.ts src/cron/task-run-detail.ts src/cron/service/task-runs.test.ts src/cron/service/timer-job-runner.interruption.test.ts src/cron/task-run-history.test.ts — passed, including formatting, production/core-test typechecks, zero-warning lint, dead exports, database guards, and import cycles.
  • Exact replacement head: .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --stream-engine-output — clean, no accepted/actionable findings; correctness 0.99.
  • Test-audit authoring gate: the combined regression protects observable persisted lifecycle/history behavior, fails pre-fix for the intended missing-reason defect, extends the existing owner suite, and adds no test-only production seam.
  • Screenshots are not applicable: this is a persisted cron lifecycle/history repair with no changed visual surface. Exact-head CI and the current-head ClawSweeper re-review remain the publication gates.

AI-assisted implementation and verification. No user transcripts are included.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review August 25, 2026 12:53
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot
roboclaw-bot force-pushed the roboclaw/pr-125397-cron-cancellation-reason branch from 4156e57 to 4ef16a5 Compare August 25, 2026 13:14
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts and removed scripts Repository scripts labels Aug 25, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot
roboclaw-bot force-pushed the roboclaw/pr-125397-cron-cancellation-reason branch from 4156e57 to 4ef16a5 Compare August 25, 2026 13:34
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Aug 25, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 10:28 PM ET / August 26, 2026, 02:28 UTC.

ClawSweeper review

What this changes

This PR preserves an operator cancellation reason when late cron finalization records the underlying execution and delivery outcome.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness finding: this is the current owner-boundary repair for a source-proven cron lifecycle bug. It should remain open for protected maintainer handling and exact-head CI completion.

Priority: P2
Reviewed head: 37c83f7a7eaa7e0f16ee2645d508f31068308139

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused, source-backed owner-boundary repair with regression and legacy compatibility coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This member/bot-maintained internal lifecycle repair is exempt from the external-contributor real-behavior-proof gate; its focused persisted-boundary regression remains relevant validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member/bot-maintained internal lifecycle repair is exempt from the external-contributor real-behavior-proof gate; its focused persisted-boundary regression remains relevant validation.
Evidence reviewed 5 items Current-main defect: Current main forwards the late event error, clear-error flag, and summary even when retrying a cancelled row, so a successful cron execution event clears the accepted cancellation error.
Owner-boundary repair: The PR omits generic lifecycle error and summary fields when preserving cancelled status, while writing the cron execution values into cron detail.
Compatibility projection: New detail values override generic lifecycle fields for newly written rows, while the generic values remain the fallback when old detail lacks those keys.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/cron/service/task-runs.test.ts -t 'keeps operator cancellation reason when required delivery is interrupted'

Result: PASS (completed)

[test] starting test/vitest/vitest.cron.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129331-oN6UfX/target

 ✓  cron  src/cron/service/task-runs.test.ts (20 tests | 19 skipped) 460ms
     ✓ keeps operator cancellation reason when required delivery is interrupted  457ms

 Test Files  1 passed (1)
      Tests  1 passed | 19 skipped (20)
   Start at  02:29:28
   Duration  10.84s (transform 8.19s, setup 945ms, import 9.08s, tests 460ms, environment 0ms)

[test] passed 1 Vitest shard in 17.31s
[test] starting test/vitest/vitest.cron.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129331-oN6UfX/target

 ✓  cron  src/cron/service/task-runs.test.ts (20 tests | 19 skipped) 440ms
     ✓ keeps operator cancellation reason when required delivery is interrupted  436ms

 Test Files  1 passed (1)
      Tests  1 passed | 19 skipped (20)
   Start at  02:29:46
   Duration  5.26s (transform 2.70s, setup 439ms, import 4.15s, tests 440ms, environment 0ms)

[test] passed 1 Vitest shard in 11.70s

Assertions:

  • PASS expect_output: keeps operator cancellation reason when required delivery is interrupted

How this fits together

Cron writes generic task lifecycle state and cron-specific detail, then projects that detail into run history. A late completion event must update cron history without overwriting an operator-owned cancellation outcome.

flowchart LR
  A[Operator cancellation] --> B[Generic task record]
  C[Cron completion event] --> D[Late finalization]
  D --> E[Cron detail]
  B --> F[Persisted task row]
  E --> G[Run history projection]
  F --> G
Loading

Before merge

  • Resolve merge risk (P2) - This changes persisted cron-detail interpretation; exact-head checks should confirm the retained generic-field fallback for pre-existing rows before merge.
  • Complete next step (P2) - The protected maintainer PR has no actionable repair finding; it needs normal exact-head CI and maintainer handling.
Agent review details

Security

None.

PR surface

Source +8, Tests +24. Total +32 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 16 8 +8
Tests 3 32 8 +24
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 48 16 +32

Review metrics

Metric Value Why it matters
Production versus tests production +8 net; tests +24 net The necessary production growth persists two cron-owned outcome fields, with focused lifecycle and legacy-projection coverage.

Root-cause cluster

Relationship: canonical
Canonical: #129331
Summary: This PR replaces the closed, unmerged earlier attempt; the larger cron delivery-lifecycle PR addresses an adjacent invariant.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Require exact-head compatibility proof (recommended)
    Merge only after the exact head confirms both the new cron-detail projection and generic-field fallback for older rows.

Technical review

Best possible solution:

Land this owner-boundary repair once exact-head CI is green, retaining the generic fallback for legacy task rows and the split between cancellation reason and cron execution history.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main clears a cancelled row’s error during late finalization, and the focused regression captures that exact ordering.

Is this the best way to solve the issue?

Yes. Keeping cancellation state in the generic task owner while storing the distinct cron execution outcome in cron detail avoids conflating two valid outcomes and preserves legacy reads.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 93573e8fdf7a.

Labels

Label justifications:

  • P2: This repairs a bounded persisted cron-history correctness issue without evidence of an active availability or security emergency.
  • merge-risk: 🚨 compatibility: The change gives newly written cron detail precedence over generic lifecycle fields while preserving a legacy-row fallback.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member/bot-maintained internal lifecycle repair is exempt from the external-contributor real-behavior-proof gate; its focused persisted-boundary regression remains relevant validation.

Evidence

What I checked:

  • Current-main defect: Current main forwards the late event error, clear-error flag, and summary even when retrying a cancelled row, so a successful cron execution event clears the accepted cancellation error. (src/cron/service/task-runs.ts:424, 93573e8fdf7a)
  • Owner-boundary repair: The PR omits generic lifecycle error and summary fields when preserving cancelled status, while writing the cron execution values into cron detail. (src/cron/service/task-runs.ts:430, 37c83f7a7eaa)
  • Compatibility projection: New detail values override generic lifecycle fields for newly written rows, while the generic values remain the fallback when old detail lacks those keys. (src/cron/task-run-detail.ts:335, 37c83f7a7eaa)
  • Regression coverage: The focused test reproduces cancellation followed by failed required delivery and asserts both the retained task reason and separate cron history outcome. (src/cron/service/task-runs.test.ts:446, 37c83f7a7eaa)
  • Related history: The adjacent completion-status contract was established by the earlier required-delivery repair, supporting preservation rather than collapse of completion state. (src/cron/service/task-runs.ts:422, 2bcc06cc2270)

Likely related people:

  • steipete: Authored the exact repair and the preceding required-delivery completion work on this lifecycle path. (role: feature owner; confidence: high; commits: 37c83f7a7eaa, 2bcc06cc2270; files: src/cron/service/task-runs.ts, src/cron/task-run-detail.ts)
  • Tak Hoffman: Co-authored the exact cron lifecycle repair. (role: adjacent contributor; confidence: medium; commits: 37c83f7a7eaa; files: src/cron/service/task-runs.ts, src/cron/task-run-detail.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let required checks complete successfully on the exact head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-25T13:39:32.263Z sha 4ef16a5 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T14:11:15.617Z sha 1fd6335 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T01:59:44.834Z sha 8015e3e :: needs maintainer review before merge. :: none

@roboclaw-bot
roboclaw-bot force-pushed the roboclaw/pr-125397-cron-cancellation-reason branch from 4ef16a5 to 1fd6335 Compare August 25, 2026 14:04
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 25, 2026
@roboclaw-bot
roboclaw-bot force-pushed the roboclaw/pr-125397-cron-cancellation-reason branch from 1fd6335 to 8015e3e Compare August 26, 2026 01:53
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Maintainer decision: accept the durable ownership split in this PR.

The generic task lifecycle remains authoritative for the operator cancellation outcome and reason. Cron-owned detail is the canonical source for the underlying execution error and summary on newly written rows, with the tested legacy-row fallback retained.

Focused proof after refreshing onto current main: 52/52 tests passed across task-run finalization, interruption, and history projection. Fresh Codex autoreview reported no actionable findings. This records the owner decision requested by the latest ClawSweeper review before guarded landing.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Maintainer decision: accept the durable ownership split in this PR.

The generic task lifecycle remains authoritative for the operator cancellation outcome and reason. Cron-owned detail is the canonical source for the underlying execution error and summary on newly written rows, with the tested legacy-row fallback retained.

Focused proof after refreshing onto current main: 52/52 tests passed across task-run finalization, interruption, and history projection. Fresh Codex autoreview reported no actionable findings. This records the owner decision requested by the latest ClawSweeper review before guarded landing.

Keep the generic task cancellation outcome and reason authoritative while
storing the underlying cron execution, completion, and delivery outcomes in
cron-owned history detail.

Co-authored-by: Tak Hoffman <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the roboclaw/pr-125397-cron-cancellation-reason branch from 8015e3e to 37c83f7 Compare August 26, 2026 02:22
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Land-ready proof for exact head 37c83f7:

  • 52 focused cron lifecycle tests passed, including cancellation, required-delivery failure, legacy detail fallback, disable, and removal sibling paths.
  • Exact-head CI is terminal with 149 successes, 46 expected skips, one neutral CodeQL aggregate, and zero failures.
  • Latest ClawSweeper review on this head has no actionable findings and identifies this as the best owner-boundary fix.
  • Fresh Codex branch autoreview is clean, correctness 0.98.
  • Production delta: +16/-8 (net +8); tests: +32/-8 (net +24).
  • The commit contains the exact requested trailer: Co-authored-by: Tak Hoffman [email protected].
  • This is a headless persisted-lifecycle boundary; ordered storage and projection assertions are the relevant behavior evidence, not screenshots.

@roboclaw-bot
roboclaw-bot merged commit 7df13ba into main Aug 26, 2026
196 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

@roboclaw-bot
roboclaw-bot deleted the roboclaw/pr-125397-cron-cancellation-reason branch August 26, 2026 04:12
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…claw#129331)

Keep the generic task cancellation outcome and reason authoritative while
storing the underlying cron execution, completion, and delivery outcomes in
cron-owned history detail.

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Tak Hoffman <[email protected]>
vincentkoc added a commit that referenced this pull request Aug 26, 2026
* origin/main: (24 commits)
  fix(gateway): reject rootless session permission modes (#128149)
  docs(memory): document shipped turn-taint propagation for network tool output (#129837)
  fix(ui): pool reply-less wake activity into one chat rollup (#128442)
  fix(package): prevent installs from deleting validated runtime assets (#129724)
  fix(nodes): approve silent initial node surfaces and name the pending surface approval (#129795)
  fix(backup): preserve configured agent state roots (#129773)
  fix(ui): own chat history issuance with a closed state machine (#129776)
  fix(cron): preserve cancellation reason after late finalization (#129331)
  fix(cron): prevent run waits from failing after clock changes (#129805)
  fix(telegram): route commentary through one frozen progress owner (#128259)
  fix(release): start approved VCR mirror recovery jobs (#129829)
  test: complete current-plugin-metadata-snapshot mock factories (#129791)
  test(telegram): remove duplicate reaction case (#129848)
  fix(channels): honor supported account reply-threading policies (#129679)
  refactor(cli): deduplicate lazy subcommand registration (#129351)
  fix(ai): report interrupted local-model streams instead of empty success (#129794)
  refactor(cli): consolidate Gateway fallback and hook ownership (#129802)
  fix(qa): reject token confidence lanes without executed evidence (#129830)
  fix(tui): fence session state and delayed actions (#129810)
  fix(control-ui): keep task progress full width on hover (#129832)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants