oficina / equipo Public

chat: run waiting Mac checks again when a Mac that fits arrives

A task at Ready to merge whose newest checks ended not run (needs_macos)
waited for nothing: Wait for a Mac only closed the card. Now, when a
runner enrols or comes back online (Connect, and a heartbeat after being
offline), recheckMac places the checks again on the exact candidate,
through nextStep and the usual placement, for each of the person's tasks
that is approved, still at that candidate, with no merge of it, and
whose declared needs the arriving Mac covers (macOS, the step's needs,
not refused, protocol 2, a primary that can relay).

Once per candidate per runner: the new checks step records the runner
(chat_steps.recheck_by, migration 0060), so a reconnect runs nothing.
The open merge card is withdrawn and merge_asked cleared, so an outcome
that still needs a decision asks afresh. A pass grants merge eligibility
in advance (slice 4c then merges with no tap); a failure takes the fix
round.

work.decide.mac_hint is a plain line again, accepted by delegation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 72d48ab3aaa54a8ba6310fa506394caf768ad817 parent a069080
12 files changed, +339 −9
  • .rastrillo/budgets.txt +2 −2
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +9 −1
  • internal/equipo/chat/macrecheck.go +90 −0
  • internal/equipo/chat/review.go +4 −0
  • internal/equipo/chat/runner.go +8 −2
  • internal/equipo/chat/runners.go +7 −1
  • internal/equipo/chat/tasks.go +3 −0
  • internal/equipo/copy.go +1 −1
  • internal/equipo/migrations/0060_thin_mac_recheck.sql +1 −0
  • internal/equipo/migrations/schema.sql +1 −1
  • internal/thintest/macrecheck_contract_test.go +212 −0
  • internal/thintest/projects_pages_test.go +1 −1
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index e283c55d..01305a54 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -49,7 +49,7 @@ perf GET /api/v1/notebook skip Thin v1 person API: bearer-only JSON for devices;
perf GET /api/v1/thinking skip Thin v1 person API: bearer-only JSON for devices; the browser reads thinking words on /settings/thinking.
perf GET /api/v1/tasks skip Thin v1 person API: bearer-only JSON for devices; the browser reads tasks through /tasks.
perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads a task through /tasks/{id}.
-size internal/equipo/chat 12450 - Spend 1 merged onto Projects UX: measured 12376 with both. Spend 1 adds a task's spend from its usage rows (TaskSpend, about 60 lines) and the usage rows' round; measured 12047. Projects UX adds per-person project stars with the auto-star reconciliation, the person's and the coordinator's star_project (stars.go, about 210 lines) and the project's own repository in its view; measured 12206. Claude's sign-in by a link adds the code route beside the token's in SendSecret, the sign-in prompt and the kind it becomes (about 40 lines); measured 11933. Mac runners slices A and B add per-runner mailboxes, placement, withdrawal, the offline rule, the runners view, transfers and publication (runners.go, transfers.go, about 1100 lines). Composer attachments add uploads, the message link, the mailbox relay with chunk frames hydrated from the stored file, and serving (attachments.go, attachments_http.go, about 330 lines); the link and relay run inside the send and dispatch transactions, so they live beside them; sniffing and stripping are pure, in internal/attach. Measured 10292. Merged with UX1 thinking words (f2602d3), measured 9801. Housekeeping slice 1 adds the loop's ledger and state machine, the housekeeping principal's checks inside the shared store functions, reservations, Pause, quiet hours, the digest, claim recovery and the API (housekeeping.go, housekeeping_control.go, housekeeping_http.go, about 1,350 lines); the checks must run inside the store's transactions, so they live beside them; the detectors themselves are pure, in internal/equipo/housekeeping. Measured 9637. Thin v1 UX1 thinking words adds the per-person set and its API (thinking.go, about 100 lines); measured 8305. Connections slice 1 review round 2: the mutation ledger matches record_task by subject only and refuses an ambiguous call with the earlier operations, the preference and forget (about 120 lines); measured 8236. Thin v1 UX1 round 3 adds Equipo combining duplicate tasks reversibly (duplicates.go: detection, the in-transaction fold checks, fold, Undo, about 400 lines) and headlines on findings and steps (headline.go); measured 7898. Connections slice 1 adds connection records from hello and attempts, the connect mailbox, the API, usage rows and the turn's mutation ledger (connections.go and tools.go, about 600 lines); measured 7400 after merging UX1. Thin v1 UX1 adds step activity lines, duplicates and their fold, the coordinator at work on a task, project facts from the runner catalog and open merge cards for the pages (inner.go, about 330 lines); measured 6610 with slice 4c's review fixes. Thin v1 slice 4c adds the merge policy, the merge card, the rebase round and duplicate reports (merge.go, about 380 lines). Thin v1 instance core: conversation, projects, tasks, review and, from slice 4b, questions to the specialists (questions.go, about 470 lines) share one store, transaction and event log; splitting would export the transaction internals. Measured 5514 source lines; revisit at the slice 7 sweep.
+size internal/equipo/chat 12550 - Mac recheck runs a waiting task's needs_macos checks again when a Mac that fits arrives (macrecheck.go, about 90 lines); measured 12485. Spend 1 merged onto Projects UX: measured 12376 with both. Spend 1 adds a task's spend from its usage rows (TaskSpend, about 60 lines) and the usage rows' round; measured 12047. Projects UX adds per-person project stars with the auto-star reconciliation, the person's and the coordinator's star_project (stars.go, about 210 lines) and the project's own repository in its view; measured 12206. Claude's sign-in by a link adds the code route beside the token's in SendSecret, the sign-in prompt and the kind it becomes (about 40 lines); measured 11933. Mac runners slices A and B add per-runner mailboxes, placement, withdrawal, the offline rule, the runners view, transfers and publication (runners.go, transfers.go, about 1100 lines). Composer attachments add uploads, the message link, the mailbox relay with chunk frames hydrated from the stored file, and serving (attachments.go, attachments_http.go, about 330 lines); the link and relay run inside the send and dispatch transactions, so they live beside them; sniffing and stripping are pure, in internal/attach. Measured 10292. Merged with UX1 thinking words (f2602d3), measured 9801. Housekeeping slice 1 adds the loop's ledger and state machine, the housekeeping principal's checks inside the shared store functions, reservations, Pause, quiet hours, the digest, claim recovery and the API (housekeeping.go, housekeeping_control.go, housekeeping_http.go, about 1,350 lines); the checks must run inside the store's transactions, so they live beside them; the detectors themselves are pure, in internal/equipo/housekeeping. Measured 9637. Thin v1 UX1 thinking words adds the per-person set and its API (thinking.go, about 100 lines); measured 8305. Connections slice 1 review round 2: the mutation ledger matches record_task by subject only and refuses an ambiguous call with the earlier operations, the preference and forget (about 120 lines); measured 8236. Thin v1 UX1 round 3 adds Equipo combining duplicate tasks reversibly (duplicates.go: detection, the in-transaction fold checks, fold, Undo, about 400 lines) and headlines on findings and steps (headline.go); measured 7898. Connections slice 1 adds connection records from hello and attempts, the connect mailbox, the API, usage rows and the turn's mutation ledger (connections.go and tools.go, about 600 lines); measured 7400 after merging UX1. Thin v1 UX1 adds step activity lines, duplicates and their fold, the coordinator at work on a task, project facts from the runner catalog and open merge cards for the pages (inner.go, about 330 lines); measured 6610 with slice 4c's review fixes. Thin v1 slice 4c adds the merge policy, the merge card, the rebase round and duplicate reports (merge.go, about 380 lines). Thin v1 instance core: conversation, projects, tasks, review and, from slice 4b, questions to the specialists (questions.go, about 470 lines) share one store, transaction and event log; splitting would export the transaction internals. Measured 5514 source lines; revisit at the slice 7 sweep.
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.
@@ -62,4 +62,4 @@ perf GET /conversation/attachments/{id}/preview skip Composer attachments: an 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 Mac runners slice B: TestReleaseRunnerHasNoFakeWorker builds the release runner exactly as make release-runner does and the thin package under the testbuild tag (measured 11.9s locally with a warm cache).
size internal/headless - 8300 Claude's sign-in by a link adds its end-to-end, contained-launch and real runner kill tests (signin_test.go, signin_contained_test.go, about 400 lines); measured 8090.
-size internal/thintest - 11400 Spend 1 merged onto the four UI branches: measured 11325. Spend 1 marks overcounting Claude rows (about 120 lines); it adds the task page's spend contract and the 0059 upgrade (spend_pages_test.go, about 100 lines) and the fix round feedback by protocol (about 40); measured 10224. The team panel merged onto Projects UX and the Settings UX pass: measured 11064 with all three. The team panel adds its page contract and the drawer's browser drive at 1280 and 390 (team_panel_test.go, team_panel_browser_test.go, about 300 lines); measured 10235. Projects UX merged onto the Settings UX pass: measured 10768 with both. Projects UX adds the Projects page contracts (order, quiet fold, filter, stars and Undo, the coordinator's star, repository counts, whole words), the decision cards' Mac and Ask about this contracts and their browser drive (projects_pages_test.go, projects_browser_test.go, about 330 lines); measured 10321. The Settings UX pass adds the Settings pattern's page contracts and the savebar, Housekeeping groups and Teams browser drives (settings_ux_pages_test.go, settings_ux_browser_test.go, about 430 lines); measured 10390. Claude's sign-in by a link adds the code contract (signin_contract_test.go: the card, the code route's refusals, the wrong-code card, the kind it becomes and the canary sweep, about 220 lines); measured 9896. The Connections Add page and the Settings rail add their page contracts and the rail's browser drive (connections_add_pages_test.go, settings_rail_pages_test.go, about 230 lines); measured 9676. Claude setup tokens add the token and Check again contracts; measured 9444 with the composer and Mac lines merged. The instant thinking line adds its browser drive (instant_browser_test.go, about 230 lines); measured 9064 with the composer and Mac lines merged. Mac runners add the role, scoping, migration, placement, withdrawal, transfer and publication contracts (about 900 test lines) beside the thin v1 contracts; one package keeps one instance harness.
+size internal/thintest - 11600 Mac recheck adds its enrolment, skip and outcome contracts (macrecheck_contract_test.go, about 210 lines); measured 11537. Spend 1 merged onto the four UI branches: measured 11325. Spend 1 marks overcounting Claude rows (about 120 lines); it adds the task page's spend contract and the 0059 upgrade (spend_pages_test.go, about 100 lines) and the fix round feedback by protocol (about 40); measured 10224. The team panel merged onto Projects UX and the Settings UX pass: measured 11064 with all three. The team panel adds its page contract and the drawer's browser drive at 1280 and 390 (team_panel_test.go, team_panel_browser_test.go, about 300 lines); measured 10235. Projects UX merged onto the Settings UX pass: measured 10768 with both. Projects UX adds the Projects page contracts (order, quiet fold, filter, stars and Undo, the coordinator's star, repository counts, whole words), the decision cards' Mac and Ask about this contracts and their browser drive (projects_pages_test.go, projects_browser_test.go, about 330 lines); measured 10321. The Settings UX pass adds the Settings pattern's page contracts and the savebar, Housekeeping groups and Teams browser drives (settings_ux_pages_test.go, settings_ux_browser_test.go, about 430 lines); measured 10390. Claude's sign-in by a link adds the code contract (signin_contract_test.go: the card, the code route's refusals, the wrong-code card, the kind it becomes and the canary sweep, about 220 lines); measured 9896. The Connections Add page and the Settings rail add their page contracts and the rail's browser drive (connections_add_pages_test.go, settings_rail_pages_test.go, about 230 lines); measured 9676. Claude setup tokens add the token and Check again contracts; measured 9444 with the composer and Mac lines merged. The instant thinking line adds its browser drive (instant_browser_test.go, about 230 lines); measured 9064 with the composer and Mac lines merged. Mac runners add the role, scoping, migration, placement, withdrawal, transfer and publication contracts (about 900 test lines) beside the thin v1 contracts; one package keeps one instance harness.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 99451fde..11f0396b 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -5947,7 +5947,7 @@ records remain unchanged.
| `work.chip.waiting_mac` | Waiting for a Mac to run checks | Tasks and Needs you (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `work.summary.waiting_mac` | Approved. Waiting for a Mac to run checks. You can merge now without checks. | Tasks and Needs you (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `work.decide.mac_why` | Review approved. Checks need a Mac, and no Mac is set up to run them. | Tasks and Needs you (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
-| `work.decide.mac_hint` | Merge now merges it without checks. Wait for a Mac leaves it as it is. Once a Mac is set up, checks run on its next change, and if they pass, Equipo merges it by itself. | Tasks and Needs you (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
+| `work.decide.mac_hint` | Merge now merges it without checks. Wait for a Mac keeps it ready. Once a Mac is set up, checks run, and if they pass, Equipo merges it by itself. | Tasks and Needs you (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `work.decide.mac.merge` | Merge now | Tasks and Needs you (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `work.decide.mac.wait` | Wait for a Mac | Tasks and Needs you (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| `work.decide.mac_set_up` | Set up a Mac | Tasks and Needs you (projects-ux) | COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
@@ -6711,3 +6711,11 @@ coordinator's ruling (2026-11-11), still accepted by delegation:
Spend 1's eight strings (`work.spend*`, with `work.spend_left_out`) had
their own small Astra pass on 2026-11-11 with the same brief: all eight
kept, no flags; marked accepted by delegation.
+
+Mac recheck (2026-11-11) closes the `work.decide.mac_hint` gap above: a
+Mac that fits, enrolling or back online, runs a waiting task's
+`needs_macos` checks again on its candidate (`chat/macrecheck.go`), and a
+pass merges under slice 4c. The hint is a plain line again: "Merge now
+merges it without checks. Wait for a Mac keeps it ready. Once a Mac is set
+up, checks run, and if they pass, Equipo merges it by itself." Accepted by
+delegation like its neighbours.
diff --git a/internal/equipo/chat/macrecheck.go b/internal/equipo/chat/macrecheck.go
new file mode 100644
index 00000000..0d8e9ad6
--- /dev/null
+++ b/internal/equipo/chat/macrecheck.go
@@ -0,0 +1,90 @@
+package chat
+
+import (
+ "slices"
+
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// recheckMac runs again the checks of the person's tasks that wait for a
+// Mac, when runner (just enrolled, or back online) fits them: Ready to
+// merge, approved, their newest checks not run because no runner could
+// (needs_macos), the branch still at that candidate and no merge of it.
+// The checks are placed afresh on that exact candidate through the usual
+// placement (nextStep), so a pass merges under the slice 4c policy
+// (advance grants it) and a failure takes the fix round. Once per
+// candidate per runner: a reconnect of the same runner runs nothing.
+func (t *txn) recheckMac(person, runner string) error {
+ rs, err := t.runners(person)
+ if err != nil {
+ return err
+ }
+ primary, err := t.s.authority.PrimaryRunner(t.db, person)
+ if err != nil {
+ return err
+ }
+ var mac *runnerInfo
+ relay := false
+ for i := range rs {
+ if rs[i].ID == runner && rs[i].Online && slices.Contains(rs[i].tags(), wire.TagMacOS) {
+ mac = &rs[i]
+ }
+ if rs[i].ID == primary && rs[i].Protocol >= wire.Protocol2 {
+ relay = true
+ }
+ }
+ if mac == nil || !relay && runner != primary {
+ // Not a Mac, or placement would end on the primary again.
+ return nil
+ }
+ var tasks []taskRecord
+ if err := t.db.Where("creator = ? AND stage = ? AND cancel_requested = ?", person, wire.StageReadyToMerge, false).Order("created_at, id").Find(&tasks).Error; err != nil {
+ return err
+ }
+ for i := range tasks {
+ k := &tasks[i]
+ steps, err := t.steps(k.ID)
+ if err != nil {
+ return err
+ }
+ p := progressFor(*k, steps)
+ c := p.checks
+ if p.moved || p.merge != nil || p.eng == nil || p.eng.Person != person || c == nil || c.State != wire.StepDone || c.Checks != wire.ChecksCannotRun || c.Reason != "needs_macos" {
+ continue
+ }
+ if _, _, verdict, _ := p.judged(); verdict != wire.VerdictApprove {
+ continue
+ }
+ needs := decodeList(c.Needs)
+ if len(needs) == 0 {
+ if needs, err = t.checksNeeds(*k, *c); err != nil {
+ return err
+ }
+ }
+ if !slices.Contains(needs, wire.TagMacOS) || !mac.fits(needs, decodeList(c.RefusedBy)) {
+ continue
+ }
+ var ran int64
+ if err := t.db.Model(&stepRecord{}).Where("task_id = ? AND specialist = ? AND candidate_sha = ? AND recheck_by = ?", k.ID, wire.SpecialistChecks, p.candidate, runner).Count(&ran).Error; err != nil {
+ return err
+ }
+ if ran > 0 {
+ continue
+ }
+ // The card asked whether to merge without checks; they run now,
+ // and their outcome asks afresh if it must.
+ if err := t.withdrawMergeCards(*k); err != nil {
+ return err
+ }
+ k.MergeAsked = ""
+ if err := t.db.Model(&taskRecord{}).Where("id = ?", k.ID).Update("merge_asked", "").Error; err != nil {
+ return err
+ }
+ s := stepRecord{Specialist: wire.SpecialistChecks, Person: p.eng.Person, Round: p.eng.Round, BaseSHA: k.BaseSHA, CandidateSHA: p.candidate, RecheckBy: runner}
+ k.Stage = wire.StageInReview
+ if err := t.nextStep(k, steps, s); err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/internal/equipo/chat/review.go b/internal/equipo/chat/review.go
index 319461b2..c019a211 100644
--- a/internal/equipo/chat/review.go
+++ b/internal/equipo/chat/review.go
@@ -192,6 +192,10 @@ func (t *txn) advance(k *taskRecord) error {
if checks == wire.ChecksPassed {
k.MergeEligible = p.candidate
}
+ } else if checks == wire.ChecksPassed && p.checks.RecheckBy != "" && k.MergeEligible != p.candidate {
+ // Its checks waited for a Mac and passed there (macrecheck.go):
+ // what passing at the first Ready would have granted.
+ k.MergeEligible, ready = p.candidate, true
}
if ready {
if err := t.saveTask(k); err != nil {
diff --git a/internal/equipo/chat/runner.go b/internal/equipo/chat/runner.go
index 3114e7db..3646113e 100644
--- a/internal/equipo/chat/runner.go
+++ b/internal/equipo/chat/runner.go
@@ -95,7 +95,10 @@ func (s *Store) Connect(ctx context.Context, p RunnerPrincipal, process string,
return err
}
// A runner that fits may have come online.
- return t.placeWaiting(p.Person)
+ if err := t.placeWaiting(p.Person); err != nil {
+ return err
+ }
+ return t.recheckMac(p.Person, p.RunnerID)
})
return lease, err
}
@@ -174,7 +177,10 @@ func (s *Store) Heartbeat(ctx context.Context, l Lease, hello wire.Hello) error
if err := t.runnerEvent(l.Runner.Person, r); err != nil {
return err
}
- return t.placeWaiting(l.Runner.Person)
+ if err := t.placeWaiting(l.Runner.Person); err != nil {
+ return err
+ }
+ return t.recheckMac(l.Runner.Person, l.Runner.RunnerID)
}
return nil
})
diff --git a/internal/equipo/chat/runners.go b/internal/equipo/chat/runners.go
index 3922070c..93b31696 100644
--- a/internal/equipo/chat/runners.go
+++ b/internal/equipo/chat/runners.go
@@ -248,6 +248,12 @@ func (r runnerInfo) tags() []string {
return r.Hello.Capabilities.Tags
}
+// fits reports whether checks with needs, refused by those runners, may
+// be placed on r.
+func (r runnerInfo) fits(needs, refused []string) bool {
+ return wire.Covers(r.tags(), needs) && !slices.Contains(refused, r.ID) && r.Protocol >= wire.Protocol2 && !r.Removing
+}
+
// runners are the person's unrevoked runners in enrolment order, with
// what each last said and how many steps it runs.
func (t *txn) runners(person string) ([]runnerInfo, error) {
@@ -464,7 +470,7 @@ func (t *txn) place(k *taskRecord, s *stepRecord) (placed bool, err error) {
if r.ID == primary && r.Protocol >= wire.Protocol2 {
relay = true
}
- if wire.Covers(r.tags(), needs) && !slices.Contains(refused, r.ID) && r.Protocol >= wire.Protocol2 && !r.Removing {
+ if r.fits(needs, refused) {
fit = append(fit, r)
}
}
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go
index d2d92d76..d33ebc7d 100644
--- a/internal/equipo/chat/tasks.go
+++ b/internal/equipo/chat/tasks.go
@@ -166,6 +166,9 @@ type stepRecord struct {
// none when they ran outside the sandbox (Paul's ruling 2). "" is the
// primary's bubblewrap.
ChecksSandbox string
+ // RecheckBy is the runner whose arrival ran these checks again, after
+ // they waited for a Mac (macrecheck.go). Set only at creation.
+ RecheckBy string
}
func (stepRecord) TableName() string { return "chat_steps" }
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 38f4da37..431ebc85 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -1137,7 +1137,7 @@ var pageCopy = map[string]string{
"work.chip.waiting_mac": "Waiting for a Mac to run checks", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
"work.summary.waiting_mac": "Approved. Waiting for a Mac to run checks. You can merge now without checks.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
"work.decide.mac_why": "Review approved. Checks need a Mac, and no Mac is set up to run them.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
- "work.decide.mac_hint": "Merge now merges it without checks. Wait for a Mac leaves it as it is. Once a Mac is set up, checks run on its next change, and if they pass, Equipo merges it by itself.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
+ "work.decide.mac_hint": "Merge now merges it without checks. Wait for a Mac keeps it ready. Once a Mac is set up, checks run, and if they pass, Equipo merges it by itself.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
"work.decide.mac.merge": "Merge now", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
"work.decide.mac.wait": "Wait for a Mac", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
"work.decide.mac_set_up": "Set up a Mac", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
diff --git a/internal/equipo/migrations/0060_thin_mac_recheck.sql b/internal/equipo/migrations/0060_thin_mac_recheck.sql
new file mode 100644
index 00000000..1cdbed2a
--- /dev/null
+++ b/internal/equipo/migrations/0060_thin_mac_recheck.sql
@@ -0,0 +1 @@
+ALTER TABLE chat_steps ADD COLUMN recheck_by text;
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql
index 0a02895c..4902d47a 100644
--- a/internal/equipo/migrations/schema.sql
+++ b/internal/equipo/migrations/schema.sql
@@ -598,7 +598,7 @@ CREATE INDEX chat_card_task ON chat_cards(task_id);
CREATE TABLE chat_project_attachments (project_id text, kind text, ref text, name text, created_at datetime, PRIMARY KEY (project_id, kind, ref));
CREATE TABLE chat_tasks (id text PRIMARY KEY, project_id text, title text, brief text, stage text, branch text, base_sha text, creator text, turn_id text, cancel_requested numeric, revision integer, created_at datetime, updated_at datetime, watching text, moved_from text, branch_head text, merge_asked text, merged_sha text, merged_into text, merge_strategy text, merged_without_checks numeric, merged_at datetime, ready_sha text, merge_eligible text, done_at datetime, duplicate_of text, folded_into text, folded_stage text, folded_at datetime, engineering_runner text);
CREATE INDEX chat_task_project ON chat_tasks(project_id);
-CREATE TABLE chat_steps (id text PRIMARY KEY, task_id text, idx integer, specialist text, person text, state text, reason text, attempt integer, base_sha text, candidate_sha text, pushed numeric, terminated numeric, summary text, log_tail text, started_at datetime, finished_at datetime, revision integer, created_at datetime, updated_at datetime, round integer, family text, account text, verdict text, review_label text, findings text, checks text, gate text, exit_code integer, output text, republish numeric, from_attempt integer, askable numeric, rebase numeric, from_base text, from_candidate text, merge_sha text, merge_into text, merge_strategy text, without_checks numeric, activity text, switched text, headline text, runner_id text, needs text, placement text, waiting_since datetime, refused_by text, withdrawn numeric, termination_kind text, publication text, publication_id text, apple numeric, checks_sandbox text);
+CREATE TABLE chat_steps (id text PRIMARY KEY, task_id text, idx integer, specialist text, person text, state text, reason text, attempt integer, base_sha text, candidate_sha text, pushed numeric, terminated numeric, summary text, log_tail text, started_at datetime, finished_at datetime, revision integer, created_at datetime, updated_at datetime, round integer, family text, account text, verdict text, review_label text, findings text, checks text, gate text, exit_code integer, output text, republish numeric, from_attempt integer, askable numeric, rebase numeric, from_base text, from_candidate text, merge_sha text, merge_into text, merge_strategy text, without_checks numeric, activity text, switched text, headline text, runner_id text, needs text, placement text, waiting_since datetime, refused_by text, withdrawn numeric, termination_kind text, publication text, publication_id text, apple numeric, checks_sandbox text, recheck_by text);
CREATE INDEX chat_step_task ON chat_steps(task_id);
CREATE TABLE chat_task_entries (id text PRIMARY KEY, task_id text, idempotency_key text, kind text, author text, text text, repo text, path text, line integer, created_at datetime, headline text, folded_from text);
CREATE INDEX chat_entry_task ON chat_task_entries(task_id);
diff --git a/internal/thintest/macrecheck_contract_test.go b/internal/thintest/macrecheck_contract_test.go
new file mode 100644
index 00000000..7e06f974
--- /dev/null
+++ b/internal/thintest/macrecheck_contract_test.go
@@ -0,0 +1,212 @@
+package thintest
+
+import (
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// waitingForMac runs an iOS change with no Mac enrolled to Ready to merge:
+// its checks end on the primary as not run (needs_macos), review
+// approves, and the merge card asks. It returns the task, its candidate
+// and the card.
+func (r *runnersRig) waitingForMac(title string) (task, sha string, card wire.Card) {
+ r.t.Helper()
+ task, sha = r.candidate(title, true)
+ _, body := r.expect(wire.FrameDispatch)
+ c := body.(*wire.DispatchCommand)
+ if c.Specialist != wire.SpecialistChecks || c.TaskID != task || len(c.Needs) != 0 {
+ r.t.Fatalf("checks on the primary %+v", c)
+ }
+ r.checks(task+"-c", c, wire.ChecksCannotRun, nil, "needs_macos", "")
+ _, body = r.expect(wire.FrameDispatch)
+ r.verdict(task+"-r", body.(*wire.DispatchCommand), wire.VerdictApprove)
+ r.wait("waiting for a Mac", func(c *Conversation) bool {
+ for _, k := range c.Cards {
+ if k.Kind == wire.CardMerge && k.TaskID == task && c.Tasks[task].Stage == wire.StageReadyToMerge {
+ card = k
+ return true
+ }
+ }
+ return false
+ })
+ return task, sha, card
+}
+
+// checksRuns are the task's checks steps.
+func (r *runnersRig) checksRuns(task string) []wire.Step {
+ r.t.Helper()
+ k, err := r.client.Task(r.ctx, task)
+ if err != nil {
+ r.t.Fatal(err)
+ }
+ var out []wire.Step
+ for _, s := range k.Steps {
+ if s.Specialist == wire.SpecialistChecks {
+ out = append(out, s)
+ }
+ }
+ return out
+}
+
+// macRecheck reads the Mac's dispatch of a task's checks again, on sha.
+func macRecheck(t *testing.T, w *peer, task, sha string) *wire.DispatchCommand {
+ t.Helper()
+ _, body := w.expect(wire.FrameDispatch)
+ d := body.(*wire.DispatchCommand)
+ if d.Specialist != wire.SpecialistChecks || d.TaskID != task || d.CandidateSHA != sha || d.Attempt != 1 || strings.Join(d.Needs, ",") != "macos,xcode" {
+ t.Fatalf("checks again on the Mac %+v", d)
+ }
+ return d
+}
+
+// A task waiting for a Mac (Wait for a Mac on its card) gets its checks
+// again, on the exact candidate, the moment a Mac that fits enrols: once,
+// a reconnect places nothing more. They pass on the Mac (sandboxed), so
+// Equipo merges that SHA with no tap.
+func TestContractMacRecheckOnEnrol(t *testing.T) {
+ r := newRunnersRig(t)
+ task, sha, card := r.waitingForMac("Swipe back on iOS")
+ if out, err := r.client.Answer(r.ctx, card.ID, wire.ChoiceWait, card.Revision); err != nil || out.Card.Choice != wire.ChoiceWait {
+ t.Fatalf("wait %+v %v", out, err)
+ }
+ w, _ := r.newWorker("Tito Studio")
+ d := macRecheck(t, w, task, sha)
+ if runs := r.checksRuns(task); len(runs) != 2 || runs[1].ID != d.StepID || runs[1].RunnerLabel != "Tito Studio" {
+ t.Fatalf("checks runs %+v", runs)
+ }
+ w = r.reconnectPeer(w)
+ w.none(wire.FrameDispatch, 200*time.Millisecond)
+ if runs := r.checksRuns(task); len(runs) != 2 {
+ t.Fatalf("a reconnect ran the checks again: %+v", runs)
+ }
+ r.relay(w, []byte("PACK swipe back"))
+ if !w.lease(d.StepID, 1) {
+ t.Fatal("start refused")
+ }
+ pass := passed(task, d.StepID, 1, sha)
+ pass.ChecksSandbox = wire.SandboxSeatbelt
+ w.send(wire.FrameStep, pass)
+ _, body := r.expect(wire.FrameDispatch)
+ if m := body.(*wire.DispatchCommand); m.Specialist != wire.SpecialistMerge || m.TaskID != task || m.CandidateSHA != sha {
+ t.Fatalf("merge dispatch %+v", m)
+ }
+ if k, _ := r.client.Task(r.ctx, task); k.Stage != wire.StageMerging || k.Checks != wire.ChecksPassed {
+ t.Fatalf("after the Mac's pass %+v", k)
+ }
+}
+
+// Only tasks still waiting: a Linux runner enrolling places nothing; a
+// Mac enrolling skips cancelled tasks, merged ones, ones whose person
+// chose Merge (without checks, even back at Ready after the hub refused
+// it) and ones whose branch moved off the
+// candidate, and re-runs only the one still waiting (left with its card
+// open, which the run withdraws).
+func TestContractMacRecheckOnlyWaiting(t *testing.T) {
+ r := newRunnersRig(t)
+ waiting, sha, open := r.waitingForMac("Still waiting")
+ cancelled, _, _ := r.waitingForMac("Cancelled one")
+ if _, err := r.client.CancelTask(r.ctx, cancelled); err != nil {
+ t.Fatal(err)
+ }
+ merged, _, mc := r.waitingForMac("Merged")
+ if _, err := r.client.Answer(r.ctx, mc.ID, wire.ChoiceMerge, mc.Revision); err != nil {
+ t.Fatal(err)
+ }
+ _, body := r.expect(wire.FrameDispatch)
+ r.mergedStep("merged-m", body.(*wire.DispatchCommand), strings.Repeat("f", 40))
+ chosen, _, cc := r.waitingForMac("Merge chosen")
+ if _, err := r.client.Answer(r.ctx, cc.ID, wire.ChoiceMerge, cc.Revision); err != nil {
+ t.Fatal(err)
+ }
+ _, body = r.expect(wire.FrameDispatch)
+ m := body.(*wire.DispatchCommand)
+ if m.Specialist != wire.SpecialistMerge {
+ t.Fatalf("merge chosen %+v", m)
+ }
+ // The hub refused it: back at Ready to merge, with Retry.
+ r.step("chosen-m", wire.StepReport{TaskID: chosen, StepID: m.StepID, Attempt: 1, State: wire.StepFailed, Reason: "amadan_ci_pending", BaseSHA: m.BaseSHA, CandidateSHA: m.CandidateSHA, Termination: true})
+ moved, msha, _ := r.waitingForMac("Moved")
+ if err := r.runner.Send(r.ctx, "moved-b", wire.FrameBranch, wire.BranchReport{TaskID: moved, CandidateSHA: msha, Head: strings.Repeat("9", 40)}); err != nil {
+ t.Fatal(err)
+ }
+ r.wait("ended or moved", func(c *Conversation) bool {
+ return c.Tasks[moved].NeedsYou == wire.NeedsBranchMoved && c.Tasks[merged].Stage == wire.StageDone && c.Tasks[cancelled].Stage == wire.StageCancelled && c.Tasks[chosen].Stage == wire.StageReadyToMerge
+ })
+
+ linux := WorkerHello(0)
+ linux.Label, linux.Platform, linux.Sandbox = "Build box", &wire.Platform{OS: "linux", Arch: "amd64"}, wire.SandboxBubblewrap
+ linux.Capabilities = &wire.Capabilities{Simulators: []wire.Simulator{}, Tags: []string{wire.TagLinux, wire.TagGo}}
+ lr, err := DialRunnerHello(r.ctx, r.inst.URL, r.inst.EnrolRunner(t).Token, linux)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(lr.Close)
+ (&peer{t: t, r: r.toolRig, fr: lr}).none(wire.FrameDispatch, 200*time.Millisecond)
+ for _, id := range []string{waiting, cancelled, merged, chosen, moved} {
+ if runs := r.checksRuns(id); len(runs) != 1 {
+ t.Fatalf("a Linux runner re-ran %s's checks: %+v", id, runs)
+ }
+ }
+
+ w, _ := r.newWorker("Tito Studio")
+ macRecheck(t, w, waiting, sha)
+ w.none(wire.FrameDispatch, 200*time.Millisecond)
+ for _, id := range []string{cancelled, merged, chosen, moved} {
+ if runs := r.checksRuns(id); len(runs) != 1 {
+ t.Fatalf("checks of %s re-ran: %+v", id, runs)
+ }
+ }
+ r.wait("card withdrawn", func(c *Conversation) bool { return c.Cards[open.ID].State == wire.CardResolved })
+}
+
+// The run follows the usual paths: ending not run again on the Mac
+// (needs_macos) asks the card afresh, and that Mac reconnecting runs
+// nothing (once per candidate per enrolment); another Mac enrolling runs
+// them once more, and checks that fail send Engineering its fix round.
+func TestContractMacRecheckOutcomes(t *testing.T) {
+ r := newRunnersRig(t)
+ task, sha, _ := r.waitingForMac("Swipe back on iOS")
+ a, _ := r.newWorker("Mac A")
+ d := macRecheck(t, a, task, sha)
+ r.relay(a, []byte("PACK a"))
+ if !a.lease(d.StepID, 1) {
+ t.Fatal("start refused")
+ }
+ a.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: 1, State: wire.StepDone, Reason: "needs_macos", CandidateSHA: sha, Checks: wire.ChecksCannotRun, Termination: true, TerminationKind: wire.TerminationProcessGroup, Findings: []wire.Finding{}})
+ var card wire.Card
+ r.wait("asked again", func(c *Conversation) bool {
+ for _, k := range c.Cards {
+ if k.Kind == wire.CardMerge && k.TaskID == task && k.State == wire.CardOpen {
+ card = k
+ }
+ }
+ return card.ID != "" && c.Tasks[task].Stage == wire.StageReadyToMerge
+ })
+ a = r.reconnectPeer(a)
+ a.none(wire.FrameDispatch, 200*time.Millisecond)
+ if runs := r.checksRuns(task); len(runs) != 2 {
+ t.Fatalf("the same Mac reconnecting re-ran them: %+v", runs)
+ }
+ // Mac A away, so placement takes the newcomer.
+ a.fr.Close()
+ time.Sleep(100 * time.Millisecond)
+ b, _ := r.newWorker("Mac B")
+ _, body := b.expect(wire.FrameDispatch)
+ d2 := body.(*wire.DispatchCommand)
+ if d2.TaskID != task || d2.CandidateSHA != sha || d2.StepID == d.StepID {
+ t.Fatalf("second Mac's checks %+v", d2)
+ }
+ r.relay(b, []byte("PACK b"))
+ if !b.lease(d2.StepID, 1) {
+ t.Fatal("start refused")
+ }
+ one := 1
+ b.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: d2.StepID, Attempt: 1, State: wire.StepDone, CandidateSHA: sha, Checks: wire.ChecksFailed, Gate: "xcodebuild test", ExitCode: &one, Output: "** TEST FAILED **", ChecksSandbox: wire.SandboxSeatbelt, Termination: true, TerminationKind: wire.TerminationProcessGroup, Findings: []wire.Finding{}})
+ _, body = r.expect(wire.FrameDispatch)
+ if e := body.(*wire.DispatchCommand); e.Specialist != wire.SpecialistEngineering || e.TaskID != task || e.Round != 1 {
+ t.Fatalf("fix round %+v", e)
+ }
+}
diff --git a/internal/thintest/projects_pages_test.go b/internal/thintest/projects_pages_test.go
index ece6ead4..f6705f04 100644
--- a/internal/thintest/projects_pages_test.go
+++ b/internal/thintest/projects_pages_test.go
@@ -252,7 +252,7 @@ func TestPagesTaskDecisionsSayWhy(t *testing.T) {
card := regexp.MustCompile(`(?s)<div equipo-decision[^>]*data-decision="` + g.unchecked + `">.*?</div>\n</div>`).FindString(needs)
for _, want := range []string{"Review approved. Checks need a Mac, and no Mac is set up to run them.", "Merge without checks?",
`data-merge-choice="merge">Merge now</button>`, `data-merge-choice="wait">Wait for a Mac</button>`,
- "Merge now merges it without checks. Wait for a Mac leaves it as it is. Once a Mac is set up, checks run on its next change, and if they pass, Equipo merges it by itself.",
+ "Merge now merges it without checks. Wait for a Mac keeps it ready. Once a Mac is set up, checks run, and if they pass, Equipo merges it by itself.",
`<a equipo-link href="/runners/enrol" data-set-up-mac>Set up a Mac</a>`, `href="/conversation?about=` + g.unchecked + `" data-ask-about>Ask about this</a>`} {
if !strings.Contains(card, want) {
t.Fatalf("Mac decision lacks %q:\n%s", want, card)