oficina / equipo Public

Fix Claude gitignore validation for restrictive runtime permissions

Co-Authored-By: Astra <noreply@openai.com>
claude bb922d2b04305a26ba5a861caf0c7998d7a9d47d parent ae08731
3 files changed, +304 −23
  • docs/superpowers/plans/CONTROLLER-REPORT-git-ignore-allowance.md +186 −0
  • internal/runner/provider/probe_runtime_test.go +94 −22
  • internal/runner/provider/runtime_claude.go +24 −1

CI failed — run details

diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-git-ignore-allowance.md b/docs/superpowers/plans/CONTROLLER-REPORT-git-ignore-allowance.md
new file mode 100644
index 00000000..687c5df7
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-git-ignore-allowance.md
@@ -0,0 +1,186 @@
+# Git ignore allowance
+
+The fix and coordinator probe proof are complete. Full Engineering and Review
+live proofs remain incomplete at the 40-admission ceiling because the model
+declined the native negative controls.
+
+The failure comes from restrictive file permissions. The failed run used files
+consistent with umask `0077`; the previous passing run used `0002`. Claude
+2.1.312 writes the same 23-byte gitignore under either umask. The old allowance
+required directory mode `0775` and file mode `0664`, so it refused the new
+`0700` directory before inspecting its `0600` file.
+
+## Evidence and change
+
+I compared the read-only evidence in `run-2031427639` and `run-4261561216`
+under `/home/paulca/.local/share/equipo/try/`. Both used Claude executable
+SHA-256 `4f4178ce41d83e23341ebfbaecdbcf8ea6bf7baea0690025abe49eeec3a5d01d`.
+Engineering and Review policy hashes also match between runs. The coordinator
+hash changed after `propose_project` was added, as expected.
+
+The passing run's `repo/.git/config`, `description`, and `info/exclude` have
+mode `0664`; `.git`, `.git/hooks`, and `.claude` have mode `0775`. In the failed
+run the corresponding files have mode `0600` and directories `0700`. Both
+workspaces contain `.claude/.cc-writes`. The saved evidence does not retain the
+runtime gitignore or the launching process's umask, so I reproduced the modes
+with explicit umasks in disposable live runs.
+
+| Umask | Runtime entry | Kind | Mode | Bytes | UID | Links |
+|---|---|---|---|---:|---:|---:|
+| `0002` | `.config/git` | Directory | `0775` | 4096 | 1001 | 2 |
+| `0002` | `.config/git/ignore` | Regular file | `0664` | 23 | 1001 | 1 |
+| `0077` | `.config/git` | Directory | `0700` | 4096 | 1001 | 2 |
+| `0077` | `.config/git/ignore` | Regular file | `0600` | 23 | 1001 | 1 |
+
+Both observed files contain exactly `**/.claude/.cc-writes/\n`, where `\n`
+means one LF byte. Before printing either file I checked for token-like strings
+and credential keywords; none were present. No credential contents were read,
+printed, copied or hashed by the diagnostic harness. Product account leases
+performed their normal credential staging and validation.
+
+The pinned executable's `jJr` implementation writes the global ignore entry
+asynchronously, using `**/` followed by `.claude/.cc-writes/`. It does not set
+an explicit file mode. A live Engineering run with `umask 077` reproduced
+`probes: provider_account_containment: runtime_claude_git_ignore` after the
+first completed Bash probe turn. The observed bytes and size were unchanged.
+
+`runtime_claude.go` now permits only the two observed directory modes and two
+observed file modes. It requires the exact observed bytes, including the final
+newline. A same-size substitute, extra pattern, empty file or missing newline
+is refused. Reading is bounded to 24 bytes. The open refuses symlinks throughout
+the path, verifies the inode against the walk result, and checks the opened
+file's owner, link count, kind, mode and size. Existing provider-version,
+special-file, setuid/setgid and unexpected-child guards remain in force.
+Source-home staging and provider tool policy are unchanged.
+
+`TestDirectLiveCoordinator` did not fail independently in the saved run. Every
+saved coordinator check passed. Its test invokes the shared driver first through
+`sync.Once`; the delegated runner returned exit status 1 for the Engineering
+and Review failures, and every test group received that same error. Production
+`exercise` opens a fresh account lease and runtime home per tuple, closes it
+before the next tuple, and runs the coordinator last.
+
+## Tests and guard checks
+
+Before implementation, this failed because arbitrary 23-byte contents were
+accepted:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/provider -run '^TestClaudeGitIgnoreState$' -count=1
+```
+
+After adding the restrictive-mode regression, the same command failed on
+`private` with `runtime_claude_git_ignore`. Both failures were corrected.
+The final targeted command passed:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/provider -run 'TestClaudeGitIgnore|TestAccountClaudeRuntime|TestAccountCodexRuntimeOwner' -count=1
+```
+
+Temporary Go overlays broke each guard below. Every invocation exited 1 with
+an assertion failure, then the unchanged working-tree implementation was used
+again. The command form was:
+
+```sh
+CGO_ENABLED=0 go test -overlay "$task/<mutation>.json" ./internal/runner/provider -run '<test>' -count=1
+```
+
+| Mutation | Test subcase that caught it |
+|---|---|
+| Compare length instead of contents | `TestClaudeGitIgnoreState/same-size-content` |
+| Remove allowed file-mode check | `TestClaudeGitIgnoreState/mode` |
+| Remove allowed directory-mode check | `TestClaudeGitIgnoreState/directory-mode` |
+| Remove pinned-version check | `TestClaudeGitIgnoreState/version` |
+| Remove inode comparison | `TestClaudeGitIgnoreReadback/replaced` |
+| Allow symlinks during open | `TestClaudeGitIgnoreReadback/symlink` and `parent-symlink` |
+| Remove opened-file metadata check | `TestClaudeGitIgnoreReadback/hardlink` |
+| Remove opened-file mode comparison | `TestClaudeGitIgnoreReadback/mode` |
+| Remove owner check | `TestAccountCodexRuntimeOwner` |
+| Remove link-count check | `TestClaudeGitIgnoreState/hardlink` |
+| Remove setuid/setgid check | `TestClaudeGitIgnoreState/setuid` and `setgid` |
+| Accept an unexpected git-config child | `TestClaudeGitIgnoreState/child` |
+| Accept special files in the walk | `TestClaudeGitIgnoreState/fifo` |
+| Accept symlinks in the walk | `TestClaudeGitIgnoreState/symlink` |
+| Accept a directory as the ignore file | `TestClaudeGitIgnoreState/directory` |
+| Accept a failed open | `TestClaudeGitIgnoreReadback/missing` |
+
+## Live runs
+
+All launches were sequential, using only `claude-a`, whose verified binding is
+`paul@tito.io` at `account-1004981892`. The configured `claude-b` identity is
+`paul@keymail.dev`; it was not launched. Other provider homes were not used.
+Bindings, saved setup, previous evidence and runner environment were unchanged.
+Only the permitted executable-path entries were selected from `runner.env`.
+There were no sign-ins, full live gate, certification bundle, release or push.
+The stopped runner service was not started.
+
+The disposable harness used production `driver.exercise`, `CertificationInputs`,
+account leases, launchers, namespace management, journal and tool proxy. A Go
+overlay returned immediately after the production specialist `probes` call;
+coordinator runs used the production fixture and calibration checks. The test
+executable's existing `NamespaceMain` handler supplied the namespace helper.
+The pinned provider binaries and production-built tool proxy were verified.
+The initial attempt with a separately built runner was refused because the
+namespace manager requires the controller executable's identity; no model turn
+was admitted. A second setup attempt lacked the configured binding path and
+also admitted no turn. Both were corrected before the first live model request.
+
+Each run used a new initialized Git workspace and disposable synthetic markers,
+so the harness did not read marker contents from real account homes. Temporary
+observations were printed as would-be checks and deleted, without writing an
+index or certification bundle. Admissions below conservatively count dispatch
+attempts that were refused before reaching the model.
+
+| UTC on 2026-11-06 | Tuple | Debug ID | Admissions | Result |
+|---|---|---|---:|---|
+| 10:25:47–10:25:48 | Engineering | `3968425379` | 0 | Controller executable identity refused |
+| 10:26:09–10:26:09 | Engineering | `3519747751` | 0 | Configured binding path missing |
+| 10:26:37–10:30:26 | Engineering | `1632246206` | 30 | Original modes accepted; model repeatedly declined native negative controls. Stopped the owned namespace during turn 30 to preserve budget; cleanup completed. |
+| 10:31:06–10:31:38 | Engineering | `814281508` | 2 | Restrictive modes reproduced the original gitignore refusal |
+| 10:32:37–10:32:47 | Coordinator | `630303671` | 1 | All 21 would-be checks passed; harness calibration tried to overwrite an existing observation and returned an error |
+| 10:33:55–10:34:06 | Coordinator | `2348183858` | 1 | All 21 would-be checks passed; harness exited 0 |
+| 10:34:19–10:35:30 | Review | `3487763934` | 6 | Fixed allowance accepted restrictive modes across six turns; model declined native negative controls; the remaining admission budget stopped further retries |
+
+The current total is **40 of 40 admissions**, conservatively including the
+second restrictive-run admission refused before a model request. An extension
+was requested, but no additional turns are authorized yet. The coordinator
+proof is complete. Full Engineering and Review probe proofs remain incomplete:
+the model declined native filesystem calls, so their would-be `direct-isolation`
+checks remain `not-certified`. No refusal was relabelled as a passing check.
+Review's final `provider_policy_rejected` came from `reserveRecovery` reaching
+the per-run six-admission cap; it was not another gitignore rejection.
+
+Coordinator would-be checks all passed: account version, exact tool inventory,
+structured question, effective policy, host control sockets, absent host services,
+immutable settings, no hooks/plugins, subscription currency, PID-1 ownership,
+private network, provider frame JSON, settings write denial, and all admission,
+usage and reservation checks. Both specialist attempts printed per-tool results;
+missing native denials remain visible as `declined` or `not-certified`.
+
+## Full gate and handoff
+
+One `make -k ci` invocation exited 0; there were no reruns. Build, vet,
+formatting, staticcheck, govulncheck, gitleaks, source budgets, tests, adapter
+checks, namespace checks, migration check and performance passed. The full test
+step ran 34 packages uncached, with zero failures. Cold boot measured 147 ms
+against 500 ms; all measured screens met the 150 ms budget.
+
+The local gate reported timing overruns, which would fail with `CI` or
+`AMADAN_CI` set. Another `make -k ci` was running concurrently on the shared
+machine. No budget was raised and no timing claim is made for a CI environment.
+
+| Package | Measured | Budget |
+|---|---:|---:|
+| `internal/directlive` | 8m14.430s | 6m |
+| `internal/equipotest` | 5m6.489s | 5m |
+| `internal/runner` | 8m47.223s | 5m30s |
+| `internal/runner/provider` | 21.927s | 15s |
+| `internal/runner/provider/claude` | 50.498s | 45s |
+| `internal/runner/provider/codex` | 42.056s | 35s |
+
+`git diff --check` passed. The task's live namespaces and tuple directories
+were retired. Scratch binaries, overlays and logs were removed from
+`/home/paulca/.cache/tmp/git-ignore-allowance`. No task processes remain, and
+`equipo-runner.service` is still inactive. No copy-review server was started.
+Only the implementation, regression tests and this report are included in the
+commit. The controller owns pushing and any further authorized live proof.
diff --git a/internal/runner/provider/probe_runtime_test.go b/internal/runner/provider/probe_runtime_test.go
index 8b8be7f5..82a32330 100644
--- a/internal/runner/provider/probe_runtime_test.go
+++ b/internal/runner/provider/probe_runtime_test.go
@@ -1,9 +1,13 @@
package provider
import (
+ "errors"
"os"
"path/filepath"
+ "strings"
"testing"
+
+ "golang.org/x/sys/unix"
)
func TestClaudePrivateWriteStaging(t *testing.T) {
@@ -54,44 +58,112 @@ func TestClaudePrivateWriteStaging(t *testing.T) {
}
func TestClaudeGitIgnoreState(t *testing.T) {
- for _, kind := range []string{"observed", "size", "mode", "version", "child", "symlink", "hardlink"} {
+ for _, kind := range []string{"observed", "private", "same-size-content", "empty", "extra-pattern", "missing-newline", "mode", "directory-mode", "version", "child", "symlink", "hardlink", "directory", "fifo", "setuid", "setgid"} {
t.Run(kind, func(t *testing.T) {
l := &AccountLease{source: Binding{Provider: "claude", Expected: Identity{ProviderVersion: ClaudeVersion}}, runtime: t.TempDir()}
- dir := filepath.Join(l.runtime, ".config/git")
- if err := os.MkdirAll(dir, 0775); err != nil {
- t.Fatal(err)
- }
- if err := os.Chmod(dir, 0775); err != nil {
- t.Fatal(err)
+ must := func(err error) {
+ t.Helper()
+ if err != nil {
+ t.Fatal(err)
+ }
}
+ dir := filepath.Join(l.runtime, ".config/git")
+ must(os.MkdirAll(dir, 0775))
+ must(os.Chmod(dir, 0775))
path := filepath.Join(dir, "ignore")
- size := 23
- if kind == "size" {
- size++
- }
- if err := os.WriteFile(path, make([]byte, size), 0664); err != nil {
- t.Fatal(err)
- }
- if err := os.Chmod(path, 0664); err != nil {
- t.Fatal(err)
+ content := "**/.claude/.cc-writes/\n"
+ switch kind {
+ case "same-size-content":
+ content = strings.Repeat("x", len(content))
+ case "empty":
+ content = ""
+ case "extra-pattern":
+ content += "*\n"
+ case "missing-newline":
+ content = strings.TrimSuffix(content, "\n")
}
+ must(os.WriteFile(path, []byte(content), 0664))
+ must(os.Chmod(path, 0664))
switch kind {
+ case "private":
+ must(os.Chmod(dir, 0700))
+ must(os.Chmod(path, 0600))
case "mode":
- os.Chmod(path, 0666)
+ must(os.Chmod(path, 0666))
+ case "directory-mode":
+ must(os.Chmod(dir, 0777))
case "version":
l.source.Expected.ProviderVersion = "other"
case "child":
- os.WriteFile(filepath.Join(dir, "config"), nil, 0600)
+ must(os.WriteFile(filepath.Join(dir, "config"), nil, 0600))
case "symlink":
- os.Remove(path)
- os.Symlink("/workspace/ignore", path)
+ must(os.Remove(path))
+ must(os.Symlink("/workspace/ignore", path))
case "hardlink":
- os.Link(path, filepath.Join(t.TempDir(), "link"))
+ must(os.Link(path, filepath.Join(t.TempDir(), "link")))
+ case "directory":
+ must(os.Remove(path))
+ must(os.Mkdir(path, 0664))
+ case "fifo":
+ must(os.Remove(path))
+ must(unix.Mkfifo(path, 0664))
+ case "setuid":
+ must(os.Chmod(path, 0664|os.ModeSetuid))
+ case "setgid":
+ must(os.Chmod(path, 0664|os.ModeSetgid))
}
err := l.validateRuntimeEntries()
- if (kind == "observed") != (err == nil) {
+ if (kind == "observed" || kind == "private") != (err == nil) {
t.Fatalf("%s: %v", kind, err)
}
+ if err != nil && !errors.Is(err, ErrContainment) {
+ t.Fatalf("wrong refusal: %v", err)
+ }
+ })
+ }
+}
+
+func TestClaudeGitIgnoreReadback(t *testing.T) {
+ for _, change := range []string{"unchanged", "missing", "replaced", "mode", "size", "hardlink", "symlink", "parent-symlink", "unreadable"} {
+ t.Run(change, func(t *testing.T) {
+ must := func(err error) {
+ t.Helper()
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+ l := &AccountLease{runtime: t.TempDir()}
+ dir := filepath.Join(l.runtime, ".config/git")
+ must(os.MkdirAll(dir, 0700))
+ path := filepath.Join(dir, "ignore")
+ content := []byte("**/.claude/.cc-writes/\n")
+ must(os.WriteFile(path, content, 0600))
+ info, err := os.Lstat(path)
+ must(err)
+ switch change {
+ case "missing":
+ must(os.Remove(path))
+ case "replaced":
+ must(os.Rename(path, path+".old"))
+ must(os.WriteFile(path, content, 0600))
+ case "mode":
+ must(os.Chmod(path, 0664))
+ case "size":
+ must(os.WriteFile(path, append(content, '\n'), 0600))
+ case "hardlink":
+ must(os.Link(path, filepath.Join(t.TempDir(), "link")))
+ case "symlink":
+ must(os.Rename(path, path+".old"))
+ must(os.Symlink(path+".old", path))
+ case "parent-symlink":
+ must(os.Rename(dir, dir+".old"))
+ must(os.Symlink(dir+".old", dir))
+ case "unreadable":
+ must(os.Chmod(path, 0000))
+ }
+ if got := l.claudeGitIgnore(info); got != (change == "unchanged") {
+ t.Fatalf("%s accepted=%v", change, got)
+ }
})
}
}
diff --git a/internal/runner/provider/runtime_claude.go b/internal/runner/provider/runtime_claude.go
index 6fefd2d6..f44abd0a 100644
--- a/internal/runner/provider/runtime_claude.go
+++ b/internal/runner/provider/runtime_claude.go
@@ -1,10 +1,13 @@
package provider
import (
+ "io"
"os"
"path/filepath"
"regexp"
"strings"
+
+ "golang.org/x/sys/unix"
)
var claudeRuntimeLog = regexp.MustCompile(`^\.cache/claude-cli-nodejs/-workspace/mcp-logs-equipo/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}-[0-9]{2}-[0-9]{2}-[0-9]{3}Z\.jsonl$`)
@@ -49,7 +52,7 @@ func (l *AccountLease) claudeRuntimeEntry(rel string, info os.FileInfo) (bool, e
return true, accountContainment("runtime_claude_" + category)
}
if rel == ".config/git" || rel == ".config/git/ignore" {
- valid := rel == ".config/git" && info.IsDir() && info.Mode().Perm() == 0775 || rel == ".config/git/ignore" && info.Mode().IsRegular() && info.Mode().Perm() == 0664 && info.Size() == 23
+ valid := rel == ".config/git" && info.IsDir() && (info.Mode().Perm() == 0775 || info.Mode().Perm() == 0700) || rel == ".config/git/ignore" && l.claudeGitIgnore(info)
if !valid {
return true, accountContainment("runtime_claude_git_ignore")
}
@@ -90,6 +93,26 @@ func (l *AccountLease) claudeRuntimeEntry(rel string, info os.FileInfo) (bool, e
return true, nil
}
+func (l *AccountLease) claudeGitIgnore(info os.FileInfo) bool {
+ const observed = "**/.claude/.cc-writes/\n"
+ if !info.Mode().IsRegular() || (info.Mode().Perm() != 0664 && info.Mode().Perm() != 0600) || info.Size() != int64(len(observed)) {
+ return false
+ }
+ path := filepath.Join(l.runtime, ".config/git/ignore")
+ fd, err := unix.Openat2(unix.AT_FDCWD, path, &unix.OpenHow{Flags: unix.O_RDONLY | unix.O_CLOEXEC | unix.O_NONBLOCK, Resolve: unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS})
+ if err != nil {
+ return false
+ }
+ f := os.NewFile(uintptr(fd), path)
+ defer f.Close()
+ opened, err := f.Stat()
+ if err != nil || !os.SameFile(info, opened) || !runtimeEntryMetadata(opened) || !opened.Mode().IsRegular() || opened.Mode().Perm() != info.Mode().Perm() || opened.Size() != info.Size() {
+ return false
+ }
+ raw, err := io.ReadAll(io.LimitReader(f, int64(len(observed)+1)))
+ return err == nil && string(raw) == observed
+}
+
func runtimePolicyEntry(name string) bool {
name = strings.ToLower(name)
switch name {