Mac slice F task 8: darwin Engineering policy and settings
The darwin launch's own certified shape (claude.DarwinPolicy): the pinned CLI and its digest, argv, settings, MCP config, worktree, scratch, denied paths, environment and Xcode access. The launcher regenerates it from its inputs and refuses on any byte of difference (ValidateDarwin), then checks the filesystem and starts through ClaudeCLI.Launch (mac.LaunchEngineering). Settings per task 1 S2: every command sandboxed, no unsandboxed way out, allowedDomains empty with strictAllowlist, no sockets or local ports, Mach services only with sandboxed Xcode access. Denied both ways: the 4.2 list, the connection's homes, the runtime copies and the step socket's directory; writes also denied to the install dir and the pinned CLI's directory. The token goes only on descriptor 3. Variants: Engineering, the read-only ask and the token check. mac/profile.go shares Xcode's places and the Mach name rule with checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+2,617
−10
internal/runner/mac/engineering.go+219 −0internal/runner/mac/engineering_test.go+674 −0internal/runner/mac/profile.go+32 −10internal/runner/mac/testdata/engineering-2026-11-28-answer.json+336 −0internal/runner/mac/testdata/engineering-2026-11-28-check.json+322 −0internal/runner/mac/testdata/engineering-2026-11-28-implement-xcode.json+350 −0internal/runner/mac/testdata/engineering-2026-11-28-implement.json+340 −0internal/runner/provider/claude/darwin.go+344 −0
diff --git a/internal/runner/mac/engineering.go b/internal/runner/mac/engineering.go| new file mode 100644 |
| index 00000000..80048061 |
| --- /dev/null |
| +++ b/internal/runner/mac/engineering.go |
| @@ -0,0 +1,219 @@ |
| +package mac |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "errors" |
| + "io/fs" |
| + "os" |
| + "path/filepath" |
| + "slices" |
| + "sort" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runner/provider/claude" |
| +) |
| + |
| +// Engineering on a Mac (spec §4.4, §8.2; slice F task 8): the pinned |
| +// CLI, unsandboxed as the runner user, with its Bash commands in |
| +// Seatbelt under the per-attempt settings claude.DarwinPolicy makes. |
| +// This file turns the runner's places into that policy's inputs and is |
| +// the one way to start the CLI with it: regenerate, compare byte for |
| +// byte, check the filesystem, then ClaudeCLI.Launch. |
| + |
| +// EngineeringInput is one Mac launch of the CLI: Engineering, an ask or |
| +// a token check. |
| +type EngineeringInput struct { |
| + // Paths are the §4.2 places (DenyList) and, for sandboxed Xcode |
| + // access, the user's T (UserTemp). |
| + Paths |
| + // Action is claude.DarwinImplement, DarwinAnswer or DarwinCheck. |
| + Action, Model string |
| + // Worktree is the task tree at its real path (the workspace root of |
| + // the permission port), Scratch the attempt's scratch (TMPDIR). |
| + Worktree, Scratch string |
| + // Runner is the runner binary (cfg.Executable), serving MCP in its |
| + // tool-proxy mode on Socket, which lies in ToolRoot (thin's toolRoot, |
| + // <scratch root>/t). |
| + Runner, ToolRoot, Socket string |
| + // ConfigDir is the connection's runtime copy (CLAUDE_CONFIG_DIR), |
| + // inside RuntimeRoot (<scratch root>/homes); CredentialHome is its |
| + // dedicated home. |
| + ConfigDir, CredentialHome, RuntimeRoot string |
| + // XcodeAccess is "" or wire.XcodeAccessSandboxed. Mach is the |
| + // P2-recorded service list (CheckMachServices narrowed by P2); it is |
| + // used only with sandboxed access. |
| + XcodeAccess string |
| + Mach []string |
| + // DeveloperDir is xcode-select -p ("" for none). Attempt is the |
| + // attempt's marker. SessionID starts the session, or resumes it. |
| + DeveloperDir, Attempt, SessionID string |
| + Resume bool |
| +} |
| + |
| +// EngineeringCommand is exactly what to start: Argv (the verified CLI's |
| +// path first), the whole environment Env (nothing inherited), in Dir. |
| +// Files[i] becomes descriptor 3+i in the child (exec.Cmd.ExtraFiles); |
| +// Files[0] is the read end of a pipe holding the token. |
| +type EngineeringCommand struct { |
| + Argv, Env []string |
| + Dir string |
| + Files []*os.File |
| +} |
| + |
| +// EngineeringStart starts c and returns once the process exists (task |
| +// 9's executor: its process group, marker and record). It is called |
| +// while ClaudeCLI.Launch holds the hashed CLI open. |
| +type EngineeringStart func(ctx context.Context, c EngineeringCommand) error |
| + |
| +// MaxToken bounds the token written to the descriptor: far above a |
| +// setup token, far below a pipe's buffer, so the write never blocks. |
| +const MaxToken = 4096 |
| + |
| +// darwinInputs fills claude.DarwinInputs from in and the pinned CLI. |
| +func (c ClaudeCLI) darwinInputs(in EngineeringInput) (claude.DarwinInputs, error) { |
| + if c.installDir == "" || c.pin == "" || c.installDir != in.InstallDir { |
| + return claude.DarwinInputs{}, provider.ErrPolicy |
| + } |
| + d := claude.DarwinInputs{Action: in.Action, Model: in.Model, |
| + CLI: ClaudePath(c.installDir), CLIDigest: c.pin, CLIDir: ClaudeDir(c.installDir), InstallDir: in.InstallDir, |
| + Runner: in.Runner, ToolRoot: in.ToolRoot, Socket: in.Socket, |
| + Workspace: in.Worktree, Scratch: in.Scratch, Home: in.Home, |
| + ConfigDir: in.ConfigDir, CredentialHome: in.CredentialHome, RuntimeRoot: in.RuntimeRoot, |
| + Denied: DenyList(in.Paths), XcodeAccess: in.XcodeAccess, |
| + DeveloperDir: in.DeveloperDir, Attempt: in.Attempt, SessionID: in.SessionID, Resume: in.Resume} |
| + // Xcode's services and places only with sandboxed access (§8.2): the |
| + // caller's Mach list is not used otherwise. |
| + if in.XcodeAccess != "" { |
| + places, err := xcodePlaces(in.Paths) |
| + if err != nil || machNames(in.Mach) != nil { |
| + return claude.DarwinInputs{}, provider.ErrPolicy |
| + } |
| + d.XcodeWrites = append([]string{filepath.Join(in.Scratch, "DerivedData")}, places...) |
| + d.Mach = slices.Clone(in.Mach) |
| + } |
| + return d, nil |
| +} |
| + |
| +// EngineeringPolicy is the certified policy for in with the pinned CLI |
| +// cli: what a step records and what LaunchEngineering checks again. |
| +func EngineeringPolicy(cli ClaudeCLI, in EngineeringInput) (provider.Policy, error) { |
| + d, err := cli.darwinInputs(in) |
| + if err != nil { |
| + return provider.Policy{}, err |
| + } |
| + return claude.DarwinPolicy(d) |
| +} |
| + |
| +// ValidateEngineering regenerates the policy from cli and in and refuses |
| +// p on any difference (claude.ValidateDarwin). It reads no file: a seam |
| +// for a caller that checks a stored policy without launching. |
| +func ValidateEngineering(cli ClaudeCLI, in EngineeringInput, p provider.Policy) error { |
| + d, err := cli.darwinInputs(in) |
| + if err != nil { |
| + return err |
| + } |
| + return claude.ValidateDarwin(d, p) |
| +} |
| + |
| +// LaunchEngineering starts the pinned CLI under p, which must be exactly |
| +// the policy cli and in make. Then the filesystem must agree: the |
| +// worktree and scratch are real directories at their own real paths, |
| +// and the runtime copy is a real directory with no token file the CLI |
| +// would read on its own. The settings and MCP config are written into |
| +// the runtime copy (0600, renamed into place), the token into a pipe |
| +// whose read end is descriptor 3, and start runs the policy's argv and |
| +// environment, nothing else, through ClaudeCLI.Launch, which hashes the |
| +// CLI and checks it again immediately before start. Any refusal starts |
| +// nothing and names no token. |
| +func LaunchEngineering(ctx context.Context, cli ClaudeCLI, in EngineeringInput, p provider.Policy, token []byte, start EngineeringStart) error { |
| + if err := ValidateEngineering(cli, in, p); err != nil { |
| + return err |
| + } |
| + argv := claude.DarwinArgv(p) |
| + if len(argv) < 2 || len(token) == 0 || len(token) > MaxToken || bytes.ContainsAny(token, "\x00\r\n") { |
| + return provider.ErrPolicy |
| + } |
| + for _, dir := range []string{in.Worktree, in.Scratch} { |
| + if !realDir(dir) { |
| + return provider.ErrPolicy |
| + } |
| + } |
| + if info, err := os.Lstat(in.ConfigDir); err != nil || !info.IsDir() { |
| + return provider.ErrPolicy |
| + } |
| + // The CLI falls back to <config>/.oauth_token when no descriptor is |
| + // named (task 1, S4), and .oauth-token is a dedicated home's: the |
| + // runtime copy holds neither. |
| + for _, name := range []string{".oauth_token", ".oauth-token"} { |
| + if _, err := os.Lstat(filepath.Join(in.ConfigDir, name)); !errors.Is(err, fs.ErrNotExist) { |
| + return provider.ErrPolicy |
| + } |
| + } |
| + for name, body := range map[string][]byte{claude.DarwinSettingsFile: p.Settings, claude.DarwinMCPFile: p.MCP} { |
| + if err := placeFile(in.ConfigDir, name, body); err != nil { |
| + return provider.ErrPolicy |
| + } |
| + } |
| + env := make([]string, 0, len(p.Env)) |
| + for k, v := range p.Env { |
| + env = append(env, k+"="+v) |
| + } |
| + sort.Strings(env) |
| + read, write, err := os.Pipe() |
| + if err != nil { |
| + return err |
| + } |
| + defer read.Close() |
| + _, err = write.Write(token) |
| + if cerr := write.Close(); err == nil { |
| + err = cerr |
| + } |
| + if err != nil { |
| + return provider.ErrPolicy |
| + } |
| + return cli.Launch(ctx, func(ctx context.Context, verified []string) error { |
| + // The verified path is the policy's CLI, and nothing else moved. |
| + if !slices.Equal(verified, argv) { |
| + return provider.ErrPolicy |
| + } |
| + return start(ctx, EngineeringCommand{Argv: slices.Clone(argv), Env: env, Dir: in.Worktree, Files: []*os.File{read}}) |
| + }, argv[1:]...) |
| +} |
| + |
| +// realDir: a directory, at its own real path (no link anywhere in it). |
| +func realDir(dir string) bool { |
| + real, err := filepath.EvalSymlinks(dir) |
| + if err != nil || real != dir { |
| + return false |
| + } |
| + info, err := os.Lstat(dir) |
| + return err == nil && info.IsDir() |
| +} |
| + |
| +// placeFile writes body as dir/name, mode 0600: a new file renamed over |
| +// whatever was there, so a link at the name is replaced, never followed. |
| +func placeFile(dir, name string, body []byte) error { |
| + f, err := os.CreateTemp(dir, "."+name+"-*") |
| + if err != nil { |
| + return err |
| + } |
| + tmp := f.Name() |
| + _, err = f.Write(body) |
| + if e := f.Chmod(0600); err == nil { |
| + err = e |
| + } |
| + if e := f.Sync(); err == nil { |
| + err = e |
| + } |
| + if e := f.Close(); err == nil { |
| + err = e |
| + } |
| + if err == nil { |
| + err = os.Rename(tmp, filepath.Join(dir, name)) |
| + } |
| + if err != nil { |
| + os.Remove(tmp) |
| + } |
| + return err |
| +} |
diff --git a/internal/runner/mac/engineering_test.go b/internal/runner/mac/engineering_test.go| new file mode 100644 |
| index 00000000..8ac97a79 |
| --- /dev/null |
| +++ b/internal/runner/mac/engineering_test.go |
| @@ -0,0 +1,674 @@ |
| +package mac |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "crypto/sha256" |
| + "encoding/hex" |
| + "encoding/json" |
| + "errors" |
| + "io" |
| + "io/fs" |
| + "maps" |
| + "os" |
| + "path/filepath" |
| + "slices" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runner/provider/claude" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// The darwin Engineering launch's certified shape (task 8): the settings |
| +// the pinned CLI and its sandboxed Bash run under on a Mac, the argv, |
| +// the MCP config and the environment, checked byte for byte before |
| +// anything starts. The golden files are this code's output on fixed |
| +// inputs (testPaths, /Users/equipo-paul), reviewed by hand on |
| +// 2026-11-28 (docs-t1, linux/amd64); EQUIPO_UPDATE_GOLDEN=1 rewrites them. |
| + |
| +const goldenScratchRoot = "/Users/equipo-paul/.local/share/equipo-runner/scratch" |
| + |
| +func goldenCLI() ClaudeCLI { |
| + return NewClaudeCLI("/Users/equipo-paul", "/Users/equipo-paul/.local/lib/equipo-runner") |
| +} |
| + |
| +func goldenInput(action, xcode string) EngineeringInput { |
| + s := goldenScratchRoot |
| + return EngineeringInput{Paths: testPaths(), Action: action, Model: "claude-haiku-5-5", |
| + Worktree: s + "/worker-steps/k/tree", Scratch: s + "/policy-1", |
| + Runner: "/Users/equipo-paul/.local/lib/equipo-runner/equipo-runner", ToolRoot: s + "/t", Socket: s + "/t/1234567890/s", |
| + ConfigDir: s + "/homes/account-1", CredentialHome: "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", RuntimeRoot: s + "/homes", |
| + XcodeAccess: xcode, Mach: CheckMachServices, DeveloperDir: "/Applications/Xcode.app/Contents/Developer", |
| + Attempt: "attempt-7f3a", SessionID: "00000000-0000-4000-8000-000000000001"} |
| +} |
| + |
| +// darwinSettings is the part of the CLI's settings the tests read. |
| +type darwinSettings struct { |
| + DisableAllHooks, AutoMemoryEnabled, AutoDreamEnabled *bool |
| + EnabledPlugins map[string]bool |
| + Sandbox struct { |
| + Enabled, FailIfUnavailable, AllowUnsandboxedCommands, AutoAllowBashIfSandboxed *bool |
| + ExcludedCommands []string |
| + Filesystem struct{ AllowWrite, DenyRead, DenyWrite []string } |
| + Network struct { |
| + AllowedDomains, AllowUnixSockets, AllowMachLookup []string |
| + StrictAllowlist, AllowLocalBinding, AllowAllUnixSockets *bool |
| + } |
| + } |
| + Permissions struct{ Allow, Ask, Deny []string } |
| +} |
| + |
| +func settingsOf(t *testing.T, p provider.Policy) (darwinSettings, map[string]any) { |
| + t.Helper() |
| + var s darwinSettings |
| + var generic map[string]any |
| + if err := json.Unmarshal(p.Settings, &s); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := json.Unmarshal(p.Settings, &generic); err != nil { |
| + t.Fatal(err) |
| + } |
| + return s, generic |
| +} |
| + |
| +func is(b *bool, want bool) bool { return b != nil && *b == want } |
| + |
| +// TestEngineeringSettingsExact: the golden policy for Engineering with |
| +// and without sandboxed Xcode access, the read-only ask and the token |
| +// check; then what each part of it means, read back. |
| +func TestEngineeringSettingsExact(t *testing.T) { |
| + cases := []struct { |
| + name, action, xcode string |
| + tools []string |
| + native string |
| + }{ |
| + {"implement", claude.DarwinImplement, "", []string{"mcp__equipo__submit_candidate", "mcp__equipo__ask_person", "mcp__equipo__submit_render"}, "Bash,Read,Write,Edit,Glob,Grep"}, |
| + {"implement-xcode", claude.DarwinImplement, wire.XcodeAccessSandboxed, []string{"mcp__equipo__submit_candidate", "mcp__equipo__ask_person", "mcp__equipo__submit_render"}, "Bash,Read,Write,Edit,Glob,Grep"}, |
| + {"answer", claude.DarwinAnswer, "", []string{"mcp__equipo__git_log", "mcp__equipo__git_diff", "mcp__equipo__git_show"}, "Read,Glob,Grep"}, |
| + {"check", claude.DarwinCheck, "", []string{}, ""}, |
| + } |
| + for _, c := range cases { |
| + t.Run(c.name, func(t *testing.T) { |
| + in := goldenInput(c.action, c.xcode) |
| + p, err := EngineeringPolicy(goldenCLI(), in) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var pretty bytes.Buffer |
| + if err := json.Indent(&pretty, p.Manifest, "", " "); err != nil { |
| + t.Fatal(err) |
| + } |
| + pretty.WriteByte('\n') |
| + golden := filepath.Join("testdata", "engineering-2026-11-28-"+c.name+".json") |
| + if os.Getenv("EQUIPO_UPDATE_GOLDEN") == "1" { |
| + if err := os.WriteFile(golden, pretty.Bytes(), 0644); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + want, err := os.ReadFile(golden) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !bytes.Equal(pretty.Bytes(), want) { |
| + t.Fatalf("policy differs from %s:\n%s", golden, pretty.Bytes()) |
| + } |
| + if sum := sha256.Sum256(p.Manifest); p.Hash != hex.EncodeToString(sum[:]) || p.ManifestHash != p.Hash { |
| + t.Fatalf("hash %s / %s", p.Hash, p.ManifestHash) |
| + } |
| + |
| + s, generic := settingsOf(t, p) |
| + readOnly := c.action != claude.DarwinImplement |
| + // Hooks, plugins and memory off. |
| + if !is(s.DisableAllHooks, true) || !is(s.AutoMemoryEnabled, false) || !is(s.AutoDreamEnabled, false) || len(s.EnabledPlugins) != 2 || s.EnabledPlugins["agents-md@builtin"] || s.EnabledPlugins["plugin-authoring@builtin"] { |
| + t.Fatalf("hooks, plugins or memory: %s", p.Settings) |
| + } |
| + // Every command sandboxed, no way out, the sandbox required. |
| + sb := s.Sandbox |
| + if !is(sb.Enabled, true) || !is(sb.FailIfUnavailable, true) || !is(sb.AllowUnsandboxedCommands, false) || !is(sb.AutoAllowBashIfSandboxed, true) || sb.ExcludedCommands == nil || len(sb.ExcludedCommands) != 0 { |
| + t.Fatalf("sandbox: %s", p.Settings) |
| + } |
| + if _, ok := generic["sandbox"].(map[string]any)["enableWeakerNestedSandbox"]; ok { |
| + t.Fatalf("enableWeakerNestedSandbox is Linux only: %s", p.Settings) |
| + } |
| + // No network: an empty list, and strict, so a host is denied |
| + // without asking anyone; no sockets, no local ports. |
| + n := sb.Network |
| + if n.AllowedDomains == nil || len(n.AllowedDomains) != 0 || !is(n.StrictAllowlist, true) || n.AllowUnixSockets == nil || len(n.AllowUnixSockets) != 0 || !is(n.AllowLocalBinding, false) || !is(n.AllowAllUnixSockets, false) { |
| + t.Fatalf("network: %s", p.Settings) |
| + } |
| + // §4.2, both ways, plus the connection's homes and the step |
| + // socket's directory. |
| + fsys := sb.Filesystem |
| + denied := append(DenyList(in.Paths), in.CredentialHome, in.ConfigDir, in.RuntimeRoot, in.ToolRoot) |
| + for _, d := range denied { |
| + if !slices.Contains(fsys.DenyRead, d) || !slices.Contains(fsys.DenyWrite, d) { |
| + t.Fatalf("%s not denied both ways: %s", d, p.Settings) |
| + } |
| + } |
| + if len(fsys.DenyRead) != len(denied) { |
| + t.Fatalf("denyRead %v, want exactly %v", fsys.DenyRead, denied) |
| + } |
| + // The runner's install dir and the pinned CLI's own directory: |
| + // no sandboxed command may replace the binary the launcher |
| + // hashed (macOS execs it by path). |
| + for _, d := range []string{in.InstallDir, ClaudeDir(in.InstallDir)} { |
| + if !slices.Contains(fsys.DenyWrite, d) || slices.Contains(fsys.DenyRead, d) { |
| + t.Fatalf("%s: writes denied, reads allowed: %s", d, p.Settings) |
| + } |
| + } |
| + wantWrite := []string{in.Worktree, in.Scratch} |
| + if readOnly { |
| + wantWrite = []string{in.Scratch} |
| + if !slices.Contains(fsys.DenyWrite, in.Worktree) { |
| + t.Fatalf("a read-only launch may write the worktree: %s", p.Settings) |
| + } |
| + } else if slices.Contains(fsys.DenyWrite, in.Worktree) { |
| + t.Fatalf("Engineering cannot write its worktree: %s", p.Settings) |
| + } |
| + if c.xcode == wire.XcodeAccessSandboxed { |
| + wantWrite = append(wantWrite, in.Scratch+"/DerivedData", in.UserTemp, in.Home+"/Library/Developer/Xcode/DerivedData", in.Home+"/Library/Caches/org.swift.swiftpm", in.Home+"/Library/org.swift.swiftpm") |
| + } |
| + if !slices.Equal(fsys.AllowWrite, wantWrite) { |
| + t.Fatalf("allowWrite %v, want %v", fsys.AllowWrite, wantWrite) |
| + } |
| + // The CLI's own rules: the generated denies, the native tools |
| + // asked about on the worktree, the step's tools allowed, no |
| + // shell rule. |
| + rules, err := claude.NativeDenyRules(fsys.DenyRead) |
| + if err != nil || !slices.Equal(s.Permissions.Deny, rules) { |
| + t.Fatalf("deny rules %v", s.Permissions.Deny) |
| + } |
| + var ask []string |
| + for _, tool := range []string{"Read", "Write", "Edit", "Glob", "Grep"} { |
| + if strings.Contains(","+c.native+",", ","+tool+",") { |
| + ask = append(ask, tool+"(/"+in.Worktree+"/**)") |
| + } |
| + } |
| + if !slices.Equal(s.Permissions.Ask, ask) && !(len(ask) == 0 && len(s.Permissions.Ask) == 0) || !slices.Equal(s.Permissions.Allow, c.tools) && !(len(c.tools) == 0 && len(s.Permissions.Allow) == 0) { |
| + t.Fatalf("permissions ask %v allow %v", s.Permissions.Ask, s.Permissions.Allow) |
| + } |
| + // The argv: the pinned CLI, no settings or MCP but Equipo's, |
| + // manual permissions through the port, the role's tools. |
| + argv := claude.DarwinArgv(p) |
| + cfg := in.ConfigDir |
| + wantArgv := []string{ClaudePath(in.InstallDir), "-p", "--verbose", "--include-hook-events", "--input-format", "stream-json", "--output-format", "stream-json", "--model", in.Model, "--setting-sources", "", "--disable-slash-commands", "--strict-mcp-config", "--mcp-config", cfg + "/equipo-mcp.json", "--settings", cfg + "/equipo-settings.json", "--permission-mode", "manual", "--permission-prompt-tool", "mcp__equipo__permission", "--tools", c.native} |
| + if readOnly { |
| + wantArgv = append(wantArgv, "--include-partial-messages") |
| + } |
| + wantArgv = append(wantArgv, "--session-id", in.SessionID) |
| + if !slices.Equal(argv, wantArgv) { |
| + t.Fatalf("argv %q\nwant %q", argv, wantArgv) |
| + } |
| + mcp, _ := provider.DarwinToolMCP(in.Runner, in.Socket) |
| + if !bytes.Equal(p.MCP, mcp) { |
| + t.Fatalf("mcp %s", p.MCP) |
| + } |
| + // The permission port reads this policy: the worktree is its |
| + // root, and on Engineering a shell command is the sandbox's. |
| + if w, r := claude.Roots(p); w != in.Worktree || r != "" { |
| + t.Fatalf("roots %q %q", w, r) |
| + } |
| + bash := json.RawMessage(`{"tool_name":"Bash","input":{"command":"ls"}}`) |
| + var answer struct{ Behavior string } |
| + json.Unmarshal(claude.StepPermission(bash, p), &answer) |
| + if (answer.Behavior == "allow") != (c.action == claude.DarwinImplement) { |
| + t.Fatalf("Bash answered %q", answer.Behavior) |
| + } |
| + }) |
| + } |
| + // A fix round or an ask resumes its session; nothing else changes. |
| + in := goldenInput(claude.DarwinImplement, "") |
| + start, _ := EngineeringPolicy(goldenCLI(), in) |
| + in.Resume = true |
| + resume, err := EngineeringPolicy(goldenCLI(), in) |
| + a, b := claude.DarwinArgv(start), claude.DarwinArgv(resume) |
| + if err != nil || !slices.Equal(a[:len(a)-2], b[:len(b)-2]) || !slices.Equal(b[len(b)-2:], []string{"--resume", in.SessionID}) || !bytes.Equal(start.Settings, resume.Settings) { |
| + t.Fatalf("resume argv %q (%v)", b, err) |
| + } |
| +} |
| + |
| +// TestEngineeringSettingsRefuses: a policy that would not mean what it |
| +// says is never made. |
| +func TestEngineeringSettingsRefuses(t *testing.T) { |
| + if _, err := EngineeringPolicy(goldenCLI(), goldenInput(claude.DarwinImplement, wire.XcodeAccessSandboxed)); err != nil { |
| + t.Fatal(err) |
| + } |
| + s := goldenScratchRoot |
| + cases := map[string]func(*EngineeringInput, *ClaudeCLI){ |
| + "worktree in the state dir": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = in.StateDir + "/tree" }, |
| + "worktree in the accounts root": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = in.AccountsRoot + "/tree" }, |
| + "worktree in another home": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = "/Users/paul/tree" }, |
| + "worktree on a volume": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = "/Volumes/x/tree" }, |
| + "worktree in the install dir": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = in.InstallDir + "/tree" }, |
| + "worktree in the step socket dir": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = in.ToolRoot + "/tree" }, |
| + "worktree holding ~/.ssh": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = in.Home }, |
| + "worktree in an unknown /Users": func(in *EngineeringInput, _ *ClaudeCLI) { in.HomesUnknown = true }, |
| + "relative worktree": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = "tree" }, |
| + "relative scratch": func(in *EngineeringInput, _ *ClaudeCLI) { in.Scratch = "policy-1" }, |
| + "unclean worktree": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = s + "/x/../tree" }, |
| + "glob worktree": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = s + "/worker-steps/*" }, |
| + "glob other home": func(in *EngineeringInput, _ *ClaudeCLI) { in.OtherHomes = []string{"/Users/*"} }, |
| + "brace scratch": func(in *EngineeringInput, _ *ClaudeCLI) { in.Scratch = s + "/policy-{1,2}" }, |
| + "newline in a path": func(in *EngineeringInput, _ *ClaudeCLI) { in.Scratch = s + "/policy\n1" }, |
| + "root as worktree": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = "/" }, |
| + "scratch inside the worktree": func(in *EngineeringInput, _ *ClaudeCLI) { in.Scratch = in.Worktree + "/tmp" }, |
| + "worktree inside the scratch": func(in *EngineeringInput, _ *ClaudeCLI) { in.Worktree = in.Scratch + "/tree" }, |
| + "token home inside the worktree": func(in *EngineeringInput, _ *ClaudeCLI) { in.CredentialHome = in.Worktree + "/.home" }, |
| + "runtime copy inside the worktree": func(in *EngineeringInput, _ *ClaudeCLI) { in.ConfigDir = in.Worktree + "/.claude" }, |
| + "runtime copy outside its root": func(in *EngineeringInput, _ *ClaudeCLI) { in.ConfigDir = s + "/elsewhere/account-1" }, |
| + "socket outside the socket dir": func(in *EngineeringInput, _ *ClaudeCLI) { in.Socket = s + "/sock" }, |
| + "socket path too long": func(in *EngineeringInput, _ *ClaudeCLI) { |
| + in.Socket = in.ToolRoot + "/" + strings.Repeat("d", 90) + "/s" |
| + }, |
| + "user temp outside the folders": func(in *EngineeringInput, _ *ClaudeCLI) { in.UserTemp = "/tmp/T" }, |
| + "no user temp": func(in *EngineeringInput, _ *ClaudeCLI) { in.UserTemp = "" }, |
| + "a Mach wildcard": func(in *EngineeringInput, _ *ClaudeCLI) { in.Mach = []string{"*"} }, |
| + "a Mach inner wildcard": func(in *EngineeringInput, _ *ClaudeCLI) { in.Mach = []string{"com.apple.*.x"} }, |
| + "unknown Xcode access": func(in *EngineeringInput, _ *ClaudeCLI) { in.XcodeAccess = "full" }, |
| + "unknown action": func(in *EngineeringInput, _ *ClaudeCLI) { in.Action = "copy" }, |
| + "no model": func(in *EngineeringInput, _ *ClaudeCLI) { in.Model = "" }, |
| + "a flag as model": func(in *EngineeringInput, _ *ClaudeCLI) { in.Model = "--dangerously-skip-permissions" }, |
| + "no session": func(in *EngineeringInput, _ *ClaudeCLI) { in.SessionID = "" }, |
| + "a session with a space": func(in *EngineeringInput, _ *ClaudeCLI) { in.SessionID = "a b" }, |
| + "no marker": func(in *EngineeringInput, _ *ClaudeCLI) { in.Attempt = "" }, |
| + "a marker with credentials": func(in *EngineeringInput, _ *ClaudeCLI) { in.Attempt = "https://user:pass@host" }, |
| + "a relative developer dir": func(in *EngineeringInput, _ *ClaudeCLI) { in.DeveloperDir = "Xcode.app" }, |
| + "a relative runner": func(in *EngineeringInput, _ *ClaudeCLI) { in.Runner = "equipo-runner" }, |
| + "no CLI": func(_ *EngineeringInput, c *ClaudeCLI) { *c = ClaudeCLI{} }, |
| + "a CLI in another install dir": func(_ *EngineeringInput, c *ClaudeCLI) { |
| + *c = NewClaudeCLI("/Users/equipo-paul", "/Users/equipo-paul/other") |
| + }, |
| + "an ask with Xcode access": func(in *EngineeringInput, _ *ClaudeCLI) { in.Action = claude.DarwinAnswer }, |
| + "a check with Xcode access": func(in *EngineeringInput, _ *ClaudeCLI) { in.Action = claude.DarwinCheck }, |
| + } |
| + for name, mutate := range cases { |
| + t.Run(name, func(t *testing.T) { |
| + in, cli := goldenInput(claude.DarwinImplement, wire.XcodeAccessSandboxed), goldenCLI() |
| + mutate(&in, &cli) |
| + if p, err := EngineeringPolicy(cli, in); !errors.Is(err, provider.ErrPolicy) { |
| + t.Fatalf("made %s (%v)", p.Settings, err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// TestEngineeringNoMachWithoutAccess: Xcode's services and caches come |
| +// only with sandboxed Xcode access; without it the list the caller holds |
| +// is not used, and the policy layer refuses one handed to it anyway. |
| +func TestEngineeringNoMachWithoutAccess(t *testing.T) { |
| + in := goldenInput(claude.DarwinImplement, "") |
| + in.Mach = []string{"com.apple.CoreSimulator.*", "com.apple.dt.*"} |
| + p, err := EngineeringPolicy(goldenCLI(), in) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + s, _ := settingsOf(t, p) |
| + if m := s.Sandbox.Network.AllowMachLookup; m == nil || len(m) != 0 { |
| + t.Fatalf("Mach without access: %v", m) |
| + } |
| + for _, w := range s.Sandbox.Filesystem.AllowWrite { |
| + if w != in.Worktree && w != in.Scratch { |
| + t.Fatalf("an Xcode place without access: %v", s.Sandbox.Filesystem.AllowWrite) |
| + } |
| + } |
| + var m struct{ XcodeAccess *string } |
| + if json.Unmarshal(p.Manifest, &m) != nil || m.XcodeAccess == nil || *m.XcodeAccess != "" { |
| + t.Fatalf("xcode access not recorded: %s", p.Manifest) |
| + } |
| + in.XcodeAccess = wire.XcodeAccessSandboxed |
| + p, err = EngineeringPolicy(goldenCLI(), in) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if s, _ = settingsOf(t, p); !slices.Equal(s.Sandbox.Network.AllowMachLookup, in.Mach) { |
| + t.Fatalf("sandboxed access: %v", s.Sandbox.Network.AllowMachLookup) |
| + } |
| + // The policy layer on its own: services or Xcode writes with no |
| + // access are refused, not quietly kept. |
| + d := claudeInputs(t, goldenInput(claude.DarwinImplement, "")) |
| + for name, mutate := range map[string]func(*claude.DarwinInputs){ |
| + "mach": func(d *claude.DarwinInputs) { d.Mach = []string{"com.apple.dt.*"} }, |
| + "writes": func(d *claude.DarwinInputs) { |
| + d.XcodeWrites = []string{"/Users/equipo-paul/Library/Developer/Xcode/DerivedData"} |
| + }, |
| + } { |
| + c := d |
| + mutate(&c) |
| + if _, err := claude.DarwinPolicy(c); !errors.Is(err, provider.ErrPolicy) { |
| + t.Fatalf("%s without access: %v", name, err) |
| + } |
| + } |
| +} |
| + |
| +func claudeInputs(t *testing.T, in EngineeringInput) claude.DarwinInputs { |
| + t.Helper() |
| + d, err := goldenCLI().darwinInputs(in) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return d |
| +} |
| + |
| +// engRig is a launch on this machine's filesystem: a provisioned fake |
| +// CLI in a private home, a real worktree, scratch and runtime copy. |
| +type engRig struct { |
| + t *testing.T |
| + cli ClaudeCLI |
| + in EngineeringInput |
| + token []byte |
| + started []EngineeringCommand |
| + read [][]byte |
| +} |
| + |
| +func newEngRig(t *testing.T) *engRig { |
| + t.Helper() |
| + home, err := filepath.EvalSymlinks(t.TempDir()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Chmod(home, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + install := filepath.Join(home, ".local", "lib", "equipo-runner") |
| + share := filepath.Join(home, ".local", "share", "equipo-runner") |
| + scratch := filepath.Join(share, "scratch") |
| + in := EngineeringInput{ |
| + Paths: Paths{Home: home, StateDir: filepath.Join(share, "state"), AccountsRoot: filepath.Join(home, ".local", "share", "equipo", "accounts"), SessionRoot: filepath.Join(share, "sessions"), InstallDir: install, OtherHomes: []string{"/Users/paul"}}, |
| + Action: claude.DarwinImplement, Model: "claude-haiku-5-5", |
| + Worktree: filepath.Join(scratch, "worker-steps", "k", "tree"), Scratch: filepath.Join(scratch, "policy-1"), |
| + // The socket is never dialled here, and a temporary home is too |
| + // deep for sun_path: a short path stands for it. |
| + Runner: filepath.Join(install, "equipo-runner"), ToolRoot: "/private/tmp/equipo-t", Socket: "/private/tmp/equipo-t/1/s", |
| + ConfigDir: filepath.Join(scratch, "homes", "account-1"), CredentialHome: filepath.Join(home, ".local", "share", "equipo", "accounts", "claude-1"), RuntimeRoot: filepath.Join(scratch, "homes"), |
| + DeveloperDir: "/Applications/Xcode.app/Contents/Developer", Attempt: "attempt-7f3a", SessionID: "00000000-0000-4000-8000-000000000001", |
| + } |
| + for _, d := range []string{install, in.Worktree, in.Scratch, in.ConfigDir, in.CredentialHome, in.StateDir} { |
| + if err := os.MkdirAll(d, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + body := fakeClaude() |
| + cli := homeCLI(home, install, body) |
| + if err := cli.Provision(context.Background(), serve(body, nil)); err != nil { |
| + t.Fatal(err) |
| + } |
| + return &engRig{t: t, cli: cli, in: in, token: []byte("sk-ant-oat01-SENTINEL-the-token-goes-by-descriptor-only-AA")} |
| +} |
| + |
| +func (r *engRig) policy() provider.Policy { |
| + r.t.Helper() |
| + p, err := EngineeringPolicy(r.cli, r.in) |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + return p |
| +} |
| + |
| +// launch runs LaunchEngineering with a start that records the command |
| +// and reads the token descriptor to its end, as the CLI does. |
| +func (r *engRig) launch(p provider.Policy) error { |
| + return LaunchEngineering(context.Background(), r.cli, r.in, p, slices.Clone(r.token), func(_ context.Context, c EngineeringCommand) error { |
| + r.started = append(r.started, c) |
| + var got []byte |
| + if len(c.Files) > 0 { |
| + got, _ = io.ReadAll(c.Files[0]) |
| + } |
| + r.read = append(r.read, got) |
| + return nil |
| + }) |
| +} |
| + |
| +// rehashed is p with its manifest changed by edit and every hash |
| +// recomputed, as someone forging a policy would. |
| +func rehashed(t *testing.T, p provider.Policy, edit func(m map[string]json.RawMessage)) provider.Policy { |
| + t.Helper() |
| + var m map[string]json.RawMessage |
| + if err := json.Unmarshal(p.Manifest, &m); err != nil { |
| + t.Fatal(err) |
| + } |
| + edit(m) |
| + raw, err := json.Marshal(m) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + sum := sha256.Sum256(raw) |
| + p.Manifest, p.Hash, p.ManifestHash = raw, hex.EncodeToString(sum[:]), hex.EncodeToString(sum[:]) |
| + p.Settings = bytes.Clone(m["Settings"]) |
| + var env map[string]string |
| + json.Unmarshal(m["Env"], &env) |
| + p.Env = env |
| + return p |
| +} |
| + |
| +// TestEngineeringPolicyValidatedBeforeLaunch: the launcher regenerates |
| +// the policy from its inputs and starts nothing on any difference. |
| +func TestEngineeringPolicyValidatedBeforeLaunch(t *testing.T) { |
| + r := newEngRig(t) |
| + p := r.policy() |
| + if err := r.launch(p); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(r.started) != 1 || !slices.Equal(r.started[0].Argv, claude.DarwinArgv(p)) || r.started[0].Argv[0] != ClaudePath(r.in.InstallDir) || r.started[0].Dir != r.in.Worktree { |
| + t.Fatalf("started %+v", r.started) |
| + } |
| + settings := filepath.Join(r.in.ConfigDir, "equipo-settings.json") |
| + mcp := filepath.Join(r.in.ConfigDir, "equipo-mcp.json") |
| + for path, want := range map[string][]byte{settings: p.Settings, mcp: p.MCP} { |
| + got, err := os.ReadFile(path) |
| + info, _ := os.Lstat(path) |
| + if err != nil || !bytes.Equal(got, want) || info.Mode() != 0600 { |
| + t.Fatalf("%s: %v %s", path, err, got) |
| + } |
| + } |
| + other := r.in |
| + other.SessionID = "00000000-0000-4000-8000-000000000002" |
| + forOther, err := EngineeringPolicy(r.cli, other) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + cases := map[string]func(provider.Policy) provider.Policy{ |
| + "one byte of settings": func(p provider.Policy) provider.Policy { |
| + p.Settings = bytes.Replace(bytes.Clone(p.Settings), []byte("600000"), []byte("600001"), 1) |
| + return p |
| + }, |
| + "one byte of the manifest's settings, rehashed": func(p provider.Policy) provider.Policy { |
| + return rehashed(t, p, func(m map[string]json.RawMessage) { |
| + m["Settings"] = bytes.Replace(m["Settings"], []byte(`"strictAllowlist":true`), []byte(`"strictAllowlist":0 `), 1) |
| + }) |
| + }, |
| + "a different argv, rehashed": func(p provider.Policy) provider.Policy { |
| + return rehashed(t, p, func(m map[string]json.RawMessage) { |
| + m["Argv"] = bytes.Replace(m["Argv"], []byte(`"manual"`), []byte(`"bypassPermissions"`), 1) |
| + }) |
| + }, |
| + "an extra environment key": func(p provider.Policy) provider.Policy { |
| + p.Env = maps.Clone(p.Env) |
| + p.Env["NODE_OPTIONS"] = "--require /tmp/x.js" |
| + return p |
| + }, |
| + "an extra environment key, rehashed": func(p provider.Policy) provider.Policy { |
| + return rehashed(t, p, func(m map[string]json.RawMessage) { |
| + m["Env"] = bytes.Replace(m["Env"], []byte(`{`), []byte(`{"NODE_OPTIONS":"--require /tmp/x.js",`), 1) |
| + }) |
| + }, |
| + "a changed hash": func(p provider.Policy) provider.Policy { |
| + p.Hash = strings.Repeat("0", 64) |
| + return p |
| + }, |
| + "a mount added": func(p provider.Policy) provider.Policy { |
| + p.Mounts = []provider.Mount{{Source: "/", Target: "/x"}} |
| + return p |
| + }, |
| + "another attempt's policy": func(provider.Policy) provider.Policy { return forOther }, |
| + } |
| + for name, mutate := range cases { |
| + t.Run(name, func(t *testing.T) { |
| + r.started = nil |
| + os.Remove(settings) |
| + if err := r.launch(mutate(p)); !errors.Is(err, provider.ErrPolicy) || len(r.started) != 0 { |
| + t.Fatalf("launched (%v, %d)", err, len(r.started)) |
| + } |
| + if _, err := os.Lstat(settings); !errors.Is(err, fs.ErrNotExist) { |
| + t.Fatalf("settings written for a refused launch: %v", err) |
| + } |
| + }) |
| + } |
| + // What the filesystem must show at the start: a worktree that is its |
| + // own real path, and no token file the CLI would read by itself. |
| + t.Run("a token file in the runtime copy", func(t *testing.T) { |
| + for _, name := range []string{".oauth_token", ".oauth-token"} { |
| + r.started = nil |
| + path := filepath.Join(r.in.ConfigDir, name) |
| + if err := os.WriteFile(path, []byte("x"), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := r.launch(p); !errors.Is(err, provider.ErrPolicy) || len(r.started) != 0 { |
| + t.Fatalf("%s: launched (%v)", name, err) |
| + } |
| + os.Remove(path) |
| + } |
| + }) |
| + t.Run("a worktree that is a link", func(t *testing.T) { |
| + r.started = nil |
| + real := r.in.Worktree + ".real" |
| + if err := os.Rename(r.in.Worktree, real); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Symlink(real, r.in.Worktree); err != nil { |
| + t.Fatal(err) |
| + } |
| + defer func() { os.Remove(r.in.Worktree); os.Rename(real, r.in.Worktree) }() |
| + if err := r.launch(p); !errors.Is(err, provider.ErrPolicy) || len(r.started) != 0 { |
| + t.Fatalf("launched (%v)", err) |
| + } |
| + }) |
| + // The CLI itself is still checked by ClaudeCLI.Launch. |
| + t.Run("an unpinned CLI", func(t *testing.T) { |
| + r.started = nil |
| + if err := os.Chmod(ClaudePath(r.in.InstallDir), 0755); err != nil { |
| + t.Fatal(err) |
| + } |
| + defer os.Chmod(ClaudePath(r.in.InstallDir), 0700) |
| + var u *ClaudeUnavailable |
| + if err := r.launch(p); !errors.As(err, &u) || len(r.started) != 0 { |
| + t.Fatalf("launched (%v)", err) |
| + } |
| + }) |
| +} |
| + |
| +// TestEngineeringEnvFromScratch: the CLI's environment is exactly the |
| +// certified one; nothing of the runner's own is inherited. |
| +func TestEngineeringEnvFromScratch(t *testing.T) { |
| + t.Setenv("EQUIPO_INHERITED_SENTINEL", "inherited") |
| + t.Setenv("CLAUDE_CODE_OAUTH_TOKEN", "inherited-token") |
| + t.Setenv("ANTHROPIC_API_KEY", "inherited-key") |
| + t.Setenv("SSH_AUTH_SOCK", "/private/tmp/agent.sock") |
| + r := newEngRig(t) |
| + p := r.policy() |
| + if err := r.launch(p); err != nil { |
| + t.Fatal(err) |
| + } |
| + want := []string{ |
| + "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1", |
| + "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR=3", |
| + "CLAUDE_CODE_PROJECT_DIR_NAME=-workspace", |
| + "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1", |
| + "CLAUDE_CONFIG_DIR=" + r.in.ConfigDir, |
| + "DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer", |
| + "DISABLE_AUTOUPDATER=1", |
| + "EQUIPO_ATTEMPT=attempt-7f3a", |
| + "HOME=" + r.in.Home, |
| + "LANG=en_US.UTF-8", |
| + "PATH=/usr/bin:/bin:/usr/sbin:/sbin", |
| + "TMPDIR=" + r.in.Scratch, |
| + } |
| + if len(r.started) != 1 || !slices.Equal(r.started[0].Env, want) { |
| + t.Fatalf("env %+v\nwant %q", r.started, want) |
| + } |
| + // The policy records the same environment, and the marker's name is |
| + // one the CLI's scrub keeps (task 1, S5). |
| + var rec []string |
| + for k, v := range p.Env { |
| + rec = append(rec, k+"="+v) |
| + } |
| + slices.Sort(rec) |
| + if !slices.Equal(rec, want) { |
| + t.Fatalf("policy env %q", rec) |
| + } |
| + for _, word := range []string{"TOKEN", "KEY", "AUTH", "PAT", "SECRET"} { |
| + if strings.Contains("EQUIPO_ATTEMPT", word) { |
| + t.Fatalf("marker name has %s", word) |
| + } |
| + } |
| + // No developer dir: no DEVELOPER_DIR, nothing else changes. |
| + r.in.DeveloperDir = "" |
| + r.started = nil |
| + if err := r.launch(r.policy()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !slices.Equal(r.started[0].Env, slices.DeleteFunc(slices.Clone(want), func(s string) bool { return strings.HasPrefix(s, "DEVELOPER_DIR=") })) { |
| + t.Fatalf("env without a developer dir: %q", r.started[0].Env) |
| + } |
| +} |
| + |
| +// TestEngineeringTokenNotInArgvOrPolicy: the token reaches the CLI only |
| +// on its descriptor. It is in no argv, no policy, no environment (a |
| +// sandboxed command can read the CLI's initial environment), no file and |
| +// no refusal's words. |
| +func TestEngineeringTokenNotInArgvOrPolicy(t *testing.T) { |
| + r := newEngRig(t) |
| + p := r.policy() |
| + if err := r.launch(p); err != nil { |
| + t.Fatal(err) |
| + } |
| + token := string(r.token) |
| + c := r.started[0] |
| + if strings.Contains(strings.Join(c.Argv, "\x00"), token) || strings.Contains(strings.Join(c.Env, "\x00"), token) { |
| + t.Fatal("token in argv or environment") |
| + } |
| + for _, kv := range c.Env { |
| + k, _, _ := strings.Cut(kv, "=") |
| + if k == "CLAUDE_CODE_OAUTH_TOKEN" || k == "ANTHROPIC_API_KEY" || k == "ANTHROPIC_AUTH_TOKEN" { |
| + t.Fatalf("a token variable in the environment: %s", k) |
| + } |
| + } |
| + stored, _ := json.Marshal(p) |
| + if bytes.Contains(stored, r.token) || bytes.Contains(p.Manifest, r.token) { |
| + t.Fatal("token in the policy") |
| + } |
| + if len(c.Files) != 1 || !bytes.Equal(r.read[0], r.token) || !slices.Contains(c.Env, "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR=3") { |
| + t.Fatalf("token not on descriptor 3: %q", r.read) |
| + } |
| + // Nothing on disk under the runner's home holds it. |
| + filepath.WalkDir(r.in.Home, func(path string, d fs.DirEntry, err error) error { |
| + if err == nil && d.Type().IsRegular() { |
| + if b, _ := os.ReadFile(path); bytes.Contains(b, r.token) { |
| + t.Fatalf("token written to %s", path) |
| + } |
| + } |
| + return nil |
| + }) |
| + // Refusals neither start nor say it. |
| + for name, bad := range map[string][]byte{ |
| + "empty": nil, |
| + "a newline": []byte(token + "\nmore"), |
| + "too long": bytes.Repeat([]byte("a"), 4097), |
| + } { |
| + r.started = nil |
| + err := LaunchEngineering(context.Background(), r.cli, r.in, p, bad, func(context.Context, EngineeringCommand) error { |
| + r.started = append(r.started, EngineeringCommand{}) |
| + return nil |
| + }) |
| + if err == nil || len(r.started) != 0 || strings.Contains(err.Error(), token) { |
| + t.Fatalf("%s token: %v", name, err) |
| + } |
| + } |
| + r.started = nil |
| + bad := p |
| + bad.Hash = "" |
| + if err := r.launch(bad); err == nil || strings.Contains(err.Error(), token) || len(r.started) != 0 { |
| + t.Fatalf("refused policy: %v", err) |
| + } |
| +} |
diff --git a/internal/runner/mac/profile.go b/internal/runner/mac/profile.go| index a6b65cfd..0bfd5de1 100644 |
| --- a/internal/runner/mac/profile.go |
| +++ b/internal/runner/mac/profile.go |
| @@ -88,13 +88,11 @@ type Filesystem struct { |
| // writes; no network; the Mach services xcodebuild needs. |
| func ChecksSettings(in ChecksInput) ([]byte, error) { |
| deny := DenyList(in.Paths) |
| - if in.UserTemp == "" || in.UserTemp == UserTempPrefix || !within(UserTempPrefix, in.UserTemp) { |
| - return nil, ErrProfile |
| + places, err := xcodePlaces(in.Paths) |
| + if err != nil { |
| + return nil, err |
| } |
| - write := []string{in.Tree, in.Attempt, in.UserTemp, |
| - filepath.Join(in.Home, "Library/Developer/Xcode/DerivedData"), |
| - filepath.Join(in.Home, "Library/Caches/org.swift.swiftpm"), |
| - filepath.Join(in.Home, "Library/org.swift.swiftpm")} |
| + write := append([]string{in.Tree, in.Attempt}, places...) |
| denyWrite := compact(append(slices.Clone(deny), in.InstallDir)) |
| for _, p := range append(append(slices.Clone(denyWrite), write...), in.Home) { |
| if !literalPath(p) { |
| @@ -111,10 +109,8 @@ func ChecksSettings(in ChecksInput) ([]byte, error) { |
| } |
| } |
| } |
| - for _, m := range in.Mach { |
| - if m == "" || m == "*" || strings.ContainsAny(m, "/ \"") || strings.Contains(strings.TrimSuffix(m, "*"), "*") { |
| - return nil, ErrProfile |
| - } |
| + if err := machNames(in.Mach); err != nil { |
| + return nil, err |
| } |
| s := Settings{ |
| Network: Network{AllowedDomains: []string{}, DeniedDomains: []string{}, AllowMachLookup: append([]string{}, in.Mach...)}, |
| @@ -123,6 +119,32 @@ func ChecksSettings(in ChecksInput) ([]byte, error) { |
| return json.MarshalIndent(s, "", " ") |
| } |
| +// xcodePlaces are where a build writes outside its tree and scratch, |
| +// shared by the checks profile and Engineering with sandboxed Xcode |
| +// access: the runner user's T (resolved and checked, Xcode writes there |
| +// whatever $TMPDIR says), Xcode's DerivedData and SwiftPM's caches. |
| +func xcodePlaces(p Paths) ([]string, error) { |
| + if p.UserTemp == "" || p.UserTemp == UserTempPrefix || !within(UserTempPrefix, p.UserTemp) { |
| + return nil, ErrProfile |
| + } |
| + return []string{p.UserTemp, |
| + filepath.Join(p.Home, "Library/Developer/Xcode/DerivedData"), |
| + filepath.Join(p.Home, "Library/Caches/org.swift.swiftpm"), |
| + filepath.Join(p.Home, "Library/org.swift.swiftpm")}, nil |
| +} |
| + |
| +// machNames refuses a Mach service list that opens more than it names: |
| +// an empty name, a bare wildcard, a wildcard anywhere but the end (the |
| +// runtime takes one trailing *), or a character no service name has. |
| +func machNames(names []string) error { |
| + for _, m := range names { |
| + if m == "" || m == "*" || strings.ContainsAny(m, "/ \"") || strings.Contains(strings.TrimSuffix(m, "*"), "*") { |
| + return ErrProfile |
| + } |
| + } |
| + return nil |
| +} |
| + |
| // literalPath is an absolute, clean path srt cannot read as a pattern. |
| func literalPath(p string) bool { |
| return p != "" && filepath.IsAbs(p) && filepath.Clean(p) == p && p != "/" && !strings.ContainsAny(p, "*?[]{}\\\n\x00") |
diff --git a/internal/runner/mac/testdata/engineering-2026-11-28-answer.json b/internal/runner/mac/testdata/engineering-2026-11-28-answer.json| new file mode 100644 |
| index 00000000..3fa249a2 |
| --- /dev/null |
| +++ b/internal/runner/mac/testdata/engineering-2026-11-28-answer.json |
| @@ -0,0 +1,336 @@ |
| +{ |
| + "Version": "darwin-engineering-1", |
| + "Platform": "darwin", |
| + "WorkspaceRoot": "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "Action": "answer", |
| + "ProviderVersion": "2.1.312", |
| + "CLI": "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312/claude", |
| + "CLIDigest": "6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620", |
| + "Argv": [ |
| + "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312/claude", |
| + "-p", |
| + "--verbose", |
| + "--include-hook-events", |
| + "--input-format", |
| + "stream-json", |
| + "--output-format", |
| + "stream-json", |
| + "--model", |
| + "claude-haiku-5-5", |
| + "--setting-sources", |
| + "", |
| + "--disable-slash-commands", |
| + "--strict-mcp-config", |
| + "--mcp-config", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/equipo-mcp.json", |
| + "--settings", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/equipo-settings.json", |
| + "--permission-mode", |
| + "manual", |
| + "--permission-prompt-tool", |
| + "mcp__equipo__permission", |
| + "--tools", |
| + "Read,Glob,Grep", |
| + "--include-partial-messages", |
| + "--session-id", |
| + "00000000-0000-4000-8000-000000000001" |
| + ], |
| + "Env": { |
| + "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", |
| + "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR": "3", |
| + "CLAUDE_CODE_PROJECT_DIR_NAME": "-workspace", |
| + "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB": "1", |
| + "CLAUDE_CONFIG_DIR": "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "DEVELOPER_DIR": "/Applications/Xcode.app/Contents/Developer", |
| + "DISABLE_AUTOUPDATER": "1", |
| + "EQUIPO_ATTEMPT": "attempt-7f3a", |
| + "HOME": "/Users/equipo-paul", |
| + "LANG": "en_US.UTF-8", |
| + "PATH": "/usr/bin:/bin:/usr/sbin:/sbin", |
| + "TMPDIR": "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1" |
| + }, |
| + "Workspace": "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "Scratch": "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1", |
| + "CredentialHome": "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "ConfigDir": "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "DeniedPaths": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ], |
| + "Tools": [ |
| + "Read", |
| + "Glob", |
| + "Grep", |
| + "mcp__equipo__permission", |
| + "mcp__equipo__git_log", |
| + "mcp__equipo__git_diff", |
| + "mcp__equipo__git_show" |
| + ], |
| + "XcodeAccess": "", |
| + "Settings": { |
| + "autoDreamEnabled": false, |
| + "autoMemoryEnabled": false, |
| + "disableAllHooks": true, |
| + "enabledPlugins": { |
| + "agents-md@builtin": false, |
| + "plugin-authoring@builtin": false |
| + }, |
| + "env": { |
| + "MCP_TOOL_TIMEOUT": "600000" |
| + }, |
| + "permissions": { |
| + "allow": [ |
| + "mcp__equipo__git_log", |
| + "mcp__equipo__git_diff", |
| + "mcp__equipo__git_show" |
| + ], |
| + "ask": [ |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)" |
| + ], |
| + "deny": [ |
| + "Read(//Users/Shared)", |
| + "Read(//Users/Shared/**)", |
| + "Write(//Users/Shared)", |
| + "Write(//Users/Shared/**)", |
| + "Edit(//Users/Shared)", |
| + "Edit(//Users/Shared/**)", |
| + "Glob(//Users/Shared)", |
| + "Glob(//Users/Shared/**)", |
| + "Grep(//Users/Shared)", |
| + "Grep(//Users/Shared/**)", |
| + "Read(//Users/equipo-paul/.aws)", |
| + "Read(//Users/equipo-paul/.aws/**)", |
| + "Write(//Users/equipo-paul/.aws)", |
| + "Write(//Users/equipo-paul/.aws/**)", |
| + "Edit(//Users/equipo-paul/.aws)", |
| + "Edit(//Users/equipo-paul/.aws/**)", |
| + "Glob(//Users/equipo-paul/.aws)", |
| + "Glob(//Users/equipo-paul/.aws/**)", |
| + "Grep(//Users/equipo-paul/.aws)", |
| + "Grep(//Users/equipo-paul/.aws/**)", |
| + "Read(//Users/equipo-paul/.config/op)", |
| + "Read(//Users/equipo-paul/.config/op/**)", |
| + "Write(//Users/equipo-paul/.config/op)", |
| + "Write(//Users/equipo-paul/.config/op/**)", |
| + "Edit(//Users/equipo-paul/.config/op)", |
| + "Edit(//Users/equipo-paul/.config/op/**)", |
| + "Glob(//Users/equipo-paul/.config/op)", |
| + "Glob(//Users/equipo-paul/.config/op/**)", |
| + "Grep(//Users/equipo-paul/.config/op)", |
| + "Grep(//Users/equipo-paul/.config/op/**)", |
| + "Read(//Users/equipo-paul/.gnupg)", |
| + "Read(//Users/equipo-paul/.gnupg/**)", |
| + "Write(//Users/equipo-paul/.gnupg)", |
| + "Write(//Users/equipo-paul/.gnupg/**)", |
| + "Edit(//Users/equipo-paul/.gnupg)", |
| + "Edit(//Users/equipo-paul/.gnupg/**)", |
| + "Glob(//Users/equipo-paul/.gnupg)", |
| + "Glob(//Users/equipo-paul/.gnupg/**)", |
| + "Grep(//Users/equipo-paul/.gnupg)", |
| + "Grep(//Users/equipo-paul/.gnupg/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Read(//Users/equipo-paul/.ssh)", |
| + "Read(//Users/equipo-paul/.ssh/**)", |
| + "Write(//Users/equipo-paul/.ssh)", |
| + "Write(//Users/equipo-paul/.ssh/**)", |
| + "Edit(//Users/equipo-paul/.ssh)", |
| + "Edit(//Users/equipo-paul/.ssh/**)", |
| + "Glob(//Users/equipo-paul/.ssh)", |
| + "Glob(//Users/equipo-paul/.ssh/**)", |
| + "Grep(//Users/equipo-paul/.ssh)", |
| + "Grep(//Users/equipo-paul/.ssh/**)", |
| + "Read(//Users/equipo-paul/Library/Keychains)", |
| + "Read(//Users/equipo-paul/Library/Keychains/**)", |
| + "Write(//Users/equipo-paul/Library/Keychains)", |
| + "Write(//Users/equipo-paul/Library/Keychains/**)", |
| + "Edit(//Users/equipo-paul/Library/Keychains)", |
| + "Edit(//Users/equipo-paul/Library/Keychains/**)", |
| + "Glob(//Users/equipo-paul/Library/Keychains)", |
| + "Glob(//Users/equipo-paul/Library/Keychains/**)", |
| + "Grep(//Users/equipo-paul/Library/Keychains)", |
| + "Grep(//Users/equipo-paul/Library/Keychains/**)", |
| + "Read(//Users/paul)", |
| + "Read(//Users/paul/**)", |
| + "Write(//Users/paul)", |
| + "Write(//Users/paul/**)", |
| + "Edit(//Users/paul)", |
| + "Edit(//Users/paul/**)", |
| + "Glob(//Users/paul)", |
| + "Glob(//Users/paul/**)", |
| + "Grep(//Users/paul)", |
| + "Grep(//Users/paul/**)", |
| + "Read(//Volumes)", |
| + "Read(//Volumes/**)", |
| + "Write(//Volumes)", |
| + "Write(//Volumes/**)", |
| + "Edit(//Volumes)", |
| + "Edit(//Volumes/**)", |
| + "Glob(//Volumes)", |
| + "Glob(//Volumes/**)", |
| + "Grep(//Volumes)", |
| + "Grep(//Volumes/**)" |
| + ] |
| + }, |
| + "sandbox": { |
| + "allowUnsandboxedCommands": false, |
| + "autoAllowBashIfSandboxed": true, |
| + "enabled": true, |
| + "excludedCommands": [], |
| + "failIfUnavailable": true, |
| + "filesystem": { |
| + "allowWrite": [ |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1" |
| + ], |
| + "denyRead": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ], |
| + "denyWrite": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/lib/equipo-runner", |
| + "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ] |
| + }, |
| + "network": { |
| + "allowAllUnixSockets": false, |
| + "allowLocalBinding": false, |
| + "allowMachLookup": [], |
| + "allowUnixSockets": [], |
| + "allowedDomains": [], |
| + "strictAllowlist": true |
| + } |
| + } |
| + }, |
| + "MCP": { |
| + "mcpServers": { |
| + "equipo": { |
| + "type": "stdio", |
| + "command": "/Users/equipo-paul/.local/lib/equipo-runner/equipo-runner", |
| + "args": [ |
| + "tool-proxy", |
| + "--socket", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t/1234567890/s" |
| + ] |
| + } |
| + } |
| + }, |
| + "ThreadPolicy": { |
| + "specialist": "Answerer", |
| + "model": "claude-haiku-5-5", |
| + "start": "session-id", |
| + "resume": "resume" |
| + }, |
| + "TurnPolicy": {} |
| +} |
diff --git a/internal/runner/mac/testdata/engineering-2026-11-28-check.json b/internal/runner/mac/testdata/engineering-2026-11-28-check.json| new file mode 100644 |
| index 00000000..6ce95612 |
| --- /dev/null |
| +++ b/internal/runner/mac/testdata/engineering-2026-11-28-check.json |
| @@ -0,0 +1,322 @@ |
| +{ |
| + "Version": "darwin-engineering-1", |
| + "Platform": "darwin", |
| + "WorkspaceRoot": "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "Action": "check", |
| + "ProviderVersion": "2.1.312", |
| + "CLI": "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312/claude", |
| + "CLIDigest": "6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620", |
| + "Argv": [ |
| + "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312/claude", |
| + "-p", |
| + "--verbose", |
| + "--include-hook-events", |
| + "--input-format", |
| + "stream-json", |
| + "--output-format", |
| + "stream-json", |
| + "--model", |
| + "claude-haiku-5-5", |
| + "--setting-sources", |
| + "", |
| + "--disable-slash-commands", |
| + "--strict-mcp-config", |
| + "--mcp-config", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/equipo-mcp.json", |
| + "--settings", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/equipo-settings.json", |
| + "--permission-mode", |
| + "manual", |
| + "--permission-prompt-tool", |
| + "mcp__equipo__permission", |
| + "--tools", |
| + "", |
| + "--include-partial-messages", |
| + "--session-id", |
| + "00000000-0000-4000-8000-000000000001" |
| + ], |
| + "Env": { |
| + "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", |
| + "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR": "3", |
| + "CLAUDE_CODE_PROJECT_DIR_NAME": "-workspace", |
| + "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB": "1", |
| + "CLAUDE_CONFIG_DIR": "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "DEVELOPER_DIR": "/Applications/Xcode.app/Contents/Developer", |
| + "DISABLE_AUTOUPDATER": "1", |
| + "EQUIPO_ATTEMPT": "attempt-7f3a", |
| + "HOME": "/Users/equipo-paul", |
| + "LANG": "en_US.UTF-8", |
| + "PATH": "/usr/bin:/bin:/usr/sbin:/sbin", |
| + "TMPDIR": "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1" |
| + }, |
| + "Workspace": "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "Scratch": "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1", |
| + "CredentialHome": "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "ConfigDir": "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "DeniedPaths": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ], |
| + "Tools": [ |
| + "mcp__equipo__permission" |
| + ], |
| + "XcodeAccess": "", |
| + "Settings": { |
| + "autoDreamEnabled": false, |
| + "autoMemoryEnabled": false, |
| + "disableAllHooks": true, |
| + "enabledPlugins": { |
| + "agents-md@builtin": false, |
| + "plugin-authoring@builtin": false |
| + }, |
| + "env": { |
| + "MCP_TOOL_TIMEOUT": "600000" |
| + }, |
| + "permissions": { |
| + "allow": [], |
| + "ask": [], |
| + "deny": [ |
| + "Read(//Users/Shared)", |
| + "Read(//Users/Shared/**)", |
| + "Write(//Users/Shared)", |
| + "Write(//Users/Shared/**)", |
| + "Edit(//Users/Shared)", |
| + "Edit(//Users/Shared/**)", |
| + "Glob(//Users/Shared)", |
| + "Glob(//Users/Shared/**)", |
| + "Grep(//Users/Shared)", |
| + "Grep(//Users/Shared/**)", |
| + "Read(//Users/equipo-paul/.aws)", |
| + "Read(//Users/equipo-paul/.aws/**)", |
| + "Write(//Users/equipo-paul/.aws)", |
| + "Write(//Users/equipo-paul/.aws/**)", |
| + "Edit(//Users/equipo-paul/.aws)", |
| + "Edit(//Users/equipo-paul/.aws/**)", |
| + "Glob(//Users/equipo-paul/.aws)", |
| + "Glob(//Users/equipo-paul/.aws/**)", |
| + "Grep(//Users/equipo-paul/.aws)", |
| + "Grep(//Users/equipo-paul/.aws/**)", |
| + "Read(//Users/equipo-paul/.config/op)", |
| + "Read(//Users/equipo-paul/.config/op/**)", |
| + "Write(//Users/equipo-paul/.config/op)", |
| + "Write(//Users/equipo-paul/.config/op/**)", |
| + "Edit(//Users/equipo-paul/.config/op)", |
| + "Edit(//Users/equipo-paul/.config/op/**)", |
| + "Glob(//Users/equipo-paul/.config/op)", |
| + "Glob(//Users/equipo-paul/.config/op/**)", |
| + "Grep(//Users/equipo-paul/.config/op)", |
| + "Grep(//Users/equipo-paul/.config/op/**)", |
| + "Read(//Users/equipo-paul/.gnupg)", |
| + "Read(//Users/equipo-paul/.gnupg/**)", |
| + "Write(//Users/equipo-paul/.gnupg)", |
| + "Write(//Users/equipo-paul/.gnupg/**)", |
| + "Edit(//Users/equipo-paul/.gnupg)", |
| + "Edit(//Users/equipo-paul/.gnupg/**)", |
| + "Glob(//Users/equipo-paul/.gnupg)", |
| + "Glob(//Users/equipo-paul/.gnupg/**)", |
| + "Grep(//Users/equipo-paul/.gnupg)", |
| + "Grep(//Users/equipo-paul/.gnupg/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Read(//Users/equipo-paul/.ssh)", |
| + "Read(//Users/equipo-paul/.ssh/**)", |
| + "Write(//Users/equipo-paul/.ssh)", |
| + "Write(//Users/equipo-paul/.ssh/**)", |
| + "Edit(//Users/equipo-paul/.ssh)", |
| + "Edit(//Users/equipo-paul/.ssh/**)", |
| + "Glob(//Users/equipo-paul/.ssh)", |
| + "Glob(//Users/equipo-paul/.ssh/**)", |
| + "Grep(//Users/equipo-paul/.ssh)", |
| + "Grep(//Users/equipo-paul/.ssh/**)", |
| + "Read(//Users/equipo-paul/Library/Keychains)", |
| + "Read(//Users/equipo-paul/Library/Keychains/**)", |
| + "Write(//Users/equipo-paul/Library/Keychains)", |
| + "Write(//Users/equipo-paul/Library/Keychains/**)", |
| + "Edit(//Users/equipo-paul/Library/Keychains)", |
| + "Edit(//Users/equipo-paul/Library/Keychains/**)", |
| + "Glob(//Users/equipo-paul/Library/Keychains)", |
| + "Glob(//Users/equipo-paul/Library/Keychains/**)", |
| + "Grep(//Users/equipo-paul/Library/Keychains)", |
| + "Grep(//Users/equipo-paul/Library/Keychains/**)", |
| + "Read(//Users/paul)", |
| + "Read(//Users/paul/**)", |
| + "Write(//Users/paul)", |
| + "Write(//Users/paul/**)", |
| + "Edit(//Users/paul)", |
| + "Edit(//Users/paul/**)", |
| + "Glob(//Users/paul)", |
| + "Glob(//Users/paul/**)", |
| + "Grep(//Users/paul)", |
| + "Grep(//Users/paul/**)", |
| + "Read(//Volumes)", |
| + "Read(//Volumes/**)", |
| + "Write(//Volumes)", |
| + "Write(//Volumes/**)", |
| + "Edit(//Volumes)", |
| + "Edit(//Volumes/**)", |
| + "Glob(//Volumes)", |
| + "Glob(//Volumes/**)", |
| + "Grep(//Volumes)", |
| + "Grep(//Volumes/**)" |
| + ] |
| + }, |
| + "sandbox": { |
| + "allowUnsandboxedCommands": false, |
| + "autoAllowBashIfSandboxed": true, |
| + "enabled": true, |
| + "excludedCommands": [], |
| + "failIfUnavailable": true, |
| + "filesystem": { |
| + "allowWrite": [ |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1" |
| + ], |
| + "denyRead": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ], |
| + "denyWrite": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/lib/equipo-runner", |
| + "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ] |
| + }, |
| + "network": { |
| + "allowAllUnixSockets": false, |
| + "allowLocalBinding": false, |
| + "allowMachLookup": [], |
| + "allowUnixSockets": [], |
| + "allowedDomains": [], |
| + "strictAllowlist": true |
| + } |
| + } |
| + }, |
| + "MCP": { |
| + "mcpServers": { |
| + "equipo": { |
| + "type": "stdio", |
| + "command": "/Users/equipo-paul/.local/lib/equipo-runner/equipo-runner", |
| + "args": [ |
| + "tool-proxy", |
| + "--socket", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t/1234567890/s" |
| + ] |
| + } |
| + } |
| + }, |
| + "ThreadPolicy": { |
| + "specialist": "Coordinator", |
| + "model": "claude-haiku-5-5", |
| + "start": "session-id", |
| + "resume": "resume" |
| + }, |
| + "TurnPolicy": {} |
| +} |
diff --git a/internal/runner/mac/testdata/engineering-2026-11-28-implement-xcode.json b/internal/runner/mac/testdata/engineering-2026-11-28-implement-xcode.json| new file mode 100644 |
| index 00000000..e65c2781 |
| --- /dev/null |
| +++ b/internal/runner/mac/testdata/engineering-2026-11-28-implement-xcode.json |
| @@ -0,0 +1,350 @@ |
| +{ |
| + "Version": "darwin-engineering-1", |
| + "Platform": "darwin", |
| + "WorkspaceRoot": "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "Action": "implement", |
| + "ProviderVersion": "2.1.312", |
| + "CLI": "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312/claude", |
| + "CLIDigest": "6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620", |
| + "Argv": [ |
| + "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312/claude", |
| + "-p", |
| + "--verbose", |
| + "--include-hook-events", |
| + "--input-format", |
| + "stream-json", |
| + "--output-format", |
| + "stream-json", |
| + "--model", |
| + "claude-haiku-5-5", |
| + "--setting-sources", |
| + "", |
| + "--disable-slash-commands", |
| + "--strict-mcp-config", |
| + "--mcp-config", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/equipo-mcp.json", |
| + "--settings", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/equipo-settings.json", |
| + "--permission-mode", |
| + "manual", |
| + "--permission-prompt-tool", |
| + "mcp__equipo__permission", |
| + "--tools", |
| + "Bash,Read,Write,Edit,Glob,Grep", |
| + "--session-id", |
| + "00000000-0000-4000-8000-000000000001" |
| + ], |
| + "Env": { |
| + "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", |
| + "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR": "3", |
| + "CLAUDE_CODE_PROJECT_DIR_NAME": "-workspace", |
| + "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB": "1", |
| + "CLAUDE_CONFIG_DIR": "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "DEVELOPER_DIR": "/Applications/Xcode.app/Contents/Developer", |
| + "DISABLE_AUTOUPDATER": "1", |
| + "EQUIPO_ATTEMPT": "attempt-7f3a", |
| + "HOME": "/Users/equipo-paul", |
| + "LANG": "en_US.UTF-8", |
| + "PATH": "/usr/bin:/bin:/usr/sbin:/sbin", |
| + "TMPDIR": "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1" |
| + }, |
| + "Workspace": "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "Scratch": "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1", |
| + "CredentialHome": "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "ConfigDir": "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "DeniedPaths": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ], |
| + "Tools": [ |
| + "Bash", |
| + "Read", |
| + "Write", |
| + "Edit", |
| + "Glob", |
| + "Grep", |
| + "mcp__equipo__permission", |
| + "mcp__equipo__submit_candidate", |
| + "mcp__equipo__ask_person", |
| + "mcp__equipo__submit_render" |
| + ], |
| + "XcodeAccess": "sandboxed", |
| + "Settings": { |
| + "autoDreamEnabled": false, |
| + "autoMemoryEnabled": false, |
| + "disableAllHooks": true, |
| + "enabledPlugins": { |
| + "agents-md@builtin": false, |
| + "plugin-authoring@builtin": false |
| + }, |
| + "env": { |
| + "MCP_TOOL_TIMEOUT": "600000" |
| + }, |
| + "permissions": { |
| + "allow": [ |
| + "mcp__equipo__submit_candidate", |
| + "mcp__equipo__ask_person", |
| + "mcp__equipo__submit_render" |
| + ], |
| + "ask": [ |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)" |
| + ], |
| + "deny": [ |
| + "Read(//Users/Shared)", |
| + "Read(//Users/Shared/**)", |
| + "Write(//Users/Shared)", |
| + "Write(//Users/Shared/**)", |
| + "Edit(//Users/Shared)", |
| + "Edit(//Users/Shared/**)", |
| + "Glob(//Users/Shared)", |
| + "Glob(//Users/Shared/**)", |
| + "Grep(//Users/Shared)", |
| + "Grep(//Users/Shared/**)", |
| + "Read(//Users/equipo-paul/.aws)", |
| + "Read(//Users/equipo-paul/.aws/**)", |
| + "Write(//Users/equipo-paul/.aws)", |
| + "Write(//Users/equipo-paul/.aws/**)", |
| + "Edit(//Users/equipo-paul/.aws)", |
| + "Edit(//Users/equipo-paul/.aws/**)", |
| + "Glob(//Users/equipo-paul/.aws)", |
| + "Glob(//Users/equipo-paul/.aws/**)", |
| + "Grep(//Users/equipo-paul/.aws)", |
| + "Grep(//Users/equipo-paul/.aws/**)", |
| + "Read(//Users/equipo-paul/.config/op)", |
| + "Read(//Users/equipo-paul/.config/op/**)", |
| + "Write(//Users/equipo-paul/.config/op)", |
| + "Write(//Users/equipo-paul/.config/op/**)", |
| + "Edit(//Users/equipo-paul/.config/op)", |
| + "Edit(//Users/equipo-paul/.config/op/**)", |
| + "Glob(//Users/equipo-paul/.config/op)", |
| + "Glob(//Users/equipo-paul/.config/op/**)", |
| + "Grep(//Users/equipo-paul/.config/op)", |
| + "Grep(//Users/equipo-paul/.config/op/**)", |
| + "Read(//Users/equipo-paul/.gnupg)", |
| + "Read(//Users/equipo-paul/.gnupg/**)", |
| + "Write(//Users/equipo-paul/.gnupg)", |
| + "Write(//Users/equipo-paul/.gnupg/**)", |
| + "Edit(//Users/equipo-paul/.gnupg)", |
| + "Edit(//Users/equipo-paul/.gnupg/**)", |
| + "Glob(//Users/equipo-paul/.gnupg)", |
| + "Glob(//Users/equipo-paul/.gnupg/**)", |
| + "Grep(//Users/equipo-paul/.gnupg)", |
| + "Grep(//Users/equipo-paul/.gnupg/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Read(//Users/equipo-paul/.ssh)", |
| + "Read(//Users/equipo-paul/.ssh/**)", |
| + "Write(//Users/equipo-paul/.ssh)", |
| + "Write(//Users/equipo-paul/.ssh/**)", |
| + "Edit(//Users/equipo-paul/.ssh)", |
| + "Edit(//Users/equipo-paul/.ssh/**)", |
| + "Glob(//Users/equipo-paul/.ssh)", |
| + "Glob(//Users/equipo-paul/.ssh/**)", |
| + "Grep(//Users/equipo-paul/.ssh)", |
| + "Grep(//Users/equipo-paul/.ssh/**)", |
| + "Read(//Users/equipo-paul/Library/Keychains)", |
| + "Read(//Users/equipo-paul/Library/Keychains/**)", |
| + "Write(//Users/equipo-paul/Library/Keychains)", |
| + "Write(//Users/equipo-paul/Library/Keychains/**)", |
| + "Edit(//Users/equipo-paul/Library/Keychains)", |
| + "Edit(//Users/equipo-paul/Library/Keychains/**)", |
| + "Glob(//Users/equipo-paul/Library/Keychains)", |
| + "Glob(//Users/equipo-paul/Library/Keychains/**)", |
| + "Grep(//Users/equipo-paul/Library/Keychains)", |
| + "Grep(//Users/equipo-paul/Library/Keychains/**)", |
| + "Read(//Users/paul)", |
| + "Read(//Users/paul/**)", |
| + "Write(//Users/paul)", |
| + "Write(//Users/paul/**)", |
| + "Edit(//Users/paul)", |
| + "Edit(//Users/paul/**)", |
| + "Glob(//Users/paul)", |
| + "Glob(//Users/paul/**)", |
| + "Grep(//Users/paul)", |
| + "Grep(//Users/paul/**)", |
| + "Read(//Volumes)", |
| + "Read(//Volumes/**)", |
| + "Write(//Volumes)", |
| + "Write(//Volumes/**)", |
| + "Edit(//Volumes)", |
| + "Edit(//Volumes/**)", |
| + "Glob(//Volumes)", |
| + "Glob(//Volumes/**)", |
| + "Grep(//Volumes)", |
| + "Grep(//Volumes/**)" |
| + ] |
| + }, |
| + "sandbox": { |
| + "allowUnsandboxedCommands": false, |
| + "autoAllowBashIfSandboxed": true, |
| + "enabled": true, |
| + "excludedCommands": [], |
| + "failIfUnavailable": true, |
| + "filesystem": { |
| + "allowWrite": [ |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1/DerivedData", |
| + "/private/var/folders/4m/abc123_def/T", |
| + "/Users/equipo-paul/Library/Developer/Xcode/DerivedData", |
| + "/Users/equipo-paul/Library/Caches/org.swift.swiftpm", |
| + "/Users/equipo-paul/Library/org.swift.swiftpm" |
| + ], |
| + "denyRead": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ], |
| + "denyWrite": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/lib/equipo-runner", |
| + "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ] |
| + }, |
| + "network": { |
| + "allowAllUnixSockets": false, |
| + "allowLocalBinding": false, |
| + "allowMachLookup": [ |
| + "com.apple.CoreSimulator.*", |
| + "com.apple.dt.*", |
| + "com.apple.testmanagerd*", |
| + "com.apple.coresymbolicationd" |
| + ], |
| + "allowUnixSockets": [], |
| + "allowedDomains": [], |
| + "strictAllowlist": true |
| + } |
| + } |
| + }, |
| + "MCP": { |
| + "mcpServers": { |
| + "equipo": { |
| + "type": "stdio", |
| + "command": "/Users/equipo-paul/.local/lib/equipo-runner/equipo-runner", |
| + "args": [ |
| + "tool-proxy", |
| + "--socket", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t/1234567890/s" |
| + ] |
| + } |
| + } |
| + }, |
| + "ThreadPolicy": { |
| + "specialist": "Engineering", |
| + "model": "claude-haiku-5-5", |
| + "start": "session-id", |
| + "resume": "resume" |
| + }, |
| + "TurnPolicy": {} |
| +} |
diff --git a/internal/runner/mac/testdata/engineering-2026-11-28-implement.json b/internal/runner/mac/testdata/engineering-2026-11-28-implement.json| new file mode 100644 |
| index 00000000..c0253360 |
| --- /dev/null |
| +++ b/internal/runner/mac/testdata/engineering-2026-11-28-implement.json |
| @@ -0,0 +1,340 @@ |
| +{ |
| + "Version": "darwin-engineering-1", |
| + "Platform": "darwin", |
| + "WorkspaceRoot": "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "Action": "implement", |
| + "ProviderVersion": "2.1.312", |
| + "CLI": "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312/claude", |
| + "CLIDigest": "6b5ec691195e551b02c41df9f7d723f4ea61eaa03c2df90acefe3736f1aeb620", |
| + "Argv": [ |
| + "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312/claude", |
| + "-p", |
| + "--verbose", |
| + "--include-hook-events", |
| + "--input-format", |
| + "stream-json", |
| + "--output-format", |
| + "stream-json", |
| + "--model", |
| + "claude-haiku-5-5", |
| + "--setting-sources", |
| + "", |
| + "--disable-slash-commands", |
| + "--strict-mcp-config", |
| + "--mcp-config", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/equipo-mcp.json", |
| + "--settings", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/equipo-settings.json", |
| + "--permission-mode", |
| + "manual", |
| + "--permission-prompt-tool", |
| + "mcp__equipo__permission", |
| + "--tools", |
| + "Bash,Read,Write,Edit,Glob,Grep", |
| + "--session-id", |
| + "00000000-0000-4000-8000-000000000001" |
| + ], |
| + "Env": { |
| + "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", |
| + "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR": "3", |
| + "CLAUDE_CODE_PROJECT_DIR_NAME": "-workspace", |
| + "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB": "1", |
| + "CLAUDE_CONFIG_DIR": "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "DEVELOPER_DIR": "/Applications/Xcode.app/Contents/Developer", |
| + "DISABLE_AUTOUPDATER": "1", |
| + "EQUIPO_ATTEMPT": "attempt-7f3a", |
| + "HOME": "/Users/equipo-paul", |
| + "LANG": "en_US.UTF-8", |
| + "PATH": "/usr/bin:/bin:/usr/sbin:/sbin", |
| + "TMPDIR": "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1" |
| + }, |
| + "Workspace": "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "Scratch": "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1", |
| + "CredentialHome": "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "ConfigDir": "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "DeniedPaths": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ], |
| + "Tools": [ |
| + "Bash", |
| + "Read", |
| + "Write", |
| + "Edit", |
| + "Glob", |
| + "Grep", |
| + "mcp__equipo__permission", |
| + "mcp__equipo__submit_candidate", |
| + "mcp__equipo__ask_person", |
| + "mcp__equipo__submit_render" |
| + ], |
| + "XcodeAccess": "", |
| + "Settings": { |
| + "autoDreamEnabled": false, |
| + "autoMemoryEnabled": false, |
| + "disableAllHooks": true, |
| + "enabledPlugins": { |
| + "agents-md@builtin": false, |
| + "plugin-authoring@builtin": false |
| + }, |
| + "env": { |
| + "MCP_TOOL_TIMEOUT": "600000" |
| + }, |
| + "permissions": { |
| + "allow": [ |
| + "mcp__equipo__submit_candidate", |
| + "mcp__equipo__ask_person", |
| + "mcp__equipo__submit_render" |
| + ], |
| + "ask": [ |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree/**)" |
| + ], |
| + "deny": [ |
| + "Read(//Users/Shared)", |
| + "Read(//Users/Shared/**)", |
| + "Write(//Users/Shared)", |
| + "Write(//Users/Shared/**)", |
| + "Edit(//Users/Shared)", |
| + "Edit(//Users/Shared/**)", |
| + "Glob(//Users/Shared)", |
| + "Glob(//Users/Shared/**)", |
| + "Grep(//Users/Shared)", |
| + "Grep(//Users/Shared/**)", |
| + "Read(//Users/equipo-paul/.aws)", |
| + "Read(//Users/equipo-paul/.aws/**)", |
| + "Write(//Users/equipo-paul/.aws)", |
| + "Write(//Users/equipo-paul/.aws/**)", |
| + "Edit(//Users/equipo-paul/.aws)", |
| + "Edit(//Users/equipo-paul/.aws/**)", |
| + "Glob(//Users/equipo-paul/.aws)", |
| + "Glob(//Users/equipo-paul/.aws/**)", |
| + "Grep(//Users/equipo-paul/.aws)", |
| + "Grep(//Users/equipo-paul/.aws/**)", |
| + "Read(//Users/equipo-paul/.config/op)", |
| + "Read(//Users/equipo-paul/.config/op/**)", |
| + "Write(//Users/equipo-paul/.config/op)", |
| + "Write(//Users/equipo-paul/.config/op/**)", |
| + "Edit(//Users/equipo-paul/.config/op)", |
| + "Edit(//Users/equipo-paul/.config/op/**)", |
| + "Glob(//Users/equipo-paul/.config/op)", |
| + "Glob(//Users/equipo-paul/.config/op/**)", |
| + "Grep(//Users/equipo-paul/.config/op)", |
| + "Grep(//Users/equipo-paul/.config/op/**)", |
| + "Read(//Users/equipo-paul/.gnupg)", |
| + "Read(//Users/equipo-paul/.gnupg/**)", |
| + "Write(//Users/equipo-paul/.gnupg)", |
| + "Write(//Users/equipo-paul/.gnupg/**)", |
| + "Edit(//Users/equipo-paul/.gnupg)", |
| + "Edit(//Users/equipo-paul/.gnupg/**)", |
| + "Glob(//Users/equipo-paul/.gnupg)", |
| + "Glob(//Users/equipo-paul/.gnupg/**)", |
| + "Grep(//Users/equipo-paul/.gnupg)", |
| + "Grep(//Users/equipo-paul/.gnupg/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/t)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/scratch/t/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/sessions)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/sessions/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Read(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Write(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/state)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo-runner/state/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/**)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Read(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Write(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Edit(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Glob(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/claude-1)", |
| + "Grep(//Users/equipo-paul/.local/share/equipo/accounts/claude-1/**)", |
| + "Read(//Users/equipo-paul/.ssh)", |
| + "Read(//Users/equipo-paul/.ssh/**)", |
| + "Write(//Users/equipo-paul/.ssh)", |
| + "Write(//Users/equipo-paul/.ssh/**)", |
| + "Edit(//Users/equipo-paul/.ssh)", |
| + "Edit(//Users/equipo-paul/.ssh/**)", |
| + "Glob(//Users/equipo-paul/.ssh)", |
| + "Glob(//Users/equipo-paul/.ssh/**)", |
| + "Grep(//Users/equipo-paul/.ssh)", |
| + "Grep(//Users/equipo-paul/.ssh/**)", |
| + "Read(//Users/equipo-paul/Library/Keychains)", |
| + "Read(//Users/equipo-paul/Library/Keychains/**)", |
| + "Write(//Users/equipo-paul/Library/Keychains)", |
| + "Write(//Users/equipo-paul/Library/Keychains/**)", |
| + "Edit(//Users/equipo-paul/Library/Keychains)", |
| + "Edit(//Users/equipo-paul/Library/Keychains/**)", |
| + "Glob(//Users/equipo-paul/Library/Keychains)", |
| + "Glob(//Users/equipo-paul/Library/Keychains/**)", |
| + "Grep(//Users/equipo-paul/Library/Keychains)", |
| + "Grep(//Users/equipo-paul/Library/Keychains/**)", |
| + "Read(//Users/paul)", |
| + "Read(//Users/paul/**)", |
| + "Write(//Users/paul)", |
| + "Write(//Users/paul/**)", |
| + "Edit(//Users/paul)", |
| + "Edit(//Users/paul/**)", |
| + "Glob(//Users/paul)", |
| + "Glob(//Users/paul/**)", |
| + "Grep(//Users/paul)", |
| + "Grep(//Users/paul/**)", |
| + "Read(//Volumes)", |
| + "Read(//Volumes/**)", |
| + "Write(//Volumes)", |
| + "Write(//Volumes/**)", |
| + "Edit(//Volumes)", |
| + "Edit(//Volumes/**)", |
| + "Glob(//Volumes)", |
| + "Glob(//Volumes/**)", |
| + "Grep(//Volumes)", |
| + "Grep(//Volumes/**)" |
| + ] |
| + }, |
| + "sandbox": { |
| + "allowUnsandboxedCommands": false, |
| + "autoAllowBashIfSandboxed": true, |
| + "enabled": true, |
| + "excludedCommands": [], |
| + "failIfUnavailable": true, |
| + "filesystem": { |
| + "allowWrite": [ |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/worker-steps/k/tree", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/policy-1" |
| + ], |
| + "denyRead": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ], |
| + "denyWrite": [ |
| + "/Users/Shared", |
| + "/Users/equipo-paul/.aws", |
| + "/Users/equipo-paul/.config/op", |
| + "/Users/equipo-paul/.gnupg", |
| + "/Users/equipo-paul/.local/lib/equipo-runner", |
| + "/Users/equipo-paul/.local/lib/equipo-runner/tools/claude-2.1.312", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/homes/account-1", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t", |
| + "/Users/equipo-paul/.local/share/equipo-runner/sessions", |
| + "/Users/equipo-paul/.local/share/equipo-runner/state", |
| + "/Users/equipo-paul/.local/share/equipo/accounts", |
| + "/Users/equipo-paul/.local/share/equipo/accounts/claude-1", |
| + "/Users/equipo-paul/.ssh", |
| + "/Users/equipo-paul/Library/Keychains", |
| + "/Users/paul", |
| + "/Volumes" |
| + ] |
| + }, |
| + "network": { |
| + "allowAllUnixSockets": false, |
| + "allowLocalBinding": false, |
| + "allowMachLookup": [], |
| + "allowUnixSockets": [], |
| + "allowedDomains": [], |
| + "strictAllowlist": true |
| + } |
| + } |
| + }, |
| + "MCP": { |
| + "mcpServers": { |
| + "equipo": { |
| + "type": "stdio", |
| + "command": "/Users/equipo-paul/.local/lib/equipo-runner/equipo-runner", |
| + "args": [ |
| + "tool-proxy", |
| + "--socket", |
| + "/Users/equipo-paul/.local/share/equipo-runner/scratch/t/1234567890/s" |
| + ] |
| + } |
| + } |
| + }, |
| + "ThreadPolicy": { |
| + "specialist": "Engineering", |
| + "model": "claude-haiku-5-5", |
| + "start": "session-id", |
| + "resume": "resume" |
| + }, |
| + "TurnPolicy": {} |
| +} |
diff --git a/internal/runner/provider/claude/darwin.go b/internal/runner/provider/claude/darwin.go| new file mode 100644 |
| index 00000000..ebe59bf0 |
| --- /dev/null |
| +++ b/internal/runner/provider/claude/darwin.go |
| @@ -0,0 +1,344 @@ |
| +package claude |
| + |
| +import ( |
| + "bytes" |
| + "crypto/sha256" |
| + "encoding/hex" |
| + "encoding/json" |
| + "maps" |
| + "path/filepath" |
| + "regexp" |
| + "slices" |
| + "sort" |
| + "strconv" |
| + "strings" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +// The darwin launch's certified shape (Mac runners spec §4.4, §8.2; |
| +// slice F task 8). A Mac has no namespace: the pinned CLI runs as the |
| +// runner user, unsandboxed, and only its Bash commands are in Seatbelt |
| +// under the settings below. So this is its own policy, not |
| +// provider.BuildPolicy with the bubblewrap fields faked: the manifest |
| +// names the exact CLI and its digest, argv, settings, MCP config, |
| +// worktree, attempt scratch, denied paths, environment and Xcode access. |
| +// Nothing in it is templated; the launcher regenerates it from the same |
| +// inputs and requires byte equality (ValidateDarwin) before it starts |
| +// anything, as validatePolicy does on Linux. |
| +// |
| +// Settings keys are those the pinned 2.1.312 reads (task 1, S2). Two |
| +// differ from the spec's first reading: an empty allowedDomains asks |
| +// rather than denies, so strictAllowlist is set as well (and the |
| +// permission port denies SandboxNetworkAccess); and |
| +// enableWeakerNestedSandbox is Linux only, so it is not set. |
| + |
| +const ( |
| + // DarwinPolicyVersion names this shape in every darwin manifest. |
| + DarwinPolicyVersion = "darwin-engineering-1" |
| + // DarwinImplement is an Engineering attempt (or a fix or rebase |
| + // round): the shell and the file tools on the worktree. |
| + DarwinImplement = "implement" |
| + // DarwinAnswer asks a step's own session about its work: Read, Glob |
| + // and Grep only, the worktree read-only. |
| + DarwinAnswer = "answer" |
| + // DarwinCheck is the token check (task 10): no native tool, no |
| + // Equipo tool, an empty read-only workspace. |
| + DarwinCheck = "check" |
| + // DarwinTokenFD is the descriptor the token arrives on. The CLI reads |
| + // /dev/fd/<n> named by CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR (task |
| + // 1, S4); the token is never in the environment, where a sandboxed |
| + // command could read it through KERN_PROCARGS2 (R4). |
| + DarwinTokenFD = 3 |
| + // DarwinSettingsFile and DarwinMCPFile are written into the runtime |
| + // copy (CLAUDE_CONFIG_DIR), which no sandboxed command can read or |
| + // write, just before the start. |
| + DarwinSettingsFile = "equipo-settings.json" |
| + DarwinMCPFile = "equipo-mcp.json" |
| + // DarwinPath is the CLI's PATH: only SIP-protected system |
| + // directories. The CLI, unsandboxed and holding the token, resolves |
| + // tools such as security and git through it. |
| + DarwinPath = "/usr/bin:/bin:/usr/sbin:/sbin" |
| + // DarwinLang is the locale every Mac launch uses. |
| + DarwinLang = "en_US.UTF-8" |
| + // DarwinMarkerEnv carries the attempt's marker (spec §5). Its name has |
| + // none of the words the CLI's scrub removes (task 1, S5). |
| + DarwinMarkerEnv = "EQUIPO_ATTEMPT" |
| + // darwinXcodeSandboxed is wire.XcodeAccessSandboxed (wire is not a |
| + // dependency of this package). |
| + darwinXcodeSandboxed = "sandboxed" |
| + darwinTokenFDEnv = "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR" |
| +) |
| + |
| +// DarwinInputs are everything a Mac launch's policy is made from. Every |
| +// path is absolute and clean, as it will be used; the package mac |
| +// adapter (mac.EngineeringPolicy) fills them from the runner's places. |
| +type DarwinInputs struct { |
| + // Action is DarwinImplement, DarwinAnswer or DarwinCheck. The Equipo |
| + // tools are the action's own (provider.Profile); a check has none. |
| + Action, Model string |
| + // CLI is the pinned binary's path, CLIDigest the digest it must have, |
| + // CLIDir its directory, InstallDir the runner's (writes denied). |
| + CLI, CLIDigest, CLIDir, InstallDir string |
| + // Runner is the runner binary, serving MCP in its tool-proxy mode on |
| + // Socket, which lies in ToolRoot (<scratch root>/t). |
| + Runner, ToolRoot, Socket string |
| + // Workspace is the worktree at its real path, Scratch the attempt's |
| + // scratch (TMPDIR), Home the runner user's home (HOME). |
| + Workspace, Scratch, Home string |
| + // ConfigDir is the connection's runtime copy (CLAUDE_CONFIG_DIR), |
| + // inside RuntimeRoot; CredentialHome its dedicated home. |
| + ConfigDir, CredentialHome, RuntimeRoot string |
| + // Denied is the §4.2 list (denylist.DenyList). |
| + Denied []string |
| + // XcodeAccess is "" or "sandboxed". Only sandboxed access has |
| + // XcodeWrites (DerivedData, the user's T, SwiftPM's caches) and Mach |
| + // (the P2-recorded services). |
| + XcodeAccess string |
| + XcodeWrites, Mach []string |
| + // DeveloperDir is xcode-select -p, or "" for none. Attempt is the |
| + // marker. SessionID starts a session, or resumes it with Resume. |
| + DeveloperDir, Attempt, SessionID string |
| + Resume bool |
| +} |
| + |
| +// darwinManifest is the certified record. Its JSON names are the Linux |
| +// manifest's where they mean the same (the permission port and |
| +// ValidateInit read both), and NativeRoots marks it darwin. |
| +type darwinManifest struct { |
| + Version string |
| + NativeRoots |
| + Action, ProviderVersion string |
| + CLI, CLIDigest string |
| + Argv []string |
| + Env map[string]string |
| + Workspace, Scratch string |
| + CredentialHome, ConfigDir string |
| + DeniedPaths, Tools []string |
| + XcodeAccess string |
| + Settings, MCP json.RawMessage |
| + ThreadPolicy, TurnPolicy json.RawMessage |
| +} |
| + |
| +var ( |
| + darwinModel = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._:\[\]-]{0,127}$`) |
| + darwinSession = regexp.MustCompile(`^[A-Za-z0-9-]{1,64}$`) |
| + darwinMarker = regexp.MustCompile(`^[A-Za-z0-9._-]{1,64}$`) |
| + darwinDigest = regexp.MustCompile(`^[0-9a-f]{64}$`) |
| +) |
| + |
| +// darwinLiteral is a path neither the sandbox nor a permission rule can |
| +// read as a pattern: absolute, clean, not /, no glob or control bytes. |
| +func darwinLiteral(p string) bool { |
| + return p != "" && filepath.IsAbs(p) && filepath.Clean(p) == p && p != "/" && !strings.ContainsAny(p, "*?[]{}()\\\n\r\t\x00") |
| +} |
| + |
| +// overlaps: either path is the other or below it, compared as APFS |
| +// compares names (foldedWithin), so it refuses every spelling. |
| +func overlaps(a, b string) bool { return foldedWithin(a, b) || foldedWithin(b, a) } |
| + |
| +// darwinProfile is the native tools and Equipo tools of an action, and |
| +// whether its workspace is read-only. |
| +func darwinProfile(action string) (specialist string, tools []string, readOnly bool, err error) { |
| + switch action { |
| + case DarwinImplement, DarwinAnswer: |
| + p, e := provider.Profile(action) |
| + if e != nil { |
| + return "", nil, false, e |
| + } |
| + return p.Specialist, p.MCPTools(), p.ReadOnly, nil |
| + case DarwinCheck: |
| + return "Coordinator", []string{}, true, nil |
| + } |
| + return "", nil, false, provider.ErrPolicy |
| +} |
| + |
| +// DarwinPolicy is the certified policy of one Mac launch, or |
| +// provider.ErrPolicy when the inputs would not mean what they say: a |
| +// path that is relative, unclean or a pattern; a writable place inside a |
| +// denied one or holding one; a worktree and scratch that overlap; Xcode |
| +// services or writes without sandboxed access. |
| +func DarwinPolicy(in DarwinInputs) (provider.Policy, error) { |
| + specialist, tools, readOnly, err := darwinProfile(in.Action) |
| + if err != nil { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + native, err := nativeTools(specialist) |
| + if err != nil || !darwinModel.MatchString(in.Model) || !darwinSession.MatchString(in.SessionID) || !darwinMarker.MatchString(in.Attempt) || !darwinDigest.MatchString(in.CLIDigest) { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + paths := []string{in.CLI, in.CLIDir, in.InstallDir, in.Runner, in.ToolRoot, in.Socket, in.Workspace, in.Scratch, in.Home, in.ConfigDir, in.CredentialHome, in.RuntimeRoot} |
| + if in.DeveloperDir != "" { |
| + paths = append(paths, in.DeveloperDir) |
| + } |
| + for _, p := range append(append(paths, in.Denied...), in.XcodeWrites...) { |
| + if !darwinLiteral(p) { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + } |
| + if len(in.Denied) == 0 || !within(in.CLIDir, in.CLI) || in.CLIDir == in.CLI || !within(in.ToolRoot, in.Socket) || in.ToolRoot == in.Socket || !within(in.RuntimeRoot, in.ConfigDir) || in.RuntimeRoot == in.ConfigDir || overlaps(in.Workspace, in.Scratch) { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + switch in.XcodeAccess { |
| + case "": |
| + if len(in.XcodeWrites) != 0 || len(in.Mach) != 0 { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + case darwinXcodeSandboxed: |
| + if in.Action != DarwinImplement || len(in.XcodeWrites) == 0 { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + default: |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + for _, m := range in.Mach { |
| + if m == "" || m == "*" || strings.ContainsAny(m, "/ \"\\\n\x00") || strings.Contains(strings.TrimSuffix(m, "*"), "*") { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + } |
| + mcp, err := provider.DarwinToolMCP(in.Runner, in.Socket) |
| + if err != nil { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + |
| + // Denied both ways: §4.2, the connection's homes, the runtime copies |
| + // and the step socket's directory (a sandboxed command is the same |
| + // uid as the CLI: only Seatbelt keeps it off the socket). Writes are |
| + // also denied to the install dir and the pinned CLI's directory: |
| + // macOS execs the CLI by path, after the launcher's last hash. |
| + denyRead := sortedSet(append(slices.Clone(in.Denied), in.CredentialHome, in.ConfigDir, in.RuntimeRoot, in.ToolRoot)) |
| + denyWrite := sortedSet(append(slices.Clone(denyRead), in.InstallDir, in.CLIDir)) |
| + write := []string{in.Workspace, in.Scratch} |
| + if readOnly { |
| + write = []string{in.Scratch} |
| + } |
| + write = append(write, in.XcodeWrites...) |
| + // A writable place inside a denied one would not be writable |
| + // (denyWrite wins), and one holding a denied place would expose it: |
| + // refuse rather than launch something that does not mean its words. |
| + for _, w := range append(slices.Clone(write), in.Workspace) { |
| + for _, d := range denyWrite { |
| + if overlaps(w, d) { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + } |
| + } |
| + if readOnly { |
| + denyWrite = sortedSet(append(denyWrite, in.Workspace)) |
| + } |
| + rules, err := NativeDenyRules(denyRead) |
| + if err != nil { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + ask := []string{} |
| + for _, tool := range native { |
| + if slices.Contains(nativeFileTools, tool) { |
| + ask = append(ask, tool+"(/"+in.Workspace+"/**)") |
| + } |
| + } |
| + mach := append([]string{}, in.Mach...) |
| + settings, err := json.Marshal(map[string]any{ |
| + "env": map[string]string{"MCP_TOOL_TIMEOUT": "600000"}, |
| + "disableAllHooks": true, "enabledPlugins": map[string]any{"agents-md@builtin": false, "plugin-authoring@builtin": false}, "autoMemoryEnabled": false, "autoDreamEnabled": false, |
| + "sandbox": map[string]any{ |
| + "enabled": true, "failIfUnavailable": true, "allowUnsandboxedCommands": false, "autoAllowBashIfSandboxed": true, "excludedCommands": []string{}, |
| + "filesystem": map[string]any{"allowWrite": write, "denyRead": denyRead, "denyWrite": denyWrite}, |
| + "network": map[string]any{"allowedDomains": []string{}, "strictAllowlist": true, "allowUnixSockets": []string{}, "allowAllUnixSockets": false, "allowLocalBinding": false, "allowMachLookup": mach}, |
| + }, |
| + "permissions": map[string]any{"deny": rules, "allow": append([]string{}, tools...), "ask": ask}, |
| + }) |
| + if err != nil { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + |
| + argv := append([]string{in.CLI}, baseArgs(in.Model, strings.Join(native, ","))[1:]...) |
| + for i, a := range argv { |
| + switch a { |
| + case provider.MCPPath: |
| + argv[i] = filepath.Join(in.ConfigDir, DarwinMCPFile) |
| + case provider.SettingsPath: |
| + argv[i] = filepath.Join(in.ConfigDir, DarwinSettingsFile) |
| + } |
| + } |
| + if readOnly { |
| + argv = append(argv, "--include-partial-messages") |
| + } |
| + flag := "--session-id" |
| + if in.Resume { |
| + flag = "--resume" |
| + } |
| + argv = append(argv, flag, in.SessionID) |
| + |
| + // The environment from scratch. CLAUDE_CODE_SUBPROCESS_ENV_SCRUB |
| + // forces permission mode default and turns autoAllowBashIfSandboxed |
| + // off (S5): Bash goes through the permission port, which allows it |
| + // only under these sandbox settings. |
| + env := map[string]string{ |
| + "HOME": in.Home, "CLAUDE_CONFIG_DIR": in.ConfigDir, "TMPDIR": in.Scratch, |
| + "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB": "1", "DISABLE_AUTOUPDATER": "1", "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1", |
| + "PATH": DarwinPath, "LANG": DarwinLang, DarwinMarkerEnv: in.Attempt, |
| + darwinTokenFDEnv: strconv.Itoa(DarwinTokenFD), |
| + } |
| + if in.DeveloperDir != "" { |
| + env["DEVELOPER_DIR"] = in.DeveloperDir |
| + } |
| + PinProjectDir(env) |
| + |
| + thread, _ := json.Marshal(threadPolicy{specialist, in.Model, "session-id", "resume"}) |
| + m := darwinManifest{Version: DarwinPolicyVersion, NativeRoots: NativeRoots{Platform: PlatformDarwin, WorkspaceRoot: in.Workspace}, |
| + Action: in.Action, ProviderVersion: Version, CLI: in.CLI, CLIDigest: in.CLIDigest, Argv: argv, Env: env, |
| + Workspace: in.Workspace, Scratch: in.Scratch, CredentialHome: in.CredentialHome, ConfigDir: in.ConfigDir, |
| + DeniedPaths: denyRead, Tools: append(append(append([]string{}, native...), "mcp__equipo__permission"), tools...), |
| + XcodeAccess: in.XcodeAccess, Settings: settings, MCP: mcp, ThreadPolicy: thread, TurnPolicy: json.RawMessage(`{}`)} |
| + raw, err := json.Marshal(m) |
| + if err != nil || !nonsecretDarwin(settings, mcp) { |
| + return provider.Policy{}, provider.ErrPolicy |
| + } |
| + sum := sha256.Sum256(raw) |
| + hash := hex.EncodeToString(sum[:]) |
| + return provider.Policy{Hash: hash, ManifestHash: hash, Manifest: raw, Env: env, Settings: settings, MCP: mcp, ThreadPolicy: thread, TurnPolicy: json.RawMessage(`{}`)}, nil |
| +} |
| + |
| +// nonsecretDarwin: the generated JSON has no duplicate key (the CLI and |
| +// this check would read one differently). |
| +func nonsecretDarwin(raws ...json.RawMessage) bool { |
| + for _, raw := range raws { |
| + if !uniqueJSON(raw) { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| + |
| +func sortedSet(in []string) []string { |
| + out := slices.Clone(in) |
| + sort.Strings(out) |
| + return slices.Compact(out) |
| +} |
| + |
| +// ValidateDarwin regenerates the policy from in and refuses p on any |
| +// difference, byte for byte: manifest, hashes, settings, MCP, thread and |
| +// turn policies, environment, and no mounts. Call it immediately before |
| +// a launch, with the launcher's own inputs. |
| +func ValidateDarwin(in DarwinInputs, p provider.Policy) error { |
| + want, err := DarwinPolicy(in) |
| + if err != nil { |
| + return err |
| + } |
| + sum := sha256.Sum256(p.Manifest) |
| + if hex.EncodeToString(sum[:]) != p.Hash || p.Hash != want.Hash || p.ManifestHash != want.ManifestHash || p.InstructionHash != "" || len(p.Mounts) != 0 || |
| + !bytes.Equal(p.Manifest, want.Manifest) || !bytes.Equal(p.Settings, want.Settings) || !bytes.Equal(p.MCP, want.MCP) || |
| + !bytes.Equal(p.ThreadPolicy, want.ThreadPolicy) || !bytes.Equal(p.TurnPolicy, want.TurnPolicy) || !maps.Equal(p.Env, want.Env) { |
| + return provider.ErrPolicy |
| + } |
| + return nil |
| +} |
| + |
| +// DarwinArgv is a darwin policy's argv (the CLI's path first), or nil. |
| +func DarwinArgv(p provider.Policy) []string { |
| + var m darwinManifest |
| + if json.Unmarshal(p.Manifest, &m) != nil || m.Version != DarwinPolicyVersion { |
| + return nil |
| + } |
| + return m.Argv |
| +} |