Mac slice F task 15: D1 on both sides, Mac Engineering views, copy
D1 (Paul, 2026-11-28: no). One predicate per side, unsandboxedAllowed: the instance offers, records, places and dispatches no check outside the sandbox on a Mac it holds as having a model credential; the worker refuses such a dispatch while its durable hold is set (reading it again after the taint). Setting the hold withdraws a choice on a waiting attempt, takes back an unstarted dispatch, audits it and tells the creator once. Views: Made on <Mac> and the no-Xcode line on the step, the base wait, the held line on Needs you, the switched-off wording, and on the Machines page whether Engineering can run, the home guard and Keychain lines (protocol 37 runner user), and the hold. Copy JSON lists all 57 pending slice F keys plus the docs placeholder.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 files changed,
+1,167
−41
.rastrillo/budgets.txt+5 −5docs/superpowers/plans/2026-11-28-mac-slice-f-copy.json+134 −3docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+18 −2internal/equipo/chat/macsandbox.go+107 −2internal/equipo/chat/runners.go+9 −1internal/equipo/chat/tasks.go+6 −1internal/equipo/chat/worker_connections.go+7 −1internal/equipo/copy.go+20 −2internal/equipo/mac_engineering_views_test.go+195 −0internal/equipo/machines_view.go+5 −2internal/equipo/runners.go+42 −2internal/equipo/setup/runner_models.go+5 −0internal/equipo/templates/runners.html+3 −0internal/equipo/templates/work_parts.html+1 −1internal/equipo/work_pages.go+12 −0internal/equipo/work_views.go+9 −1internal/runner/thin/mac.go+39 −12internal/runner/thin/mac_test.go+1 −1internal/runner/thin/maccreds.go+3 −0internal/runner/thin/sandbox_consent_test.go+7 −1internal/runner/thin/unsandboxed_d1_test.go+150 −0internal/runner/thin/worker_conns.go+3 −0internal/thintest/mac_views_contract_test.go+86 −0internal/thintest/unsandboxed_d1_contract_test.go+244 −0internal/wire/mac_engineering.go+19 −3internal/wire/mac_engineering_test.go+20 −0internal/wire/runners.go+5 −1internal/wire/tasks.go+12 −0
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index a3707375..5687ecf8 100644 |
| --- a/.rastrillo/budgets.txt |
| +++ b/.rastrillo/budgets.txt |
| @@ -14,8 +14,8 @@ perf GET /* skip Unknown private paths render 404; this fallback contains no scr |
| time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial reruns measured 18.079s and 22.031s. Keep migration, recovery, accounting and concurrency assertions; 60s leaves 30 percent headroom above loaded CI. |
| time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage. |
| -size internal/equipo 24152 - Preview, retry, merges, kept work, check-db, notifications, places, GitHub routes, Mac waits, probe and proof codes, Mac credential copy, Mac connections, worker Engineering reasons, F probes; 24152. |
| -size internal/wire 8658 - Protocols 31 to 35 (facts, diffs, evidence, CI units, files, places), Mac waits, 37 Mac Engineering, probe and proof codes, credential_unproven, model hold, worker Engineering reasons; measured 8658. |
| +size internal/equipo 24233 - Preview, retry, merges, kept work, check-db, notifications, places, GitHub routes, Mac waits, probe and proof codes, Mac credential copy, Mac connections, Engineering reasons, F probes, D1; 24233. |
| +size internal/wire 8690 - Protocols 31 to 35 (facts, diffs, evidence, CI units, files, places), Mac waits, 37 Mac Engineering, probe and proof codes, credential_unproven, model hold, runner user; 8690. |
| size internal/equipotest - 12683 GitHub connect value search, lifecycle and sweep-log contracts; Task 21 migration fixtures and Rastrillo asset contract; measured 0/12683 source/test lines. |
| time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded); |
| time internal/runner 330s Plan 3 CI repair measured 292.120s for the full package (controller CI 472.184s). |
| @@ -38,7 +38,7 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full |
| perf GET /releases/* skip Verified runner release file downloads, not browser GET screens. |
| perf GET /install.sh skip Mac runners: the one-line bootstrap a terminal pipes to sh, not a browser screen. |
| time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s; |
| -size internal/runner/thin 34096 30973 Protocols 31 to 35, merge credential, publication guards, kept work, scans, Mac pin, paths, bases, endpoint, Mac turns, Mac credentials, worker conns, Engineering, asks, F probes; 34096/30973. |
| +size internal/runner/thin 34129 31123 Protocols 31 to 35, merge credential, publication guards, kept work, scans, Mac pin, paths, bases, endpoint, Mac turns, Mac credentials, worker conns, Engineering, asks, F probes, D1; 34129/31123. |
| time internal/thintest 240s Thin contract and page tests, the Assistant's and the models' included, share one harness. Measured 202s on a shared 16 CPU box (2026-11-13); CI runs two lanes. |
| time internal/runner/mac 45s Real processes killed and proven gone: groups, sessions, the runner-user sweep, turns, restarts; probes end to end. Measured 29.3s locally. |
| time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s). |
| @@ -56,7 +56,7 @@ perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for device |
| perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen. |
| perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen. |
| perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen. |
| -size internal/equipo/chat 39267 12122 File facts/diffs, previews, merge authority, unfinished work, CI feedback, notification receipts, Assistant files, places, waiting cards, Mac waits, Engineering, conns, asks; measured 39267/12122. |
| +size internal/equipo/chat 39391 12122 File facts/diffs, previews, merge authority, unfinished work, CI feedback, notification receipts, Assistant files, places, waiting cards, Mac waits, Engineering, conns, asks, D1; 39391/12122. |
| perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}. |
| perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}. |
| perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections. |
| @@ -71,7 +71,7 @@ perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one im |
| perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section. |
| time cmd/equipo-runner 60s TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally). |
| size internal/headless - 11999 Grant scenarios (#48); sign-in email at 1280 and 390; Assistant files end to end; the restart wait; the live site waits for a place; a card answer settles at the bottom; measured 11999 test lines. |
| -size internal/thintest - 39946 Protocol 31 contracts, 35 diffs, stuck tasks, no-access merges, held retries, unfinished work, free rounds, previews, Assistant files, places, Mac waits, Mac Engineering, conns, asks; measured 39946. |
| +size internal/thintest - 40276 Protocol 31 contracts, 35 diffs, stuck tasks, no-access merges, held retries, unfinished work, free rounds, previews, Assistant files, places, Mac waits, Mac Engineering, conns, asks, D1; 40276. |
| perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}. |
| perf GET /api/v1/usage skip Thin v1 person API: bearer-only JSON for devices; the browser reads usage through /usage. |
diff --git a/docs/superpowers/plans/2026-11-28-mac-slice-f-copy.json b/docs/superpowers/plans/2026-11-28-mac-slice-f-copy.json| index f249e2a1..d16e5759 100644 |
| --- a/docs/superpowers/plans/2026-11-28-mac-slice-f-copy.json |
| +++ b/docs/superpowers/plans/2026-11-28-mac-slice-f-copy.json |
| @@ -2,12 +2,14 @@ |
| { |
| "key": "work.needs.mac_connection", |
| "where": "Task line (Needs you), Mac Engineering waiting for a Mac's Claude connection; %s is the Mac", |
| - "draft": "Needs you: %s needs Claude to make this change" |
| + "draft": "Needs you: %s needs Claude to make this change", |
| + "paul_sees": true |
| }, |
| { |
| "key": "work.needs.mac_update", |
| "where": "Task line (Needs you), Mac Engineering waiting for an update; %s is the Mac or the main runner", |
| - "draft": "Needs you: %s needs an update to make changes" |
| + "draft": "Needs you: %s needs an update to make changes", |
| + "paul_sees": true |
| }, |
| { |
| "key": "work.decide.mac_connection_why.no_connection", |
| @@ -107,7 +109,8 @@ |
| { |
| "key": "chat.connections.add_to", |
| "where": "Connections page, the button under a Mac's group that adds Claude to that Mac; also the Needs you link on a task waiting for Claude on that Mac (waiting_mac_connection, no connection or signed out); %s is the Mac's name", |
| - "draft": "Add Claude to %s" |
| + "draft": "Add Claude to %s", |
| + "paul_sees": true |
| }, |
| { |
| "key": "chat.connections.reason.mac_claude_only", |
| @@ -163,5 +166,133 @@ |
| "key": "runner.probe.F7", |
| "where": "Machines page, Self-checks list: the name beside probe F7's verdict (runner.verdict.*), after P1 to P7. F7 checks: xcodebuild, simctl and CoreSimulator refused under the no-Xcode settings.", |
| "draft": "No Xcode for Claude without access" |
| + }, |
| + { |
| + "key": "work.needs.mac_runner", |
| + "where": "From mac-placement-wait (this branch stacks on it), unchanged by slice F: Task line (Needs you), Mac work waiting because no Mac runner is added", |
| + "draft": "Needs you: this work needs a Mac, and no Mac runner is added yet", |
| + "paul_sees": true |
| + }, |
| + { |
| + "key": "work.decide.mac_runner_why", |
| + "where": "From mac-placement-wait (this branch stacks on it), unchanged by slice F: Task decision card, why (waiting for a Mac runner)", |
| + "draft": "This work needs a Mac, and no Mac runner is added to your team yet. It waits instead of running on Linux." |
| + }, |
| + { |
| + "key": "work.decide.mac_runner_ask", |
| + "where": "From mac-placement-wait (this branch stacks on it), unchanged by slice F: Task decision card, ask (waiting for a Mac runner)", |
| + "draft": "Add a Mac runner and it starts by itself." |
| + }, |
| + { |
| + "key": "work.waits.mac_runner", |
| + "where": "From mac-placement-wait (this branch stacks on it), unchanged by slice F: Who-it-waits-on phrase for a task waiting for a Mac runner (\"%s. It waits on %s.\")", |
| + "draft": "It needs a Mac runner" |
| + }, |
| + { |
| + "key": "work.needs.mac_engineering", |
| + "where": "Task line (Needs you), Mac Engineering waiting because making changes on a Mac is switched off on the instance (EQUIPO_MAC_ENGINEERING off, waiting_mac_engineering). Rewritten by slice F task 15: the mac-placement-wait draft said Mac runners can't make changes, which slice F makes untrue", |
| + "draft": "Needs you: this change needs a Mac, and making changes on a Mac is switched off", |
| + "paul_sees": true |
| + }, |
| + { |
| + "key": "work.decide.mac_engineering_why", |
| + "where": "Task decision card, why, same switched-off case (waiting_mac_engineering). Rewritten by slice F task 15 for the switch-off case", |
| + "draft": "This change needs a Mac. Making changes on a Mac is switched off for now, so it waits instead of being made on Linux." |
| + }, |
| + { |
| + "key": "work.decide.mac_engineering_ask", |
| + "where": "From mac-placement-wait (this branch stacks on it), unchanged by slice F: Task decision card, ask, same switched-off case", |
| + "draft": "Leave it waiting, or cancel it." |
| + }, |
| + { |
| + "key": "work.waits.mac_engineering", |
| + "where": "From mac-placement-wait (this branch stacks on it), unchanged by slice F: Who-it-waits-on phrase, same switched-off case", |
| + "draft": "It needs a Mac that can make changes" |
| + }, |
| + { |
| + "key": "work.step.made_on", |
| + "where": "Task page, an Engineering step's line, after \"Engineering, attempt 1: done\" and a middle dot, when the attempt ran on a Mac worker (never the main runner); %s is the Mac's name", |
| + "draft": "Made on %s", |
| + "paul_sees": true |
| + }, |
| + { |
| + "key": "work.step.no_xcode", |
| + "where": "Task page, under an Engineering step made on a Mac without Xcode access (probe F5 not denied, or no Xcode): the change was not built while it was made; the Mac's checks build and test it", |
| + "draft": "Built and tested by the Mac's checks, not while making the change" |
| + }, |
| + { |
| + "key": "work.step.waiting_base", |
| + "where": "Task line, after an Engineering step's state and a middle dot, while the main runner prepares the starting point to send to the Mac (waiting_base); %s is the Mac's name", |
| + "draft": "Getting the project ready to send to %s" |
| + }, |
| + { |
| + "key": "work.decide.sandbox_held", |
| + "where": "Task decision card (Needs you: checks waiting for the Mac's sandbox), in place of \"Wait, or run them outside the sandbox?\" when the Mac holds a Claude connection, so Run outside the sandbox is not offered (D1, Paul 2026-11-28); %s is the Mac's name", |
| + "draft": "%s holds a Claude connection, so its checks can’t run outside the sandbox." |
| + }, |
| + { |
| + "key": "work.decide.unsandboxed_withdrawn", |
| + "where": "Conversation, a message from Equipo to the task's creator when their choice to run a task's checks outside the sandbox is withdrawn because a Claude connection starts on that Mac before the checks start; %s are the task's title, its link and the Mac's name (Markdown link)", |
| + "draft": "I won’t run the checks for [%s](%s) outside the sandbox after all: Claude is being added to %s, and a Mac with Claude runs checks only in its sandbox. They wait for its sandbox instead." |
| + }, |
| + { |
| + "key": "runner.engineering", |
| + "where": "Machines page, a Mac's details: the label beside whether Engineering (making changes) can run on that Mac now", |
| + "draft": "Makes changes" |
| + }, |
| + { |
| + "key": "runner.engineering.ready", |
| + "where": "Machines page, value beside \"Makes changes\": the Mac can make changes now", |
| + "draft": "Yes" |
| + }, |
| + { |
| + "key": "runner.engineering.no_connection", |
| + "where": "Machines page, value beside \"Makes changes\": no Claude connection on the Mac yet", |
| + "draft": "Not yet: it has no Claude connection" |
| + }, |
| + { |
| + "key": "runner.engineering.signed_out", |
| + "where": "Machines page, value beside \"Makes changes\": the Mac's Claude connection is signed out", |
| + "draft": "Not now: Claude is signed out on this Mac" |
| + }, |
| + { |
| + "key": "runner.engineering.limited", |
| + "where": "Machines page, value beside \"Makes changes\": the Mac's Claude connection is at its usage limit", |
| + "draft": "Not now: Claude has reached its usage limit" |
| + }, |
| + { |
| + "key": "runner.engineering.probes_pending", |
| + "where": "Machines page, value beside \"Makes changes\": the F self-checks have not all passed yet (the list below shows which)", |
| + "draft": "Not yet: its self-checks for Claude are still running" |
| + }, |
| + { |
| + "key": "runner.engineering.probes_failed", |
| + "where": "Machines page, value beside \"Makes changes\": one or more F self-checks failed (the list below shows which)", |
| + "draft": "No: some of its self-checks for Claude failed" |
| + }, |
| + { |
| + "key": "runner.engineering.cli_unpinned", |
| + "where": "Machines page, value beside \"Makes changes\": the Mac's Claude Code is not the pinned, approved version", |
| + "draft": "Not yet: it doesn't have the approved version of Claude Code" |
| + }, |
| + { |
| + "key": "runner.engineering.home_open", |
| + "where": "Machines page, value beside \"Makes changes\": the home guard failed; the line under it (runner.mac.home_open or home_open_folder) says what to change", |
| + "draft": "No: other people on this Mac can reach the runner's folders" |
| + }, |
| + { |
| + "key": "runner.engineering.tainted", |
| + "where": "Machines page, value beside \"Makes changes\": a check once ran outside the sandbox on this Mac, so it takes no Claude connection", |
| + "draft": "No: it once ran checks outside the sandbox" |
| + }, |
| + { |
| + "key": "runner.mac.holds_claude", |
| + "where": "Machines page, a Mac's card: a note while the instance holds that Mac as having a Claude credential (connecting, connected, or files and Keychain items not yet proven gone): its checks run only in its sandbox (D1)", |
| + "draft": "This Mac holds a Claude connection, or something one left, so its checks run only in its sandbox." |
| + }, |
| + { |
| + "key": "docs/mac-runner.md#make-changes-on-the-mac", |
| + "where": "docs/mac-runner.md, the section \"Make changes on the Mac\" (owner turns the switch on; the runner user fixes its home folder if the Machines page asks; the person adds Claude to the Mac and signs in)", |
| + "draft": "PLACEHOLDER: not written yet. Plan task 17 adds this section as draft copy; review it with the rest once it exists." |
| } |
| ] |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 84cb490e..8e1474f1 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -6998,10 +6998,10 @@ records remain unchanged. |
| | `places.deploy_lost` | A deploy key named %s may still be live on CARLOS without Equipo holding it. You can revoke it in the CARLOS console. | Places slice 1, Places page (Luna, codex gpt-5.6-luna, house rules) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26) | |
| | `places.deploy_none` | No deploy key yet: the first publish makes one. | Places slice 1, Places page (Luna, codex gpt-5.6-luna, house rules) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26) | |
| | `work.needs.mac_runner` | Needs you: this work needs a Mac, and no Mac runner is added yet | Copy specialist | COPY REVIEW PENDING | |
| -| `work.needs.mac_engineering` | Needs you: this change needs a Mac, and Mac runners can’t make changes yet | Copy specialist | COPY REVIEW PENDING | |
| +| `work.needs.mac_engineering` | Needs you: this change needs a Mac, and making changes on a Mac is switched off | Copy specialist | COPY REVIEW PENDING | |
| | `work.decide.mac_runner_why` | This work needs a Mac, and no Mac runner is added to your team yet. It waits instead of running on Linux. | Copy specialist | COPY REVIEW PENDING | |
| | `work.decide.mac_runner_ask` | Add a Mac runner and it starts by itself. | Copy specialist | COPY REVIEW PENDING | |
| -| `work.decide.mac_engineering_why` | This change needs a Mac. Your Mac runner can run checks but can’t make changes yet, so it waits instead of being made on Linux. | Copy specialist | COPY REVIEW PENDING | |
| +| `work.decide.mac_engineering_why` | This change needs a Mac. Making changes on a Mac is switched off for now, so it waits instead of being made on Linux. | Copy specialist | COPY REVIEW PENDING | |
| | `work.decide.mac_engineering_ask` | Leave it waiting, or cancel it. | Copy specialist | COPY REVIEW PENDING | |
| | `work.waits.mac_runner` | It needs a Mac runner | Copy specialist | COPY REVIEW PENDING | |
| | `work.waits.mac_engineering` | It needs a Mac that can make changes | Copy specialist | COPY REVIEW PENDING | |
| @@ -7038,6 +7038,22 @@ records remain unchanged. |
| | `runner.probe.F5` | Xcode inside Claude's sandbox | Copy specialist | COPY REVIEW PENDING | |
| | `runner.probe.F6` | Claude's file tools and private folders | Copy specialist | COPY REVIEW PENDING | |
| | `runner.probe.F7` | No Xcode for Claude without access | Copy specialist | COPY REVIEW PENDING | |
| +| `work.decide.sandbox_held` | %s holds a Claude connection, so its checks can’t run outside the sandbox. | Copy specialist | COPY REVIEW PENDING | |
| +| `work.decide.unsandboxed_withdrawn` | I won’t run the checks for [%s](%s) outside the sandbox after all: Claude is being added to %s, and a Mac with Claude runs checks only in its sandbox. They wait for its sandbox instead. | Copy specialist | COPY REVIEW PENDING | |
| +| `work.step.made_on` | Made on %s | Copy specialist | COPY REVIEW PENDING | |
| +| `work.step.no_xcode` | Built and tested by the Mac's checks, not while making the change | Copy specialist | COPY REVIEW PENDING | |
| +| `work.step.waiting_base` | Getting the project ready to send to %s | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering` | Makes changes | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering.ready` | Yes | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering.no_connection` | Not yet: it has no Claude connection | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering.signed_out` | Not now: Claude is signed out on this Mac | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering.limited` | Not now: Claude has reached its usage limit | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering.probes_pending` | Not yet: its self-checks for Claude are still running | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering.probes_failed` | No: some of its self-checks for Claude failed | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering.cli_unpinned` | Not yet: it doesn't have the approved version of Claude Code | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering.home_open` | No: other people on this Mac can reach the runner's folders | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.engineering.tainted` | No: it once ran checks outside the sandbox | Copy specialist | COPY REVIEW PENDING | |
| +| `runner.mac.holds_claude` | This Mac holds a Claude connection, or something one left, so its checks run only in its sandbox. | Copy specialist | COPY REVIEW PENDING | |
| ## Task 21 |
diff --git a/internal/equipo/chat/macsandbox.go b/internal/equipo/chat/macsandbox.go| index 848ec379..948ee8d9 100644 |
| --- a/internal/equipo/chat/macsandbox.go |
| +++ b/internal/equipo/chat/macsandbox.go |
| @@ -9,7 +9,8 @@ import ( |
| "amadan.net/oficina/equipo/internal/wire" |
| ) |
| -// Checks never run outside a Mac's sandbox unless a person chose it. |
| +// Checks never run outside a Mac's sandbox unless a person chose it, and |
| +// never on a Mac that holds a model credential (D1, unsandboxedAllowed). |
| // A Mac whose sandbox is not proven (its hello says other than seatbelt: |
| // probe P2 did not deny every hostile attempt, or the runner tainted |
| // itself) or that the instance holds tainted gets no checks: they wait |
| @@ -36,6 +37,88 @@ func unsandboxedChosen(s stepRecord, runner string) bool { |
| return s.UnsandboxedBy != "" && s.UnsandboxedAt != nil && s.UnsandboxedAttempt == s.Attempt && s.UnsandboxedRunner == runner && runner != "" |
| } |
| +// unsandboxedAllowed is D1 on the instance (Paul, 2026-11-28): once a Mac |
| +// holds a Claude credential, its checks run sandboxed or not at all. The |
| +// creator may choose to run checks on runner outside its sandbox only |
| +// while the instance holds no model credential there (from connecting |
| +// until the Mac says its files and Keychain items are gone). A lookup |
| +// error denies. If Paul rules otherwise, this and the worker's |
| +// unsandboxedAllowed are the change (and the warning names the Claude |
| +// connection). |
| +func (t *txn) unsandboxedAllowed(runner string) (bool, error) { |
| + held, err := t.macCredentialHeld(runner) |
| + return err == nil && !held, err |
| +} |
| + |
| +// withdrawUnsandboxed withdraws every choice to run checks on runner |
| +// outside the sandbox that an attempt not yet started there carries, now |
| +// that the instance holds runner as having a model credential (D1): the |
| +// choice is cleared and audited, an attempt already dispatched there is |
| +// taken back (it can never start; the next waits for the sandbox), and |
| +// the creator is told once, in the task's lane. An attempt that started |
| +// is left: the Mac tainted itself before it ran, so it takes no |
| +// credential. |
| +func (t *txn) withdrawUnsandboxed(runner string) error { |
| + var steps []stepRecord |
| + if err := t.db.Where("unsandboxed_runner = ? AND unsandboxed_at IS NOT NULL AND unsandboxed_attempt = attempt AND specialist = ? AND state = ? AND started_at IS NULL", runner, wire.SpecialistChecks, wire.StepQueued).Find(&steps).Error; err != nil { |
| + return err |
| + } |
| + for _, st := range steps { |
| + k, err := t.loadTask(st.TaskID) |
| + if err != nil { |
| + return err |
| + } |
| + attempt := st.Attempt |
| + st.UnsandboxedBy, st.UnsandboxedAt, st.UnsandboxedAttempt, st.UnsandboxedRunner = "", nil, 0, "" |
| + if t.s.authority.Audit != nil { |
| + if err := t.s.authority.Audit(t.db, "instance", "task.checks_unsandboxed_withdrawn", st.ID+"/"+strconv.FormatInt(attempt, 10)+"@"+runner); err != nil { |
| + return err |
| + } |
| + } |
| + if st.RunnerID == runner { |
| + // Dispatched with the choice and not started: it never starts. |
| + if err := t.withdraw(&k, &st); err != nil { |
| + return err |
| + } |
| + } else if err := t.saveStep(&st, &k); err != nil { |
| + return err |
| + } |
| + if err := t.tellUnsandboxedWithdrawn(k, st.ID, attempt, runner); err != nil { |
| + return err |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// tellUnsandboxedWithdrawn tells the task's creator, once per attempt, |
| +// that their choice to run its checks on runner outside the sandbox went |
| +// away, and why. |
| +func (t *txn) tellUnsandboxedWithdrawn(k taskRecord, step string, attempt int64, runner string) error { |
| + text := t.words("work.decide.unsandboxed_withdrawn", mdLabel(k.Title), TaskLink(k.ID), t.runnerLabel(runner)) |
| + if text == "" { |
| + return nil |
| + } |
| + idem := "unsandboxed-withdrawn:" + step + ":" + strconv.FormatInt(attempt, 10) |
| + var n int64 |
| + if err := t.db.Model(&messageRecord{}).Where("person = ? AND idempotency_key = ?", k.Creator, idem).Count(&n).Error; err != nil || n > 0 { |
| + return err |
| + } |
| + m := messageRecord{ID: newID("m_"), Person: k.Creator, IdempotencyKey: idem, Role: wire.RoleCoordinator, Text: text, Revision: 1, CreatedAt: t.now(), Lane: k.Lane} |
| + if err := t.db.Create(&m).Error; err != nil { |
| + return err |
| + } |
| + return t.messageEvent(m) |
| +} |
| + |
| +// unsandboxedOK reports whether the step's current attempt may run on |
| +// runner outside the sandbox: the creator chose it, and D1 allows it. |
| +func (t *txn) unsandboxedOK(s stepRecord, runner string) (bool, error) { |
| + if !unsandboxedChosen(s, runner) { |
| + return false, nil |
| + } |
| + return t.unsandboxedAllowed(runner) |
| +} |
| + |
| // stepRunnerLabel names where a step's attempt runs, or, while it is |
| // placed nowhere, the runner it waits for: a Mac's sandbox, a Mac's |
| // Claude connection or update (or the primary's update), the base for |
| @@ -49,9 +132,25 @@ func (t *txn) stepRunnerLabel(s stepRecord) string { |
| // stepWaitView adds to a step's view what the runner it waits for says |
| // now: while it waits for a Mac's Claude connection, that Mac's |
| -// Engineering status (read when rendered, never stored). |
| +// Engineering status (read when rendered, never stored); while checks |
| +// wait for its sandbox, whether the creator may run them outside (D1); |
| +// and the worker Engineering ran on. |
| func (t *txn) stepWaitView(sv *wire.Step, s stepRecord) { |
| sv.RunnerLabel = t.stepRunnerLabel(s) |
| + if s.Specialist == wire.SpecialistEngineering && s.RunnerID != "" && s.StartedAt != nil { |
| + // Made on a worker: named, with what it got of Xcode (never the |
| + // main runner: house rule 2026-11-07.8). |
| + if primary, err := t.s.authority.PrimaryRunner(t.db, s.Person); err == nil && primary != s.RunnerID { |
| + sv.MadeOn, sv.XcodeAccess = sv.RunnerLabel, s.XcodeAccess |
| + } |
| + } |
| + if s.Placement == wire.PlacementSandbox && s.SandboxRunner != "" && s.Specialist == wire.SpecialistChecks { |
| + // Whether its creator may run it outside the sandbox (D1); unknown |
| + // (a lookup error) offers nothing. |
| + if ok, err := t.unsandboxedAllowed(s.SandboxRunner); err == nil { |
| + sv.SandboxChoice = map[bool]string{true: wire.SandboxChoiceOffered, false: wire.SandboxChoiceHeld}[ok] |
| + } |
| + } |
| if s.Placement != wire.PlacementMacConnection || s.SandboxRunner == "" { |
| return |
| } |
| @@ -163,6 +262,12 @@ func (s *Store) RunUnsandboxed(ctx context.Context, person, id, stepID string, a |
| if !found || st.ID != stepID || st.Attempt != attempt || st.Specialist != wire.SpecialistChecks || st.State != wire.StepQueued || st.Placement != wire.PlacementSandbox || st.SandboxRunner == "" || st.Person != person { |
| return ErrNotRetryable |
| } |
| + // D1: not on a Mac the instance holds as having a model credential. |
| + if ok, err := t.unsandboxedAllowed(st.SandboxRunner); err != nil { |
| + return err |
| + } else if !ok { |
| + return ErrNotRetryable |
| + } |
| now := t.now() |
| st.UnsandboxedBy, st.UnsandboxedAt, st.UnsandboxedAttempt, st.UnsandboxedRunner = person, &now, st.Attempt, st.SandboxRunner |
| if s.authority.Audit != nil { |
diff --git a/internal/equipo/chat/runners.go b/internal/equipo/chat/runners.go| index 7460c2c7..0e2e3545 100644 |
| --- a/internal/equipo/chat/runners.go |
| +++ b/internal/equipo/chat/runners.go |
| @@ -579,7 +579,15 @@ func (t *txn) place(k *taskRecord, s *stepRecord) (placed bool, err error) { |
| var chosen, unproven *runnerInfo |
| for i := range fit { |
| r := &fit[i] |
| - if !r.sandboxProven() && !unsandboxedChosen(*s, r.ID) { |
| + ok := r.sandboxProven() |
| + if !ok { |
| + // Outside the sandbox only by the creator's choice, and never on |
| + // a Mac holding a model credential (D1). |
| + if ok, err = t.unsandboxedOK(*s, r.ID); err != nil { |
| + return false, err |
| + } |
| + } |
| + if !ok { |
| if r.Online && unproven == nil { |
| unproven = r |
| } |
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go| index 09b9024c..19af5496 100644 |
| --- a/internal/equipo/chat/tasks.go |
| +++ b/internal/equipo/chat/tasks.go |
| @@ -1241,7 +1241,12 @@ func (t *txn) dispatchStep(k *taskRecord, s *stepRecord) error { |
| cmd.RunnerID = s.RunnerID |
| // The person's recorded choice to run this attempt on this Mac |
| // outside the sandbox (protocol 7; Encode drops it for older peers). |
| - cmd.Unsandboxed = s.Specialist == wire.SpecialistChecks && unsandboxedChosen(*s, s.RunnerID) |
| + if s.Specialist == wire.SpecialistChecks { |
| + // Never on a Mac holding a model credential (D1). |
| + if cmd.Unsandboxed, err = t.unsandboxedOK(*s, s.RunnerID); err != nil { |
| + return err |
| + } |
| + } |
| // The primary may take the hub's hosted CI verdict for checks (a |
| // protocol 5 runner; Encode drops the offer for older ones). |
| cmd.HostedChecks = s.Specialist == wire.SpecialistChecks && s.RunnerID == primary |
diff --git a/internal/equipo/chat/worker_connections.go b/internal/equipo/chat/worker_connections.go| index cfea6397..285d0497 100644 |
| --- a/internal/equipo/chat/worker_connections.go |
| +++ b/internal/equipo/chat/worker_connections.go |
| @@ -137,8 +137,14 @@ func (t *txn) macCredentialHeld(runner string) (bool, error) { |
| } |
| // holdCredential sets the hold on runner, from now, if it is not set. |
| +// Setting it withdraws any choice to run checks there outside the |
| +// sandbox that a waiting attempt carries (D1, withdrawUnsandboxed). |
| func (t *txn) holdCredential(runner string) error { |
| - return t.db.Exec(`UPDATE runners SET credential_held_at = ? WHERE id = ? AND credential_held_at IS NULL`, t.now(), runner).Error |
| + res := t.db.Exec(`UPDATE runners SET credential_held_at = ? WHERE id = ? AND credential_held_at IS NULL`, t.now(), runner) |
| + if res.Error != nil || res.RowsAffected == 0 { |
| + return res.Error |
| + } |
| + return t.withdrawUnsandboxed(runner) |
| } |
| // helloHold applies a worker's hello (protocol 37) to its credential |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index bf3b766b..a8d0404e 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -1759,10 +1759,10 @@ var pageCopy = map[string]string{ |
| "work.decide.sandbox_why": "Checks are waiting for the Mac's sandbox. They run automatically once %s passes its sandbox check, unless the Mac is tainted.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "work.decide.sandbox_ask": "Wait, or run them outside the sandbox?", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "work.needs.mac_runner": "Needs you: this work needs a Mac, and no Mac runner is added yet", // COPY REVIEW PENDING |
| - "work.needs.mac_engineering": "Needs you: this change needs a Mac, and Mac runners can’t make changes yet", // COPY REVIEW PENDING |
| + "work.needs.mac_engineering": "Needs you: this change needs a Mac, and making changes on a Mac is switched off", // COPY REVIEW PENDING |
| "work.decide.mac_runner_why": "This work needs a Mac, and no Mac runner is added to your team yet. It waits instead of running on Linux.", // COPY REVIEW PENDING |
| "work.decide.mac_runner_ask": "Add a Mac runner and it starts by itself.", // COPY REVIEW PENDING |
| - "work.decide.mac_engineering_why": "This change needs a Mac. Your Mac runner can run checks but can’t make changes yet, so it waits instead of being made on Linux.", // COPY REVIEW PENDING |
| + "work.decide.mac_engineering_why": "This change needs a Mac. Making changes on a Mac is switched off for now, so it waits instead of being made on Linux.", // COPY REVIEW PENDING |
| "work.decide.mac_engineering_ask": "Leave it waiting, or cancel it.", // COPY REVIEW PENDING |
| "work.waits.mac_runner": "It needs a Mac runner", // COPY REVIEW PENDING |
| "work.waits.mac_engineering": "It needs a Mac that can make changes", // COPY REVIEW PENDING |
| @@ -2543,6 +2543,24 @@ var pageCopy = map[string]string{ |
| "work.reason.engineering_unavailable": "the Mac couldn’t start Claude safely for this change", // COPY REVIEW PENDING |
| "chat.merge.not.mac_made": "it was made on a Mac runner, so it merges only when you choose", // COPY REVIEW PENDING |
| "work.ask.mac_offline": "%s is offline. Ask again when it is back.", // COPY REVIEW PENDING |
| + |
| + // Mac Engineering (slice F, plan task 15): D1 and the views. |
| + "work.step.made_on": "Made on %s", // COPY REVIEW PENDING |
| + "work.step.no_xcode": "Built and tested by the Mac's checks, not while making the change", // COPY REVIEW PENDING |
| + "work.step.waiting_base": "Getting the project ready to send to %s", // COPY REVIEW PENDING |
| + "runner.engineering": "Makes changes", // COPY REVIEW PENDING |
| + "runner.engineering.ready": "Yes", // COPY REVIEW PENDING |
| + "runner.engineering.no_connection": "Not yet: it has no Claude connection", // COPY REVIEW PENDING |
| + "runner.engineering.signed_out": "Not now: Claude is signed out on this Mac", // COPY REVIEW PENDING |
| + "runner.engineering.limited": "Not now: Claude has reached its usage limit", // COPY REVIEW PENDING |
| + "runner.engineering.probes_pending": "Not yet: its self-checks for Claude are still running", // COPY REVIEW PENDING |
| + "runner.engineering.probes_failed": "No: some of its self-checks for Claude failed", // COPY REVIEW PENDING |
| + "runner.engineering.cli_unpinned": "Not yet: it doesn't have the approved version of Claude Code", // COPY REVIEW PENDING |
| + "runner.engineering.home_open": "No: other people on this Mac can reach the runner's folders", // COPY REVIEW PENDING |
| + "runner.engineering.tainted": "No: it once ran checks outside the sandbox", // COPY REVIEW PENDING |
| + "runner.mac.holds_claude": "This Mac holds a Claude connection, or something one left, so its checks run only in its sandbox.", // COPY REVIEW PENDING |
| + "work.decide.sandbox_held": "%s holds a Claude connection, so its checks can’t run outside the sandbox.", // COPY REVIEW PENDING |
| + "work.decide.unsandboxed_withdrawn": "I won’t run the checks for [%s](%s) outside the sandbox after all: Claude is being added to %s, and a Mac with Claude runs checks only in its sandbox. They wait for its sandbox instead.", // COPY REVIEW PENDING |
| } |
| // pasteLabels are the paste box's words, for the shared renderer, and |
diff --git a/internal/equipo/mac_engineering_views_test.go b/internal/equipo/mac_engineering_views_test.go| new file mode 100644 |
| index 00000000..148f9557 |
| --- /dev/null |
| +++ b/internal/equipo/mac_engineering_views_test.go |
| @@ -0,0 +1,195 @@ |
| +package equipo |
| + |
| +import ( |
| + "fmt" |
| + "regexp" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/setup" |
| + "amadan.net/oficina/equipo/internal/runner/mac/creds" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// TestMacEngineeringViews: every line slice F adds, where it shows. The |
| +// step names the Mac when Engineering ran on a worker (only then: house |
| +// rule 2026-11-07.8) and, without Xcode access, says the Mac's checks |
| +// build it; the waits and stops have their own words; Needs you says |
| +// when a Mac holding Claude takes the outside-the-sandbox choice away, and |
| +// what the switched-off case waits for; the Machines page shows F1 to F7, |
| +// the home guard (as whom to fix it), a Keychain item, the hold, the |
| +// taint, and whether Engineering can run there. |
| +func TestMacEngineeringViews(t *testing.T) { |
| + const me = "owner@example.com" |
| + for _, key := range []string{"work.step.made_on", "work.step.no_xcode", "work.step.waiting_base", "work.decide.sandbox_held", "work.decide.unsandboxed_withdrawn", "runner.engineering", "runner.mac.holds_claude"} { |
| + if copyText(key) == "" { |
| + t.Fatalf("no copy for %s", key) |
| + } |
| + } |
| + started := time.Now() |
| + |
| + // The step: made on a Mac, without Xcode access. |
| + eng := wire.Step{ID: "s1", Specialist: wire.SpecialistEngineering, State: wire.StepDone, Attempt: 1, Summary: "Swipe back", RunnerID: "w-studio", RunnerLabel: "Tito Studio", MadeOn: "Tito Studio", StartedAt: &started} |
| + task := wire.Task{ID: "t1", Creator: me, Stage: wire.StageInReview, Steps: []wire.Step{eng}} |
| + v := taskLineOf(task, me) |
| + if want := fmt.Sprintf(copyText("work.step.made_on"), "Tito Studio"); !strings.HasSuffix(v.Steps[0].Line, " · "+want) || v.StepLine != v.Steps[0].Line { |
| + t.Fatalf("step line %q", v.Steps[0].Line) |
| + } |
| + if v.Steps[0].Result != copyText("work.step.no_xcode") { |
| + t.Fatalf("no-Xcode line %q", v.Steps[0].Result) |
| + } |
| + // With sandboxed Xcode access: named, no such line. |
| + eng.XcodeAccess = wire.XcodeAccessSandboxed |
| + task.Steps = []wire.Step{eng} |
| + if v := taskLineOf(task, me); v.Steps[0].Result != "" || !strings.Contains(v.Steps[0].Line, "Tito Studio") { |
| + t.Fatalf("with Xcode access %+v", v.Steps[0]) |
| + } |
| + // On the main runner (the instance names none): neither line. |
| + main := wire.Step{ID: "s1", Specialist: wire.SpecialistEngineering, State: wire.StepDone, Attempt: 1, RunnerID: "r-desk", RunnerLabel: "docs-t1", StartedAt: &started} |
| + task.Steps = []wire.Step{main} |
| + if v := taskLineOf(task, me); strings.Contains(v.Steps[0].Line, "docs-t1") || v.Steps[0].Result != "" { |
| + t.Fatalf("the main runner named: %+v", v.Steps[0]) |
| + } |
| + |
| + // The wait for the Mac's base. |
| + task.Steps = []wire.Step{{ID: "s1", Specialist: wire.SpecialistEngineering, State: wire.StepQueued, Attempt: 1, Placement: wire.PlacementBase, RunnerLabel: "Tito Studio"}} |
| + task.Stage = wire.StageInProgress |
| + if v := taskLineOf(task, me); !strings.HasSuffix(v.StepLine, " · "+fmt.Sprintf(copyText("work.step.waiting_base"), "Tito Studio")) { |
| + t.Fatalf("waiting_base line %q", v.StepLine) |
| + } |
| + |
| + // The stops slice F adds: each its own words, with Try again. |
| + for _, reason := range []string{wire.ReasonBaseUnavailable, wire.ReasonWorkspaceTooLarge, wire.ReasonSecretInCandidate, wire.ReasonEngineeringUnavailable} { |
| + words := copyText("work.reason." + reason) |
| + task.Steps = []wire.Step{{ID: "s1", Specialist: wire.SpecialistEngineering, State: wire.StepFailed, Reason: reason, Terminated: true, Attempt: 1}} |
| + if v := taskLineOf(task, me); words == "" || v.StageLine != fmt.Sprintf(copyText("work.stopped"), words) || !v.Retry { |
| + t.Fatalf("%s: %q retry %v", reason, v.StageLine, v.Retry) |
| + } |
| + } |
| + |
| + // Needs you: checks waiting for a Mac that holds Claude. No choice, |
| + // and the card says why; the Mac free, the choice is offered. |
| + checks := wire.Step{ID: "c1", Specialist: wire.SpecialistChecks, State: wire.StepQueued, Attempt: 2, Placement: wire.PlacementSandbox, RunnerLabel: "Tito Studio", SandboxChoice: wire.SandboxChoiceHeld} |
| + task = wire.Task{ID: "t1", Creator: me, Stage: wire.StageInProgress, NeedsYou: wire.NeedsMacSandbox, Steps: []wire.Step{checks}} |
| + v = taskLineOf(task, me) |
| + v.Mine, v.Cancel = true, true |
| + d := decisionOf(task, v) |
| + if d.Unsandboxed != nil || !d.SandboxHeld || d.Ask != fmt.Sprintf(copyText("work.decide.sandbox_held"), "Tito Studio") { |
| + t.Fatalf("held: %+v", d) |
| + } |
| + html := decisionHTML(t, task, v) |
| + if strings.Contains(html, "data-task-unsandboxed") || !strings.Contains(html, "data-sandbox-held") { |
| + t.Fatalf("held card:\n%s", html) |
| + } |
| + checks.SandboxChoice = wire.SandboxChoiceOffered |
| + task.Steps = []wire.Step{checks} |
| + if d := decisionOf(task, v); d.Unsandboxed == nil || d.SandboxHeld || d.Ask != copyText("work.decide.sandbox_ask") { |
| + t.Fatalf("offered: %+v", d) |
| + } |
| + // Not known either way: nothing offered. |
| + checks.SandboxChoice = "" |
| + task.Steps = []wire.Step{checks} |
| + if d := decisionOf(task, v); d.Unsandboxed != nil { |
| + t.Fatalf("offered without the instance's word: %+v", d) |
| + } |
| + // The switched-off case says it is switched off, not that Macs cannot. |
| + task = wire.Task{ID: "t1", Creator: me, Stage: wire.StageInProgress, NeedsYou: wire.NeedsMacEngineering, Steps: []wire.Step{{ID: "s1", Specialist: wire.SpecialistEngineering, State: wire.StepQueued, Placement: wire.PlacementMacEngineering, Attempt: 1}}} |
| + v = taskLineOf(task, me) |
| + if v.StageLine != copyText("work.needs.mac_engineering") || !strings.Contains(v.StageLine, "switched off") { |
| + t.Fatalf("switch off: %q", v.StageLine) |
| + } |
| + if d := decisionOf(task, v); !strings.Contains(d.Why, "switched off") { |
| + t.Fatalf("switch off why %q", d.Why) |
| + } |
| + |
| + // The Machines page. |
| + if homeMode != creds.CodeHomeMode { |
| + t.Fatalf("home_mode is %q in the guard", creds.CodeHomeMode) |
| + } |
| + f := func(id, verdict string) wire.Probe { return wire.Probe{ID: id, Verdict: verdict, Detail: "synthetic"} } |
| + caps := &wire.Capabilities{Tags: []string{wire.TagMacOS, wire.TagXcode}, RunnerUser: "paulequipo", |
| + Probes: []wire.Probe{f("P2", wire.ProbeDenied), f("F1", wire.ProbeDenied), f("F2", wire.ProbeFailed), f("F3", wire.ProbeDenied), f("F4", wire.ProbePassed), f("F5", wire.ProbeSkipped), f("F6", wire.ProbeUnavailable), f("F7", wire.ProbeDenied)}, |
| + Engineering: &wire.EngineeringStatus{State: wire.EngineeringHomeOpen, Reason: creds.CodeHomeMode}, |
| + ModelHold: true, |
| + HoldingItems: []string{"Claude Code-credentials-1a2b3c4d"}} |
| + hello := wire.Hello{Platform: &wire.Platform{OS: "darwin", Arch: "arm64"}, Sandbox: wire.SandboxSeatbelt, Capabilities: caps} |
| + held, tainted := time.Now(), time.Now() |
| + rec := machineRecord{Runner: Runner{ID: "w-studio", Person: me, Label: "Tito Studio", Role: setup.RoleWorker, TaintedAt: &tainted, CredentialHeldAt: &held, Report: reportOf(hello)}} |
| + page := machinesHTML(t, machinesPage([]machineRecord{rec}, me, time.Now(), false, "")) |
| + for _, want := range []string{ |
| + `data-probe="F1" data-verdict="denied"><span>` + escape(copyText("runner.probe.F1")), |
| + `data-probe="F2" data-verdict="failed"><span>` + escape(copyText("runner.probe.F2")), |
| + `data-probe="F7" data-verdict="denied"><span>` + escape(copyText("runner.probe.F7")), |
| + escape(fmt.Sprintf(copyText("runner.mac.home_open"), "paulequipo")), |
| + escape(fmt.Sprintf(copyText("runner.mac.keychain_item"), "Claude Code-credentials-1a2b3c4d", "paulequipo")), |
| + escape(copyText("runner.mac.holds_claude")), |
| + escape(copyText("runner.tainted")), |
| + `<dt>` + escape(copyText("runner.engineering")) + `</dt><dd data-engineering="home_open">` + escape(copyText("runner.engineering.home_open")) + `</dd>`, |
| + } { |
| + if !strings.Contains(page, want) { |
| + t.Fatalf("Machines page lacks %q:\n%s", want, page) |
| + } |
| + } |
| + for _, id := range wire.EngineeringProbeIDs { |
| + if copyText("runner.probe."+id) == "" || !strings.Contains(page, `data-probe="`+id+`"`) { |
| + t.Fatalf("%s not shown", id) |
| + } |
| + } |
| + // Another guard code names the folder case; each state its own words. |
| + caps.Engineering = &wire.EngineeringStatus{State: wire.EngineeringHomeOpen, Reason: "acl"} |
| + if r := reportOf(hello); !slicesHas(r.Guards, fmt.Sprintf(copyText("runner.mac.home_open_folder"), "paulequipo")) { |
| + t.Fatalf("folder guard %+v", r.Guards) |
| + } |
| + seen := map[string]string{} |
| + for _, state := range wire.EngineeringStates { |
| + caps.Engineering = &wire.EngineeringStatus{State: state} |
| + r := reportOf(hello) |
| + if r.Engineering == "" || r.EngineeringState != state { |
| + t.Fatalf("%s: no words", state) |
| + } |
| + if other, ok := seen[r.Engineering]; ok { |
| + t.Fatalf("%s and %s say the same", state, other) |
| + } |
| + seen[r.Engineering] = state |
| + } |
| + // Without the runner user, no line names a fix as nobody; a Linux |
| + // runner or a Mac below 37 says nothing of Engineering. |
| + caps.RunnerUser, caps.Engineering = "", &wire.EngineeringStatus{State: wire.EngineeringHomeOpen, Reason: creds.CodeHomeMode} |
| + if r := reportOf(hello); len(r.Guards) != 0 || r.Engineering == "" { |
| + t.Fatalf("without a user %+v", r) |
| + } |
| + caps.Engineering, caps.HoldingItems = nil, nil |
| + if r := reportOf(hello); r.Engineering != "" || len(r.Guards) != 0 { |
| + t.Fatalf("no status %+v", r) |
| + } |
| + plain := rec |
| + plain.CredentialHeldAt, plain.TaintedAt = nil, nil |
| + if page := machinesHTML(t, machinesPage([]machineRecord{plain}, me, time.Now(), false, "")); strings.Contains(page, "data-holds-claude") || strings.Contains(page, "data-tainted") { |
| + t.Fatal("a Mac holding nothing, untainted, says otherwise") |
| + } |
| +} |
| + |
| +// decisionHTML renders the task's decision card as the task page does. |
| +func decisionHTML(t *testing.T, task wire.Task, v taskLine) string { |
| + t.Helper() |
| + v.Decision = decisionOf(task, v) |
| + var b strings.Builder |
| + if err := pages["work_task"].ExecuteTemplate(&b, "decision", map[string]any{"Task": v, "From": "task"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + return b.String() |
| +} |
| + |
| +func escape(s string) string { |
| + return regexp.MustCompile(`'`).ReplaceAllString(strings.NewReplacer("&", "&", "<", "<", ">", ">", `"`, """).Replace(s), "'") |
| +} |
| + |
| +func slicesHas(list []string, s string) bool { |
| + for _, x := range list { |
| + if x == s { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
diff --git a/internal/equipo/machines_view.go b/internal/equipo/machines_view.go| index e628270c..0de04340 100644 |
| --- a/internal/equipo/machines_view.go |
| +++ b/internal/equipo/machines_view.go |
| @@ -66,7 +66,10 @@ type machineRow struct { |
| Raw, Version, Protocol, Tags, Enrolled, EnrolledBy, Fingerprint string |
| Report *setup.RunnerReport |
| Tainted, Removing, Revoked bool |
| - Revision int64 |
| + // HoldsClaude: the instance holds this Mac as having a model |
| + // credential (D1: its checks run only in its sandbox). |
| + HoldsClaude bool |
| + Revision int64 |
| // Record is the runner itself, for its supervised history. |
| Record Runner |
| } |
| @@ -100,7 +103,7 @@ func machinesPage(records []machineRecord, me string, now time.Time, adding bool |
| func machineRowOf(r machineRecord, now time.Time) machineRow { |
| f := r.Facts |
| - row := machineRow{ID: r.ID, Name: r.Label, Person: r.Person, Fingerprint: r.MachineKeyHash, Report: r.Report, Tainted: r.TaintedAt != nil, Removing: r.RemovingAt != nil, Revoked: r.RevokedAt != nil, Revision: r.Revision, Record: r.Runner, Mark: "monitor"} |
| + row := machineRow{ID: r.ID, Name: r.Label, Person: r.Person, Fingerprint: r.MachineKeyHash, Report: r.Report, Tainted: r.TaintedAt != nil, HoldsClaude: r.CredentialHeldAt != nil, Removing: r.RemovingAt != nil, Revoked: r.RevokedAt != nil, Revision: r.Revision, Record: r.Runner, Mark: "monitor"} |
| if f.Label != "" { |
| row.Name = f.Label |
| } |
diff --git a/internal/equipo/runners.go b/internal/equipo/runners.go| index 9cfbb4c5..7cd25bfc 100644 |
| --- a/internal/equipo/runners.go |
| +++ b/internal/equipo/runners.go |
| @@ -6,6 +6,7 @@ import ( |
| "crypto/rand" |
| "encoding/json" |
| "errors" |
| + "fmt" |
| "time" |
| "amadan.net/oficina/equipo/internal/equipo/setup" |
| @@ -345,17 +346,56 @@ func runnerReport(tx *gorm.DB, id string) (*setup.RunnerReport, error) { |
| return nil, nil |
| } |
| var h wire.Hello |
| - if json.Unmarshal([]byte(hellos[0]), &h) != nil || h.Platform == nil { |
| + if json.Unmarshal([]byte(hellos[0]), &h) != nil { |
| return nil, nil |
| } |
| + return reportOf(h), nil |
| +} |
| + |
| +// homeMode is the home guard's code for a home folder others can open |
| +// (creds.CodeHomeMode): its fix is chmod 700 ~. |
| +const homeMode = "home_mode" |
| + |
| +// reportOf is what a stored hello says for the Machines page (nil |
| +// without a platform). |
| +func reportOf(h wire.Hello) *setup.RunnerReport { |
| + if h.Platform == nil { |
| + return nil |
| + } |
| r := &setup.RunnerReport{Platform: h.Platform.OS + "/" + h.Platform.Arch, Sandbox: h.Sandbox} |
| if h.Capabilities != nil && wire.ValidCapabilities(*h.Capabilities) == nil { |
| for _, p := range h.Capabilities.Probes { |
| r.Probes = append(r.Probes, setup.RunnerProbe{ID: p.ID, Verdict: p.Verdict, Detail: probeDetail(p.Detail)}) |
| } |
| r.Unproven = unprovenText(h.Capabilities.Unproven) |
| + macGuards(r, *h.Capabilities) |
| + } |
| + return r |
| +} |
| + |
| +// macGuards adds what a Mac at 37 says of Engineering: whether it can run |
| +// there, in words, and what keeps Claude off it (the home guard, a |
| +// Keychain item) with as whom to change it. A line naming the fix is |
| +// left out while the runner user is unknown. |
| +func macGuards(r *setup.RunnerReport, c wire.Capabilities) { |
| + e := c.Engineering |
| + if e == nil { |
| + return |
| + } |
| + r.Engineering, r.EngineeringState = copyText("runner.engineering."+e.State), e.State |
| + if c.RunnerUser == "" { |
| + return |
| + } |
| + if e.State == wire.EngineeringHomeOpen { |
| + key := "runner.mac.home_open_folder" |
| + if e.Reason == homeMode { |
| + key = "runner.mac.home_open" |
| + } |
| + r.Guards = append(r.Guards, fmt.Sprintf(copyText(key), c.RunnerUser)) |
| + } |
| + for _, item := range c.HoldingItems { |
| + r.Guards = append(r.Guards, fmt.Sprintf(copyText("runner.mac.keychain_item"), item, c.RunnerUser)) |
| } |
| - return r, nil |
| } |
| // probeDetail is a probe's detail as the Machines page shows it: a |
diff --git a/internal/equipo/setup/runner_models.go b/internal/equipo/setup/runner_models.go| index 5c51e55d..49284c34 100644 |
| --- a/internal/equipo/setup/runner_models.go |
| +++ b/internal/equipo/setup/runner_models.go |
| @@ -36,6 +36,11 @@ type RunnerReport struct { |
| // Unproven says, in words, why an attempt's end there can never be |
| // proven ("" for none). |
| Unproven string |
| + // Engineering says, in words, whether Engineering can run there now |
| + // (a Mac at protocol 37; "" otherwise), EngineeringState its state; |
| + // Guards say what keeps Claude off it and as whom to change it. |
| + Engineering, EngineeringState string |
| + Guards []string |
| } |
| // RunnerProbe is one self-probe: P1 to P7, its verdict and detail. |
diff --git a/internal/equipo/templates/runners.html b/internal/equipo/templates/runners.html| index 1ef34e14..d6e1579e 100644 |
| --- a/internal/equipo/templates/runners.html |
| +++ b/internal/equipo/templates/runners.html |
| @@ -14,12 +14,15 @@ |
| <dt>{{copy "machines.protocol"}}</dt><dd>{{with $m.Protocol}}{{.}}{{else}}<span equipo-mach-unknown>{{copy "machines.not_reported"}}</span>{{end}}</dd> |
| {{with $m.Tags}}<dt>{{copy "machines.tags"}}</dt><dd>{{.}}</dd>{{end}} |
| {{with $m.Report}}{{with .Sandbox}}<dt>{{copy "runner.checks_run"}}</dt><dd data-sandbox="{{.}}">{{copy (printf "runner.sandbox.%s" .)}}</dd>{{end}}{{end}} |
| +{{with $m.Report}}{{with .Engineering}}<dt>{{copy "runner.engineering"}}</dt><dd data-engineering="{{$m.Report.EngineeringState}}">{{.}}</dd>{{end}}{{end}} |
| {{with $m.Enrolled}}<dt>{{copy "machines.enrolled"}}</dt><dd>{{.}}</dd>{{end}} |
| {{with $m.EnrolledBy}}<dt>{{copy "machines.enrolled_by"}}</dt><dd>{{.}}</dd>{{end}} |
| {{if .Others}}<dt>{{copy "runner.person"}}</dt><dd>{{$m.Person}}</dd>{{end}} |
| <dt>{{copy "runner.fingerprint"}}</dt><dd equipo-mach-key>{{$m.Fingerprint}}</dd> |
| </dl> |
| {{if $m.Tainted}}<p equipo-mach-note data-tainted>{{copy "runner.tainted"}}</p>{{end}} |
| +{{if $m.HoldsClaude}}<p equipo-mach-note data-holds-claude>{{copy "runner.mac.holds_claude"}}</p>{{end}} |
| +{{with $m.Report}}{{range .Guards}}<p equipo-mach-note data-guard>{{.}}</p>{{end}}{{end}} |
| {{with $m.Report}}{{with .Unproven}}<p equipo-mach-note data-unproven>{{.}}</p>{{end}}{{end}} |
| {{with $m.Report}}{{if .Probes}}<h4 equipo-mach-sub>{{copy "runner.probes"}}</h4> |
| <ul equipo-probes>{{range .Probes}}<li data-probe="{{.ID}}" data-verdict="{{.Verdict}}"><span>{{copy (printf "runner.probe.%s" .ID)}}</span> <span equipo-probe-verdict>{{copy (printf "runner.verdict.%s" .Verdict)}}</span>{{with .Detail}} <span equipo-quiet>{{.}}</span>{{end}}</li>{{end}}</ul>{{end}}{{end}} |
diff --git a/internal/equipo/templates/work_parts.html b/internal/equipo/templates/work_parts.html| index feb29522..ec6dbe32 100644 |
| --- a/internal/equipo/templates/work_parts.html |
| +++ b/internal/equipo/templates/work_parts.html |
| @@ -36,7 +36,7 @@ |
| {{define "decision"}}{{$t := .Task}}{{with $t.Decision}}<div equipo-decision{{if eq $.From "task"}} id="decide"{{end}}{{with .Tone}} data-tone="{{.}}"{{end}} data-need="{{.Need}}" data-decision="{{$t.ID}}"> |
| {{if $.Head}}{{template "mono" $t.Mono}}<div equipo-d-title><a href="/tasks/{{$t.ID}}">{{$t.Title}}</a><div equipo-quiet>{{template "placement-chip" $t}} · {{template "source" $t}}</div></div>{{end}} |
| <p equipo-d-why>{{.Why}}</p> |
| -{{with .Ask}}<p equipo-d-ask>{{.}}</p>{{end}}{{if .Link}}<p equipo-quiet data-direction-line>{{with .LinkText}}{{.}} {{end}}<a equipo-link href="{{.Link}}" rel="noopener noreferrer" target="_blank" data-direction-link>{{.LinkLabel}}</a>{{with .AltLink}} <a equipo-link href="{{.}}" rel="noopener noreferrer" target="_blank" data-direction-branch>{{$t.Decision.AltLabel}}</a>{{end}}</p>{{end}}{{with .Said}}<p equipo-quiet data-triage-said>{{.}}</p>{{end}}{{with .Failed}}<p equipo-quiet data-triage-failed>{{.}}</p>{{end}}{{with .Recommend}}<p equipo-quiet data-triage-recommend>{{.}}</p>{{end}} |
| +{{with .Ask}}<p equipo-d-ask{{if $t.Decision.SandboxHeld}} data-sandbox-held{{end}}>{{.}}</p>{{end}}{{if .Link}}<p equipo-quiet data-direction-line>{{with .LinkText}}{{.}} {{end}}<a equipo-link href="{{.Link}}" rel="noopener noreferrer" target="_blank" data-direction-link>{{.LinkLabel}}</a>{{with .AltLink}} <a equipo-link href="{{.}}" rel="noopener noreferrer" target="_blank" data-direction-branch>{{$t.Decision.AltLabel}}</a>{{end}}</p>{{end}}{{with .Said}}<p equipo-quiet data-triage-said>{{.}}</p>{{end}}{{with .Failed}}<p equipo-quiet data-triage-failed>{{.}}</p>{{end}}{{with .Recommend}}<p equipo-quiet data-triage-recommend>{{.}}</p>{{end}} |
| <div equipo-d-actions>{{if .CopyContinue}}<form method="post" action="/conversation/tasks/{{$t.ID}}/continue-without-copy"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-copy-continue>{{copy "copy.continue"}}</button></form>{{end}}{{with .Card}}<form method="post" action="/conversation/cards/{{.ID}}/answer"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="task" value="{{$t.ID}}">{{if $.Task.Decision.Note}}<textarea rst-input name="note" maxlength="1000" rows="2" aria-label="{{copy "chat.card.direction_note"}}" placeholder="{{copy "chat.card.direction_note"}}" data-direction-note></textarea>{{end}}{{range $.Task.Decision.Choices}}<button equipo-btn{{if .Primary}} data-primary{{end}} type="submit" name="choice" value="{{.Value}}" data-merge-choice="{{.Value}}">{{.Label}}</button>{{end}}</form>{{end}}{{if .Fold}}<form method="post" action="/tasks/{{$t.ID}}/duplicate"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="of" value="{{$t.Dup.ID}}"><button equipo-btn data-primary type="submit" data-task-duplicate>{{copy "work.decide.fold"}}</button></form>{{end}}{{if .Recover}}<form method="post" action="/conversation/tasks/{{$t.ID}}/recover"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-task-recover>{{copy "work.recover"}}</button></form>{{end}}{{with .Unsandboxed}}<details equipo-mach-confirm data-unsandboxed><summary equipo-btn>{{copy "work.decide.unsandboxed"}}</summary><div><p>{{.Warning}}</p><form method="post" action="/conversation/tasks/{{$t.ID}}/unsandboxed"><input type="hidden" name="from" value="{{$.From}}"><input type="hidden" name="step" value="{{.Step}}"><input type="hidden" name="attempt" value="{{.Attempt}}"><button equipo-btn data-danger type="submit" data-task-unsandboxed>{{copy "work.decide.unsandboxed_confirm"}}</button></form></div></details>{{end}}{{if .Retry}}<form method="post" action="/conversation/tasks/{{$t.ID}}/retry"><input type="hidden" name="from" value="{{$.From}}"><button {{if .Fold}}equipo-link{{else}}equipo-btn data-primary{{end}} type="submit" data-task-retry>{{copy "work.retry"}}</button></form>{{end}}{{if .Round}}<form method="post" action="/conversation/tasks/{{$t.ID}}/round"><input type="hidden" name="from" value="{{$.From}}"><button equipo-btn data-primary type="submit" data-task-round>{{copy "work.decide.round"}}</button></form>{{end}}{{if .Talk}}<a equipo-btn href="/conversation?about={{$t.ID}}" data-ask-coordinator>{{copy "work.decide.ask_coordinator"}}</a>{{end}}{{if .Cancel}}<form method="post" action="/conversation/tasks/{{$t.ID}}/cancel"><input type="hidden" name="from" value="{{$.From}}"><button equipo-link type="submit" data-task-cancel>{{copy "work.decide.cancel"}}</button></form>{{end}}{{with .Hint}}<span equipo-quiet>{{.}}</span>{{end}}<span equipo-d-quiet>{{if .AddClaude}}<a equipo-link href="{{.AddClaude}}" data-add-claude>{{.AddClaudeLabel}}</a>{{end}}{{if .Mac}}<a equipo-link href="/conversation/settings/machines/add" data-set-up-mac>{{copy "work.decide.mac_set_up"}}</a>{{end}}<a equipo-link href="/conversation?about={{$t.ID}}" data-ask-about>{{copy "work.ask_about"}}</a></span></div> |
| </div>{{end}}{{end}} |
| {{define "star-toggle"}}{{$p := .P}}<form method="post" action="/projects/{{$p.ID}}/star" equipo-star-form><input type="hidden" name="starred" value="{{if $p.Star.On}}0{{else}}1{{end}}"><input type="hidden" name="from" value="{{.From}}"><button type="submit" equipo-star{{if $p.Star.On}} aria-pressed="true"{{if $p.Star.Auto}} data-auto{{end}}{{else}} aria-pressed="false"{{end}} aria-label="{{$p.Star.Label}}" title="{{$p.Star.Who}}" data-star-toggle>{{icon "star"}}</button></form>{{end}} |
diff --git a/internal/equipo/work_pages.go b/internal/equipo/work_pages.go| index bf757474..722b435d 100644 |
| --- a/internal/equipo/work_pages.go |
| +++ b/internal/equipo/work_pages.go |
| @@ -169,6 +169,18 @@ func taskLineOf(t wire.Task, viewer string) taskLine { |
| // The model a metered step ran on (§16.7). |
| l.Line += " · " + fmt.Sprintf(copyText("work.step.model"), s.Model) |
| } |
| + if s.MadeOn != "" { |
| + // Engineering on a worker, named (only then: house rule |
| + // 2026-11-07.8); without Xcode access the Mac's checks build it. |
| + l.Line += " · " + fmt.Sprintf(copyText("work.step.made_on"), s.MadeOn) |
| + if s.XcodeAccess != wire.XcodeAccessSandboxed { |
| + l.Result = copyText("work.step.no_xcode") |
| + } |
| + } |
| + if s.Specialist == wire.SpecialistEngineering && s.State == wire.StepQueued && s.Placement == wire.PlacementBase && s.RunnerLabel != "" { |
| + // The main runner resolves the Mac's starting point first. |
| + l.Line += " · " + fmt.Sprintf(copyText("work.step.waiting_base"), s.RunnerLabel) |
| + } |
| if s.State == wire.StepDone { |
| switch s.Specialist { |
| case wire.SpecialistChecks: |
diff --git a/internal/equipo/work_views.go b/internal/equipo/work_views.go| index d5ce8eac..a6a11216 100644 |
| --- a/internal/equipo/work_views.go |
| +++ b/internal/equipo/work_views.go |
| @@ -164,7 +164,10 @@ type decisionView struct { |
| AddClaude, AddClaudeLabel string |
| // Unsandboxed offers the creator Run outside the sandbox, behind a |
| // confirm with its warning, for checks waiting for a Mac's sandbox. |
| + // SandboxHeld: not offered, because that Mac holds Claude (D1); Ask |
| + // says so. |
| Unsandboxed *unsandboxedOffer |
| + SandboxHeld bool |
| } |
| // unsandboxedOffer is Run outside the sandbox for one attempt of a |
| @@ -838,7 +841,12 @@ func decisionOf(t wire.Task, v taskLine) *decisionView { |
| // Mac's sandbox is proven. Only the creator may choose otherwise. |
| s := t.Steps[len(t.Steps)-1] |
| d.Why, d.Ask, d.Cancel = fmt.Sprintf(copyText("work.decide.sandbox_why"), s.RunnerLabel), copyText("work.decide.sandbox_ask"), v.Cancel |
| - if v.Mine && s.RunnerLabel != "" { |
| + switch { |
| + case s.SandboxChoice == wire.SandboxChoiceHeld: |
| + // D1: the Mac holds Claude, so its checks run sandboxed or not |
| + // at all. Nothing to choose; the card says why. |
| + d.Ask, d.SandboxHeld = fmt.Sprintf(copyText("work.decide.sandbox_held"), s.RunnerLabel), true |
| + case v.Mine && s.RunnerLabel != "" && s.SandboxChoice == wire.SandboxChoiceOffered: |
| d.Unsandboxed = &unsandboxedOffer{Step: s.ID, Attempt: s.Attempt, Warning: fmt.Sprintf(copyText("work.decide.unsandboxed_warning"), s.RunnerLabel)} |
| } |
| } |
diff --git a/internal/runner/thin/mac.go b/internal/runner/thin/mac.go| index c552e5b8..229d73a4 100644 |
| --- a/internal/runner/thin/mac.go |
| +++ b/internal/runner/thin/mac.go |
| @@ -56,8 +56,11 @@ func (m macGate) Verify(id string) bool { return m.g.Verify(id) } |
| // runner is tainted for good (macTaint): it never labels a check |
| // sandboxed again. |
| type macChecks struct { |
| - probes *macProbes |
| - taint *macTaint |
| + probes *macProbes |
| + taint *macTaint |
| + // creds is the Mac's credential operations: its hold decides whether |
| + // a check may run outside the sandbox at all (unsandboxedAllowed). |
| + creds *macCreds |
| srt string |
| sandboxed, unproven, bare *mac.Gate |
| } |
| @@ -78,22 +81,42 @@ func (m *macChecks) pick() *mac.Gate { |
| func (m *macChecks) Sandbox() string { return m.pick().Sandbox } |
| // Run runs a check outside the sandbox (bare, or srt unproven) only when |
| -// the person chose that for this attempt (unsandboxedChosen); otherwise |
| -// it runs nothing, taints nothing and says sandbox_unproven, which the |
| -// instance turns back into waiting for the Mac's sandbox. It taints the |
| -// runner before a check runs outside the sandbox: what it runs could |
| -// change anything this user may. |
| +// the person chose that for this attempt (unsandboxedChosen) and the Mac |
| +// holds no model credential (unsandboxedAllowed); otherwise it runs |
| +// nothing, taints nothing and says sandbox_unproven, which the instance |
| +// turns back into waiting for the Mac's sandbox. It taints the runner |
| +// before a check runs outside the sandbox: what it runs could change |
| +// anything this user may. |
| func (m *macChecks) Run(ctx context.Context, attempt, dir string, argv []string, limit time.Duration, record func(string) error) gateResult { |
| g := m.pick() |
| if g.Sandbox != wire.SandboxSeatbelt { |
| - if !unsandboxedChosen(ctx) { |
| - return gateResult{reason: wire.ReasonSandboxUnproven, terminated: true, sandbox: g.Sandbox} |
| + refused := gateResult{reason: wire.ReasonSandboxUnproven, terminated: true, sandbox: g.Sandbox} |
| + if !unsandboxedChosen(ctx) || !m.unsandboxedAllowed(ctx) { |
| + return refused |
| } |
| m.taint.Set() |
| + // Read again now the taint is set: a token store checks the taint |
| + // in its own turn, so one that got past that check before it was |
| + // set is on record here (its attempt holds from its start), and |
| + // the check never shares the Mac with it. The Mac stays tainted. |
| + if !m.unsandboxedAllowed(ctx) { |
| + return refused |
| + } |
| } |
| return macGate{g}.Run(ctx, attempt, dir, argv, limit, record) |
| } |
| +// unsandboxedAllowed is D1 on the worker (Paul, 2026-11-28): no check |
| +// runs outside the sandbox here while this Mac holds, or may hold, a |
| +// model credential (its durable hold: an attempt connecting, a sign-out |
| +// owed, a binding, anything in the accounts root, a Keychain record). |
| +// Before its connections open nothing says it holds none, so it refuses. |
| +// If Paul rules otherwise, this and the instance's unsandboxedAllowed |
| +// are the change (with the warning naming the Claude connection). |
| +func (m *macChecks) unsandboxedAllowed(ctx context.Context) bool { |
| + return m.creds != nil && m.creds.held != nil && !m.creds.held(ctx) |
| +} |
| + |
| // unsandboxedKey carries an attempt's recorded choice to run outside the |
| // sandbox from its dispatch (DispatchCommand.Unsandboxed, protocol 7) to |
| // the gate that runs it. |
| @@ -747,8 +770,8 @@ func newMacHost(c runner.Config, o Options) (h *macHost, err error) { |
| h.probes.log = o.Logger |
| h.probes.fingerprint = func() string { return toolFingerprint(h.paths.InstallDir, h.tools) } |
| h.taint = loadTaint(filepath.Join(c.StateDir, "tainted")) |
| - h.checks = &macChecks{probes: h.probes, taint: h.taint, srt: h.tools.SRT, sandboxed: gate(h.tools.SRT, wire.SandboxSeatbelt), unproven: gate(h.tools.SRT, wire.SandboxNone), bare: gate("", wire.SandboxNone)} |
| h.creds = h.newCreds(c) |
| + h.checks = &macChecks{probes: h.probes, taint: h.taint, creds: h.creds, srt: h.tools.SRT, sandboxed: gate(h.tools.SRT, wire.SandboxSeatbelt), unproven: gate(h.tools.SRT, wire.SandboxNone), bare: gate("", wire.SandboxNone)} |
| h.caps = func(ctx context.Context) wire.Capabilities { |
| // The first gathering is the one the first hello waits on: each |
| // command at info. Later ones (hourly, each check's gate) at debug. |
| @@ -775,10 +798,14 @@ func newMacHost(c runner.Config, o Options) (h *macHost, err error) { |
| } |
| // credentialCaps says why the Mac can take no Claude connection, if its |
| -// guards say so (maccreds.go), and looks again for a Keychain item it |
| -// found. |
| +// guards say so (maccreds.go), and as which user, and looks again for a |
| +// Keychain item it found. |
| func (h *macHost) credentialCaps(ctx context.Context, caps *wire.Capabilities) { |
| caps.Engineering = h.creds.status() |
| + if wire.ValidRunnerUser(h.creds.user) { |
| + // As whom the Machines page says to close a folder. |
| + caps.RunnerUser = h.creds.user |
| + } |
| if h.creds.Held() { |
| h.creds.settle(ctx, false) |
| } |
diff --git a/internal/runner/thin/mac_test.go b/internal/runner/thin/mac_test.go| index 1f45ce98..a345c7b1 100644 |
| --- a/internal/runner/thin/mac_test.go |
| +++ b/internal/runner/thin/mac_test.go |
| @@ -436,7 +436,7 @@ func TestMacCounterfeitSRT(t *testing.T) { |
| func TestMacTaintIsSticky(t *testing.T) { |
| x := newProbeRig(t) |
| file := filepath.Join(t.TempDir(), "tainted") |
| - m := &macChecks{probes: x.p, taint: loadTaint(file), srt: "/x/srt", sandboxed: &mac.Gate{Sandbox: wire.SandboxSeatbelt}, unproven: &mac.Gate{SRT: "/x/srt", Sandbox: wire.SandboxNone}, bare: &mac.Gate{Sandbox: wire.SandboxNone, Env: []string{"PATH=/usr/bin:/bin"}}} |
| + m := &macChecks{probes: x.p, taint: loadTaint(file), creds: holdsNothing(), srt: "/x/srt", sandboxed: &mac.Gate{Sandbox: wire.SandboxSeatbelt}, unproven: &mac.Gate{SRT: "/x/srt", Sandbox: wire.SandboxNone}, bare: &mac.Gate{Sandbox: wire.SandboxNone, Env: []string{"PATH=/usr/bin:/bin"}}} |
| tree := filepath.Join(t.TempDir(), "tree") |
| if err := os.MkdirAll(tree, 0700); err != nil { |
| t.Fatal(err) |
diff --git a/internal/runner/thin/maccreds.go b/internal/runner/thin/maccreds.go| index 2cc623ad..33643d23 100644 |
| --- a/internal/runner/thin/maccreds.go |
| +++ b/internal/runner/thin/maccreds.go |
| @@ -100,6 +100,9 @@ type macCreds struct { |
| user string |
| uid int |
| log *slog.Logger |
| + // held is the worker's credential hold (Connector.credentialHeld), |
| + // set once its connections open (openWorkerConns); nil until then. |
| + held func(context.Context) bool |
| } |
| // newCreds is h's credential operations for c. |
diff --git a/internal/runner/thin/sandbox_consent_test.go b/internal/runner/thin/sandbox_consent_test.go| index e181a39e..317bc435 100644 |
| --- a/internal/runner/thin/sandbox_consent_test.go |
| +++ b/internal/runner/thin/sandbox_consent_test.go |
| @@ -22,7 +22,7 @@ func TestMacChecksRefuseUnprovenWithoutConsent(t *testing.T) { |
| t.Fatal(err) |
| } |
| newChecks := func(t *testing.T, probes *macProbes) *macChecks { |
| - return &macChecks{probes: probes, taint: loadTaint(filepath.Join(t.TempDir(), "tainted")), srt: "/x/srt", sandboxed: &mac.Gate{Sandbox: wire.SandboxSeatbelt}, unproven: &mac.Gate{SRT: "/x/srt", Sandbox: wire.SandboxNone}, bare: &mac.Gate{Sandbox: wire.SandboxNone, Env: []string{"PATH=/usr/bin:/bin"}}} |
| + return &macChecks{probes: probes, taint: loadTaint(filepath.Join(t.TempDir(), "tainted")), creds: holdsNothing(), srt: "/x/srt", sandboxed: &mac.Gate{Sandbox: wire.SandboxSeatbelt}, unproven: &mac.Gate{SRT: "/x/srt", Sandbox: wire.SandboxNone}, bare: &mac.Gate{Sandbox: wire.SandboxNone, Env: []string{"PATH=/usr/bin:/bin"}}} |
| } |
| run := func(ctx context.Context, m *macChecks) (gateResult, int) { |
| recorded := 0 |
| @@ -63,6 +63,12 @@ func TestMacChecksRefuseUnprovenWithoutConsent(t *testing.T) { |
| } |
| } |
| +// holdsNothing is the credential operations of a Mac that holds no |
| +// model credential: its hold is known, and clear (D1 allows a choice). |
| +func holdsNothing() *macCreds { |
| + return &macCreds{held: func(context.Context) bool { return false }} |
| +} |
| + |
| // consentGate is a gate that records whether each run carried the |
| // person's choice, and refuses like an unproven Mac without it. |
| type consentGate struct { |
diff --git a/internal/runner/thin/unsandboxed_d1_test.go b/internal/runner/thin/unsandboxed_d1_test.go| new file mode 100644 |
| index 00000000..9d5b4edc |
| --- /dev/null |
| +++ b/internal/runner/thin/unsandboxed_d1_test.go |
| @@ -0,0 +1,150 @@ |
| +//go:build testbuild |
| + |
| +package thin |
| + |
| +import ( |
| + "context" |
| + "os" |
| + "path/filepath" |
| + "sync/atomic" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/fakeclaude" |
| + "amadan.net/oficina/equipo/internal/runner/mac" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// D1 (Paul, 2026-11-28): once a Mac holds a Claude credential, its checks |
| +// run sandboxed or not at all. The worker refuses a dispatch that carries |
| +// the creator's choice to run outside the sandbox (sandbox_unproven: |
| +// nothing run, nothing tainted) for as long as its own durable hold is |
| +// set: a token file, a connection in progress, or only a Keychain item a |
| +// refused sign-in left, across a restart. Once the hold is gone the |
| +// choice runs, outside the sandbox, and taints as before. |
| +func TestWorkerRefusesUnsandboxedWithToken(t *testing.T) { |
| + r := newDarwinRig(t) |
| + w := r.worker() |
| + tree := filepath.Join(t.TempDir(), "tree") |
| + if err := os.MkdirAll(tree, 0o700); err != nil { |
| + t.Fatal(err) |
| + } |
| + // An unproven Mac (no probe report: the bare gate), its checks |
| + // against the worker's real credential operations. |
| + checks := func(creds *macCreds) *macChecks { |
| + return &macChecks{probes: newProbeRig(t).p, taint: loadTaint(filepath.Join(t.TempDir(), "tainted")), creds: creds, srt: "/x/srt", sandboxed: &mac.Gate{Sandbox: wire.SandboxSeatbelt}, unproven: &mac.Gate{SRT: "/x/srt", Sandbox: wire.SandboxNone}, bare: &mac.Gate{Sandbox: wire.SandboxNone, Env: []string{"PATH=/usr/bin:/bin"}}} |
| + } |
| + run := func(m *macChecks) (gateResult, int) { |
| + recorded := 0 |
| + res := m.Run(withUnsandboxed(context.Background(), true), "checks-t-1", tree, []string{"/bin/true"}, time.Minute, func(string) error { recorded++; return nil }) |
| + return res, recorded |
| + } |
| + refused := func(what string, m *macChecks) { |
| + t.Helper() |
| + if m.pick() != m.bare { |
| + t.Fatalf("%s: rig: not the bare gate", what) |
| + } |
| + res, recorded := run(m) |
| + if res.reason != wire.ReasonSandboxUnproven || !res.terminated || recorded != 0 || m.taint.Tainted() { |
| + t.Fatalf("%s: ran outside the sandbox: %+v recorded %d tainted %v", what, res, recorded, m.taint.Tainted()) |
| + } |
| + } |
| + |
| + // Its connections not opened yet: nothing says the Mac holds none. |
| + refused("no hold known", checks(&macCreds{})) |
| + refused("no credential operations", checks(nil)) |
| + |
| + // A Mac that never held a credential: the choice runs, and taints. |
| + fresh := checks(r.m) |
| + if res, recorded := run(fresh); res.reason != "" || res.sandbox != wire.SandboxNone || recorded == 0 || !fresh.taint.Tainted() { |
| + t.Fatalf("a Mac holding nothing refused the choice: %+v recorded %d", res, recorded) |
| + } |
| + |
| + // A token file. |
| + home, end := r.paste(w.connector, "c1", fakeclaude.Token("b@example.com")) |
| + if end.State != wire.ConnHealthy { |
| + t.Fatalf("rig: paste %+v", end) |
| + } |
| + if _, err := os.Stat(filepath.Join(home, provider.TokenFile)); err != nil { |
| + t.Fatalf("rig: no token file: %v", err) |
| + } |
| + refused("token file", checks(r.m)) |
| + // Signed out: the files go, the hold with them. |
| + if err := w.connector.Disconnect(r.ctx, "f-out-1", wire.DisconnectCommand{Connection: "c1", Person: connPerson, LocalID: filepath.Base(home), RunnerID: tokenRunner}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if entries, _ := os.ReadDir(r.root); len(entries) != 0 || w.held(r.ctx) { |
| + t.Fatalf("rig: still held after the sign-out: %d entries", len(entries)) |
| + } |
| + |
| + // A sign-in in progress, refused, leaving only a Keychain item; then |
| + // a restart. |
| + r.kc.set(true) |
| + link, _ := r.signIn(w.connector, "s1") |
| + if link == "" || !w.held(r.ctx) { |
| + t.Fatal("rig: no sign-in in progress") |
| + } |
| + refused("connecting", checks(r.m)) |
| + item := r.own(r.signInDir()) |
| + r.kc.add(item) |
| + r.codeIn(w.connector, "s1", link, "c@example.com") |
| + if end := r.ended("s1"); end.Reason != "provider_refused" { |
| + t.Fatalf("rig: refused sign-in %+v", end) |
| + } |
| + if entries, _ := os.ReadDir(r.root); len(entries) != 0 || len(r.m.keychain.Residue()) == 0 { |
| + t.Fatalf("rig: not only the Keychain item left: %d entries, residue %v", len(entries), r.m.keychain.Residue()) |
| + } |
| + refused("Keychain residue", checks(r.m)) |
| + again := darwinRigAt(t, r.dir) |
| + again.kc = r.kc |
| + again.m.keychain.List, again.m.keychain.Delete = r.kc.list, r.kc.delete |
| + again.kc.r = again |
| + w2 := openWorkerConns(again.cfg, again.workerOptions(0), again.state, runnerproto.RunnerCredential{RunnerID: tokenRunner, Person: connPerson}, again.m, nil, nil) |
| + refused("Keychain residue after a restart", checks(again.m)) |
| + |
| + // The item goes; the restart's settling clears the hold: the choice |
| + // runs outside the sandbox, and taints. |
| + r.kc.set(false) |
| + w2.connector.spawn = func(f func()) { f() } |
| + if err := w2.start(again.ctx); err != nil { |
| + t.Fatal(err) |
| + } |
| + if w2.held(again.ctx) { |
| + t.Fatal("rig: still held once everything is gone") |
| + } |
| + free := checks(again.m) |
| + if res, recorded := run(free); res.reason != "" || res.sandbox != wire.SandboxNone || recorded == 0 || !free.taint.Tainted() { |
| + t.Fatalf("no hold: the choice did not run: %+v recorded %d tainted %v", res, recorded, free.taint.Tainted()) |
| + } |
| + |
| + // A connection that starts as the check starts: the hold is read |
| + // again once the taint is set, so a store that got past the taint's |
| + // check before it was set never shares the Mac with the check. |
| + var reads atomic.Int32 |
| + racing := checks(&macCreds{held: func(context.Context) bool { return reads.Add(1) > 1 }}) |
| + res, recorded := run(racing) |
| + if res.reason != wire.ReasonSandboxUnproven || recorded != 0 || reads.Load() < 2 { |
| + t.Fatalf("a hold that came as the check started: %+v recorded %d reads %d", res, recorded, reads.Load()) |
| + } |
| +} |
| + |
| +// The capability report names the Mac's runner user, so the Machines |
| +// page can say as whom to close a folder; a name the wire would refuse |
| +// is left out, never sent to sink the report. |
| +func TestMacCapsNameTheRunnerUser(t *testing.T) { |
| + r := newDarwinRig(t) |
| + h := &macHost{creds: r.m, taint: r.m.taint} |
| + caps := wire.Capabilities{} |
| + h.credentialCaps(r.ctx, &caps) |
| + if !wire.ValidRunnerUser(r.user) || caps.RunnerUser != r.user || wire.ValidCapabilities(caps) != nil { |
| + t.Fatalf("runner user %q, want %q", caps.RunnerUser, r.user) |
| + } |
| + r.m.user = "not a name" |
| + caps = wire.Capabilities{} |
| + h.credentialCaps(r.ctx, &caps) |
| + if caps.RunnerUser != "" || wire.ValidCapabilities(caps) != nil { |
| + t.Fatalf("an invalid runner user sent: %q", caps.RunnerUser) |
| + } |
| +} |
diff --git a/internal/runner/thin/worker_conns.go b/internal/runner/thin/worker_conns.go| index e7999d43..74eb23e8 100644 |
| --- a/internal/runner/thin/worker_conns.go |
| +++ b/internal/runner/thin/worker_conns.go |
| @@ -71,6 +71,9 @@ func openWorkerConns(c runner.Config, o Options, state *State, bearer runnerprot |
| return err |
| } |
| w.conns = conns |
| + // The Mac's checks read this hold before any runs outside the |
| + // sandbox (macChecks.unsandboxedAllowed, D1). |
| + m.held = w.held |
| w.connector = &Connector{Runner: c, State: state, Conns: conns, Root: m.paths.AccountsRoot, Owners: withPerson(coordinatorPersons(c)(), bearer.Person), Notify: notify, Logger: o.Logger, Limit: o.ConnectLimit, RunnerID: bearer.RunnerID, Mac: m} |
| if key, err := runner.ReadMachineKey(c.StateDir); err == nil { |
| if keys, err := sealbox.FromEd25519(key); err == nil { |
diff --git a/internal/thintest/mac_views_contract_test.go b/internal/thintest/mac_views_contract_test.go| new file mode 100644 |
| index 00000000..a68be022 |
| --- /dev/null |
| +++ b/internal/thintest/mac_views_contract_test.go |
| @@ -0,0 +1,86 @@ |
| +package thintest |
| + |
| +import ( |
| + "html" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// macMade runs w's Engineering attempt d to done with a summary, and the |
| +// primary publishes it. |
| +func (r *runnersRig) macMade(w *peer, d *wire.DispatchCommand, cand string) { |
| + r.t.Helper() |
| + if !w.lease(d.StepID, d.Attempt) { |
| + r.t.Fatal("start refused") |
| + } |
| + w.send(wire.FrameStep, wire.StepReport{TaskID: d.TaskID, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepRunning, BaseSHA: d.BaseSHA, Findings: []wire.Finding{}}) |
| + w.send(wire.FrameStep, wire.StepReport{TaskID: d.TaskID, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepRunning, CandidateSHA: cand, Phase: wire.OutcomeCommitted, Findings: []wire.Finding{}}) |
| + _, body := w.expect(wire.FrameSendPack) |
| + h := body.(*wire.SendPackCommand).Transfer |
| + w.send(wire.FrameStep, wire.StepReport{TaskID: d.TaskID, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepDone, CandidateSHA: cand, Summary: "Swipe back added.", Termination: true, TerminationKind: wire.TerminationProcessGroup, Findings: []wire.Finding{}}) |
| + w.send(wire.FrameBlob, chunk(h, []byte("PACK commit"))) |
| + r.fromPrimary(wire.FrameBlob) |
| + pub := r.fromPrimary(wire.FramePublish).(*wire.PublishCommand) |
| + r.primary.send(wire.FramePublished, wire.PublishedReport{Publication: pub.Publication, TaskID: d.TaskID, StepID: d.StepID, Attempt: d.Attempt, CandidateSHA: cand, Pushed: true}) |
| +} |
| + |
| +// TestContractStepSaysMadeOn: the instance names the worker an |
| +// Engineering attempt ran on (never before it starts, never the main |
| +// runner) with what it got of Xcode, and the task page says "Made on" |
| +// the Mac and, without Xcode access, that the Mac's checks build it. |
| +// While the base is prepared the step says which Mac it waits for. |
| +func TestContractStepSaysMadeOn(t *testing.T) { |
| + r := newMacRig(t) |
| + w := r.newMacEngineer("Tito Studio", wire.EngineeringReady) |
| + task := r.macTask("iOS made") |
| + if s := r.newestEngineering(task); s.Placement != wire.PlacementBase || s.RunnerLabel != "Tito Studio" || s.MadeOn != "" { |
| + t.Fatalf("waiting for its base %+v", s) |
| + } |
| + r.based(r.prepared(task), sha(1)) |
| + _, body := w.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + r.engineeringTransfer(w, d) |
| + if s := r.newestEngineering(task); s.MadeOn != "" { |
| + t.Fatalf("named before it started %+v", s) |
| + } |
| + r.macMade(w, d, sha(0xc1)) |
| + s := r.newestEngineering(task) |
| + if s.MadeOn != "Tito Studio" || s.XcodeAccess != "" { |
| + t.Fatalf("made on %+v", s) |
| + } |
| + page := html.UnescapeString(r.get(r.inst.Cookie(), "/tasks/"+task, 200)) |
| + for _, want := range []string{"Made on Tito Studio", "Built and tested by the Mac's checks, not while making the change"} { |
| + if !strings.Contains(page, want) { |
| + t.Fatalf("task page lacks %q:\n%s", want, page) |
| + } |
| + } |
| + |
| + // F5 denied: sandboxed Xcode access, so no such line. |
| + r = newMacRig(t) |
| + w = r.newMacEngineerAt("Tito Studio", wire.EngineeringReady, wire.ProtocolMacEngineering, true) |
| + task = r.macTask("iOS xcode") |
| + r.based(r.prepared(task), sha(2)) |
| + _, body = w.expect(wire.FrameDispatch) |
| + d = body.(*wire.DispatchCommand) |
| + r.engineeringTransfer(w, d) |
| + r.macMade(w, d, sha(0xc2)) |
| + if s := r.newestEngineering(task); s.MadeOn != "Tito Studio" || s.XcodeAccess != wire.XcodeAccessSandboxed { |
| + t.Fatalf("with Xcode access %+v", s) |
| + } |
| + if page := html.UnescapeString(r.get(r.inst.Cookie(), "/tasks/"+task, 200)); !strings.Contains(page, "Made on Tito Studio") || strings.Contains(page, "not while making the change") { |
| + t.Fatalf("with Xcode access, the page:\n%s", page) |
| + } |
| +} |
| + |
| +// Engineering on the main runner names no machine. |
| +func TestContractMainRunnerNotNamed(t *testing.T) { |
| + r := newRunnersRig(t) |
| + task, _ := r.candidate("Linux change", false) |
| + for _, s := range r.task(task).Steps { |
| + if s.Specialist == wire.SpecialistEngineering && (s.MadeOn != "" || s.StartedAt == nil) { |
| + t.Fatalf("the main runner named, or the rig did not start it: %+v", s) |
| + } |
| + } |
| +} |
diff --git a/internal/thintest/unsandboxed_d1_contract_test.go b/internal/thintest/unsandboxed_d1_contract_test.go| new file mode 100644 |
| index 00000000..b265fb9c |
| --- /dev/null |
| +++ b/internal/thintest/unsandboxed_d1_contract_test.go |
| @@ -0,0 +1,244 @@ |
| +package thintest |
| + |
| +import ( |
| + "net/url" |
| + "strconv" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/sealbox" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// D1 (Paul, 2026-11-28): once a Mac holds a Claude credential, its checks |
| +// run sandboxed or not at all. While the instance holds a Mac as having |
| +// one (from connecting until the Mac says its files and Keychain items |
| +// are gone), the task page offers no Run outside the sandbox for checks |
| +// waiting for that Mac and says why; the choice is refused if posted, and |
| +// nothing is dispatched outside the sandbox. A choice already recorded on |
| +// a waiting attempt is withdrawn when a connection starts, and its |
| +// creator is told. |
| + |
| +// d1Mac is a Mac worker at 37 whose sandbox is not proven (hello sandbox |
| +// none), with its seal key, saying its whole inventory. |
| +func (r *runnersRig) d1Mac(label string) (*peer, sealbox.Keys) { |
| + r.t.Helper() |
| + keys := sealKeys(r.t) |
| + w := r.newMacEngineer(label, wire.EngineeringNoConnection) |
| + w.heartbeat(d1Hello(keys, nil)) |
| + return w, keys |
| +} |
| + |
| +// d1Hello is that Mac's full hello, sandbox none; change sets its hold. |
| +func d1Hello(keys sealbox.Keys, change func(*wire.Capabilities), conns ...wire.HeldConnection) wire.Hello { |
| + h := inventoryHello(keys.PublicString(), change, conns...) |
| + h.Sandbox = wire.SandboxNone |
| + return h |
| +} |
| + |
| +// sandboxChoice is what the task page shows its creator for checks |
| +// waiting for the Mac's sandbox: the offer, or the line saying the Mac |
| +// holds Claude; and the step's word on it. |
| +func (r *runnersRig) sandboxChoice(task string) (offered, held bool, choice string) { |
| + r.t.Helper() |
| + page := r.get(r.inst.Cookie(), "/tasks/"+task, 200) |
| + return strings.Contains(page, "data-task-unsandboxed"), strings.Contains(page, "data-sandbox-held"), r.checksStep(task).SandboxChoice |
| +} |
| + |
| +// chooseUnsandboxed posts the creator's Run outside the sandbox for the |
| +// checks step's attempt, as the page's confirm does. |
| +func (r *runnersRig) chooseUnsandboxed(task string, s wire.Step) int { |
| + r.t.Helper() |
| + status, _ := r.post(r.inst.Cookie(), "/conversation/tasks/"+task+"/unsandboxed", url.Values{"from": {"task"}, "step": {s.ID}, "attempt": {strconv.FormatInt(s.Attempt, 10)}}) |
| + return status |
| +} |
| + |
| +func TestUnsandboxedNotOfferedWithCredential(t *testing.T) { |
| + r := newRunnersRig(t) |
| + w, keys := r.d1Mac("Tito Studio") |
| + wid := w.fr.Welcome.RunnerID |
| + task, _ := r.candidate("iOS swipe", true) |
| + s := r.waitsForSandbox(w, task, 1) |
| + machinesSay := func() bool { |
| + t.Helper() |
| + return strings.Contains(r.get(r.inst.Cookie(), "/conversation/settings/machines", 200), "data-holds-claude") |
| + } |
| + offeredNow := func(when string) { |
| + t.Helper() |
| + if offered, held, choice := r.sandboxChoice(task); !offered || held || choice != wire.SandboxChoiceOffered || machinesSay() { |
| + t.Fatalf("%s: offered %v held line %v choice %q machines page says held %v", when, offered, held, choice, machinesSay()) |
| + } |
| + } |
| + notOffered := func(when string) { |
| + t.Helper() |
| + if !r.heldNow(wid) { |
| + t.Fatalf("%s: rig: the instance does not hold the Mac", when) |
| + } |
| + if offered, held, choice := r.sandboxChoice(task); offered || !held || choice != wire.SandboxChoiceHeld || !machinesSay() { |
| + t.Fatalf("%s: offered %v held line %v choice %q machines page says held %v", when, offered, held, choice, machinesSay()) |
| + } |
| + if status := r.chooseUnsandboxed(task, r.checksStep(task)); status != 409 { |
| + t.Fatalf("%s: the choice was taken: %d", when, status) |
| + } |
| + w.none(wire.FrameDispatch, 100*time.Millisecond) |
| + var by string |
| + if err := r.inst.DB.Writer().QueryRow("SELECT coalesce(unsandboxed_by, '') FROM chat_steps WHERE id = ?", r.checksStep(task).ID).Scan(&by); err != nil || by != "" { |
| + t.Fatalf("%s: a choice recorded: %q %v", when, by, err) |
| + } |
| + } |
| + offeredNow("nothing held") |
| + |
| + // Connecting, before and after the Mac has the frame. |
| + a, err := r.client.Connect(r.ctx, wire.Connect{Provider: wire.ProviderClaude, RunnerID: wid}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + notOffered("connecting") |
| + w.expect(wire.FrameConnect) |
| + w.heartbeat(d1Hello(keys, nil)) |
| + notOffered("connecting, the frame taken") |
| + |
| + // A failed connect that left a Keychain item. |
| + w.send(wire.FrameConnection, wire.ConnectionReport{Connection: a.ID, Person: Owner, Provider: wire.ProviderClaude, State: wire.ConnError, Reason: "provider_refused"}) |
| + w.heartbeat(d1Hello(keys, func(c *wire.Capabilities) { |
| + c.ModelHold, c.HoldingItems = true, []string{"Claude Code-credentials-1a2b3c4d"} |
| + })) |
| + notOffered("a failed connect's Keychain item") |
| + |
| + // The Mac says everything is gone: offered again. |
| + w.heartbeat(d1Hello(keys, nil)) |
| + offeredNow("the item gone") |
| + |
| + // Connected, then signed out: held until the Mac says the files are |
| + // gone too. |
| + b, err := r.client.Connect(r.ctx, wire.Connect{Provider: wire.ProviderClaude, Kind: wire.KindToken, RunnerID: wid}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + w.expect(wire.FrameConnect) |
| + w.send(wire.FrameConnection, wire.ConnectionReport{Connection: b.ID, Person: Owner, LocalID: "claude-1", Provider: wire.ProviderClaude, State: wire.ConnHealthy, Label: "w@example.com"}) |
| + held := wire.HeldConnection{LocalID: "claude-1", Person: Owner, Provider: wire.ProviderClaude, Kind: wire.KindToken, Label: "w@example.com", State: wire.ConnHealthy} |
| + w.heartbeat(d1Hello(keys, func(c *wire.Capabilities) { c.ModelHold = true }, held)) |
| + notOffered("connected") |
| + if _, err := r.client.SignOut(r.ctx, b.ID); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.expect(wire.FrameDisconnect) |
| + w.heartbeat(d1Hello(keys, func(c *wire.Capabilities) { c.ModelHold = true })) |
| + notOffered("signed out, its files not yet gone") |
| + w.heartbeat(d1Hello(keys, nil)) |
| + offeredNow("its files gone") |
| + |
| + // Free again, the creator's choice runs as before. |
| + if status := r.chooseUnsandboxed(task, s); status != 303 { |
| + t.Fatalf("the choice once nothing is held: %d", status) |
| + } |
| + _, body := w.expect(wire.FrameDispatch) |
| + if d := body.(*wire.DispatchCommand); !d.Unsandboxed || d.Attempt != 1 { |
| + t.Fatalf("dispatch %+v", d) |
| + } |
| +} |
| + |
| +// TestUnsandboxedChoiceWithdrawnOnConnect: the creator chose to run the |
| +// checks outside the sandbox and the attempt has not started on the Mac |
| +// when a Claude connection starts there. The choice is withdrawn (its |
| +// dispatch can no longer start, the next attempt waits for the sandbox |
| +// with no choice on it, audited) and the creator is told once, in the |
| +// task's lane. When the hold lifts the choice does not come back: the |
| +// creator may choose again. |
| +func TestUnsandboxedChoiceWithdrawnOnConnect(t *testing.T) { |
| + r := newRunnersRig(t) |
| + w, keys := r.d1Mac("Tito Studio") |
| + wid := w.fr.Welcome.RunnerID |
| + task, _ := r.candidate("iOS swipe", true) |
| + s := r.waitsForSandbox(w, task, 1) |
| + if status := r.chooseUnsandboxed(task, s); status != 303 { |
| + t.Fatalf("choose: %d", status) |
| + } |
| + _, body := w.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + if !d.Unsandboxed { |
| + t.Fatalf("rig: dispatch %+v", d) |
| + } |
| + |
| + a, err := r.client.Connect(r.ctx, wire.Connect{Provider: wire.ProviderClaude, RunnerID: wid}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if w.lease(d.StepID, d.Attempt) { |
| + t.Fatal("the withdrawn choice's attempt started") |
| + } |
| + next := r.waitsForSandbox(w, task, 2) |
| + if next.SandboxChoice != wire.SandboxChoiceHeld { |
| + t.Fatalf("next attempt %+v", next) |
| + } |
| + var by string |
| + if err := r.inst.DB.Writer().QueryRow("SELECT coalesce(unsandboxed_by, '') FROM chat_steps WHERE id = ?", s.ID).Scan(&by); err != nil || by != "" { |
| + t.Fatalf("the choice stayed recorded: %q %v", by, err) |
| + } |
| + var audits int |
| + if err := r.inst.DB.Writer().QueryRow("SELECT count(*) FROM audit_events WHERE kind = 'task.checks_unsandboxed_withdrawn'").Scan(&audits); err != nil || audits != 1 { |
| + t.Fatalf("withdrawal audited %d times: %v", audits, err) |
| + } |
| + told := func() int { |
| + t.Helper() |
| + var n int |
| + if err := r.inst.DB.Writer().QueryRow("SELECT count(*) FROM chat_messages WHERE person = ? AND role = ? AND text LIKE ? AND text LIKE ?", Owner, wire.RoleCoordinator, "%Tito Studio%", "%"+task+"%").Scan(&n); err != nil { |
| + t.Fatal(err) |
| + } |
| + return n |
| + } |
| + if told() != 1 { |
| + t.Fatalf("the creator was told %d times", told()) |
| + } |
| + |
| + // The Mac takes the frame, the attempt ends, the hold lifts: nothing |
| + // runs by itself outside the sandbox, nobody is told again, and the |
| + // choice is the creator's to make again. |
| + w.expect(wire.FrameConnect) |
| + w.send(wire.FrameConnection, wire.ConnectionReport{Connection: a.ID, Person: Owner, Provider: wire.ProviderClaude, State: wire.ConnError, Reason: "provider_refused"}) |
| + w.heartbeat(d1Hello(keys, nil)) |
| + w.none(wire.FrameDispatch, 150*time.Millisecond) |
| + if r.heldNow(wid) { |
| + t.Fatal("rig: still held") |
| + } |
| + if offered, _, choice := r.sandboxChoice(task); !offered || choice != wire.SandboxChoiceOffered { |
| + t.Fatalf("not offered again once free: %v %q", offered, choice) |
| + } |
| + if told() != 1 { |
| + t.Fatalf("told again: %d", told()) |
| + } |
| +} |
| + |
| +// TestUnsandboxedChoiceNotDispatchedWhileHeld: placement and the dispatch |
| +// read D1 themselves. A choice on the current attempt with the hold |
| +// already set (written by an instance from before D1, say: nothing here |
| +// withdrew it) never sends the checks to the Mac outside its sandbox; |
| +// once the Mac's sandbox is proven they go, without the choice. |
| +func TestUnsandboxedChoiceNotDispatchedWhileHeld(t *testing.T) { |
| + r := newRunnersRig(t) |
| + w, keys := r.d1Mac("Tito Studio") |
| + wid := w.fr.Welcome.RunnerID |
| + task, _ := r.candidate("iOS swipe", true) |
| + s := r.waitsForSandbox(w, task, 1) |
| + if _, err := r.inst.DB.Writer().Exec("UPDATE chat_steps SET unsandboxed_by = ?, unsandboxed_at = ?, unsandboxed_attempt = ?, unsandboxed_runner = ? WHERE id = ?", Owner, time.Now().UTC(), s.Attempt, wid, s.ID); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := r.inst.DB.Writer().Exec("UPDATE runners SET credential_held_at = ? WHERE id = ?", time.Now().UTC(), wid); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.heartbeat(d1Hello(keys, func(c *wire.Capabilities) { c.ModelHold = true })) |
| + if err := r.inst.Store.Chat().Place(r.ctx); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.waitsForSandbox(w, task, 1) |
| + // Proven now: placed, sandboxed, the choice not carried. |
| + h := d1Hello(keys, func(c *wire.Capabilities) { c.ModelHold = true }) |
| + h.Sandbox = wire.SandboxSeatbelt |
| + w.heartbeat(h) |
| + _, body := w.expect(wire.FrameDispatch) |
| + if d := body.(*wire.DispatchCommand); d.StepID != s.ID || d.Unsandboxed { |
| + t.Fatalf("dispatch while held %+v", d) |
| + } |
| +} |
diff --git a/internal/wire/mac_engineering.go b/internal/wire/mac_engineering.go| index 3467d685..6883ab16 100644 |
| --- a/internal/wire/mac_engineering.go |
| +++ b/internal/wire/mac_engineering.go |
| @@ -230,6 +230,22 @@ func validProbeVerdict(id, verdict string) bool { |
| return slices.Contains(ProbeIDs, id) && (verdict != ProbeDenied || id == "P2") |
| } |
| +// A checks step's SandboxChoice while it waits for a Mac's sandbox |
| +// (Step.SandboxChoice): the creator may choose to run it outside, or may |
| +// not because the Mac holds a model credential (D1, Paul 2026-11-28: |
| +// once a Mac holds one, its checks run sandboxed or not at all). |
| +const ( |
| + SandboxChoiceOffered = "offered" |
| + SandboxChoiceHeld = "credential_held" |
| +) |
| + |
| +// runnerUser is a macOS short name: what a Mac worker's runner user may |
| +// be called. |
| +var runnerUser = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_.-]{0,31}$`) |
| + |
| +// ValidRunnerUser reports whether name may be a Mac's runner user. |
| +func ValidRunnerUser(name string) bool { return runnerUser.MatchString(name) } |
| + |
| func validEngineeringStatus(s EngineeringStatus) bool { |
| return slices.Contains(EngineeringStates, s.State) && (s.State != EngineeringReady || s.Reason == "") |
| } |
| @@ -253,7 +269,7 @@ const ( |
| ) |
| // WithoutMacEngineering drops a hello's Engineering status, Unproven, the |
| -// credential hold, the inventory mark, F probes and a Mac's claude tag |
| +// credential hold, the runner user, the inventory mark, F probes and a Mac's claude tag |
| // (in new values; the caller's are untouched). The runner's first hello |
| // on a connection goes out before the welcome names the protocol, and an |
| // older instance's ValidCapabilities refuses an F probe; the runner sends |
| @@ -269,11 +285,11 @@ func WithoutMacEngineering(h *Hello) bool { |
| // A slice F Mac (it says its Engineering status) says claude only at |
| // 37: an older instance would take it for a Mac that can run Claude. |
| macClaude := h.Platform != nil && h.Platform.OS == "darwin" && c.Engineering != nil && slices.Contains(c.Tags, TagClaude) |
| - if c.Engineering == nil && c.Unproven == "" && !c.ModelHold && c.HoldingItems == nil && !slices.ContainsFunc(c.Probes, isF) && !macClaude { |
| + if c.Engineering == nil && c.Unproven == "" && !c.ModelHold && c.HoldingItems == nil && c.RunnerUser == "" && !slices.ContainsFunc(c.Probes, isF) && !macClaude { |
| return inventory |
| } |
| out := *c |
| - out.Engineering, out.Unproven, out.ModelHold, out.HoldingItems = nil, "", false, nil |
| + out.Engineering, out.Unproven, out.ModelHold, out.HoldingItems, out.RunnerUser = nil, "", false, nil, "" |
| if macClaude { |
| out.Tags = slices.DeleteFunc(slices.Clone(c.Tags), func(t string) bool { return t == TagClaude }) |
| } |
diff --git a/internal/wire/mac_engineering_test.go b/internal/wire/mac_engineering_test.go| index 9942c2d9..4163ebe7 100644 |
| --- a/internal/wire/mac_engineering_test.go |
| +++ b/internal/wire/mac_engineering_test.go |
| @@ -593,3 +593,23 @@ func TestMacEngineeringWorkerReasonsKnown(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// A Mac worker names its runner user (a macOS short name, nothing else) |
| +// at 37 only, so the Machines page can say as whom to change a folder; |
| +// WithoutMacEngineering drops it, alone or with the rest. |
| +func TestRunnerUserInCapabilities(t *testing.T) { |
| + for _, name := range []string{"paulequipo", "equipo-paul", "_runner", "a.b"} { |
| + if err := wire.ValidCapabilities(wire.Capabilities{RunnerUser: name}); err != nil { |
| + t.Errorf("%q refused: %v", name, err) |
| + } |
| + } |
| + for _, name := range []string{"Users/paulequipo", "/Users/x", "a b", "x=y", "-x", "1x", strings.Repeat("a", 33), "pau\nl", "paulé"} { |
| + if wire.ValidCapabilities(wire.Capabilities{RunnerUser: name}) == nil { |
| + t.Errorf("%q taken as a runner user", name) |
| + } |
| + } |
| + h := wire.Hello{Platform: &wire.Platform{OS: "darwin", Arch: "arm64"}, Capabilities: &wire.Capabilities{Tags: []string{wire.TagMacOS}, RunnerUser: "paulequipo"}} |
| + if !wire.WithoutMacEngineering(&h) || h.Capabilities.RunnerUser != "" { |
| + t.Fatalf("below 37 the runner user stays: %+v", h.Capabilities) |
| + } |
| +} |
diff --git a/internal/wire/runners.go b/internal/wire/runners.go| index 327c3bb3..0460ac2d 100644 |
| --- a/internal/wire/runners.go |
| +++ b/internal/wire/runners.go |
| @@ -340,6 +340,10 @@ type Capabilities struct { |
| // (their services) that hold it, at most MaxHoldingItems. |
| ModelHold bool `json:"model_hold,omitempty"` |
| HoldingItems []string `json:"holding_items,omitempty"` |
| + // RunnerUser (ProtocolMacEngineering) is a Mac worker's runner user, |
| + // its short name, so the Machines page can say as whom to change a |
| + // folder (ValidRunnerUser). |
| + RunnerUser string `json:"runner_user,omitempty"` |
| } |
| // UnprovenRecordIncomplete: an attempt's turn record was not complete |
| @@ -458,7 +462,7 @@ func ValidCapabilities(c Capabilities) error { |
| if e := c.Engineering; e != nil && !validEngineeringStatus(*e) { |
| return ErrCapabilities |
| } |
| - if len(c.HoldingItems) > MaxHoldingItems { |
| + if len(c.HoldingItems) > MaxHoldingItems || c.RunnerUser != "" && !ValidRunnerUser(c.RunnerUser) { |
| return ErrCapabilities |
| } |
| if err := checkStrings(reflect.ValueOf(c)); err != nil { |
diff --git a/internal/wire/tasks.go b/internal/wire/tasks.go| index 51cbf432..9843662f 100644 |
| --- a/internal/wire/tasks.go |
| +++ b/internal/wire/tasks.go |
| @@ -320,6 +320,18 @@ type Step struct { |
| // EngineeringStatus is, while Placement is waiting_mac_connection, the |
| // Engineering status the Mac it waits for (RunnerLabel) says now. |
| EngineeringStatus *EngineeringStatus `json:"engineering_status,omitempty"` |
| + // SandboxChoice is, while Placement is waiting_sandbox, whether the |
| + // task's creator may run the checks outside the Mac's sandbox |
| + // (SandboxChoiceOffered) or not, because the instance holds that Mac |
| + // as having a model credential (SandboxChoiceHeld); absent when |
| + // neither is known. |
| + SandboxChoice string `json:"sandbox_choice,omitempty"` |
| + // MadeOn names the worker an Engineering attempt ran on, when it is |
| + // not the person's main runner; XcodeAccess is what that attempt got |
| + // of Xcode's services (sandboxed, or "" for none: the Mac's checks |
| + // build and test the change). |
| + MadeOn string `json:"made_on,omitempty"` |
| + XcodeAccess string `json:"xcode_access,omitempty"` |
| // ChecksSandbox: seatbelt or none (ran outside the sandbox) for a |
| // worker's checks; absent for the primary's. |
| ChecksSandbox string `json:"checks_sandbox,omitempty"` |