| Phase | 1 — Contracts |
| Status | Not started |
| Depends on | 01 |
| Size | M |
| Drop-in critical | ★ (policy files + decision semantics) |
Port codex-execpolicy: the Starlark-based, prefix-rule engine that classifies a
command as allow / prompt / forbidden, including host_executable basename
resolution. Used by codex-protocol, config, and core.
reference-codex/codex-rs/execpolicy/(src/,README.md).reference-codex/codex-rs/execpolicy-legacy/(older Starlark engine — port only if still referenced; document if dropped).reference-codex/docs/execpolicy.md.
- Evaluate Starlark policy files exposing
prefix_rule(pattern, decision, justification, match, not_match)andhost_executable(name, paths)viago.starlark.net. - Matching semantics:
- Ordered token match;
[...]token = OR alternatives. - Exact first-token (absolute path) match wins; otherwise basename fallback resolves the program name.
host_executable(name, paths)restricts basename fallback to listed paths; absence → unrestricted fallback.- Strictest decision wins (
forbidden>prompt>allow).
- Ordered token match;
- Emit the same result JSON:
matchedRules[].prefixRuleMatch{ matchedPrefix, decision, resolvedProgram?, justification? }and top-leveldecision. - Built-in/default baseline policy bundled (embedded) identically to Codex.
match/not_matchexamples in a policy act as self-tests at load time.
- For the bundled default policy, every
match/not_matchexample evaluates correctly (load-time self-test passes). - Golden differential: a corpus of commands evaluated by
codex execpolicy checkproduces identical decision JSON fromcodexgo. - Basename fallback +
host_executablerestriction reproduced on path-variant command fixtures (e.g./usr/bin/gitvs/opt/homebrew/bin/git).
go.starlark.netdialect differences fromstarlark-rust(e.g. type coercion, error messages). Validate the specific builtins/grammar Codex policies use.- The legacy engine uses
allocative/derive_more; confirm whether it is reachable at runtime before investing.
- Actually enforcing sandboxing (spec 12–14) — this spec only decides.