Merge design-mac-runner (b5f7259) into thin-v1-runners
Brings the accepted Mac runners spec (rev 4) onto the branch that builds its Linux-side slices A and B.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+639
−0
docs/superpowers/specs/2026-11-07-equipo-mac-runners.md+639 −0
Intent
diff --git a/docs/superpowers/specs/2026-11-07-equipo-mac-runners.md b/docs/superpowers/specs/2026-11-07-equipo-mac-runners.md| new file mode 100644 |
| index 00000000..8d91cb54 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-07-equipo-mac-runners.md |
| @@ -0,0 +1,639 @@ |
| +# 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.76.110.54). 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, `~/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. |
| + |
| +## 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. |