Skip to content

feat(guest): share the Python guest filesystem engine - #333

Merged
steipete merged 2 commits into
mainfrom
codex/guest-filesystem-helper-20260913
Sep 14, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/guest-filesystem-helper-20260913

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenClaw carries a 663-line Python filesystem engine for Docker and SSH guests, including writes, exclusive create, bounded reads, copy, rename/EXDEV fallback, directory traversal, and removal. Its workspace bootstrap also reuses the no-replace rename implementation. These filesystem mechanics can have one maintained owner in fs-safe.

Why This Change Was Made

Add @openclaw/fs-safe/guest with the complete Python source string, two existing protocol exit constants, and the independently consumed no-replace rename fragment. Importing the subpath performs no I/O or process launch. The caller keeps transport, interpreter discovery, quoting, mount selection, read-only policy, path authorization, and live authority.

The extracted engine has two deliberate repairs: basename syntax validation before filesystem operations, and short independent staging names. The latter fixes an inherited NAME_MAX failure for legal 240-byte destinations during writes and cross-device file/directory moves. The argument frames, standalone rename fragment, publication order, and all other program bytes are unchanged. The docs describe the trusted-root boundary and existing cancellation, resource-budget, and partial-publication limits.

User Impact

The prepared OpenClaw cutover deletes both program modules and migrates every Docker/SSH/bootstrap consumer through a six-line infra facade: 657 fewer OpenClaw production lines, with zero net test/support lines. It targets OpenClaw 610f6dcfef322b85af25f0df495715e426adaee5; all seven consumer/test bodies retain their behavior.

Linux/macOS guests need Python 3, without requiring Node or the fs-safe addon inside the guest. Adoption waits for a separately approved fs-safe release. This PR changes no dependency versions or native ABI and does not activate unavailable imports in OpenClaw.

Evidence

  • Full pnpm check passed on the reviewed code: 6,248 tests passed, with 2,820 existing platform/native gates skipped; build, docs examples, public API inventory, and installed-tarball smoke passed. Integration with current main changed only release-note placement and the README table; guest source and tests remain byte-identical to the reviewed code. Combined build/package checks passed on the updated base. Docs-site build also passed.
  • All 49 guest cases passed on macOS and Linux. The three long-name regressions failed before the repair and pass afterward.
  • Installed-tarball Linux proof performed long-name writes and real cross-device file and directory moves to 240-byte destinations, verifying bytes, modes, source removal, and absence of staging leftovers.
  • The source comparison accounts for exactly the 369-byte preflight and seven staging-name/signature/call changes; all remaining program bytes and the standalone fragment match the original. Short-name protocol scenarios remain equivalent across every operation.
  • The downstream patch applies cleanly. All 13 existing fault-injection anchors still match exactly once, and all 10 injected programs compile; no consumer-test migration is needed.
  • Fresh independent Codex P0–P2 review found no actionable findings.
Captured Linux guest and installed-tarball output
Test Files  4 passed (4)
     Tests  49 passed (49)
guest installed-package real cross-device file and directory moves with long basenames passed
guest installed-package Python protocol and standalone rename fragment passed

The package smoke verified different device IDs before moving a 131,089-byte payload from temporary storage to /dev/shm. The task-owned Linux environment was released after proof.

  • Tests added or updated when behavior changed
  • Security and compatibility impact considered
  • CHANGELOG.md updated when release-relevant
  • No credentials, private paths, private hosts, or sensitive contents included

@steipete
steipete requested a review from a team as a code owner September 13, 2026 23:18
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 8:03 PM ET / September 14, 2026, 00:03 UTC (Revision 5).

ClawSweeper review

What this changes

Adds a public Python filesystem engine for caller-launched Linux/macOS guests, with basename checks, support for long filenames, protocol documentation, and regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a distinct contribution absent from current main. The previous filename and merge-conflict blockers are resolved, the recorded runtime proof still applies, and no actionable patch defects were found.

Priority: P2
Reviewed head: b913fff846e78e045668eb8bcba1cc79d269ee1e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent extraction with explicit boundaries, meaningful regressions, and sufficient real filesystem proof.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Captured Linux installed-package output exercises the exported Python engine through real filesystem writes and cross-device file/directory moves, with assertions for long names, bytes, modes, source removal, and cleanup; the proof-bearing source remains unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Captured Linux installed-package output exercises the exported Python engine through real filesystem writes and cross-device file/directory moves, with assertions for long names, bytes, modes, source removal, and cleanup; the proof-bearing source remains unchanged.
Evidence reviewed 8 items Repository policy applied: Read the complete root AGENTS.md and contribution/security policies. No nested AGENTS.md or maintainer notes were found. Reviewed confinement, publication, public exports, and changelog alignment; did not execute builds, tests, or autoreview helpers.
Current-main and release necessity: The fetched main tree has no guest implementation or guest documentation. The v0.10.0 package export map also lacks the guest subpath. The documented retirement of the host-side Python worker concerns a different execution boundary.
Previous blockers resolved: Raw test-merge parents are the pinned base b79e041 followed by the exact reviewed head. GitHub contents API blob comparisons confirmed that all three guest source modules, four guest test suites, and the package-smoke script are identical to prior reviewed revision 3e21fa7. Historical objects unavailable locally were inspected through GitHub instead.
Findings None None.
Security None None.

