fix(doctor): bound AGENTS.md and root-memory file reads#101448
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 8:42 AM ET / 12:42 UTC. Summary PR surface: Source +128, Tests +249. Total +377 across 2 files. Reproducibility: yes. in source terms: the doctor workspace migration has concrete paths for oversized, unreadable, raced, and archive-failure root-memory inputs. The provided transcript demonstrates an older head, but not the full current-head race and atomic archive behavior. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Keep the capped descriptor-backed reads and validate the complete current-head migration contract with a redacted terminal transcript covering normal merge, rejected reads, archive-race growth, restoration/atomic archive failure, and symlinked guidance before assigned-owner merge review. Do we have a high-confidence way to reproduce the issue? Yes, in source terms: the doctor workspace migration has concrete paths for oversized, unreadable, raced, and archive-failure root-memory inputs. The provided transcript demonstrates an older head, but not the full current-head race and atomic archive behavior. Is this the best way to solve the issue? Yes in direction: bounded regular-file reads and validate-before-mutate behavior are the narrowest solution. The current head still needs real behavior evidence for its later recovery branches before it is the best proven merge candidate. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against af2662f25a85. Label changesLabel justifications:
Evidence reviewedPR surface: Source +128, Tests +249. Total +377 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (36 earlier review cycles; latest 8 shown)
|
7980abb to
d13a867
Compare
|
@clawsweeper re-review\n\nI added real behavior proof to the PR body, including the local test command and output that exercises the oversized-file rejection path. |
d13a867 to
f486bc9
Compare
|
@clawsweeper re-review Added real behavior proof that exercises the doctor workspace memory helpers (
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
b873ef4 to
f476845
Compare
|
@clawsweeper re-review Rebased once more onto the latest New head: |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Rebased onto the latest
New head: |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review - separated oversized-file rejection from other read failures and added regression tests for both diagnostics. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review - rebased onto latest main to pick up unrelated CI/test fixes. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review - rebased onto latest main to resolve the unrelated check-dependencies and check-lint drift. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review — branch is rebased onto latest CI=true pnpm test src/commands/doctor-workspace.test.tsResult: 9/9 tests passed, including the oversized Ready for review/land. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head behavior proof at Setup: Node v24.15.0, isolated (a) Normal merge — small canonical + small legacy (b) Oversized canonical (8 MiB + 4 KiB > 8 MiB cap) — rejected, no mutation (c) Oversized legacy (8 MiB + 4 KiB > 8 MiB cap) — rejected, no mutation (d) Unreadable canonical (chmod 000) — readError branch, no mutation Bonus — the 1 MiB Regression tests at the same exact head: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: 陈宪彪0668000387 <[email protected]>
Co-authored-by: 陈宪彪0668000387 <[email protected]>
Co-authored-by: 陈宪彪0668000387 <[email protected]>
Co-authored-by: 陈宪彪0668000387 <[email protected]>
Co-authored-by: 陈宪彪0668000387 <[email protected]>
|
Merged via squash.
|
What Problem This Solves
shouldSuggestMemorySystemandmigrateLegacyRootMemoryFileinsrc/commands/doctor-workspace.tsreadAGENTS.md,MEMORY.md, and archivedmemory.mdwith unboundedfs.promises.readFile(..., "utf-8"). A malicious or runaway workspace file could OOM the doctor repair path before any diagnosis or merge.Why This Change Was Made
AGENTS.mdis only scanned for a memory-system reference, so a 1 MiB cap is plenty.catchbehavior is preserved: an oversized/unreadableAGENTS.mdis treated as missing guidance, and an oversized or unreadableMEMORY.md/memory.mdpair is left fully in place (no archive, no merge) with a skipped-repair note.User Impact
openclaw doctorworkspace memory checks no longer buffer arbitrarily large files.AGENTS.md/ memory files are handled gracefully instead of crashing.Evidence
fs.promises.readFilecalls withreadRegularFilecapped reads insrc/commands/doctor-workspace.ts.src/commands/doctor-workspace.test.tscovering an oversizedAGENTS.md, oversized canonical/legacy memory files, and an unreadable canonical file.Real behavior proof
Exact-head run at
1a34dcabb0a386b5f2db5707a7c83c084b40fedfwith a standalone driver (node --import tsx, Node v24.15.0) that imports the real helpers fromsrc/commands/doctor-workspace.ts— the moduleopenclaw doctorcalls viasrc/commands/doctor-memory-search.ts— against isolated/tmpworkspaces (HOME/OPENCLAW_STATE_DIRpointed at the fixture root; paths redacted as$PROOF). Each fixture went throughmigrateLegacyRootMemoryFile(structured result) andmaybeRepairWorkspaceMemoryHealth(theopenclaw doctor --fixrepair entry, auto-approved prompter); note boxes trimmed to content lines:Interpretation:
memory.mdis archived under.openclaw-repair/root-memory/<ts>/and its content is merged intoMEMORY.md.readLimitExceeded) from other read failures (readError).AGENTS.mdexceeds the 1 MiB cap and is treated as missing guidance.