| 1 | # Mac runners slice F: Engineering on a Mac worker |
| 2 | |
| 3 | Status: rev 4, 2026-11-28. Astra round 1 NOT READY (20 findings), round |
| 4 | 2 NOT READY (8 partly resolved, 4 new), round 3 READY AFTER FIXES (4 |
| 5 | partly resolved, 1 new, 2 trivial). All findings applied; no fourth |
| 6 | round (round limit). Spec: `docs/superpowers/specs/2026-11-07-equipo-mac-runners.md` |
| 7 | rev 4 plus its §8 addendum (2026-11-28), which is current where they |
| 8 | differ. Branch `mac-slice-f` from `origin/main` 8bd40ed1. Controller |
| 9 | brief: `CONTROLLER-BRIEF-mac-slice-f.md`. |
| 10 | |
| 11 | Rulings (Paul, 2026-11-28): **D1 no**, as the default below: once the |
| 12 | Studio holds a Claude token, checks there run sandboxed or not at all. |
| 13 | **D2 keep `paulequipo`**: Paul signs in Claude for it at the witness and |
| 14 | runs `chmod 700 ~` as `paulequipo` if the home guard asks. |
| 15 | |
| 16 | Paul (2026-11-28): "Surely mac runners need to be able to do native Mac |
| 17 | and iOS development?" Slice F lets a Mac worker run Engineering steps |
| 18 | with Claude Code, so iOS and Mac changes are made, and where the sandbox |
| 19 | is proven built, on a Mac. The primary still holds the forge, chooses |
| 20 | bases, pushes, reviews and merges. |
| 21 | |
| 22 | ## 0. Ground rules for every task |
| 23 | |
| 24 | - **Tests first.** Each task writes its failing tests, runs them, and |
| 25 | sees them fail for the stated reason before implementing. Every guard |
| 26 | named in a task gets a **mutation check**: break the guarded line, |
| 27 | watch a named test fail, restore. Record commands and results in |
| 28 | `docs/superpowers/plans/MAC-SLICE-F-PROGRESS.md` (AGENTS.md). |
| 29 | - **Targeted runs while iterating**, such as |
| 30 | `go test ./internal/runner/thin/ -run TestWorkerEngineering -count=1`. |
| 31 | `make ci` runs once, before the whole-branch review. Darwin code is |
| 32 | built on Linux. Every task that touches darwin files runs |
| 33 | `GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build ./...` and |
| 34 | `make vet` (which vets the runner for darwin/arm64). |
| 35 | - **What only a Mac can show** is unit-tested with recorded outputs and |
| 36 | fakes, then proven by the shipped probes (task 14) once a release runs |
| 37 | on the Studio. Each recorded output carries its date and the machine |
| 38 | it came from. |
| 39 | - **Protocol 36** (`wire.ProtocolMacEngineering`) gates every new frame, |
| 40 | field and command. `wire.Encode(f, p)` for p < 36 drops them. The |
| 41 | fixture tests encode each new frame at 35 and at 36. Both the primary |
| 42 | and the worker must speak 36 before Mac Engineering is placed. Confirm |
| 43 | the number with the parent before code, since other branches also |
| 44 | allocate numbers. Use one migration, with the next free number at the |
| 45 | time. |
| 46 | - **Copy** follows AGENTS.md: new runtime strings go in |
| 47 | `internal/equipo/copy.go`, marked pending with |
| 48 | `python3 scripts/copy-status.py pending`. The same strings also go in |
| 49 | the copy-review JSON `docs/superpowers/plans/2026-11-28-mac-slice-f-copy.json` |
| 50 | for Luna's review (task 15). Luna's edits are applied verbatim, and |
| 51 | the strings stay pending. Acceptance happens only through the |
| 52 | project's own path (AGENTS.md: the owner's "Copy can accept on my |
| 53 | behalf" setting with matching server records and exact text hashes), |
| 54 | never by the controller, the parent or an implementer. Pending copy keeps blocking release, which is correct. |
| 55 | No em dashes, no exclamation marks. |
| 56 | - **Round limit.** Astra reviews this plan, the risky tasks (3, 4, 7, 8, |
| 57 | 9, 10, 11, 12, 15) and the whole branch, **at most three rounds each**. |
| 58 | After round 3 the controller fixes what is clearly right, records what |
| 59 | stays open, and asks the parent. There is never a fourth round. |
| 60 | - **Never** merge, deploy, enrol, change Studio state, sign in to a |
| 61 | provider, or run a live model turn. The shipped probe turn (task 14) |
| 62 | runs only on the Studio, after a deploy someone else does. |
| 63 | |
| 64 | ## 1. What exists and what is missing |
| 65 | |
| 66 | Built (slices A to E, `RUNNERS-PROGRESS.md`, `DARWIN-PROGRESS.md`): |
| 67 | per-runner mailbox, roles, protocol negotiation, capability report, |
| 68 | placement with start authorization and withdrawal, the Engineering pin |
| 69 | column, transfers and blob relay, the primary's `publish`/`published` |
| 70 | path (`thin/relay.go: publishWorker`), the darwin runner build, the srt |
| 71 | checks profile, the process-group gate (`mac.Gate`, `mac.Turns`), probes |
| 72 | P1 to P7, the launchd agent, the installer, self-update, the taint, and |
| 73 | the user-temp cleanup (`simctl shutdown all`, then sweep). |
| 74 | |
| 75 | Missing, with the task that adds it: |
| 76 | |
| 77 | | Gap | Task | |
| 78 | |---|---| |
| 79 | | The worker refuses every step but Checks (`thin/worker.go`) | 12 | |
| 80 | | Placement never sends Engineering to a worker; `mac-placement-wait` parks it | 3 | |
| 81 | | No base resolution for a worker's first step or rebase round (the primary picks it inside `Engineer.Exec`) | 3, 4 | |
| 82 | | No darwin Claude Code pin; Mac discovery runs an unpinned `claude` | 5 | |
| 83 | | No darwin launch policy (Linux Engineering is a bubblewrap-certified launch) | 8 | |
| 84 | | No MCP tool endpoint on a Mac | 6 | |
| 85 | | `/workspace` hard-coded in answers, transcripts (`projects/-workspace`) and prompts | 7 | |
| 86 | | Restart proof can pass with the recorded group alive (`mac/gate.go` `!ours`) | 9 | |
| 87 | | Token check and sign-in need Linux containment (`tokencheck.go`, `signin.go`) | 10 | |
| 88 | | No home guard; P4's `Exposed` tests only as the current user | 10 | |
| 89 | | A worker has no connections, seal key or `Conns`; Cancel and Sign out target the primary by local ID | 11 | |
| 90 | | `TransferHeader` has one commit; no shallow handling; no pack inventory check | 2, 4, 12 | |
| 91 | | Change diffs are accepted only from the step's runner while running | 2, 4 | |
| 92 | | Worker outcomes (unfinished, no-shell) survive only for primary Engineering | 4 | |
| 93 | | `AskCommand` lacks the Engineering attempt, account and session binding | 13 | |
| 94 | | No probes of Claude's own sandbox on a Mac; P2 never tries the token | 14 | |
| 95 | | D1 and D2 not enforced anywhere | 10, 15 | |
| 96 | | No M9 scenario | 16 | |
| 97 | |
| 98 | ## 2. Task order |
| 99 | |
| 100 | | # | Task | Risk | Per-task Astra | |
| 101 | |---|---|---|---| |
| 102 | | 0 | Base: merge `mac-placement-wait`, allocate numbers | low | no | |
| 103 | | 1 | Read-only probes, static reads, the Studio's verdicts | low | no | |
| 104 | | 2 | Wire, protocol 36, migration, fixtures | medium | no | |
| 105 | | 3 | Instance: placement, base preparation, pinning, waits, switch | high | yes | |
| 106 | | 4 | Primary: prepare base, packs, publication-bound diffs, worker outcomes | high | yes | |
| 107 | | 5 | Darwin Claude Code pin and provisioning | medium | no | |
| 108 | | 6 | Darwin MCP tool endpoint | medium | no | |
| 109 | | 7 | Native permission port and workspace paths | high | yes | |
| 110 | | 8 | Darwin Engineering policy and settings | high | yes | |
| 111 | | 9 | Darwin executor, termination, machine lock, cleanup | high | yes | |
| 112 | | 10 | Darwin credential operations, home guard, taint gate | high | yes | |
| 113 | | 11 | Worker connections, lifecycle routed by runner | high | yes | |
| 114 | | 12 | Worker Engineering `Exec`, object scan, outbound pack | high | yes | |
| 115 | | 13 | Ask the implementer, pinned exactly | medium | no | |
| 116 | | 14 | Shipped probes F1 to F7, P2 token sources, Engineering status | medium | no | |
| 117 | | 15 | D1 across every connection state, views, copy | high | yes | |
| 118 | | 16 | M9 and mixed versions on Linux CI | medium | no | |
| 119 | | 17 | Release, docs, `make ci`, whole-branch review | medium | yes | |
| 120 | | 18 | Live witness on production (after someone else deploys) | n/a | no | |
| 121 | |
| 122 | Dependencies: 2 before everything else that touches the wire. 3 and 4 |
| 123 | together (the base exchange spans both). 5, 6 and 7 are independent and |
| 124 | may run in parallel worktrees. 8 needs 5 to 7. 9 needs 8. 10 needs 5, 8 |
| 125 | and 9. 11 needs 2 and 10. 12 needs 4 and 8 to 11. 13 needs 7 and 12. |
| 126 | 14 needs 9, 10 and 12. 15 needs 3, 11 and 14. |
| 127 | |
| 128 | --- |
| 129 | |
| 130 | ## Task 0. Base |
| 131 | |
| 132 | 1. `git merge origin/mac-placement-wait` into `mac-slice-f`, or rebase |
| 133 | onto main if it has merged by then. Run its tests: |
| 134 | `go test ./internal/thintest/ -run 'MacWait|Macrecheck|Placement' -count=1` |
| 135 | and `go test ./internal/equipo/ -run TestMacWait -count=1`. |
| 136 | 2. Ask the parent for the protocol number (expected 36) and the next |
| 137 | free migration number. Write both at the top of the progress file. |
| 138 | 3. Create `MAC-SLICE-F-PROGRESS.md` in the layout of `DARWIN-PROGRESS.md` |
| 139 | (Done, Decisions, Only the Mac can show, Open issues, Copy), with D1 |
| 140 | and D2 from spec §8.7 listed as open until Paul rules. |
| 141 | |
| 142 | ## Task 1. Read-only probes, static reads, the Studio's verdicts |
| 143 | |
| 144 | Before any Darwin code, as slice C did. Nothing on the Studio changes. |
| 145 | SSH as `paulca` only (`ssh -o BatchMode=yes tito-studio`, with the |
| 146 | sandbox off, since `~/.ssh` is read-denied inside it). No `sudo`. Never |
| 147 | read `paulequipo`'s files: its home can be listed, but its contents are |
| 148 | not ours. Scratch on docs-t1 goes in a `mktemp -d` under `$TMPDIR`, |
| 149 | removed at the end of the task. |
| 150 | |
| 151 | **On the Studio as paulca** (record output in the progress file, dated): |
| 152 | |
| 153 | - R1 `sw_vers`, `xcodebuild -version`, `xcode-select -p`, |
| 154 | `xcrun simctl list -j runtimes`, `swift --version`, |
| 155 | `sysctl hw.ncpu hw.memsize`, `uptime`. Seen 2026-11-28: macOS 27.2, |
| 156 | Xcode 27.2 (27B52), iOS 27.0 and 27.2 runtimes, M5 Ultra, 36 cores, |
| 157 | 96 GB, load about 1.7, several other users' Claude sessions running. |
| 158 | - R2 `ls -led /Users/*` (the ACL picture; seen: `paulequipo`'s home is |
| 159 | `drwxr-x---` group `staff`, no ACL shutting out other users), |
| 160 | `id paulequipo`, and `ps -axo user,pid,etime,command | grep |
| 161 | equipo-runner`. |
| 162 | - R3 `sandbox-exec -p '(version 1)(allow default)' /usr/bin/true`, then |
| 163 | the same with a nested `sandbox-exec` inside it. Record whether macOS |
| 164 | 27.2 lets a Seatbelt profile be applied inside another. This is |
| 165 | background only: the design does not nest. |
| 166 | - R4 `ps -E -p <own pid>` and a `sysctl kern.procargs2` read of a |
| 167 | same-user process, from a plain shell and from inside a hand-written |
| 168 | profile `(deny default)(allow process-exec)(allow file-read*)`. This |
| 169 | shows what `process-info*` governs on 27.2. F3 is the proof. |
| 170 | |
| 171 | **The Studio's current verdicts.** Ask the parent for the production |
| 172 | Machines page line for Tito Studio: protocol, P1 to P7 verdicts, tainted |
| 173 | or not. If P2 is not `denied`, write it in the progress file as a |
| 174 | witness blocker (spec §8.7, D1) and go on. Slice F does not include |
| 175 | repairing P2. If the parent has a fix branch for P2, note its name. |
| 176 | |
| 177 | **On docs-t1, static reads of the pinned CLI.** Fetch the official Claude |
| 178 | Code 2.1.312 release manifest and the `darwin-arm64` binary (about |
| 179 | 200 MB, within the "ask before a few GB" rule) into the scratch dir. |
| 180 | Check the binary against the manifest digest, then read it with `rg -a` |
| 181 | and `strings`, without running it. Record what each finding matched: |
| 182 | |
| 183 | - S1 the darwin-arm64 digest and the manifest URL. This becomes |
| 184 | `claude.ExecutableSHA256DarwinArm64`. |
| 185 | - S2 the sandbox settings keys the build reads: `sandbox.filesystem. |
| 186 | {allowWrite, allowRead, denyRead, denyWrite}`, `sandbox.network. |
| 187 | {allowedDomains, allowUnixSockets, allowLocalBinding, allowMachLookup}`, |
| 188 | `failIfUnavailable`, `allowUnsandboxedCommands`, `excludedCommands`, |
| 189 | `enableWeakerNestedSandbox`; what an empty `allowedDomains` means (no |
| 190 | network, or ask). A key the design needs that is absent is a stop: |
| 191 | write it up and ask the parent. |
| 192 | - S3 the version of `@anthropic-ai/sandbox-runtime` the build embeds, |
| 193 | and, from that tag's source (`macos-sandbox-utils.ts`), what its |
| 194 | generated profile allows by default: `process-info*`, `mach-lookup` |
| 195 | (including `securityd`), the breadth of `file-read*`, `sysctl-read`. |
| 196 | - S4 whether the build reads the OAuth token from a file descriptor |
| 197 | (a `*_FILE_DESCRIPTOR` variable beside `CLAUDE_CODE_OAUTH_TOKEN`), and |
| 198 | whether a set `CLAUDE_CODE_OAUTH_TOKEN` skips every Keychain read and |
| 199 | write (`security`, `Claude Code-credentials`). |
| 200 | - S5 how the Bash tool starts its shell on darwin (`detached`, `setsid`, |
| 201 | a new process group), and what `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` |
| 202 | removes. Task 9 depends on `EQUIPO_ATTEMPT` surviving. |
| 203 | - S6 how the build names a project's transcript directory from its cwd |
| 204 | (the rule that gives `projects/-workspace` on Linux), so task 7 can |
| 205 | compute it for a real Mac path. |
| 206 | |
| 207 | Delete the scratch dir. Done when R1 to R4, the verdicts and S1 to S6 |
| 208 | are in the progress file, and any stop has been raised. |
| 209 | |
| 210 | ## Task 2. Wire, protocol 36, migration, fixtures |
| 211 | |
| 212 | Files: `internal/wire/` (`runners.go`, `tasks.go`, `questions.go`, |
| 213 | `capabilities` validation, a new `mac_engineering.go`), the frames |
| 214 | testdata, the migration, `internal/equipo/chat/transfers.go` (storage |
| 215 | only). |
| 216 | |
| 217 | Changes: |
| 218 | |
| 219 | - `TransferHeader` stays a comparable struct. Add `Kind` (`""` for |
| 220 | checks, `engineering`) and `OldBaseSHA`. An Engineering transfer has |
| 221 | `BaseSHA` (the tree to start from), and for a rebase round also |
| 222 | `OldBaseSHA` and `CandidateSHA`. Add `func (h TransferHeader) |
| 223 | Commits() []string`, the bounded, de-duplicated list the pack must |
| 224 | yield, and `Valid()`, which checks each SHA and allows at most three. |
| 225 | Every existing `!=` comparison keeps working. |
| 226 | - Migration: `transfers.kind`, `transfers.old_base_sha`; |
| 227 | `chat_steps.xcode_access`, `chat_steps.outcome_phase` (committed, |
| 228 | unfinished or no-shell, kept apart from transfer progress), |
| 229 | `chat_steps.session_id` (the kept Engineering session); |
| 230 | `chat_questions.eng_attempt`, `eng_account`, `eng_session`, |
| 231 | `runner_id`, `base_sha`, `candidate_sha` (frozen when the question is |
| 232 | created, task 13). Additive only. |
| 233 | - New durable command `PrepareBaseCommand{task, step, attempt, repo, |
| 234 | rebase, from_base, candidate}` (instance to primary) and report |
| 235 | `BaseReport{task, step, attempt, base_sha, reason}` (primary to |
| 236 | instance). |
| 237 | - `DispatchCommand.XcodeAccess` (`sandboxed` or `""`). |
| 238 | - `StepReport.XcodeAccess` echoes what ran. `StepReport.SessionID` |
| 239 | names the kept session (protocol 36, from any runner; the primary |
| 240 | starts sending it too). `StepReport.OutcomePhase` carries the commit's |
| 241 | outcome separately from progress phases. |
| 242 | - `PublishCommand.OutcomePhase`, and `PublishedReport.ChangeFiles |
| 243 | *ChangeFiles`, `DiffCollection string` and `OutcomePhase`, so the |
| 244 | instance keeps the worker's outcome through publication (task 4). |
| 245 | - `ChangeDiffUpload` gains `Publication` (empty: today's path). |
| 246 | - `AskCommand` gains `EngAttempt`, `EngAccount`, `EngSession`. |
| 247 | - `Capabilities.Engineering *EngineeringStatus{state, reason}`: |
| 248 | `ready`, `no_connection`, `signed_out`, `limited`, `probes_pending`, |
| 249 | `probes_failed`, `cli_unpinned`, `home_open`, `tainted`, `busy` is not |
| 250 | a state (placement counts running steps). |
| 251 | - `ValidCapabilities` accepts probes F1 to F7, with `denied` and |
| 252 | `passed` allowed where each probe defines them. |
| 253 | - New reasons: `secret_in_candidate`, `workspace_too_large`, |
| 254 | `engineering_unavailable`, `base_unavailable`. New placements: |
| 255 | `waiting_mac_connection` (with the status reason), |
| 256 | `waiting_mac_update`, `waiting_base`. New Needs-you kinds: |
| 257 | `mac_connection`, `mac_update`. |
| 258 | - A worker's hello at 36 may carry `Connections` and `SealKey`. The |
| 259 | instance ignores both from a worker below 36. |
| 260 | |
| 261 | Tests first (`internal/wire`): `TestProtocol36Constants` (and update the |
| 262 | tests that pin 35); `TestEncodeDropsMacEngineeringBelow36` for every new |
| 263 | field and frame; `TestTransferHeaderCommits` (order, de-duplication, the |
| 264 | bound of three, invalid SHAs, kind rules); `TestValidCapabilitiesF`; |
| 265 | fixture round-trips for `frames/prepare-base.json`, `frames/base.json`, |
| 266 | `frames/dispatch-mac-engineering.json`, `frames/blob-engineering.json`, |
| 267 | `frames/published-change-files.json`, `frames/hello-worker-conns.json`, |
| 268 | `frames/ask-pinned.json`, `frames/step-mac-engineering.json`; a |
| 269 | migration test over a database holding open checks transfers and kept |
| 270 | questions. |
| 271 | |
| 272 | Mutations: drop a `< 36` clear in `Encode`; allow four commits; accept |
| 273 | `denied` for F4. Each must fail a named test. |
| 274 | |
| 275 | ## Task 3. Instance: placement, base preparation, pinning, waits, switch |
| 276 | |
| 277 | Files: `internal/equipo/chat/runners.go` (`place`, `macEngineering`, |
| 278 | `placeWaiting`), `macsandbox.go`, `transfers.go`, `tasks.go`, a new |
| 279 | `base_prepare.go`, the store's boot config, `internal/thintest/`. |
| 280 | |
| 281 | Behaviour: |
| 282 | |
| 283 | - `engineeringNeeds` adds `wire.TagClaude` for Mac work. |
| 284 | - Switch: `EQUIPO_MAC_ENGINEERING=1`, read at boot. Unset, Mac |
| 285 | Engineering waits exactly as `mac-placement-wait` left it. |
| 286 | - Switch on. The candidate runners are, in order, the pinned worker |
| 287 | (enrolled, not removing), then the §1.4 order among workers covering |
| 288 | the needs. Both the worker and the primary must speak ≥ 36; otherwise |
| 289 | wait `waiting_mac_update`, with Needs you naming which one. If a Mac |
| 290 | covers everything but `claude`, wait `waiting_mac_connection` carrying |
| 291 | the worker's `EngineeringStatus` reason. Never place on a different |
| 292 | worker just because the pinned one lost its tag; wait for it. |
| 293 | - **Base preparation**, two phases in separate transactions: |
| 294 | 1. If the attempt has no bound base (a first step, or a rebase round |
| 295 | whose new tip is unknown), write `prepare_base` to the primary's |
| 296 | mailbox. The step waits `waiting_base`. |
| 297 | 2. On the primary's `base` report for the current attempt, from the |
| 298 | primary's connection, not withdrawn: bind `base_sha` to the |
| 299 | attempt, then place, dispatch and open the inbound Engineering |
| 300 | transfer in one transaction. Any other report is refused and |
| 301 | logged. `base{reason: base_unavailable}` ends the attempt failed |
| 302 | with that reason and Needs you `retry`. |
| 303 | A fix round's base is the task branch's published tip, which is |
| 304 | already known, so it skips phase 1. A Retry rebinds nothing that was |
| 305 | bound to an earlier attempt. |
| 306 | - `XcodeAccess: sandboxed` is sent only when the instance holds the |
| 307 | worker sandbox-proven (`sandboxProven`) and its probe report has F5 |
| 308 | `denied`. A tainted Mac never gets it. |
| 309 | - A removed pinned worker follows the existing removal path (quarantine, |
| 310 | then Recover). After Recover the next Engineering step re-pins to a |
| 311 | fitting Mac or waits `waiting_mac`. It is never placed on the Linux |
| 312 | primary. The protocol 1 primary exception from `mac-placement-wait` |
| 313 | stays. |
| 314 | - Review of a Mac-made candidate is placed on the primary after |
| 315 | publication. Ready to merge never auto-merges a Mac-made candidate, |
| 316 | because a worker cannot run certified base gates (injection defences). |
| 317 | |
| 318 | Tests first, as contracts in `internal/thintest/mac_engineering_contract_test.go`, |
| 319 | with a primary and a fake worker both at 36 unless stated: |
| 320 | |
| 321 | 1. `TestContractMacEngineeringPlacedOnWorker`: prepare-base first, then |
| 322 | the dispatch with its transfer (`kind engineering`, base only) in one |
| 323 | transaction, and the pin set. |
| 324 | 2. `TestContractMacEngineeringSwitchOff`. |
| 325 | 3. `TestContractMacEngineeringStatusWaits`: one case per |
| 326 | `EngineeringStatus` reason. Each is its own wait and Needs-you line, |
| 327 | and `placeWaiting` places once the status is `ready`. |
| 328 | 4. `TestContractMacEngineeringOldWorker` and `...OldPrimary`: both wait |
| 329 | `waiting_mac_update`; neither receives a field or frame from protocol |
| 330 | 36. |
| 331 | 5. `TestContractMacEngineeringOffline`: `waiting_runner`, then Needs you |
| 332 | `runner_offline` after 30 minutes, Cancel works, and it never moves to |
| 333 | Linux. |
| 334 | 6. `TestContractMacEngineeringPinHolds`: a fix round, a Retry, a |
| 335 | republish and a rebase round all go to the pinned worker even with a |
| 336 | second fitting worker. The rebase transfer carries base, old base and |
| 337 | candidate. |
| 338 | 7. `TestContractMacEngineeringPinnedLostTag`: the pinned worker drops |
| 339 | `claude` mid-task. The next round waits for it; it is never placed on |
| 340 | the second worker. |
| 341 | 8. `TestContractMacEngineeringPinnedRemoved`. |
| 342 | 9. `TestContractPrepareBase`: a report from the worker, for an older |
| 343 | attempt, after withdrawal, or after Cancel is refused; a second report |
| 344 | for the same attempt is a no-op; `base_unavailable` ends it with Retry. |
| 345 | 10. `TestContractMacEngineeringXcodeAccess`. |
| 346 | 11. `TestContractWorkerEngineeringReports`: a worker's `pushed: true` is |
| 347 | refused; `committed` opens the outbound transfer for exactly that |
| 348 | candidate; `done` waits for the primary's `published` (extending |
| 349 | `TestContractPublishedBeforeWorkerDone`). |
| 350 | 12. `TestContractReviewStaysOnPrimary` and |
| 351 | `TestContractMacMadeNeverAutoMerges`. |
| 352 | |
| 353 | Mutations: place on the primary when the pin is removed; omit `claude`; |
| 354 | place with an old primary; send `xcode_access` without F5; open the |
| 355 | transfer before the base is bound; accept a base report from the |
| 356 | worker. Each must fail a named contract. |
| 357 | |
| 358 | ## Task 4. Primary: prepare base, packs, publication-bound diffs, worker outcomes |
| 359 | |
| 360 | Files: `internal/runner/thin/relay.go` (`packCandidate`, |
| 361 | `publishWorker`, a new `prepareBase`), `change_files.go`, |
| 362 | `change_diffs.go`, `link.go` (the new command), and on the instance |
| 363 | `internal/equipo/chat/change_diffs.go`, `transfers.go`, `tasks.go` |
| 364 | (`unfinishedReport` and the no-shell handling). |
| 365 | |
| 366 | Runner (primary): |
| 367 | |
| 368 | - `prepareBase`: fetch, then resolve the default tip exactly as |
| 369 | `Engineer.Exec` does today (`defaultTip`, including the unborn case, |
| 370 | which is refused for a worker as `base_unavailable`). Report `base`. |
| 371 | Durable and idempotent: a restart re-reports the same SHA for the same |
| 372 | attempt. |
| 373 | - `packCommits(header)`: with no kind, today's one-commit pack. For an |
| 374 | Engineering header, `rev-list --objects --no-walk` of exactly |
| 375 | `header.Commits()` into `pack-objects`. Refuse a commit missing from |
| 376 | the clone, a non-SHA or a repository that is not `ValidHub` before git |
| 377 | runs. |
| 378 | - `publishWorker` after a successful push (at 36): compute change files |
| 379 | for base to candidate, queue change-diff uploads bound to the |
| 380 | publication (leaving out the primary's known secrets, as today), and |
| 381 | report `published` with `ChangeFiles`, `DiffCollection` and the |
| 382 | `OutcomePhase` the instance put in the `publish` command. Failure to compute diffs is a diagnostic, |
| 383 | never a push failure. |
| 384 | |
| 385 | Instance: |
| 386 | |
| 387 | - Accept change-diff uploads that name a publication only from that |
| 388 | publication's primary connection, for the worker's task, step and |
| 389 | attempt, while the publication is `pending` or `published`, in either |
| 390 | order relative to the worker's `done`. Change both acceptance paths: |
| 391 | `changeDiff` (today it needs the step's runner and `running`) and |
| 392 | `acceptChangeDiffs` (today the uploader must equal the step's runner). |
| 393 | Refuse stale publications, another primary and a wrong attempt. |
| 394 | - The worker's `done` never touches `ChangeFiles` or the diff |
| 395 | collection on a worker step; only `published` sets them. A `done` |
| 396 | arriving after `published` must not clear them. |
| 397 | - Keep the worker's outcome. A worker's `committed` report records |
| 398 | `outcome_phase`. The instance copies it into `publish`, the primary |
| 399 | echoes it in `published`, and only then does the step take |
| 400 | `step_timeout` (unfinished) or the no-shell reason, with `Pushed` set |
| 401 | by the primary. Republish keeps it. Two places rebuild `Pushed=true` |
| 402 | from an unfinished outcome today, and both must not do so for a |
| 403 | worker: the instance's `unfinishedReport` (`chat/tasks.go`) and the |
| 404 | runner's (`thin/step.go`). |
| 405 | |
| 406 | Tests first: |
| 407 | |
| 408 | - `TestPrepareBaseResolvesAndIsIdempotent`, `TestPrepareBaseRefusesUnborn` |
| 409 | (thin). |
| 410 | - `TestPackCommitsInventory` (thin): index the pack into an empty |
| 411 | repository, then list the commit objects **in the pack itself** |
| 412 | (`verify-pack -v`, or `show-index` plus `cat-file --batch-check`). |
| 413 | Exactly the named commits, each with a complete tree, and no other |
| 414 | commit. |
| 415 | - `TestPackCommitsRefuses` (thin). |
| 416 | - `TestPublishWorkerChangeFilesAndDiffs` (thin): files and diffs bound to |
| 417 | the publication; the bearer token never in a diff. |
| 418 | - Instance contracts: `TestContractPublicationDiffs` (both orderings of |
| 419 | worker `done` and the primary's uploads, a restart between, a stale |
| 420 | publication, a wrong primary, a wrong attempt); |
| 421 | `TestContractWorkerUnfinishedThroughPublication` (timeout, no-shell |
| 422 | fix round, failed publication then republish: the phase survives and |
| 423 | `Pushed` comes only from `published`); |
| 424 | `TestContractPublishedFilesSurviveDone` (files and diffs visible on the |
| 425 | task in both orderings of `done` and `published`, and after a |
| 426 | restart); `TestWorkerUnfinishedReportNeverPushed` (thin, the runner's |
| 427 | `unfinishedReport`). |
| 428 | - `TestPackOversizeIsWorkspaceTooLarge`: declared oversize ends the step |
| 429 | `workspace_too_large` with Needs you. |
| 430 | |
| 431 | Mutations: walk history (drop `--no-walk`); accept diffs from the |
| 432 | worker; set `Pushed` from the worker's unfinished report; queue diffs |
| 433 | before the push. Each must fail a named test. |
| 434 | |
| 435 | ## Task 5. Darwin Claude Code pin and provisioning |
| 436 | |
| 437 | Files: `internal/runner/provider/claude/pins.go`, a new |
| 438 | `internal/runner/mac/claude.go`, `thin/mac.go` (`macTools`, |
| 439 | `newMacHost`), `mac/caps.go`. |
| 440 | |
| 441 | The worker runs only the 2.1.312 darwin-arm64 binary whose digest |
| 442 | (task 1, S1) is compiled in as `claude.ExecutableSHA256DarwinArm64`. It |
| 443 | provisions that binary itself, so Paul has no install step. It never |
| 444 | runs a `claude` from `PATH` or `EQUIPO_CLAUDE_PATH` again, not even for |
| 445 | `--version`. The capability report states the pinned version only after |
| 446 | verification. |
| 447 | |
| 448 | Tests first (`internal/runner/mac/claude_test.go`): |
| 449 | |
| 450 | - `TestClaudePinDarwin`: `ReleasePinFor("darwin", "arm64")` is the |
| 451 | constant; nothing else on darwin has a pin. |
| 452 | - `TestProvisionChecksDigestBeforeExec`: one changed byte is refused, |
| 453 | never made executable, and nothing is left behind. |
| 454 | - `TestProvisionBoundsAndPlace`: a 512 MB bound; written only under |
| 455 | `~/.local/lib/equipo-runner/tools/claude-2.1.312/` through an |
| 456 | `os.Root`, mode 0700, no symlink followed; a present file with the |
| 457 | wrong digest is replaced. |
| 458 | - `TestProvisionOnlyFromTheOfficialURL`: the URL comes from the version |
| 459 | and platform constants. A local file can stand in only under the |
| 460 | `testbuild` tag. |
| 461 | - `TestVerifyBeforeEveryLaunch`: the launcher re-hashes before each |
| 462 | launch; a swapped file stops it with `engineering_unavailable`. |
| 463 | - `TestDiscoveryNeverRunsUnpinnedClaude`: the capability probe runs no |
| 464 | binary but the verified pin. |
| 465 | |
| 466 | Env-gated (`EQUIPO_CLAUDE_DARWIN_BINARY=<path>`), run once on docs-t1 |
| 467 | with the task 1 download: the real binary matches the pin. |
| 468 | |
| 469 | Mutations: skip the digest; follow a symlink; run `PATH` `claude` in |
| 470 | discovery. Each must fail a named test. |
| 471 | |
| 472 | ## Task 6. Darwin MCP tool endpoint |
| 473 | |
| 474 | The Linux tool proxy stays byte-identical (do not touch |
| 475 | `internal/toolproxy`). The release check that it matches its certified |
| 476 | digest must stay green. On darwin, `equipo-runner tool-proxy --socket |
| 477 | <path>` speaks the same stdio MCP protocol to the CLI and the same |
| 478 | framing to the step socket. |
| 479 | |
| 480 | Files: `internal/runner/tool_proxy_serve_darwin.go` (now refuses), a |
| 481 | darwin-only command in `cmd/equipo-runner`, `thin/mcp.go` |
| 482 | (`openToolSet`), `thin/toolsocket_other.go`. |
| 483 | |
| 484 | Tests first: |
| 485 | |
| 486 | - `TestDarwinToolProxySpeaksTheProtocol`: shared code split as |
| 487 | `darwin || testbuild`, so it runs on Linux. The permission tool, |
| 488 | `submit_candidate`, `ask_person`, `submit_answer` and the answer |
| 489 | action's `git_*` tools round-trip with the same replies as the Linux |
| 490 | proxy; a transcript recorded from the Linux proxy tests is the oracle. |
| 491 | - `TestToolSocketPeerUID`: on darwin only the runner's own uid is |
| 492 | accepted (`LOCAL_PEERCRED`, `peer_darwin.go`), exercised through its |
| 493 | seam. |
| 494 | - `TestToolSocketPathFits`: the socket path stays under 104 bytes for a |
| 495 | long `/Users/<name>` home (use the scratch root's short `t/`). |
| 496 | - The certified Linux tool proxy check passes unchanged. |
| 497 | |
| 498 | Mutations: accept any peer uid; allow a permission the Linux proxy |
| 499 | denies. Each must fail a named test. |
| 500 | |
| 501 | ## Task 7. Native permission port and workspace paths |
| 502 | |
| 503 | Spec §4.4, "Native file permissions, ported explicitly", and the |
| 504 | transcript and prompt paths. Files: `provider/claude/answers.go`, |
| 505 | `thin/claude.go` (`transcriptPath`, `keepTranscript`, `copyPrivate` |
| 506 | callers), `thin/engineer.go` and `thin/ask.go` prompts. |
| 507 | |
| 508 | - The workspace root and the read-only research root become policy |
| 509 | fields. Linux keeps `/workspace` and `/research`, and its certified |
| 510 | policy hashes must not change: assert the Linux settings bytes are |
| 511 | identical before and after. |
| 512 | - Every requested path is resolved with `realpath` against the real root |
| 513 | and checked against the §4.2 list before answering. Read, Edit, Write, |
| 514 | Glob and Grep deny rules are generated for each §4.2 path. |
| 515 | `StepPermission` and `ReadPermission` share the port. "Nobody to ask" |
| 516 | stays the default. |
| 517 | - `transcriptPath(home, cwd, session)` computes the project directory |
| 518 | from the cwd with the CLI's rule (task 1, S6). Resuming a kept |
| 519 | transcript into a new attempt's worktree moves it into the new cwd's |
| 520 | project directory. Linux output is unchanged. |
| 521 | - Prompts name the workspace root from the policy, not `/workspace`. |
| 522 | |
| 523 | Tests first (`answers_test.go`, a new `answers_darwin_policy_test.go` |
| 524 | that runs on Linux with temp dirs standing in for Mac paths, |
| 525 | `claude_transcript_test.go`): |
| 526 | |
| 527 | - `TestPermissionLinuxUnchanged`: every existing answer test passes; |
| 528 | the Linux settings hash is unchanged. |
| 529 | - `TestPermissionRootIsResolved`: a symlinked alias of the root (the |
| 530 | stand-in for `/var` to `/private/var`) is allowed only when it lands |
| 531 | inside the real root. |
| 532 | - `TestPermissionRefusesEscapes`: `..`, a glob that expands outside the |
| 533 | root, an absolute outside path, an inside symlink pointing out. |
| 534 | - `TestPermissionDeniedPathsGenerated`: each §4.2 path appears as |
| 535 | `Tool(/<path>)` and `Tool(/<path>/**)` for all five tools. |
| 536 | - `TestTranscriptPathForRealCwd` and `TestResumeAcrossWorktrees`: keep in |
| 537 | worktree A, resume in worktree B, then again after a runner restart. |
| 538 | Linux paths stay `projects/-workspace`. |
| 539 | - `TestPromptsNameTheRoot`. |
| 540 | |
| 541 | The symlink swap after the check cannot be proven by a unit test. Live |
| 542 | proof is probe F6 (task 14), and Engineering stays unavailable until F6 |
| 543 | passes. |
| 544 | |
| 545 | Mutations: compare prefixes without resolving; drop the `..` check; |
| 546 | skip one deny path; hard-code `-workspace` on darwin. Each must fail a |
| 547 | named test. |
| 548 | |
| 549 | ## Task 8. Darwin Engineering policy and settings |
| 550 | |
| 551 | Files: a new `internal/runner/mac/engineering.go`, a darwin policy |
| 552 | beside `provider/claude/launcher.go` (`darwinPolicy`, `validateDarwin`), |
| 553 | and `mac/profile.go`, which shares the §4.2 list with checks. |
| 554 | |
| 555 | The darwin policy is its own certified shape, not `provider.BuildPolicy` |
| 556 | with bubblewrap fields faked. It records the pinned CLI digest, argv, |
| 557 | settings JSON, MCP JSON (the darwin tool endpoint), workspace root, |
| 558 | attempt scratch, denied paths, environment keys and `xcode_access`. |
| 559 | Before launch the launcher regenerates it from its inputs and requires |
| 560 | byte equality, as `validatePolicy` does. |
| 561 | |
| 562 | Settings per attempt (keys confirmed by task 1, S2): |
| 563 | |
| 564 | - `disableAllHooks: true`, plugins off, `autoMemoryEnabled: false`, |
| 565 | `--setting-sources ''`, `--strict-mcp-config`, |
| 566 | `--disable-slash-commands`, `--permission-mode manual`, |
| 567 | `--permission-prompt-tool mcp__equipo__permission`, tools |
| 568 | `Bash,Read,Write,Edit,Glob,Grep` (as Linux Engineering). |
| 569 | - `sandbox.enabled: true`, `failIfUnavailable: true`, |
| 570 | `allowUnsandboxedCommands: false`, `excludedCommands: []`, |
| 571 | `autoAllowBashIfSandboxed: true`. |
| 572 | - `filesystem.allowWrite`: the worktree and the attempt scratch. With |
| 573 | `xcode_access: sandboxed`, also the attempt's DerivedData under |
| 574 | scratch, the runner user's `DARWIN_USER_TEMP_DIR` (resolved as the |
| 575 | checks profile does, `mac/usertemp.go`), |
| 576 | `~/Library/Developer/Xcode/DerivedData` and the SwiftPM caches. |
| 577 | `denyRead` and `denyWrite`: the §4.2 list, plus the connection's |
| 578 | dedicated home and its runtime copy. |
| 579 | - `network.allowedDomains: []`. If S2 shows that empty means "ask", the |
| 580 | permission tool answers deny, and F1 proves no connection is made. |
| 581 | `allowUnixSockets: []`, `allowLocalBinding: false`, and |
| 582 | `allowMachLookup` set to the P2-recorded list (`mac.CheckMachServices`, |
| 583 | narrowed by P2) only with sandboxed Xcode access, else `[]`. An empty |
| 584 | list is not proof of no Mach access (S3 lists the runtime's defaults); |
| 585 | F7 is the proof. |
| 586 | - `permissions.deny`: task 7's generated rules. `ask`: the native tools |
| 587 | on the workspace root. |
| 588 | - Environment from scratch: `HOME` the runner user's home (Xcode needs |
| 589 | it), `CLAUDE_CONFIG_DIR` the runtime copy, |
| 590 | `CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1`, `DISABLE_AUTOUPDATER=1`, |
| 591 | `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`, `TMPDIR` the attempt |
| 592 | scratch, `DEVELOPER_DIR` from `xcode-select -p`, a fixed `PATH`, |
| 593 | `LANG`, `EQUIPO_ATTEMPT=<marker>`. The token goes by descriptor if S4 |
| 594 | found one, otherwise in `CLAUDE_CODE_OAUTH_TOKEN`. Either way F3 must |
| 595 | prove the sandboxed shell cannot read it. |
| 596 | - A read-only variant for asks: `denyWrite` includes the worktree, and |
| 597 | the tools are `Read,Glob,Grep`. |
| 598 | |
| 599 | Tests first (`internal/runner/mac/engineering_test.go`): |
| 600 | `TestEngineeringSettingsExact` (golden JSON for both Xcode modes and the |
| 601 | read-only variant); `TestEngineeringSettingsRefuses` (a worktree inside |
| 602 | a denied place, relative paths, globs, scratch inside the worktree, a |
| 603 | token home inside the worktree); `TestEngineeringNoMachWithoutAccess`; |
| 604 | `TestEngineeringPolicyValidatedBeforeLaunch` (one byte of settings, a |
| 605 | different argv, an extra environment key: no launch); |
| 606 | `TestEngineeringEnvFromScratch`; `TestEngineeringTokenNotInArgvOrPolicy` |
| 607 | (the token is never in argv, the stored policy, the step log or a |
| 608 | report). |
| 609 | |
| 610 | Mutations: allow network; drop the accounts root from `denyRead`; grant |
| 611 | Mach lookups without access; inherit the environment. Each must fail a |
| 612 | named test. |
| 613 | |
| 614 | ## Task 9. Darwin executor, termination, machine lock, cleanup |
| 615 | |
| 616 | Spec §5. Files: `internal/runner/mac/gate.go` (pull the process-group |
| 617 | executor out so the gate and Engineering share it), a new |
| 618 | `internal/runner/mac/launch.go` implementing `thin`'s `starter` for a |
| 619 | Mac, `mac/usertemp.go` (`Turns`), `thin/step.go` (`recordedStart`), |
| 620 | `thin/state.go` (recovery). |
| 621 | |
| 622 | - **Record order.** Write the marker to the step row before the process |
| 623 | starts; nothing starts if that write fails. Write the actual group id |
| 624 | once the process exists; if that write fails, kill the group and stop. |
| 625 | - **Stop.** Close stdin and wait for a graceful end (as `stopStep`), |
| 626 | then `SIGTERM` to the group, 10 s, `SIGKILL`, then the marked sweep |
| 627 | (`ps -E`). Then the user-temp cleanup protocol as it is today: |
| 628 | `simctl shutdown all` (the mac-user-temp ruling; all simulators of the |
| 629 | runner user are its own), then the sweep of what the attempt created. |
| 630 | - **Proof.** Termination is proven only when `kill(-pgid, 0)` returns |
| 631 | `ESRCH` and no marked process is left, within 30 s. **Fix the restart |
| 632 | path** (`mac/gate.go`): today `gone := !ours || ...` passes when no |
| 633 | marked process is found, even if the recorded group is still alive. |
| 634 | New rule: if the recorded group is alive and holds no marked process, |
| 635 | it is either our child that scrubbed its environment or a reused |
| 636 | group id. Do not kill it, and do not prove termination. The step |
| 637 | stays unterminated (no Retry) until the group is gone. Keep today's |
| 638 | protection against killing a reused group. |
| 639 | - **One machine lock, per operation.** Every operation that runs |
| 640 | repository code, runs Xcode, or has a model token in a process takes |
| 641 | `mac.Turns` for that operation's life and no longer: a check, an |
| 642 | Engineering attempt, an ask, a probe run (P1 to P7, F1 to F7), a token |
| 643 | check, a sign-in pty, a token store. Descendants the operation itself |
| 644 | starts (Xcode under Engineering, the simulator under a check) belong |
| 645 | to it. Turns are serialized, so a stored connection never blocks |
| 646 | sandboxed checks and Engineering from taking turns one after another. |
| 647 | The temp-cleanup "pending" record is owned by the turn that wrote it; |
| 648 | only its owner or a restart may clear it. |
| 649 | - **The credential flag is separate from the lock.** The persistent |
| 650 | "this Mac has a model credential" flag (task 11, D1) lasts from a |
| 651 | connection's `connecting` until its files and any Keychain item are |
| 652 | proven gone. It only forbids unsandboxed turns; it does not hold |
| 653 | `Turns`. |
| 654 | - `termination_kind: process_group`. If task 1 (S5) shows the marker |
| 655 | does not survive the CLI's scrub, stop and raise it: the honest limit |
| 656 | in §5 would then cover every Bash command. |
| 657 | |
| 658 | Tests first (`internal/runner/mac/launch_test.go`, Linux-runnable with |
| 659 | the `/proc` sweep): `TestEngineeringLaunchRecordsMarkerThenGroup`; |
| 660 | `TestEngineeringTerminationGroupAndMarker` (a fake CLI forks a `setsid` |
| 661 | child that keeps the marker: the sweep ends it and the proof waits); |
| 662 | `TestRestartUnmarkedSurvivorWithholdsProof` (an unmarked process alive |
| 663 | in the recorded group: no kill, no proof); |
| 664 | `TestRestartReusedGroupNotKilled` (an unrelated group reusing the id: |
| 665 | not killed, no proof until it is gone); `TestRestartKillsMarked`; |
| 666 | `TestTurnsCoverEveryTokenOperation` (an Engineering turn, a token check |
| 667 | and a probe cannot overlap; checks wait while a sign-in pty is open); |
| 668 | `TestStoredConnectionAllowsSerialTurns` (with a connection stored, |
| 669 | Engineering then sandboxed checks then an ask run one after another); |
| 670 | `TestCleanupOwnedByItsTurn` (an interrupted cleanup is finished only by |
| 671 | its owner or a restart, never by another turn). |
| 672 | |
| 673 | Mutations: proof without the group check; record the group before the |
| 674 | marker; let a token check run outside `Turns`; let one turn clear |
| 675 | another's pending cleanup. Each must fail a named test. |
| 676 | |
| 677 | ## Task 10. Darwin credential operations, home guard, taint gate |
| 678 | |
| 679 | Files: `thin/tokencheck.go`, `thin/signin.go`, `thin/token.go`, a new |
| 680 | `mac/credentials.go`, a new `mac/homeguard.go`, and `thin/mac.go`. |
| 681 | |
| 682 | - **Darwin token check.** The same check as Linux (the CLI's own auth |
| 683 | status and usage read with the token), run through the darwin |
| 684 | launcher (tasks 8 and 9) with a check-only policy: no tools, no |
| 685 | workspace, no network for any shell. Same outcomes, cancellation and |
| 686 | crash recovery as Linux. No containment manager needed. |
| 687 | - **Darwin sign-in by link.** The pinned CLI's `setup-token` in a pty |
| 688 | under the darwin launcher, inside `Turns`, with the same prompt |
| 689 | framing, code delivery (sealed), timeout and recovery as |
| 690 | `thin/signin.go`. **Keychain.** Prevention first: launch with whatever |
| 691 | S4 showed keeps the CLI off the Keychain (the token in the |
| 692 | environment, `CLAUDE_CONFIG_DIR` set). Then detection: before and |
| 693 | after, list the login Keychain's generic-password items by attributes |
| 694 | only (`security dump-keychain` without `-d`, or `find-generic-password` |
| 695 | without `-w`) and diff the lists. An item that appeared during the |
| 696 | attempt is deleted only when it is positively the attempt's own: in |
| 697 | the runner user's login Keychain named by path, with the CLI's service |
| 698 | name (from S4) and an account the CLI derives for this connection's |
| 699 | config dir. Delete it by service, account and keychain path |
| 700 | (`security delete-generic-password -s <service> -a <account> |
| 701 | <keychain>`). The connection is refused, and the credential hold stays |
| 702 | set until a second listing shows the item gone. Any other new item, or |
| 703 | one whose ownership is ambiguous, is never deleted: the hold stays, |
| 704 | the connection is refused, and the Machines page names the item's |
| 705 | service for the person to remove. An item present before the attempt |
| 706 | is never touched; if one with the CLI's service name exists before the |
| 707 | first sign-in, the worker refuses to add a connection and says so. |
| 708 | The before-list is written durably before the pty starts, so a crash |
| 709 | or cancel is cleaned up on restart. |
| 710 | - **Home guard** (spec §8.3, item 1). Decide from ownership, mode bits |
| 711 | and ACLs alone; never test by opening files as ourselves (P4's |
| 712 | `Exposed` cannot see what another user sees). Pass only if all of |
| 713 | these hold: |
| 714 | - the home, state dir, config dir and accounts root are owned by the |
| 715 | runner user; |
| 716 | - none has group or other bits; |
| 717 | - none has an ACL entry granting anyone else any right at all (read, |
| 718 | list, search, readattr, readextattr, readsecurity, write, append, |
| 719 | add_file, add_subdirectory, delete, delete_child, writeattr, |
| 720 | writeextattr, writesecurity, chown), whether or not inherited; |
| 721 | - each lies inside the home; |
| 722 | - every ancestor from the home down to each root is a real directory |
| 723 | (no symlink) owned by the runner user, with no group or other write |
| 724 | bit and no such ACL grant, so nobody else can replace it. |
| 725 | Read the facts with `stat` and `ls -led` (recorded outputs), or the |
| 726 | ACL API through the seam. On failure, name what to change. |
| 727 | - **Taint gate** (D2 default). A runner tainted on the instance or in its |
| 728 | own state takes no model connection, and its `EngineeringStatus` says |
| 729 | `tainted`. |
| 730 | - The guard and the taint are checked when a connection is stored and |
| 731 | before every use, not only once. |
| 732 | |
| 733 | Tests first: `TestDarwinTokenCheck` (success, signed out, limited, |
| 734 | cancelled, a crash then recovery), `TestDarwinSignIn` (code delivered, |
| 735 | timeout, cancel, restart, a Keychain item created means refused, deleted |
| 736 | by its exact attributes and the flag held until a second listing shows it |
| 737 | gone, a pre-existing item untouched, a failed delete keeps the flag, an |
| 738 | unrelated item created at the same time left alone with the hold kept, |
| 739 | matching attributes in another keychain left alone), |
| 740 | `TestHomeGuard` (0700 passes; 0750; an ACL grant to `everyone`; an ACL |
| 741 | grant to one user; a write, `writesecurity` or `chown` ACL grant; an |
| 742 | inherited grant; a root outside the home; a symlinked ancestor; an |
| 743 | ancestor owned by another user; a mode changed between store and use), |
| 744 | `TestTaintBlocksConnections`. |
| 745 | |
| 746 | Mutations: accept group read; ignore ACL entries; skip the check before |
| 747 | use; let a tainted runner store a token. Each must fail a named test. |
| 748 | |
| 749 | ## Task 11. Worker connections, lifecycle routed by runner |
| 750 | |
| 751 | Files: `thin/run.go` (`runWorker`: `Conns`, the seal key, hello |
| 752 | connections), `thin/conns.go`, `thin/connector.go`; on the instance |
| 753 | `chat/connections.go`, `chat/runner.go` (hello processing), |
| 754 | `chat_connections.go`, `connections_view.go` and the templates. |
| 755 | |
| 756 | Runner side: a worker at 36 opens `Conns` over its own accounts root, |
| 757 | sends `Connections` and `SealKey` in hello, and accepts connect, cancel, |
| 758 | sign-out and preference commands addressed to its runner id. It accepts |
| 759 | only Claude token connections, by pasted token or by the darwin sign-in |
| 760 | (task 10). Codex, API key and endpoint kinds are refused with a stated |
| 761 | reason. |
| 762 | |
| 763 | Instance side: |
| 764 | |
| 765 | - Every connection operation is routed by the connection row's |
| 766 | `runner_id`: start, cancel, sign out, forget, preference delivery, |
| 767 | usage, refresh. Today Cancel and Sign out use `t.command` to the |
| 768 | primary (`chat/connections.go`), and the runner's `Connector.remove` |
| 769 | selects by local ID and person, so a worker connection with the same |
| 770 | local ID as one on the primary could remove the primary's. Fix both: |
| 771 | command to the row's runner, and match `(runner_id, local_id)`. |
| 772 | - Hello processing (`chat/runner.go`) stops treating connections as |
| 773 | primary-only. It upserts the connections of whichever runner sent the |
| 774 | hello, scoped to that runner. |
| 775 | - The Connections page groups rows by machine, the primary first. For a |
| 776 | Mac worker at 36 it offers "Add Claude to <Mac>". The card seals to |
| 777 | that runner's key. Needs you `mac_connection` links straight there. |
| 778 | - **D1 bookkeeping, a durable hold.** From the moment a connection on a |
| 779 | Mac enters `connecting`, the instance holds that Mac as "has a model |
| 780 | credential" (used by task 15). The hold is released only when the |
| 781 | runner reports the connection's files gone **and** no Keychain residue |
| 782 | (task 10), not on file deletion alone. The runner keeps the same hold |
| 783 | in its own state across restarts. |
| 784 | |
| 785 | Tests first: `TestContractWorkerConnectionLifecycle` (thintest: start, |
| 786 | cancel, sign out and preference on the worker never reach the primary; |
| 787 | two runners with the same local ID; a sealed token for one runner cannot |
| 788 | be accepted by the other); `TestWorkerHelloConnections` (thin: at 36 |
| 789 | yes, at 35 none); `TestWorkerTokenConnectionStored` (thin: 0600 file in |
| 790 | a 0700 home, refused when the home guard fails); |
| 791 | `TestWorkerRefusesOtherConnectionKinds`; |
| 792 | `TestConnectionsPageGroupsByMachine` (equipo); |
| 793 | `TestContractCredentialHeldFromConnecting` (held through a refused |
| 794 | connect that left a Keychain item, and across a restart, until both |
| 795 | are gone). |
| 796 | |
| 797 | Mutations: route Sign out to the primary; match by local ID only; show |
| 798 | the add button for a worker at 35; store the token 0644. Each must fail |
| 799 | a named test. |
| 800 | |
| 801 | ## Task 12. Worker Engineering `Exec`, object scan, outbound pack |
| 802 | |
| 803 | Files: `thin/worker.go`, split into `worker_checks.go` and |
| 804 | `worker_engineering.go` to stay under the size budget; `engineer.go` |
| 805 | (share `stepPrompt`, `fixPrompt`, `rebasePrompt`, `commitMessage`, |
| 806 | `splitHeadline`, `emptyStepReason`); `relay.go` (the worker's upload); |
| 807 | `state.go` (phases). |
| 808 | |
| 809 | One attempt on a worker: |
| 810 | |
| 811 | 1. Guards: specialist Engineering; owner; `ValidHub`; `ValidTaskBranch`; |
| 812 | protocol 36 spoken; a bound, non-empty base; `EngineeringStatus` |
| 813 | `ready`; `XcodeAccess` no stronger than its own trusted report |
| 814 | allows. Anything else ends `engineering_unavailable` or |
| 815 | `policy_rejected`, with nothing run. |
| 816 | 2. Take `Turns`. Record the marker. Lease (`AuthorizeStep`). |
| 817 | 3. Await the inbound pack. Compare the header with the step row (kind, |
| 818 | base, old base, candidate). Index it. Check the pack's own inventory |
| 819 | (task 4's method). Write the named commits to the store's `shallow` |
| 820 | file, merging with what is there, so later rev-list and log commands |
| 821 | stop at them. |
| 822 | 4. Prepare the tree under the scratch root from the worker store. A |
| 823 | rebase round uses `TaskTree.Rebase` (merge-tree with the explicit |
| 824 | merge base needs only the three commits). |
| 825 | 5. Pick a connection among the worker's own. Fail over among them on a |
| 826 | limit or a sign-in refusal, as `refused` does on the primary, from a |
| 827 | fresh tree each time. |
| 828 | 6. Run through the darwin launcher. Keep the session for fix rounds and |
| 829 | asks. Fix rounds resume the kept session (`fixSession`) through |
| 830 | task 7's transcript move. |
| 831 | 7. Commit with `tree.Commit` (Equipo Engineering identity, parent the |
| 832 | base). Apply the same rules for unfinished, no-shell and empty |
| 833 | results, and record the **outcome** (committed, unfinished, no-shell) |
| 834 | in its own durable field, never in the transfer progress phase. |
| 835 | Compute `Apple` from the changed files. **Retain the candidate:** |
| 836 | copy its new objects from the task tree's private repository into the |
| 837 | worker store (`git --git-dir=<tree git> pack-objects --revs --stdout` |
| 838 | with `^base` and the candidate on stdin, piped to |
| 839 | `git --git-dir=<store> index-pack --stdin`) and pin it with a ref |
| 840 | (`refs/equipo/<task>/<step>/<attempt>`) before anything else, so |
| 841 | upload, restart, republish and asks never depend on the attempt's |
| 842 | directory. The instance's `forgetTask` (today primary-only, |
| 843 | `chat/questions.go`) also sends `forget_task` to every worker that |
| 844 | holds the task's steps, and the worker honours its `KeepUntil`: the |
| 845 | ref and kept sessions go at once when there is none, or when it |
| 846 | passes. |
| 847 | 8. **Object scan, before anything leaves.** List the new objects |
| 848 | (`rev-list --objects ^base candidate`) and read each with `cat-file |
| 849 | --batch`: blobs (binary too; symlink targets are blobs), trees (file |
| 850 | names) and the commit (message and identity). Search for each known |
| 851 | secret of this worker (every connection's token, its runner |
| 852 | credential, the seal key's private half), raw, base64 (standard and |
| 853 | URL) and hex. Then run the pinned darwin gitleaks, offline, under srt |
| 854 | with no network, over the changed files with the trusted |
| 855 | configuration. Fail closed: a hit, a scanner error, an object over the |
| 856 | scan bound (the 64 MB pack bound), or a list that cannot be read ends |
| 857 | the step `secret_in_candidate`, and nothing is uploaded. Logs and |
| 858 | reports name only the object id and its kind, never a path (a file |
| 859 | name can be the secret) and never the matched bytes. Independently, |
| 860 | the summary, headline, log tail and every report string are passed |
| 861 | through the same known-secret redaction before they leave the worker. |
| 862 | 9. Record progress `committed` durably and report `committed` with the |
| 863 | candidate and its outcome. The instance opens the outbound transfer. Upload |
| 864 | the thin pack (`pack-objects --revs --thin --stdout` with |
| 865 | `^base candidate`) as blob frames. End `done`, `pushed: false`. |
| 866 | 10. A restart after `committed` resumes the upload and never launches |
| 867 | the CLI again for that attempt. |
| 868 | |
| 869 | Research hand-off: the quoted findings text arrives in the dispatch, as |
| 870 | on the primary. Kept images are not relayed, and the prompt says the |
| 871 | images stay on the main runner. Explore tasks run the same Engineering |
| 872 | step; their preview runs on the primary from the published candidate. |
| 873 | |
| 874 | Tests first (`internal/runner/thin/worker_engineering_test.go`, with the |
| 875 | fake CLI and the process-group executor without a sandbox, `testbuild` |
| 876 | only): |
| 877 | |
| 878 | - `TestWorkerEngineeringCommitsAndUploads`: to `done`, `pushed: false`; |
| 879 | the outbound pack indexes on the primary (`publishWorker`) to exactly |
| 880 | the candidate. |
| 881 | - `TestWorkerEngineeringRefusesGuards`: one case per guard. |
| 882 | - `TestWorkerStoreShallowBoundaries`: after two fix rounds and one |
| 883 | rebase into the same store, `git log` and `rev-list` in the store |
| 884 | succeed and stop at the boundaries; the thin pack builds. |
| 885 | - `TestWorkerEngineeringRebaseRound`, `TestWorkerEngineeringFixRoundResumes`. |
| 886 | - `TestWorkerObjectScan`: the fake CLI plants the token raw in a text |
| 887 | file, base64 in a binary file, in a file name, in a symlink target, in |
| 888 | the commit message (through its summary), and hex-encoded. Each is |
| 889 | refused with nothing uploaded, and neither the log nor the report |
| 890 | contains the token or the file name. Plus a gitleaks-detectable fake |
| 891 | key, a scanner that exits with an error, an object past the bound, and |
| 892 | the token in the CLI's summary text (redacted in the report). |
| 893 | - `TestWorkerCandidateRetained`: after the attempt dir is removed and the |
| 894 | runner restarts, the upload resumes, a republish works and an ask |
| 895 | reads the candidate from the store. |
| 896 | - `TestWorkerForgetTask`: a forget with no `KeepUntil` removes the ref |
| 897 | and sessions at once; one with a later `KeepUntil` keeps them until it |
| 898 | passes; `TestContractForgetReachesWorkers` (thintest) shows the |
| 899 | instance sends it to the worker as well as the primary. |
| 900 | - `TestWorkerEngineeringRestartAfterCommit`, `TestWorkerEngineeringFailover`. |
| 901 | - `TestWorkerChecksUnchanged`: every existing worker checks test passes. |
| 902 | |
| 903 | Mutations: skip the base64 form; scan only the diff; upload before the |
| 904 | scan; ignore a scanner error; reuse the refused attempt's tree; relaunch |
| 905 | after `committed`. Each must fail a named test. |
| 906 | |
| 907 | ## Task 13. Ask the implementer, pinned exactly |
| 908 | |
| 909 | Files: `internal/equipo/chat/questions*.go` (creation and dispatch), |
| 910 | `thin/ask.go`, the worker's kept-session store. |
| 911 | |
| 912 | - Every runner reports the kept session id in its Engineering step |
| 913 | report at 36 (`StepReport.SessionID`), and the instance stores it on |
| 914 | the step (`chat_steps.session_id`, task 2). |
| 915 | - When a question is created for an Engineering step, the instance |
| 916 | freezes on the question row the Engineering attempt, account, session |
| 917 | id, runner, base and candidate (task 2's columns) and sends them in |
| 918 | `AskCommand`. Dispatch (`nextQuestion`), cancel (`stopQuestion`), |
| 919 | replies (`ownQuestion`) and reconnect (`syncQuestions`) all read today's |
| 920 | mutable step; each must use the frozen runner and values instead. |
| 921 | - The worker keeps Engineering sessions per (step, attempt, account, |
| 922 | session id) under its state dir, with the primary's retention. An ask |
| 923 | resumes exactly the bound session on the runner that holds it, with |
| 924 | the read-only darwin settings (task 8) and `git_log`, `git_diff` and |
| 925 | `git_show` over its store (task 12's shallow boundaries keep them |
| 926 | working). A different runner, attempt, account or session is refused. |
| 927 | - An offline worker gets "Tito Studio is offline; ask again when it is |
| 928 | back" (exists; extend it to a Mac-made step). |
| 929 | |
| 930 | Tests first: `TestContractAskBindsTheSession` (thintest: a question |
| 931 | created after a newer attempt that produced the **same** candidate is |
| 932 | still bound to the attempt it was asked about, and a step that moved on |
| 933 | after the question was created does not change its runner, base or |
| 934 | candidate; the worker refuses the other); `TestWorkerAskAnswersFromKeptSession`; |
| 935 | `TestWorkerAskRefusesMismatch`; `TestWorkerAskCannotWrite`; |
| 936 | `TestContractAskMacOffline`; `TestContractQuestionLifecycleFrozen` |
| 937 | (cancel, a reply and a reconnect sync after the step moved to a new |
| 938 | attempt all address the frozen runner and attempt). |
| 939 | |
| 940 | Mutations: choose the newest kept session; allow Write in the ask |
| 941 | settings. Each must fail a named test. |
| 942 | |
| 943 | ## Task 14. Shipped probes F1 to F7, P2 token sources, Engineering status |
| 944 | |
| 945 | Files: `internal/runner/mac/probe.go`, a new `probe_engineering.go`, the |
| 946 | fixtures under `internal/runner/mac/fixtures/`, `thin/mac.go` |
| 947 | (`macProbes`), `thin/capabilities.go`. |
| 948 | |
| 949 | The probes ship in the binary and run on the Mac as the runner user, |
| 950 | inside `Turns`, as P1 to P7 do. They are reported in |
| 951 | `capabilities.probes` and trusted only for this runner version, this |
| 952 | settings profile, the verified pinned CLI, this Xcode version and its |
| 953 | simulator runtimes, for under a day. Any change to those inputs means |
| 954 | they run again. They need a Claude connection. They run as **three short |
| 955 | probe launches** on the connection's small model, each prompted to run |
| 956 | one fixed script with Bash: |
| 957 | |
| 958 | - launch A, under the no-Xcode Engineering settings: F1, F2, F3, F6, F7; |
| 959 | - launch B, under the sandboxed-Xcode settings, only when P2 is |
| 960 | `denied`: F5; |
| 961 | - launch C, under the no-Xcode settings, last: F4, which cancels the |
| 962 | launch. |
| 963 | |
| 964 | Each launch's results are stored with the inputs it ran under. The |
| 965 | status aggregates them only when every required result matches the |
| 966 | current inputs. The verdict never reads model text. As in P2, |
| 967 | every probe has a control that must succeed, a missing line is not a |
| 968 | denial, and outside observers decide: a loopback listener, nonce |
| 969 | sentinels, and the runner's own search of the probe tree. The probe |
| 970 | tree is never committed, uploaded or logged, and it is deleted after. |
| 971 | |
| 972 | - **F1 sandbox on, no network.** Control: a nonce written to the probe |
| 973 | tree must appear. A TCP connect to the runner's loopback listener, a |
| 974 | DNS lookup of a name the runner watches, and an HTTPS request through |
| 975 | the CLI's proxy must all fail, and the listener must see nothing. |
| 976 | - **F2 reads denied (shell).** Nonce sentinels in the runner state dir, |
| 977 | the accounts root, the connection's runtime copy, |
| 978 | `~/Library/Keychains`, another `/Users/*` home that P4 shows closed, |
| 979 | and `/Volumes`. No nonce may reach the probe tree. |
| 980 | - **F3 the token is out of reach.** From inside Bash, the script copies |
| 981 | what each source yields into the probe tree: `ps -E -p $PPID`, `ps -E` |
| 982 | of every own process, `sysctl kern.procargs2` of the CLI's pid, |
| 983 | `launchctl getenv CLAUDE_CODE_OAUTH_TOKEN`, `env`, and the token file |
| 984 | read by path. The runner then searches the tree for the token (raw, |
| 985 | base64, hex). Any hit fails F3. |
| 986 | - **F4 process group.** The script forks a `setsid` child that sleeps. |
| 987 | The runner cancels the turn; the marked sweep must end it, and the |
| 988 | proof must hold. |
| 989 | - **F5 Xcode under Claude's sandbox.** Runs only when P2 is `denied`. |
| 990 | The P2 hostile fixture (run-script phase, SwiftPM build tool plugin, |
| 991 | XCTest on the newest iPhone simulator), with F3's token sources added |
| 992 | to each hostile part, is built and tested by `xcodebuild` from the |
| 993 | Bash tool under the sandboxed-Xcode settings. Every sentinel read, |
| 994 | token source, connection and Keychain read must be denied, and the |
| 995 | build and test must complete (a failed build is not a denial). |
| 996 | - **F6 native tools.** Prompted tool calls (Read, Glob, Grep, Write) on |
| 997 | each denied path, through a symlink planted in the probe tree, and |
| 998 | through a symlink swapped by a background process between calls. All |
| 999 | must be refused, by the permission tool or the CLI, and no nonce may |
| 1000 | reach the probe tree. The swap race is retried 50 times. |
| 1001 | - **F7 no Xcode without access.** Under the no-Xcode settings, `xcodebuild |
| 1002 | -list`, `xcrun simctl list` and a Mach lookup of |
| 1003 | `com.apple.CoreSimulator.CoreSimulatorService` from Bash must all |
| 1004 | fail. Control: the same commands outside the sandbox succeed. |
| 1005 | - **P2 gains F3's token sources** in its run-script phase, plugin and |
| 1006 | XCTest, under the srt checks profile, so checks that run as the same |
| 1007 | user are proven not to reach the token either. P2 `denied` needs them |
| 1008 | denied. |
| 1009 | |
| 1010 | `EngineeringStatus` is `ready` when the pinned CLI is verified, F1 to |
| 1011 | F4, F6 and F7 passed for the current inputs, the home guard passes, the |
| 1012 | runner is not tainted, and at least one Claude connection is usable. |
| 1013 | Otherwise it names the first missing input. F5 decides only |
| 1014 | `xcode_access`. The `claude` tag goes with `ready`. The Machines page |
| 1015 | shows F1 to F7 beside P1 to P7. |
| 1016 | |
| 1017 | Tests first (`internal/runner/mac/probe_engineering_test.go`, recorded |
| 1018 | outputs and fakes): `TestProbeLaunchesAggregate` (a stale launch A |
| 1019 | with a fresh launch C is not ready), `TestF1RequiresControlAndListener`, |
| 1020 | `TestF2NoncesDecide`, `TestF3AnySourceFails`, `TestF4SweepProof`, |
| 1021 | `TestF5OnlyAfterP2AndNeedsTheBuild`, `TestF6SwapRace`, |
| 1022 | `TestF7NeedsTheOutsideControl`, `TestP2TriesTheToken`, |
| 1023 | `TestProbeInputsInvalidate` (a new Xcode build, a new runtime, a new CLI |
| 1024 | digest), `TestEngineeringStatusOrder`, |
| 1025 | `TestProbeTurnVerdictIgnoresModelText` (the fake CLI claims success in |
| 1026 | text while the sentinels say otherwise; the verdict follows the |
| 1027 | sentinels). |
| 1028 | |
| 1029 | Mutations: take a missing line as denied; ignore the listener; give |
| 1030 | `ready` without a connection; run F5 before P2; keep a verdict across an |
| 1031 | Xcode change. Each must fail a named test. |
| 1032 | |
| 1033 | ## Task 15. D1 across every connection state, views, copy |
| 1034 | |
| 1035 | **D1 default** (spec §8.7; Paul may overrule). While the instance holds a |
| 1036 | Mac as having a model credential (task 11, from `connecting` until the |
| 1037 | files and any Keychain item are proven gone), it does not offer "Run outside the sandbox" for checks |
| 1038 | on that Mac (`macsandbox.go`). The worker refuses an unsandboxed |
| 1039 | dispatch (`sandbox_unproven`) while its own durable credential hold |
| 1040 | (task 11) is set, which covers token files, connections in progress |
| 1041 | and Keychain residue. Put the rule in one predicate |
| 1042 | (`unsandboxedAllowed(runner)`) on each side, so if Paul rules otherwise |
| 1043 | the change is that predicate plus a warning string. An unsandboxed |
| 1044 | choice already recorded on a waiting attempt is withdrawn when a |
| 1045 | connection starts, and the creator is told. |
| 1046 | |
| 1047 | **Views.** The step line names the Mac when Engineering ran on a worker |
| 1048 | (house rule 2026-11-07.8: only when it is not the primary). Without |
| 1049 | Xcode access, the Engineering card says the Mac's checks build it. The |
| 1050 | new waits and Needs-you lines appear (`mac_connection` with its status |
| 1051 | reason, `mac_update`, `waiting_base`, `workspace_too_large`, |
| 1052 | `secret_in_candidate`). The Machines page shows F1 to F7, the home |
| 1053 | guard, the taint and whether Engineering can run there. |
| 1054 | |
| 1055 | **Copy** (drafts; Luna reviews all of it, and Paul sees the user-facing |
| 1056 | card lines). Mark each string pending with `scripts/copy-status.py |
| 1057 | pending` and list it in `2026-11-28-mac-slice-f-copy.json` in the |
| 1058 | copy-review skill's format, with key, where it shows, and draft. |
| 1059 | Starting drafts: |
| 1060 | |
| 1061 | - `work.needs.mac_connection`: "Needs you: %s needs Claude to make this |
| 1062 | change" |
| 1063 | - `work.decide.mac_connection_why`: "This change needs a Mac. %s is |
| 1064 | ready, but it has no Claude connection yet." |
| 1065 | - `work.decide.mac_connection_ask`: "Add Claude to %s and it starts by |
| 1066 | itself." |
| 1067 | - one line per other `EngineeringStatus` reason (signed out, limited, |
| 1068 | probes pending, probes failed, home open, tainted) |
| 1069 | - `chat.connections.add_to`: "Add Claude to %s" |
| 1070 | - `work.needs.mac_update`: "Needs you: %s needs an update to make |
| 1071 | changes" |
| 1072 | - `work.reason.base_unavailable`, `work.reason.workspace_too_large` |
| 1073 | ("the project is too large to send to the Mac"), |
| 1074 | `work.reason.secret_in_candidate` ("the change contained a secret, so |
| 1075 | it was not sent") |
| 1076 | - `work.step.made_on`: "Made on %s" |
| 1077 | - `work.step.no_xcode`: "Built and tested by the Mac's checks, not while |
| 1078 | making the change" |
| 1079 | - `runner.mac.home_open`: names what to change, for example "Other |
| 1080 | people on this Mac can open %s's home folder. Run chmod 700 ~ as %s, |
| 1081 | then try again." |
| 1082 | - `work.decide.unsandboxed_withdrawn`: why the outside-the-sandbox |
| 1083 | choice went away |
| 1084 | - the F1 to F7 probe names and verdict lines, following |
| 1085 | `runner.probe.P1` onwards |
| 1086 | - the `mac-placement-wait` strings slice F makes untrue |
| 1087 | (`work.needs.mac_engineering`, `work.decide.mac_engineering_why`), |
| 1088 | rewritten for the switch-off case |
| 1089 | |
| 1090 | Tests first: `TestUnsandboxedNotOfferedWithCredential` (thintest: from |
| 1091 | `connecting` through deletion, including a failed connect and a sign |
| 1092 | out), `TestWorkerRefusesUnsandboxedWithToken` (also with only |
| 1093 | Keychain residue left after a refused connect and a restart), |
| 1094 | `TestUnsandboxedChoiceWithdrawnOnConnect`, `TestMacEngineeringViews` |
| 1095 | (equipo: each line on the step, task, Needs you and Machines page). |
| 1096 | `make copy-release-check` keeps blocking release while copy is pending, |
| 1097 | which is correct. |
| 1098 | |
| 1099 | Mutations: offer the choice while `connecting`; let the worker run |
| 1100 | unsandboxed with a token file present. Each must fail a named test. |
| 1101 | |
| 1102 | ## Task 16. M9 and mixed versions on Linux CI |
| 1103 | |
| 1104 | Files: `internal/headless/mac_test.go` (extend `TestMacWorker`), |
| 1105 | `thin/fakeworker_testbuild.go`, `internal/fakeclaude`. |
| 1106 | |
| 1107 | The fake worker is the real thin runner under `testbuild` with |
| 1108 | `EQUIPO_FAKE_PLATFORM=darwin/arm64`, a fixture capability report with F1 |
| 1109 | to F7 passed and `EngineeringStatus ready`, the fake CLI, and the |
| 1110 | process-group executor without a sandbox. `scripts/no-fake-worker.sh` |
| 1111 | keeps it out of releases. |
| 1112 | |
| 1113 | Scenarios, within the headless budget: |
| 1114 | |
| 1115 | - **M9a** a Woodstar-shaped repository (an `.xcodeproj` with a shared |
| 1116 | scheme, and an `.equipo/gates.json` gate that needs Xcode). Prepare |
| 1117 | base, then Engineering on the worker. The inbound pack is relayed, the |
| 1118 | fake CLI edits a Swift file, the worker scans, commits and uploads a |
| 1119 | thin pack, and the primary pushes. Change files and diffs appear, |
| 1120 | checks run on the worker, review runs on the primary, and Ready to |
| 1121 | merge asks (no auto-merge). |
| 1122 | - **M9b** a fix round from the checks output stays on the worker and |
| 1123 | resumes its session in a new worktree. A push failure, then Retry, |
| 1124 | republishes the same commit without running Engineering. |
| 1125 | - **M9c** a rebase round on the worker. |
| 1126 | - **M9d** ask the implementer answered on the worker; refused for |
| 1127 | another attempt; the offline line when the worker is stopped. |
| 1128 | - **M9e** the worker is SIGKILLed mid-Engineering: process-group |
| 1129 | termination, Retry on the same worker, done. |
| 1130 | - **M9f** the switch is off: the step waits and nothing reaches the |
| 1131 | worker. |
| 1132 | - **M9g** mixed versions, with binaries built from `main` at the branch |
| 1133 | point (cached as M8 does): a protocol 35 worker with a 36 primary, and |
| 1134 | a 36 worker with a 35 primary, both wait `waiting_mac_update`. A 36 |
| 1135 | worker against an instance rolled back to 35 downgrades in its hello, |
| 1136 | queues no protocol 36 command, and loses nothing. |
| 1137 | - **M9h** a secret in the candidate: refused, nothing pushed. |
| 1138 | - **M9i** a timed-out step on the worker: unfinished through |
| 1139 | publication, never shown as finished work. |
| 1140 | - The `oficina/suite` scenario and every slice 1 to 4 and A to E |
| 1141 | scenario stay green, especially Linux termination before Retry. |
| 1142 | |
| 1143 | ## Task 17. Release, docs, `make ci`, whole-branch review |
| 1144 | |
| 1145 | - No new Mac artifact: the runner provisions the CLI (task 5), and the |
| 1146 | darwin gitleaks already ships. `make release-runner` and |
| 1147 | `scripts/staged-artifacts.py` stay green, and the Linux tool proxy |
| 1148 | digest is unchanged. |
| 1149 | - `docs/mac-runner.md` gains "Make changes on the Mac": the owner turns |
| 1150 | the switch on; the runner user fixes its home folder if the Machines |
| 1151 | page asks; the person adds Claude to the Mac and signs in. This is |
| 1152 | draft copy, so it goes in the copy JSON. |
| 1153 | - `make ci` once. Fix what it finds. Push. |
| 1154 | - Whole-branch Astra review (at most three rounds), then the controller |
| 1155 | report, and a handoff with task 18's runbook. |
| 1156 | |
| 1157 | ## Task 18. Live witness on production (not the controller's to start) |
| 1158 | |
| 1159 | Runs only after the parent has merged and deployed the release |
| 1160 | (`scripts/upgrade-thin.sh`, per AGENTS.md), the Studio has self-updated, |
| 1161 | Paul has ruled on D1 and D2, and the owner has set |
| 1162 | `EQUIPO_MAC_ENGINEERING=1`. The controller writes the runbook and the |
| 1163 | read-only checks, and runs none of the steps that change things. |
| 1164 | |
| 1165 | Prerequisite: the Studio's P2 is `denied` (task 1). Otherwise checks |
| 1166 | there wait under D1, and step 3 cannot reach Ready. |
| 1167 | |
| 1168 | 1. The Machines page shows the Studio at protocol 36, P1 to P7, the |
| 1169 | home guard and the taint. If the guard fails, Paul (or the runner |
| 1170 | user) makes the named change. That is his step. |
| 1171 | 2. Paul taps "Add Claude to Tito Studio" and signs in (his step). F1 to |
| 1172 | F7 run, the Machines page shows them, and `claude` appears in the |
| 1173 | Studio's tags. |
| 1174 | 3. The Woodstar swipe-back witness: a fresh "Fix the Woodstar iOS |
| 1175 | swipe-back bug" task, or a re-run of `tklkbx5vid3y` from `82a4a0cc`. |
| 1176 | The base is prepared by docs-t1. Engineering runs on Tito Studio with |
| 1177 | `xcode_access` as F5 decided. The candidate is relayed and pushed by |
| 1178 | docs-t1. Checks on the Studio record `xcodebuild test` (or |
| 1179 | Woodstar's gate), a real exit code and 200 lines. Review runs on |
| 1180 | docs-t1. Any fix round runs on the Studio. One ask to the implementer |
| 1181 | is answered from the Studio. Ready to merge asks Paul, and nothing |
| 1182 | auto-merges. |
| 1183 | 4. Read-only checks afterwards, as paulca: no marked processes left on |
| 1184 | the Studio (`ps`), the worker's step dirs swept, and the outbound |
| 1185 | transfer closed. |
| 1186 | |
| 1187 | Pass means every line of step 3 happened as written. A Woodstar build |
| 1188 | that fails for Woodstar's own reasons still passes if the failure is |
| 1189 | reported honestly. |
| 1190 | |
| 1191 | ## 3. Risks and honest limits |
| 1192 | |
| 1193 | - `sandbox-exec` is deprecated. `failIfUnavailable` turns its removal |
| 1194 | into `engineering_unavailable`, never a silent unsandboxed run. |
| 1195 | - The claude process itself runs outside any sandbox on the Mac, as the |
| 1196 | runner user, and talks to Anthropic (the trust Paul granted, §4.4). |
| 1197 | Its native file tools are confined by permission rules (task 7), and |
| 1198 | F6 proves them live. |
| 1199 | - Without F5 the Mac makes changes it cannot build while it makes them. |
| 1200 | Checks build them, so each fix round costs a round trip. That is |
| 1201 | slower, not unsafe. |
| 1202 | - SwiftPM packages need network to resolve, and Bash has none. A project |
| 1203 | whose packages are not already in the runner user's caches fails its |
| 1204 | build with `needs_network`, honestly. A package mirror is later work. |
| 1205 | - The CPU is shared: one turn at a time per Mac, so a long Engineering |
| 1206 | step delays that Mac's checks. |
| 1207 | - `have` lists and thin inbound packs remain open (a slice B note). |
| 1208 | Engineering inbound packs are whole packs of the named commits, so |
| 1209 | large repositories hit the 64 MB bound early. |
| 1210 | - D1 and D2 are Paul's. The defaults are the safe ones, and the witness |
| 1211 | waits for his rulings. |
| 1212 | |