Skip to content

refactor(cron): deslop shared history ordering - #160897

Merged
steipete merged 1 commit into
mainfrom
hostneutral/cron-history-order-0928
Sep 29, 2026
Merged

steipete merged 1 commit into
mainfrom
hostneutral/cron-history-order-0928

Conversation

@steipete

@steipete steipete commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cron history pages, retention, and recovery repeated the same recency order in three modules, allowing their timestamp and tie-break rules to drift.

User Impact

No deliberate behavior change. History ordering, retention thresholds, exact-receipt recovery, and recovery's separate preference for unfinished runs are preserved.

Why This Change Was Made

The existing timestamp owner now also owns newest-first record comparison. Paging, retention, and recovery consume that comparison; ascending pages reverse its direction. A small page-level table test covers timestamp precedence and creation/id ties in both directions.

Evidence

  • Production +21/-25/net -4; tests +22/-0/net +22; docs +0/-0/net 0 against merge-base.
  • Independent Codex autoreview: scoped-clean through P2. Fresh-main rebase retained byte-identical reviewed source.
  • Focused Testbox proof: 37 tests passed across two files, using pnpm test <file> --maxWorkers=1 on tbx_01m3nadhyxv9k98c5g1hhk2nw1, exact head 3b474a5638609efca4b9efe8a785fcbe0076332f materialized from its verified Git bundle in an isolated checkout.
  • Test cost: pnpm test src/cron/run-history.test.ts --maxWorkers=1 passed 10 tests in 37.13s wall; pnpm test src/cron/run-history-detail.test.ts --maxWorkers=1 passed 27 tests in 36.58s wall. The existing history suite covers worker-backed persistence, retention and exact-receipt recovery; the two added cases are pure in-memory page projections with no new fixture, import, timer, or process. CI timing will be recorded once available.
  • Exact-head CI passed production types, test types, guards, security-fast, and the selected tests. The failing owner job is core lint: untouched src/gateway/talk/relay/session-create.ts is 702/700 lines and untouched src/gateway/server-methods/sessions.dispatch.device.test.ts is 1002/1000. A clean detached main checkout at 4187710037fc88b467b9a6017c069c833e6d6f10 reproduced both exact errors on Testbox tbx_01m3njdxea14ksvwtdhc0h0rmz with node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <the two files> (10.2s). CI linted the merge ref, including main's newer device-test additions. These inherited size failures qualify for the requested pinned-head admin exception. The duplicate Testbox type pass was stopped after exact-head hosted type/guard/security checks passed; its partial run is not claimed as a full changed-gate pass.

Merged with the documented pinned-head admin exception as 27aa6213dfaad8223b8d8b3df55799358037729e; main ancestry and reviewed patch identity verified.

Correction from the complete CI log: core lint also reported an introduced oxc(no-map-spread) error in the new test fixture, omitted from the annotations used in the initial summary. Concurrent main repair 743c2ceb72e replaced that fixture builder and preserved its assertions. This error was caused by this PR and is not covered by the inherited-size exception. A duplicate candidate was independently reviewed and passed focused lint (14.27s) and 10 tests (31.17s), then discarded in favor of the landed main repair. The two added CI cases took 0.004s and 0.002s in run 36512203161.

@clawsweeper

clawsweeper Bot commented Sep 29, 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.

@steipete
steipete enabled auto-merge (squash) September 29, 2026 02:24
@clawsweeper

clawsweeper Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

Cron history paging, retention, and recovery use one newest-first record comparison, with tests for ascending and descending pages.

Merge readiness

✅ Ready for maintainer review

Current main has not absorbed this work. The shared ordering appears equivalent for normalized cron records, and this review found no blocking defect.

Priority: P3
Reviewed head: 3b474a5638609efca4b9efe8a785fcbe0076332f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The small refactor has coherent consumer changes and focused ordering coverage, with no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored internal refactor changes cron history ordering across paging, retention, and recovery. The PR reports exact-head focused Testbox tests; the external-contributor real-setup gate does not apply, and no stored-data shape changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored internal refactor changes cron history ordering across paging, retention, and recovery. The PR reports exact-head focused Testbox tests; the external-contributor real-setup gate does not apply, and no stored-data shape changes.
Evidence reviewed 6 items Introduced comparison: The new comparator uses the existing timestamp resolver, then creation time and record ID as tie-breakers.
Consumer behavior: Paging reverses the shared order for ascending requests; recovery retains its separate preference for unfinished records, and retention uses the same newest-first comparator.
Current-main necessity: Current main still contains a separate paging comparator; its recovery and retention files also retain their own timestamp and tie-break expressions.
Findings None None.
Security None None.

How this fits together

OpenClaw stores automation run records in shared SQLite state. Gateway requests page those records, while maintenance prunes old history and recovery identifies completed runs.

flowchart LR
A[Automation runs] --> B[SQLite run records]
B --> C[Shared recency order]
C --> D[Gateway history pages]
C --> E[History retention]
C --> F[Run recovery]
F --> G[Recovered result]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -4, Tests +22. Total +18 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 4 21 25 -4
Tests 1 22 0 +22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 43 25 +18

Review metrics

None.

Technical review

Best possible solution:

Keep one record-ordering rule for the three cron consumers while preserving their existing paging, retention, and exact-receipt recovery contracts.

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

Not applicable: this refactor reports no failing user flow. Source comparison and the added page cases provide the relevant ordering check.

Is this the best way to solve the issue?

Yes: the existing timestamp owner is a narrow home for the shared comparison, and the consumers retain their distinct rules.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3b5043053a91.

Labels

Label changes:

  • add P3: This is a bounded internal cleanup with no intended user-visible behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is a bounded internal cleanup with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

@steipete
steipete merged commit 27aa621 into main Sep 29, 2026
218 of 221 checks passed
@steipete
steipete deleted the hostneutral/cron-history-order-0928 branch September 29, 2026 03:27
steipete added a commit that referenced this pull request Sep 29, 2026
#160897 (27aa621) built the ordering fixture with a spread inside
.map, which oxlint's no-map-spread rejects; check-lint-core-1 failed on
hourly 36518039325 at src/cron/run-history.test.ts:65.

Build each record through a small typed factory instead. The records,
their order, and every assertion are unchanged.

Proof: oxlint clean on the file; run-history.test.ts 10/10.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
Centralize recency ordering for history pages, retention, and recovery while preserving timestamp precedence and tie-breaks.

Validation: 37 focused tests and independent P2 review passed. Exact-head CI types, guards and security passed. The admin merge exception covers only two unrelated max-lines failures reproduced on clean main 25055f0; evidence is recorded in the PR body.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
openclaw#160897 (b1b7546) built the ordering fixture with a spread inside
.map, which oxlint's no-map-spread rejects; check-lint-core-1 failed on
hourly 36518039325 at src/cron/run-history.test.ts:65.

Build each record through a small typed factory instead. The records,
their order, and every assertion are unchanged.

Proof: oxlint clean on the file; run-history.test.ts 10/10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant