oficina / equipo Public

Fix authenticated provider startup state and specialist policy

Co-Authored-By: Astra <noreply@openai.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 7b2d0b26e0b217c7e92649ceff58a2d949b6aca0 parent 26a75e0
21 files changed, +488 −68
  • docs/superpowers/plans/CONTROLLER-REPORT-live-open-failures.md +160 −3
  • internal/directlive/codex_inventory.go +7 −0
  • internal/directlive/try_inventory_test.go +12 −0
  • internal/release/manifest.json +17 −17
  • internal/runner/provider/account_diagnostics_test.go +3 −3
  • internal/runner/provider/claude/launcher.go +2 −2
  • internal/runner/provider/claude/launcher_test.go +11 −2
  • internal/runner/provider/claude/runtime_replay_test.go +16 −2
  • internal/runner/provider/codex/launcher.go +2 −2
  • internal/runner/provider/codex/runtime_policy_test.go +3 −3
  • internal/runner/provider/codex/runtime_replay_test.go +4 −2
  • internal/runner/provider/direct_certification.go +1 −1
  • internal/runner/provider/direct_live_config.go +2 −2
  • internal/runner/provider/login_terminal.go +1 −1
  • internal/runner/provider/runtime_claude.go +21 −5
  • internal/runner/provider/runtime_claude_test.go +1 −1
  • internal/runner/provider/runtime_home.go +57 −16
  • internal/runner/provider/runtime_links_test.go +12 −2
  • internal/runner/provider/runtime_startup_test.go +148 −0
  • internal/runner/provider/types.go +4 −0
  • scripts/runner-reference-allowlist.json +4 −4

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 e478063a..0aca0e08 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-live-open-failures.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-live-open-failures.md
@@ -1,6 +1,6 @@
# Live open failures
-The three rounds fix auth framing, config readback and the runtime-home
+The four 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.
@@ -51,7 +51,7 @@ The fixture preserves response `equipo:3`; `/home/paulca` was replaced with
`internal/runner/provider/accounts.go` and `runtime_home.go` now attach fixed
reason codes to containment failures. They never include file contents,
arbitrary filenames, or underlying filesystem errors. Known Codex startup
-artifacts get fixed categories, such as `runtime_codex_tmp`. This does not
+artifacts get fixed categories, such as `runtime_codex_dot_tmp`. This does not
allow those artifacts or bypass identity, permissions, refresh, or policy
checks. In particular, bundled skills are still rejected.
@@ -156,7 +156,7 @@ Codex error prefix separates these cases:
failed before the probe. The fixed suffix identifies which check.
- `codex_preflight_probe`: process/identity/config readback or post-probe
account validation failed.
-- `codex_open_runtime_policy` with `runtime_codex_tmp` or
+- `codex_open_runtime_policy` with `runtime_codex_plugins` or
`runtime_policy_entry`: the CLI created startup files that conflict with
the strict runtime policy.
@@ -472,3 +472,160 @@ 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.
+
+## Round 4
+
+Specialists now disable Codex goals, plugins, remote plugins and tool
+suggestions, using the same feature flags as the coordinator. Both real
+0.165.0 empty-home replays pass the production `config/read` comparison
+under `--strict-config`. Tests also change each effective flag to true
+and require refusal. The specialist live inventory rejects goal, plugin
+and suggestion tools, including functions inside the `functions`
+namespace. This assertion is tested with synthetic catalog frames; no
+live gate or authenticated turn was run.
+
+Neither real replay leaves `.tmp/plugins.sha` or `.tmp/plugins` in its
+staged home. That observation is limited to network-isolated startup;
+it cannot prove what an authenticated startup would attempt. The runtime
+validator now refuses `.tmp/plugins*` outright. Known paths have fixed
+categories: `runtime_codex_plugins`, `runtime_codex_dot_tmp`,
+`runtime_codex_tmp`, `runtime_codex_arg0`, `runtime_codex_skills`,
+`runtime_codex_installation_id`, `runtime_codex_goals`,
+`runtime_codex_memories` and `runtime_codex_queue`. Unknown names and file
+contents never appear in these diagnostics. The earlier references to the
+category for `.tmp` have been corrected.
+
+For Claude 2.1.312, only these three root-level policy-limit files are
+newly accepted: `policy-limits.json`, `policy-limits.json.signature.json`
+and `policy-limits.json.signature-iat.json`. They must be regular files
+with the runner uid, no setuid/setgid bits and one hard link.
+`remote-settings.json` remains refused, with
+`runtime_claude_remote_settings`. Tests cover wrong kinds, links, mode,
+provider and version, plus source-home exclusion and a second BeginTurn.
+
+Claude settings disable both `agents-md@builtin` and
+`plugin-authoring@builtin`, and set `autoMemoryEnabled` and
+`autoDreamEnabled` false. Both role replays assert the constructed settings
+and read back the actual settings mount before starting the pinned CLI.
+The production no-input startup probe still requires an empty plugin
+inventory. Claude does not provide the Codex effective-config RPC here;
+the settings-file readback is not a claim of such an RPC. Separate policy
+refusal tests reject attempts to enable each new setting.
+
+### Bash state fallback and binary evidence
+
+The pinned Claude executable was inspected directly, without executing it
+against an account home. Its embedded source has no compatible setting or
+environment switch that disables both shell snapshots and session env
+files. `CLAUDE_CODE_DONT_INHERIT_ENV` changes the snapshot subprocess
+environment; it does not suppress the files. The snapshot function's
+`Kv()` check refuses program starts in diskless sessions, so it is not a
+switch for this Bash-capable launcher. The brief's fallback applies.
+
+The embedded snapshot constructor, `ikn`, chooses `bash`, `zsh` or `sh`,
+then builds `snapshot-${shell}-${Date.now()}-${random}.sh`. Random text is
+`Math.random().toString(36).substring(2,8)`, at most six lowercase base-36
+characters, possibly empty for zero. Its optional session suffix calls
+`k_n`, whose guard `d_n()` is hardcoded false in this binary. The accepted
+pattern therefore has a 13-digit millisecond timestamp, zero to six
+base-36 characters and no session suffix. Other shells, uppercase text,
+long random text, suffixes and nested directories are refused.
+
+The embedded `YNt` constructor writes a lowercased hook name and index.
+Its reader's exact `vG` pattern is
+`^(setup|sessionstart|cwdchanged|filechanged)-hook-(\d+)\.sh$`.
+These regular files are accepted only directly under
+`session-env/<uuid>/`. The UUID directory and both root directories must
+be directories. Unrecognized names, extra depth, special files, hard
+links, foreign owners and unsafe modes remain refused.
+
+This exception relies on the staged home being denied to native file
+operations and Bash. The comment in `runtime_claude.go` cites the deny
+construction at `claude/launcher.go:139-149`; existing launch-policy tests
+check those paths. Synthetic provider-written state survives EndTurn and
+passes the next BeginTurn. The unauthenticated replay does not exercise
+an authenticated Bash call, so the filename evidence is the pinned
+binary and the second-turn evidence is the account-lease regression.
+
+The provider version strings now have shared constants, with the adapter
+`Version` constants referring to them. This avoids an import cycle
+between account validation and its adapters. Codex arg0 shim paths accept
+only the already-authorized symlinks; regular files and directories at
+those paths are refused. Seventeen changed constructor hashes were
+refreshed in the release manifest. All 18 policies remain `uncertified`;
+the Codex coordinator's hash did not change.
+
+### Verification
+
+All Go commands use `CGO_ENABLED=0 GOTOOLCHAIN=go1.26.10`, default Go caches
+and on-disk `$TMPDIR`. New assertions were added before implementation:
+
+```sh
+go test ./internal/runner/provider ./internal/runner/provider/codex \
+ ./internal/runner/provider/claude ./internal/directlive \
+ -run 'TestAccountClaudeAuthenticatedState|TestAccountStartupRefusals|TestAccountCodexRuntimeLinks|TestCodexRuntimeSettings|TestClaudeEmptyHomeReplay|TestSpecialistNoGoalOrPluginTools' \
+ -count=1
+```
+
+The first command had a missing test brace in the provider package; that
+was corrected and the provider subset rerun before implementation. The
+assertions failed for missing specialist flags, missing Claude settings,
+exposed goal/plugin tools, accepted regular arg0 shims, rejected startup
+files on a second turn and missing fixed refusal categories. An initial
+hardlink fixture linked the credential itself, causing EndTurn to refuse
+it before the runtime check; the fixture now links a separate test file.
+
+After implementation, one old recording expected a skills refusal, but
+its curated-plugin cache is now refused first. Its assertion now names
+that observed failure. The two policy-inventory tests identified the 17
+changed hashes before the manifest update. The targeted run then passed:
+
+```sh
+go test ./internal/runner/provider ./internal/runner/provider/codex \
+ ./internal/runner/provider/claude ./internal/directlive ./internal/release \
+ -run 'TestAccount|TestCodexRuntime|TestCodexEmptyHomeReplay|TestClaudeEmptyHomeReplay|TestClaudeLaunchPolicy|TestClaudePolicyRefusals|TestSpecialist|TestMergedPlanPolicyInventory|TestPlanWorkflowReleasePolicyInventory|TestPlanWorkflowReleaseRejectsOldCertificate' \
+ -count=1
+```
+
+Every mutation below failed by assertion and was restored immediately.
+Commands are `go test <package> -run '<pattern>' -count=1`.
+
+| Temporary break | Package | Pattern |
+| --- | --- | --- |
+| Enable each of goals, plugins, remote_plugin and tool_suggest separately | `./internal/runner/provider/codex` | `^TestCodexRuntimeSettings/implement$` |
+| Accept effective config without comparison | `./internal/runner/provider/codex` | `^TestCodexRuntimeSettings/implement$` |
+| Enable plugin-authoring, memory or dreaming separately | `./internal/runner/provider/claude` | `^TestClaudeLaunchPolicy/Engineering$` |
+| Accept goal/plugin/suggestion tools | `./internal/directlive` | `^TestSpecialistNoGoalOrPluginTools$` |
+| Permit the curated plugin cache | `./internal/runner/provider` | `^TestAccountStartupRefusals/codex/.tmp/plugins.sha$` |
+| Accept regular arg0 files or directories | `./internal/runner/provider` | `^TestAccountCodexRuntimeLinks/(regular\|directory)$` |
+| Accept remote settings | `./internal/runner/provider` | `^TestAccountStartupRefusals/claude/remote-settings.json$` |
+| Ignore Claude version | `./internal/runner/provider` | `^TestAccountClaudeAuthenticatedState/policy-limits.json/version$` |
+| Apply Claude allowances to other providers | `./internal/runner/provider` | `^TestAccountClaudeAuthenticatedState/policy-limits.json/provider$` |
+| Ignore uid | `./internal/runner/provider` | `^TestAccountCodexRuntimeOwner$` |
+| Ignore setuid/setgid | `./internal/runner/provider` | `^TestAccountClaudeAuthenticatedState/policy-limits.json/(setuid\|setgid)$` |
+| Ignore hardlink count | `./internal/runner/provider` | `^TestAccountClaudeAuthenticatedState/policy-limits.json/hardlink$` |
+| Permit symlinks and FIFOs | `./internal/runner/provider` | `^TestAccountClaudeAuthenticatedState/policy-limits.json/(link\|fifo)$` |
+| Ignore file kind | `./internal/runner/provider` | `^TestAccountClaudeAuthenticatedState/policy-limits.json/directory$` |
+| Ignore snapshot filename pattern | `./internal/runner/provider` | `^TestAccountStartupRefusals/claude/shell-snapshots/evil.sh$` |
+| Ignore session-env filename pattern | `./internal/runner/provider` | `^TestAccountStartupRefusals/claude/session-env/12345678-1234-4123-8123-123456789abc/evil.sh$` |
+| Drop fixed Codex categories | `./internal/runner/provider` | `^TestAccountStartupRefusals/codex$` |
+
+With all 22 mutations restored, the targeted command above passed again.
+The exact reference inventory and size budgets passed without raising any
+limits. One full `make -k ci` then passed, exit 0; no rerun was needed.
+All 27 main-suite test packages ran without cached results or failures.
+Build, vet, formatting, staticcheck, govulncheck, gitleaks, adapter,
+namespace, migration and performance checks passed. Median cold boot was
+103 ms against the 500 ms limit.
+
+The local gate reported two advisory timing overruns: provider tests took
+20.195 seconds against 15, and Codex tests took 37.638 seconds against 35.
+These limits become failures in the CI environment, so this local result
+does not establish that CI timing will pass. No budget was changed.
+The runner took 326.395 seconds, within its 330-second limit.
+
+Account-home contents and existing Equipo state were untouched. No
+sign-in, authenticated provider call, live gate, merge, default-branch
+push, deployment or copy-review server was run. Both live-test flags
+were unset for the full gate. Test subprocesses exited and session
+scratch was removed before commit and branch push.
diff --git a/internal/directlive/codex_inventory.go b/internal/directlive/codex_inventory.go
index 131cd0fc..2f33c4fd 100644
--- a/internal/directlive/codex_inventory.go
+++ b/internal/directlive/codex_inventory.go
@@ -4,6 +4,7 @@ import (
"amadan.net/oficina/equipo/internal/runner/provider"
"encoding/json"
"slices"
+ "strings"
)
// Read the pinned CLI's raw catalog, never a model-authored tool list.
@@ -33,6 +34,12 @@ func codexInventory(session string, frames []json.RawMessage) ([]string, error)
if !ok {
return nil, provider.ErrPolicy
}
+ for _, name := range got {
+ // Disabled features must also be absent from the live tool catalog.
+ if strings.Contains(name, "goal") || strings.Contains(name, "plugin") || name == "suggest_tools" {
+ return nil, provider.ErrPolicy
+ }
+ }
names = append(names, got...)
}
slices.Sort(names)
diff --git a/internal/directlive/try_inventory_test.go b/internal/directlive/try_inventory_test.go
index 1f9623c8..54908084 100644
--- a/internal/directlive/try_inventory_test.go
+++ b/internal/directlive/try_inventory_test.go
@@ -2,6 +2,7 @@ package directlive
import (
"encoding/json"
+ "strings"
"testing"
)
@@ -18,3 +19,14 @@ func TestSpecialistObservedCatalog(t *testing.T) {
t.Fatal("missing catalog accepted")
}
}
+
+func TestSpecialistNoGoalOrPluginTools(t *testing.T) {
+ for _, tool := range []string{"create_goal", "get_goal", "update_goal", "request_plugin_install", "list_plugins", "suggest_tools"} {
+ t.Run(tool, func(t *testing.T) {
+ raw := json.RawMessage(strings.ReplaceAll(`{"method":"rawResponseItem/completed","params":{"threadId":"session","item":{"type":"additional_tools","role":"developer","tools":[{"type":"namespace","name":"functions","tools":[{"type":"function","name":"TOOL"}]}]}}}`, "TOOL", tool))
+ if _, err := codexInventory("session", []json.RawMessage{raw}); err == nil {
+ t.Fatal("forbidden capability accepted")
+ }
+ })
+ }
+}
diff --git a/internal/release/manifest.json b/internal/release/manifest.json
index 48cc6e2a..b76c9476 100644
--- a/internal/release/manifest.json
+++ b/internal/release/manifest.json
@@ -18,103 +18,103 @@
{
"provider": "claude",
"action": "reproduce",
- "inventory_hash": "5f7f57b7992f742bbd34f9a7c438a2faebe13d0b5eb66204f45cefb675c2d2a1",
+ "inventory_hash": "4461a88e42061669b15f4f17ac4c9647dd2535d97aa9ef658cbd23e99a196c71",
"status": "uncertified"
},
{
"provider": "claude",
"action": "scope",
- "inventory_hash": "d7389ca1bc8b01ead54257ac060900f05945e5b9c8d4288acf381ce9200ff5a4",
+ "inventory_hash": "605d30bb8933d655a71812e4ba3538e5e71aa7931ddf8553360d2537a15f1f4a",
"status": "uncertified"
},
{
"provider": "claude",
"action": "recommend",
- "inventory_hash": "77634c102c1a58e733aecdcdf30b2a31134f735553d29b466c8f5d574663ccc2",
+ "inventory_hash": "88378e2c3272a0e5c33ac096e391135e7763997b56bd9938aef5912892f0cd68",
"status": "uncertified"
},
{
"provider": "claude",
"action": "investigate",
- "inventory_hash": "347e2e2df6589fb89d2a2ca92d2ef129b4f684c799c263fd019901404a989460",
+ "inventory_hash": "9e71893e8f6df2140754ed383507c2af9e823cf53f57038ff1bb94c9f303eb2d",
"status": "uncertified"
},
{
"provider": "claude",
"action": "implement",
- "inventory_hash": "5007c7ba9ba1fb42ee440dfef755a672b9e4661a8c12f74036c5fa981dca008f",
+ "inventory_hash": "ad14842ae5a456b5feba849f0266a9b0aec539d5febddbb795198c7833e2eab7",
"status": "uncertified"
},
{
"provider": "claude",
"action": "copy",
- "inventory_hash": "b759b124ab1ff2b5cd5c4d16e5f94fbcdca111a00487733a690c87bed43a72b5",
+ "inventory_hash": "93cf1c3b5892015875b539c0cbc0cec6386cad7a820452f6b417bb2a6c9b1859",
"status": "uncertified"
},
{
"provider": "claude",
"action": "design",
- "inventory_hash": "c515d7399b0e4b6a8b6e515230e434fb888cb853d849462391980e4027ea9771",
+ "inventory_hash": "9245b82ba234223254ece2e42be2068da0accb6a3010c9ac2d5e0a6e8bcd43a6",
"status": "uncertified"
},
{
"provider": "claude",
"action": "review",
- "inventory_hash": "bb08623f090d231a171c9b8bed3a31f541f157f64ecce0bd14d3834f342e7a7f",
+ "inventory_hash": "24dedbe7e36ec4bddcfaa036add9c8413fd8518a242e230dd33bf6af93f204a1",
"status": "uncertified"
},
{
"provider": "codex",
"action": "reproduce",
- "inventory_hash": "d47d4dfaaece777379a3cb2352283fbfc62e494efc2f2639b1854b8086798a1d",
+ "inventory_hash": "fcccaa4a16a4610b336d952a40fb39a38bf475a0534e8635d681fd4bf61f2e59",
"status": "uncertified"
},
{
"provider": "codex",
"action": "scope",
- "inventory_hash": "3323d907bf469c1b9360fcad127144f68d8b5edbb4a2493caab02564dc2c177c",
+ "inventory_hash": "6c4c841c3a982197fd4ddd96b09accfb95bb9bcac8ea033cad74e29fc678b401",
"status": "uncertified"
},
{
"provider": "codex",
"action": "recommend",
- "inventory_hash": "8b75831f5294aba541f18b79b6abc5342a9a5bd962d299fc83965d7423957b71",
+ "inventory_hash": "adeaf002bbe057c8cdff6f936e88736c36515ce0e355c4bd6e54d63a573553b1",
"status": "uncertified"
},
{
"provider": "codex",
"action": "investigate",
- "inventory_hash": "168e4089db1371767ee1029dd47da4d1a892e7c6c838af1b2c0213eb98331061",
+ "inventory_hash": "364020e8babe87c13b852afe97ca464b3cf232931c7c9fbe207f6a38d05ef939",
"status": "uncertified"
},
{
"provider": "codex",
"action": "implement",
- "inventory_hash": "07481884f41d57b7e3fb6c3eb54614e4fb80e97f0e82676b0b1f9cd12e2d0db2",
+ "inventory_hash": "a1f288e532bb1a05e0c3609a70420dd6e7b5349f15c2cdf4110c93caa3c19ffa",
"status": "uncertified"
},
{
"provider": "codex",
"action": "copy",
- "inventory_hash": "51f450134f7dccb85961cf54890366eda6482da1ff7bcc55d5db158ae08623b5",
+ "inventory_hash": "ef5c28d89cf4ef559c9e8bfd20b999354b82adcca8ff3d5f1583b7e30e012d95",
"status": "uncertified"
},
{
"provider": "codex",
"action": "design",
- "inventory_hash": "6372458e251dbd10c2d354ec1d511baf85a133ab6a6deeed475b9b54e221302e",
+ "inventory_hash": "dbcbec44e32f70af2b3d1d5e0f9bc67d2dabb0bbe6169de64a9f7f452985b291",
"status": "uncertified"
},
{
"provider": "codex",
"action": "review",
- "inventory_hash": "8a16b1292bd4c3e9c7d618c854cfb4fb2fe3a68a4c18a3e71cfdb17ab2921a83",
+ "inventory_hash": "aee076046a446421909429f32973146fe5eb58c89543056d39853f454845ded7",
"status": "uncertified"
},
{
"provider": "claude",
"action": "coordinate",
- "inventory_hash": "e8e71d79de46b5418f2bdceb4ce45a3e0a5e94eb63aba08c96ad4795f82e88e7",
+ "inventory_hash": "f8bca395f5b11b7ab92bc3e99088d25c47f542383687f0a47a47d16caf69739f",
"status": "uncertified"
},
{
diff --git a/internal/runner/provider/account_diagnostics_test.go b/internal/runner/provider/account_diagnostics_test.go
index c4632241..1cf4f98c 100644
--- a/internal/runner/provider/account_diagnostics_test.go
+++ b/internal/runner/provider/account_diagnostics_test.go
@@ -38,7 +38,7 @@ func TestAccountContainmentDiagnostics(t *testing.T) {
if err := os.Mkdir(filepath.Join(l.runtime, "skills"), 0700); err != nil {
t.Fatal(err)
}
- want = "runtime_policy_entry"
+ want = "runtime_codex_skills"
case "runtime-entry":
writeFake(t, filepath.Join(l.runtime, "secret-sentinel"), "secret-sentinel")
want = "runtime_unexpected_entry"
@@ -82,7 +82,7 @@ func TestAccountRecordedCodexRuntimeRefused(t *testing.T) {
}
}
err = l.ValidatePolicy(context.Background())
- if !errors.Is(err, ErrContainment) || !strings.Contains(err.Error(), "runtime_policy_entry") {
- t.Fatalf("bundled skills not refused: %v", err)
+ if !errors.Is(err, ErrContainment) || !strings.Contains(err.Error(), "runtime_codex_plugins") {
+ t.Fatalf("curated plugins not refused: %v", err)
}
}
diff --git a/internal/runner/provider/claude/launcher.go b/internal/runner/provider/claude/launcher.go
index fc13d2ae..99447b26 100644
--- a/internal/runner/provider/claude/launcher.go
+++ b/internal/runner/provider/claude/launcher.go
@@ -18,7 +18,7 @@ import (
"amadan.net/oficina/equipo/internal/runner/provider"
)
-const Version = "2.1.312"
+const Version = provider.ClaudeVersion
const ExecutableSHA256 = "4f4178ce41d83e23341ebfbaecdbcf8ea6bf7baea0690025abe49eeec3a5d01d"
const errNotReady provider.Error = "claude_not_ready"
const errUncertain provider.Error = "claude_turn_uncertain"
@@ -155,7 +155,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, specialist, mode
}
}
settings := map[string]any{
- "disableAllHooks": true, "enabledPlugins": map[string]any{"agents-md@builtin": false},
+ "disableAllHooks": true, "enabledPlugins": map[string]any{"agents-md@builtin": false, "plugin-authoring@builtin": false}, "autoMemoryEnabled": false, "autoDreamEnabled": false,
"sandbox": map[string]any{"enabled": true, "failIfUnavailable": true, "allowUnsandboxedCommands": false, "autoAllowBashIfSandboxed": true, "excludedCommands": []string{}, "filesystem": map[string]any{"denyRead": denied, "denyWrite": denied}, "network": map[string]any{"allowUnixSockets": []string{}}},
"permissions": map[string]any{"deny": nativeDenies, "allow": allow},
}
diff --git a/internal/runner/provider/claude/launcher_test.go b/internal/runner/provider/claude/launcher_test.go
index 86e4ba2c..c10766f0 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 || !reflect.DeepEqual(settings["enabledPlugins"], map[string]any{"agents-md@builtin": false}) {
+ if settings["disableAllHooks"] != true || !reflect.DeepEqual(settings["enabledPlugins"], map[string]any{"agents-md@builtin": false, "plugin-authoring@builtin": false}) || settings["autoMemoryEnabled"] != false || settings["autoDreamEnabled"] != 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"]}}}`)) {
@@ -579,11 +579,20 @@ func TestClaudeObservedIdentity(t *testing.T) {
}
}
func TestClaudePolicyRefusals(t *testing.T) {
- for _, field := range []string{"settings", "mcp", "tools", "argv", "env", "version", "helper", "managed", "managed_instruction", "hash"} {
+ for _, field := range []string{"settings", "autoMemoryEnabled", "autoDreamEnabled", "plugin-authoring@builtin", "mcp", "tools", "argv", "env", "version", "helper", "managed", "managed_instruction", "hash"} {
t.Run(field, func(t *testing.T) {
f := fixtureFor(t, "Engineering")
in := f.inputs
switch field {
+ case "autoMemoryEnabled", "autoDreamEnabled", "plugin-authoring@builtin":
+ var v map[string]any
+ json.Unmarshal(in.Settings, &v)
+ if field == "plugin-authoring@builtin" {
+ v["enabledPlugins"].(map[string]any)[field] = true
+ } else {
+ v[field] = true
+ }
+ in.Settings, _ = json.Marshal(v)
case "settings":
var v map[string]any
json.Unmarshal(in.Settings, &v)
diff --git a/internal/runner/provider/claude/runtime_replay_test.go b/internal/runner/provider/claude/runtime_replay_test.go
index 97af14f8..9660592d 100644
--- a/internal/runner/provider/claude/runtime_replay_test.go
+++ b/internal/runner/provider/claude/runtime_replay_test.go
@@ -35,6 +35,20 @@ func (h *offlineClaudeHost) Start(ctx context.Context, l provider.Launch, argv [
}
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 {
+ if m.Target == provider.SettingsPath {
+ raw, e := os.ReadFile(m.Source)
+ if e != nil || !sameJSON(raw, l.Policy.Settings) {
+ h.t.Fatal("mounted settings differ from policy", e)
+ }
+ var settings map[string]any
+ if json.Unmarshal(raw, &settings) != nil {
+ h.t.Fatal("invalid mounted settings")
+ }
+ plugins, ok := settings["enabledPlugins"].(map[string]any)
+ if !ok || plugins["agents-md@builtin"] != false || plugins["plugin-authoring@builtin"] != false || settings["autoMemoryEnabled"] != false || settings["autoDreamEnabled"] != false {
+ h.t.Fatal("startup settings readback failed")
+ }
+ }
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")
@@ -125,8 +139,8 @@ func TestClaudeEmptyHomeReplay(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")
+ if settings["enabledPlugins"].(map[string]any)["agents-md@builtin"] != false || settings["enabledPlugins"].(map[string]any)["plugin-authoring@builtin"] != false || settings["autoMemoryEnabled"] != false || settings["autoDreamEnabled"] != false {
+ t.Error("plugins, memory or dreaming not disabled")
}
source := filepath.Join(filepath.Dir(f.interactive), "dedicated")
for _, name := range []string{".credentials.json", ".claude.json"} {
diff --git a/internal/runner/provider/codex/launcher.go b/internal/runner/provider/codex/launcher.go
index 94475e11..f2a36e8a 100644
--- a/internal/runner/provider/codex/launcher.go
+++ b/internal/runner/provider/codex/launcher.go
@@ -20,7 +20,7 @@ import (
"amadan.net/oficina/equipo/internal/runner/provider"
)
-const Version = "0.165.0"
+const Version = provider.CodexVersion
const ExecutableSHA256 = "c06a67fd8ac76508dc78bd99ce20c9f317b8d568beda59485f3f4134df9962d5"
const CodeModeHostSHA256 = "522935d4392ec9674fab60b239b5495992c6a93e4deb65113a216b6f5451ccd4"
const errNotReady provider.Error = "codex_not_ready"
@@ -132,7 +132,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, model string) (p
"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, "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"}}},
+ "features": map[string]any{"incremental_tools": true, "apps": false, "multi_agent": false, "remote_control": false, "memories": false, "goals": false, "plugins": false, "remote_plugin": false, "tool_suggest": 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
index 3c32e20e..18193eaf 100644
--- a/internal/runner/provider/codex/runtime_policy_test.go
+++ b/internal/runner/provider/codex/runtime_policy_test.go
@@ -21,7 +21,7 @@ func TestCodexRuntimeSettings(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !configSubset([]byte(`{"skills":{"bundled":{"enabled":false}},"features":{"memories":false}}`), in.Settings) {
+ if !configSubset([]byte(`{"skills":{"bundled":{"enabled":false}},"features":{"memories":false,"goals":false,"plugins":false,"remote_plugin":false,"tool_suggest":false}}`), in.Settings) {
t.Fatal("skills or memories not disabled")
}
if !strings.Contains(strings.Join(in.Argv, " "), `skills={"bundled"={"enabled"=false}}`) {
@@ -31,14 +31,14 @@ func TestCodexRuntimeSettings(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- for _, key := range []string{"skills", "features"} {
+ for _, key := range []string{"skills", "memories", "goals", "plugins", "remote_plugin", "tool_suggest"} {
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
+ got["features"].(map[string]any)[key] = 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 {
diff --git a/internal/runner/provider/codex/runtime_replay_test.go b/internal/runner/provider/codex/runtime_replay_test.go
index cc000758..15c5fc61 100644
--- a/internal/runner/provider/codex/runtime_replay_test.go
+++ b/internal/runner/provider/codex/runtime_replay_test.go
@@ -163,8 +163,10 @@ func TestCodexEmptyHomeReplay(t *testing.T) {
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)
+ for _, name := range []string{"skills", ".tmp/plugins.sha", ".tmp/plugins"} {
+ if _, err = os.Lstat(filepath.Join(f.lease.Binding().Home, name)); !os.IsNotExist(err) {
+ t.Fatalf("disabled startup artifact %s: %v", name, err)
+ }
}
// Only make the fixture ready after all real processes have exited, so
// ValidatePolicy can check their actual startup files. No CLI uses this
diff --git a/internal/runner/provider/direct_certification.go b/internal/runner/provider/direct_certification.go
index e68d2c5a..9998403b 100644
--- a/internal/runner/provider/direct_certification.go
+++ b/internal/runner/provider/direct_certification.go
@@ -149,7 +149,7 @@ func (e DirectEvidence) ValidateGroup(root, group string) error {
if len(required) == 0 || e.Schema != 1 || e.Source != "direct-live" || e.RunID == "" || e.LauncherVersion != LauncherVersion || e.BwrapVersion != "0.11.0" || e.PolicyVersion != PolicyVersion || !liveDigest(e.PolicyHash) || !liveDigest(e.ConfigSHA256) || e.AccountID == "" || e.HomeID == "" || e.Model == "" || e.AuthHost != "" {
return ErrPolicy
}
- version := map[string]string{"claude": "2.1.312", "codex": "0.165.0"}[e.Provider]
+ version := map[string]string{"claude": ClaudeVersion, "codex": CodexVersion}[e.Provider]
if version == "" || version != e.ProviderVersion {
return ErrPolicy
}
diff --git a/internal/runner/provider/direct_live_config.go b/internal/runner/provider/direct_live_config.go
index 0c86fcb4..a652dd0d 100644
--- a/internal/runner/provider/direct_live_config.go
+++ b/internal/runner/provider/direct_live_config.go
@@ -89,7 +89,7 @@ func (c DirectLiveConfig) Validate(enabled string) error {
rules := DefaultHomeRules()
for _, entry := range c.Bindings {
b := entry.Binding
- version := map[string]string{"claude": "2.1.312", "codex": "0.165.0"}[b.Provider]
+ version := map[string]string{"claude": ClaudeVersion, "codex": CodexVersion}[b.Provider]
if version == "" || seen[b.Provider] || b.ID == "" || b.AccountID == "" || b.Expected.AccountID != b.AccountID || b.Expected.HomeID == "" || b.Expected.ProviderVersion != version || entry.Model == "" || entry.AuthHost != "" || (b.Provider == "claude" && !entry.ClaudeTOFUConfirmed) {
return ErrIdentity
}
@@ -120,7 +120,7 @@ func (c DirectLiveConfig) Validate(enabled string) error {
changes["claude"] = *c.AccountChange
}
for family, b := range changes {
- version := map[string]string{"claude": "2.1.312", "codex": "0.165.0"}[family]
+ version := map[string]string{"claude": ClaudeVersion, "codex": CodexVersion}[family]
if version == "" || b.Provider != family || b.ID == "" || b.AccountID == "" || b.Expected.AccountID != b.AccountID || b.Expected.HomeID == "" || b.Expected.ProviderVersion != version {
return ErrIdentity
}
diff --git a/internal/runner/provider/login_terminal.go b/internal/runner/provider/login_terminal.go
index e4a10c5c..72a562cb 100644
--- a/internal/runner/provider/login_terminal.go
+++ b/internal/runner/provider/login_terminal.go
@@ -37,7 +37,7 @@ func NewLoginDriver(options ...LoginOptions) LoginDriver {
}
func LoginVersion(name string) string {
- return map[string]string{"claude": "2.1.312", "codex": "0.165.0"}[name]
+ return map[string]string{"claude": ClaudeVersion, "codex": CodexVersion}[name]
}
func (d *terminalLoginDriver) binary(name string) string {
if name == "claude" {
diff --git a/internal/runner/provider/runtime_claude.go b/internal/runner/provider/runtime_claude.go
index dc437f0b..921deb63 100644
--- a/internal/runner/provider/runtime_claude.go
+++ b/internal/runner/provider/runtime_claude.go
@@ -9,8 +9,14 @@ import (
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.
+// 2.1.312 uses Date.now() and Math.random().toString(36).substring(2,8).
+// Its session suffix helper is disabled in this binary.
+var claudeShellSnapshot = regexp.MustCompile(`^shell-snapshots/snapshot-(bash|zsh|sh)-[0-9]{13}-[a-z0-9]{0,6}\.sh$`)
+var claudeSessionDir = regexp.MustCompile(`^session-env/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)
+var claudeSessionFile = regexp.MustCompile(`^session-env/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/(setup|sessionstart|cwdchanged|filechanged)-hook-[0-9]+\.sh$`)
+
+// Only pinned startup paths are runtime state. Empty support directories
+// do not authorize SSH, config, mod or seed files.
func (l *AccountLease) claudeRuntimeEntry(rel string, info os.FileInfo) (bool, error) {
top := strings.SplitN(rel, "/", 2)[0]
category := ""
@@ -25,18 +31,28 @@ func (l *AccountLease) claudeRuntimeEntry(rel string, info os.FileInfo) (bool, e
category = "dev_mods"
case "seed-admin":
category = "seed_admin"
+ case "policy-limits.json", "policy-limits.json.signature.json", "policy-limits.json.signature-iat.json":
+ category = "policy_limits"
+ case "shell-snapshots":
+ category = "shell_snapshots"
+ case "session-env":
+ category = "session_env"
default:
return false, nil
}
- if l.source.Expected.ProviderVersion != "2.1.312" {
+ if l.source.Expected.ProviderVersion != ClaudeVersion {
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":
+ case ".cache", ".cache/claude-cli-nodejs", ".cache/claude-cli-nodejs/-workspace", ".cache/claude-cli-nodejs/-workspace/mcp-logs-equipo", ".config", ".config/anthropic", ".claude", ".claude/ssh", ".npm", ".npm/_logs", "dev-mods", "seed-admin", "shell-snapshots", "session-env":
directory = true
+ case "policy-limits.json", "policy-limits.json.signature.json", "policy-limits.json.signature-iat.json":
default:
- if rel != ".npm/_update-notifier-last-checked" && !claudeRuntimeLog.MatchString(rel) && !claudeNPMLog.MatchString(rel) {
+ // These scripts are safe only while agent tools cannot access the staged
+ // home: claude/launcher.go:139-149 builds native and Bash sandbox denies.
+ directory = claudeSessionDir.MatchString(rel)
+ if !directory && !claudeShellSnapshot.MatchString(rel) && !claudeSessionFile.MatchString(rel) && rel != ".npm/_update-notifier-last-checked" && !claudeRuntimeLog.MatchString(rel) && !claudeNPMLog.MatchString(rel) {
return true, accountContainment("runtime_claude_" + category)
}
}
diff --git a/internal/runner/provider/runtime_claude_test.go b/internal/runner/provider/runtime_claude_test.go
index e3f9fa5e..f1408b7b 100644
--- a/internal/runner/provider/runtime_claude_test.go
+++ b/internal/runner/provider/runtime_claude_test.go
@@ -77,7 +77,7 @@ func TestAccountClaudeRuntimeGuards(t *testing.T) {
{"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"},
+ {".cache/agents", "dir", "policy_entry"}, {"shell-snapshots/evil", "dir", "shell_snapshots"}, {"session-env/evil", "dir", "session_env"},
{"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"},
diff --git a/internal/runner/provider/runtime_home.go b/internal/runner/provider/runtime_home.go
index 3aafdd9f..59212160 100644
--- a/internal/runner/provider/runtime_home.go
+++ b/internal/runner/provider/runtime_home.go
@@ -25,24 +25,41 @@ func (l *AccountLease) validateRuntimeEntries() error {
return nil
}
name := d.Name()
+ rel, err := filepath.Rel(l.runtime, path)
+ if err != nil {
+ return reason("walk")
+ }
+ entryReason := reason
+ if l.source.Provider == "codex" {
+ entryReason = func(category string) error {
+ if known := codexRuntimeCategory(rel); known != "" {
+ return accountContainment("runtime_codex_" + known)
+ }
+ return reason(category)
+ }
+ if strings.HasPrefix(rel, ".tmp/plugins") {
+ return entryReason("policy_entry")
+ }
+ if codexArg0Link.MatchString(rel) && d.Type()&os.ModeSymlink == 0 {
+ return entryReason("special_entry")
+ }
+ }
+ if l.source.Provider == "claude" && name == "remote-settings.json" {
+ return accountContainment("runtime_claude_remote_settings")
+ }
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) {
+ if statErr == nil && l.codexRuntimeLink(path, rel, info) {
return nil
}
- return reason("special_entry")
+ return entryReason("special_entry")
}
if d.Type()&(os.ModeSocket|os.ModeDevice|os.ModeNamedPipe) != 0 {
- return reason("special_entry")
- }
- if runtimePolicyEntry(name) {
- return reason("policy_entry")
+ return entryReason("special_entry")
}
-
- rel, err := filepath.Rel(l.runtime, path)
- if err != nil {
- return reason("walk")
+ claudeShell := l.source.Provider == "claude" && l.source.Expected.ProviderVersion == ClaudeVersion && (rel == "shell-snapshots" || rel == "session-env")
+ if runtimePolicyEntry(name) && !claudeShell {
+ return entryReason("policy_entry")
}
top := strings.SplitN(rel, string(filepath.Separator), 2)[0]
if l.source.Provider == "claude" {
@@ -54,21 +71,21 @@ func (l *AccountLease) validateRuntimeEntries() error {
return e
}
}
- if l.source.Provider == "codex" && l.source.Expected.ProviderVersion == "0.165.0" {
+ if l.source.Provider == "codex" && l.source.Expected.ProviderVersion == CodexVersion {
scratch := top == ".tmp" || top == "tmp"
if scratch || codexRuntimeState(top) {
info, err := d.Info()
if err != nil || !runtimeEntryMetadata(info) {
- return accountContainment("runtime_codex_metadata")
+ return entryReason("metadata")
}
if (scratch && rel == top && !info.IsDir()) || (!scratch && !info.Mode().IsRegular()) {
- return accountContainment("runtime_codex_kind")
+ return entryReason("kind")
}
return nil
}
}
if filepath.Dir(path) == l.runtime && !allowed[name] && !strings.HasPrefix(name, "state_") && !strings.HasPrefix(name, "logs_") {
- return reason("unexpected_entry")
+ return entryReason("unexpected_entry")
}
return nil
})
@@ -96,7 +113,7 @@ func runtimeEntryMetadata(info os.FileInfo) bool {
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) {
+ if l.source.Provider != "codex" || l.source.Expected.ProviderVersion != CodexVersion || !codexArg0Link.MatchString(rel) {
return false
}
stat, ok := info.Sys().(*syscall.Stat_t)
@@ -106,3 +123,27 @@ func (l *AccountLease) codexRuntimeLink(path, rel string, info os.FileInfo) bool
target, err := os.Readlink(path)
return err == nil && target == "/opt/codex"
}
+
+func codexRuntimeCategory(rel string) string {
+ if strings.HasPrefix(rel, ".tmp/plugins") {
+ return "plugins"
+ }
+ if strings.HasPrefix(rel, "tmp/arg0-linux") {
+ return "arg0"
+ }
+ top := strings.SplitN(rel, "/", 2)[0]
+ switch top {
+ case ".tmp":
+ return "dot_tmp"
+ case "tmp":
+ return "tmp"
+ case "skills", "plugins", "installation_id":
+ return top
+ }
+ for _, state := range []string{"goals", "memories", "queue"} {
+ if strings.HasPrefix(top, state+"_") {
+ return state
+ }
+ }
+ return ""
+}
diff --git a/internal/runner/provider/runtime_links_test.go b/internal/runner/provider/runtime_links_test.go
index 64c13051..06cfc98c 100644
--- a/internal/runner/provider/runtime_links_test.go
+++ b/internal/runner/provider/runtime_links_test.go
@@ -18,6 +18,8 @@ func TestAccountCodexRuntimeLinks(t *testing.T) {
{"apply_patch", dir + "apply_patch", "/opt/codex", true},
{"applypatch", dir + "applypatch", "/opt/codex", true},
{"sandbox", dir + "codex-linux-sandbox", "/opt/codex", true},
+ {"regular", dir + "apply_patch", "", false},
+ {"directory", dir + "applypatch", "", false},
{"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},
@@ -43,7 +45,15 @@ func TestAccountCodexRuntimeLinks(t *testing.T) {
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
t.Fatal(err)
}
- if err := os.Symlink(tc.target, path); err != nil {
+ var createErr error
+ if tc.name == "regular" {
+ createErr = os.WriteFile(path, []byte("fixture"), 0600)
+ } else if tc.name == "directory" {
+ createErr = os.Mkdir(path, 0700)
+ } else {
+ createErr = os.Symlink(tc.target, path)
+ }
+ if err := createErr; err != nil {
t.Fatal(err)
}
if tc.name == "other-version" {
@@ -57,7 +67,7 @@ func TestAccountCodexRuntimeLinks(t *testing.T) {
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")) {
+ } else if !errors.Is(err, ErrContainment) || (tc.name != "other-version" && tc.name != "other-provider" && !strings.Contains(err.Error(), "runtime_special_entry") && !strings.Contains(err.Error(), "runtime_codex_")) {
t.Fatalf("unsafe link accepted or wrong reason: %v", err)
}
if tc.name == "source-not-staged" {
diff --git a/internal/runner/provider/runtime_startup_test.go b/internal/runner/provider/runtime_startup_test.go
new file mode 100644
index 00000000..f6133ab2
--- /dev/null
+++ b/internal/runner/provider/runtime_startup_test.go
@@ -0,0 +1,148 @@
+package provider
+
+import (
+ "context"
+ "errors"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "golang.org/x/sys/unix"
+)
+
+const sessionEnvFixture = "session-env/12345678-1234-4123-8123-123456789abc/"
+
+func TestAccountClaudeAuthenticatedState(t *testing.T) {
+ for _, name := range []string{"policy-limits.json", "policy-limits.json.signature.json", "policy-limits.json.signature-iat.json", "shell-snapshots/snapshot-bash-1793880000000-abc123.sh", "shell-snapshots/snapshot-zsh-1793880000000-0.sh", "shell-snapshots/snapshot-sh-1793880000000-.sh", sessionEnvFixture + "setup-hook-0.sh", sessionEnvFixture + "sessionstart-hook-123.sh", sessionEnvFixture + "cwdchanged-hook-1.sh", sessionEnvFixture + "filechanged-hook-9.sh"} {
+ t.Run(name, func(t *testing.T) {
+ for _, kind := range []string{"file", "directory", "link", "hardlink", "fifo", "setuid", "setgid", "version", "provider", "source"} {
+ t.Run(kind, func(t *testing.T) {
+ fullTurn := kind == "file" || kind == "source"
+ l := &AccountLease{source: Binding{Provider: "claude", Expected: Identity{ProviderVersion: ClaudeVersion}}, runtime: t.TempDir()}
+ ctx := context.Background()
+ if fullTurn {
+ l = claudeRuntimeFixture(t)
+ preflightFixture(t, l)
+ if err := l.BeginTurn(ctx); err != nil {
+ t.Fatal(err)
+ }
+ }
+ root := l.runtime
+ if kind == "source" {
+ root = l.source.Home
+ }
+ path := filepath.Join(root, name)
+ if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
+ t.Fatal(err)
+ }
+ var err error
+ switch kind {
+ case "directory":
+ err = os.Mkdir(path, 0700)
+ case "link":
+ err = os.Symlink("/opt/claude", path)
+ case "hardlink":
+ target := filepath.Join(t.TempDir(), "state")
+ writeFake(t, target, "fixture")
+ err = os.Link(target, path)
+ case "fifo":
+ err = unix.Mkfifo(path, 0600)
+ default:
+ err = os.WriteFile(path, []byte("fixture"), 0600)
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ if kind == "setuid" {
+ err = os.Chmod(path, 0600|os.ModeSetuid)
+ }
+ if kind == "setgid" {
+ err = os.Chmod(path, 0600|os.ModeSetgid)
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ if fullTurn {
+ if err = l.EndTurn(ctx); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if kind == "source" {
+ preflightFixture(t, l)
+ if _, err = os.Lstat(filepath.Join(l.runtime, name)); !os.IsNotExist(err) {
+ t.Fatal("source runtime state staged")
+ }
+ }
+ if kind == "version" {
+ l.source.Expected.ProviderVersion = "other"
+ }
+ if kind == "provider" {
+ l.source.Provider = "other"
+ }
+ if !fullTurn {
+ err = l.validateRuntimeEntries()
+ } else {
+ err = l.BeginTurn(ctx)
+ }
+ if kind == "file" || kind == "source" {
+ if err != nil {
+ t.Fatalf("second turn: %v", err)
+ }
+ } else if !errors.Is(err, ErrContainment) {
+ t.Fatalf("unsafe %s accepted: %v", kind, err)
+ }
+ })
+ }
+ })
+ }
+}
+
+func TestAccountStartupRefusals(t *testing.T) {
+ for _, tc := range []struct{ family, path, category string }{
+ {"claude", "remote-settings.json", "runtime_claude_remote_settings"},
+ {"claude", "policy-limits.json.extra", "runtime_claude_unexpected_entry"},
+ {"claude", "shell-snapshots/evil.sh", "runtime_claude_shell_snapshots"},
+ {"claude", "shell-snapshots/snapshot-fish-1793880000000-abc123.sh", "runtime_claude_shell_snapshots"},
+ {"claude", "shell-snapshots/snapshot-bash-1793880000000-abcdefg.sh", "runtime_claude_shell_snapshots"},
+ {"claude", "shell-snapshots/snapshot-bash-1793880000000-ABC123.sh", "runtime_claude_shell_snapshots"},
+ {"claude", "shell-snapshots/snapshot-bash-1793880000000-abc123-session.sh", "runtime_claude_shell_snapshots"},
+ {"claude", "shell-snapshots/nested/evil.sh", "runtime_claude_shell_snapshots"},
+ {"claude", "session-env/not-a-uuid/setup-hook-1.sh", "runtime_claude_session_env"},
+ {"claude", sessionEnvFixture + "evil.sh", "runtime_claude_session_env"},
+ {"claude", sessionEnvFixture + "setup-hook-x.sh", "runtime_claude_session_env"},
+ {"claude", sessionEnvFixture + "stop-hook-1.sh", "runtime_claude_session_env"},
+ {"claude", sessionEnvFixture + "nested/setup-hook-1.sh", "runtime_claude_session_env"},
+ {"claude", "logs/shell-snapshots/evil.sh", "runtime_claude_policy_entry"},
+ {"codex", ".tmp/plugins.sha", "runtime_codex_plugins"},
+ {"codex", ".tmp/plugins/cache", "runtime_codex_plugins"},
+ {"codex", ".tmp/plugins-other", "runtime_codex_plugins"},
+ {"codex", "tmp/config.toml", "runtime_codex_tmp"},
+ {"codex", ".tmp/config.toml", "runtime_codex_dot_tmp"},
+ {"codex", "skills/.system/evil", "runtime_codex_skills"},
+ {"codex", "installation_id/evil", "runtime_codex_installation_id"},
+ {"codex", "goals_1.sqlite/evil", "runtime_codex_goals"},
+ {"codex", "memories_1.sqlite/evil", "runtime_codex_memories"},
+ {"codex", "queue_1.sqlite/evil", "runtime_codex_queue"},
+ {"codex", "tmp/arg0-linux/codex-arg0abc123/apply_patch", "runtime_codex_arg0"},
+ } {
+ t.Run(tc.family+"/"+tc.path, func(t *testing.T) {
+ var l *AccountLease
+ if tc.family == "claude" {
+ l = claudeRuntimeFixture(t)
+ } else {
+ b, r := accountFixture(t)
+ l = openFixture(t, b, r)
+ }
+ path := filepath.Join(l.runtime, tc.path)
+ if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
+ t.Fatal(err)
+ }
+ writeFake(t, path, "secret-sentinel")
+ err := l.validateRuntimeEntries()
+ if !errors.Is(err, ErrContainment) || !strings.Contains(err.Error(), tc.category) || strings.Contains(err.Error(), "secret-sentinel") {
+ t.Fatalf("want %s: %v", tc.category, err)
+ }
+ })
+ }
+}
diff --git a/internal/runner/provider/types.go b/internal/runner/provider/types.go
index 19cbfde4..3683c139 100644
--- a/internal/runner/provider/types.go
+++ b/internal/runner/provider/types.go
@@ -10,6 +10,10 @@ import (
const Version = 2
+// Provider pins are shared by launchers and staged-home validation.
+const ClaudeVersion = "2.1.312"
+const CodexVersion = "0.165.0"
+
type Selection struct {
ConnectionID, Provider, Family, Model, AccountID string
}
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 8fdfba94..10da52e9 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -7498,28 +7498,28 @@
},
{
"path": "internal/runner/provider/runtime_claude.go",
- "line_sha256": "df8f195cf927c0e7896bad695d3c01e2da30d594170c17c104a5af2c681019ca",
+ "line_sha256": "04f646f29e45ec7d48258e933c2b1b17dae3a32ee06dbee129eeeef9e208fcd6",
"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",
+ "line_sha256": "04f646f29e45ec7d48258e933c2b1b17dae3a32ee06dbee129eeeef9e208fcd6",
"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",
+ "line_sha256": "afe728150ad11996748ee1318be2a51fb94edc004bd6566a41362be4b7f03320",
"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",
+ "line_sha256": "afe728150ad11996748ee1318be2a51fb94edc004bd6566a41362be4b7f03320",
"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."