Skip to content

fix(memory): prevent Forget worker OOM on large live transcripts - #180286

Closed
roboclaw-bot wants to merge 8 commits into
mainfrom
openclaw/mem-b1-g1-forget-bounded-repair
Closed

roboclaw-bot wants to merge 8 commits into
mainfrom
openclaw/mem-b1-g1-forget-bounded-repair

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #176243

What Problem This Solves

Fixes a worker out-of-memory failure when Memory Forget inspects a large live SQLite transcript containing original messages.

Memory impact

Historical matched benchmark: 59.67% lower median sampled process-tree PSS high water — 2,070,743,040 → 835,210,240 bytes (1.93 → 0.78 GiB; 1,178.3 MiB less). This is the median of five per-run sampled maxima, not steady-state memory or a true peak.

Current PR candidate: memory reduction NOT MEASURED. Those five interleaved pairs measured an older pre-extraction candidate, before helper relocation, CI metadata repairs and main integration changed shared worker/dependency inputs. They are historical evidence, not performance acceptance for this head.

  • Workload: real compiled offline Memory Forget CLI preview, synthetic ASCII transcript, 34,401 events / 463,059,747 JSONL bytes; Node 26.12.1, unchanged 512/32 MiB worker limits. Nominal 25 ms sampling sums observed process-tree PSS, including the timing wrapper; Worker-thread RSS is not added.
  • Main-isolate heap reduction, whole-process RSS reduction and true-peak reduction: NOT MEASURED by this comparison. No percentage for those metrics or for general workloads is claimed.
  • Tradeoff: a 463,162,950-byte private temporary export (about 442 MiB), removed on normal completion; crash leftovers remain possible.
  • The earlier cohort still FAILED both wall/CPU STOP thresholds (candidate 27.356 s / 16.74 s CPU versus baseline 6.914 s / 8.60 s CPU). Later pairs do not erase that failure or establish its cause; the original archived incident remains unproved.

Exact historical patch/workload bindings, all five paired values, method limits and retained failures are in Evidence below.

User Impact

Users can inspect/forget large live-session history without a full decoded worker reply, preserving snapshot/reset/provenance/failure ordering. No heap-limit, schema, config, or retention change.

The operation uses temporary disk proportional to the transcript: the measured fixture needs a 463,162,950-byte private export (463,163,392 allocated bytes, about 442 MiB). Normal completion removes it; a process crash can leave that private export behind. The exact archived transcript from the issue is unavailable, so this PR does not claim to reproduce or resolve every retained-archive failure.

Why This Change Was Made

The existing export owner captures an immutable snapshot under its fence/version contract. The acknowledged exchange returns a compact descriptor. Native reader settlement and validation precede callbacks. Replay preserves originals/order; archive/incognito/public array contracts are unchanged.

Operation-local writer/reader buffers grow as needed and use initialized prefixes, eliminating per-record churn and combining frame writes. No global cache, mutable-page callbacks, heap increase, or skipped native join.

Evidence

  • Regression proof: the base original-snapshot worker reply exceeded the 4 KiB contract (74,283 bytes); the bounded-source candidate returned a 260-byte descriptor while preserving callback snapshot semantics.

  • Pre-buffer product proof: Unicode/equal-byte ASCII sources, each 34,401 events / 463,059,747 JSONL bytes, actual 512/32 MiB limits. Preview/apply/repeat/since/refusal preserved source/control/origins/tombstones. Prior-head evidence, not a revised-head large-Unicode/model/Gateway run.

  • Revised-head focused proof: 63 tests across nine affected files passed, including real-worker snapshot, callback/reset/read-hold/custody paths. The new framing regression is red before buffer reuse and green after it: exact independent Unicode framing, long-to-short records, independent yielded objects, short I/O, and a truncated tail. Three frames plus a forced short write used one writer backing store / four writes; replay used header and payload stores / eight reads including short read and EOF. Only the narrow framing test mocks its database I/O source.

  • Scoped production/test typechecks, typed lint, formatting/whitespace checks, and the canonical build passed. The build retained its existing nonfatal locale-size diagnostic. Broad exact-head CI is reported separately by GitHub, not inferred from local success.

  • Normal hooks moved two helpers byte-for-byte into the already-imported projection sibling; 41 consumer tests, types, lint and hooks passed. Build/cost evidence predates that move and main integration.

  • Integration follow-up: merged main 4d294053ad54, including fix(ci): require native-subagent authority coverage #180315’s native-subagent expectation fix, and repaired the newer scheduled-turns expectation from feat(plugins): let requester commands schedule bounded follow-up turns #180282. That case failed before the one-line fix; six affected cases and 33 transcript tests then passed, plus targeted types/lint/format. Candidate review: 19 partitioned passes, no actionable findings; static only. Old CI run 39722865071 remains failed; new-head CI is separate.

Completed revised-candidate cost comparison

Five predeclared interleaved pairs ran once each: no warmups, discarded/replaced samples, or forced GC. Once-seeded variants matched transcript/table/control facts, normalized config/runtime/time/workload hashes. Real compiled offline CLI preview retained worker limits. All functional/protected-state/default-limit/process-settlement/cleanup checks passed.

Pair Baseline wall ms Candidate wall ms Baseline waited CPU µs Candidate waited CPU µs Baseline observed tree-PSS B Candidate observed tree-PSS B
1 6656.329451 4315.143755 8260000 6730000 2116646912 835210240
2 5267.495488 4256.881545 8080000 6800000 2051841024 837079040
3 5039.606078 4209.454111 7720000 6820000 2060108800 819704832
4 6039.779969 5029.855176 8310000 7640000 2089146368 835561472
5 7723.621762 5821.617906 9260000 8030000 2070743040 789981184

Written gate: stop immediately if candidate paired wall or waited CPU exceeds baseline by more than 20%, or functional/default-limit/coverage/cleanup checks fail. Require median and nearest-rank p95 wall/CPU to hold or improve, and median observed-PSS reduction of at least min(5 MiB, 2% of baseline median). All five pairs pass. Median wall improves 28.55% (6039.779969 → 4315.143755 ms), CPU 17.43% (8260000 → 6820000 µs), and observed PSS 59.67% (2070743040 → 835210240 B). Median PSS reduction is 1,235,532,800 B versus the 5,242,880 B floor. Nearest-rank p95 with n=5 is the maximum: wall 7723.621762 → 5821.617906 ms; CPU 9260000 → 8030000 µs; PSS 2116646912 → 837079040 B.

Limits: nominal 25 ms sampled tree-PSS is observed high water, not true peak. GNU Time user+system covers waited descendants, not orphan/cgroup-total; Node exit CPU only crosschecks it. Known timing-wrapper PSS is included; Worker RSS is not added. A5 maximum interval was 57.297481 ms versus candidate maximum 26.054988 ms. All gaps/variable loads retained, no filtering/noise waiver. Five pairs do not establish population tails. Both used current Node 26.12.1, not the earlier failed cohort runtime.

Earlier failed comparison remains failed

Before buffer reuse, a separate first pair measured baseline 6913.909567 ms / 8600000 µs CPU versus candidate 27356.483281 ms / 16740000 µs. Both +20% STOP thresholds fired. That cohort remains failed, never replaced. Excess wall followed an early JS exit marker; later-JS/native teardown cause is unidentified. Two unscored diagnostics did not reproduce it and were not clearance. New qualification does not prove buffers/runtime caused the old tail.

Independent review completed four P0–P3 passes with all 15 pre-extraction files supplied in full plus unchanged owners; context was partitioned, not all modules in each pass. Native findings / exit 1 remains: four P2 entries described ONE qualification gap, addressed by independently crosschecked five-pair evidence. No other actionable functional/security defect established.

Historical benchmark provenance and cleanup

The task-specific 612-line benchmark harness has been removed from this PR's current diff; production code and product-boundary regression tests are unchanged by that cleanup. Results remain above, including the failed cohort and measurement limits. No replacement benchmark PR or new benchmark run was made.

