oficina / equipo Public

Mac slice F task 16: the fake Mac worker makes changes (M9a, M9f)

The test build's fake Mac worker now takes Engineering as a Mac does:
the darwin launch of a pinned stand-in for Claude Code (a script that
runs the fake CLI, provisioned and pinned to its own digest with
mac.PinnedForTest, test build only), package mac's turns and
process-group executor without a sandbox, the Mac's credential
operations with no Keychain, its own Claude token connection, and the
pinned gitleaks of its tools. Its fixture report has P1 to P7, F1 to F7
at their success verdicts and Engineering ready.

Headless: the worker has its own config dir, bindings and accounts
root, the primary has forge credentials for the Woodstar repositories,
and TestMacWorker gains M9a (Engineering on the worker through
publication, change files and diffs, checks on the worker, review on
the primary, Ready to merge asks) and M9f in M0 (switch off: nothing
reaches the worker).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev bae4df76444b04fef9ec6217f89c7da7749e57fe parent 21b3f92
7 files changed, +284 −13
  • internal/headless/env_test.go +15 −2
  • internal/headless/mac_test.go +138 −4
  • internal/runner/thin/fakeworker.go +7 −1
  • internal/runner/thin/fakeworker_testbuild.go +112 −4
  • internal/runner/thin/preview_security.go +6 −0
  • internal/runner/thin/run.go +5 −1
  • internal/runner/thin/worker_conns_test.go +1 −1
