Mac slice F task 16: M9g mixed versions; a worker downgrades its hello
TestMacMixedVersions builds main at the branch point (8bd40ed1, protocol 35) with the test build, cached as M8's slice 4 binary is, and runs: that worker with this primary, and this worker with that primary, both waiting waiting_mac_update and dispatched nowhere; and this worker against that instance (rolled back), which speaks 35 in its hello, queues nothing only 37 carries, keeps its Claude connection, and still takes checks. The last one found a bug: a slice F Mac's first hello, before any welcome, carried its F probes and Engineering status; a protocol 35 instance refuses a hello it cannot read, and the worker took that for a protocol 1 instance and stopped. Until a welcome says 37 a worker's hello now carries none of slice F's report (as its connections already wait), and the welcome at 37 asks for the whole report at once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+383
−25
internal/headless/env_test.go+14 −2internal/headless/m8_test.go+31 −10internal/headless/mac_mixed_test.go+305 −0internal/headless/mac_test.go+22 −10internal/runner/thin/run.go+11 −3
diff --git a/internal/headless/env_test.go b/internal/headless/env_test.go| index 5c465758..c71eb528 100644 |
| --- a/internal/headless/env_test.go |
| +++ b/internal/headless/env_test.go |
| @@ -182,8 +182,11 @@ type localRunner struct { |
| // test binary), not this one. |
| binary string |
| inst *thintest.Instance |
| - root string |
| - cmd *exec.Cmd |
| + // instanceDB is the database of an instance in another process (an |
| + // older release's), read to see this runner connect when inst is nil. |
| + instanceDB string |
| + root string |
| + cmd *exec.Cmd |
| mu sync.Mutex |
| cancel context.CancelFunc |
| @@ -564,6 +567,15 @@ func runnerProcess(path string) int { |
| func (r *localRunner) generation() int64 { |
| var g int64 |
| + if r.inst == nil { |
| + d, err := sql.Open("sqlite", "file:"+r.instanceDB+"?mode=ro&_pragma=busy_timeout(5000)") |
| + if err != nil { |
| + return 0 |
| + } |
| + defer d.Close() |
| + d.QueryRow("SELECT coalesce(max(generation),0) FROM runner_sessions WHERE connected = 1 AND runner_id = ?", r.runnerID).Scan(&g) |
| + return g |
| + } |
| if r.runnerID != "" { |
| r.inst.DB.Writer().QueryRow("SELECT coalesce(max(generation),0) FROM runner_sessions WHERE connected = 1 AND runner_id = ?", r.runnerID).Scan(&g) |
| return g |
diff --git a/internal/headless/m8_test.go b/internal/headless/m8_test.go| index e535670e..ea611ff2 100644 |
| --- a/internal/headless/m8_test.go |
| +++ b/internal/headless/m8_test.go |
| @@ -69,14 +69,27 @@ var oldOnce sync.Mutex |
| // and kept in EQUIPO_M8_CACHE when it is set (CI keeps it as an |
| // artifact), else in the test's own directory. |
| func oldBinary(t *testing.T) string { |
| + return oldBinaryAt(t, slice4, "", map[string]string{"m8_old_instance_test.go": oldInstanceTest}) |
| +} |
| + |
| +// oldBinaryAt is the headless test binary of commit, built with tags |
| +// ("" for none) and the extra test files (name: source) added to its |
| +// headless package, once, and cached as oldBinary says (by commit and |
| +// tags). Nothing is downloaded: the tree comes from git history and the |
| +// modules from the module cache (-mod=readonly). |
| +func oldBinaryAt(t *testing.T, commit, tags string, extra map[string]string) string { |
| t.Helper() |
| oldOnce.Lock() |
| defer oldOnce.Unlock() |
| + key := commit |
| + if tags != "" { |
| + key += "-" + tags |
| + } |
| cache := os.Getenv("EQUIPO_M8_CACHE") |
| - if cache == "" || os.MkdirAll(filepath.Join(cache, slice4), 0700) != nil { |
| + if cache == "" || os.MkdirAll(filepath.Join(cache, key), 0700) != nil { |
| cache = t.TempDir() |
| } |
| - bin := filepath.Join(cache, slice4, "headless.test") |
| + bin := filepath.Join(cache, key, "headless.test") |
| if info, err := os.Stat(bin); err == nil && info.Mode().IsRegular() { |
| return bin |
| } |
| @@ -88,7 +101,7 @@ func oldBinary(t *testing.T) string { |
| t.Fatalf("M8 needs the repository's history: %v", err) |
| } |
| src := t.TempDir() |
| - archive := exec.Command("git", "-C", strings.TrimSpace(string(top)), "archive", "--format=tar", slice4) |
| + archive := exec.Command("git", "-C", strings.TrimSpace(string(top)), "archive", "--format=tar", commit) |
| untar := exec.Command("tar", "-x", "-C", src) |
| pipe, _ := archive.StdoutPipe() |
| untar.Stdin = pipe |
| @@ -96,23 +109,31 @@ func oldBinary(t *testing.T) string { |
| t.Fatal(err) |
| } |
| if err := archive.Run(); err != nil { |
| - t.Fatalf("M8 needs commit %s in the repository's history: %v", slice4, err) |
| + t.Fatalf("M8 needs commit %s in the repository's history: %v", commit, err) |
| } |
| if err := untar.Wait(); err != nil { |
| t.Fatal(err) |
| } |
| - extra := filepath.Join(t.TempDir(), "m8_old_instance_test.go") |
| - if err := os.WriteFile(extra, []byte(oldInstanceTest), 0600); err != nil { |
| - t.Fatal(err) |
| + replace := map[string]string{} |
| + for name, body := range extra { |
| + file := filepath.Join(t.TempDir(), name) |
| + if err := os.WriteFile(file, []byte(body), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + replace[filepath.Join(src, "internal", "headless", name)] = file |
| } |
| overlay := filepath.Join(t.TempDir(), "overlay.json") |
| - raw, _ := json.Marshal(map[string]any{"Replace": map[string]string{filepath.Join(src, "internal", "headless", "m8_old_instance_test.go"): extra}}) |
| + raw, _ := json.Marshal(map[string]any{"Replace": replace}) |
| if err := os.WriteFile(overlay, raw, 0600); err != nil { |
| t.Fatal(err) |
| } |
| // Niced, two compile jobs: the build must not starve the packages |
| // testing beside it. |
| - args := []string{"go", "test", "-c", "-p", "2", "-overlay", overlay, "-o", bin + ".tmp", "./internal/headless"} |
| + args := []string{"go", "test", "-c", "-p", "2", "-overlay", overlay, "-o", bin + ".tmp"} |
| + if tags != "" { |
| + args = append(args, "-tags", tags) |
| + } |
| + args = append(args, "./internal/headless") |
| if nice, err := exec.LookPath("nice"); err == nil { |
| args = append([]string{nice, "-n", "15"}, args...) |
| } |
| @@ -120,7 +141,7 @@ func oldBinary(t *testing.T) string { |
| build.Dir = src |
| build.Env = append(os.Environ(), "CGO_ENABLED=0", "GOFLAGS=-mod=readonly") |
| if out, err := build.CombinedOutput(); err != nil { |
| - t.Fatalf("building slice 4 at %s: %v %s", slice4, err, out) |
| + t.Fatalf("building %s at %s: %v %s", key, commit, err, out) |
| } |
| if err := os.Rename(bin+".tmp", bin); err != nil { |
| t.Fatal(err) |
diff --git a/internal/headless/mac_mixed_test.go b/internal/headless/mac_mixed_test.go| new file mode 100644 |
| index 00000000..be7a82e5 |
| --- /dev/null |
| +++ b/internal/headless/mac_mixed_test.go |
| @@ -0,0 +1,305 @@ |
| +//go:build testbuild |
| + |
| +package headless |
| + |
| +import ( |
| + "bytes" |
| + "database/sql" |
| + "encoding/json" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "slices" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "amadan.net/oficina/equipo/internal/thintest" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// branchPoint is main where Mac runners slice F branched: protocol 35, |
| +// Mac work waiting for a Mac, no Engineering on one. M9g runs its |
| +// runner, fake Mac worker (the test build) and instance against this |
| +// branch's. |
| +const branchPoint = "8bd40ed15aae17b594ce2f0fe07e02978b80222f" |
| + |
| +// oldMacInstanceTest is added to the branch point's tree when its test |
| +// binary is built: an instance of that release, in its own process, with |
| +// a primary and a worker enrolled, until stdin closes. |
| +const oldMacInstanceTest = `package headless |
| + |
| +import ( |
| + "encoding/json" |
| + "io" |
| + "os" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/thintest" |
| +) |
| + |
| +func TestM9OldInstance(t *testing.T) { |
| + out := os.Getenv("EQUIPO_M9_OUT") |
| + if out == "" { |
| + t.Skip("M9g only") |
| + } |
| + inst := thintest.StartInstance(t) |
| + token := inst.DeviceToken(t) |
| + primary := inst.EnrolRunner(t) |
| + worker := inst.EnrolRunner(t) |
| + raw, _ := json.Marshal(map[string]any{"url": inst.URL, "team": inst.TeamID, "token": token, "db": inst.Path, "primary": primary, "worker": worker}) |
| + if err := os.WriteFile(out+".tmp", raw, 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Rename(out+".tmp", out); err != nil { |
| + t.Fatal(err) |
| + } |
| + _, _ = io.Copy(io.Discard, os.Stdin) |
| +} |
| +` |
| + |
| +// branchBinary is the branch point's headless test binary, with the |
| +// test build (its fake Mac worker) and the old instance above, built |
| +// once and cached as M8's is. |
| +func branchBinary(t *testing.T) string { |
| + return oldBinaryAt(t, branchPoint, "testbuild", map[string]string{"m9_old_instance_test.go": oldMacInstanceTest}) |
| +} |
| + |
| +// workerOnline waits for the worker labelled Tito Studio. |
| +func (s *session) workerOnline(t *testing.T) { |
| + t.Helper() |
| + s.wait(t, "the worker online", 30*time.Second, func(c *thintest.Conversation) bool { |
| + for _, r := range c.Runners { |
| + if r.Role == wire.RoleWorker && r.Online && r.Label == "Tito Studio" { |
| + return true |
| + } |
| + } |
| + return false |
| + }) |
| +} |
| + |
| +// waitsForUpdate sends a Panes change (Mac work) and waits for its |
| +// Engineering to wait for the update of who, never dispatched. |
| +func (s *session) waitsForUpdate(t *testing.T, inst *thintest.Instance, worker, who string) { |
| + t.Helper() |
| + sent := s.send(t, "tool:record_task:woodstar/panes|Pane titles, mixed|Say what each pane is for.\ntool:start_task:$task|edit:Woodstar/Swipe.swift|edgeSwipe = false|edgeSwipe = true") |
| + id := s.taskOf(t, sent.Turn.ID) |
| + s.wait(t, "Engineering waiting for the update", 2*time.Minute, func(c *thintest.Conversation) bool { |
| + return stepOf(c.Tasks[id], wire.SpecialistEngineering, 0).Placement == wire.PlacementMacUpdate |
| + }) |
| + k, err := s.env.Client.Task(s.ctx, id) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + eng := stepOf(k, wire.SpecialistEngineering, 0) |
| + var waits string |
| + if err := inst.DB.Writer().QueryRow("SELECT coalesce(sandbox_runner, '') FROM chat_steps WHERE id = ?", eng.ID).Scan(&waits); err != nil { |
| + t.Fatal(err) |
| + } |
| + if eng.State != wire.StepQueued || eng.RunnerID != "" || waits != who { |
| + t.Fatalf("waiting for %q to update: %+v (waits for %q)", who, eng, waits) |
| + } |
| + // A moment more: nothing is dispatched anywhere meanwhile. |
| + time.Sleep(2 * time.Second) |
| + var dispatched int |
| + if err := inst.DB.Writer().QueryRow("SELECT count(*) FROM runner_commands WHERE kind = ? AND instr(body, ?) > 0", wire.FrameDispatch, eng.ID).Scan(&dispatched); err != nil || dispatched != 0 { |
| + t.Fatalf("%d dispatches of the waiting Engineering step (%v)", dispatched, err) |
| + } |
| + if _, err := s.env.Client.CancelTask(s.ctx, id); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +func sessionProtocol(t *testing.T, inst *thintest.Instance, runner string) int { |
| + t.Helper() |
| + var p int |
| + if err := inst.DB.Writer().QueryRow("SELECT protocol FROM runner_sessions WHERE runner_id = ?", runner).Scan(&p); err != nil { |
| + t.Fatal(err) |
| + } |
| + return p |
| +} |
| + |
| +// M9g: mixed versions with main at the branch point (protocol 35). Mac |
| +// Engineering needs 37 on both the primary and the worker: either one |
| +// older, and it waits for that one's update (waiting_mac_update), |
| +// dispatched nowhere. A 37 worker against an instance rolled back to |
| +// the branch point speaks 35 in its hello, queues nothing only 37 |
| +// carries, and loses nothing: its Claude connection stays, and it still |
| +// takes checks. |
| +func TestMacMixedVersions(t *testing.T) { |
| + if testing.Short() { |
| + t.Skip("builds main at the branch point") |
| + } |
| + old := branchBinary(t) |
| + |
| + t.Run("old worker, new primary", func(t *testing.T) { |
| + env, inst, primary := localEnv(t) |
| + addWoodstar(t, primary.root, primary.opts.Forge.(*localForge)) |
| + woodstarCredentials(t, primary) |
| + primary.start(t) |
| + inst.Store.Chat().SetMacEngineering(true) |
| + worker, _ := macWorker(t, inst, primary) |
| + worker.binary = old |
| + worker.start(t) |
| + s := open(t, env) |
| + s.keep() |
| + s.workerOnline(t) |
| + if p := sessionProtocol(t, inst, worker.runnerID); p != wire.Protocol35 { |
| + t.Fatalf("the branch point's worker speaks %d", p) |
| + } |
| + s.waitsForUpdate(t, inst, worker.runnerID, worker.runnerID) |
| + }) |
| + |
| + t.Run("new worker, old primary", func(t *testing.T) { |
| + env, inst, primary := localEnv(t) |
| + addWoodstar(t, primary.root, primary.opts.Forge.(*localForge)) |
| + woodstarCredentials(t, primary) |
| + primary.subprocess, primary.binary = true, old |
| + primary.start(t) |
| + var primaryID string |
| + if err := inst.DB.Writer().QueryRow("SELECT runner_id FROM runner_sessions WHERE connected = 1").Scan(&primaryID); err != nil { |
| + t.Fatal(err) |
| + } |
| + inst.Store.Chat().SetMacEngineering(true) |
| + worker, _ := macWorker(t, inst, primary) |
| + worker.start(t) |
| + s := open(t, env) |
| + s.keep() |
| + s.workerOnline(t) |
| + if p, w := sessionProtocol(t, inst, primaryID), sessionProtocol(t, inst, worker.runnerID); p != wire.Protocol35 || w != wire.ProtocolMacEngineering { |
| + t.Fatalf("protocols: primary %d, worker %d", p, w) |
| + } |
| + s.waitsForUpdate(t, inst, worker.runnerID, primaryID) |
| + }) |
| + |
| + t.Run("new worker, old instance", func(t *testing.T) { |
| + out := filepath.Join(t.TempDir(), "instance.json") |
| + cmd := exec.Command(old, "-test.run", "^TestM9OldInstance$", "-test.timeout", "20m") |
| + cmd.Env = append(os.Environ(), "EQUIPO_M9_OUT="+out) |
| + stdin, _ := cmd.StdinPipe() |
| + var logs bytes.Buffer |
| + cmd.Stdout, cmd.Stderr = &logs, &logs |
| + if err := cmd.Start(); err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { |
| + stdin.Close() |
| + done := make(chan error, 1) |
| + go func() { done <- cmd.Wait() }() |
| + select { |
| + case <-done: |
| + case <-time.After(30 * time.Second): |
| + cmd.Process.Kill() |
| + <-done |
| + } |
| + }) |
| + var info struct { |
| + URL, Team, Token, DB string |
| + Primary, Worker runnerproto.RunnerCredential |
| + } |
| + for deadline := time.Now().Add(2 * time.Minute); ; time.Sleep(100 * time.Millisecond) { |
| + raw, err := os.ReadFile(out) |
| + if err == nil && json.Unmarshal(raw, &info) == nil { |
| + break |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatalf("the branch point's instance did not start: %s", logs.String()) |
| + } |
| + } |
| + primary, forge := runnerSetup(t, info.URL, info.Team, info.Primary) |
| + t.Cleanup(func() { primary.stop(t) }) |
| + addWoodstar(t, primary.root, forge) |
| + woodstarCredentials(t, primary) |
| + primary.start(t) |
| + worker, _ := macWorkerAs(t, info.Worker, primary) |
| + worker.instanceDB = info.DB |
| + worker.start(t) |
| + turns := 0 |
| + env := &Env{Client: thintest.NewClient(info.URL, info.Token), turns: &turns, ForgePath: forge.path} |
| + s := open(t, env) |
| + s.keep() |
| + s.workerOnline(t) |
| + // Its hello is a protocol 35 hello: none of slice F's fields. |
| + d, err := sql.Open("sqlite", "file:"+info.DB+"?mode=ro&_pragma=busy_timeout(5000)") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer d.Close() |
| + var protocol int |
| + var hello string |
| + if err := d.QueryRow("SELECT protocol, hello FROM runner_sessions WHERE runner_id = ?", info.Worker.RunnerID).Scan(&protocol, &hello); err != nil { |
| + t.Fatal(err) |
| + } |
| + var h wire.Hello |
| + if err := json.Unmarshal([]byte(hello), &h); err != nil || h.Capabilities == nil { |
| + t.Fatalf("hello %s: %v", hello, err) |
| + } |
| + if protocol != wire.Protocol35 || h.Capabilities.Engineering != nil || h.SealKey != "" || h.Inventory || len(h.Connections) != 0 || slices.ContainsFunc(h.Capabilities.Probes, func(p wire.Probe) bool { return strings.HasPrefix(p.ID, "F") }) { |
| + t.Fatalf("the worker's hello at %d: %s", protocol, hello) |
| + } |
| + // It still takes checks: a Swift change on Woodstar, checked on it. |
| + sent := s.send(t, "tool:record_task:woodstar/woodstar|iOS edge swipe, rolled back|Swipe back from the edge feels late.\ntool:start_task:$task|edit:Woodstar/Swipe.swift|edgeSwipe = false|edgeSwipe = true") |
| + id := s.taskOf(t, sent.Turn.ID) |
| + k := s.settled(t, id, 3*time.Minute) |
| + if c := stepOf(k, wire.SpecialistChecks, 0); c.Checks != wire.ChecksPassed || c.RunnerID != info.Worker.RunnerID { |
| + t.Fatalf("checks on the worker against the rolled-back instance: %+v (%s)", c, stepKinds(k)) |
| + } |
| + // It queued nothing only protocol 37 carries, and lost nothing it |
| + // sent: every frame of its outbox is a protocol 35 frame, acked. |
| + w, err := sql.Open("sqlite", "file:"+filepath.Join(worker.cfg.StateDir, "thin.db")+"?mode=ro&_pragma=busy_timeout(5000)") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer w.Close() |
| + for deadline := time.Now().Add(30 * time.Second); ; time.Sleep(200 * time.Millisecond) { |
| + var unacked int |
| + w.QueryRow("SELECT count(*) FROM outbox WHERE acked = 0").Scan(&unacked) |
| + if unacked == 0 { |
| + break |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatalf("%d frames of the worker never acked", unacked) |
| + } |
| + } |
| + rows, err := w.Query("SELECT id, kind, body FROM outbox") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + n := 0 |
| + for rows.Next() { |
| + var fid, kind, body string |
| + if err := rows.Scan(&fid, &kind, &body); err != nil { |
| + t.Fatal(err) |
| + } |
| + f := wire.Frame{ID: fid, Type: kind, Data: json.RawMessage(body)} |
| + at35, err := wire.Encode(f, wire.Protocol35) |
| + if err != nil || !jsonEqual(at35.Data, f.Data) { |
| + t.Fatalf("the worker queued more than protocol 35 carries: %v %s %s", err, kind, body) |
| + } |
| + n++ |
| + } |
| + rows.Close() |
| + // Its own Claude connection is still on disk, for a 37 instance. |
| + raw, err := os.ReadFile(worker.cfg.AccountBindingsPath) |
| + if err != nil || !strings.Contains(string(raw), `"`+macClaude+`"`) { |
| + t.Fatalf("the worker's bindings after the rolled-back instance: %s %v", raw, err) |
| + } |
| + if _, err := os.Stat(filepath.Join(worker.root, "accounts", macClaude, provider.TokenFile)); err != nil { |
| + t.Fatalf("the worker's token: %v", err) |
| + } |
| + t.Logf("rolled back: worker at %d, %d frames, task %s %s", protocol, n, id, k.Stage) |
| + }) |
| +} |
| + |
| +// jsonEqual compares two JSON documents by value. |
| +func jsonEqual(a, b []byte) bool { |
| + var x, y any |
| + if json.Unmarshal(a, &x) != nil || json.Unmarshal(b, &y) != nil { |
| + return false |
| + } |
| + ax, _ := json.Marshal(x) |
| + by, _ := json.Marshal(y) |
| + return bytes.Equal(ax, by) |
| +} |
diff --git a/internal/headless/mac_test.go b/internal/headless/mac_test.go| index 41ba52ff..470cf523 100644 |
| --- a/internal/headless/mac_test.go |
| +++ b/internal/headless/mac_test.go |
| @@ -21,6 +21,7 @@ import ( |
| "amadan.net/oficina/equipo/internal/equipo/chat" |
| "amadan.net/oficina/equipo/internal/runner/thin" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| "amadan.net/oficina/equipo/internal/thintest" |
| "amadan.net/oficina/equipo/internal/wire" |
| ) |
| @@ -88,13 +89,21 @@ func seedIOS(t *testing.T, root string, f *localForge, repo string, gate map[str |
| // beside its gate's tools; it holds one Claude token connection of its |
| // own (macClaude), which only it can use. |
| func macWorker(t *testing.T, inst *thintest.Instance, primary *localRunner) (*localRunner, string) { |
| + t.Helper() |
| + w, xcodebuild := macWorkerAs(t, inst.EnrolRunner(t), primary) |
| + w.inst = inst |
| + return w, xcodebuild |
| +} |
| + |
| +// macWorkerAs is macWorker enrolled as cred (on an instance that may run |
| +// in another process: set inst or instanceDB before start). |
| +func macWorkerAs(t *testing.T, cred runnerproto.RunnerCredential, primary *localRunner) (*localRunner, string) { |
| t.Helper() |
| root := private(t, filepath.Join(primary.root, "mac")) |
| bin := private(t, filepath.Join(root, "bin")) |
| copyExecutable(t, filepath.Join(bin, "xcodebuild")) |
| copyExecutable(t, filepath.Join(bin, "gitleaks")) |
| state := private(t, filepath.Join(root, "state")) |
| - cred := inst.EnrolRunner(t) |
| if err := thintest.WriteRunnerCredential(state, cred); err != nil { |
| t.Fatal(err) |
| } |
| @@ -103,7 +112,7 @@ func macWorker(t *testing.T, inst *thintest.Instance, primary *localRunner) (*lo |
| cfg.StateDir, cfg.WorkspaceRoot, cfg.ScratchRoot, cfg.MachineLabel = state, filepath.Join(root, "work"), filepath.Join(root, "scratch"), "Tito Studio" |
| cfg.AccountBindingsPath = filepath.Join(config, "bindings.json") |
| writeJSON(t, cfg.AccountBindingsPath, []map[string]any{}) |
| - w := &localRunner{inst: inst, root: root, cfg: cfg, subprocess: true, runnerID: cred.RunnerID, opts: thin.Options{Version: "test", Logger: slog.New(slog.NewTextHandler(io.Discard, nil)), FakePlatform: "darwin/arm64", FakeBin: bin, FakeSandbox: wire.SandboxSeatbelt, Claude: primary.opts.Claude, AccountsRoot: private(t, filepath.Join(root, "accounts")), MaxStep: time.Minute}} |
| + w := &localRunner{root: root, cfg: cfg, subprocess: true, runnerID: cred.RunnerID, opts: thin.Options{Version: "test", Logger: slog.New(slog.NewTextHandler(io.Discard, nil)), FakePlatform: "darwin/arm64", FakeBin: bin, FakeSandbox: wire.SandboxSeatbelt, Claude: primary.opts.Claude, AccountsRoot: private(t, filepath.Join(root, "accounts")), MaxStep: time.Minute}} |
| w.addToken(t, macClaude, "mac@example.com") |
| t.Cleanup(func() { |
| w.stop(t) |
| @@ -192,6 +201,16 @@ func macCaps(t *testing.T, inst *thintest.Instance, runner string) wire.Capabili |
| return *h.Capabilities |
| } |
| +// woodstarCredentials gives the primary forge credentials that name the |
| +// Woodstar repositories, as a real primary's do: a publication's file |
| +// list is screened against them before it leaves (without them it is |
| +// withheld). |
| +func woodstarCredentials(t *testing.T, primary *localRunner) { |
| + t.Helper() |
| + creds := map[string]any{"agent": "equipo-test", "repositories": map[string]any{woodstar: map[string]string{"api": "amk_test_woodstar", "git": "git_test_woodstar"}, panes: map[string]string{"api": "amk_test_panes", "git": "git_test_panes"}}} |
| + writeJSON(t, primary.cfg.AmadanCredentialPath, creds) |
| +} |
| + |
| // macClaude is the fake Mac's own Claude token connection. |
| const macClaude = "mac-claude" |
| @@ -307,14 +326,7 @@ func (s *session) mergeWorkerPass(t *testing.T, id string, timeout time.Duration |
| func TestMacWorker(t *testing.T) { |
| env, inst, primary := localEnv(t) |
| addWoodstar(t, primary.root, primary.opts.Forge.(*localForge)) |
| - // The primary's forge credentials name the Woodstar repositories, as |
| - // a real primary's do: a publication's file list is screened against |
| - // them before it leaves (without them it is withheld). |
| - creds := map[string]any{"agent": "equipo-test", "repositories": map[string]any{woodstar: map[string]string{"api": "amk_test_woodstar", "git": "git_test_woodstar"}, panes: map[string]string{"api": "amk_test_panes", "git": "git_test_panes"}}} |
| - writeJSON(t, primary.cfg.AmadanCredentialPath, creds) |
| - if err := os.Chmod(primary.cfg.AmadanCredentialPath, 0600); err != nil { |
| - t.Fatal(err) |
| - } |
| + woodstarCredentials(t, primary) |
| primary.start(t) |
| worker, xcodebuild := macWorker(t, inst, primary) |
| worker.start(t) |
diff --git a/internal/runner/thin/run.go b/internal/runner/thin/run.go| index 8f45bf25..4175c33b 100644 |
| --- a/internal/runner/thin/run.go |
| +++ b/internal/runner/thin/run.go |
| @@ -785,10 +785,17 @@ func runWorker(ctx context.Context, c runner.Config, o Options, platform wire.Pl |
| link.Hello = func() wire.Hello { |
| report := caps.Get(ctx) |
| h := wire.Hello{Repos: []string{}, CreateIn: []string{}, Catalog: []wire.RepoInfo{}, Connections: []wire.HeldConnection{}, Versions: map[string]string{"runner": o.Version}, Platform: &platform, Label: c.MachineLabel, Sandbox: w.gate.Sandbox(), Capabilities: &report} |
| + spoken, _ := link.Spoken() |
| if own != nil { |
| - spoken, _ := link.Spoken() |
| own.hello(spoken, &h) |
| } |
| + if spoken < wire.ProtocolMacEngineering { |
| + // Before a welcome says 37 (and below it) none of slice F's |
| + // report either: an older instance refuses a hello it cannot |
| + // read, and a worker it refuses takes it for protocol 1 and |
| + // stops (M9g). The welcome at 37 asks for the whole report. |
| + wire.WithoutMacEngineering(&h) |
| + } |
| return h |
| } |
| // Its owners include the person it is enrolled for, as on the primary: |
| @@ -834,8 +841,9 @@ func runWorker(ctx context.Context, c runner.Config, o Options, platform wire.Pl |
| if w.welcomed != nil { |
| w.welcomed(welcome, worker, cancel) |
| } |
| - if own != nil { |
| - // The first hello said no connections: the next says them. |
| + if spoken, _ := link.Spoken(); own != nil || spoken >= wire.ProtocolMacEngineering { |
| + // The first hello said no connections and none of slice F's |
| + // report: the next says them. |
| link.HelloSoon() |
| } |
| } |