Skip to content

refactor(cron): read run history through its worker - #158222

Merged
steipete merged 16 commits into
mainfrom
codex/taskflow-cron-owner
Sep 26, 2026
Merged

steipete merged 16 commits into
mainfrom
codex/taskflow-cron-owner

Conversation

@steipete

@steipete steipete commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Related: #156532

What Problem This Solves

Moves Cron run-history reads off the Gateway main thread and gives Cron its own history projection before the remaining Tasks runtime retires.

User Impact

cron.runs retains its response shape, filtering, pagination, retained history and access rules. Reads now recheck current authority, expiring self-management grants, job ownership and job names after awaiting the worker.

Tasks remains the sole writer, cancellation and retention owner for the existing rows in this batch. Database schema and stored-data interpretation are unchanged.

Why This Change Was Made

The existing Cron read-only worker reads the canonical rows through the existing Tasks decoder, then projects them into neutral Cron history records. One narrow adapter serves remaining Task callers; the native Cron codec owns presentation and paging. This is the prerequisite for moving Cron transcripts away from Tasks RPCs without introducing a second ledger or maintenance loop.

Evidence

  • 339 distinct scoped tests passed, covering the real reader/RPC, pagination, visibility, cancellation, recovery, retention and legacy import.
  • Revoked authority, expired self-management grants and changed job names were reproduced across the awaited read boundary and then passed with fresh publication facts. Negative controls fail when required post-read checks are removed.
  • Final RPC selection: 272 cases in 54.78s. Standalone measured files: history 51.47s, validation 86.02s and real RPC visibility 25.79s, including worker preparation.
  • Core and affected test type graphs, targeted lint, line-count guards, formatting and diff checks passed. Fresh independent review is clean through P2.

The later Cron writer/pruner cutover remains coupled to retirement of the old Task maintenance owner.

Follow-up CI cleanup removes an unused private failover type and makes the retained JSON type dependency explicit. Both full unused-code scans, core types, targeted lint, and fresh P2 review pass. Published-updater acceptance for retained Cron history has passed for both 9.4 and 9.6, with artifacts verified.

Published-driver upgrade proof was rebuilt after incorporating current-main Doctor/update changes. Package Acceptance 36219323700 passed both 9.4 and 9.6 cells with exact product/harness 8b693ecd25f277171c469b514cf3517f6547a4a3; the current head adds only an empty CI refresh. The 9.4 driver proves Doctor imports both retained legacy records; the 9.6 driver proves both native runs survive. Retained fields, filtering, pagination, and missing-run results match after update and candidate restart. Tarball SHA-256: 060e7404f95def474a4217878b9d309740807734c49197d3f74f98a844ae7baa. Verified baseline artifacts and complete post-merge proof.

Earlier runs and the fixture repairs remain described in the preceding evidence comment. They are not substituted for the rebuilt package. The sole merge conflict was an additive union of retained Cron/Webhooks diagnostic logs; 147 combined owner/harness cases, both affected type graphs, and fresh P2 review pass.

The remaining test-only failover type import now derives its identical union from the canonical constants. All 25 test type graphs and all three unused-code scans pass; assertion baselines only shrink for the deleted codec and simplified handler.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations size: XL labels Sep 25, 2026
@steipete
steipete marked this pull request as ready for review September 25, 2026 17:13
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 26, 2026, 2:33 AM ET / 06:33 UTC (Revision 17).

ClawSweeper review

What this changes

Moves scheduled-job run-history reads into Cron’s read-only SQLite worker, then filters and pages the existing records for Gateway clients.

Merge readiness

⛔ Blocked before merge - 1 item remains

Current main still reads Cron run history synchronously through Tasks, so this PR remains useful. The worker path preserves the history response and rechecks authority before replying. I found no introduced blocking defect, and published-updater acceptance passed for two released versions.

Priority: P2
Reviewed head: 405c8989c1c6573813aa6ba97cce7e2e413b07d6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Published upgrade proof is strong and the worker cutover appears correct; the broad refactor remains subject to ordinary exact-head merge gates.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The changed Cron worker and Gateway history path were exercised by published-updater package acceptance: released 2026.9.4 legacy rows and 2026.9.6 CLI-authored native runs retained their fields, filters, pages, and missing-run behavior after update and candidate restart. The proven product tree matches the current head. No stored-data contract changes; authority revocation is additionally covered at the handler response boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The changed Cron worker and Gateway history path were exercised by published-updater package acceptance: released 2026.9.4 legacy rows and 2026.9.6 CLI-authored native runs retained their fields, filters, pages, and missing-run behavior after update and candidate restart. The proven product tree matches the current head. No stored-data contract changes; authority revocation is additionally covered at the handler response boundary.
Evidence reviewed 8 items Current main still needs the change: The current-main cron.runs handler calls the synchronous Tasks-backed history reader; it has not adopted the proposed worker read.
Worker read boundary: The introduced worker reads canonical Cron task rows through the existing Tasks decoder and filters them by Cron store partition.
Authority at reply: After awaiting the worker, the Gateway checks current client and agent-run authority, then evaluates current job and session visibility before returning a history page.
Findings None None.
Security None None.

