core-agent-ide/codex-rs/execpolicy/src
Michael Bolin cafb07fe6e
feat: add justification arg to prefix_rule() in *.rules (#8751)
Adds an optional `justification` parameter to the `prefix_rule()`
execpolicy DSL so policy authors can attach human-readable rationale to
a rule. That justification is propagated through parsing/matching and
can be surfaced to the model (or approval UI) when a command is blocked
or requires approval.

When a command is rejected (or gated behind approval) due to policy, a
generic message makes it hard for the model/user to understand what went
wrong and what to do instead. Allowing policy authors to supply a short
justification improves debuggability and helps guide the model toward
compliant alternatives.

Example:

```python
prefix_rule(
    pattern = ["git", "push"],
    decision = "forbidden",
    justification = "pushing is blocked in this repo",
)
```

If Codex tried to run `git push origin main`, now the failure would
include:

```
`git push origin main` rejected: pushing is blocked in this repo
```

whereas previously, all it was told was:

```
execpolicy forbids this command
```
2026-01-05 21:24:48 +00:00
..
amend.rs fix: policy/*.codexpolicy -> rules/*.rules (#7888) 2025-12-11 14:46:00 -08:00
decision.rs migrating execpolicy -> execpolicy-legacy and execpolicy2 -> execpolicy (#6956) 2025-11-19 19:14:10 -08:00
error.rs feat: add justification arg to prefix_rule() in *.rules (#8751) 2026-01-05 21:24:48 +00:00
execpolicycheck.rs fix: policy/*.codexpolicy -> rules/*.rules (#7888) 2025-12-11 14:46:00 -08:00
lib.rs execpolicy helpers (#7032) 2025-12-02 15:05:27 -05:00
main.rs Refactor execpolicy fallback evaluation (#7544) 2025-12-03 23:39:48 -08:00
parser.rs feat: add justification arg to prefix_rule() in *.rules (#8751) 2026-01-05 21:24:48 +00:00
policy.rs feat: add justification arg to prefix_rule() in *.rules (#8751) 2026-01-05 21:24:48 +00:00
rule.rs feat: add justification arg to prefix_rule() in *.rules (#8751) 2026-01-05 21:24:48 +00:00