Skip to content

refactor: replace duplicated filesystem helpers with fs-safe - #148442

Merged
steipete merged 6 commits into
mainfrom
codex/fs-safe-011-adoption-20260914
Sep 14, 2026
Merged

steipete merged 6 commits into
mainfrom
codex/fs-safe-011-adoption-20260914

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenClaw still duplicates filesystem code now available in fs-safe 0.11.0, adopted in #148087.

User Impact

Filesystem operations retain OpenClaw’s path policy, execution guards, publication, and recovery behavior. Recursive removal avoids rereading the parent directory for every child. Borrowed-handle copies use fs-safe’s strict file identities and no-progress diagnostics.

Why This Change Was Made

Remove 1,041 net production lines by using the released guest Python program, producer isolation, directory identities, case probing, recursive removal, and descriptor copy/hash/overwrite operations. OpenClaw keeps transport and admission, durability requirements, rollback decisions, and persisted digest field names. The superseded Python modules and private temporary-file owner are deleted.

The change adds filesystem regression coverage and removes one obsolete assertion-baseline entry. Canonical wizard registration is supplied by #148504, and the independent routing assertions are also on main through #148366; final integration preserves them once. Dependency pins and streamed-create compatibility are already on main through #148087. Current-main integration retains both the existing buildRandomTempFilePath and the new probePathCaseInsensitiveSync exports.

Evidence

  • Before integration, 1,027 tests passed across 31 files, with 15 platform skips; build and changed-file checks passed. Integration retained the prerequisite’s adapter, with 56 facade/stream/error tests and core typing passing. Independent audits confirm that the filesystem implementations remain byte-equivalent, apart from main’s additional advanced export.
  • 33 real-filesystem groups passed against actual OpenClaw imports and installed fs-safe 0.11.0 on macOS: host tools, partial-write rollback and revoked authority, snapshot descriptors, producer publication, recursive removal, both APFS case modes, and Python guest/remote-bridge composition. Input hashes and cleanup were verified.
  • An isolated Linux ARM64 cell passed published OpenClaw 2026.9.4 → candidate → installed-candidate replay. Exactly one local override was reapplied, with matching bytes, no conflicts or warnings, and no installation residue. Target archives used metadata-only first-hop fixture versions, preserving candidate executable bytes.
  • For a 100-file directory, observed directory enumeration calls fell 102 → 2 and median local APFS removal time fell 44.8 ms → 21.8 ms across three interleaved samples of the actual old and new modules.
  • The browser download containment test now asserts the released not-file code instead of retired wording. The old assertion reproduced the CI failure; all 17 tests in its file pass with the save-count and outside-directory checks intact. Targeted lint passed in a flat checkout with dependency-isolation guards enabled.
  • CI integration exposed two independent duplicate-removal commits deleting opposite copies of the wizard recovery test registration. The merged tree consequently ran that test without its required host broker. The real failure and a new independent routing assertion both reproduced before repair. With exactly one registration restored, all 8 recovery cases pass in the forked infra pool; actual Vitest discovery finds the test once there and excludes it from the threaded wizard pool. The five-line routing regression and targeted lint pass. Integrating test: route provider integration and wizard recovery tests correctly #148504 retains its single canonical registration; the regression also caught the duplicate created by combining the two branches before that duplicate was removed.
  • Both advanced exports resolve through the actual OpenClaw facade, and the existing case-probing tests pass after the mechanical main-merge resolution. Managed P2 reviews found no actionable issue in the adoption or its integration repairs.

The inherited Radius boundary failures are resolved by integrating canonical #148504. Both the actual core-graph guard and the deep-import boundary contract pass after integration; no alternative Radius implementation is added.

An earlier hosted run also encountered native fs.rm / ENOTEMPTY during an unchanged memory test’s teardown. The same memory lane subsequently passed; the exact late writer remains unproven, and this PR adds no speculative memory repair or removal retry.

Earlier implementation proof is retained with its source identity; it is not relabeled as final-head execution. Required hosted CI is green for unchanged head 9e666f59b2f17115e6a02c30370917dbc11e3ec5: run 34897239695, attempt 2 finished with 121 passing checks and 16 skips. Local filesystem proof does not claim a deployed remote backend, Windows live filesystem behavior, broad concurrent races, crash durability, or final link-to-copy fallback. The Linux package update cell did not start a Gateway or use provider credentials.

