Skip to content

fix(fs): guard skill reads and bound worker bundle staging - #147336

Merged
steipete merged 2 commits into
mainfrom
codex/fs-safe-followup-20260913
Sep 13, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fs-safe-followup-20260913

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Skill discovery can read beyond its checked metadata limits or follow a substituted file, while worker bundle preparation buffers each deploy artifact in full.

User Impact

Source-install metadata now stays within its existing 16 KiB limit, and pinned skill instructions enforce their existing 1 MiB artifact limit when first loaded. Valid aliases, source hardlinks, selected revision pins, batched metadata lookup, and cached content remain supported. Worker bundles retain their exact bytes, modes, and identities while staging with bounded memory.

Why This Change Was Made

Use published fs-safe 0.10 descriptor admission and bounded consumption for skill reads, and guarded exclusive copying followed by hashing the staged descriptor for bundle creation. Hashing the staged file adds a read pass; it avoids retaining a whole artifact buffer and keeps the archive and manifest tied to staged bytes. Copies explicitly retain the byte-copy strategy while the Linux offload fix awaits publication (openclaw/fs-safe#306).

The dependency pin, SQLite schema, cache lifecycle, worker retention, and release version are unchanged. New fs-safe API proposals are separate from this adoption.

No data migration is required: source-origin version 1, SQLite schema version 17, revision manifests and tree hashes, and worker bundle version 1 retain their existing formats and writers. The live CLI and library fixtures were produced through write owners unchanged from the PR base, then consumed by the new readers. The 16 KiB and 1 MiB limits also predate this change. This is compatibility evidence from unchanged writers and verified outputs; it is not a cross-version migration run.

Evidence

  • The later test-only commit 514d1e68d9f4 repairs a CI collision in the existing TLS proof: Gateway and its lazy sandbox now use the shared allocator for both ports. The real TLS scenario, targeted changed-file checks, and independent P2 review pass. Production files remain byte-identical to the live-tested 9c065bc commit below.
  • Five regressions fail on the original skill readers: oversized source metadata, final-link substitution, oversized/hardlinked pinned instructions, and a nested symlink in a selected revision.
  • All 56 focused tests pass across the source-install, library service, and bundle suites. Coverage includes cached pins after disk changes, state-root aliases, completed-stage source rebuilds, and a hardlinked deploy artifact larger than 16 MiB. The final source-normalization check also passed its 19 tests.
  • Full changed-file checks passed, including core/test types, lint, repository guards, and import-cycle validation. Independent review through P2 is clean.
  • Isolated live consumer proof passed on exact source 9c065bc with published fs-safe 0.10.0: an independently built CLI preserved the source-install key at 16,384 bytes, fell back at 16,385 bytes, and recovered after restoration. Runtime preparation accepted the exact 1 MiB library limit, rejected and recovered an oversized cold pin, and preserved the warm pinned hash after disk changes.
  • The actual bundle producer and system tar verified a 19,573,464-byte hardlinked artifact, fixed 0700 mode, independent hashes, stable cache reuse, and original staged bytes after a concurrent source rebuild. All nine commands exited zero. Independent evidence audit passed; the synthetic state and CLI checkout were removed. No operator Gateway or lease was used.
Selected synthetic CLI and filesystem results
{
  "source": "9c065bc2135d001523b9ce532842bd3f7c7e8cf0",
  "fsSafe": "0.10.0",
  "cliBuild": {
    "version": "2026.9.4",
    "commit": "9c065bc2135d001523b9ce532842bd3f7c7e8cf0",
    "builtAt": "2026-09-13T19:40:25.379Z",
    "buildId": "2026.9.4-9c065bc2135d-2026-09-13T19-40-25.379Z"
  },
  "sourceOrigin": {
    "name": "cli-source-install-origin-limits",
    "status": "passed",
    "observations": [
      {
        "case": "normal",
        "metadataBytes": 227,
        "skillKey": "fs-safe-source-installed"
      },
      {
        "case": "boundary",
        "metadataBytes": 16384,
        "skillKey": "fs-safe-source-installed"
      },
      {
        "case": "oversized",
        "metadataBytes": 16385,
        "skillKey": "fs-safe-source-display"
      },
      {
        "case": "restored",
        "metadataBytes": 227,
        "skillKey": "fs-safe-source-installed"
      }
    ],
    "entrypoint": "skills install --as and fresh skills info processes",
    "gateway": "implicit local fallback; no Gateway started or contacted successfully"
  },
  "consumerResults": [
    {
      "name": "pinned-library-exact-cold-limit",
      "status": "passed",
      "bytes": 1048576,
      "hash": "2386c2e2ee382afe845339fd7bbf7a6ddbe373aeab2762df6ab4d153f573ff47",
      "consumer": "prepareWorkspaceSkills"
    },
    {
      "name": "pinned-library-oversized-cold-read",
      "status": "passed",
      "oversizedBytes": 1048704,
      "rejected": true,
      "repairedSamePinLoaded": true,
      "failedReadCached": false
    },
    {
      "name": "pinned-library-cache-preservation",
      "status": "passed",
      "hash": "8b66d2bbd3091963edd6b51d01a3e994add6d7a721c021e99920224670a79c75",
      "backingFileNowOversized": true,
      "equivalentPinRetainsMetadataHash": true
    },
    {
      "name": "worker-bundle-large-hardlinked-source",
      "status": "passed",
      "workerBytes": 19573464,
      "sourceLinks": 2,
      "artifactCount": 3,
      "bundleHash": "7aff9a5aaba4c46aae3492997f48c5dc8eeef2d0428f1a4f0742d627d6f04cce",
      "tarballSha256": "79143e29218365506f1d319c28a3a30fd4dc91dddb711ef8ce9996e3ff5b11e0",
      "independentTarReader": "system tar",
      "outputMode": "0700",
      "repeatedPreparationStable": true
    },
    {
      "name": "worker-bundle-source-rebuild-after-staging",
      "status": "passed",
      "observedBoundary": "temporary TAR file created after completed staging",
      "sourceChangedBeforePrepareResolved": true,
      "sourceHash": "4489e58714b08788cea2f9bfdfd98aaa8a40165b1ba928808fb947814cf571ac",
      "archivedWorkerHash": "2820bb7369d43ed2e9db766f79b3da3a4c41842210096e9fb0a42bdce828e5ba",
      "bundleHash": "7aff9a5aaba4c46aae3492997f48c5dc8eeef2d0428f1a4f0742d627d6f04cce",
      "matchesOriginalStagedManifest": true,
      "stagingResidue": false
    }
  ],
  "cleanup": {
    "syntheticState": "removed and independently verified absent",
    "leasesCreated": 0,
    "gatewayProcessesCreated": 0,
    "syntheticStateRemoved": true
  }
}

@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 complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 13, 2026 19:42
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 4:33 PM ET / 20:33 UTC (Revision 2).

ClawSweeper review

What this changes

The PR bounds skill metadata and instruction reads, streams worker artifacts into guarded staging, and fixes port allocation in the TLS proof.

Merge readiness

⛔ Blocked before merge - 1 item remains

The fix remains useful on current main, with no blocking introduced defect found. The updated compatibility explanation, unchanged writers, and live consumer results resolve the previous migration-proof concern.

Priority: P2
Reviewed head: 514d1e68d9f4aec444e02fd7fee75f9b67b0c4ad

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with strong real-consumer evidence and no blocking correctness or compatibility finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied CLI and production-consumer output demonstrates metadata limit fallback and recovery, cold-pin rejection and recovery, warm-pin stability, and correct large-artifact archives; those production files are unchanged at the reviewed head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Supplied CLI and production-consumer output demonstrates metadata limit fallback and recovery, cold-pin rejection and recovery, warm-pin stability, and correct large-artifact archives; those production files are unchanged at the reviewed head.
Evidence reviewed 10 items Pinned introduction and review continuity: The complete introduced diff contains the filesystem changes and TLS test adjustment. Comparing the previously reviewed, live-tested revision with HEAD shows only the TLS proof file changed; production code remains identical.
Current main still needs the reader repair: Current main checks source metadata before reopening it with readFileSync, while selected library instructions are read without the artifact byte limit. The reviewed branch pins descriptors and bounds their consumption.
Release and main necessity: The latest supplied release still buffers each worker artifact with handle.readFile(). The staging owner also has no changes between the merge base and fetched main, so the proposed streaming implementation is not already present there.
Findings None None.
Security None None.

How this fits together

Skill loading turns installed metadata and selected library revisions into agent instructions. Worker bundle preparation packages deployment files into a content-addressed archive for remote execution.

flowchart TD
  A[Installed skill metadata] --> C[Guarded bounded reads]
  B[Selected library revisions] --> C
  C --> D[Cached agent instructions]
  E[Worker deployment files] --> F[Guarded staging copy]
  F --> G[Staged file hashes]
  G --> H[Worker archive]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +41, Tests +213. Total +254 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 84 43 +41
Tests 4 287 74 +213
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 371 117 +254

Review metrics

Metric Value Why it matters
Production versus test growth Production +41 net lines; tests and test support +213 net lines Production growth adds descriptor ownership and bounded reads through existing helpers; tests cover limits, aliases, cache preservation, and archive identity.

Stored data model

Persistent data-model change detected: serialized state: src/skills/library/selection.ts, serialized state: src/skills/loading/skill-entry-metadata.ts, unknown-data-model-change: src/skills/loading/skill-entry-metadata.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Use the existing filesystem safety owner while preserving valid artifacts, pinned session content, and worker archive identity.

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

Yes, source establishes unbounded selected-instruction reads and a check-then-reopen metadata path on current main; focused regressions and supplied live results cover their repair. This review did not execute a reproduction.

Is this the best way to solve the issue?

Yes. Reusing published filesystem primitives is a narrow repair, and hashing the staged descriptor preserves archive identity without buffering whole artifacts or changing stored formats.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded filesystem correctness and memory-use improvement without evidence of an urgent production outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Supplied CLI and production-consumer output demonstrates metadata limit fallback and recovery, cold-pin rejection and recovery, warm-pin stability, and correct large-artifact archives; those production files are unchanged at the reviewed head.
  • proof: sufficient: Contributor real behavior proof is sufficient. Supplied CLI and production-consumer output demonstrates metadata limit fallback and recovery, cold-pin rejection and recovery, warm-pin stability, and correct large-artifact archives; those production files are unchanged at the reviewed head.

Evidence

What I checked:

  • Pinned introduction and review continuity: The complete introduced diff contains the filesystem changes and TLS test adjustment. Comparing the previously reviewed, live-tested revision with HEAD shows only the TLS proof file changed; production code remains identical. (test/e2e/qa-lab/runtime/gateway-tls-pinning.ts:402, 514d1e68d9f4)
  • Current main still needs the reader repair: Current main checks source metadata before reopening it with readFileSync, while selected library instructions are read without the artifact byte limit. The reviewed branch pins descriptors and bounds their consumption. (src/skills/loading/skill-entry-metadata.ts:15, 6fd88d996503)
  • Release and main necessity: The latest supplied release still buffers each worker artifact with handle.readFile(). The staging owner also has no changes between the merge base and fetched main, so the proposed streaming implementation is not already present there. (src/gateway/worker-environments/bundle-staging.ts:65, 3a9d69db306c)
  • Compatibility concern resolved: The publication owner, source-install writer, protocol limits, worker hash format, dependency pin, and lockfile have no introduced changes. Existing documentation specifies immutable selected revisions and the 1 MiB file limit; the publication owner already rejects links and oversized files. No stored data-model migration is introduced. (src/skills/library/bundle.ts:1, 514d1e68d9f4)
  • Concrete dependency boundary: The changed staging owner imports the OpenClaw fs-safe facade and durability helper; these delegate copyIn and sha256File to published @openclaw/fs-safe 0.10.0. The skill readers likewise delegate descriptor admission and bounded consumption to that dependency. (src/gateway/worker-environments/bundle-staging.ts:3, 514d1e68d9f4)
  • Published copy contract inspected: GitHub resolves v0.10.0 to this commit. copyFileInRoot opens the source through its Root, honors sourceHardlinks and clone mode, performs guarded exclusive publication, verifies the source, and closes its descriptor. The separately inspected hash and bounded-read implementations consume files in bounded buffers. (src/root-impl.ts:1114, ac371ee74846)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • 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 (1 earlier review cycle)
  • reviewed 2026-09-13T19:54:36.624Z sha 9c065bc :: blocked before merge. :: none

@steipete
steipete merged commit 858ec8b into main Sep 13, 2026
320 of 323 checks passed
@steipete
steipete deleted the codex/fs-safe-followup-20260913 branch September 13, 2026 21:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to Alix-007/openclaw that referenced this pull request Sep 13, 2026
…1-prep

* commit '912ae8d96e5964dfdcdf419b79613fb941cdf0a8': (350 commits)
  fix: keep workspace preparation responsive during cleanup (openclaw#147358)
  docs: alphabetize donors and sponsors and add Red Hat logo (openclaw#147302)
  fix(plugins): retain update authority through doctor effects (openclaw#144316)
  refactor(qa): share Multipass mount retry lifecycle (openclaw#147084)
  fix(memory): emit one JSON result for command failures (openclaw#147366)
  improve(plugins): speed up cold metadata loading (openclaw#147411)
  fix(sessions): avoid duplicate work after waited child replies (openclaw#147394)
  fix(agents): retain outstanding child results in parent context (openclaw#112623)
  test: preserve native workflow loader selection (openclaw#147403)
  fix: reduce repeated work while polling session pull requests (openclaw#147373)
  test(qa): preserve task cancellation across process replacement (openclaw#147382)
  fix: prevent sidebar refresh storms during session activity (openclaw#147400)
  refactor: simplify skills CLI formatting (openclaw#147368)
  fix: prevent Git checkout certificate failures behind egress proxy (openclaw#147410)
  fix(qa): stop live threads after their process leader exits (openclaw#147386)
  refactor(release): share agent turn retry lifecycle (openclaw#147076)
  fix(ui): keep uploaded images aligned with their prompts (openclaw#147389)
  fix(fs): guard skill reads and bound worker bundle staging (openclaw#147336)
  fix(ci): restore Linux service ownership fixtures (openclaw#147398)
  fix(plugins): preserve manifest permissions when building plugins (openclaw#147393)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…147336)

* fix(fs): guard skill reads and bound worker bundle staging

* test: allocate paired ports for TLS renewal proof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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