How this fits together

Cron schedules jobs and stores their run records in the shared Tasks database. The Gateway receives history requests from clients and returns records after applying current access and paging rules.

flowchart LR
  A[History client] --> B[Gateway Cron request]
  B --> C[Cron read worker]
  C --> D[Tasks SQLite records]
  D --> C
  C --> E[Current access and paging]
  B --> E
  E --> F[History response]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +140, Tests +351, Other +118. Total +609 across 67 files.

View PR surface stats
Area Files Added Removed Net
Source 19 355 215 +140
Tests 38 571 220 +351
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 10 128 10 +118
Total 67 1054 445 +609

Review metrics

Metric Value Why it matters
Source growth production +239 net lines; tests and proof +371 net lines The production growth supports the worker boundary and adapter, while the larger proof addition checks retained history and upgrades.
Published upgrade cells 2 passed Released 2026.9.4 legacy history and 2026.9.6 native runs were read back after update.

Stored data model

Persistent data-model change detected: migration/backfill/repair: scripts/e2e/lib/upgrade-survivor/diagnostics.mjs, migration/backfill/repair: scripts/e2e/lib/upgrade-survivor/legacy-operator-state.mjs, unknown-data-model-change: scripts/e2e/lib/upgrade-survivor/legacy-operator-state.mjs. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep Cron’s existing worker as the history read boundary, preserve the released cron.runs response and live access checks, and leave row writing and retention with Tasks until their separate cutover.

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

Not applicable: this is a refactor. Current main’s direct Tasks-backed history read and the branch’s worker entrypoint are source-verifiable.

Is this the best way to solve the issue?

Yes. Extending Cron’s existing read-only worker avoids a second ledger, while the Gateway applies current access rules after the awaited read.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 91264b958cf1.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded internal reliability and responsiveness improvement to a working Cron history flow.
  • merge-risk: 🚨 compatibility: The PR changes the reader for released, retained history rows; published-updater acceptance covers the two tested upgrade paths.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The changed Cron worker and Gateway history path were exercised by published-updater package acceptance: released 2026.9.4 legacy rows and 2026.9.6 CLI-authored native runs retained their fields, filters, pages, and missing-run behavior after update and candidate restart. The proven product tree matches the current head. No stored-data contract changes; authority revocation is additionally covered at the handler response boundary.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed Cron worker and Gateway history path were exercised by published-updater package acceptance: released 2026.9.4 legacy rows and 2026.9.6 CLI-authored native runs retained their fields, filters, pages, and missing-run behavior after update and candidate restart. The proven product tree matches the current head. No stored-data contract changes; authority revocation is additionally covered at the handler response boundary.

Evidence

What I checked:

  • Current main still needs the change: The current-main cron.runs handler calls the synchronous Tasks-backed history reader; it has not adopted the proposed worker read. (src/gateway/server-methods/cron.ts:1165, 91264b958cf1)
  • Worker read boundary: The introduced worker reads canonical Cron task rows through the existing Tasks decoder and filters them by Cron store partition. (src/cron/store/read-only.worker.ts:56, 405c8989c1c6)
  • Authority at reply: After awaiting the worker, the Gateway checks current client and agent-run authority, then evaluates current job and session visibility before returning a history page. (src/gateway/server-methods/cron.ts:1112, 405c8989c1c6)
  • Forbidden-client control: The handler test closes client authority during an awaited history read and requires no response for both job and all scopes; separate tests cover expired self-management and changed job visibility. (src/gateway/server-methods/cron.validation.test.ts:4300, 405c8989c1c6)
  • Published upgrade acceptance: Package Acceptance run 36219323700 completed successfully at product and harness SHA 8b693ec; its published-updater 2026.9.4 and 2026.9.6 jobs both succeeded. The linked PR discussion describes retained-field, filtering, pagination, and restart readback, with artifacts 10899685183 and 10899114669. (8b693ecd25f2)
  • Proof applies to current head: The accepted product source and current PR head have identical Git trees; later commits made no file changes. (405c8989c1c6)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (16 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-26T00:08:20.362Z sha dd6820d :: blocked before merge. :: none
  • reviewed 2026-09-26T01:08:56.508Z sha db0a3eb :: blocked before merge. :: none
  • reviewed 2026-09-26T01:20:06.201Z sha db0a3eb :: blocked before merge. :: none
  • reviewed 2026-09-26T01:49:12.995Z sha ca6f28f :: blocked before merge. :: none
  • reviewed 2026-09-26T02:33:05.492Z sha 848e538 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T03:36:01.146Z sha 2a353ce :: blocked before merge. :: none
  • reviewed 2026-09-26T04:40:23.823Z sha 8b693ec :: blocked before merge. :: none
  • reviewed 2026-09-26T06:11:32.338Z sha 744523d :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 25, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

The published-updater evidence is now running on the reviewed candidate in https://github.com/openclaw/openclaw/actions/runs/36175255389. Workflow and package identities both pin 7f27837.

Two cells cover the actual storage contracts: 2026.9.4 retained legacy history imported by candidate Doctor, and 2026.9.6 native history authored by its real CLI before upgrade. Both query the installed candidate Gateway for exact retained fields, run filtering and pagination. The harness preserves successful readback artifacts and has 66 focused passing tests plus a clean P2 review. This remains a pre-merge gate; no hosted pass is claimed yet.

CI type and shrink-only ratchet cleanup is also complete, with all 25 test type graphs and three unused-code scans passing.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Re-evaluate the unchanged reader against main after 7c4866c repaired the Team Reports test import. Production and upgrade-harness source remain unchanged.
@steipete

Copy link
Copy Markdown
Contributor Author

The latest merge-ref CI failure was an unrelated main regression: #157819 removed the Team Reports source barrel while its scheduler test retained the import. The same defect was reproduced on current main, then fixed directly under the repository's broken-main procedure in 7c4866c. The exact extension typecheck, all 36 scheduler tests, changed checks, and independent P2 review pass.

A fresh CI push will evaluate this PR against the repaired main. The reader product and upgrade harness remain unchanged from the Package Acceptance source 7f27837; the subsequent change only fixes a compile-only type-contract consumer.

Current head is 7f43a20; its latest commit changes no source and refreshes the failed merge-ref check after the upstream fix.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Sep 26, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 26, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

The retained-history upgrade requirement is now proven through both published drivers. The 9.4 cell passed in run 36175255389: the installed updater ran first, candidate Doctor imported two legacy records, and retained fields, run filters, pagination, and missing-run behavior matched after update and after candidate restart. The 9.6 replay passed in run 36197664173: two jobs authored and executed by the released CLI retained their native run IDs and complete fields through the same boundaries. Both used the verified product package built from 7f27837 (SHA-256 788ccac62377bd9212992833f9e8bff3789f9294af275e0629e5c8cf7e851c5a); the 9.6 replay harness was 6a6a5f9. Subsequent changes are test/tooling metadata and fixtures; this is scoped package evidence with separate product/harness identities.

The original 9.6 fixture failed before candidate installation because its default announcement had no Discord recipient. The executed fixture jobs now explicitly disable delivery; history assertions are unchanged. The final 9.6 proof artifact is 10891687468, SHA-256 c5ff89f2bcd3a58bcdfa12319e0ce04c01ae7b6df0a12ec69b46b00bb9110e8b.

Ordinary CI's original Bun Canary startup SIGSEGV remains unexplained. An exact-merge Linux replay passed all 92 Bun client cases, and the one exact-job replay passed in the original CI environment. Those passes show non-reproduction, not a claimed engine fix. Completing the cancelled coverage then exposed an inherited catalog test mixing fake timers with real performance.now(); a deterministic six-second monotonic-clock probe reproduced the exact failed host result. The fixture now uses one fake clock, preserving production deadlines and assertions. Focused tests, the 235-case catalog shard, scoped checks, and independent P2 review pass. The changed file costs 19.56 seconds wall; its optional benchmark remains skipped.

The next run caught one remaining stale Cron invalid-ID expectation. It now matches the canonical owner wording while retaining all three invalid-ID rejection cases. The original full file failed; all 13 cases pass after the correction in 18.54 seconds. Fresh P2 review is clean. Current-head ordinary CI remains the landing gate.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

The required post-merge package proof is complete: Package Acceptance 36219323700 passed both published 9.4 and 9.6 legacy-operator-state cells. Product and harness are both 8b693ecd25f277171c469b514cf3517f6547a4a3; independently hashed tarball SHA-256 is 060e7404f95def474a4217878b9d309740807734c49197d3f74f98a844ae7baa. We rebuilt because incoming main changed Doctor, migration and backup admission; the earlier package result was not treated as proof for those newer bytes.

Each actual released updater installed build 2026.9.6-8b693ecd25f2-2026-09-26T04-59-02.465Z. The 9.4 cell proves candidate Doctor imported both legacy rows through main's existing schema migration, with no malformed or skipped rows. The 9.6 cell preserves both CLI-authored native runs, with successful completion and delivery intentionally not requested. At both post-update and candidate stages, untruncated proof JSON confirms every retained field, exact run filtering, pagination, missing-run behavior, and identical readback pages.

Verified artifacts: 9.4 10899685183, SHA-256 b9443901d9747a2283d5886ef1442c9c26fe35d409c54a06b387c45d66b004c7; 9.6 10899114669, SHA-256 7cee7e93d433a5304c75f022b5c38673d6796a927262ba2f5f408ed9a4e70f49. Raw diagnostics retain their normal bounded/redacted omissions; structured history proof is complete.

The main-merge conflict was only the retained diagnostic-log list. Its resolution is the additive union of both parents' Cron/Webhooks proof files. All 147 combined owner/harness tests and both affected type graphs pass, with a fresh clean P2 review. No removal-specific schema change was introduced.

Ordinary CI exposed separate main-side Linux fixture and worker transfer races; those failures remain recorded, with reproduced owner repairs rather than weakened checks. Current-head CI remains required for landing.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 3c449bd into main Sep 26, 2026
228 checks passed
@steipete
steipete deleted the codex/taskflow-cron-owner branch September 26, 2026 07:07
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
* refactor(cron): read run history through its worker

* refactor(cron): clean up retired history type exports

* test(cron): finish history type and ratchet cleanup

* test(cron): prove published upgrade history reads

* test(cron): retain canonical failover type contract

* ci: refresh Cron checks after main import repair

Re-evaluate the unchanged reader against main after c54d53f repaired the Team Reports test import. Production and upgrade-harness source remain unchanged.

* fix(cron): complete wrapper cutover and upgrade diagnostics

* test(cron): complete source references and delivery-free upgrade seed

* test(codex): keep catalog progress on one fake clock

* test(cron): align invalid run id assertion with owner

* ci: refresh Cron checks after async task main repair

* ci: refresh Cron checks after main QA reference repair

* ci: refresh Cron checks after Linux fixture repair

* ci: refresh Cron checks after workspace quota repair

* ci: refresh Cron checks after main progress type repair
steipete added a commit that referenced this pull request Sep 27, 2026
Remove Tasks and TaskFlow runtime, APIs, CLI, SDK surfaces and panels after the Cron, session, native execution and media completion ownership cutovers. Preserve stored rows and import provable legacy native assignments through Doctor; ambiguous ownership stays untouched with a warning.

Follows #158221, #158217, #158225, #158222, #158702 and #158776. Related: #156532. Task-specific public APIs retire immediately; retained responsibilities use their existing owners.

Maintainer-authorized administrative landing after full CI run 36312986498 attempt 2 passed on 274595e, with subsequent actual conflicts reviewed and focused checks passing. Current PR CI preflight hits the 64 KiB changed-path metadata limit before tests (run 36335042695); its duplicate security-review status mirrors that planning failure. Review and scoped proof are recorded in the PR. Published 9.4 native import is proven; remaining native completion and 9.4 rollback witnesses are explicitly unproven.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
Remove Tasks and TaskFlow runtime, APIs, CLI, SDK surfaces and panels after the Cron, session, native execution and media completion ownership cutovers. Preserve stored rows and import provable legacy native assignments through Doctor; ambiguous ownership stays untouched with a warning.

Follows openclaw#158221, openclaw#158217, openclaw#158225, openclaw#158222, openclaw#158702 and openclaw#158776. Related: openclaw#156532. Task-specific public APIs retire immediately; retained responsibilities use their existing owners.

Maintainer-authorized administrative landing after full CI run 36312986498 attempt 2 passed on 274595e, with subsequent actual conflicts reviewed and focused checks passing. Current PR CI preflight hits the 64 KiB changed-path metadata limit before tests (run 36335042695); its duplicate security-review status mirrors that planning failure. Review and scoped proof are recorded in the PR. Published 9.4 native import is proven; remaining native completion and 9.4 rollback witnesses are explicitly unproven.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui cli CLI command changes commands Command implementations extensions: codex extensions: qa-lab gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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.

1 participant