# Task 1 report: read-only probes and static reads (slice F)

Status: DONE_WITH_CONCERNS. No code, no commits, nothing changed on the
Studio. Tests, mutations, copy: none (no code in this task).

Machines and dates:
- Studio outputs: `tito-studio` (hostname `Tito-Studio.localdomain`), as
  `paulca` (uid 502), over `ssh -o BatchMode=yes`, 2026-11-28 17:55Z to
  18:09Z.
- CLI reads: docs-t1, 2026-11-28 17:57Z to 18:10Z, static reads only
  (`rg -a`, `dd`), the binary was never executed.

Verdicts: the Machines page line for Tito Studio (protocol, P1 to P7,
tainted) was not fetched here; per the controller, that is the
controller's job. Not recorded in this report.

## R1 Studio basics (tito-studio, 2026-11-28 17:55Z)

```
sw_vers:        ProductName macOS, ProductVersion 27.2, BuildVersion 26B123
xcodebuild:     Xcode 27.2, Build version 27B52
xcode-select:   /Applications/Xcode.app/Contents/Developer
swift:          swift-driver 1.168.6, Apple Swift 6.4.2 (swiftlang-6.4.2.1.9 clang-2100.4.1.1)
                Target: arm64-apple-macosx27.2.0
sysctl:         hw.ncpu: 36, hw.memsize: 103079215104 (96 GiB),
                machdep.cpu.brand_string: Apple M5 Ultra
uptime:         17:55 up 19 days, 7:20, 8 users, load averages: 0.83 1.15 1.25
simctl runtimes (identifier, version, build, available, device types):
  com.apple.CoreSimulator.SimRuntime.iOS-27-0            27.0 24A434    true 62
  com.apple.CoreSimulator.SimRuntime.iOS-27-2-iPhone19-4 27.2 24B91016s true  1
  com.apple.CoreSimulator.SimRuntime.iOS-27-2            27.2 24B8117   true 63
```

Note: the BuildVersion `26B123` is what `sw_vers` printed; recorded as is.
There are three runtimes, not two: a device-specific `iOS-27-2-iPhone19-4`
runtime (one device type) sits beside the general 27.2 one. Task code
that picks "the newest iPhone simulator" should not assume one runtime
per version.

## R2 Homes, ACLs, the runner (tito-studio, 2026-11-28 17:55Z)

`ls -led /Users/*`:

```
drwxr-x---+ 51 billhorsman  staff  1632 28 Nov 17:35 /Users/billhorsman
 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
 1: group:everyone deny delete
drwxr-x---+ 16 ci           staff   512 11 Nov 17:48 /Users/ci
 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
 1: group:everyone deny delete
drwxr-x---+ 37 drbparsons   staff  1184 28 Nov 17:54 /Users/drbparsons
 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
 1: group:everyone deny delete
drwxr-x---+ 28 murraysum    staff   896  6 Oct 13:27 /Users/murraysum
 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
 1: group:everyone deny delete
drwxr-x---+ 45 paulca       staff  1440 28 Nov 15:05 /Users/paulca
 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
 1: group:everyone deny delete
drwxr-x---+ 19 paulequipo   staff   608 28 Nov 15:22 /Users/paulequipo
 0: group:everyone deny delete
drwxrwxrwt   8 root         wheel   256  9 Nov 10:37 /Users/Shared
drwxr-x---+ 41 vicky        staff  1312 28 Nov 17:29 /Users/vicky
 0: user:paulequipo deny list,search,readattr,readextattr,readsecurity
 1: group:everyone deny delete
```

This differs from what the brief recorded earlier ("no ACL"). Every other
home now carries an ACL that denies `paulequipo` list and search. So the
runner user cannot enter other people's homes, whatever their modes.
`paulequipo`'s own home has no such entry: it is `drwxr-x---` group
`staff`, and every human user is in `staff`. So any staff user can list
and traverse `/Users/paulequipo`. What they can read inside depends on
the modes of its contents, which I did not read.

`id paulequipo`:
```
uid=506(paulequipo) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),
204(_developer),702(...sharepoint.group.2),703,705,704,100(_lpoperator),707,701,706
```
`dscl`: NFSHomeDirectory /Users/paulequipo, PrimaryGroupID 20, UniqueID
506, UserShell /bin/zsh. `paulequipo` is not in `admin` (paulca is).

`ps -axo user,pid,etime,command | grep equipo-runner`:
```
paulequipo 32952 02:33:28 /Users/paulequipo/.local/lib/equipo-runner/equipo-runner run --env-file /Users/paulequipo/.config/equipo-runner/runner.env
```
One runner, up 2 h 33 min at 17:55Z.

## R3 Nested Seatbelt on macOS 27.2 (tito-studio, 2026-11-28 17:55Z to 17:56Z)

| Outer profile | Inner profile | Result |
|---|---|---|
| none | `(allow default)` | rc 0 |
| `(allow default)` | `(allow default)` | rc 0 |
| `(allow default)` | `(deny default)(allow process-exec)(allow file-read*)` | rc 71, `sandbox-exec: sandbox_apply: Operation not permitted` |
| `(deny default)(allow process-exec)(allow process-fork)(allow file-read*)` | `(allow default)` | rc 71, same message |
| `(allow default)` | `(allow default)(deny file-read* (literal "/private/etc/hosts"))` | rc 71, same message |
| `(allow default)(deny file-read* (literal "/private/etc/hosts"))` | `(allow default)` | rc 71 |
| none (control) | `(allow default)(deny file-read* (literal "/private/etc/hosts"))`, `cat /etc/hosts` | rc 1, `cat: /etc/hosts: Operation not permitted` (single profile works) |
| `(allow default)` | `(deny default)` + exec, fork, read, sysctl-read, mach-lookup | rc 71, same message |

