Skip to content

fix(cron): offload read-only inspection outside native exclusions - #152500

Merged
steipete merged 63 commits into
mainfrom
codex/cron-readonly-actual-main
Sep 19, 2026
Merged

steipete merged 63 commits into
mainfrom
codex/cron-readonly-actual-main

Conversation

@steipete

@steipete steipete commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Prerequisite #151829 landed in 600657d52843417a69fd8b242839a7930bceaf2c. This update integrates captured main 2e053112b61f34964d4b0c360e3562c71f728e99 while preserving the original Cron feature patch.

What Problem This Solves

CLI and Doctor Cron inspection awaited a function that still opened, queried, and closed SQLite on the caller thread.

User Impact

Ordinary cold reads and artifact-preserving cold reads now run their SQLite work off the caller thread. Missing state remains absent, legacy layouts remain unmigrated, and admitted database errors retain their native categories. An already-held exclusive source scope retains its original synchronous host snapshot preparation; that native owner cannot transfer its drained source to another isolate.

Invalid non-file database targets now fail canonical lifecycle admission before opening SQLite. For a directory, the observed Node diagnostic changes from ERR_SQLITE_ERROR / disk I/O error to SQLite worker database path must identify a regular file. The five production callers do not branch on that native I/O code; their existing failure/warning behavior remains intact.

Why This Change Was Made

The existing Cron decoder runs in a bounded generic worker task. The shared snapshot owner allocates parent-known staging before dispatch, and cleanup waits for the source-copy process and reader worker to exit before retiring its token and removing copied bytes. Failed worker retirement or snapshot removal stays registered with the canonical lifecycle for explicit retry, including failures before a copied location is returned. Captured environment and generation admission survive asynchronous work. Schemas, retention, configuration, and public signatures are unchanged.

Evidence

The original entry failed both cold SQL-zero regressions. The main composition passes 160 selected tests: the original 140 caller and lifecycle cases plus 20 incoming backup, diagnostic, worker-CPU, and retirement controls. The nine Cron worker regressions cover SQL placement, missing/legacy state, native errors, generation drainage, worker retirement, and both formerly failing cold-copy cleanup cases.

Normal-build Node 24.21.0 and Bun 1.4.2 each pass ordinary and artifact-preserving A-B-A store-key reads in one process from an exited seeder: all caller-thread prepare/exec/close/get/all/run/iterate counts are zero, legacy bytes remain identical, and no snapshot artifacts remain. The queued-capacity environment proof passes.

Fresh P2 review is clean on the integrated main composition. The earlier non-file diagnostic finding and its source-backed rejection remain preserved; the resulting behavior is described above. The normal build, full repository check, and changed-scope gate pass on the integrated commit. Package boundary declaration generation emits 10,156 files successfully.

@clawsweeper

clawsweeper Bot commented Sep 19, 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 docs Improvements or additions to documentation size: L maintainer Maintainer-authored PR labels Sep 19, 2026
@steipete
steipete marked this pull request as ready for review September 19, 2026 04:44
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 19, 2026, 4:41 AM ET / 08:41 UTC (Revision 3).

ClawSweeper review

What this changes

Moves scheduled-job inspection into a bounded worker while preserving read-only behavior and retaining failed cleanup for retry.

Merge readiness

✅ Ready for maintainer review

This remains useful: current main still performs read-only Cron inspection on the caller thread. The revised head addresses the earlier integration concern, and this review found no actionable introduced defect.

Priority: P2
Reviewed head: c7d11a9816ab66f94944485e9a677552f2b3e721

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful lifecycle regressions and reported compiled-runtime validation; no blocking defect was identified.
Proof confidence 🌊 off-meta tidepool Not applicable: The provided maintainer classification exempts this PR from the external-contributor proof gate. Its captured body reports compiled Node/Bun runs through the changed reader, observing zero caller-thread SQL, preserved legacy bytes, and completed snapshot cleanup; these reports were not independently rerun.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The provided maintainer classification exempts this PR from the external-contributor proof gate. Its captured body reports compiled Node/Bun runs through the changed reader, observing zero caller-thread SQL, preserved legacy bytes, and completed snapshot cleanup; these reports were not independently rerun.
Evidence reviewed 8 items Current-main necessity: At fetched main, the read-only entry still directly opens SQLite, invokes the Cron decoder, and closes the database on the caller thread. The latest release source also retains this implementation.
Verified introduction and review continuity: The exact head records the earlier reviewed head and pinned main base as its two parents. The introduced delta is confined to Cron inspection, its tests, documentation, and worker registration. Comparing the earlier reviewed head with this head produced no changes to the Cron reader or worker. The supplied test merge is stale and was not used to infer merge-result behavior.
Admission and retryable cleanup: The parent captures admission before asynchronous work, registers its resource with canonical cleanup, waits for worker retirement and producer settlement before deleting snapshots, and retains registration and pins when cleanup fails. Admission is checked again before returning results.
Findings None None.
Security None None.

