Exercise emergency routing through the Codex adapter

Why: Parser hardening requires the emergency fixture to use the real Codex adapter contract instead of a custom adapter.

Evidence: Agent-exec and config suites pass 58 executions with one opt-in probe skipped; validate and diff-check pass.

Impact: Test fixture only; production validation remains strict.

Refs: feature/agent-cli-enforcement
This commit is contained in:
2026-10-15 16:54:23 +00:00
parent d54306b65e
commit 2a994ca768
+27 -5
View File
@@ -185,6 +185,12 @@ def _write_fake_worker(
return path
def _codex_help() -> str:
from scripts.agent_exec_adapters import _REQUIRED_HELP_MARKERS
return "\n".join(_REQUIRED_HELP_MARKERS["codex"]) + "\n"
class AgentExecControllerTests(unittest.TestCase):
def setUp(self) -> None:
self.tmp = tempfile.TemporaryDirectory(prefix="agent-exec-ctrl-")
@@ -589,13 +595,27 @@ class AgentExecControllerTests(unittest.TestCase):
_write_fake_worker(
self.bindir,
"codex",
help_text=_codex_help(),
body=textwrap.dedent(
f"""\
if [ "$1" = "exec" ] && [ "$2" = "--help" ]; then
exec "$0" --help
fi
printf 'codex\\n' >> "{launches}"
workspace="$1"
result="$3"
mkdir -p "$workspace/src"
printf 'final\\n' > "$workspace/src/marker.txt"
result=""
prev=""
for arg in "$@"; do
if [ "$prev" = "--output-last-message" ]; then
result="$arg"
fi
prev="$arg"
done
if [ -z "$result" ]; then
echo "missing --output-last-message" >&2
exit 2
fi
mkdir -p src
printf 'final\\n' > src/marker.txt
printf '%s\\n' '{{"terminal_status":"completed","summary":"done","changed_files":["src/marker.txt"],"evidence":[],"scope_expansion":null}}' > "$result"
exit 0
"""
@@ -604,7 +624,7 @@ class AgentExecControllerTests(unittest.TestCase):
self._configure(
profiles={
"regular": {"adapter": "custom", "executable": "regular"},
"codex": {"adapter": "custom", "executable": "codex"},
"codex": {"adapter": "codex", "executable": "codex", "model": "auto"},
},
role_order=["regular"],
max_attempts_per_profile=3,
@@ -614,6 +634,7 @@ class AgentExecControllerTests(unittest.TestCase):
self.assertEqual(loaded.execution.max_attempts_per_profile, 3)
self.assertEqual(loaded.execution.emergency_profile, "codex")
self.assertIn("codex", loaded.profiles)
self.assertEqual(loaded.profiles["codex"].adapter, "codex")
for role_names in loaded.roles.values():
self.assertNotIn("codex", role_names)
unit = _write_unit(self.root / "unit.json")
@@ -655,6 +676,7 @@ class AgentExecControllerTests(unittest.TestCase):
line for line in launches.read_text(encoding="utf-8").splitlines() if line
]
self.assertEqual(observed, ["regular", "regular", "regular", "codex"])
self.assertEqual(data["attempts"][-1]["summary"], "done")
self.assertEqual(proc.returncode, agent_exec.EXIT_SUCCESS, proc.stderr + proc.stdout)
self._assert_canonical_untouched()