Skip to content

fix: keep a file's own permissions on a macos dashboard save - #31436

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/13035-macos-acl-carry
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/13035-macos-acl-carry

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On macOS, saving a file from the dashboard keeps the access entries the owner set on that file.

On macOS, a save from the dashboard file editor, a steering document or a skill replaced the file with a new copy. The copy kept only the permissions its folder hands down, so an access entry the owner had added to the file itself was gone after one save. This is the code defect behind the first macOS test group in #12268 section 3.

Why it matters

A macOS user who narrows one file below its folder, for example so that another account cannot read it, loses that restriction the first time they save the file from the dashboard, and nothing tells them.

Not a goal

What changed (motivation → approach → change)

A dashboard save writes the new content to a temporary copy beside the file, then swaps the copy in. On Linux that save already copies the file's access entries onto the copy. macOS keeps them where that copy step does not look, so on macOS nothing was copied.

On macOS the save now gives the temporary copy exactly the replaced file's own access entries, inherited ones included, before any content is written to it (atomic_write.py, with the macOS calls in a new macos_acl.py). A file with no entries of its own, or on a disk without access lists, saves as before. If the entries cannot be read or copied, the save is refused and the original is left as it was.

A refused save still cleans up its temporary copy. When the copied entries stop a plain delete, the copy is first made owner-only (no group or other access), then its entries are emptied so it can be removed, so a "deny read" entry is never lifted while another account could still open the new content. If the copy cannot be made owner-only, it keeps its entries and stays. If its folder refuses the removal anyway, the copy gets its entries back, so a copy left behind is never less restricted than the file it was meant to replace.

The specs under docs that describe these saves say what is kept on macOS.

Backwards compatibility

Breaking: on macOS, a dashboard save of a file whose own access entries cannot be read or copied is refused and the file is left unchanged; before, that save went through and dropped the entries. Writer sweep on origin/main @ a47c2d4: the three callers that hand the shared save step the file being replaced on macOS (the dashboard file save, the steering update, the skill update) already report a failed write as a failed save. Every other caller hands it no file on macOS and is unchanged, its cleanup included.

Tests

  • On macOS, a real access entry set on a file is still there after a save, next to the new content. Fails without this change.
  • On macOS, a save refused by the file's own "deny delete" entry leaves the original as it was and no temporary copy in the folder.
  • On macOS, a temporary copy of a 0644 file carrying "deny read" and "deny delete" entries is owner-only at the moment its entries are emptied for removal. Fails without this change.
  • On macOS, when the folder also refuses removing the temporary copy, the copy left behind still carries the entry it was given.
  • On every platform, a failing macOS copy step makes the save raise, keeps the original bytes and leaves no temporary file.
  • On every Linux and macOS host, against a stand-in for the macOS system library: the copy step gives the new file the old file's entries and releases what it read, does nothing when there is nothing to carry, and raises on any other read failure or a refused write; the cleanup step makes the copy owner-only before emptying its entries, and gives them back when the removal is refused.

Determinism: both changed test files passed 20 of 20 runs at -n0, 10 of 10 at -n 2 --dist loadgroup beside two sibling files, and a shuffled order of both (seed 31436). The macOS checks compare an entry's fixed account id, so they do not depend on a name lookup.

Proof: PROVEN test/test_atomic_write_acl_preservation.py::test_macos_extended_acl_survives_a_pinned_replace, test/test_atomic_write_acl_preservation.py::test_a_temp_is_owner_only_before_its_acl_is_emptied_for_removal (head c996e57)

The production code is the same on the current head. prove.py cannot repeat that verdict there: reverting the production code also removes the module test/test_macos_acl.py imports, which stops collection before any test runs.

Manual verification

On macOS 26.7.2 (Apple silicon), an isolated gateway on loopback with its own data home saved a file carrying one extra entry (user:nobody deny read) through the dashboard's file-write endpoint:

tree entry after the save content after the save
main gone new
this change kept new

