Repository navigation
fix(doctor): bound session snapshot store reads with size cap - #110835
nocodet888-arch wants to merge 3 commits into
Conversation
|
Codex review: blocked before merge. Reviewed September 7, 2026, 8:50 PM ET / September 8, 2026, 00:50 UTC. ClawSweeper reviewWhat this changesLimits Doctor’s session-snapshot JSON reads to 16 MiB, including repair hydration, and reports oversized stores instead of loading them. Merge readiness⛔ Blocked before merge - 7 items remain This remains useful: current main and the latest release retain the unbounded snapshot read, and the merged SQLite fix explicitly excluded it. Both previous guard-placement findings are addressed, but overflow reporting still has a defect. Priority: P2 Review scores
Verification
How this fits togetherDoctor inspects cached skill paths in legacy session files and optionally repairs outdated paths through a serialized writer. Its results become console notes and structured health findings. flowchart TD
A[Doctor command] --> B[Legacy session files]
B --> C[Descriptor read with byte limit]
C -->|Within limit| D[Inspect cached skill paths]
C -->|Over limit| E[Skipped-store warning]
D --> F[Serialized repair writer]
F --> G[Backup and repaired file]
Decision needed
Why: The limit prevents unbounded reads but introduces an operator-visible cutoff absent from the existing migration contract. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +129, Tests +52. Total +181 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep bounded reads in the current Doctor-only legacy owner, report every overflow consistently, and preserve a supported migration path for valid large stores. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main reads the complete legacy JSON file before parsing, and the revised branch drops structured overflow warnings when growth triggers the helper’s RangeError. Neither path was executed during this review. Is this the best way to solve the issue? Acceptable mitigation, but not yet the best finished fix: reuse the bounded reader in the current legacy owner and normalize its overflow result; a global heap increase would leave the unbounded read intact. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 53ff0867149e. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (11 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review Oversized stores now emit an operator-visible Session snapshots warning (and structured |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
Pin one FD for snapshot store reads, enforce the 16 MiB cap while reading, and plumb maxBytes through updateSessionStore hydration so repair cannot allocate after a store grows while queued.
|
@clawsweeper re-review Pushed |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
Closing due to inactivity. |
What Problem This Solves
Doctor session-snapshot scan/repair loaded session store JSON with unbounded
fs.readFileSyncat two call sites. A corrupted or hostile multi-GBsessions.jsonunder the user state directory could OOMopenclaw doctorbefore JSON parse or repair logic ran.
Earlier revisions checked size via pathname
statSyncthen opened the pathagain, and repair hydration could still allocate after a store grew while
queued.
Why This Change Was Made
readSnapshotStoreRawpins one FD (openSync/fstatSync), enforces the16 MiB cap while reading via
readFileDescriptorBoundedSync, and closes infinally.maxBytes: MAX_SNAPSHOT_STORE_BYTESintoupdateSessionStoreso writer hydration cannot allocate above the bound after queued growth.
and structured
kind: "store-too-large"/would-skip-oversized-session-store.User Impact
Before: An oversized session store could force an unbounded sync string
alloc during doctor snapshot health, or bypass a pathname-stat race / grow
while repair waited.
After: Stores above 16 MiB are rejected on a pinned descriptor (and at the
writer load boundary). Doctor reports the skip; normal stores continue.
Evidence
src/commands/doctor-session-snapshots.ts,src/config/sessions/store-load.ts,src/config/sessions/store.tsnoteSessionSnapshotHealth→loadSessionStoreForSnapshotScan/ repairupdateSessionStore({ maxBytes })→ descriptor-bounded read
ec2d1617bceReal behavior proof
Behavior or issue addressed
A ~17 MiB session store is not fully buffered. Isolated
openclaw doctor --non-interactive --yesprints a Session snapshots note thatthe store was skipped as oversized. Descriptor-bound + writer
maxBytesclosethe concurrent-growth gaps called out in review.
Canonical reachability path
openclaw doctor→ session snapshot health →readSnapshotStoreRaw(pinned FD + bounded read) /updateSessionStore(..., { maxBytes })→ skip + warn on overflowShared helper / provider constraint check
Uses
readFileDescriptorBoundedSync; same 16 MiB campaign cap; no newconfig/env keys.
Real environment tested
Local trusted source checkout at PR head; Node 22.23.1; isolated
OPENCLAW_STATE_DIRwith a planted 17 MiBsessions.json; CLI vianode scripts/run-node.mjs doctor --non-interactive --yes.Exact steps or command run after this patch
node scripts/run-vitest.mjs src/commands/doctor-session-snapshots.test.ts \ -t "oversized session stores" --reporter=verboseEvidence after fix
Redacted CLI previously captured:
Fix classification
bugfix — resource bound / OOM hardening (descriptor + writer load)
AI Assistance
AI-assisted implementation and proof.