| 1 | # Equipo: Mac runners for thin v1 |
| 2 | |
| 3 | Status: rev 4, ACCEPTED by Paul 2026-11-07 (his two rulings in §7), |
| 4 | after Astra's rounds 1 and 2 (9852fc8, 0f6eaa6) and the controller's |
| 5 | verification of rev 3 (460f31b). Written by Claude (Fable 5.1) from the |
| 6 | approved thin v1 spec (`2026-11-06-equipo-thin-v1.md`), the slice 1 to 4 |
| 7 | logs and the code at `thin-v1-slice4` (ca0a65c). Not implemented. Facts |
| 8 | about `srt`, Claude Code and Codex were read from their current docs on |
| 9 | 2026-11-07; what still needs a probe on the Mac is marked. |
| 10 | |
| 11 | ## 0. The problem and the shape of the answer |
| 12 | |
| 13 | Woodstar is an iOS app. On the Linux runner its checks step says "Checks |
| 14 | can't run here (needs macOS)" (`judge.go: needsMacOS`) and Engineering |
| 15 | cannot build or run it. Paul has a shared Mac, Tito Studio |
| 16 | (`tito-studio`, Tailscale 100.64.0.1). He wants work that needs macOS |
| 17 | to go there without choosing anything. |
| 18 | |
| 19 | The answer is a second runner of the same person, a **worker**, enrolled |
| 20 | with one install command and one tap. The worker advertises what it can |
| 21 | do; the instance places each step on a runner that can do it; the |
| 22 | coordinator stays on the primary (docs-t1) and only says where things |
| 23 | ran. Linux keeps bubblewrap unchanged. The Mac trusts the harness |
| 24 | sandboxes, as Paul ruled. |
| 25 | |
| 26 | Rev 2's structural change: **the worker never holds the forge |
| 27 | credential.** Only the primary talks to Amadan. The primary fetches the |
| 28 | exact candidate and ships it to the worker as a verified git pack |
| 29 | through the instance; the worker returns its commit the same way, and |
| 30 | the primary pushes through `internal/runner/forge` exactly as today. That |
| 31 | removes a credential-transfer protocol and means nothing that escapes |
| 32 | the Mac's sandbox can reach the forge. |
| 33 | |
| 34 | ## 1. Several runners per person |
| 35 | |
| 36 | ### 1.1 Roles and identity |
| 37 | |
| 38 | Today `primaryRunner` (`chat_wiring.go`) is the newest unrevoked runner |
| 39 | of an owner. Rev 2 adds an explicit `role` (`primary` or `worker`) to |
| 40 | the `runners` row, in an additive migration that marks every existing |
| 41 | runner `primary`: the production and staging primaries do not move. A |
| 42 | person's first enrolment is primary; later ones are workers. The |
| 43 | coordinator session, move-in, notebook, catalog index, forge credential |
| 44 | and `watch_merge` live on the primary. Workers run steps. |
| 45 | |
| 46 | Identity is unchanged: each machine runs `equipo-runner enrol`, gets a |
| 47 | device code and a runner credential of its own, and holds one outbound |
| 48 | WebSocket with acks, generation lease and the `lease` check from |
| 49 | slice 1. **Enrolment in one tap:** the Mac installer (§3) ends by |
| 50 | running `enrol` and prints one link. Paul taps it; the page says "Add |
| 51 | Tito Studio to your team" (`scutil --get ComputerName`) with one button. |
| 52 | Because a primary exists, the row is a worker. |
| 53 | |
| 54 | ### 1.2 The mailbox becomes runner-addressed |
| 55 | |
| 56 | The slice 1 mailbox is person-keyed: `commandRecord{Person, Kind, Body}`, |
| 57 | `Pending` serves whatever is pending for the person once it has checked |
| 58 | the connection is the primary, `ack` and the inbox are per person, and |
| 59 | `syncSteps` scans the person's queued and running steps. Rev 2 keeps the |
| 60 | tables and adds a destination: |
| 61 | |
| 62 | - Migration 0045 adds `runner_commands.runner_id` and `steps.runner_id` |
| 63 | (both indexed) and `runners.role`, in this order inside one |
| 64 | transaction: add the columns; backfill every runner `primary`; backfill |
| 65 | every command and every existing step, in every state including |
| 66 | running, pending termination and queued, with the person's primary at |
| 67 | migration time (the `primaryRunner` query, run per person); only then |
| 68 | does the code that enforces ownership (below) ship, in the same |
| 69 | release, so no existing attempt is ever reported or reconciled against |
| 70 | an empty owner. A step with an empty `runner_id` after migration is a |
| 71 | bug the schema check fails on. `txn.command` takes a runner id; |
| 72 | message, cancel, reset, `watch_merge` and `publish` commands name the |
| 73 | primary. |
| 74 | - `Pending` serves only commands whose `runner_id` is the connection's |
| 75 | runner; `ack` marks a command acked only if the acking connection is |
| 76 | that runner and holds the current generation and process (the |
| 77 | `current(lease)` check that exists today). Inbox dedup stays |
| 78 | transactional per frame id. |
| 79 | - A step report is accepted only from the runner recorded on the step |
| 80 | row and only for the current attempt (added to `stepReport`'s existing |
| 81 | forward-only and attempt checks). `syncSteps` scans only steps whose |
| 82 | `runner_id` is the syncing runner, so a worker's sync can neither |
| 83 | settle the primary's work nor a Linux attempt still awaiting its |
| 84 | termination proof. Turn reconciliation stays primary-only. |
| 85 | - Tests: a worker acking the primary's command is a no-op; a worker's |
| 86 | sync omitting a step owned by the primary leaves it untouched; a |
| 87 | report from the wrong runner is refused; a Linux step pending |
| 88 | termination survives a worker's sync and still refuses Retry |
| 89 | (`TestStepPendingTermination` extended with a second runner); a |
| 90 | migration test runs 0045 over a slice 4 database holding a running |
| 91 | step, a pending-termination attempt and unacked commands, and shows |
| 92 | every row bound to the old primary and every slice 1 to 4 contract |
| 93 | test still green on it. |
| 94 | |
| 95 | ### 1.3 The capability report |
| 96 | |
| 97 | `hello` gains `platform {os, arch}`, `label`, `sandbox` (`bubblewrap` or |
| 98 | `seatbelt`) and `capabilities`, a bounded object (40 simulators, 300 |
| 99 | bytes per string, 8 KB total) the runner computes at start, re-probes |
| 100 | hourly and on disagreement, and sends with every 30 s heartbeat; the |
| 101 | instance stores the newest beside the `hello` column: |
| 102 | |
| 103 | - `xcode {version, build}` from `xcodebuild -version`; empty on Linux. |
| 104 | - `simulators [{name, runtime, udid, state}]` from `xcrun simctl list -j |
| 105 | devices available`. |
| 106 | - `toolchains {go, swift, node}` and `harness {claude, codex, srt}` |
| 107 | versions. |
| 108 | - `accounts` as today, one per provider home on that machine. |
| 109 | - `tags` from the fixed set `linux`, `macos`, `xcode`, `ios_simulator`, |
| 110 | `claude`, `codex`, `go`. |
| 111 | |
| 112 | No path, credential or raw tool output; a guard test checks every field. |
| 113 | |
| 114 | ### 1.4 Needs, placement, pinning and withdrawal |
| 115 | |
| 116 | Each step declares `needs`, a subset of the tag set, derived by the |
| 117 | instance from facts it holds, never by the model: |
| 118 | |
| 119 | - Checks: `macos`, `xcode` (and `ios_simulator` when the repository has a |
| 120 | shared scheme) when `needsMacOS(changed, gateText)` is true. The rule |
| 121 | moves instance-side: the primary's index reports `needs_macos` per |
| 122 | repository in `RepoInfo`, and the Engineering step report says |
| 123 | whether its change touched Apple files. |
| 124 | - Engineering (slice F only): `macos`, `xcode`, `ios_simulator`, `claude` |
| 125 | for a `needs_macos` repository. Until then, nothing. |
| 126 | - Review: nothing. Ask the implementer: pinned (below). |
| 127 | |
| 128 | **Placement** runs in `advance` when a step is created and whenever a |
| 129 | runner comes online while steps wait: among the person's unrevoked |
| 130 | runners whose tags cover the needs, prefer the primary; else the online |
| 131 | worker with the fewest running steps; ties by enrolment order. The step |
| 132 | row records `runner_id` and the dispatch is written to that runner's |
| 133 | mailbox in the same transaction. `DispatchCommand` carries `needs`; a |
| 134 | runner receiving needs it lacks refuses with `placement_refused` and the |
| 135 | step is re-placed. |
| 136 | |
| 137 | **Pinning.** A task's Engineering runner is chosen at the first |
| 138 | Engineering step and stored on the task (`tasks.engineering_runner`); |
| 139 | fix rounds, retries and republishes go there, so two runners never |
| 140 | touch one branch. Ask the implementer resumes the exact `(step, attempt, |
| 141 | account, session_id)` recorded on the step row, on the runner that holds |
| 142 | it; a different runner, account or a later attempt is refused, and an |
| 143 | offline runner gets "Tito Studio is offline; ask again when it is back." |
| 144 | |
| 145 | **Withdrawal.** An unacked dispatch is not an undelivered one: the |
| 146 | runner records a dispatch durably and wakes the step engine before it |
| 147 | sends the ack (`link.go: read`), so a lost ack leaves executable work. |
| 148 | Rev 3 therefore stops reasoning about delivery and makes **starting an |
| 149 | attempt a transaction on the instance.** The runner already does a lease |
| 150 | round trip before any step executes (`judge.go: lease`, `Engineer.lease`); |
| 151 | that frame becomes `lease{generation, step_id, attempt}` and the |
| 152 | instance acks it only inside a write transaction that finds the attempt |
| 153 | assigned to this runner and not withdrawn, and sets `steps.started_at` |
| 154 | there. Withdrawal is the other side of the same row: in one transaction |
| 155 | it marks the attempt `withdrawn`, which `Pending` never serves again, |
| 156 | and reads `started_at`. If it is empty, nothing can ever run: a later |
| 157 | start authorization for that attempt is refused and the runner deletes |
| 158 | its row with reason `withdrawn`. If it is set, the work is possibly |
| 159 | running: the instance sends `cancel_step` and waits for the terminal |
| 160 | report with termination before it creates the next attempt elsewhere, |
| 161 | exactly the Retry rule. This is chosen over "treat every unacked |
| 162 | dispatch as possibly running" because it costs nothing new (the round |
| 163 | trip exists), it is exact rather than conservative, and SQLite's |
| 164 | serialisation of the two writes is the proof. Tests: a lost ack (the |
| 165 | instance resends, the runner's inbox dedups, the attempt is authorised |
| 166 | once and runs once); withdrawal committed just before the start |
| 167 | authorization (start refused, no process, re-placement proceeds at |
| 168 | once); withdrawal committed just after it (withdrawal sees `started_at`, |
| 169 | takes the cancel path, and the next attempt exists only after |
| 170 | termination); a delayed report for a withdrawn or older attempt refused; |
| 171 | a delayed checks or review result for an older SHA dropped by the |
| 172 | judged-SHA rule so it cannot make a newer candidate Ready |
| 173 | (`TestContractReviewAndChecks` gains both delayed-report cases). |
| 174 | |
| 175 | **Honest outcomes when nobody fits.** No runner has ever had the tags: |
| 176 | checks end `cannot_run`/`needs_macos` at once (today), Engineering runs |
| 177 | on the primary with today's summary. A fitting worker is offline: the |
| 178 | step is `queued`, `placement: waiting_runner`, card line "Waiting for |
| 179 | Tito Studio (offline since 10:12)". After 30 minutes a checks step is |
| 180 | withdrawn and resolves `cannot_run`/`runner_offline`, never a pass, and |
| 181 | review proceeds; an Engineering step keeps waiting and raises Needs you |
| 182 | `runner_offline`; Cancel stays available. |
| 183 | |
| 184 | ### 1.5 Health and the Runners view |
| 185 | |
| 186 | Online is today's `runnerOnline` window per runner. `GET |
| 187 | /api/v1/runners` returns `{items: [Runner]}`; `snapshot` gains |
| 188 | `runners` (singular `runner` stays one release). The `runner` event |
| 189 | fires per runner. The Team section lists runners by label with an |
| 190 | online dot. `status()` lists them; `read_task` carries each step's |
| 191 | `runner_label`; house rule 2026-11-07.8: mention where a step runs only |
| 192 | when it is not the primary. |
| 193 | |
| 194 | ## 2. Candidates travel as packs, not credentials |
| 195 | |
| 196 | The worker has no clone and no forge access. Objects move inside a |
| 197 | **transfer**, a row the instance opens and that authorises every chunk: |
| 198 | `transfers{id, person, from_runner, to_runner, repo, task_id, step_id, |
| 199 | attempt, base_sha, candidate_sha, direction, state, expires_at}`. An |
| 200 | inbound transfer (primary to worker) is opened in the same transaction |
| 201 | as the worker's dispatch. An outbound one (worker to primary) is opened |
| 202 | when the instance accepts the worker's `step{state: running, phase: |
| 203 | committed, candidate_sha}` report for the current attempt, for exactly |
| 204 | that candidate. The primary (which already builds a one-commit pack with |
| 205 | `rev-list --objects --no-walk` and `pack-objects`, `judge.go: |
| 206 | checkRepository`) or the worker then sends `blob{transfer, index, total, |
| 207 | sha256, data}` frames, `data` base64 under 192 KB so a frame stays under |
| 208 | `MaxFrameBytes`, durable and acked like any other. |
| 209 | |
| 210 | **Authorization, checked before bytes are kept.** The instance accepts a |
| 211 | chunk only from the connection of `from_runner`, holding its current |
| 212 | generation, for a transfer in state `open` whose attempt is the step's |
| 213 | current attempt and not withdrawn, cancelled or superseded; anything else |
| 214 | is refused with `transfer_refused` and logged. `Pending` serves chunks to |
| 215 | `to_runner` only. The receiver, before `index-pack`, checks the transfer |
| 216 | header against its own step row: repository, task, step, attempt, base |
| 217 | and candidate must match, and the direction must be the one it expects. |
| 218 | A transfer closes when its last chunk is acked or its attempt ends, and |
| 219 | its chunks are deleted; a 24-hour TTL sweeps the rest. Tests, apart from |
| 220 | byte tampering (M7): a stale attempt's chunks refused after Retry; a |
| 221 | second worker uploading for a transfer not its own; chunks for task A |
| 222 | sent under task B's transfer; a candidate that does not match the |
| 223 | opened transfer; an inbound transfer answered in the outbound direction. |
| 224 | |
| 225 | **Integrity.** The worker reassembles, checks `sha256`, runs `index-pack`, |
| 226 | and refuses the step (`candidate_unavailable`) unless the pack yields |
| 227 | exactly the dispatched `candidate_sha` with a complete tree. Bound: 64 MB |
| 228 | per transfer; above it the step is `cannot_run`/`checks_unavailable` |
| 229 | with "candidate too large to relay". The worker keeps objects per |
| 230 | repository under its state dir, and later dispatches carry a thin pack |
| 231 | against the `have` list in its reports, so Woodstar moves once. |
| 232 | |
| 233 | **Publication stays the primary's word.** For Engineering on a worker |
| 234 | (slice F) the worker commits as the runner does today (`add -A`, |
| 235 | `write-tree`, `commit-tree` on the base, identity `Equipo Engineering`), |
| 236 | reports `committed` with `candidate_sha`, uploads the thin pack in the |
| 237 | outbound transfer, and ends its step `done` with `pushed: false`. A |
| 238 | worker report carrying `pushed: true` is refused. The step gains |
| 239 | `publication` (`none`, `pending`, `published`, `failed`): when the |
| 240 | outbound transfer completes, the instance sets `pending` and writes a |
| 241 | durable `publish{task, step, attempt, candidate_sha, base_sha, transfer}` |
| 242 | command to the primary's mailbox in the same transaction. The primary |
| 243 | indexes the pack into the task's private repository, verifies the |
| 244 | commit's parent is the dispatched base and its tree complete, confirms |
| 245 | the lease **and the publication id** immediately before the push (the |
| 246 | existing pre-push confirmation, widened so a cancelled publication is |
| 247 | refused), and calls `PushBranch` with every check it has today |
| 248 | (repository, task branch, descendant of base, person, `--force-with-lease`, |
| 249 | record then reconcile). It then reports durable `published{task, step, |
| 250 | attempt, candidate_sha, pushed, reason}`; only this report, from the |
| 251 | primary, for the current attempt and candidate, sets `Step.Pushed` and |
| 252 | `publication: published`, and only then does `advance` create the checks |
| 253 | and review steps. `published{pushed: false}` sets `failed` with |
| 254 | `push_failed` or `push_conflict` and Needs you `retry`; Retry re-sends |
| 255 | `publish` for the recorded commit (slice 4's republish) without running |
| 256 | Engineering again. The primary keeps a `publications` table; its `sync` |
| 257 | lists the ones it holds, the instance resends unacked `publish` commands, |
| 258 | and `PushBranch`'s record-then-reconcile makes a repeat idempotent. |
| 259 | Tests: push failure then Retry publishes the same commit once; primary |
| 260 | SIGKILLed after indexing and before the push, restarted, pushed exactly |
| 261 | once; primary SIGKILLed after the push and before `published`, |
| 262 | reconciled from the remote on restart; cancel after pack receipt and |
| 263 | before push: no push, the candidate never published, the worker's |
| 264 | objects swept; the worker's `pushed: true` refused. Paul's ruling of |
| 265 | 2026-11-07 stands beside this: Equipo merges its own Ready-to-merge work |
| 266 | (slice 4c, on the primary), and a Mac Engineering candidate flows into |
| 267 | that path unchanged once the primary has published it; merging is not |
| 268 | designed here. |
| 269 | |
| 270 | What a worker can reach if its sandbox is escaped (§4.3): its own |
| 271 | enrolment key and state, so it could report a false result **for steps |
| 272 | placed on it**, and later the model account homes on that machine. It |
| 273 | cannot push, cannot read the primary's state and cannot touch another |
| 274 | person's work: the instance accepts its reports only for its own steps |
| 275 | and attempts (§1.2). A worker's checks verdict is labelled with the |
| 276 | runner on the task page, so a person reading "Checks passed (xcodebuild |
| 277 | test, Tito Studio)" knows whose word it is. |
| 278 | |
| 279 | ## 3. Install, update, discovery, sign-in and the dedicated user |
| 280 | |
| 281 | ### 3.1 Artifacts |
| 282 | |
| 283 | `make release` adds `releases/equipo-runner-darwin-arm64-<version>/` |
| 284 | (`equipo-runner`, `equipo-tool-proxy`, `io.amadan.equipo-runner.plist`, |
| 285 | the installer), built `CGO_ENABLED=0 GOOS=darwin GOARCH=arm64` on Linux |
| 286 | CI (the runner uses `modernc.org/sqlite`). Go ad-hoc signs darwin/arm64 |
| 287 | binaries and `curl` sets no quarantine attribute, so Gatekeeper does not |
| 288 | block them. `install-manifest.json` gains a `targets` map (`linux/amd64`, |
| 289 | `darwin/arm64`) with digests; `install-v1.sh` dispatches on `uname`; |
| 290 | `make staged-check` records both targets. |
| 291 | |
| 292 | ### 3.2 One command, then one tap |
| 293 | |
| 294 | `curl -fsSL https://<instance>/install.sh | sh` installs to |
| 295 | `~/.local/lib/equipo-runner`, writes |
| 296 | `~/Library/LaunchAgents/io.amadan.equipo-runner.plist` (`RunAtLoad`, |
| 297 | `KeepAlive`, `ProcessType Standard` so builds are not throttled, logs |
| 298 | under `~/Library/Logs/equipo-runner/`, `ProgramArguments` `equipo-runner |
| 299 | run --env-file ~/.config/equipo-runner/runner.env`, a new flag since |
| 300 | launchd has no `EnvironmentFile`), loads it with `launchctl bootstrap |
| 301 | gui/$UID`, installs `srt` with `npm install -g` when `npm` is present |
| 302 | (else one printed line; checks report `checks_unavailable` until it is), |
| 303 | then runs `enrol` and prints the link. A user agent runs only while that |
| 304 | user has a GUI session; a sleeping Mac is an offline worker; the runner |
| 305 | wraps every step in `caffeinate -i`. |
| 306 | |
| 307 | ### 3.3 Discovery and update |
| 308 | |
| 309 | At start the runner looks for `claude`, `codex` and `srt` at |
| 310 | `~/.local/bin`, `/opt/homebrew/bin`, `/usr/local/bin`, `npm root -g`, |
| 311 | then a login shell's `PATH`; versions go in the capability report; |
| 312 | `EQUIPO_CLAUDE_PATH` still overrides. Update: `welcome` gains `release`; |
| 313 | an older worker downloads its target from `/releases/<version>/`, |
| 314 | verifies the manifest digests, swaps the binary between steps and exits |
| 315 | 0 for `KeepAlive`. |
| 316 | |
| 317 | **Version-aware encoding.** `wire.Strict` rejects unknown fields and |
| 318 | `Frame.Decode` rejects unknown types, so nothing new may reach a runner |
| 319 | that has not said it understands it. `hello` gains `protocol` (2 for |
| 320 | this spec; absent means 1, the slice 4 wire) and `welcome` echoes the |
| 321 | protocol the instance will speak, the lower of the two. The instance |
| 322 | encodes every frame per connection with `wire.Encode(frame, protocol)`: |
| 323 | to a protocol 1 runner it sends exactly the slice 4 frame set and field |
| 324 | set (`welcome` without `role` or `release`, `dispatch` without `needs` or |
| 325 | `runner_id`, `lease` without step fields, no `blob`, `publish` or |
| 326 | `published`), it places no step whose needs are non-empty on it, and it |
| 327 | treats its capability report as the Linux default. A protocol 1 runner |
| 328 | is always a primary. The fixture tests encode every new frame at both |
| 329 | protocols. **Upgrade order:** instance, then the primary, then workers; |
| 330 | a runner's release comes only from its own instance, so a worker cannot |
| 331 | run ahead. The reverse pair (a newer runner against an instance rolled |
| 332 | back) still happens, so a runner whose protocol 2 `hello` is refused by |
| 333 | a strict decode (the close the instance already sends for a bad frame) |
| 334 | retries once with a protocol 1 `hello`, logs that the instance is older, |
| 335 | and runs as a protocol 1 runner until its next `welcome` says otherwise. |
| 336 | Mixed versions are tested with actual binaries (§6, M8). |
| 337 | |
| 338 | ### 3.4 Account sign-in and the Keychain hypothesis |
| 339 | |
| 340 | `equipo-runner login claude` works as on Linux: a dedicated home under |
| 341 | `~/.local/share/equipo/accounts/claude-<n>`, the official login, the |
| 342 | observed email recorded. Claude's docs describe separate configuration |
| 343 | directories for several accounts, and on macOS the CLI may keep its |
| 344 | OAuth token in the login Keychain rather than in the home. Both "one |
| 345 | file per home, the Linux copy cycle applies" and "one Keychain item per |
| 346 | macOS user, native refresh, one account" are hypotheses until probe P3 |
| 347 | answers them with sentinel items. Checks-only (slices D, E) needs no |
| 348 | account on the Mac at all; Engineering (F) waits for P3. |
| 349 | |
| 350 | ### 3.5 A dedicated macOS user per person (Paul's ruling) |
| 351 | |
| 352 | A runner on a shared Mac runs as a standard (non-admin) macOS user named |
| 353 | for its owner, `equipo-<person-handle>`: on tito-studio, `equipo-paul`. |
| 354 | Never a shared `equipo` user: each runner holds its owner's model |
| 355 | sign-ins and runner identity, and Unix permissions are what separate |
| 356 | people. The box is shared, so those permissions are the hard boundary |
| 357 | around Paul's and others' homes, with Seatbelt denies as the second |
| 358 | layer; the runner's Keychain, DerivedData, simulators and caches stay |
| 359 | out of his own account; and a process sweep can fall back to "every |
| 360 | process of user `equipo-paul` outside the runner". The dedicated user |
| 361 | still owns the runner's own enrolment key and state, which §2 bounds. |
| 362 | Probe P4 verifies, rather than assumes, that other homes on tito-studio |
| 363 | are unreadable by `equipo-paul` (`ls` and a sentinel read against each |
| 364 | `/Users/*`), and the installer refuses to enrol while a readable foreign |
| 365 | home exists or while it is running as a user not named `equipo-*`. |
| 366 | |
| 367 | Paul must, once: create the user `equipo-paul` (System Settings, Users & |
| 368 | Groups, Standard); add it to the developer group (`sudo dscl . append |
| 369 | /Groups/_developer GroupMembership equipo-paul`); log it in with fast |
| 370 | user switching and leave it logged in, sleep off while plugged in; open |
| 371 | a terminal as that user, paste the install command, tap the link. |
| 372 | Xcode's licence and `DevToolsSecurity` are machine-wide and already |
| 373 | accepted; the installer runs `xcodebuild -runFirstLaunch`. A second |
| 374 | person on the same Mac repeats this as `equipo-<their-handle>`. |
| 375 | |
| 376 | ## 4. The macOS sandbox, per step kind |
| 377 | |
| 378 | ### 4.1 What the harnesses give us (verified 2026-11-07) |
| 379 | |
| 380 | Claude Code's sandbox (`sandbox.enabled`) is built on |
| 381 | `@anthropic-ai/sandbox-runtime`, Seatbelt on macOS, and covers **shell |
| 382 | commands only**; Read, Edit, Write and WebFetch "follow permission rules |
| 383 | instead." A headless run takes `--settings <file>`, above user and |
| 384 | project files and below managed settings. Keys used here: |
| 385 | `sandbox.enabled`, `failIfUnavailable`, `allowUnsandboxedCommands`, |
| 386 | `excludedCommands`, `filesystem.{allowWrite, denyWrite, denyRead, |
| 387 | allowRead}`, `network.{allowedDomains, allowUnixSockets, |
| 388 | allowLocalBinding, allowMachLookup}`. |
| 389 | |
| 390 | `srt` (Apache-2.0, `npm install -g @anthropic-ai/sandbox-runtime`, 0.0.81 |
| 391 | on main today, Node 22.12 or later, `ripgrep`) wraps one command: |
| 392 | `srt --settings <path> -- <cmd> <args>`. Its settings JSON has |
| 393 | `network.allowedDomains` (empty means no network), `allowUnixSockets`, |
| 394 | `allowLocalBinding`, `allowMachLookup` (in `sandbox-config.ts`), |
| 395 | `filesystem.denyRead`, `allowRead`, `allowWrite` (empty means no writes), |
| 396 | `denyWrite`, `allowPty`, `enableWeakerNetworkIsolation`, |
| 397 | `allowAppleEvents`. On macOS it runs `sandbox-exec` with a generated |
| 398 | Seatbelt profile; its profile allows `securityd` and `SecurityServer` |
| 399 | lookups (`macos-sandbox-utils.ts`), so denying `~/Library/Keychains` on |
| 400 | disk does not deny the Keychain API; network goes through a local proxy |
| 401 | named by `HTTP_PROXY`/`HTTPS_PROXY`/`ALL_PROXY` and the profile allows |
| 402 | only that loopback port. `~` expands; paths are git-style globs. A |
| 403 | mandatory deny list blocks writes to shell rc files, `.gitconfig`, |
| 404 | `.git/config` and `.git/hooks` even inside `allowWrite`. |
| 405 | |
| 406 | Codex's `workspace-write` (`sandbox_mode`, `[sandbox_workspace_write]`, |
| 407 | app-server `turn/start.sandboxPolicy`) is Seatbelt too and now documents |
| 408 | filesystem read-deny rules under permissions. Codex on the Mac stays |
| 409 | parked (slice G) because the thin runner has no Codex step path until |
| 410 | slice 5 and nesting `codex` under `srt` is unproven (P5). |
| 411 | |
| 412 | ### 4.2 Equipo's deny list (every profile) |
| 413 | |
| 414 | `denyRead` and `denyWrite`: the runner's state dir (enrolment key, |
| 415 | steps, relayed objects), the accounts root, the session homes, `~/.ssh`, |
| 416 | `~/.aws`, `~/.gnupg`, `~/.config/op`, `~/Library/Keychains`, every home |
| 417 | under `/Users` other than the runner user's, `/Volumes`, and the install |
| 418 | dir for writes. There is no forge credential on the machine to list. |
| 419 | |
| 420 | ### 4.3 Xcode's services: a boundary to prove, not assume |
| 421 | |
| 422 | `xcodebuild` talks over Mach to CoreSimulatorService and XCBBuildService, |
| 423 | per-user launchd services outside any sandbox, and a repository's build |
| 424 | phases, SwiftPM plugins and tests are code the repository controls. It |
| 425 | does not follow from sandboxing `xcodebuild` that code those services |
| 426 | execute inherits the sandbox. Probe P2 is therefore the gate on checks: |
| 427 | a hostile Woodstar-shaped fixture whose run-script phase, SwiftPM build |
| 428 | tool plugin and XCTest each try to read a sentinel file in the runner's |
| 429 | state dir and in another `/Users/*` home, to open a TCP connection and a |
| 430 | DNS lookup, and to read a sentinel Keychain item, all under the §4.4 |
| 431 | checks profile. Checks on the Mac are enabled only when every attempt is |
| 432 | denied; a denial that depends on Unix permissions rather than Seatbelt |
| 433 | is recorded as such. A successful Woodstar build is not evidence. **If |
| 434 | P2 fails, checks still run on the Mac** (Paul's ruling), labelled "ran |
| 435 | outside the sandbox": the step and task carry `checks_sandbox: none`, |
| 436 | the label shows on the checks badge, in the task timeline and on the |
| 437 | Ready to merge card, and it is not a pass in disguise. The bound of §2 |
| 438 | holds (a worker can lie only about its own steps and cannot push). The |
| 439 | coordinator's auto-merge (slice 4c) treats such checks as passed only |
| 440 | for repositories the task's creator owns; that rule is noted here and |
| 441 | designed there. |
| 442 | |
| 443 | ### 4.4 Profiles |
| 444 | |
| 445 | **Checks** (no harness, so `srt`): the runner writes a per-attempt |
| 446 | settings file and runs `srt --settings <file> -- /bin/bash -c <gate>` in |
| 447 | the checks tree (the exact SHA, with the one-commit `.git` as today). |
| 448 | `allowWrite`: the tree, the attempt's DerivedData and temp dirs under |
| 449 | scratch, the runner user's `DARWIN_USER_TEMP_DIR` (resolved and checked |
| 450 | at start; Xcode writes there whatever `TMPDIR` says), |
| 451 | `~/Library/Developer/Xcode/DerivedData`, |
| 452 | `~/Library/Caches/org.swift.swiftpm`, `~/Library/org.swift.swiftpm`; |
| 453 | §4.2 denies; `network.allowedDomains` empty; `allowMachLookup` set to |
| 454 | exactly what P2 shows `xcodebuild test` needs. A network failure is |
| 455 | `needs_network`, honest, as on Linux. Environment from scratch: `HOME`, |
| 456 | `DEVELOPER_DIR` from `xcode-select -p`, `TMPDIR` the attempt dir, `CI=1`, |
| 457 | a fixed `PATH`. Exit code and the last 200 lines are recorded as today. |
| 458 | |
| 459 | When the repository has no `.amadan/ci.d`, `.amadan/ci` or `make ci` but |
| 460 | has an `.xcodeproj` or `.xcworkspace`, the Mac runner synthesises |
| 461 | `xcodebuild test -scheme <scheme> -destination 'platform=iOS |
| 462 | Simulator,name=<device>' -derivedDataPath <attempt dir> |
| 463 | CODE_SIGNING_ALLOWED=NO`, gate name `xcodebuild test`: the one shared |
| 464 | scheme, or the one named like the project; the newest available iPhone |
| 465 | simulator from the report. Several candidates or none is |
| 466 | `cannot_run`/`checks_unavailable`. Simulator builds need no signing |
| 467 | identity; device builds are out of scope. |
| 468 | |
| 469 | **Engineering** (slice F, Claude Code): `claude -p` as today |
| 470 | (`--setting-sources ''`, `--strict-mcp-config`, pinned tools) plus |
| 471 | `--settings <per-attempt file>` with `sandbox.enabled true`, |
| 472 | `allowUnsandboxedCommands false`, `failIfUnavailable true`, |
| 473 | `excludedCommands []`, `allowWrite` the worktree plus the DerivedData |
| 474 | and SwiftPM paths, the §4.2 denies, `allowedDomains` empty, |
| 475 | `allowMachLookup` per P2. The `claude` process talks to Anthropic as the |
| 476 | runner user outside the sandbox, the trust Paul granted. |
| 477 | |
| 478 | **Native file permissions, ported explicitly.** `claude/answers.go` |
| 479 | hard-codes `/workspace`: `workspaceNativePath` and `protectedNativePath` |
| 480 | test that prefix, and the symlink check walks a Linux mount. On the Mac |
| 481 | the worktree is a real path, so the Darwin port makes the workspace |
| 482 | root a policy field, resolves every requested path with `realpath` |
| 483 | against the worktree root and the §4.2 list before answering, generates |
| 484 | permission `deny` rules for Read, Edit, Write, Glob and Grep on the |
| 485 | §4.2 paths alongside the sandbox denies, and keeps the "nobody to ask" |
| 486 | default. Tests against sentinel files: an alias through `/private` and |
| 487 | `/var` (macOS symlinks), a glob that expands outside the root, `..` |
| 488 | components, and a symlink swapped after the check (the race the Linux |
| 489 | comment already names; on the Mac the generated native deny rules are |
| 490 | the second layer). `StepPermission` and `ReadPermission` share the port. |
| 491 | |
| 492 | **Review** (`inspect`): Read, Glob and Grep only, no shell, so Seatbelt |
| 493 | has nothing to do; the ported `ReadPermission` confines reads. Review is |
| 494 | placed by §1.4 and usually stays on the primary. |
| 495 | |
| 496 | **Ask the implementer**: the inspect tool set on the pinned session |
| 497 | (§1.4), needing step sessions kept per task (session home copied back |
| 498 | as the coordinator's is); built in slice F. |
| 499 | |
| 500 | ### 4.5 Honest limits |
| 501 | |
| 502 | `sandbox-exec` is deprecated by Apple but still what both harnesses use; |
| 503 | `failIfUnavailable` turns its removal into a stop. No PID namespace, no |
| 504 | uid isolation, no resource limits; path rules resolve through symlinks; |
| 505 | allowed Mach lookups are open, including `securityd`. Network filtering |
| 506 | is a proxy plus environment variables without TLS termination; we allow |
| 507 | no hosts. Claude's sandbox covers shell commands only; hooks, MCP servers |
| 508 | and `apiKeyHelper` run unsandboxed (Equipo disables hooks and pins MCP). |
| 509 | Violations show only in `log stream --predicate 'process == |
| 510 | "sandbox-exec"'`, which the runner tails and counts in the step log. |
| 511 | |
| 512 | The user's temp folder is shared between attempts. After each sandboxed |
| 513 | attempt the runner shuts its simulators down and removes what appeared |
| 514 | there, but a check can leave changes inside folders that existed before |
| 515 | the attempt. The runner user is per person and holds no secrets, so v1 |
| 516 | accepts this. The v2 path is a disposable Mac user per attempt. |
| 517 | |
| 518 | ## 5. Termination on macOS |
| 519 | |
| 520 | No namespace and no pidfd proof. Each attempt starts in its own session |
| 521 | and process group with `EQUIPO_ATTEMPT=<key>` in its environment. Cancel |
| 522 | or timeout: `SIGTERM` to the group, 10 s, `SIGKILL` to the group, then a |
| 523 | sweep (`ps -axo pid,pgid,user,command`, `ps -E` for own processes) that |
| 524 | kills anything with the group id or the marker, then `xcrun simctl |
| 525 | shutdown` for simulators the attempt booted. **Termination is reported, |
| 526 | and Retry allowed, when `kill(-pgid, 0)` returns `ESRCH` and the sweep |
| 527 | finds no marked process, within 30 s.** `StepReport` and `Step` gain |
| 528 | `termination_kind` (`namespace` or `process_group`). Not covered: a |
| 529 | child that leaves the group and scrubs its environment; XCBBuildService |
| 530 | and CoreSimulatorService, which survive by design. Startup after a crash |
| 531 | kills every marked process before reporting `runner_restarted`. The |
| 532 | Linux rule is untouched: a Linux step's termination is still the |
| 533 | verified namespace exit, and nothing in §1.2 lets another runner supply |
| 534 | it. |
| 535 | |
| 536 | ## 6. Wire, API v1, fixtures and testing |
| 537 | |
| 538 | Frames (protocol 2 only): `hello` adds `protocol`, `platform`, `label`, |
| 539 | `sandbox`, `capabilities`; `welcome` adds `protocol`, `role`, `release`; |
| 540 | `dispatch` adds `needs`, `runner_id`; `lease` adds `step_id`, `attempt`; |
| 541 | new `blob{transfer, index, total, sha256, data}` both ways, `publish` |
| 542 | (instance to primary) and `published` (primary to instance), all |
| 543 | durable; `step` adds `termination_kind`, `have []string`, `phase`; new |
| 544 | step reasons `placement_refused`, `withdrawn`, `transfer_refused`; new |
| 545 | checks reason `runner_offline`. Resources: `Runner` adds `label`, `role`, `since`, |
| 546 | `platform`, `capabilities`; `RunnerList` at `GET /api/v1/runners`; |
| 547 | `Snapshot.runners`; `Step` adds `runner_id`, `runner_label`, `needs`, |
| 548 | `placement`, `publication`, `termination_kind`; `Task` adds |
| 549 | `engineering_runner` and Needs you `runner_offline`. Fixtures: `api/runners.json`, |
| 550 | `api/task-placed.json`, `api/task-mac-checks.json` (pass and fail with |
| 551 | `exit_code`), `frames/hello-mac.json`, `frames/welcome-worker.json`, |
| 552 | `frames/dispatch-needs.json`, `frames/blob.json`, |
| 553 | `frames/step-process-group.json`. |
| 554 | |
| 555 | Copy for review (existing marker until Luna's pass): "Add %s to your |
| 556 | team", "Waiting for %s (offline since %s)", "Checks can't run here (%s |
| 557 | was offline)", "Needs you: %s has been offline for 30 minutes", "Checks |
| 558 | are running on %s", "Checks passed (%s, %s)", "%s is offline; ask again |
| 559 | when it is back", "Runners". |
| 560 | |
| 561 | **Linux CI.** The fake worker is the real thin runner started with |
| 562 | `EQUIPO_FAKE_PLATFORM=darwin/arm64`, a fixture capability report from P1, |
| 563 | a fake `xcodebuild` that passes, fails or hangs, and the process-group |
| 564 | executor **without** a sandbox, compiled only under a `testbuild` tag so |
| 565 | no release binary can run unsandboxed. Darwin-only code (`srt` settings, |
| 566 | `simctl` parsing, plist, scheme discovery, sweep, the native permission |
| 567 | port) is unit-tested with recorded outputs. Scenarios, under the |
| 568 | two-minute budget: M1 iOS change, checks placed on the worker via blob |
| 569 | relay, real pass, review on the primary, Ready; M2 worker offline, |
| 570 | waiting, reconnect, run; and the 30-minute path with a fake clock to |
| 571 | `runner_offline`; M3 no worker, `needs_macos` (`4_checks_honest` still |
| 572 | green); M4 worker SIGKILLed mid-checks, `process_group` termination, |
| 573 | Retry, pass; M5 fake gate fails, fix round from its output; M6 one-tap |
| 574 | enrolment as worker, mailbox scoping (wrong-runner ack, sync and report |
| 575 | all refused), `placement_refused` and re-place, withdrawal of an unacked |
| 576 | dispatch, cancel-then-reassign of an acked one, a delayed old-SHA report |
| 577 | that cannot make a newer candidate Ready; M7 blob tampering (bad |
| 578 | `sha256`, wrong SHA, oversize, missing chunk) refused; M8 mixed |
| 579 | versions with the real slice 4 binaries (instance and runner built from |
| 580 | ca0a65c in CI and cached as artifacts): the slice 4 runner against the |
| 581 | new instance speaks protocol 1, runs the `oficina/sample` scenario to |
| 582 | Ready, and never receives a `blob` or a `needs` field; the new runner |
| 583 | against the slice 4 instance falls back to protocol 1 after one refusal |
| 584 | and runs the same scenario; a new worker enrolled against the slice 4 |
| 585 | instance is refused with a clear log line and nothing is lost; M9 (slice F) Engineering on the worker returns a thin pack, the |
| 586 | primary pushes, pinning holds across a fix round and a republish; ask |
| 587 | the implementer pinned and refused elsewhere. All slice 1 to 4 guards |
| 588 | stay, especially Linux termination before Retry. |
| 589 | |
| 590 | **Probes on tito-studio, before any Darwin build work** (slice C): |
| 591 | |
| 592 | - P1 record `xcodebuild -version`, `simctl list -j`, `ComputerName`. |
| 593 | - P2 the hostile fixture of §4.3 under the checks profile; which Mach |
| 594 | services `xcodebuild test` needs; denial of every sentinel attempt. |
| 595 | - P3 `claude /login` with `HOME` set to an empty dir: Keychain item or |
| 596 | file; whether a second home gets a second identity; sentinel Keychain |
| 597 | items readable from inside the shell sandbox or not. |
| 598 | - P4 home permissions of every `/Users/*` as `equipo-paul`; `launchctl |
| 599 | bootstrap gui/$UID` as non-admin; fast-user-switch and sleep. |
| 600 | - P5 `srt -- codex exec` under `workspace-write`: nested Seatbelt. |
| 601 | - P6 group SIGKILL during `xcodebuild test`: what survives; is `simctl |
| 602 | shutdown` needed before the tree can be removed. |
| 603 | - P7 `npm install -g @anthropic-ai/sandbox-runtime` as `equipo-paul`. |
| 604 | |
| 605 | **Witness** (slice E): staging worker under `equipo-paul` with its own state |
| 606 | root, enrolled as a worker of the staging owner; re-judge the Woodstar |
| 607 | witness task `tklkbx5vid3y` at `82a4a0cc`. Pass: the checks step records |
| 608 | `xcodebuild test` (or Woodstar's gate), a real exit code, 200 lines of |
| 609 | Xcode output, `passed` or `failed`, never `cannot_run`; the pack arrived |
| 610 | by relay; Review stayed on the primary. Zero model turns. The live |
| 611 | `oficina/suite` scenario still lands on the primary unchanged. |
| 612 | |
| 613 | ## 7. Slices, decisions and risks |
| 614 | |
| 615 | | Slice | Content | Size | |
| 616 | |---|---|---| |
| 617 | | 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 | |
| 618 | | 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 | |
| 619 | | C Mac probes | P1 to P7 on tito-studio, fixtures recorded, P2 verdict written up | 1 day plus Paul's steps | |
| 620 | | 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 | |
| 621 | | E Witness | Woodstar real pass or fail on tito-studio | 0.5 day | |
| 622 | | 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 | |
| 623 | | G Codex on the Mac | after slice 5 and P5 | parked | |
| 624 | |
| 625 | **Paul's rulings, 2026-11-07:** |
| 626 | |
| 627 | 1. **Dedicated user: yes, one per person.** A runner on a shared Mac |
| 628 | runs as a non-admin user `equipo-<person-handle>` (`equipo-paul`), |
| 629 | never a shared `equipo` user: each runner holds its owner's model |
| 630 | sign-ins and runner identity, and Unix permissions separate people |
| 631 | (§3.5). |
| 632 | 2. **If P2 fails, checks still run on the Mac,** labelled "ran outside |
| 633 | the sandbox" on the checks badge, in the timeline and on Ready to |
| 634 | merge; never a pass in disguise. The slice 4c auto-merge treats them |
| 635 | as passed only for repositories the task's creator owns (§4.3). |
| 636 | |
| 637 | No decisions remain open. |
| 638 | |
| 639 | **Risks.** P2 may fail and bring ruling 2 into play. P3 may limit the Mac to one |
| 640 | Claude account; checks-only does not care, Engineering's Review label |
| 641 | stays honest. A shared Mac is a shared CPU: one step at a time per |
| 642 | worker, `caffeinate` only while a step runs. Pack relay through the |
| 643 | instance costs storage and bandwidth once per repository and a thin pack |
| 644 | per candidate; the 64 MB bound and TTL keep it small, and the instance |
| 645 | stores opaque bytes it never interprets. The mailbox migration touches |
| 646 | every command path; slice A ships alone, with every slice 1 to 4 |
| 647 | scenario green before B begins. |
| 648 | |
| 649 | ## 8. Addendum, 2026-11-28: slice F against today's code |
| 650 | |
| 651 | Written while planning slice F (plan |
| 652 | `docs/superpowers/plans/2026-11-28-mac-runners-slice-f.md`), from `main` |
| 653 | at 8bd40ed1, the unmerged branch `mac-placement-wait` (570375ec) and |
| 654 | read-only probes of tito-studio as `paulca`. Sections 1 to 7 stay as |
| 655 | accepted; where this section disagrees with them about slice F, this |
| 656 | section is current. Nothing here reopens slices A to E. |
| 657 | |
| 658 | ### 8.1 Facts that moved |
| 659 | |
| 660 | - **Numbers.** Migrations are past 0114 and the runner protocol is 35 |
| 661 | (`wire.ProtocolCurrent = ProtocolChangeDiffs`). "Migration 0045" and |
| 662 | "protocol 2" in §§1 to 3 are history. Slice F takes the next protocol |
| 663 | (36, `ProtocolMacEngineering`, confirmed with the parent before code, |
| 664 | since other branches also allocate numbers) and at most one migration. |
| 665 | - **The machine.** tito-studio is reached at its own Tailscale address |
| 666 | (100.76.110.54), not 100.64.0.1. It runs macOS 27.2 on an M5 Ultra (36 |
| 667 | cores, 96 GB), Xcode 27.2 (27B52), with iOS 27.0 and 27.2 simulator |
| 668 | runtimes. Seven people have homes there and several run Claude Code |
| 669 | sessions all day, so it is a busy shared machine. Sleep is off. |
| 670 | `DevToolsSecurity` reports developer mode off; simulator work as a |
| 671 | `_developer` member does not need it. |
| 672 | - **The runner user** is `paulequipo` (Paul, 2026-11-10 and 2026-11-13: |
| 673 | any Standard user with "equipo" in its name; the 11-11 taint |
| 674 | accepted). Its home is `drwxr-x---` group `staff` with no ACL for |
| 675 | other users, so **every other Studio user can list and traverse it** |
| 676 | (verified from `paulca`). Paul's own home has the ACL that shuts out |
| 677 | `paulequipo`; the reverse direction was never needed while the Mac |
| 678 | held no secret. Slice F puts a model credential on the Mac, so it now |
| 679 | matters (§8.3). |
| 680 | - **Enrolment.** The Studio is enrolled to production as worker "Tito |
| 681 | Studio" (2026-11-28). One enrolment per macOS user, so there is no |
| 682 | staging worker. The slice F witness therefore runs on production |
| 683 | behind an instance switch (§8.6), unless Paul makes a second Mac user |
| 684 | for staging. |
| 685 | - **Placement.** `mac-placement-wait` (to merge before slice F) makes |
| 686 | Mac work wait instead of running on Linux: checks needing macOS with no |
| 687 | fitting runner wait (`waiting_mac`), and Engineering for a repository |
| 688 | whose base gate needs Xcode (`RepoInfo.NeedsMacOS`) never runs on a |
| 689 | Linux primary (`waiting_mac`, or `waiting_mac_engineering` while the |
| 690 | only fitting runners are workers). One compatibility exception stays: |
| 691 | a protocol 1 primary, which has no workers, still runs it as before. |
| 692 | §1.4's "Engineering runs on the primary with today's summary" no |
| 693 | longer holds otherwise. Slice F replaces `waiting_mac_engineering` |
| 694 | with placement on the worker. |
| 695 | - **Checks sandbox.** srt is installed privately with pinned Node, |
| 696 | ripgrep and lockfile, not `npm install -g`. The P2 verdict lives only |
| 697 | in the worker's memory and is trusted only under those pins; a runner |
| 698 | that ever ran checks outside the sandbox is tainted for good. Ruling 2 |
| 699 | became, by delegation (2026-11-11), "checks wait for the Mac's |
| 700 | sandbox; the task's creator may run one attempt outside it from the |
| 701 | task page" (`chat/macsandbox.go`). |
| 702 | - **Accounts.** §3.4 (`equipo-runner login claude`, the Keychain |
| 703 | hypothesis, probe P3) is superseded by Connections (2026-11-08) and |
| 704 | token connections (Paul, 2026-11-10): a pasted or runner-made |
| 705 | `claude setup-token` token rests in `.oauth-token` in a dedicated home |
| 706 | and reaches the CLI as `CLAUDE_CODE_OAUTH_TOKEN`, with |
| 707 | `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1`. Connection rows carry a |
| 708 | `runner_id`, but a worker's hello sends no connections and no seal |
| 709 | key, and the Connections page only adds to the primary. |
| 710 | - **Claude Code pin.** Every runner pins Claude Code 2.1.312 by digest: |
| 711 | `claude.ExecutableSHA256` is the certified linux/amd64 build, with an |
| 712 | arm64 test pin. There is no darwin pin, and the Mac's capability |
| 713 | discovery today runs whatever `claude` it finds to read its version. |
| 714 | Many runner behaviours were read statically from 2.1.312 (subprocess |
| 715 | scrub, remote settings, setup-token), so the Mac must run the same |
| 716 | version, and slice F stops running an unpinned `claude` at all. |
| 717 | - **Engineering on Linux** is no longer "`claude -p` as today" plus a |
| 718 | settings file. It is a certified launch: `provider.BuildPolicy` needs a |
| 719 | bubblewrap version, `/opt` mounts, `/home/runner` and `/workspace`; |
| 720 | the CLI runs inside the containment namespace, and its own Bash sandbox |
| 721 | runs nested inside that. None of this exists on a Mac. The Darwin path |
| 722 | needs its own policy and launcher (§8.2). |
| 723 | - **The tool proxy.** Engineering's permission prompt and |
| 724 | `submit_candidate` reach the runner through the MCP tool proxy. The |
| 725 | Mac release has no tool proxy (its Linux build's digest is certified, |
| 726 | and a portability edit changed its bytes), and `ServeToolProxy` on |
| 727 | darwin refuses today. Slice F makes the runner binary itself serve that |
| 728 | MCP endpoint in a darwin-only mode; the Linux tool proxy stays |
| 729 | byte-identical. |
| 730 | - **Credential operations and transcripts are Linux-shaped.** The token |
| 731 | check (`thin/tokencheck.go`) and the sign-in by link (`thin/signin.go`) |
| 732 | need the containment manager and Linux sign-in policies. Kept |
| 733 | transcripts live under `projects/-workspace` (`thin/claude.go`), and |
| 734 | Engineering and question prompts name `/workspace`. A Mac needs Darwin |
| 735 | versions of each. |
| 736 | - **Ask the implementer is not pinned exactly.** `AskCommand` carries |
| 737 | the question's attempt, not the Engineering attempt, account and |
| 738 | session it must resume; `keptSessionFor` takes the newest. §1.4's |
| 739 | exact pinning still has to be built. |
| 740 | - **Injection defences** (2026-11-19). Gates come from the base |
| 741 | (`.equipo/gates.json`), and "Mac worker results remain diagnostic until |
| 742 | their executor can enforce immutable base gates, and cannot grant |
| 743 | standing auto-merge authority." Slice F keeps that: a Mac-made |
| 744 | candidate merges only on a person's tap. Prompts quote untrusted text |
| 745 | in data blocks; the worker builds its prompts with the same functions. |
| 746 | - **Secrets in candidates.** gitleaks 8.30.1 is pinned and ships for |
| 747 | darwin/arm64 too. Engineering's change diffs leave out the primary's |
| 748 | known secrets. For a worker's candidate, the worker checks its own |
| 749 | known secrets before upload (§8.3) and the primary computes change |
| 750 | files and diffs when it publishes. `PublishedReport` carries neither |
| 751 | today. |
| 752 | - **carlos guard.** Previews, sites and the devbox need the guarded |
| 753 | `carlos` CLI. They stay on the primary; a worker never looks carlos up. |
| 754 | - **Engineering grew** after 11-07: kept sessions and fix rounds that |
| 755 | resume them, unfinished work kept on `step_timeout`, rebase rounds |
| 756 | (`merge-tree` with an explicit merge base), the Research hand-off |
| 757 | (quoted findings plus kept images), scheduler holds, failover across |
| 758 | connections, change diffs, task kinds (`change`, `explore`). A worker |
| 759 | carries each one or refuses it out loud (plan task 12). Copy, Design, |
| 760 | Research, Preview, Publish and Merge steps stay on the primary. |
| 761 | |
| 762 | ### 8.2 The Darwin Engineering launch |
| 763 | |
| 764 | The worker runs the pinned 2.1.312 darwin-arm64 CLI, which it fetches |
| 765 | itself from the official release and checks against a digest compiled |
| 766 | into the runner. It never runs a `claude` from `PATH`, and it never |
| 767 | needs Paul to install one. Each launch gets: |
| 768 | |
| 769 | - the §4.4 Engineering settings, generated per attempt and checked |
| 770 | byte-for-byte before launch, as `validatePolicy` does on Linux. |
| 771 | Settings keys the pinned build does not read are a stop, not a guess. |
| 772 | Plan task 1 reads them statically from the binary; |
| 773 | - the worktree at its real path (`realpath`, no `/private` alias) as the |
| 774 | workspace root of the ported native permission rules (§4.4); |
| 775 | - the runner's darwin tool-proxy mode as the only MCP server, on a |
| 776 | 0600 socket in a 0700 directory, peer uid checked; |
| 777 | - a runtime copy of the connection's dedicated home as |
| 778 | `CLAUDE_CONFIG_DIR`, and the token in the environment, or through a |
| 779 | file descriptor if the pinned build reads one (task 1 checks); |
| 780 | - process-group termination exactly as §5, reusing the checks gate's |
| 781 | executor. |
| 782 | |
| 783 | **Xcode access for Engineering follows the proof.** Engineering's Bash |
| 784 | sandbox gets the Mach services Xcode needs only when this Mac's P2 is |
| 785 | denied **and** probe F5 (P2's hostile fixture built by `xcodebuild` |
| 786 | under Claude's own sandbox settings, since the CLI's embedded sandbox |
| 787 | runtime is not the pinned srt) is denied too. Otherwise Engineering on |
| 788 | the Mac runs with no Mach services: it edits, reads and uses tools that |
| 789 | need no Xcode service. The build and test then happen in Checks, and |
| 790 | the step says so. Reason: code that XCBBuildService or a simulator runs |
| 791 | for the repository would run outside Seatbelt, with network, as the user |
| 792 | that now holds a Claude token. |
| 793 | |
| 794 | ### 8.3 A model credential on a shared Mac |
| 795 | |
| 796 | Until now the Mac held only its runner identity. After slice F it holds |
| 797 | a long-lived Claude token. Three consequences, all in the plan: |
| 798 | |
| 799 | 1. **Unix permissions.** The worker refuses to store or use a model |
| 800 | connection unless it can show, from ownership, mode bits and ACLs |
| 801 | alone (it cannot test as another user), that no other user can list, |
| 802 | traverse or read its home, state dir, config dir and accounts root, |
| 803 | and that each of those lies inside the home. It names what to change, |
| 804 | for example `chmod 700 ~` run as the runner user, plus removing any |
| 805 | ACL entry that grants access. |
| 806 | 2. **The sandbox is the only thing between repository code and the |
| 807 | token.** On Linux a PID namespace hides the CLI's environment from its |
| 808 | Bash commands. On a Mac there is no namespace, so probe F3 checks, |
| 809 | from inside the CLI's Bash sandbox, that the CLI's environment and the |
| 810 | token file cannot be read (`ps -E`, `sysctl kern.procargs2`, the file |
| 811 | by path). If F3 is not denied, the worker takes no Engineering. |
| 812 | 3. **Outside-the-sandbox runs reach the token.** A check run outside the |
| 813 | sandbox on that Mac (the creator's per-attempt choice) runs as the user |
| 814 | that holds the token, with network. **Decision for Paul, D1** (§8.7). |
| 815 | 4. **Checks run as the same user.** The srt checks profile must also |
| 816 | keep the token out of reach (P2 gains the F3 sources). One |
| 817 | machine-wide lock serializes every operation that runs repository |
| 818 | code, runs Xcode or puts a token in a process (a check, an |
| 819 | Engineering attempt, an ask, a probe run, a token check, a sign-in), |
| 820 | each for its own life; descendants an operation starts belong to it. |
| 821 | Separately, from the moment a connection starts connecting until its |
| 822 | files and any Keychain item are proven gone, the Mac counts as |
| 823 | holding a credential, which matters for D1. |
| 824 | 5. **A user that ever ran unsandboxed** may hold persistence (a launch |
| 825 | agent, a changed config, a waiting process) that no later probe can |
| 826 | rule out. **Decision for Paul, D2** (§8.7). |
| 827 | |
| 828 | The worker also checks every new object before upload (blobs, |
| 829 | including binary ones and symlink targets, trees for file names, and the |
| 830 | commit message) for each of its known secrets, raw and encoded, and runs |
| 831 | gitleaks under the trusted configuration over the changed files. A hit, |
| 832 | a scanner failure or an object over the scan bound refuses the step with |
| 833 | `secret_in_candidate`, and nothing is uploaded. |
| 834 | |
| 835 | ### 8.4 Packs for Engineering |
| 836 | |
| 837 | The base of a first Engineering step and the new tip of a rebase round |
| 838 | are chosen by the primary today, inside `Engineer.Exec`. For a worker |
| 839 | the primary resolves them first: the instance asks it to prepare the |
| 840 | base, it fetches and reports the SHA, and the instance binds that SHA to |
| 841 | the attempt before it dispatches to the worker and opens the transfer. |
| 842 | |
| 843 | An inbound Engineering transfer has a kind and names its commits in |
| 844 | fixed, comparable header fields (protocol 36): the base; for a rebase |
| 845 | round, also the old base and the candidate. The worker's store marks |
| 846 | those commits as shallow boundaries, so nothing walks into missing |
| 847 | parents. Its tree has only those commits, like the depth-1 clones the |
| 848 | index already makes. The worker checks the pack's own inventory: exactly |
| 849 | the named commits, each with a complete tree. The outbound pack is thin |
| 850 | against the base (`^base candidate`), which the primary already indexes |
| 851 | with `--fix-thin` beside its clone. Repositories without commits are |
| 852 | never Mac work (no gate, so no `needs_macos`), and a worker refuses an |
| 853 | empty base. The 64 MB bound stands. Over it, Engineering ends |
| 854 | `workspace_too_large` with Needs you, rather than running on Linux. |
| 855 | |
| 856 | Change files and diffs for a worker's candidate come from the primary |
| 857 | when it publishes. The instance accepts them from the primary for that |
| 858 | publication only, bound to the worker's task, step and attempt. |
| 859 | |
| 860 | ### 8.5 Placement, pinning and connections |
| 861 | |
| 862 | Engineering for Mac work needs `macos`, `xcode`, `ios_simulator` (when |
| 863 | the repository has a shared scheme) and `claude`. A worker advertises |
| 864 | `claude` only when the pinned CLI is verified, F1 to F4, F6 and F7 |
| 865 | passed for this version, profile and Xcode, the home guard passes, and |
| 866 | it holds at least one usable Claude connection. Beside the tag it sends |
| 867 | an Engineering status naming the first thing missing. When a Mac fits |
| 868 | everything but `claude`, the step waits with that reason, so the person |
| 869 | sees what to do: add Claude to the Mac, sign in again, wait for a limit, |
| 870 | fix the home folder, or wait for the probes. A Mac or a primary older |
| 871 | than protocol 36 waits as `waiting_mac_update`. |
| 872 | Pinning (§1.4) is unchanged and now real: fix rounds, retries, rebases, |
| 873 | republishes and questions go to the task's Engineering runner. A removed |
| 874 | pinned worker leaves the task at Recover. It is never re-pinned silently |
| 875 | to the Linux primary. |
| 876 | |
| 877 | Connections on a worker: its hello sends its connections and its seal |
| 878 | key; the Connections page groups connections by machine and offers "Add |
| 879 | Claude to <Mac>" for a Mac worker. The token is sealed to that worker's |
| 880 | key in the browser, or made by that worker's own `setup-token` sign-in, |
| 881 | as on the primary. Only Claude token connections run on a Mac in slice |
| 882 | F. Codex stays slice G; metered and endpoint connections stay on the |
| 883 | primary. |
| 884 | |
| 885 | ### 8.6 Witness and switch |
| 886 | |
| 887 | `EQUIPO_MAC_ENGINEERING=1` on the instance enables placement on a |
| 888 | worker. Unset, Mac Engineering waits as `mac-placement-wait` left it, so |
| 889 | the release can deploy inert. The live witness (§6, M9, slice F row) runs |
| 890 | on production with the Studio after the release is deployed by whoever |
| 891 | holds that authority. It needs Paul for his rulings on D1 and D2 |
| 892 | (§8.7) and to sign in when adding Claude to Tito Studio, and it needs |
| 893 | the Studio's P2 denied. M9 itself runs offline on Linux CI with the test |
| 894 | build's fake worker and fake CLI. |
| 895 | |
| 896 | ### 8.7 Decisions |
| 897 | |
| 898 | - **D1 (Paul).** A Mac that holds a model connection: may a check still |
| 899 | run outside its sandbox on the creator's choice? Recommended default, |
| 900 | which the plan builds: **no.** While a Mac holds a model connection, |
| 901 | the "Run outside the sandbox" choice is not offered for it, and the |
| 902 | worker refuses an unsandboxed dispatch. Checks there wait for the |
| 903 | sandbox. If Paul rules yes, the choice stays, its warning names the |
| 904 | Claude connection, and the connection is marked "sign in again" after |
| 905 | such a run. Either way the change is small: one predicate (plan task |
| 906 | 15). |
| 907 | The default also means checks on a Mac whose P2 is not denied wait |
| 908 | for good once it holds a connection, so the witness needs the Studio's |
| 909 | P2 denied. |
| 910 | - **D2 (Paul).** A runner user that ever ran checks outside the sandbox |
| 911 | (the Studio's `paulequipo` did on 2026-11-11; Paul accepted that taint |
| 912 | on 2026-11-13, before any credential lived on the Mac) may hold |
| 913 | persistence no probe can rule out. Recommended default, which the plan |
| 914 | builds: a runner whose instance record or own state says tainted |
| 915 | takes no model connection, and the Machines page says why. For the |
| 916 | Studio's production enrolment (a fresh state dir and runner row) the |
| 917 | code sees no taint, so the 11-11 history is Paul's call: keep |
| 918 | `paulequipo` for Engineering, or make a fresh Standard user for it (his |
| 919 | sign-in and the install command, as on 2026-11-10). |
| 920 | - **Settled here, by the controller's reading of the accepted rulings:** |
| 921 | Review stays on the primary (the table's "Mac Engineering and Review" |
| 922 | means Review of Mac-made candidates). Research images are not relayed |
| 923 | in slice F; the findings text is, and the prompt says the images are on |
| 924 | the main runner. `simctl shutdown all` before a temp cleanup stays (the |
| 925 | mac-user-temp ruling): the runner user's simulators are all its own. |
| 926 | |
| 927 | ### 8.8 Addendum to §5, 2026-11-28: finding what an attempt left |
| 928 | |
| 929 | Written for plan task 9, from task 1's findings |
| 930 | (`docs/superpowers/plans/MAC-SLICE-F-TASK1-FINDINGS.md`, R4 and S5), the |
| 931 | sweep the coordinating session approved on 2026-11-28, and the |
| 932 | controller's stricter ruling after review round 1 (no exemption by |
| 933 | path). Where it disagrees with §5, this section is current. |
| 934 | |
| 935 | **What task 1 found.** |
| 936 | |
| 937 | - Claude Code 2.1.312 starts every Bash tool command with |
| 938 | `detached: true`, so each command runs in a new session and process |
| 939 | group (setsid), outside the attempt's group. Signals to the |
| 940 | attempt's group never reach them. |
| 941 | - On macOS 27.2 the kernel hides the environment of platform binaries |
| 942 | (`/bin/bash`, `/bin/zsh`, `/bin/sleep`, `/usr/bin/env`, |
| 943 | `/usr/bin/sandbox-exec`) even from their own user. `ps -E` and |
| 944 | `KERN_PROCARGS2` show `EQUIPO_ATTEMPT` only on other binaries (Xcode's |
| 945 | tools, built test binaries, Homebrew tools). |
| 946 | - Together: §5's group-plus-marker sweep misses exactly the processes |
| 947 | Bash commands are made of. A sandboxed `sleep 1000 &` would outlive a |
| 948 | cancel, unseen. |
| 949 | |
| 950 | **Identity.** Every process is named by its pid and the kernel's start |
| 951 | time (microseconds, from `kern.proc`). A pid used again later is another |
| 952 | identity. Nothing is matched by name, and nothing is spared by path. |
| 953 | |
| 954 | **The kill set.** At an operation's end, these are killed: |
| 955 | |
| 956 | - (a) what the runner saw of the operation while it ran: the processes |
| 957 | under its leader, read about every 250 ms (`kern.proc.ruid` and |
| 958 | `getsid`), and every process in a group or session they made; |
| 959 | - (b) every process of the runner user that started after the turn |
| 960 | began (it is not in the table read when the turn began), whatever its |
| 961 | parent or path. That includes launchd-parented processes under |
| 962 | `/System`, `/usr/libexec` or `/usr/sbin` started during the turn: they |
| 963 | are per-user on-demand agents of a dedicated user, and launchd starts |
| 964 | them again when they are next needed; |
| 965 | - (c) every process carrying the marker, wherever the kernel shows it. |
| 966 | |
| 967 | The only processes never in it are the runner itself and the helpers it |
| 968 | registered for itself (`mac.StartOwn`: capability queries, `ps`, |
| 969 | `caffeinate`, the worker's git, later gitleaks and packing), by identity, |
| 970 | together with their descendants seen while the helper lived. A |
| 971 | descendant stays the runner's own after its helper exits; a process that |
| 972 | later has a helper's pid is not. |
| 973 | |
| 974 | **The stop.** Close stdin and wait for a graceful end. Then send SIGTERM |
| 975 | to the kill set, wait the 10 s grace, and send SIGKILL. Before each |
| 976 | signal the runner reads that process again, and signals it only if it is |
| 977 | the same identity and still the runner user's. A group is signalled |
| 978 | whole only while a member read just then is still in it. Another user's |
| 979 | process is never signalled. |
| 980 | |
| 981 | **Three phases.** |
| 982 | |
| 983 | 1. The first kill pass signals what the first read found. Just before |
| 984 | its first signal, the runner reads the table's clock (the clock of the |
| 985 | kernel's start times): that moment is the relaunch cutoff. |
| 986 | 2. Discovery is exactly one more read. What it finds new joins the kill |
| 987 | set and is signalled. One exception: a process whose parent is |
| 988 | launchd, whose kernel path (`proc_pidpath`, never `argv[0]`) is under |
| 989 | `/System` (not `/System/Volumes`), `/usr/libexec` or `/usr/sbin`, and |
| 990 | which started after the cutoff, is taken as launchd starting a killed |
| 991 | agent again. It is not killed and does not block the proof. One that |
| 992 | started before the cutoff is killed, even if the first read missed |
| 993 | it. |
| 994 | 3. Later reads only check. They signal the kill set again (SIGKILL once |
| 995 | the grace is over) and add nothing to it. Each one withholds both the |
| 996 | proof and the Mac's clearance (`Owed`) while any process of the |
| 997 | runner user born during the turn is alive, other than the runner's |
| 998 | own and a relaunch as defined in phase 2. Such a process is not |
| 999 | signalled; the turn's record stays, and the next turn's settling, |
| 1000 | with its own kill pass, ends it. |
| 1001 | |
| 1002 | Every group and session a kill-set process leads becomes an obligation. |
| 1003 | So a process born into one after discovery (a fork from a dying target) |
| 1004 | keeps the proof waiting, though no read adds it. |
| 1005 | |
| 1006 | **The proof.** Termination is proven only when all of these hold, within |
| 1007 | one absolute 30 s deadline. The deadline covers every table read, every |
| 1008 | durable note and its fsync, the settling of an earlier turn, |
| 1009 | `settleRecord` and the debt check. A proof is accepted only if the |
| 1010 | deadline has not passed when the last of these returns, and `Verify` |
| 1011 | gives its parts no separate budgets: |
| 1012 | |
| 1013 | - every process in the kill set is gone, matched by pid and start time; |
| 1014 | - every recorded group returns ESRCH to `kill(-pgid, 0)`; |
| 1015 | - no process of any user is left in a recorded session; |
| 1016 | - no marked process remains, and the leader is reaped; |
| 1017 | - everything above is durably on the turn's record, and the stop's |
| 1018 | final note marked it complete. |
| 1019 | |
| 1020 | **The user-temp cleanup has its own bound (2026-11-29).** The 30 s |
| 1021 | deadline covers process termination only: the stop, the sweep and the |
| 1022 | proof. An attempt that may write the runner user's T then has its |
| 1023 | cleanup (simulators shut down, what it made in T removed, the pending |
| 1024 | cleanup record removed) bounded by `CleanLimit` (3 minutes) from the |
| 1025 | cleanup's start, because a simulator shutdown can take minutes. The |
| 1026 | time is read after the last of these returns, the record removal |
| 1027 | included, and in `Verify` after the final save of what the attempt |
| 1028 | owed. An attempt is terminated (`Terminated: true`, a launch's end |
| 1029 | proven) only with its proof inside the 30 s and its cleanup inside its |
| 1030 | bound. On any error or overrun the pending cleanup record (if it is |
| 1031 | still there) and the turn's record stay, so its boot-qualified evidence |
| 1032 | survives: after a reboot `Verify` clears the attempt from that evidence |
| 1033 | before it looks at any old process id, and keeps the completion for |
| 1034 | each consumer. A later `Verify` finishes the cleanup. |
| 1035 | |
| 1036 | If the turn's record cannot be written, the operation is stopped at once |
| 1037 | and its proof withheld, and no further launch starts in that turn. A |
| 1038 | record is complete (a durable `complete` mark) only once every launch of |
| 1039 | the turn has written its own final note, each after all its group and |
| 1040 | session writes, and no evidence write of the turn ever failed. After a restart, a record without that mark is |
| 1041 | incomplete: what it left is swept as usual, but recovery alone never |
| 1042 | proves its attempts over. Each such attempt stays unterminated with no |
| 1043 | Retry, and the Mac's card on the Machines page says so (the capability |
| 1044 | code `unproven: record_incomplete`, worded on the instance, which also |
| 1045 | says a restart of the Mac clears it), until one of two clearances proves |
| 1046 | it: |
| 1047 | |
| 1048 | 1. **An idle read** (first, and cheaper). It applies only to a turn in |
| 1049 | which nothing ran outside a sandbox. Before any unsandboxed |
| 1050 | operation starts (an unsandboxed check, a bare probe gate, anything |
| 1051 | that runs repository or model-chosen code outside a sandbox), the |
| 1052 | turn's record durably gets `unsandboxed_ran`; if that write fails, |
| 1053 | nothing starts. Every record carries `flags_known` from its start. |
| 1054 | A turn whose flag is set, or whose record cannot show it was never |
| 1055 | set, clears only by a reboot. |
| 1056 | |
| 1057 | The reason is the one thing an idle read cannot see. A process of |
| 1058 | the attempt that changed its real uid has left the runner user's |
| 1059 | table. Changing the real uid needs a setuid program, and on macOS |
| 1060 | 27.2 no Seatbelt profile can exec one (task 1, R4: `sandbox-exec` |
| 1061 | refuses to exec `/bin/ps`, a setuid binary, under every profile). |
| 1062 | So in a turn where everything ran sandboxed, no process of the |
| 1063 | attempt can have changed its uid. |
| 1064 | |
| 1065 | The runner user is dedicated. At runner start, and each time the |
| 1066 | instance syncs (a person's Retry among them), the runner holds the |
| 1067 | Mac's turn and reads every process of the runner user twice, each |
| 1068 | read whole and in time. Every process found must be the runner, a |
| 1069 | helper it registered (with what that helper started), or a process |
| 1070 | that existed, by pid and start time, when the earliest unresolved |
| 1071 | turn began. That baseline is the table of the earliest turn that |
| 1072 | still owes anything, never a later turn's, whose table may hold an |
| 1073 | earlier turn's survivor. A turn on record without a table exempts |
| 1074 | nothing. Then every process, group and session the record names |
| 1075 | must be gone, for every user. |
| 1076 | |
| 1077 | The clearance covers every unresolved turn, not only the attempt's. |
| 1078 | While any other turn that still owes anything ran something outside |
| 1079 | a sandbox, or has a record that cannot show it did not, nothing is |
| 1080 | cleared this way: one of its processes may have changed its uid and |
| 1081 | still be running. Each other unresolved turn must be sandbox-only, |
| 1082 | and every process, group and session it names must be gone, for |
| 1083 | every user, before this attempt clears. |
| 1084 | |
| 1085 | Any unaccounted process, or a failed or late read, keeps the attempt |
| 1086 | unproven. The Machines page then gives only their number |
| 1087 | (`unproven: processes_left` with `unproven_count`), never names, |
| 1088 | pids or paths, and says a restart clears it. The clearance refuses |
| 1089 | to run outside a held turn, and on a table that is not the runner's |
| 1090 | alone. |
| 1091 | |
| 1092 | **Why a process born after the second read is not a survivor.** |
| 1093 | Take any unresolved turn. It ran only sandboxed, so none of its |
| 1094 | processes left the runner user's table, and every one it recorded is |
| 1095 | gone for every user. Every exempt process predates every unresolved |
| 1096 | turn, so it is none of that turn's processes. Every other process of |
| 1097 | the runner user blocks the clearance at either read. So no process |
| 1098 | of any unresolved turn was present at either read, under any uid, |
| 1099 | and none can fork after the second. Both reads and the |
| 1100 | acceptance happen holding the turn, so no operation of the runner's |
| 1101 | starts a process meanwhile, and any process born after the earliest |
| 1102 | unresolved turn began that is not the runner's own blocks the |
| 1103 | clearance at either read. A process born after the second read can |
| 1104 | therefore come only from an exempt process or from the runner's |
| 1105 | own: work a pre-turn service does, perhaps on a request, but not a |
| 1106 | process of the turn. |
| 1107 | 2. **A reboot** (the fallback). Nothing outlives a boot. A record or an |
| 1108 | obligation whose turn began in an earlier boot counts as proven. That |
| 1109 | needs another boot identity (`kern.bootsessionuuid`, so a clock step |
| 1110 | cannot fake it) and a boot time after the turn's start. Such a record |
| 1111 | is settled without a sweep, its table being the earlier boot's. The |
| 1112 | result is boot-qualified: the old boot's group and session ids, and |
| 1113 | a pending user-temp cleanup's group id, are this boot's to use, so |
| 1114 | they are neither checked nor signalled. An unreadable boot proves |
| 1115 | nothing. |
| 1116 | |
| 1117 | A record has more than one consumer: the step's recovery and the |
| 1118 | Keychain recovery both prove the same process record, in either |
| 1119 | order and perhaps in different runner processes. So the reboot's |
| 1120 | proof is kept on `<lock>.owed` as a completion, keyed by the |
| 1121 | attempt and this boot's identity. A proof only reads it: a later |
| 1122 | proof of the same record finds the completion and succeeds without |
| 1123 | checking or signalling anything, across a runner restart too. Each |
| 1124 | consumer acknowledges the completion, in a separate step, once its |
| 1125 | own result is durable: the step recovery after its transaction |
| 1126 | commits (at a restart, or when a later probe records the |
| 1127 | termination), and the Keychain recovery once the watch's record is |
| 1128 | saved as checked or removed. The completion goes only when both |
| 1129 | have acknowledged it, so a crash between a proof and its commit |
| 1130 | loses nothing. A completion that some consumer never acknowledges |
| 1131 | is dropped after 30 days. |
| 1132 | |
| 1133 | The evidence is per marker. One turn's obligation can name several |
| 1134 | launches (a probe's, or an Engineering operation's). Proving one of |
| 1135 | them takes only its marker out of the obligation; the others keep |
| 1136 | their reboot evidence, and each is proven on its own. |
| 1137 | |
| 1138 | Both clearances run under the attempt's one proof deadline. They remove |
| 1139 | nothing on their own: what the attempt owes is discharged only once its |
| 1140 | whole proof, including any cleanup, has succeeded in time. A proof that |
| 1141 | fails or expires leaves every obligation in place. |
| 1142 | |
| 1143 | The deadline covers every step of the proof: the pending user-temp |
| 1144 | cleanup (shutting simulators down among it), the lock on |
| 1145 | `<lock>.owed.lock` that the discharge needs, and the save itself (its |
| 1146 | write, sync and rename). If any of them cannot finish in time, the |
| 1147 | proof fails, and the debt and the pending cleanup stay; a later proof |
| 1148 | carries on from there, the cleanup being safe to repeat. A discharge |
| 1149 | whose save ends late writes the debt back. A reboot's completion saved |
| 1150 | late stays: it is the evidence the later proof finishes from. An |
| 1151 | assessment that cannot open or lock the debts proves nothing. |
| 1152 | |
| 1153 | Otherwise the step stays unterminated (no Retry), and its turn's record |
| 1154 | stays too. The next turn, in any runner process, settles that record |
| 1155 | before it begins, with the same kill set and the earlier turn's "before" |
| 1156 | table. If a process of the runner user is still left, the next turn does |
| 1157 | not begin. If only processes, groups or sessions another user now holds |
| 1158 | are left, the Mac may take turns again: those obligations are kept |
| 1159 | (`<lock>.owed`), never signalled, and the attempt is not proven over |
| 1160 | until they end. |
| 1161 | |
| 1162 | That release needs a clean read: a read that fails voids any earlier |
| 1163 | clearance, and only a later read in time that shows nothing of the |
| 1164 | runner user's left restores it. Every runner process reads and writes |
| 1165 | `<lock>.owed` only under an flock on `<lock>.owed.lock`, `Verify` |
| 1166 | included. |
| 1167 | |
| 1168 | **After a restart.** The new runner settles the dead runner's turn |
| 1169 | record first. Then, for each recorded attempt, it kills every process |
| 1170 | carrying the marker, and the recorded group only while a marked process, |
| 1171 | read just then, is in it. A recorded group that is alive with no marked |
| 1172 | process in it is either the attempt's child that scrubbed its |
| 1173 | environment or the group id used again by someone else. It is not |
| 1174 | killed, and the attempt is not proven over until the group is gone. |
| 1175 | |
| 1176 | A user-temp cleanup left pending belongs to the attempt, in the runner |
| 1177 | process that wrote it. Only that attempt (its run, or its later proof) |
| 1178 | or a restart may finish it. A restart is recognised only when the writer |
| 1179 | is surely gone: an identity that cannot be read is not a dead one. |
| 1180 | |
| 1181 | **One turn per operation.** `mac.Turns` is taken for each operation's |
| 1182 | life and no longer: a check, an Engineering attempt, an ask, a probe run |
| 1183 | (P1 to P7 as one turn; F1 to F7 likewise), a token check, a sign-in pty |
| 1184 | and a token store. What the operation starts itself belongs to it. Every |
| 1185 | Mac launch refuses to start outside a held turn. A probe run that reaches |
| 1186 | its limit reports at once but keeps the turn until its gates have |
| 1187 | stopped and cleaned up. The credential flag (task 11) is separate: it |
| 1188 | holds no turn. |
| 1189 | |
| 1190 | **The honest limit.** One case is left: the relaunch identification |
| 1191 | itself. A process with a system path, reparented to launchd, that starts |
| 1192 | after the relaunch cutoff (during the kill pass) cannot be told from a |
| 1193 | relaunch, so it is spared and does not block the proof. |
| 1194 | |
| 1195 | Also not covered: |
| 1196 | |
| 1197 | - the moment between a fresh read of a process and its signal, in which |
| 1198 | a pid could in theory be used again (macOS allocates pids in sequence, |
| 1199 | so this needs a full wrap of the pid space within that moment); |
| 1200 | - a process that changes its real uid leaves the runner user's table. |
| 1201 | The proof still waits for it while it is in the kill set or in a |
| 1202 | recorded group or session. |
| 1203 | |
| 1204 | Since the runner user is dedicated and turns are serialized, the sweep |
| 1205 | also ends anything else of the runner user's that started during the |
| 1206 | turn: a person signed in as that user, or launchd agents (which launchd |
| 1207 | starts again on demand). |
| 1208 | |