# Equipo: Mac runners for thin v1

Status: rev 4, ACCEPTED by Paul 2026-11-07 (his two rulings in §7),
after Astra's rounds 1 and 2 (9852fc8, 0f6eaa6) and the controller's
verification of rev 3 (460f31b). Written by Claude (Fable 5.1) from the
approved thin v1 spec (`2026-11-06-equipo-thin-v1.md`), the slice 1 to 4
logs and the code at `thin-v1-slice4` (ca0a65c). Not implemented. Facts
about `srt`, Claude Code and Codex were read from their current docs on
2026-11-07; what still needs a probe on the Mac is marked.

## 0. The problem and the shape of the answer

Woodstar is an iOS app. On the Linux runner its checks step says "Checks
can't run here (needs macOS)" (`judge.go: needsMacOS`) and Engineering
cannot build or run it. Paul has a shared Mac, Tito Studio
(`tito-studio`, Tailscale 100.64.0.1). He wants work that needs macOS
to go there without choosing anything.

The answer is a second runner of the same person, a **worker**, enrolled
with one install command and one tap. The worker advertises what it can
do; the instance places each step on a runner that can do it; the
coordinator stays on the primary (docs-t1) and only says where things
ran. Linux keeps bubblewrap unchanged. The Mac trusts the harness
sandboxes, as Paul ruled.

Rev 2's structural change: **the worker never holds the forge
credential.** Only the primary talks to Amadan. The primary fetches the
exact candidate and ships it to the worker as a verified git pack
through the instance; the worker returns its commit the same way, and
the primary pushes through `internal/runner/forge` exactly as today. That
removes a credential-transfer protocol and means nothing that escapes
the Mac's sandbox can reach the forge.

## 1. Several runners per person

### 1.1 Roles and identity

Today `primaryRunner` (`chat_wiring.go`) is the newest unrevoked runner
of an owner. Rev 2 adds an explicit `role` (`primary` or `worker`) to
the `runners` row, in an additive migration that marks every existing
runner `primary`: the production and staging primaries do not move. A
person's first enrolment is primary; later ones are workers. The
coordinator session, move-in, notebook, catalog index, forge credential
and `watch_merge` live on the primary. Workers run steps.

Identity is unchanged: each machine runs `equipo-runner enrol`, gets a
device code and a runner credential of its own, and holds one outbound
WebSocket with acks, generation lease and the `lease` check from
slice 1. **Enrolment in one tap:** the Mac installer (§3) ends by
running `enrol` and prints one link. Paul taps it; the page says "Add
Tito Studio to your team" (`scutil --get ComputerName`) with one button.
Because a primary exists, the row is a worker.

### 1.2 The mailbox becomes runner-addressed

The slice 1 mailbox is person-keyed: `commandRecord{Person, Kind, Body}`,
`Pending` serves whatever is pending for the person once it has checked
the connection is the primary, `ack` and the inbox are per person, and
`syncSteps` scans the person's queued and running steps. Rev 2 keeps the
tables and adds a destination:

- Migration 0045 adds `runner_commands.runner_id` and `steps.runner_id`
  (both indexed) and `runners.role`, in this order inside one
  transaction: add the columns; backfill every runner `primary`; backfill
  every command and every existing step, in every state including
  running, pending termination and queued, with the person's primary at
  migration time (the `primaryRunner` query, run per person); only then
  does the code that enforces ownership (below) ship, in the same
  release, so no existing attempt is ever reported or reconciled against
  an empty owner. A step with an empty `runner_id` after migration is a
  bug the schema check fails on. `txn.command` takes a runner id;
  message, cancel, reset, `watch_merge` and `publish` commands name the
  primary.
- `Pending` serves only commands whose `runner_id` is the connection's
  runner; `ack` marks a command acked only if the acking connection is
  that runner and holds the current generation and process (the
  `current(lease)` check that exists today). Inbox dedup stays
  transactional per frame id.
- A step report is accepted only from the runner recorded on the step
  row and only for the current attempt (added to `stepReport`'s existing
  forward-only and attempt checks). `syncSteps` scans only steps whose
  `runner_id` is the syncing runner, so a worker's sync can neither
  settle the primary's work nor a Linux attempt still awaiting its
  termination proof. Turn reconciliation stays primary-only.
- Tests: a worker acking the primary's command is a no-op; a worker's
  sync omitting a step owned by the primary leaves it untouched; a
  report from the wrong runner is refused; a Linux step pending
  termination survives a worker's sync and still refuses Retry
  (`TestStepPendingTermination` extended with a second runner); a
  migration test runs 0045 over a slice 4 database holding a running
  step, a pending-termination attempt and unacked commands, and shows
  every row bound to the old primary and every slice 1 to 4 contract
  test still green on it.

### 1.3 The capability report

`hello` gains `platform {os, arch}`, `label`, `sandbox` (`bubblewrap` or
`seatbelt`) and `capabilities`, a bounded object (40 simulators, 300
bytes per string, 8 KB total) the runner computes at start, re-probes
hourly and on disagreement, and sends with every 30 s heartbeat; the
instance stores the newest beside the `hello` column:

- `xcode {version, build}` from `xcodebuild -version`; empty on Linux.
- `simulators [{name, runtime, udid, state}]` from `xcrun simctl list -j
  devices available`.
- `toolchains {go, swift, node}` and `harness {claude, codex, srt}`
  versions.
- `accounts` as today, one per provider home on that machine.
- `tags` from the fixed set `linux`, `macos`, `xcode`, `ios_simulator`,
  `claude`, `codex`, `go`.

No path, credential or raw tool output; a guard test checks every field.

### 1.4 Needs, placement, pinning and withdrawal

Each step declares `needs`, a subset of the tag set, derived by the
instance from facts it holds, never by the model:

- Checks: `macos`, `xcode` (and `ios_simulator` when the repository has a
  shared scheme) when `needsMacOS(changed, gateText)` is true. The rule
  moves instance-side: the primary's index reports `needs_macos` per
  repository in `RepoInfo`, and the Engineering step report says
  whether its change touched Apple files.
- Engineering (slice F only): `macos`, `xcode`, `ios_simulator`, `claude`
  for a `needs_macos` repository. Until then, nothing.
- Review: nothing. Ask the implementer: pinned (below).

**Placement** runs in `advance` when a step is created and whenever a
runner comes online while steps wait: among the person's unrevoked
runners whose tags cover the needs, prefer the primary; else the online
worker with the fewest running steps; ties by enrolment order. The step
row records `runner_id` and the dispatch is written to that runner's
mailbox in the same transaction. `DispatchCommand` carries `needs`; a
runner receiving needs it lacks refuses with `placement_refused` and the
step is re-placed.

**Pinning.** A task's Engineering runner is chosen at the first
Engineering step and stored on the task (`tasks.engineering_runner`);
fix rounds, retries and republishes go there, so two runners never
touch one branch. Ask the implementer resumes the exact `(step, attempt,
account, session_id)` recorded on the step row, on the runner that holds
it; a different runner, account or a later attempt is refused, and an
offline runner gets "Tito Studio is offline; ask again when it is back."

**Withdrawal.** An unacked dispatch is not an undelivered one: the
runner records a dispatch durably and wakes the step engine before it
sends the ack (`link.go: read`), so a lost ack leaves executable work.
Rev 3 therefore stops reasoning about delivery and makes **starting an
attempt a transaction on the instance.** The runner already does a lease
round trip before any step executes (`judge.go: lease`, `Engineer.lease`);
that frame becomes `lease{generation, step_id, attempt}` and the
instance acks it only inside a write transaction that finds the attempt
assigned to this runner and not withdrawn, and sets `steps.started_at`
there. Withdrawal is the other side of the same row: in one transaction
it marks the attempt `withdrawn`, which `Pending` never serves again,
and reads `started_at`. If it is empty, nothing can ever run: a later
start authorization for that attempt is refused and the runner deletes
its row with reason `withdrawn`. If it is set, the work is possibly
running: the instance sends `cancel_step` and waits for the terminal
report with termination before it creates the next attempt elsewhere,
exactly the Retry rule. This is chosen over "treat every unacked
dispatch as possibly running" because it costs nothing new (the round
trip exists), it is exact rather than conservative, and SQLite's
serialisation of the two writes is the proof. Tests: a lost ack (the
instance resends, the runner's inbox dedups, the attempt is authorised
once and runs once); withdrawal committed just before the start
authorization (start refused, no process, re-placement proceeds at
once); withdrawal committed just after it (withdrawal sees `started_at`,
takes the cancel path, and the next attempt exists only after
termination); a delayed report for a withdrawn or older attempt refused;
a delayed checks or review result for an older SHA dropped by the
judged-SHA rule so it cannot make a newer candidate Ready
(`TestContractReviewAndChecks` gains both delayed-report cases).