Cleanup verification: the only source change from pre-cleanup 0794052e2497 is deletion of that harness; every retained production and regression-test blob is identical. Reference/whitespace checks, normal commit hooks and a fresh P0–P3 deletion review passed. The PR shrank from 20 files (+1,432/−125) to 19 (+820/−125). An installed npm 11.20.0 pack --dry-run --ignore-scripts --json inventory listed 15,617 files with zero matches for the removed harness or scripts/perf/. It ran no lifecycle scripts, wrote no tarball and did not build; it checked the current package manifest against existing older dist artifacts, not fresh release packaging or runtime behavior.

The exact historical harness is retained in pre-cleanup commit 0794052e2497db6e0c76d47a6d31b02c7b1cea65, SHA256 56ec30ac3e7acd02a76184fa4257741f9480d8778251ac8cac00671764e9688f. That commit preserves the harness, not a claim that its integrated production tree was benchmarked. The measured production patch is bound separately below. Historical raw receipts, the failed cohort and two unscored diagnostics remain retained privately; no private logs or heap data are published.

Measured pre-extraction full-patch SHA256 1725077016f16ea7c5c4dbbb4bdbc7e934bc8429b0c1ef11457c6aaa4e1e1ea0; workload 56ec30ac3e7acd02a76184fa4257741f9480d8778251ac8cac00671764e9688f. Build/cost results predate helper relocation, CI metadata repairs and main 4d294053ad54 integration. Shared worker/dependency inputs changed: these are NOT measurements of this integrated head. Synthetic origins prove purge selection, not model promotion. Populated-vector purge uses existing tests, not this fixture. No new large-Unicode product run, exact archived-incident reproduction, crash-leftover cleanup guarantee, or merge/CI approval is implied.

Worked on by

Work sessions

roboclaw-bot and others added 2 commits October 22, 2026 04:13
Capture and validate an immutable original-message source before callbacks, with bounded worker exchange and operation-local framing buffers.

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: e56228fa-9134-4724-af94-35f30ce5069e
@clawsweeper

clawsweeper Bot commented Oct 22, 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 scripts Repository scripts size: XL labels Oct 22, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 22, 2026 04:16
roboclaw-bot and others added 2 commits October 22, 2026 04:30
Include the prepared source in extracted wrapper imports, retire the removed assertion allowance, document framing-test isolation, and track the existing worker-owned read operation after its private-kernel extraction.

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 9b9b27aa-8cb8-4e46-88cd-60b0d1a6738e
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces full original-message worker replies with a private temporary export that is validated and replayed incrementally.

Example: Memory Forget inspects the 34,401-event forget-bench-ascii transcript.

  • Before: The worker retains and returns the complete decoded original-message snapshot.
  • After: The worker returns compact metadata while the caller replays a 463,162,950-byte private export and removes it after consumption.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A coherent repair with production-entry evidence and distinct regression coverage; readiness remains scoped to the live-transcript subset of the linked report.
Proof confidence 🐚 platinum hermit (4/6) This collaborator-authored PR is outside the ordinary contributor proof gate; its body reports compiled offline CLI preview and earlier apply/repeat/refusal runs at default worker limits, with focused worker regressions after integration, while explicitly limiting large-workload measurements to an earlier revision.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Memory Forget can exhaust its transcript worker while inspecting one large live session.
Reason: The maintainer-authored direction repairs a demonstrated allocation without raising heap limits; Related wording correctly preserves the broader retained-archive report.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a distinct live-transcript allocation still present on main; no actionable introduced defect was found.

Priority: P2
Reviewed head: 0794052e2497db6e0c76d47a6d31b02c7b1cea65

Before merge

None.

Findings

None.

Agent review details

How this fits together

Memory Forget uses the memory host’s transcript reader to collect curated-write provenance before planning deletion; this change bounds original-message transfer between the database worker and that reader.

