Repository navigation
fix(apply): bound report retention and ledger finalization - #1254
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 10:30 PM ET / August 27, 2026, 02:30 UTC. ClawSweeper reviewWhat this changesThis PR bounds apply-lane report retention and ledger finalization to selected records and required paired or in-flight records, with regression tests and a memory-focused CLI harness. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep this PR open for normal maintainer landing: the prior CHANGELOG finding does not apply because this is a ClawSweeper PR, and the focused retention change has strong current-head proof. Likely related people: steipete (high-confidence recent apply-records owner). Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherClawSweeper’s apply lane reads stored review reports, checks close safety, syncs GitHub comments, and records outcomes in an action ledger. This change limits retained and reloaded report bodies without changing close eligibility, cursor ordering, or ledger identity. flowchart LR
A[Selected review reports] --> B[Apply lane]
C[Paired close record] --> D[On-demand lookup]
D --> B
B --> E[Close guards and comment sync]
E --> F[Action ledger]
F --> G[Bounded finalization]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the narrow bounded-read implementation while retaining its paired-close, partial-failure, and runtime-budget regression coverage. Do we have a high-confidence way to reproduce the issue? Yes. The supplied current-head built-CLI harness creates a large report corpus and verifies targeted, broad, partial-failure, and runtime-budget scenarios under a fixed 256 MiB heap limit. Is this the best way to solve the issue? Yes. Lazy paired-record lookup and a finalization set derived from requested, result, and active ledger items remove the unnecessary retention while preserving the existing safety boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4a6f9ecb165e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
@clawsweeper re-review The main PR body now records green exact-head hosted CI, the clean independent committed-branch review, and the disposition of the changelog finding. The head remains Please apply the release-note rule to its named repository: |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Landed as 5cb6777. The fix removes the unrelated open-report retention and archive-wide finalization reload that reproduced the apply OOM. Selected snapshots, independent paired evidence, canonical CAS/baselines, close guards, cursor progress, and partial/in-flight ledger identities remain intact; no additional item becomes eligible to close. Verification at reviewed head The actual merge base advanced through the independently landed Go-toolchain fix #1247. Post-merge comparison verified that all 11 files from this PR are byte-identical to the reviewed head; the additional base delta is confined to Go live-proof workflow setup, its docs, and its tests. No unreviewed memory-fix changes were introduced by the merge. Caveats remain explicit: the local full suite had 48 baseline environment failures (inherited Git pruning and offline fixture package resolution); that local run is not labeled green. The automatic terminal-proof wrapper also reported a timeout despite capturing successful proof output; the independent seven-scenario exact-head replay is the proof package. No live apply/close was invoked, and production recovery still needs confirmation from normal scheduled runs. |
What Problem This Solves
Resolves a problem where scheduled proof and comment-sync runs can exhaust the JavaScript heap even with a small selected batch. Apply eagerly retained unrelated open reports for paired lookups, then reloaded every open and archived report during finalization. That could leave accepted comment writes without a finalized action-ledger batch.
Why This Change Was Made
Paired lookups now load and cache only explicitly referenced independent records, including missing lookups, while preserving the exact-event selection restriction. Finalization reloads only requested/result records and started, nonterminal, or in-flight ledger items from the open and closed locations. Broad candidate ordering, original snapshots, cursor progress, canonical baselines/CAS, paired evidence, close guards, and ledger identities remain unchanged. The fix stays in apply ownership; the shared report reader, policy, public schema, credentials, heap settings, and workflow limits are untouched.
User Impact
Small apply/proof/comment-sync batches avoid retaining unrelated report bodies or loading the full archive when completing or yielding. This reduces memory pressure without making additional items eligible for closing. Untargeted apply still retains its complete selected open set.
OpenClaw Bay Impact
OpenClaw Bay is unaffected: no public API, schema, UI, or published status contract changes, and no action controls are added.
Documentation Impact
Updated the active scheduler reference with the apply retention/finalization contract and added the fix to CHANGELOG.md. The scheduler reference remains owned by ClawSweeper maintainers, with planner/runtime source and the sweep workflow as its source of truth; changes to apply selection, paired lookup, or ledger finalization trigger updates. This proof verifies the changed apply scope at
673c0f160a251637eef13b5d8cc01213eabd0706, not every scheduler operation.Two additional changelog credit lines are maintainer housekeeping for already-landed #1242 and #1240 from the same health session; they do not alter contributor branches or add their implementation to this diff.
Evidence
Final head:
673c0f160a251637eef13b5d8cc01213eabd0706. Tested base:4a6f9ecb165edc400996fb3bb58c1a56d6133bd2. This is one commit on currentmain, including integration with the newly landed ETag fix.The final-head Node 24 build passed. All 60 focused tests passed, with zero failures, cancellations, or skips: memory boundaries and harness safety, cursor/budget handling, same-author paired-close controls, action-ledger controls, and the ETag broker integration.
git diff --checkpassed. The independent precommit Codex review was clean after the harness OOM/ownership findings were fixed; the reviewed source, tests, and hardened harness hashes stayed unchanged through the rebase. The only post-review edit was the two maintainer changelog credit lines.The prior full local
pnpm run checkis not green: 3,693 passed / 48 failed / 9 skipped, with exactly the same 48 baseline failures in unchanged tests. Inheritedfetch.prune=truedeletes fixtureorigin/main; a task-local configuration demonstrated the ref-preservation cause. Separately, deliberately offline validation uses a fresh isolated cache that cannot resolve fixture pnpm 10.33.0 from the pnpm 11 launcher. No test, pin, offline control, budget, timeout, global Git configuration, or unrelated source was weakened. That full check was not rerun on the final head because the identical environment blockers remain. Prior static/lint checks passed; they do not waive the local full-check failure.Hosted exact-head CI 33032661025 is now green: full
pnpm check, sparse repair build, and Windows Codex launcher all passed at673c0f160a251637eef13b5d8cc01213eabd0706. The fresh independent committed-branch Codex review against base4a6f9ecb165edc400996fb3bb58c1a56d6133bd2is also clean. The local baseline fixture failures above remain disclosed; hosted success does not relabel that local run. Current-head-and-body ClawSweeper review remains the final discussion/readiness gate.Real Behavior Proof
Claim: report retention and finalization no longer scale with unrelated stored history for targeted apply, while controlled outcomes and ledger identities are preserved; broad apply avoids the archive-wide finalization reload.
Surface and environment: the real built CLI runs as a subprocess against a filesystem Markdown corpus and writes real canonical baselines, reports, cursors, and immutable ledger events. GitHub is a fail-closed local fixture transport. Provider is
local-process, macOS arm64, Node v24.19.0, pinned pnpm 11.10.0. All seven scenarios ran serially at the unchanged 256 MiB V8 heap ceiling and 120-second per-case timeout. No full suite ran concurrently. No Crabbox provider, image, lease, Linux run, or hosted GitHub runtime proof is claimed.Corpus: 5,500 unrelated open records and 12,000 archived records, 32 KiB each, plus the selected records. The broad archive control uses 40 open records and the same 12,000-record archive. The harness owns its generated corpus and refuses unowned corpus paths or overwriting an existing case. The child receives no ambient credentials; the observer rejects network access and non-fixture subprocesses except the existing local macOS ledger identity probes.
Executed commands (Node 24 selected on PATH; no baseline-OOM acceptance flag for the candidate):
Use a fresh output directory or label to reproduce. Each subprocess uses
--skip-dashboard, temporary records/report/cursor/baseline/closed paths, explicit item selection except the bounded 40-record broad control, and the committed transport/observer.Observed results: the harness exited 0; all seven scenario gates passed on the final head. The partial-failure process intentionally exits 1 and passes only when its in-flight ledger identity and partial outcome are preserved. Every scenario finalized its ledger and read zero archived bodies.
Both 40-record sync scenarios preserved 20 accepted fixture comments, 20 source-drift skips, all 40 cursor numbers, and 163 ledger events. The other gates check protected-label skips without comments, partial-failure identity absent from the result row, runtime-budget yield with resumable cursor, fail-closed exact-event missing-revision behavior, and zero-candidate finalization. Candidate OOM, signal, timeout, arbitrary process failure, unexpected fixture requests, or finalization failure fails the harness. Expected-baseline-OOM mode is explicit and separate; it never accepts timeouts.
Historical controls on
afe976209aa58a5629041b42b66f6ee11b2812a7established the allocation defects at the same heap ceiling: the two-PR case aborted after its protected-label outcomes at 251.83 MiB sampled heap without finalizing the ledger; the broad archive case aborted after 20 fixture comment writes and 20 drift skips, having read 6,770 archived bodies without finalization. Its captured allocation path wasfinishApply -> reportEntriesForDir -> Array.map -> readFileSync. The two-PR control was repeated with the hardened runner: default mode rejected the OOM, while explicit expected-OOM mode accepted only that expected abort. The archive baseline remains the historical allocation control, not a freshly rerun final-head baseline.An earlier replay concurrent with the full suite timed out at 120 seconds and remains failed evidence. It was not relabeled green and no limit was raised. The table above is the fresh serial replay of the committed head.
Durable trace and provenance: the inline table and JSON below record the executed results and source/build digests; no local-only artifact is required to inspect this evidence. Every scenario's copied runtime matched these three built-module digests. The committed runner, fixture transport, observer, and harness safety tests define the commands and fail-closed gates. Source at the tested head: decision workflow, record ownership, and close guards.
{ "head": "673c0f160a251637eef13b5d8cc01213eabd0706", "base": "4a6f9ecb165edc400996fb3bb58c1a56d6133bd2", "provider": "local-process", "platform": "darwin/arm64", "node": "v24.19.0", "pnpm": "11.10.0", "heapLimitMiB": 256, "timeoutMs": 120000, "serial": true, "harnessExit": 0, "sourceSha256": { "src/clawsweeper-apply-close-guards.ts": "83aacd3d4a6908c89687d9d05f39cd7edcdbfb28908d88bbc355052bfc3160d7", "src/clawsweeper-apply-decision-workflow.ts": "4e48883d7615cfce1855e9dc6c6c04359fc7d79539c414740149ac2695844cf2", "src/clawsweeper-apply-records.ts": "85d2cb273ccdea738f4cbb9041272bfe26587a780460fedec10e19c60c0caa67" }, "buildSha256": { "clawsweeper-apply-decision-workflow.js": "4d0cc2cc8df1a319f6c820c35807dab84f814d22ebfde39714f6536d40622364", "clawsweeper-apply-records.js": "44a06d884974461117fb28b9cbd40c272acde615693d069bd384f021f8631ff1", "clawsweeper-apply-close-guards.js": "d44e52836384c25256aca0955d69bcad9b3652602b2c6bec47ffe93a6b85ced2" } }Limits: sampled heap values are observations, not continuous maxima; aborted-baseline observations are lower bounds. This controlled corpus proves the allocation fix, not the sole cause of the production heap failures or complete production recovery. The protected PR dry-run does not invoke Codex coverage proof or close PRs. Paired-close mutation preservation comes from separate focused integration controls, not the memory harness. Exact publication exercises the fail-closed missing-revision path. The harness
GITHUB_SHAis synthetic ledger identity; the actual commit and source/build digests above establish candidate provenance. No mass corpus, raw logs, or agent transcript is published. No deployment, live GitHub closure, live model proof, or post-deployment health result is claimed.Finding Disposition
Rejected: “Remove release-owned CHANGELOG entries.” This finding applies the policy of a different repository. This PR targets
openclaw/clawsweeper, notopenclaw/openclaw. AGENTS.md lines 50–51 explicitly make the OpenClaw changelog release-owned. CONTRIBUTING.md lines 16–19 scope that restriction to anopenclaw/openclawtarget and separately direct ClawSweeper changes to this repository's release-note policy. These three entries are maintainer-authored ClawSweeper release context, including credit for the two fixes already landed during this health session. They do not edit OpenClaw's changelog, publish a release, or alter contributor branches. They remain intentionally.The only code-related merge risk is the existing availability boundary; focused, paired/CAS/cursor controls, exact-head full CI, and seven controlled runtime scenarios cover it without changing close eligibility. No runtime finding remains accepted or unresolved.
The automated live-verification wrapper reported a 30-second previous-command timeout even though its captured built-CLI result shows
scenario: proof, exit 0, zero archive reads, andvalidation.passed: true. That wrapper outcome remains a failed attempt; it is not relabeled green. The independent seven-scenario final-head runtime proof above remains the executed proof package, and the durable review already assessed it as sufficient. This metadata-only update requires a fresh review of the current body, not a change to the proven runtime or its safety controls.