Skip to content

fix(update): skip unreadable foreign directories during update capture - #194166

Draft
roboclaw-bot wants to merge 1 commit into
mainfrom
roboclaw/ne-191855-unreadable-entry
Draft

roboclaw-bot wants to merge 1 commit into
mainfrom
roboclaw/ne-191855-unreadable-entry

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Original-state capture and full backups abort when a workspace contains an unreadable foreign entry, such as the root-owned .fseventsd directory on a mounted APFS volume. Reported by @BorClaw.

Fixes #191855.

User Impact

Capture and backup can finish around unreadable foreign entries, with one warning per omitted path and explicit manifest omissions. Unreadable owned files, explicitly selected resources, canonical databases, and present private-capture markers still refuse. The running updater needs this repair for original-state capture; installing a corrected candidate cannot change the older updater's capture code.

Why This Change Was Made

At base 8dd41fc95291553e5885fec09992bd41c3038004, update-recovery-baseline-capture.ts:312 calls the privacy classifier before enumerating a directory. update-capture-paths.ts:18–23 probes the marker inside that directory and refuses on EACCES. The original-capture caller catches this as a continuation warning; it is not itself the stopping validation exception.

The other walks are agent scratch discovery, backup SQLite inventory, and payload tar traversal. The installed v2026.10.10 updater's broad backup-sqlite-snapshot.ts:183 reaches the same privacy check through isTraversable; its directory failures also propagate at line 192. Supplemental candidate-state discovery calls that owner during validation, inside the broad package-update catch. This is a source-supported validating-phase failure path, not identification of the report's discarded exception. Main already narrows supplemental discovery to declared plugin resources (4a393be419f3), so an unrelated workspace subtree need not be visited there. Capture and full-backup omission handling were still missing on main. Classification and exception-retention work belongs to #194160.

One shared permission/UID policy now serves the walkers. The backup inventory retains skipped paths across discovery and archiving, and checks deferred scratch-scan failures after all explicit includes are known. SQLite readability probes use descriptor-free access checks to preserve existing POSIX database locks. Capture records omissions in its existing excludedRoots; backup records unreadable-foreign entries in its existing skipped manifest. Mount traversal policy is unchanged.

Evidence

  • Pre-fix owner-boundary reproduction: both captureUpdateRecoveryBaseline and createBackupArchive failed with the reported marker lstat EACCES. The focused reproduction took 44.53 seconds including subprocess fixture preparation.
  • GREEN narrow proof: CI=1 node scripts/run-vitest.mjs src/infra/backup-tar-walk.test.ts src/commands/backup-resource-inventory.test.ts src/infra/update-capture-paths.test.ts --maxWorkers=1 — 21 passed, 4.78 seconds wall time. Covers permission-denied readdir/open, owned-file refusal, late explicit-resource protection, and privacy/symlink safeguards.
  • Committed capture and archive/manifest regressions are in the existing Doctor capture and backup ownership suites. They use real chmod-000 denial and synthetic foreign UID metadata, skip root/Windows, and include foreign SQLite plus owned-file refusal. Their complete GREEN runs and typecheck/build are pending remote CI, dispatched with target_ref=5438a832520be89cde6799215b99a711fc039950; preflight confirms that checkout SHA and passed. Build and test jobs are running; their results remain pending. CI seconds are pending. The first dispatch was cancelled after preflight rejected validation_tier=main for a cross-revision target; the linked replacement uses the supported default inputs.
  • Touched-file lint passes with config/tsconfig/oxlint.core.json; formatting, git diff --check, and commit hooks pass. A separate 200-line regression allocation preserves inherited test-line debt and leaves the shared scalar unchanged.
  • Local autoreview: Codex GPT-6.1 Sol, P0–P3, base 8dd41fc95291553e5885fec09992bd41c3038004 to local production changes, full affected production modules supplied. Explicit-resource and SQLite-probe findings were resolved; final production review is scoped-clean. Subsequent test fixture type guards and relocation into the existing ownership suite were mechanical.
  • Simplification: the permission/UID decision has one shared owner; existing manifests carry omissions without a new format or version. Necessary production growth connects the capture, discovery, and archive boundaries; net test growth is 200 lines.