The first CI attempt had one five-second Gateway shutdown timeout. The unchanged two-case test passed locally, a temporary trace probe passed and was exactly removed, and all 327 tests in the original 27-file execution order passed locally with reporter order verified. A single retry of the failed job then completed all six packed groups successfully. The original timeout cause remains unproven; no timeout, assertion, or runtime behavior was changed.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 14, 2026
@steipete
steipete marked this pull request as ready for review September 14, 2026 18:19
@steipete
steipete requested a review from a team as a code owner September 14, 2026 18:19
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 5:18 PM ET / 21:18 UTC (Revision 6).

ClawSweeper review

What this changes

Replaces duplicated filesystem implementations with fs-safe helpers while retaining OpenClaw’s path checks, write guards, snapshot formats, and recovery behavior.

Merge readiness

✅ Ready for maintainer review

The consolidation remains useful and distinct from its merged prerequisites. No blocking introduced defect was found; the protected maintainer PR should remain open.

Priority: P2
Reviewed head: 9e666f59b2f17115e6a02c30370917dbc11e3ec5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent consolidation with directly inspected dependency contracts, useful recorded validation, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer PR is exempt from the external-contributor proof gate. Its supplied body records real filesystem and published-driver upgrade observations for the changed adapters; those earlier results are retained without claiming final-head execution or Windows and deployed-remote coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer PR is exempt from the external-contributor proof gate. Its supplied body records real filesystem and published-driver upgrade observations for the changed adapters; those earlier results are retained without claiming final-head execution or Windows and deployed-remote coverage.
Evidence reviewed 9 items Current main still contains the duplicated implementation: Fetched main retains the private temporary-file wrapper and descriptor-copy implementation. The latest release also retains the temporary-file wrapper. The merged dependency upgrade supplies the library version but does not perform this consolidation.
Host write guard remains at the mutation boundary: The adapter passes its captured execution guard as beforeWrite. Existing entrypoint tests cover revoked, replaced, aborted, and active authority, partial-write rollback, inode preservation, and shorter writes.
Released overwrite contract inspected directly: The target directly imports overwriteFileHandle through its descriptor facade, establishing the dependency boundary. Version 0.11.0 resolves to this dependency commit; its implementation prepares rollback bytes, invokes beforeWrite synchronously, then retains the extension-first write and failure rollback sequence.
Findings None None.
Security None None.

How this fits together

OpenClaw’s filesystem adapters support agent writes, sandbox operations, generated files, package installation, and snapshots. They apply OpenClaw policy around the shared library’s file operations.

flowchart TD
  A[Agent and sandbox requests] --> C[OpenClaw filesystem adapters]
  B[Artifacts and package updates] --> C
  C --> D[Path and execution checks]
  D --> E[Shared fs-safe operations]
  E --> F[Files and snapshots]
  E --> G[Publication and recovery results]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1041, Tests +34, Other -1. Total -1008 across 33 files.

View PR surface stats
Area Files Added Removed Net
Source 20 104 1145 -1041
Tests 12 163 129 +34
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 33 267 1275 -1008

Review metrics

Metric Value Why it matters
Reported recursive-removal work 102 → 2 directory enumerations for 100 files The reported comparison exercises the old and new OpenClaw modules and supports the reduction in repeated scanning.

Technical review

Best possible solution:

Keep OpenClaw’s admission, durability, and recovery policy in thin adapters while fs-safe owns the shared filesystem mechanics.

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

Not applicable: this PR consolidates existing implementations; source comparisons establish the duplication without requiring a failing runtime reproduction.

Is this the best way to solve the issue?

Yes: the released dependency provides the required primitives, while the adapters preserve OpenClaw-specific policy and serialized contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a useful shared-filesystem maintenance and performance improvement without evidence of an urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer PR is exempt from the external-contributor proof gate. Its supplied body records real filesystem and published-driver upgrade observations for the changed adapters; those earlier results are retained without claiming final-head execution or Windows and deployed-remote coverage.

