Skip to content

fix(cron): link active tasks to execution transcripts - #117679

Merged
steipete merged 2 commits into
mainfrom
codex/autoqa-cron-task-session-link-20260801
Aug 1, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/autoqa-cron-task-session-link-20260801

Conversation

@steipete

@steipete steipete commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #117678

What Problem This Solves

Fixes an issue where an active scheduled task could link to the session that created the job instead of the transcript where the scheduled run was actually executing. Opening the task could therefore show an unrelated conversation or a provisional key that never received the run.

Why This Change Was Made

Cron task rows now start without an invented transcript link for agent turns and adopt the exact session key reported by the runner when execution begins. Both timeout and no-timeout paths use the same callback; main system events retain their deterministic per-run key, headless jobs stay childless, and terminal outcomes keep their existing authoritative session projection. A durable task-kind marker now distinguishes canonical pre-session rows from unmarked legacy cleanup rows, so cancellation no longer abuses transcript-link presence as a lifecycle sentinel.

User Impact

Operators opening active automation tasks now land in the real execution transcript for current, isolated, and custom persistent session targets. Script, command, and heartbeat tasks no longer advertise nonexistent conversations.

Evidence

  • Current-main reproduction at eb8c22ed13f9865e07c0e363706183188e2a8fd1: custom and isolated jobs can carry both a creator job.sessionKey and a different execution target, while the task projection prefers the creator metadata.
  • Blacksmith Testbox tbx_01kyzs0ds7t8df63v96a4d35mg, run 30722526103: 81/81 focused cron and task assertions passed, covering current, isolated-with-source, custom persistent sessions, timeout/no-timeout callbacks, main system events, and headless work.
  • Exact-head CI on the first head caught the hidden cancellation sibling: a childless canonical row could be mistaken for stale legacy state and overwritten during timeout cleanup. The repair adds an explicit task-kind fact instead of restoring a fake transcript link.
  • Blacksmith Testbox tbx_01kyzswphf6sw5ft5584xgxeph, run 30723047598: the exact failed timer regression and full task-registry suite passed 178/178 after the ownership repair.
  • Real isolated Gateway + public CLI proof on Testbox tbx_01kyzv0jw2s8c6h74fekm8gxrm, run 30723680725: a cron agent turn remained actively running, carried taskKind: "automation_run", and changed from creator session agent:main:telegram:group:creator-proof to the runner's exact agent:main:cron:<job>:run:<session> key before terminal completion. The full product build passed first; the owned Gateway, mock provider, state directory, and non-default ports were cleaned up.
  • Fresh final whole-branch Codex autoreview 019fbfa2-b05e-7ff0-a6f4-be30d1432aa0: TruffleHog clean, zero findings, patch correct at 0.96 confidence.
  • Independent owner/history review found no blocker, confirmed job.sessionKey is creator/wake/delivery metadata rather than execution identity, and verified the runner callback is the authoritative transcript boundary.
  • Targeted oxfmt and git diff --check passed. Production is +55/-34 (net +21); tests are +141/-49.

Release-note context: active cron task links now open the transcript where the scheduled run is actually executing.

AI-assisted: yes. The execution owner, task registry projection, timeout siblings, history, and focused proof were independently reviewed.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 23:09
@steipete steipete self-assigned this Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 7:47 PM ET / 23:47 UTC.

ClawSweeper review

What this changes

The branch changes active cron task records to adopt the execution transcript reported by the cron runner instead of pre-populating creator or provisional session links.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This PR remains necessary: current main still pre-populates active cron task links from job metadata, while the runner owns the exact execution transcript. The branch moves that fact to the execution-start boundary, covers current/isolated/custom targets and cancellation, and includes reported real Gateway-plus-CLI proof; keep it open for maintainer handling and the normal final merge gate.

