Skip to content

fix(worktrees): preserve inherited ACLs on APFS - #146586

Merged
steipete merged 1 commit into
mainfrom
codex/apfs-acl-inheritance
Sep 13, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/apfs-acl-inheritance

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #146401 and #146288.

What Problem This Solves

Fixes inherited ACL permissions being omitted from descendant files and directories when managed APFS worktrees use directory-clone acceleration.

User Impact

Worktree locations that rely on ACL inheritance now use normal Git checkout and receive the same permissions as an unaccelerated worktree. ACL-free locations and destination parents with only non-inheritable ACL entries retain native cloning. No new configuration is required.

Why This Change Was Made

Apple's directory clone can inherit an ACL at the new root while omitting inheritance below it. Git content and mode validation does not detect that difference. Check destination ACL eligibility on every selection, reject ACL-bearing template roots, and recheck the parent/new root around the admitted native operation. Unknown ACL metadata also uses the existing Git fallback. Git owns file creation and inheritance; this change does not introduce an ACL-repair pass or another lifecycle owner.

The inline documentation now cites Apple's warning and XNU's unfinished descendant-inheritance note, records the known limitation without inventing Apple's complete rationale, and explains why an admitted native clone must settle before cancellation recovery. The ACL reader also documents Darwin's empty-ACL/ENOENT ambiguity and its unusual iteration return values.

Evidence

  • Real managed-service regressions compared ACLs against normal Git checkout and failed on the original descendant-inheritance loss, including cached template reuse.
  • 32 focused tests passed on native macOS, with 3 Linux-only cases skipped. Coverage includes directory/file inheritance, non-inheritable parent ACLs, stale template ACLs, parent/template ACL changes during cloning, unavailable metadata, independent contents/indexes and existing fallback/cancellation behavior.
  • Independent P0–P2 review found no actionable defect.
  • Changed-file checks and the full production build passed.
  • Five live pnpm openclaw worktrees create calls passed with isolated state: ACL-free clones shared APFS data blocks with distinct inodes, inherited ACLs matched normal Git checkout on the root/nested directory/file/symlink, and a non-inheritable parent ACL retained cloning and independent writes.

@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 00:14
@steipete steipete self-assigned this Sep 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 13, 2026
@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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 8:20 PM ET / September 13, 2026, 00:20 UTC.

ClawSweeper review

What this changes

Preserves inherited macOS filesystem permissions by falling back to Git checkout when APFS directory cloning cannot safely retain them, with native regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix: fetched main still lacks ACL eligibility checks, and no introduced blocking defect was found. The maintainer-protected PR should remain open for normal landing.

Priority: P2
Reviewed head: ee0f3756eb45441a0957392986947d0834b104e5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful native regression coverage and reported CLI validation; no blocking defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored exemption applies. The captured body additionally reports five real macOS CLI creations exercising the changed backend, with inherited ACLs matching Git and eligible clones retaining shared blocks; raw execution traces were not supplied.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored exemption applies. The captured body additionally reports five real macOS CLI creations exercising the changed backend, with inherited ACLs matching Git and eligible clones retaining shared blocks; raw execution traces were not supplied.
Evidence reviewed 8 items Introduced scope: The verified merge-base-to-head patch adds ACL inspection and fallback guards; the supplied verified test merge preserves the same five-file scope. Base-only changes were excluded from this review.
Still necessary on fetched main: Fetched main selects APFS by filesystem type and clones without checking ACLs. The existing worktreeAcceleration=false option avoids cloning globally, but does not provide automatic per-destination permission preservation.
Existing recovery owner: ACL rejection reaches the existing guarded cleanup path, which recreates the destination and invokes Git reset --hard. Creation and restore both use this checkout owner; the patch adds no ACL writer, persisted schema, or competing recovery lifecycle.
Findings None None.
Security None None.

How this fits together

Managed worktrees give agent tasks independent Git checkouts. Their filesystem backend can clone cached source templates for speed, while Git owns registration, indexes, and fallback checkout.