How this fits together

CLI and Doctor inspections read scheduled jobs from OpenClaw’s shared SQLite database. This change moves database opening, decoding, and closing into a worker, while the existing state lifecycle manages admission and cleanup.

flowchart TD
  A[CLI and Doctor inspection] --> B[Capture database admission]
  B --> C{Artifact preservation needed?}
  C -->|Yes| D[Existing snapshot owner]
  C -->|No| E[Bounded reader worker]
  D --> E
  E --> F[Decode scheduled jobs]
  F --> G[Join worker and clean resources]
  G --> H[Validate admission and return jobs]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +218, Tests +395, Docs +16. Total +629 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 271 53 +218
Tests 3 395 0 +395
Docs 1 18 2 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 684 55 +629

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +218 net lines; tests +395 lines Production growth implements worker admission and retryable cleanup while reusing the existing decoder and snapshot owners.

Technical review

Best possible solution:

Keep one Cron decoder and the existing snapshot lifecycle, with ordinary inspection off-thread and native exclusion preparation retained by its current owner.

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

Yes, from source: current main’s asynchronous inspection function directly performs synchronous SQLite opening, queries, and closing. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes. The patch moves execution through the existing worker infrastructure, reuses Cron decoding, and preserves native exclusion ownership without adding schema or configuration surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f9adf0b31ee3.

Labels

Label justifications:

  • P2: This is a bounded responsiveness improvement for CLI and Doctor scheduled-job inspection.
  • 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: The provided maintainer classification exempts this PR from the external-contributor proof gate. Its captured body reports compiled Node/Bun runs through the changed reader, observing zero caller-thread SQL, preserved legacy bytes, and completed snapshot cleanup; these reports were not independently rerun.

Evidence

What I checked:

  • Current-main necessity: At fetched main, the read-only entry still directly opens SQLite, invokes the Cron decoder, and closes the database on the caller thread. The latest release source also retains this implementation. (src/cron/store.ts:156, f9adf0b31ee3)
  • Verified introduction and review continuity: The exact head records the earlier reviewed head and pinned main base as its two parents. The introduced delta is confined to Cron inspection, its tests, documentation, and worker registration. Comparing the earlier reviewed head with this head produced no changes to the Cron reader or worker. The supplied test merge is stale and was not used to infer merge-result behavior. (c7d11a9816ab)
  • Admission and retryable cleanup: The parent captures admission before asynchronous work, registers its resource with canonical cleanup, waits for worker retirement and producer settlement before deleting snapshots, and retains registration and pins when cleanup fails. Admission is checked again before returning results. (src/cron/store/read-only.ts:88, c7d11a9816ab)
  • Existing decoder and native settlement: The worker invokes the existing decoder without a writer, preserving the no-migration path. Its native section encloses snapshot copying, SQLite reads, and close; the shared pool waits for that section before terminating the worker. (src/cron/store/read-only.worker.ts:30, c7d11a9816ab)
  • Regression and runtime evidence: The supplied complete tests cover nine cases across SQL placement, absent and legacy databases, native errors, drainage, and failed worker/snapshot cleanup. The captured PR body reports 160 passing selected tests and compiled Node 24.21.0/Bun 1.4.2 ordinary and artifact-preserving A-B-A reads with zero observed caller-thread SQL calls, unchanged legacy bytes, and no remaining snapshots. These are contributor-reported results; this review did not execute tests or builds. (src/cron/store.readonly-worker.test.ts:13, c7d11a9816ab)
  • Prerequisite is distinct: The supplied GitHub metadata verifies that refactor(state): move fixed-read snapshot coordination off the main thread #151829 merged as 600657d. It supplies shared snapshot coordination; current-main source confirms that it did not complete this Cron read-only cutover. (600657d52843)