Priority: P2
Reviewed head: eef2967441d52bf106a81e5f6a06927c7a3300e8

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with targeted sibling coverage and concrete after-fix Gateway/CLI proof; only routine final merge validation remains.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides a concrete after-fix Testbox Gateway-plus-public-CLI observation of the active task adopting the runner session before completion; retain only redacted identifiers and endpoints in any public proof artifact.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides a concrete after-fix Testbox Gateway-plus-public-CLI observation of the active task adopting the runner session before completion; retain only redacted identifiers and endpoints in any public proof artifact.
Evidence reviewed 6 items Current-main defect: Current main derives the active task child-session link from job/session metadata before the runner supplies the execution identity, which can select a creator or provisional transcript instead of the actual run.
Authoritative session producer: The isolated cron runner publishes its prepared run session key through onExecutionStarted, establishing the runner callback as the authoritative point to update the active task record.
Repair and sibling lifecycle coverage: The branch leaves agent-turn task rows unlinked until execution starts, records the callback session through the task progress API, stamps canonical cron rows with taskKind, and preserves childless canonical rows during cancellation.
Findings None None.
Security None None.

How this fits together

Cron creates a durable task row before scheduled work runs, while the cron runner later resolves the exact agent execution session. The task registry exposes that row to task views and cancellation, so its child-session link must match the run actually in progress.

flowchart LR
  A[Scheduled cron job] --> B[Create active task row]
  B --> C[Cron runner starts work]
  C --> D[Reports execution session]
  D --> E[Update task transcript link]
  E --> F[Tasks UI and API]
  E --> G[Cancellation handling]
Loading

Before merge

  • Resolve merge risk (P1) - The PR is behind current main, so required checks and mergeability should be evaluated on the final merge head; this does not by itself show that the branch would remove current-main behavior.
  • Resolve merge risk (P1) - The patch intentionally changes persisted active-task child-session state and the interpretation of childless cron rows during cancellation, so the existing focused sibling coverage should remain part of merge validation.
  • Complete next step (P2) - The linked open bug and this maintainer-labeled PR already own the repair; the remaining action is final maintainer merge handling, not a replacement fix PR.
Agent review details

Security

None.

PR surface

Source +21, Tests +92. Total +113 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 55 34 +21
Tests 3 141 49 +92
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 196 83 +113

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #117678
Summary: This PR is the explicitly linked candidate fix for the canonical active-cron-task transcript issue.

Members:

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

Merge-risk options

Maintainer options:

  1. Merge with final session-state validation (recommended)
    Merge after the final head confirms the runner-owned task link and canonical childless-cancellation regressions still pass.
  2. Pause only for a rebase-discovered ownership conflict
    Pause if current-main changes reveal a conflicting newer task-registry ownership model that cannot preserve the runner as the authoritative session producer.

Technical review

Best possible solution:

Land the focused owner-boundary repair after final current-head checks: use only the runner-reported execution session for agent-turn task links, retain deterministic system-event links, and retain taskKind as the separate canonical cancellation lifecycle fact.

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

Yes, source-reproducible: current main assigns the active task link before the runner callback publishes the exact execution session. The branch’s focused tests and reported Gateway/CLI run cover the observable state transition for current, isolated, and custom session targets.

Is this the best way to solve the issue?

Yes: recording the runner callback’s session at its producer boundary is more maintainable than inferring execution identity from creator metadata, while taskKind preserves the distinct cancellation invariant without a fabricated transcript link.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4153451a9a1d.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides a concrete after-fix Testbox Gateway-plus-public-CLI observation of the active task adopting the runner session before completion; retain only redacted identifiers and endpoints in any public proof artifact.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides a concrete after-fix Testbox Gateway-plus-public-CLI observation of the active task adopting the runner session before completion; retain only redacted identifiers and endpoints in any public proof artifact.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The defect deterministically mis-associates active automation transcript state but does not stop scheduled work from running.
  • merge-risk: 🚨 session-state: The branch changes persisted child-session identity for running cron tasks and the lifecycle handling of childless task records.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides a concrete after-fix Testbox Gateway-plus-public-CLI observation of the active task adopting the runner session before completion; retain only redacted identifiers and endpoints in any public proof artifact.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides a concrete after-fix Testbox Gateway-plus-public-CLI observation of the active task adopting the runner session before completion; retain only redacted identifiers and endpoints in any public proof artifact.

Evidence

What I checked:

  • Current-main defect: Current main derives the active task child-session link from job/session metadata before the runner supplies the execution identity, which can select a creator or provisional transcript instead of the actual run. (src/cron/service/task-runs.ts:70, 4153451a9a1d)
  • Authoritative session producer: The isolated cron runner publishes its prepared run session key through onExecutionStarted, establishing the runner callback as the authoritative point to update the active task record. (src/cron/isolated-agent/run.ts:135, 825a79467255)
  • Repair and sibling lifecycle coverage: The branch leaves agent-turn task rows unlinked until execution starts, records the callback session through the task progress API, stamps canonical cron rows with taskKind, and preserves childless canonical rows during cancellation. (src/cron/service/task-runs.ts:84, eef2967441d5)
  • Focused regression coverage: The branch tests current, isolated-with-source, and custom persistent session targets from an initial empty link through the runner-reported execution session, plus the canonical childless cancellation case. (src/cron/service/task-runs.test.ts:173, eef2967441d5)
  • Feature-history routing: Current-line blame attributes the pre-run session inference to commit 80c187b; Peter Steinberger has extensive recent cron/task-registry history and authored both commits on this repair branch. (src/cron/service/task-runs.ts:70, 80c187b8667d)
  • Real behavior proof and current status: The PR body reports an exact-head Testbox run with an isolated built Gateway and public CLI that observed a running cron task change from the creator session to the runner’s exact session before completion; the provided check context reports successful Real behavior proof runs. The checkout is clean, while GitHub reports the PR as mergeable but behind current main. (eef2967441d5)

Likely related people:

  • steipete: Peter Steinberger authored both repair commits and has a substantial recent history across cron and task-registry maintenance, including the active task inspection and cron ledger paths. (role: recent area contributor; confidence: high; commits: 404adc869031, eef2967441d5, a9f82837a1ef; files: src/cron/service/task-runs.ts, src/cron/service/timer-job-runner.ts, src/tasks/task-registry-cancel.ts)
  • Vincent Koc: Blame attributes the current active-task session inference to commit 80c187b, making this a useful routing contact for the behavior now being replaced. (role: current-line introducer; confidence: medium; commits: 80c187b8667d; files: src/cron/service/task-runs.ts)

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 (2 earlier review cycles)
  • reviewed 2026-08-01T23:13:50.819Z sha 404adc8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T23:28:03.249Z sha eef2967 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 1, 2026
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes exact-head real behavior proof from Testbox run 30723680725. It uses an isolated built Gateway, mock provider, public CLI task projection, and non-default ports to show the active task adopting the runner session key before completion.

@clawsweeper

clawsweeper Bot commented Aug 1, 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 repository_dispatch).
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 proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 1, 2026
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready maintainer validation is complete at exact head eef2967.

The repair now records the execution transcript only when the cron runner owns the exact session identity, keeps headless work childless, and records task kind separately so cancellation no longer infers lifecycle state from the presence of a presentation link.

Proof:

  • Focused Testbox run 30722526103 passed 81 of 81 cron and task assertions.
  • Exact-head CI run 30722762683 exposed the connected childless-cancellation invariant and prevented the narrower patch from landing.
  • Repaired Testbox run 30723047598 passed 178 of 178 timer and task-registry assertions.
  • Repaired exact-head CI run 30723167196 completed green, including openclaw/ci-gate.
  • Real-behavior Testbox run 30723680725 built the product and used the public CLI with an isolated Gateway and mock provider; the running task changed from the creator session to the runner exact session before completion.
  • Final whole-branch autoreview 019fbfa2-b05e-7ff0-a6f4-be30d1432aa0 was clean at 0.96, including TruffleHog.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 117679 completed successfully after refreshing current main and revalidated the review artifacts as READY FOR /prepare-pr with zero findings.

The latest ClawSweeper review is proof sufficient, 5 of 6, with no findings. Its final merge-head, sibling-session-state, and maintainer-handling moves are covered. Known proof gaps: none for the changed contract.

@steipete
steipete merged commit 34348d8 into main Aug 1, 2026
145 of 154 checks passed
@steipete
steipete deleted the codex/autoqa-cron-task-session-link-20260801 branch August 1, 2026 23:54
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* fix(cron): link tasks to execution sessions

Fixes openclaw#117678

* fix(tasks): preserve canonical cron cancellation state
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: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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.

[Bug]: Active cron tasks can link to the wrong execution transcript

1 participant