oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1# Darwin progress: the Mac side of Mac runners (slice D, checks only)
2
3Branch `thin-v1-darwin` from `thin-v1-runners` at 1b89bd1 (slices A and
4B, Linux). Spec: `docs/superpowers/specs/2026-11-07-equipo-mac-runners.md`
5rev 4. First Mac: tito-studio, user `equipo-paul`. Nothing here has run
6on a Mac: everything is tested on Linux with recorded outputs, fakes for
7srt and xcodebuild, and the test build's fake worker. Conventions as in
8`RUNNERS-PROGRESS.md`.
9
10## Done
11
121. **The runner builds for darwin/arm64.** It did not: openat2, O_PATH,
13 pidfds, prctl, close_range, SO_PEERCRED, the Linux pty ioctls and
14 the boot-time clock. Each is behind a `_linux.go`/`_darwin.go` pair;
15 on macOS the bubblewrap-only calls refuse (ENOSYS). The containment
16 launcher reaches unix through `containment/sysunix`, so
17 `NamespaceMain`'s text and the certified launcher digest are
18 unchanged. `make build` (CI 05-build) cross-compiles the runner and
19 the tool proxy.
202. **`internal/runner/mac`**, the Darwin pieces:
21 - `ChecksSettings`: the §4.4 srt settings over the §4.2 deny list, in
22 srt 0.0.81's schema (read from its package: `network.allowedDomains`,
23 `deniedDomains`, `filesystem.denyRead`, `allowWrite`, `denyWrite`
24 required; `allowMachLookup` takes a trailing `*`). No network;
25 writes only to the tree, the attempt's scratch, DerivedData and
26 SwiftPM caches. Refuses globs, relative paths and a tree inside a
27 denied place (srt's denyWrite wins over allowWrite).
28 - `Gate`: process-group termination (§5): own session, marker,
29 environment from scratch, caffeinate `-w`, SIGTERM, 10 s, SIGKILL,
30 a sweep of marked processes (`ps -E` on a Mac, `/proc` on Linux),
31 `simctl shutdown` of what the attempt booted, proof only when the
32 group is gone and nothing marked is left within 30 s. After a
33 restart a reused group id is killed only if a marked process is
34 in it.
35 - Capabilities from `xcodebuild -version`, `simctl list -j`, swift,
36 node, srt, claude; the `xcodebuild test` gate for a project with no
37 gate (one shared scheme or the one named like it; newest iPhone
38 simulator by UDID; DerivedData in scratch; no signing; several
39 candidates or none is `checks_unavailable`).
40 - Probes P1 to P7 and the hostile fixture (run-script phase with
41 Xcode's own script sandbox off, SwiftPM build tool plugin, XCTest),
42 shipped in the binary. P2 is `denied` only when every attempt of
43 every place says denied and nothing outside contradicts it: a
44 loopback listener per place catches a connection behind a
45 "denied" line; DNS and Keychain controls run outside first; a
46 missing line is not a denial. P3 and P5 say why they did not run.
47 - The launchd agent; the installer's account refusals; the pinned
48 srt lockfile (`npm ci`, every package by integrity).
493. **Wire** (protocol 2, omitempty, dropped at protocol 1):
50 `capabilities.probes` and `step.checks_sandbox`. Fixtures
51 `frames/hello-mac-probes.json`, `frames/step-mac-checks.json`.
524. **Worker on a Mac** (`thin/mac.go`): each attempt's gate follows the
53 newest probe report; trees under the scratch root (outside the
54 denied state dir); probes run at start when the report is not this
55 version's and profile's, steps wait for them; `equipo-runner probe`
56 on demand; self-update to the instance's release (darwin target,
57 digest, swapped while no step runs, exit 75); `run --env-file`.
58 The test build's fake worker now runs the Mac gate; it labels its
59 checks none (it has no sandbox) unless `EQUIPO_FAKE_SANDBOX=seatbelt`
60 makes it play a Mac whose P2 denied, as `TestMacWorker` does so that
61 Equipo still merges its scenarios on its own.
625. **Install**: `install-v1.sh` dispatches on `uname` (Darwin/arm64:
63 refuses root, reads the darwin target with plutil, checks shasum);
64 `equipo-runner install` on a Mac refuses root, administrators, users
65 not named `equipo-*`, another user's home and a readable foreign
66 home, copies the runner, installs srt, writes `runner.env`, enrols
67 (the link carries the code), loads the agent. `GET /install.sh` is
68 `curl -fsSL https://<instance>/install.sh | sh`.
696. **Release**: `make release-runner` builds `darwin-arm64/` beside the
70 Linux runner (and checks it for the fake worker);
71 `install-manifest.json` gains `targets`; the instance serves the Mac
72 files when they match; `staged-artifacts.py` records both targets.
737. **Instance**: migration 0055 `chat_steps.checks_sandbox`; a worker's
74 checks carry `seatbelt` or `none` (anything else is none); step and
75 task show it; "ran outside the sandbox" on the checks line, badge,
76 timeline and Ready to merge card; the primary's checks are never
77 labelled. The runners view (Connections, Machines) shows platform,
78 where checks run and each probe. One-tap enrolment page.
798. **Docs**: `docs/mac-runner.md`, Paul's four steps.
80
81Tests (each seen failing first or by a mutation, list below):
82`TestChecksSettings*`, `TestGate*`, `TestParseMarked`,
83`TestCapabilitiesFromRecordedTools`, `TestXcodeGate`,
84`TestRunProbesAllDenied`, `TestP2IsDeniedOnlyWhenEverythingIs`,
85`TestJudgeP2`, `TestP4`, `TestFixtureShips`, `TestACSleepAndNode`,
86`TestRefuseAccount`, `TestReadAccount`, `TestHomes`, `TestLaunchAgent`,
87`TestSRTPinned`, `TestMacWorkerConfig`, `TestWorkerMacReports`,
88`TestMacChecksPick`, `TestMacProbesStart`, `TestMacFind`,
89`TestMacUpdater`, `TestInstallMacRefusals`, `TestInstallMac`,
90`TestEnvFileAndExits`, `TestMacInstallShell`,
91`TestInstallPackagingDarwinTarget`, `TestStagedArtifactsGate`
92(extended), `TestCapabilitiesGuard` and
93`TestEncodeProtocol1IsTheSlice4Wire` (extended),
94`TestContractChecksPlacedOnTheWorker` (extended: darwin capabilities
95with probes, the label, the primary unlabelled),
96`TestChecksOutsideTheSandboxAreLabelled`, `TestRunnersViewShowsProbes`,
97`TestInstallScript`, `TestEnrolmentLinkIsOneTap`,
98`TestOnboardingPairingBound` (extended). `TestMacWorker` (headless,
99M1/M2/M4/M5) passes on the shared gate.
100
101Mutations, each killed: profile (Keychains dropped, install dir not
102denied, nesting check off); gate (status file ignored, sweep off,
103reused group killed, shutdown of what was already booted, inherited
104environment, proof with marked left); capabilities (unavailable
105simulators, xcode tag without Xcode); xcode gate (two projects, two
106schemes); probes (accepted connection ignored, missing line as denied,
107DNS control ignored, sentinel kept, path in P4, srt-ran without the
108build); account (admin), launchd (SuccessfulExit); thin (same-version
109update, digest ignored, swap without the step lock, pick, probe rerun,
110bash path, reason ignored, label dropped, ready ignored); install
111(readable home, account, Intel, srt path, launchd exit); script (root,
112version, digest length, Darwin/Intel); release (darwin served when
113tampered, staged darwin, target version); instance (worker label on the
114primary, seatbelt default, task label); views (label, probes); config
115(overlap); enrolment link.
116
117## Astra round 1 (45b6335), fixed
118
1191. P2 on the simulator: the hostile test runs on the newest iOS
120 simulator (none: P2 unavailable) and tries the host's login keychain
121 file from there; denied needs the build and test completed under srt
122 and the end proven. P6's test hashes and writes files until killed.
123 `TestP2NeedsTheSimulatorAndAProvenEnd`.
1242. Unforgeable verdict: the report lives only in the worker's memory;
125 nothing on disk is read back as a verdict; `equipo-runner probe`
126 only asks for a new run. Trusted while this version's, this
127 profile's, made with the srt, Node and ripgrep on disk now
128 (fingerprint) and under a day old; otherwise checks run labelled
129 outside the sandbox and the probes run again. `TestMacProbesTrust`,
130 `TestSRTFingerprint`.
1313. Record before running: marker recorded before anything starts (the
132 worker's git processes carry it too), group recorded once it exists,
133 nothing runs or the group is killed if a record fails; recovery never
134 takes an unrecorded attempt as ended (UnrecordedStep, settled by the
135 marker on a worker, by "no namespace left" on Linux).
136 `TestGateRecordsBeforeRunning`, `TestGateVerifyByMarkerAlone`,
137 `TestWorkerRecordsBeforeRunning`, `TestStepRecoverUnrecorded`.
1384. Homes: closed only if this user can neither list, traverse (a
139 missing name answers "not found" to a searcher) nor open a usual
140 file; symlinked homes and their targets; a /Users that cannot be
141 read stops the installer, fails P4 and denies all of /Users.
142 `TestHomes`. On Linux the file-read check is not separately
143 testable (reading needs traversal), on a Mac ACLs could differ.
1445. Reinstall stops the agent before replacing anything; the enrolment
145 check then gets the state lock. `TestInstallMacAgain`.
1466. Worker only: the Mac says so when it begins enrolment
147 (`worker_only`, migration 0055 `runner_enrolments.worker_only`); the
148 instance refuses to show or approve it for a person with no primary
149 ("Add your main runner first"). The runner refuses a welcome as
150 primary (the runners round's ErrRoleMismatch).
151 `TestMacEnrolmentNeedsAPrimary`, `TestWorkerEnrolRefusesAnOlderInstance`.
1527. Output: 200 lines of at most 4 KB, enforced on every write.
153 `TestTailIsBounded`.
1548. The env file's values reach the Mac host (Options.Getenv), and every
155 tool it runs gets the runner's Node and ripgrep first on PATH.
156 `TestMacHostPaths`.
157Also: Linux-only tests carry a linux build tag and `make vet` vets the
158runner for darwin/arm64. Merged thin-v1-runners d7c803b, then 15feb20
159(enrolled role file, cancel before withdrawal, two-phase removal). A
160Mac also checks the role the instance put in its enrolment credential:
161anything but worker keeps nothing (`ErrEnrolledAsPrimary`) and the
162installer says to add the main runner first (`TestEnrolKeepsTheRole`,
163`TestInstallMacEnrolledAsPrimary`).
164
165## Astra round 2 (be0f1e3 and 9e407e2), fixed
166
1671. Forged approval: the tools srt runs on are checked against pins
168 compiled into the runner, not a fingerprint taken at run time:
169 ripgrep's and Node's programs as the pinned archives unpack them
170 (`RGBinarySHA256`, `NodeBinarySHA256`) and the srt package tree
171 `npm ci` makes from the shipped lockfile (`SRTTreeSHA256`; the same
172 with npm 11.17 and Node 22.23.4's own npm 10.9.9), each at its
173 installed place and srt's .bin link at its fixed target. Checked
174 before and after every probe run and before every sandboxed check;
175 the installer checks them too. A runner is tainted for good once any
176 check runs outside the sandbox (labelled none): it never labels a
177 check sandboxed again, whatever a later probe says. The taint is kept
178 in the state dir and by the instance (`runners.tainted_at`, set from
179 a tainted hello or any worker check labelled none, never cleared; the
180 instance labels a tainted runner's checks none whatever it reports,
181 and says tainted in every welcome). The runners view and
182 docs/mac-runner.md say so. `TestVerifyToolsRefuses`,
183 `TestVerifyToolsReal` (with the real archives and npm tree, run here:
184 a one-byte counterfeit srt, a moved ripgrep and a re-pointed srt link
185 all fail), `TestMacCounterfeitSRT`, `TestMacTaintIsSticky`,
186 `TestContractWorkerTaintIsSticky`, `TestInstallMacVerifiesThePins`.
1872. Reinstall: an agent launchd has is booted out, and a refused bootout
188 stops the installer at once; it then waits, bounded, until launchd
189 no longer has it and the state lock is free, or changes nothing and
190 says so. `TestInstallMacWhenTheRunnerWillNotStop`.
1913. Archive links: entries are created through an os.Root; no symbolic
192 or hard link from an archive is ever made; Node's npm and npx links
193 are made afterwards with fixed targets, corepack is left out.
194 `TestFetchMakesNoLinksFromTheArchive` (the chained-link archive).
195
196Env-gated tests (the real archives and npm tree are not downloaded in
197CI) were run here and pass.
198
199## Restage finding: the tool proxy
200
201`make release` refused b4a3b6d: the darwin portability edit to
202internal/toolproxy (O_PATH behind a per-OS constant) changed the Linux
203tool proxy's bytes, and its digest is certified. internal/toolproxy is
204back to exactly its 1b89bd1 source; the runner reaches it only on Linux
205(ServeToolProxy in tool_proxy_serve_linux.go), and the Mac release has
206no tool proxy (a worker has no coordinator to serve). The darwin target
207names only the runner. `TestToolProxyIsTheCertifiedBuild` builds the
208tool proxy as the release does and compares it with the certified
209digest, so CI catches this from now on.
210
211## The Mac user's name (Paul, 2026-11-10)
212
213macOS's Add User dialog made `paulequipo` from "Paul Equipo". The
214installer now accepts any Standard, non-root user whose short name
215contains "equipo" in any case (`paulequipo`, `equipo-paul`,
216`paul-equipo`); admin, root and home isolation are unchanged. Otherwise
217it says "Equipo runs in its own Mac user so it can't reach your files.
218Create a Standard user with 'equipo' in its account name, then run this
219again." `TestRefuseAccount`, `TestInstallMacAddUserDialogName`.
220
221## Decisions
222
223- **P2 not denied:** checks still run (ruling 2), labelled none. If the
224 fixture at least built and tested under srt, srt still confines them
225 (the boundary is unproven, not absent); otherwise they run with no
226 sandbox. Only P2 `denied` is labelled seatbelt.
227- srt exits 0 when its command dies of SIGTERM (cli.ts). A pass needs
228 srt's exit and the status the gate's shell recorded both 0.
229- launchd restarts only after a non-zero exit (KeepAlive
230 SuccessfulExit false): an update exits 75; a superseded runner exits
231 0 on a Mac (3 on Linux). The spec said "exits 0 for KeepAlive"; that
232 would also restart a superseded runner into a lease fight.
233- srt is installed privately (`~/.local/lib/equipo-runner/srt`, `npm ci`
234 from a shipped lockfile), not `npm install -g`: a Standard user cannot
235 write Homebrew's global prefix, and the lockfile pins every package.
236- What srt needs on macOS, per its README and package.json: ripgrep, and
237 Node.js 22.12 or later to run (`sandbox-exec` is built in). A Standard
238 user cannot use Homebrew, so the installer fetches both from their
239 official releases into `~/.local/lib/equipo-runner/tools`: ripgrep
240 15.2.0 (`ripgrep-15.2.0-aarch64-apple-darwin.tar.gz`, sha256
241 3750b2e9...973e4, the release's own `.sha256` asset) and Node v22.23.4
242 LTS (`node-v22.23.4-darwin-arm64.tar.gz`, sha256 c9e1dbc7...b66428,
243 from SHASUMS256.txt), both re-checked by downloading them. The digest
244 is checked before anything is unpacked; unpacking keeps every entry
245 and symlink inside the archive's root. ripgrep's binary links only
246 libSystem and libiconv. The runner puts both first on its own PATH
247 and the gates' (srt starts through `env node`). `TestToolPins`,
248 `TestFetchChecksTheDigest`, `TestFetchKeepsToTheRoot`; with
249 EQUIPO_TOOL_ARCHIVES set, `TestFetchRealArchives` unpacks the real
250 archives (it did, here).
251- No `claude` tag on a Mac until slice F: nothing but checks is placed
252 there.
253- Mach services are candidates (`com.apple.CoreSimulator.*`,
254 `com.apple.dt.*`, `com.apple.testmanagerd*`,
255 `com.apple.coresymbolicationd`); P2 shows whether xcodebuild runs
256 with them. The list is never widened automatically.
257- The plist is generated per user by the installer, not shipped as a
258 file.
259- `/install.sh` names the team id the runner enrols with (no secret; a
260 person still approves).
261
262## Only the Mac can show
263
264Everything Seatbelt and Xcode do: whether the profile lets
265`xcodebuild test` reach the simulator (the Mach list), whether code run
266by XCBBuildService, CoreSimulatorService, the plugin or the test
267inherits the sandbox (P2's question), Keychain reads from inside srt
268(srt allows securityd, so P2 probably fails on the Keychain and brings
269ruling 2 in), `ps -E` and `simctl` outputs (recorded shapes), the
270fixture's first build, `pmset` on a Mac Studio, `launchctl bootstrap`
271as a Standard user, `xcodebuild -runFirstLaunch` without admin (likely
272refused; ignored), the darwin binary's ad-hoc signature, srt needing
273ripgrep on macOS, the self-update swap under launchd.
274
275## Open issues
276
277- **A likely fifth step:** macOS homes are often listable by the
278 `staff` group. The installer then stops and names the ACL that shuts
279 out only the Equipo user (`sudo chmod +a "<user> deny
280 list,search,readattr,readextattr,readsecurity" <homes>`, undone with
281 `chmod -a` and the same entry). P4 reports it too.
282- Auto-merge: until slice 4c's rule for checks outside the sandbox
283 exists (passed only for the creator's own repositories, spec §4.3),
284 Equipo never merges those on its own; it asks "Merge <title>?"
285 (`TestContractChecksPlacedOnTheWorker`).
286- Sandbox violations are not tailed from `log stream` (§4.5); P2 does
287 not read the unified log for the Mach services xcodebuild was denied.
288- CI under load: A5 (headless connections) saw "signed out" while the
289 Codex home was still being deleted (the instance infers signed out
290 from the hello the runner sends once the binding is dropped); the test
291 now waits for the home. `make test` passes `-timeout 15m` so the
292 headless package's 720s budget, not go test's 10-minute panic, judges
293 it on a loaded runner.
294- Tool discovery skips `npm root -g` and a login shell's PATH.
295- An srt, Node or ripgrep pin change needs the installer run again;
296 self-update swaps only the runner.
297
298## Installing under su or sudo (2026-11-10)
299
300Paul's first install, from `sudo su paulequipo`, stopped on
301`TMPDIR: parameter null or not set`. Neither installer now needs
302anything from the environment:
303
304- `install-v1.sh` works in `$TMPDIR` when set, else the user's own
305 temporary folder (`getconf DARWIN_USER_TEMP_DIR`), else `mktemp -d`,
306 else a private folder in the user's own home (`~/.cache/
307 equipo-bootstrap`). On a Mac it sets HOME from the user directory
308 (`dscl`) before handing over, and appends the system folders to PATH.
309 `TestMacInstallShellUnderSu` runs it with TMPDIR unset and HOME set to
310 another user's home (fails on the old script with Paul's error).
311- `equipo-runner install` reads the home from `dscl` (`mac.ReadHome`),
312 never `$HOME`, and runs npm and xcodebuild with HOME, USER and LOGNAME
313 of the user (`userEnv`). `TestInstallMacIgnoresInheritedHome`;
314 mutations (home from `$HOME`, `userEnv` keeping HOME, xcodebuild
315 given `$HOME`) fail it.
316- Before changing anything it checks the login session
317 (`launchctl print gui/<uid>`); without one it says "Log in as <user>
318 on this Mac (fast user switching) and keep it logged in, then run this
319 again." (`runner.mac.not_logged_in`). From `sudo -iu` it installs when
320 the session exists. Refusal case "logged out"; removing the check
321 fails it.
322- The home-isolation message now suggests the targeted ACL instead of
323 `chmod 700` (`TestInstallMacHomeACLMessage` checks the exact text).
324 The isolation check already counts an ACL deny as closed: it tries to
325 list, pass through and open a file in each home and counts only
326 permission denied as closed.
327
328## Enrolment that waits and says why (2026-11-10)
329
330Paul's install printed the link (H0SNVFN19S), polled staging from 11:58
331to 12:06 UTC, then ended on "Runner installation is unavailable." The
332enrolment row shows it was never approved (no page load or approve POST
333after 11:58; last good poll 12:06:23). The next poll, at 12:06:28, got a
3345xx; any answer other than 200 or 409 ended `runner.Enrol`, and neither
335the instance (no log line for a 503 to a device) nor the installer (the
336bare unavailable line) said what it was. The approval path itself works
337for a Mac joining a person with a Linux primary
338(`TestMacEnrolmentApprovedAfterAPrimary`).
339
340- `runner.Enrol` waits out no answer, 5xx and 429, backing off from the
341 poll interval up to a minute, until the code expires; the protocol
342 question and the start of the enrolment are tried up to four times. A
343 5xx on the protocol question is no longer "the instance is older".
344- 403 is "expired" within a minute of the code's expiry, "turned down"
345 otherwise; running out is "expired", unless it was still failing,
346 which is reported as that failure. Expired or turned down, the saved
347 code is dropped so the next run gets a new link.
348- `Config.EnrolNotify` hears "waiting" once and each retry; both
349 installers print "Waiting for you to approve…", each retry with its
350 cause, and at the end the expiry, the refusal or "Adding this machine
351 to Equipo failed: <cause>" before the unavailable line; the same lines
352 go to the install log (`~/Library/Logs/equipo-runner/install.log` on a
353 Mac, `install.log` in the runner root on Linux). Causes are the HTTP
354 status and error key or the network error: never a body.
355- The instance logs a server error on the two device routes, with the
356 route and the error (`TestEnrolmentServerErrorIsLogged`).
357- Tests: `TestEnrolWaitsOutTransientFailures`, `TestEnrolEndsInWords`,
358 `TestInstallMacEnrolmentInWords`. Mutations shown failing: transient
359 never retried, a 5xx protocol answer taken as older, turned down
360 reported as expired, the used code kept, the last failure hidden by
361 expiry.
362- Open: the approve button's confirmation lasts five minutes, the code
363 ten. Tapping a page opened more than five minutes earlier is refused
364 ("You do not have access to this page"); opening the link again
365 works.
366
367## Copy for review
368
369All marked COPY ACCEPTED FOR NOW and listed in the plan 3 inventory:
370`runner.mac.*` (installer lines, `runner.mac.not_logged_in` and the
371ACL wording of `runner.mac.home` and `runner.enrol.*` added
3722026-11-10), `runner.add_title` ("Add %s to your
373team"), the runners view (`runner.platform`, `runner.checks_run`,
374`runner.sandbox.*`, `runner.probes`, `runner.probe.P1` to `P7`,
375`runner.verdict.*`), `work.checks.outside_sandbox` ("%s, ran outside
376the sandbox"), and `docs/mac-runner.md`.
377