**Honest outcomes when nobody fits.** No runner has ever had the tags:
checks end `cannot_run`/`needs_macos` at once (today), Engineering runs
on the primary with today's summary. A fitting worker is offline: the
step is `queued`, `placement: waiting_runner`, card line "Waiting for
Tito Studio (offline since 10:12)". After 30 minutes a checks step is
withdrawn and resolves `cannot_run`/`runner_offline`, never a pass, and
review proceeds; an Engineering step keeps waiting and raises Needs you
`runner_offline`; Cancel stays available.

### 1.5 Health and the Runners view

Online is today's `runnerOnline` window per runner. `GET
/api/v1/runners` returns `{items: [Runner]}`; `snapshot` gains
`runners` (singular `runner` stays one release). The `runner` event
fires per runner. The Team section lists runners by label with an
online dot. `status()` lists them; `read_task` carries each step's
`runner_label`; house rule 2026-11-07.8: mention where a step runs only
when it is not the primary.

## 2. Candidates travel as packs, not credentials

The worker has no clone and no forge access. Objects move inside a
**transfer**, a row the instance opens and that authorises every chunk:
`transfers{id, person, from_runner, to_runner, repo, task_id, step_id,
attempt, base_sha, candidate_sha, direction, state, expires_at}`. An
inbound transfer (primary to worker) is opened in the same transaction
as the worker's dispatch. An outbound one (worker to primary) is opened
when the instance accepts the worker's `step{state: running, phase:
committed, candidate_sha}` report for the current attempt, for exactly
that candidate. The primary (which already builds a one-commit pack with
`rev-list --objects --no-walk` and `pack-objects`, `judge.go:
checkRepository`) or the worker then sends `blob{transfer, index, total,
sha256, data}` frames, `data` base64 under 192 KB so a frame stays under
`MaxFrameBytes`, durable and acked like any other.

**Authorization, checked before bytes are kept.** The instance accepts a
chunk only from the connection of `from_runner`, holding its current
generation, for a transfer in state `open` whose attempt is the step's
current attempt and not withdrawn, cancelled or superseded; anything else
is refused with `transfer_refused` and logged. `Pending` serves chunks to
`to_runner` only. The receiver, before `index-pack`, checks the transfer
header against its own step row: repository, task, step, attempt, base
and candidate must match, and the direction must be the one it expects.
A transfer closes when its last chunk is acked or its attempt ends, and
its chunks are deleted; a 24-hour TTL sweeps the rest. Tests, apart from
byte tampering (M7): a stale attempt's chunks refused after Retry; a
second worker uploading for a transfer not its own; chunks for task A
sent under task B's transfer; a candidate that does not match the
opened transfer; an inbound transfer answered in the outbound direction.

**Integrity.** The worker reassembles, checks `sha256`, runs `index-pack`,
and refuses the step (`candidate_unavailable`) unless the pack yields
exactly the dispatched `candidate_sha` with a complete tree. Bound: 64 MB
per transfer; above it the step is `cannot_run`/`checks_unavailable`
with "candidate too large to relay". The worker keeps objects per
repository under its state dir, and later dispatches carry a thin pack
against the `have` list in its reports, so Woodstar moves once.

**Publication stays the primary's word.** For Engineering on a worker
(slice F) the worker commits as the runner does today (`add -A`,
`write-tree`, `commit-tree` on the base, identity `Equipo Engineering`),
reports `committed` with `candidate_sha`, uploads the thin pack in the
outbound transfer, and ends its step `done` with `pushed: false`. A
worker report carrying `pushed: true` is refused. The step gains
`publication` (`none`, `pending`, `published`, `failed`): when the
outbound transfer completes, the instance sets `pending` and writes a
durable `publish{task, step, attempt, candidate_sha, base_sha, transfer}`
command to the primary's mailbox in the same transaction. The primary
indexes the pack into the task's private repository, verifies the
commit's parent is the dispatched base and its tree complete, confirms
the lease **and the publication id** immediately before the push (the
existing pre-push confirmation, widened so a cancelled publication is
refused), and calls `PushBranch` with every check it has today
(repository, task branch, descendant of base, person, `--force-with-lease`,
record then reconcile). It then reports durable `published{task, step,
attempt, candidate_sha, pushed, reason}`; only this report, from the
primary, for the current attempt and candidate, sets `Step.Pushed` and
`publication: published`, and only then does `advance` create the checks
and review steps. `published{pushed: false}` sets `failed` with
`push_failed` or `push_conflict` and Needs you `retry`; Retry re-sends
`publish` for the recorded commit (slice 4's republish) without running
Engineering again. The primary keeps a `publications` table; its `sync`
lists the ones it holds, the instance resends unacked `publish` commands,
and `PushBranch`'s record-then-reconcile makes a repeat idempotent.
Tests: push failure then Retry publishes the same commit once; primary
SIGKILLed after indexing and before the push, restarted, pushed exactly
once; primary SIGKILLed after the push and before `published`,
reconciled from the remote on restart; cancel after pack receipt and
before push: no push, the candidate never published, the worker's
objects swept; the worker's `pushed: true` refused. Paul's ruling of
2026-11-07 stands beside this: Equipo merges its own Ready-to-merge work
(slice 4c, on the primary), and a Mac Engineering candidate flows into
that path unchanged once the primary has published it; merging is not
designed here.

What a worker can reach if its sandbox is escaped (§4.3): its own
enrolment key and state, so it could report a false result **for steps
placed on it**, and later the model account homes on that machine. It
cannot push, cannot read the primary's state and cannot touch another
person's work: the instance accepts its reports only for its own steps
and attempts (§1.2). A worker's checks verdict is labelled with the
runner on the task page, so a person reading "Checks passed (xcodebuild
test, Tito Studio)" knows whose word it is.

## 3. Install, update, discovery, sign-in and the dedicated user

### 3.1 Artifacts

`make release` adds `releases/equipo-runner-darwin-arm64-<version>/`
(`equipo-runner`, `equipo-tool-proxy`, `io.amadan.equipo-runner.plist`,
the installer), built `CGO_ENABLED=0 GOOS=darwin GOARCH=arm64` on Linux
CI (the runner uses `modernc.org/sqlite`). Go ad-hoc signs darwin/arm64
binaries and `curl` sets no quarantine attribute, so Gatekeeper does not
block them. `install-manifest.json` gains a `targets` map (`linux/amd64`,
`darwin/arm64`) with digests; `install-v1.sh` dispatches on `uname`;
`make staged-check` records both targets.

### 3.2 One command, then one tap

`curl -fsSL https://<instance>/install.sh | sh` installs to
`~/.local/lib/equipo-runner`, writes
`~/Library/LaunchAgents/io.amadan.equipo-runner.plist` (`RunAtLoad`,
`KeepAlive`, `ProcessType Standard` so builds are not throttled, logs
under `~/Library/Logs/equipo-runner/`, `ProgramArguments` `equipo-runner
run --env-file ~/.config/equipo-runner/runner.env`, a new flag since
launchd has no `EnvironmentFile`), loads it with `launchctl bootstrap
gui/$UID`, installs `srt` with `npm install -g` when `npm` is present
(else one printed line; checks report `checks_unavailable` until it is),
then runs `enrol` and prints the link. A user agent runs only while that
user has a GUI session; a sleeping Mac is an offline worker; the runner
wraps every step in `caffeinate -i`.

### 3.3 Discovery and update

