* fix(#1151): drive codex sandbox_mode emission from runtime descriptor sandboxTier axis The sandboxTier runtime-capability axis was cosmetic: declared and validated on all 16 descriptors but read by nothing. The codex per-agent sandbox_mode line was emitted unconditionally from the hardcoded CODEX_AGENT_SANDBOX map, so the descriptor field drove no behaviour (ADR-857 audit finding F10; the "rides along in 5e/5g" promise in ADR-1016 §8 never landed). Make the axis load-bearing: - resolveInstallPlan projects sandboxTier as a 7th InstallPlan axis and fails loud (throws) on a missing/invalid value rather than coercing to 'none'. - installCodexConfig / generateCodexAgentToml gate sandbox_mode emission on sandboxTier !== 'none'. - The per-agent CODEX_AGENT_SANDBOX map is kept: it is GSD agent policy, not a runtime-descriptor property (different layer). Full removal of that map is tracked under #1138 (phase-6 descriptor-residue removal). For codex (sandboxTier === 'codex-agent-sandbox') the emitted TOML is byte-identical to before; for 'none' runtimes sandbox_mode is omitted. Adds leaf, projection, and installCodexConfig threading-seam regression tests; updates the enh-1082 InstallPlan golden master with sandboxTier for all 16 runtimes. Confirmed hypothesis: schema-first vocabulary closure outran consumer wiring, with no conformance gate to catch the orphaned axis. Closes #1151 Refs #857, #1138 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(#1151): stamp changeset with PR number 1152 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,8 @@ const {
|
||||
resolveNodeRunner,
|
||||
} = require('../bin/install.js');
|
||||
|
||||
const { resolveInstallPlan } = require('../gsd-core/bin/lib/runtime-config-adapter-registry.cjs');
|
||||
|
||||
function runCodexInstall(codexHome, cwd = path.join(__dirname, '..')) {
|
||||
const previousCodeHome = process.env.CODEX_HOME;
|
||||
const previousCwd = process.cwd();
|
||||
@@ -579,6 +581,109 @@ description: Maps the codebase
|
||||
});
|
||||
});
|
||||
|
||||
// ─── sandboxTier gate on generateCodexAgentToml ────────────────────────────────
|
||||
|
||||
describe('generateCodexAgentToml sandboxTier gate', () => {
|
||||
const sampleAgent = `---
|
||||
name: gsd-executor
|
||||
description: Executes plans
|
||||
tools: Read, Write, Edit
|
||||
color: yellow
|
||||
---
|
||||
|
||||
<role>You are an executor.</role>`;
|
||||
|
||||
test('sandboxTier=none: does NOT emit sandbox_mode', () => {
|
||||
const result = generateCodexAgentToml('gsd-executor', sampleAgent, null, null, null, 'none');
|
||||
assert.ok(!result.includes('sandbox_mode'), 'sandbox_mode must be absent when sandboxTier is none');
|
||||
});
|
||||
|
||||
test('sandboxTier=codex-agent-sandbox: emits sandbox_mode = "workspace-write"', () => {
|
||||
const result = generateCodexAgentToml('gsd-executor', sampleAgent, null, null, null, 'codex-agent-sandbox');
|
||||
assert.ok(result.includes('sandbox_mode = "workspace-write"'), 'must emit workspace-write for codex-agent-sandbox tier');
|
||||
});
|
||||
|
||||
test('default (no sandboxTier arg): still emits sandbox_mode = "workspace-write" (no-op for codex)', () => {
|
||||
const result = generateCodexAgentToml('gsd-executor', sampleAgent);
|
||||
assert.ok(result.includes('sandbox_mode = "workspace-write"'), 'default preserves codex behavior');
|
||||
});
|
||||
|
||||
test('resolveInstallPlan projection: codex.sandboxTier === "codex-agent-sandbox"', () => {
|
||||
const plan = resolveInstallPlan('codex');
|
||||
assert.strictEqual(plan.sandboxTier, 'codex-agent-sandbox', 'codex must project sandboxTier=codex-agent-sandbox');
|
||||
});
|
||||
|
||||
test('resolveInstallPlan projection: claude.sandboxTier === "none"', () => {
|
||||
const plan = resolveInstallPlan('claude');
|
||||
assert.strictEqual(plan.sandboxTier, 'none', 'claude must project sandboxTier=none');
|
||||
});
|
||||
});
|
||||
|
||||
// ─── installCodexConfig threading-seam: sandboxTier → per-agent TOML ─────────
|
||||
|
||||
describe('installCodexConfig sandboxTier threading seam', () => {
|
||||
const { installCodexConfig } = require('../bin/install.js');
|
||||
|
||||
let tmpDir;
|
||||
let agentsSrc;
|
||||
let targetDir;
|
||||
|
||||
beforeEach(() => {
|
||||
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-sandboxtier-seam-'));
|
||||
agentsSrc = path.join(tmpDir, 'agents');
|
||||
targetDir = path.join(tmpDir, 'codex');
|
||||
fs.mkdirSync(agentsSrc, { recursive: true });
|
||||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
// Write a minimal gsd-executor agent fixture
|
||||
fs.writeFileSync(path.join(agentsSrc, 'gsd-executor.md'), [
|
||||
'---',
|
||||
'name: gsd-executor',
|
||||
'description: Executes plans',
|
||||
'tools: Read, Write, Edit',
|
||||
'---',
|
||||
'',
|
||||
'<role>You are an executor.</role>',
|
||||
].join('\n'));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup(tmpDir);
|
||||
});
|
||||
|
||||
test('sandboxTier=none: written per-agent .toml does NOT contain sandbox_mode', () => {
|
||||
installCodexConfig(targetDir, agentsSrc, 'none');
|
||||
const tomlPath = path.join(targetDir, 'agents', 'gsd-executor.toml');
|
||||
assert.ok(fs.existsSync(tomlPath), 'per-agent TOML must be written');
|
||||
const toml = fs.readFileSync(tomlPath, 'utf8');
|
||||
assert.ok(!toml.includes('sandbox_mode'), 'sandbox_mode must be absent when sandboxTier=none');
|
||||
});
|
||||
|
||||
test('sandboxTier=codex-agent-sandbox: written per-agent .toml contains sandbox_mode', () => {
|
||||
installCodexConfig(targetDir, agentsSrc, 'codex-agent-sandbox');
|
||||
const tomlPath = path.join(targetDir, 'agents', 'gsd-executor.toml');
|
||||
assert.ok(fs.existsSync(tomlPath), 'per-agent TOML must be written');
|
||||
const toml = fs.readFileSync(tomlPath, 'utf8');
|
||||
assert.ok(toml.includes('sandbox_mode'), 'sandbox_mode must be present when sandboxTier=codex-agent-sandbox');
|
||||
});
|
||||
|
||||
test('default 2-arg form (no sandboxTier): written per-agent .toml contains sandbox_mode (codex default)', () => {
|
||||
installCodexConfig(targetDir, agentsSrc);
|
||||
const tomlPath = path.join(targetDir, 'agents', 'gsd-executor.toml');
|
||||
assert.ok(fs.existsSync(tomlPath), 'per-agent TOML must be written');
|
||||
const toml = fs.readFileSync(tomlPath, 'utf8');
|
||||
assert.ok(toml.includes('sandbox_mode'), 'sandbox_mode must be present in default 2-arg form (codex-agent-sandbox default)');
|
||||
});
|
||||
});
|
||||
|
||||
// NOTE: A test for the new fail-loud throw on missing/invalid sandboxTier in
|
||||
// resolveInstallPlan is omitted here. Constructing a descriptor without the
|
||||
// field would require mocking the capability-registry module which is a
|
||||
// singleton require(); patching it invasively would corrupt other tests in the
|
||||
// same process. The throw path is verified at the type level (tsc) and by the
|
||||
// build passing, and the happy-path coverage (claude.sandboxTier === 'none' and
|
||||
// codex.sandboxTier === 'codex-agent-sandbox') confirms the real registry has
|
||||
// valid values for all 16 runtimes.
|
||||
|
||||
// ─── CODEX_AGENT_SANDBOX mapping ────────────────────────────────────────────────
|
||||
|
||||
describe('CODEX_AGENT_SANDBOX', () => {
|
||||
|
||||
@@ -26,6 +26,7 @@ const EXPECTED = {
|
||||
hookEvents: 'claude',
|
||||
extendedHookEvents: ['SubagentStop', 'Stop', 'PreCompact', 'FileChanged'],
|
||||
hooksSurface: 'settings-json',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
codex: {
|
||||
runtime: 'codex',
|
||||
@@ -35,6 +36,7 @@ const EXPECTED = {
|
||||
hookEvents: 'claude',
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'codex-hooks-json',
|
||||
sandboxTier: 'codex-agent-sandbox',
|
||||
},
|
||||
antigravity: {
|
||||
runtime: 'antigravity',
|
||||
@@ -44,6 +46,7 @@ const EXPECTED = {
|
||||
hookEvents: 'gemini',
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'settings-json',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
gemini: {
|
||||
runtime: 'gemini',
|
||||
@@ -53,6 +56,7 @@ const EXPECTED = {
|
||||
hookEvents: 'gemini',
|
||||
extendedHookEvents: ['BeforeAgent', 'AfterAgent', 'BeforeModel'],
|
||||
hooksSurface: 'settings-json',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
cursor: {
|
||||
runtime: 'cursor',
|
||||
@@ -62,6 +66,7 @@ const EXPECTED = {
|
||||
hookEvents: 'claude',
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'cursor-hooks-json',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
opencode: {
|
||||
runtime: 'opencode',
|
||||
@@ -71,6 +76,7 @@ const EXPECTED = {
|
||||
hookEvents: undefined,
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'none',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
kilo: {
|
||||
runtime: 'kilo',
|
||||
@@ -80,6 +86,7 @@ const EXPECTED = {
|
||||
hookEvents: undefined,
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'none',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
copilot: {
|
||||
runtime: 'copilot',
|
||||
@@ -89,6 +96,7 @@ const EXPECTED = {
|
||||
hookEvents: undefined,
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'copilot-inline',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
augment: {
|
||||
runtime: 'augment',
|
||||
@@ -98,6 +106,7 @@ const EXPECTED = {
|
||||
hookEvents: 'claude',
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'settings-json',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
trae: {
|
||||
runtime: 'trae',
|
||||
@@ -107,6 +116,7 @@ const EXPECTED = {
|
||||
hookEvents: undefined,
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'none',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
qwen: {
|
||||
runtime: 'qwen',
|
||||
@@ -116,6 +126,7 @@ const EXPECTED = {
|
||||
hookEvents: 'claude',
|
||||
extendedHookEvents: ['SubagentStop', 'Stop', 'PreCompact'],
|
||||
hooksSurface: 'settings-json',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
hermes: {
|
||||
runtime: 'hermes',
|
||||
@@ -125,6 +136,7 @@ const EXPECTED = {
|
||||
hookEvents: 'claude',
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'settings-json',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
codebuddy: {
|
||||
runtime: 'codebuddy',
|
||||
@@ -134,6 +146,7 @@ const EXPECTED = {
|
||||
hookEvents: 'claude',
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'settings-json',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
cline: {
|
||||
runtime: 'cline',
|
||||
@@ -143,6 +156,7 @@ const EXPECTED = {
|
||||
hookEvents: undefined,
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'cline-rules',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
kimi: {
|
||||
runtime: 'kimi',
|
||||
@@ -152,6 +166,7 @@ const EXPECTED = {
|
||||
hookEvents: undefined,
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'none',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
windsurf: {
|
||||
runtime: 'windsurf',
|
||||
@@ -161,6 +176,7 @@ const EXPECTED = {
|
||||
hookEvents: undefined,
|
||||
extendedHookEvents: [],
|
||||
hooksSurface: 'none',
|
||||
sandboxTier: 'none',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user