Verdict: macOS 27.2 does not let a real profile be applied inside
another. The only nesting that "works" is two bare `(allow default)`
profiles; as soon as either side restricts anything, the inner
`sandbox_apply` fails with EPERM. Background only: the design does not
nest. It does mean anything a sandboxed command starts that itself calls
`sandbox-exec` (a nested `claude`, `srt`, a tool that sandboxes itself)
fails rather than running weaker.

## R4 What `process-info*` governs on 27.2 (tito-studio, 2026-11-28 17:56Z to 18:08Z)

Method: a scratch dir from `mktemp -d` under paulca's `$TMPDIR`
(`/var/folders/3s/.../T/r4probe.*`), removed in the same command. A
small C reader (built with `clang` in the scratch dir) calls
`sysctl({CTL_KERN, KERN_PROCARGS2, pid})`, `proc_pidinfo(PROC_PIDTBSDINFO)`
and `proc_pidpath`. Targets are processes I started with
`R4_MARKER=r4probe` in their environment: `/bin/sleep`, a non-platform
sleeper compiled in the scratch dir, `/bin/bash -c`, `/bin/zsh -c`, and
Xcode's `git hash-object --stdin`.

Plain shell (no sandbox), same uid:

| Target | `ps -E` shows env | `KERN_PROCARGS2` env |
|---|---|---|
| own process (the reader, self) | n/a | yes (1372 bytes, marker seen) |
| `/bin/sleep` (platform binary) | no | no (34 bytes: argv only) |
| `/bin/bash -c` (platform) | no | (not run; `ps -E` uses procargs2) |
| `/bin/zsh -c` (platform) | no | (as above) |
| scratch-built sleeper (ad hoc signed) | yes | yes (1356 bytes, marker seen) |
| Xcode `git` (Apple signed, not platform) | yes | (as above) |
| own login shell `$$` | marker absent, as expected: exported after the shell started |

`codesign -dv`: `/bin/bash`, `/bin/zsh`, `/bin/sleep`,
`/usr/bin/sandbox-exec`, `/usr/bin/env` all show `Platform identifier=27`;
Xcode's `git` and `xcodebuild` show `flags=0x2000(library-validation)` and
no platform identifier.

So on 27.2 the kernel hides the environment of **platform binaries**
from other processes, even of the same user, and shows it for every
other same-user process.

Inside `sandbox-exec -p '(version 1)(deny default)(allow process-exec)(allow file-read*)'`:
- the reader still read the full environment of the same-user
  non-platform sleeper through `KERN_PROCARGS2` (marker seen), and
  `proc_pidinfo` and `proc_pidpath` still succeeded for both targets;
- `kern.argmax` (plain `sysctl-read`) failed with EPERM, so the deny
  default was in force;
- adding `(allow sysctl-read)`, `(allow process-info*)`, or
  `(allow process-info* (target same-sandbox))` changed nothing;
- `/bin/ps` could not be started at all under any profile, including
  `(allow default)`: `sandbox-exec: execvp() of '/bin/ps' failed:
  Operation not permitted`. `/bin/ps` is setuid root
  (`-rwsr-xr-x root wheel`), and a sandboxed process may not exec a
  setuid binary.

What this shows for 27.2: in these tests, `process-info*` does not stop
`KERN_PROCARGS2`, `proc_pidinfo(TBSDINFO)` or `proc_pidpath` against
same-user processes. A sandboxed command can read the initial
environment of any same-user non-platform process, which includes the
`claude` binary itself. F3 is the proof under the real generated
profile; this is the hand-written-profile preview.

Two consequences, for task 9 and task 10:
- The §5 marker sweep (`ps -E` for `EQUIPO_ATTEMPT`) cannot see the
  marker on `/bin/bash`, `/bin/zsh`, `/bin/sleep`, `/usr/bin/env` or
  `/usr/bin/sandbox-exec`. Those are exactly the processes Claude's
  Bash tool starts (see S5). The sweep sees the marker only on
  non-platform children (Xcode tools, built test binaries, Homebrew
  tools).
- A token in `claude`'s environment at exec is readable by its own
  sandboxed Bash commands through `KERN_PROCARGS2`. Use the file
  descriptor path (S4) so the token is never in `claude`'s environ.

## S1 Pinned CLI digest (docs-t1, 2026-11-28 17:58Z)

The official installer `https://claude.ai/install.sh` (fetched 17:57Z)
sets `DOWNLOAD_BASE_URL="https://downloads.claude.ai/claude-code-releases"`.
It fetches `$DOWNLOAD_BASE_URL/$version/manifest.json`, reads
`.platforms["darwin-arm64"].checksum`, downloads
`$DOWNLOAD_BASE_URL/$version/$platform/claude` and checks its SHA-256. It
no longer names a `storage.googleapis.com` bucket; `downloads.claude.ai`
is the one host it uses. (`$DOWNLOAD_BASE_URL/latest` answered `2.1.332`
at 17:57Z.)