At start the runner looks for `claude`, `codex` and `srt` at
`~/.local/bin`, `/opt/homebrew/bin`, `/usr/local/bin`, `npm root -g`,
then a login shell's `PATH`; versions go in the capability report;
`EQUIPO_CLAUDE_PATH` still overrides. Update: `welcome` gains `release`;
an older worker downloads its target from `/releases/<version>/`,
verifies the manifest digests, swaps the binary between steps and exits
0 for `KeepAlive`.

**Version-aware encoding.** `wire.Strict` rejects unknown fields and
`Frame.Decode` rejects unknown types, so nothing new may reach a runner
that has not said it understands it. `hello` gains `protocol` (2 for
this spec; absent means 1, the slice 4 wire) and `welcome` echoes the
protocol the instance will speak, the lower of the two. The instance
encodes every frame per connection with `wire.Encode(frame, protocol)`:
to a protocol 1 runner it sends exactly the slice 4 frame set and field
set (`welcome` without `role` or `release`, `dispatch` without `needs` or
`runner_id`, `lease` without step fields, no `blob`, `publish` or
`published`), it places no step whose needs are non-empty on it, and it
treats its capability report as the Linux default. A protocol 1 runner
is always a primary. The fixture tests encode every new frame at both
protocols. **Upgrade order:** instance, then the primary, then workers;
a runner's release comes only from its own instance, so a worker cannot
run ahead. The reverse pair (a newer runner against an instance rolled
back) still happens, so a runner whose protocol 2 `hello` is refused by
a strict decode (the close the instance already sends for a bad frame)
retries once with a protocol 1 `hello`, logs that the instance is older,
and runs as a protocol 1 runner until its next `welcome` says otherwise.
Mixed versions are tested with actual binaries (§6, M8).

### 3.4 Account sign-in and the Keychain hypothesis

`equipo-runner login claude` works as on Linux: a dedicated home under
`~/.local/share/equipo/accounts/claude-<n>`, the official login, the
observed email recorded. Claude's docs describe separate configuration
directories for several accounts, and on macOS the CLI may keep its
OAuth token in the login Keychain rather than in the home. Both "one
file per home, the Linux copy cycle applies" and "one Keychain item per
macOS user, native refresh, one account" are hypotheses until probe P3
answers them with sentinel items. Checks-only (slices D, E) needs no
account on the Mac at all; Engineering (F) waits for P3.

### 3.5 A dedicated macOS user per person (Paul's ruling)

A runner on a shared Mac runs as a standard (non-admin) macOS user named
for its owner, `equipo-<person-handle>`: on tito-studio, `equipo-paul`.
Never a shared `equipo` user: each runner holds its owner's model
sign-ins and runner identity, and Unix permissions are what separate
people. The box is shared, so those permissions are the hard boundary
around Paul's and others' homes, with Seatbelt denies as the second
layer; the runner's Keychain, DerivedData, simulators and caches stay
out of his own account; and a process sweep can fall back to "every
process of user `equipo-paul` outside the runner". The dedicated user
still owns the runner's own enrolment key and state, which §2 bounds.
Probe P4 verifies, rather than assumes, that other homes on tito-studio
are unreadable by `equipo-paul` (`ls` and a sentinel read against each
`/Users/*`), and the installer refuses to enrol while a readable foreign
home exists or while it is running as a user not named `equipo-*`.

Paul must, once: create the user `equipo-paul` (System Settings, Users &
Groups, Standard); add it to the developer group (`sudo dscl . append
/Groups/_developer GroupMembership equipo-paul`); log it in with fast
user switching and leave it logged in, sleep off while plugged in; open
a terminal as that user, paste the install command, tap the link.
Xcode's licence and `DevToolsSecurity` are machine-wide and already
accepted; the installer runs `xcodebuild -runFirstLaunch`. A second
person on the same Mac repeats this as `equipo-<their-handle>`.

## 4. The macOS sandbox, per step kind

### 4.1 What the harnesses give us (verified 2026-11-07)

Claude Code's sandbox (`sandbox.enabled`) is built on
`@anthropic-ai/sandbox-runtime`, Seatbelt on macOS, and covers **shell
commands only**; Read, Edit, Write and WebFetch "follow permission rules
instead." A headless run takes `--settings <file>`, above user and
project files and below managed settings. Keys used here:
`sandbox.enabled`, `failIfUnavailable`, `allowUnsandboxedCommands`,
`excludedCommands`, `filesystem.{allowWrite, denyWrite, denyRead,
allowRead}`, `network.{allowedDomains, allowUnixSockets,
allowLocalBinding, allowMachLookup}`.

`srt` (Apache-2.0, `npm install -g @anthropic-ai/sandbox-runtime`, 0.0.81
on main today, Node 22.12 or later, `ripgrep`) wraps one command:
`srt --settings <path> -- <cmd> <args>`. Its settings JSON has
`network.allowedDomains` (empty means no network), `allowUnixSockets`,
`allowLocalBinding`, `allowMachLookup` (in `sandbox-config.ts`),
`filesystem.denyRead`, `allowRead`, `allowWrite` (empty means no writes),
`denyWrite`, `allowPty`, `enableWeakerNetworkIsolation`,
`allowAppleEvents`. On macOS it runs `sandbox-exec` with a generated
Seatbelt profile; its profile allows `securityd` and `SecurityServer`
lookups (`macos-sandbox-utils.ts`), so denying `~/Library/Keychains` on
disk does not deny the Keychain API; network goes through a local proxy
named by `HTTP_PROXY`/`HTTPS_PROXY`/`ALL_PROXY` and the profile allows
only that loopback port. `~` expands; paths are git-style globs. A
mandatory deny list blocks writes to shell rc files, `.gitconfig`,
`.git/config` and `.git/hooks` even inside `allowWrite`.

Codex's `workspace-write` (`sandbox_mode`, `[sandbox_workspace_write]`,
app-server `turn/start.sandboxPolicy`) is Seatbelt too and now documents
filesystem read-deny rules under permissions. Codex on the Mac stays
parked (slice G) because the thin runner has no Codex step path until
slice 5 and nesting `codex` under `srt` is unproven (P5).

### 4.2 Equipo's deny list (every profile)

`denyRead` and `denyWrite`: the runner's state dir (enrolment key,
steps, relayed objects), the accounts root, the session homes, `~/.ssh`,
`~/.aws`, `~/.gnupg`, `~/.config/op`, `~/Library/Keychains`, every home
under `/Users` other than the runner user's, `/Volumes`, and the install
dir for writes. There is no forge credential on the machine to list.

### 4.3 Xcode's services: a boundary to prove, not assume

`xcodebuild` talks over Mach to CoreSimulatorService and XCBBuildService,
per-user launchd services outside any sandbox, and a repository's build
phases, SwiftPM plugins and tests are code the repository controls. It
does not follow from sandboxing `xcodebuild` that code those services
execute inherits the sandbox. Probe P2 is therefore the gate on checks:
a hostile Woodstar-shaped fixture whose run-script phase, SwiftPM build
tool plugin and XCTest each try to read a sentinel file in the runner's
state dir and in another `/Users/*` home, to open a TCP connection and a
DNS lookup, and to read a sentinel Keychain item, all under the §4.4
checks profile. Checks on the Mac are enabled only when every attempt is
denied; a denial that depends on Unix permissions rather than Seatbelt
is recorded as such. A successful Woodstar build is not evidence. **If
P2 fails, checks still run on the Mac** (Paul's ruling), labelled "ran
outside the sandbox": the step and task carry `checks_sandbox: none`,
the label shows on the checks badge, in the task timeline and on the
Ready to merge card, and it is not a pass in disguise. The bound of §2
holds (a worker can lie only about its own steps and cannot push). The
coordinator's auto-merge (slice 4c) treats such checks as passed only
for repositories the task's creator owns; that rule is noted here and
designed there.

### 4.4 Profiles

**Checks** (no harness, so `srt`): the runner writes a per-attempt
settings file and runs `srt --settings <file> -- /bin/bash -c <gate>` in
the checks tree (the exact SHA, with the one-commit `.git` as today).
`allowWrite`: the tree, the attempt's DerivedData and temp dirs under
scratch, the runner user's `DARWIN_USER_TEMP_DIR` (resolved and checked
at start; Xcode writes there whatever `TMPDIR` says),
`~/Library/Developer/Xcode/DerivedData`,
`~/Library/Caches/org.swift.swiftpm`, `~/Library/org.swift.swiftpm`;
§4.2 denies; `network.allowedDomains` empty; `allowMachLookup` set to
exactly what P2 shows `xcodebuild test` needs. A network failure is
`needs_network`, honest, as on Linux. Environment from scratch: `HOME`,
`DEVELOPER_DIR` from `xcode-select -p`, `TMPDIR` the attempt dir, `CI=1`,
a fixed `PATH`. Exit code and the last 200 lines are recorded as today.

