Mac probes copy their fixture under the scratch root
The probe host took its scratch from the state dir's parent, which is the scratch root only in the installer's layout. It now uses the configured scratch root; TestMacHostPaths also checks that a worker's attempt tree passes the checks profile and one in the state dir does not.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+47
−8
internal/runner/thin/mac.go+11 −8internal/runner/thin/mac_test.go+36 −0
Intent
diff --git a/internal/runner/thin/mac.go b/internal/runner/thin/mac.go| index ea1bbc5f..b3165a7f 100644 |
| --- a/internal/runner/thin/mac.go |
| +++ b/internal/runner/thin/mac.go |
| @@ -147,12 +147,15 @@ func (p *macProbes) wait(ctx context.Context) error { |
| // 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 |
| + // scratch is the runner's scratch root: the probes' fixture copies |
| + // live there, outside every denied place. |
| + scratch string |
| + 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 |
| @@ -216,7 +219,7 @@ func newMacHost(c runner.Config, o Options, getenv func(string) string) (*macHos |
| if accounts == "" { |
| accounts = DefaultAccountsRoot() |
| } |
| - h := &macHost{} |
| + h := &macHost{scratch: c.ScratchRoot} |
| 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"} |
| @@ -267,7 +270,7 @@ func newMacHost(c runner.Config, o Options, getenv func(string) string) (*macHos |
| } |
| 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, |
| + return mac.ProbeHost{Exec: execTool, Tools: h.tools, Paths: h.paths, Scratch: filepath.Join(h.scratch, "probes"), UID: os.Getuid(), Version: version, |
| Gate: func(sandboxed bool) *mac.Gate { |
| if sandboxed { |
| return gate(h.tools.SRT, wire.SandboxSeatbelt) |
diff --git a/internal/runner/thin/mac_test.go b/internal/runner/thin/mac_test.go| index 601a1652..ec3f579e 100644 |
| --- a/internal/runner/thin/mac_test.go |
| +++ b/internal/runner/thin/mac_test.go |
| @@ -15,6 +15,7 @@ import ( |
| "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" |
| ) |
| @@ -212,3 +213,38 @@ func TestMacUpdater(t *testing.T) { |
| t.Fatalf("left %v", left) |
| } |
| } |
| + |
| +// The Mac host keeps every tree the checks profile must let a gate |
| +// write (attempt trees, the probes' fixture copies) under the scratch |
| +// root, outside the state dir the profile denies. |
| +func TestMacHostPaths(t *testing.T) { |
| + root := t.TempDir() |
| + c := runner.Config{StateDir: filepath.Join(root, "share/state"), ScratchRoot: filepath.Join(root, "share/scratch"), WorkspaceRoot: filepath.Join(root, "share/work"), Executable: filepath.Join(root, "lib/equipo-runner")} |
| + srt := filepath.Join(root, "srt") |
| + if err := os.WriteFile(srt, []byte("#!/bin/sh\n"), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + h, err := newMacHost(c, Options{Version: "v1", AccountsRoot: filepath.Join(root, "accounts")}, func(k string) string { |
| + if k == "EQUIPO_SRT_PATH" { |
| + return srt |
| + } |
| + return "" |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if p := h.probeHost("v1", nil); p.Scratch != filepath.Join(c.ScratchRoot, "probes") || p.Paths.StateDir != c.StateDir || p.Paths.InstallDir != filepath.Join(root, "lib") { |
| + t.Fatalf("%+v", p) |
| + } |
| + settings := h.checks.sandboxed.Settings |
| + if settings == nil || h.checks.bare.Settings != nil || h.checks.sandboxed.Sandbox != wire.SandboxSeatbelt || h.checks.unproven.Sandbox != wire.SandboxNone { |
| + t.Fatal("gates") |
| + } |
| + key := filepath.Join(c.ScratchRoot, "worker-steps", "k") |
| + if _, err := settings(filepath.Join(key, "tree"), filepath.Join(key, "attempt-1")); err != nil { |
| + t.Fatalf("a worker tree refused: %v", err) |
| + } |
| + if _, err := settings(filepath.Join(c.StateDir, "worker", "steps", "k", "tree"), filepath.Join(key, "attempt-1")); err == nil { |
| + t.Fatal("a tree in the state dir accepted") |
| + } |
| +} |