Blockers / Crabbox receipt: provider blacksmith-testbox, Linux lease tbx_01m6rjrhygjtsk58zyh6kgayr3. The requested main build (pnpm build:ci-artifacts) queued before payload execution; no build or CLI update ran. The lease was stopped, then reconciliation confirmed the exact GitHub run cancelled and crabbox inspect confirmed state=completed, ready=false, hasHost=false. Built-CLI main/branch RED/GREEN with a real root-owned 0700 workspace directory remains unproven. The initial named integration/lint entrypoints unexpectedly prepared broad worker fixtures/declarations; this wrapper expansion was not repeated after recognition. Subsequent checks used the narrow walkers and source-backed touched-file lint. This PR stays draft for the missing CLI proof and remote build/typecheck/capture-suite results.

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: steipete <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 6, 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 docs Improvements or additions to documentation commands Command implementations size: M labels Nov 6, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR records and skips unreadable foreign filesystem entries during original-state capture and backup creation.

Example: UID 501 backs up a workspace containing a root-owned, mode-0700 .fseventsd directory.

  • Before: Privacy-marker inspection raises EACCES and aborts capture.
  • After: The directory is omitted with a warning and manifest entry while readable files remain captured.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is coherent and no discrete bug was established, but the explicitly required product-entry proof remains absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A foreign protected directory prevents retaining readable originals or producing a full backup.
Reason: The maintainer-authored direction addresses a concrete reported failure, while the linked issue's stopping update exception remains unresolved.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this maintainer-authored draft open: it addresses a source-supported capture failure, and no discrete correctness defect was established.

Priority: P2
Reviewed head: 5438a832520be89cde6799215b99a711fc039950

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not show shipped-CLI baseline failure and repaired capture/backup success with genuine foreign ownership, or an upgrade from latest stable preserving existing settings and data.
Agent review details

How this fits together

Update capture and backup owners inventory configuration, databases, and filesystem resources, then publish recovery manifests or verified archives.

flowchart TD
  A[Update or backup request] --> B[Resource ownership inventory]
  B --> C[Filesystem and SQLite discovery]
  C --> D[Shared permission policy]
  D --> E[Capture or archive writer]
  E --> F[Payload and omission manifest]
Loading

Technical review

Best possible solution:

Retain the shared omission policy in the existing owners and describe this PR as related to the broader update report rather than closing its unresolved validating-phase failure.

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

The reported marker-lstat EACCES maps directly to current-main directory capture and backup privacy probing; no target code was executed during this review.

Is this the best way to solve the issue?

The shared permission classifier and existing omission fields provide a focused repair without a new configuration surface or competing traversal implementation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Resource inventory and foreign SQLite treatment changes intended behavior with a stated reason (b10035f: Separate managed database snapshots from opaque foreign files while retaining ownership-based refusal.)
  • Archive traversal changes intended behavior with a stated reason (4735c02: Continue around vanished descendants while preserving required-source and I/O failures.)
  • Original-state capture changes intended behavior with a stated reason (e47d0ce: Retain configuration and declared state before updates or Doctor repairs mutate originals.)
  • SQLite header worker changes intended behavior with a stated reason (bc22cdb: Use the active runtime in an isolated declared worker and refuse unreadable candidates.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e47d0ce adds src/infra/update-recovery-baseline-capture.ts:211 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e47d0ce424bc; files: src/infra/update-recovery-baseline-capture.ts)
  • Vincent Koc: Raw commit 9203043 adds src/infra/backup-sqlite-snapshot.ts:123 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 920304344fbf; files: src/infra/backup-sqlite-snapshot.ts)

PR surface

Source +197, Tests +200, Docs +8, Other +2. Total +407 across 14 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 7 212 15 +197
Tests 5 201 1 +200
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 14 423 16 +407

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production +212/-15; tests and support +201/-1 Production growth connects four existing traversal boundaries to one permission policy; tests cover actual permission denial, omission manifests, and explicit-resource refusal.

Labels