Evidence

What I checked:

  • Current main still contains the duplicated implementation: Fetched main retains the private temporary-file wrapper and descriptor-copy implementation. The latest release also retains the temporary-file wrapper. The merged dependency upgrade supplies the library version but does not perform this consolidation. (src/infra/sibling-temp-file.ts:9, f48695a2abc7)
  • Host write guard remains at the mutation boundary: The adapter passes its captured execution guard as beforeWrite. Existing entrypoint tests cover revoked, replaced, aborted, and active authority, partial-write rollback, inode preservation, and shorter writes. (src/agents/host-file-write.ts:41, 9e666f59b2f1)
  • Released overwrite contract inspected directly: The target directly imports overwriteFileHandle through its descriptor facade, establishing the dependency boundary. Version 0.11.0 resolves to this dependency commit; its implementation prepares rollback bytes, invokes beforeWrite synchronously, then retains the extension-first write and failure rollback sequence. (src/overwrite-file-handle.ts:13, 5209566a355f)
  • Producer isolation and directory identity contracts: Inspected the released producer-isolation implementation and directory guards. Private workspace ownership is established before invoking the producer; parent and workspace identities are checked before publication. Directory assertions preserve raw filesystem errors and permit identity-only checks for deliberately relocated recovery receipts. (src/sibling-staged-file.ts:44, 5209566a355f)
  • Guest protocol retains the caller-owned boundary: The target imports the guest Python program directly. Its released source retains operation frames and exit statuses, adds basename validation, and uses bounded temporary names. The native publication fragment matches the removed implementation after export renaming; OpenClaw retains mount admission, quoting, transport, and read-only checks. (src/guest.ts:15, 5209566a355f)
  • Compatibility remains adapter-owned: Recursive removal explicitly retains sorted traversal and unlimited historical budgets. Snapshot digest fields remain sha256 and sizeBytes; local overrides retain canonical-root checks, and installation retains its publication receipts and rollback decisions. No dependency pin, persisted schema, or public configuration is introduced. (src/infra/fs-safe-remove.ts:37, 9e666f59b2f1)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • zenglingbiao: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-14T18:26:49.157Z sha 389f428 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T18:58:30.615Z sha b1a89fd :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T19:36:06.997Z sha 406ddea :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T19:53:20.358Z sha 406ddea :: blocked before merge. :: none
  • reviewed 2026-09-14T20:35:12.753Z sha e6b841f :: needs maintainer review before merge. :: none

@steipete steipete self-assigned this Sep 14, 2026
Remove the duplicate inventory entry so compact CI shard manifest generation retains one execution group and its strict timing uniqueness guard.
steipete added a commit that referenced this pull request Sep 14, 2026
Retain the routing regression from #148442 while inheriting the canonical registration repair in #148504. Require one infra registration and exclusion from the thread-based wizard project.
steipete added a commit that referenced this pull request Sep 14, 2026
* perf(sessions): reduce redundant SQLite scans

* style(acp): avoid shadowed query builder names

* test(ui): exercise session eviction through the wizard choice button

* test(ui): wait for the current publication subscription

* test(ci): protect wizard recovery broker routing

Retain the routing regression from #148442 while inheriting the canonical registration repair in #148504. Require one infra registration and exclusion from the thread-based wizard project.
@steipete
steipete merged commit e836b72 into main Sep 14, 2026
333 of 336 checks passed
@steipete
steipete deleted the codex/fs-safe-011-adoption-20260914 branch September 14, 2026 22:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
* perf(sessions): reduce redundant SQLite scans

* style(acp): avoid shadowed query builder names

* test(ui): exercise session eviction through the wizard choice button

* test(ui): wait for the current publication subscription

* test(ci): protect wizard recovery broker routing

Retain the routing regression from openclaw#148442 while inheriting the canonical registration repair in openclaw#148504. Require one infra registration and exclusion from the thread-based wizard project.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
…w#148442)

* refactor: reuse fs-safe filesystem owners

* fix(ci): register inference recovery tests once

Remove the duplicate inventory entry so compact CI shard manifest generation retains one execution group and its strict timing uniqueness guard.

* test(browser): assert structured download guard error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: browser maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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