oficina / equipo Public

Fix pinned provider turn startup and failure diagnostics

Co-Authored-By: Astra <noreply@openai.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 2418dac0a3ed33a9b114cb2b1fdacbf8b03dc3b5 parent 90af662
34 files changed, +977 −59
  • docs/superpowers/plans/CONTROLLER-REPORT-live-turn-failures.md +198 −0
  • internal/directlive/coordinator_fixes_test.go +0 −3
  • internal/directlive/coordinator_inventory.go +0 −3
  • internal/directlive/probes.go +4 −0
  • internal/directlive/readback.go +1 −1
  • internal/directlive/testdata/fake-cli.py +1 −1
  • internal/directlive/turn.go +5 −1
  • internal/release/manifest.json +9 −9
  • internal/runner/containment/egress_test.go +3 −0
  • internal/runner/containment/linux.go +7 −0
  • internal/runner/egress/diagnostics_test.go +25 −0
  • internal/runner/egress/proxy.go +6 −0
  • internal/runner/provider/claude/diagnostics.go +85 −0
  • internal/runner/provider/claude/launcher.go +20 −27
  • internal/runner/provider/claude/launcher_test.go +3 −2
  • internal/runner/provider/claude/live_turn_test.go +90 −0
  • internal/runner/provider/codex/config_readback.go +5 −0
  • internal/runner/provider/codex/disabled_project_test.go +32 −0
  • internal/runner/provider/codex/events.go +16 −0
  • internal/runner/provider/codex/first_turn_test.go +25 −0
  • internal/runner/provider/codex/informational.go +29 −0
  • internal/runner/provider/codex/informational_test.go +43 −0
  • internal/runner/provider/codex/launcher.go +53 −6
  • internal/runner/provider/codex/launcher_test.go +32 −5
  • internal/runner/provider/codex/nested_deny_test.go +41 −0
  • internal/runner/provider/codex/rate_notice_test.go +21 −0
  • internal/runner/provider/codex/resume_usage_test.go +34 −0
  • internal/runner/provider/codex/testdata/coordinator-notices-0.165.0.json +42 −0
  • internal/runner/provider/runtime_claude.go +8 −0
  • internal/runner/provider/runtime_cleanup_test.go +40 −0
  • internal/runner/provider/runtime_codex_turn.go +32 −0
  • internal/runner/provider/runtime_codex_turn_test.go +51 −0
  • internal/runner/provider/runtime_home.go +9 −1
  • scripts/runner-reference-allowlist.json +7 −0

CI passed — run details

diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-live-turn-failures.md b/docs/superpowers/plans/CONTROLLER-REPORT-live-turn-failures.md
new file mode 100644
index 00000000..7f63d880
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-live-turn-failures.md
@@ -0,0 +1,198 @@
+# Live turn failures
+
+Both providers now complete a specialist's first turn and focused sandbox
+probes. Both coordinator fixtures complete their single structured question
+with the exact expected tool inventory. This is debugging evidence, not release
+certification. The full live gate was not run.
+
+## Causes and fixes
+
+The saved run `run-2006336109` identifies Claude's first failure without
+another model call: its `system/init` frame reports `permissionMode: default`
+and omits `mcp__equipo__permission` from the model-visible tools. The launcher
+expected `manual` and counted that callback as a visible tool. It rejected the
+frame and cancelled the process before any assistant response. The caller then
+replaced the reason with `provider_uncertain`.
+
+The launcher still requests manual permissions and uses the same permission
+callback, sandbox settings and exact tool policy. Init validation now requires
+the pinned binary's observed `default` value and exact visible inventory. It
+rejects other modes, missing tools, extra tools and duplicate tools. The direct
+fixture's readback and coordinator inventory use the same observed convention.
+Its specialist probe inventory records the permission callback as non-exposed.
+
+Claude failures now emit a structured terminal payload after process cleanup:
+fixed reason category, last frame category, exit code, signal, stderr category
+and egress-denial count. Unknown measurements remain null. Raw stderr and
+untrusted frame-type text never enter that payload. Policy rejection is retained
+instead of being overwritten by incomplete-turn cleanup. The journal retains
+the event, and the direct driver saves `turn-N-failure.json` before returning an
+error that names it. The egress relay counts rejected CONNECT requests without
+recording their submitted destinations.
+
+Codex's original mount error was caused by redundant denials, rather than a
+missing outer `/dev` mount. Both the earlier nesting probe and production use
+`--dev /dev` and `--proc /proc`. The earlier probe denied an ordinary sentinel;
+it did not combine the production denials. Codex masks `/proc`, then tries to
+mask `/dev/fd`, whose symlink now points into the masked tree. Removing that
+redundant entry exposed a second failure: masking `/tool` read-only before
+creating a child mask for `/tool/equipo.sock`. The policy now denies the parent
+directories. The same protected paths remain inaccessible. A nested bubblewrap
+test reproduces both original mount failures when either child entry returns.
+No device binds, mount propagation changes or sandbox bypasses were needed.
+
+Once those failures were fixed, the live launches exposed these additional
+pinned behaviors:
+
+- Claude writes `.last-cleanup` after a turn. Only that exact 24-byte regular
+ file is accepted, under version 2.1.312.
+- Codex writes a three-byte `.sandbox_migration`, an empty coordination lock,
+ empty UUIDv7 thread locks, and the three `thread_history_1.sqlite` database
+ files. These names, kinds and applicable sizes are checked under 0.165.0;
+ existing owner, hard-link, symlink and policy-file checks still apply.
+- A fresh Codex thread has no rollout to resume before turn 1. The first turn
+ uses the effective policy already verified by `thread/start`, with fresh
+ account/config/source checks. Later turns still reassert and validate the
+ saved thread's policy. Resume requests exclude old turns.
+- Resume emits the completed turn's usage snapshot again. One exact snapshot
+ replay is accepted per resume, compared with the previously observed
+ thread, turn and counters. It is retained in capture but not counted again
+ or assigned to the next turn. Changed snapshots still fail closed.
+- Codex discovers an empty disabled `/workspace/.codex` project layer lazily.
+ Validation accepts one such layer with the exact observed disabled reason.
+ Enabled, nonempty, duplicated or differently located layers remain rejected.
+- Subscription rate-limit notifications have no session ID. They remain in
+ capture and are not projected as session events. Requests and malformed
+ envelopes are rejected. The five exact deprecation notices generated by the
+ coordinator's disabled legacy flags receive the same treatment. Other
+ notices and account-change events remain rejected.
+
+## Live launches
+
+All times below are UTC on 2026-11-05. Only `claude-a` and `codex`, both confirmed
+as `paul@tito.io`, were selected. Their source homes were
+`account-1004981892` and `account-2598223264` under the existing accounts directory.
+The other five homes were not launched or read. The bindings and setup-state
+files were read only. No sign-in or configuration change was performed.
+
+The temporary harness used `CertificationInputs`, production account leases,
+launchers, capture/journal, tool broker, namespace manager and turn dispatch.
+It used the pinned executables and a test executable running the production
+namespace entry point. It did not call a provider CLI with hand-built flags.
+It used synthetic markers in disposable workspaces and staged homes, never
+source-home sentinels. Runtime investigations inspected names, sizes and modes
+only. No credential contents were inspected, printed, copied manually or hashed
+by the harness. Credential staging was performed only by the product lease.
+
+Each row is one sequential tuple invocation, including its production
+preflights. A launched Claude tuple includes auth-status, empty-input dependency
+preflight and session processes; Codex includes preflight and session processes.
+The three setup-only rows started no provider process. The interval bounds all
+subprocess launches for that row. No tuples ran concurrently.
+
+The Calls column charges admissions conservatively, including those rejected
+before a model prompt reached the provider. Its total is **26 of 40**. Sixteen
+turns are directly visible as Claude result frames or Codex turn-start frames;
+additional cancelled or rejected admissions remain charged in the 26.
+
+| UTC interval | Tuple | Debug ID | Calls | Outcome |
+|---|---|---:|---:|---|
+| 07:40:40–07:40:41 | Claude Engineering | 2828611459 | 0 | Harness executable identity check; no provider launch |
+| 07:41:05–07:41:06 | Claude Engineering | 1814237159 | 0 | Harness bindings path correction; no provider launch |
+| 07:41:55–07:42:10 | Claude Engineering | 4019389454 | 3 | Two turns completed; cleanup marker blocked next admission |
+| 07:42:54–07:42:55 | Codex Engineering | 3811154342 | 0 | Binary source-path guard; no provider launch |
+| 07:43:26–07:43:38 | Claude Engineering | 3507904384 | 3 | Reproduced cleanup marker; captured metadata |
+| 07:44:05–07:44:12 | Codex Engineering | 357022885 | 0 | `/dev/fd` fixed; redundant socket mask failed |
+| 07:44:29–07:44:54 | Claude Engineering | 109350906 | 3 | First turn, native Read probes and Bash probes completed |
+| 07:45:26–07:45:34 | Codex Engineering | 1726159049 | 1 | Mounts fixed; runtime thread state rejected |
+| 07:46:25–07:46:31 | Codex Engineering | 3087197226 | 1 | Transient per-thread lock rejected |
+| 07:47:02–07:47:08 | Codex Engineering | 3078603337 | 1 | Captured active lock metadata before shutdown |
+| 07:47:42–07:47:50 | Codex Engineering | 1095714057 | 1 | Premature resume: no rollout found |
+| 07:49:27–07:49:39 | Codex Engineering | 660293223 | 1 | Model answered; unscoped rate notice rejected |
+| 07:51:10–07:51:19 | Codex Engineering | 2991876854 | 2 | Turn 1 completed; thread-history files blocked next admission |
+| 07:51:52–07:51:59 | Codex Engineering | 1455404923 | 1 | Empty disabled project layer rejected |
+| 07:53:12–07:53:23 | Codex Engineering | 4077550212 | 2 | Turn 1 completed; resume usage replay raced with turn 2 |
+| 07:55:03–07:55:35 | Codex Engineering | 2919593894 | 2 | Two turns completed; workspace read succeeded |
+| 07:56:02–07:56:11 | Claude Coordinator | 748372905 | 1 | One question, exact inventory, fixture passed |
+| 07:56:20–07:56:27 | Codex Coordinator | 1600362866 | 1 | Unscoped legacy-flag notices rejected |
+| 07:57:54–07:58:11 | Codex Coordinator | 2683324626 | 1 | One question, exact inventory, fixture passed |
+| 07:59:13–07:59:44 | Codex Engineering | 1870392552 | 2 | First turn and deterministic access probe completed |
+
+Claude's native Read returned the synthetic workspace marker and rejected the
+staged-home marker, `/proc/1/root` and `/dev/fd/0` through configured permission
+rules. Bash read the workspace marker; the staged-home marker was hidden and
+`/proc/1/root` returned permission denied. Its own stdin through `/dev/fd/0`
+was empty, not a denied handle; that is not claimed as a protected-file denial.
+
+Codex initially declined to call tools on paths described as denied. That
+model refusal was not treated as proof. A later real shell call checked
+`os.access(path, os.R_OK)` without reading contents. Its output was:
+
+```text
+/workspace/sentinel True
+/home/runner/equipo-read-sentinel False
+/proc/1/root/home/runner/equipo-read-sentinel False
+/tool/equipo.sock False
+```
+
+These are focused debugging probes, not certification of every tool or account.
+The coordinator runs used the existing fixture line, not a real team operation.
+Temporary captures and fixture observations were removed, with no certification
+bundle, release evidence or installed capability change.
+
+## Tests and guard checks
+
+Every behavior change began with a failing targeted test. Initial failures were:
+`TestPinnedLiveInit` rejected the recorded init; `TestClaudeFailureDiagnostics`
+received opaque failures; `TestEgressDenialCount` had no counter; and
+`TestNestedProcDeny` reproduced the nested mount errors. The cleanup-marker,
+thread-state, first-turn, rate-notice, disabled-project, resume-usage and
+coordinator-notice tests each failed before their corresponding fix.
+
+Targeted commands used `CGO_ENABLED=0 go test <package> -run <test> -count=1`.
+The complete Claude and Codex adapter suites passed after restoration, as did
+the focused provider, relay, containment and coordinator-inventory tests.
+
+For each row below, the listed expression was deliberately broken, the named
+test failed, and the source was restored. The mutation runs all exited 1.
+
+| Broken behavior | Package under `internal/runner/` | Test |
+|---|---|---|
+| Accept other permission modes | `provider/claude` | `TestPinnedLiveInit` |
+| Ignore visible tool inventory | `provider/claude` | `TestPinnedLiveInit` |
+| Emit raw stderr | `provider/claude` | `TestFailurePayloadSanitized` |
+| Stop counting relay denials | `egress` | `TestEgressDenialCount` |
+| Restore redundant `/dev/fd` mask | `provider/codex` | `TestNestedProcDeny` |
+| Restore redundant socket mask | `provider/codex` | `TestNestedProcDeny` |
+| Accept other cleanup-marker sizes | `provider` | `TestClaudeLiveCleanupMarker` |
+| Accept nonempty thread locks | `provider` | `TestCodexLiveThreadState` |
+| Resume a fresh unpersisted thread | `provider/codex` | `TestCodexFirstTurnDoesNotResumeUnpersistedThread` |
+| Accept changed replayed counters | `provider/codex` | `TestCodexResumeUsageSnapshot` |
+| Accept nonempty disabled project config | `provider/codex` | `TestCodexDisabledEmptyProjectLayer` |
+| Accept extra notice parameters | `provider/codex` | `TestPinnedCoordinatorNotices` |
+
+The first `make -k ci` completed with exit 2. Build, vet, formatting,
+staticcheck, govulncheck, gitleaks, size budgets, migration and performance passed.
+The reference scanner found the supplied brief's unclassified runtime reference;
+that exact line was added to its inventory. Nine Codex constructor hashes changed
+with the parent-directory denial fix. Their entries in the release manifest were
+updated, retaining `uncertified` status and empty certification/evidence lists.
+The inventory tests then passed.
+
+The full fake driver also exposed its remaining assumption that Claude's
+permission callback was model-visible. Specialist probes now record that callback
+as non-exposed, matching the launcher and coordinator checks. One unrelated
+`TestReviewUnconfirmedExpiredAccountSignsIn/claude` run returned `account_busy`;
+its isolated rerun passed, without a product change. Local timing notes exceeded
+some package budgets; those notes are not a claim that CI timing limits passed.
+
+The second `make -k ci` passed with exit 0. All 27 test packages passed,
+followed by provider/check-sandbox, namespace and migration checks. Performance
+checks also passed. There were two full gate invocations in total, one initial
+run and one permitted rerun. No checks or timing budgets were weakened.
+
+The final scratch cleanup removed the temporary harness, binaries, logs,
+mutation script and captures from the task-owned directory under `$TMPDIR`.
+No staged account homes, namespace state or debugging processes remained.
+No copy-review server was started. The branch is `live-turn-failures`; no merge,
+default-branch push or deployment was performed.
diff --git a/internal/directlive/coordinator_fixes_test.go b/internal/directlive/coordinator_fixes_test.go
index 17638a0f..0f32b71d 100644
--- a/internal/directlive/coordinator_fixes_test.go
+++ b/internal/directlive/coordinator_fixes_test.go
@@ -22,9 +22,6 @@ func TestCoordinatorInventoryObservation(t *testing.T) {
for _, family := range []string{"claude", "codex"} {
t.Run(family, func(t *testing.T) {
want := provider.ActionProfile{Action: "coordinate"}.MCPTools()
- if family == "claude" {
- want = append(want, "mcp__equipo__permission")
- }
if family == "codex" {
members := []any{}
for _, name := range want {
diff --git a/internal/directlive/coordinator_inventory.go b/internal/directlive/coordinator_inventory.go
index af85e5d6..47d80440 100644
--- a/internal/directlive/coordinator_inventory.go
+++ b/internal/directlive/coordinator_inventory.go
@@ -11,9 +11,6 @@ import (
// fresh thread. Missing observations and later additions both fail closed.
func coordinatorInventory(family, session string, frames [][]byte) bool {
want := provider.ActionProfile{Action: "coordinate"}.MCPTools()
- if family == "claude" {
- want = append(want, "mcp__equipo__permission")
- }
want = append(want, provider.CoordinatorNativeTools(family)...)
slices.Sort(want)
observed := false
diff --git a/internal/directlive/probes.go b/internal/directlive/probes.go
index f140832e..c120f1ac 100644
--- a/internal/directlive/probes.go
+++ b/internal/directlive/probes.go
@@ -66,6 +66,10 @@ func (x *exercise) probes(ctx context.Context, inventory []string) error {
}
}
for _, tool := range inventory {
+ if x.evidence.Provider == "claude" && tool == "mcp__equipo__permission" {
+ x.evidence.Tools = append(x.evidence.Tools, provider.LiveTool{Name: tool, Surface: "mcp", Exposed: false, MissingReason: "pinned permission callback is not model-visible"})
+ continue
+ }
surface := "native"
switch {
case tool == "Bash" || tool == "commandExecution" || tool == "exec_command" || tool == "shell_command":
diff --git a/internal/directlive/readback.go b/internal/directlive/readback.go
index 58b55ed3..2a79c961 100644
--- a/internal/directlive/readback.go
+++ b/internal/directlive/readback.go
@@ -27,7 +27,7 @@ func observedPolicy(frames []json.RawMessage, l provider.Launch) (map[string]boo
continue
}
if l.Selection.Provider == "claude" && frame.Type == "system" && frame.Subtype == "init" {
- checks["effective-policy-readback"] = frame.Version == l.Binding.Expected.ProviderVersion && frame.Model == l.Selection.Model && frame.PermissionMode == "manual"
+ checks["effective-policy-readback"] = frame.Version == l.Binding.Expected.ProviderVersion && frame.Model == l.Selection.Model && frame.PermissionMode == "default"
checks["strict-mcp"] = len(frame.MCP) == 1 && frame.MCP[0].Name == "equipo" && frame.MCP[0].Status == "connected"
// Init exposes plugins and skills but no effective hook settings.
checks["no-hooks-plugins"] = false
diff --git a/internal/directlive/testdata/fake-cli.py b/internal/directlive/testdata/fake-cli.py
index 75a1c883..f796cb43 100644
--- a/internal/directlive/testdata/fake-cli.py
+++ b/internal/directlive/testdata/fake-cli.py
@@ -79,7 +79,7 @@ for line in sys.stdin:
session=req['session_id']
prompt=req['message']['content']
tools=[name for name in sys.argv[sys.argv.index('--tools')+1].split(',') if name]+mcp()
- emit({'type':'system','subtype':'init','session_id':session,'claude_code_version':'2.1.312','model':'fixture-model','permissionMode':'manual','tools':tools,'skills':[],'plugins':[],'mcp_servers':[{'name':'equipo','status':'connected'}]})
+ emit({'type':'system','subtype':'init','session_id':session,'claude_code_version':'2.1.312','model':'fixture-model','permissionMode':'default','tools':[t for t in tools if t!='mcp__equipo__permission'],'skills':[],'plugins':[],'mcp_servers':[{'name':'equipo','status':'connected'}]})
if 'Certification action: native-' in prompt:
allow='native-allow' in prompt
command='printf equipo-cert-'+('allow' if allow else 'deny')
diff --git a/internal/directlive/turn.go b/internal/directlive/turn.go
index 257c55fc..323beeb5 100644
--- a/internal/directlive/turn.go
+++ b/internal/directlive/turn.go
@@ -119,7 +119,11 @@ func (x *exercise) turn(ctx context.Context, prompt string) ([][]byte, error) {
}
}
if ev.Kind == "turn.failed" {
- return frames, fmt.Errorf("turn-%d-ended: %w", x.sequence, provider.ErrUncertain)
+ name := fmt.Sprintf("turn-%d-failure.json", x.sequence)
+ if err = save(x.root, name, runner.RedactJSON(ev.Payload, nil)); err != nil {
+ return frames, err
+ }
+ return frames, fmt.Errorf("turn-%d-ended (%s): %w", x.sequence, name, provider.ErrUncertain)
}
if ev.Kind == "turn.completed" {
sample := provider.LiveUsage{Complete: usage != nil}
diff --git a/internal/release/manifest.json b/internal/release/manifest.json
index b76c9476..600b4294 100644
--- a/internal/release/manifest.json
+++ b/internal/release/manifest.json
@@ -66,49 +66,49 @@
{
"provider": "codex",
"action": "reproduce",
- "inventory_hash": "fcccaa4a16a4610b336d952a40fb39a38bf475a0534e8635d681fd4bf61f2e59",
+ "inventory_hash": "3e654f4d3338c79a06bee1ed52a08dafbac6c77c8733cf80e8efca0601ec2d94",
"status": "uncertified"
},
{
"provider": "codex",
"action": "scope",
- "inventory_hash": "6c4c841c3a982197fd4ddd96b09accfb95bb9bcac8ea033cad74e29fc678b401",
+ "inventory_hash": "ab2df060065ea0fb5b3799863acb21678c35399971bc6057b3ffc215fe36a432",
"status": "uncertified"
},
{
"provider": "codex",
"action": "recommend",
- "inventory_hash": "adeaf002bbe057c8cdff6f936e88736c36515ce0e355c4bd6e54d63a573553b1",
+ "inventory_hash": "65a09644dbe645f524a473896f42797b811b258039277f40bbfe552169fbb386",
"status": "uncertified"
},
{
"provider": "codex",
"action": "investigate",
- "inventory_hash": "364020e8babe87c13b852afe97ca464b3cf232931c7c9fbe207f6a38d05ef939",
+ "inventory_hash": "6243fcd151a57c60ff3471f1d72ea2b130e3152ab62ebd6c5bbe45dee705ca29",
"status": "uncertified"
},
{
"provider": "codex",
"action": "implement",
- "inventory_hash": "a1f288e532bb1a05e0c3609a70420dd6e7b5349f15c2cdf4110c93caa3c19ffa",
+ "inventory_hash": "b97f5901d7a1d6acd84401165b32a1e01667f88bda610bf415c955bccc371135",
"status": "uncertified"
},
{
"provider": "codex",
"action": "copy",
- "inventory_hash": "ef5c28d89cf4ef559c9e8bfd20b999354b82adcca8ff3d5f1583b7e30e012d95",
+ "inventory_hash": "58dc40125799612f0fc50ff163207afabc59b9f52e0e0db61e0981fab3fc5b77",
"status": "uncertified"
},
{
"provider": "codex",
"action": "design",
- "inventory_hash": "dbcbec44e32f70af2b3d1d5e0f9bc67d2dabb0bbe6169de64a9f7f452985b291",
+ "inventory_hash": "e70408c880c8fab939b7fcd1c9fd5abfe715fc67d61b5d78c93d6f1ee69f865f",
"status": "uncertified"
},
{
"provider": "codex",
"action": "review",
- "inventory_hash": "aee076046a446421909429f32973146fe5eb58c89543056d39853f454845ded7",
+ "inventory_hash": "03a3803ca109d3322ba93e330b41f8181735971fa07a44ae93da271a610463fc",
"status": "uncertified"
},
{
@@ -120,7 +120,7 @@
{
"provider": "codex",
"action": "coordinate",
- "inventory_hash": "3d39700c840ac70165dbc94ec9438cf68503f382321c3ab2ac68206a96c36045",
+ "inventory_hash": "597e67b75161d6890e04df083a4e770bb44df9ccfded6678a901391aa399eb5a",
"status": "uncertified"
}
]
diff --git a/internal/runner/containment/egress_test.go b/internal/runner/containment/egress_test.go
index b11afe04..1a706e23 100644
--- a/internal/runner/containment/egress_test.go
+++ b/internal/runner/containment/egress_test.go
@@ -119,6 +119,9 @@ except OSError:
errout, _ := io.ReadAll(p.Stderr())
t.Fatalf("isolation/relay: %q exit=%+v err=%v stderr=%s", b, exit, e, errout)
}
+ if p.(*process).EgressDenials() != 1 {
+ t.Fatal("relay denial absent from process diagnostics")
+ }
}
func TestEgressLongScratchRoot(t *testing.T) {
diff --git a/internal/runner/containment/linux.go b/internal/runner/containment/linux.go
index e79b3811..5e98af16 100644
--- a/internal/runner/containment/linux.go
+++ b/internal/runner/containment/linux.go
@@ -53,6 +53,13 @@ type process struct {
err error
}
+func (p *process) EgressDenials() uint64 {
+ if p.egress == nil {
+ return 0
+ }
+ return p.egress.Denials()
+}
+
func (p *process) Record() Record { return p.record }
func (p *process) Contain(ctx context.Context) error {
if err := p.kill(); err != nil {
diff --git a/internal/runner/egress/diagnostics_test.go b/internal/runner/egress/diagnostics_test.go
new file mode 100644
index 00000000..1abc09ed
--- /dev/null
+++ b/internal/runner/egress/diagnostics_test.go
@@ -0,0 +1,25 @@
+package egress
+
+import (
+ "context"
+ "errors"
+ "net"
+ "net/netip"
+ "testing"
+)
+
+func TestEgressDenialCount(t *testing.T) {
+ p := fixtureProxy(t, []netip.Addr{netip.MustParseAddr("127.0.0.1")}, func(context.Context, string, string) (net.Conn, error) { return nil, errors.New("unexpected dial") })
+ counter, ok := any(p).(interface{ Denials() uint64 })
+ if !ok {
+ t.Fatal("denials unavailable")
+ }
+ if counter.Denials() != 0 {
+ t.Fatal("nonzero initial count")
+ }
+ connect(t, p, request("unknown.example:443"))
+ connect(t, p, request("fixture.example:443"))
+ if counter.Denials() != 2 {
+ t.Fatal("denials not recorded", counter.Denials())
+ }
+}
diff --git a/internal/runner/egress/proxy.go b/internal/runner/egress/proxy.go
index a19c0f89..61c1d8a3 100644
--- a/internal/runner/egress/proxy.go
+++ b/internal/runner/egress/proxy.go
@@ -13,6 +13,7 @@ import (
"strconv"
"strings"
"sync"
+ "sync/atomic"
"time"
"golang.org/x/sys/unix"
@@ -45,6 +46,7 @@ func defaults() dependencies {
}
type Proxy struct {
+ denials atomic.Uint64
listener net.Listener
directory *os.File
path string
@@ -122,6 +124,8 @@ func open(ctx context.Context, dir string, policy Policy, d dependencies) (*Prox
}()
return p, nil
}
+func (p *Proxy) Denials() uint64 { return p.denials.Load() }
+
func (p *Proxy) SocketPath() string { return p.path }
// Done closes on endpoint loss, cancellation or Close. Owners stop the attempt.
@@ -226,6 +230,7 @@ func (p *Proxy) handle(c net.Conn) {
r := bufio.NewReaderSize(c, MaxHeaders+1)
host, e := authority(r)
if e != nil || !p.hosts[host] {
+ p.denials.Add(1)
io.WriteString(c, "HTTP/1.1 403 Forbidden\r\n\r\n")
return
}
@@ -239,6 +244,7 @@ func (p *Proxy) handle(c net.Conn) {
// Reject the whole answer if any address is unsafe. Never resolve again in Dial.
for _, a := range addresses {
if !publicAddress(a) {
+ p.denials.Add(1)
io.WriteString(c, "HTTP/1.1 403 Forbidden\r\n\r\n")
return
}
diff --git a/internal/runner/provider/claude/diagnostics.go b/internal/runner/provider/claude/diagnostics.go
new file mode 100644
index 00000000..84306f05
--- /dev/null
+++ b/internal/runner/provider/claude/diagnostics.go
@@ -0,0 +1,85 @@
+package claude
+
+import (
+ "encoding/json"
+ "errors"
+ "strings"
+
+ "amadan.net/oficina/equipo/internal/runner/provider"
+)
+
+// Only fixed categories and observed numbers leave this boundary, never stderr text.
+func failurePayload(s *sessionState, last string, exit provider.Exit, waitErr error) json.RawMessage {
+ d := struct {
+ Reason, LastFrame, Stderr string
+ ExitCode, Signal *int
+ EgressDenials *uint64
+ }{Reason: failureReason(s.err), LastFrame: last, Stderr: "unknown"}
+ if waitErr == nil {
+ d.ExitCode = &exit.Code
+ d.Signal = &exit.Signal
+ }
+ if s.capture.Diagnostics != nil {
+ d.Stderr = stderrCategory(s.capture.Diagnostics())
+ }
+ if p, ok := s.process.(interface{ EgressDenials() uint64 }); ok {
+ n := p.EgressDenials()
+ d.EgressDenials = &n
+ }
+ raw, _ := json.Marshal(d)
+ return raw
+}
+
+func failureReason(err error) string {
+ switch {
+ case errors.Is(err, provider.ErrPolicy):
+ return "policy_rejected"
+ case errors.Is(err, provider.ErrIdentity):
+ return "identity_rejected"
+ case errors.Is(err, errProtocol):
+ return "protocol_rejected"
+ case errors.Is(err, errFailed):
+ return "process_or_result_failed"
+ case errors.Is(err, errUncertain):
+ return "incomplete_turn"
+ default:
+ return "capture_or_lifecycle_failed"
+ }
+}
+
+func stderrCategory(s string) string {
+ switch {
+ case s == "":
+ return "empty"
+ case strings.Contains(s, "Sandbox required but unavailable"):
+ return "sandbox_unavailable"
+ case strings.Contains(s, "bwrap:"):
+ return "sandbox_setup_failed"
+ case strings.Contains(s, "403 Forbidden"):
+ return "http_forbidden"
+ case strings.Contains(s, "401 Unauthorized"):
+ return "authentication_failed"
+ case strings.Contains(s, "429"):
+ return "rate_limited"
+ default:
+ return "other"
+ }
+}
+
+func frameCategory(raw []byte) string {
+ var v struct{ Type, Subtype string }
+ if json.Unmarshal(raw, &v) != nil {
+ return "malformed"
+ }
+ switch v.Type {
+ case "system":
+ if v.Subtype == "init" {
+ return "system/init"
+ }
+ return "system/other"
+ case "assistant", "user", "result", "control_request", "control_response":
+ return v.Type
+ default:
+ return "other"
+ }
+}
diff --git a/internal/runner/provider/claude/launcher.go b/internal/runner/provider/claude/launcher.go
index 99447b26..1f11c705 100644
--- a/internal/runner/provider/claude/launcher.go
+++ b/internal/runner/provider/claude/launcher.go
@@ -659,7 +659,7 @@ func (l *Launcher) read(s *sessionState) {
defer close(s.done)
defer close(s.events)
var sequence int64
- reportedFailure := false
+ lastFrame := "none"
for {
select {
case <-s.ctx.Done():
@@ -668,6 +668,7 @@ func (l *Launcher) read(s *sessionState) {
if !ok {
goto finished
}
+ lastFrame = frameCategory(frame.Bytes)
l.mu.Lock()
var events []provider.Event
var e error
@@ -705,55 +706,45 @@ func (l *Launcher) read(s *sessionState) {
}
s.finished = ev.Kind == "turn.completed"
if !s.finished {
- reportedFailure = true
- s.err = errFailed
+ e = errFailed
}
}
}
}
if e != nil {
- reportedFailure = true
s.err = e
s.cancel()
- events = []provider.Event{{SessionID: s.session.ID, TurnID: s.turn.ID, Kind: "turn.failed"}}
}
l.mu.Unlock()
+ if e != nil {
+ goto finished
+ }
for _, ev := range events {
- if e != nil {
- select {
- case s.events <- ev:
- default:
- }
- continue
- }
select {
case s.events <- ev:
case <-s.ctx.Done():
- if e == nil {
- goto finished
- }
+ goto finished
}
}
- if e != nil {
- goto finished
- }
}
}
finished:
+ waitCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
var captureErr error
select {
case captureErr = <-s.capture.Done:
- case <-s.ctx.Done():
- captureErr = s.ctx.Err()
+ case <-waitCtx.Done():
+ captureErr = waitCtx.Err()
}
- waitCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
- defer cancel()
exit, waitErr := s.process.Wait(waitCtx)
l.mu.Lock()
if s.active {
s.lease.EndTurn(context.Background())
s.active = false
- s.err = errUncertain
+ if s.err == nil {
+ s.err = errUncertain
+ }
}
if captureErr != nil || waitErr != nil || exit.Code != 0 || exit.Signal != 0 {
if s.err == nil {
@@ -761,11 +752,12 @@ finished:
}
}
s.clean = s.closed && s.err == nil && s.finished
- failed := s.err != nil && !reportedFailure
+ failed := s.err != nil
+ payload := failurePayload(s, lastFrame, exit, waitErr)
l.mu.Unlock()
if failed {
select {
- case s.events <- provider.Event{SessionID: s.session.ID, TurnID: s.turn.ID, Kind: "turn.failed"}:
+ case s.events <- provider.Event{SessionID: s.session.ID, TurnID: s.turn.ID, Kind: "turn.failed", Payload: payload}:
default:
}
}
@@ -781,7 +773,7 @@ func (l *Launcher) validateInit(s *sessionState, raw []byte) error {
Plugins []struct{ Name, Path, Source string } `json:"plugins"`
Servers []struct{ Name, Status string } `json:"mcp_servers"`
}
- if json.Unmarshal(raw, &v) != nil || v.Version != Version || v.Model != s.session.Model || v.Permission != "manual" || len(v.Skills) != 0 {
+ if json.Unmarshal(raw, &v) != nil || v.Version != Version || v.Model != s.session.Model || v.Permission != "default" || len(v.Skills) != 0 {
return provider.ErrPolicy
}
// These two plugins are bundled into the pinned executable, not loaded homes.
@@ -792,7 +784,8 @@ func (l *Launcher) validateInit(s *sessionState, raw []byte) error {
}
var m manifest
json.Unmarshal(s.launch.Policy.Manifest, &m)
- want := append([]string{}, m.Tools...)
+ // The pinned CLI hides the permission callback from model-visible tools.
+ want := slices.DeleteFunc(slices.Clone(m.Tools), func(tool string) bool { return tool == "mcp__equipo__permission" })
sort.Strings(want)
sort.Strings(v.Tools)
if !reflect.DeepEqual(want, v.Tools) || len(v.Servers) != 1 || v.Servers[0].Name != "equipo" || v.Servers[0].Status != "connected" {
diff --git a/internal/runner/provider/claude/launcher_test.go b/internal/runner/provider/claude/launcher_test.go
index c10766f0..a9dcffa5 100644
--- a/internal/runner/provider/claude/launcher_test.go
+++ b/internal/runner/provider/claude/launcher_test.go
@@ -41,8 +41,8 @@ idx=0
for line in sys.stdin:
v=json.loads(line)
if v['type']!='user': sys.exit(2)
- init={'type':'system','subtype':'init','session_id':sid,'claude_code_version':'2.1.312','model':args[args.index('--model')+1],'permissionMode':'manual','tools':args[args.index('--tools')+1].split(',')+['mcp__equipo__permission'],'mcp_servers':[{'name':'equipo','status':'connected'}],'skills':[],'plugins':[]}
- if os.environ.get('FAKE_TOOLS'): init['tools']=json.loads(os.environ['FAKE_TOOLS'])
+ init={'type':'system','subtype':'init','session_id':sid,'claude_code_version':'2.1.312','model':args[args.index('--model')+1],'permissionMode':'default','tools':args[args.index('--tools')+1].split(',')+['mcp__equipo__permission'],'mcp_servers':[{'name':'equipo','status':'connected'}],'skills':[],'plugins':[]}
+ if os.environ.get('FAKE_TOOLS'): init['tools']=[t for t in json.loads(os.environ['FAKE_TOOLS']) if t!='mcp__equipo__permission']
if os.environ['FAKE_MODE']=='identity': init['session_id']='different'
if os.environ['FAKE_MODE']=='tools': init['tools'].append('WebFetch')
if os.environ['FAKE_MODE']=='plugins': init['plugins']=[{'name':'extra','path':'/untrusted','source':'extra'}]
@@ -198,6 +198,7 @@ func (f *captureFactory) Open(ctx context.Context, p provider.Process, l provide
case frames <- provider.Frame{Sequence: seq, Bytes: b}:
case <-ctx.Done():
close(frames)
+ <-stderrDone
done <- ctx.Err()
return
}
diff --git a/internal/runner/provider/claude/live_turn_test.go b/internal/runner/provider/claude/live_turn_test.go
new file mode 100644
index 00000000..b9906918
--- /dev/null
+++ b/internal/runner/provider/claude/live_turn_test.go
@@ -0,0 +1,90 @@
+package claude
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "slices"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/runner/provider"
+)
+
+func TestPinnedLiveInit(t *testing.T) {
+ for _, role := range []string{"Engineering", "Coordinator"} {
+ t.Run(role, func(t *testing.T) {
+ f := fixtureFor(t, role)
+ tools := slices.DeleteFunc(slices.Clone(f.inputs.Tools), func(s string) bool { return s == "mcp__equipo__permission" })
+ init := map[string]any{"claude_code_version": Version, "model": f.launch.Selection.Model, "permissionMode": "default", "tools": tools, "skills": []string{}, "plugins": []any{}, "mcp_servers": []any{map[string]string{"name": "equipo", "status": "connected"}}}
+ state := &sessionState{launch: f.launch, session: provider.Session{Model: f.launch.Selection.Model}}
+ raw, _ := json.Marshal(init)
+ if err := f.l.validateInit(state, raw); err != nil {
+ t.Fatalf("observed pinned init rejected: %v", err)
+ }
+ for _, mode := range []string{"manual", "bypassPermissions", "acceptEdits", "plan", "auto", ""} {
+ init["permissionMode"] = mode
+ raw, _ = json.Marshal(init)
+ if f.l.validateInit(state, raw) == nil {
+ t.Fatalf("unobserved mode accepted: %q", mode)
+ }
+ }
+ init["permissionMode"] = "default"
+ changes := [][]string{append(slices.Clone(tools), "mcp__equipo__permission"), append(slices.Clone(tools), "WebFetch")}
+ if len(tools) > 0 {
+ changes = append(changes, append(slices.Clone(tools), tools[0]), tools[1:])
+ }
+ for _, changed := range changes {
+ init["tools"] = changed
+ raw, _ = json.Marshal(init)
+ if f.l.validateInit(state, raw) == nil {
+ t.Fatal("changed inventory accepted")
+ }
+ }
+ })
+ }
+}
+
+func TestClaudeFailureDiagnostics(t *testing.T) {
+ for _, mode := range []string{"missing", "tools", "partial", "rate"} {
+ t.Run(mode, func(t *testing.T) {
+ f := fixtureFor(t, "Engineering")
+ f.host.mode = mode
+ s, events := openFixture(t, f)
+ if err := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "failure", AdmissionID: "failure", Prompt: "short"}); err != nil {
+ t.Fatal(err)
+ }
+ for ev := range events {
+ if ev.Kind != "turn.failed" {
+ continue
+ }
+ var d struct {
+ Reason, LastFrame, Stderr string
+ ExitCode, Signal *int
+ EgressDenials *uint64
+ }
+ if json.Unmarshal(ev.Payload, &d) != nil || d.Reason == "" || d.LastFrame == "" || d.Stderr == "" || d.ExitCode == nil || d.Signal == nil {
+ t.Fatalf("opaque failure: %s", ev.Payload)
+ }
+ return
+ }
+ t.Fatal("missing failure")
+ })
+ }
+}
+
+func TestFailurePayloadSanitized(t *testing.T) {
+ for _, text := range []string{"bearer-secret-token", "bwrap: credential-secret", "Sandbox required but unavailable token=secret", "401 Unauthorized secret", "403 Forbidden secret", "429 secret"} {
+ s := &sessionState{err: provider.ErrPolicy, capture: &provider.Capture{Diagnostics: func() string { return text }}}
+ raw := failurePayload(s, "system/init", provider.Exit{Code: 137, Signal: 9}, nil)
+ if bytes.Contains(raw, []byte("secret")) || !bytes.Contains(raw, []byte(`"Reason":"policy_rejected"`)) || !bytes.Contains(raw, []byte(`"Signal":9`)) {
+ t.Fatalf("unsafe or missing diagnostic: %s", raw)
+ }
+ }
+ if frameCategory([]byte(`{"type":"credential-secret"}`)) != "other" {
+ t.Fatal("untrusted frame type escaped")
+ }
+ raw := failurePayload(&sessionState{err: errUncertain, capture: &provider.Capture{}}, "none", provider.Exit{}, context.DeadlineExceeded)
+ if !bytes.Contains(raw, []byte(`"ExitCode":null`)) || !bytes.Contains(raw, []byte(`"EgressDenials":null`)) {
+ t.Fatalf("unknown reported as zero: %s", raw)
+ }
+}
diff --git a/internal/runner/provider/codex/config_readback.go b/internal/runner/provider/codex/config_readback.go
index bd2aace3..00574c73 100644
--- a/internal/runner/provider/codex/config_readback.go
+++ b/internal/runner/provider/codex/config_readback.go
@@ -37,3 +37,8 @@ func effectiveConfigMatches(p provider.Policy, got map[string]json.RawMessage) b
delete(want, "tools")
return configSubset(marshal(want), marshal(got))
}
+
+// The pinned CLI discovers this disabled layer lazily after thread/start.
+func disabledEmptyProject(name, config []byte, reason string) bool {
+ return sameJSON(name, []byte(`{"type":"project","dotCodexFolder":"/workspace/.codex"}`)) && sameJSON(config, []byte(`{}`)) && reason == "To load project-local config, hooks, and exec policies, add /workspace as a trusted project in /home/runner/config.toml."
+}
diff --git a/internal/runner/provider/codex/disabled_project_test.go b/internal/runner/provider/codex/disabled_project_test.go
new file mode 100644
index 00000000..75fd35e0
--- /dev/null
+++ b/internal/runner/provider/codex/disabled_project_test.go
@@ -0,0 +1,32 @@
+package codex
+
+import "testing"
+
+const disabledProjectReason = "To load project-local config, hooks, and exec policies, add /workspace as a trusted project in /home/runner/config.toml."
+
+func TestCodexDisabledEmptyProjectLayer(t *testing.T) {
+ for _, mode := range []string{"observed", "enabled", "config", "path", "reason", "duplicate"} {
+ t.Run(mode, func(t *testing.T) {
+ v, p := liveConfig(t)
+ layer := map[string]any{"name": map[string]any{"type": "project", "dotCodexFolder": "/workspace/.codex"}, "version": "pinned-observation", "config": map[string]any{}, "disabledReason": disabledProjectReason}
+ switch mode {
+ case "enabled":
+ layer["disabledReason"] = nil
+ case "config":
+ layer["config"] = map[string]any{"hooks": true}
+ case "path":
+ layer["name"] = map[string]any{"type": "project", "dotCodexFolder": "/other/.codex"}
+ case "reason":
+ layer["disabledReason"] = "other"
+ }
+ v["layers"] = append(v["layers"].([]any), layer)
+ if mode == "duplicate" {
+ v["layers"] = append(v["layers"].([]any), layer)
+ }
+ err := validateConfig(marshal(v), p)
+ if (err == nil) != (mode == "observed") {
+ t.Fatalf("%s: %v", mode, err)
+ }
+ })
+ }
+}
diff --git a/internal/runner/provider/codex/events.go b/internal/runner/provider/codex/events.go
index 4ee74062..5036a656 100644
--- a/internal/runner/provider/codex/events.go
+++ b/internal/runner/provider/codex/events.go
@@ -50,6 +50,22 @@ func Decode(raw []byte) ([]provider.Event, error) {
if e != nil {
return nil, e
}
+ if v.Method == "deprecationNotice" {
+ if !pinnedDeprecation(v) {
+ return nil, errProtocol
+ }
+ return nil, nil
+ }
+ if v.Method == "account/rateLimits/updated" {
+ var params map[string]json.RawMessage
+ var limits map[string]json.RawMessage
+ if len(v.ID) != 0 || json.Unmarshal(v.Params, &params) != nil || len(params) != 1 || json.Unmarshal(params["rateLimits"], &limits) != nil || limits == nil {
+ return nil, errProtocol
+ }
+ // Global subscription telemetry has no thread or turn to journal as an event.
+ // The durable capture still retains the frame; account/updated stays fenced.
+ return nil, nil
+ }
if v.Method == "" || disabledRemoteControl(v) {
return nil, nil
}
diff --git a/internal/runner/provider/codex/first_turn_test.go b/internal/runner/provider/codex/first_turn_test.go
new file mode 100644
index 00000000..0d68b139
--- /dev/null
+++ b/internal/runner/provider/codex/first_turn_test.go
@@ -0,0 +1,25 @@
+package codex
+
+import (
+ "context"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/runner/provider"
+)
+
+func TestCodexFirstTurnDoesNotResumeUnpersistedThread(t *testing.T) {
+ f := fixtureFor(t)
+ f.host.set("unpersisted")
+ s, events := openFixture(t, f)
+ for _, id := range []string{"first", "second"} {
+ if err := f.l.StartTurn(context.Background(), s, provider.Turn{ID: id, AdmissionID: id, Prompt: "ready"}); err != nil {
+ t.Fatal(err)
+ }
+ if ev := terminal(t, events); ev.Kind != "turn.completed" {
+ t.Fatal(ev)
+ }
+ }
+ if f.host.count("thread/start") != 1 || f.host.count("thread/resume") != 1 || f.host.count("turn/start") != 2 {
+ t.Fatal("thread lifecycle not preserved")
+ }
+}
diff --git a/internal/runner/provider/codex/informational.go b/internal/runner/provider/codex/informational.go
new file mode 100644
index 00000000..fcdb10be
--- /dev/null
+++ b/internal/runner/provider/codex/informational.go
@@ -0,0 +1,29 @@
+package codex
+
+import "encoding/json"
+
+// These notices come from disabled legacy flags in the pinned coordinator policy.
+// Unknown notices and requests still fail closed.
+func pinnedDeprecation(v envelope) bool {
+ if len(v.ID) != 0 {
+ return false
+ }
+ var p map[string]json.RawMessage
+ var summary, details string
+ if json.Unmarshal(v.Params, &p) != nil || len(p) != 2 || json.Unmarshal(p["summary"], &summary) != nil || json.Unmarshal(p["details"], &details) != nil {
+ return false
+ }
+ switch summary {
+ case "`[features].web_search_cached` is deprecated because web search is enabled by default.":
+ return details == "Set `web_search` to `\"live\"`, `\"indexed\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml if you want to override it."
+ case "`[features].web_search_request` is deprecated because web search is enabled by default.":
+ return details == "Set `web_search` to `\"live\"`, `\"indexed\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml if you want to override it."
+ case "`[features].imagegenext` is deprecated. Use `[features].image_generation` instead.":
+ return details == "Enable it with `--enable image_generation` or `[features].image_generation` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details."
+ case "`[features].memory_tool` is deprecated. Use `[features].memories` instead.":
+ return details == "Enable it with `--enable memories` or `[features].memories` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details."
+ case "`[features].web_search` is deprecated because web search is enabled by default.":
+ return details == "Set `web_search` to `\"live\"`, `\"indexed\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml if you want to override it."
+ }
+ return false
+}
diff --git a/internal/runner/provider/codex/informational_test.go b/internal/runner/provider/codex/informational_test.go
new file mode 100644
index 00000000..6e42a457
--- /dev/null
+++ b/internal/runner/provider/codex/informational_test.go
@@ -0,0 +1,43 @@
+package codex
+
+import (
+ "encoding/json"
+ "os"
+ "testing"
+)
+
+func TestPinnedCoordinatorNotices(t *testing.T) {
+ raw, err := os.ReadFile("testdata/coordinator-notices-0.165.0.json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var frames []map[string]any
+ if err = json.Unmarshal(raw, &frames); err != nil {
+ t.Fatal(err)
+ }
+ if len(frames) != 5 {
+ t.Fatal("incomplete fixture")
+ }
+ for _, f := range frames {
+ if ev, err := Decode(marshal(f)); err != nil || len(ev) != 0 {
+ t.Fatalf("pinned notice became session event: %v", err)
+ }
+ for _, field := range []string{"summary", "details", "extra"} {
+ p := f["params"].(map[string]any)
+ before, exists := p[field]
+ p[field] = "unexpected"
+ if _, err := Decode(marshal(f)); err == nil {
+ t.Fatal("unexpected notice accepted", field)
+ }
+ if exists {
+ p[field] = before
+ } else {
+ delete(p, field)
+ }
+ }
+ f["id"] = 1
+ if _, err := Decode(marshal(f)); err == nil {
+ t.Fatal("request suppressed")
+ }
+ }
+}
diff --git a/internal/runner/provider/codex/launcher.go b/internal/runner/provider/codex/launcher.go
index f2a36e8a..5723e39f 100644
--- a/internal/runner/provider/codex/launcher.go
+++ b/internal/runner/provider/codex/launcher.go
@@ -37,6 +37,9 @@ type Launcher struct {
sessions map[string]*sessionState
}
type sessionState struct {
+ resumeUsagePending bool
+ completedProviderTurn string
+ lastUsage, completedUsage json.RawMessage
startupNoticeSeen, turnStarted bool
mcpCalls map[string]json.RawMessage
nativeCalls map[string]json.RawMessage
@@ -122,7 +125,10 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, model string) (p
fs["/workspace"] = "read"
}
}
- for _, path := range append(append([]string{}, in.DeniedPaths...), b.CredentialHome, b.Home, "/home/runner", "/egress", "/tool", "/tool/equipo.sock", "/config", "/proc", "/dev/fd") {
+ // /dev/fd resolves into /proc. Masking that symlink after /proc makes
+ // pinned Codex fail its nested mount setup; the /proc deny covers both.
+ // Likewise /tool already masks equipo.sock before child mounts are applied.
+ for _, path := range append(append([]string{}, in.DeniedPaths...), b.CredentialHome, b.Home, "/home/runner", "/egress", "/tool", "/config", "/proc") {
if !filepath.IsAbs(path) || filepath.Clean(path) != path || path == "/" || path == "/workspace" || path == "/tmp" {
return in, provider.ErrPolicy
}
@@ -358,11 +364,18 @@ func validateConfig(raw []byte, p provider.Policy) error {
if json.Unmarshal(want["mcp_servers"], &expectedMCP) != nil || json.Unmarshal(v.Config["mcp_servers"], &effectiveMCP) != nil || len(expectedMCP) != len(effectiveMCP) {
return provider.ErrPolicy
}
- seenFlags := false
+ seenFlags, seenDisabledProject := false, false
for _, layer := range v.Layers {
- if layer.Version == "" || layer.DisabledReason != nil {
+ if layer.Version == "" {
return provider.ErrPolicy
}
+ if layer.DisabledReason != nil {
+ if seenDisabledProject || !disabledEmptyProject(layer.Name, layer.Config, *layer.DisabledReason) {
+ return provider.ErrPolicy
+ }
+ seenDisabledProject = true
+ continue
+ }
switch {
case sameJSON(layer.Name, []byte(`{"type":"sessionFlags"}`)):
if seenFlags || !sameJSON(layer.Config, p.Settings) {
@@ -525,6 +538,15 @@ func (l *Launcher) Open(ctx context.Context, launch provider.Launch) (provider.S
if e = s.checkReadback(ctx); e != nil {
return fail(e)
}
+ if previous != nil {
+ previous.mu.Lock()
+ s.mu.Lock()
+ s.completedProviderTurn = previous.completedProviderTurn
+ s.completedUsage = bytes.Clone(previous.completedUsage)
+ s.session.ID = launch.ResumeSessionID
+ s.mu.Unlock()
+ previous.mu.Unlock()
+ }
method := "thread/start"
if launch.ResumeSessionID != "" {
method = "thread/resume"
@@ -571,6 +593,11 @@ func (s *sessionState) thread(ctx context.Context, method, id string) (string, e
if e := s.lease.ValidatePolicy(ctx); e != nil {
return "", e
}
+ if method == "thread/resume" {
+ s.mu.Lock()
+ s.resumeUsagePending = len(s.completedUsage) > 0
+ s.mu.Unlock()
+ }
params := threadParams(s.launch.Policy.ThreadPolicy, method, id)
raw, e := s.rpc.Call(ctx, method, marshal(params))
if e != nil {
@@ -633,6 +660,7 @@ func (l *Launcher) StartTurn(ctx context.Context, session provider.Session, t pr
s.op.Lock()
defer s.op.Unlock()
s.mu.Lock()
+ fresh := !s.turnStarted && s.launch.ResumeSessionID == ""
ready := !s.closed && s.err == nil && !s.active && s.attached && t.ID != "" && t.AdmissionID != "" && t.Prompt != "" && !s.used[t.ID] && !s.used[t.AdmissionID]
s.mu.Unlock()
if !ready {
@@ -665,9 +693,12 @@ func (l *Launcher) StartTurn(ctx context.Context, session provider.Session, t pr
if e = s.checkReadback(ctx); e != nil {
return s.stop(e)
}
- // Reassert and observe the saved thread's effective policy without starting work.
- if _, e = s.thread(ctx, "thread/resume", session.ID); e != nil {
- return s.stop(e)
+ // A fresh pinned thread has no rollout until its first turn. Open already
+ // verified its effective policy; later turns must reassert the saved thread.
+ if !fresh {
+ if _, e = s.thread(ctx, "thread/resume", session.ID); e != nil {
+ return s.stop(e)
+ }
}
if e = s.beginTurn(ctx, t); e != nil {
return s.stop(e)
@@ -774,6 +805,16 @@ func (s *sessionState) handle(frame provider.Frame) error {
if ev.SessionID != "" && s.session.ID != "" && ev.SessionID != s.session.ID {
return provider.ErrIdentity
}
+ if ev.Kind == "usage" && ev.TurnID == s.completedProviderTurn && s.completedProviderTurn != "" {
+ if !s.resumeUsagePending || !sameJSON(v.Params, s.completedUsage) {
+ return errProtocol
+ }
+ s.resumeUsagePending = false
+ continue
+ }
+ if ev.Kind == "usage" {
+ s.lastUsage = bytes.Clone(v.Params)
+ }
if ev.TurnID == "" && ev.Kind == "request" {
v, _ := parse(ev.Payload)
if (v.Method == "execCommandApproval" || v.Method == "applyPatchApproval") && s.active && s.providerTurn != "" {
@@ -856,6 +897,10 @@ func (s *sessionState) handle(frame provider.Frame) error {
return e
}
s.finished = ev.Kind == "turn.completed"
+ if s.finished {
+ s.completedProviderTurn = s.providerTurn
+ s.completedUsage = bytes.Clone(s.lastUsage)
+ }
if !s.finished {
s.err = errFailed
}
@@ -920,6 +965,7 @@ func (s *sessionState) beginTurn(ctx context.Context, t provider.Turn) error {
s.finished = false
s.turn = t
s.providerTurn = ""
+ s.lastUsage = nil
s.used[t.ID] = true
s.used[t.AdmissionID] = true
return nil
@@ -953,6 +999,7 @@ func threadParams(policy json.RawMessage, method, id string) map[string]json.Raw
_ = json.Unmarshal(policy, &params)
if method == "thread/resume" {
delete(params, "experimentalRawEvents")
+ params["excludeTurns"] = marshal(true)
params["threadId"] = marshal(id)
}
return params
diff --git a/internal/runner/provider/codex/launcher_test.go b/internal/runner/provider/codex/launcher_test.go
index 9321c8d2..ddf67df4 100644
--- a/internal/runner/provider/codex/launcher_test.go
+++ b/internal/runner/provider/codex/launcher_test.go
@@ -175,6 +175,25 @@ func (h *fakeHost) Start(ctx context.Context, l provider.Launch, args []string)
}
case "thread/start", "thread/resume":
+ if req.Method == "thread/resume" && strings.HasPrefix(mode, "resume-usage") {
+ raw, _ := os.ReadFile("testdata/probe.jsonl")
+ var snapshot map[string]any
+ for _, line := range bytes.Split(bytes.TrimSpace(raw), []byte("\n")) {
+ var frame map[string]any
+ json.Unmarshal(line, &frame)
+ if frame["method"] == "thread/tokenUsage/updated" {
+ snapshot = frame
+ }
+ }
+ if mode == "resume-usage-changed" {
+ snapshot["params"].(map[string]any)["tokenUsage"].(map[string]any)["total"].(map[string]any)["inputTokens"] = 99999
+ }
+ send(snapshot)
+ }
+ if mode == "unpersisted" && req.Method == "thread/resume" && turn == 0 {
+ send(map[string]any{"id": req.ID, "error": map[string]any{"code": -32600, "message": "no rollout found for thread id thread-1"}})
+ continue
+ }
if mode == "turn-race" {
os.WriteFile(filepath.Join(l.Binding.CredentialHome, "auth.json"), []byte(`{"fake":"changed"}`), 0600)
}
@@ -385,7 +404,7 @@ func TestCodexAppServerPolicy(t *testing.T) {
if !bytes.Equal(before, after) {
t.Fatal("interactive config changed")
}
- if f.host.count("thread/resume") != 3 {
+ if f.host.count("thread/resume") != 2 {
t.Fatal("resume not used")
}
f.host.mu.Lock()
@@ -456,7 +475,7 @@ func TestCodexNoLegacyPolicyOverride(t *testing.T) {
var settings map[string]any
json.Unmarshal(in.Settings, &settings)
if strings.HasPrefix(change, "deny-") {
- path := map[string]string{"deny-home": f.launch.Binding.CredentialHome, "deny-egress": "/egress", "deny-tool": "/tool/equipo.sock", "deny-alias": "/alias/login"}[change]
+ path := map[string]string{"deny-home": f.launch.Binding.CredentialHome, "deny-egress": "/egress", "deny-tool": "/tool", "deny-alias": "/alias/login"}[change]
delete(settings["permissions"].(map[string]any)["equipo"].(map[string]any)["filesystem"].(map[string]any), path)
in.Settings, _ = json.Marshal(settings)
} else {
@@ -512,6 +531,10 @@ func TestCodexUnexpectedPolicyChange(t *testing.T) {
t.Parallel()
f := fixtureFor(t)
s, ch := openFixture(t, f)
+ if e := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "initial", AdmissionID: "initial", Prompt: "ready"}); e != nil {
+ t.Fatal(e)
+ }
+ terminal(t, ch)
f.host.set(mode)
if mode == "source-file" {
os.WriteFile(f.inputs.RuntimeFiles[1].Source, []byte("tampered"), 0700)
@@ -760,7 +783,7 @@ func TestCodexPolicyShape(t *testing.T) {
t.Fatal("equipo profile missing")
}
fs := profile["filesystem"].(map[string]any)
- for _, path := range []string{f.launch.Binding.CredentialHome, f.launch.Binding.Home, "/home/runner", "/egress", "/tool", "/tool/equipo.sock", "/config", "/proc", "/dev/fd", "/alias/login", "/private/state"} {
+ for _, path := range []string{f.launch.Binding.CredentialHome, f.launch.Binding.Home, "/home/runner", "/egress", "/tool", "/config", "/proc", "/alias/login", "/private/state"} {
if fs[path] != "deny" {
t.Fatal("missing deny", path)
}
@@ -794,12 +817,16 @@ func TestCodexResumeRechecksLease(t *testing.T) {
func TestCodexTurnRechecksLease(t *testing.T) {
t.Parallel()
f := fixtureFor(t)
- s, _ := openFixture(t, f)
+ s, events := openFixture(t, f)
+ if e := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "initial", AdmissionID: "initial", Prompt: "ready"}); e != nil {
+ t.Fatal(e)
+ }
+ terminal(t, events)
f.host.set("turn-race")
if e := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "t", AdmissionID: "a", Prompt: "hello"}); e == nil {
t.Fatal("turn accepted stale lease")
}
- if f.host.count("turn/start") != 0 {
+ if f.host.count("turn/start") != 1 {
t.Fatal("turn/start sent after source changed")
}
}
diff --git a/internal/runner/provider/codex/nested_deny_test.go b/internal/runner/provider/codex/nested_deny_test.go
new file mode 100644
index 00000000..a8112941
--- /dev/null
+++ b/internal/runner/provider/codex/nested_deny_test.go
@@ -0,0 +1,41 @@
+package codex
+
+import (
+ "encoding/json"
+ "os/exec"
+ "testing"
+)
+
+func TestNestedProcDeny(t *testing.T) {
+ f := fixtureFor(t)
+ var settings struct {
+ Permissions map[string]struct{ Filesystem map[string]string }
+ }
+ if err := json.Unmarshal(f.inputs.Settings, &settings); err != nil {
+ t.Fatal(err)
+ }
+ fs := settings.Permissions["equipo"].Filesystem
+ if fs["/proc"] != "deny" {
+ t.Fatal("proc denial absent")
+ }
+ if fs["/tool"] != "deny" {
+ t.Fatal("tool denial absent")
+ }
+ inner := []string{"/usr/bin/bwrap", "--ro-bind", "/", "/", "--tmpfs", "/proc", "--tmpfs", "/tool", "--remount-ro", "/tool"}
+ if fs["/dev/fd"] == "deny" {
+ inner = append(inner, "--tmpfs", "/dev/fd")
+ }
+ if fs["/tool/equipo.sock"] == "deny" {
+ inner = append(inner, "--ro-bind", "/dev/null", "/tool/equipo.sock")
+ }
+ inner = append(inner, "/usr/bin/python3", "-c", `import os
+assert not os.path.exists('/proc/1/root')
+assert not os.path.exists('/dev/fd/0')
+assert not os.path.exists('/tool/equipo.sock')
+print('nested-denials-ok')`)
+ args := []string{"--unshare-pid", "--die-with-parent", "--ro-bind", "/usr", "/usr", "--symlink", "usr/bin", "/bin", "--symlink", "usr/lib", "/lib", "--symlink", "usr/lib64", "/lib64", "--proc", "/proc", "--dev", "/dev", "--tmpfs", "/tmp", "--dir", "/tool"}
+ out, err := exec.Command("/usr/bin/bwrap", append(args, inner...)...).CombinedOutput()
+ if err != nil {
+ t.Fatalf("nested deny setup failed: %v: %s", err, out)
+ }
+}
diff --git a/internal/runner/provider/codex/rate_notice_test.go b/internal/runner/provider/codex/rate_notice_test.go
new file mode 100644
index 00000000..69d31356
--- /dev/null
+++ b/internal/runner/provider/codex/rate_notice_test.go
@@ -0,0 +1,21 @@
+package codex
+
+import "testing"
+
+func TestCodexRateLimitNotice(t *testing.T) {
+ raw := []byte(`{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","planType":"promax","primary":{"usedPercent":100,"windowDurationMins":10080,"resetsAt":1794297404},"secondary":null,"credits":{"hasCredits":true,"unlimited":false,"balance":"1"}}}}`)
+ events, err := Decode(raw)
+ if err != nil || len(events) != 0 {
+ t.Fatalf("global rate notice became a session event: %+v %v", events, err)
+ }
+ for _, raw := range []string{
+ `{"id":1,"method":"account/rateLimits/updated","params":{"rateLimits":{}}}`,
+ `{"method":"account/rateLimits/updated","params":{"rateLimits":null}}`,
+ `{"method":"account/rateLimits/updated","params":{"rateLimits":{},"threadId":"other"}}`,
+ `{"method":"account/rateLimits/updated","params":{}}`,
+ } {
+ if _, err := Decode([]byte(raw)); err == nil {
+ t.Fatal("unexpected rate notice accepted", raw)
+ }
+ }
+}
diff --git a/internal/runner/provider/codex/resume_usage_test.go b/internal/runner/provider/codex/resume_usage_test.go
new file mode 100644
index 00000000..3f49e1f0
--- /dev/null
+++ b/internal/runner/provider/codex/resume_usage_test.go
@@ -0,0 +1,34 @@
+package codex
+
+import (
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "context"
+ "testing"
+)
+
+func TestCodexResumeUsageSnapshot(t *testing.T) {
+ for _, mode := range []string{"resume-usage", "resume-usage-changed"} {
+ t.Run(mode, func(t *testing.T) {
+ f := fixtureFor(t)
+ s, events := openFixture(t, f)
+ if err := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "first", AdmissionID: "first", Prompt: "ready"}); err != nil {
+ t.Fatal(err)
+ }
+ terminal(t, events)
+ f.host.set(mode)
+ err := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "second", AdmissionID: "second", Prompt: "ready"})
+ if mode == "resume-usage-changed" {
+ if err == nil && terminal(t, events).Kind != "turn.failed" {
+ t.Fatal("changed snapshot accepted")
+ }
+ return
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ if ev := terminal(t, events); ev.Kind != "turn.completed" {
+ t.Fatal(ev)
+ }
+ })
+ }
+}
diff --git a/internal/runner/provider/codex/testdata/coordinator-notices-0.165.0.json b/internal/runner/provider/codex/testdata/coordinator-notices-0.165.0.json
new file mode 100644
index 00000000..059420ca
--- /dev/null
+++ b/internal/runner/provider/codex/testdata/coordinator-notices-0.165.0.json
@@ -0,0 +1,42 @@
+[
+ {
+ "emittedAtMs": 1793865386795,
+ "method": "deprecationNotice",
+ "params": {
+ "details": "Set `web_search` to `\"live\"`, `\"indexed\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml if you want to override it.",
+ "summary": "`[features].web_search_cached` is deprecated because web search is enabled by default."
+ }
+ },
+ {
+ "emittedAtMs": 1793865386795,
+ "method": "deprecationNotice",
+ "params": {
+ "details": "Set `web_search` to `\"live\"`, `\"indexed\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml if you want to override it.",
+ "summary": "`[features].web_search_request` is deprecated because web search is enabled by default."
+ }
+ },
+ {
+ "emittedAtMs": 1793865386795,
+ "method": "deprecationNotice",
+ "params": {
+ "details": "Enable it with `--enable image_generation` or `[features].image_generation` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details.",
+ "summary": "`[features].imagegenext` is deprecated. Use `[features].image_generation` instead."
+ }
+ },
+ {
+ "emittedAtMs": 1793865386795,
+ "method": "deprecationNotice",
+ "params": {
+ "details": "Enable it with `--enable memories` or `[features].memories` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details.",
+ "summary": "`[features].memory_tool` is deprecated. Use `[features].memories` instead."
+ }
+ },
+ {
+ "emittedAtMs": 1793865386795,
+ "method": "deprecationNotice",
+ "params": {
+ "details": "Set `web_search` to `\"live\"`, `\"indexed\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml if you want to override it.",
+ "summary": "`[features].web_search` is deprecated because web search is enabled by default."
+ }
+ }
+]
diff --git a/internal/runner/provider/runtime_claude.go b/internal/runner/provider/runtime_claude.go
index 921deb63..4f02f319 100644
--- a/internal/runner/provider/runtime_claude.go
+++ b/internal/runner/provider/runtime_claude.go
@@ -21,6 +21,8 @@ func (l *AccountLease) claudeRuntimeEntry(rel string, info os.FileInfo) (bool, e
top := strings.SplitN(rel, "/", 2)[0]
category := ""
switch top {
+ case ".last-cleanup":
+ category = "cleanup_marker"
case ".cache":
category = "cache"
case ".config", ".claude":
@@ -43,6 +45,12 @@ func (l *AccountLease) claudeRuntimeEntry(rel string, info os.FileInfo) (bool, e
if l.source.Expected.ProviderVersion != ClaudeVersion {
return true, accountContainment("runtime_claude_" + category)
}
+ if category == "cleanup_marker" {
+ if rel != ".last-cleanup" || !info.Mode().IsRegular() || info.Size() != 24 {
+ return true, accountContainment("runtime_claude_cleanup_marker")
+ }
+ return true, nil
+ }
directory := false
switch rel {
case ".cache", ".cache/claude-cli-nodejs", ".cache/claude-cli-nodejs/-workspace", ".cache/claude-cli-nodejs/-workspace/mcp-logs-equipo", ".config", ".config/anthropic", ".claude", ".claude/ssh", ".npm", ".npm/_logs", "dev-mods", "seed-admin", "shell-snapshots", "session-env":
diff --git a/internal/runner/provider/runtime_cleanup_test.go b/internal/runner/provider/runtime_cleanup_test.go
new file mode 100644
index 00000000..c203b199
--- /dev/null
+++ b/internal/runner/provider/runtime_cleanup_test.go
@@ -0,0 +1,40 @@
+package provider
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+func TestClaudeLiveCleanupMarker(t *testing.T) {
+ l := claudeRuntimeFixture(t)
+ path := filepath.Join(l.runtime, ".last-cleanup")
+ if err := os.WriteFile(path, make([]byte, 24), 0664); err != nil {
+ t.Fatal(err)
+ }
+ if err := l.validateRuntimeEntries(); err != nil {
+ t.Fatalf("observed marker rejected: %v", err)
+ }
+ for _, tc := range []struct {
+ name string
+ size int
+ }{{".last-cleanup", 25}, {".last-cleanup.extra", 24}} {
+ os.Remove(path)
+ p := filepath.Join(l.runtime, tc.name)
+ os.WriteFile(p, make([]byte, tc.size), 0600)
+ if l.validateRuntimeEntries() == nil {
+ t.Fatal("unobserved marker accepted", tc)
+ }
+ os.Remove(p)
+ }
+ os.Mkdir(path, 0700)
+ if l.validateRuntimeEntries() == nil {
+ t.Fatal("marker directory accepted")
+ }
+ os.Remove(path)
+ os.WriteFile(path, make([]byte, 24), 0600)
+ l.source.Expected.ProviderVersion = "other"
+ if l.validateRuntimeEntries() == nil {
+ t.Fatal("other version accepted")
+ }
+}
diff --git a/internal/runner/provider/runtime_codex_turn.go b/internal/runner/provider/runtime_codex_turn.go
new file mode 100644
index 00000000..a7c06980
--- /dev/null
+++ b/internal/runner/provider/runtime_codex_turn.go
@@ -0,0 +1,32 @@
+package provider
+
+import (
+ "os"
+ "regexp"
+)
+
+var codexThreadLock = regexp.MustCompile(`^thread-writer-locks/[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.lock$`)
+
+func codexTurnEntry(rel string, info os.FileInfo) error {
+ if !runtimeEntryMetadata(info) {
+ return accountContainment("runtime_codex_thread_metadata")
+ }
+ if codexThreadLock.MatchString(rel) && info.Mode().IsRegular() && info.Size() == 0 {
+ return nil
+ }
+ switch rel {
+ case ".sandbox_migration":
+ if info.Mode().IsRegular() && info.Size() == 3 {
+ return nil
+ }
+ case "thread-writer-locks":
+ if info.IsDir() {
+ return nil
+ }
+ case "thread-writer-locks/.coordination.lock":
+ if info.Mode().IsRegular() && info.Size() == 0 {
+ return nil
+ }
+ }
+ return accountContainment("runtime_codex_thread_entry")
+}
diff --git a/internal/runner/provider/runtime_codex_turn_test.go b/internal/runner/provider/runtime_codex_turn_test.go
new file mode 100644
index 00000000..662d79be
--- /dev/null
+++ b/internal/runner/provider/runtime_codex_turn_test.go
@@ -0,0 +1,51 @@
+package provider
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+func TestCodexLiveThreadState(t *testing.T) {
+ for _, tc := range []struct {
+ path string
+ size int
+ dir, want bool
+ }{
+ {"thread-writer-locks/01a1aaad-0467-7f31-8540-a9004a8aaae2.lock", 0, false, true},
+ {"thread-writer-locks/01a1aaad-0467-7f31-8540-a9004a8aaae2.lock", 1, false, false},
+ {"thread-writer-locks/NOT-A-UUID.lock", 0, false, false},
+ {"thread_history_1.sqlite", 4096, false, true},
+ {"thread_history_1.sqlite-shm", 32768, false, true},
+ {"thread_history_1.sqlite-wal", 383192, false, true},
+ {"thread_history_1.sqlite", 0, true, false},
+ {"thread_history_1.sqlite-extra", 0, false, false},
+ {".sandbox_migration", 3, false, true}, {"thread-writer-locks", 0, true, true}, {"thread-writer-locks/.coordination.lock", 0, false, true},
+ {".sandbox_migration", 4, false, false}, {".sandbox_migration", 0, true, false}, {"thread-writer-locks", 0, false, false},
+ {"thread-writer-locks/unknown", 0, false, false}, {"thread-writer-locks/.coordination.lock", 1, false, false},
+ } {
+ t.Run(tc.path, func(t *testing.T) {
+ l := &AccountLease{source: Binding{Provider: "codex", Expected: Identity{ProviderVersion: CodexVersion}}, runtime: t.TempDir()}
+ path := filepath.Join(l.runtime, tc.path)
+ if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
+ t.Fatal(err)
+ }
+ var err error
+ if tc.dir {
+ err = os.Mkdir(path, 0700)
+ } else {
+ err = os.WriteFile(path, make([]byte, tc.size), 0600)
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = l.validateRuntimeEntries(); (err == nil) != tc.want {
+ t.Fatalf("want allowed=%v got %v", tc.want, err)
+ }
+ l.source.Expected.ProviderVersion = "other"
+ if l.validateRuntimeEntries() == nil {
+ t.Fatal("other version accepted")
+ }
+ })
+ }
+}
diff --git a/internal/runner/provider/runtime_home.go b/internal/runner/provider/runtime_home.go
index 59212160..8c3174c9 100644
--- a/internal/runner/provider/runtime_home.go
+++ b/internal/runner/provider/runtime_home.go
@@ -72,6 +72,13 @@ func (l *AccountLease) validateRuntimeEntries() error {
}
}
if l.source.Provider == "codex" && l.source.Expected.ProviderVersion == CodexVersion {
+ if top == ".sandbox_migration" || top == "thread-writer-locks" {
+ info, err := d.Info()
+ if err != nil {
+ return entryReason("metadata")
+ }
+ return codexTurnEntry(rel, info)
+ }
scratch := top == ".tmp" || top == "tmp"
if scratch || codexRuntimeState(top) {
info, err := d.Info()
@@ -96,7 +103,8 @@ func codexRuntimeState(name string) bool {
switch name {
case "installation_id", "goals_1.sqlite", "goals_1.sqlite-shm", "goals_1.sqlite-wal",
"memories_1.sqlite", "memories_1.sqlite-shm", "memories_1.sqlite-wal",
- "queue_1.sqlite", "queue_1.sqlite-shm", "queue_1.sqlite-wal":
+ "queue_1.sqlite", "queue_1.sqlite-shm", "queue_1.sqlite-wal",
+ "thread_history_1.sqlite", "thread_history_1.sqlite-shm", "thread_history_1.sqlite-wal":
return true
}
return false
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 10da52e9..2e3245cd 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -7663,5 +7663,12 @@
"match": "npm",
"count": 1,
"reason": "Recorded Claude 2.1.312 runtime cache and log paths, with exact allowances and refusal coverage; no executable dependency is introduced."
+ },
+ {
+ "path": "docs/superpowers/plans/CODEX-BRIEF-live-turn-failures.md",
+ "line_sha256": "324713000487a3ad5e4719cf4db789629ff68efb64d93784af72a1e7030c93a6",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Task authorization or controller evidence for the existing direct provider runtime; no legacy transport is introduced."
}
]