Label changes:

  • add P2: A mounted foreign directory can prevent recovery capture or full backup, with limited scope and no demonstrated current outage.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: A mounted foreign directory can prevent recovery capture or full backup, with limited scope and no demonstrated current outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the shipped-CLI permission-denial scenario and latest-stable upgrade validation before leaving draft.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 6, 2026, 9:40 AM ET / 14:40 UTC.

@BorClaw

BorClaw commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Reporter of #191855 here — this PR targets exactly what our machine hits. Real-world data from the box that produced all three updater failures (macOS 26.3.1 arm64, updater runs as uid 501/20, admin group):\n\n$OPENCLAW_STATE_DIR contains two local volume mounts (mounted by alex; one HFS, one APFS noowners), and each volume root carries a .fseventsd:\n\n- drwx------@ 0:20 (root-owned, mode 0700, BSD flags set) — ls as uid 501: Permission denied. This is the only uid-501-unreadable class of entries in the walked tree, and it sits at a mount root inside the state dir — consistent with the original-state capture refusal in our Nov 3 runs (capture is unavailable … export refused; EACCES). Matches your before/after example one-to-one.\n- drwx------ 501:20 with a single allow readextattr ACL — owner-listable and readable, so capture ingests it (exercises the owned-and-readable path).\n- The same tree also holds an owned unix socket (srwx------ 501, live postgres socket) that the current updater already handles as an unsupported file kind warning instead of an abort — so that separate warning path works on real data.\n\nOn this machine the proposed rule (skip unreadable foreign entries with a warning + manifest omission; still refuse unreadable owned files) would unblock capture: our aborting entry is genuinely foreign (uid 0). One detail worth a look: the foreign entry is on an HFS mount, not APFS — fine if the skip logic is pure stat/ownership-based, but worth confirming the detection has no APFS-only assumption. Also note the APFS noowners mount displays root-created entries as uid-501-owned — foreign-detection by apparent uid may need the mount-option nuance if such entries exist on noowners volumes.\n\nIf a testable CLI build of this branch lands, we can run the missing RED/GREEN against this exact tree (real root-owned 0700 directory, uid 501 vs root, macOS 26.3.1 arm64) and report back.

@jamesachurchill

Copy link
Copy Markdown
Contributor

NUC reproduction: valid private markers fail only in the confined service

I can reproduce the update-capture failure described by #191855 on a Linux/systemd NUC running OpenClaw 2026.11.1.

Environment

  • OpenClaw 2026.11.1
  • Linux, systemd service
  • backup process runs as the openclaw user
  • service confinement includes NoNewPrivileges=yes, ProtectSystem=strict, and ProtectHome=read-only
  • configured state root is /opt/openclaw/data/state
  • backup command is openclaw backup create --verify --no-include-workspace --json

Reproduction

The managed update-capture markers are regular files owned by openclaw:openclaw, mode 0600, with exact content:

openclaw-private-update-capture-v1

The same marker files are readable and valid when checked as the openclaw user outside the systemd service namespace. A non-confined stock dry-run also completes.

When the same stock command is run through the confined systemd unit, it aborts before archive publication:

Private update capture marker is unreadable; export refused.

The unit's NAS ReadWritePaths drop-in was removed and the failure persists. The marker roots are ordinary ext4 directories, not bind mounts, and the enable marker for the test service is removed afterward.

A previous attended service run completed with dryRun=false, verified=true, and includeWorkspace=false; repeated runs now fail consistently at marker admission, so this needs a deterministic regression test rather than assuming the earlier success is sufficient.

Expected

Valid private update-capture markers should be recognized and the update-capture payloads omitted from the ordinary backup. The backup should continue around unreadable foreign directories when the new omission policy applies, while still refusing unreadable owned files and malformed/private markers.

Could this PR add a regression case for a valid marker under this confined systemd service context, or clarify which namespace/path-admission condition is expected to make the marker unreadable?

@blexibot

Copy link
Copy Markdown

Candidate backup scenario passes on Linux at head 5438a832520be89cde6799215b99a711fc039950; backup only, no matched base, macOS volume and update not run.