diff --git a/internal/headless/env_test.go b/internal/headless/env_test.go
index dde6a0ce..ffa7d942 100644
--- a/internal/headless/env_test.go
+++ b/internal/headless/env_test.go
@@ -25,6 +25,7 @@ import (
"amadan.net/oficina/equipo/internal/fakecodex"
"amadan.net/oficina/equipo/internal/runner"
"amadan.net/oficina/equipo/internal/runner/containment"
+ "amadan.net/oficina/equipo/internal/runner/provider"
"amadan.net/oficina/equipo/internal/runner/thin"
"amadan.net/oficina/equipo/internal/runnerproto"
"amadan.net/oficina/equipo/internal/testci"
@@ -32,6 +33,7 @@ import (
"amadan.net/oficina/equipo/internal/toolproxy"
"amadan.net/oficina/equipo/internal/wire"
"amadan.net/rastrillo/rastrillo/budget"
+ gitleakscmd "github.com/zricethezav/gitleaks/v8/cmd"
_ "modernc.org/sqlite"
)
@@ -47,11 +49,22 @@ func TestMain(m *testing.M) {
os.Exit(fakecodex.Main(os.Args[1:], os.Stdin, os.Stdout, os.Stderr))
case "codex-code-mode-host":
os.Exit(0)
+ case "scanner", "gitleaks":
+ // The fake Mac worker's pinned gitleaks (the scan before anything
+ // of a candidate made on the Mac leaves it).
+ gitleakscmd.Execute()
+ return
case "equipo-tool-proxy":
- if len(os.Args) != 3 || os.Args[1] != "--socket" {
+ args := os.Args
+ if len(args) == 4 && args[1] == provider.DarwinToolProxyCommand {
+ // The darwin MCP config's command line (the fake Mac worker's
+ // Engineering): equipo-runner tool-proxy --socket <path>.
+ args = append(args[:1:1], args[2:]...)
+ }
+ if len(args) != 3 || args[1] != "--socket" {
os.Exit(2)
}
- if toolproxy.Serve(context.Background(), os.Stdin, os.Stdout, os.Args[2]) != nil {
+ if toolproxy.Serve(context.Background(), os.Stdin, os.Stdout, args[2]) != nil {
os.Exit(1)
}
os.Exit(0)
diff --git a/internal/headless/mac_test.go b/internal/headless/mac_test.go
index 5f9515df..d7952500 100644
--- a/internal/headless/mac_test.go
+++ b/internal/headless/mac_test.go
@@ -4,8 +4,11 @@ package headless
import (
"context"
+ "encoding/json"
"io"
"log/slog"
+ "net/http"
+ "net/url"
"os"
"path/filepath"
"strings"
@@ -74,23 +77,78 @@ func seedIOS(t *testing.T, root string, f *localForge, repo string, gate map[str
// PATH, run as a process so it can be killed. It plays a Mac whose
// probe P2 denied (checks labelled seatbelt). Worker checks are diagnostic
// until they certify immutable base gates, so the person chooses Merge.
+//
+// Since slice F it is also a Mac that makes changes: its home is root
+// (the runner user's, 0700), with its own config dir, bindings and
+// accounts root, which its home guard checks; the pinned gitleaks sits
+// beside its gate's tools; it holds one Claude token connection of its
+// own (macClaude), which only it can use.
func macWorker(t *testing.T, inst *thintest.Instance, primary *localRunner) (*localRunner, string) {
t.Helper()
root := private(t, filepath.Join(primary.root, "mac"))
bin := private(t, filepath.Join(root, "bin"))
copyExecutable(t, filepath.Join(bin, "xcodebuild"))
+ copyExecutable(t, filepath.Join(bin, "gitleaks"))
state := private(t, filepath.Join(root, "state"))
cred := inst.EnrolRunner(t)
if err := thintest.WriteRunnerCredential(state, cred); err != nil {
t.Fatal(err)
}
+ config := private(t, filepath.Join(root, "config"))
cfg := primary.cfg
cfg.StateDir, cfg.WorkspaceRoot, cfg.ScratchRoot, cfg.MachineLabel = state, filepath.Join(root, "work"), filepath.Join(root, "scratch"), "Tito Studio"
- w := &localRunner{inst: inst, root: root, cfg: cfg, subprocess: true, runnerID: cred.RunnerID, opts: thin.Options{Version: "test", Logger: slog.New(slog.NewTextHandler(io.Discard, nil)), FakePlatform: "darwin/arm64", FakeBin: bin, FakeSandbox: wire.SandboxSeatbelt, Claude: primary.opts.Claude}}
- t.Cleanup(func() { w.stop(t) })
+ cfg.AccountBindingsPath = filepath.Join(config, "bindings.json")
+ writeJSON(t, cfg.AccountBindingsPath, []map[string]any{})
+ w := &localRunner{inst: inst, root: root, cfg: cfg, subprocess: true, runnerID: cred.RunnerID, opts: thin.Options{Version: "test", Logger: slog.New(slog.NewTextHandler(io.Discard, nil)), FakePlatform: "darwin/arm64", FakeBin: bin, FakeSandbox: wire.SandboxSeatbelt, Claude: primary.opts.Claude, AccountsRoot: private(t, filepath.Join(root, "accounts"))}}
+ w.addToken(t, macClaude, "mac@example.com")
+ t.Cleanup(func() {
+ w.stop(t)
+ if t.Failed() {
+ // The worker process's own log (warnings: why a step stopped).
+ if raw, err := os.ReadFile(filepath.Join(root, "runner.log")); err == nil {
+ t.Logf("worker log:\n%s", raw[max(0, len(raw)-8000):])
+ }
+ }
+ })
return w, filepath.Join(bin, "xcodebuild")
}
+// macClaude is the fake Mac's own Claude token connection.
+const macClaude = "mac-claude"
+
+// macDispatches counts the Engineering dispatches the instance queued
+// for runner, acked or not.
+func macDispatches(t *testing.T, inst *thintest.Instance, runner string) int {
+ t.Helper()
+ var n int
+ if err := inst.DB.Writer().QueryRow("SELECT count(*) FROM runner_commands WHERE runner_id = ? AND kind = ? AND instr(body, ?) > 0", runner, wire.FrameDispatch, `"specialist":"engineering"`).Scan(&n); err != nil {
+ t.Fatal(err)
+ }
+ return n
+}
+
+// changeDiff is the person API's patch of one changed file of a task's
+// candidate.
+func (s *session) changeDiff(t *testing.T, id, sha, path string) wire.ChangeDiff {
+ t.Helper()
+ c := s.env.Client
+ req, err := http.NewRequestWithContext(s.ctx, http.MethodGet, c.Origin+"/api/v1/tasks/"+id+"/changes/diff?candidate_sha="+sha+"&path="+url.QueryEscape(path), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ req.Header.Set("Authorization", "Bearer "+c.Token)
+ resp, err := c.HTTP.Do(req)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ var out wire.ChangeDiff
+ if resp.StatusCode != http.StatusOK || json.NewDecoder(resp.Body).Decode(&out) != nil {
+ t.Fatalf("change diff of %s: %s", path, resp.Status)
+ }
+ return out
+}
+
func stepOf(k wire.Task, specialist string, n int) wire.Step {
for _, s := range k.Steps {
if s.Specialist == specialist {
@@ -160,6 +218,14 @@ func (s *session) mergeWorkerPass(t *testing.T, id string, timeout time.Duration
func TestMacWorker(t *testing.T) {
env, inst, primary := localEnv(t)
addWoodstar(t, primary.root, primary.opts.Forge.(*localForge))
+ // The primary's forge credentials name the Woodstar repositories, as
+ // a real primary's do: a publication's file list is screened against
+ // them before it leaves (without them it is withheld).
+ creds := map[string]any{"agent": "equipo-test", "repositories": map[string]any{woodstar: map[string]string{"api": "amk_test_woodstar", "git": "git_test_woodstar"}, panes: map[string]string{"api": "amk_test_panes", "git": "git_test_panes"}}}
+ writeJSON(t, primary.cfg.AmadanCredentialPath, creds)
+ if err := os.Chmod(primary.cfg.AmadanCredentialPath, 0600); err != nil {
+ t.Fatal(err)
+ }
primary.start(t)
worker, xcodebuild := macWorker(t, inst, primary)
worker.start(t)
@@ -175,8 +241,9 @@ func TestMacWorker(t *testing.T) {
})
// Mac work: Panes' gate runs xcodebuild, so its Engineering never runs
- // on the Linux primary, and the Mac worker takes only checks: it
- // waits, saying why, under Needs you.
+ // on the Linux primary, and with EQUIPO_MAC_ENGINEERING unset (M9f)
+ // the Mac worker takes only checks: it waits, saying why, under Needs
+ // you.
t.Run("M0", func(t *testing.T) {
sent := s.send(t, "tool:record_task:woodstar/panes|Pane titles|Say what each pane is for.\ntool:start_task:$task|edit:Woodstar/About.swift|An iOS reading app|An iOS reading app with titled panes")
id := s.taskOf(t, sent.Turn.ID)
@@ -185,6 +252,11 @@ func TestMacWorker(t *testing.T) {
if k.NeedsYou != wire.NeedsMacEngineering || eng.State != wire.StepQueued || eng.Placement != wire.PlacementMacEngineering || eng.RunnerID != "" {
t.Fatalf("Mac engineering %+v / %+v", k, eng)
}
+ // M9f: the switch is off, so nothing reaches the worker, though
+ // it could take it (its report says ready, claude).
+ if n := macDispatches(t, inst, worker.runnerID); n != 0 {
+ t.Fatalf("switch off: %d Engineering dispatches queued for the worker", n)
+ }
if _, err := env.Client.CancelTask(s.ctx, id); err != nil {
t.Fatal(err)
}
@@ -326,4 +398,66 @@ func TestMacWorker(t *testing.T) {
t.Fatalf("checks after Retry %+v", c)
}
})
+
+ // Mac Engineering (slice F): EQUIPO_MAC_ENGINEERING is set from here.
+ inst.Store.Chat().SetMacEngineering(true)
+
+ // M9a: Panes is Woodstar-shaped (an .xcodeproj with a shared scheme,
+ // a gate that runs xcodebuild), so its Engineering is Mac work. The
+ // primary prepares the base, the attempt goes to the worker with the
+ // inbound pack, the fake CLI edits a Swift file there (darwin launch,
+ // the pinned stand-in, the worker's own Claude connection), and the
+ // worker scans, commits and uploads a thin pack the primary pushes.
+ // The change's files and diffs show, checks run on the worker, review
+ // on the primary, and Ready to merge asks: a Mac-made candidate is
+ // never merged by policy.
+ t.Run("M9a", func(t *testing.T) {
+ sent := s.send(t, "tool:record_task:woodstar/panes|Edge swipe on the Mac|Swipe back from the edge feels late.\ntool:start_task:$task|edit:Woodstar/Swipe.swift|edgeSwipe = false|edgeSwipe = true")
+ id := s.taskOf(t, sent.Turn.ID)
+ s.wait(t, "Engineering placed on the worker", 2*time.Minute, func(c *thintest.Conversation) bool {
+ e := stepOf(c.Tasks[id], wire.SpecialistEngineering, 0)
+ return e.RunnerID == worker.runnerID || e.State == wire.StepFailed
+ })
+ k, err := env.Client.Task(s.ctx, id)
+ if err != nil {
+ t.Fatal(err)
+ }
+ eng := stepOf(k, wire.SpecialistEngineering, 0)
+ if eng.RunnerID != worker.runnerID || eng.RunnerLabel != "Tito Studio" {
+ t.Fatalf("Engineering not on the worker: %+v", eng)
+ }
+ s.wait(t, "the worker's candidate published", 3*time.Minute, func(c *thintest.Conversation) bool {
+ e := stepOf(c.Tasks[id], wire.SpecialistEngineering, 0)
+ return e.Pushed || e.State == wire.StepFailed
+ })
+ if k, err = env.Client.Task(s.ctx, id); err != nil {
+ t.Fatal(err)
+ }
+ eng = stepOf(k, wire.SpecialistEngineering, 0)
+ if eng.State != wire.StepDone || !eng.Pushed || eng.Account != macClaude || eng.TerminationKind != wire.TerminationProcessGroup || !eng.Terminated || eng.XcodeAccess != wire.XcodeAccessSandboxed || k.EngineeringRunner != worker.runnerID {
+ t.Fatalf("Engineering on the worker %+v (task runner %q)", eng, k.EngineeringRunner)
+ }
+ if f := eng.ChangeFiles; f == nil || f.SHA != eng.CandidateSHA || len(f.Entries) != 1 || f.Entries[0].Path != "Woodstar/Swipe.swift" {
+ t.Fatalf("change files %+v", eng.ChangeFiles)
+ }
+ if d := s.changeDiff(t, id, eng.CandidateSHA, "Woodstar/Swipe.swift"); !strings.Contains(d.Patch, "+let edgeSwipe = true") {
+ t.Fatalf("diff %+v", d)
+ }
+ // The primary pushed exactly the worker's commit, made as Equipo.
+ bare := env.ForgePath(panes)
+ if head := forgeHead(t, bare, k.Branch); head != eng.CandidateSHA {
+ t.Fatalf("branch %s at %s, want %s", k.Branch, head, eng.CandidateSHA)
+ }
+ if who := forgeShow(t, bare, "-s", "--format=%an <%ae>", eng.CandidateSHA); !strings.Contains(who, "Equipo") {
+ t.Fatalf("candidate author %q", who)
+ }
+ k = s.mergeWorkerPass(t, id, 4*time.Minute)
+ checks, review := stepOf(k, wire.SpecialistChecks, 0), stepOf(k, wire.SpecialistReview, 0)
+ if checks.RunnerID != worker.runnerID || checks.Checks != wire.ChecksPassed || checks.CandidateSHA != eng.CandidateSHA || review.RunnerID == worker.runnerID || review.Verdict != wire.VerdictApprove {
+ t.Fatalf("checks %+v review %+v", checks, review)
+ }
+ if k.Merged == nil || k.Merged.WithoutChecks {
+ t.Fatalf("merge %+v", k)
+ }
+ })
}
diff --git a/internal/runner/thin/fakeworker.go b/internal/runner/thin/fakeworker.go
index 78198300..cdb17519 100644
--- a/internal/runner/thin/fakeworker.go
+++ b/internal/runner/thin/fakeworker.go
@@ -3,6 +3,7 @@ package thin
import (
"context"
+ "amadan.net/oficina/equipo/internal/runner"
"amadan.net/oficina/equipo/internal/wire"
)
@@ -11,8 +12,13 @@ import (
type fakeMac interface {
marker() string
platform(spec string) (wire.Platform, bool)
- capabilities(context.Context) wire.Capabilities
+ // probe is the fixture capability report, for a Mac whose checks
+ // sandbox is sandbox (seatbelt: probe P2 denied).
+ probe(sandbox string) func(context.Context) wire.Capabilities
gate(bin, sandbox string) GateRunner
+ // engineering is the fake Mac's credential operations and its
+ // Engineering pieces (Mac runners slice F, task 16).
+ engineering(ctx context.Context, c *runner.Config, o Options) (*macCreds, *WorkerEngineering, error)
}
var fake fakeMac
diff --git a/internal/runner/thin/fakeworker_testbuild.go b/internal/runner/thin/fakeworker_testbuild.go
index 19de0aec..28c4c177 100644
--- a/internal/runner/thin/fakeworker_testbuild.go
+++ b/internal/runner/thin/fakeworker_testbuild.go
@@ -4,9 +4,18 @@ package thin
import (
"context"
+ "crypto/sha256"
+ "encoding/hex"
+ "errors"
+ "io"
+ "os"
+ "os/exec"
+ "path/filepath"
"strings"
+ "amadan.net/oficina/equipo/internal/runner"
"amadan.net/oficina/equipo/internal/runner/mac"
+ "amadan.net/oficina/equipo/internal/runner/mac/creds"
"amadan.net/oficina/equipo/internal/wire"
)
@@ -20,6 +29,14 @@ const fakeWorkerMarker = "equipo-fake-worker-unsandboxed-process-group"
// 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.
+//
+// Since slice F (task 16) it also makes changes, as a Mac does: Engineering
+// through the darwin launch of a pinned stand-in for Claude Code (a
+// script that runs the fake CLI, pinned by its own digest: the release
+// pin is the official binary's, which no fake can match), package mac's
+// turns and process-group executor without a sandbox, the Mac's
+// credential operations with no Keychain, its own Claude connections,
+// and the pinned gitleaks of its tools before anything leaves.
func init() {
fake = &fakeWorker{}
}
@@ -36,10 +53,30 @@ func (fakeWorker) platform(spec string) (wire.Platform, bool) {
return wire.Platform{OS: osName, Arch: arch}, true
}
-// capabilities is the fixture report of a Mac with Xcode and one iPhone
-// simulator.
-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}}
+// fakeProbeDetail is the detail of every probe the fixture reports.
+const fakeProbeDetail = "synthetic"
+
+// probe is the fixture report of a Mac with Xcode and one iPhone
+// simulator, whose probes all came out as a Mac that can make changes
+// reports them (task 14's "ready" fixture): P1 to P7, P2 denied when its
+// checks are seatbelt, F1 to F7 at their success verdicts (F5 skipped
+// while P2 is not denied), and its Engineering status ready.
+func (fakeWorker) probe(sandbox string) func(context.Context) wire.Capabilities {
+ return func(context.Context) wire.Capabilities {
+ p2, f5, f5Detail := wire.ProbeFailed, wire.ProbeSkipped, "P2 is not denied, so Xcode runs only in checks"
+ if sandbox == wire.SandboxSeatbelt {
+ p2, f5, f5Detail = wire.ProbeDenied, wire.ProbeDenied, fakeProbeDetail
+ }
+ probes := []wire.Probe{{ID: "P1", Verdict: wire.ProbePassed, Detail: "Xcode 16.2 (16C5032a); 1 iOS simulators; Tito Studio"}, {ID: "P2", Verdict: p2, Detail: fakeProbeDetail}, {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}}
+ for _, id := range wire.EngineeringProbeIDs {
+ p := wire.Probe{ID: id, Verdict: wire.EngineeringProbeSuccess(id), Detail: fakeProbeDetail}
+ if id == "F5" {
+ p.Verdict, p.Detail = f5, f5Detail
+ }
+ probes = append(probes, p)
+ }
+ 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}, Probes: probes, Engineering: &wire.EngineeringStatus{State: wire.EngineeringReady}}
+ }
}
// gate runs checks in a process group with an environment from scratch:
@@ -53,3 +90,74 @@ func (fakeWorker) gate(bin, sandbox 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: label}}
}
+
+// fakeCLIScript is the pinned stand-in for Claude Code: it runs the fake
+// CLI (the test binary started as claude, at %s) with the launch's argv.
+// Its digest is the pin, so every launch hashes it exactly as a Mac
+// hashes the official binary (ClaudeCLI.Launch).
+const fakeCLIScript = "#!/bin/sh\nexec '%s' \"$@\"\n"
+
+// fakeUserTemp is the Mac-shaped DARWIN_USER_TEMP_DIR the fake names in
+// a sandboxed Xcode policy (its writes). It is a policy literal only:
+// nothing is made there, and the fake's executor cleans no T (a Mac's
+// XcodeExec does).
+const fakeUserTemp = mac.UserTempPrefix + "/eq/fake-worker/T"
+
+// engineering is the fake Mac's credential operations and Engineering
+// pieces. Its home is the directory above its state dir (the runner
+// user's home on a Mac); the stand-in is provisioned into the install
+// dir there and pinned (mac.PinnedForTest: test build only); this
+// process launches as a Mac does; it lists no Keychain (Linux has none)
+// and its home guard reads plain modes. It needs its own accounts root
+// and bindings, never a person's real ones, and the fake CLI at
+// c.ClaudePath, which a Mac has no use for afterwards (cleared).
+func (fakeWorker) engineering(ctx context.Context, c *runner.Config, o Options) (*macCreds, *WorkerEngineering, error) {
+ cli := c.ClaudePath
+ if o.AccountsRoot == "" || c.AccountBindingsPath == "" || !filepath.IsAbs(cli) || strings.ContainsAny(cli, "'\n") {
+ return nil, nil, errors.New("the fake Mac worker needs its own accounts root and bindings, and the fake CLI")
+ }
+ c.ClaudePath = ""
+ darwinLaunch = true
+ home := filepath.Dir(c.StateDir)
+ install := filepath.Join(home, "lib")
+ if err := os.MkdirAll(install, 0o700); err != nil {
+ return nil, nil, err
+ }
+ script := strings.Replace(fakeCLIScript, "%s", cli, 1)
+ sum := sha256.Sum256([]byte(script))
+ pinned := mac.PinnedForTest(mac.NewClaudeCLI(home, install), hex.EncodeToString(sum[:]))
+ if err := pinned.Provision(ctx, func(context.Context, string) (io.ReadCloser, error) {
+ return io.NopCloser(strings.NewReader(script)), nil
+ }); err != nil {
+ return nil, nil, err
+ }
+ out, err := exec.Command("/usr/bin/id", "-un").Output()
+ if err != nil {
+ return nil, nil, err
+ }
+ user := strings.TrimSpace(string(out))
+ turns := mac.NewTurns(filepath.Join(c.StateDir, "mac-gate.lock"))
+ m := &macCreds{turns: turns, exec: &mac.Executor{Turns: turns}, cli: pinned,
+ paths: mac.Paths{Home: home, StateDir: c.StateDir, AccountsRoot: o.AccountsRoot, SessionRoot: SessionRoot(*c), InstallDir: install, UserTemp: fakeUserTemp},
+ configDir: macConfigDir(*c, home), runner: firstNonEmpty(c.ToolProxyPath, c.Executable), scratch: c.ScratchRoot, taint: loadTaint(filepath.Join(c.StateDir, "tainted")),
+ boot: creds.BootTime, user: user, uid: os.Getuid(), log: o.Logger}
+ m.fact = func(p string) (creds.Fact, error) { return creds.Read(p, nil) }
+ m.keychain = &creds.Keychain{Dir: filepath.Join(c.StateDir, "keychain"), Login: filepath.Join(home, "Library", "Keychains", "login.keychain-db"), User: user,
+ List: func(context.Context, string) ([]creds.Item, error) { return nil, nil },
+ Delete: func(context.Context, creds.Item) error { return errKeychain }}
+ // The pinned gitleaks beside the fake's tools, pinned to what is
+ // there at start (a Mac's is pinned at build time).
+ scanner, pin := filepath.Join(o.FakeBin, "gitleaks"), ""
+ if raw, err := os.ReadFile(scanner); err == nil {
+ s := sha256.Sum256(raw)
+ pin = hex.EncodeToString(s[:])
+ }
+ scan := &Engineer{O: ClaudeOptions{Runner: *c}}
+ eng := &WorkerEngineering{
+ // Sandboxed Xcode access as a Mac whose P2 and F5 are denied.
+ Xcode: func() bool { return o.FakeSandbox == wire.SandboxSeatbelt && !m.taint.Tainted() },
+ Leaks: func(ctx context.Context, dir, _ string, _ func(string) error) (bool, error) {
+ return scan.gitleaksAt(ctx, scanner, pin, dir, workerSecretRules())
+ }}
+ return m, eng, nil
+}
diff --git a/internal/runner/thin/preview_security.go b/internal/runner/thin/preview_security.go
index ab289f5e..89735a5d 100644
--- a/internal/runner/thin/preview_security.go
+++ b/internal/runner/thin/preview_security.go
@@ -96,6 +96,12 @@ func (e *Engineer) gitleaks(ctx context.Context, stage string) (bool, error) {
// gitleaksWith is gitleaks with the trusted rules given.
func (e *Engineer) gitleaksWith(ctx context.Context, stage, rules string) (bool, error) {
binary, pin := previewScannerTool(e.O.Runner)
+ return e.gitleaksAt(ctx, binary, pin, stage, rules)
+}
+
+// gitleaksAt is gitleaksWith with the scanner binary and its pin given
+// (the test build's fake Mac worker names its own).
+func (e *Engineer) gitleaksAt(ctx context.Context, binary, pin, stage, rules string) (bool, error) {
if !release.VerifyGitleaks(binary, pin) {
return false, errScanner
}
diff --git a/internal/runner/thin/run.go b/internal/runner/thin/run.go
index 0f8d4daf..de78d17b 100644
--- a/internal/runner/thin/run.go
+++ b/internal/runner/thin/run.go
@@ -154,7 +154,11 @@ 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, workerSetup{probe: fake.capabilities, gate: fake.gate(o.FakeBin, o.FakeSandbox)})
+ m, eng, err := fake.engineering(ctx, &c, o)
+ if err != nil {
+ return err
+ }
+ return runWorker(ctx, c, o, platform, workerSetup{probe: fake.probe(o.FakeSandbox), gate: fake.gate(o.FakeBin, o.FakeSandbox), creds: m, engineering: eng})
}
if runtime.GOOS == "darwin" {
return runMac(ctx, c, o)
diff --git a/internal/runner/thin/worker_conns_test.go b/internal/runner/thin/worker_conns_test.go
index 3f3d7d2b..91c014d8 100644
--- a/internal/runner/thin/worker_conns_test.go
+++ b/internal/runner/thin/worker_conns_test.go
@@ -187,7 +187,7 @@ func (r *darwinRig) runWorker(inst *workerInstance, protocol int) (stop func())
ctx, cancel := context.WithCancel(r.ctx)
done := make(chan error, 1)
go func() {
- done <- runWorker(ctx, c, r.workerOptions(protocol), wire.Platform{OS: "darwin", Arch: "arm64"}, workerSetup{probe: fake.capabilities, gate: fake.gate("", ""), creds: r.m})
+ done <- runWorker(ctx, c, r.workerOptions(protocol), wire.Platform{OS: "darwin", Arch: "arm64"}, workerSetup{probe: fake.probe(""), gate: fake.gate("", ""), creds: r.m})
}()
return func() {
r.t.Helper()