flowchart TD
A[Memory Forget] --> B[Memory host reader]
B --> C[Transcript worker]
C --> D[Versioned SQLite export]
D --> E[Private framed export]
E --> F[Validation and incremental replay]
F --> G[Provenance collection]
G --> H[Export cleanup]
Loading

Technical review

Best possible solution:

Land the bounded original-message export while keeping the unavailable retained-archive case tracked separately.

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

Current source confirms the full-original snapshot allocation, and the supplied regression demonstrates oversized worker replies; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The change fixes the allocation at the existing export owner while preserving immutable snapshot, reset, provenance, and callback ordering contracts.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Worker-owned original-message snapshots keeps the original intent (1ebb24d: Move durable snapshot and SDK reads off the Gateway thread while preserving callback semantics.)
  • Sliced export consistency keeps the original intent (471a768: Release SQLite read snapshots between bounded payload slices and fall back to a whole snapshot when the transcript version changes.)
  • Reset recall boundaries keeps the original intent (a9ee661: Separate prior private conversation generations while rejecting malformed or crossing reset boundaries.)
  • Direct record consumption keeps the original intent (3fb0ba1: Avoid duplicate transcript representations while preserving raw ordinals, provenance, and observer ordering.)
  • Parsing yields keeps the original intent (482af6d: Keep large session ingestion from starving the Gateway event loop.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1ebb24d adds src/config/sessions/session-transcript-hydration-read.worker.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1ebb24d4fbd5; files: src/config/sessions/session-transcript-hydration-read.worker.ts)
  • Mitchell Etzel: Raw commit 471a768 adds src/config/sessions/session-accessor.sqlite-export-slices.ts:110 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 471a768fa058; files: src/config/sessions/session-accessor.sqlite-export-slices.ts)
  • Vitor Cepeda Lopes: Raw commit a9ee661 adds packages/memory-host-sdk/src/host/session-reset-recall.ts:38 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a9ee6618fe64; files: packages/memory-host-sdk/src/host/session-reset-recall.ts)

PR surface

Source +371, Tests +321, Other +615. Total +1307 across 20 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 11 468 97 +371
Tests 5 347 26 +321
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 4 617 2 +615
Total 20 1432 125 +1307

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair addresses a large-session memory-maintenance failure without evidence of a broader runtime outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-22T05:00:38.715Z sha 7ce0d46 :: needs maintainer review before merge. :: none

Reviewed October 22, 2026, 3:10 AM ET / 07:10 UTC (Revision 2).

roboclaw-bot and others added 2 commits October 22, 2026 07:02
Merge main at 4d29405 to include the landed native-subagent owner correction. Include the newly observed scheduled-turns authority consumer in the same owner expectation.

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: afa2faa5-0b5a-4df3-b24b-c1a31967d888
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
roboclaw-bot and others added 2 commits October 23, 2026 05:48
Keep historical results and source bindings in the PR description; preserve the bounded-export fix and product-boundary regressions.

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: e09ad30b-f87c-4610-98fb-007da9f89cbc
steipete added a commit that referenced this pull request Oct 25, 2026
An explicit cron run reads its authorized job definition and private scratch separately inside a SQLite read transaction. Read both in one dialect-layer LEFT JOIN so they share a statement snapshot, removing three SQL statements per SQLite run without another worker request.

The job reader keeps its all-column authorization relation, ordered narrow projection, exact returned-ID check, existing decoder/config revision and legacy creation fallback. Missing scratch still reports revision 0; deletion keeps its revision tombstone. The standalone maintenance reader remains. No schema, cache, write, receipt, claim-before-effect, delivery authority, FIFO or 64-receipt retention change.

PostgreSQL retains the shared reader's outer read-only transaction and rollback: its exact-job read is 4→3 SQL, not 4→1. SQLite exact-job is 4→1, heartbeat 3→1; PostgreSQL heartbeat remains 3→3. Accepted noncontract edges: an absent/malformed job can now require scratch SELECT privilege, and malformed job plus unsafe numeric scratch can reject the numeric data first. These do not remove the existing caller/source/cancellation checks.