With a root-created drwx------ root root directory at <state>/workspace/state/foreign (test user uid 1001, Ubuntu 24.04 Incus container), openclaw backup create --verify --json refuses on shipped 2026.11.3 and completes on this PR's head (built from source; it reports itself as OpenClaw 2026.11.1 (5438a83)). Owned-entry refusal controls still refuse on the head. One run per cell.

Build Entry under workspace/state backup create --verify
2026.11.3 (847611d), npm root-owned 0700 foreign rc=1, Private update capture marker is unreadable; export refused.
2026.11.3, same state foreign removed by root rc=0
PR head 5438a83, source root-owned 0700 foreign rc=0, skipped entry "reason": "unreadable-foreign", warning Skipped unreadable foreign entry: …/foreign
PR head, control N1 owned dir, mode 000 rc=1, Private update capture marker is unreadable; export refused.
PR head, control N2 owned marker file, mode 000 rc=1, Private update capture marker is invalid or unreadable; export refused.

Limits:

  • No parent/base build of this branch was run with the same kit, so the release-vs-head comparison is confounded; this shows the candidate passes the scenario, not which change repairs it.
  • The head ran on state written by 2026.11.3 and printed Your OpenClaw config was written by version 2026.11.3, but this command is running 2026.11.1., plus a pending schema-migration notice and a "backup outcome could not be recorded" warning. Their effect on the result is unknown.
  • --verify shows the archive is internally valid. The archive was not opened, so whether foreign is absent, readable siblings were retained, or a restore works is unknown.
  • Not run on the head: the macOS attached-volume .fseventsd case, original update capture, and openclaw update. N1 ran with foreign still present; that the refusal came from the owned entry is inferred from the C1 pass.

Evidence packet: https://github.com/blexibot/openclaw-lab-evidence/tree/main/191855

Reproduced by an autonomous lab of AI agents using local models; I reviewed the commands, evidence and conclusions.

@blexibot

Copy link
Copy Markdown

macOS follow-up, backup path only, OpenClaw 2026.11.1-based builds (one run per cell): PR base 8dd41fc refuses, head 5438a83 completes, same guest and kit. This adds the matched base/head missing from the Linux comment above. The update-capture path could not be evaluated on this base because its capture manifest did not include the workspace; this therefore says nothing about the update-capture change.

The guest was a fresh macOS 26.6.2 arm64 VM with test user uid 501. I attached a 64 MB APFS image (hdiutil attach -owners on) under <state>/workspace/state/. Its root carries macOS's own .fseventsd (drwx------+ root staff), and stat of the private marker inside it returns Permission denied for the test user. Base and head were built from clean checkouts with the repo's packager and installed with npm install -g <tgz>. One run per cell.

Build backup create --verify, volume attached
PR base 8dd41fc (head's parent) rc=1, Private update capture marker is unreadable; export refused.
PR head 5438a83 rc=0, warning Skipped unreadable foreign entry: …/labvol/.fseventsd, manifest "reason": "unreadable-foreign"; the volume's readable file (x.txt) is in the archive with its expected content

On head, the refusal controls still refuse: an owned unreadable dir, an owned unreadable or malformed marker, and a foreign marker that is unreadable to the test user in a searchable root-owned dir. A valid marker in an owned dir still keeps that dir out of the archive. All builds succeed with the volume detached, before and after. Shipped 2026.11.3 refuses the same way as base, as reported on #191855.

Limits:

Controls, per build
Control 2026.11.3 base head
owned dir, mode 000 rc=1 unreadable rc=1 unreadable rc=1 unreadable
owned valid marker, mode 000 rc=1 invalid rc=1 invalid rc=1 invalid
owned malformed marker rc=1 invalid rc=1 invalid rc=1 invalid
valid marker in owned priv/ + secret.txt rc=0, nothing from priv/ same same
foreign marker (root 0600, unreadable to the test user) in a searchable root-owned dir rc=1 invalid rc=1 invalid rc=1 invalid

unreadable = Private update capture marker is unreadable; export refused.; invalid = … is invalid or unreadable; export refused.

Evidence packet: https://github.com/blexibot/openclaw-lab-evidence/tree/main/194166-macos

Reproduced by an autonomous lab of AI agents using local models; I reviewed the commands, evidence and conclusions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M

Projects

None yet

4 participants