The macOS test groups from #12268 section 3 pass on main on this Mac (312 passed, 20 skipped), and the dashboard file, steering, skill and cron-merge tests pass with this change.

Screenshots / video

N/A: backend only, nothing on screen changes.

Related Issues

Part of #12268
Closes #13035

#12268 status: section 3's four test groups were already fixed on main, and this change fixes the code defect behind group 1 for the three dashboard saves. Section 1's row fix shipped; the login implementation it names is intentionally absent (a test pins that no backend implements it, and #11596 is closed). Section 2 shipped in #17721.

Sibling sweep

Siblings: none -- the three dashboard saves share the one save step this fixes, and every other caller of that step hands it no file to copy from on macOS.

Pattern harvest

Not generalizable: the loss came from one platform keeping access entries where the shared save step did not look, not from a code shape a rule could match.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 13:41
@bolichen97 bolichen97 added the ci:macos Run the on-demand macOS suite against this PR head label Nov 6, 2026
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 13:41
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 7f9997219fc6723b00add4b14e488174d0422a2f touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 13:43
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 7f9997219fc6723b00add4b14e488174d0422a2f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the macOS ACL carry sits in the shared staging step, behind the existing descriptor seam, and refuses the save when it fails.

Notes

  • The sweep claim "every other caller hands it no file on macOS" is false. snapshot_merge.py:511 passes preserve_access_control_from=dst_fd if pinned else None, and the pinned path runs on macOS, so the cron merge now also carries the ACL and can now be refused. Add it to ## Backwards compatibility.

[DESIGN-REVIEWED] 7f99972

Description read

[DESCRIPTION-READ] dc52c8eb1057a1166d503a0cf0ec342c660f62c2dde0b7b8864cc8164a7b41eb

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 7f9997219fc6723b00add4b14e488174d0422a2f — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The ACL copy goes into the shared save step itself, and the doc text this PR adds says the cron merge's in-place rewrite is no longer needed for ACLs.

Not checked: whether libSystem's acl_get_fd_np/acl_set_fd_np behave on real macOS as the code assumes.

Notes

  • Item 5 — oversized (deferred): cli.md now says "atomic_write itself carries a macOS extended ACL from a passed descriptor, so the ACL no longer needs this rewrite." That makes the in-place rewrite a second way of keeping the cron store's ACL, and it can leave a torn crons.json. Subtraction: delete _cron_rewrite_in_place (snapshot_merge.py:351) in a follow-up, and send the cron merge back through atomic_write's pinned replace.

What this change ships

Inventory (5 items) — 4 justified

Intent: on macOS, a file saved from the dashboard keeps the access entries its owner put on that file. This is a FIX.

  1. On macOS, the file editor, steering and skill saves keep the file's own extended ACL — justified
  2. On macOS, a save whose ACL can't be read or copied is now refused and the original is left unchanged — justified
  3. A refused save's temporary copy is made owner-only, its ACL emptied, then removed; if removal still fails, the ACL is set back — justified
  4. New module macos_acl with copy_extended_acl and unlink_clearing_acl, each with one consumer (atomic_write) — justified
  5. Spec text says the cron merge's in-place rewrite is redundant but keeps it — oversized: a second ACL-keeping mechanism stays

[FIRST-PRINCIPLES-REVIEWED] 7f99972

Description read

[DESCRIPTION-READ] 38ace0184af09ad335d536756597838757ee3d55f0ae7d3bc92b5e63a623262c

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 7f9997219fc6723b00add4b14e488174d0422a2f — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 7f99972

Verdict parsed from the review's SHA-scoped output markers for commit 7f9997219fc6723b00add4b14e488174d0422a2f.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 7f9997219fc6723b00add4b14e488174d0422a2f false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 7f9997219fc6723b00add4b14e488174d0422a2f and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7f99972

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 7f9997219fc6723b00add4b14e488174d0422a2f false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/13035-macos-acl-carry branch from b86fc21 to f685e26 Compare November 6, 2026 14:52
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97]

  • Cleanup exposes staged content when it clears read-denying ACLs span=37f7733cea5a
    self-added: no
    mechanism: a refused macOS save narrows its temp to owner-only before emptying the temp's ACL to remove it