The production delta is +3 lines: one joined query replaces the transaction and duplicate read while sharing NULL handling with heartbeat. Existing test files cover read-after-write, tombstones, missing jobs/monitors and both database engines. No new suite or runner is added.

Acceptance was registered before measurement: the committed `scripts/bench-cron-run.mts` drives signed WebSocket `cron.run` against an isolated synthetic Gateway/provider, once cold and twice warm. Each run must produce one start, one finish, one Responses request and exact-run history verification. Compare execution, history verification and settlement separately and together, plus shutdown and the entire invocation. The scratch owner must fall from 4→1 SQL with 1 request and 0 MAIN throughout; no cost may be deferred outside the run. Keep cold/warm separate and report median/p95/range. Three same-platform alternating pairs when calm, or one pair plus source attribution under campaign load. Counts and profiles make no latency/CPU-speed claim; timing claims require the timing lock, load below 24 and ≥5 alternating samples per arm. A 20% user-facing regression stops acceptance. Delivery mode none does not claim an external-send proof.

The same-platform explicit comparison (baseline 814e732, candidate 93a6c4) gives:

| SQL / requests / MAIN | Baseline | Candidate |
| --- | --- | --- |
| Cold execution + verification + settlement | 257 / 80 / 0 | 254 / 78 / 0 |
| Warm 1 | 247 / 64 / 0 | 235 / 60 / 0 |
| Warm 2 | 252 / 61 / 0 | 245 / 65 / 0 |
| Warm median | 249.5 / 62.5 / 0 | 240 / 62.5 / 0 |
| Warm descriptive p95 | 252 / 64 / 0 | 245 / 65 / 0 |
| Warm range | 247–252 / 61–64 / 0 | 235–245 / 60–65 / 0 |
| Shutdown | 22 / 6 / 5 | 40 / 10 / 5 |
| Whole invocation | 1383 / 356 / 58 | 1369 / 352 / 58 |

Each of the three runs completed one start, finish, Responses request and exact history verification. The scratch owner is exactly 4/1/0 → 1/1/0 in every run, all in its execution phase, with no extra or deferred scratch requests. All execution/verification/settlement phases are SQL-error-free and runtime MAIN remains zero. The count comparison is diagnostic, not an error-free full invocation: the frozen analyzer rejects two failed shutdown `state_leases` DELETEs (`database is locked`). Shutdown exceeds the 20% stop threshold; it was stopped and explicitly accepted by the coordinator as inherited after an independent main shutdown-lock reproduction. The separate SHUTDOWNLOCK lane owns that repair. The scratch join changes no lease code or writes. No latency or CPU-speed claim is made.

The frozen 3.1.5 standard workload is a different scheduled `cron.add` flow: three valid baselines gave 06.cron 231/62/0, 235/65/0, 233/63/0 (median 233/63/0), versus ordinary warm 45/12/0. The descriptive excess is 188 SQL/51 requests, not causal subtraction. One extra standard setup aborted before any Gateway; it supplies no performance evidence. The existing scratch source is identical across that baseline and the explicit baseline. Full current-standard delta is deferred to the next census.

