oficina / equipo Public

Mac worker wired in: install, probes, gates, update, labels

Runner: on darwin, thin.Run serves as a Mac worker. Each attempt's gate
follows the probe report (srt and seatbelt only when P2 denied; srt
labelled none when the fixture at least built under srt; otherwise no
sandbox, labelled none). Trees live under the scratch root, outside the
denied state dir; a repository without a gate but with an Xcode
project gets xcodebuild test. Probes run at start when the saved
report is not this version's, and steps wait for them; `equipo-runner
probe` runs them on demand. The worker updates itself to its
instance's release (darwin target, digest, swapped between steps, exit
75 for launchd). run --env-file reads the agent's environment file.
The fake worker now runs the Mac's process-group gate.

Install on a Mac: refuses root, admins, users not named equipo-* and a
readable foreign home; copies the verified runner, npm ci the pinned
srt lockfile, writes runner.env, enrols, loads the launchd agent.
The enrolment link carries its code: opening it shows "Add <machine>
to your team" with the one confirmed button.

Instance: migration 0055 adds chat_steps.checks_sandbox; a worker's
checks carry seatbelt or none, step and task show it, and checks that
ran outside the sandbox say so on the line, badge, timeline and card.
The runners view shows platform, where checks run and the probes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 4ebf75a8f17ffc719c5f79baff2bae7ec07dfd2c parent 0b4d533
39 files changed, +2,045 −171
  • cmd/equipo-runner/install_mac.go +218 −0
  • cmd/equipo-runner/install_mac_test.go +205 −0
  • cmd/equipo-runner/main.go +70 −3
  • cmd/equipo-runner/platform.go +6 −0
  • internal/equipo/chat/tasks.go +17 −2
  • internal/equipo/copy.go +57 −0
  • internal/equipo/mac_view_test.go +55 −0
  • internal/equipo/migrations/0055_thin_checks_sandbox.sql +1 −0
  • internal/equipo/migrations/schema.sql +1 −1
  • internal/equipo/runner_handlers.go +11 −0
  • internal/equipo/runners.go +31 −0
  • internal/equipo/setup/runner_models.go +12 −0
  • internal/equipo/templates/runners.html +4 −1
  • internal/equipo/work_pages.go +17 −7
  • internal/equipo/work_views.go +5 −5
  • internal/equipotest/enrolment_link_test.go +48 −0
  • internal/release/install.go +34 −0
  • internal/runner/config.go +29 −1
  • internal/runner/config_test.go +24 −0
  • internal/runner/enrol.go +4 −1
  • internal/runner/mac/account_test.go +12 −0
  • internal/runner/mac/gate.go +7 −0
  • internal/runner/mac/srt.go +39 −0
  • internal/runner/mac/srt/package-lock.json +64 −0
  • internal/runner/mac/srt/package.json +8 −0
  • internal/runner/onboarding_test.go +2 −1
  • internal/runner/setup/service.go +10 −1
  • internal/runner/thin/fakeworker_testbuild.go +9 −123
  • internal/runner/thin/judge.go +2 −0
  • internal/runner/thin/link.go +6 −0
  • internal/runner/thin/mac.go +433 −0
  • internal/runner/thin/mac_test.go +214 −0
  • internal/runner/thin/run.go +42 −10
  • internal/runner/thin/worker.go +44 −4
  • internal/runner/thin/worker_test.go +5 −4
  • internal/thintest/fakerunner.go +2 −1
  • internal/thintest/placement_contract_test.go +21 −2
  • internal/wire/tasks.go +10 −4
  • scripts/runner-reference-allowlist.json +266 −0
diff --git a/cmd/equipo-runner/install_mac.go b/cmd/equipo-runner/install_mac.go
new file mode 100644
index 00000000..fe059cc6
--- /dev/null
+++ b/cmd/equipo-runner/install_mac.go
@@ -0,0 +1,218 @@
+package main
+
+import (
+ "context"
+ "errors"
+ "flag"
+ "fmt"
+ "io"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "sort"
+ "strconv"
+ "strings"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/release"
+ "amadan.net/oficina/equipo/internal/runner"
+ "amadan.net/oficina/equipo/internal/runner/mac"
+ runnersetup "amadan.net/oficina/equipo/internal/runner/setup"
+ "amadan.net/rastrillo/rastrillo"
+)
+
+// macInstallHost is what installing on a Mac touches; tests stand in.
+type macInstallHost struct {
+ goos, goarch, home, users, self string
+ exec mac.Exec
+ listHome func(string) bool
+ // node finds Node.js; npmCI installs the pinned srt into prefix with
+ // the npm beside it.
+ node func() string
+ npmCI func(ctx context.Context, npm, prefix string) error
+ enrol func(ctx context.Context, cfg runner.Config, out io.Writer) error
+ // launchctl runs launchctl; firstLaunch runs xcodebuild -runFirstLaunch.
+ launchctl func(ctx context.Context, args ...string) error
+ firstLaunch func(ctx context.Context)
+}
+
+func realMacInstallHost() macInstallHost {
+ home, _ := os.UserHomeDir()
+ self, _ := os.Executable()
+ run := func(ctx context.Context, name string, args ...string) error {
+ return exec.CommandContext(ctx, name, args...).Run()
+ }
+ return macInstallHost{goos: goos(), goarch: goarch(), home: home, users: "/Users", self: self, exec: func(ctx context.Context, name string, args ...string) (string, error) {
+ out, err := exec.CommandContext(ctx, name, args...).Output()
+ return string(out), err
+ }, listHome: mac.CanList, node: func() string { return findNode(home) },
+ npmCI: func(ctx context.Context, npm, prefix string) error {
+ cmd := exec.CommandContext(ctx, npm, "ci", "--prefix", prefix, "--ignore-scripts", "--omit=dev", "--no-audit", "--no-fund")
+ cmd.Env = append(os.Environ(), "PATH="+filepath.Dir(npm)+":/usr/bin:/bin")
+ return cmd.Run()
+ },
+ enrol: runner.Enrol,
+ launchctl: func(ctx context.Context, args ...string) error { return run(ctx, "/bin/launchctl", args...) },
+ firstLaunch: func(ctx context.Context) {
+ c, cancel := context.WithTimeout(ctx, 10*time.Minute)
+ defer cancel()
+ _ = run(c, "/usr/bin/xcodebuild", "-runFirstLaunch")
+ },
+ }
+}
+
+// installMac installs a Mac worker for the user running it (Mac runners
+// spec §3.2): refuses root, administrators, users not named equipo-*
+// and a readable foreign home; copies the verified runner into
+// ~/.local/lib/equipo-runner; installs the pinned srt; writes the
+// environment file; enrols (the link Paul taps); then loads the launchd
+// agent, whose runner probes the Mac by itself.
+func installMac(ctx context.Context, args []string, h macInstallHost, out, errout io.Writer) int {
+ say := func(key string, a ...any) { fmt.Fprintf(errout, equipo.RunnerSetupCopy(key)+"\n", a...) }
+ fail := func(key string, a ...any) int { say(key, a...); return 1 }
+ flags := flag.NewFlagSet("install", flag.ContinueOnError)
+ flags.SetOutput(io.Discard)
+ instance := flags.String("instance", "", "")
+ version := flags.String("release", "", "")
+ origin := flags.String("origin", "", "")
+ if flags.Parse(args) != nil || flags.NArg() != 0 || *instance == "" || *version != rastrillo.BuildVersion || !release.InstallOrigin(*origin) || !release.ValidInstallVersion(*version) {
+ return fail("runner.install.release")
+ }
+ if h.goos != "darwin" || h.goarch != "arm64" {
+ return fail("runner.mac.platform")
+ }
+ account, err := mac.ReadAccount(ctx, h.exec)
+ if err != nil {
+ return fail("runner.install.unavailable")
+ }
+ if key := mac.RefuseAccount(account); key != "" {
+ return fail(key)
+ }
+ if h.home == "" || filepath.Base(h.home) != account.Name {
+ return fail("runner.install.destination")
+ }
+ if readable := mac.ReadableHomes(mac.OtherHomes(h.users, h.home), h.listHome); len(readable) > 0 {
+ return fail("runner.mac.home", strings.Join(readable, " "), strings.Join(readable, " "))
+ }
+ lib := filepath.Join(h.home, ".local", "lib", "equipo-runner")
+ share := filepath.Join(h.home, ".local", "share", "equipo-runner")
+ conf := filepath.Join(h.home, ".config", "equipo-runner")
+ logs := filepath.Join(h.home, "Library", "Logs", "equipo-runner")
+ agents := filepath.Join(h.home, "Library", "LaunchAgents")
+ for _, d := range []string{lib, filepath.Join(share, "state"), filepath.Join(share, "work"), filepath.Join(share, "scratch"), conf, logs} {
+ if err := os.MkdirAll(d, 0700); err != nil {
+ return fail("runner.install.destination")
+ }
+ }
+ if err := os.MkdirAll(agents, 0755); err != nil {
+ return fail("runner.install.destination")
+ }
+ binary := filepath.Join(lib, "equipo-runner")
+ if err := copyPrivate(h.self, binary, 0700); err != nil {
+ return fail("runner.install.destination")
+ }
+ values := map[string]string{"EQUIPO_ORIGIN": *origin, "EQUIPO_INSTANCE_ID": *instance, "EQUIPO_RUNNER_STATE_DIR": filepath.Join(share, "state"), "EQUIPO_WORKSPACE_ROOT": filepath.Join(share, "work"), "EQUIPO_SCRATCH_ROOT": filepath.Join(share, "scratch"), "EQUIPO_GIT_PATH": "/usr/bin/git"}
+ if node := h.node(); node == "" {
+ say("runner.mac.no_node")
+ } else {
+ prefix := filepath.Join(lib, "srt")
+ pkg, lock := mac.SRTPackage()
+ if os.MkdirAll(prefix, 0700) != nil || os.WriteFile(filepath.Join(prefix, "package.json"), pkg, 0600) != nil || os.WriteFile(filepath.Join(prefix, "package-lock.json"), lock, 0600) != nil {
+ return fail("runner.install.destination")
+ }
+ if err := h.npmCI(ctx, filepath.Join(filepath.Dir(node), "npm"), prefix); err != nil {
+ say("runner.mac.no_srt")
+ } else {
+ values["EQUIPO_SRT_PATH"] = filepath.Join(prefix, "node_modules", ".bin", "srt")
+ }
+ values["EQUIPO_NODE_PATH"] = node
+ }
+ h.firstLaunch(ctx)
+ label := mac.ComputerName(ctx, h.exec)
+ if label == "" || len(label) > 80 || strings.ContainsAny(label, "\r\n\x00") {
+ label = "Mac"
+ }
+ values["EQUIPO_MACHINE_LABEL"] = label
+ envFile := filepath.Join(conf, "runner.env")
+ if err := writeEnvFile(envFile, values); err != nil {
+ return fail("runner.install.config")
+ }
+ cfg := runner.Config{Origin: *origin, InstanceID: *instance, StateDir: values["EQUIPO_RUNNER_STATE_DIR"], WorkspaceRoot: values["EQUIPO_WORKSPACE_ROOT"], ScratchRoot: values["EQUIPO_SCRATCH_ROOT"], GitPath: values["EQUIPO_GIT_PATH"], MachineLabel: label, Executable: binary, WorkerOnly: true}
+ say("runner.mac.tap")
+ if err := h.enrol(ctx, cfg, out); err != nil {
+ return fail("runner.install.unavailable")
+ }
+ plist := filepath.Join(agents, mac.AgentLabel+".plist")
+ if err := os.WriteFile(plist, mac.LaunchAgent(binary, envFile, logs), 0644); err != nil {
+ return fail("runner.install.service")
+ }
+ domain := "gui/" + strconv.Itoa(account.UID)
+ _ = h.launchctl(ctx, "bootout", domain+"/"+mac.AgentLabel)
+ if err := h.launchctl(ctx, "bootstrap", domain, plist); err != nil {
+ return fail("runner.install.service")
+ }
+ say("runner.mac.installed")
+ return 0
+}
+
+// findNode is Node.js where a Mac usually has it.
+func findNode(home string) string {
+ for _, d := range []string{"/opt/homebrew/bin", "/usr/local/bin", filepath.Join(home, ".local", "bin")} {
+ p := filepath.Join(d, "node")
+ if info, err := os.Stat(p); err == nil && info.Mode().IsRegular() && info.Mode().Perm()&0111 != 0 {
+ return p
+ }
+ }
+ return ""
+}
+
+func writeEnvFile(path string, values map[string]string) error {
+ keys := make([]string, 0, len(values))
+ for k := range values {
+ keys = append(keys, k)
+ }
+ sort.Strings(keys)
+ var b strings.Builder
+ for _, k := range keys {
+ fmt.Fprintf(&b, "%s=%s\n", k, strconv.Quote(values[k]))
+ }
+ tmp := path + ".new"
+ if err := os.WriteFile(tmp, []byte(b.String()), 0600); err != nil {
+ return err
+ }
+ if err := os.Chmod(tmp, 0600); err != nil {
+ return err
+ }
+ if err := os.Rename(tmp, path); err != nil {
+ return err
+ }
+ // Read it back the way the agent will.
+ _, err := runnersetup.ReadEnvFile(path)
+ return err
+}
+
+func copyPrivate(src, dst string, mode os.FileMode) error {
+ if src == "" {
+ return errors.New("no source")
+ }
+ raw, err := os.ReadFile(src)
+ if err != nil {
+ return err
+ }
+ tmp, err := os.CreateTemp(filepath.Dir(dst), ".equipo-runner-")
+ if err != nil {
+ return err
+ }
+ defer os.Remove(tmp.Name())
+ if _, err = tmp.Write(raw); err == nil {
+ err = tmp.Chmod(mode)
+ }
+ if cerr := tmp.Close(); err == nil {
+ err = cerr
+ }
+ if err != nil {
+ return err
+ }
+ return os.Rename(tmp.Name(), dst)
+}
diff --git a/cmd/equipo-runner/install_mac_test.go b/cmd/equipo-runner/install_mac_test.go
new file mode 100644
index 00000000..31c99bbf
--- /dev/null
+++ b/cmd/equipo-runner/install_mac_test.go
@@ -0,0 +1,205 @@
+package main
+
+import (
+ "bytes"
+ "context"
+ "errors"
+ "io"
+ "os"
+ "path/filepath"
+ "slices"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/runner"
+ "amadan.net/oficina/equipo/internal/runner/mac"
+ runnersetup "amadan.net/oficina/equipo/internal/runner/setup"
+ "amadan.net/rastrillo/rastrillo"
+)
+
+type macRig struct {
+ h macInstallHost
+ home string
+ ids map[string]string
+ calls []string
+ enrolled *runner.Config
+ readable map[string]bool
+ node string
+}
+
+func newMacRig(t *testing.T) *macRig {
+ t.Helper()
+ old := rastrillo.BuildVersion
+ rastrillo.BuildVersion = "abc1234"
+ t.Cleanup(func() { rastrillo.BuildVersion = old })
+ root := t.TempDir()
+ users := filepath.Join(root, "Users")
+ x := &macRig{home: filepath.Join(users, "equipo-paul"), ids: map[string]string{"-un": "equipo-paul\n", "-u": "502\n", "-Gn": "staff everyone localaccounts _developer\n"}, readable: map[string]bool{}, node: "/opt/homebrew/bin/node"}
+ for _, d := range []string{x.home, filepath.Join(users, "paul"), filepath.Join(users, "Shared")} {
+ if err := os.MkdirAll(d, 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
+ self := filepath.Join(root, "downloaded-equipo-runner")
+ if err := os.WriteFile(self, []byte("#!verified runner\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ x.h = macInstallHost{goos: "darwin", goarch: "arm64", home: x.home, users: users, self: self,
+ exec: func(_ context.Context, name string, args ...string) (string, error) {
+ switch name {
+ case "/usr/bin/id":
+ return x.ids[args[0]], nil
+ case "/usr/sbin/scutil":
+ return "Tito Studio\n", nil
+ }
+ return "", errors.New("unexpected " + name)
+ },
+ listHome: func(p string) bool { return x.readable[filepath.Base(p)] },
+ node: func() string { return x.node },
+ npmCI: func(_ context.Context, npm, prefix string) error {
+ x.calls = append(x.calls, "npm "+npm+" "+prefix)
+ if _, err := os.Stat(filepath.Join(prefix, "package-lock.json")); err != nil {
+ return err
+ }
+ return nil
+ },
+ enrol: func(_ context.Context, cfg runner.Config, out io.Writer) error {
+ x.enrolled = &cfg
+ _, _ = io.WriteString(out, "[https://equipo.example/runners/enrol?code=ABCDEFGHIJ](https://equipo.example/runners/enrol?code=ABCDEFGHIJ)\nABCDEFGHIJ\n")
+ return nil
+ },
+ launchctl: func(_ context.Context, args ...string) error {
+ x.calls = append(x.calls, "launchctl "+strings.Join(args, " "))
+ return nil
+ },
+ firstLaunch: func(context.Context) { x.calls = append(x.calls, "firstLaunch") },
+ }
+ return x
+}
+
+func (x *macRig) install() (int, string, string) {
+ var out, errout bytes.Buffer
+ code := installMac(context.Background(), []string{"--release", "abc1234", "--origin", "https://equipo.example", "--instance", "team1"}, x.h, &out, &errout)
+ return code, out.String(), errout.String()
+}
+
+// The installer refuses before touching anything: not a Mac, root, an
+// administrator, a user not named equipo-*, a home of another person
+// this user can open.
+func TestInstallMacRefusals(t *testing.T) {
+ for name, c := range map[string]struct {
+ set func(*macRig)
+ want string
+ }{
+ "linux": {func(x *macRig) { x.h.goos = "linux" }, "runner.mac.platform"},
+ "intel": {func(x *macRig) { x.h.goarch = "amd64" }, "runner.mac.platform"},
+ "root": {func(x *macRig) { x.ids["-u"], x.ids["-un"] = "0\n", "root\n" }, "runner.mac.root"},
+ "administrator": {func(x *macRig) { x.ids["-Gn"] = "staff admin _developer\n" }, "runner.mac.admin"},
+ "own account": {func(x *macRig) { x.ids["-un"] = "paul\n" }, "runner.mac.user"},
+ "shared user": {func(x *macRig) { x.ids["-un"] = "equipo\n" }, "runner.mac.user"},
+ "readable home": {func(x *macRig) { x.readable["paul"] = true }, "runner.mac.home"},
+ "another's home": {func(x *macRig) { x.h.home = filepath.Join(filepath.Dir(x.home), "paul") }, "runner.install.destination"},
+ } {
+ x := newMacRig(t)
+ c.set(x)
+ code, _, errout := x.install()
+ want := equipo.RunnerSetupCopy(c.want)
+ if c.want == "runner.mac.home" {
+ want = strings.SplitN(want, "(", 2)[0]
+ }
+ if code != 1 || !strings.Contains(errout, want) || x.enrolled != nil || len(x.calls) != 0 {
+ t.Fatalf("%s: code %d %q calls %v", name, code, errout, x.calls)
+ }
+ if _, err := os.Stat(filepath.Join(x.home, ".local")); !os.IsNotExist(err) {
+ t.Fatalf("%s: installed something", name)
+ }
+ }
+}
+
+// One command: the verified runner copied into ~/.local/lib, srt
+// installed from the pinned lockfile, a private env file, the link
+// printed for Paul to tap (enrolled as a worker named for the Mac),
+// then the launchd agent written and loaded.
+func TestInstallMac(t *testing.T) {
+ x := newMacRig(t)
+ code, out, errout := x.install()
+ if code != 0 {
+ t.Fatalf("code %d: %s", code, errout)
+ }
+ lib := filepath.Join(x.home, ".local/lib/equipo-runner")
+ if raw, _ := os.ReadFile(filepath.Join(lib, "equipo-runner")); string(raw) != "#!verified runner\n" {
+ t.Fatal("runner not installed")
+ }
+ if !strings.Contains(out, "(https://equipo.example/runners/enrol?code=ABCDEFGHIJ)") || !strings.Contains(errout, equipo.RunnerSetupCopy("runner.mac.tap")) || !strings.Contains(errout, equipo.RunnerSetupCopy("runner.mac.installed")) {
+ t.Fatalf("out %q err %q", out, errout)
+ }
+ env := filepath.Join(x.home, ".config/equipo-runner/runner.env")
+ values, err := runnersetup.ReadEnvFile(env)
+ if err != nil {
+ t.Fatal(err)
+ }
+ share := filepath.Join(x.home, ".local/share/equipo-runner")
+ for k, v := range map[string]string{"EQUIPO_ORIGIN": "https://equipo.example", "EQUIPO_INSTANCE_ID": "team1", "EQUIPO_RUNNER_STATE_DIR": share + "/state", "EQUIPO_SCRATCH_ROOT": share + "/scratch", "EQUIPO_WORKSPACE_ROOT": share + "/work", "EQUIPO_MACHINE_LABEL": "Tito Studio", "EQUIPO_SRT_PATH": lib + "/srt/node_modules/.bin/srt", "EQUIPO_NODE_PATH": "/opt/homebrew/bin/node", "EQUIPO_GIT_PATH": "/usr/bin/git"} {
+ if values[k] != v {
+ t.Fatalf("%s=%q, want %q", k, values[k], v)
+ }
+ }
+ if x.enrolled == nil || !x.enrolled.WorkerOnly || x.enrolled.MachineLabel != "Tito Studio" || x.enrolled.StateDir != share+"/state" {
+ t.Fatalf("enrolled %+v", x.enrolled)
+ }
+ plist := filepath.Join(x.home, "Library/LaunchAgents/io.amadan.equipo-runner.plist")
+ raw, err := os.ReadFile(plist)
+ if err != nil || !bytes.Equal(raw, mac.LaunchAgent(filepath.Join(lib, "equipo-runner"), env, filepath.Join(x.home, "Library/Logs/equipo-runner"))) {
+ t.Fatalf("plist %v", err)
+ }
+ want := []string{"npm /opt/homebrew/bin/npm " + lib + "/srt", "firstLaunch", "launchctl bootout gui/502/io.amadan.equipo-runner", "launchctl bootstrap gui/502 " + plist}
+ if !slices.Equal(x.calls, want) {
+ t.Fatalf("calls %v", x.calls)
+ }
+ // Without Node: one line, no srt, checks run outside the sandbox and
+ // say so.
+ x = newMacRig(t)
+ x.node = ""
+ if code, _, errout := x.install(); code != 0 || !strings.Contains(errout, equipo.RunnerSetupCopy("runner.mac.no_node")) {
+ t.Fatalf("no node: %d %q", code, errout)
+ }
+ values, _ = runnersetup.ReadEnvFile(filepath.Join(x.home, ".config/equipo-runner/runner.env"))
+ if _, ok := values["EQUIPO_SRT_PATH"]; ok {
+ t.Fatal("srt path without srt")
+ }
+}
+
+func TestEnvFileAndExits(t *testing.T) {
+ for _, c := range []struct {
+ in []string
+ rest []string
+ file string
+ ok bool
+ }{
+ {[]string{"run"}, []string{"run"}, "", true},
+ {[]string{"run", "--env-file", "/x/runner.env"}, []string{"run"}, "/x/runner.env", true},
+ {[]string{"probe", "--env-file", "/x/runner.env"}, []string{"probe"}, "/x/runner.env", true},
+ {[]string{"enrol", "--env-file", "/x/runner.env"}, nil, "", false},
+ {[]string{"run", "--env-file"}, nil, "", false},
+ {[]string{"run", "--env-file", "/a", "--env-file", "/b"}, nil, "", false},
+ } {
+ rest, file, ok := cutEnvFile(c.in)
+ if ok != c.ok || file != c.file || !slices.Equal(rest, c.rest) {
+ t.Fatalf("%v: %v %q %v", c.in, rest, file, ok)
+ }
+ }
+ if supersededExit("darwin") != 0 || supersededExit("linux") != 3 || mac.ExitUpdated == 0 {
+ t.Fatal("exit statuses")
+ }
+ // The file is what the runner reads: a bad origin in it is reported.
+ dir := t.TempDir()
+ env := filepath.Join(dir, "runner.env")
+ if err := os.WriteFile(env, []byte("EQUIPO_ORIGIN=\"http://example.com\"\n"), 0600); err != nil {
+ t.Fatal(err)
+ }
+ var out, log bytes.Buffer
+ if run(context.Background(), []string{"run", "--env-file", env}, strings.NewReader(""), &out, &log, func(string) string { return "" }) != 1 || !strings.Contains(log.String(), "EQUIPO_ORIGIN") {
+ t.Fatalf("env file not read: %q", log.String())
+ }
+}
diff --git a/cmd/equipo-runner/main.go b/cmd/equipo-runner/main.go
index ea92ae9a..db31e657 100644
--- a/cmd/equipo-runner/main.go
+++ b/cmd/equipo-runner/main.go
@@ -14,6 +14,7 @@ import (
"amadan.net/oficina/equipo/internal/equipo"
"amadan.net/oficina/equipo/internal/release"
"amadan.net/oficina/equipo/internal/runner"
+ "amadan.net/oficina/equipo/internal/runner/mac"
runnersetup "amadan.net/oficina/equipo/internal/runner/setup"
"amadan.net/oficina/equipo/internal/runner/thin"
"amadan.net/rastrillo/rastrillo"
@@ -36,8 +37,30 @@ func run(ctx context.Context, args []string, input io.Reader, output, errorOutpu
return accountLogin(ctx, args[1:], input, output, errorOutput, getenv)
}
if len(args) > 0 && args[0] == "install" {
+ if goos() == "darwin" {
+ return installMac(ctx, args[1:], realMacInstallHost(), output, errorOutput)
+ }
return installRunner(ctx, args[1:], input, output, errorOutput, getenv)
}
+ // A Mac's launchd agent passes its environment as a file (launchd has
+ // no EnvironmentFile): run --env-file <path>, probe --env-file <path>.
+ args, envFile, ok := cutEnvFile(args)
+ if !ok {
+ return fail(nil)
+ }
+ if envFile != "" {
+ values, err := runnersetup.ReadEnvFile(envFile)
+ if err != nil {
+ return fail(err)
+ }
+ base := getenv
+ getenv = func(k string) string {
+ if v, ok := values[k]; ok {
+ return v
+ }
+ return base(k)
+ }
+ }
if len(args) == 2 && args[0] == "login" {
cfg, err := runner.LoadConfig(getenv)
if err != nil {
@@ -70,7 +93,7 @@ func run(ctx context.Context, args []string, input io.Reader, output, errorOutpu
}
return 0
}
- if args[0] != "run" && args[0] != "enrol" && args[0] != "preflight" && args[0] != "reset" {
+ if args[0] != "run" && args[0] != "enrol" && args[0] != "preflight" && args[0] != "reset" && args[0] != "probe" {
return fail(nil)
}
cfg, err := runner.LoadConfig(getenv)
@@ -91,12 +114,29 @@ func run(ctx context.Context, args []string, input io.Reader, output, errorOutpu
case "reset":
err = runner.Reset(ctx, cfg)
case "run":
- opts := thin.OptionsFromEnv(os.Getenv)
+ opts := thin.OptionsFromEnv(getenv)
opts.Version, opts.Logger = rastrillo.BuildVersion, slog.New(slog.NewTextHandler(errorOutput, nil))
err = thin.Run(ctx, cfg, opts)
if errors.Is(err, thin.ErrSuperseded) {
_, _ = fmt.Fprintf(errorOutput, equipo.CopyRunnerDiagnostic, "runner.superseded", "-")
- return thin.ExitSuperseded
+ return supersededExit(goos())
+ }
+ if errors.Is(err, thin.ErrUpdated) {
+ return mac.ExitUpdated
+ }
+ case "probe":
+ // The Mac's self-probes, on demand; the running worker picks the
+ // report up and sends it. Paul never needs this.
+ if goos() != "darwin" {
+ _, _ = fmt.Fprintln(errorOutput, equipo.RunnerSetupCopy("runner.mac.platform"))
+ return 1
+ }
+ opts := thin.OptionsFromEnv(getenv)
+ opts.Version = rastrillo.BuildVersion
+ var report mac.Report
+ report, err = thin.RunProbes(ctx, cfg, opts)
+ if err == nil {
+ err = json.NewEncoder(output).Encode(report.Probes)
}
case "preflight":
var reports any
@@ -122,3 +162,30 @@ func main() {
stop()
os.Exit(code)
}
+
+// supersededExit: systemd must not restart a runner that lost its lease
+// (RestartPreventExitStatus=3); launchd restarts any non-zero exit
+// (KeepAlive SuccessfulExit false), so on a Mac it is 0.
+func supersededExit(goos string) int {
+ if goos == "darwin" {
+ return 0
+ }
+ return thin.ExitSuperseded
+}
+
+// cutEnvFile takes "--env-file <path>" out of the arguments of run and
+// probe. ok is false when it is malformed or given to another verb.
+func cutEnvFile(args []string) (rest []string, file string, ok bool) {
+ for i := 0; i < len(args); i++ {
+ if args[i] != "--env-file" {
+ rest = append(rest, args[i])
+ continue
+ }
+ if file != "" || i+1 >= len(args) || len(rest) != 1 || (rest[0] != "run" && rest[0] != "probe") {
+ return nil, "", false
+ }
+ file = args[i+1]
+ i++
+ }
+ return rest, file, true
+}
diff --git a/cmd/equipo-runner/platform.go b/cmd/equipo-runner/platform.go
new file mode 100644
index 00000000..e5ea5d73
--- /dev/null
+++ b/cmd/equipo-runner/platform.go
@@ -0,0 +1,6 @@
+package main
+
+import "runtime"
+
+func goos() string { return runtime.GOOS }
+func goarch() string { return runtime.GOARCH }
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go
index cf37f3a4..75483d46 100644
--- a/internal/equipo/chat/tasks.go
+++ b/internal/equipo/chat/tasks.go
@@ -162,6 +162,10 @@ type stepRecord struct {
// Apple: Engineering's change touched Apple files (its checks need
// macOS).
Apple bool
+ // ChecksSandbox is how a worker's checks were confined: seatbelt, or
+ // none when they ran outside the sandbox (Paul's ruling 2). "" is the
+ // primary's bubblewrap.
+ ChecksSandbox string
}
func (stepRecord) TableName() string { return "chat_steps" }
@@ -325,7 +329,7 @@ func (t *txn) latestStep(taskID string) (stepRecord, bool, error) {
}
func stepView(s stepRecord) wire.Step {
- return wire.Step{RunnerID: s.RunnerID, Needs: decodeList(s.Needs), Placement: s.Placement, Publication: s.Publication, TerminationKind: s.TerminationKind, ID: s.ID, Revision: s.Revision, TaskID: s.TaskID, Index: s.Idx, Specialist: s.Specialist, State: s.State, Reason: s.Reason, Attempt: s.Attempt, BaseSHA: s.BaseSHA, CandidateSHA: s.CandidateSHA, Pushed: s.Pushed, Terminated: s.Terminated, Summary: s.Summary, Headline: s.Headline, LogTail: s.LogTail, StartedAt: s.StartedAt, FinishedAt: s.FinishedAt,
+ return wire.Step{RunnerID: s.RunnerID, Needs: decodeList(s.Needs), Placement: s.Placement, Publication: s.Publication, TerminationKind: s.TerminationKind, ChecksSandbox: s.ChecksSandbox, ID: s.ID, Revision: s.Revision, TaskID: s.TaskID, Index: s.Idx, Specialist: s.Specialist, State: s.State, Reason: s.Reason, Attempt: s.Attempt, BaseSHA: s.BaseSHA, CandidateSHA: s.CandidateSHA, Pushed: s.Pushed, Terminated: s.Terminated, Summary: s.Summary, Headline: s.Headline, LogTail: s.LogTail, StartedAt: s.StartedAt, FinishedAt: s.FinishedAt,
Round: s.Round, Family: s.Family, Account: s.Account, Verdict: s.Verdict, ReviewLabel: s.ReviewLabel, Findings: decodeFindings(s.Findings), Checks: s.Checks, Gate: s.Gate, ExitCode: s.ExitCode, Askable: s.Askable,
Rebase: s.Rebase, MergeSHA: s.MergeSHA, Into: s.MergeInto, Strategy: s.MergeStrategy, WithoutChecks: s.WithoutChecks, Activity: decodeActivity(s.Activity)}
}
@@ -382,6 +386,9 @@ func (t *txn) taskView(k taskRecord) (wire.Task, error) {
v.BranchHead = k.BranchHead
}
v.Checks, v.ChecksReason, v.Verdict, v.ReviewLabel = pr.judged()
+ if (v.Checks == wire.ChecksPassed || v.Checks == wire.ChecksFailed) && pr.checks != nil {
+ v.ChecksSandbox = pr.checks.ChecksSandbox
+ }
v.NeedsYou = pr.needsYou(k)
if pr.eng != nil {
v.FixRounds = pr.eng.Round
@@ -465,7 +472,7 @@ func (t *txn) saveStep(s *stepRecord, k *taskRecord) error {
}
s.Revision++
s.UpdatedAt = t.now()
- if err := t.db.Model(&stepRecord{}).Where("id = ?", s.ID).Select("state", "reason", "attempt", "base_sha", "candidate_sha", "pushed", "terminated", "summary", "log_tail", "started_at", "finished_at", "revision", "updated_at", "headline", "family", "account", "verdict", "review_label", "findings", "checks", "gate", "exit_code", "output", "republish", "from_attempt", "askable", "rebase", "from_base", "from_candidate", "merge_sha", "merge_into", "merge_strategy", "without_checks", "switched", "activity", "runner_id", "needs", "placement", "waiting_since", "refused_by", "withdrawn", "termination_kind", "publication", "publication_id", "apple").Updates(s).Error; err != nil {
+ if err := t.db.Model(&stepRecord{}).Where("id = ?", s.ID).Select("state", "reason", "attempt", "base_sha", "candidate_sha", "pushed", "terminated", "summary", "log_tail", "started_at", "finished_at", "revision", "updated_at", "headline", "family", "account", "verdict", "review_label", "findings", "checks", "gate", "exit_code", "output", "republish", "from_attempt", "askable", "rebase", "from_base", "from_candidate", "merge_sha", "merge_into", "merge_strategy", "without_checks", "switched", "activity", "runner_id", "needs", "placement", "waiting_since", "refused_by", "withdrawn", "termination_kind", "publication", "publication_id", "apple", "checks_sandbox").Updates(s).Error; err != nil {
return err
}
members, err := t.members()
@@ -977,6 +984,14 @@ func (t *txn) stepReport(l Lease, v *wire.StepReport) error {
return nil
}
s.Reason, s.Verdict, s.ReviewLabel, s.Checks, s.Gate, s.ExitCode = v.Reason, v.Verdict, v.ReviewLabel, v.Checks, v.Gate, v.ExitCode
+ if s.Specialist == wire.SpecialistChecks && role == wire.RoleWorker {
+ // A worker's word on how its checks were confined;
+ // anything but seatbelt is outside the sandbox.
+ s.ChecksSandbox = wire.SandboxNone
+ if v.ChecksSandbox == wire.SandboxSeatbelt {
+ s.ChecksSandbox = wire.SandboxSeatbelt
+ }
+ }
s.Output = clipText(v.Output, wire.MaxChecksOutput)
var pr projectRecord
if err := t.db.Where("id = ?", k.ProjectID).First(&pr).Error; err != nil {
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 4497a072..d31a963a 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -255,6 +255,24 @@ var pageCopy = map[string]string{
"runner.install.label": "Machine label [%s]: ",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.install.enrol
"runner.install.enrol": "Enrol this machine with this label? Type yes: ",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.platform
+ "runner.mac.platform": "This installer is for Macs with Apple silicon.",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.root
+ "runner.mac.root": "Run the installer as the Mac user made for Equipo, not as root.",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.admin
+ "runner.mac.admin": "This Mac user is an administrator. Run the installer as a Standard user named equipo-yourname.",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.user
+ "runner.mac.user": "Run the installer as a Standard user named equipo-yourname, such as equipo-paul.",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.home
+ "runner.mac.home": "This user can open another person's home folder (%s). An administrator can close it with: sudo chmod 700 %s",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.no_node
+ "runner.mac.no_node": "Node.js is not installed, so the checks sandbox was not installed. Checks will run outside the sandbox and say so.",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.no_srt
+ "runner.mac.no_srt": "The checks sandbox could not be installed. Checks will run outside the sandbox and say so.",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.tap
+ "runner.mac.tap": "Open this link and add this Mac to your team:",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.mac.installed
+ "runner.mac.installed": "This Mac is ready. It checks itself, then waits for work whenever this user is logged in.",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): invite.welcome
"invite.welcome": "Join the team",
@@ -547,6 +565,7 @@ var pageCopy = map[string]string{
"work.checks.checks_timeout": "Checks didn't finish in time", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"work.checks.checks_unavailable": "Checks can't run on this runner", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"work.checks.running": "Running checks…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "work.checks.outside_sandbox": "%s, ran outside the sandbox", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"work.review.approve": "Approved (%s)", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"work.review.changes_requested": "Changes requested (%s)", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"work.review.running": "Reviewing…", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
@@ -1217,6 +1236,44 @@ var pageCopy = map[string]string{
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"runner.title": "Machines",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.add_title": "Add %s to your team",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.platform": "Platform",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.checks_run": "Checks run",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.sandbox.seatbelt": "In the sandbox",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.sandbox.bubblewrap": "In the sandbox",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.sandbox.none": "Outside the sandbox",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.probes": "Self-checks",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.probe.P1": "Xcode and simulators",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.probe.P2": "Sandbox against a hostile build",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.probe.P3": "Model sign-in",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.probe.P4": "Mac user, agent and sleep",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.probe.P5": "Codex",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.probe.P6": "Stopping checks",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.probe.P7": "Sandbox tools",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.verdict.passed": "Passed",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.verdict.denied": "Every attempt denied",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.verdict.failed": "Failed",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.verdict.skipped": "Not run",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "runner.verdict.unavailable": "Unavailable",
+ // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"runner.origin": "Equipo address:",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"runner.approve-title": "Approve this machine",
diff --git a/internal/equipo/mac_view_test.go b/internal/equipo/mac_view_test.go
new file mode 100644
index 00000000..a93c269e
--- /dev/null
+++ b/internal/equipo/mac_view_test.go
@@ -0,0 +1,55 @@
+package equipo
+
+import (
+ "bytes"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/equipo/setup"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// Checks a worker ran outside the sandbox say so wherever their result
+// shows (the line, the badge, the timeline and the Ready to merge card
+// share checksLine): never a pass in disguise. Sandboxed checks and the
+// primary's read as before.
+func TestChecksOutsideTheSandboxAreLabelled(t *testing.T) {
+ zero, two := 0, 2
+ if got := checksLine(wire.ChecksPassed, "", "xcodebuild test", &zero, wire.SandboxNone); got != "Checks passed (xcodebuild test), ran outside the sandbox" {
+ t.Fatalf("%q", got)
+ }
+ if got := checksLine(wire.ChecksFailed, "", "make ci", &two, wire.SandboxNone); got != "Checks failed (make ci, exit 2), ran outside the sandbox" {
+ t.Fatalf("%q", got)
+ }
+ for _, sandbox := range []string{wire.SandboxSeatbelt, ""} {
+ if got := checksLine(wire.ChecksPassed, "", "xcodebuild test", &zero, sandbox); got != "Checks passed (xcodebuild test)" {
+ t.Fatalf("%s: %q", sandbox, got)
+ }
+ }
+ task := wire.Task{Checks: wire.ChecksPassed, ChecksSandbox: wire.SandboxNone, CandidateSHA: "c", Steps: []wire.Step{{Specialist: wire.SpecialistChecks, State: wire.StepDone, Checks: wire.ChecksPassed, CandidateSHA: "c", Gate: "xcodebuild test", ExitCode: &zero, ChecksSandbox: wire.SandboxNone}}}
+ b := checksBadge(task, nil)
+ if !strings.Contains(b.Text, "ran outside the sandbox") || !strings.Contains(b.Title, "ran outside the sandbox") {
+ t.Fatalf("badge %+v", b)
+ }
+ v := taskLineOf(task, "a@example.com")
+ if !strings.HasSuffix(v.ChecksLine, "ran outside the sandbox") {
+ t.Fatalf("card %q", v.ChecksLine)
+ }
+}
+
+// The Connections runner view shows what a Mac said of itself: its
+// platform, where checks run, and each self-probe in words.
+func TestRunnersViewShowsProbes(t *testing.T) {
+ data := pageData{Runners: []Runner{{ID: "r1", Label: "Tito Studio", Report: &setup.RunnerReport{Platform: "darwin/arm64", Sandbox: wire.SandboxNone,
+ Probes: []setup.RunnerProbe{{ID: "P2", Verdict: wire.ProbeFailed, Detail: "allowed: test.keychain; xcodebuild ran in srt"}, {ID: "P7", Verdict: wire.ProbePassed, Detail: "srt 0.0.81"}}}}}}
+ var buf bytes.Buffer
+ if err := pages["runners"].ExecuteTemplate(&buf, "content", data); err != nil {
+ t.Fatal(err)
+ }
+ html := buf.String()
+ for _, want := range []string{"darwin/arm64", "Outside the sandbox", "Self-checks", "Sandbox against a hostile build", "Failed", "allowed: test.keychain; xcodebuild ran in srt", "Sandbox tools", `data-probe="P2" data-verdict="failed"`} {
+ if !strings.Contains(html, want) {
+ t.Fatalf("%q missing:\n%s", want, html)
+ }
+ }
+}
diff --git a/internal/equipo/migrations/0055_thin_checks_sandbox.sql b/internal/equipo/migrations/0055_thin_checks_sandbox.sql
new file mode 100644
index 00000000..545de0a7
--- /dev/null
+++ b/internal/equipo/migrations/0055_thin_checks_sandbox.sql
@@ -0,0 +1 @@
+ALTER TABLE chat_steps ADD COLUMN checks_sandbox text;
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql
index 4b5236a3..9c80eaf2 100644
--- a/internal/equipo/migrations/schema.sql
+++ b/internal/equipo/migrations/schema.sql
@@ -595,7 +595,7 @@ CREATE INDEX chat_card_task ON chat_cards(task_id);
CREATE TABLE chat_project_attachments (project_id text, kind text, ref text, name text, created_at datetime, PRIMARY KEY (project_id, kind, ref));
CREATE TABLE chat_tasks (id text PRIMARY KEY, project_id text, title text, brief text, stage text, branch text, base_sha text, creator text, turn_id text, cancel_requested numeric, revision integer, created_at datetime, updated_at datetime, watching text, moved_from text, branch_head text, merge_asked text, merged_sha text, merged_into text, merge_strategy text, merged_without_checks numeric, merged_at datetime, ready_sha text, merge_eligible text, done_at datetime, duplicate_of text, folded_into text, folded_stage text, folded_at datetime, engineering_runner text);
CREATE INDEX chat_task_project ON chat_tasks(project_id);
-CREATE TABLE chat_steps (id text PRIMARY KEY, task_id text, idx integer, specialist text, person text, state text, reason text, attempt integer, base_sha text, candidate_sha text, pushed numeric, terminated numeric, summary text, log_tail text, started_at datetime, finished_at datetime, revision integer, created_at datetime, updated_at datetime, round integer, family text, account text, verdict text, review_label text, findings text, checks text, gate text, exit_code integer, output text, republish numeric, from_attempt integer, askable numeric, rebase numeric, from_base text, from_candidate text, merge_sha text, merge_into text, merge_strategy text, without_checks numeric, activity text, switched text, headline text, runner_id text, needs text, placement text, waiting_since datetime, refused_by text, withdrawn numeric, termination_kind text, publication text, publication_id text, apple numeric);
+CREATE TABLE chat_steps (id text PRIMARY KEY, task_id text, idx integer, specialist text, person text, state text, reason text, attempt integer, base_sha text, candidate_sha text, pushed numeric, terminated numeric, summary text, log_tail text, started_at datetime, finished_at datetime, revision integer, created_at datetime, updated_at datetime, round integer, family text, account text, verdict text, review_label text, findings text, checks text, gate text, exit_code integer, output text, republish numeric, from_attempt integer, askable numeric, rebase numeric, from_base text, from_candidate text, merge_sha text, merge_into text, merge_strategy text, without_checks numeric, activity text, switched text, headline text, runner_id text, needs text, placement text, waiting_since datetime, refused_by text, withdrawn numeric, termination_kind text, publication text, publication_id text, apple numeric, checks_sandbox text);
CREATE INDEX chat_step_task ON chat_steps(task_id);
CREATE TABLE chat_task_entries (id text PRIMARY KEY, task_id text, idempotency_key text, kind text, author text, text text, repo text, path text, line integer, created_at datetime, headline text, folded_from text);
CREATE INDEX chat_entry_task ON chat_task_entries(task_id);
diff --git a/internal/equipo/runner_handlers.go b/internal/equipo/runner_handlers.go
index 266f68f8..9676e6e8 100644
--- a/internal/equipo/runner_handlers.go
+++ b/internal/equipo/runner_handlers.go
@@ -144,6 +144,17 @@ func (a *application) enrolmentPage(w http.ResponseWriter, r *http.Request) {
a.failure(w, r, err)
return
}
+ // The link a runner prints carries its code: show that machine with
+ // its one button (approval is still the confirmed POST below).
+ if code := r.URL.Query().Get("code"); code != "" && len(code) <= 16 {
+ data.Enrolment, err = a.store.approveOrInspect(r.Context(), Actor{Address: id.Address}, code, false)
+ if err != nil {
+ a.runnerFormFailure(w, r, err)
+ return
+ }
+ data.UserCode = code
+ data.PairingConfirmation = setup.PairingConfirmation(a.store.invitationKey, id.Address, code, a.store.runnerClock.Now())
+ }
a.renderLive(w, r, "runners", data)
}
diff --git a/internal/equipo/runners.go b/internal/equipo/runners.go
index db3ad18a..5b0848f5 100644
--- a/internal/equipo/runners.go
+++ b/internal/equipo/runners.go
@@ -4,9 +4,13 @@ import (
"amadan.net/oficina/equipo/internal/equipo/personapi"
"context"
"crypto/rand"
+ "encoding/json"
"errors"
"time"
+ "amadan.net/oficina/equipo/internal/equipo/setup"
+ "amadan.net/oficina/equipo/internal/wire"
+
"amadan.net/oficina/equipo/internal/runnerproto"
"gorm.io/gorm"
)
@@ -218,6 +222,9 @@ func (s *Store) runnersFor(ctx context.Context, actor Actor) ([]Runner, error) {
record.TrialAt = history.AcknowledgedAt
record.TrialVersions = history.Versions
}
+ if record.Report, err = runnerReport(tx, record.ID); err != nil {
+ return storeError(err)
+ }
result = append(result, record.Runner)
}
return nil
@@ -227,3 +234,27 @@ func (s *Store) runnersFor(ctx context.Context, actor Actor) ([]Runner, error) {
}
return result, nil
}
+
+// runnerReport is the runner's newest hello as the Connections view
+// shows it: platform, confinement of checks and self-probes, each value
+// already checked by the hello's bounds when it was stored.
+func runnerReport(tx *gorm.DB, id string) (*setup.RunnerReport, error) {
+ var hellos []string
+ if err := tx.Raw(`SELECT coalesce(hello, '') FROM runner_sessions WHERE runner_id = ?`, id).Scan(&hellos).Error; err != nil {
+ return nil, err
+ }
+ if len(hellos) != 1 || hellos[0] == "" {
+ return nil, nil
+ }
+ var h wire.Hello
+ if json.Unmarshal([]byte(hellos[0]), &h) != nil || h.Platform == nil {
+ return nil, nil
+ }
+ r := &setup.RunnerReport{Platform: h.Platform.OS + "/" + h.Platform.Arch, Sandbox: h.Sandbox}
+ if h.Capabilities != nil && wire.ValidCapabilities(*h.Capabilities) == nil {
+ for _, p := range h.Capabilities.Probes {
+ r.Probes = append(r.Probes, setup.RunnerProbe{ID: p.ID, Verdict: p.Verdict, Detail: p.Detail})
+ }
+ }
+ return r, nil
+}
diff --git a/internal/equipo/setup/runner_models.go b/internal/equipo/setup/runner_models.go
index 22f4ac79..b0de3c46 100644
--- a/internal/equipo/setup/runner_models.go
+++ b/internal/equipo/setup/runner_models.go
@@ -15,8 +15,20 @@ type Runner struct {
RevokedAt *time.Time
// Role is primary (the person's first runner) or worker.
Role string
+ // Report is what the runner last said of itself: its platform, how
+ // it confines checks and a Mac's self-probes (nil until it has).
+ Report *RunnerReport `gorm:"-"`
}
+// RunnerReport is a runner's own report, for the Connections view.
+type RunnerReport struct {
+ Platform, Sandbox string
+ Probes []RunnerProbe
+}
+
+// RunnerProbe is one self-probe: P1 to P7, its verdict and detail.
+type RunnerProbe struct{ ID, Verdict, Detail string }
+
// Runner roles.
const (
RolePrimary = "primary"
diff --git a/internal/equipo/templates/runners.html b/internal/equipo/templates/runners.html
index d385f326..dbb39fe3 100644
--- a/internal/equipo/templates/runners.html
+++ b/internal/equipo/templates/runners.html
@@ -3,7 +3,7 @@
<p>{{copy "runner.origin"}} <span>{{.Origin}}</span></p>
{{if .UserCode}}
<section equipo-card>
-<h2>{{copy "runner.approve-title"}}</h2>
+<h2>{{printf (copy "runner.add_title") .Enrolment.Label}}</h2>
<dl equipo-metadata>
<dt>{{copy "runner.label"}}</dt><dd>{{.Enrolment.Label}}</dd>
<dt>{{copy "runner.requested"}}</dt><dd>{{.Enrolment.RequestedAt.UTC.Format (copy "runner.requested_format")}}</dd>
@@ -32,7 +32,10 @@
<dl equipo-metadata>
<dt>{{copy "runner.person"}}</dt><dd>{{.Person}}</dd>
<dt>{{copy "runner.fingerprint"}}</dt><dd>{{.MachineKeyHash}}</dd>
+{{with .Report}}<dt>{{copy "runner.platform"}}</dt><dd>{{.Platform}}</dd>{{with .Sandbox}}<dt>{{copy "runner.checks_run"}}</dt><dd data-sandbox="{{.}}">{{copy (printf "runner.sandbox.%s" .)}}</dd>{{end}}{{end}}
</dl>
+{{with .Report}}{{if .Probes}}<h4>{{copy "runner.probes"}}</h4>
+<ul equipo-probes>{{range .Probes}}<li data-probe="{{.ID}}" data-verdict="{{.Verdict}}"><span>{{copy (printf "runner.probe.%s" .ID)}}</span> <span>{{copy (printf "runner.verdict.%s" .Verdict)}}</span>{{with .Detail}} <span equipo-quiet>{{.}}</span>{{end}}</li>{{end}}</ul>{{end}}{{end}}
{{if .TrialOwner}}<p>{{copy "trial.history"}}: {{.TrialOwner}} / {{.TrialAt}}</p><pre>{{.TrialVersions}}</pre>{{end}}
{{if not .RevokedAt}}<form method="post" action="/runners/{{.ID}}/revoke" equipo-form>
<input type="hidden" name="revision" value="{{.Revision}}">
diff --git a/internal/equipo/work_pages.go b/internal/equipo/work_pages.go
index 5cb909ba..d9bd1b5e 100644
--- a/internal/equipo/work_pages.go
+++ b/internal/equipo/work_pages.go
@@ -68,17 +68,19 @@ func specialistName(s string) string {
return s
}
-// checksLine is a checks result in words, honest about what did not run.
-func checksLine(outcome, reason, gate string, code *int) string {
+// checksLine is a checks result in words, honest about what did not run
+// and about checks that ran outside the sandbox (sandbox none, a Mac
+// worker whose probe P2 did not deny: Paul's ruling 2).
+func checksLine(outcome, reason, gate string, code *int, sandbox string) string {
switch outcome {
case wire.ChecksPassed:
- return fmt.Sprintf(copyText("work.checks.passed"), gate)
+ return outsideSandbox(fmt.Sprintf(copyText("work.checks.passed"), gate), sandbox)
case wire.ChecksFailed:
n := -1
if code != nil {
n = *code
}
- return fmt.Sprintf(copyText("work.checks.failed"), gate, n)
+ return outsideSandbox(fmt.Sprintf(copyText("work.checks.failed"), gate, n), sandbox)
case wire.ChecksNone:
return copyText("work.checks.none")
case wire.ChecksCannotRun:
@@ -90,6 +92,14 @@ func checksLine(outcome, reason, gate string, code *int) string {
return ""
}
+// outsideSandbox labels a checks result that ran outside the sandbox.
+func outsideSandbox(line, sandbox string) string {
+ if sandbox != wire.SandboxNone {
+ return line
+ }
+ return fmt.Sprintf(copyText("work.checks.outside_sandbox"), line)
+}
+
func reviewLine(verdict, label string) string {
if verdict == "" {
return ""
@@ -126,7 +136,7 @@ func taskLineOf(t wire.Task, viewer string) taskLine {
if s.State == wire.StepDone {
switch s.Specialist {
case wire.SpecialistChecks:
- l.Result = checksLine(s.Checks, s.Reason, s.Gate, s.ExitCode)
+ l.Result = checksLine(s.Checks, s.Reason, s.Gate, s.ExitCode, s.ChecksSandbox)
case wire.SpecialistReview:
l.Result = reviewLine(s.Verdict, s.ReviewLabel)
case wire.SpecialistMerge:
@@ -135,10 +145,10 @@ func taskLineOf(t wire.Task, viewer string) taskLine {
}
v.Steps = append(v.Steps, l)
}
- v.ChecksLine = checksLine(t.Checks, t.ChecksReason, "", nil)
+ v.ChecksLine = checksLine(t.Checks, t.ChecksReason, "", nil, t.ChecksSandbox)
for _, s := range t.Steps {
if s.CandidateSHA == t.CandidateSHA && s.Specialist == wire.SpecialistChecks && s.State == wire.StepDone {
- v.ChecksLine = checksLine(s.Checks, s.Reason, s.Gate, s.ExitCode)
+ v.ChecksLine = checksLine(s.Checks, s.Reason, s.Gate, s.ExitCode, s.ChecksSandbox)
}
}
v.ReviewLine = reviewLine(t.Verdict, t.ReviewLabel)
diff --git a/internal/equipo/work_views.go b/internal/equipo/work_views.go
index 26ae3491..bb3a6485 100644
--- a/internal/equipo/work_views.go
+++ b/internal/equipo/work_views.go
@@ -318,12 +318,12 @@ func checksBadge(t wire.Task, running *wire.Step) *badgeLine {
gate, code = s.Gate, s.ExitCode
}
}
- title := checksLine(t.Checks, t.ChecksReason, gate, code)
+ title := checksLine(t.Checks, t.ChecksReason, gate, code, t.ChecksSandbox)
switch t.Checks {
case wire.ChecksPassed:
- return &badgeLine{Kind: "checks", Tone: "positive", Icon: "check", Text: copyText("work.badge.checks_passed"), Title: title}
+ return &badgeLine{Kind: "checks", Tone: "positive", Icon: "check", Text: outsideSandbox(copyText("work.badge.checks_passed"), t.ChecksSandbox), Title: title}
case wire.ChecksFailed:
- return &badgeLine{Kind: "checks", Tone: "negative", Icon: "x", Text: copyText("work.badge.checks_failed"), Title: title}
+ return &badgeLine{Kind: "checks", Tone: "negative", Icon: "x", Text: outsideSandbox(copyText("work.badge.checks_failed"), t.ChecksSandbox), Title: title}
case wire.ChecksCannotRun:
text := copyText("work.badge.cannot." + t.ChecksReason)
if text == "" {
@@ -738,10 +738,10 @@ func timelineOf(t wire.Task, v taskLine) []timelineItem {
out = append(out, it)
case wire.SpecialistChecks:
one := t
- one.Checks, one.ChecksReason, one.CandidateSHA = s.Checks, s.Reason, s.CandidateSHA
+ one.Checks, one.ChecksReason, one.CandidateSHA, one.ChecksSandbox = s.Checks, s.Reason, s.CandidateSHA, s.ChecksSandbox
it := timelineItem{Kind: "step", What: title, Badge: checksBadge(one, nil), Took: took(s), Headline: checksHeadline(s.Checks, s.Reason), At: s.FinishedAt}
it.Text = append(it.Text, on(s.CandidateSHA))
- if line := checksLine(s.Checks, s.Reason, s.Gate, s.ExitCode); line != "" {
+ if line := checksLine(s.Checks, s.Reason, s.Gate, s.ExitCode, s.ChecksSandbox); line != "" {
it.Text = append(it.Text, line+".")
}
if s.Checks == wire.ChecksFailed && s.LogTail != "" {
diff --git a/internal/equipotest/enrolment_link_test.go b/internal/equipotest/enrolment_link_test.go
new file mode 100644
index 00000000..15e63486
--- /dev/null
+++ b/internal/equipotest/enrolment_link_test.go
@@ -0,0 +1,48 @@
+package equipotest
+
+import (
+ "encoding/json"
+ "net/url"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/runnerproto"
+)
+
+// One tap (Mac runners spec §1.1): the link a runner prints carries its
+// code, so opening it shows "Add <machine> to your team" with the one
+// confirmed button; nothing is approved until that POST. A wrong code
+// shows nothing to add.
+func TestEnrolmentLinkIsOneTap(t *testing.T) {
+ f := newEnrolHTTP(t)
+ c := signinClient(t, f.server.URL)
+ signinEmail(t, c, f.server.URL, testOrigin, f.mail, ownerAddress)
+ pub, key := machine(t)
+ status, body := enrolJSON(t, f.server.Client(), f.server.URL+"/api/enrolments", runnerproto.BeginEnrolmentRequest{Version: 1, MachinePublicKey: pub, Label: "Tito Studio"}, "")
+ if status != 201 {
+ t.Fatalf("begin HTTP: %d %s", status, body)
+ }
+ var code runnerproto.DeviceCode
+ if err := json.Unmarshal(body, &code); err != nil {
+ t.Fatal(err)
+ }
+ view := taskGet(t, c, f.server.URL, "/runners/enrol?code="+url.QueryEscape(code.UserCode), 200)
+ if !strings.Contains(view, "Add Tito Studio to your team") || !strings.Contains(view, `name="action" value="approve"`) {
+ t.Fatalf("the link did not show the machine to add:\n%s", view)
+ }
+ // Opening it twice still shows it: the GET inspects, never approves.
+ if again := taskGet(t, c, f.server.URL, "/runners/enrol?code="+url.QueryEscape(code.UserCode), 200); !strings.Contains(again, "Add Tito Studio to your team") {
+ t.Fatal("opening the link changed the enrolment")
+ }
+ pagePost(t, c, f.server.URL, "/runners/enrol", testOrigin, formFields(t, view, "/runners/enrol"), 303)
+ if status, body := enrolJSON(t, f.server.Client(), f.server.URL+"/api/enrolments/token", runnerproto.ExchangeEnrolmentRequest{Version: 1, DeviceSecret: code.DeviceSecret, Proof: deviceProof(code, key)}, ""); status != 200 {
+ t.Fatalf("the one button did not add it: %d %s", status, body)
+ }
+ res, err := c.Get(f.server.URL + "/runners/enrol?code=ZZZZZZZZZZ")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if wrong := readBody(t, res); res.StatusCode == 200 && strings.Contains(wrong, "to your team") {
+ t.Fatal("a wrong code showed a machine")
+ }
+}
diff --git a/internal/release/install.go b/internal/release/install.go
index a0b6d16a..771a4e34 100644
--- a/internal/release/install.go
+++ b/internal/release/install.go
@@ -18,6 +18,40 @@ type InstallManifest struct {
RunnerSHA256 string `json:"runner_sha256"`
NamespaceArgs []string `json:"namespace_args"`
Release Manifest `json:"release"`
+ // Targets are every platform's runner in this release with its
+ // digests (Mac runners spec §3.1): linux/amd64 (the top-level fields
+ // above, kept for older bootstraps) and darwin/arm64, a Mac worker
+ // served under DarwinDir.
+ Targets map[string]InstallTarget `json:"targets,omitempty"`
+}
+
+// InstallTarget is one platform's runner and tool proxy digests.
+type InstallTarget struct {
+ RunnerSHA256 string `json:"runner_sha256"`
+ ToolProxySHA256 string `json:"tool_proxy_sha256"`
+}
+
+// The Mac worker's target and where its files are served, under
+// /releases/<version>/.
+const (
+ TargetDarwin = "darwin/arm64"
+ DarwinDir = "darwin-arm64"
+)
+
+// DarwinTarget is the Mac runner of a release manifest, checked: the
+// version this runner asked for and two SHA-256 digests. A Mac worker
+// runs checks only, so the Linux certification does not apply to it.
+func (m InstallManifest) DarwinTarget(version string) (InstallTarget, error) {
+ t, ok := m.Targets[TargetDarwin]
+ if !ValidInstallVersion(version) || m.Version != version || !ok || !sha256Hex(t.RunnerSHA256) || !sha256Hex(t.ToolProxySHA256) {
+ return InstallTarget{}, errManifest
+ }
+ return t, nil
+}
+
+func sha256Hex(s string) bool {
+ b, err := hex.DecodeString(s)
+ return err == nil && len(b) == 32 && strings.ToLower(s) == s
}
var installVersion = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$`)
diff --git a/internal/runner/config.go b/internal/runner/config.go
index 143a2e4e..afdad523 100644
--- a/internal/runner/config.go
+++ b/internal/runner/config.go
@@ -40,7 +40,15 @@ func validOrigin(origin string) bool {
u, err := url.Parse(origin)
return err == nil && u.Host != "" && u.User == nil && u.Path == "" && u.RawQuery == "" && !u.ForceQuery && u.Fragment == "" && !strings.Contains(origin, "#") && (u.Scheme == "https" || (u.Scheme == "http" && u.Hostname() == "127.0.0.1"))
}
-func (c Config) validate() error {
+func (c Config) validate() error { return c.validateFor(runtime.GOOS) }
+
+// validateFor checks the configuration a runner on goos needs. A Mac
+// runs checks only (a worker): no bubblewrap, model harness, forge
+// credential or Go toolchain, so it needs its roots, git and itself.
+func (c Config) validateFor(goos string) error {
+ if goos == "darwin" {
+ return c.validateWorker()
+ }
if !validOrigin(c.Origin) {
return configIssue("runner.config.origin", "EQUIPO_ORIGIN", provider.ErrContract)
}
@@ -68,6 +76,26 @@ func (c Config) validate() error {
return nil
}
+func (c Config) validateWorker() error {
+ if !validOrigin(c.Origin) {
+ return configIssue("runner.config.origin", "EQUIPO_ORIGIN", provider.ErrContract)
+ }
+ if c.InstanceID == "" {
+ return configIssue("runner.config.missing", "EQUIPO_INSTANCE_ID", provider.ErrContract)
+ }
+ for _, v := range []struct{ name, path string }{{"EQUIPO_RUNNER_STATE_DIR", c.StateDir}, {"EQUIPO_WORKSPACE_ROOT", c.WorkspaceRoot}, {"EQUIPO_SCRATCH_ROOT", c.ScratchRoot}, {"EQUIPO_GIT_PATH", c.GitPath}, {"EQUIPO_RUNNER_EXECUTABLE", c.Executable}} {
+ if !filepath.IsAbs(v.path) || filepath.Clean(v.path) != v.path || v.path == "/" {
+ return configIssue("runner.config.path", v.name, provider.ErrContract)
+ }
+ }
+ for _, v := range []struct{ name, path string }{{"EQUIPO_WORKSPACE_ROOT", c.WorkspaceRoot}, {"EQUIPO_SCRATCH_ROOT", c.ScratchRoot}} {
+ if containsPath(c.StateDir, v.path) || containsPath(v.path, c.StateDir) {
+ return configIssue("runner.config.overlap", v.name, provider.ErrPolicy)
+ }
+ }
+ return nil
+}
+
func containsPath(root, path string) bool {
r, err := filepath.Rel(root, path)
return err == nil && (r == "." || r != ".." && !strings.HasPrefix(r, "../"))
diff --git a/internal/runner/config_test.go b/internal/runner/config_test.go
index 24aa92ee..af2e6af1 100644
--- a/internal/runner/config_test.go
+++ b/internal/runner/config_test.go
@@ -208,3 +208,27 @@ func TestRunnerConfigAmadanPath(t *testing.T) {
})
}
}
+
+// A Mac worker needs its roots, git and itself, nothing of the Linux
+// runner's harnesses; the same configuration on Linux is refused.
+func TestMacWorkerConfig(t *testing.T) {
+ root := t.TempDir()
+ c := Config{Origin: "https://equipo.example", InstanceID: "instance", StateDir: filepath.Join(root, "state"), WorkspaceRoot: filepath.Join(root, "work"), ScratchRoot: filepath.Join(root, "scratch"), GitPath: "/usr/bin/git", Executable: "/Users/equipo-paul/.local/lib/equipo-runner/equipo-runner"}
+ mustJournal(t, c.validateFor("darwin"))
+ if c.validateFor("linux") == nil {
+ t.Fatal("a Linux runner without bubblewrap or harnesses accepted")
+ }
+ for name, bad := range map[string]func(*Config){
+ "origin": func(c *Config) { c.Origin = "http://example.com" },
+ "instance": func(c *Config) { c.InstanceID = "" },
+ "git": func(c *Config) { c.GitPath = "git" },
+ "scratch inside": func(c *Config) { c.ScratchRoot = filepath.Join(c.StateDir, "scratch") },
+ "state inside": func(c *Config) { c.StateDir = filepath.Join(c.WorkspaceRoot, "state") },
+ } {
+ b := c
+ bad(&b)
+ if b.validateFor("darwin") == nil {
+ t.Fatalf("%s accepted", name)
+ }
+ }
+}
diff --git a/internal/runner/enrol.go b/internal/runner/enrol.go
index 625ce1fc..d367eb0d 100644
--- a/internal/runner/enrol.go
+++ b/internal/runner/enrol.go
@@ -157,7 +157,10 @@ func Enrol(ctx context.Context, c Config, output io.Writer) (resultErr error) {
if !pending.usable(c.Origin, c.InstanceID) {
return provider.ErrIdentity
}
- if _, err = io.WriteString(output, "["+code.VerificationURI+"]("+code.VerificationURI+")\n"+code.UserCode+"\n"); err != nil {
+ // The link carries the code, so opening it shows this machine with one
+ // button to add it; the code stays on its own line for typing.
+ link := code.VerificationURI + "?code=" + url.QueryEscape(code.UserCode)
+ if _, err = io.WriteString(output, "["+link+"]("+link+")\n"+code.UserCode+"\n"); err != nil {
return err
}
for time.Now().Before(code.ExpiresAt) {
diff --git a/internal/runner/mac/account_test.go b/internal/runner/mac/account_test.go
index 7f8e43e1..b66599dc 100644
--- a/internal/runner/mac/account_test.go
+++ b/internal/runner/mac/account_test.go
@@ -151,3 +151,15 @@ func parsePlist(t *testing.T, raw []byte) map[string]string {
}
return out
}
+
+// srt is pinned: the lockfile the installer ships names 0.0.81 with its
+// integrity hash, and every package in it has one.
+func TestSRTPinned(t *testing.T) {
+ if !SRTPinned() {
+ t.Fatal("srt not pinned")
+ }
+ _, lock := SRTPackage()
+ if strings.Count(string(lock), `"integrity": "sha512-`) < 5 {
+ t.Fatal("a package without an integrity hash")
+ }
+}
diff --git a/internal/runner/mac/gate.go b/internal/runner/mac/gate.go
index e37b2158..fbf93a64 100644
--- a/internal/runner/mac/gate.go
+++ b/internal/runner/mac/gate.go
@@ -51,6 +51,10 @@ type Gate struct {
Lines int
// Sandbox labels the result: srt confines it (seatbelt) or not (none).
Sandbox string
+ // ScratchHome sets HOME to the attempt's scratch too (the test
+ // build's fake worker; a Mac keeps the runner user's home, where
+ // Xcode's caches are).
+ ScratchHome bool
// Watch sees each line of output as it comes (probe P6 waits for a
// test to start before it kills the group).
Watch func(string)
@@ -99,6 +103,9 @@ func (g *Gate) Run(ctx context.Context, attempt, dir string, argv []string, limi
cmd := exec.Command(cmdline[0], cmdline[1:]...)
cmd.Dir = dir
cmd.Env = append(append([]string{}, g.Env...), "TMPDIR="+scratch, "EQUIPO_ATTEMPT="+attempt, "EQUIPO_GATE_STATUS="+status)
+ if g.ScratchHome {
+ cmd.Env = append(cmd.Env, "HOME="+scratch)
+ }
out := &tail{max: max(g.Lines, 1), watch: g.Watch}
cmd.Stdout, cmd.Stderr = out, out
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
diff --git a/internal/runner/mac/srt.go b/internal/runner/mac/srt.go
new file mode 100644
index 00000000..93166b6d
--- /dev/null
+++ b/internal/runner/mac/srt.go
@@ -0,0 +1,39 @@
+package mac
+
+import (
+ "embed"
+ "encoding/json"
+)
+
+// SRTVersion is the pinned @anthropic-ai/sandbox-runtime. The installer
+// installs it privately with `npm ci` from this lockfile, so every
+// package srt brings is pinned by its integrity hash too.
+const SRTVersion = "0.0.81"
+
+//go:embed srt/package.json srt/package-lock.json
+var srtPackage embed.FS
+
+// SRTPackage is the package.json and package-lock.json the installer
+// writes into the private srt prefix before `npm ci`.
+func SRTPackage() (pkg, lock []byte) {
+ pkg, _ = srtPackage.ReadFile("srt/package.json")
+ lock, _ = srtPackage.ReadFile("srt/package-lock.json")
+ return pkg, lock
+}
+
+// SRTPinned reports whether the lockfile pins srt at SRTVersion with an
+// integrity hash.
+func SRTPinned() bool {
+ _, lock := SRTPackage()
+ var l struct {
+ Packages map[string]struct {
+ Version string `json:"version"`
+ Integrity string `json:"integrity"`
+ } `json:"packages"`
+ }
+ if json.Unmarshal(lock, &l) != nil {
+ return false
+ }
+ p := l.Packages["node_modules/@anthropic-ai/sandbox-runtime"]
+ return p.Version == SRTVersion && len(p.Integrity) > len("sha512-")
+}
diff --git a/internal/runner/mac/srt/package-lock.json b/internal/runner/mac/srt/package-lock.json
new file mode 100644
index 00000000..bbd19060
--- /dev/null
+++ b/internal/runner/mac/srt/package-lock.json
@@ -0,0 +1,64 @@
+{
+ "name": "equipo-runner-srt",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "equipo-runner-srt",
+ "dependencies": {
+ "@anthropic-ai/sandbox-runtime": "0.0.81"
+ }
+ },
+ "node_modules/@anthropic-ai/sandbox-runtime": {
+ "version": "0.0.81",
+ "resolved": "https://registry.npmjs.org/@anthropic-ai/sandbox-runtime/-/sandbox-runtime-0.0.81.tgz",
+ "integrity": "sha512-bjHDu87gjIR7+Oxy9jPiK3v8CvSELCzfpXa3fjqfSKdvlZET2iF51xcXILWPayTpowB3xtZeQVf2JR916nVW/w==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@pondwader/socks5-server": "^1.0.10",
+ "commander": "^12.1.0",
+ "node-forge": "^1.4.0",
+ "zod": "^3.25.0"
+ },
+ "bin": {
+ "srt": "dist/cli.js"
+ },
+ "engines": {
+ "node": ">=22.12.0"
+ }
+ },
+ "node_modules/@pondwader/socks5-server": {
+ "version": "1.0.10",
+ "resolved": "https://registry.npmjs.org/@pondwader/socks5-server/-/socks5-server-1.0.10.tgz",
+ "integrity": "sha512-bQY06wzzR8D2+vVCUoBsr5QS2U6UgPUQRmErNwtsuI6vLcyRKkafjkr3KxbtGFf9aBBIV2mcvlsKD1UYaIV+sg==",
+ "license": "MIT"
+ },
+ "node_modules/commander": {
+ "version": "12.1.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
+ "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/node-forge": {
+ "version": "1.4.3",
+ "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.3.tgz",
+ "integrity": "sha512-P6wzfh6t70avmV8FrVEAd/36sOPJQ+hkaJVX1Laap9J/77m7M0eyozDvc8SwnDf4P7MP94gwbAAo0rg3YVXT+g==",
+ "license": "(BSD-3-Clause OR GPL-2.0)",
+ "engines": {
+ "node": ">= 6.13.0"
+ }
+ },
+ "node_modules/zod": {
+ "version": "3.25.76",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
+ "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/colinhacks"
+ }
+ }
+ }
+}
diff --git a/internal/runner/mac/srt/package.json b/internal/runner/mac/srt/package.json
new file mode 100644
index 00000000..5a62add1
--- /dev/null
+++ b/internal/runner/mac/srt/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "equipo-runner-srt",
+ "private": true,
+ "description": "The checks sandbox of a Mac runner, pinned.",
+ "dependencies": {
+ "@anthropic-ai/sandbox-runtime": "0.0.81"
+ }
+}
diff --git a/internal/runner/onboarding_test.go b/internal/runner/onboarding_test.go
index 78d448aa..0d5b4dad 100644
--- a/internal/runner/onboarding_test.go
+++ b/internal/runner/onboarding_test.go
@@ -63,7 +63,8 @@ func TestOnboardingPairingBound(t *testing.T) {
out := &enrolOutput{cancel: cancel}
e := Enrol(ctx, c, out)
cancel()
- if e == nil || !strings.Contains(out.String(), "0123456789") || !strings.Contains(out.String(), c.Origin+"/runners/enrol") {
+ // One tap: the link carries the code; the code is also on its own line.
+ if e == nil || !strings.Contains(out.String(), "\n0123456789\n") || !strings.Contains(out.String(), "("+c.Origin+"/runners/enrol?code=0123456789)") {
t.Fatalf("missing code or verification address %q %v", out.String(), e)
}
}
diff --git a/internal/runner/setup/service.go b/internal/runner/setup/service.go
index 18e38035..59c4e693 100644
--- a/internal/runner/setup/service.go
+++ b/internal/runner/setup/service.go
@@ -57,7 +57,16 @@ func SaveServiceEnvironment(root string, data []byte) error {
}
func ReadServiceEnvironment(root string) (map[string]string, error) {
- path := root + "/runner.env"
+ return ReadEnvFile(root + "/runner.env")
+}
+
+// ReadEnvFile reads a private runner environment file: EQUIPO_ keys
+// only, each once, values optionally quoted; the file the runner's own,
+// 0600, no symlink (a Mac's launchd agent passes it with --env-file).
+func ReadEnvFile(path string) (map[string]string, error) {
+ if !filepath.IsAbs(path) || filepath.Clean(path) != path {
+ return nil, errUnavailable
+ }
real, e := filepath.EvalSymlinks(path)
if e != nil || real != path {
return nil, errUnavailable
diff --git a/internal/runner/thin/fakeworker_testbuild.go b/internal/runner/thin/fakeworker_testbuild.go
index fe5ba415..4fe8dce5 100644
--- a/internal/runner/thin/fakeworker_testbuild.go
+++ b/internal/runner/thin/fakeworker_testbuild.go
@@ -3,17 +3,10 @@
package thin
import (
- "bytes"
"context"
- "errors"
- "os"
- "os/exec"
- "path/filepath"
- "strconv"
"strings"
- "syscall"
- "time"
+ "amadan.net/oficina/equipo/internal/runner/mac"
"amadan.net/oficina/equipo/internal/wire"
)
@@ -24,8 +17,9 @@ const fakeWorkerMarker = "equipo-fake-worker-unsandboxed-process-group"
// The test build's fake Mac worker (Mac runners spec §6): the real thin
// runner started with EQUIPO_FAKE_PLATFORM=darwin/arm64 reports a Mac's
// capabilities (a fixture until probe P1 records tito-studio's) and runs
-// checks in a process group WITHOUT a sandbox. It exists only under the
-// testbuild tag, so no release binary can run anything unsandboxed.
+// checks with the Mac's process-group gate WITHOUT a sandbox. It exists
+// only under the testbuild tag, so no release binary can run checks
+// unsandboxed on Linux.
func init() {
fake = &fakeWorker{}
}
@@ -48,117 +42,9 @@ func (fakeWorker) capabilities(context.Context) wire.Capabilities {
return wire.Capabilities{Xcode: wire.Xcode{Version: "16.2", Build: "16C5032a"}, Simulators: []wire.Simulator{{Name: "iPhone 16 Pro", Runtime: "iOS 18.2", UDID: "5C0A1E2B-3D4F-4A5B-9C6D-7E8F90A1B2C3", State: "Shutdown"}}, Toolchains: wire.Toolchains{Swift: "6.0.3", Node: "v22.12.0"}, Harness: wire.Harness{Claude: "2.1.312", SRT: "0.0.81"}, Tags: []string{wire.TagMacOS, wire.TagXcode, wire.TagIOSSimulator, wire.TagClaude}}
}
-func (fakeWorker) gate(bin string) GateRunner { return &groupGate{bin: bin} }
-
-// groupGate runs a gate in its own session and process group, marked with
-// EQUIPO_ATTEMPT, with an environment from scratch: HOME and TMPDIR in
-// the attempt's directory, CI=1, a fixed PATH (bin first: the fake
-// xcodebuild). Cancel or timeout: SIGTERM to the group, 10 s, SIGKILL,
-// then a sweep of marked processes. Termination is the group gone and no
-// marked process left, within 30 s.
-type groupGate struct{ bin string }
-
-func (groupGate) Sandbox() string { return wire.SandboxNone }
-
-func (g *groupGate) Run(ctx context.Context, attempt, dir string, argv []string, limit time.Duration, record func(string)) gateResult {
- scratch, err := os.MkdirTemp(filepath.Dir(dir), "attempt-")
- if err != nil {
- return gateResult{reason: "checks_unavailable", terminated: true}
- }
- defer os.RemoveAll(scratch)
- cmd := exec.Command(argv[0], argv[1:]...)
- cmd.Dir = dir
- cmd.Env = []string{"HOME=" + scratch, "TMPDIR=" + scratch, "CI=1", "PATH=" + g.bin + ":/usr/local/bin:/usr/bin:/bin", "EQUIPO_ATTEMPT=" + attempt, "LANG=C"}
- out := &lineTail{max: wire.MaxChecksLines}
- cmd.Stdout, cmd.Stderr = out, out
- cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
- if err := cmd.Start(); err != nil {
- return gateResult{reason: "checks_unavailable", terminated: true}
- }
- pgid := cmd.Process.Pid
- record("pg:" + strconv.Itoa(pgid) + ":" + attempt)
- exited := make(chan error, 1)
- go func() { exited <- cmd.Wait() }()
- res := gateResult{code: -1}
- stop := func(reason string) {
- res.reason = reason
- _ = syscall.Kill(-pgid, syscall.SIGTERM)
- select {
- case <-exited:
- case <-time.After(10 * time.Second):
- _ = syscall.Kill(-pgid, syscall.SIGKILL)
- <-exited
- }
- }
- select {
- case err := <-exited:
- var exit *exec.ExitError
- if err == nil {
- res.code = 0
- } else if errors.As(err, &exit) {
- res.code = exit.ExitCode()
- }
- case <-ctx.Done():
- stop("cancelled")
- case <-time.After(limit):
- stop("checks_timeout")
- }
- res.terminated = g.settle(pgid, attempt)
- res.output = out.String()
- return res
-}
-
-// settle kills what is left of the group and of the marked processes and
-// reports whether, within 30 s, none remains.
-func (g *groupGate) settle(pgid int, attempt string) bool {
- deadline := time.Now().Add(30 * time.Second)
- for time.Now().Before(deadline) {
- _ = syscall.Kill(-pgid, syscall.SIGKILL)
- marked := markedProcesses(attempt)
- for _, pid := range marked {
- _ = syscall.Kill(pid, syscall.SIGKILL)
- }
- if syscall.Kill(-pgid, 0) == syscall.ESRCH && len(marked) == 0 {
- return true
- }
- time.Sleep(100 * time.Millisecond)
- }
- return false
-}
-
-// Verify: a recorded attempt has ended when its group is gone and no
-// process still carries its marker.
-func (g *groupGate) Verify(id string) bool {
- rest, ok := strings.CutPrefix(id, "pg:")
- if !ok {
- return false
- }
- num, attempt, _ := strings.Cut(rest, ":")
- pgid, err := strconv.Atoi(num)
- if err != nil || pgid <= 1 {
- return false
- }
- return g.settle(pgid, attempt)
-}
-
-// markedProcesses are this user's processes whose environment carries the
-// attempt's marker (Linux /proc; the Mac uses ps -E).
-func markedProcesses(attempt string) []int {
- if attempt == "" {
- return nil
- }
- want := []byte("EQUIPO_ATTEMPT=" + attempt + "\x00")
- entries, _ := os.ReadDir("/proc")
- var out []int
- for _, e := range entries {
- pid, err := strconv.Atoi(e.Name())
- if err != nil || pid == os.Getpid() {
- continue
- }
- env, err := os.ReadFile(filepath.Join("/proc", e.Name(), "environ"))
- if err == nil && bytes.Contains(append(env, 0), want) {
- out = append(out, pid)
- }
- }
- return out
+// gate runs checks in a process group with an environment from scratch:
+// HOME and TMPDIR the attempt's scratch, CI=1, a fixed PATH (bin first:
+// the fake xcodebuild).
+func (fakeWorker) gate(bin string) GateRunner {
+ return macGate{g: &mac.Gate{Env: []string{"CI=1", "PATH=" + bin + ":/usr/local/bin:/usr/bin:/bin", "LANG=C"}, ScratchHome: true, Lines: wire.MaxChecksLines, Sandbox: wire.SandboxNone}}
}
diff --git a/internal/runner/thin/judge.go b/internal/runner/thin/judge.go
index 468ef3c6..05ca6dc4 100644
--- a/internal/runner/thin/judge.go
+++ b/internal/runner/thin/judge.go
@@ -422,6 +422,8 @@ type gateResult struct {
output, reason string
code int
terminated bool
+ // sandbox is how a worker's gate was confined (wire.Sandbox*).
+ sandbox string
}
// runGate runs the gate in the containment's check profile: the tree at
diff --git a/internal/runner/thin/link.go b/internal/runner/thin/link.go
index 5d265f33..b6999646 100644
--- a/internal/runner/thin/link.go
+++ b/internal/runner/thin/link.go
@@ -54,6 +54,9 @@ type Link struct {
// Relay uploads packs and publishes workers' commits (protocol 2).
Relay *Relay
Hello func() wire.Hello
+ // Welcomed sees each welcome (a Mac worker updates itself to the
+ // release it names).
+ Welcomed func(wire.Welcome)
// Connector adds connections the person starts from the app.
Connector *Connector
Logger *slog.Logger
@@ -468,6 +471,9 @@ func (l *Link) serve(ctx context.Context, c *websocket.Conn, welcome *wire.Welco
if err := l.State.SaveGeneration(ctx, welcome.Generation); err != nil {
return 0, err
}
+ if l.Welcomed != nil {
+ l.Welcomed(*welcome)
+ }
sync, err := l.State.Sync(ctx)
if err == nil && l.Hello != nil {
sync.Connections = l.Hello().Connections
diff --git a/internal/runner/thin/mac.go b/internal/runner/thin/mac.go
new file mode 100644
index 00000000..ea1bbc5f
--- /dev/null
+++ b/internal/runner/thin/mac.go
@@ -0,0 +1,433 @@
+package thin
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/hex"
+ "encoding/json"
+ "errors"
+ "io"
+ "net"
+ "net/http"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "sync"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/release"
+ "amadan.net/oficina/equipo/internal/runner"
+ "amadan.net/oficina/equipo/internal/runner/mac"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// A Mac worker (Mac runners spec §§3 to 5): checks only, under srt when
+// probe P2 denied every hostile attempt, otherwise outside the sandbox
+// and labelled so (Paul's ruling 2). The pieces are in internal/runner/
+// mac; this file wires them to the worker.
+
+// macGate adapts a Mac gate to the worker's GateRunner.
+type macGate struct{ g *mac.Gate }
+
+func (m macGate) Sandbox() string { return m.g.Sandbox }
+
+func (m macGate) Run(ctx context.Context, attempt, dir string, argv []string, limit time.Duration, record func(string)) gateResult {
+ r := m.g.Run(ctx, attempt, dir, argv, limit, record)
+ return gateResult{output: r.Output, reason: r.Reason, code: r.Code, terminated: r.Terminated, sandbox: r.Sandbox}
+}
+
+func (m macGate) Verify(id string) bool { return m.g.Verify(id) }
+
+// macChecks chooses each attempt's gate from the newest probe report:
+// srt and seatbelt when P2 denied; srt still, labelled none, when the
+// fixture at least built under srt (the boundary is unproven, not
+// absent); otherwise no sandbox, labelled none.
+type macChecks struct {
+ probes *macProbes
+ srt string
+ sandboxed, unproven, bare *mac.Gate
+}
+
+func (m *macChecks) pick() *mac.Gate {
+ r := m.probes.report()
+ switch {
+ case m.srt != "" && r.Sandboxed():
+ return m.sandboxed
+ case m.srt != "" && r.SRTRanXcode:
+ return m.unproven
+ }
+ return m.bare
+}
+
+func (m *macChecks) Sandbox() string { return m.pick().Sandbox }
+
+func (m *macChecks) Run(ctx context.Context, attempt, dir string, argv []string, limit time.Duration, record func(string)) gateResult {
+ return macGate{m.pick()}.Run(ctx, attempt, dir, argv, limit, record)
+}
+
+// Verify settles a recorded attempt the same way whatever confined it.
+func (m *macChecks) Verify(id string) bool { return m.bare.Verify(id) }
+
+// macProbes keeps the probe report (probes.json in the state dir, where
+// `equipo-runner probe` writes too) and runs the probes when it is
+// missing or was made by another version or profile.
+type macProbes struct {
+ file, version string
+ run func(context.Context) mac.Report
+
+ mu sync.Mutex
+ last mac.Report
+ mtime time.Time
+ ready chan struct{}
+}
+
+func newMacProbes(file, version string, run func(context.Context) mac.Report) *macProbes {
+ return &macProbes{file: file, version: version, run: run, ready: make(chan struct{})}
+}
+
+// report is the newest report, re-read when the file changed.
+func (p *macProbes) report() mac.Report {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ if info, err := os.Stat(p.file); err == nil && !info.ModTime().Equal(p.mtime) {
+ if r, err := mac.LoadReport(p.file); err == nil {
+ p.last, p.mtime = r, info.ModTime()
+ }
+ }
+ return p.last
+}
+
+// start runs the probes now unless the saved report is current; ready
+// closes when there is a current report. refresh tells the instance.
+func (p *macProbes) start(ctx context.Context, refresh func()) {
+ if p.report().Current(p.version) {
+ close(p.ready)
+ return
+ }
+ go func() {
+ r := p.run(ctx)
+ if ctx.Err() != nil {
+ return
+ }
+ if err := mac.SaveReport(p.file, r); err == nil {
+ p.mu.Lock()
+ p.last, p.mtime = r, time.Time{}
+ p.mu.Unlock()
+ }
+ close(p.ready)
+ refresh()
+ }()
+}
+
+// watch tells the instance when someone ran `equipo-runner probe`.
+func (p *macProbes) watch(ctx context.Context, refresh func()) {
+ seen := p.report().At
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-time.After(30 * time.Second):
+ }
+ if at := p.report().At; !at.Equal(seen) {
+ seen = at
+ refresh()
+ }
+ }
+}
+
+func (p *macProbes) wait(ctx context.Context) error {
+ select {
+ case <-p.ready:
+ return nil
+ case <-ctx.Done():
+ return ctx.Err()
+ }
+}
+
+// macHost is the Mac worker's setup: its tools, paths and gates.
+type macHost struct {
+ paths mac.Paths
+ tools mac.Tools
+ env []string
+ probes *macProbes
+ checks *macChecks
+ caps func(context.Context) wire.Capabilities
+}
+
+// Mac tool discovery (spec §3.3): EQUIPO_SRT_PATH and the installer's
+// private srt first, then the usual places.
+func macTools(installDir, home string, getenv func(string) string) mac.Tools {
+ dirs := []string{filepath.Join(installDir, "srt", "node_modules", ".bin"), filepath.Join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin", "/usr/bin"}
+ find := func(env, name string) string {
+ if p := getenv(env); filepath.IsAbs(p) && executable(p) {
+ return p
+ }
+ for _, d := range dirs {
+ if p := filepath.Join(d, name); executable(p) {
+ return p
+ }
+ }
+ return ""
+ }
+ return mac.Tools{Xcodebuild: "/usr/bin/xcodebuild", Xcrun: "/usr/bin/xcrun", Swift: "/usr/bin/swift", Git: getenv("EQUIPO_GIT_PATH"),
+ SRT: find("EQUIPO_SRT_PATH", "srt"), Node: find("EQUIPO_NODE_PATH", "node"), RG: find("EQUIPO_RG_PATH", "rg"), Claude: find("EQUIPO_CLAUDE_PATH", "claude"), Codex: find("EQUIPO_CODEX_PATH", "codex")}
+}
+
+func executable(p string) bool {
+ info, err := os.Stat(p)
+ return err == nil && info.Mode().IsRegular() && info.Mode().Perm()&0111 != 0
+}
+
+func execTool(ctx context.Context, name string, args ...string) (string, error) {
+ out, err := exec.CommandContext(ctx, name, args...).Output()
+ return string(out), err
+}
+
+// gatePath is a gate's fixed PATH: the system's, Homebrew's, and Node's
+// directory (srt runs on Node).
+func gatePath(t mac.Tools) string {
+ dirs := []string{"/usr/bin", "/bin", "/usr/sbin", "/sbin", "/opt/homebrew/bin", "/usr/local/bin"}
+ for _, tool := range []string{t.Node, t.RG} {
+ if tool != "" {
+ if d := filepath.Dir(tool); !contains(dirs, d) {
+ dirs = append([]string{d}, dirs...)
+ }
+ }
+ }
+ return strings.Join(dirs, ":")
+}
+
+func contains(list []string, s string) bool {
+ for _, x := range list {
+ if x == s {
+ return true
+ }
+ }
+ return false
+}
+
+func newMacHost(c runner.Config, o Options, getenv func(string) string) (*macHost, error) {
+ home, err := os.UserHomeDir()
+ if err != nil {
+ return nil, err
+ }
+ accounts := o.AccountsRoot
+ if accounts == "" {
+ accounts = DefaultAccountsRoot()
+ }
+ h := &macHost{}
+ h.paths = mac.Paths{Home: home, StateDir: c.StateDir, AccountsRoot: accounts, SessionRoot: SessionRoot(c), InstallDir: filepath.Dir(c.Executable), OtherHomes: mac.OtherHomes("/Users", home)}
+ h.tools = macTools(h.paths.InstallDir, home, getenv)
+ h.env = []string{"HOME=" + home, "PATH=" + gatePath(h.tools), "CI=1", "LANG=en_US.UTF-8"}
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ if out, err := execTool(ctx, "/usr/bin/xcode-select", "-p"); err == nil && filepath.IsAbs(strings.TrimSpace(out)) {
+ h.env = append(h.env, "DEVELOPER_DIR="+strings.TrimSpace(out))
+ }
+ cancel()
+ settings := func(tree, attempt string) ([]byte, error) {
+ return mac.ChecksSettings(mac.ChecksInput{Paths: h.paths, Tree: tree, Attempt: attempt, Mach: mac.CheckMachServices})
+ }
+ booted := func(ctx context.Context) []string {
+ out, err := execTool(ctx, h.tools.Xcrun, "simctl", "list", "-j", "devices", "booted")
+ var udids []string
+ if err == nil {
+ for _, s := range mac.ParseSimulators([]byte(out)) {
+ if s.State == "Booted" {
+ udids = append(udids, s.UDID)
+ }
+ }
+ }
+ return udids
+ }
+ shutdown := func(ctx context.Context, udid string) {
+ c, cancel := context.WithTimeout(ctx, time.Minute)
+ defer cancel()
+ _, _ = execTool(c, h.tools.Xcrun, "simctl", "shutdown", udid)
+ }
+ gate := func(srt, label string) *mac.Gate {
+ g := &mac.Gate{SRT: srt, Env: h.env, Caffeinate: "/usr/bin/caffeinate", Booted: booted, Shutdown: shutdown, Lines: wire.MaxChecksLines, Sandbox: label}
+ if srt != "" {
+ g.Settings = settings
+ }
+ return g
+ }
+ h.probes = newMacProbes(filepath.Join(c.StateDir, "probes.json"), o.Version, func(ctx context.Context) mac.Report {
+ return mac.RunProbes(ctx, h.probeHost(o.Version, gate))
+ })
+ h.checks = &macChecks{probes: h.probes, srt: h.tools.SRT, sandboxed: gate(h.tools.SRT, wire.SandboxSeatbelt), unproven: gate(h.tools.SRT, wire.SandboxNone), bare: gate("", wire.SandboxNone)}
+ h.caps = func(ctx context.Context) wire.Capabilities {
+ caps := mac.Capabilities(ctx, execTool, h.tools)
+ if probes := h.probes.report().Probes; len(probes) > 0 {
+ caps.Probes = probes
+ }
+ return caps
+ }
+ return h, nil
+}
+
+func (h *macHost) probeHost(version string, gate func(string, string) *mac.Gate) mac.ProbeHost {
+ return mac.ProbeHost{Exec: execTool, Tools: h.tools, Paths: h.paths, Scratch: filepath.Join(filepath.Dir(h.paths.StateDir), "scratch", "probes"), UID: os.Getuid(), Version: version,
+ Gate: func(sandboxed bool) *mac.Gate {
+ if sandboxed {
+ return gate(h.tools.SRT, wire.SandboxSeatbelt)
+ }
+ return gate("", wire.SandboxNone)
+ },
+ Resolve: func(ctx context.Context, name string) bool {
+ addrs, err := net.DefaultResolver.LookupHost(ctx, name)
+ return err == nil && len(addrs) > 0
+ },
+ ListHome: mac.CanList,
+ Listen: func() (net.Listener, error) { return net.Listen("tcp", "127.0.0.1:0") },
+ }
+}
+
+// find chooses a Mac's gate: the repository's own (with macOS's bash),
+// else xcodebuild test for an Xcode project.
+func (h *macHost) find(dir string) (gate, string, bool) {
+ if g, ok := findGate(dir); ok {
+ if len(g.argv) > 0 && g.argv[0] == "/usr/bin/bash" {
+ g.argv = append([]string{"/bin/bash"}, g.argv[1:]...)
+ }
+ return g, "", true
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
+ defer cancel()
+ argv, ok, reason := mac.XcodeGate(dir, h.caps(ctx).Simulators)
+ if !ok {
+ return gate{}, "", false
+ }
+ return gate{name: mac.XcodeGateName, argv: argv}, reason, true
+}
+
+// runMac serves the instance as a Mac worker.
+func runMac(ctx context.Context, c runner.Config, o Options) error {
+ h, err := newMacHost(c, o, os.Getenv)
+ if err != nil {
+ return err
+ }
+ if o.Logger != nil && h.tools.SRT == "" {
+ o.Logger.Warn("srt is not installed: checks run outside the sandbox and say so")
+ }
+ up := &macUpdater{origin: c.Origin, version: o.Version, binary: c.Executable, fetch: fetchLimited}
+ return runWorker(ctx, c, o, hostPlatform(), workerSetup{probe: h.caps, gate: h.checks, find: h.find, ready: h.probes.wait,
+ started: func(ctx context.Context, refresh func()) {
+ h.probes.start(ctx, refresh)
+ go h.probes.watch(ctx, refresh)
+ },
+ welcomed: func(w wire.Welcome, worker *Worker, stop context.CancelCauseFunc) {
+ up.offer(w, func() func() { worker.mu.Lock(); return worker.mu.Unlock }, func() { stop(ErrUpdated) }, o.Logger)
+ }})
+}
+
+// RunProbes runs the Mac probes now and saves the report where the
+// running worker reads it (`equipo-runner probe`).
+func RunProbes(ctx context.Context, c runner.Config, o Options) (mac.Report, error) {
+ h, err := newMacHost(c, o, os.Getenv)
+ if err != nil {
+ return mac.Report{}, err
+ }
+ r := h.probes.run(ctx)
+ if err := ctx.Err(); err != nil {
+ return r, err
+ }
+ return r, mac.SaveReport(h.probes.file, r)
+}
+
+// macUpdater replaces the worker's binary with the release its instance
+// serves (spec §3.3): the darwin/arm64 runner of that release's install
+// manifest, verified against its digest, swapped between steps; then the
+// worker exits mac.ExitUpdated and launchd starts the new one.
+type macUpdater struct {
+ origin, version, binary string
+ fetch func(ctx context.Context, url string, limit int64) ([]byte, error)
+ once sync.Once
+ done chan error
+}
+
+func (u *macUpdater) offer(w wire.Welcome, hold func() func(), stop func(), log interface{ Warn(string, ...any) }) {
+ if w.Release == "" || w.Release == u.version || !release.ValidInstallVersion(w.Release) {
+ return
+ }
+ u.once.Do(func() {
+ u.done = make(chan error, 1)
+ go func() {
+ err := u.apply(context.Background(), w.Release, hold, stop)
+ if err != nil && log != nil {
+ log.Warn("update to the instance's release failed", "release", w.Release, "err", err)
+ }
+ u.done <- err
+ }()
+ })
+}
+
+func (u *macUpdater) apply(ctx context.Context, version string, hold func() func(), stop func()) error {
+ base := u.origin + "/releases/" + version + "/"
+ raw, err := u.fetch(ctx, base+"install-manifest.json", 1<<20)
+ if err != nil {
+ return err
+ }
+ var m release.InstallManifest
+ if err := json.Unmarshal(raw, &m); err != nil {
+ return err
+ }
+ t, err := m.DarwinTarget(version)
+ if err != nil {
+ return err
+ }
+ bin, err := u.fetch(ctx, base+release.DarwinDir+"/equipo-runner", 128<<20)
+ if err != nil {
+ return err
+ }
+ if sum := sha256.Sum256(bin); hex.EncodeToString(sum[:]) != t.RunnerSHA256 {
+ return errors.New("the release's runner does not match its digest")
+ }
+ tmp, err := os.CreateTemp(filepath.Dir(u.binary), ".equipo-runner-update-")
+ if err != nil {
+ return err
+ }
+ defer os.Remove(tmp.Name())
+ if _, err = tmp.Write(bin); err == nil {
+ err = tmp.Chmod(0700)
+ }
+ if err == nil {
+ err = tmp.Sync()
+ }
+ if cerr := tmp.Close(); err == nil {
+ err = cerr
+ }
+ if err != nil {
+ return err
+ }
+ // Between steps: no attempt runs while the binary changes.
+ release := hold()
+ defer release()
+ if err := os.Rename(tmp.Name(), u.binary); err != nil {
+ return err
+ }
+ stop()
+ return nil
+}
+
+// fetchLimited GETs url (no redirects) and refuses more than limit bytes.
+func fetchLimited(ctx context.Context, url string, limit int64) ([]byte, error) {
+ c := http.Client{Timeout: 5 * time.Minute, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
+ if err != nil {
+ return nil, err
+ }
+ resp, err := c.Do(req)
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ return nil, errors.New("release download: " + resp.Status)
+ }
+ b, err := io.ReadAll(io.LimitReader(resp.Body, limit+1))
+ if err != nil || int64(len(b)) > limit {
+ return nil, errors.New("release download too large")
+ }
+ return b, nil
+}
diff --git a/internal/runner/thin/mac_test.go b/internal/runner/thin/mac_test.go
new file mode 100644
index 00000000..d0bed37d
--- /dev/null
+++ b/internal/runner/thin/mac_test.go
@@ -0,0 +1,214 @@
+package thin
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/hex"
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/release"
+ "amadan.net/oficina/equipo/internal/runner/mac"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// A worker's report says how its checks were confined, and a tree whose
+// gate cannot be chosen (two schemes, no simulator) is checks that
+// cannot run, never a pass; the gate waits until the probes are done.
+func TestWorkerMacReports(t *testing.T) {
+ x := newWorkerRig(t)
+ x.chunk(t, "c1", x.header(), x.pack, 0, 1, "")
+ x.gate.sandbox = wire.SandboxNone
+ if rep := x.run(); rep.Checks != wire.ChecksPassed || rep.ChecksSandbox != wire.SandboxNone {
+ t.Fatalf("label %+v", rep)
+ }
+ x.r.Attempt = 2
+ h := x.header()
+ h.ID = "tr_2"
+ x.chunk(t, "c2", h, x.pack, 0, 1, "")
+ x.w.Find = func(string) (gate, string, bool) { return gate{}, "checks_unavailable", true }
+ if rep := x.run(); rep.State != wire.StepDone || rep.Checks != wire.ChecksCannotRun || rep.Reason != "checks_unavailable" || len(x.gate.ran) != 1 {
+ t.Fatalf("unchosen gate %+v ran %v", rep, x.gate.ran)
+ }
+ x.w.Find = nil
+ x.w.Ready = func(ctx context.Context) error { return context.Canceled }
+ if rep := x.run(); rep.State != wire.StepCancelled || len(x.gate.ran) != 1 {
+ t.Fatalf("ran before the probes were done: %+v", rep)
+ }
+}
+
+func saveReport(t *testing.T, file string, r mac.Report) {
+ t.Helper()
+ if err := mac.SaveReport(file, r); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// Each attempt's gate follows the newest probe report: srt and seatbelt
+// only when P2 denied; srt labelled none when the fixture built under
+// srt; otherwise outside the sandbox, labelled none. No srt, no
+// sandbox, whatever the report says.
+func TestMacChecksPick(t *testing.T) {
+ file := filepath.Join(t.TempDir(), "probes.json")
+ p := newMacProbes(file, "v1", nil)
+ m := &macChecks{probes: p, srt: "/x/srt", sandboxed: &mac.Gate{Sandbox: wire.SandboxSeatbelt}, unproven: &mac.Gate{SRT: "/x/srt", Sandbox: wire.SandboxNone}, bare: &mac.Gate{Sandbox: wire.SandboxNone}}
+ if m.pick() != m.bare {
+ t.Fatal("no report: not bare")
+ }
+ saveReport(t, file, mac.Report{Probes: []wire.Probe{{ID: "P2", Verdict: wire.ProbeFailed}}, SRTRanXcode: true})
+ if m.pick() != m.unproven || m.Sandbox() != wire.SandboxNone {
+ t.Fatal("srt ran xcodebuild, P2 failed: not srt labelled none")
+ }
+ time.Sleep(10 * time.Millisecond)
+ saveReport(t, file, mac.Report{Probes: []wire.Probe{{ID: "P2", Verdict: wire.ProbeDenied}}, SRTRanXcode: true})
+ if m.pick() != m.sandboxed || m.Sandbox() != wire.SandboxSeatbelt {
+ t.Fatal("P2 denied: not seatbelt")
+ }
+ m.srt = ""
+ if m.pick() != m.bare {
+ t.Fatal("no srt: not bare")
+ }
+}
+
+// The probes run at start unless the saved report is this version's
+// with this profile; steps wait for them; the instance is told.
+func TestMacProbesStart(t *testing.T) {
+ file := filepath.Join(t.TempDir(), "probes.json")
+ var runs atomic.Int32
+ run := func(context.Context) mac.Report {
+ runs.Add(1)
+ return mac.Report{Version: "v2", Profile: mac.ProfileDigest(), Probes: probesAll(wire.ProbeDenied)}
+ }
+ p := newMacProbes(file, "v2", run)
+ refreshed := make(chan struct{}, 1)
+ p.start(context.Background(), func() { refreshed <- struct{}{} })
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ if err := p.wait(ctx); err != nil {
+ t.Fatal(err)
+ }
+ <-refreshed
+ if runs.Load() != 1 || !p.report().Sandboxed() {
+ t.Fatalf("runs %d report %+v", runs.Load(), p.report())
+ }
+ again := newMacProbes(file, "v2", run)
+ again.start(context.Background(), func() {})
+ if err := again.wait(ctx); err != nil || runs.Load() != 1 {
+ t.Fatalf("a current report probed again: %d", runs.Load())
+ }
+ newer := newMacProbes(file, "v3", run)
+ newer.start(context.Background(), func() {})
+ if err := newer.wait(ctx); err != nil || runs.Load() != 2 {
+ t.Fatalf("a new version did not probe: %d", runs.Load())
+ }
+}
+
+func probesAll(p2 string) []wire.Probe {
+ var out []wire.Probe
+ for _, id := range wire.ProbeIDs {
+ v := wire.ProbePassed
+ if id == "P2" {
+ v = p2
+ }
+ out = append(out, wire.Probe{ID: id, Verdict: v})
+ }
+ return out
+}
+
+// A Mac finds the repository's own gate first (with macOS's bash), and
+// gives an Xcode project without one xcodebuild test.
+func TestMacFind(t *testing.T) {
+ sims := []wire.Simulator{{Name: "iPhone 16 Pro", Runtime: "iOS 18.2", UDID: "5C0A1E2B-3D4F-4A5B-9C6D-7E8F90A1B2C3", State: "Shutdown"}}
+ h := &macHost{caps: func(context.Context) wire.Capabilities { return wire.Capabilities{Simulators: sims} }}
+ tree := t.TempDir()
+ scheme := filepath.Join(tree, "Woodstar.xcodeproj/xcshareddata/xcschemes/Woodstar.xcscheme")
+ if err := os.MkdirAll(filepath.Dir(scheme), 0700); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(scheme, []byte("<Scheme/>"), 0600); err != nil {
+ t.Fatal(err)
+ }
+ g, reason, ok := h.find(tree)
+ if !ok || reason != "" || g.name != "xcodebuild test" || !strings.Contains(g.argv[2], "-scheme 'Woodstar' -destination 'platform=iOS Simulator,id=5C0A1E2B-3D4F-4A5B-9C6D-7E8F90A1B2C3'") {
+ t.Fatalf("%+v %q", g, reason)
+ }
+ if err := os.MkdirAll(filepath.Join(tree, ".amadan/ci.d"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(tree, ".amadan/ci.d/10-test"), []byte("#!/bin/sh\nmake test\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ if g, _, ok := h.find(tree); !ok || g.name != ".amadan/ci.d" || g.argv[0] != "/bin/bash" {
+ t.Fatalf("own gate %+v", g)
+ }
+}
+
+// The worker updates itself to its instance's release: the darwin
+// runner of that release's manifest, verified, swapped while no step
+// runs, then it stops to be restarted. A digest mismatch replaces
+// nothing; its own release or no release asks for nothing.
+func TestMacUpdater(t *testing.T) {
+ newBin := []byte("#!new runner\n")
+ sum := sha256.Sum256(newBin)
+ digest := hex.EncodeToString(sum[:])
+ var served atomic.Int32
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ served.Add(1)
+ switch r.URL.Path {
+ case "/releases/bbb2222/install-manifest.json":
+ _ = json.NewEncoder(w).Encode(release.InstallManifest{Version: "bbb2222", Targets: map[string]release.InstallTarget{release.TargetDarwin: {RunnerSHA256: digest, ToolProxySHA256: digest}}})
+ case "/releases/ccc3333/install-manifest.json":
+ _ = json.NewEncoder(w).Encode(release.InstallManifest{Version: "ccc3333", Targets: map[string]release.InstallTarget{release.TargetDarwin: {RunnerSHA256: strings.Repeat("0", 64), ToolProxySHA256: digest}}})
+ case "/releases/bbb2222/darwin-arm64/equipo-runner", "/releases/ccc3333/darwin-arm64/equipo-runner":
+ _, _ = w.Write(newBin)
+ default:
+ http.NotFound(w, r)
+ }
+ }))
+ defer srv.Close()
+ binary := filepath.Join(t.TempDir(), "equipo-runner")
+ if err := os.WriteFile(binary, []byte("#!old runner\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ try := func(rel string) (error, bool, bool) {
+ u := &macUpdater{origin: srv.URL, version: "aaa1111", binary: binary, fetch: fetchLimited}
+ held, stopped := false, false
+ u.offer(wire.Welcome{Release: rel}, func() func() { held = true; return func() {} }, func() { stopped = true }, nil)
+ if u.done == nil {
+ return nil, held, stopped
+ }
+ return <-u.done, held, stopped
+ }
+ for _, rel := range []string{"", "aaa1111", "dev", "../x"} {
+ if _, _, stopped := try(rel); stopped || served.Load() != 0 {
+ t.Fatalf("release %q fetched or stopped", rel)
+ }
+ }
+ if err, _, stopped := try("ccc3333"); err == nil || stopped {
+ t.Fatal("a runner whose digest does not match was taken")
+ }
+ if raw, _ := os.ReadFile(binary); string(raw) != "#!old runner\n" {
+ t.Fatal("binary replaced by an unverified download")
+ }
+ err, held, stopped := try("bbb2222")
+ if err != nil || !held || !stopped {
+ t.Fatalf("update: %v held=%v stopped=%v", err, held, stopped)
+ }
+ if raw, _ := os.ReadFile(binary); string(raw) != string(newBin) {
+ t.Fatal("binary not replaced")
+ }
+ if info, _ := os.Stat(binary); info.Mode().Perm() != 0700 {
+ t.Fatal("new binary not private and executable")
+ }
+ left, _ := filepath.Glob(filepath.Join(filepath.Dir(binary), ".equipo-runner-update-*"))
+ if len(left) != 0 {
+ t.Fatalf("left %v", left)
+ }
+}
diff --git a/internal/runner/thin/run.go b/internal/runner/thin/run.go
index 581b14f9..fcd0acff 100644
--- a/internal/runner/thin/run.go
+++ b/internal/runner/thin/run.go
@@ -6,6 +6,7 @@ import (
"log/slog"
"os"
"path/filepath"
+ "runtime"
"slices"
"strings"
@@ -94,7 +95,10 @@ func Run(ctx context.Context, c runner.Config, o Options) error {
if o.Logger != nil {
o.Logger.Warn("test build: the fake Mac worker runs checks in a process group without a sandbox", "build", fake.marker())
}
- return runWorker(ctx, c, o, platform, fake.capabilities, fake.gate(o.FakeBin))
+ return runWorker(ctx, c, o, platform, workerSetup{probe: fake.capabilities, gate: fake.gate(o.FakeBin)})
+ }
+ if runtime.GOOS == "darwin" {
+ return runMac(ctx, c, o)
}
// Ownership first: the state lock, then the scratch and workspace
// roots. Only then may recovery touch namespaces or scratch.
@@ -461,9 +465,27 @@ func verifiedExit(ctx context.Context, m *containment.Manager, id string) bool {
// no release binary runs the unsandboxed fake worker.
var ErrNotTestBuild = errors.New("EQUIPO_FAKE_PLATFORM: this runner is not a test build")
+// workerSetup is what differs between workers: the capability report,
+// the gate, how a gate is found in a tree, what must be ready before
+// judging, and what runs once the worker holds its roots.
+type workerSetup struct {
+ probe func(context.Context) wire.Capabilities
+ gate GateRunner
+ find func(dir string) (gate, string, bool)
+ ready func(context.Context) error
+ // started runs after startup with a function that refreshes the
+ // capability report; welcomed sees each welcome.
+ started func(ctx context.Context, refresh func())
+ welcomed func(wire.Welcome, *Worker, context.CancelCauseFunc)
+}
+
+// ErrUpdated ends a worker that replaced its binary with the instance's
+// release: the service manager starts the new one.
+var ErrUpdated = errors.New("runner updated to the instance's release")
+
// runWorker serves the instance as a worker: it runs the steps placed on
// it and nothing else (no coordinator, no clone, no forge credential).
-func runWorker(ctx context.Context, c runner.Config, o Options, platform wire.Platform, probe func(context.Context) wire.Capabilities, gate GateRunner) error {
+func runWorker(ctx context.Context, c runner.Config, o Options, platform wire.Platform, w workerSetup) error {
release, err := startup(ctx, c, func(context.Context) error { return nil })
if err != nil {
return err
@@ -478,35 +500,45 @@ func runWorker(ctx context.Context, c runner.Config, o Options, platform wire.Pl
return err
}
defer state.Close()
- ctx, cancel := context.WithCancel(ctx)
- defer cancel()
- caps := &Capabilities{Probe: probe}
+ ctx, cancel := context.WithCancelCause(ctx)
+ defer cancel(nil)
+ caps := &Capabilities{Probe: w.probe}
link := &Link{Origin: c.Origin, Token: creds.Bearer.Token, State: state, Logger: o.Logger, Connected: o.Connected, Protocol: o.Protocol, WorkerOnly: true}
link.Hello = func() wire.Hello {
report := caps.Get(ctx)
- return 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: gate.Sandbox(), Capabilities: &report}
+ return 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}
}
engineer := &Engineer{O: o.Claude, Authorize: link.Confirm, AuthorizeStep: link.ConfirmStep, Owners: coordinatorPersons(c)(), MaxStep: o.MaxStep, Host: c.MachineLabel}
engineer.O.Runner, engineer.O.State, engineer.O.Logger = c, state, o.Logger
- worker := &Worker{State: state, Engine: engineer, Gate: gate, MaxStep: o.MaxStep}
+ worker := &Worker{State: state, Engine: engineer, Gate: w.gate, MaxStep: o.MaxStep, StepRoot: filepath.Join(c.ScratchRoot, "worker-steps"), Find: w.find, Ready: w.ready}
+ if w.welcomed != nil {
+ link.Welcomed = func(welcome wire.Welcome) { w.welcomed(welcome, worker, cancel) }
+ }
+ if w.started != nil {
+ w.started(ctx, func() { caps.Stale(); link.HelloSoon() })
+ }
tags := func() []string { return caps.Get(ctx).Tags }
steps := &StepEngine{State: state, Exec: placementGuard(tags, caps.Stale, worker.Exec), Notify: link.Notify, Logger: o.Logger,
Sweep: func(ctx context.Context) {
keys, err := state.finishedSteps(ctx)
if err == nil {
for _, r := range keys {
- _ = os.RemoveAll(filepath.Join(worker.root(), "steps", stepKey(r)))
+ _ = os.RemoveAll(filepath.Join(worker.stepsDir(), stepKey(r)))
}
}
},
- Verify: func(_ context.Context, id string) bool { return id == "" || gate.Verify(id) }, TerminationKind: wire.TerminationProcessGroup}
+ Verify: func(_ context.Context, id string) bool { return id == "" || w.gate.Verify(id) }, TerminationKind: wire.TerminationProcessGroup}
link.Steps = steps
if err := steps.Start(ctx); err != nil {
return err
}
err = link.Run(ctx)
- cancel()
+ updated := errors.Is(context.Cause(ctx), ErrUpdated)
+ cancel(nil)
steps.Wait()
+ if updated {
+ return ErrUpdated
+ }
if errors.Is(err, ErrSuperseded) {
_ = state.Supersede(context.Background())
return err
diff --git a/internal/runner/thin/worker.go b/internal/runner/thin/worker.go
index c9d12b9d..028e4807 100644
--- a/internal/runner/thin/worker.go
+++ b/internal/runner/thin/worker.go
@@ -8,6 +8,7 @@ import (
"os/exec"
"path/filepath"
"strings"
+ "sync"
"time"
"amadan.net/oficina/equipo/internal/runner/workspace"
@@ -56,10 +57,38 @@ type Worker struct {
// minutes); MaxStep bounds the gate.
PackWait time.Duration
MaxStep time.Duration
+ // StepRoot holds each attempt's tree. On a Mac it is under the
+ // scratch root, outside the state dir the checks profile denies.
+ StepRoot string
+ // Find chooses the gate in a tree (findGate, and on a Mac the
+ // xcodebuild test a project without a gate gets); reason says why
+ // none can run (checks_unavailable).
+ Find func(dir string) (g gate, reason string, ok bool)
+ // Ready waits until the runner may judge (a Mac's probes).
+ Ready func(context.Context) error
+
+ // mu is held while an attempt runs, so an update swaps the binary
+ // only between steps.
+ mu sync.Mutex
}
func (w *Worker) root() string { return filepath.Join(w.Engine.O.Runner.StateDir, "worker") }
+func (w *Worker) stepsDir() string {
+ if w.StepRoot != "" {
+ return w.StepRoot
+ }
+ return filepath.Join(w.root(), "steps")
+}
+
+func (w *Worker) find(dir string) (gate, string, bool) {
+ if w.Find != nil {
+ return w.Find(dir)
+ }
+ g, ok := findGate(dir)
+ return g, "", ok
+}
+
// objects is the worker's object store for a repository: relayed packs
// stay there, so a repository's objects move once.
func (w *Worker) objects(repo string) string {
@@ -78,6 +107,13 @@ func (w *Worker) Exec(ctx context.Context, r stepRow, progress func(wire.StepRep
// Only checks are placed on workers until slice F.
return end(wire.StepFailed, "placement_refused")
}
+ w.mu.Lock()
+ defer w.mu.Unlock()
+ if w.Ready != nil {
+ if err := w.Ready(ctx); err != nil {
+ return end(wire.StepCancelled, "cancelled")
+ }
+ }
if err := w.Engine.lease(ctx, r); err != nil {
return end(wire.StepCancelled, leaseReason(err))
}
@@ -96,7 +132,7 @@ func (w *Worker) Exec(ctx context.Context, r stepRow, progress func(wire.StepRep
return end(wire.StepFailed, "candidate_unavailable")
}
rep.Have = []string{r.CandidateSHA}
- dir := filepath.Join(w.root(), "steps", stepKey(r))
+ dir := filepath.Join(w.stepsDir(), stepKey(r))
defer os.RemoveAll(dir)
tree := workspace.TaskTree{Dir: filepath.Join(dir, "tree"), GitDir: store, Git: w.Engine.O.Runner.GitPath, Branch: r.Branch, Base: r.BaseSHA}
if err := w.checkout(ctx, tree, r.CandidateSHA); err != nil {
@@ -104,11 +140,15 @@ func (w *Worker) Exec(ctx context.Context, r stepRow, progress func(wire.StepRep
return end(wire.StepFailed, "workspace_refused")
}
progress(rep)
- g, ok := findGate(tree.Dir)
- if !ok {
+ g, reason, ok := w.find(tree.Dir)
+ switch {
+ case !ok:
rep.LogTail = "No checks found: no .amadan/ci.d, .amadan/ci or make ci target."
rep.Checks = wire.ChecksNone
return end(wire.StepDone, "")
+ case reason != "":
+ rep.Checks = wire.ChecksCannotRun
+ return end(wire.StepDone, reason)
}
if err := w.Engine.checkRepository(ctx, tree, r.CandidateSHA); err != nil {
w.Engine.log("worker checks repository", err)
@@ -121,7 +161,7 @@ func (w *Worker) Exec(ctx context.Context, r stepRow, progress func(wire.StepRep
res := w.Gate.Run(ctx, "checks/"+stepKey(r), tree.Dir, g.argv, limit, func(id string) {
_ = w.State.setStepNamespace(context.WithoutCancel(ctx), r, id)
})
- rep.TerminationKind = wire.TerminationProcessGroup
+ rep.TerminationKind, rep.ChecksSandbox = wire.TerminationProcessGroup, res.sandbox
rep.Gate, rep.Output, rep.LogTail = g.name, res.output, lastLines(res.output, stepTailLines, wire.MaxLogTail)
if !res.terminated {
rep.State, rep.Reason, rep.Termination = wire.StepFailed, firstNonEmpty(res.reason, "provider_failed"), false
diff --git a/internal/runner/thin/worker_test.go b/internal/runner/thin/worker_test.go
index 83e07626..c9887195 100644
--- a/internal/runner/thin/worker_test.go
+++ b/internal/runner/thin/worker_test.go
@@ -17,9 +17,10 @@ import (
// stubGate records what it was asked to run and answers code.
type stubGate struct {
- ran [][]string
- dirs []string
- code int
+ ran [][]string
+ dirs []string
+ code int
+ sandbox string
}
func (g *stubGate) Sandbox() string { return wire.SandboxNone }
@@ -28,7 +29,7 @@ func (g *stubGate) Run(_ context.Context, _, dir string, argv []string, _ time.D
g.dirs = append(g.dirs, dir)
record("pg:1:stub")
head, _ := os.ReadFile(filepath.Join(dir, "Swipe.swift"))
- return gateResult{code: g.code, terminated: true, output: "ran on " + strings.TrimSpace(string(head))}
+ return gateResult{code: g.code, terminated: true, output: "ran on " + strings.TrimSpace(string(head)), sandbox: g.sandbox}
}
func (g *stubGate) Verify(string) bool { return true }
diff --git a/internal/thintest/fakerunner.go b/internal/thintest/fakerunner.go
index c15a86e1..51396879 100644
--- a/internal/thintest/fakerunner.go
+++ b/internal/thintest/fakerunner.go
@@ -31,7 +31,8 @@ func DialRunner(ctx context.Context, origin, token string, generation int64) (*F
// capability report.
func WorkerHello(generation int64) wire.Hello {
return wire.Hello{Generation: generation, Repos: []string{}, CreateIn: []string{}, Catalog: []wire.RepoInfo{}, Connections: []wire.HeldConnection{}, Versions: map[string]string{"runner": "test"}, Protocol: wire.Protocol2, Platform: &wire.Platform{OS: "darwin", Arch: "arm64"}, Label: "Tito Studio", Sandbox: wire.SandboxSeatbelt,
- Capabilities: &wire.Capabilities{Xcode: wire.Xcode{Version: "16.2", Build: "16C5032a"}, Simulators: []wire.Simulator{{Name: "iPhone 16 Pro", Runtime: "iOS 18.2", UDID: "5C0A1E2B-3D4F-4A5B-9C6D-7E8F90A1B2C3", State: "Shutdown"}}, Tags: []string{wire.TagMacOS, wire.TagXcode, wire.TagIOSSimulator}}}
+ Capabilities: &wire.Capabilities{Xcode: wire.Xcode{Version: "16.2", Build: "16C5032a"}, Simulators: []wire.Simulator{{Name: "iPhone 16 Pro", Runtime: "iOS 18.2", UDID: "5C0A1E2B-3D4F-4A5B-9C6D-7E8F90A1B2C3", State: "Shutdown"}}, Tags: []string{wire.TagMacOS, wire.TagXcode, wire.TagIOSSimulator},
+ Probes: []wire.Probe{{ID: "P1", Verdict: wire.ProbePassed, Detail: "Xcode 16.2 (16C5032a); 1 iOS simulators; Tito Studio"}, {ID: "P2", Verdict: wire.ProbeFailed, Detail: "allowed: test.keychain; xcodebuild ran in srt"}, {ID: "P3", Verdict: wire.ProbeSkipped}, {ID: "P4", Verdict: wire.ProbePassed}, {ID: "P5", Verdict: wire.ProbeSkipped}, {ID: "P6", Verdict: wire.ProbePassed}, {ID: "P7", Verdict: wire.ProbePassed}}}}
}
// DialRunnerHello connects and says hello.
diff --git a/internal/thintest/placement_contract_test.go b/internal/thintest/placement_contract_test.go
index 1b887f3d..d9e2614a 100644
--- a/internal/thintest/placement_contract_test.go
+++ b/internal/thintest/placement_contract_test.go
@@ -279,7 +279,11 @@ func TestContractChecksPlacedOnTheWorker(t *testing.T) {
t.Fatal("a repeated start authorization (a resent lease) was refused")
}
w.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, CandidateSHA: sha, Findings: []wire.Finding{}})
- w.send(wire.FrameStep, passed(task, d.StepID, 1, sha))
+ // P2 did not deny every attempt, so the worker ran checks outside the
+ // sandbox and says so; step and task carry it (Paul's ruling 2).
+ pass := passed(task, d.StepID, 1, sha)
+ pass.ChecksSandbox = wire.SandboxNone
+ w.send(wire.FrameStep, pass)
_, body = r.expect(wire.FrameDispatch)
if rv := body.(*wire.DispatchCommand); rv.Specialist != wire.SpecialistReview || len(rv.Needs) != 0 {
t.Fatalf("review dispatch %+v", rv)
@@ -288,17 +292,32 @@ func TestContractChecksPlacedOnTheWorker(t *testing.T) {
if k.Checks != wire.ChecksPassed || k.Steps[1].TerminationKind != wire.TerminationProcessGroup || k.Steps[1].StartedAt == nil {
t.Fatalf("task %+v", k)
}
+ if k.ChecksSandbox != wire.SandboxNone || k.Steps[1].ChecksSandbox != wire.SandboxNone {
+ t.Fatalf("checks outside the sandbox not labelled: task %q step %q", k.ChecksSandbox, k.Steps[1].ChecksSandbox)
+ }
runners, err := r.client.Runners(r.ctx)
if err != nil || len(runners.Items) != 2 || runners.Items[0].Role != wire.RolePrimary || runners.Items[1].Label != "Tito Studio" || !runners.Items[1].Online {
t.Fatalf("runners %+v %v", runners, err)
}
+ if c := runners.Items[1].Capabilities; c == nil || len(c.Probes) != 7 || c.Probes[1].ID != "P2" || c.Probes[1].Verdict != wire.ProbeFailed {
+ t.Fatalf("the worker's probes are not on the runners view: %+v", c)
+ }
// A change that needs no Mac stays on the primary, worker or not.
plain, _ := r.candidate("Go fix", false)
_, body = r.expect(wire.FrameDispatch)
- if c := body.(*wire.DispatchCommand); c.Specialist != wire.SpecialistChecks || c.TaskID != plain || len(c.Needs) != 0 {
+ c := body.(*wire.DispatchCommand)
+ if c.Specialist != wire.SpecialistChecks || c.TaskID != plain || len(c.Needs) != 0 {
t.Fatalf("plain checks %+v", c)
}
+ // The primary's checks carry no worker label, whatever it reports.
+ own := passed(plain, c.StepID, 1, c.CandidateSHA)
+ own.ChecksSandbox = wire.SandboxNone
+ r.primary.send(wire.FrameStep, own)
+ r.expect(wire.FrameDispatch)
+ if k, _ := r.client.Task(r.ctx, plain); k.Checks != wire.ChecksPassed || k.ChecksSandbox != "" {
+ t.Fatalf("primary's checks labelled: %+v", k)
+ }
}
// M3 at the contract: with no worker that fits, checks go to the primary
diff --git a/internal/wire/tasks.go b/internal/wire/tasks.go
index 87bf2bb3..3c0f0b39 100644
--- a/internal/wire/tasks.go
+++ b/internal/wire/tasks.go
@@ -280,6 +280,9 @@ type Step struct {
Placement string `json:"placement"`
Publication string `json:"publication"`
TerminationKind string `json:"termination_kind"`
+ // ChecksSandbox: seatbelt or none (ran outside the sandbox) for a
+ // worker's checks; absent for the primary's.
+ ChecksSandbox string `json:"checks_sandbox,omitempty"`
}
// Task is one piece of work under a project. Branch is the task's own
@@ -310,10 +313,13 @@ type Task struct {
CandidateSHA string `json:"candidate_sha"`
Checks string `json:"checks"`
ChecksReason string `json:"checks_reason"`
- Verdict string `json:"verdict"`
- ReviewLabel string `json:"review_label"`
- NeedsYou string `json:"needs_you"`
- FixRounds int `json:"fix_rounds"`
+ // ChecksSandbox is the newest checks' confinement when a worker ran
+ // them: none means they ran outside the sandbox (Paul's ruling 2).
+ ChecksSandbox string `json:"checks_sandbox,omitempty"`
+ Verdict string `json:"verdict"`
+ ReviewLabel string `json:"review_label"`
+ NeedsYou string `json:"needs_you"`
+ FixRounds int `json:"fix_rounds"`
// BranchHead is the task branch's head on Amadan when it moved away
// from CandidateSHA ("" while it is there, or once the branch is gone
// with NeedsYou branch_moved).
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 581bab59..30e4b6ae 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -10932,5 +10932,271 @@
"match": "equipo-runner",
"count": 1,
"reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/equipo/copy.go",
+ "line_sha256": "4bf8b63d8ae89fbe0916f035026a11ea8e0d3a9c74ef855fd4f353008db634bd",
+ "match": "node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/equipo/copy.go",
+ "line_sha256": "e39a01d11b11ac8186c264038a7762548d4b4f5d8de0583ae45ef602435fd1ea",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/equipo/copy.go",
+ "line_sha256": "e39a01d11b11ac8186c264038a7762548d4b4f5d8de0583ae45ef602435fd1ea",
+ "match": "node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/config_test.go",
+ "line_sha256": "8393adb2809e8ea1d50a71f1c8a9a4eaf84e71575f5248069f932d0cb37d18b4",
+ "match": "equipo-runner",
+ "count": 2,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/account_test.go",
+ "line_sha256": "17d0e1af19b79db7553c6b77bb4ef0af3c7a56ecae74fcb251ece41c5f7e4de0",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/account_test.go",
+ "line_sha256": "68c6f7e0200c17ada751745a0438ea9af1605aa54cbeb412d0d1dcf239b33c81",
+ "match": "equipo-runner",
+ "count": 3,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/account_test.go",
+ "line_sha256": "f6754318ff8bc96f3a1fc44b28087cf497c78ff6cd74cbf77451dbdbce38617b",
+ "match": "equipo-runner",
+ "count": 4,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/caps.go",
+ "line_sha256": "5abbc8a613a7361123b31ce476f23dcd343b0268b89ded2135d55116e7af739f",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/caps.go",
+ "line_sha256": "9cdca89a36bff960c02b434ea2062ae64f62221f5847669901d46007124973aa",
+ "match": "node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/caps.go",
+ "line_sha256": "b335daf90e975de5c78d819d80149643401c52d83e6dc0706befa62a45efbfb8",
+ "match": "Node",
+ "count": 2,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/caps.go",
+ "line_sha256": "b335daf90e975de5c78d819d80149643401c52d83e6dc0706befa62a45efbfb8",
+ "match": "node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/caps_test.go",
+ "line_sha256": "0bb4c12f6dfec025dae938a149973d97f54aa1f3033a46d1d1d9eb324ec5ae36",
+ "match": "node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/caps_test.go",
+ "line_sha256": "aa868b41d078f76e1bbc236a9b9d3b402e64af694ad21cd90be31639d3dfa50f",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/caps_test.go",
+ "line_sha256": "aa868b41d078f76e1bbc236a9b9d3b402e64af694ad21cd90be31639d3dfa50f",
+ "match": "node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/caps_test.go",
+ "line_sha256": "d44406bca55c20fbbbe9fb866fe391d10a99ad9177fd633ae97df98afe50ffb2",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/gate_test.go",
+ "line_sha256": "08e775c26ee7a10d52eb238ca48318a258a75dff287caaba6e997a93324332e7",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/launchd.go",
+ "line_sha256": "99a502db260d1eefe5aac690e75cadb1c573447e4027f283ef3492fb44da159d",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/launchd.go",
+ "line_sha256": "ed2a03a5db9f21c5524a21fc553f4722c89cffc749feae4b14f9a5a7bfe06eb2",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe.go",
+ "line_sha256": "205ed031190f9ddb1308fe06f42ad896ba4dbf61c4868dbcfa0da6755ed0664b",
+ "match": "node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe.go",
+ "line_sha256": "7e3f1544a8d1acdd60f8df3bab40c35bf4be3e7261ec930988b737803aa7d7c5",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe.go",
+ "line_sha256": "7e3f1544a8d1acdd60f8df3bab40c35bf4be3e7261ec930988b737803aa7d7c5",
+ "match": "node",
+ "count": 2,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe.go",
+ "line_sha256": "c81037c36360a41353bfba90770713cb485cfad32a906c68fb41864fd4f5e2a6",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe.go",
+ "line_sha256": "d0665703bd159146c44afbcd235bc9cba187e235caaf054548571da9fdd13b6e",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe.go",
+ "line_sha256": "d0665703bd159146c44afbcd235bc9cba187e235caaf054548571da9fdd13b6e",
+ "match": "node",
+ "count": 2,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe.go",
+ "line_sha256": "e156b388ad45ac4dad7ed97b31b00e993ebd199706839a3f85d0cf70e59a7c5e",
+ "match": "node",
+ "count": 2,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe.go",
+ "line_sha256": "f5b85feb4a5a34694098ca14b0944ced93cd3c3f27c4eb71735d396b9d383747",
+ "match": "Node",
+ "count": 2,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe_test.go",
+ "line_sha256": "44950e069b32e9cac0bd1be01071e463f77784b7352d107830249ae15b225ac1",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe_test.go",
+ "line_sha256": "44950e069b32e9cac0bd1be01071e463f77784b7352d107830249ae15b225ac1",
+ "match": "node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe_test.go",
+ "line_sha256": "600016836ab52d0d6221cca4bf018df03ff3ce1a8c00cda521e252510c63fcb5",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe_test.go",
+ "line_sha256": "99f609b8249e80ce13c643bf443b3919265800055cbb581f708c2efe48713150",
+ "match": "Node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe_test.go",
+ "line_sha256": "ca726ef7b5740b9f9fa886ba41f184a2b218ae6123158cdc7da808772d6c4429",
+ "match": "equipo-runner",
+ "count": 2,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/probe_test.go",
+ "line_sha256": "f2bb245c829d9b35db391bb1fc0d88de1d7a4a10915085906b8431b85b8739c4",
+ "match": "node",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/profile_test.go",
+ "line_sha256": "057a49d5cac42ea6da38d18643036e6cd1254f661a9129775b0d8ddb8b8a948f",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/profile_test.go",
+ "line_sha256": "095015546fe33a52af1c2704906d73ef082715126dfc09409d4f8e101ddb5746",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/profile_test.go",
+ "line_sha256": "cc08558447e34a0cb611d0e264faf60851dc339709325670d26a7620bcd40a10",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/profile_test.go",
+ "line_sha256": "dd5cfc42e325a3c270c0e7634c6f9a6139386ff9b84b7067e1b89677cb09989b",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/runner/mac/profile_test.go",
+ "line_sha256": "f621067b9e17cb2e5d2bdcd247ec26a6a0f51a1c42b499df80ba5d239fe3cc83",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
+ },
+ {
+ "path": "internal/wire/wiretest/testdata/frames/hello-mac-probes.json",
+ "line_sha256": "7c1514f581e43cf001aec9df10a3f08626277be4696fbda524072c6acb073677",
+ "match": "node",
+ "count": 2,
+ "reason": "Mac runner (darwin worker): the runner executable, its launchd agent, install paths, the pinned srt package and Node it needs, and their tests and docs."
}
]