Likely related people:

  • steipete: 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 (2 earlier review cycles)
  • reviewed 2026-09-19T04:50:56.494Z sha 219fba3 :: blocked before merge. :: none
  • reviewed 2026-09-19T07:02:34.209Z sha 219fba3 :: blocked before merge. :: none

Base automatically changed from codex/sqlite-snapshot-token-fleet429 to main September 19, 2026 06:55
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts fleet size: XL and removed size: L labels Sep 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed scripts Repository scripts fleet size: XL labels Sep 19, 2026
@steipete
steipete merged commit 49b3315 into main Sep 19, 2026
217 of 219 checks passed
@steipete
steipete deleted the codex/cron-readonly-actual-main branch September 19, 2026 12:40
@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 20, 2026
…enclaw#152500)

* perf(fleet): run registry operations in SQLite workers

* fix(state): preserve readonly admission error context

* test(gateway): retain catalog root failure diagnostics

* fix: preserve uncertain lease outcomes before caller recovery

* fix(state): reject retired read scopes and retain wrapper imports

Reject new admissions to closing or closed selected read scopes while keeping already-admitted readers owned through cleanup. Preserve typed invalidation at plugin discovery boundaries.

Include the retained-read eager dependencies in the canonical PR wrapper inventory.

* test(state): require rejection of retired read scopes

Update the three existing disposable-scope variants to expect the canonical
admission error while preserving active and unrelated source assertions.

* fix(state): keep ordinary reads in the SQLite worker

Use the existing independent readonly worker for ordinary fixed reads while
retaining cached writer custody. Validate captured file identity around opens
and acceptance, and bind previously missing paths when their first file appears.

Keep selected snapshots and native preparation scopes with their existing owners.

* fix: catalog refresh fails when previous discovery finishes

Retain selected plugin registries through awaited preparation and hand construction claims to the completed generation. Preserve stale-publication cleanup and borrowed Gateway-root ownership. Related: openclaw#151588, openclaw#148290.

* fix(test): retain Telegram suite output on subprocess errors

* fix(ci): require full compact proof for worker policy guards (openclaw#151427)

Fix compact CI policy guards that confused a two-worker budget with a parallel-to-serial transition. Preserve inherited job ceilings on already-serial recipients and reject redundant group-policy rewrites.

Select the complete compact plan on Blacksmith and hybrid runs when the owning planner-policy test changes; keep GitHub targeting precise. Production admission-before-placement, worker limits, and measurements remain unchanged.

Validation: focused host-profile and policy cases, serial-policy negative controls, and exact-head CI run 35343663468 passed. ClawSweeper and the retained scoped review found no actionable defects. No user-visible runtime change.

* refactor(state): move fixed-read snapshot tokens off the main thread

* perf(gateway): materialize archived session rows on demand (openclaw#151574)

* fix: avoid host-speed failures in catalog performance checks (openclaw#151732)

Replace the catalog benchmark's host-dependent 20 ms median limit with 20 times an independent in-process CPU reference. Check every composed list for exactly 20 SQLite reads, including three binding-authority reads, and zero plugin-state worker operations, while preserving the existing native-RPC, file-I/O, and session-payload guards.

This is a test reliability repair with no runtime or update behavior change. Production changes: 0 lines; tests and test support: +61/-7 across two files.

Validation: exact-head CI is green; the reviewed proof includes five passing local runs, two-CPU Testbox and hosted calibration, an extra-SELECT negative control, and a uniform CPU slowdown that fails the independent timing guard. Round-2 Codex autoreview and exact-head ClawSweeper review found no actionable defects.

* test(gateway): match catalog read budget to binding owner

* test(codex): synchronize agent-end context scenarios

Own the fixture clock and wait for turn start and ten response progress
events before selecting completion, cancellation, or refusal. Keep the
five-second budget and require the expected terminal outcome.

Restore real timers before cancelling and joining the run so a failed
assertion cannot discard cleanup deadlines.

Validation: 62 agent-end, deadline, and lifecycle tests; extension test
types; scoped lint and format; independent P2 review. A temporary assertion
failure also verified cancellation, unsubscribe, and joined cleanup.

* test(state): intercept asynchronous snapshot preparation in lifecycle controls

* fix(sqlite): name scoped worker declaration return type

* fix(cron): offload read-only inspection outside native exclusions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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