flowchart TD
  A[Worktree creation or restore] --> B[Inspect destination and template ACLs]
  B -->|Eligible| C[APFS directory clone]
  B -->|Inheritable or unknown| E[Git checkout]
  C --> D[Recheck ACL policy]
  D -->|Accepted| F[Independent registered worktree]
  D -->|Rejected| G[Clean cloned destination]
  G --> E
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +89, Tests +166, Docs +2. Total +257 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 92 3 +89
Tests 2 166 0 +166
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 261 4 +257

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +89 lines; tests +166 lines Production growth implements native ACL inspection and backend eligibility checks; tests compare permissions with independent Git controls.

Technical review

Best possible solution:

Keep permission inheritance with Git and retain native cloning only for eligible private templates and destinations.

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

Yes: create an accelerated APFS worktree beneath an inheritable ACL and compare descendant ACLs with an unaccelerated Git checkout. Current source and Apple's contract support this path; native execution was reported by the author, not repeated here.

Is this the best way to solve the issue?

Yes: rejecting unsafe acceleration through the existing Git fallback is narrower and more maintainable than recursively rewriting ACLs after cloning.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: Repairs permission inheritance for the bounded case of accelerated managed worktrees on APFS.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored exemption applies. The captured body additionally reports five real macOS CLI creations exercising the changed backend, with inherited ACLs matching Git and eligible clones retaining shared blocks; raw execution traces were not supplied.

Label justifications:

  • P2: Repairs permission inheritance for the bounded case of accelerated managed worktrees on APFS.
  • 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-authored exemption applies. The captured body additionally reports five real macOS CLI creations exercising the changed backend, with inherited ACLs matching Git and eligible clones retaining shared blocks; raw execution traces were not supplied.

Evidence

What I checked:

  • Introduced scope: The verified merge-base-to-head patch adds ACL inspection and fallback guards; the supplied verified test merge preserves the same five-file scope. Base-only changes were excluded from this review. (src/agents/worktrees/filesystem-backend.ts:145, ee0f3756eb45)
  • Still necessary on fetched main: Fetched main selects APFS by filesystem type and clones without checking ACLs. The existing worktreeAcceleration=false option avoids cloning globally, but does not provide automatic per-destination permission preservation. (src/agents/worktrees/filesystem-backend.ts:137, 94a56b2f78fb)
  • Existing recovery owner: ACL rejection reaches the existing guarded cleanup path, which recreates the destination and invokes Git reset --hard. Creation and restore both use this checkout owner; the patch adds no ACL writer, persisted schema, or competing recovery lifecycle. (src/agents/worktrees/checkout.ts:320, ee0f3756eb45)
  • Native regression coverage and reported runtime proof: Tests compare root and descendant ACLs against ordinary Git checkout, exercise cached-template reuse, changed ACL policy, unreadable metadata, and retained clone sharing. The complete captured PR body reports 32 native macOS tests and five supported CLI creates with matching inherited ACLs and independent writes. These are contributor-reported results; this read-only review did not execute them. (src/agents/worktrees/service.apfs.test.ts:35, ee0f3756eb45)
  • Darwin ACL contract: The patch directly calls Darwin ACL APIs. Apple's acl_get_entry implementation returns zero for an entry and -1/EINVAL at exhaustion; acl_get_flag_np returns zero or one. The published header confirms the entry selectors, extended ACL type, and inheritance flag values used by the patch. (posix1e/acl_entry.c:129, 71bbe350ab79)
  • Native inheritance limitation: The patch cites this kernel contract directly. Apple's directory-clone authorizer records unfinished ACL inheritance handling, supporting the documented limitation and the decision to delegate affected checkouts to Git. (bsd/vfs/vfs_subr.c:8879, f6217f891ac0)

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.

@steipete
steipete merged commit c0b7c48 into main Sep 13, 2026
255 checks passed
@steipete
steipete deleted the codex/apfs-acl-inheritance branch September 13, 2026 00:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation 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: 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