Validation: count regression red on baseline (2 SELECTs and BEGIN/COMMIT), all 17 scratch-store tests green on the candidate; two isolated Codex P0–P2 reviews scoped-clean. The existing two-engine conformance test passed on actual SQLite and PostgreSQL 17, with catalog/trigger parity and cleanup verified. Test cost: scratch cases totaled 6.528 s (125.95 s file duration, mostly transform); the two engine cases totaled 1.846 s (260.62 s file duration, mostly transform). The candidate build and official source-freshness check passed at measured runtime head 93a6c4d; the three-sample invocation completed with the shutdown limitation above. Exact-head CI run 40176443806 completed successfully: 39 successful jobs, 26 skipped, no failures, including all three actual PostgreSQL shards, production/test types, lint, source contracts, Madge, and worker/T1/dialect ratchets. The earlier run passed types, lint and source contracts but found a worker-inventory omission: the new direct query was conservatively labeled T1. Head a187ecf corrects only inventory metadata and regenerates its snapshot: the worker snapshot and its private heartbeat helper are W, while the native Doctor reader stays T3. No runtime or SQL change is involved. The generated snapshot also catches up existing main classifications; targeted script lint and formatting pass. The two production reviews remain valid; this tooling-only correction adds no production review round. PG review approved the semantics at 68c24c4, and the coordinator explicitly carried REVIEW-OK to 93a6c4d because only benchmark TypeScript annotations changed. Candidate counts and the inherited-shutdown disposition are recorded; the corrected head’s CI and all three PG shards passed. The test-only import relocation avoids another open PR's adjacent import change; production bytes remain identical to both isolated reviews and database proof. The benchmark annotations fix CI TS7022 without changing emitted behavior.