When the repository has no `.amadan/ci.d`, `.amadan/ci` or `make ci` but
has an `.xcodeproj` or `.xcworkspace`, the Mac runner synthesises
`xcodebuild test -scheme <scheme> -destination 'platform=iOS
Simulator,name=<device>' -derivedDataPath <attempt dir>
CODE_SIGNING_ALLOWED=NO`, gate name `xcodebuild test`: the one shared
scheme, or the one named like the project; the newest available iPhone
simulator from the report. Several candidates or none is
`cannot_run`/`checks_unavailable`. Simulator builds need no signing
identity; device builds are out of scope.

**Engineering** (slice F, Claude Code): `claude -p` as today
(`--setting-sources ''`, `--strict-mcp-config`, pinned tools) plus
`--settings <per-attempt file>` with `sandbox.enabled true`,
`allowUnsandboxedCommands false`, `failIfUnavailable true`,
`excludedCommands []`, `allowWrite` the worktree plus the DerivedData
and SwiftPM paths, the §4.2 denies, `allowedDomains` empty,
`allowMachLookup` per P2. The `claude` process talks to Anthropic as the
runner user outside the sandbox, the trust Paul granted.

**Native file permissions, ported explicitly.** `claude/answers.go`
hard-codes `/workspace`: `workspaceNativePath` and `protectedNativePath`
test that prefix, and the symlink check walks a Linux mount. On the Mac
the worktree is a real path, so the Darwin port makes the workspace
root a policy field, resolves every requested path with `realpath`
against the worktree root and the §4.2 list before answering, generates
permission `deny` rules for Read, Edit, Write, Glob and Grep on the
§4.2 paths alongside the sandbox denies, and keeps the "nobody to ask"
default. Tests against sentinel files: an alias through `/private` and
`/var` (macOS symlinks), a glob that expands outside the root, `..`
components, and a symlink swapped after the check (the race the Linux
comment already names; on the Mac the generated native deny rules are
the second layer). `StepPermission` and `ReadPermission` share the port.

**Review** (`inspect`): Read, Glob and Grep only, no shell, so Seatbelt
has nothing to do; the ported `ReadPermission` confines reads. Review is
placed by §1.4 and usually stays on the primary.

