Repository navigation
docs: the enterprise path, the macOS gate user, and || exit 2 on pre - #30
Merged
Merged
Conversation
docs/enterprise.md is one recommended path for an organization: a central gate over mTLS, keys in Vault, grants from directory groups, device certificates from Jamf or Intune, managed settings that lock the hooks on, and receipts to a SIEM and write-once storage, each marked built and tested or designed only. Every Claude Code managed-settings key and path was checked against the Claude Code documentation pages on 2026-10-02. scripts/writ-gate-macos.sh runs the gate as a hidden _writ account under two LaunchDaemons (the gate on a socket, and the grant renewal), with the binary root-owned, and retires the seeds of a gate that ran in place. Every pre hook in the docs now ends in `|| exit 2`: Claude Code runs the tool when a PreToolUse hook exits with any code but 2 and prints no decision, so a missing binary (127) let a Bash call run in a headless session; with the fallback it was blocked. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 4, 2026
No conflicts. README.md and docs/claude-code.md auto-merged: main's playground line and central-gate row sit alongside this branch's enterprise.md index line, the macOS setup, and || exit 2 on pre. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
A hosted macOS runner has passwordless sudo, so the gate gets its own _writ account and LaunchDaemons as it would on a laptop. The runner user stands in for the agent's user: reading the gate's seeds must be refused for permission, while root reading the same files must succeed, so a missing file cannot pass as a refusal. A Read call through the socket must be admitted and receipted, and the receipt must verify with the writ verifier outside the gate, against the response the job sent, while a different response must not. Uninstall must leave no account, daemon, process, or binary, and a hook must then fail closed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
Run 43358454491 installed scripts/writ-gate-macos.sh with sudo on a GitHub-hosted macOS 26.7.2 runner: the runner user was refused all three seeds with Permission denied while root read them, a Read call through the socket was receipted and verified with writ verify, and uninstall left nothing running. Both docs now cite the job, and say what it does not cover: a live Claude Code session, retire and unretire, and Linux. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
…nstall install copied the binary into /usr/local/bin without making it, and created the _writ account first, so on a Mac with no /usr/local/bin it stopped with the account made and nothing else. It now places the binary (making the folder root:wheel 755 when missing) before the account, and on any failure undoes only what that run created: daemons, account, state, binary, and folder. A failed reinstall keeps what was there. The macos-gate job moves the runner's /usr/local/bin aside, requires an install of /usr/bin/false to fail and leave nothing, requires a good install to make the folder root:wheel 755 and uninstall cleanly, then puts the folder back before the main test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
Treating the agent's user as the attacker: - H1: remove retire and unretire. As root they followed symlinks the user could plant, which could move the live gate's seeds or hand a root file to the user. - H2: install into /usr/local/libexec/writ, a folder the script makes, and refuse if it or any folder above is a symlink, not root's, or writable by its group or everyone. On Intel Homebrew Macs /usr/local/bin is the user's, so the user could swap the program the renew daemon runs as _writ. - M1: the SHA-256 is required (or --no-checksum), and is checked on a root-owned copy before it is moved into place, not on the source. - M2: fixed PATH and umask 022 for everything run as root. - L1: Ctrl-C, SIGTERM, and SIGHUP roll back like a failure. - L3: an existing _writ account is reused only with uid and group 350, shell /usr/bin/false, hidden, and password "*". - L4: a failed dscl search is an error, not a free uid. - L5: uninstall makes the kept state root's; install gives it back. - Reinstall: remove the stopped gate's socket before restarting, so the wait does not take the old socket for the new gate. - WRIT_GATE_LIBEXEC and WRIT_GATE_GRANT for testing and narrowing. The macos-gate job adds: missing and wrong checksum leave nothing; a runner-owned and a group-writable parent are refused; key files are 600 _writ; the runner cannot rename, overwrite, or add to the program folder while root can; a reinstall over a running gate keeps its state and a changed account is refused; uninstall leaves only root-owned state; a reinstall over it hands it back under a narrower grant that admits Read and refuses Bash. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
On macOS 26, dscl prints IsHidden as "dsAttrTypeNative:IsHidden: 1", so the account check refused the account the install itself had made (CI run on fb3f9b3, reinstall step). Accept either form, and name the value found when the password field does not match. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
The program lives in /usr/local/libexec/writ, in root-owned folders only; the install takes a required SHA-256 from a release page or a clean clone and runs with the system bash from a reviewed checkout. retire and unretire are gone: an earlier same-user gate's keys are exposed, and ~/.writ is deleted by hand. Say what the account does not do (the hooks are the user's own unless managed) and what it assumes (no NOPASSWD sudo, no unprompted Touch ID approvals); that the standing grant is broad and how WRIT_GATE_GRANT narrows it; that a reinstall over kept state reuses its keys; that uninstall leaves the state root's; and that a failed reinstall does not restore the program or plists. List what the macos-gate job now requires. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
- H1: a root chown -R follows hard links, so a gate that linked a root file into its home would be handed that file by the next install, and uninstall had the same flaw. Install now hands kept state back only to an account it just made, with nothing running as uid 350, and refuses unless every entry is a folder, a socket, or a single-named file; it then chowns with find -exec chown -h. Uninstall kills uid 350, removes every other name (which never touches the linked inode), then makes the rest root's the same way. - M1: the log folder is root:wheel 755, and each install replaces the two log files with fresh ones, _writ 0640, so the gate cannot plant a link where launchd, as root, opens them. - M2: everything runs from main, called on the last line with exit, so lines appended to the script while it runs never run. - L1: WRIT_GATE_LIBEXEC may not hold . or .. segments or sit in the gate's state; the program folder is printed first. - L2: WRIT_GATE_GRANT must keep -name session and set -uses above 0; the grant is printed before it is signed. - L3: a failed install over state kept by uninstall gives it back to root rather than leave it owned by a uid with no account. - L4: a _writ group with no _writ account is refused; a reused account's group must have gid 350 and no members. The macos-gate job adds: those settings and the stray group refused; the log folder root:wheel 755 with _writ 640 logs; and a hard link from /private/etc/hosts planted by _writ, which must succeed, after which a reinstall, an uninstall, a refused install over a link left in kept state, and a clean install must all leave hosts root:wheel. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
Add a "before you run it" section (quit every agent session; confirm the reviewed commit and a clean status right before sudo; take the program and SHA-256 from the Releases page if any agent has run as this user; /usr/bin/sudo from /bin/bash --noprofile --norc; an account compromised before the install cannot be made safe by it) and a ten-step first-run checklist for a real Mac. Show the local managed-settings.json for the socket and /usr/local/libexec/writ, root: wheel 644. Say the grant must keep -name session and set -uses above 0, and correct the sentence on what installing again replaces. Say how uninstall and install treat links in the kept state, that uninstall needs the same WRIT_GATE_LIBEXEC, and list the new CI controls. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
Three review rounds found holes in one mechanism: root changing the owner of a tree that _writ, or the user through an ACL _writ left, could shape (hard links to root files and root sockets, ACLs, 0777 folders). It is removed rather than patched again. - Install never adopts state. With no _writ account, an existing /var/db/writ is refused, and root creates the whole tree fresh. own_state, unsafe_entries, state_to_root, and every recursive chown are gone. - A reinstall over a live gate leaves the state as it is, after a tripwire: /var/db/writ, home, run, and log must have the expected owner and mode and no ACL, or it refuses. - Uninstall boots out the daemons, checks launchd no longer has them, STOPs and KILLs uid 350 until none is left, archives /var/db/writ into a new root-only tar file in /var/db (unless --purge), clears file flags, and removes the tree with rm -rf, which removes names and follows no link. - Rollback removes only the tree it created, the same way. - WRIT_GATE_GRANT is parsed as strict flag and value pairs, so a stray word cannot hide a -uses 0 from the check while Go's flag parsing stops before the later value. WRIT_GATE_LIBEXEC refuses //, a trailing /, and the state path in any letter case. - The log folder gets chmod -h -N; the log files chown -h. CI: as _writ, plant hard links to /private/etc/hosts and the root socket /private/var/run/syslog, a symlink, a FIFO, a uchg file, an ACL on the run folder, and a 0777 folder; a reinstall must refuse the ACL; uninstall must leave hosts and syslog as they were, remove /var/db/writ, and leave a root:wheel 600 archive whose audit record verifies; leftover state with no account must be refused; a clean install must give a run folder the runner cannot write. A fresh install makes new keys, and uninstall --purge writes no archive. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
Say plainly that uninstall archives the gate's keys and receipts to a root-only tar file, then deletes them; that a later install refuses leftover state and otherwise makes fresh keys; that old receipts come back only by reading the archive, by hand; and that a removed gate's keys are retired. Drop the sentences claiming a root chown could not be misled and that kept state was safe because it was root's. Describe the live-reinstall tripwire and the strict grant syntax. Verify a release tarball against SHA256SUMS and slsa-verifier, then hash the extracted writ-hook; use /usr/bin/git and PATH=/usr/bin:/bin before sudo; add dscl . -search /Groups PrimaryGroupID 350 to the checklist. List what the macos-gate job now requires. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
- HIGH: root's rm -rf of /var/db/writ, and its find -exec chflags, could be aimed outside the tree by a folder swapped for a symlink mid-walk. Both are gone. The gate's own account (as_gate, now with the fixed PATH and stdin from /dev/null) runs chflags -R and rm -rf on the contents of home and run, so a swap can only aim it at what the gate could delete anyway. Root then removes the two log files by name and rmdirs home, run, log, and /var/db/writ. If anything is left, the whole folder is renamed to /var/db/writ-leftover-<time>-<pid> and that one directory made root:wheel 700. Rollback uses the same routine. - The archive is made by the gate's account, tar writing to stdout into the root-created 0600 file, so it cannot hold root-only files the gate linked in. A failed tar, or an unreadable archive, now stops the uninstall before anything is removed. - Cron: uninstall and rollback remove _writ's crontab before stopping it, boot out launchd's user/350 domain, and remove the tab file after the account. A fresh install refuses a tab file for _writ or at jobs owned by uid 350. - Small: -uses may not start with 0 (Go reads it as octal); --no-checksum takes only a root-owned file that is not a link; a reinstall waits for launchd to let the old daemons go. CI: _writ installs a crontab, which uninstall must remove; a planted tab file must stop a fresh install; a file the gate cannot read must make uninstall stop with the keys still there and no archive left; and while uninstall --purge runs, the runner flips folders in a gate-made 0777 folder between real folders and symlinks to a root-only victim folder, whose sentinel must survive untouched. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
The unreadable file the control planted was empty, and tar does not open an empty file, so the control could not fail tar (run on fbb2f54). It now holds data. as_gate now runs from /, so a gate process never starts in a folder it cannot read. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
Drop the false claim that root's deletion follows no link. Say that uninstall removes the gate's crontab before stopping it; that the gate's own account makes the archive and empties its folders while root only removes names and empty folders; that the archive holds what the gate could read and is read by listing or by printing one member, never extracted whole as root; that a failed tar removes nothing; how a leftover folder is set aside; to uninstall rather than reinstall a gate you suspect; that --no-checksum takes only root-owned files; and add the crontab file to first-run step 2. List the new CI controls. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
The swap control's run (on 23dc056) showed uninstall reporting /var/db/writ as removed after it had moved it to a leftover folder. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
- N1: remove --no-checksum; its check and its copy read the same name, so a swap between them could install another program. The SHA-256 is always required. - N2: refuse a source that is a symbolic link or not a regular file; copy at most 256 MiB with head -c; a mismatch names no hash. - N3: as_gate runs the command in a new session through the system perl's setsid, with stdin /dev/null and stdout and stderr through pipes (cat), keeping its exit status; the comment says so. - N4: after removing the state, uninstall removes the crontab and kills uid 350 once more, and warns if anything still runs as uid 350. - N5: uninstall refuses if the _writ account does not have uid 350. - N6: safe_dir refuses an ACL on the program folder or above it. - N7: the printed hint extracts the audit record to a file and runs writ audit on it. - N8: uninstall removes files owned by uid 350 in /usr/lib/cron/jobs. - N9: scripts/check-gate-script.sh fails on a root-run recursive rm, chown, chmod, or chflags, or a find on the state tree; the macos-gate job runs it, then runs it on a copy with rm -rf "$STATE" added, which must fail. It also fails on the script at 393536e. CI also refuses a source given as a symbolic link. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
Add what a compromised _writ can still do (read and forge what the gate holds, stall uninstall or leave a leftover folder, leave uid 350 files outside /var/db/writ that a fresh install's gate would own) and the find to run before installing again. Drop --no-checksum; say the source must be a regular file; check the archived audit record from a file rather than printing it; say uninstall refuses a _writ without uid 350; list the static check and the symlinked-source refusal among the CI controls. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ
pete-builds
marked this pull request as ready for review
November 13, 2026 14:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Steps 1 and 4 of the enterprise path. Step 1 used to wait on a manual sudo run on a Mac. It is now a CI job,
macos-gate, that runs on every push and pull request, and the macOS row is marked tested on the strength of that job. Draft. The fifth review found nothing blocking (merge with notes); its notes are in, below.What changes
docs/enterprise.md: one recommended path, every part marked built and tested or designed only. Every managed-settings key and path was checked against the Claude Code docs pages, not memory:allowManagedHooksOnly,disableAllHooks,permissions.disableBypassPermissionsMode("disable"), thecom.anthropic.claudecodeplist domain,HKLM\SOFTWARE\Policies\ClaudeCode, the file paths, and source precedence (only the highest-ranked managed source applies by default). It also notes that/goaldoesn't run underallowManagedHooksOnly.scripts/writ-gate-macos.sh: runs the gate as a hidden_writaccount (no shell, no password) under two LaunchDaemons, from a root-owned program folder, with state in a fresh/var/db/writ;uninstallhas the gate archive and empty that state, then removes the empty folders by name. Passes shellcheck; the generated plists passplutil -lint.docs/claude-code.md: the macOS setup, a first-run checklist, the local managed settings file, what the separate account does and does not protect, and|| exit 2on everyprehook. Claude Code runs the tool when a PreToolUse hook exits with any code but 2 and prints no decision. Tested in a headless session: with the hook pointing at a missing binary, a Bashtouchran; with|| exit 2, it was blocked..github/workflows/ci.yml: themacos-gatejob (below). Actions pinned by commit SHA,contents: readonly, no secrets, so it runs the same on a fork's pull request.The design, after four reviews
Every hole the reviews found in the last two rounds came from one mechanism: root changing the owner of a tree that
_writ, or the normal user through an ACL_writleft, could shape (hard links to root files and root sockets, ACLs, 0777 folders). That mechanism is gone. Root never changes the owner of, or walks, anything the gate could have shaped._writaccount and/var/db/writexists, it refuses and namesuninstall, which archives it. Root then creates the whole tree fresh in root-owned/var/db, each folder withinstall -dand an explicit owner and mode. There is no recursive chown anywhere./var/db/writ,home,run, andlogmust have the expected owner and mode and no ACL (find -maxdepth 0 -acl), or it refuses.user/350domain and both daemons (waiting untillaunchctl printno longer finds them), then STOPs and KILLs uid 350 untilpgrepfinds nothing (bounded; it dies if anything survives). Unless--purgeis given, root creates/var/db/writ-archive-<time>-<pid>.tarwithumask 077and noclobber, and the gate's account writes the tree into it as a tar stream, so it holds nothing the gate could not read; a failed tar or an unreadable archive stops the uninstall before anything is removed. The gate's account then runschflags -Randrm -rfon the contents ofhomeandrun, so a folder swapped for a symlink can only aim it at what the gate could delete anyway. Root removes the two log files by name andrmdirshome,run,log, and/var/db/writ; if anything is left, it renames the whole folder to/var/db/writ-leftover-<time>-<pid>and makes that one directory root:wheel 700. Then it removes the account, group, crontab file, plists, and program.own_state,unsafe_entries,state_to_root, the hand-back block, and every recursive chown. Removed in the fourth: root'srm -rfof the tree and itsfind -exec chflags.Fifth review notes
--no-checksumis removed: its check and its copy read the same name, so a rename between them could install another program. The SHA-256 is always required.head -c); a mismatch names no hash.as_gateruns the command in a new session (setsidthrough the system perl), with stdin/dev/nulland stdout and stderr through pipes, keeping its exit status; the comment says exactly that._writaccount does not have uid 350.safe_dirrefuses an ACL on the program folder or any folder above it.writ auditon it, not printed to the terminal./usr/lib/cron/jobs.scripts/check-gate-script.shfails on any root-run recursiverm,chown,chmod, orchflags, or a rootfindon the state tree. The job runs it, then runs it on a copy withrm -rf "$STATE"added, which must fail. Run against the script at 393536e it fails on the old rootfind ... chflagsandrm -rf "$STATE"lines. This static check is what guards against root walking the tree again./var/db/writthat a fresh install's gate would own; so after a suspected compromise,sudo find /System/Volumes/Data -xdev -user 350and remove what it finds before installing again.Also from the fourth review:
crontabis setuid root andcron.denylists only Guest, so_writcould install a crontab that outlives uninstall and runs under the next install's_writ. Uninstall and rollback remove it before stopping the gate and delete the tab file after the account; a fresh install refuses a tab file for_writ, or files owned by uid 350 in/usr/lib/cron/jobs(theatspool;atis off by default on macOS, so this checks files rather thanatq).-usesmay not start with 0 (Go reads it as octal); a reinstall waits for launchd to let the old daemons go;as_gateruns from/with the fixedPATHand stdin from/dev/null.From the third review:
grant -name session -uses 0 x -uses 5passed the old check and would have signed an unlimited grant.WRIT_GATE_GRANTis now strict flag and value pairs from-name -tools -under -uses -ttl -renew-before, each at most once; anything else is refused.WRIT_GATE_LIBEXECwith//, a trailing/, or the state path in any letter case is refused.chmod -h -Non the log folder,chown -hon the log files.SHA256SUMScovers the tarballs, so the docs verify the tarball (andslsa-verifier), extract it, then hashwrit-hook; the pre-install shell uses/usr/bin/gitandPATH=/usr/bin:/bin; checklist step 2 also runsdscl . -search /Groups PrimaryGroupID 350. Uninstall's new behaviour is stated plainly: it archives then deletes the keys and receipts, a later install makes fresh keys, restoring old receipts is a manual read-only act on the archive, and a removed gate's keys are retired. The sentences claiming a root chown could not be misled, and that kept state was safe because it was root's, are gone.Earlier rounds, still in place
retireandunretireremoved (an earlier same-user gate's keys are exposed; delete~/.writby hand); the program in/usr/local/libexec/writwith every folder above it checked for root ownership and no group or world write; a required SHA-256 checked on a root-owned copy; a fixedPATHandumask 022; Ctrl-C and signals roll back; an existing_writis reused only with uid and group 350, shell/usr/bin/false, hidden, password*, and a group with gid 350 and no members; a faileddscl -searchis an error; a stray_writgroup with no account is refused.mainon its last line, so lines appended while it runs never run; the docs' first-run checklist, managed settings file, and pre-install precautions.What the
macos-gatejob provesA GitHub-hosted macOS runner has passwordless sudo. The job builds
writ-hookandwrit, then, with the runner's own user (uid 501, not root) standing in for the user Claude Code's tools run as, requires:scripts/check-gate-script.shpasses on the script and fails on a copy with a rootrm -rf "$STATE"added. An install with no checksum, a wrong one, or a source given as a symbolic link is refused, and leaves no account, daemon, program, folder, or state./var/db/writ(also as//var/db/writ/binor/VAR/DB/WRIT/bin) or with a..segment, a grant with-uses 0, without-uses, under another name, or-uses 0 x -uses 5, and a stray_writgroup with no account./usr/bin/falsefails at key setup after creating the account, and removes all of it._writunder launchd from/usr/local/libexec/writ(root:wheel 755); no ACL on/var/db/writor its folders; the log folder root:wheel 755, each log_writ640.600 _writ, and the runner user'scatfails withPermission denied; listing the folder is refused the same way.Permission denied; the same rename as root succeeds.preandpostthrough the socket are admitted and receipted, a call naming the gate's keys is refused, andreceiptsreports1 receipt(s) verified, 0 invalidwith the audit links intact. The receipt, copied out as root, verifies withwrit verify("verdict":"valid"), and a different response fails (tally_mismatch)./bin/zsh, a reinstall is refused._writ, all of these succeed: hard links to/private/etc/hostsand to the root socket/private/var/run/syslog, a symlink to/private/etc/hosts, a FIFO, a file flaggeduchg, the ACLeveryone allow add_file,add_subdirectory,delete_childon the run folder, a 0777 folder in it, and a crontab. A reinstall then refuses (carries an ACL).uninstallleaves/private/etc/hostsand/private/var/run/syslogwith the owner, group, mode, and link count they had before;/var/db/writand/usr/lib/cron/tabs/_writare gone; no uid 350 process is left; the archive is root:wheel 600, unreadable by the runner, and the audit record read out of it passeswrit audit./var/db/writwith no account is refused, and so is one with a crontab for_writplanted as root; a clean install then gives a fresh tree with no ACL, a run folder the runner user cannot create a file in, and0 receipt(s).uninstallstops on the tar failure: the keys are still there and no archive is left. Once the file is readable again,uninstallleaves no_writaccount or group, daemon, process as uid 350, program, or/var/db/writ, andprethen blocks the next call.WRIT_GATE_GRANTnarrowed to Read admits a Read and refuses a Bash call ("allows only Read"), anduninstall --purgewrites no new archive.uninstall --purgeruns, the runner user, inside a 0777 folder the gate made inrun, keeps replacing 20 folders with symlinks to/private/var/tmp/writ-victim(root:wheel 700, holding a sentinel) behind a 30,000-file folder that keeps rm busy. The sentinel survives, the folder is unchanged, and what the gate could not delete ends in a root:wheel 700 leftover folder. This is a smoke test, not a regression control: the protection comes from the delete running as uid 350, which cannot write the victim folder, and from a delete that does not follow links; it does not show the race can be won against the old code. The static check in N9 is the regression guard.Runs: green on macOS 26.7.2 arm64 at the current head, https://github.com/pete-builds/writ-protocol/actions/runs/43443301946, on the first run with the fifth-review notes.
Not covered: a live Claude Code session against the installed gate (the job writes the hook events itself), the managed settings file, an interrupted install (the traps are in place, not exercised), and the Linux setup.
Follow-ups
as_gatedepends on/usr/bin/perlforsetsid; if Apple removes perl, it needs another way to start a new session.writ-hook grantshould refuse extra arguments (if fs.NArg() != 0). The script's strict parsing covers the installed grant; the Go change needs a subprocess test, more than a few lines, so it waits for after the build freeze.~/.writreceipts out as the normal user, with no root step that follows paths in the user's folder.Merge order
#28 and #29 are merged, and main is merged into this branch.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Tx4atDCeB6HjAm4bkeL9WZ