Final-head overlap at a187ecf: complete shared-index base-versus-candidate merge-tree comparison covers 21 peers (#183410, #183285, #181057, #180871, #180286, #180139, #169241, #168956, #168615, #167546, #167471, #165039, #161997, #157922, #157693, #156613, #141004, #137788, #136476, #129388, #121204). No new source conflict paths, regions or messages. Six peers (#181057, #180871, #180139, #169241, #129388, #121204) have added or changed conflicts confined to the fully generated worker inventory. The coordinator explicitly accepted this class because main's snapshot was stale and generated outputs must be regenerated, not hand-edited. The same exact-head disposition carries PG REVIEW-OK because runtime bytes are unchanged. Exact-head CI and all three PostgreSQL shards passed.

PG checklist: (1) read-only; existing writer transaction/advisory-lock, DML/conflict and cross-store commit ordering unchanged. (2) At most one joined row via the existing composite primary keys, original job fields plus four scratch fields, unchanged 256 KiB scratch write bound. (3) No cache/generation or invalidation change; one statement snapshot, existing outer PG read transaction retained. (4) No schema/admission/identity/retry/probe change. (5) Same worker owner, one request, no MAIN expansion; target 4→1 SQL in all three real Gateway runs, with the inherited shutdown failure disclosed above. (6) Actual PostgreSQL 17 and SQLite owner conformance passed; all three final-head PostgreSQL CI shards and the other selected static checks passed.

Knip was run separately because ordinary PR CI excludes it. The canonical candidate export scan failed with 26 script, 20 production and 16 full-tree findings; none is in a changed file. All 62 occurrences (52 unique file/symbol pairs), scanner/config/compiler inputs and package inputs are unchanged from merge-base dada70f. The only removed imports, runSqliteReadSnapshotSync and loadCronRows, both retain multiple real production consumers. Current-main diagnostic sections reported 14 script and 7 production findings; main has already repaired 40 candidate occurrences in unrelated changes. Its separate full-tree scan was intentionally stopped after the coordinator accepted the source-attributed inherited findings; it is not a passing full-main scan. No ignored exports, baselines or unrelated code were changed. The failed candidate scan is explicitly accepted as inherited; all branch changes and selected CI static checks pass.

Pre-merge shared-index refresh retains 17 open peers from that audit. Only #180871 moved (f140f16); its fresh base-versus-candidate comparison still adds conflicts solely in the generated worker inventory, within the coordinator-accepted class. No new source conflicts.

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
An explicit cron run reads its authorized job definition and private scratch separately inside a SQLite read transaction. Read both in one dialect-layer LEFT JOIN so they share a statement snapshot, removing three SQL statements per SQLite run without another worker request.

The job reader keeps its all-column authorization relation, ordered narrow projection, exact returned-ID check, existing decoder/config revision and legacy creation fallback. Missing scratch still reports revision 0; deletion keeps its revision tombstone. The standalone maintenance reader remains. No schema, cache, write, receipt, claim-before-effect, delivery authority, FIFO or 64-receipt retention change.

PostgreSQL retains the shared reader's outer read-only transaction and rollback: its exact-job read is 4→3 SQL, not 4→1. SQLite exact-job is 4→1, heartbeat 3→1; PostgreSQL heartbeat remains 3→3. Accepted noncontract edges: an absent/malformed job can now require scratch SELECT privilege, and malformed job plus unsafe numeric scratch can reject the numeric data first. These do not remove the existing caller/source/cancellation checks.

The production delta is +3 lines: one joined query replaces the transaction and duplicate read while sharing NULL handling with heartbeat. Existing test files cover read-after-write, tombstones, missing jobs/monitors and both database engines. No new suite or runner is added.

Acceptance was registered before measurement: the committed `scripts/bench-cron-run.mts` drives signed WebSocket `cron.run` against an isolated synthetic Gateway/provider, once cold and twice warm. Each run must produce one start, one finish, one Responses request and exact-run history verification. Compare execution, history verification and settlement separately and together, plus shutdown and the entire invocation. The scratch owner must fall from 4→1 SQL with 1 request and 0 MAIN throughout; no cost may be deferred outside the run. Keep cold/warm separate and report median/p95/range. Three same-platform alternating pairs when calm, or one pair plus source attribution under campaign load. Counts and profiles make no latency/CPU-speed claim; timing claims require the timing lock, load below 24 and ≥5 alternating samples per arm. A 20% user-facing regression stops acceptance. Delivery mode none does not claim an external-send proof.

The same-platform explicit comparison (baseline 814e732, candidate 93a6c4) gives:

| SQL / requests / MAIN | Baseline | Candidate |
| --- | --- | --- |
| Cold execution + verification + settlement | 257 / 80 / 0 | 254 / 78 / 0 |
| Warm 1 | 247 / 64 / 0 | 235 / 60 / 0 |
| Warm 2 | 252 / 61 / 0 | 245 / 65 / 0 |
| Warm median | 249.5 / 62.5 / 0 | 240 / 62.5 / 0 |
| Warm descriptive p95 | 252 / 64 / 0 | 245 / 65 / 0 |
| Warm range | 247–252 / 61–64 / 0 | 235–245 / 60–65 / 0 |
| Shutdown | 22 / 6 / 5 | 40 / 10 / 5 |
| Whole invocation | 1383 / 356 / 58 | 1369 / 352 / 58 |

Each of the three runs completed one start, finish, Responses request and exact history verification. The scratch owner is exactly 4/1/0 → 1/1/0 in every run, all in its execution phase, with no extra or deferred scratch requests. All execution/verification/settlement phases are SQL-error-free and runtime MAIN remains zero. The count comparison is diagnostic, not an error-free full invocation: the frozen analyzer rejects two failed shutdown `state_leases` DELETEs (`database is locked`). Shutdown exceeds the 20% stop threshold; it was stopped and explicitly accepted by the coordinator as inherited after an independent main shutdown-lock reproduction. The separate SHUTDOWNLOCK lane owns that repair. The scratch join changes no lease code or writes. No latency or CPU-speed claim is made.

The frozen 3.1.5 standard workload is a different scheduled `cron.add` flow: three valid baselines gave 06.cron 231/62/0, 235/65/0, 233/63/0 (median 233/63/0), versus ordinary warm 45/12/0. The descriptive excess is 188 SQL/51 requests, not causal subtraction. One extra standard setup aborted before any Gateway; it supplies no performance evidence. The existing scratch source is identical across that baseline and the explicit baseline. Full current-standard delta is deferred to the next census.

Validation: count regression red on baseline (2 SELECTs and BEGIN/COMMIT), all 17 scratch-store tests green on the candidate; two isolated Codex P0–P2 reviews scoped-clean. The existing two-engine conformance test passed on actual SQLite and PostgreSQL 17, with catalog/trigger parity and cleanup verified. Test cost: scratch cases totaled 6.528 s (125.95 s file duration, mostly transform); the two engine cases totaled 1.846 s (260.62 s file duration, mostly transform). The candidate build and official source-freshness check passed at measured runtime head 93a6c4d; the three-sample invocation completed with the shutdown limitation above. Exact-head CI run 40176443806 completed successfully: 39 successful jobs, 26 skipped, no failures, including all three actual PostgreSQL shards, production/test types, lint, source contracts, Madge, and worker/T1/dialect ratchets. The earlier run passed types, lint and source contracts but found a worker-inventory omission: the new direct query was conservatively labeled T1. Head a187ecf corrects only inventory metadata and regenerates its snapshot: the worker snapshot and its private heartbeat helper are W, while the native Doctor reader stays T3. No runtime or SQL change is involved. The generated snapshot also catches up existing main classifications; targeted script lint and formatting pass. The two production reviews remain valid; this tooling-only correction adds no production review round. PG review approved the semantics at 68c24c4, and the coordinator explicitly carried REVIEW-OK to 93a6c4d because only benchmark TypeScript annotations changed. Candidate counts and the inherited-shutdown disposition are recorded; the corrected head’s CI and all three PG shards passed. The test-only import relocation avoids another open PR's adjacent import change; production bytes remain identical to both isolated reviews and database proof. The benchmark annotations fix CI TS7022 without changing emitted behavior.

Final-head overlap at a187ecf: complete shared-index base-versus-candidate merge-tree comparison covers 21 peers (openclaw#183410, openclaw#183285, openclaw#181057, openclaw#180871, openclaw#180286, openclaw#180139, openclaw#169241, openclaw#168956, openclaw#168615, openclaw#167546, openclaw#167471, openclaw#165039, openclaw#161997, openclaw#157922, openclaw#157693, openclaw#156613, openclaw#141004, openclaw#137788, openclaw#136476, openclaw#129388, openclaw#121204). No new source conflict paths, regions or messages. Six peers (openclaw#181057, openclaw#180871, openclaw#180139, openclaw#169241, openclaw#129388, openclaw#121204) have added or changed conflicts confined to the fully generated worker inventory. The coordinator explicitly accepted this class because main's snapshot was stale and generated outputs must be regenerated, not hand-edited. The same exact-head disposition carries PG REVIEW-OK because runtime bytes are unchanged. Exact-head CI and all three PostgreSQL shards passed.

PG checklist: (1) read-only; existing writer transaction/advisory-lock, DML/conflict and cross-store commit ordering unchanged. (2) At most one joined row via the existing composite primary keys, original job fields plus four scratch fields, unchanged 256 KiB scratch write bound. (3) No cache/generation or invalidation change; one statement snapshot, existing outer PG read transaction retained. (4) No schema/admission/identity/retry/probe change. (5) Same worker owner, one request, no MAIN expansion; target 4→1 SQL in all three real Gateway runs, with the inherited shutdown failure disclosed above. (6) Actual PostgreSQL 17 and SQLite owner conformance passed; all three final-head PostgreSQL CI shards and the other selected static checks passed.

Knip was run separately because ordinary PR CI excludes it. The canonical candidate export scan failed with 26 script, 20 production and 16 full-tree findings; none is in a changed file. All 62 occurrences (52 unique file/symbol pairs), scanner/config/compiler inputs and package inputs are unchanged from merge-base 71bc695. The only removed imports, runSqliteReadSnapshotSync and loadCronRows, both retain multiple real production consumers. Current-main diagnostic sections reported 14 script and 7 production findings; main has already repaired 40 candidate occurrences in unrelated changes. Its separate full-tree scan was intentionally stopped after the coordinator accepted the source-attributed inherited findings; it is not a passing full-main scan. No ignored exports, baselines or unrelated code were changed. The failed candidate scan is explicitly accepted as inherited; all branch changes and selected CI static checks pass.

Pre-merge shared-index refresh retains 17 open peers from that audit. Only openclaw#180871 moved (f140f16); its fresh base-versus-candidate comparison still adds conflicts solely in the generated worker inventory, within the coordinator-accepted class. No new source conflicts.

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts 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