**Ask the implementer**: the inspect tool set on the pinned session
(§1.4), needing step sessions kept per task (session home copied back
as the coordinator's is); built in slice F.

### 4.5 Honest limits

`sandbox-exec` is deprecated by Apple but still what both harnesses use;
`failIfUnavailable` turns its removal into a stop. No PID namespace, no
uid isolation, no resource limits; path rules resolve through symlinks;
allowed Mach lookups are open, including `securityd`. Network filtering
is a proxy plus environment variables without TLS termination; we allow
no hosts. Claude's sandbox covers shell commands only; hooks, MCP servers
and `apiKeyHelper` run unsandboxed (Equipo disables hooks and pins MCP).
Violations show only in `log stream --predicate 'process ==
"sandbox-exec"'`, which the runner tails and counts in the step log.

The user's temp folder is shared between attempts. After each sandboxed
attempt the runner shuts its simulators down and removes what appeared
there, but a check can leave changes inside folders that existed before
the attempt. The runner user is per person and holds no secrets, so v1
accepts this. The v2 path is a disposable Mac user per attempt.

## 5. Termination on macOS

No namespace and no pidfd proof. Each attempt starts in its own session
and process group with `EQUIPO_ATTEMPT=<key>` in its environment. Cancel
or timeout: `SIGTERM` to the group, 10 s, `SIGKILL` to the group, then a
sweep (`ps -axo pid,pgid,user,command`, `ps -E` for own processes) that
kills anything with the group id or the marker, then `xcrun simctl
shutdown` for simulators the attempt booted. **Termination is reported,
and Retry allowed, when `kill(-pgid, 0)` returns `ESRCH` and the sweep
finds no marked process, within 30 s.** `StepReport` and `Step` gain
`termination_kind` (`namespace` or `process_group`). Not covered: a
child that leaves the group and scrubs its environment; XCBBuildService
and CoreSimulatorService, which survive by design. Startup after a crash
kills every marked process before reporting `runner_restarted`. The
Linux rule is untouched: a Linux step's termination is still the
verified namespace exit, and nothing in §1.2 lets another runner supply
it.

## 6. Wire, API v1, fixtures and testing

Frames (protocol 2 only): `hello` adds `protocol`, `platform`, `label`,
`sandbox`, `capabilities`; `welcome` adds `protocol`, `role`, `release`;
`dispatch` adds `needs`, `runner_id`; `lease` adds `step_id`, `attempt`;
new `blob{transfer, index, total, sha256, data}` both ways, `publish`
(instance to primary) and `published` (primary to instance), all
durable; `step` adds `termination_kind`, `have []string`, `phase`; new
step reasons `placement_refused`, `withdrawn`, `transfer_refused`; new
checks reason `runner_offline`. Resources: `Runner` adds `label`, `role`, `since`,
`platform`, `capabilities`; `RunnerList` at `GET /api/v1/runners`;
`Snapshot.runners`; `Step` adds `runner_id`, `runner_label`, `needs`,
`placement`, `publication`, `termination_kind`; `Task` adds
`engineering_runner` and Needs you `runner_offline`. Fixtures: `api/runners.json`,
`api/task-placed.json`, `api/task-mac-checks.json` (pass and fail with
`exit_code`), `frames/hello-mac.json`, `frames/welcome-worker.json`,
`frames/dispatch-needs.json`, `frames/blob.json`,
`frames/step-process-group.json`.

Copy for review (existing marker until Luna's pass): "Add %s to your
team", "Waiting for %s (offline since %s)", "Checks can't run here (%s
was offline)", "Needs you: %s has been offline for 30 minutes", "Checks
are running on %s", "Checks passed (%s, %s)", "%s is offline; ask again
when it is back", "Runners".

**Linux CI.** The fake worker is the real thin runner started with
`EQUIPO_FAKE_PLATFORM=darwin/arm64`, a fixture capability report from P1,
a fake `xcodebuild` that passes, fails or hangs, and the process-group
executor **without** a sandbox, compiled only under a `testbuild` tag so
no release binary can run unsandboxed. Darwin-only code (`srt` settings,
`simctl` parsing, plist, scheme discovery, sweep, the native permission
port) is unit-tested with recorded outputs. Scenarios, under the
two-minute budget: M1 iOS change, checks placed on the worker via blob
relay, real pass, review on the primary, Ready; M2 worker offline,
waiting, reconnect, run; and the 30-minute path with a fake clock to
`runner_offline`; M3 no worker, `needs_macos` (`4_checks_honest` still
green); M4 worker SIGKILLed mid-checks, `process_group` termination,
Retry, pass; M5 fake gate fails, fix round from its output; M6 one-tap
enrolment as worker, mailbox scoping (wrong-runner ack, sync and report
all refused), `placement_refused` and re-place, withdrawal of an unacked
dispatch, cancel-then-reassign of an acked one, a delayed old-SHA report
that cannot make a newer candidate Ready; M7 blob tampering (bad
`sha256`, wrong SHA, oversize, missing chunk) refused; M8 mixed
versions with the real slice 4 binaries (instance and runner built from
ca0a65c in CI and cached as artifacts): the slice 4 runner against the
new instance speaks protocol 1, runs the `oficina/sample` scenario to
Ready, and never receives a `blob` or a `needs` field; the new runner
against the slice 4 instance falls back to protocol 1 after one refusal
and runs the same scenario; a new worker enrolled against the slice 4
instance is refused with a clear log line and nothing is lost; M9 (slice F) Engineering on the worker returns a thin pack, the
primary pushes, pinning holds across a fix round and a republish; ask
the implementer pinned and refused elsewhere. All slice 1 to 4 guards
stay, especially Linux termination before Retry.

**Probes on tito-studio, before any Darwin build work** (slice C):

- P1 record `xcodebuild -version`, `simctl list -j`, `ComputerName`.
- P2 the hostile fixture of §4.3 under the checks profile; which Mach
  services `xcodebuild test` needs; denial of every sentinel attempt.
- P3 `claude /login` with `HOME` set to an empty dir: Keychain item or
  file; whether a second home gets a second identity; sentinel Keychain
  items readable from inside the shell sandbox or not.
- P4 home permissions of every `/Users/*` as `equipo-paul`; `launchctl
  bootstrap gui/$UID` as non-admin; fast-user-switch and sleep.
- P5 `srt -- codex exec` under `workspace-write`: nested Seatbelt.
- P6 group SIGKILL during `xcodebuild test`: what survives; is `simctl
  shutdown` needed before the tree can be removed.
- P7 `npm install -g @anthropic-ai/sandbox-runtime` as `equipo-paul`.

**Witness** (slice E): staging worker under `equipo-paul` with its own state
root, enrolled as a worker of the staging owner; re-judge the Woodstar
witness task `tklkbx5vid3y` at `82a4a0cc`. Pass: the checks step records
`xcodebuild test` (or Woodstar's gate), a real exit code, 200 lines of
Xcode output, `passed` or `failed`, never `cannot_run`; the pack arrived
by relay; Review stayed on the primary. Zero model turns. The live
`oficina/suite` scenario still lands on the primary unchanged.

## 7. Slices, decisions and risks

| Slice | Content | Size |
|---|---|---|
| A Mailbox destinations and protocol | migration 0045 with the step backfill and its test, `runner_id` on commands and steps, per-runner `Pending`, ack, reports and `syncSteps`, roles with existing runners primary, `protocol` negotiation and `wire.Encode`, M6's scoping cases, M8 with the slice 4 binaries | 2 days |
| B Placement, transfers and publication | capability report, `needs`, placement in `advance`, start authorization and withdrawal, pinning, offline rule, `runners` API and view, fake worker (testbuild only), transfers with authorization tests and M7, `publish`/`published` with the crash and cancel tests, M1 to M6 | 3 days |
| C Mac probes | P1 to P7 on tito-studio, fixtures recorded, P2 verdict written up | 1 day plus Paul's steps |
| D Darwin checks-only | darwin/arm64 target and manifest, installer and plist, discovery, `--env-file`, self-update, process-group termination, `srt` checks profile from P2, `xcodebuild test` synthesis | 2.5 days |
| E Witness | Woodstar real pass or fail on tito-studio | 0.5 day |
| F Mac Engineering and Review | native permission port with its tests, Claude sandbox settings, sessions per step, pinning in anger, return packs and primary push, M9, live Woodstar swipe-back built and tested on the Mac | 3 days |
| G Codex on the Mac | after slice 5 and P5 | parked |

**Paul's rulings, 2026-11-07:**

1. **Dedicated user: yes, one per person.** A runner on a shared Mac
   runs as a non-admin user `equipo-<person-handle>` (`equipo-paul`),
   never a shared `equipo` user: each runner holds its owner's model
   sign-ins and runner identity, and Unix permissions separate people
   (§3.5).
2. **If P2 fails, checks still run on the Mac,** labelled "ran outside
   the sandbox" on the checks badge, in the timeline and on Ready to
   merge; never a pass in disguise. The slice 4c auto-merge treats them
   as passed only for repositories the task's creator owns (§4.3).

No decisions remain open.

**Risks.** P2 may fail and bring ruling 2 into play. P3 may limit the Mac to one
Claude account; checks-only does not care, Engineering's Review label
stays honest. A shared Mac is a shared CPU: one step at a time per
worker, `caffeinate` only while a step runs. Pack relay through the
instance costs storage and bandwidth once per repository and a thin pack
per candidate; the 64 MB bound and TTL keep it small, and the instance
stores opaque bytes it never interprets. The mailbox migration touches
every command path; slice A ships alone, with every slice 1 to 4
scenario green before B begins.

## 8. Addendum, 2026-11-28: slice F against today's code

Written while planning slice F (plan
`docs/superpowers/plans/2026-11-28-mac-runners-slice-f.md`), from `main`
at 8bd40ed1, the unmerged branch `mac-placement-wait` (570375ec) and
read-only probes of tito-studio as `paulca`. Sections 1 to 7 stay as
accepted; where this section disagrees with them about slice F, this
section is current. Nothing here reopens slices A to E.

### 8.1 Facts that moved

- **Numbers.** Migrations are past 0114 and the runner protocol is 35
  (`wire.ProtocolCurrent = ProtocolChangeDiffs`). "Migration 0045" and
  "protocol 2" in §§1 to 3 are history. Slice F takes the next protocol
  (36, `ProtocolMacEngineering`, confirmed with the parent before code,
  since other branches also allocate numbers) and at most one migration.
- **The machine.** tito-studio is reached at its own Tailscale address
  (100.76.110.54), not 100.64.0.1. It runs macOS 27.2 on an M5 Ultra (36
  cores, 96 GB), Xcode 27.2 (27B52), with iOS 27.0 and 27.2 simulator
  runtimes. Seven people have homes there and several run Claude Code
  sessions all day, so it is a busy shared machine. Sleep is off.
  `DevToolsSecurity` reports developer mode off; simulator work as a
  `_developer` member does not need it.
- **The runner user** is `paulequipo` (Paul, 2026-11-10 and 2026-11-13:
  any Standard user with "equipo" in its name; the 11-11 taint
  accepted). Its home is `drwxr-x---` group `staff` with no ACL for
  other users, so **every other Studio user can list and traverse it**
  (verified from `paulca`). Paul's own home has the ACL that shuts out
  `paulequipo`; the reverse direction was never needed while the Mac
  held no secret. Slice F puts a model credential on the Mac, so it now
  matters (§8.3).
- **Enrolment.** The Studio is enrolled to production as worker "Tito
  Studio" (2026-11-28). One enrolment per macOS user, so there is no
  staging worker. The slice F witness therefore runs on production
  behind an instance switch (§8.6), unless Paul makes a second Mac user
  for staging.
- **Placement.** `mac-placement-wait` (to merge before slice F) makes
  Mac work wait instead of running on Linux: checks needing macOS with no
  fitting runner wait (`waiting_mac`), and Engineering for a repository
  whose base gate needs Xcode (`RepoInfo.NeedsMacOS`) never runs on a
  Linux primary (`waiting_mac`, or `waiting_mac_engineering` while the
  only fitting runners are workers). One compatibility exception stays:
  a protocol 1 primary, which has no workers, still runs it as before.
  §1.4's "Engineering runs on the primary with today's summary" no
  longer holds otherwise. Slice F replaces `waiting_mac_engineering`
  with placement on the worker.
- **Checks sandbox.** srt is installed privately with pinned Node,
  ripgrep and lockfile, not `npm install -g`. The P2 verdict lives only
  in the worker's memory and is trusted only under those pins; a runner
  that ever ran checks outside the sandbox is tainted for good. Ruling 2
  became, by delegation (2026-11-11), "checks wait for the Mac's
  sandbox; the task's creator may run one attempt outside it from the
  task page" (`chat/macsandbox.go`).
- **Accounts.** §3.4 (`equipo-runner login claude`, the Keychain
  hypothesis, probe P3) is superseded by Connections (2026-11-08) and
  token connections (Paul, 2026-11-10): a pasted or runner-made
  `claude setup-token` token rests in `.oauth-token` in a dedicated home
  and reaches the CLI as `CLAUDE_CODE_OAUTH_TOKEN`, with
  `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1`. Connection rows carry a
  `runner_id`, but a worker's hello sends no connections and no seal
  key, and the Connections page only adds to the primary.
- **Claude Code pin.** Every runner pins Claude Code 2.1.312 by digest:
  `claude.ExecutableSHA256` is the certified linux/amd64 build, with an
  arm64 test pin. There is no darwin pin, and the Mac's capability
  discovery today runs whatever `claude` it finds to read its version.
  Many runner behaviours were read statically from 2.1.312 (subprocess
  scrub, remote settings, setup-token), so the Mac must run the same
  version, and slice F stops running an unpinned `claude` at all.
- **Engineering on Linux** is no longer "`claude -p` as today" plus a
  settings file. It is a certified launch: `provider.BuildPolicy` needs a
  bubblewrap version, `/opt` mounts, `/home/runner` and `/workspace`;
  the CLI runs inside the containment namespace, and its own Bash sandbox
  runs nested inside that. None of this exists on a Mac. The Darwin path
  needs its own policy and launcher (§8.2).
- **The tool proxy.** Engineering's permission prompt and
  `submit_candidate` reach the runner through the MCP tool proxy. The
  Mac release has no tool proxy (its Linux build's digest is certified,
  and a portability edit changed its bytes), and `ServeToolProxy` on
  darwin refuses today. Slice F makes the runner binary itself serve that
  MCP endpoint in a darwin-only mode; the Linux tool proxy stays
  byte-identical.
- **Credential operations and transcripts are Linux-shaped.** The token
  check (`thin/tokencheck.go`) and the sign-in by link (`thin/signin.go`)
  need the containment manager and Linux sign-in policies. Kept
  transcripts live under `projects/-workspace` (`thin/claude.go`), and
  Engineering and question prompts name `/workspace`. A Mac needs Darwin
  versions of each.
- **Ask the implementer is not pinned exactly.** `AskCommand` carries
  the question's attempt, not the Engineering attempt, account and
  session it must resume; `keptSessionFor` takes the newest. §1.4's
  exact pinning still has to be built.
- **Injection defences** (2026-11-19). Gates come from the base
  (`.equipo/gates.json`), and "Mac worker results remain diagnostic until
  their executor can enforce immutable base gates, and cannot grant
  standing auto-merge authority." Slice F keeps that: a Mac-made
  candidate merges only on a person's tap. Prompts quote untrusted text
  in data blocks; the worker builds its prompts with the same functions.
- **Secrets in candidates.** gitleaks 8.30.1 is pinned and ships for
  darwin/arm64 too. Engineering's change diffs leave out the primary's
  known secrets. For a worker's candidate, the worker checks its own
  known secrets before upload (§8.3) and the primary computes change
  files and diffs when it publishes. `PublishedReport` carries neither
  today.
- **carlos guard.** Previews, sites and the devbox need the guarded
  `carlos` CLI. They stay on the primary; a worker never looks carlos up.
- **Engineering grew** after 11-07: kept sessions and fix rounds that
  resume them, unfinished work kept on `step_timeout`, rebase rounds
  (`merge-tree` with an explicit merge base), the Research hand-off
  (quoted findings plus kept images), scheduler holds, failover across
  connections, change diffs, task kinds (`change`, `explore`). A worker
  carries each one or refuses it out loud (plan task 12). Copy, Design,
  Research, Preview, Publish and Merge steps stay on the primary.

### 8.2 The Darwin Engineering launch

The worker runs the pinned 2.1.312 darwin-arm64 CLI, which it fetches
itself from the official release and checks against a digest compiled
into the runner. It never runs a `claude` from `PATH`, and it never
needs Paul to install one. Each launch gets:

- the §4.4 Engineering settings, generated per attempt and checked
  byte-for-byte before launch, as `validatePolicy` does on Linux.
  Settings keys the pinned build does not read are a stop, not a guess.
  Plan task 1 reads them statically from the binary;
- the worktree at its real path (`realpath`, no `/private` alias) as the
  workspace root of the ported native permission rules (§4.4);
- the runner's darwin tool-proxy mode as the only MCP server, on a
  0600 socket in a 0700 directory, peer uid checked;
- a runtime copy of the connection's dedicated home as
  `CLAUDE_CONFIG_DIR`, and the token in the environment, or through a
  file descriptor if the pinned build reads one (task 1 checks);
- process-group termination exactly as §5, reusing the checks gate's
  executor.

**Xcode access for Engineering follows the proof.** Engineering's Bash
sandbox gets the Mach services Xcode needs only when this Mac's P2 is
denied **and** probe F5 (P2's hostile fixture built by `xcodebuild`
under Claude's own sandbox settings, since the CLI's embedded sandbox
runtime is not the pinned srt) is denied too. Otherwise Engineering on
the Mac runs with no Mach services: it edits, reads and uses tools that
need no Xcode service. The build and test then happen in Checks, and
the step says so. Reason: code that XCBBuildService or a simulator runs
for the repository would run outside Seatbelt, with network, as the user
that now holds a Claude token.

### 8.3 A model credential on a shared Mac

Until now the Mac held only its runner identity. After slice F it holds
a long-lived Claude token. Three consequences, all in the plan:

1. **Unix permissions.** The worker refuses to store or use a model
   connection unless it can show, from ownership, mode bits and ACLs
   alone (it cannot test as another user), that no other user can list,
   traverse or read its home, state dir, config dir and accounts root,
   and that each of those lies inside the home. It names what to change,
   for example `chmod 700 ~` run as the runner user, plus removing any
   ACL entry that grants access.
2. **The sandbox is the only thing between repository code and the
   token.** On Linux a PID namespace hides the CLI's environment from its
   Bash commands. On a Mac there is no namespace, so probe F3 checks,
   from inside the CLI's Bash sandbox, that the CLI's environment and the
   token file cannot be read (`ps -E`, `sysctl kern.procargs2`, the file
   by path). If F3 is not denied, the worker takes no Engineering.
3. **Outside-the-sandbox runs reach the token.** A check run outside the
   sandbox on that Mac (the creator's per-attempt choice) runs as the user
   that holds the token, with network. **Decision for Paul, D1** (§8.7).
4. **Checks run as the same user.** The srt checks profile must also
   keep the token out of reach (P2 gains the F3 sources). One
   machine-wide lock serializes every operation that runs repository
   code, runs Xcode or puts a token in a process (a check, an
   Engineering attempt, an ask, a probe run, a token check, a sign-in),
   each for its own life; descendants an operation starts belong to it.
   Separately, from the moment a connection starts connecting until its
   files and any Keychain item are proven gone, the Mac counts as
   holding a credential, which matters for D1.
5. **A user that ever ran unsandboxed** may hold persistence (a launch
   agent, a changed config, a waiting process) that no later probe can
   rule out. **Decision for Paul, D2** (§8.7).

The worker also checks every new object before upload (blobs,
including binary ones and symlink targets, trees for file names, and the
commit message) for each of its known secrets, raw and encoded, and runs
gitleaks under the trusted configuration over the changed files. A hit,
a scanner failure or an object over the scan bound refuses the step with
`secret_in_candidate`, and nothing is uploaded.

### 8.4 Packs for Engineering

The base of a first Engineering step and the new tip of a rebase round
are chosen by the primary today, inside `Engineer.Exec`. For a worker
the primary resolves them first: the instance asks it to prepare the
base, it fetches and reports the SHA, and the instance binds that SHA to
the attempt before it dispatches to the worker and opens the transfer.

An inbound Engineering transfer has a kind and names its commits in
fixed, comparable header fields (protocol 36): the base; for a rebase
round, also the old base and the candidate. The worker's store marks
those commits as shallow boundaries, so nothing walks into missing
parents. Its tree has only those commits, like the depth-1 clones the
index already makes. The worker checks the pack's own inventory: exactly
the named commits, each with a complete tree. The outbound pack is thin
against the base (`^base candidate`), which the primary already indexes
with `--fix-thin` beside its clone. Repositories without commits are
never Mac work (no gate, so no `needs_macos`), and a worker refuses an
empty base. The 64 MB bound stands. Over it, Engineering ends
`workspace_too_large` with Needs you, rather than running on Linux.

Change files and diffs for a worker's candidate come from the primary
when it publishes. The instance accepts them from the primary for that
publication only, bound to the worker's task, step and attempt.

### 8.5 Placement, pinning and connections

Engineering for Mac work needs `macos`, `xcode`, `ios_simulator` (when
the repository has a shared scheme) and `claude`. A worker advertises
`claude` only when the pinned CLI is verified, F1 to F4, F6 and F7
passed for this version, profile and Xcode, the home guard passes, and
it holds at least one usable Claude connection. Beside the tag it sends
an Engineering status naming the first thing missing. When a Mac fits
everything but `claude`, the step waits with that reason, so the person
sees what to do: add Claude to the Mac, sign in again, wait for a limit,
fix the home folder, or wait for the probes. A Mac or a primary older
than protocol 36 waits as `waiting_mac_update`.
Pinning (§1.4) is unchanged and now real: fix rounds, retries, rebases,
republishes and questions go to the task's Engineering runner. A removed
pinned worker leaves the task at Recover. It is never re-pinned silently
to the Linux primary.

Connections on a worker: its hello sends its connections and its seal
key; the Connections page groups connections by machine and offers "Add
Claude to <Mac>" for a Mac worker. The token is sealed to that worker's
key in the browser, or made by that worker's own `setup-token` sign-in,
as on the primary. Only Claude token connections run on a Mac in slice
F. Codex stays slice G; metered and endpoint connections stay on the
primary.

### 8.6 Witness and switch

`EQUIPO_MAC_ENGINEERING=1` on the instance enables placement on a
worker. Unset, Mac Engineering waits as `mac-placement-wait` left it, so
the release can deploy inert. The live witness (§6, M9, slice F row) runs
on production with the Studio after the release is deployed by whoever
holds that authority. It needs Paul for his rulings on D1 and D2
(§8.7) and to sign in when adding Claude to Tito Studio, and it needs
the Studio's P2 denied. M9 itself runs offline on Linux CI with the test
build's fake worker and fake CLI.

### 8.7 Decisions

- **D1 (Paul).** A Mac that holds a model connection: may a check still
  run outside its sandbox on the creator's choice? Recommended default,
  which the plan builds: **no.** While a Mac holds a model connection,
  the "Run outside the sandbox" choice is not offered for it, and the
  worker refuses an unsandboxed dispatch. Checks there wait for the
  sandbox. If Paul rules yes, the choice stays, its warning names the
  Claude connection, and the connection is marked "sign in again" after
  such a run. Either way the change is small: one predicate (plan task
  15).
  The default also means checks on a Mac whose P2 is not denied wait
  for good once it holds a connection, so the witness needs the Studio's
  P2 denied.
- **D2 (Paul).** A runner user that ever ran checks outside the sandbox
  (the Studio's `paulequipo` did on 2026-11-11; Paul accepted that taint
  on 2026-11-13, before any credential lived on the Mac) may hold
  persistence no probe can rule out. Recommended default, which the plan
  builds: a runner whose instance record or own state says tainted
  takes no model connection, and the Machines page says why. For the
  Studio's production enrolment (a fresh state dir and runner row) the
  code sees no taint, so the 11-11 history is Paul's call: keep
  `paulequipo` for Engineering, or make a fresh Standard user for it (his
  sign-in and the install command, as on 2026-11-10).
- **Settled here, by the controller's reading of the accepted rulings:**
  Review stays on the primary (the table's "Mac Engineering and Review"
  means Review of Mac-made candidates). Research images are not relayed
  in slice F; the findings text is, and the prompt says the images are on
  the main runner. `simctl shutdown all` before a temp cleanup stays (the
  mac-user-temp ruling): the runner user's simulators are all its own.

### 8.8 Addendum to §5, 2026-11-28: finding what an attempt left

Written for plan task 9, from task 1's findings
(`docs/superpowers/plans/MAC-SLICE-F-TASK1-FINDINGS.md`, R4 and S5), the
sweep the coordinating session approved on 2026-11-28, and the
controller's stricter ruling after review round 1 (no exemption by
path). Where it disagrees with §5, this section is current.

**What task 1 found.**

- Claude Code 2.1.312 starts every Bash tool command with
  `detached: true`, so each command runs in a new session and process
  group (setsid), outside the attempt's group. Signals to the
  attempt's group never reach them.
- On macOS 27.2 the kernel hides the environment of platform binaries
  (`/bin/bash`, `/bin/zsh`, `/bin/sleep`, `/usr/bin/env`,
  `/usr/bin/sandbox-exec`) even from their own user. `ps -E` and
  `KERN_PROCARGS2` show `EQUIPO_ATTEMPT` only on other binaries (Xcode's
  tools, built test binaries, Homebrew tools).
- Together: §5's group-plus-marker sweep misses exactly the processes
  Bash commands are made of. A sandboxed `sleep 1000 &` would outlive a
  cancel, unseen.

**Identity.** Every process is named by its pid and the kernel's start
time (microseconds, from `kern.proc`). A pid used again later is another
identity. Nothing is matched by name, and nothing is spared by path.

**The kill set.** At an operation's end, these are killed:

- (a) what the runner saw of the operation while it ran: the processes
  under its leader, read about every 250 ms (`kern.proc.ruid` and
  `getsid`), and every process in a group or session they made;
- (b) every process of the runner user that started after the turn
  began (it is not in the table read when the turn began), whatever its
  parent or path. That includes launchd-parented processes under
  `/System`, `/usr/libexec` or `/usr/sbin` started during the turn: they
  are per-user on-demand agents of a dedicated user, and launchd starts
  them again when they are next needed;
- (c) every process carrying the marker, wherever the kernel shows it.

The only processes never in it are the runner itself and the helpers it
registered for itself (`mac.StartOwn`: capability queries, `ps`,
`caffeinate`, the worker's git, later gitleaks and packing), by identity,
together with their descendants seen while the helper lived. A
descendant stays the runner's own after its helper exits; a process that
later has a helper's pid is not.

**The stop.** Close stdin and wait for a graceful end. Then send SIGTERM
to the kill set, wait the 10 s grace, and send SIGKILL. Before each
signal the runner reads that process again, and signals it only if it is
the same identity and still the runner user's. A group is signalled
whole only while a member read just then is still in it. Another user's
process is never signalled.

**Three phases.**

1. The first kill pass signals what the first read found. Just before
   its first signal, the runner reads the table's clock (the clock of the
   kernel's start times): that moment is the relaunch cutoff.
2. Discovery is exactly one more read. What it finds new joins the kill
   set and is signalled. One exception: a process whose parent is
   launchd, whose kernel path (`proc_pidpath`, never `argv[0]`) is under
   `/System` (not `/System/Volumes`), `/usr/libexec` or `/usr/sbin`, and
   which started after the cutoff, is taken as launchd starting a killed
   agent again. It is not killed and does not block the proof. One that
   started before the cutoff is killed, even if the first read missed
   it.
3. Later reads only check. They signal the kill set again (SIGKILL once
   the grace is over) and add nothing to it. Each one withholds both the
   proof and the Mac's clearance (`Owed`) while any process of the
   runner user born during the turn is alive, other than the runner's
   own and a relaunch as defined in phase 2. Such a process is not
   signalled; the turn's record stays, and the next turn's settling,
   with its own kill pass, ends it.

Every group and session a kill-set process leads becomes an obligation.
So a process born into one after discovery (a fork from a dying target)
keeps the proof waiting, though no read adds it.

**The proof.** Termination is proven only when all of these hold, within
one absolute 30 s deadline. The deadline covers every table read, every
durable note and its fsync, the settling of an earlier turn,
`settleRecord` and the debt check. A proof is accepted only if the
deadline has not passed when the last of these returns, and `Verify`
gives its parts no separate budgets:

- every process in the kill set is gone, matched by pid and start time;
- every recorded group returns ESRCH to `kill(-pgid, 0)`;
- no process of any user is left in a recorded session;
- no marked process remains, and the leader is reaped;
- everything above is durably on the turn's record, and the stop's
  final note marked it complete.

**The user-temp cleanup has its own bound (2026-11-29).** The 30 s
deadline covers process termination only: the stop, the sweep and the
proof. An attempt that may write the runner user's T then has its
cleanup (simulators shut down, what it made in T removed, the pending
cleanup record removed) bounded by `CleanLimit` (3 minutes) from the
cleanup's start, because a simulator shutdown can take minutes. The
time is read after the last of these returns, the record removal
included, and in `Verify` after the final save of what the attempt
owed. An attempt is terminated (`Terminated: true`, a launch's end
proven) only with its proof inside the 30 s and its cleanup inside its
bound. On any error or overrun the pending cleanup record (if it is
still there) and the turn's record stay, so its boot-qualified evidence
survives: after a reboot `Verify` clears the attempt from that evidence
before it looks at any old process id, and keeps the completion for
each consumer. A later `Verify` finishes the cleanup.

If the turn's record cannot be written, the operation is stopped at once
and its proof withheld, and no further launch starts in that turn. A
record is complete (a durable `complete` mark) only once every launch of
the turn has written its own final note, each after all its group and
session writes, and no evidence write of the turn ever failed. After a restart, a record without that mark is
incomplete: what it left is swept as usual, but recovery alone never
proves its attempts over. Each such attempt stays unterminated with no
Retry, and the Mac's card on the Machines page says so (the capability
code `unproven: record_incomplete`, worded on the instance, which also
says a restart of the Mac clears it), until one of two clearances proves
it:

1. **An idle read** (first, and cheaper). It applies only to a turn in
   which nothing ran outside a sandbox. Before any unsandboxed
   operation starts (an unsandboxed check, a bare probe gate, anything
   that runs repository or model-chosen code outside a sandbox), the
   turn's record durably gets `unsandboxed_ran`; if that write fails,
   nothing starts. Every record carries `flags_known` from its start.
   A turn whose flag is set, or whose record cannot show it was never
   set, clears only by a reboot.

   The reason is the one thing an idle read cannot see. A process of
   the attempt that changed its real uid has left the runner user's
   table. Changing the real uid needs a setuid program, and on macOS
   27.2 no Seatbelt profile can exec one (task 1, R4: `sandbox-exec`
   refuses to exec `/bin/ps`, a setuid binary, under every profile).
   So in a turn where everything ran sandboxed, no process of the
   attempt can have changed its uid.

   The runner user is dedicated. At runner start, and each time the
   instance syncs (a person's Retry among them), the runner holds the
   Mac's turn and reads every process of the runner user twice, each
   read whole and in time. Every process found must be the runner, a
   helper it registered (with what that helper started), or a process
   that existed, by pid and start time, when the earliest unresolved
   turn began. That baseline is the table of the earliest turn that
   still owes anything, never a later turn's, whose table may hold an
   earlier turn's survivor. A turn on record without a table exempts
   nothing. Then every process, group and session the record names
   must be gone, for every user.

   The clearance covers every unresolved turn, not only the attempt's.
   While any other turn that still owes anything ran something outside
   a sandbox, or has a record that cannot show it did not, nothing is
   cleared this way: one of its processes may have changed its uid and
   still be running. Each other unresolved turn must be sandbox-only,
   and every process, group and session it names must be gone, for
   every user, before this attempt clears.

   Any unaccounted process, or a failed or late read, keeps the attempt
   unproven. The Machines page then gives only their number
   (`unproven: processes_left` with `unproven_count`), never names,
   pids or paths, and says a restart clears it. The clearance refuses
   to run outside a held turn, and on a table that is not the runner's
   alone.

   **Why a process born after the second read is not a survivor.**
   Take any unresolved turn. It ran only sandboxed, so none of its
   processes left the runner user's table, and every one it recorded is
   gone for every user. Every exempt process predates every unresolved
   turn, so it is none of that turn's processes. Every other process of
   the runner user blocks the clearance at either read. So no process
   of any unresolved turn was present at either read, under any uid,
   and none can fork after the second. Both reads and the
   acceptance happen holding the turn, so no operation of the runner's
   starts a process meanwhile, and any process born after the earliest
   unresolved turn began that is not the runner's own blocks the
   clearance at either read. A process born after the second read can
   therefore come only from an exempt process or from the runner's
   own: work a pre-turn service does, perhaps on a request, but not a
   process of the turn.
2. **A reboot** (the fallback). Nothing outlives a boot. A record or an
   obligation whose turn began in an earlier boot counts as proven. That
   needs another boot identity (`kern.bootsessionuuid`, so a clock step
   cannot fake it) and a boot time after the turn's start. Such a record
   is settled without a sweep, its table being the earlier boot's. The
   result is boot-qualified: the old boot's group and session ids, and
   a pending user-temp cleanup's group id, are this boot's to use, so
   they are neither checked nor signalled. An unreadable boot proves
   nothing.

   A record has more than one consumer: the step's recovery and the
   Keychain recovery both prove the same process record, in either
   order and perhaps in different runner processes. So the reboot's
   proof is kept on `<lock>.owed` as a completion, keyed by the
   attempt and this boot's identity. A proof only reads it: a later
   proof of the same record finds the completion and succeeds without
   checking or signalling anything, across a runner restart too. Each
   consumer acknowledges the completion, in a separate step, once its
   own result is durable: the step recovery after its transaction
   commits (at a restart, or when a later probe records the
   termination), and the Keychain recovery once the watch's record is
   saved as checked or removed. The completion goes only when both
   have acknowledged it, so a crash between a proof and its commit
   loses nothing. A completion that some consumer never acknowledges
   is dropped after 30 days.

   The evidence is per marker. One turn's obligation can name several
   launches (a probe's, or an Engineering operation's). Proving one of
   them takes only its marker out of the obligation; the others keep
   their reboot evidence, and each is proven on its own.

Both clearances run under the attempt's one proof deadline. They remove
nothing on their own: what the attempt owes is discharged only once its
whole proof, including any cleanup, has succeeded in time. A proof that
fails or expires leaves every obligation in place.

The deadline covers every step of the proof: the pending user-temp
cleanup (shutting simulators down among it), the lock on
`<lock>.owed.lock` that the discharge needs, and the save itself (its
write, sync and rename). If any of them cannot finish in time, the
proof fails, and the debt and the pending cleanup stay; a later proof
carries on from there, the cleanup being safe to repeat. A discharge
whose save ends late writes the debt back. A reboot's completion saved
late stays: it is the evidence the later proof finishes from. An
assessment that cannot open or lock the debts proves nothing.

Otherwise the step stays unterminated (no Retry), and its turn's record
stays too. The next turn, in any runner process, settles that record
before it begins, with the same kill set and the earlier turn's "before"
table. If a process of the runner user is still left, the next turn does
not begin. If only processes, groups or sessions another user now holds
are left, the Mac may take turns again: those obligations are kept
(`<lock>.owed`), never signalled, and the attempt is not proven over
until they end.

That release needs a clean read: a read that fails voids any earlier
clearance, and only a later read in time that shows nothing of the
runner user's left restores it. Every runner process reads and writes
`<lock>.owed` only under an flock on `<lock>.owed.lock`, `Verify`
included.

**After a restart.** The new runner settles the dead runner's turn
record first. Then, for each recorded attempt, it kills every process
carrying the marker, and the recorded group only while a marked process,
read just then, is in it. A recorded group that is alive with no marked
process in it is either the attempt's child that scrubbed its
environment or the group id used again by someone else. It is not
killed, and the attempt is not proven over until the group is gone.

A user-temp cleanup left pending belongs to the attempt, in the runner
process that wrote it. Only that attempt (its run, or its later proof)
or a restart may finish it. A restart is recognised only when the writer
is surely gone: an identity that cannot be read is not a dead one.

**One turn per operation.** `mac.Turns` is taken for each operation's
life and no longer: a check, an Engineering attempt, an ask, a probe run
(P1 to P7 as one turn; F1 to F7 likewise), a token check, a sign-in pty
and a token store. What the operation starts itself belongs to it. Every
Mac launch refuses to start outside a held turn. A probe run that reaches
its limit reports at once but keeps the turn until its gates have
stopped and cleaned up. The credential flag (task 11) is separate: it
holds no turn.

**The honest limit.** One case is left: the relaunch identification
itself. A process with a system path, reparented to launchd, that starts
after the relaunch cutoff (during the kill pass) cannot be told from a
relaunch, so it is spared and does not block the proof.

Also not covered:

- the moment between a fresh read of a process and its signal, in which
  a pid could in theory be used again (macOS allocates pids in sequence,
  so this needs a full wrap of the pid space within that moment);
- a process that changes its real uid leaves the runner user's table.
  The proof still waits for it while it is in the kill set or in a
  recorded group or session.

Since the runner user is dedicated and turns are serialized, the sweep
also ends anything else of the runner user's that started during the
turn: a person signed in as that user, or launchd agents (which launchd
starts again on demand).
