diff --git a/.chock/bin/gate.py b/.chock/bin/gate.py index f3af6e6..41abf26 100644 --- a/.chock/bin/gate.py +++ b/.chock/bin/gate.py @@ -1302,6 +1302,7 @@ def _verdict(result: GateResult, declared: str, level: str = ROLLOUT_ENFORCE) -> _CUSTOMISE_POINTER = ( "A person customises this policy's rules in .agents/policies/{policy}/manifest.yaml; an agent cannot loosen them." ) +_SCRIPT_KIND = "script" def _for_agent(text: str) -> str: @@ -1331,10 +1332,15 @@ def _reason(result: GateResult, spec: dict, event: str = "commit", policy_id: st return "\n".join([*matches, _summary(result, policy_id), policy]) +def _may_waive(spec: dict, event: str) -> bool: + """Whether the policy can honour a waiver: an `allowlist_pragma`, or a script that reads its own.""" + return spec.get("kind") == _SCRIPT_KIND or bool(_waiver_pattern(spec.get("params") or {}, event)) + + def _report_refusal(result: GateResult, spec: dict, judged: str, signal: str | None, policy_id: str | None) -> None: reason = _reason(result, spec, judged, policy_id) print(_encodable(ci_inert(reason) if judged == "ci" else reason, sys.stderr), file=sys.stderr) - if judged == AGENT_COMMIT_EVENT and signal and _waiver_pattern(spec.get("params") or {}, judged): + if judged == AGENT_COMMIT_EVENT and signal and _may_waive(spec, judged): print(_AGENT_COMMIT_NOTE.format(signal=signal), file=sys.stderr) diff --git a/README.md b/README.md index 247e170..d165049 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Tiers: `commit` is a git hook or CI gate that exits non-zero. `in-agent` is the chock is on PyPI, but the release there (0.15.2, 30 Sep 2026) is older than the engine this page describes. Install the frozen engine from its commit (Python 3.11 or newer): ```bash -pip install "chock @ git+https://github.com/open-coder-ai/chock@a6ec2f3603da832ed43fabace95504e5e13b013b" +pip install "chock @ git+https://github.com/open-coder-ai/chock@2f3be6d04349a7ec433657e16a294efc62b51d4f" ``` ### Two ways to adopt it