fixed in f685e26: the temp is made owner-only (0600) through its descriptor before its ACL is emptied; if that narrowing fails, the temp keeps its ACL and stays.
So a deny entry is never lifted while group or other bits could admit the account it denied, and a still-refused removal sets the ACL back on the owner-only temp.
test_a_temp_is_owner_only_before_its_acl_is_emptied_for_removal pins the reported case (0644 file, deny read plus deny delete): red on b86fc21 (0644 at the emptied-ACL unlink), green on f685e26.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/13035-macos-acl-carry branch from f685e26 to 7ac7eec Compare November 6, 2026 16:40
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased: main moved in docs/system-specs/modules/cli.md, src/kiro_crew/mcp_cleanup.py, src/kiro_crew/crew_log/store.py and 10 more files beside this change since this head went green (85ce466 -> 38a8ef5); CI re-running.

The previous head's only red was test/test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget (shard 2 on Linux, Windows and macOS). This change touches nothing in that package; the test failed on main and #31469 fixed it there, and the new base carries that fix. The rebased commit is the same patch (range-diff =).

@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/13035-macos-acl-carry branch from 7ac7eec to c996e57 Compare November 7, 2026 01:15
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased: main moved in docs/system-specs/modules/cli.md, docs/system-specs/modules/memory-skills-hooks.md, docs/system-specs/modules/steering-viewer.md, src/kiro_crew/atomic_write.py, test/test_atomic_write_acl_preservation.py since this head went green (38a8ef5 -> 1f819b8); CI re-running. The Windows half of #13035 (#31695) merged in the same files, so the issue line is now Closes #13035.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 7, 2026
@bolichen97
bolichen97 force-pushed the fix/13035-macos-acl-carry branch from c996e57 to b3db98d Compare November 7, 2026 02:41
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 7, 2026
On macOS, saving a file from the dashboard (the file editor, a steering
document or a skill) replaced it with a new copy that kept only the
permissions its folder hands down. An access entry the owner had set on
the file itself was lost by a single save.

The new copy now takes the replaced file's own access entries before
any content is written to it. A save that cannot keep them is refused,
the original file is left as it was, and no temporary file is left
behind. Cleaning up that temporary file never opens its content to an
account the entries kept out.
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased: main moved in docs/system-specs/modules/cli.md, docs/system-specs/modules/memory-skills-hooks.md and other files since this head went green (c5c4de1 -> e4611c5); CI re-running. The patch is unchanged (range-diff identical). This is the third and last re-sync on this PR.

@bolichen97
bolichen97 force-pushed the fix/13035-macos-acl-carry branch from b3db98d to 7f99972 Compare November 7, 2026 04:39
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 7, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for the on-call. Review lanes pass on 7f99972, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 6f9aaf6 into main Nov 7, 2026
104 checks passed
auto-merge was automatically disabled November 7, 2026 05:37

Pull Request is not mergeable

@KiroCrewCaptain
KiroCrewCaptain deleted the fix/13035-macos-acl-carry branch November 7, 2026 05:37
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
buluoray pushed a commit that referenced this pull request Nov 9, 2026
On macOS, saving a file from the dashboard (the file editor, a steering
document or a skill) replaced it with a new copy that kept only the
permissions its folder hands down. An access entry the owner had set on
the file itself was lost by a single save.

The new copy now takes the replaced file's own access entries before
any content is written to it. A save that cannot keep them is refused,
the original file is left as it was, and no temporary file is left
behind. Cleaning up that temporary file never opens its content to an
account the entries kept out.

(cherry picked from commit 6f9aaf6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:macos Run the on-demand macOS suite against this PR head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Carry Windows DACL and macOS extended ACL on the three pre-existing overwrite sites

2 participants