How this fits together

The host supplies authorized roots, operation arguments, and file bytes to a Python program inside a guest. The program performs descriptor-relative filesystem operations and returns bytes, directory listings, or exit statuses; authorization and process lifetime remain with the caller.

flowchart LR
  A[Caller authorizes roots and paths] --> B[Guest transport]
  C[Exported Python source] --> B
  B --> D[Validate basename syntax]
  D --> E[Descriptor-relative filesystem operations]
  E --> F[Guest files and directories]
  E --> G[Bytes listings and exit status]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth Production +674 lines; tests and API inventory +549 lines; package smoke +93 lines Production growth has a stated extraction rationale and a prepared downstream cutover; the claimed downstream reduction is outside this diff.
Public API addition 1 subpath, 4 runtime exports Package exports, documentation, and the public API inventory consistently describe the additive surface.

Technical review

Best possible solution:

Maintain one documented guest engine in fs-safe and migrate downstream consumers together after a separately approved package release.

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

Not applicable to the extraction as a whole; the included long-filename repair has focused regression coverage and recorded after-fix filesystem proof.

Is this the best way to solve the issue?

Yes. A source-only subpath supports guests without Node while preserving caller-owned transport and authorization, and avoids reviving the retired host-side Python worker.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded filesystem-library improvement with useful protocol consolidation and no demonstrated urgent production regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; 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. Sufficient (terminal): Captured Linux installed-package output exercises the exported Python engine through real filesystem writes and cross-device file/directory moves, with assertions for long names, bytes, modes, source removal, and cleanup; the proof-bearing source remains unchanged.
  • proof: sufficient: Contributor real behavior proof is sufficient. Captured Linux installed-package output exercises the exported Python engine through real filesystem writes and cross-device file/directory moves, with assertions for long names, bytes, modes, source removal, and cleanup; the proof-bearing source remains unchanged.

Evidence

What I checked:

  • Repository policy applied: Read the complete root AGENTS.md and contribution/security policies. No nested AGENTS.md or maintainer notes were found. Reviewed confinement, publication, public exports, and changelog alignment; did not execute builds, tests, or autoreview helpers. (AGENTS.md:1, b913fff846e7)
  • Current-main and release necessity: The fetched main tree has no guest implementation or guest documentation. The v0.10.0 package export map also lacks the guest subpath. The documented retirement of the host-side Python worker concerns a different execution boundary. (docs/migrating-to-0.5.md:29, ac371ee74846)
  • Previous blockers resolved: Raw test-merge parents are the pinned base b79e041 followed by the exact reviewed head. GitHub contents API blob comparisons confirmed that all three guest source modules, four guest test suites, and the package-smoke script are identical to prior reviewed revision 3e21fa7. Historical objects unavailable locally were inspected through GitHub instead. (d1ae4eb7d568)
  • Filename repair and boundary checks: Temporary write and move names no longer include the destination basename. The complete program validates both copy/rename leaves and single-leaf operations before dispatch opens roots. Tests cover traversal rejection without outside writes, symlink parents, hardlinked inputs, exclusive-publication collisions, and partial-publication recovery. (src/guest.ts:75, b913fff846e7)
  • Recorded real filesystem proof: The supplied body snapshot, sourceRevision 7185036c9d972296667701532602b78e35e16c376bb1e2e287ca9daa27da3e9e, includes captured successful installed-package Python output. The inspected smoke invokes the exported program with literal argv, checks distinct device IDs, moves a 131,089-byte payload to /dev/shm with 240-byte destinations, and asserts bytes, file mode, source removal, and staging cleanup. The body also records 49 passing guest cases on Linux and macOS; these tests supplement the installed-package run. (scripts/guest-package-smoke.mjs:64, b913fff846e7)
  • Explicit extraction dependency: The PR explicitly claims compatibility with OpenClaw's engine at this revision. Inspected the original complete program, native publication fragment, and applicable root/agent policy through GitHub. The original uses destination-dependent staging names; the extraction retains the operation frames and publication mechanics while adding the stated preflight and filename repairs. This is a concrete OpenClaw source dependency, with no Codex-runtime dependency. (src/agents/sandbox/fs-bridge-mutation-python.ts:15, 610f6dcfef32)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (4 earlier review cycles)
  • reviewed 2026-09-13T23:21:15.348Z sha b6e4475 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-13T23:29:51.546Z sha b6e4475 :: blocked before merge. :: [P2] Bound staging names independently of the destination basename
  • reviewed 2026-09-13T23:49:29.371Z sha b9ca0b8 :: blocked before merge. :: none
  • reviewed 2026-09-13T23:58:28.322Z sha 3e21fa7 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 13, 2026
@steipete
steipete force-pushed the codex/guest-filesystem-helper-20260913 branch from b9ca0b8 to 3e21fa7 Compare September 13, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant