Merge mac-placement-wait into mac-slice-f (task 0)
Slice F builds on the Mac placement wait.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 files changed,
+759
−93
.rastrillo/budgets.txt+5 −5docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+8 −0internal/equipo/chat/explore.go+5 −0internal/equipo/chat/mac_needs_test.go+83 −0internal/equipo/chat/review.go+6 −0internal/equipo/chat/runners.go+149 −25internal/equipo/chat/tools.go+4 −0internal/equipo/copy.go+8 −0internal/equipo/mac_wait_view_test.go+46 −0internal/equipo/work_pages.go+5 −0internal/equipo/work_views.go+10 −2internal/headless/ask_test.go+14 −4internal/headless/env_test.go+29 −0internal/headless/mac_test.go+49 −17internal/headless/merge_test.go+22 −1internal/headless/review_test.go+24 −12internal/thintest/mac_wait_contract_test.go+244 −0internal/thintest/macrecheck_contract_test.go+24 −9internal/thintest/macrecheck_mergeauth_contract_test.go+2 −6internal/thintest/placement_contract_test.go+6 −9internal/wire/runners.go+10 −3internal/wire/tasks.go+6 −0
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index f8c47b83..b7f4378d 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 23925 - Preview grants, retry/timeline, no-access merges, kept work, check-db copy, notification actions, places page and its superseded card, GitHub owner routes; measured 23925 source lines. |
| -size internal/wire 8171 - Protocol 31 facts, 32 unfinished work, task evidence, CI units, notification inputs, 33 Assistant files, 34 places, 35 diffs; measured 8171 source lines. |
| +size internal/equipo 23946 - Preview grants, retry/timeline, no-access merges, kept work, check-db copy, notification actions, places page and its superseded card, GitHub owner routes, Mac waits; measured 23946. |
| +size internal/wire 8184 - Protocol 31 facts, 32 unfinished work, task evidence, CI units, notification inputs, 33 Assistant files, 34 places, 35 diffs, Mac waits; measured 8184. |
| 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). |
| @@ -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 37977 11915 File facts/diffs, previews, merge authority, unfinished work, CI feedback, notification receipts, Assistant files, places and where their cards land, waiting cards; measured 37977/11915. |
| +size internal/equipo/chat 38116 11998 File facts/diffs, previews, merge authority, unfinished work, CI feedback, notification receipts, Assistant files, places and where their cards land, waiting cards, Mac waits; measured 38116/11998. |
| 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. |
| @@ -70,8 +70,8 @@ perf GET /api/v1/tasks/{id}/files/{file} skip Research kept images: bearer-only |
| perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one image, shown on the task page; a file, not a screen. |
| 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 - 11873 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 11873 test lines. |
| -size internal/thintest - 36971 Protocol 31 contracts, 35 diffs, stuck tasks, no-access merges, held retries, unfinished work, free rounds, previews, Assistant files, places and where their cards land; measured 36971 test lines. |
| +size internal/headless - 11977 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 11977 test lines. |
| +size internal/thintest - 37223 Protocol 31 contracts, 35 diffs, stuck tasks, no-access merges, held retries, unfinished work, free rounds, previews, Assistant files, places and where their cards land, Mac waits; measured 37223. |
| 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/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 05cf4945..b908a7a7 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -6997,6 +6997,14 @@ records remain unchanged. |
| | `places.deploy_held` | Its deploy key is %s. | Places slice 1, Places page (Luna, codex gpt-5.6-luna, house rules) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-26) | |
| | `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.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_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 | |
| ## Task 21 |
diff --git a/internal/equipo/chat/explore.go b/internal/equipo/chat/explore.go| index 6a99c3dd..17cf7177 100644 |
| --- a/internal/equipo/chat/explore.go |
| +++ b/internal/equipo/chat/explore.go |
| @@ -48,6 +48,11 @@ func (p progress) needsExplore(k taskRecord) string { |
| return wire.NeedsReviewBlocked |
| case w.State == wire.StepFailed && w.Terminated: |
| return wire.NeedsRetry |
| + case w.State == wire.StepQueued && w.Placement == wire.PlacementMac: |
| + // Waiting for a Mac, as any task (needsYou). |
| + return wire.NeedsMacRunner |
| + case w.State == wire.StepQueued && w.Placement == wire.PlacementMacEngineering: |
| + return wire.NeedsMacEngineering |
| case w.State != wire.StepDone || p.candidate == "": |
| return "" |
| } |
diff --git a/internal/equipo/chat/mac_needs_test.go b/internal/equipo/chat/mac_needs_test.go| new file mode 100644 |
| index 00000000..261a123f |
| --- /dev/null |
| +++ b/internal/equipo/chat/mac_needs_test.go |
| @@ -0,0 +1,83 @@ |
| +package chat |
| + |
| +import ( |
| + "context" |
| + "io" |
| + "log/slog" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| + "amadan.net/rastrillo/rastrillo/db" |
| + "gorm.io/gorm" |
| +) |
| + |
| +// Checks need a Mac when any Engineering round of the task touched Apple |
| +// files, not only the round whose commit is the candidate: a delegated |
| +// Copy commit, or a later fix round that touched only the README, makes |
| +// a new candidate that still holds the Swift changes (Astra, |
| +// mac-placement-wait). |
| +func TestChecksNeedAMacForEveryAppleRound(t *testing.T) { |
| + src, err := hkTemplatePath() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, err := os.ReadFile(src) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + path := filepath.Join(t.TempDir(), "macneeds.db") |
| + if err := os.WriteFile(path, raw, 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + d, err := db.Open(path, slog.New(slog.NewTextHandler(io.Discard, nil))) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { _ = d.Close() }) |
| + s := NewStore(d, Authority{Copy: func(key string) string { return key }, PrimaryRunner: func(*gorm.DB, string) (string, error) { return "", nil }}, nil) |
| + const person = "owner@example.com" |
| + now := time.Now().UTC() |
| + sha := func(c string) string { return strings.Repeat(c, 40) } |
| + if err := d.G.Create(&projectRecord{ID: "p1", Repo: "oficina/sample"}).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, k := range []taskRecord{{ID: "tk1", ProjectID: "p1", Creator: person, Stage: wire.StageInProgress, Revision: 1, CreatedAt: now, UpdatedAt: now}, {ID: "tk2", ProjectID: "p1", Creator: person, Stage: wire.StageInProgress, Revision: 1, CreatedAt: now, UpdatedAt: now}} { |
| + if err := d.G.Create(&k).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + for _, st := range []stepRecord{ |
| + {ID: "e1", TaskID: "tk1", Idx: 1, Specialist: wire.SpecialistEngineering, Person: person, State: wire.StepDone, Round: 1, CandidateSHA: sha("a"), Apple: true}, |
| + {ID: "c1", TaskID: "tk1", Idx: 2, Specialist: wire.SpecialistCopy, Person: person, State: wire.StepDone, Round: 1, CandidateSHA: sha("b")}, |
| + {ID: "e2", TaskID: "tk1", Idx: 3, Specialist: wire.SpecialistEngineering, Person: person, State: wire.StepDone, Round: 2, CandidateSHA: sha("c")}, |
| + {ID: "e3", TaskID: "tk2", Idx: 1, Specialist: wire.SpecialistEngineering, Person: person, State: wire.StepDone, Round: 1, CandidateSHA: sha("d")}, |
| + } { |
| + if err := d.G.Create(&st).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + for _, c := range []struct { |
| + task, candidate string |
| + mac bool |
| + }{{"tk1", sha("a"), true}, {"tk1", sha("b"), true}, {"tk1", sha("c"), true}, {"tk2", sha("d"), false}} { |
| + var needs []string |
| + err := s.tx(context.Background(), func(t *txn) error { |
| + k, err := t.loadTask(c.task) |
| + if err != nil { |
| + return err |
| + } |
| + needs, err = t.checksNeeds(k, stepRecord{TaskID: c.task, Specialist: wire.SpecialistChecks, Person: person, CandidateSHA: c.candidate}) |
| + return err |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := strings.Join(needs, ","); (got == "macos,xcode") != c.mac { |
| + t.Errorf("%s at %s: needs %q", c.task, c.candidate[:1], got) |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/chat/review.go b/internal/equipo/chat/review.go| index 0295c045..88d7b834 100644 |
| --- a/internal/equipo/chat/review.go |
| +++ b/internal/equipo/chat/review.go |
| @@ -180,6 +180,12 @@ func (p progress) needsYou(k taskRecord) string { |
| if p.last.Specialist == wire.SpecialistChecks && p.last.State == wire.StepQueued && p.last.Placement == wire.PlacementSandbox { |
| return wire.NeedsMacSandbox |
| } |
| + if p.last.State == wire.StepQueued && p.last.Placement == wire.PlacementMac { |
| + return wire.NeedsMacRunner |
| + } |
| + if p.last.State == wire.StepQueued && p.last.Placement == wire.PlacementMacEngineering { |
| + return wire.NeedsMacEngineering |
| + } |
| if p.last.Specialist == wire.SpecialistEngineering && p.last.State == wire.StepDone && p.last.Publication == wire.PublicationFailed { |
| return wire.NeedsRetry |
| } |
diff --git a/internal/equipo/chat/runners.go b/internal/equipo/chat/runners.go| index ac2c8289..3a536fbc 100644 |
| --- a/internal/equipo/chat/runners.go |
| +++ b/internal/equipo/chat/runners.go |
| @@ -375,35 +375,71 @@ const OfflineLimit = 30 * time.Minute |
| // checksNeeds are the tags checks of the task's newest candidate need: |
| // macOS and Xcode when the change touched Apple files or the |
| // repository's gate needs Xcode (the primary's index says so), and the |
| -// iOS simulator when the repository has a shared scheme. |
| +// iOS simulator when the repository has a shared scheme. The change is |
| +// every Engineering round of the task, not only the one whose commit is |
| +// the candidate: a later round, or a delegated Copy commit, makes a new |
| +// candidate that still holds an earlier round's Apple files. |
| func (t *txn) checksNeeds(k taskRecord, s stepRecord) ([]string, error) { |
| - var eng stepRecord |
| - err := t.db.Where("task_id = ? AND specialist = ? AND candidate_sha = ?", k.ID, wire.SpecialistEngineering, s.CandidateSHA).Order("idx DESC").First(&eng).Error |
| - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { |
| + var apple int64 |
| + if err := t.db.Model(&stepRecord{}).Where("task_id = ? AND specialist = ? AND apple = ?", k.ID, wire.SpecialistEngineering, true).Count(&apple).Error; err != nil { |
| return nil, err |
| } |
| - var p projectRecord |
| - if err := t.db.Where("id = ?", k.ProjectID).First(&p).Error; err != nil { |
| + info, err := t.repoInfo(k, s.Person) |
| + if err != nil { |
| return nil, err |
| } |
| - h, err := t.hello(s.Person) |
| + return macNeeds(apple > 0 || info.NeedsMacOS, info), nil |
| +} |
| + |
| +// engineeringNeeds are the tags Engineering of the task needs: macOS and |
| +// Xcode (and the simulator) when the repository's gate needs Xcode, as |
| +// the primary's index of its default branch says (the base, not anything |
| +// the change wrote). Anything else needs nothing. |
| +func (t *txn) engineeringNeeds(k taskRecord, person string) ([]string, error) { |
| + info, err := t.repoInfo(k, person) |
| if err != nil { |
| return nil, err |
| } |
| + return macNeeds(info.NeedsMacOS, info), nil |
| +} |
| + |
| +// repoInfo is the primary's catalog entry for the task's repository |
| +// (zero when it has none). |
| +func (t *txn) repoInfo(k taskRecord, person string) (wire.RepoInfo, error) { |
| + var p projectRecord |
| + if err := t.db.Where("id = ?", k.ProjectID).First(&p).Error; err != nil { |
| + return wire.RepoInfo{}, err |
| + } |
| + h, err := t.hello(person) |
| + if err != nil { |
| + return wire.RepoInfo{}, err |
| + } |
| var info wire.RepoInfo |
| for _, r := range h.Catalog { |
| if r.Repo == p.Repo { |
| info = r |
| } |
| } |
| - if !eng.Apple && !info.NeedsMacOS { |
| - return []string{}, nil |
| + return info, nil |
| +} |
| + |
| +func macNeeds(mac bool, info wire.RepoInfo) []string { |
| + if !mac { |
| + return []string{} |
| } |
| needs := []string{wire.TagMacOS, wire.TagXcode} |
| if info.Simulator { |
| needs = append(needs, wire.TagIOSSimulator) |
| } |
| - return needs, nil |
| + return needs |
| +} |
| + |
| +// waitForMac leaves Mac work waiting (placed false): for a Mac runner to |
| +// be added (waiting_mac), or, placement, for the reason it names. |
| +func (t *txn) waitForMac(s *stepRecord, needs []string, placement string) (bool, error) { |
| + now := t.now() |
| + s.Needs, s.RunnerID, s.Placement, s.WaitingSince = encodeList(needs), "", placement, &now |
| + return false, nil |
| } |
| func decodeList(raw string) []string { |
| @@ -423,14 +459,19 @@ func encodeList(v []string) string { |
| } |
| // place chooses the runner for a step's current attempt (Mac runners spec |
| -// §1.4). Only checks are placed by their needs in this release: |
| -// Engineering, Review and merges run on the primary (Engineering pinned |
| -// there for the task), as before. Among the person's runners whose tags |
| -// cover the needs: the primary if it does, else the online worker running |
| -// fewest steps, ties by enrolment order. A fitting runner that is offline |
| -// leaves the step waiting (placed false). When no runner has ever had the |
| -// tags, or the primary cannot relay a pack (protocol 1), the step goes to |
| -// the primary without needs and ends honestly there (needs_macos). A Mac |
| +// §1.4). Checks are placed by their needs; Review and merges run on the |
| +// primary; Engineering runs on the primary (pinned there for the task) |
| +// unless it is Mac work. Mac work never runs on a Linux primary |
| +// (2026-11-28): checks that need macOS with no enrolled runner that fits |
| +// wait for a Mac runner (waiting_mac, the person's to add), and so does |
| +// Engineering for a repository whose gate needs Xcode; with a Mac |
| +// enrolled, that Engineering still waits (waiting_mac_engineering), since |
| +// a Mac worker takes only checks until slice F. Among the person's |
| +// runners whose tags cover the needs: the primary if it does, else the |
| +// online worker running fewest steps, ties by enrolment order. A fitting |
| +// runner that is offline leaves the step waiting (placed false). When the |
| +// primary cannot relay a pack (protocol 1), the step goes to the primary |
| +// without needs and ends honestly there (needs_macos), as before. A Mac |
| // whose sandbox is not proven gets checks only with the person's choice |
| // for this attempt on it (macsandbox.go); when it is the only one online |
| // that fits, the step waits for its sandbox (placed false). |
| @@ -442,6 +483,9 @@ func (t *txn) place(k *taskRecord, s *stepRecord) (placed bool, err error) { |
| s.Placement, s.WaitingSince, s.SandboxRunner = "", nil, "" |
| switch s.Specialist { |
| case wire.SpecialistEngineering: |
| + if wait, err := t.macEngineering(k, s, primary); err != nil || wait { |
| + return false, err |
| + } |
| s.Needs = "" |
| s.RunnerID = primary |
| if k.EngineeringRunner != "" && k.EngineeringRunner != primary { |
| @@ -495,9 +539,20 @@ func (t *txn) place(k *taskRecord, s *stepRecord) (placed bool, err error) { |
| fit = append(fit, r) |
| } |
| } |
| - if len(fit) == 0 || !relay { |
| - // Nobody can: the primary judges it and says why (needs_macos). |
| - return true, nil |
| + if len(fit) == 0 { |
| + // No runner can, and none is enrolled that could: the checks wait |
| + // for a Mac runner instead of the Linux primary judging them |
| + // needs_macos, whatever its protocol. |
| + return t.waitForMac(s, needs, wire.PlacementMac) |
| + } |
| + if !relay { |
| + // A Mac is enrolled but an older primary cannot relay a pack to |
| + // it: the checks wait for a runner (the primary's update), and |
| + // resolve as not run after the offline limit, as for an offline |
| + // Mac. Never judged on the Linux primary. |
| + now := t.now() |
| + s.RunnerID, s.Placement, s.WaitingSince = "", wire.PlacementWaiting, &now |
| + return false, nil |
| } |
| var chosen, unproven *runnerInfo |
| for i := range fit { |
| @@ -531,6 +586,61 @@ func (t *txn) place(k *taskRecord, s *stepRecord) (placed bool, err error) { |
| return true, nil |
| } |
| +// macEngineering decides whether Engineering of the task is Mac work that |
| +// must wait rather than run on the Linux primary, and leaves it waiting |
| +// if so: for a Mac runner when none enrolled fits, else because no runner |
| +// that fits takes Engineering (only the primary does). An older primary |
| +// (protocol 1) is no exception. |
| +func (t *txn) macEngineering(k *taskRecord, s *stepRecord, primary string) (bool, error) { |
| + needs, err := t.engineeringNeeds(*k, s.Person) |
| + if err != nil || len(needs) == 0 { |
| + return false, err |
| + } |
| + rs, err := t.runners(s.Person) |
| + if err != nil { |
| + return false, err |
| + } |
| + fit := false |
| + for _, r := range rs { |
| + if r.fits(needs, nil) { |
| + if r.ID == primary { |
| + // A primary that is a Mac takes it. |
| + return false, nil |
| + } |
| + fit = true |
| + } |
| + } |
| + if !fit { |
| + _, err := t.waitForMac(s, needs, wire.PlacementMac) |
| + return true, err |
| + } |
| + _, err = t.waitForMac(s, needs, wire.PlacementMacEngineering) |
| + return true, err |
| +} |
| + |
| +// restartMacEngineering: whether the unstarted Engineering attempt s is |
| +// Mac work its runner cannot take; if so the attempt is ended and the |
| +// next one placed (it waits for a Mac). |
| +func (t *txn) restartMacEngineering(s *stepRecord) (bool, error) { |
| + k, err := t.loadTask(s.TaskID) |
| + if err != nil { |
| + return false, err |
| + } |
| + primary, err := t.s.authority.PrimaryRunner(t.db, s.Person) |
| + if err != nil { |
| + return false, err |
| + } |
| + probe := *s |
| + wait, err := t.macEngineering(&k, &probe, primary) |
| + if err != nil || !wait { |
| + return false, err |
| + } |
| + if err := t.replace(&k, s); err != nil { |
| + return false, err |
| + } |
| + return true, t.saveStep(s, &k) |
| +} |
| + |
| // replace ends the current attempt's placement and places the next one: |
| // after a refusal, a withdrawal before it started, or a withdrawn |
| // attempt's termination. The caller saves s. |
| @@ -655,18 +765,32 @@ func (s *Store) Authorize(ctx context.Context, l Lease, stepID string, attempt i |
| if st.StartedAt != nil { |
| return nil |
| } |
| + if st.Specialist == wire.SpecialistEngineering { |
| + // Placement is decided again before Engineering starts: one |
| + // dispatched to the Linux primary before Mac work waited for a |
| + // Mac (an instance upgraded with it queued), or before the |
| + // catalog said the gate needs Xcode, does not start there. |
| + mac, err := t.restartMacEngineering(&st) |
| + if err != nil || mac { |
| + refused = "withdrawn" |
| + return err |
| + } |
| + } |
| now := t.now() |
| return t.db.Model(&stepRecord{}).Where("id = ? AND attempt = ?", st.ID, st.Attempt).Update("started_at", now).Error |
| }) |
| return refused, err |
| } |
| +// waitingPlacements are the placements of a step waiting to be placed. |
| +var waitingPlacements = []string{wire.PlacementWaiting, wire.PlacementSandbox, wire.PlacementMac, wire.PlacementMacEngineering} |
| + |
| // placeWaiting places the person's steps waiting for a runner, when one |
| -// that fits may have come online, or for a Mac's sandbox, when it may be |
| -// proven now. |
| +// that fits may have come online or been added, or for a Mac's sandbox, |
| +// when it may be proven now. |
| func (t *txn) placeWaiting(person string) error { |
| var rows []stepRecord |
| - if err := t.db.Where("person = ? AND placement IN ? AND state = ?", person, []string{wire.PlacementWaiting, wire.PlacementSandbox}, wire.StepQueued).Order("created_at").Find(&rows).Error; err != nil { |
| + if err := t.db.Where("person = ? AND placement IN ? AND state = ?", person, waitingPlacements, wire.StepQueued).Order("created_at").Find(&rows).Error; err != nil { |
| return err |
| } |
| for i := range rows { |
| @@ -705,7 +829,7 @@ func (t *txn) placeWaiting(person string) error { |
| func (s *Store) Place(ctx context.Context) error { |
| return s.tx(ctx, func(t *txn) error { |
| var persons []string |
| - if err := t.db.Model(&stepRecord{}).Where("state IN ? AND (placement IN ? OR runner_id IN (SELECT id FROM runners WHERE role = ?))", []string{wire.StepQueued, wire.StepRunning}, []string{wire.PlacementWaiting, wire.PlacementSandbox}, wire.RoleWorker).Distinct().Pluck("person", &persons).Error; err != nil { |
| + if err := t.db.Model(&stepRecord{}).Where("state IN ? AND (placement IN ? OR runner_id IN (SELECT id FROM runners WHERE role = ?))", []string{wire.StepQueued, wire.StepRunning}, waitingPlacements, wire.RoleWorker).Distinct().Pluck("person", &persons).Error; err != nil { |
| return err |
| } |
| for _, p := range persons { |
diff --git a/internal/equipo/chat/tools.go b/internal/equipo/chat/tools.go| index 46a863b4..96f9b392 100644 |
| --- a/internal/equipo/chat/tools.go |
| +++ b/internal/equipo/chat/tools.go |
| @@ -171,6 +171,10 @@ func blockedLine(cause string) string { |
| return "they need to bring their computer back online" |
| case wire.NeedsMacSandbox: |
| return "they need to let it be tested on their Mac" |
| + case wire.NeedsMacRunner: |
| + return "it needs a Mac, and they need to add a Mac runner; it will not run on Linux" |
| + case wire.NeedsMacEngineering: |
| + return "it needs a Mac to make the change, and their Mac runner can only run checks for now; it will not run on Linux" |
| case causeGoingLive: |
| return "going live failed, and they need to try it again" |
| case causeNoAccess: |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 8f658ea9..bea45450 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -1758,6 +1758,14 @@ var pageCopy = map[string]string{ |
| "work.checks.waiting_sandbox": "Waiting for the Mac's sandbox", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "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.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_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 |
| "work.decide.unsandboxed": "Run outside the sandbox", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "work.decide.unsandboxed_warning": "This runs the checks on %s outside the sandbox. They can read anything that account can. The Mac is then marked tainted.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
| "work.decide.unsandboxed_confirm": "Run them outside the sandbox", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11) |
diff --git a/internal/equipo/mac_wait_view_test.go b/internal/equipo/mac_wait_view_test.go| new file mode 100644 |
| index 00000000..cc3b25a3 |
| --- /dev/null |
| +++ b/internal/equipo/mac_wait_view_test.go |
| @@ -0,0 +1,46 @@ |
| +package equipo |
| + |
| +import ( |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// Mac work waiting for a Mac runner, or for a Mac that can make changes, |
| +// is the creator's to see under Needs you (2026-11-28): the decision says |
| +// why in words, the line says what waits, and a waiting checks step does |
| +// not read as running. Only the wait for a runner links setting up a Mac. |
| +func TestMacWaitNeedsYou(t *testing.T) { |
| + for _, c := range []struct { |
| + need, specialist, placement, why, line, checks string |
| + mac bool |
| + }{ |
| + {wire.NeedsMacRunner, wire.SpecialistChecks, wire.PlacementMac, "work.decide.mac_runner_why", "work.needs.mac_runner", "work.chip.waiting_mac", true}, |
| + {wire.NeedsMacRunner, wire.SpecialistEngineering, wire.PlacementMac, "work.decide.mac_runner_why", "work.needs.mac_runner", "", true}, |
| + {wire.NeedsMacEngineering, wire.SpecialistEngineering, wire.PlacementMacEngineering, "work.decide.mac_engineering_why", "work.needs.mac_engineering", "", false}, |
| + } { |
| + task := wire.Task{ID: "t1", Creator: "owner@example.com", Stage: wire.StageInProgress, NeedsYou: c.need, Steps: []wire.Step{{ID: "s1", Specialist: c.specialist, State: wire.StepQueued, Placement: c.placement, Attempt: 1}}} |
| + if !needsViewer(task, "owner@example.com", nil) || !needsSomeone(task) || groupOf(task, "owner@example.com", nil) != "needs" { |
| + t.Fatalf("%s: not under Needs you", c.need) |
| + } |
| + if needsViewer(task, "other@example.com", nil) { |
| + t.Fatalf("%s: someone else's decision", c.need) |
| + } |
| + v := taskLineOf(task, "owner@example.com") |
| + if v.StageLine != copyText(c.line) || copyText(c.line) == "" { |
| + t.Fatalf("%s: stage line %q", c.need, v.StageLine) |
| + } |
| + if c.checks != "" && v.ChecksLine != copyText(c.checks) { |
| + t.Fatalf("%s: checks line %q", c.need, v.ChecksLine) |
| + } |
| + v.Mine, v.Cancel = true, true |
| + d := decisionOf(task, v) |
| + if d == nil || d.Why != copyText(c.why) || d.Why == "" || d.Ask == "" || d.Mac != c.mac || !d.Cancel { |
| + t.Fatalf("%s: decision %+v", c.need, d) |
| + } |
| + if r := waitReason(task, v); r == "" || strings.HasPrefix(r, "Needs you") { |
| + t.Fatalf("%s: wait reason %q", c.need, r) |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/work_pages.go b/internal/equipo/work_pages.go| index fcd85de5..026f4c2e 100644 |
| --- a/internal/equipo/work_pages.go |
| +++ b/internal/equipo/work_pages.go |
| @@ -203,6 +203,9 @@ func taskLineOf(t wire.Task, viewer string) taskLine { |
| if s.Placement == wire.PlacementSandbox { |
| v.ChecksLine = copyText("work.checks.waiting_sandbox") |
| } |
| + if s.Placement == wire.PlacementMac { |
| + v.ChecksLine = copyText("work.chip.waiting_mac") |
| + } |
| case wire.SpecialistReview: |
| v.ReviewLine = copyText("work.review.running") |
| } |
| @@ -229,6 +232,8 @@ func taskLineOf(t wire.Task, viewer string) taskLine { |
| v.StageLine = copyText("work.needs." + t.NeedsYou) |
| case wire.NeedsMacSandbox: |
| v.StageLine = copyText("work.checks.waiting_sandbox") |
| + case wire.NeedsMacRunner, wire.NeedsMacEngineering: |
| + v.StageLine = copyText("work.needs." + t.NeedsYou) |
| case wire.NeedsBranchMoved: |
| // What was checked and reviewed is not what the branch holds now: |
| // none of it is shown beside the branch's link. |
diff --git a/internal/equipo/work_views.go b/internal/equipo/work_views.go| index e865b8e3..7906d3ba 100644 |
| --- a/internal/equipo/work_views.go |
| +++ b/internal/equipo/work_views.go |
| @@ -260,7 +260,7 @@ func needsViewer(t wire.Task, viewer string, card *wire.Card) bool { |
| return true |
| } |
| switch t.NeedsYou { |
| - case wire.NeedsRetry, wire.NeedsReviewBlocked, wire.NeedsFixRounds, wire.NeedsBranchMoved, wire.NeedsMergeConflict, wire.NeedsMachineRemoved, wire.NeedsMacSandbox, wire.NeedsDirection: |
| + case wire.NeedsRetry, wire.NeedsReviewBlocked, wire.NeedsFixRounds, wire.NeedsBranchMoved, wire.NeedsMergeConflict, wire.NeedsMachineRemoved, wire.NeedsMacSandbox, wire.NeedsMacRunner, wire.NeedsMacEngineering, wire.NeedsDirection: |
| return true |
| case wire.NeedsMerge, wire.NeedsHeld: |
| return card != nil |
| @@ -274,7 +274,7 @@ func needsSomeone(t wire.Task) bool { |
| return !wire.FinalStage(t.Stage) |
| } |
| switch t.NeedsYou { |
| - case wire.NeedsRetry, wire.NeedsReviewBlocked, wire.NeedsFixRounds, wire.NeedsBranchMoved, wire.NeedsMergeConflict, wire.NeedsMachineRemoved, wire.NeedsMacSandbox, wire.NeedsDirection: |
| + case wire.NeedsRetry, wire.NeedsReviewBlocked, wire.NeedsFixRounds, wire.NeedsBranchMoved, wire.NeedsMergeConflict, wire.NeedsMachineRemoved, wire.NeedsMacSandbox, wire.NeedsMacRunner, wire.NeedsMacEngineering, wire.NeedsDirection: |
| return !wire.FinalStage(t.Stage) |
| } |
| return false |
| @@ -803,6 +803,14 @@ func decisionOf(t wire.Task, v taskLine) *decisionView { |
| d.Choices = append(d.Choices, decisionChoice{Value: o, Label: copyText("chat.card." + o), Primary: o == wire.ChoiceBuild}) |
| } |
| } |
| + case wire.NeedsMacRunner: |
| + // Not a failure: Mac work waits for a Mac runner rather than run on |
| + // Linux, and starts by itself once one is added. |
| + d.Why, d.Ask, d.Mac, d.Cancel = copyText("work.decide.mac_runner_why"), copyText("work.decide.mac_runner_ask"), true, v.Cancel |
| + case wire.NeedsMacEngineering: |
| + // A Mac runner takes only checks so far: the change waits, and |
| + // never goes to Linux. |
| + d.Why, d.Ask, d.Cancel = copyText("work.decide.mac_engineering_why"), copyText("work.decide.mac_engineering_ask"), v.Cancel |
| case wire.NeedsMacSandbox: |
| // Not a failure: the checks wait, and run by themselves once the |
| // Mac's sandbox is proven. Only the creator may choose otherwise. |
diff --git a/internal/headless/ask_test.go b/internal/headless/ask_test.go| index 4829c8a0..40b020af 100644 |
| --- a/internal/headless/ask_test.go |
| +++ b/internal/headless/ask_test.go |
| @@ -61,10 +61,13 @@ func scenarioAsk(t *testing.T, env *Env) { |
| s := open(t, env) |
| s.keep() |
| s.wait(t, "runner online", 30*time.Second, func(c *thintest.Conversation) bool { return c.Runner.Online }) |
| - // The change touches the iOS app too, so its checks cannot run here |
| - // and Equipo asks before merging: the task waits at Ready to merge |
| - // while its creator asks (a task Equipo merges ends at once). |
| - sent := s.send(t, "tool:record_task:oficina/sample|Fix the README typo|The README says teh panes.\ntool:start_task:$task|edit:ios/App.swift|import SwiftUI|import SwiftUI // reading edit:README.md|teh panes|the panes") |
| + // The change adds a file under .github too, a sensitive path, so Equipo asks |
| + // before merging: the task waits at Ready to merge while its creator |
| + // asks (a task Equipo merges ends at once). It touched the iOS app |
| + // until 2026-11-28, when such a change began waiting for a Mac instead |
| + // of having its checks judged on Linux. Review tries to write too |
| + // (4_checks_honest did this until then): it is read-only. |
| + sent := s.send(t, "tool:record_task:oficina/sample|Fix the README typo|The README says teh panes.\ntool:start_task:$task|create:.github/notes.md|Reading notes.; edit:README.md|teh panes|the panes review:write:README.md") |
| id := s.taskOf(t, sent.Turn.ID) |
| k := s.settled(t, id, 5*time.Minute) |
| if k.Stage != wire.StageReadyToMerge { |
| @@ -82,6 +85,13 @@ func scenarioAsk(t *testing.T, env *Env) { |
| if !eng.Askable || !rev.Askable { |
| t.Fatalf("sessions not kept: engineering %v review %v", eng.Askable, rev.Askable) |
| } |
| + // Review read the change and could not write anything. |
| + if !strings.Contains(rev.Summary, "Write to README.md was denied.") || rev.Family != "claude" || rev.Account == "" { |
| + t.Fatalf("review %+v", rev) |
| + } |
| + if strings.Contains(forgeShow(t, env.ForgePath("amadan.net/oficina/sample"), k.CandidateSHA+":README.md"), "\nx") { |
| + t.Fatal("review wrote") |
| + } |
| if n := env.KeptSessions(t); n != 2 { |
| t.Fatalf("%d kept sessions, want 2", n) |
| } |
diff --git a/internal/headless/env_test.go b/internal/headless/env_test.go| index 4e4fd8c5..7830e32f 100644 |
| --- a/internal/headless/env_test.go |
| +++ b/internal/headless/env_test.go |
| @@ -20,6 +20,7 @@ import ( |
| "testing" |
| "time" |
| + "amadan.net/oficina/equipo/internal/equipo/chat" |
| "amadan.net/oficina/equipo/internal/fakeclaude" |
| "amadan.net/oficina/equipo/internal/fakecodex" |
| "amadan.net/oficina/equipo/internal/runner" |
| @@ -100,6 +101,13 @@ type Env struct { |
| Witness, CrashWitness, CancelWitness string |
| // ForgePath is a local forge repository's bare path (local only). |
| ForgePath func(repo string) string |
| + // OfflineMac enrols a Mac worker that said hello once and is offline |
| + // (local only): checks that need a Mac wait for it (waiting_runner), |
| + // not for a Mac runner to be added. The func it returns removes it. |
| + // PastOfflineLimit runs placement with the clock past the offline |
| + // limit, so such checks end not run (runner_offline). |
| + OfflineMac func(t *testing.T) func() |
| + PastOfflineLimit func(t *testing.T) |
| // GrantNow makes a repository reachable without restarting the |
| // runner, like a grant on the hub (local only). |
| GrantNow func(t *testing.T, repo string) |
| @@ -310,6 +318,27 @@ func localEnv(t *testing.T) (*Env, *thintest.Instance, *localRunner) { |
| r.start(t) |
| }, |
| ForgePath: forge.path, |
| + OfflineMac: func(t *testing.T) func() { |
| + cred := inst.EnrolRunner(t) |
| + w, err := thintest.DialRunnerHello(context.Background(), inst.URL, cred.Token, thintest.WorkerHello(0)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + w.Close() |
| + return func() { |
| + if _, err := inst.DB.Writer().Exec("UPDATE runners SET revoked_at = ? WHERE id = ?", time.Now().UTC(), cred.RunnerID); err != nil { |
| + t.Error(err) |
| + } |
| + } |
| + }, |
| + PastOfflineLimit: func(t *testing.T) { |
| + later := time.Now().UTC().Add(chat.OfflineLimit + time.Minute) |
| + inst.Store.Chat().SetClock(func() time.Time { return later }) |
| + defer inst.Store.Chat().SetClock(func() time.Time { return time.Now().UTC() }) |
| + if err := inst.Store.Chat().Place(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + }, |
| AskNamespace: func(t *testing.T, question string) string { |
| d, err := sql.Open("sqlite", "file:"+filepath.Join(state, "thin.db")+"?mode=ro&_pragma=busy_timeout(5000)") |
| if err != nil { |
diff --git a/internal/headless/mac_test.go b/internal/headless/mac_test.go| index 322a4192..5f9515df 100644 |
| --- a/internal/headless/mac_test.go |
| +++ b/internal/headless/mac_test.go |
| @@ -18,25 +18,41 @@ import ( |
| "amadan.net/oficina/equipo/internal/wire" |
| ) |
| -const woodstar = "amadan.net/woodstar/woodstar" |
| +const woodstar, panes = "amadan.net/woodstar/woodstar", "amadan.net/woodstar/panes" |
| -// addWoodstar adds an iOS app to the local forge: its gate runs |
| -// xcodebuild test, it has a shared scheme, and edge swipe does nothing. |
| +// addWoodstar adds an iOS app to the local forge: it has a shared scheme |
| +// and edge swipe does nothing. Its gate runs scripts/test, which runs |
| +// xcodebuild test, so its base does not say it needs a Mac: Engineering |
| +// runs on the Linux primary and a change to its Swift files is checked on |
| +// a Mac. Panes is the same app whose gate runs xcodebuild itself, so |
| +// everything about it is Mac work (Engineering waits for a Mac that can |
| +// make changes, 2026-11-28). |
| func addWoodstar(t *testing.T, root string, f *localForge) { |
| t.Helper() |
| - work := filepath.Join(root, "seed-woodstar") |
| - for p, body := range map[string]string{ |
| + xcode := "xcodebuild test -scheme Woodstar -destination 'platform=iOS Simulator,name=iPhone 16 Pro'\n" |
| + seedIOS(t, root, f, woodstar, map[string]string{".amadan/ci": "#!/bin/sh\nset -e\nexec ./scripts/test\n", "scripts/test": "#!/bin/sh\nset -e\n" + xcode}) |
| + seedIOS(t, root, f, panes, map[string]string{".amadan/ci": "#!/bin/sh\nset -e\n" + xcode}) |
| +} |
| + |
| +func seedIOS(t *testing.T, root string, f *localForge, repo string, gate map[string]string) { |
| + t.Helper() |
| + work := filepath.Join(root, "seed-"+filepath.Base(repo)) |
| + files := map[string]string{ |
| "README.md": "# Woodstar\n\nAn iOS reading app with sliding panes.\n", |
| ".equipo/gates.json": "{\"version\":1,\"files\":[]}\n", |
| - ".amadan/ci": "#!/bin/sh\nset -e\nxcodebuild test -scheme Woodstar -destination 'platform=iOS Simulator,name=iPhone 16 Pro'\n", |
| "Woodstar/Swipe.swift": "let edgeSwipe = false\n", |
| + "Woodstar/About.swift": "let about = \"An iOS reading app\"\n", |
| "Woodstar.xcodeproj/xcshareddata/xcschemes/Woodstar.xcscheme": "<Scheme/>\n", |
| - } { |
| + } |
| + for p, body := range gate { |
| + files[p] = body |
| + } |
| + for p, body := range files { |
| if err := os.MkdirAll(filepath.Dir(filepath.Join(work, p)), 0700); err != nil { |
| t.Fatal(err) |
| } |
| mode := os.FileMode(0600) |
| - if p == ".amadan/ci" { |
| + if p == ".amadan/ci" || p == "scripts/test" { |
| mode = 0700 |
| } |
| if err := os.WriteFile(filepath.Join(work, p), []byte(body), mode); err != nil { |
| @@ -46,9 +62,9 @@ func addWoodstar(t *testing.T, root string, f *localForge) { |
| gitRun(t, work, "init", "-q", "-b", "main") |
| gitRun(t, work, "add", "-A") |
| gitRun(t, work, "commit", "-q", "-m", "seed") |
| - gitRun(t, root, "clone", "-q", "--bare", work, f.path(woodstar)) |
| + gitRun(t, root, "clone", "-q", "--bare", work, f.path(repo)) |
| f.mu.Lock() |
| - f.repos = append(f.repos, woodstar) |
| + f.repos = append(f.repos, repo) |
| f.mu.Unlock() |
| } |
| @@ -158,11 +174,27 @@ func TestMacWorker(t *testing.T) { |
| return false |
| }) |
| - // M5: the fake gate fails on the worker (a README change, judged on a |
| - // Mac because Woodstar's gate is xcodebuild); the fix round works from |
| - // its output; the new candidate's checks pass on the worker. |
| + // Mac work: Panes' gate runs xcodebuild, so its Engineering never runs |
| + // on the Linux primary, and the Mac worker takes only checks: it |
| + // waits, saying why, under Needs you. |
| + t.Run("M0", func(t *testing.T) { |
| + sent := s.send(t, "tool:record_task:woodstar/panes|Pane titles|Say what each pane is for.\ntool:start_task:$task|edit:Woodstar/About.swift|An iOS reading app|An iOS reading app with titled panes") |
| + id := s.taskOf(t, sent.Turn.ID) |
| + k := s.settled(t, id, 2*time.Minute) |
| + eng := stepOf(k, wire.SpecialistEngineering, 0) |
| + if k.NeedsYou != wire.NeedsMacEngineering || eng.State != wire.StepQueued || eng.Placement != wire.PlacementMacEngineering || eng.RunnerID != "" { |
| + t.Fatalf("Mac engineering %+v / %+v", k, eng) |
| + } |
| + if _, err := env.Client.CancelTask(s.ctx, id); err != nil { |
| + t.Fatal(err) |
| + } |
| + }) |
| + |
| + // M5: the fake gate fails on the worker (a Swift change, judged on a |
| + // Mac); the fix round works from its output; the new candidate's |
| + // checks pass on the worker. |
| t.Run("M5", func(t *testing.T) { |
| - sent := s.send(t, "tool:record_task:woodstar/woodstar|Describe the panes|Say what the panes are for.\ntool:start_task:$task|edit:README.md|sliding panes|sliding panes, again") |
| + sent := s.send(t, "tool:record_task:woodstar/woodstar|Describe the panes|Say what the panes are for.\ntool:start_task:$task|edit:Woodstar/About.swift|An iOS reading app|An iOS reading app with sliding panes") |
| id := s.taskOf(t, sent.Turn.ID) |
| k := s.mergeWorkerPass(t, id, 4*time.Minute) |
| first, second := stepOf(k, wire.SpecialistChecks, 0), stepOf(k, wire.SpecialistChecks, 1) |
| @@ -207,7 +239,7 @@ func TestMacWorker(t *testing.T) { |
| } |
| return false |
| }) |
| - sent := s.send(t, "tool:record_task:woodstar/woodstar|README while away|Name the app.\ntool:start_task:$task|edit:README.md|reading app|reading app (m2a)") |
| + sent := s.send(t, "tool:record_task:woodstar/woodstar|About while away|Name the app.\ntool:start_task:$task|edit:Woodstar/About.swift|reading app|reading app (m2a)") |
| id := s.taskOf(t, sent.Turn.ID) |
| s.wait(t, "checks waiting", 2*time.Minute, func(c *thintest.Conversation) bool { |
| for _, st := range c.Tasks[id].Steps { |
| @@ -224,7 +256,7 @@ func TestMacWorker(t *testing.T) { |
| } |
| worker.stop(t) |
| - sent = s.send(t, "tool:record_task:woodstar/woodstar|README, worker gone|Name it again.\ntool:start_task:$task|edit:README.md|reading app (m2a)|reading app (m2b)") |
| + sent = s.send(t, "tool:record_task:woodstar/woodstar|About, worker gone|Name it again.\ntool:start_task:$task|edit:Woodstar/About.swift|reading app (m2a)|reading app (m2b)") |
| late := s.taskOf(t, sent.Turn.ID) |
| s.wait(t, "checks waiting", 2*time.Minute, func(c *thintest.Conversation) bool { |
| for _, st := range c.Tasks[late].Steps { |
| @@ -256,7 +288,7 @@ func TestMacWorker(t *testing.T) { |
| if err := os.WriteFile(xcodebuild+".hang", nil, 0600); err != nil { |
| t.Fatal(err) |
| } |
| - sent := s.send(t, "tool:record_task:woodstar/woodstar|Killed mid checks|Tighten the summary line.\ntool:start_task:$task|edit:README.md|reading app (m2a)|reading app (m4)") |
| + sent := s.send(t, "tool:record_task:woodstar/woodstar|Killed mid checks|Tighten the summary line.\ntool:start_task:$task|edit:Woodstar/About.swift|reading app (m2a)|reading app (m4)") |
| id := s.taskOf(t, sent.Turn.ID) |
| s.wait(t, "checks running on the worker", 3*time.Minute, func(c *thintest.Conversation) bool { |
| for _, st := range c.Tasks[id].Steps { |
diff --git a/internal/headless/merge_test.go b/internal/headless/merge_test.go| index ebcad95c..3cde52d0 100644 |
| --- a/internal/headless/merge_test.go |
| +++ b/internal/headless/merge_test.go |
| @@ -75,7 +75,24 @@ func (s *session) mergeCard(t *testing.T, id string) wire.Card { |
| return card |
| } |
| -// 4c: checks that could not run (an iOS change on Linux) are no pass, so |
| +// offlineMacChecks lets the task's checks wait for the offline Mac |
| +// (env.OfflineMac), then end not run (runner_offline) past the offline |
| +// limit, as they do when the Mac stays away. |
| +func (s *session) offlineMacChecks(t *testing.T, id string) { |
| + t.Helper() |
| + s.wait(t, "checks waiting for the Mac", 2*time.Minute, func(c *thintest.Conversation) bool { |
| + for _, st := range c.Tasks[id].Steps { |
| + if st.Specialist == wire.SpecialistChecks && st.Placement == wire.PlacementWaiting { |
| + return true |
| + } |
| + } |
| + return false |
| + }) |
| + s.env.PastOfflineLimit(t) |
| +} |
| + |
| +// 4c: checks that could not run (an iOS change whose Mac stayed offline; |
| +// with no Mac at all it waits for one, 4_checks_honest) are no pass, so |
| // Equipo asks once with a card instead of merging. While it waits the |
| // task branch moves and comes back (readiness follows it, Astra round 1). |
| // Wait leaves it at Ready to merge, and a person may still merge it on |
| @@ -89,8 +106,10 @@ func scenarioChecksCard(t *testing.T, env *Env) { |
| s.keep() |
| s.wait(t, "runner online", 30*time.Second, func(c *thintest.Conversation) bool { return c.Runner.Online }) |
| bare := env.ForgePath("amadan.net/oficina/sample") |
| + defer env.OfflineMac(t)() |
| sent := s.send(t, "tool:record_task:oficina/sample|iOS edge swipe|Swipe back does nothing on iOS.\ntool:start_task:$task|edit:ios/App.swift|edgeSwipe = false|edgeSwipe = true") |
| id := s.taskOf(t, sent.Turn.ID) |
| + s.offlineMacChecks(t, id) |
| card := s.mergeCard(t, id) |
| k, _ := env.Client.Task(s.ctx, id) |
| if k.Stage != wire.StageReadyToMerge || k.Checks != wire.ChecksCannotRun || k.NeedsYou != wire.NeedsMerge || card.Question != "Merge iOS edge swipe? I'd wait: I don't know yet whether merging to Sample's main branch ships to users." || card.State != wire.CardOpen { |
| @@ -142,6 +161,7 @@ func scenarioChecksCard(t *testing.T, env *Env) { |
| // The next one: Merge. |
| sent = s.send(t, "tool:record_task:oficina/sample|iPad edge swipe|Swipe back does nothing on iPad.|separate\ntool:start_task:$task|edit:ios/App.swift|import SwiftUI|import SwiftUI // iPad") |
| id2 := s.taskOf(t, sent.Turn.ID) |
| + s.offlineMacChecks(t, id2) |
| card2 := s.mergeCard(t, id2) |
| asked := time.Now() |
| if out, err := env.Client.Answer(s.ctx, card2.ID, wire.ChoiceMerge, card2.Revision); err != nil || out.Card.Choice != wire.ChoiceMerge { |
| @@ -176,6 +196,7 @@ func scenarioChecksCard(t *testing.T, env *Env) { |
| } |
| sent = s.send(t, "tool:record_task:oficina/sample|Haptics on iOS|No haptic on a swipe back.|separate\ntool:start_task:$task|edit:ios/App.swift|edgeSwipe = true|edgeSwipe = true // haptic") |
| id3 := s.taskOf(t, sent.Turn.ID) |
| + s.offlineMacChecks(t, id3) |
| s.wait(t, "merged on its own", 2*time.Minute, func(c *thintest.Conversation) bool { return c.Tasks[id3].Stage == wire.StageDone }) |
| k3, _ := env.Client.Task(s.ctx, id3) |
| if k3.Merged == nil || !k3.Merged.WithoutChecks || !k3.UndoOffered || k3.MergeDecision == nil || k3.MergeDecision.Class != "act" { |
diff --git a/internal/headless/review_test.go b/internal/headless/review_test.go| index 3af5d0f5..8ad48368 100644 |
| --- a/internal/headless/review_test.go |
| +++ b/internal/headless/review_test.go |
| @@ -192,9 +192,10 @@ func firstOf(v ...string) string { |
| } |
| // Checks are honest about what this runner cannot check: a change to an |
| -// iOS file needs macOS, so the gate is not run (never a pass), and review |
| -// still reads it, unable to write anything. Ready to merge then says the |
| -// checks did not run, and why, and Equipo does not merge it on its own. |
| +// iOS file needs macOS, and with no Mac runner it is not checked on Linux |
| +// (never a pass, and since 2026-11-28 not judged needs_macos there |
| +// either). The task waits under Needs you for a Mac runner: no gate ran, |
| +// no review ran on an unchecked change, and nothing merged. |
| func scenarioChecksHonest(t *testing.T, env *Env) { |
| if env.Live { |
| t.Skip("local only: the live Woodstar witness covers it") |
| @@ -202,21 +203,32 @@ func scenarioChecksHonest(t *testing.T, env *Env) { |
| s := open(t, env) |
| s.keep() |
| s.wait(t, "runner online", 30*time.Second, func(c *thintest.Conversation) bool { return c.Runner.Online }) |
| - sent := s.send(t, "tool:record_task:oficina/sample|iOS edge swipe|Swipe back does nothing on iOS.\ntool:start_task:$task|edit:ios/App.swift|edgeSwipe = false|edgeSwipe = true review:write:README.md") |
| + sent := s.send(t, "tool:record_task:oficina/sample|iOS edge swipe|Swipe back does nothing on iOS.\ntool:start_task:$task|edit:ios/App.swift|edgeSwipe = false|edgeSwipe = true") |
| id := s.taskOf(t, sent.Turn.ID) |
| k := s.settled(t, id, 5*time.Minute) |
| - checks, review := oneSHA(t, k) |
| - if k.Stage != wire.StageReadyToMerge || k.Checks != wire.ChecksCannotRun || k.ChecksReason != "needs_macos" || checks.ExitCode != nil || checks.Gate != "" { |
| - t.Fatalf("checks not honest: %+v / %+v", k, checks) |
| + if k.NeedsYou != wire.NeedsMacRunner || k.Stage == wire.StageReadyToMerge || k.Checks != "" { |
| + t.Fatalf("not waiting for a Mac: %+v", k) |
| } |
| - if !strings.Contains(review.Summary, "Write to README.md was denied.") || review.Family != "claude" || review.Account == "" { |
| - t.Fatalf("review %+v", review) |
| + var checks, review wire.Step |
| + for _, st := range k.Steps { |
| + switch st.Specialist { |
| + case wire.SpecialistChecks: |
| + checks = st |
| + case wire.SpecialistReview: |
| + review = st |
| + } |
| } |
| - if strings.Contains(forgeShow(t, env.ForgePath("amadan.net/oficina/sample"), k.CandidateSHA+":README.md"), "\nx") { |
| - t.Fatal("review wrote") |
| + if checks.State != wire.StepQueued || checks.Placement != wire.PlacementMac || checks.RunnerID != "" || checks.Gate != "" || checks.ExitCode != nil || checks.CandidateSHA != k.CandidateSHA { |
| + t.Fatalf("checks %+v", checks) |
| + } |
| + if review.ID != "" { |
| + t.Fatalf("reviewed before any checks: %+v", review) |
| } |
| if k.Merged != nil || forgeHead(t, env.ForgePath("amadan.net/oficina/sample"), k.Branch) != k.CandidateSHA { |
| - t.Fatalf("merged without checks on its own: %+v", k) |
| + t.Fatalf("merged without checks: %+v", k) |
| + } |
| + if _, err := env.Client.CancelTask(s.ctx, id); err != nil { |
| + t.Fatal(err) |
| } |
| } |
diff --git a/internal/thintest/mac_wait_contract_test.go b/internal/thintest/mac_wait_contract_test.go| new file mode 100644 |
| index 00000000..776fcba3 |
| --- /dev/null |
| +++ b/internal/thintest/mac_wait_contract_test.go |
| @@ -0,0 +1,244 @@ |
| +package thintest |
| + |
| +import ( |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/chat" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// engineeringStep is the task's first Engineering step. |
| +func (r *runnersRig) engineeringStep(task string) wire.Step { |
| + r.t.Helper() |
| + k, err := r.client.Task(r.ctx, task) |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + for _, s := range k.Steps { |
| + if s.Specialist == wire.SpecialistEngineering { |
| + return s |
| + } |
| + } |
| + r.t.Fatalf("no engineering step: %+v", k.Steps) |
| + return wire.Step{} |
| +} |
| + |
| +func (r *runnersRig) needsYou(task string) string { |
| + r.t.Helper() |
| + k, err := r.client.Task(r.ctx, task) |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + return k.NeedsYou |
| +} |
| + |
| +// Checks that need a Mac, with no Mac runner enrolled, no longer go to the |
| +// Linux primary to end as needs_macos (task tkdn6i2ex2xj, 2026-11-28: a |
| +// Mac sidebar change checked and reviewed on docs-t1 alone). They wait, |
| +// needing the person (a Mac runner), past the offline limit too, and run |
| +// on the Mac as soon as one enrols. |
| +func TestContractChecksWaitForAMacRunner(t *testing.T) { |
| + r := newRunnersRig(t) |
| + task, sha := r.candidate("Mac sidebar", true) |
| + r.primary.none(wire.FrameDispatch, 200*time.Millisecond) |
| + s := r.checksStep(task) |
| + if s.State != wire.StepQueued || s.Placement != wire.PlacementMac || s.RunnerID != "" || strings.Join(s.Needs, ",") != "macos,xcode" { |
| + t.Fatalf("checks did not wait for a Mac: %+v", s) |
| + } |
| + if got := r.needsYou(task); got != wire.NeedsMacRunner { |
| + t.Fatalf("needs you %q", got) |
| + } |
| + clock := time.Now().UTC().Add(chat.OfflineLimit + time.Hour) |
| + r.inst.Store.Chat().SetClock(func() time.Time { return clock }) |
| + if err := r.inst.Store.Chat().Place(r.ctx); err != nil { |
| + t.Fatal(err) |
| + } |
| + if s := r.checksStep(task); s.State != wire.StepQueued || s.Placement != wire.PlacementMac { |
| + t.Fatalf("waiting for a Mac ended by the offline limit: %+v", s) |
| + } |
| + w, _ := r.newWorker("Tito Studio") |
| + _, body := w.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + if d.TaskID != task || d.Specialist != wire.SpecialistChecks || d.CandidateSHA != sha || strings.Join(d.Needs, ",") != "macos,xcode" { |
| + t.Fatalf("checks on the new Mac: %+v", d) |
| + } |
| + if s := r.checksStep(task); s.Placement != "" || s.RunnerLabel != "Tito Studio" { |
| + t.Fatalf("not placed on the Mac: %+v", s) |
| + } |
| + if got := r.needsYou(task); got != "" { |
| + t.Fatalf("still needs you: %q", got) |
| + } |
| +} |
| + |
| +// Engineering for a repository whose gate needs Xcode (the base's |
| +// catalog says so) never runs on the Linux primary: with no Mac runner it |
| +// waits for one; with one, it still waits, saying why, because a Mac |
| +// runner does not take Engineering yet (only checks, until slice F). A |
| +// repository that needs no Mac is unchanged: Engineering on the primary. |
| +func TestContractMacEngineeringWaits(t *testing.T) { |
| + r := newRunnersRig(t) |
| + h := primaryHello(0) |
| + h.Catalog[0].NeedsMacOS = true |
| + r.primary.heartbeat(h) |
| + task := taskID(t, r.call("c-mac", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Mac app", "brief": "b"})) |
| + r.call("s-mac", wire.ToolStartTask, map[string]string{"task": task, "brief": "go"}) |
| + r.primary.none(wire.FrameDispatch, 200*time.Millisecond) |
| + s := r.engineeringStep(task) |
| + if s.State != wire.StepQueued || s.Placement != wire.PlacementMac || s.RunnerID != "" { |
| + t.Fatalf("engineering did not wait for a Mac: %+v", s) |
| + } |
| + if got := r.needsYou(task); got != wire.NeedsMacRunner { |
| + t.Fatalf("needs you %q", got) |
| + } |
| + w, _ := r.newWorker("Tito Studio") |
| + w.none(wire.FrameDispatch, 200*time.Millisecond) |
| + r.primary.none(wire.FrameDispatch, 0) |
| + if s := r.engineeringStep(task); s.State != wire.StepQueued || s.Placement != wire.PlacementMacEngineering || s.RunnerID != "" { |
| + t.Fatalf("engineering with a Mac that cannot take it: %+v", s) |
| + } |
| + if got := r.needsYou(task); got != wire.NeedsMacEngineering { |
| + t.Fatalf("needs you %q", got) |
| + } |
| + |
| + // Not Mac work: Engineering on the primary, as before. |
| + h.Catalog[0].NeedsMacOS = false |
| + r.primary.heartbeat(h) |
| + plain := taskID(t, r.call("c-go", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Go fix", "brief": "b"})) |
| + r.call("s-go", wire.ToolStartTask, map[string]string{"task": plain, "brief": "go"}) |
| + // (The first task, no longer Mac work by its catalog, may go first.) |
| + for range 2 { |
| + _, body := r.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + if d.Specialist != wire.SpecialistEngineering || d.RunnerID == "" { |
| + t.Fatalf("engineering %+v", d) |
| + } |
| + if d.TaskID == plain { |
| + return |
| + } |
| + } |
| + t.Fatal("plain engineering not dispatched to the primary") |
| +} |
| + |
| +// An older primary (protocol 1, no relay) is no way round the rule: |
| +// Mac Engineering and checks that need macOS wait for a Mac there too, |
| +// rather than run, or be judged needs_macos, on Linux (Astra, |
| +// mac-placement-wait). |
| +func TestContractMacWorkWaitsOnAnOlderPrimary(t *testing.T) { |
| + // The tool rig's runner is a protocol 1 primary. |
| + older := func() *runnersRig { |
| + r := newToolRig(t) |
| + return &runnersRig{toolRig: r, primary: &peer{t: t, r: r, fr: r.runner}, creds: map[*FakeRunner][2]string{}} |
| + } |
| + r := older() |
| + h := toolHello(0) |
| + h.Catalog[0].NeedsMacOS = true |
| + r.primary.heartbeat(h) |
| + task := taskID(t, r.call("c-old", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Mac app", "brief": "b"})) |
| + r.call("s-old", wire.ToolStartTask, map[string]string{"task": task, "brief": "go"}) |
| + r.primary.none(wire.FrameDispatch, 200*time.Millisecond) |
| + if n := r.heldKinds(wire.FrameDispatch); n != 0 { |
| + t.Fatalf("%d dispatches to an older primary", n) |
| + } |
| + if s := r.engineeringStep(task); s.State != wire.StepQueued || s.Placement != wire.PlacementMac || s.RunnerID != "" { |
| + t.Fatalf("Mac engineering on an older primary: %+v", s) |
| + } |
| + |
| + r = older() |
| + task = taskID(t, r.call("c-side", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Mac sidebar", "brief": "b"})) |
| + r.call("s-side", wire.ToolStartTask, map[string]string{"task": task, "brief": "go"}) |
| + _, body := r.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + sha := strings.Repeat("f", 40) |
| + r.step("o1", wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepRunning, BaseSHA: strings.Repeat("1", 40), Findings: []wire.Finding{}}) |
| + r.step("o2", wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepDone, CandidateSHA: sha, Pushed: true, Termination: true, TerminationKind: wire.TerminationNamespace, Apple: true, Findings: []wire.Finding{}}) |
| + r.primary.none(wire.FrameDispatch, 200*time.Millisecond) |
| + if n := r.heldKinds(wire.FrameDispatch); n != 0 { |
| + t.Fatalf("%d checks dispatches to an older primary", n) |
| + } |
| + if s := r.checksStep(task); s.State != wire.StepQueued || s.Placement != wire.PlacementMac || s.RunnerID != "" { |
| + t.Fatalf("Mac checks on an older primary: %+v", s) |
| + } |
| + if got := r.needsYou(task); got != wire.NeedsMacRunner { |
| + t.Fatalf("needs you %q", got) |
| + } |
| +} |
| + |
| +// Engineering dispatched to the Linux primary before this rule (an |
| +// instance upgraded with it queued, here: the catalog said Xcode only |
| +// after the dispatch) is refused when the primary asks to start it, and |
| +// waits for a Mac like new work. |
| +func TestContractMacEngineeringQueuedBeforeTheRule(t *testing.T) { |
| + r := newRunnersRig(t) |
| + task := taskID(t, r.call("c-q", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Mac app", "brief": "b"})) |
| + r.call("s-q", wire.ToolStartTask, map[string]string{"task": task, "brief": "go"}) |
| + _, body := r.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + if d.Specialist != wire.SpecialistEngineering { |
| + t.Fatalf("dispatch %+v", d) |
| + } |
| + h := primaryHello(0) |
| + h.Catalog[0].NeedsMacOS = true |
| + r.primary.heartbeat(h) |
| + if r.primary.lease(d.StepID, d.Attempt) { |
| + t.Fatal("Mac engineering started on the Linux primary") |
| + } |
| + if s := r.engineeringStep(task); s.State != wire.StepQueued || s.Placement != wire.PlacementMac || s.RunnerID != "" || s.Attempt != d.Attempt+1 { |
| + t.Fatalf("not waiting for a Mac: %+v", s) |
| + } |
| + if got := r.needsYou(task); got != wire.NeedsMacRunner { |
| + t.Fatalf("needs you %q", got) |
| + } |
| +} |
| + |
| +// Checks of a change that touched no Apple file still wait for a Mac |
| +// when the repository's own gate needs Xcode (the base's catalog), and |
| +// run on the Mac once one enrols. |
| +func TestContractChecksWaitForTheGatesMac(t *testing.T) { |
| + r := newRunnersRig(t) |
| + task := taskID(t, r.call("c-g", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Readme", "brief": "b"})) |
| + r.call("s-g", wire.ToolStartTask, map[string]string{"task": task, "brief": "go"}) |
| + _, body := r.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + // Engineering ran before the gate needed Xcode; its checks come after. |
| + h := primaryHello(0) |
| + h.Catalog[0].NeedsMacOS = true |
| + r.primary.heartbeat(h) |
| + sha := strings.Repeat("e", 40) |
| + r.step("g1", wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepRunning, BaseSHA: strings.Repeat("1", 40), Findings: []wire.Finding{}}) |
| + r.step("g2", wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: d.Attempt, State: wire.StepDone, CandidateSHA: sha, Pushed: true, Termination: true, TerminationKind: wire.TerminationNamespace, Findings: []wire.Finding{}}) |
| + r.primary.none(wire.FrameDispatch, 200*time.Millisecond) |
| + if s := r.checksStep(task); s.State != wire.StepQueued || s.Placement != wire.PlacementMac || !strings.Contains(strings.Join(s.Needs, ","), "xcode") { |
| + t.Fatalf("gate-only checks did not wait for a Mac: %+v", s) |
| + } |
| + w, _ := r.newWorker("Tito Studio") |
| + _, body = w.expect(wire.FrameDispatch) |
| + if c := body.(*wire.DispatchCommand); c.TaskID != task || c.Specialist != wire.SpecialistChecks || c.CandidateSHA != sha { |
| + t.Fatalf("checks on the new Mac: %+v", c) |
| + } |
| +} |
| + |
| +// An exploration of an Xcode repository waits for a Mac under Needs you, |
| +// like any task, and can be cancelled from there. |
| +func TestContractExplorationWaitsForAMac(t *testing.T) { |
| + r := newRunnersRig(t) |
| + h := primaryHello(0) |
| + h.Catalog[0].NeedsMacOS = true |
| + r.primary.heartbeat(h) |
| + task := taskID(t, r.call("c-x", wire.ToolRecordTask, map[string]any{"repo": "oficina/sample", "title": "Mac mockups", "brief": "Two mockups.", "separate": true, "kind": wire.KindExplore})) |
| + r.call("s-x", wire.ToolStartTask, map[string]string{"task": task, "brief": "go"}) |
| + r.primary.none(wire.FrameDispatch, 200*time.Millisecond) |
| + if s := r.engineeringStep(task); s.State != wire.StepQueued || s.Placement != wire.PlacementMac { |
| + t.Fatalf("exploration engineering %+v", s) |
| + } |
| + if got := r.needsYou(task); got != wire.NeedsMacRunner { |
| + t.Fatalf("an exploration waiting for a Mac needs you %q", got) |
| + } |
| + if _, err := r.client.CancelTask(r.ctx, task); err != nil { |
| + t.Fatal(err) |
| + } |
| + if k, err := r.client.Task(r.ctx, task); err != nil || k.Stage != wire.StageCancelled || k.NeedsYou != "" { |
| + t.Fatalf("not cancelled: %+v %v", k, err) |
| + } |
| +} |
diff --git a/internal/thintest/macrecheck_contract_test.go b/internal/thintest/macrecheck_contract_test.go| index e76a16ca..6a592801 100644 |
| --- a/internal/thintest/macrecheck_contract_test.go |
| +++ b/internal/thintest/macrecheck_contract_test.go |
| @@ -8,20 +8,35 @@ import ( |
| "amadan.net/oficina/equipo/internal/wire" |
| ) |
| +// legacyMacChecks is an iOS change's checks as an instance before |
| +// 2026-11-28 placed them with no Mac enrolled: on the Linux primary, which |
| +// judged them not run (needs_macos). An instance now leaves them waiting |
| +// for a Mac runner (waiting_mac); the tasks that reached Ready to merge |
| +// that way before still wait for a Mac, and these contracts keep them. |
| +// The fixture moves the waiting step onto the primary as the old |
| +// placement did and returns its dispatch, for the primary to report. |
| +func (r *runnersRig) legacyMacChecks(task, sha string) *wire.DispatchCommand { |
| + r.t.Helper() |
| + s := r.checksStep(task) |
| + if s.Placement != wire.PlacementMac { |
| + r.t.Fatalf("checks not waiting for a Mac: %+v", s) |
| + } |
| + if _, err := r.inst.DB.Writer().Exec("UPDATE chat_steps SET placement = '', waiting_since = NULL, needs = '', runner_id = ? WHERE id = ?", r.primary.fr.Welcome.RunnerID, s.ID); err != nil { |
| + r.t.Fatal(err) |
| + } |
| + return &wire.DispatchCommand{TaskID: task, StepID: s.ID, Attempt: s.Attempt, Specialist: wire.SpecialistChecks, BaseSHA: s.BaseSHA, CandidateSHA: sha} |
| +} |
| + |
| // 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. |
| +// its checks end on the primary as not run (needs_macos, legacyMacChecks), |
| +// 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) |
| - } |
| + c := r.legacyMacChecks(task, sha) |
| r.checks(task+"-c", c, wire.ChecksCannotRun, nil, "needs_macos", "") |
| - _, body = r.expect(wire.FrameDispatch) |
| + _, 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 { |
diff --git a/internal/thintest/macrecheck_mergeauth_contract_test.go b/internal/thintest/macrecheck_mergeauth_contract_test.go| index a8fa7eff..e62664de 100644 |
| --- a/internal/thintest/macrecheck_mergeauth_contract_test.go |
| +++ b/internal/thintest/macrecheck_mergeauth_contract_test.go |
| @@ -13,13 +13,9 @@ import ( |
| func (r *runnersRig) waitingForMacMeasured(title string, paths ...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 { |
| - r.t.Fatalf("checks on the primary %+v", c) |
| - } |
| + c := r.legacyMacChecks(task, sha) |
| r.checks(task+"-c", c, wire.ChecksCannotRun, nil, "needs_macos", "") |
| - _, body = r.expect(wire.FrameDispatch) |
| + _, body := r.expect(wire.FrameDispatch) |
| rv := body.(*wire.DispatchCommand) |
| r.step(task+"-r", wire.StepReport{TaskID: rv.TaskID, StepID: rv.StepID, Attempt: rv.Attempt, State: wire.StepDone, BaseSHA: rv.BaseSHA, CandidateSHA: rv.CandidateSHA, Termination: true, Family: "codex", Account: "codex-a", Verdict: wire.VerdictApprove, ReviewLabel: wire.ReviewOtherFamily, Findings: []wire.Finding{}, Summary: "Read it.", Change: facts(rv, paths...)}) |
| card = r.mergeCardsWait(task) |
diff --git a/internal/thintest/placement_contract_test.go b/internal/thintest/placement_contract_test.go| index 37651b76..d7ea3885 100644 |
| --- a/internal/thintest/placement_contract_test.go |
| +++ b/internal/thintest/placement_contract_test.go |
| @@ -341,17 +341,14 @@ func TestContractChecksPlacedOnTheWorker(t *testing.T) { |
| } |
| } |
| -// M3 at the contract: with no worker that fits, checks go to the primary |
| -// with no needs and end there honestly (needs_macos), as before. |
| +// M3 at the contract: with no worker that fits, checks no longer go to |
| +// the Linux primary (2026-11-28): they wait for a Mac runner, nothing |
| +// dispatched (TestContractChecksWaitForAMacRunner follows them to a Mac). |
| func TestContractChecksWithoutAWorker(t *testing.T) { |
| r := newRunnersRig(t) |
| - task, sha := r.candidate("iOS swipe", true) |
| - _, body := r.expect(wire.FrameDispatch) |
| - d := body.(*wire.DispatchCommand) |
| - if d.Specialist != wire.SpecialistChecks || len(d.Needs) != 0 || d.CandidateSHA != sha { |
| - t.Fatalf("checks %+v", d) |
| - } |
| - if s := r.checksStep(task); s.Placement != "" || s.RunnerLabel != "docs-t1" { |
| + task, _ := r.candidate("iOS swipe", true) |
| + r.primary.none(wire.FrameDispatch, 200*time.Millisecond) |
| + if s := r.checksStep(task); s.Placement != wire.PlacementMac || s.RunnerID != "" { |
| t.Fatalf("checks step %+v", s) |
| } |
| } |
diff --git a/internal/wire/runners.go b/internal/wire/runners.go| index 50f45fca..0cf4dea7 100644 |
| --- a/internal/wire/runners.go |
| +++ b/internal/wire/runners.go |
| @@ -465,10 +465,17 @@ func Covers(tags, needs []string) bool { |
| // Placement of a step: "" placed on its runner; waiting_runner while the |
| // only runners that fit are offline; waiting_sandbox while the only Macs |
| // online that fit have not proven their sandbox (probe P2) or are |
| -// tainted, and nobody chose to run the checks outside it. |
| +// tainted, and nobody chose to run the checks outside it; waiting_mac |
| +// while Mac work (checks that need macOS, Engineering for a repository |
| +// whose gate needs Xcode) has no enrolled runner that fits, so it waits |
| +// for one rather than run on a Linux primary; waiting_mac_engineering |
| +// while the only runners that fit Mac Engineering are Mac workers, which |
| +// do not take Engineering yet. |
| const ( |
| - PlacementWaiting = "waiting_runner" |
| - PlacementSandbox = "waiting_sandbox" |
| + PlacementWaiting = "waiting_runner" |
| + PlacementSandbox = "waiting_sandbox" |
| + PlacementMac = "waiting_mac" |
| + PlacementMacEngineering = "waiting_mac_engineering" |
| ) |
| // Publication of a worker's Engineering candidate: only the primary |
diff --git a/internal/wire/tasks.go b/internal/wire/tasks.go| index 655a977d..6921efb5 100644 |
| --- a/internal/wire/tasks.go |
| +++ b/internal/wire/tasks.go |
| @@ -122,6 +122,12 @@ const ( |
| // themselves once it is proven, or the creator may choose to run them |
| // outside it. |
| NeedsMacSandbox = "mac_sandbox" |
| + // NeedsMacRunner: Mac work waits for a Mac runner to be added; it |
| + // starts by itself once one is. |
| + NeedsMacRunner = "mac_runner" |
| + // NeedsMacEngineering: Engineering for Mac work waits because a Mac |
| + // runner does not take Engineering yet, and it never runs on Linux. |
| + NeedsMacEngineering = "mac_engineering" |
| ) |
| // MaxRebaseRounds is how many times Engineering is sent to put the change |