| index fd8e028c..9ed8eb8a 100644 |
| --- a/docs/superpowers/plans/2026-11-28-mac-runners-slice-f.md |
| +++ b/docs/superpowers/plans/2026-11-28-mac-runners-slice-f.md |
| @@ -1,7 +1,7 @@ |
| # Mac runners slice F: Engineering on a Mac worker |
| |
| -Status: rev 2, 2026-11-28, after Astra round 1 (NOT READY, 20 findings, |
| -all taken). Spec: `docs/superpowers/specs/2026-11-07-equipo-mac-runners.md` |
| +Status: rev 3, 2026-11-28, after Astra round 1 (NOT READY, 20 findings, |
| +all taken) and round 2 (NOT READY: 8 partly resolved, 4 new; all taken). Spec: `docs/superpowers/specs/2026-11-07-equipo-mac-runners.md` |
| rev 4 plus its §8 addendum (2026-11-28), which is current where they |
| differ. Branch `mac-slice-f` from `origin/main` 8bd40ed1. Controller |
| brief: `CONTROLLER-BRIEF-mac-slice-f.md`. |
| @@ -40,8 +40,13 @@ bases, pushes, reviews and merges. |
| `internal/equipo/copy.go`, marked pending with |
| `python3 scripts/copy-status.py pending`. The same strings also go in |
| the copy-review JSON `docs/superpowers/plans/2026-11-28-mac-slice-f-copy.json` |
| - for Luna's review (task 15). Engineering never writes acceptance |
| - markers. No em dashes, no exclamation marks. |
| + for Luna's review (task 15). Luna's edits are applied verbatim, and |
| + the strings stay pending. Acceptance happens only through the |
| + project's own path (AGENTS.md: the owner's "Copy can accept on my |
| + behalf" setting with matching server records and exact text hashes, |
| + or the parent's release step), never by the controller or an |
| + implementer. Pending copy keeps blocking release, which is correct. |
| + No em dashes, no exclamation marks. |
| - **Round limit.** Astra reviews this plan, the risky tasks (3, 4, 7, 8, |
| 9, 10, 11, 12, 15) and the whole branch, **at most three rounds each**. |
| After round 3 the controller fixes what is clearly right, records what |
| @@ -213,17 +218,24 @@ Changes: |
| yield, and `Valid()`, which checks each SHA and allows at most three. |
| Every existing `!=` comparison keeps working. |
| - Migration: `transfers.kind`, `transfers.old_base_sha`; |
| - `chat_steps.xcode_access`; `chat_questions.eng_attempt`, |
| - `eng_account`, `eng_session` (task 13). Additive only. |
| + `chat_steps.xcode_access`, `chat_steps.outcome_phase` (committed, |
| + unfinished or no-shell, kept apart from transfer progress), |
| + `chat_steps.session_id` (the kept Engineering session); |
| + `chat_questions.eng_attempt`, `eng_account`, `eng_session`, |
| + `runner_id`, `base_sha`, `candidate_sha` (frozen when the question is |
| + created, task 13). Additive only. |
| - New durable command `PrepareBaseCommand{task, step, attempt, repo, |
| rebase, from_base, candidate}` (instance to primary) and report |
| `BaseReport{task, step, attempt, base_sha, reason}` (primary to |
| instance). |
| - `DispatchCommand.XcodeAccess` (`sandboxed` or `""`). |
| -- `StepReport.XcodeAccess` echoes what ran. |
| -- `PublishedReport.ChangeFiles *ChangeFiles` and `DiffCollection string`, |
| - plus `Phase` (the commit's phase: committed, unfinished, no-shell), so |
| - the instance keeps the worker's outcome through publication (task 4). |
| +- `StepReport.XcodeAccess` echoes what ran. `StepReport.SessionID` |
| + names the kept session (protocol 36, from any runner; the primary |
| + starts sending it too). `StepReport.OutcomePhase` carries the commit's |
| + outcome separately from progress phases. |
| +- `PublishCommand.OutcomePhase`, and `PublishedReport.ChangeFiles |
| + *ChangeFiles`, `DiffCollection string` and `OutcomePhase`, so the |
| + instance keeps the worker's outcome through publication (task 4). |
| - `ChangeDiffUpload` gains `Publication` (empty: today's path). |
| - `AskCommand` gains `EngAttempt`, `EngAccount`, `EngSession`. |
| - `Capabilities.Engineering *EngineeringStatus{state, reason}`: |
| @@ -370,13 +382,21 @@ Instance: |
| - Accept change-diff uploads that name a publication only from that |
| publication's primary connection, for the worker's task, step and |
| attempt, while the publication is `pending` or `published`, in either |
| - order relative to the worker's `done`. Refuse stale publications, |
| - another primary and a wrong attempt. |
| -- Keep the worker's outcome. A worker's `committed` report records its |
| - phase. The `published` report carries it back, and only then does the |
| - step take `step_timeout` (unfinished) or the no-shell reason, with |
| - `Pushed` set by the primary. `unfinishedReport` must not rebuild |
| - `Pushed=true` from a worker report. Republish keeps the phase. |
| + order relative to the worker's `done`. Change both acceptance paths: |
| + `changeDiff` (today it needs the step's runner and `running`) and |
| + `acceptChangeDiffs` (today the uploader must equal the step's runner). |
| + Refuse stale publications, another primary and a wrong attempt. |
| +- The worker's `done` never touches `ChangeFiles` or the diff |
| + collection on a worker step; only `published` sets them. A `done` |
| + arriving after `published` must not clear them. |
| +- Keep the worker's outcome. A worker's `committed` report records |
| + `outcome_phase`. The instance copies it into `publish`, the primary |
| + echoes it in `published`, and only then does the step take |
| + `step_timeout` (unfinished) or the no-shell reason, with `Pushed` set |
| + by the primary. Republish keeps it. Two places rebuild `Pushed=true` |
| + from an unfinished outcome today, and both must not do so for a |
| + worker: the instance's `unfinishedReport` (`chat/tasks.go`) and the |
| + runner's (`thin/step.go`). |
| |
| Tests first: |
| |
| @@ -395,7 +415,11 @@ Tests first: |
| publication, a wrong primary, a wrong attempt); |
| `TestContractWorkerUnfinishedThroughPublication` (timeout, no-shell |
| fix round, failed publication then republish: the phase survives and |
| - `Pushed` comes only from `published`). |
| + `Pushed` comes only from `published`); |
| + `TestContractPublishedFilesSurviveDone` (files and diffs visible on the |
| + task in both orderings of `done` and `published`, and after a |
| + restart); `TestWorkerUnfinishedReportNeverPushed` (thin, the runner's |
| + `unfinishedReport`). |
| - `TestPackOversizeIsWorkspaceTooLarge`: declared oversize ends the step |
| `workspace_too_large` with Needs you. |
| |
| @@ -607,13 +631,21 @@ Mac, `mac/usertemp.go` (`Turns`), `thin/step.go` (`recordedStart`), |
| group id. Do not kill it, and do not prove termination. The step |
| stays unterminated (no Retry) until the group is gone. Keep today's |
| protection against killing a reused group. |
| -- **One machine lock.** Every operation that runs repository code, runs |
| - Xcode, or holds a model token takes `mac.Turns` for its whole life: |
| - checks, Engineering, asks, probes P1 to P7 and F1 to F7, the token |
| - check, the sign-in pty, and token storage. The temp-cleanup "pending" |
| - record is owned by the turn that wrote it, and only its owner or a |
| - restart may clear it. While a connection is in any state from |
| - connecting to deleted (task 11), no turn may run unsandboxed. |
| +- **One machine lock, per operation.** Every operation that runs |
| + repository code, runs Xcode, or has a model token in a process takes |
| + `mac.Turns` for that operation's life and no longer: a check, an |
| + Engineering attempt, an ask, a probe run (P1 to P7, F1 to F7), a token |
| + check, a sign-in pty, a token store. Descendants the operation itself |
| + starts (Xcode under Engineering, the simulator under a check) belong |
| + to it. Turns are serialized, so a stored connection never blocks |
| + sandboxed checks and Engineering from taking turns one after another. |
| + The temp-cleanup "pending" record is owned by the turn that wrote it; |
| + only its owner or a restart may clear it. |
| +- **The credential flag is separate from the lock.** The persistent |
| + "this Mac has a model credential" flag (task 11, D1) lasts from a |
| + connection's `connecting` until its files and any Keychain item are |
| + proven gone. It only forbids unsandboxed turns; it does not hold |
| + `Turns`. |
| - `termination_kind: process_group`. If task 1 (S5) shows the marker |
| does not survive the CLI's scrub, stop and raise it: the honest limit |
| in §5 would then cover every Bash command. |
| @@ -628,6 +660,8 @@ in the recorded group: no kill, no proof); |
| not killed, no proof until it is gone); `TestRestartKillsMarked`; |
| `TestTurnsCoverEveryTokenOperation` (an Engineering turn, a token check |
| and a probe cannot overlap; checks wait while a sign-in pty is open); |
| +`TestStoredConnectionAllowsSerialTurns` (with a connection stored, |
| +Engineering then sandboxed checks then an ask run one after another); |
| `TestCleanupOwnedByItsTurn` (an interrupted cleanup is finished only by |
| its owner or a restart, never by another turn). |
| |
| @@ -648,11 +682,20 @@ Files: `thin/tokencheck.go`, `thin/signin.go`, `thin/token.go`, a new |
| - **Darwin sign-in by link.** The pinned CLI's `setup-token` in a pty |
| under the darwin launcher, inside `Turns`, with the same prompt |
| framing, code delivery (sealed), timeout and recovery as |
| - `thin/signin.go`. Before and after, a metadata-only Keychain check |
| - (`security find-generic-password -s 'Claude Code-credentials'`, |
| - without `-w`) records whether the CLI created an item. If it did, the |
| - connection is refused and the item is named in the log, since a |
| - Keychain copy would escape every deny rule. |
| + `thin/signin.go`. **Keychain.** Prevention first: launch with whatever |
| + S4 showed keeps the CLI off the Keychain (the token in the |
| + environment, `CLAUDE_CONFIG_DIR` set). Then detection: before and |
| + after, list the login Keychain's generic-password items by attributes |
| + only (`security dump-keychain` without `-d`, or `find-generic-password` |
| + without `-w`) and diff the lists. An item that appeared during the |
| + attempt is deleted by its exact service and account |
| + (`security delete-generic-password -s <service> -a <account>`), the |
| + connection is refused, and the credential flag stays set until a |
| + second listing shows it gone. An item present before the attempt is |
| + never touched; if one with the CLI's service name exists before the |
| + first sign-in, the worker refuses to add a connection and says so. |
| + The before-list is written durably before the pty starts, so a crash |
| + or cancel is cleaned up on restart. |
| - **Home guard** (spec §8.3, item 1). Decide from ownership, mode bits |
| and ACLs alone; never test by opening files as ourselves (P4's |
| `Exposed` cannot see what another user sees). Pass only if all of |
| @@ -660,10 +703,14 @@ Files: `thin/tokencheck.go`, `thin/signin.go`, `thin/token.go`, a new |
| - the home, state dir, config dir and accounts root are owned by the |
| runner user; |
| - none has group or other bits; |
| - - none has an ACL entry that allows list, search, read or readattr to |
| - anyone else; |
| + - none has an ACL entry granting anyone else any right at all (read, |
| + list, search, readattr, readextattr, readsecurity, write, append, |
| + add_file, add_subdirectory, delete, delete_child, writeattr, |
| + writeextattr, writesecurity, chown), whether or not inherited; |
| - each lies inside the home; |
| - - no ancestor between the home and each root is a symlink. |
| + - every ancestor from the home down to each root is a real directory |
| + (no symlink) owned by the runner user, with no group or other write |
| + bit and no such ACL grant, so nobody else can replace it. |
| Read the facts with `stat` and `ls -led` (recorded outputs), or the |
| ACL API through the seam. On failure, name what to change. |
| - **Taint gate** (D2 default). A runner tainted on the instance or in its |
| @@ -674,10 +721,14 @@ Files: `thin/tokencheck.go`, `thin/signin.go`, `thin/token.go`, a new |
| |
| Tests first: `TestDarwinTokenCheck` (success, signed out, limited, |
| cancelled, a crash then recovery), `TestDarwinSignIn` (code delivered, |
| -timeout, cancel, restart, a Keychain item created means refused), |
| +timeout, cancel, restart, a Keychain item created means refused, deleted |
| +by its exact attributes and the flag held until a second listing shows it |
| +gone, a pre-existing item untouched, a failed delete keeps the flag), |
| `TestHomeGuard` (0700 passes; 0750; an ACL grant to `everyone`; an ACL |
| -grant to one user; a root outside the home; a symlinked ancestor; a mode |
| -changed between store and use), `TestTaintBlocksConnections`. |
| +grant to one user; a write, `writesecurity` or `chown` ACL grant; an |
| +inherited grant; a root outside the home; a symlinked ancestor; an |
| +ancestor owned by another user; a mode changed between store and use), |
| +`TestTaintBlocksConnections`. |
| |
| Mutations: accept group read; ignore ACL entries; skip the check before |
| use; let a tainted runner store a token. Each must fail a named test. |
| @@ -761,8 +812,17 @@ One attempt on a worker: |
| task 7's transcript move. |
| 7. Commit with `tree.Commit` (Equipo Engineering identity, parent the |
| base). Apply the same rules for unfinished, no-shell and empty |
| - results, and record the phase. Compute `Apple` from the changed |
| - files. |
| + results, and record the **outcome** (committed, unfinished, no-shell) |
| + in its own durable field, never in the transfer progress phase. |
| + Compute `Apple` from the changed files. **Retain the candidate:** |
| + copy its new objects from the task tree's private repository into the |
| + worker store (`pack-objects --revs ^base candidate | index-pack` |
| + into the store) and pin it with a ref |
| + (`refs/equipo/<task>/<step>/<attempt>`) before anything else, so |
| + upload, restart, republish and asks never depend on the attempt's |
| + directory. The ref is deleted when the instance forgets the task |
| + (`ForgetTask`) or the kept-session retention ends, whichever is |
| + later. |
| 8. **Object scan, before anything leaves.** List the new objects |
| (`rev-list --objects ^base candidate`) and read each with `cat-file |
| --batch`: blobs (binary too; symlink targets are blobs), trees (file |
| @@ -774,9 +834,12 @@ One attempt on a worker: |
| configuration. Fail closed: a hit, a scanner error, an object over the |
| scan bound (the 64 MB pack bound), or a list that cannot be read ends |
| the step `secret_in_candidate`, and nothing is uploaded. Logs and |
| - reports name the path or object id, never the matched bytes. |
| -9. Record phase `committed` durably and report `committed` with the |
| - candidate and phase. The instance opens the outbound transfer. Upload |
| + reports name only the object id and its kind, never a path (a file |
| + name can be the secret) and never the matched bytes. Independently, |
| + the summary, headline, log tail and every report string are passed |
| + through the same known-secret redaction before they leave the worker. |
| +9. Record progress `committed` durably and report `committed` with the |
| + candidate and its outcome. The instance opens the outbound transfer. Upload |
| the thin pack (`pack-objects --revs --thin --stdout` with |
| `^base candidate`) as blob frames. End `done`, `pushed: false`. |
| 10. A restart after `committed` resumes the upload and never launches |
| @@ -802,9 +865,14 @@ only): |
| - `TestWorkerObjectScan`: the fake CLI plants the token raw in a text |
| file, base64 in a binary file, in a file name, in a symlink target, in |
| the commit message (through its summary), and hex-encoded. Each is |
| - refused with nothing uploaded and the log names only the path. Plus a |
| - gitleaks-detectable fake key, a scanner that exits with an error, and |
| - an object past the bound. |
| + refused with nothing uploaded, and neither the log nor the report |
| + contains the token or the file name. Plus a gitleaks-detectable fake |
| + key, a scanner that exits with an error, an object past the bound, and |
| + the token in the CLI's summary text (redacted in the report). |
| +- `TestWorkerCandidateRetained`: after the attempt dir is removed and the |
| + runner restarts, the upload resumes, a republish works and an ask |
| + reads the candidate from the store; the ref goes when the task is |
| + forgotten. |
| - `TestWorkerEngineeringRestartAfterCommit`, `TestWorkerEngineeringFailover`. |
| - `TestWorkerChecksUnchanged`: every existing worker checks test passes. |
| |
| @@ -817,10 +885,14 @@ after `committed`. Each must fail a named test. |
| Files: `internal/equipo/chat/questions*.go` (creation and dispatch), |
| `thin/ask.go`, the worker's kept-session store. |
| |
| -- When a question is created for an Engineering step, the instance binds |
| - the Engineering attempt, account and session id recorded on the step |
| - (`eng_attempt`, `eng_account`, `eng_session`) and sends them in |
| - `AskCommand`. |
| +- Every runner reports the kept session id in its Engineering step |
| + report at 36 (`StepReport.SessionID`), and the instance stores it on |
| + the step (`chat_steps.session_id`, task 2). |
| +- When a question is created for an Engineering step, the instance |
| + freezes on the question row the Engineering attempt, account, session |
| + id, runner, base and candidate (task 2's columns) and sends them in |
| + `AskCommand`. Dispatch (`nextQuestion`, which today rereads the |
| + mutable step) uses only the frozen values. |
| - The worker keeps Engineering sessions per (step, attempt, account, |
| session id) under its state dir, with the primary's retention. An ask |
| resumes exactly the bound session on the runner that holds it, with |
| @@ -832,8 +904,9 @@ Files: `internal/equipo/chat/questions*.go` (creation and dispatch), |
| |
| Tests first: `TestContractAskBindsTheSession` (thintest: a question |
| created after a newer attempt that produced the **same** candidate is |
| -still bound to the attempt it was asked about; the worker refuses the |
| -other); `TestWorkerAskAnswersFromKeptSession`; |
| +still bound to the attempt it was asked about, and a step that moved on |
| +after the question was created does not change its runner, base or |
| +candidate; the worker refuses the other); `TestWorkerAskAnswersFromKeptSession`; |
| `TestWorkerAskRefusesMismatch`; `TestWorkerAskCannotWrite`; |
| `TestContractAskMacOffline`. |
| |
| @@ -851,9 +924,19 @@ inside `Turns`, as P1 to P7 do. They are reported in |
| `capabilities.probes` and trusted only for this runner version, this |
| settings profile, the verified pinned CLI, this Xcode version and its |
| simulator runtimes, for under a day. Any change to those inputs means |
| -they run again. They need a Claude connection, and they run as **one |
| -short probe turn** on the connection's small model, prompted to run one |
| -fixed script with Bash. The verdict never reads model text. As in P2, |
| +they run again. They need a Claude connection. They run as **three short |
| +probe launches** on the connection's small model, each prompted to run |
| +one fixed script with Bash: |
| + |
| +- launch A, under the no-Xcode Engineering settings: F1, F2, F3, F6, F7; |
| +- launch B, under the sandboxed-Xcode settings, only when P2 is |
| + `denied`: F5; |
| +- launch C, under the no-Xcode settings, last: F4, which cancels the |
| + launch. |
| + |
| +Each launch's results are stored with the inputs it ran under. The |
| +status aggregates them only when every required result matches the |
| +current inputs. The verdict never reads model text. As in P2, |
| every probe has a control that must succeed, a missing line is not a |
| denial, and outside observers decide: a loopback listener, nonce |
| sentinels, and the runner's own search of the probe tree. The probe |
| @@ -905,7 +988,8 @@ Otherwise it names the first missing input. F5 decides only |
| shows F1 to F7 beside P1 to P7. |
| |
| Tests first (`internal/runner/mac/probe_engineering_test.go`, recorded |
| -outputs and fakes): `TestF1RequiresControlAndListener`, |
| +outputs and fakes): `TestProbeLaunchesAggregate` (a stale launch A |
| +with a fresh launch C is not ready), `TestF1RequiresControlAndListener`, |
| `TestF2NoncesDecide`, `TestF3AnySourceFails`, `TestF4SweepProof`, |
| `TestF5OnlyAfterP2AndNeedsTheBuild`, `TestF6SwapRace`, |
| `TestF7NeedsTheOutsideControl`, `TestP2TriesTheToken`, |
| @@ -923,7 +1007,7 @@ Xcode change. Each must fail a named test. |
| |
| **D1 default** (spec §8.7; Paul may overrule). While the instance holds a |
| Mac as having a model credential (task 11, from `connecting` until the |
| -files are gone), it does not offer "Run outside the sandbox" for checks |
| +files and any Keychain item are proven gone), it does not offer "Run outside the sandbox" for checks |
| on that Mac (`macsandbox.go`). The worker refuses an unsandboxed |
| dispatch (`sandbox_unproven`) whenever it holds any token file or has a |
| connection in progress. Put the rule in one predicate |