- Manifest URL: `https://downloads.claude.ai/claude-code-releases/2.1.312/manifest.json`
  (file sha256 `f9bc2d099665e498cbc4123f81f2220852c3a75ee118c0081ef83f42f165aec9`).
  Contents: `"version": "2.1.312"`, `"commit":
  "f375cd85d4f70920de17ce3a4ad646e18834e833"`, `"buildDate":
  "2026-10-27T17:16:03Z"`, `"manifestSignatureEnforcement": "flag"`.
- Binary URL: `https://downloads.claude.ai/claude-code-releases/2.1.312/darwin-arm64/claude`
- Manifest `darwin-arm64`: `checksum
  6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620`,
  `size 275988512`.
- Downloaded: 275988512 bytes, `sha256sum`
  `6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620`.
  It matches. `file`: `Mach-O 64-bit arm64 executable`.

**`claude.ExecutableSHA256DarwinArm64 = "6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620"`**

Kept for task 5: `/home/paulca/.cache/mac-slice-f-build/claude-2.1.312-darwin-arm64`,
mode `-rw-rw-r--` (no exec bit; it was never run), sha256 as above.

## S2 Sandbox settings keys (docs-t1, static)

The settings schema (zod, `nur=f(()=>u({enabled:...`) and its network
(`Rf`) and filesystem (`Tf`) parts list every key the design names:

| Key | Present | Matched text (short) |
|---|---|---|
| `sandbox.enabled` | yes | `enabled:M().optional().describe("Run Bash commands inside the sandbox. Default: false.` |
| `sandbox.failIfUnavailable` | yes | `failIfUnavailable:M().optional().describe("Exit with an error at startup if sandbox.enabled is true but the sandbox cannot start` |
| `sandbox.allowUnsandboxedCommands` | yes | `When false, the dangerouslyDisableSandbox parameter is completely ignored and all commands must run sandboxed. Default: true.` |
| `sandbox.excludedCommands` | yes | `excludedCommands:C(o()).optional().describe("Command patterns (Bash permission-rule syntax) that always run outside the sandbox.` |
| `sandbox.enableWeakerNestedSandbox` | yes, **Linux only** | `enableWeakerNestedSandbox:M().optional().describe("Linux only: Run without the fresh /proc mount` |
| `sandbox.filesystem.allowWrite` | yes | `allowWrite:C(o()).optional().describe("Additional paths to allow writing within the sandbox.` |
| `sandbox.filesystem.denyWrite` | yes | `denyWrite:C(o()).optional().describe("Additional paths to deny writing within the sandbox.` |
| `sandbox.filesystem.denyRead` | yes | `denyRead:C(o()).optional().describe("Additional paths to deny reading within the sandbox.` |
| `sandbox.filesystem.allowRead` | yes | `allowRead:C(o()).optional().describe("Paths to re-allow reading within denyRead regions.` |
| `sandbox.network.allowedDomains` | yes | `allowedDomains:C(o()).optional().describe("Domains sandboxed commands may reach without a prompt` |
| `sandbox.network.allowUnixSockets` | yes | `allowUnixSockets:C(o()).optional().describe("macOS only: Unix socket paths to allow.` |
| `sandbox.network.allowLocalBinding` | yes | `allowLocalBinding:M().optional().describe("macOS only: If true, sandboxed commands can bind to localhost ports.` |
| `sandbox.network.allowMachLookup` | yes | `allowMachLookup:...describe('macOS only: Additional XPC/Mach service names to allow looking up. Supports trailing-wildcard prefix matching (e.g., "com.apple.CoreSimulator.*")` |

Also present and relevant: `network.strictAllowlist`, `network.deniedDomains`,
`network.allowAllUnixSockets`, `autoAllowBashIfSandboxed`,
`enableWeakerNetworkIsolation` (macOS: opens `com.apple.trustd.agent`),
`allowAppleEvents`, `credentials.{files, envVars}`, `filesystem.disabled`.
`allowMachLookup` wildcards: only one trailing `*`.

Settings-source rule: the CLI refuses repo settings that negate operator
posture: `["sandbox.enabled",...,!1],["disableAllHooks",...],["sandbox.allowUnsandboxedCommands",...,!0],["sandbox.failIfUnavailable",...,!1]`
throws `negates the operator's ${de} posture (projectSettings overrides userSettings ...)`.
And `if(s.enabled===!0&&m.failIfUnavailable===void 0)m.failIfUnavailable=!0`
in the `--settings` merge: `sandbox.enabled: true` in a `--settings`
file implies `failIfUnavailable: true` unless set.

**What an empty `allowedDomains` means: ask, not "no network".** This
contradicts spec §4.1 line 393 ("empty means no network").
- macOS wrap: `ge=h?.network?.allowedDomains!==void 0||Pe?.network?.allowedDomains!==void 0,ue=b?.denyAllNetwork===!0,Ce=ge||ue` and the
  profile gets `needsNetworkRestriction:Ce`. Any defined list, even
  `[]`, puts network behind the local proxy. If neither is set the
  profile says `(allow network*)`. Claude Code itself always passes a
  defined array (`allowedDomains:z`, built from settings and
  `WebFetch(domain:...)` rules) unless the env-scrub subprocess sandbox
  is in use.
- The proxy's per-request filter, in order:
  `Denied by config rule` (deniedDomains) then `Allowed by config rule`
  (allowedDomains) then
  `if(Pe.network.strictAllowlist)return Et("No matching config rule, denying: ...")`,
  then per-command lists, then `if(!r)return Et("No matching rule, denying: ...")`,
  else `Et("No matching rule, asking user: ...")` and `await r({host,port})`.
- In headless `--print` / stream-json, the ask callback is either
  `createSandboxAskCallback(...)`, which sends the SDK host
  `{subtype:"can_use_tool",tool_name:"SandboxNetworkAccess",input:{host},description:"Allow network connection to ${m}?"}`
  and allows on `behavior:"allow"`, or `LE(e)`, which emits a
  permission denial (`emitPermissionDenied(aQ,...)`, `aQ="SandboxNetworkAccess"`)
  and returns false. In auto mode a classifier decides
  (`Auto mode classifier blocked sandbox network access to ${e}`).
- So with `allowedDomains: []` alone, every host becomes a
  `SandboxNetworkAccess` permission request to Equipo's canUseTool
  answerer. Equipo's "nobody to ask" default probably denies it, but
  that denial comes from Equipo's answer, not from the sandbox.
  `network.strictAllowlist: true` gives a deterministic deny:
  `"If true, hosts not in allowedDomains are denied without consulting the ask callback"`.
  It is honoured only from user, managed/policy or `--settings`
  (`Only honored from user, managed/policy, or CLI (--settings) settings`).
  `--settings` is how Equipo passes it, so it applies.

Recommendation for task 8 (not a stop: every needed key exists): set
`network.strictAllowlist: true` next to `allowedDomains: []`, and make
the answerer deny `SandboxNetworkAccess` as a second layer.
`enableWeakerNestedSandbox` does nothing on macOS (Linux only); do not
rely on it.

## S3 Embedded sandbox-runtime and its macOS profile (docs-t1, static)

**Version.** The binary embeds no `@anthropic-ai/sandbox-runtime`
version string. (I looked for `sandbox-runtime` with a version, `srtVersion`,
`SANDBOX_RUNTIME_VERSION`, and `package.json` fragments.) I fetched the
npm tarballs 0.0.79, 0.0.80, 0.0.81, 0.0.82 and 0.0.83 (sha512 integrity
checked against the registry; `latest` is 0.0.83, published 2026-11-13).
The embedded code matches none of them exactly:

| Fingerprint string | binary | 0.0.79 | 0.0.80 | 0.0.81 | 0.0.82 | 0.0.83 |
|---|---|---|---|---|---|---|
| `askCallbackDenyReason` | yes | no | yes | yes | yes | yes |
| `denyAllNetwork` | yes | no | no | no | no | no |
| `file mask degrades to deny on macOS until the interposer lands` | yes | no | no | no | no | no |
| `getProfileReadSecurityWarnings` | yes | no | no | no | no | no |
| `network-bind (local ip "localhost:` (proxy port bind) | no | yes | yes | yes | yes | yes |

So 2.1.312 (built 2026-10-27) vendors an unreleased sandbox-runtime
that is newer than 0.0.80 and differs from every public release up to
0.0.83. The source of truth for its profile is the generator inside the
binary, which I read directly (function `z9`, beginning
`"(version 1)",\`(deny default (with message "${q}"))\``). The spec's
"0.0.81 on main today" (§4.1) is not the embedded code.

**Generated profile defaults (from the binary):**
- `(deny default (with message "<logTag>"))`.
- Process: `(allow process-exec)`, `(allow process-fork)`,
  `(allow process-info* (target same-sandbox))`,
  `(allow signal (target same-sandbox))`,
  `(allow mach-priv-task-port (target same-sandbox))`. Note R4: on 27.2
  `process-info*` did not stop `KERN_PROCARGS2` for same-user processes.
- `mach-lookup` (fixed list): `com.apple.audio.systemsoundserver`,
  `com.apple.distributed_notifications@Uv3`, `com.apple.FontObjectsServer`,
  `com.apple.fonts`, `com.apple.logd`, `com.apple.lsd.mapdb`,
  `com.apple.PowerManagement.control`, `com.apple.system.logger`,
  `com.apple.system.notification_center`,
  `com.apple.system.opendirectoryd.libinfo`,
  `com.apple.system.opendirectoryd.membership`, `com.apple.bsd.dirhelper`,
  **`com.apple.securityd.xpc`**, `com.apple.coreservices.launchservicesd`;
  and separately, under `; Specific mach-lookup permissions for security operations`,
  **`(allow mach-lookup (global-name "com.apple.SecurityServer"))`**. So
  the Keychain API is reachable from every sandboxed command, as §4.5
  says. Opt-ins add `com.apple.trustd.agent` (enableWeakerNetworkIsolation),
  appleevents plus `lsopen` (allowAppleEvents), and the user's
  `allowMachLookup` entries (`global-name` or `global-name-prefix`).
- `file-read*`: `q9` starts with `"(allow file-read*)"`, which allows
  everything. Then it adds denyRead regions as
  `(deny file-read* ...)`, re-allows allowRead inside them, and adds
  `(allow file-read-metadata (vnode-type DIRECTORY))` when any deny
  exists. With no read config the whole read section is just
  `(allow file-read*)`. Reads are deny-list, never allow-list.
- `sysctl-read`: a fixed list (hw.*, `kern.argmax`, `kern.hostname`,
  `kern.osproductversion`, `kern.osversion`, `vm.loadavg`, and so on)
  plus prefixes `hw.optional.arm`, `hw.perflevel`, `kern.proc.all`,
  `kern.proc.pgrp.`, `kern.proc.pid.`, `machdep.cpu.`, `net.routetable.`.
  It also has `(allow sysctl-write (sysctl-name "kern.tcsm_enable"))`.
  `kern.proc.all` and `kern.proc.pid.` mean sandboxed commands can list
  every process.
- Also: `user-preference-read`, `ipc-posix-shm`, `ipc-posix-sem`,
  a few IOKit classes, `iokit-get-properties`, `AF_SYSTEM` sockets,
  `distributed-notification-post`, `file-ioctl` on /dev/null, zero,
  random, urandom, dtracehelper, tty.
- Network: `(allow network*)` only when no restriction is needed;
  otherwise, with `allowLocalBinding`,
  `(allow network-bind (local ip "*:*"))`, `(allow network-inbound (local ip "*:*"))`,
  `(allow network-outbound (remote ip "localhost:*"))`. Unix sockets
  are per path, or all of them. For the proxy ports it emits
  `(deny network-bind network-inbound (local ip "*:<port>"))` and
  `(allow network-outbound (remote ip "localhost:<port>"))`. (0.0.81
  instead *allows* bind and inbound on `localhost:<port>`.)
- Writes: `allowOnly` roots, then denies for `denyWithinAllow` plus a
  fixed list per cwd: shell rc and dangerous files (`EQn`, `vQn`),
  `.git/hooks` and `**/.git/hooks/**`, and `.git/config` unless
  `allowGitConfig`.
- The wrapper (`PGr`) runs
  `env -u <unset vars> <set vars> <proxy env> /usr/bin/sandbox-exec -p <profile> <shell> -c <command>`,
  with shell `binShell || "bash"` found on PATH. Violations are read from
  `log stream --predicate (eventMessage ENDSWITH "<random>_SBX")`, not
  `process == "sandbox-exec"` as §4.5 has it.

## S4 OAuth token by file descriptor, and the Keychain (docs-t1, static)

**File descriptor: yes.** The build reads
`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR` (36 occurrences):
`Pv(){return ... $Zr({envVar:"CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR",wellKnownPath:bte,label:"OAuth token",...})}`.
The reader parses the number, then
`let l=\`/dev/fd/${p}\`,c=mlt(l,{maxBytes:LUe}).trim()` and logs
`Successfully read ${o} from file descriptor ${p}`. If the env var is
unset it falls back to the well-known file `bte=\`${y}/.oauth_token\``.
It persists the token to disk only when `CLAUDE_CODE_REMOTE` is set
(`async function D(...){if(!i.CLAUDE_CODE_REMOTE)return;...`). The env
var itself (just the number) is deleted only in the socket case
(`delete process.env[e]` after `Leo(l)`).

Precedence (`function ha()`): apiKeyHelper (bare) > `ANTHROPIC_AUTH_TOKEN`
> `if(i.CLAUDE_CODE_OAUTH_TOKEN||o0()!==null)return{source:"CLAUDE_CODE_OAUTH_TOKEN"}`
> `if(Pv()){...return{source:"CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR"}}`
> apiKeyHelper > profile > `claude.ai` (stored, Keychain-backed). An env
token or an FD token is used before the Keychain-backed sign-in.

Other FD variables in the build: `CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR`,
`CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR`,
`CLAUDE_CODE_GATEWAY_TOKEN_FILE_DESCRIPTOR`,
`CCR_AGENT_PROXY_TOKEN_FILE_DESCRIPTOR`.

Bash children never get the token in their env: `$Tn=["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_SESSIONS_OAUTH_TOKEN",...]`
is always deleted from the child env (`M.has(o.toUpperCase())&&!L(o,d)` then `delete d[o]`).
But R4 shows that a sandboxed child can still read `claude`'s
**initial** environment through `KERN_PROCARGS2`. So the FD path is the
one that keeps the token out of reach.

**A set `CLAUDE_CODE_OAUTH_TOKEN` does not skip every Keychain read.**
- Startup prefetch, called unconditionally from the main entry
  (`process.env.NoDefaultCurrentDirectoryInExePath="1";...;rts();`):
  `function rts(){let e=yr();if(o||e)return;...s(HW(KPe))...s(HW())...}`,
  where `s(e)` runs
  `execFile("security",["find-generic-password","-a",iO(),"-w","-s",e],...)`.
  `yr` comes from the module that exports
  `function yr(){return Ne(process.env.CLAUDE_CODE_SIMPLE)||i("--bare")}`.
  So on every start, unless `--bare` or `CLAUDE_CODE_SIMPLE`, it reads
  two items: `Claude Code-credentials` and the legacy `Claude Code` API
  key item. This happens whether or not `CLAUDE_CODE_OAUTH_TOKEN` or the
  FD variable is set.
- Service name: `function HW(e=""){...return\`Claude Code${on().OAUTH_FILE_SUFFIX}${e}${a}\`}`,
  where `a` is `-<first 8 hex of sha256(config dir)>` when
  `CLAUDE_CONFIG_DIR` (or `CLAUDE_SECURESTORAGE_CONFIG_DIR`) is set, and
  empty otherwise. `KPe="-credentials"`. The account (`iO()`) is
  `process.env.USER` or the OS username, or `claude-code-user` if that
  has odd characters. So a per-session `CLAUDE_CONFIG_DIR` gives a
  per-config-dir Keychain service name.
