Handle pinned Codex and Claude runtime homes
Co-Authored-By: Astra <noreply@openai.com>
24 files changed,
+2,112
−63
docs/superpowers/plans/CONTROLLER-REPORT-live-open-failures.md+310 −4internal/release/manifest.json+18 −18internal/runner/capture.go+2 −1internal/runner/capture_framing.go+0 −11internal/runner/live_open_test.go+1 −1internal/runner/provider/account_diagnostics_test.go+2 −2internal/runner/provider/claude/auth_framing.go+19 −0internal/runner/provider/claude/auth_framing_test.go+29 −0internal/runner/provider/claude/launcher.go+8 −2internal/runner/provider/claude/launcher_test.go+1 −1internal/runner/provider/claude/runtime_replay_test.go+231 −0internal/runner/provider/codex/config_readback.go+3 −1internal/runner/provider/codex/launcher.go+3 −2internal/runner/provider/codex/runtime_policy_test.go+77 −0internal/runner/provider/codex/runtime_replay_test.go+187 −0internal/runner/provider/codex/testdata/disabled-skills-0.165.0.json+231 −0internal/runner/provider/runtime_claude.go+56 −0internal/runner/provider/runtime_claude_test.go+147 −0internal/runner/provider/runtime_home.go+82 −20internal/runner/provider/runtime_home_test.go+119 −0internal/runner/provider/runtime_links_test.go+126 −0internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json+115 −0internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json+100 −0scripts/runner-reference-allowlist.json+245 −0
CI passed — run details
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-live-open-failures.md b/docs/superpowers/plans/CONTROLLER-REPORT-live-open-failures.md| index d60599b2..e478063a 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-live-open-failures.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-live-open-failures.md |
| @@ -1,9 +1,9 @@ |
| # Live open failures |
| -The Claude auth framing bug, Codex coordinator config mismatch, and guide |
| -path diagnostic are fixed. Codex specialist containment still needs the |
| -next authenticated observation. Its guards remain strict, with reason codes |
| -that distinguish the failing checks. This branch is not live-certified. |
| +The three rounds fix auth framing, config readback and the runtime-home |
| +conflicts reproduced with the pinned providers. Both providers now pass |
| +unauthenticated runtime replays for the specialist and coordinator. The |
| +branch is not live-certified; authenticated behavior remains unobserved. |
| ## Causes and confidence |
| @@ -166,3 +166,309 @@ Do not capture credential, SQLite, or skill contents. Any policy adjustment |
| needs evidence that the particular files cannot introduce tools or settings; |
| the empty-home observation alone does not establish that. No claim is made |
| that the next authenticated run will pass. |
| + |
| +## Round 2 |
| + |
| +The pinned 0.165.0 binary supports `skills.bundled.enabled=false`. Both |
| +specialist and coordinator policies now pass that setting and |
| +`features.memories=false` through their hashed settings, argv and thread |
| +policy. Config readback must retain both values. The runtime validator |
| +still refuses `skills`, including `skills/.system`. |
| + |
| +### Switch evidence |
| + |
| +The probes used only new credential-free homes under the on-disk |
| +`$TMPDIR`, with `bwrap --unshare-all --die-with-parent --new-session`, an |
| +empty environment, and the verified pinned binary. There was no egress |
| +relay, account-home mount, sign-in, thread, turn or live gate. |
| + |
| +`codex --help` and `codex app-server --help` describe `-c`, `--disable` and |
| +`--strict-config`, but no dedicated bundled-skills option. The recorded |
| +round-one `equipo:3` response has `skills:null` and `memories:null`; its |
| +coordinator feature map already has `memories:false`. |
| + |
| +`codex features list` includes `memories` and |
| +`skip_host_skill_discovery`. A probe with the latter enabled still |
| +installed and listed all five bundled skills. That flag is insufficient. |
| +The pinned binary's config type names include `SkillsConfig`, `bundled` |
| +and `BundledSkillsConfig`, which led to the successful strict-config |
| +probe: |
| + |
| +```sh |
| +/opt/codex app-server --strict-config --listen stdio:// \ |
| + -c features.remote_control=false \ |
| + -c skills.bundled.enabled=false -c features.memories=false |
| +``` |
| + |
| +The effective config and session layer both retain the requested values. |
| +`skills/list` with `forceReload:true` returns one workspace with empty |
| +skills and errors arrays. No `skills` directory is created. Direct |
| +responses from `initialize`, `account/read`, `config/read` and |
| +`skills/list` are recorded in |
| +`internal/runner/provider/codex/testdata/disabled-skills-0.165.0.json`. |
| +The account is null. Installation-specific notifications were omitted. |
| +The manifest fallback in D1 is therefore unnecessary. |
| + |
| +### Runtime state |
| + |
| +For Codex 0.165.0 only, the staged-home validator now permits `.tmp` and |
| +`tmp` directories, `installation_id`, and the three named SQLite files |
| +with their `-shm` and `-wal` siblings. Entries must belong to the runner |
| +uid, with no setuid or setgid bits. State entries must be regular files; |
| +regular files with multiple hard links are refused. Nested scratch |
| +entries retain the policy-name and special-file checks. Other versions, |
| +providers and new top-level names do not gain these allowances. |
| +`AccountLease.stage` is unchanged and copies none of these source-home |
| +artifacts. A regression checks that source scratch and state stay out of |
| +the staged home. |
| + |
| +### Replay and remaining decision |
| + |
| +`TestCodexEmptyHomeReplay` invokes the production `Launcher.Open` for |
| +`implement` and `coordinate` with the real pinned executable and code |
| +mode helper. Its test transport uses a network-isolated bubblewrap home |
| +and the existing frame-capture fixture. It skips clearly when the pinned |
| +installation is absent. The source is newly created, with an |
| +`auth_mode:apikey` marker and no key or other credential. An empty JSON |
| +object is unsuitable: Codex interprets it as incomplete ChatGPT auth and |
| +returns a protocol error requiring a plan type. |
| + |
| +Both real opens now return `codex_preflight_probe: |
| +provider_identity_mismatch` from the missing account. Since this occurs |
| +before config readback, a second unauthenticated process checks the same |
| +policy through production `readConfig`. Only after every process exits |
| +does the test mark its synthetic lease ready, solely to run |
| +`ValidatePolicy` against the actual startup tree. No real process runs |
| +with that synthetic identity. |
| + |
| +That final check found another artifact not retained by the graceful |
| +round-one probe: `tmp/arg0-linux/codex-arg0*/apply_patch`, `applypatch` |
| +and `codex-linux-sandbox` are symlinks to `/opt/codex`. They remain after |
| +the launcher's cancellation path. The current validator refuses them |
| +with `runtime_special_entry`. D2 says no escaping symlinks; these leave |
| +the runtime home but target the pinned binary inside the namespace. |
| +Permission to allow only those verified links is pending. The replay |
| +still fails its final runtime check, so this round is not complete. |
| + |
| +### Verification so far |
| + |
| +All Go commands use `CGO_ENABLED=0 GOTOOLCHAIN=go1.26.10` and default caches. |
| +Before implementation, this command failed for all twelve allowed state |
| +entries and for the missing disable settings in both roles: |
| + |
| +```sh |
| +go test ./internal/runner/provider ./internal/runner/provider/codex \ |
| + -run 'TestAccountCodexRuntimeState|TestCodexRuntimeSettings' -count=1 |
| +``` |
| + |
| +Those tests now pass. The complete provider and Codex packages pass with |
| +the unresolved real replay excluded (11.135 seconds and 20.380 seconds): |
| + |
| +```sh |
| +go test ./internal/runner/provider ./internal/runner/provider/codex \ |
| + -skip '^TestCodexEmptyHomeReplay$' -count=1 |
| +``` |
| + |
| +Each guard below was temporarily broken, observed failing by assertion, |
| +and restored before continuing. Commands use `go test`, the package |
| +shown, `-run` with the pattern shown, and `-count=1`. |
| + |
| +| Temporary break | Package and test pattern | |
| +| --- | --- | |
| +| Ignore uid | `./internal/runner/provider -run '^TestAccountCodexRuntimeOwner'` | |
| +| Ignore setuid/setgid | `./internal/runner/provider -run '^TestAccountCodexRuntimeStateGuards/(nested-setuid\|setgid)$'` | |
| +| Accept wrong entry kinds | `./internal/runner/provider -run '^TestAccountCodexRuntimeStateGuards/(scratch-file\|state-directory)$'` | |
| +| Accept hard links | `./internal/runner/provider -run '^TestAccountCodexRuntimeStateGuards/hardlink$'` | |
| +| Remove version restriction | `./internal/runner/provider -run '^TestAccountCodexRuntimeStateGuards/other-version$'` | |
| +| Remove provider restriction | `./internal/runner/provider -run '^TestAccountCodexRuntimeStateGuards/other-provider$'` | |
| +| Allow an unrecorded database name | `./internal/runner/provider -run '^TestAccountCodexRuntimeStateGuards/other-state$'` | |
| +| Accept policy-bearing names | `./internal/runner/provider -run '^TestAccountCodexRuntimeStateGuards/(skills\|nested-policy)$'` | |
| +| Accept special entries | `./internal/runner/provider -run '^TestAccountCodexRuntimeStateGuards/(symlink\|fifo)$'` | |
| +| Ignore effective config mismatch | `./internal/runner/provider/codex -run '^TestCodexRuntimeSettings$'` | |
| +| Enable memories in policy | `./internal/runner/provider/codex -run '^TestCodexRuntimeSettings$'` | |
| +| Enable bundled skills | `./internal/runner/provider/codex -run '^TestCodexEmptyHomeReplay/implement$'` | |
| + |
| +The last mutation made the real replay fail specifically because bundled |
| +skills were installed. Size budgets pass unchanged. The reference |
| +inventory includes the two null JS-path fields in the new config fixture. |
| +The expanded targeted checks also passed for the runner and all provider |
| +packages, selecting the account, Codex, workflow-policy and coordinator |
| +MCP tests, with only the unresolved replay excluded. |
| + |
| +After adding the production `TMPDIR` and `LANG` environment values to the |
| +replay transport, the specialist still failed on the leftover symlinks; |
| +the coordinator passed that run. Their survival depends on cancellation |
| +timing. The full `make -k ci` has not yet run in round 2. Nothing has been |
| +committed or pushed for this round. All temporary mutations are restored, |
| +and this session's scratch and processes have been removed. |
| + |
| +## Round 3 |
| + |
| +E1 resolves round 2's pending decision. Codex 0.165.0 may leave exactly |
| +`tmp/arg0-linux/codex-arg0[A-Za-z0-9]{6}/apply_patch`, `applypatch`, and |
| +`codex-linux-sandbox` as links to `/opt/codex`. This round observed suffixes |
| +`gpkiVb` and `5Tf46c` in the failing specialist and coordinator replays. |
| +The validator uses `Readlink`, never resolves the target, and checks the |
| +link's uid and mode. The containing directories retain the round 2 |
| +metadata guards. The launcher independently verifies the pinned executable |
| +and its namespace mount. Other names, suffix lengths, characters, parents, |
| +targets, owners, providers and versions are refused. Source-home links are |
| +not staged. Both real Codex Opens now reach the missing-account error, and |
| +the resulting runtime trees pass whether cancellation leaves the links or |
| +removes them. |
| + |
| +### Claude observations and fix |
| + |
| +`TestClaudeEmptyHomeReplay` checks the pinned 2.1.312 binary's SHA-256 and |
| +uses the production specialist and coordinator policy, Open, lease and |
| +no-input preflight probe. The test transport runs bubblewrap without any |
| +network or egress relay. It mounts only fresh test homes, a fresh workspace, |
| +read-only runtime files and generated policy. Its capture decodes JSON; |
| +the existing runner capture tests separately exercise production framing. |
| +The tool-proxy mount is an inert fixture: this is not a tool-call test. |
| + |
| +Real Open stops at unauthenticated auth status, with exit 1 and no signal. |
| +It does not reach the full `-p` dependency probe. The replay therefore also |
| +invokes that exact production probe inside the lease's checking callback, |
| +with stdin closed and no prompt. It first substitutes a completely empty |
| +`CLAUDE_CONFIG_DIR`, then runs against the newly staged credential-free |
| +fixture. The full probe exits successfully in both roles. Only after every |
| +real process exits does a synthetic identity callback enable the final |
| +`ValidatePolicy` check. No provider process uses that synthetic identity. |
| + |
| +The baseline probe created `plugins/store/cc-plugin-agents-md_builtin-*.json` |
| +despite `disableAllHooks=true`, an empty `enabledPlugins` object, and |
| +`--disable-slash-commands`. It also created `.cache`, `.claude`, `.config`, |
| +`.npm`, `dev-mods` and `seed-admin`, which were outside the runtime allowlist. |
| +These are reproduced startup conflicts, not guesses about authenticated |
| +sessions. |
| + |
| +The pinned binary contains the `enabledPlugins` setting and the |
| +`agents-md@builtin` alias. Setting that entry to `false` prevents the plugin |
| +directory in both roles. The launcher now sets it, and the replay asserts |
| +the setting and the absence of plugins, skills, agents, commands, shell |
| +snapshots and session env scripts. `--bare` was considered and rejected: |
| +its embedded help says it disables OAuth reads. `--safe-mode` disables MCP |
| +servers while retaining built-in plugins, so it is also unsuitable. |
| + |
| +Names, kinds and modes from the empty-home probes are recorded in |
| +`internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json` |
| +and `claude-empty-home-disabled-2.1.312.json`. No runtime file contents were |
| +retained. The new 2.1.312 allowances are limited to: |
| + |
| +- The exact cache directories through |
| + `.cache/claude-cli-nodejs/-workspace/mcp-logs-equipo`, and timestamped |
| + JSONL log files there. |
| +- `.npm`, `.npm/_logs`, its recorded timestamped debug-log names, and the |
| + regular `_update-notifier-last-checked` marker. |
| +- The empty directories `.claude`, `.claude/ssh`, `.config`, |
| + `.config/anthropic`, `dev-mods` and `seed-admin`. No files or further |
| + directories under these paths are allowed. |
| + |
| +Claude entries must belong to the runner uid, have no setuid/setgid bits, |
| +and be directories or regular files with one hard link. Symlinks and other |
| +special files remain refused. The new allowances do not apply to source |
| +homes, other providers or other versions. Policy names are refused at any |
| +depth, including `plugins`, `skills`, `agents`, `commands`, `hooks`, |
| +`settings*.json`, `CLAUDE.md`, MCP config, `shell-snapshots` and `session-env`. |
| +Fixed `runtime_claude_*` categories identify cache, config, npm, mod, seed, |
| +metadata, kind, policy, special-file and unexpected-entry failures without |
| +echoing arbitrary names or contents. The baseline fixture remains refused |
| +at its plugin directory; the disabled-plugin fixture passes. |
| + |
| +### Minor fixes and verification |
| + |
| +Auth argv now comes from `claude.AuthStatusArgs`, which returns a fresh |
| +slice. The shared framing selector lives beside it in the Claude adapter |
| +and is called by runner capture. It checks both the binding and manifest |
| +provider versions, along with the existing manifest hash and exact argv. |
| +The manifest-version test covers a wrong version and an absent version. |
| +The Codex readback comment now identifies the live coordinator tool |
| +inventory as the real guard for the two flags missing from typed config. |
| + |
| +All Go commands use `CGO_ENABLED=0 GOTOOLCHAIN=go1.26.10` and default Go |
| +caches. New tests were run before their implementation: |
| + |
| +```sh |
| +go test ./internal/runner ./internal/runner/provider/codex \ |
| + -run 'TestDirectClaudeAuthDocument|TestCodexEmptyHomeReplay' -count=1 -v |
| +go test ./internal/runner/provider -run '^TestAccountCodexRuntimeLinks$' -count=1 |
| +go test ./internal/runner/provider/claude -run '^TestClaudeEmptyHomeReplay$' -count=1 -v |
| +go test ./internal/runner/provider -run '^TestAccountClaude' -count=1 |
| +``` |
| + |
| +The first run failed on missing/wrong manifest versions and both Codex |
| +runtime trees. The link test rejected the three authorized links. The |
| +corrected Claude replay reached the full no-input probe and failed runtime |
| +validation; adding the plugin-setting assertion also failed before its |
| +implementation. Claude inventory and refusal tests failed before their |
| +runtime changes. The manifest-version cases now live in |
| +`TestClaudeAuthManifestVersion`, keeping the runner's existing 8,800-line |
| +test ceiling without removing coverage or raising budgets. |
| + |
| +Each new guard was temporarily broken and restored. Every row below failed |
| +by assertion. Two initial mutation attempts had unused-variable compile |
| +errors; those were corrected and rerun before counting the guard as tested. |
| +Commands use `go test`, the package and `-run` pattern shown, and `-count=1`. |
| + |
| +| Temporary break | Package and test pattern | |
| +| --- | --- | |
| +| Ignore the Codex link path pattern | `./internal/runner/provider -run '^TestAccountCodexRuntimeLinks$'` | |
| +| Accept any nonempty link target | `./internal/runner/provider -run '^TestAccountCodexRuntimeLinks$'` | |
| +| Ignore link uid | `./internal/runner/provider -run '^TestAccountCodexLinkOwner$'` | |
| +| Ignore the link's provider version | `./internal/runner/provider -run '^TestAccountCodexLinkScope/version$'` | |
| +| Ignore the link's provider | `./internal/runner/provider -run '^TestAccountCodexLinkScope/provider$'` | |
| +| Accept unrecorded Claude paths | `./internal/runner/provider -run '^TestAccountClaudeRuntimeGuards$'` | |
| +| Ignore the Claude version pin | `./internal/runner/provider -run '^TestAccountClaudeRuntimeGuards/.cache/version$'` | |
| +| Apply Claude allowances to other providers | `./internal/runner/provider -run '^TestAccountClaudeRuntimeGuards/.cache/provider$'` | |
| +| Skip Claude metadata checks | `./internal/runner/provider -run '^TestAccountClaudeRuntimeGuards$'` | |
| +| Accept the wrong Claude entry kind | `./internal/runner/provider -run '^TestAccountClaudeRuntimeGuards/.cache/file$'` | |
| +| Skip policy-name checks | `./internal/runner/provider -run '^TestAccountClaudeRuntimeGuards$'` | |
| +| Ignore the auth manifest version | `./internal/runner/provider/claude -run '^TestClaudeAuthManifestVersion$'` | |
| +| Remove the built-in plugin disable setting | `./internal/runner/provider/claude -run '^TestClaudeEmptyHomeReplay/Engineering$'` | |
| + |
| +The complete provider, Claude and Codex suites passed before the final |
| +consolidated targeted run. With all mutations restored, that run is: |
| + |
| +```sh |
| +go test ./internal/runner ./internal/runner/provider/... ./internal/tryequipo \ |
| + -run 'TestAccount|TestCodex|TestClaude|TestDirectClaudeAuthDocument|TestDirectJournalFailureContains|TestPlanWorkflowProviderPoliciesLauncher|TestCoordinatorOnlyMCPServer|TestPrivateDirectoryFailureNamesPath' \ |
| + -count=1 |
| +``` |
| + |
| +Size budgets and the exact reference inventory pass without raising any |
| +limits. Full CI and final cleanup results follow below. |
| + |
| +The first full `make -k ci` finished with two failing inventory tests: |
| +`TestMergedPlanPolicyInventory` and `TestPlanWorkflowReleasePolicyInventory`. |
| +All 18 pending constructor hashes were stale after the changed Claude and |
| +Codex settings. `internal/release/manifest.json` now contains the hashes |
| +reported by those tests. Every status remains `uncertified`; no certificate, |
| +live evidence or execution authority was added. Both tests and |
| +`TestPlanWorkflowReleaseRejectsOldCertificate` pass after that update. |
| + |
| +All other first-run gates passed. The main suite ran 25 packages without |
| +cached results; only the two inventory packages failed. Local advisory time |
| +limits were exceeded by the runner (375.642 seconds against 330), provider |
| +(16.352 against 15), Claude (47.680 against 45) and Codex (39.659 against 35). |
| +No limit was raised. The performance lane passed with a 116 ms median cold |
| +boot against 500 ms. The first full rerun follows the inventory correction. |
| + |
| +The first full rerun of `make -k ci` passed, exit 0. There were two full |
| +gate runs in this round; no second rerun was needed. All 27 test packages |
| +ran without cached results or failures. The adapter, namespace, migration |
| +and performance lanes also passed. Median cold boot was 132 ms against |
| +500 ms. |
| + |
| +The successful local gate still reported advisory timing overruns: |
| +application integration 341.948 seconds against 300, runner 524.230 against |
| +330, provider 17.414 against 15, Claude 54.636 against 45, and Codex 41.347 |
| +against 35. These timing limits are enforced when the CI environment is |
| +set; this local success does not establish that those limits will pass |
| +there. No budget was relaxed and no additional full suite was run. |
| + |
| +There are no pending controller decisions for this round. Account-home |
| +contents and existing Equipo state were untouched. No sign-in, |
| +authenticated model call, live gate, merge, default-branch push, deployment |
| +or copy-review server was run. Both live-test environment flags were |
| +unset. Test processes have exited; session scratch is removed at handoff. |
diff --git a/internal/release/manifest.json b/internal/release/manifest.json| index 8eb4883a..48cc6e2a 100644 |
| --- a/internal/release/manifest.json |
| +++ b/internal/release/manifest.json |
| @@ -18,109 +18,109 @@ |
| { |
| "provider": "claude", |
| "action": "reproduce", |
| - "inventory_hash": "7889c12f50aadf831269750d4b2d4eef74444fd3e6f2e0a9a63aab53b82b51cd", |
| + "inventory_hash": "5f7f57b7992f742bbd34f9a7c438a2faebe13d0b5eb66204f45cefb675c2d2a1", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "claude", |
| "action": "scope", |
| - "inventory_hash": "599d2e62cc3aa4be8d43ca635b15edd6ebc96478d2dfbba34d8d9747b4174e06", |
| + "inventory_hash": "d7389ca1bc8b01ead54257ac060900f05945e5b9c8d4288acf381ce9200ff5a4", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "claude", |
| "action": "recommend", |
| - "inventory_hash": "965816cb740193dbe8240c247617399ad683ad469ac04f5c82e95ac81f46253f", |
| + "inventory_hash": "77634c102c1a58e733aecdcdf30b2a31134f735553d29b466c8f5d574663ccc2", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "claude", |
| "action": "investigate", |
| - "inventory_hash": "e72252a0af684addc8f65c457270fd3677f1e38e103e8006d7b50b93201c5a84", |
| + "inventory_hash": "347e2e2df6589fb89d2a2ca92d2ef129b4f684c799c263fd019901404a989460", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "claude", |
| "action": "implement", |
| - "inventory_hash": "65c7bb12b1a3d9e8f04adbce9f0884c8d5a923928b0704a8a58f2180909bb5cd", |
| + "inventory_hash": "5007c7ba9ba1fb42ee440dfef755a672b9e4661a8c12f74036c5fa981dca008f", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "claude", |
| "action": "copy", |
| - "inventory_hash": "0ec0b2990309688cadc7886c99ef88c45386645a28dc74bd5062b4f71b1ff2a8", |
| + "inventory_hash": "b759b124ab1ff2b5cd5c4d16e5f94fbcdca111a00487733a690c87bed43a72b5", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "claude", |
| "action": "design", |
| - "inventory_hash": "05121532dbc36f6a272be458ae9ea67db0b4541659d42918c628c348c2117999", |
| + "inventory_hash": "c515d7399b0e4b6a8b6e515230e434fb888cb853d849462391980e4027ea9771", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "claude", |
| "action": "review", |
| - "inventory_hash": "b3e9ece30e71857b1b5e91519ebb35659cdf99f472e930b42216ab27137d7951", |
| + "inventory_hash": "bb08623f090d231a171c9b8bed3a31f541f157f64ecce0bd14d3834f342e7a7f", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "reproduce", |
| - "inventory_hash": "2e4ca8baffdf32c0eee8506ac551936ae6a89b4a6f2b50118a5f781f2ee16d37", |
| + "inventory_hash": "d47d4dfaaece777379a3cb2352283fbfc62e494efc2f2639b1854b8086798a1d", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "scope", |
| - "inventory_hash": "fa2a7c8bc318a50977a9af60eb95d7a37fa1f15b631cde4e4cd1869bfd5ad2cb", |
| + "inventory_hash": "3323d907bf469c1b9360fcad127144f68d8b5edbb4a2493caab02564dc2c177c", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "recommend", |
| - "inventory_hash": "c0e5a0b12cf4f53ee641b2f0dd61507f73526cf7d3310afefd1bce273e2ad034", |
| + "inventory_hash": "8b75831f5294aba541f18b79b6abc5342a9a5bd962d299fc83965d7423957b71", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "investigate", |
| - "inventory_hash": "f339de414600e504e7e2f8cd6fa0c2cbacff30ff5fe1afe193b3de405ef54c22", |
| + "inventory_hash": "168e4089db1371767ee1029dd47da4d1a892e7c6c838af1b2c0213eb98331061", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "implement", |
| - "inventory_hash": "a47a468f09575940f82096b39836468ccfa7b77db4d9ecdbef92b60b5033c4bc", |
| + "inventory_hash": "07481884f41d57b7e3fb6c3eb54614e4fb80e97f0e82676b0b1f9cd12e2d0db2", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "copy", |
| - "inventory_hash": "197d0fd3074e1c5ab1483bf6c8b64ed99aa60d32f73a5b7777e34fb66ce9402b", |
| + "inventory_hash": "51f450134f7dccb85961cf54890366eda6482da1ff7bcc55d5db158ae08623b5", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "design", |
| - "inventory_hash": "7177a83262fdb00b3b89c3f5e0439a8100ca87b67e9ba550db870ed27081e37a", |
| + "inventory_hash": "6372458e251dbd10c2d354ec1d511baf85a133ab6a6deeed475b9b54e221302e", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "review", |
| - "inventory_hash": "2609f5f2c114bb133753de19b6f952f17b765e0975f5788b4c44e353e8de4eeb", |
| + "inventory_hash": "8a16b1292bd4c3e9c7d618c854cfb4fb2fe3a68a4c18a3e71cfdb17ab2921a83", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "claude", |
| "action": "coordinate", |
| - "inventory_hash": "3289121ba15a78e4ab32bb85828b3518631214be4649de85de46e3d31354de62", |
| + "inventory_hash": "e8e71d79de46b5418f2bdceb4ce45a3e0a5e94eb63aba08c96ad4795f82e88e7", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "coordinate", |
| - "inventory_hash": "57d95c9e08193d417a63e3e3e045965759d6a0ae27e3a4d7ffeebc65893cde80", |
| + "inventory_hash": "3d39700c840ac70165dbc94ec9438cf68503f382321c3ab2ac68206a96c36045", |
| "status": "uncertified" |
| } |
| ] |
diff --git a/internal/runner/capture.go b/internal/runner/capture.go| index ad6fc775..ba95e67d 100644 |
| --- a/internal/runner/capture.go |
| +++ b/internal/runner/capture.go |
| @@ -15,6 +15,7 @@ import ( |
| "amadan.net/oficina/equipo/internal/runner/containment" |
| "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runner/provider/claude" |
| "amadan.net/oficina/equipo/internal/runnerproto" |
| ) |
| @@ -238,7 +239,7 @@ func (f *captureFactory) Open(ctx context.Context, p provider.Process, l provide |
| } |
| diagnostics <- e |
| }() |
| - reader := stdoutFrames{reader: bufio.NewReaderSize(stdout, MaxFrameBytes+2), document: claudeAuthDocument(l)} |
| + reader := stdoutFrames{reader: bufio.NewReaderSize(stdout, MaxFrameBytes+2), document: claude.AuthStatusDocument(l)} |
| var seq int64 |
| for { |
| raw, e := reader.read() |
diff --git a/internal/runner/capture_framing.go b/internal/runner/capture_framing.go| index bb5674ab..9fbdb424 100644 |
| --- a/internal/runner/capture_framing.go |
| +++ b/internal/runner/capture_framing.go |
| @@ -2,23 +2,12 @@ package runner |
| import ( |
| "bufio" |
| - "encoding/json" |
| "fmt" |
| "io" |
| - "slices" |
| - "amadan.net/oficina/equipo/internal/runner/provider" |
| "amadan.net/oficina/equipo/internal/runnerproto" |
| ) |
| -// Claude 2.1.312 auth status writes one indented document. Agent sessions |
| -// still require one complete JSON object per line. |
| -func claudeAuthDocument(l provider.Launch) bool { |
| - var m struct{ Argv []string } |
| - want := []string{"/opt/claude", "--setting-sources", "", "--settings", provider.SettingsPath, "--strict-mcp-config", "--mcp-config", provider.MCPPath, "--disable-slash-commands", "auth", "status", "--json"} |
| - return l.Selection.Provider == "claude" && l.Binding.Expected.ProviderVersion == "2.1.312" && l.Policy.ManifestHash == provider.DigestDirectEvidence(l.Policy.Manifest) && json.Unmarshal(l.Policy.Manifest, &m) == nil && slices.Equal(m.Argv, want) |
| -} |
| - |
| type stdoutFrames struct { |
| reader *bufio.Reader |
| document, consumed bool |
diff --git a/internal/runner/live_open_test.go b/internal/runner/live_open_test.go| index 92f46c58..e4fbcc1b 100644 |
| --- a/internal/runner/live_open_test.go |
| +++ b/internal/runner/live_open_test.go |
| @@ -35,7 +35,7 @@ func TestDirectClaudeAuthDocument(t *testing.T) { |
| case "oversized": |
| raw = "{\"secret\":\"" + strings.Repeat("x", MaxFrameBytes) + "\"}\n" |
| } |
| - l.Policy.Manifest, _ = json.Marshal(map[string]any{"Argv": args}) |
| + l.Policy.Manifest, _ = json.Marshal(map[string]any{"Argv": args, "ProviderVersion": "2.1.312"}) |
| l.Policy.ManifestHash = provider.DigestDirectEvidence(l.Policy.Manifest) |
| if mode == "tampered-manifest" { |
| l.Policy.ManifestHash = "wrong" |
diff --git a/internal/runner/provider/account_diagnostics_test.go b/internal/runner/provider/account_diagnostics_test.go| index 7fca0e84..c4632241 100644 |
| --- a/internal/runner/provider/account_diagnostics_test.go |
| +++ b/internal/runner/provider/account_diagnostics_test.go |
| @@ -82,7 +82,7 @@ func TestAccountRecordedCodexRuntimeRefused(t *testing.T) { |
| } |
| } |
| err = l.ValidatePolicy(context.Background()) |
| - if !errors.Is(err, ErrContainment) || !strings.Contains(err.Error(), "runtime_codex_tmp") { |
| - t.Fatalf("startup directory not identified: %v", err) |
| + if !errors.Is(err, ErrContainment) || !strings.Contains(err.Error(), "runtime_policy_entry") { |
| + t.Fatalf("bundled skills not refused: %v", err) |
| } |
| } |
diff --git a/internal/runner/provider/claude/auth_framing.go b/internal/runner/provider/claude/auth_framing.go| new file mode 100644 |
| index 00000000..1b274283 |
| --- /dev/null |
| +++ b/internal/runner/provider/claude/auth_framing.go |
| @@ -0,0 +1,19 @@ |
| +package claude |
| + |
| +import ( |
| + "encoding/json" |
| + "slices" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +// AuthStatusDocument selects the pinned auth command, which writes one |
| +// indented document. Agent sessions still require one JSON object per line. |
| +func AuthStatusDocument(l provider.Launch) bool { |
| + var m struct { |
| + Argv []string |
| + ProviderVersion string |
| + } |
| + want := AuthStatusArgs() |
| + return l.Selection.Provider == "claude" && l.Binding.Expected.ProviderVersion == Version && l.Policy.ManifestHash == provider.DigestDirectEvidence(l.Policy.Manifest) && json.Unmarshal(l.Policy.Manifest, &m) == nil && m.ProviderVersion == Version && slices.Equal(m.Argv, want) |
| +} |
diff --git a/internal/runner/provider/claude/auth_framing_test.go b/internal/runner/provider/claude/auth_framing_test.go| new file mode 100644 |
| index 00000000..eb5f84b3 |
| --- /dev/null |
| +++ b/internal/runner/provider/claude/auth_framing_test.go |
| @@ -0,0 +1,29 @@ |
| +package claude |
| + |
| +import ( |
| + "encoding/json" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +func TestClaudeAuthManifestVersion(t *testing.T) { |
| + for _, version := range []string{Version, "other", ""} { |
| + t.Run(version, func(t *testing.T) { |
| + manifest := map[string]any{"Argv": AuthStatusArgs()} |
| + if version != "" { |
| + manifest["ProviderVersion"] = version |
| + } |
| + raw, _ := json.Marshal(manifest) |
| + l := provider.Launch{Selection: provider.Selection{Provider: "claude"}, Binding: provider.Binding{Expected: provider.Identity{ProviderVersion: Version}}, Policy: provider.Policy{Manifest: raw, ManifestHash: provider.DigestDirectEvidence(raw)}} |
| + if AuthStatusDocument(l) != (version == Version) { |
| + t.Fatal("manifest version was not checked") |
| + } |
| + }) |
| + } |
| + args := AuthStatusArgs() |
| + args[0] = "mutated" |
| + if AuthStatusArgs()[0] != "/opt/claude" { |
| + t.Fatal("auth command is mutable") |
| + } |
| +} |
diff --git a/internal/runner/provider/claude/launcher.go b/internal/runner/provider/claude/launcher.go| index cb8b08f9..fc13d2ae 100644 |
| --- a/internal/runner/provider/claude/launcher.go |
| +++ b/internal/runner/provider/claude/launcher.go |
| @@ -94,6 +94,12 @@ func missing(v any) bool { |
| } |
| return false |
| } |
| + |
| +// AuthStatusArgs returns a fresh copy of the exact document-framed auth command. |
| +func AuthStatusArgs() []string { |
| + return []string{"/opt/claude", "--setting-sources", "", "--settings", provider.SettingsPath, "--strict-mcp-config", "--mcp-config", provider.MCPPath, "--disable-slash-commands", "auth", "status", "--json"} |
| +} |
| + |
| func baseArgs(model, tools string) []string { |
| return []string{"/opt/claude", "-p", "--verbose", "--input-format", "stream-json", "--output-format", "stream-json", "--model", model, "--setting-sources", "", "--disable-slash-commands", "--strict-mcp-config", "--mcp-config", provider.MCPPath, "--settings", provider.SettingsPath, "--permission-mode", "manual", "--permission-prompt-tool", "mcp__equipo__permission", "--tools", tools} |
| } |
| @@ -149,7 +155,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, specialist, mode |
| } |
| } |
| settings := map[string]any{ |
| - "disableAllHooks": true, "enabledPlugins": map[string]any{}, |
| + "disableAllHooks": true, "enabledPlugins": map[string]any{"agents-md@builtin": false}, |
| "sandbox": map[string]any{"enabled": true, "failIfUnavailable": true, "allowUnsandboxedCommands": false, "autoAllowBashIfSandboxed": true, "excludedCommands": []string{}, "filesystem": map[string]any{"denyRead": denied, "denyWrite": denied}, "network": map[string]any{"allowUnixSockets": []string{}}}, |
| "permissions": map[string]any{"deny": nativeDenies, "allow": allow}, |
| } |
| @@ -328,7 +334,7 @@ func (l *Launcher) preflight(ctx context.Context, b provider.Binding, lease *pro |
| return observed, e |
| } |
| func (l *Launcher) probeIdentity(ctx context.Context, b provider.Binding, in provider.PolicyInputs) (provider.Identity, error) { |
| - frames, e := l.probe(ctx, b, in, []string{"/opt/claude", "--setting-sources", "", "--settings", provider.SettingsPath, "--strict-mcp-config", "--mcp-config", provider.MCPPath, "--disable-slash-commands", "auth", "status", "--json"}) |
| + frames, e := l.probe(ctx, b, in, AuthStatusArgs()) |
| if e != nil { |
| return provider.Identity{}, e |
| } |
diff --git a/internal/runner/provider/claude/launcher_test.go b/internal/runner/provider/claude/launcher_test.go| index 97fd3f66..86e4ba2c 100644 |
| --- a/internal/runner/provider/claude/launcher_test.go |
| +++ b/internal/runner/provider/claude/launcher_test.go |
| @@ -327,7 +327,7 @@ func TestClaudeLaunchPolicy(t *testing.T) { |
| } |
| var settings map[string]any |
| json.Unmarshal(f.inputs.Settings, &settings) |
| - if settings["disableAllHooks"] != true || len(settings["enabledPlugins"].(map[string]any)) != 0 { |
| + if settings["disableAllHooks"] != true || !reflect.DeepEqual(settings["enabledPlugins"], map[string]any{"agents-md@builtin": false}) { |
| t.Fatal("hooks/plugins enabled") |
| } |
| if !sameJSON(f.inputs.MCP, []byte(`{"mcpServers":{"equipo":{"type":"stdio","command":"/opt/equipo-tool-proxy","args":["--socket","/tool/equipo.sock"]}}}`)) { |
diff --git a/internal/runner/provider/claude/runtime_replay_test.go b/internal/runner/provider/claude/runtime_replay_test.go| new file mode 100644 |
| index 00000000..97af14f8 |
| --- /dev/null |
| +++ b/internal/runner/provider/claude/runtime_replay_test.go |
| @@ -0,0 +1,231 @@ |
| +package claude |
| + |
| +import ( |
| + "context" |
| + "crypto/sha256" |
| + "encoding/hex" |
| + "encoding/json" |
| + "errors" |
| + "io" |
| + "io/fs" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +// Only the transport and capture are test code; policy, Open and the |
| +// no-input dependency probe use the production launcher. There is no egress. |
| +type offlineClaudeHost struct { |
| + t *testing.T |
| + home string |
| +} |
| + |
| +func (h *offlineClaudeHost) Start(ctx context.Context, l provider.Launch, argv []string) (provider.Process, error) { |
| + if _, err := provider.AttestLaunch(l, argv); err != nil { |
| + return nil, err |
| + } |
| + home := l.Binding.Home |
| + if h.home != "" { |
| + home = h.home |
| + } |
| + args := []string{"--unshare-all", "--die-with-parent", "--new-session", "--ro-bind", "/usr", "/usr", "--symlink", "usr/bin", "/bin", "--symlink", "usr/lib", "/lib", "--symlink", "usr/lib64", "/lib64", "--proc", "/proc", "--dev", "/dev", "--tmpfs", "/tmp", "--bind", home, "/home/runner", "--bind", l.Workspace, "/workspace"} |
| + for _, m := range l.Policy.Mounts { |
| + args = append(args, "--ro-bind", m.Source, m.Target) |
| + } |
| + args = append(args, "--chdir", "/workspace", "--clearenv", "--setenv", "PATH", "/usr/bin:/bin:/opt", "--setenv", "HOME", "/home/runner", "--setenv", "TMPDIR", "/tmp") |
| + for k, v := range l.Policy.Env { |
| + args = append(args, "--setenv", k, v) |
| + } |
| + args = append(args, argv...) |
| + cmd := exec.CommandContext(ctx, "bwrap", args...) |
| + in, err := cmd.StdinPipe() |
| + if err != nil { |
| + return nil, err |
| + } |
| + out, outWrite, err := os.Pipe() |
| + if err != nil { |
| + in.Close() |
| + return nil, err |
| + } |
| + cmd.Stdout = outWrite |
| + p := &fakeProcess{cmd: cmd, in: in, out: out, err: io.NopCloser(strings.NewReader("")), done: make(chan struct{})} |
| + if err = cmd.Start(); err != nil { |
| + in.Close() |
| + out.Close() |
| + outWrite.Close() |
| + return nil, err |
| + } |
| + go func() { _ = cmd.Wait(); outWrite.Close(); p.exit.Code = cmd.ProcessState.ExitCode(); close(p.done) }() |
| + h.t.Cleanup(func() { _ = cmd.Process.Kill(); <-p.done; in.Close(); out.Close() }) |
| + return p, nil |
| +} |
| + |
| +type offlineClaudeCapture struct{ loggedOut bool } |
| + |
| +func (c *offlineClaudeCapture) Open(ctx context.Context, p provider.Process, _ provider.Launch) (*provider.Capture, error) { |
| + frames, done := make(chan provider.Frame), make(chan error, 1) |
| + go func() { |
| + defer close(done) |
| + defer close(frames) |
| + decoder := json.NewDecoder(io.LimitReader(p.Stdout(), MaxFrameBytes+1)) |
| + for seq := int64(1); ; seq++ { |
| + var raw json.RawMessage |
| + err := decoder.Decode(&raw) |
| + if err == io.EOF { |
| + done <- nil |
| + return |
| + } |
| + if err != nil { |
| + done <- err |
| + return |
| + } |
| + var status struct { |
| + LoggedIn *bool `json:"loggedIn"` |
| + } |
| + if json.Unmarshal(raw, &status) == nil && status.LoggedIn != nil && !*status.LoggedIn { |
| + c.loggedOut = true |
| + } |
| + select { |
| + case frames <- provider.Frame{Sequence: seq, Bytes: raw}: |
| + case <-ctx.Done(): |
| + done <- ctx.Err() |
| + return |
| + } |
| + } |
| + }() |
| + return &provider.Capture{Input: p.Stdin(), Frames: frames, Done: done}, nil |
| +} |
| + |
| +func TestClaudeEmptyHomeReplay(t *testing.T) { |
| + home, err := os.UserHomeDir() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + binary := filepath.Join(home, ".local/share/equipo/try/bin/claude") |
| + file, err := os.Open(binary) |
| + if os.IsNotExist(err) { |
| + t.Skip("pinned Claude 2.1.312 binary absent; empty-home replay requires the local pinned installation") |
| + } |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + sum := sha256.New() |
| + _, err = io.Copy(sum, file) |
| + file.Close() |
| + if err != nil || hex.EncodeToString(sum.Sum(nil)) != ExecutableSHA256 { |
| + t.Fatal("pinned Claude digest differs") |
| + } |
| + for _, role := range []string{"Engineering", "Coordinator"} { |
| + t.Run(role, func(t *testing.T) { |
| + f := fixtureFor(t, role) |
| + var settings map[string]any |
| + json.Unmarshal(f.inputs.Settings, &settings) |
| + if settings["enabledPlugins"].(map[string]any)["agents-md@builtin"] != false { |
| + t.Error("built-in agents-md plugin not disabled") |
| + } |
| + source := filepath.Join(filepath.Dir(f.interactive), "dedicated") |
| + for _, name := range []string{".credentials.json", ".claude.json"} { |
| + if err = os.WriteFile(filepath.Join(source, name), []byte(`{}`), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + f.lease.Close() |
| + id := f.lease.Identity() |
| + f.lease, err = provider.OpenAccount(context.Background(), provider.Binding{ID: "binding", Home: source, AccountID: id.AccountID, Provider: "claude", Expected: id, RuntimeRoot: filepath.Join(filepath.Dir(source), "empty-homes")}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { f.lease.Close() }) |
| + f.launch.Binding = f.lease.Binding() |
| + in := f.inputs |
| + in.RuntimeFiles[0].Source = binary |
| + in.DeniedPaths = []string{"/private/state", "/alias/login"} |
| + in.Action = "implement" |
| + if role == "Coordinator" { |
| + in.Action = "coordinate" |
| + } |
| + profile, _ := provider.Profile(in.Action) |
| + in.Tools = profile.MCPTools() |
| + in, err = PolicyInputs(f.lease.Binding(), in, role, f.launch.Selection.Model) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + f.launch.Policy, err = provider.BuildPolicy(f.lease.Binding(), in) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + host := &offlineClaudeHost{t: t} |
| + capture := &offlineClaudeCapture{} |
| + launcher, err := New(host, capture) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + ctx, cancel := context.WithTimeout(context.Background(), 40*time.Second) |
| + defer cancel() |
| + _, err = launcher.Open(ctx, f.launch) |
| + if !errors.Is(err, errFailed) || errors.Is(err, provider.ErrContainment) || !capture.loggedOut { |
| + t.Fatalf("expected unauthenticated auth exit from Open, got %v", err) |
| + } |
| + t.Logf("real Open: %v", err) |
| + // Auth exits before the no-input -p probe. Exercise that exact probe |
| + // separately, first with a completely empty config directory. |
| + for _, empty := range []bool{true, false} { |
| + root := f.lease.Binding().Home |
| + if empty { |
| + root = t.TempDir() |
| + host.home = root |
| + } else { |
| + host.home = "" |
| + } |
| + var probeErr error |
| + err = f.lease.Preflight(ctx, func(ctx context.Context, b provider.Binding) (provider.Identity, error) { |
| + _, probeErr = launcher.probe(ctx, b, in, append(append([]string{}, in.Argv...), "--session-id", uuid())) |
| + return provider.Identity{}, provider.ErrIdentity |
| + }) |
| + if !errors.Is(err, provider.ErrIdentity) { |
| + t.Fatal(err) |
| + } |
| + err = probeErr |
| + t.Logf("full preflight empty=%v: %v", empty, err) |
| + if err != nil { |
| + t.Fatalf("probe did not complete: %v", err) |
| + } |
| + for _, name := range []string{"plugins", "skills", "agents", "commands", "shell-snapshots", "session-env"} { |
| + if _, e := os.Lstat(filepath.Join(root, name)); !os.IsNotExist(e) { |
| + t.Fatalf("policy entry created: %s: %v", name, e) |
| + } |
| + } |
| + if err = filepath.WalkDir(root, func(path string, d fs.DirEntry, e error) error { |
| + if e != nil { |
| + return e |
| + } |
| + if path == root { |
| + return nil |
| + } |
| + info, e := d.Info() |
| + if e != nil { |
| + return e |
| + } |
| + rel, _ := filepath.Rel(root, path) |
| + t.Logf("runtime empty=%v: %s %s %04o", empty, rel, info.Mode().Type(), info.Mode().Perm()) |
| + return nil |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + // No real CLI runs with this synthetic identity. It only enables the |
| + // final runtime-policy check after every subprocess has exited. |
| + if err = f.lease.Preflight(ctx, func(context.Context, provider.Binding) (provider.Identity, error) { return f.lease.Identity(), nil }); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err = f.lease.ValidatePolicy(ctx); err != nil { |
| + t.Fatalf("real runtime tree rejected: %v", err) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/runner/provider/codex/config_readback.go b/internal/runner/provider/codex/config_readback.go| index ea345a96..bd2aace3 100644 |
| --- a/internal/runner/provider/codex/config_readback.go |
| +++ b/internal/runner/provider/codex/config_readback.go |
| @@ -19,7 +19,9 @@ func effectiveConfigMatches(p provider.Policy, got map[string]json.RawMessage) b |
| return false |
| } |
| // 0.165.0 keeps these two disabled flags in the session layer but omits |
| - // them from typed effective config. The unmodified layer is checked too. |
| + // them from typed effective config; this is not proof they are disabled. |
| + // The live tool inventory check in directlive/coordinator_inventory.go is |
| + // the real guard. The unmodified command-line layer is checked below. |
| var tools, effective map[string]json.RawMessage |
| if json.Unmarshal(want["tools"], &tools) != nil || len(tools) != 2 || json.Unmarshal(got["tools"], &effective) != nil { |
| return false |
diff --git a/internal/runner/provider/codex/launcher.go b/internal/runner/provider/codex/launcher.go| index 4fdc7d86..94475e11 100644 |
| --- a/internal/runner/provider/codex/launcher.go |
| +++ b/internal/runner/provider/codex/launcher.go |
| @@ -129,9 +129,10 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, model string) (p |
| fs[path] = "deny" |
| } |
| settings := map[string]any{ |
| - "model": model, "model_provider": "openai", "approval_policy": "on-request", "approvals_reviewer": "user", "default_permissions": "equipo", |
| + "skills": map[string]any{"bundled": map[string]any{"enabled": false}}, |
| + "model": model, "model_provider": "openai", "approval_policy": "on-request", "approvals_reviewer": "user", "default_permissions": "equipo", |
| "permissions": map[string]any{"equipo": map[string]any{"filesystem": fs, "network": map[string]any{"enabled": false}}}, |
| - "features": map[string]any{"incremental_tools": true, "apps": false, "multi_agent": false, "remote_control": false, "tool_call_mcp_elicitation": true}, "mcp_servers": map[string]any{"equipo": map[string]any{"command": "/opt/equipo-tool-proxy", "args": []string{"--socket", "/tool/equipo.sock"}}}, |
| + "features": map[string]any{"incremental_tools": true, "apps": false, "multi_agent": false, "remote_control": false, "memories": false, "tool_call_mcp_elicitation": true}, "mcp_servers": map[string]any{"equipo": map[string]any{"command": "/opt/equipo-tool-proxy", "args": []string{"--socket", "/tool/equipo.sock"}}}, |
| } |
| if in.Action == "coordinate" { |
| configureCoordinator(settings, model) |
diff --git a/internal/runner/provider/codex/runtime_policy_test.go b/internal/runner/provider/codex/runtime_policy_test.go| new file mode 100644 |
| index 00000000..3c32e20e |
| --- /dev/null |
| +++ b/internal/runner/provider/codex/runtime_policy_test.go |
| @@ -0,0 +1,77 @@ |
| +package codex |
| + |
| +import ( |
| + "encoding/json" |
| + "os" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +func TestCodexRuntimeSettings(t *testing.T) { |
| + for _, action := range []string{"implement", "coordinate"} { |
| + t.Run(action, func(t *testing.T) { |
| + f := fixtureFor(t) |
| + in := f.inputs |
| + in.Action = action |
| + profile, _ := provider.Profile(action) |
| + in.Tools = profile.MCPTools() |
| + in, err := PolicyInputs(f.lease.Binding(), in, f.launch.Selection.Model) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !configSubset([]byte(`{"skills":{"bundled":{"enabled":false}},"features":{"memories":false}}`), in.Settings) { |
| + t.Fatal("skills or memories not disabled") |
| + } |
| + if !strings.Contains(strings.Join(in.Argv, " "), `skills={"bundled"={"enabled"=false}}`) { |
| + t.Fatal("skills missing from argv") |
| + } |
| + p, err := provider.BuildPolicy(f.lease.Binding(), in) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, key := range []string{"skills", "features"} { |
| + t.Run(key, func(t *testing.T) { |
| + var got map[string]any |
| + json.Unmarshal(in.Settings, &got) |
| + if key == "skills" { |
| + got[key].(map[string]any)["bundled"].(map[string]any)["enabled"] = true |
| + } else { |
| + got[key].(map[string]any)["memories"] = true |
| + } |
| + readback := marshal(map[string]any{"config": got, "origins": map[string]any{}, "layers": []any{map[string]any{"name": map[string]any{"type": "sessionFlags"}, "version": "fixture", "config": json.RawMessage(in.Settings)}}}) |
| + if validateConfig(readback, p) == nil { |
| + t.Fatal("enabled capability accepted") |
| + } |
| + }) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestCodexRecordedDisabledRuntime(t *testing.T) { |
| + raw, err := os.ReadFile("testdata/disabled-skills-0.165.0.json") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var frames []struct { |
| + ID int |
| + Result json.RawMessage |
| + } |
| + if err = json.Unmarshal(raw, &frames); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(frames) != 4 { |
| + t.Fatal("incomplete recording") |
| + } |
| + if !configSubset([]byte(`{"account":null,"requiresOpenaiAuth":true}`), frames[1].Result) { |
| + t.Fatal("recording is not unauthenticated") |
| + } |
| + if !configSubset([]byte(`{"config":{"skills":{"bundled":{"enabled":false}},"features":{"memories":false}}}`), frames[2].Result) { |
| + t.Fatal("disabled config not recorded") |
| + } |
| + if !sameJSON(frames[3].Result, []byte(`{"data":[{"cwd":"/workspace","skills":[],"errors":[]}]}`)) { |
| + t.Fatal("skills exposed") |
| + } |
| +} |
diff --git a/internal/runner/provider/codex/runtime_replay_test.go b/internal/runner/provider/codex/runtime_replay_test.go| new file mode 100644 |
| index 00000000..cc000758 |
| --- /dev/null |
| +++ b/internal/runner/provider/codex/runtime_replay_test.go |
| @@ -0,0 +1,187 @@ |
| +package codex |
| + |
| +import ( |
| + "context" |
| + "crypto/sha256" |
| + "encoding/hex" |
| + "errors" |
| + "io" |
| + "io/fs" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +// The transport runs the real CLI without an egress relay. Open, policy |
| +// attestation, account staging and RPC handling are the production code. |
| +type offlineCodexHost struct{ t *testing.T } |
| +type offlineCodexProcess struct { |
| + in io.WriteCloser |
| + out io.ReadCloser |
| + done chan struct{} |
| + exit provider.Exit |
| +} |
| + |
| +func (p *offlineCodexProcess) ID() string { return "offline-replay" } |
| +func (p *offlineCodexProcess) Stdin() io.WriteCloser { return p.in } |
| +func (p *offlineCodexProcess) Stdout() io.ReadCloser { return p.out } |
| +func (p *offlineCodexProcess) Stderr() io.ReadCloser { return io.NopCloser(strings.NewReader("")) } |
| +func (p *offlineCodexProcess) Wait(ctx context.Context) (provider.Exit, error) { |
| + select { |
| + case <-p.done: |
| + return p.exit, nil |
| + case <-ctx.Done(): |
| + return provider.Exit{}, ctx.Err() |
| + } |
| +} |
| + |
| +func (h offlineCodexHost) Start(ctx context.Context, l provider.Launch, argv []string) (provider.Process, error) { |
| + if _, err := provider.AttestLaunch(l, argv); err != nil { |
| + return nil, err |
| + } |
| + args := []string{"--unshare-all", "--die-with-parent", "--new-session", "--ro-bind", "/usr", "/usr", "--symlink", "usr/bin", "/bin", "--symlink", "usr/lib", "/lib", "--symlink", "usr/lib64", "/lib64", "--proc", "/proc", "--dev", "/dev", "--tmpfs", "/tmp", "--bind", l.Binding.Home, "/home/runner", "--bind", l.Workspace, "/workspace"} |
| + for _, m := range l.Policy.Mounts { |
| + args = append(args, "--ro-bind", m.Source, m.Target) |
| + } |
| + args = append(args, "--chdir", "/workspace", "--clearenv", "--setenv", "PATH", "/usr/bin:/bin:/opt", "--setenv", "HOME", "/home/runner", "--setenv", "CODEX_HOME", "/home/runner", "--setenv", "TMPDIR", "/tmp", "--setenv", "LANG", "C.UTF-8") |
| + args = append(args, argv...) |
| + cmd := exec.CommandContext(ctx, "bwrap", args...) |
| + p := &offlineCodexProcess{done: make(chan struct{})} |
| + var err error |
| + if p.in, err = cmd.StdinPipe(); err != nil { |
| + return nil, err |
| + } |
| + if p.out, err = cmd.StdoutPipe(); err != nil { |
| + p.in.Close() |
| + return nil, err |
| + } |
| + if err = cmd.Start(); err != nil { |
| + p.in.Close() |
| + p.out.Close() |
| + return nil, err |
| + } |
| + go func() { _ = cmd.Wait(); p.exit.Code = cmd.ProcessState.ExitCode(); close(p.done) }() |
| + h.t.Cleanup(func() { _ = cmd.Process.Kill(); <-p.done; p.in.Close(); p.out.Close() }) |
| + return p, nil |
| +} |
| + |
| +func TestCodexEmptyHomeReplay(t *testing.T) { |
| + home, err := os.UserHomeDir() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + bin := filepath.Join(home, ".local/share/equipo/try/bin") |
| + for name, want := range map[string]string{"codex": ExecutableSHA256, "codex-code-mode-host": CodeModeHostSHA256} { |
| + f, err := os.Open(filepath.Join(bin, name)) |
| + if os.IsNotExist(err) { |
| + t.Skip("pinned Codex 0.165.0 binaries absent; empty-home replay requires the local pinned installation") |
| + } |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + sum := sha256.New() |
| + _, err = io.Copy(sum, f) |
| + f.Close() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if hex.EncodeToString(sum.Sum(nil)) != want { |
| + t.Fatalf("pinned %s digest differs", name) |
| + } |
| + } |
| + for _, action := range []string{"implement", "coordinate"} { |
| + t.Run(action, func(t *testing.T) { |
| + f := fixtureFor(t) |
| + // This source is a newly-created test fixture, containing no login. |
| + source := filepath.Join(filepath.Dir(f.interactive), "dedicated", "auth.json") |
| + if err := os.WriteFile(source, []byte(`{"auth_mode":"apikey"}`), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + in := f.inputs |
| + in.Action = action |
| + profile, _ := provider.Profile(action) |
| + in.Tools = profile.MCPTools() |
| + for i := range in.RuntimeFiles { |
| + if in.RuntimeFiles[i].Target != "/opt/equipo-tool-proxy" { |
| + in.RuntimeFiles[i].Source = filepath.Join(bin, filepath.Base(in.RuntimeFiles[i].Target)) |
| + } |
| + } |
| + // No thread starts, so the tool proxy is never invoked. |
| + in, err = PolicyInputs(f.lease.Binding(), in, f.launch.Selection.Model) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + f.launch.Policy, err = provider.BuildPolicy(f.lease.Binding(), in) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + f.l, err = New(offlineCodexHost{t}, fakeCapture{}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) |
| + defer cancel() |
| + _, err = f.l.Open(ctx, f.launch) |
| + if !errors.Is(err, provider.ErrIdentity) || errors.Is(err, provider.ErrContainment) { |
| + t.Fatalf("expected missing account from real Open, got %v", err) |
| + } |
| + t.Logf("real %s Open: %v", action, err) |
| + // Missing account returns before config/read in Open. Check the same |
| + // production policy on a second unauthenticated process, without a turn. |
| + err = f.lease.Preflight(ctx, func(ctx context.Context, b provider.Binding) (provider.Identity, error) { |
| + probeCtx, stop := context.WithCancel(ctx) |
| + defer stop() |
| + launch := f.launch |
| + launch.Binding = b |
| + proc, _, rpc, e := f.l.start(probeCtx, launch, func(provider.Frame) error { return nil }) |
| + defer func() { |
| + if rpc != nil { |
| + rpc.close() |
| + } |
| + stop() |
| + waitProcess(proc) |
| + if rpc != nil { |
| + <-rpc.done |
| + } |
| + }() |
| + if e != nil { |
| + return provider.Identity{}, e |
| + } |
| + if e = initialize(probeCtx, rpc); e != nil { |
| + return provider.Identity{}, e |
| + } |
| + if e = readConfig(probeCtx, rpc, launch.Policy); e != nil { |
| + return provider.Identity{}, e |
| + } |
| + return readIdentity(probeCtx, rpc) |
| + }) |
| + if !errors.Is(err, provider.ErrIdentity) { |
| + t.Fatalf("readback probe: %v", err) |
| + } |
| + if _, err = os.Lstat(filepath.Join(f.lease.Binding().Home, "skills")); !os.IsNotExist(err) { |
| + t.Fatalf("bundled skills installed: %v", err) |
| + } |
| + // Only make the fixture ready after all real processes have exited, so |
| + // ValidatePolicy can check their actual startup files. No CLI uses this |
| + // synthetic identity and no credentials or successful Open are fabricated. |
| + if err = f.lease.Preflight(ctx, func(context.Context, provider.Binding) (provider.Identity, error) { return f.lease.Identity(), nil }); err != nil { |
| + t.Fatal(err) |
| + } |
| + filepath.WalkDir(f.lease.Binding().Home, func(path string, d fs.DirEntry, e error) error { |
| + if e == nil && strings.Contains(path, "arg0") { |
| + r, _ := filepath.Rel(f.lease.Binding().Home, path) |
| + t.Logf("runtime: %s %s", r, d.Type()) |
| + } |
| + return e |
| + }) |
| + if err = f.lease.ValidatePolicy(ctx); err != nil { |
| + t.Fatalf("real runtime tree rejected: %v", err) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/runner/provider/codex/testdata/disabled-skills-0.165.0.json b/internal/runner/provider/codex/testdata/disabled-skills-0.165.0.json| new file mode 100644 |
| index 00000000..b892b1d9 |
| --- /dev/null |
| +++ b/internal/runner/provider/codex/testdata/disabled-skills-0.165.0.json |
| @@ -0,0 +1,231 @@ |
| +[ |
| + { |
| + "id": 1, |
| + "result": { |
| + "userAgent": "equipo/0.165.0 (Debian 13.0.0; x86_64) unknown (equipo; 2)", |
| + "codexHome": "/home/runner", |
| + "platformFamily": "unix", |
| + "platformOs": "linux" |
| + } |
| + }, |
| + { |
| + "id": 2, |
| + "result": { |
| + "account": null, |
| + "requiresOpenaiAuth": true, |
| + "workspaceRouting": null |
| + } |
| + }, |
| + { |
| + "id": 3, |
| + "result": { |
| + "config": { |
| + "model": null, |
| + "review_model": null, |
| + "model_context_window": null, |
| + "model_auto_compact_token_limit": null, |
| + "model_auto_compact_token_limit_scope": null, |
| + "model_provider": null, |
| + "approval_policy": null, |
| + "approvals_reviewer": null, |
| + "sandbox_mode": null, |
| + "sandbox_workspace_write": null, |
| + "forced_chatgpt_workspace_id": null, |
| + "forced_login_method": null, |
| + "web_search": null, |
| + "tools": null, |
| + "instructions": null, |
| + "developer_instructions": null, |
| + "compact_prompt": null, |
| + "model_reasoning_effort": null, |
| + "model_reasoning_summary": null, |
| + "model_verbosity": null, |
| + "service_tier": null, |
| + "analytics": null, |
| + "apps": null, |
| + "browser_use": null, |
| + "computer_use": null, |
| + "desktop": null, |
| + "model_providers": {}, |
| + "project_doc_fallback_filenames": [], |
| + "experimental_realtime_ws_startup_context": null, |
| + "experimental_realtime_ws_base_url": null, |
| + "js_repl_node_path": null, |
| + "model_instructions_file": null, |
| + "include_environment_context_time": true, |
| + "experimental_realtime_ws_model": null, |
| + "experimental_thread_store_endpoint": null, |
| + "apps_mcp_product_sku": null, |
| + "mcp_oauth_callback_url": null, |
| + "chatgpt_base_url": "https://chatgpt.com/backend-api/", |
| + "shell_environment_policy": { |
| + "inherit": null, |
| + "ignore_default_excludes": null, |
| + "exclude": null, |
| + "set": null, |
| + "include_only": null, |
| + "filters": null, |
| + "experimental_use_profile": null |
| + }, |
| + "permissions": null, |
| + "include_collaboration_mode_instructions": true, |
| + "sqlite_home": null, |
| + "hide_agent_reasoning": false, |
| + "disable_paste_burst": null, |
| + "orchestrator": null, |
| + "feedback": null, |
| + "js_repl_node_module_dirs": null, |
| + "profile": null, |
| + "marketplaces": {}, |
| + "project_root_markers": [ |
| + ".git" |
| + ], |
| + "background_terminal_max_timeout": 300000, |
| + "plan_mode_reasoning_effort": null, |
| + "features": { |
| + "network_proxy": null, |
| + "memories": false, |
| + "remote_control": false, |
| + "api_key_cyber_access_programs": true, |
| + "api_key_model_discovery": true, |
| + "auth_elicitation": true, |
| + "background_paginated_rollout_migration": false, |
| + "codex_apps_mcp_2026_07_28": false, |
| + "mcp_2026_07_28": false, |
| + "mentions_v2": true, |
| + "remote_plugin": true, |
| + "tool_suggest": true, |
| + "windows_sandbox_service": false |
| + }, |
| + "experimental_use_unified_exec_tool": null, |
| + "log_dir": null, |
| + "show_raw_agent_reasoning": null, |
| + "notify": null, |
| + "include_environment_context": true, |
| + "oss_provider": null, |
| + "file_opener": "vscode", |
| + "model_catalog_json": null, |
| + "personality": null, |
| + "audio": null, |
| + "cli_auth_credentials_store": "file", |
| + "check_for_update_on_startup": null, |
| + "history": { |
| + "persistence": "save-all", |
| + "max_bytes": null |
| + }, |
| + "mcp_oauth_credentials_store": "auto", |
| + "ghost_snapshot": null, |
| + "experimental_realtime_ws_backend_prompt": null, |
| + "experimental_compact_prompt_file": null, |
| + "mcp_oauth_callback_port": null, |
| + "otel": null, |
| + "mcp_servers": {}, |
| + "goals": null, |
| + "allow_login_shell": true, |
| + "projects": null, |
| + "daybreak": null, |
| + "auto_review": null, |
| + "include_permissions_instructions": true, |
| + "mcp_enterprise_managed_auth": null, |
| + "project_doc_max_bytes": 32768, |
| + "skills": { |
| + "bundled": { |
| + "enabled": false |
| + } |
| + }, |
| + "plugins": {}, |
| + "suppress_unstable_features_warning": null, |
| + "memories": null, |
| + "model_post_turn_compact_threshold_percent": null, |
| + "windows": null, |
| + "profiles": {}, |
| + "mcp_optional_startup_grace_ms": null, |
| + "tool_output_token_limit": null, |
| + "experimental_realtime_start_instructions": null, |
| + "tool_suggest": null, |
| + "experimental_realtime_webrtc_call_base_url": null, |
| + "hooks": null, |
| + "allow_symlinked_codex_home": null, |
| + "agents": null, |
| + "notice": null, |
| + "cloud": null, |
| + "openai_base_url": null, |
| + "default_permissions": null, |
| + "include_apps_instructions": true, |
| + "tui": null, |
| + "thread_unload_delay_secs": null, |
| + "realtime": null, |
| + "responses_api_metadata": null, |
| + "experimental_thread_store": null |
| + }, |
| + "origins": { |
| + "features.remote_control": { |
| + "name": { |
| + "type": "sessionFlags" |
| + }, |
| + "version": "sha256:8c48aefcf518f89757c7b3bde7de76a791dd0eeb3ed3ffe1efc12d1ed0a917c1" |
| + }, |
| + "skills.bundled.enabled": { |
| + "name": { |
| + "type": "sessionFlags" |
| + }, |
| + "version": "sha256:8c48aefcf518f89757c7b3bde7de76a791dd0eeb3ed3ffe1efc12d1ed0a917c1" |
| + }, |
| + "features.memories": { |
| + "name": { |
| + "type": "sessionFlags" |
| + }, |
| + "version": "sha256:8c48aefcf518f89757c7b3bde7de76a791dd0eeb3ed3ffe1efc12d1ed0a917c1" |
| + } |
| + }, |
| + "layers": [ |
| + { |
| + "name": { |
| + "type": "sessionFlags" |
| + }, |
| + "version": "sha256:8c48aefcf518f89757c7b3bde7de76a791dd0eeb3ed3ffe1efc12d1ed0a917c1", |
| + "config": { |
| + "features": { |
| + "remote_control": false, |
| + "memories": false |
| + }, |
| + "skills": { |
| + "bundled": { |
| + "enabled": false |
| + } |
| + } |
| + } |
| + }, |
| + { |
| + "name": { |
| + "type": "user", |
| + "file": "/home/runner/config.toml", |
| + "profile": null |
| + }, |
| + "version": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a", |
| + "config": {} |
| + }, |
| + { |
| + "name": { |
| + "type": "system", |
| + "file": "/etc/codex/config.toml" |
| + }, |
| + "version": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a", |
| + "config": {} |
| + } |
| + ] |
| + } |
| + }, |
| + { |
| + "id": 4, |
| + "result": { |
| + "data": [ |
| + { |
| + "cwd": "/workspace", |
| + "skills": [], |
| + "errors": [] |
| + } |
| + ] |
| + } |
| + } |
| +] |
diff --git a/internal/runner/provider/runtime_claude.go b/internal/runner/provider/runtime_claude.go| new file mode 100644 |
| index 00000000..dc437f0b |
| --- /dev/null |
| +++ b/internal/runner/provider/runtime_claude.go |
| @@ -0,0 +1,56 @@ |
| +package provider |
| + |
| +import ( |
| + "os" |
| + "regexp" |
| + "strings" |
| +) |
| + |
| +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$`) |
| +var claudeNPMLog = regexp.MustCompile(`^\.npm/_logs/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}_[0-9]{2}_[0-9]{2}_[0-9]{3}Z-debug-0\.log$`) |
| + |
| +// Only the recorded directories and log files are runtime state. The empty |
| +// support directories do not authorize any SSH, config, mod or seed files. |
| +func (l *AccountLease) claudeRuntimeEntry(rel string, info os.FileInfo) (bool, error) { |
| + top := strings.SplitN(rel, "/", 2)[0] |
| + category := "" |
| + switch top { |
| + case ".cache": |
| + category = "cache" |
| + case ".config", ".claude": |
| + category = "config" |
| + case ".npm": |
| + category = "npm" |
| + case "dev-mods": |
| + category = "dev_mods" |
| + case "seed-admin": |
| + category = "seed_admin" |
| + default: |
| + return false, nil |
| + } |
| + if l.source.Expected.ProviderVersion != "2.1.312" { |
| + return true, accountContainment("runtime_claude_" + category) |
| + } |
| + 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": |
| + directory = true |
| + default: |
| + if rel != ".npm/_update-notifier-last-checked" && !claudeRuntimeLog.MatchString(rel) && !claudeNPMLog.MatchString(rel) { |
| + return true, accountContainment("runtime_claude_" + category) |
| + } |
| + } |
| + if (directory && !info.IsDir()) || (!directory && !info.Mode().IsRegular()) { |
| + return true, accountContainment("runtime_claude_kind") |
| + } |
| + return true, nil |
| +} |
| + |
| +func runtimePolicyEntry(name string) bool { |
| + name = strings.ToLower(name) |
| + switch name { |
| + case "config.toml", "agents.md", "claude.md", "hooks", "plugins", "skills", "agents", "commands", ".mcp.json", "mcp.json", "mcp-config.json", "shell-snapshots", "session-env": |
| + return true |
| + } |
| + return strings.HasPrefix(name, "settings") && strings.HasSuffix(name, ".json") |
| +} |
diff --git a/internal/runner/provider/runtime_claude_test.go b/internal/runner/provider/runtime_claude_test.go| new file mode 100644 |
| index 00000000..e3f9fa5e |
| --- /dev/null |
| +++ b/internal/runner/provider/runtime_claude_test.go |
| @@ -0,0 +1,147 @@ |
| +package provider |
| + |
| +import ( |
| + "encoding/json" |
| + "errors" |
| + "os" |
| + "path/filepath" |
| + "strconv" |
| + "strings" |
| + "testing" |
| + |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +func claudeRuntimeFixture(t *testing.T) *AccountLease { |
| + t.Helper() |
| + b, r := accountFixture(t) |
| + b.Provider = "claude" |
| + b.Expected.ProviderVersion = "2.1.312" |
| + writeMetadata(t, b.Home, b.Expected) |
| + writeFake(t, filepath.Join(b.Home, ".credentials.json"), `{}`) |
| + l := openFixture(t, b, r) |
| + return l |
| +} |
| +func TestAccountClaudeRecordedRuntime(t *testing.T) { |
| + for _, stage := range []string{"before", "disabled"} { |
| + t.Run(stage, func(t *testing.T) { |
| + l := claudeRuntimeFixture(t) |
| + raw, err := os.ReadFile("testdata/claude-empty-home-" + stage + "-2.1.312.json") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var tree struct { |
| + Entries []struct { |
| + Path string |
| + Directory bool |
| + Mode string |
| + } |
| + } |
| + if err = json.Unmarshal(raw, &tree); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, e := range tree.Entries { |
| + p := filepath.Join(l.runtime, e.Path) |
| + if e.Directory { |
| + err = os.MkdirAll(p, 0700) |
| + } else { |
| + err = os.WriteFile(p, []byte("fixture"), 0600) |
| + } |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + mode, e2 := strconv.ParseUint(e.Mode, 8, 32) |
| + if e2 != nil { |
| + t.Fatal(e2) |
| + } |
| + if err = os.Chmod(p, os.FileMode(mode)); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + err = l.validateRuntimeEntries() |
| + if stage == "disabled" { |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + } else if err == nil || !strings.Contains(err.Error(), "runtime_claude_policy_entry") { |
| + t.Fatalf("plugin tree not refused: %v", err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestAccountClaudeRuntimeGuards(t *testing.T) { |
| + for _, tc := range []struct{ path, kind, reason string }{ |
| + {".cache/evil", "file", "cache"}, {".config/evil", "file", "config"}, {".claude/ssh/key", "file", "config"}, |
| + {".npm/_logs/evil", "file", "npm"}, {"dev-mods/payload", "file", "dev_mods"}, {"seed-admin/config", "file", "seed_admin"}, |
| + {"plugins", "dir", "policy_entry"}, {"skills", "dir", "policy_entry"}, {"agents", "dir", "policy_entry"}, {"commands", "dir", "policy_entry"}, |
| + {"hooks", "dir", "policy_entry"}, {"settings.extra.json", "file", "policy_entry"}, {"CLAUDE.md", "file", "policy_entry"}, |
| + {".mcp.json", "file", "policy_entry"}, {"mcp.json", "file", "policy_entry"}, {".cache/settings.local.json", "file", "policy_entry"}, |
| + {".cache/agents", "dir", "policy_entry"}, {"shell-snapshots", "dir", "policy_entry"}, {"session-env", "dir", "policy_entry"}, |
| + {"secret-sentinel", "file", "unexpected_entry"}, {".cache", "file", "kind"}, |
| + {".cache", "setgid", "metadata"}, {".cache", "setuid", "metadata"}, |
| + {".cache/claude-cli-nodejs", "link", "special_entry"}, {".cache/pipe", "fifo", "special_entry"}, |
| + {".npm/_update-notifier-last-checked", "hardlink", "metadata"}, |
| + {".cache", "version", "cache"}, {".cache", "provider", "unexpected_entry"}, |
| + } { |
| + t.Run(tc.path+"/"+tc.kind, func(t *testing.T) { |
| + l := claudeRuntimeFixture(t) |
| + path := filepath.Join(l.runtime, tc.path) |
| + must := func(err error) { |
| + t.Helper() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + must(os.MkdirAll(filepath.Dir(path), 0700)) |
| + switch tc.kind { |
| + case "dir", "version", "provider", "setuid", "setgid": |
| + must(os.MkdirAll(path, 0700)) |
| + case "link": |
| + must(os.Symlink("/opt/claude", path)) |
| + case "fifo": |
| + must(unix.Mkfifo(path, 0600)) |
| + case "hardlink": |
| + must(os.Link(filepath.Join(l.runtime, ".credentials.json"), path)) |
| + default: |
| + writeFake(t, path, "fixture") |
| + } |
| + if tc.kind == "setuid" { |
| + must(os.Chmod(path, 0700|os.ModeSetuid)) |
| + } |
| + if tc.kind == "setgid" { |
| + must(os.Chmod(path, 0700|os.ModeSetgid)) |
| + } |
| + if tc.kind == "version" { |
| + l.source.Expected.ProviderVersion = "other" |
| + } |
| + if tc.kind == "provider" { |
| + l.source.Provider = "other" |
| + must(os.Remove(filepath.Join(l.runtime, ".credentials.json"))) |
| + } |
| + err := l.validateRuntimeEntries() |
| + want := "runtime_claude_" + tc.reason |
| + if tc.kind == "provider" { |
| + want = "runtime_unexpected_entry" |
| + } |
| + if !errors.Is(err, ErrContainment) || !strings.Contains(err.Error(), want) || strings.Contains(err.Error(), "secret-sentinel") { |
| + t.Fatalf("guard %s: %v", want, err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestAccountClaudeRuntimeNotStaged(t *testing.T) { |
| + l := claudeRuntimeFixture(t) |
| + for _, name := range []string{".cache", ".config", ".claude", ".npm", "dev-mods", "seed-admin"} { |
| + if err := os.Mkdir(filepath.Join(l.source.Home, name), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + preflightFixture(t, l) |
| + for _, name := range []string{".cache", ".config", ".claude", ".npm", "dev-mods", "seed-admin"} { |
| + if _, err := os.Lstat(filepath.Join(l.runtime, name)); !os.IsNotExist(err) { |
| + t.Fatalf("source state staged: %s: %v", name, err) |
| + } |
| + } |
| +} |
diff --git a/internal/runner/provider/runtime_home.go b/internal/runner/provider/runtime_home.go| index 376d8229..3aafdd9f 100644 |
| --- a/internal/runner/provider/runtime_home.go |
| +++ b/internal/runner/provider/runtime_home.go |
| @@ -4,43 +4,105 @@ import ( |
| "io/fs" |
| "os" |
| "path/filepath" |
| + "regexp" |
| "strings" |
| + "syscall" |
| ) |
| func (l *AccountLease) validateRuntimeEntries() error { |
| + reason := func(category string) error { |
| + if l.source.Provider == "claude" { |
| + return accountContainment("runtime_claude_" + category) |
| + } |
| + return accountContainment("runtime_" + category) |
| + } |
| allowed := map[string]bool{IdentityFile: true, credentialName(l.source.Provider): true, ".claude.json": true, "history.jsonl": true, "sessions": true, "archived_sessions": true, "session_index.jsonl": true, "shell_snapshots": true, "log": true, "logs": true, "debug": true, "projects": true, "todos": true, "tasks": true, "plans": true, "backups": true, "file-history": true, "telemetry": true, "statsig": true, "paste-cache": true, "downloads": true, "stats-cache.json": true, "models_cache.json": true, "version.json": true, ".last_migration": true, ".codex-global-state.json": true, "equipo-read-sentinel": true} |
| return filepath.WalkDir(l.runtime, func(path string, d fs.DirEntry, err error) error { |
| if err != nil { |
| - return accountContainment("runtime_walk") |
| + return reason("walk") |
| } |
| if path == l.runtime { |
| return nil |
| } |
| name := d.Name() |
| - if d.Type()&os.ModeSymlink != 0 || d.Type()&(os.ModeSocket|os.ModeDevice|os.ModeNamedPipe) != 0 { |
| - return accountContainment("runtime_special_entry") |
| + if d.Type()&os.ModeSymlink != 0 { |
| + rel, e := filepath.Rel(l.runtime, path) |
| + info, statErr := d.Info() |
| + if e == nil && statErr == nil && l.codexRuntimeLink(path, rel, info) { |
| + return nil |
| + } |
| + return reason("special_entry") |
| } |
| - switch strings.ToLower(name) { |
| - case "config.toml", "agents.md", "claude.md", "settings.json", "settings.local.json", "hooks", "plugins", "skills", ".mcp.json": |
| - return accountContainment("runtime_policy_entry") |
| + if d.Type()&(os.ModeSocket|os.ModeDevice|os.ModeNamedPipe) != 0 { |
| + return reason("special_entry") |
| } |
| - if filepath.Dir(path) == l.runtime && !allowed[name] && !strings.HasPrefix(name, "state_") && !strings.HasPrefix(name, "logs_") { |
| - if l.source.Provider == "codex" { |
| - switch name { |
| - case ".tmp", "tmp": |
| - return accountContainment("runtime_codex_tmp") |
| - case "installation_id": |
| - return accountContainment("runtime_codex_installation_id") |
| - case "goals_1.sqlite", "goals_1.sqlite-shm", "goals_1.sqlite-wal": |
| - return accountContainment("runtime_codex_goals") |
| - case "memories_1.sqlite", "memories_1.sqlite-shm", "memories_1.sqlite-wal": |
| - return accountContainment("runtime_codex_memories") |
| - case "queue_1.sqlite", "queue_1.sqlite-shm", "queue_1.sqlite-wal": |
| - return accountContainment("runtime_codex_queue") |
| + if runtimePolicyEntry(name) { |
| + return reason("policy_entry") |
| + } |
| + |
| + rel, err := filepath.Rel(l.runtime, path) |
| + if err != nil { |
| + return reason("walk") |
| + } |
| + top := strings.SplitN(rel, string(filepath.Separator), 2)[0] |
| + if l.source.Provider == "claude" { |
| + info, e := d.Info() |
| + if e != nil || !runtimeEntryMetadata(info) { |
| + return reason("metadata") |
| + } |
| + if handled, e := l.claudeRuntimeEntry(rel, info); handled { |
| + return e |
| + } |
| + } |
| + if l.source.Provider == "codex" && l.source.Expected.ProviderVersion == "0.165.0" { |
| + scratch := top == ".tmp" || top == "tmp" |
| + if scratch || codexRuntimeState(top) { |
| + info, err := d.Info() |
| + if err != nil || !runtimeEntryMetadata(info) { |
| + return accountContainment("runtime_codex_metadata") |
| } |
| + if (scratch && rel == top && !info.IsDir()) || (!scratch && !info.Mode().IsRegular()) { |
| + return accountContainment("runtime_codex_kind") |
| + } |
| + return nil |
| } |
| - return accountContainment("runtime_unexpected_entry") |
| + } |
| + if filepath.Dir(path) == l.runtime && !allowed[name] && !strings.HasPrefix(name, "state_") && !strings.HasPrefix(name, "logs_") { |
| + return reason("unexpected_entry") |
| } |
| return nil |
| }) |
| } |
| + |
| +// These are startup state in the staged home, never source-home inputs. |
| +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": |
| + return true |
| + } |
| + return false |
| +} |
| + |
| +func runtimeEntryMetadata(info os.FileInfo) bool { |
| + stat, ok := info.Sys().(*syscall.Stat_t) |
| + return ok && stat.Uid == uint32(os.Getuid()) && info.Mode()&(os.ModeSetuid|os.ModeSetgid) == 0 && |
| + (info.IsDir() || (info.Mode().IsRegular() && stat.Nlink == 1)) |
| +} |
| + |
| +// The CLI points these launch shims at its pinned mount inside the namespace. |
| +// Readlink compares the text only; the host must never resolve /opt/codex. |
| +var codexArg0Link = regexp.MustCompile(`^tmp/arg0-linux/codex-arg0[A-Za-z0-9]{6}/(apply_patch|applypatch|codex-linux-sandbox)$`) |
| + |
| +func (l *AccountLease) codexRuntimeLink(path, rel string, info os.FileInfo) bool { |
| + if l.source.Provider != "codex" || l.source.Expected.ProviderVersion != "0.165.0" || !codexArg0Link.MatchString(rel) { |
| + return false |
| + } |
| + stat, ok := info.Sys().(*syscall.Stat_t) |
| + if !ok || stat.Uid != uint32(os.Getuid()) || info.Mode()&os.ModeSymlink == 0 || info.Mode()&(os.ModeSetuid|os.ModeSetgid) != 0 { |
| + return false |
| + } |
| + target, err := os.Readlink(path) |
| + return err == nil && target == "/opt/codex" |
| +} |
diff --git a/internal/runner/provider/runtime_home_test.go b/internal/runner/provider/runtime_home_test.go| new file mode 100644 |
| index 00000000..cb9b0c11 |
| --- /dev/null |
| +++ b/internal/runner/provider/runtime_home_test.go |
| @@ -0,0 +1,119 @@ |
| +package provider |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "os" |
| + "path/filepath" |
| + "syscall" |
| + "testing" |
| + |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +func TestAccountCodexRuntimeState(t *testing.T) { |
| + for _, name := range []string{".tmp", "tmp", "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"} { |
| + t.Run(name, func(t *testing.T) { |
| + b, r := accountFixture(t) |
| + l := openFixture(t, b, r) |
| + preflightFixture(t, l) |
| + path := filepath.Join(l.runtime, name) |
| + if name == ".tmp" || name == "tmp" { |
| + if err := os.MkdirAll(filepath.Join(path, "nested"), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + writeFake(t, filepath.Join(path, "nested", "lock"), "fixture") |
| + } else { |
| + writeFake(t, path, "fixture") |
| + } |
| + if err := l.ValidatePolicy(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestAccountCodexRuntimeStateGuards(t *testing.T) { |
| + for _, mode := range []string{"scratch-file", "state-directory", "nested-setuid", "setgid", "symlink", "fifo", "hardlink", "skills", "nested-policy", "other-state", "other-version", "other-provider", "source-not-staged"} { |
| + t.Run(mode, func(t *testing.T) { |
| + b, r := accountFixture(t) |
| + if mode == "other-version" { |
| + b.Expected.ProviderVersion = "other" |
| + writeMetadata(t, b.Home, b.Expected) |
| + } |
| + l := openFixture(t, b, r) |
| + preflightFixture(t, l) |
| + path := filepath.Join(l.runtime, "tmp") |
| + if mode == "source-not-staged" { |
| + if err := os.Mkdir(filepath.Join(b.Home, "tmp"), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + writeFake(t, filepath.Join(b.Home, "installation_id"), "source sentinel") |
| + preflightFixture(t, l) |
| + for _, name := range []string{"tmp", "installation_id"} { |
| + if _, err := os.Lstat(filepath.Join(l.runtime, name)); !os.IsNotExist(err) { |
| + t.Fatalf("source artifact staged: %s: %v", name, err) |
| + } |
| + } |
| + return |
| + } |
| + if mode == "scratch-file" { |
| + writeFake(t, path, "fixture") |
| + } else { |
| + if err := os.Mkdir(path, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + must := func(err error) { |
| + t.Helper() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + switch mode { |
| + case "state-directory": |
| + must(os.Mkdir(filepath.Join(l.runtime, "installation_id"), 0700)) |
| + case "nested-setuid": |
| + nested := filepath.Join(path, "nested") |
| + must(os.Mkdir(nested, 0700)) |
| + must(os.Chmod(nested, 0700|os.ModeSetuid)) |
| + case "setgid": |
| + must(os.Chmod(path, 0700|os.ModeSetgid)) |
| + case "symlink": |
| + must(os.Symlink(b.Home, filepath.Join(path, "escape"))) |
| + case "fifo": |
| + must(unix.Mkfifo(filepath.Join(path, "pipe"), 0600)) |
| + case "hardlink": |
| + must(os.Link(filepath.Join(b.Home, "auth.json"), filepath.Join(path, "linked"))) |
| + case "skills": |
| + must(os.MkdirAll(filepath.Join(l.runtime, "skills", ".system"), 0700)) |
| + case "nested-policy": |
| + writeFake(t, filepath.Join(path, "config.toml"), "fixture") |
| + case "other-state": |
| + writeFake(t, filepath.Join(l.runtime, "memories_2.sqlite"), "fixture") |
| + case "other-provider": |
| + l.source.Provider = "claude" |
| + must(os.Remove(filepath.Join(l.runtime, "auth.json"))) |
| + } |
| + if err := l.validateRuntimeEntries(); !errors.Is(err, ErrContainment) { |
| + t.Fatalf("unsafe runtime accepted: %v", err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestAccountCodexRuntimeOwner(t *testing.T) { |
| + path := filepath.Join(t.TempDir(), "state") |
| + writeFake(t, path, "fixture") |
| + info, err := os.Lstat(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !runtimeEntryMetadata(info) { |
| + t.Fatal("runner-owned regular file rejected") |
| + } |
| + info.Sys().(*syscall.Stat_t).Uid++ |
| + if runtimeEntryMetadata(info) { |
| + t.Fatal("foreign owner accepted") |
| + } |
| +} |
diff --git a/internal/runner/provider/runtime_links_test.go b/internal/runner/provider/runtime_links_test.go| new file mode 100644 |
| index 00000000..64c13051 |
| --- /dev/null |
| +++ b/internal/runner/provider/runtime_links_test.go |
| @@ -0,0 +1,126 @@ |
| +package provider |
| + |
| +import ( |
| + "errors" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + "syscall" |
| + "testing" |
| +) |
| + |
| +func TestAccountCodexRuntimeLinks(t *testing.T) { |
| + const dir = "tmp/arg0-linux/codex-arg0aB12z9/" |
| + for _, tc := range []struct { |
| + name, path, target string |
| + accept bool |
| + }{ |
| + {"apply_patch", dir + "apply_patch", "/opt/codex", true}, |
| + {"applypatch", dir + "applypatch", "/opt/codex", true}, |
| + {"sandbox", dir + "codex-linux-sandbox", "/opt/codex", true}, |
| + {"other-name", dir + "codex", "/opt/codex", false}, |
| + {"short", "tmp/arg0-linux/codex-arg0abcde/apply_patch", "/opt/codex", false}, |
| + {"long", "tmp/arg0-linux/codex-arg0abcdefg/apply_patch", "/opt/codex", false}, |
| + {"suffix-punctuation", "tmp/arg0-linux/codex-arg0abc_de/apply_patch", "/opt/codex", false}, |
| + {"other-parent", "tmp/arg0/codex-arg0abc123/apply_patch", "/opt/codex", false}, |
| + {"other-top", ".tmp/arg0-linux/codex-arg0abc123/apply_patch", "/opt/codex", false}, |
| + {"nested", dir + "nested/apply_patch", "/opt/codex", false}, |
| + {"relative", dir + "apply_patch", "../../../opt/codex", false}, |
| + {"normalized-target", dir + "apply_patch", "/opt/./codex", false}, |
| + {"other-target", dir + "apply_patch", "/opt/evil", false}, |
| + {"other-version", dir + "apply_patch", "/opt/codex", false}, |
| + {"other-provider", dir + "apply_patch", "/opt/codex", false}, |
| + {"source-not-staged", dir + "apply_patch", "/opt/codex", true}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + b, r := accountFixture(t) |
| + l := openFixture(t, b, r) |
| + root := l.runtime |
| + if tc.name == "source-not-staged" { |
| + root = b.Home |
| + } |
| + path := filepath.Join(root, tc.path) |
| + if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Symlink(tc.target, path); err != nil { |
| + t.Fatal(err) |
| + } |
| + if tc.name == "other-version" { |
| + l.source.Expected.ProviderVersion = "other" |
| + } |
| + if tc.name == "other-provider" { |
| + l.source.Provider = "claude" |
| + } |
| + err := l.validateRuntimeEntries() |
| + if tc.accept { |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + } else if !errors.Is(err, ErrContainment) || (tc.name != "other-version" && tc.name != "other-provider" && !strings.Contains(err.Error(), "runtime_special_entry")) { |
| + t.Fatalf("unsafe link accepted or wrong reason: %v", err) |
| + } |
| + if tc.name == "source-not-staged" { |
| + preflightFixture(t, l) |
| + if _, err = os.Lstat(filepath.Join(l.runtime, tc.path)); !os.IsNotExist(err) { |
| + t.Fatal("source link staged") |
| + } |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestAccountCodexLinkOwner(t *testing.T) { |
| + b, r := accountFixture(t) |
| + l := openFixture(t, b, r) |
| + rel := "tmp/arg0-linux/codex-arg0aB12z9/apply_patch" |
| + path := filepath.Join(l.runtime, rel) |
| + if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Symlink("/opt/codex", path); err != nil { |
| + t.Fatal(err) |
| + } |
| + info, err := os.Lstat(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !l.codexRuntimeLink(path, rel, info) { |
| + t.Fatal("runner link rejected") |
| + } |
| + info.Sys().(*syscall.Stat_t).Uid++ |
| + if l.codexRuntimeLink(path, rel, info) { |
| + t.Fatal("foreign link accepted") |
| + } |
| +} |
| + |
| +func TestAccountCodexLinkScope(t *testing.T) { |
| + b, r := accountFixture(t) |
| + l := openFixture(t, b, r) |
| + rel := "tmp/arg0-linux/codex-arg0aB12z9/apply_patch" |
| + path := filepath.Join(l.runtime, rel) |
| + if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Symlink("/opt/codex", path); err != nil { |
| + t.Fatal(err) |
| + } |
| + info, err := os.Lstat(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, scope := range []string{"provider", "version"} { |
| + t.Run(scope, func(t *testing.T) { |
| + l.source.Provider = "codex" |
| + l.source.Expected.ProviderVersion = "0.165.0" |
| + if scope == "provider" { |
| + l.source.Provider = "claude" |
| + } else { |
| + l.source.Expected.ProviderVersion = "other" |
| + } |
| + if l.codexRuntimeLink(path, rel, info) { |
| + t.Fatal("link accepted outside pinned Codex runtime") |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json b/internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json| new file mode 100644 |
| index 00000000..97978f82 |
| --- /dev/null |
| +++ b/internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json |
| @@ -0,0 +1,115 @@ |
| +{ |
| + "version": "2.1.312", |
| + "entries": [ |
| + { |
| + "path": ".cache", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".cache/claude-cli-nodejs", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".cache/claude-cli-nodejs/-workspace", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".cache/claude-cli-nodejs/-workspace/mcp-logs-equipo", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".cache/claude-cli-nodejs/-workspace/mcp-logs-equipo/2026-11-05T00-07-05-744Z.jsonl", |
| + "directory": false, |
| + "mode": "0664" |
| + }, |
| + { |
| + "path": ".claude", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": ".claude/ssh", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": ".claude.json", |
| + "directory": false, |
| + "mode": "0600" |
| + }, |
| + { |
| + "path": ".config", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": ".config/anthropic", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": ".npm", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".npm/_logs", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".npm/_logs/2026-11-05T00_07_06_140Z-debug-0.log", |
| + "directory": false, |
| + "mode": "0664" |
| + }, |
| + { |
| + "path": ".npm/_update-notifier-last-checked", |
| + "directory": false, |
| + "mode": "0664" |
| + }, |
| + { |
| + "path": "backups", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": "backups/.claude.json.backup.1793837225577", |
| + "directory": false, |
| + "mode": "0600" |
| + }, |
| + { |
| + "path": "dev-mods", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": "plugins", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": "plugins/store", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": "plugins/store/cc-plugin-agents-md_builtin-b049b47b3618.json", |
| + "directory": false, |
| + "mode": "0600" |
| + }, |
| + { |
| + "path": "seed-admin", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": "sessions", |
| + "directory": true, |
| + "mode": "0700" |
| + } |
| + ] |
| +} |
diff --git a/internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json b/internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json| new file mode 100644 |
| index 00000000..07a91b58 |
| --- /dev/null |
| +++ b/internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json |
| @@ -0,0 +1,100 @@ |
| +{ |
| + "version": "2.1.312", |
| + "entries": [ |
| + { |
| + "path": ".cache", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".cache/claude-cli-nodejs", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".cache/claude-cli-nodejs/-workspace", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".cache/claude-cli-nodejs/-workspace/mcp-logs-equipo", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".cache/claude-cli-nodejs/-workspace/mcp-logs-equipo/2026-11-05T00-08-17-158Z.jsonl", |
| + "directory": false, |
| + "mode": "0664" |
| + }, |
| + { |
| + "path": ".claude", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": ".claude/ssh", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": ".claude.json", |
| + "directory": false, |
| + "mode": "0600" |
| + }, |
| + { |
| + "path": ".config", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": ".config/anthropic", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": ".npm", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".npm/_logs", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": ".npm/_logs/2026-11-05T00_08_17_364Z-debug-0.log", |
| + "directory": false, |
| + "mode": "0664" |
| + }, |
| + { |
| + "path": ".npm/_update-notifier-last-checked", |
| + "directory": false, |
| + "mode": "0664" |
| + }, |
| + { |
| + "path": "backups", |
| + "directory": true, |
| + "mode": "0775" |
| + }, |
| + { |
| + "path": "backups/.claude.json.backup.1793837297033", |
| + "directory": false, |
| + "mode": "0600" |
| + }, |
| + { |
| + "path": "dev-mods", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": "seed-admin", |
| + "directory": true, |
| + "mode": "0700" |
| + }, |
| + { |
| + "path": "sessions", |
| + "directory": true, |
| + "mode": "0700" |
| + } |
| + ] |
| +} |
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json| index cdba5577..8fdfba94 100644 |
| --- a/scripts/runner-reference-allowlist.json |
| +++ b/scripts/runner-reference-allowlist.json |
| @@ -7418,5 +7418,250 @@ |
| "match": "equipo-runner", |
| "count": 1, |
| "reason": "Live-open debugging brief or controller evidence: retained runner path or explicitly human-authorized future trial, not legacy execution." |
| + }, |
| + { |
| + "path": "internal/runner/provider/codex/testdata/disabled-skills-0.165.0.json", |
| + "line_sha256": "137c00a888886f9e8189748c665f0deb07b02a6f2f85a1d4cfe2cdfe68b1a7a5", |
| + "match": "node", |
| + "count": 1, |
| + "reason": "Pinned Codex config readback records a null JS runtime path; this fixture does not launch a JS runtime." |
| + }, |
| + { |
| + "path": "internal/runner/provider/codex/testdata/disabled-skills-0.165.0.json", |
| + "line_sha256": "3235b5c43714a459786c835b982827eef0956c3692bd97bad4b0b96063f8f980", |
| + "match": "node", |
| + "count": 1, |
| + "reason": "Pinned Codex config readback records a null JS runtime path; this fixture does not launch a JS runtime." |
| + }, |
| + { |
| + "path": "docs/superpowers/plans/CONTROLLER-REPORT-live-open-failures.md", |
| + "line_sha256": "101e8020b6eede9693732d759c147f284a12351c6b3a581abf1a3e63e28bf74d", |
| + "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/CONTROLLER-REPORT-live-open-failures.md", |
| + "line_sha256": "43e6319890c5e748ac7e4b2725a6d39540010346db171f05a4c94ce0c83de594", |
| + "match": "node", |
| + "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/CONTROLLER-REPORT-live-open-failures.md", |
| + "line_sha256": "99109bf11cf75388aacd05598b98499705978c6196d7e77b4e37fc9160d3be67", |
| + "match": "npm", |
| + "count": 2, |
| + "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/CONTROLLER-REPORT-live-open-failures.md", |
| + "line_sha256": "bd90228946d74196641aebb5e8a5de1080a7c593cb7738d855831b161a793b8d", |
| + "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": "internal/runner/provider/runtime_claude.go", |
| + "line_sha256": "4d622d0399570908b04ae3fa4bfc5a36a59c803a058d3a0630218f3e4b8a6e2e", |
| + "match": "node", |
| + "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": "internal/runner/provider/runtime_claude.go", |
| + "line_sha256": "276c62167a118388f0df01c258454d4e49a8b7018743dbc4b6bbb0f747669ac9", |
| + "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": "internal/runner/provider/runtime_claude.go", |
| + "line_sha256": "276c62167a118388f0df01c258454d4e49a8b7018743dbc4b6bbb0f747669ac9", |
| + "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": "internal/runner/provider/runtime_claude.go", |
| + "line_sha256": "e7dd3b60bc9d86996273ec1235adbcfbef570080d983f055b4d453fd8ba2d1c6", |
| + "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": "internal/runner/provider/runtime_claude.go", |
| + "line_sha256": "cbdb91496e3c8252ed5a9f77e4cd970ebd067fb2b1f3a711223c08d06438dac3", |
| + "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": "internal/runner/provider/runtime_claude.go", |
| + "line_sha256": "df8f195cf927c0e7896bad695d3c01e2da30d594170c17c104a5af2c681019ca", |
| + "match": "node", |
| + "count": 3, |
| + "reason": "Recorded Claude 2.1.312 runtime cache and log paths, with exact allowances and refusal coverage; no executable dependency is introduced." |
| + }, |
| + { |
| + "path": "internal/runner/provider/runtime_claude.go", |
| + "line_sha256": "df8f195cf927c0e7896bad695d3c01e2da30d594170c17c104a5af2c681019ca", |
| + "match": "npm", |
| + "count": 2, |
| + "reason": "Recorded Claude 2.1.312 runtime cache and log paths, with exact allowances and refusal coverage; no executable dependency is introduced." |
| + }, |
| + { |
| + "path": "internal/runner/provider/runtime_claude.go", |
| + "line_sha256": "820a37c88287cd57b3d705df7c4fffdd4b5965af6100a737da3108db3097548e", |
| + "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": "internal/runner/provider/runtime_claude.go", |
| + "line_sha256": "820a37c88287cd57b3d705df7c4fffdd4b5965af6100a737da3108db3097548e", |
| + "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": "internal/runner/provider/runtime_claude_test.go", |
| + "line_sha256": "34abcd4c85ee4232bc52b820c5e4544236d7222f550fd1a91d28d281b8a9f380", |
| + "match": "npm", |
| + "count": 2, |
| + "reason": "Recorded Claude 2.1.312 runtime cache and log paths, with exact allowances and refusal coverage; no executable dependency is introduced." |
| + }, |
| + { |
| + "path": "internal/runner/provider/runtime_claude_test.go", |
| + "line_sha256": "89d70a479b881b38e7436654ed339a2001240f8d08f6b6452ccff0fd35aa35b3", |
| + "match": "node", |
| + "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": "internal/runner/provider/runtime_claude_test.go", |
| + "line_sha256": "306c7517001dc01ee85d5b912a8dfa6ac1ebfce46225c54748a7a44192529eae", |
| + "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": "internal/runner/provider/runtime_claude_test.go", |
| + "line_sha256": "1b5c9e7c5b4118b33bedbf96faa16847f109f1a1eaf3905788eea86dd87bcf23", |
| + "match": "npm", |
| + "count": 2, |
| + "reason": "Recorded Claude 2.1.312 runtime cache and log paths, with exact allowances and refusal coverage; no executable dependency is introduced." |
| + }, |
| + { |
| + "path": "internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json", |
| + "line_sha256": "139141aa55da266877c65ff2d0b24cb06ae5ffd216b537dfd3e30cb50be6fcd2", |
| + "match": "node", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json", |
| + "line_sha256": "82656d44e6930d7b803847ce48b97e9b4988efd5e79c4a7431467487108ef428", |
| + "match": "node", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json", |
| + "line_sha256": "0054baee9a79123f49995e483077db058a51c0aedfa2b050e7217352e57aeb97", |
| + "match": "node", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json", |
| + "line_sha256": "c3268e2bcda1d03e5f01407202123e1370c600774890b6212259090348279770", |
| + "match": "node", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json", |
| + "line_sha256": "418e1ec6adb665ba7a1e8f8470412a0b8d0286b69c1e8a5fdf51ccf7268d7a80", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json", |
| + "line_sha256": "6eac7446badce1e5bd03450f01fde96b051b868acddfa793246d910c92a766a0", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json", |
| + "line_sha256": "c5139528cdd57a58bcdfa0e8162e9d89adf467e2a5207251cc2c64ce8f8eba4d", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-before-2.1.312.json", |
| + "line_sha256": "94f021996d8e8ff814ebc5749c3dc98e8aadb60304dc9513c4388ac75a55287b", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json", |
| + "line_sha256": "139141aa55da266877c65ff2d0b24cb06ae5ffd216b537dfd3e30cb50be6fcd2", |
| + "match": "node", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json", |
| + "line_sha256": "82656d44e6930d7b803847ce48b97e9b4988efd5e79c4a7431467487108ef428", |
| + "match": "node", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json", |
| + "line_sha256": "0054baee9a79123f49995e483077db058a51c0aedfa2b050e7217352e57aeb97", |
| + "match": "node", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json", |
| + "line_sha256": "362dcd1c45b992e8d7db6f6ac8662b0b2c26bf82b9c7e2fbc556bbf05fa06fa6", |
| + "match": "node", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json", |
| + "line_sha256": "418e1ec6adb665ba7a1e8f8470412a0b8d0286b69c1e8a5fdf51ccf7268d7a80", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json", |
| + "line_sha256": "6eac7446badce1e5bd03450f01fde96b051b868acddfa793246d910c92a766a0", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json", |
| + "line_sha256": "39709d5b923430f7bcfe58a7276a63684ff0ef715aab45641db76ebfbce47fb9", |
| + "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": "internal/runner/provider/testdata/claude-empty-home-disabled-2.1.312.json", |
| + "line_sha256": "94f021996d8e8ff814ebc5749c3dc98e8aadb60304dc9513c4388ac75a55287b", |
| + "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." |
| } |
| ] |