Repository navigation
fix(cron): keep scratch reads scoped to their current owner - #161387
Conversation
Move ordinary scratch reads through the existing shared-state reader. Bind private content to the same native job-definition snapshot and recheck the original source and caller before reply. Preserve first-use initialization through the canonical actor and the synchronous Doctor maintenance owner. Reuse the original creation-time fallback for legacy scratch read/write revision checks without overriding finite persisted values. Keep the existing write transaction, CAS, live grants and retained-outcome protocol. Qualify with causal SQL/privacy/legacy controls, 500 composed unique runtime cases, current core and 27 test type graphs, affected lint and architecture guards, clean independent review, runtime build and real Gateway restart flow. Retain the independently attributed unchanged UI max-lines failure separately.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 29, 2026, 7:14 PM ET / 23:14 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch moves private automation scratch reads to OpenClaw's SQLite read worker, checks job and caller scope before returning content, and preserves reads and writes for legacy jobs missing creation metadata. Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open. Current main still has the reported scratch-read path, and the merged write-side PR explicitly left reads for follow-up. The current head retains a distinct repair, with no blocking patch defect established in this review. Priority: P0 Review scores
Verification
How this fits togetherAutomation scratch is private per-job data in OpenClaw's shared SQLite state. Gateway requests and heartbeat preflight read it through the Cron service or read adapter before returning a result or adding context to a heartbeat. flowchart LR
A[Automation scratch request] --> B[Gateway caller check]
H[Heartbeat preflight] --> C[Scratch read adapter]
B --> C
C --> D[SQLite read worker]
D --> E[Job and scratch snapshot]
E --> F[Current authority check]
F --> G[Scratch result or refusal]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +219, Tests +321, Docs +7. Total +547 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep one authoritative job-and-scratch snapshot, refuse private replies after caller revocation or owner change, and let legacy jobs work without rewriting their stored rows. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source has an awaited scratch read after the initial Gateway scope check with no final caller recheck; the PR tests identify closure and peer-owner-transfer cases. This review did not execute the defect. Is this the best way to solve the issue? Yes. A single worker snapshot for the definition and content, followed by service and Gateway checks, is a bounded repair of the existing privacy contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 69d06b0b9c63. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Addressed the legacy-test clock finding: the test calls through the real SQLite load and pins only its transient creation-time fallback, then restores the call-through spy before the real scratch reads and writes. No polling, timer change, production seam, or weakened assertion remains. The whole scratch suite passes 20/20; removing either native fallback independently reproduces the intended read or write conflict. Fresh P0–P3 review is clean. The generated data-model flag is not applicable. No schema, persisted JSON shape, version, retention, or upgrade driver changes. The optional creation fallback is transient: a finite stored value always wins, and the test proves a later persisted definition change is rejected. Existing Doctor imports and maintenance kernels are unchanged. The earlier 31 Doctor cases and final built Gateway restart/persistence flow remain applicable because this follow-up changes only the fixture. No published-driver run is claimed. |
|
@clawsweeper re-review The clock finding is addressed in 1178a8c. The linked disposition records both causal fallback controls and the unchanged stored-schema/Doctor applicability boundary: #161387 (comment) |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…#161387) * fix(cron): keep scratch reads scoped across worker waits Move ordinary scratch reads through the existing shared-state reader. Bind private content to the same native job-definition snapshot and recheck the original source and caller before reply. Preserve first-use initialization through the canonical actor and the synchronous Doctor maintenance owner. Reuse the original creation-time fallback for legacy scratch read/write revision checks without overriding finite persisted values. Keep the existing write transaction, CAS, live grants and retained-outcome protocol. Qualify with causal SQL/privacy/legacy controls, 500 composed unique runtime cases, current core and 27 test type graphs, affected lint and architecture guards, clean independent review, runtime build and real Gateway restart flow. Retain the independently attributed unchanged UI max-lines failure separately. * test(cron): pin legacy scratch creation fallback
What Problem This Solves
Automation scratch reads can return private content after their caller closes or a peer changes the job owner, and they still execute SQLite on the Gateway thread.
User Impact
Scratch reads now use the existing worker and retain the original caller and job scope. Legacy jobs without creation metadata can read and update scratch without a false definition conflict. Wire results, schema, retention and Doctor's maintenance behavior stay unchanged.
Why This Change Was Made
The worker reads the job definition and scratch in one transaction. The service compares that definition with the authorized job, and the Gateway checks caller authority again before replying. Heartbeat preflight awaits scratch before selecting its session and pending events. First-use opening stays with the canonical mutable actor; the read worker owns no schema writes.
Reads and writes reuse the original projection's creation-time fallback only when the stored metadata is absent or nonfinite. Actual persisted values still win. The write transaction, revision CAS, live commit guards and retained outcome remain the same owners. Scratch handlers and their privacy regressions move into focused siblings with the existing worker routing.
Evidence
Causal controls reproduce caller-thread SQL, private responses after caller closure and foreign owner transfer, and the legacy read/write false conflicts. The repaired paths pass. Runtime coverage is 500 unique cases composed from 20 final scratch cases, 262 Gateway receiving cases and 218 unchanged owner cases retained from the earlier 495-case run; this is not one 500-case invocation. Core and all 27 test type graphs, affected typed lint, scripts lint, all three unused-export scans and architecture guards pass. Fresh independent P0–P2 production review and P0–P3 final test review are clean. The legacy regression now pins only the clock-derived fallback returned by the real load, without polling. Removing the read fallback or the write fallback independently still causes the intended definition-conflict failure.
The final runtime-only build passed in 112.796s. The real built CLI/Gateway flow passed scratch set/read, restart persistence, unset and stale-revision refusal, plus the existing scheduler scenarios (78.966s scenario; 139.924s command). The final deterministic 20-case scratch command took 42.946s and four-file Gateway command 94.483s. Local proof uses macOS arm64 and Node 24.21; command timings include compilation and different warm states, not a request-latency comparison. No local Linux, Bun or published-driver execution is claimed.
Broad core lint found an inherited UI max-lines violation in
ui/src/pages/model-setup/model-setup-page.ts(705 versus 700). Its blob is identical to the fixed base; the Cron change modifies no UI or lint policy. The failure is retained, the affected files pass, and the independent UI repair has its own owner.Current CI attempt 2 (run 36633755509) finished with two test failures and a separate boundary-job deadline. The Codex launcher loses late stderr after process exit; controlled real-launcher cases reproduce the defect on the exact main baseline and tested merge, with repair in #161419. The TTS fixture incorrectly requires nonempty response text after a warm snapshot restores the answer; independent main reproduces that predicate failure, and c90f579d fixes the fixture. These controls do not claim the exact uninstrumented CI event ordering or snapshot state.
The boundary job completed all 126 plugin compiles and its required canary, but GitHub cancelled the whole job at its 20-minute deadline. The measured budget correction is 5e5e50e8. Its cancelled conclusion remains recorded. Final accounting is 90 successful, 51 cancelled, 21 skipped and 3 failed jobs (the two test roots plus the aggregate); 50 cancellations belong to the Node matrix and the boundary deadline is separate. Cancelled or skipped work is not passing coverage. The initial queued attempt executed no steps during the Blacksmith outage; one same-head hosted rerun produced these results.
Stream-state writes, remaining creator/session currentness and Doctor/roster caller migration remain separate work in the original campaign.
Related: #161332.