- Other Keychain users in the build: a device-key store, service
  `"Claude Code-device-keys"`
  (`add-generic-password -U -a "${n}" -s "${C}" -X "${i}"`); the
  `/doctor` probe `"Claude Code-doctor-probe"`; and credential update
  and delete (`add-generic-password -U`, `delete-generic-password`) on
  the credentials item (sign-in, refresh, sign-out). From static reading
  I did not find a write that runs only because an env or FD token is
  in use, but I cannot prove there is none.
- `security` is spawned by bare name, resolved through `PATH`
  (`execFile("security",...)`, `it("security",...)`,
  `YUe(\`security find-generic-password ...\`)` through a shell). Only
  the confined-evaluation code names `/usr/bin/security` directly (for
  its exclusion list). So the runner can put a refusing `security` shim
  first on `claude`'s `PATH` to block the startup reads. That is a
  design option for task 10, not tested.

## S5 How Bash starts its shell, and the env scrub (docs-t1, static)

**Spawn.** The Bash shell provider returns
`{type:"bash",shellPath:e,detached:!0,stdin:"pipe",...}`, and the spawn
passes `detached:Xt.detached`:
`Wkr(ls,Es,{...,env:fLr({...}),cwd:Tn,stdio:...,detached:Xt.detached,windowsHide:!0})`.
Bun's `detached: true` on POSIX means `setsid()`: each Bash tool command
gets a **new session and a new process group** (pgid = its pid). It does
not stay in the `claude` process's group. Kill paths signal the group:
`if(I()!=="linux"&&I()!=="wsl")try{return process.kill(-p,e)}`, SIGTERM
then SIGKILL after 5 s. On macOS the chain is `<shell> -c "env -u ...
/usr/bin/sandbox-exec -p <profile> bash -c <cmd>"`, where the shell is
the user's shell (`SHELL` is set to `binShell` for bash).

Consequence for task 9 (not one of the two named stops, but it bites
§5): `SIGTERM`/`SIGKILL` to the attempt's group does not reach Bash
tool commands, because each has its own session. The §5 sweep has to
find them by marker. Per R4, `ps -E` cannot see the marker on
`/bin/bash`, `/bin/zsh`, `/usr/bin/env` or `/usr/bin/sandbox-exec`
(platform binaries); it sees it only on non-platform descendants. A
reliable sweep needs another key: a walk of the parent-pid tree from
`claude` (`kern.proc.all`), or session ids (`ps -o sess` / `getsid`)
of the per-command sessions recorded while `claude` runs, plus the
marker for non-platform children.

**`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`.** It turns on with `1/true/yes/on`
(`function On(e){...n==="1"||n==="true"||n==="yes"||n==="on"}`; also on
under `GITHUB_ACTIONS` unless explicitly `0/false/no/off`). When on:
- Bash children additionally lose the `to` list (config-path variables
  that point credential tools elsewhere), each also as `INPUT_<name>`:
  `AWS_SHARED_CREDENTIALS_FILE, AWS_CONFIG_FILE, CLOUDSDK_CONFIG,
  AZURE_CONFIG_DIR, KUBECONFIG, NETRC, PGPASSFILE, PGSERVICEFILE,
  DOCKER_CONFIG, GH_CONFIG_DIR, GNUPGHOME, NPM_CONFIG_USERCONFIG,
  NPM_CONFIG_GLOBALCONFIG, SSH_AUTH_SOCK, GIT_SSH_COMMAND, GIT_SSH,
  GIT_ASKPASS, SSH_ASKPASS, SSH_AGENT_PID, TF_CLI_CONFIG_FILE, WGETRC,
  PIP_CONFIG_FILE, UV_CONFIG_FILE, RCLONE_CONFIG, BOTO_CONFIG, BOTO_PATH,
  S3CMD_CONFIG, SOPS_AGE_KEY_FILE, ANSIBLE_VAULT_PASSWORD_FILE,
  ANSIBLE_VAULT_IDENTITY_LIST, ANSIBLE_CONFIG, GOAUTH, SBT_CREDENTIALS,
  COURSIER_CREDENTIALS, CONSUL_HTTP_TOKEN_FILE, SYSTEM_WGETRC,
  CLOUDSDK_ROOT_DIR, M2_HOME, MAVEN_HOME, LEIN_HOME, SSLKEYLOGFILE,
  GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, XDG_CONFIG_HOME, XDG_CONFIG_DIRS,
  XDG_CACHE_HOME, XDG_DATA_HOME, XDG_STATE_HOME, XDG_RUNTIME_DIR,
  HELM_REGISTRY_CONFIG, HELM_REPOSITORY_CONFIG, HELM_CONFIG_HOME,
  REGISTRY_AUTH_FILE, DOCKER_CERT_PATH, SSL_CLIENT_CERT, GIT_SSL_CERT,
  GIT_SSL_KEY, PIP_CLIENT_CERT, PGSSLKEY, VAULT_CLIENT_KEY,
  VAULT_CLIENT_CERT, CONSUL_CLIENT_KEY, CONSUL_CLIENT_CERT,
  NOMAD_CLIENT_KEY, NOMAD_CLIENT_CERT, PGSSLCERT, PGSYSCONFDIR, CURL_HOME,
  CARGO_HOME, COMPOSER_HOME, GRADLE_USER_HOME, BUNDLE_CONFIG,
  BUNDLE_USER_CONFIG, BUNDLE_USER_HOME, BUNDLE_APP_CONFIG,
  POETRY_CONFIG_DIR, COURSIER_CONFIG_DIR, HEX_HOME, HF_HOME, HF_TOKEN_PATH,
  HF_STORED_TOKENS_PATH, CONDARC, BUN_CONFIG_FILE, GOENV, NPM_CONFIG_PREFIX,
  CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE, CLAUDE_CONFIG_DIR,
  ANTHROPIC_CONFIG_DIR, ANTHROPIC_PROFILE, CLAUDE_CODE_FEDERATION_CACHE_DIR,
  CLAUDE_SECURESTORAGE_CONFIG_DIR`.
- They also lose any variable whose **name** looks like a secret
  (`m7r` then `fwe`), using the regex built from
  `Un=["TOKEN","SECRET","PASSWORD","PASSWD","PASSPHRASE","KEY","AUTH","COOKIE","PAT","DSN","WEBHOOK","CREDENTIAL","CREDENTIALS","CREDS","APIKEY",...]`,
  `$n=["PWD","PASS","JWT"]`, `Gn=[...]`, `Wn=[...]`:
  `((^|_)(Un...|(Wn...)S)|_($n...)|(Gn...))(?=$|[_0-9])`, case
  insensitive. Also `CONN_STR`-style names, `BUNDLE_*__` credentials,
  and `INPUT_`/Poetry/Conan prefixed user and password names.
- Values that look like URLs with embedded credentials are dropped or
  rewritten (`lO`, `XCn`).
- Always, scrub or not, Bash children lose `$Tn` (the CLI's own tokens,
  above), the large `eo` list of well-known secret names (GITHUB_TOKEN,
  VAULT_TOKEN and so on), `OTEL_*`, and some CLAUDE_* internals.
- Side effects of scrub mode: permission mode is forced to `default`
  (`"Permission mode forced to default — CLAUDE_CODE_SUBPROCESS_ENV_SCRUB is set (allowed_non_write_users hardening). Declare allowedTools explicitly"`);
  `autoAllowBashIfSandboxed` is off (`function zV(){return!hp()&&I()!=="windows"}`,
  `zde(){if(!zV())return!1;...}`), so sandboxed Bash goes through the
  permission answerer, not auto-allow; `--await-claim` is refused. If
  `sandbox.enabled` is not true it builds its own subprocess sandbox
  (`oSe(){return hp()&&Pie()&&!Wc()}`); with `sandbox.enabled true`
  (Equipo's Engineering profile) the normal sandbox applies.

**`EQUIPO_ATTEMPT` survives the scrub.** It is in no list (`rg -a -c EQUIPO`
finds no matches), and it does not match the name regex. Checked by
rebuilding the regex in Python from the arrays above:
`EQUIPO_ATTEMPT -`, `EQUIPO_ATTEMPT_ID -`, `EQUIPO_RUN_ATTEMPT -`, and
the controls `EQUIPO_ATTEMPT_TOKEN In`, `EQUIPO_KEY In` (scrubbed). Keep
the value plain (no `scheme://user:pass@`), keep the name free of the
listed words, and never suffix it `_KEY`, `_TOKEN`, `_AUTH`, `_PAT`
and so on. The S5 stop does not apply.

## S6 Transcript directory from cwd (docs-t1, static)

- Projects root: `function hm(){return S(Le(),"projects")}`, with
  `Le=f(()=>(B8t()??u(D(),".claude")).normalize("NFC"),B8t)` and
  `B8t(){return process.env.CLAUDE_CONFIG_DIR}`. So it is
  `$CLAUDE_CONFIG_DIR/projects`, else `~/.claude/projects`.
- Directory: `function yw(e,n=hm()){return S(n,HC(e))}`,
  `function HC(e){return KPn()??CD(e)}`.
- Override: `KPn=f(()=>B8t()||fne()?jfs(l()):void 0,S)`, where
  `l(){return process.env.CLAUDE_CODE_PROJECT_DIR_NAME}` and
  `jfs` accepts only `/^[A-Za-z0-9_-]{1,64}$/` and rejects
  `con|prn|aux|nul|com[0-9]|lpt[0-9]`. `CLAUDE_CODE_PROJECT_DIR_NAME` is
  honoured only when `CLAUDE_CONFIG_DIR` is set (or diskless).
- Default rule:
  `function k(e){return e.replace(/[^a-zA-Z0-9]/g,"-")}`,
  `function CD(e){let n=k(e);if(n.length<=lEe)return n;return\`${n.slice(0,lEe)}-${Pe(e)}\`}`,
  `lEe=200`, `function Pe(e){return Math.abs(Vme(e)).toString(36)}`,
  `function Vme(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e}`
  (a Java-style 32-bit string hash over UTF-16 code units).
- Input path: the cwd after `realpath` and `normalize("NFC")`
  (`XS(e,n){...return Hn(await J(e))}`, `Hn(t){return t.normalize("NFC")}`;
  the SDK helper does the same: `Xt(e){let s=fr(e??"."),r;try{r=cr(s)}catch{r=s}return Hn(r)}`).

So for task 7: name = `realpath(cwd)` NFC-normalised, every UTF-16 code
unit outside `[A-Za-z0-9]` replaced by `-` (an astral character becomes
`--`). If the result is longer than 200, keep its first 200 characters
and append `-` and `base36(|javaHash(realpath)|)`, where the hash is
computed on the unreplaced path. `/workspace` gives `-workspace`. On the
Mac the realpath matters: `/var/...` becomes `/private/var/...` and
`/tmp/...` becomes `/private/tmp/...`. Example:
`/Users/paulequipo/x/wt` gives `-Users-paulequipo-x-wt`. Setting both
`CLAUDE_CONFIG_DIR` and `CLAUDE_CODE_PROJECT_DIR_NAME=<attempt-safe name>`
pins the directory name outright, which is simpler than computing it.

## Stops

- S2 stop: **does not apply.** Every key the design needs is present.
  But "empty `allowedDomains` = no network" is wrong for this build.
  Empty means each host becomes a `SandboxNetworkAccess` ask to the SDK
  host. Use `network.strictAllowlist: true` for a deterministic deny.
  `enableWeakerNestedSandbox` is Linux only.
- S5 stop: **does not apply.** `EQUIPO_ATTEMPT` survives
  `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB`. But Bash tool commands run in
  their own session and process group (`detached: true`), and `ps -E`
  cannot show the marker on the platform binaries that make up that
  chain on 27.2 (R4). The §5 group-plus-marker sweep misses them as
  written.

## Only the Mac can show

- Whether `KERN_PROCARGS2` shows `claude`'s own initial environment to
  a command under the real generated profile (F3). The R4 preview says
  yes for any same-user non-platform process. `claude` is
  Anthropic-signed, not a platform binary.
- Whether the `CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR` descriptor stays
  open in Bash tool children (`ls /dev/fd` inside a sandboxed command).
  That depends on Bun's spawn closing inherited descriptors on darwin.
- Whether the startup `security find-generic-password` reads (S4) raise
  a Keychain prompt or fail quietly for `paulequipo` in a non-GUI
  session, and whether a `security` shim on PATH blocks them all.
- The actual Bash shell on the runner (`SHELL` for `paulequipo` is
  `/bin/zsh`), and the session and pgid layout of a live Bash command
  (`ps -o pid,pgid,sess,ppid`).
- Exact `realpath` of the runner's worktree root, for S6.
- Whether `xcodebuild`, `swift build` and the simulator services
  (`com.apple.CoreSimulator.*`) need more than the fixed mach-lookup
  list (P2).

## Open issues

1. Spec §4.1 says "0.0.81 on main today" and "empty means no network".
   Both differ from 2.1.312: the embedded sandbox-runtime is unreleased
   and newer, and empty `allowedDomains` asks. Task 8 should add
   `network.strictAllowlist: true` and have the answerer deny
   `SandboxNetworkAccess`.
2. Spec §5 termination: Bash commands are `setsid` children. Task 9
   needs a sweep key besides the attempt pgid and the `ps -E` marker
   (a ppid-tree walk from `claude`, or recorded session ids). Otherwise
   a sandboxed `sleep 1000 &` outlives cancel unseen.
3. Spec §4.5 names `log stream --predicate 'process == "sandbox-exec"'`.
   The build tails `eventMessage ENDSWITH "<random>_SBX"` with a
   per-session random tag. If the runner tails violations itself, match
   on `Sandbox:` and `deny` lines, not on the process name.
4. If task 9 or 10 sets `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1` (§7 line
   707), sandboxed Bash loses auto-allow and permission mode is forced
   to `default`. The answerer must allow Bash explicitly. The scrub
   also removes `CLAUDE_CONFIG_DIR`, `XDG_*`, `CARGO_HOME`,
   `GRADLE_USER_HOME`, `GIT_CONFIG_GLOBAL` and others from Bash
   commands, so builds cannot use them.
5. Keychain: a set token does not stop the two startup Keychain reads
   (S4). If D1 requires no Keychain touch at all, the options are
   `--bare`, which changes a lot, or a `security` shim on PATH. Task 10
   should decide.
6. R2: other users can list `paulequipo`'s home (group `staff`, no ACL).
   Anything secret inside it is protected only by its own file modes.
7. The Machines page line (protocol, P1 to P7, tainted) is still owed
   by the controller.

## Cleanup done

- Studio: every probe ran in a `mktemp -d` under paulca's `$TMPDIR`,
  removed in the same command (`scratch removed` printed). Probe
  processes (`sleep`, the C sleeper, `bash -c`, `zsh -c`,
  `git hash-object`) were killed. At 18:09Z:
  `no leftover probe processes`, `no r4probe scratch dirs`. Nothing of
  `paulequipo`'s was read; no settings, users, ACLs, installs, launch
  agents or the runner were touched; no sudo.
- docs-t1: the scratch dir
  `/home/paulca/.cache/tmp/claude-1001/slicef-t1.lA55Mp` (install.sh,
  manifest, npm metadata and tarballs 0.0.79 to 0.0.83, a literal
  extractor script; 76 MB) was deleted by exact name, and its absence
  confirmed.
- Kept on purpose: `/home/paulca/.cache/mac-slice-f-build/claude-2.1.312-darwin-arm64`
  (sha256 `6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620`)
  for task 5.
