diff --git a/.chock/bin/_chock_runtime.py b/.chock/bin/_chock_runtime.py
index 36926292..233ffb4c 100644
--- a/.chock/bin/_chock_runtime.py
+++ b/.chock/bin/_chock_runtime.py
@@ -32,6 +32,8 @@
BYTECODE_OFF = {'PYTHONDONTWRITEBYTECODE': '1'}
+ISOLATED_START = "import os, runpy, sys\nsys.argv = sys.argv[1:]\nsys.path.insert(0, os.path.dirname(os.path.abspath(sys.argv[0])))\nrunpy.run_path(sys.argv[0], run_name='__main__')\n"
+
PATTERN_SECONDS = 10
PATTERN_START_SECONDS = 10
@@ -111,6 +113,17 @@ def run_tree(argv, *, timeout=None, **options):
untrack_tree(proc)
return _chock_subprocess.CompletedProcess(argv, proc.returncode, out, err)
+def python_free_env(env=None):
+ """`env` (this process's by default) without any `PYTHON*` variable, plus bytecode off for grandchildren."""
+ base = _chock_os.environ if env is None else env
+ return {**{k: v for k, v in base.items() if not k.upper().startswith('PYTHON')}, **BYTECODE_OFF}
+
+def isolated_child(argv, env=None):
+ """(argv, env) that run the Python child `[interpreter, script, *args]` isolated: no PYTHON* variable,
+ user site or current folder can change what it imports; its own folder is put on sys.path explicitly."""
+ interpreter, script, *args = argv
+ return ([interpreter, '-I', '-B', '-X', 'utf8', '-c', ISOLATED_START, str(script), *args], python_free_env(env))
+
def engine_remaining(deadline):
"""Seconds left before `deadline`, never negative."""
return max(deadline - _chock_time.monotonic(), 0.0)
@@ -803,7 +816,7 @@ def bash_candidates() -> list[str]:
def interpreter_env(interpreter: str) -> dict[str, str]:
"""The environment a guard runs in: on Windows, Git's usr/bin ahead on PATH for sed and grep."""
- env = {**_chock_os.environ, **BYTECODE_OFF}
+ env = python_free_env()
env.pop(CAN_ASK_ENV, None)
if _chock_os.name != _WINDOWS:
return env
@@ -861,6 +874,11 @@ def split_command(command: str) -> tuple[list[str], bool]:
except ValueError:
return (command.split(), True)
+def _guard_start(interpreter: str, guard: _chock_Path, args: list[str], env: dict[str, str]):
+ """(argv, env) for the guard: a Python guard starts isolated, a shell guard as given."""
+ argv = [interpreter, str(guard), *args]
+ return isolated_child(argv, env) if guard.suffix == PYTHON_SUFFIX else (argv, env)
+
def run_guard(guard: _chock_Path, command: str, tool: str='') -> str:
"""`GUARD_BLOCKED` / `GUARD_ASKED` / `GUARD_CLEAN` when the guard ran, otherwise why it did not."""
return run_guard_detailed(guard, command, tool)[0]
@@ -888,7 +906,8 @@ def run_guard_detailed(guard: _chock_Path, command: str, tool: str='', *, can_as
if fallback:
env[ARGV_FALLBACK_ENV] = '1'
env.update({} if can_ask is None else {CAN_ASK_ENV: '1' if can_ask else '0'})
- proc = run_tree([interpreter, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=time_left(deadline, [interpreter, str(guard)]), check=False)
+ argv, env = _guard_start(interpreter, guard, args, env)
+ proc = run_tree(argv, capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=time_left(deadline, [interpreter, str(guard)]), check=False)
except _chock_subprocess.TimeoutExpired:
print(f'chock: guard timed out after {ENGINE_BUDGET_SECONDS}s, not checked', file=sys.stderr)
return (GUARD_ERRORED, '')
@@ -2624,9 +2643,9 @@ def run_gate(gate, writes, event, run_in, deadline):
runner = runner_for(gate)
if runner is None:
return (GATE_ERRORED, 'the vendored gate runner is not installed beside this gate')
- argv = [sys.executable, str(runner), 'run', '--gate', str(gate), '--event', event]
+ argv, env = isolated_child([sys.executable, str(runner), 'run', '--gate', str(gate), '--event', event])
try:
- proc = run_tree(argv, input=json.dumps({'writes': writes, **(extra or {})}), capture_output=True, text=True, encoding=_UTF8, errors='replace', timeout=time_left(deadline, argv), check=False, cwd=str(root) if root is not None else None)
+ proc = run_tree(argv, env=env, input=json.dumps({'writes': writes, **(extra or {})}), capture_output=True, text=True, encoding=_UTF8, errors='replace', timeout=time_left(deadline, argv), check=False, cwd=str(root) if root is not None else None)
except _chock_subprocess.TimeoutExpired as exc:
return (GATE_ERRORED, f'the gate runner gave no verdict within {allowed_seconds(exc)}')
except (OSError, _chock_subprocess.SubprocessError) as exc:
@@ -2767,9 +2786,9 @@ def _tool_call_script(spec, root, payload, deadline=None):
if not script.is_file():
return ('deny', f'script gate: {named!r} is not installed{_TOOL_CALL_UNDECIDED}')
deadline = engine_deadline() if deadline is None else deadline
- argv = [sys.executable, str(script)]
+ argv, env = isolated_child([sys.executable, str(script)])
try:
- proc = run_tree(argv, input=json.dumps(payload), capture_output=True, text=True, encoding='utf-8', errors='replace', cwd=str(root), env={**_chock_os.environ, **BYTECODE_OFF}, timeout=time_left(deadline, argv), check=False)
+ proc = run_tree(argv, input=json.dumps(payload), capture_output=True, text=True, encoding='utf-8', errors='replace', cwd=str(root), env=env, timeout=time_left(deadline, argv), check=False)
except _chock_subprocess.TimeoutExpired as exc:
budget = f'gave no verdict within {allowed_seconds(exc)}'
return ('deny', f'script gate: {script.name} {budget}{_TOOL_CALL_UNDECIDED}')
diff --git a/.chock/bin/claude_code.py b/.chock/bin/claude_code.py
index 558e7fbc..86885f6d 100755
--- a/.chock/bin/claude_code.py
+++ b/.chock/bin/claude_code.py
@@ -855,7 +855,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/.chock/bin/codex_cli.py b/.chock/bin/codex_cli.py
index 3cbb9f52..0a9db955 100755
--- a/.chock/bin/codex_cli.py
+++ b/.chock/bin/codex_cli.py
@@ -823,7 +823,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/.chock/bin/cursor.py b/.chock/bin/cursor.py
index 6db1a9cd..42fab5ed 100755
--- a/.chock/bin/cursor.py
+++ b/.chock/bin/cursor.py
@@ -721,7 +721,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/.chock/bin/devin.py b/.chock/bin/devin.py
index cccf63ea..19b17565 100755
--- a/.chock/bin/devin.py
+++ b/.chock/bin/devin.py
@@ -826,7 +826,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/.chock/bin/gate.py b/.chock/bin/gate.py
index 41abf266..a76d19f8 100755
--- a/.chock/bin/gate.py
+++ b/.chock/bin/gate.py
@@ -34,6 +34,14 @@
BYTECODE_OFF = {"PYTHONDONTWRITEBYTECODE": "1"}
+ISOLATED_START = (
+ "import os, runpy, sys\n"
+ "sys.argv = sys.argv[1:]\n"
+ "sys.path.insert(0, os.path.dirname(os.path.abspath(sys.argv[0])))\n"
+ "runpy.run_path(sys.argv[0], run_name='__main__')\n"
+)
+
+
PATTERN_SECONDS = 10
@@ -137,6 +145,19 @@ def run_tree(argv, *, timeout=None, **options):
return subprocess.CompletedProcess(argv, proc.returncode, out, err)
+def python_free_env(env=None):
+ """`env` (this process's by default) without any `PYTHON*` variable, plus bytecode off for grandchildren."""
+ base = os.environ if env is None else env
+ return {**{k: v for k, v in base.items() if not k.upper().startswith("PYTHON")}, **BYTECODE_OFF}
+
+
+def isolated_child(argv, env=None):
+ """(argv, env) that run the Python child `[interpreter, script, *args]` isolated: no PYTHON* variable,
+ user site or current folder can change what it imports; its own folder is put on sys.path explicitly."""
+ interpreter, script, *args = argv
+ return [interpreter, "-I", "-B", "-X", "utf8", "-c", ISOLATED_START, str(script), *args], python_free_env(env)
+
+
def engine_remaining(deadline):
"""Seconds left before `deadline`, never negative."""
return max(deadline - time.monotonic(), 0.0)
@@ -298,6 +319,7 @@ def __init__(
self.scope = tuple(scope or ())
#: Path prefixes this gate never judges: its own policy's source and compiled folders.
self.own = tuple(own)
+ self._rename_map: dict[str, str] | None = None
def is_own(self, path: str) -> bool:
"""Whether `path` is in this policy's own source or compiled folder."""
@@ -364,9 +386,28 @@ def staged_paths(self, diff_filter: str = "ACMRT", *, judge_own: bool = False) -
paths = self._listing("diff", *self._range(), "--name-only", f"--diff-filter={diff_filter}")
return [path for path in paths if self.in_scope(path, judge_own=judge_own)]
+ def _rename_range(self) -> list[str] | None:
+ """The git-diff scope whose renames the baseline follows; None when this context has none."""
+ return self._range()
+
+ def _renames(self) -> dict[str, str]:
+ """{new path: old path} for what git itself reports as renamed (`-M`, default similarity); never a guess.
+
+ A listing that fails or does not parse says no rename, which leaves the baseline at the path (stricter).
+ """
+ if self._rename_map is None:
+ scope, tokens = self._rename_range(), []
+ if scope is not None:
+ with contextlib.suppress(ListingError):
+ tokens = self._listing("diff", *scope, "-M", "--relative", "--name-status", "--diff-filter=R")
+ self._rename_map = {tokens[i + 2]: tokens[i + 1] for i in range(0, len(tokens) - 2, 3)}
+ return self._rename_map
+
def _diff_text(self, path: str) -> str:
"""`path`'s `-U0` diff as git writes it, unconverted; raises DiffError when git fails."""
- args = ("diff", *self._range(), "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--", path)
+ old = self._renames().get(path)
+ paths = (path, old) if old else (path,)
+ args = ("diff", *self._range(), "-M", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--", *paths)
try:
proc = subprocess.run( # noqa: S603 -- reading repo facts via git is this class's whole job
[_GIT, "--literal-pathspecs", *args],
@@ -395,8 +436,8 @@ def staged_blob(self, path: str) -> str:
return self._git("show", f"HEAD:{path}" if self.base else f":{path}")
def head_blob(self, path: str) -> str:
- """Content before the change, or "" when the path is new in it."""
- return self._git("show", f"{self.base or 'HEAD'}:{path}")
+ """Content before the change, or "" when the path is new in it; a renamed path reads its old path."""
+ return self._git("show", f"{self.base or 'HEAD'}:{self._renames().get(path, path)}")
def committed_blob(self, path: str) -> str:
"""The file as HEAD has it, or "" when HEAD does not."""
@@ -465,6 +506,10 @@ def __init__(
self._added = dict(added or {})
self._stop = stop
+ def _rename_range(self) -> list[str] | None:
+ """At the turn's end, HEAD against the index and tree; a write before the tool runs has no rename."""
+ return ["HEAD"] if self._stop else None
+
def staged_paths(self, diff_filter: str = "ACMRT", *, judge_own: bool = False) -> list[str]:
"""Every write is a present file, so a filter asking only for deletions finds none."""
if not set(diff_filter) & set("ACMRT"):
@@ -496,7 +541,7 @@ def committed_blob(self, path: str) -> str:
def head_blob(self, path: str) -> str:
"""The baseline: HEAD at the turn's end, else what is on disk now, which this write would replace."""
if self._stop:
- return self.committed_blob(path)
+ return self.committed_blob(self._renames().get(path, path))
try:
return (self.repo_root / path).read_text(encoding="utf-8")
except (OSError, UnicodeDecodeError):
@@ -550,8 +595,12 @@ def head_blob(self, path: str) -> str:
#: adds is not honoured. Coverage (`on: [commit]`) is still decided by the name `commit`.
AGENT_COMMIT_EVENT = "agent-commit"
+#: The event `chock check --floor` judges at: the change under judgement may be the refused party's, so a
+#: waiver counts only when the base already has that line (the floor's `committed_blob` reads the base).
+FLOOR_EVENT = "ci-floor"
+
#: Events where the actor may be the refused agent: a waiver counts only when HEAD already has that line.
-HEAD_WAIVER_EVENTS = frozenset({AGENT_COMMIT_EVENT, TOOL_USE_EVENT})
+HEAD_WAIVER_EVENTS = frozenset({AGENT_COMMIT_EVENT, TOOL_USE_EVENT, FLOOR_EVENT})
_HUMAN_ENV = frozenset({"0", "false", "no", "off"})
@@ -959,6 +1008,15 @@ def _kind_test_integrity(ctx: GateContext, params: dict, event: str) -> GateResu
_FINDINGS_KEY = "findings"
+#: All a script gate's environment holds at the floor: no token, secret or runner variable reaches it.
+_FLOOR_ENV_KEYS = ("PATH", "HOME", "SYSTEMROOT")
+
+
+def _env(event: object) -> dict[str, str]:
+ if event == FLOOR_EVENT:
+ return {key: os.environ[key] for key in _FLOOR_ENV_KEYS if key in os.environ} | _BYTECODE_OFF
+ return {**os.environ, **_BYTECODE_OFF}
+
def _spawn(script: Path, ctx: GateContext, payload: dict, timeout: float) -> subprocess.CompletedProcess[str]:
return run_tree(
@@ -969,7 +1027,7 @@ def _spawn(script: Path, ctx: GateContext, payload: dict, timeout: float) -> sub
encoding="utf-8",
errors="replace",
cwd=ctx.repo_root,
- env={**os.environ, **_BYTECODE_OFF},
+ env=_env(payload.get("event")),
timeout=timeout,
check=False,
)
@@ -1024,6 +1082,19 @@ def _new_findings(found: list[dict], baseline: list[dict]) -> list[dict]:
return fresh
+#: A finding's optional `tier`, ranked; a verdict is the highest among the findings the change adds.
+_TIER_RANK = {"warn": 1, "ask": 2, "block": 3}
+
+
+def _tier_verdict(fresh: list[dict]) -> str | None:
+ """The verdict word ("" blocks) when every kept finding carries a known tier, else None: the exit code decides."""
+ tiers = [item.get("tier") for item in fresh]
+ if not all(isinstance(tier, str) and tier in _TIER_RANK for tier in tiers):
+ return None
+ top = max(tiers, key=_TIER_RANK.__getitem__)
+ return "" if top == "block" else top
+
+
def _baseline_findings(ctx: GateContext, script: Path, material: dict, started: float) -> list[dict]:
"""What the script finds in the baseline text of the change's files; empty when it cannot say.
@@ -1062,7 +1133,7 @@ def _exit_verdict(script: Path, proc: subprocess.CompletedProcess[str]) -> GateR
def _judge_findings(
ctx: GateContext, script: Path, material: dict, proc: subprocess.CompletedProcess[str], started: float
) -> GateResult:
- """Judge only the findings the change introduces; the change-run's exit code is the verdict for them."""
+ """Judge only the findings the change introduces: the highest tier among them, else the change-run's exit code."""
if proc.returncode not in (_SCRIPT_ALLOW, _SCRIPT_BLOCK, _SCRIPT_ASK, _SCRIPT_WARN):
# A document followed by a crash or an unknown exit is undecided, never a clean pass.
return _exit_verdict(script, proc)
@@ -1075,7 +1146,9 @@ def _judge_findings(
if not fresh or proc.returncode == _SCRIPT_ALLOW:
return GateResult(allowed=True, detail=counts)
lines = [f"{item['path']}:{item['line']}: {item['message']}" for item in fresh]
- verdict = {_SCRIPT_ASK: "ask", _SCRIPT_WARN: "warn"}.get(proc.returncode, "")
+ verdict = _tier_verdict(fresh)
+ if verdict is None:
+ verdict = {_SCRIPT_ASK: "ask", _SCRIPT_WARN: "warn"}.get(proc.returncode, "")
return GateResult(
allowed=False, matches=lines, verdict=verdict, detail=counts, rules=_rule_ids(fresh), findings=fresh
)
@@ -1084,7 +1157,7 @@ def _judge_findings(
def _kind_script(ctx: GateContext, params: dict, event: str) -> GateResult:
"""Hand the material to the policy's own script and carry back its verdict.
- The script reads `{"event", "repo_root", "writes": {path: text}}` on stdin -- the staged
+ The script reads `{"event", "repo_root", "writes": {path: text}}` on stdin (plus `deleted` at the floor) -- the staged
blobs at commit and push, the write itself at tool use and at the turn's end -- so one
script serves every surface the declarative kinds do, and reads them the same way. It
answers with an exit code: 0 allows; 1 refuses, 3 asks, 4 warns, with its own words on stderr.
@@ -1100,9 +1173,13 @@ def _kind_script(ctx: GateContext, params: dict, event: str) -> GateResult:
if not script.is_file():
return GateResult(allowed=False, message=f"script gate: {named!r} is not installed{_UNDECIDED}")
writes = {path: ctx.staged_blob(path) for path in ctx.staged_paths()}
- if not writes:
+ # Only the floor hands a script the deleted paths: the contract every other event has is unchanged.
+ deleted = sorted(ctx.staged_paths("D")) if event == FLOOR_EVENT else []
+ if not writes and not deleted:
return GateResult(allowed=True)
material = {"event": event, "repo_root": str(ctx.repo_root), "writes": writes}
+ if event == FLOOR_EVENT:
+ material["deleted"] = deleted
if ctx.session:
material["session"] = ctx.session
started = time.monotonic()
diff --git a/.chock/bin/gemini_cli.py b/.chock/bin/gemini_cli.py
index 964ae941..9a290d83 100755
--- a/.chock/bin/gemini_cli.py
+++ b/.chock/bin/gemini_cli.py
@@ -826,7 +826,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/.chock/bin/grok.py b/.chock/bin/grok.py
index f262f001..39616f2a 100755
--- a/.chock/bin/grok.py
+++ b/.chock/bin/grok.py
@@ -826,7 +826,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/.chock/bin/index/claude_code-PreToolUse-185f9750.json b/.chock/bin/index/claude_code-PreToolUse-185f9750.json
index a5aefb93..2f066730 100644
--- a/.chock/bin/index/claude_code-PreToolUse-185f9750.json
+++ b/.chock/bin/index/claude_code-PreToolUse-185f9750.json
@@ -14,7 +14,6 @@
".chock/compiled/token-efficiency/agent-hooks/tool-call-gate.json": "0689304b5bacd25e9a371674d0faa8f9b8d9d35132d2faf7917c2b165a1a93fa",
".chock/compiled/token-efficiency/agent-hooks/tool-call-hooks.json": "7300181bc92f845f81e316813adc9eb6cfd58d8a94525126455203df7fb08e6a",
".chock/compiled/token-efficiency/ambient-rule/ambient.md": "6d94b590c79d340fe25c48dc119b41ece181c5c605b4a38a853e54b54f4e9156",
- ".chock/compiled/token-efficiency/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/token-efficiency/pre-tool-use/codex_cli-tool-call-hooks.json": "a80d3ca758064cba6407f75213a659ec24321eddd85b2adc444cf9f367c5e741",
".chock/compiled/token-efficiency/pre-tool-use/cursor-post-hooks.json": "4348e99148692cafca9417a6dba71e01bda26a404733926415313428bb7f2d93",
".chock/compiled/token-efficiency/pre-tool-use/cursor-postfailure-hooks.json": "9c1e9f0f10255027115cfe5f74ac955be9f66f29973905f8eae319293285f2ab",
diff --git a/.chock/bin/index/claude_code-PreToolUse-3a2134a7.json b/.chock/bin/index/claude_code-PreToolUse-3a2134a7.json
index 6f3c0aa2..53fe6ac3 100644
--- a/.chock/bin/index/claude_code-PreToolUse-3a2134a7.json
+++ b/.chock/bin/index/claude_code-PreToolUse-3a2134a7.json
@@ -20,7 +20,6 @@
".chock/compiled/block-destructive-commands/agent-hooks/agent-hooks.json": "166952d2add28842185387ca8602d36f511968c7e666e04c87708dc9dfe3054e",
".chock/compiled/block-destructive-commands/ambient-rule/ambient.md": "67f05c884bf417822000ebac578a7090a3ead6e07f0dea03c46eaf695214f190",
".chock/compiled/block-destructive-commands/git-hook/git-pre-push.sh": "ecb69d79165216412f646fb2ef8d53646a4c6d39fde77bfcc987adff7c76149e",
- ".chock/compiled/block-destructive-commands/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-destructive-commands/pre-tool-use/antigravity-hooks.json": "9848d7c4f5be4c7ca30d401ceffe1ad4ec30775a0383552232aed9a91499b002",
".chock/compiled/block-destructive-commands/pre-tool-use/codex_cli-hooks.json": "02d8a824208df11dfd45e452e684e0779d8f164c4b6a8164bae9f9ca2cbf0865",
".chock/compiled/block-destructive-commands/pre-tool-use/cursor-hooks.json": "7091a6caea23d8794ef4e26af62e77d9f3a3bc3a38d8de9a941277e053ca1d97",
@@ -55,7 +54,6 @@
".agents/policies/block-no-verify/skills/block-no-verify/SKILL.md": "4e40b8cb58619728bdfc8dd4de2143c77bfa8c744f1f44d34904b88ae85ac023",
".chock/compiled/block-no-verify/agent-hooks/agent-hooks.json": "82b2e539bb812058a0c6cf3298ae9b72762eec28ede995ebe730b5d76f99c02b",
".chock/compiled/block-no-verify/ambient-rule/ambient.md": "371f90ab55eea13626e972c05883f2c1c427c9ca21a6d4aff23efa4513469431",
- ".chock/compiled/block-no-verify/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-no-verify/pre-tool-use/antigravity-hooks.json": "1d5445dda7ade581edf55dc5e2d9adfde0c2ec9efd9cede936b8b99fd1fb0a9b",
".chock/compiled/block-no-verify/pre-tool-use/codex_cli-hooks.json": "a9df710f0b597cf83be795e5f7e68e0b9a641199765f4c7870de0be60b9ce8f0",
".chock/compiled/block-no-verify/pre-tool-use/cursor-hooks.json": "b7d84e25198f56302446e5a3738bfc1328a1e144c69d4d5b8cacdc83b9c829fa",
@@ -92,7 +90,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -152,7 +149,6 @@
".chock/compiled/protect-commit-privacy/agent-hooks/agent-hooks.json": "c532957fe3efd114386ced897aec8fffdfc41e8f281a39efb4620f4e6a7d2747",
".chock/compiled/protect-commit-privacy/ambient-rule/ambient.md": "0d747282d92f843a14974765e038a69a41c93c70e1e6e8100a6546d5b48865c4",
".chock/compiled/protect-commit-privacy/git-hook/git-commit-msg.sh": "c4d9679ba23a73ab2fad594b5a3c088fd1a29d2b2444483da6d08023e0fef98a",
- ".chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-commit-privacy/pre-tool-use/antigravity-hooks.json": "762b527f13d0924e9fdd48b748d1027a1232a25225189e763cabcee208e9055d",
".chock/compiled/protect-commit-privacy/pre-tool-use/codex_cli-hooks.json": "85f228d8d50290015ef3204a73e9ddf3470929ed7fbb0f0ce8bd2d2eb8460f05",
".chock/compiled/protect-commit-privacy/pre-tool-use/cursor-hooks.json": "28d17b33eacbc0e331fc588ee9a129e66f9ad29414dad360066990d1c739e4db",
diff --git a/.chock/bin/index/claude_code-PreToolUse-4acdeb9e.json b/.chock/bin/index/claude_code-PreToolUse-4acdeb9e.json
index 2653147e..95ad602b 100644
--- a/.chock/bin/index/claude_code-PreToolUse-4acdeb9e.json
+++ b/.chock/bin/index/claude_code-PreToolUse-4acdeb9e.json
@@ -17,7 +17,6 @@
".chock/compiled/block-invisible-unicode/ci-gate/step.yaml": "84e201486169ad4c016579f744c77b88b3b722628c01018d6afa7239fc9bec63",
".chock/compiled/block-invisible-unicode/git-hook/gate.json": "351fb35fffc9aba4882fe53ebbd3713b69aca6b4eb75798538a327b1cb641e1e",
".chock/compiled/block-invisible-unicode/git-hook/git-pre-commit.sh": "454c869cf2aa5123164f732ab28ffb79cfbf57c4e4a2b73597ef592bf11e59c6",
- ".chock/compiled/block-invisible-unicode/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-invisible-unicode/mcp-gateway/gateway-gate.json": "83a400812189da3cb5ba7150d969698ab2400aa6c558348499f8745b5bf17ae0",
".chock/compiled/block-invisible-unicode/pre-tool-use/codex_cli-write-hooks.json": "fbad2af5a4a0e25f8a2704865641310f88042fe3c36ef3f5184b023d7b23af09",
".chock/compiled/block-invisible-unicode/pre-tool-use/cursor-write-hooks.json": "5a8a3215d75707c045b803c913edae75beaf9554cf4fa237d757ad773dfea2f4",
@@ -61,7 +60,6 @@
".chock/compiled/block-wildcard-agent-permissions/ci-gate/step.yaml": "f173704ceb69af71a971c081d7219f205fc176b5970dd4a32e429bbf4f6cd929",
".chock/compiled/block-wildcard-agent-permissions/git-hook/gate.json": "758636f7d17326652db0cac493c4fb59dcd7eaa922824a6e43bc49bfb616f762",
".chock/compiled/block-wildcard-agent-permissions/git-hook/git-pre-commit.sh": "8ad425c111c1dbf52a48ad2ba68b645d4d716befa8dfea575817ecea752421ea",
- ".chock/compiled/block-wildcard-agent-permissions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-wildcard-agent-permissions/mcp-gateway/gateway-gate.json": "9bf2c6b2447a2227f303b44afd50771db2cfa3a3ee40edc1280ac43209060c55",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/codex_cli-write-hooks.json": "8af817d29d040a474bbd5aa4c090c6084ab153f985882588e6b753ad6df1aad1",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/cursor-write-hooks.json": "691bdbeb577970ffdbc416b828781b74c39bcc9abe6eeda09e0d0069d0a04578",
@@ -105,7 +103,6 @@
".chock/compiled/pin-github-actions/ci-gate/step.yaml": "91ed82dfc00043421971fc4f480e800682fe9f8b8c0e6aa2cfecbb1e8de8b01d",
".chock/compiled/pin-github-actions/git-hook/gate.json": "65b5bc9554fa8852cf94ceaaced461755d7694c8b87b37fe7a8434d8642c666b",
".chock/compiled/pin-github-actions/git-hook/git-pre-commit.sh": "e6e47fcbbce3525c47b7ea69deee273ce95442ef3dac7bcd43a897b553769bcd",
- ".chock/compiled/pin-github-actions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/pin-github-actions/mcp-gateway/gateway-gate.json": "308905df356acf7194c529bf0a418fd219e083ebd8545ce1aabd45c2dfbc2650",
".chock/compiled/pin-github-actions/pre-tool-use/codex_cli-write-hooks.json": "14238725b34a2e01cda395bc90e6ac5c914b4450b3b33ab81934df6324c1210d",
".chock/compiled/pin-github-actions/pre-tool-use/cursor-write-hooks.json": "68283be362683ad10a6a4542ecc4d59cb52bfcfb02483587262b5c5e6997d6e1",
@@ -152,7 +149,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -209,7 +205,6 @@
".chock/compiled/scan-secrets/ci-gate/step.yaml": "e2392603980559fbc57a1be4e0243cfa3d620fddbc6c8be7b2114fd4bbad9e07",
".chock/compiled/scan-secrets/git-hook/gate.json": "04d7a7705ced24c5c341ab4dc9806c3f488e2b1ac7a6c0b995e45b2e810cfd1b",
".chock/compiled/scan-secrets/git-hook/git-pre-commit.sh": "65c9db2f5b615a079cf92b63d3c739bcd4427ed4db33811b13d8922c43bb2b50",
- ".chock/compiled/scan-secrets/managed-setting/managed-settings.json": "650436873f2a8da403515b6a205bf0006fbd2799dd8ff6c16a46b80847beafe5",
".chock/compiled/scan-secrets/mcp-gateway/gateway-gate.json": "520fd73b5d80023c68619e7ff56539c74ed0ef672ba8ce4686cf6f34972c7b25",
".chock/compiled/scan-secrets/pre-tool-use/codex_cli-write-hooks.json": "804cedc96a9809cb84f27e5d9f0da8989b32dc5173fdd37a35bfd204771a3edc",
".chock/compiled/scan-secrets/pre-tool-use/cursor-write-hooks.json": "a81dd0ba1d107bc551c51bbd7084a272c2a0b7bcc0e0b02411c36af15db60da8",
diff --git a/.chock/bin/index/codex_cli-PreToolUse-14533f34.json b/.chock/bin/index/codex_cli-PreToolUse-14533f34.json
index 6f3c0aa2..53fe6ac3 100644
--- a/.chock/bin/index/codex_cli-PreToolUse-14533f34.json
+++ b/.chock/bin/index/codex_cli-PreToolUse-14533f34.json
@@ -20,7 +20,6 @@
".chock/compiled/block-destructive-commands/agent-hooks/agent-hooks.json": "166952d2add28842185387ca8602d36f511968c7e666e04c87708dc9dfe3054e",
".chock/compiled/block-destructive-commands/ambient-rule/ambient.md": "67f05c884bf417822000ebac578a7090a3ead6e07f0dea03c46eaf695214f190",
".chock/compiled/block-destructive-commands/git-hook/git-pre-push.sh": "ecb69d79165216412f646fb2ef8d53646a4c6d39fde77bfcc987adff7c76149e",
- ".chock/compiled/block-destructive-commands/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-destructive-commands/pre-tool-use/antigravity-hooks.json": "9848d7c4f5be4c7ca30d401ceffe1ad4ec30775a0383552232aed9a91499b002",
".chock/compiled/block-destructive-commands/pre-tool-use/codex_cli-hooks.json": "02d8a824208df11dfd45e452e684e0779d8f164c4b6a8164bae9f9ca2cbf0865",
".chock/compiled/block-destructive-commands/pre-tool-use/cursor-hooks.json": "7091a6caea23d8794ef4e26af62e77d9f3a3bc3a38d8de9a941277e053ca1d97",
@@ -55,7 +54,6 @@
".agents/policies/block-no-verify/skills/block-no-verify/SKILL.md": "4e40b8cb58619728bdfc8dd4de2143c77bfa8c744f1f44d34904b88ae85ac023",
".chock/compiled/block-no-verify/agent-hooks/agent-hooks.json": "82b2e539bb812058a0c6cf3298ae9b72762eec28ede995ebe730b5d76f99c02b",
".chock/compiled/block-no-verify/ambient-rule/ambient.md": "371f90ab55eea13626e972c05883f2c1c427c9ca21a6d4aff23efa4513469431",
- ".chock/compiled/block-no-verify/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-no-verify/pre-tool-use/antigravity-hooks.json": "1d5445dda7ade581edf55dc5e2d9adfde0c2ec9efd9cede936b8b99fd1fb0a9b",
".chock/compiled/block-no-verify/pre-tool-use/codex_cli-hooks.json": "a9df710f0b597cf83be795e5f7e68e0b9a641199765f4c7870de0be60b9ce8f0",
".chock/compiled/block-no-verify/pre-tool-use/cursor-hooks.json": "b7d84e25198f56302446e5a3738bfc1328a1e144c69d4d5b8cacdc83b9c829fa",
@@ -92,7 +90,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -152,7 +149,6 @@
".chock/compiled/protect-commit-privacy/agent-hooks/agent-hooks.json": "c532957fe3efd114386ced897aec8fffdfc41e8f281a39efb4620f4e6a7d2747",
".chock/compiled/protect-commit-privacy/ambient-rule/ambient.md": "0d747282d92f843a14974765e038a69a41c93c70e1e6e8100a6546d5b48865c4",
".chock/compiled/protect-commit-privacy/git-hook/git-commit-msg.sh": "c4d9679ba23a73ab2fad594b5a3c088fd1a29d2b2444483da6d08023e0fef98a",
- ".chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-commit-privacy/pre-tool-use/antigravity-hooks.json": "762b527f13d0924e9fdd48b748d1027a1232a25225189e763cabcee208e9055d",
".chock/compiled/protect-commit-privacy/pre-tool-use/codex_cli-hooks.json": "85f228d8d50290015ef3204a73e9ddf3470929ed7fbb0f0ce8bd2d2eb8460f05",
".chock/compiled/protect-commit-privacy/pre-tool-use/cursor-hooks.json": "28d17b33eacbc0e331fc588ee9a129e66f9ad29414dad360066990d1c739e4db",
diff --git a/.chock/bin/index/codex_cli-PreToolUse-186bd88e.json b/.chock/bin/index/codex_cli-PreToolUse-186bd88e.json
index a5aefb93..2f066730 100644
--- a/.chock/bin/index/codex_cli-PreToolUse-186bd88e.json
+++ b/.chock/bin/index/codex_cli-PreToolUse-186bd88e.json
@@ -14,7 +14,6 @@
".chock/compiled/token-efficiency/agent-hooks/tool-call-gate.json": "0689304b5bacd25e9a371674d0faa8f9b8d9d35132d2faf7917c2b165a1a93fa",
".chock/compiled/token-efficiency/agent-hooks/tool-call-hooks.json": "7300181bc92f845f81e316813adc9eb6cfd58d8a94525126455203df7fb08e6a",
".chock/compiled/token-efficiency/ambient-rule/ambient.md": "6d94b590c79d340fe25c48dc119b41ece181c5c605b4a38a853e54b54f4e9156",
- ".chock/compiled/token-efficiency/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/token-efficiency/pre-tool-use/codex_cli-tool-call-hooks.json": "a80d3ca758064cba6407f75213a659ec24321eddd85b2adc444cf9f367c5e741",
".chock/compiled/token-efficiency/pre-tool-use/cursor-post-hooks.json": "4348e99148692cafca9417a6dba71e01bda26a404733926415313428bb7f2d93",
".chock/compiled/token-efficiency/pre-tool-use/cursor-postfailure-hooks.json": "9c1e9f0f10255027115cfe5f74ac955be9f66f29973905f8eae319293285f2ab",
diff --git a/.chock/bin/index/codex_cli-PreToolUse-d2160b00.json b/.chock/bin/index/codex_cli-PreToolUse-d2160b00.json
index 2653147e..95ad602b 100644
--- a/.chock/bin/index/codex_cli-PreToolUse-d2160b00.json
+++ b/.chock/bin/index/codex_cli-PreToolUse-d2160b00.json
@@ -17,7 +17,6 @@
".chock/compiled/block-invisible-unicode/ci-gate/step.yaml": "84e201486169ad4c016579f744c77b88b3b722628c01018d6afa7239fc9bec63",
".chock/compiled/block-invisible-unicode/git-hook/gate.json": "351fb35fffc9aba4882fe53ebbd3713b69aca6b4eb75798538a327b1cb641e1e",
".chock/compiled/block-invisible-unicode/git-hook/git-pre-commit.sh": "454c869cf2aa5123164f732ab28ffb79cfbf57c4e4a2b73597ef592bf11e59c6",
- ".chock/compiled/block-invisible-unicode/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-invisible-unicode/mcp-gateway/gateway-gate.json": "83a400812189da3cb5ba7150d969698ab2400aa6c558348499f8745b5bf17ae0",
".chock/compiled/block-invisible-unicode/pre-tool-use/codex_cli-write-hooks.json": "fbad2af5a4a0e25f8a2704865641310f88042fe3c36ef3f5184b023d7b23af09",
".chock/compiled/block-invisible-unicode/pre-tool-use/cursor-write-hooks.json": "5a8a3215d75707c045b803c913edae75beaf9554cf4fa237d757ad773dfea2f4",
@@ -61,7 +60,6 @@
".chock/compiled/block-wildcard-agent-permissions/ci-gate/step.yaml": "f173704ceb69af71a971c081d7219f205fc176b5970dd4a32e429bbf4f6cd929",
".chock/compiled/block-wildcard-agent-permissions/git-hook/gate.json": "758636f7d17326652db0cac493c4fb59dcd7eaa922824a6e43bc49bfb616f762",
".chock/compiled/block-wildcard-agent-permissions/git-hook/git-pre-commit.sh": "8ad425c111c1dbf52a48ad2ba68b645d4d716befa8dfea575817ecea752421ea",
- ".chock/compiled/block-wildcard-agent-permissions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-wildcard-agent-permissions/mcp-gateway/gateway-gate.json": "9bf2c6b2447a2227f303b44afd50771db2cfa3a3ee40edc1280ac43209060c55",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/codex_cli-write-hooks.json": "8af817d29d040a474bbd5aa4c090c6084ab153f985882588e6b753ad6df1aad1",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/cursor-write-hooks.json": "691bdbeb577970ffdbc416b828781b74c39bcc9abe6eeda09e0d0069d0a04578",
@@ -105,7 +103,6 @@
".chock/compiled/pin-github-actions/ci-gate/step.yaml": "91ed82dfc00043421971fc4f480e800682fe9f8b8c0e6aa2cfecbb1e8de8b01d",
".chock/compiled/pin-github-actions/git-hook/gate.json": "65b5bc9554fa8852cf94ceaaced461755d7694c8b87b37fe7a8434d8642c666b",
".chock/compiled/pin-github-actions/git-hook/git-pre-commit.sh": "e6e47fcbbce3525c47b7ea69deee273ce95442ef3dac7bcd43a897b553769bcd",
- ".chock/compiled/pin-github-actions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/pin-github-actions/mcp-gateway/gateway-gate.json": "308905df356acf7194c529bf0a418fd219e083ebd8545ce1aabd45c2dfbc2650",
".chock/compiled/pin-github-actions/pre-tool-use/codex_cli-write-hooks.json": "14238725b34a2e01cda395bc90e6ac5c914b4450b3b33ab81934df6324c1210d",
".chock/compiled/pin-github-actions/pre-tool-use/cursor-write-hooks.json": "68283be362683ad10a6a4542ecc4d59cb52bfcfb02483587262b5c5e6997d6e1",
@@ -152,7 +149,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -209,7 +205,6 @@
".chock/compiled/scan-secrets/ci-gate/step.yaml": "e2392603980559fbc57a1be4e0243cfa3d620fddbc6c8be7b2114fd4bbad9e07",
".chock/compiled/scan-secrets/git-hook/gate.json": "04d7a7705ced24c5c341ab4dc9806c3f488e2b1ac7a6c0b995e45b2e810cfd1b",
".chock/compiled/scan-secrets/git-hook/git-pre-commit.sh": "65c9db2f5b615a079cf92b63d3c739bcd4427ed4db33811b13d8922c43bb2b50",
- ".chock/compiled/scan-secrets/managed-setting/managed-settings.json": "650436873f2a8da403515b6a205bf0006fbd2799dd8ff6c16a46b80847beafe5",
".chock/compiled/scan-secrets/mcp-gateway/gateway-gate.json": "520fd73b5d80023c68619e7ff56539c74ed0ef672ba8ce4686cf6f34972c7b25",
".chock/compiled/scan-secrets/pre-tool-use/codex_cli-write-hooks.json": "804cedc96a9809cb84f27e5d9f0da8989b32dc5173fdd37a35bfd204771a3edc",
".chock/compiled/scan-secrets/pre-tool-use/cursor-write-hooks.json": "a81dd0ba1d107bc551c51bbd7084a272c2a0b7bcc0e0b02411c36af15db60da8",
diff --git a/.chock/bin/index/cursor-beforeShellExecution-b6c825df.json b/.chock/bin/index/cursor-beforeShellExecution-b6c825df.json
index 6f3c0aa2..53fe6ac3 100644
--- a/.chock/bin/index/cursor-beforeShellExecution-b6c825df.json
+++ b/.chock/bin/index/cursor-beforeShellExecution-b6c825df.json
@@ -20,7 +20,6 @@
".chock/compiled/block-destructive-commands/agent-hooks/agent-hooks.json": "166952d2add28842185387ca8602d36f511968c7e666e04c87708dc9dfe3054e",
".chock/compiled/block-destructive-commands/ambient-rule/ambient.md": "67f05c884bf417822000ebac578a7090a3ead6e07f0dea03c46eaf695214f190",
".chock/compiled/block-destructive-commands/git-hook/git-pre-push.sh": "ecb69d79165216412f646fb2ef8d53646a4c6d39fde77bfcc987adff7c76149e",
- ".chock/compiled/block-destructive-commands/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-destructive-commands/pre-tool-use/antigravity-hooks.json": "9848d7c4f5be4c7ca30d401ceffe1ad4ec30775a0383552232aed9a91499b002",
".chock/compiled/block-destructive-commands/pre-tool-use/codex_cli-hooks.json": "02d8a824208df11dfd45e452e684e0779d8f164c4b6a8164bae9f9ca2cbf0865",
".chock/compiled/block-destructive-commands/pre-tool-use/cursor-hooks.json": "7091a6caea23d8794ef4e26af62e77d9f3a3bc3a38d8de9a941277e053ca1d97",
@@ -55,7 +54,6 @@
".agents/policies/block-no-verify/skills/block-no-verify/SKILL.md": "4e40b8cb58619728bdfc8dd4de2143c77bfa8c744f1f44d34904b88ae85ac023",
".chock/compiled/block-no-verify/agent-hooks/agent-hooks.json": "82b2e539bb812058a0c6cf3298ae9b72762eec28ede995ebe730b5d76f99c02b",
".chock/compiled/block-no-verify/ambient-rule/ambient.md": "371f90ab55eea13626e972c05883f2c1c427c9ca21a6d4aff23efa4513469431",
- ".chock/compiled/block-no-verify/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-no-verify/pre-tool-use/antigravity-hooks.json": "1d5445dda7ade581edf55dc5e2d9adfde0c2ec9efd9cede936b8b99fd1fb0a9b",
".chock/compiled/block-no-verify/pre-tool-use/codex_cli-hooks.json": "a9df710f0b597cf83be795e5f7e68e0b9a641199765f4c7870de0be60b9ce8f0",
".chock/compiled/block-no-verify/pre-tool-use/cursor-hooks.json": "b7d84e25198f56302446e5a3738bfc1328a1e144c69d4d5b8cacdc83b9c829fa",
@@ -92,7 +90,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -152,7 +149,6 @@
".chock/compiled/protect-commit-privacy/agent-hooks/agent-hooks.json": "c532957fe3efd114386ced897aec8fffdfc41e8f281a39efb4620f4e6a7d2747",
".chock/compiled/protect-commit-privacy/ambient-rule/ambient.md": "0d747282d92f843a14974765e038a69a41c93c70e1e6e8100a6546d5b48865c4",
".chock/compiled/protect-commit-privacy/git-hook/git-commit-msg.sh": "c4d9679ba23a73ab2fad594b5a3c088fd1a29d2b2444483da6d08023e0fef98a",
- ".chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-commit-privacy/pre-tool-use/antigravity-hooks.json": "762b527f13d0924e9fdd48b748d1027a1232a25225189e763cabcee208e9055d",
".chock/compiled/protect-commit-privacy/pre-tool-use/codex_cli-hooks.json": "85f228d8d50290015ef3204a73e9ddf3470929ed7fbb0f0ce8bd2d2eb8460f05",
".chock/compiled/protect-commit-privacy/pre-tool-use/cursor-hooks.json": "28d17b33eacbc0e331fc588ee9a129e66f9ad29414dad360066990d1c739e4db",
diff --git a/.chock/bin/index/cursor-preToolUse-b6c825df.json b/.chock/bin/index/cursor-preToolUse-b6c825df.json
index ee5b6120..e2017f6d 100644
--- a/.chock/bin/index/cursor-preToolUse-b6c825df.json
+++ b/.chock/bin/index/cursor-preToolUse-b6c825df.json
@@ -17,7 +17,6 @@
".chock/compiled/block-invisible-unicode/ci-gate/step.yaml": "84e201486169ad4c016579f744c77b88b3b722628c01018d6afa7239fc9bec63",
".chock/compiled/block-invisible-unicode/git-hook/gate.json": "351fb35fffc9aba4882fe53ebbd3713b69aca6b4eb75798538a327b1cb641e1e",
".chock/compiled/block-invisible-unicode/git-hook/git-pre-commit.sh": "454c869cf2aa5123164f732ab28ffb79cfbf57c4e4a2b73597ef592bf11e59c6",
- ".chock/compiled/block-invisible-unicode/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-invisible-unicode/mcp-gateway/gateway-gate.json": "83a400812189da3cb5ba7150d969698ab2400aa6c558348499f8745b5bf17ae0",
".chock/compiled/block-invisible-unicode/pre-tool-use/codex_cli-write-hooks.json": "fbad2af5a4a0e25f8a2704865641310f88042fe3c36ef3f5184b023d7b23af09",
".chock/compiled/block-invisible-unicode/pre-tool-use/cursor-write-hooks.json": "5a8a3215d75707c045b803c913edae75beaf9554cf4fa237d757ad773dfea2f4",
@@ -61,7 +60,6 @@
".chock/compiled/block-wildcard-agent-permissions/ci-gate/step.yaml": "f173704ceb69af71a971c081d7219f205fc176b5970dd4a32e429bbf4f6cd929",
".chock/compiled/block-wildcard-agent-permissions/git-hook/gate.json": "758636f7d17326652db0cac493c4fb59dcd7eaa922824a6e43bc49bfb616f762",
".chock/compiled/block-wildcard-agent-permissions/git-hook/git-pre-commit.sh": "8ad425c111c1dbf52a48ad2ba68b645d4d716befa8dfea575817ecea752421ea",
- ".chock/compiled/block-wildcard-agent-permissions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-wildcard-agent-permissions/mcp-gateway/gateway-gate.json": "9bf2c6b2447a2227f303b44afd50771db2cfa3a3ee40edc1280ac43209060c55",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/codex_cli-write-hooks.json": "8af817d29d040a474bbd5aa4c090c6084ab153f985882588e6b753ad6df1aad1",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/cursor-write-hooks.json": "691bdbeb577970ffdbc416b828781b74c39bcc9abe6eeda09e0d0069d0a04578",
@@ -105,7 +103,6 @@
".chock/compiled/pin-github-actions/ci-gate/step.yaml": "91ed82dfc00043421971fc4f480e800682fe9f8b8c0e6aa2cfecbb1e8de8b01d",
".chock/compiled/pin-github-actions/git-hook/gate.json": "65b5bc9554fa8852cf94ceaaced461755d7694c8b87b37fe7a8434d8642c666b",
".chock/compiled/pin-github-actions/git-hook/git-pre-commit.sh": "e6e47fcbbce3525c47b7ea69deee273ce95442ef3dac7bcd43a897b553769bcd",
- ".chock/compiled/pin-github-actions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/pin-github-actions/mcp-gateway/gateway-gate.json": "308905df356acf7194c529bf0a418fd219e083ebd8545ce1aabd45c2dfbc2650",
".chock/compiled/pin-github-actions/pre-tool-use/codex_cli-write-hooks.json": "14238725b34a2e01cda395bc90e6ac5c914b4450b3b33ab81934df6324c1210d",
".chock/compiled/pin-github-actions/pre-tool-use/cursor-write-hooks.json": "68283be362683ad10a6a4542ecc4d59cb52bfcfb02483587262b5c5e6997d6e1",
@@ -152,7 +149,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -209,7 +205,6 @@
".chock/compiled/scan-secrets/ci-gate/step.yaml": "e2392603980559fbc57a1be4e0243cfa3d620fddbc6c8be7b2114fd4bbad9e07",
".chock/compiled/scan-secrets/git-hook/gate.json": "04d7a7705ced24c5c341ab4dc9806c3f488e2b1ac7a6c0b995e45b2e810cfd1b",
".chock/compiled/scan-secrets/git-hook/git-pre-commit.sh": "65c9db2f5b615a079cf92b63d3c739bcd4427ed4db33811b13d8922c43bb2b50",
- ".chock/compiled/scan-secrets/managed-setting/managed-settings.json": "650436873f2a8da403515b6a205bf0006fbd2799dd8ff6c16a46b80847beafe5",
".chock/compiled/scan-secrets/mcp-gateway/gateway-gate.json": "520fd73b5d80023c68619e7ff56539c74ed0ef672ba8ce4686cf6f34972c7b25",
".chock/compiled/scan-secrets/pre-tool-use/codex_cli-write-hooks.json": "804cedc96a9809cb84f27e5d9f0da8989b32dc5173fdd37a35bfd204771a3edc",
".chock/compiled/scan-secrets/pre-tool-use/cursor-write-hooks.json": "a81dd0ba1d107bc551c51bbd7084a272c2a0b7bcc0e0b02411c36af15db60da8",
@@ -250,7 +245,6 @@
".chock/compiled/token-efficiency/agent-hooks/tool-call-gate.json": "0689304b5bacd25e9a371674d0faa8f9b8d9d35132d2faf7917c2b165a1a93fa",
".chock/compiled/token-efficiency/agent-hooks/tool-call-hooks.json": "7300181bc92f845f81e316813adc9eb6cfd58d8a94525126455203df7fb08e6a",
".chock/compiled/token-efficiency/ambient-rule/ambient.md": "6d94b590c79d340fe25c48dc119b41ece181c5c605b4a38a853e54b54f4e9156",
- ".chock/compiled/token-efficiency/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/token-efficiency/pre-tool-use/codex_cli-tool-call-hooks.json": "a80d3ca758064cba6407f75213a659ec24321eddd85b2adc444cf9f367c5e741",
".chock/compiled/token-efficiency/pre-tool-use/cursor-post-hooks.json": "4348e99148692cafca9417a6dba71e01bda26a404733926415313428bb7f2d93",
".chock/compiled/token-efficiency/pre-tool-use/cursor-postfailure-hooks.json": "9c1e9f0f10255027115cfe5f74ac955be9f66f29973905f8eae319293285f2ab",
diff --git a/.chock/bin/index/devin-PreToolUse-185f9750.json b/.chock/bin/index/devin-PreToolUse-185f9750.json
index 6f3c0aa2..53fe6ac3 100644
--- a/.chock/bin/index/devin-PreToolUse-185f9750.json
+++ b/.chock/bin/index/devin-PreToolUse-185f9750.json
@@ -20,7 +20,6 @@
".chock/compiled/block-destructive-commands/agent-hooks/agent-hooks.json": "166952d2add28842185387ca8602d36f511968c7e666e04c87708dc9dfe3054e",
".chock/compiled/block-destructive-commands/ambient-rule/ambient.md": "67f05c884bf417822000ebac578a7090a3ead6e07f0dea03c46eaf695214f190",
".chock/compiled/block-destructive-commands/git-hook/git-pre-push.sh": "ecb69d79165216412f646fb2ef8d53646a4c6d39fde77bfcc987adff7c76149e",
- ".chock/compiled/block-destructive-commands/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-destructive-commands/pre-tool-use/antigravity-hooks.json": "9848d7c4f5be4c7ca30d401ceffe1ad4ec30775a0383552232aed9a91499b002",
".chock/compiled/block-destructive-commands/pre-tool-use/codex_cli-hooks.json": "02d8a824208df11dfd45e452e684e0779d8f164c4b6a8164bae9f9ca2cbf0865",
".chock/compiled/block-destructive-commands/pre-tool-use/cursor-hooks.json": "7091a6caea23d8794ef4e26af62e77d9f3a3bc3a38d8de9a941277e053ca1d97",
@@ -55,7 +54,6 @@
".agents/policies/block-no-verify/skills/block-no-verify/SKILL.md": "4e40b8cb58619728bdfc8dd4de2143c77bfa8c744f1f44d34904b88ae85ac023",
".chock/compiled/block-no-verify/agent-hooks/agent-hooks.json": "82b2e539bb812058a0c6cf3298ae9b72762eec28ede995ebe730b5d76f99c02b",
".chock/compiled/block-no-verify/ambient-rule/ambient.md": "371f90ab55eea13626e972c05883f2c1c427c9ca21a6d4aff23efa4513469431",
- ".chock/compiled/block-no-verify/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-no-verify/pre-tool-use/antigravity-hooks.json": "1d5445dda7ade581edf55dc5e2d9adfde0c2ec9efd9cede936b8b99fd1fb0a9b",
".chock/compiled/block-no-verify/pre-tool-use/codex_cli-hooks.json": "a9df710f0b597cf83be795e5f7e68e0b9a641199765f4c7870de0be60b9ce8f0",
".chock/compiled/block-no-verify/pre-tool-use/cursor-hooks.json": "b7d84e25198f56302446e5a3738bfc1328a1e144c69d4d5b8cacdc83b9c829fa",
@@ -92,7 +90,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -152,7 +149,6 @@
".chock/compiled/protect-commit-privacy/agent-hooks/agent-hooks.json": "c532957fe3efd114386ced897aec8fffdfc41e8f281a39efb4620f4e6a7d2747",
".chock/compiled/protect-commit-privacy/ambient-rule/ambient.md": "0d747282d92f843a14974765e038a69a41c93c70e1e6e8100a6546d5b48865c4",
".chock/compiled/protect-commit-privacy/git-hook/git-commit-msg.sh": "c4d9679ba23a73ab2fad594b5a3c088fd1a29d2b2444483da6d08023e0fef98a",
- ".chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-commit-privacy/pre-tool-use/antigravity-hooks.json": "762b527f13d0924e9fdd48b748d1027a1232a25225189e763cabcee208e9055d",
".chock/compiled/protect-commit-privacy/pre-tool-use/codex_cli-hooks.json": "85f228d8d50290015ef3204a73e9ddf3470929ed7fbb0f0ce8bd2d2eb8460f05",
".chock/compiled/protect-commit-privacy/pre-tool-use/cursor-hooks.json": "28d17b33eacbc0e331fc588ee9a129e66f9ad29414dad360066990d1c739e4db",
diff --git a/.chock/bin/index/gemini_cli-BeforeTool-09cc5246.json b/.chock/bin/index/gemini_cli-BeforeTool-09cc5246.json
index 6f3c0aa2..53fe6ac3 100644
--- a/.chock/bin/index/gemini_cli-BeforeTool-09cc5246.json
+++ b/.chock/bin/index/gemini_cli-BeforeTool-09cc5246.json
@@ -20,7 +20,6 @@
".chock/compiled/block-destructive-commands/agent-hooks/agent-hooks.json": "166952d2add28842185387ca8602d36f511968c7e666e04c87708dc9dfe3054e",
".chock/compiled/block-destructive-commands/ambient-rule/ambient.md": "67f05c884bf417822000ebac578a7090a3ead6e07f0dea03c46eaf695214f190",
".chock/compiled/block-destructive-commands/git-hook/git-pre-push.sh": "ecb69d79165216412f646fb2ef8d53646a4c6d39fde77bfcc987adff7c76149e",
- ".chock/compiled/block-destructive-commands/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-destructive-commands/pre-tool-use/antigravity-hooks.json": "9848d7c4f5be4c7ca30d401ceffe1ad4ec30775a0383552232aed9a91499b002",
".chock/compiled/block-destructive-commands/pre-tool-use/codex_cli-hooks.json": "02d8a824208df11dfd45e452e684e0779d8f164c4b6a8164bae9f9ca2cbf0865",
".chock/compiled/block-destructive-commands/pre-tool-use/cursor-hooks.json": "7091a6caea23d8794ef4e26af62e77d9f3a3bc3a38d8de9a941277e053ca1d97",
@@ -55,7 +54,6 @@
".agents/policies/block-no-verify/skills/block-no-verify/SKILL.md": "4e40b8cb58619728bdfc8dd4de2143c77bfa8c744f1f44d34904b88ae85ac023",
".chock/compiled/block-no-verify/agent-hooks/agent-hooks.json": "82b2e539bb812058a0c6cf3298ae9b72762eec28ede995ebe730b5d76f99c02b",
".chock/compiled/block-no-verify/ambient-rule/ambient.md": "371f90ab55eea13626e972c05883f2c1c427c9ca21a6d4aff23efa4513469431",
- ".chock/compiled/block-no-verify/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-no-verify/pre-tool-use/antigravity-hooks.json": "1d5445dda7ade581edf55dc5e2d9adfde0c2ec9efd9cede936b8b99fd1fb0a9b",
".chock/compiled/block-no-verify/pre-tool-use/codex_cli-hooks.json": "a9df710f0b597cf83be795e5f7e68e0b9a641199765f4c7870de0be60b9ce8f0",
".chock/compiled/block-no-verify/pre-tool-use/cursor-hooks.json": "b7d84e25198f56302446e5a3738bfc1328a1e144c69d4d5b8cacdc83b9c829fa",
@@ -92,7 +90,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -152,7 +149,6 @@
".chock/compiled/protect-commit-privacy/agent-hooks/agent-hooks.json": "c532957fe3efd114386ced897aec8fffdfc41e8f281a39efb4620f4e6a7d2747",
".chock/compiled/protect-commit-privacy/ambient-rule/ambient.md": "0d747282d92f843a14974765e038a69a41c93c70e1e6e8100a6546d5b48865c4",
".chock/compiled/protect-commit-privacy/git-hook/git-commit-msg.sh": "c4d9679ba23a73ab2fad594b5a3c088fd1a29d2b2444483da6d08023e0fef98a",
- ".chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-commit-privacy/pre-tool-use/antigravity-hooks.json": "762b527f13d0924e9fdd48b748d1027a1232a25225189e763cabcee208e9055d",
".chock/compiled/protect-commit-privacy/pre-tool-use/codex_cli-hooks.json": "85f228d8d50290015ef3204a73e9ddf3470929ed7fbb0f0ce8bd2d2eb8460f05",
".chock/compiled/protect-commit-privacy/pre-tool-use/cursor-hooks.json": "28d17b33eacbc0e331fc588ee9a129e66f9ad29414dad360066990d1c739e4db",
diff --git a/.chock/bin/index/gemini_cli-BeforeTool-c8f6602b.json b/.chock/bin/index/gemini_cli-BeforeTool-c8f6602b.json
index a5aefb93..2f066730 100644
--- a/.chock/bin/index/gemini_cli-BeforeTool-c8f6602b.json
+++ b/.chock/bin/index/gemini_cli-BeforeTool-c8f6602b.json
@@ -14,7 +14,6 @@
".chock/compiled/token-efficiency/agent-hooks/tool-call-gate.json": "0689304b5bacd25e9a371674d0faa8f9b8d9d35132d2faf7917c2b165a1a93fa",
".chock/compiled/token-efficiency/agent-hooks/tool-call-hooks.json": "7300181bc92f845f81e316813adc9eb6cfd58d8a94525126455203df7fb08e6a",
".chock/compiled/token-efficiency/ambient-rule/ambient.md": "6d94b590c79d340fe25c48dc119b41ece181c5c605b4a38a853e54b54f4e9156",
- ".chock/compiled/token-efficiency/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/token-efficiency/pre-tool-use/codex_cli-tool-call-hooks.json": "a80d3ca758064cba6407f75213a659ec24321eddd85b2adc444cf9f367c5e741",
".chock/compiled/token-efficiency/pre-tool-use/cursor-post-hooks.json": "4348e99148692cafca9417a6dba71e01bda26a404733926415313428bb7f2d93",
".chock/compiled/token-efficiency/pre-tool-use/cursor-postfailure-hooks.json": "9c1e9f0f10255027115cfe5f74ac955be9f66f29973905f8eae319293285f2ab",
diff --git a/.chock/bin/index/gemini_cli-BeforeTool-e86eddda.json b/.chock/bin/index/gemini_cli-BeforeTool-e86eddda.json
index 2653147e..95ad602b 100644
--- a/.chock/bin/index/gemini_cli-BeforeTool-e86eddda.json
+++ b/.chock/bin/index/gemini_cli-BeforeTool-e86eddda.json
@@ -17,7 +17,6 @@
".chock/compiled/block-invisible-unicode/ci-gate/step.yaml": "84e201486169ad4c016579f744c77b88b3b722628c01018d6afa7239fc9bec63",
".chock/compiled/block-invisible-unicode/git-hook/gate.json": "351fb35fffc9aba4882fe53ebbd3713b69aca6b4eb75798538a327b1cb641e1e",
".chock/compiled/block-invisible-unicode/git-hook/git-pre-commit.sh": "454c869cf2aa5123164f732ab28ffb79cfbf57c4e4a2b73597ef592bf11e59c6",
- ".chock/compiled/block-invisible-unicode/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-invisible-unicode/mcp-gateway/gateway-gate.json": "83a400812189da3cb5ba7150d969698ab2400aa6c558348499f8745b5bf17ae0",
".chock/compiled/block-invisible-unicode/pre-tool-use/codex_cli-write-hooks.json": "fbad2af5a4a0e25f8a2704865641310f88042fe3c36ef3f5184b023d7b23af09",
".chock/compiled/block-invisible-unicode/pre-tool-use/cursor-write-hooks.json": "5a8a3215d75707c045b803c913edae75beaf9554cf4fa237d757ad773dfea2f4",
@@ -61,7 +60,6 @@
".chock/compiled/block-wildcard-agent-permissions/ci-gate/step.yaml": "f173704ceb69af71a971c081d7219f205fc176b5970dd4a32e429bbf4f6cd929",
".chock/compiled/block-wildcard-agent-permissions/git-hook/gate.json": "758636f7d17326652db0cac493c4fb59dcd7eaa922824a6e43bc49bfb616f762",
".chock/compiled/block-wildcard-agent-permissions/git-hook/git-pre-commit.sh": "8ad425c111c1dbf52a48ad2ba68b645d4d716befa8dfea575817ecea752421ea",
- ".chock/compiled/block-wildcard-agent-permissions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-wildcard-agent-permissions/mcp-gateway/gateway-gate.json": "9bf2c6b2447a2227f303b44afd50771db2cfa3a3ee40edc1280ac43209060c55",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/codex_cli-write-hooks.json": "8af817d29d040a474bbd5aa4c090c6084ab153f985882588e6b753ad6df1aad1",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/cursor-write-hooks.json": "691bdbeb577970ffdbc416b828781b74c39bcc9abe6eeda09e0d0069d0a04578",
@@ -105,7 +103,6 @@
".chock/compiled/pin-github-actions/ci-gate/step.yaml": "91ed82dfc00043421971fc4f480e800682fe9f8b8c0e6aa2cfecbb1e8de8b01d",
".chock/compiled/pin-github-actions/git-hook/gate.json": "65b5bc9554fa8852cf94ceaaced461755d7694c8b87b37fe7a8434d8642c666b",
".chock/compiled/pin-github-actions/git-hook/git-pre-commit.sh": "e6e47fcbbce3525c47b7ea69deee273ce95442ef3dac7bcd43a897b553769bcd",
- ".chock/compiled/pin-github-actions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/pin-github-actions/mcp-gateway/gateway-gate.json": "308905df356acf7194c529bf0a418fd219e083ebd8545ce1aabd45c2dfbc2650",
".chock/compiled/pin-github-actions/pre-tool-use/codex_cli-write-hooks.json": "14238725b34a2e01cda395bc90e6ac5c914b4450b3b33ab81934df6324c1210d",
".chock/compiled/pin-github-actions/pre-tool-use/cursor-write-hooks.json": "68283be362683ad10a6a4542ecc4d59cb52bfcfb02483587262b5c5e6997d6e1",
@@ -152,7 +149,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -209,7 +205,6 @@
".chock/compiled/scan-secrets/ci-gate/step.yaml": "e2392603980559fbc57a1be4e0243cfa3d620fddbc6c8be7b2114fd4bbad9e07",
".chock/compiled/scan-secrets/git-hook/gate.json": "04d7a7705ced24c5c341ab4dc9806c3f488e2b1ac7a6c0b995e45b2e810cfd1b",
".chock/compiled/scan-secrets/git-hook/git-pre-commit.sh": "65c9db2f5b615a079cf92b63d3c739bcd4427ed4db33811b13d8922c43bb2b50",
- ".chock/compiled/scan-secrets/managed-setting/managed-settings.json": "650436873f2a8da403515b6a205bf0006fbd2799dd8ff6c16a46b80847beafe5",
".chock/compiled/scan-secrets/mcp-gateway/gateway-gate.json": "520fd73b5d80023c68619e7ff56539c74ed0ef672ba8ce4686cf6f34972c7b25",
".chock/compiled/scan-secrets/pre-tool-use/codex_cli-write-hooks.json": "804cedc96a9809cb84f27e5d9f0da8989b32dc5173fdd37a35bfd204771a3edc",
".chock/compiled/scan-secrets/pre-tool-use/cursor-write-hooks.json": "a81dd0ba1d107bc551c51bbd7084a272c2a0b7bcc0e0b02411c36af15db60da8",
diff --git a/.chock/bin/index/grok-PreToolUse-185f9750.json b/.chock/bin/index/grok-PreToolUse-185f9750.json
index 6f3c0aa2..53fe6ac3 100644
--- a/.chock/bin/index/grok-PreToolUse-185f9750.json
+++ b/.chock/bin/index/grok-PreToolUse-185f9750.json
@@ -20,7 +20,6 @@
".chock/compiled/block-destructive-commands/agent-hooks/agent-hooks.json": "166952d2add28842185387ca8602d36f511968c7e666e04c87708dc9dfe3054e",
".chock/compiled/block-destructive-commands/ambient-rule/ambient.md": "67f05c884bf417822000ebac578a7090a3ead6e07f0dea03c46eaf695214f190",
".chock/compiled/block-destructive-commands/git-hook/git-pre-push.sh": "ecb69d79165216412f646fb2ef8d53646a4c6d39fde77bfcc987adff7c76149e",
- ".chock/compiled/block-destructive-commands/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-destructive-commands/pre-tool-use/antigravity-hooks.json": "9848d7c4f5be4c7ca30d401ceffe1ad4ec30775a0383552232aed9a91499b002",
".chock/compiled/block-destructive-commands/pre-tool-use/codex_cli-hooks.json": "02d8a824208df11dfd45e452e684e0779d8f164c4b6a8164bae9f9ca2cbf0865",
".chock/compiled/block-destructive-commands/pre-tool-use/cursor-hooks.json": "7091a6caea23d8794ef4e26af62e77d9f3a3bc3a38d8de9a941277e053ca1d97",
@@ -55,7 +54,6 @@
".agents/policies/block-no-verify/skills/block-no-verify/SKILL.md": "4e40b8cb58619728bdfc8dd4de2143c77bfa8c744f1f44d34904b88ae85ac023",
".chock/compiled/block-no-verify/agent-hooks/agent-hooks.json": "82b2e539bb812058a0c6cf3298ae9b72762eec28ede995ebe730b5d76f99c02b",
".chock/compiled/block-no-verify/ambient-rule/ambient.md": "371f90ab55eea13626e972c05883f2c1c427c9ca21a6d4aff23efa4513469431",
- ".chock/compiled/block-no-verify/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-no-verify/pre-tool-use/antigravity-hooks.json": "1d5445dda7ade581edf55dc5e2d9adfde0c2ec9efd9cede936b8b99fd1fb0a9b",
".chock/compiled/block-no-verify/pre-tool-use/codex_cli-hooks.json": "a9df710f0b597cf83be795e5f7e68e0b9a641199765f4c7870de0be60b9ce8f0",
".chock/compiled/block-no-verify/pre-tool-use/cursor-hooks.json": "b7d84e25198f56302446e5a3738bfc1328a1e144c69d4d5b8cacdc83b9c829fa",
@@ -92,7 +90,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -152,7 +149,6 @@
".chock/compiled/protect-commit-privacy/agent-hooks/agent-hooks.json": "c532957fe3efd114386ced897aec8fffdfc41e8f281a39efb4620f4e6a7d2747",
".chock/compiled/protect-commit-privacy/ambient-rule/ambient.md": "0d747282d92f843a14974765e038a69a41c93c70e1e6e8100a6546d5b48865c4",
".chock/compiled/protect-commit-privacy/git-hook/git-commit-msg.sh": "c4d9679ba23a73ab2fad594b5a3c088fd1a29d2b2444483da6d08023e0fef98a",
- ".chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-commit-privacy/pre-tool-use/antigravity-hooks.json": "762b527f13d0924e9fdd48b748d1027a1232a25225189e763cabcee208e9055d",
".chock/compiled/protect-commit-privacy/pre-tool-use/codex_cli-hooks.json": "85f228d8d50290015ef3204a73e9ddf3470929ed7fbb0f0ce8bd2d2eb8460f05",
".chock/compiled/protect-commit-privacy/pre-tool-use/cursor-hooks.json": "28d17b33eacbc0e331fc588ee9a129e66f9ad29414dad360066990d1c739e4db",
diff --git a/.chock/bin/index/tabnine-BeforeTool-c8f6602b.json b/.chock/bin/index/tabnine-BeforeTool-c8f6602b.json
index 6f3c0aa2..53fe6ac3 100644
--- a/.chock/bin/index/tabnine-BeforeTool-c8f6602b.json
+++ b/.chock/bin/index/tabnine-BeforeTool-c8f6602b.json
@@ -20,7 +20,6 @@
".chock/compiled/block-destructive-commands/agent-hooks/agent-hooks.json": "166952d2add28842185387ca8602d36f511968c7e666e04c87708dc9dfe3054e",
".chock/compiled/block-destructive-commands/ambient-rule/ambient.md": "67f05c884bf417822000ebac578a7090a3ead6e07f0dea03c46eaf695214f190",
".chock/compiled/block-destructive-commands/git-hook/git-pre-push.sh": "ecb69d79165216412f646fb2ef8d53646a4c6d39fde77bfcc987adff7c76149e",
- ".chock/compiled/block-destructive-commands/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-destructive-commands/pre-tool-use/antigravity-hooks.json": "9848d7c4f5be4c7ca30d401ceffe1ad4ec30775a0383552232aed9a91499b002",
".chock/compiled/block-destructive-commands/pre-tool-use/codex_cli-hooks.json": "02d8a824208df11dfd45e452e684e0779d8f164c4b6a8164bae9f9ca2cbf0865",
".chock/compiled/block-destructive-commands/pre-tool-use/cursor-hooks.json": "7091a6caea23d8794ef4e26af62e77d9f3a3bc3a38d8de9a941277e053ca1d97",
@@ -55,7 +54,6 @@
".agents/policies/block-no-verify/skills/block-no-verify/SKILL.md": "4e40b8cb58619728bdfc8dd4de2143c77bfa8c744f1f44d34904b88ae85ac023",
".chock/compiled/block-no-verify/agent-hooks/agent-hooks.json": "82b2e539bb812058a0c6cf3298ae9b72762eec28ede995ebe730b5d76f99c02b",
".chock/compiled/block-no-verify/ambient-rule/ambient.md": "371f90ab55eea13626e972c05883f2c1c427c9ca21a6d4aff23efa4513469431",
- ".chock/compiled/block-no-verify/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-no-verify/pre-tool-use/antigravity-hooks.json": "1d5445dda7ade581edf55dc5e2d9adfde0c2ec9efd9cede936b8b99fd1fb0a9b",
".chock/compiled/block-no-verify/pre-tool-use/codex_cli-hooks.json": "a9df710f0b597cf83be795e5f7e68e0b9a641199765f4c7870de0be60b9ce8f0",
".chock/compiled/block-no-verify/pre-tool-use/cursor-hooks.json": "b7d84e25198f56302446e5a3738bfc1328a1e144c69d4d5b8cacdc83b9c829fa",
@@ -92,7 +90,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -152,7 +149,6 @@
".chock/compiled/protect-commit-privacy/agent-hooks/agent-hooks.json": "c532957fe3efd114386ced897aec8fffdfc41e8f281a39efb4620f4e6a7d2747",
".chock/compiled/protect-commit-privacy/ambient-rule/ambient.md": "0d747282d92f843a14974765e038a69a41c93c70e1e6e8100a6546d5b48865c4",
".chock/compiled/protect-commit-privacy/git-hook/git-commit-msg.sh": "c4d9679ba23a73ab2fad594b5a3c088fd1a29d2b2444483da6d08023e0fef98a",
- ".chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-commit-privacy/pre-tool-use/antigravity-hooks.json": "762b527f13d0924e9fdd48b748d1027a1232a25225189e763cabcee208e9055d",
".chock/compiled/protect-commit-privacy/pre-tool-use/codex_cli-hooks.json": "85f228d8d50290015ef3204a73e9ddf3470929ed7fbb0f0ce8bd2d2eb8460f05",
".chock/compiled/protect-commit-privacy/pre-tool-use/cursor-hooks.json": "28d17b33eacbc0e331fc588ee9a129e66f9ad29414dad360066990d1c739e4db",
diff --git a/.chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json b/.chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json
index 9df57bb7..2c3be7d4 100644
--- a/.chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json
+++ b/.chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json
@@ -14,7 +14,6 @@
".chock/compiled/token-efficiency/agent-hooks/tool-call-gate.json": "0689304b5bacd25e9a371674d0faa8f9b8d9d35132d2faf7917c2b165a1a93fa",
".chock/compiled/token-efficiency/agent-hooks/tool-call-hooks.json": "7300181bc92f845f81e316813adc9eb6cfd58d8a94525126455203df7fb08e6a",
".chock/compiled/token-efficiency/ambient-rule/ambient.md": "6d94b590c79d340fe25c48dc119b41ece181c5c605b4a38a853e54b54f4e9156",
- ".chock/compiled/token-efficiency/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/token-efficiency/pre-tool-use/codex_cli-tool-call-hooks.json": "a80d3ca758064cba6407f75213a659ec24321eddd85b2adc444cf9f367c5e741",
".chock/compiled/token-efficiency/pre-tool-use/cursor-post-hooks.json": "4348e99148692cafca9417a6dba71e01bda26a404733926415313428bb7f2d93",
".chock/compiled/token-efficiency/pre-tool-use/cursor-postfailure-hooks.json": "9c1e9f0f10255027115cfe5f74ac955be9f66f29973905f8eae319293285f2ab",
diff --git a/.chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json b/.chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json
index 2ae882c8..79336a01 100644
--- a/.chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json
+++ b/.chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json
@@ -17,7 +17,6 @@
".chock/compiled/block-invisible-unicode/ci-gate/step.yaml": "84e201486169ad4c016579f744c77b88b3b722628c01018d6afa7239fc9bec63",
".chock/compiled/block-invisible-unicode/git-hook/gate.json": "351fb35fffc9aba4882fe53ebbd3713b69aca6b4eb75798538a327b1cb641e1e",
".chock/compiled/block-invisible-unicode/git-hook/git-pre-commit.sh": "454c869cf2aa5123164f732ab28ffb79cfbf57c4e4a2b73597ef592bf11e59c6",
- ".chock/compiled/block-invisible-unicode/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-invisible-unicode/mcp-gateway/gateway-gate.json": "83a400812189da3cb5ba7150d969698ab2400aa6c558348499f8745b5bf17ae0",
".chock/compiled/block-invisible-unicode/pre-tool-use/codex_cli-write-hooks.json": "fbad2af5a4a0e25f8a2704865641310f88042fe3c36ef3f5184b023d7b23af09",
".chock/compiled/block-invisible-unicode/pre-tool-use/cursor-write-hooks.json": "5a8a3215d75707c045b803c913edae75beaf9554cf4fa237d757ad773dfea2f4",
@@ -61,7 +60,6 @@
".chock/compiled/block-wildcard-agent-permissions/ci-gate/step.yaml": "f173704ceb69af71a971c081d7219f205fc176b5970dd4a32e429bbf4f6cd929",
".chock/compiled/block-wildcard-agent-permissions/git-hook/gate.json": "758636f7d17326652db0cac493c4fb59dcd7eaa922824a6e43bc49bfb616f762",
".chock/compiled/block-wildcard-agent-permissions/git-hook/git-pre-commit.sh": "8ad425c111c1dbf52a48ad2ba68b645d4d716befa8dfea575817ecea752421ea",
- ".chock/compiled/block-wildcard-agent-permissions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-wildcard-agent-permissions/mcp-gateway/gateway-gate.json": "9bf2c6b2447a2227f303b44afd50771db2cfa3a3ee40edc1280ac43209060c55",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/codex_cli-write-hooks.json": "8af817d29d040a474bbd5aa4c090c6084ab153f985882588e6b753ad6df1aad1",
".chock/compiled/block-wildcard-agent-permissions/pre-tool-use/cursor-write-hooks.json": "691bdbeb577970ffdbc416b828781b74c39bcc9abe6eeda09e0d0069d0a04578",
@@ -105,7 +103,6 @@
".chock/compiled/pin-github-actions/ci-gate/step.yaml": "91ed82dfc00043421971fc4f480e800682fe9f8b8c0e6aa2cfecbb1e8de8b01d",
".chock/compiled/pin-github-actions/git-hook/gate.json": "65b5bc9554fa8852cf94ceaaced461755d7694c8b87b37fe7a8434d8642c666b",
".chock/compiled/pin-github-actions/git-hook/git-pre-commit.sh": "e6e47fcbbce3525c47b7ea69deee273ce95442ef3dac7bcd43a897b553769bcd",
- ".chock/compiled/pin-github-actions/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/pin-github-actions/mcp-gateway/gateway-gate.json": "308905df356acf7194c529bf0a418fd219e083ebd8545ce1aabd45c2dfbc2650",
".chock/compiled/pin-github-actions/pre-tool-use/codex_cli-write-hooks.json": "14238725b34a2e01cda395bc90e6ac5c914b4450b3b33ab81934df6324c1210d",
".chock/compiled/pin-github-actions/pre-tool-use/cursor-write-hooks.json": "68283be362683ad10a6a4542ecc4d59cb52bfcfb02483587262b5c5e6997d6e1",
@@ -152,7 +149,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -209,7 +205,6 @@
".chock/compiled/scan-secrets/ci-gate/step.yaml": "e2392603980559fbc57a1be4e0243cfa3d620fddbc6c8be7b2114fd4bbad9e07",
".chock/compiled/scan-secrets/git-hook/gate.json": "04d7a7705ced24c5c341ab4dc9806c3f488e2b1ac7a6c0b995e45b2e810cfd1b",
".chock/compiled/scan-secrets/git-hook/git-pre-commit.sh": "65c9db2f5b615a079cf92b63d3c739bcd4427ed4db33811b13d8922c43bb2b50",
- ".chock/compiled/scan-secrets/managed-setting/managed-settings.json": "650436873f2a8da403515b6a205bf0006fbd2799dd8ff6c16a46b80847beafe5",
".chock/compiled/scan-secrets/mcp-gateway/gateway-gate.json": "520fd73b5d80023c68619e7ff56539c74ed0ef672ba8ce4686cf6f34972c7b25",
".chock/compiled/scan-secrets/pre-tool-use/codex_cli-write-hooks.json": "804cedc96a9809cb84f27e5d9f0da8989b32dc5173fdd37a35bfd204771a3edc",
".chock/compiled/scan-secrets/pre-tool-use/cursor-write-hooks.json": "a81dd0ba1d107bc551c51bbd7084a272c2a0b7bcc0e0b02411c36af15db60da8",
diff --git a/.chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json b/.chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json
index 6f3c0aa2..53fe6ac3 100644
--- a/.chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json
+++ b/.chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json
@@ -20,7 +20,6 @@
".chock/compiled/block-destructive-commands/agent-hooks/agent-hooks.json": "166952d2add28842185387ca8602d36f511968c7e666e04c87708dc9dfe3054e",
".chock/compiled/block-destructive-commands/ambient-rule/ambient.md": "67f05c884bf417822000ebac578a7090a3ead6e07f0dea03c46eaf695214f190",
".chock/compiled/block-destructive-commands/git-hook/git-pre-push.sh": "ecb69d79165216412f646fb2ef8d53646a4c6d39fde77bfcc987adff7c76149e",
- ".chock/compiled/block-destructive-commands/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-destructive-commands/pre-tool-use/antigravity-hooks.json": "9848d7c4f5be4c7ca30d401ceffe1ad4ec30775a0383552232aed9a91499b002",
".chock/compiled/block-destructive-commands/pre-tool-use/codex_cli-hooks.json": "02d8a824208df11dfd45e452e684e0779d8f164c4b6a8164bae9f9ca2cbf0865",
".chock/compiled/block-destructive-commands/pre-tool-use/cursor-hooks.json": "7091a6caea23d8794ef4e26af62e77d9f3a3bc3a38d8de9a941277e053ca1d97",
@@ -55,7 +54,6 @@
".agents/policies/block-no-verify/skills/block-no-verify/SKILL.md": "4e40b8cb58619728bdfc8dd4de2143c77bfa8c744f1f44d34904b88ae85ac023",
".chock/compiled/block-no-verify/agent-hooks/agent-hooks.json": "82b2e539bb812058a0c6cf3298ae9b72762eec28ede995ebe730b5d76f99c02b",
".chock/compiled/block-no-verify/ambient-rule/ambient.md": "371f90ab55eea13626e972c05883f2c1c427c9ca21a6d4aff23efa4513469431",
- ".chock/compiled/block-no-verify/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/block-no-verify/pre-tool-use/antigravity-hooks.json": "1d5445dda7ade581edf55dc5e2d9adfde0c2ec9efd9cede936b8b99fd1fb0a9b",
".chock/compiled/block-no-verify/pre-tool-use/codex_cli-hooks.json": "a9df710f0b597cf83be795e5f7e68e0b9a641199765f4c7870de0be60b9ce8f0",
".chock/compiled/block-no-verify/pre-tool-use/cursor-hooks.json": "b7d84e25198f56302446e5a3738bfc1328a1e144c69d4d5b8cacdc83b9c829fa",
@@ -92,7 +90,6 @@
".chock/compiled/protect-agent-config/agent-hooks/gate-hooks.json": "d7a2a9b67c712958415981eb0cb7b6dccff19f3162c079c5cfa445afe82e4f9a",
".chock/compiled/protect-agent-config/agent-hooks/gate.json": "15fef0cfe7fbbd34e8b8833fdf9b45f14630cc3b202ea29256a5dd8a3b3d8b33",
".chock/compiled/protect-agent-config/ambient-rule/ambient.md": "933e699a70fa72f4ea3eedc8e21078455785ede5a46c291ee57814b1d16d0cd0",
- ".chock/compiled/protect-agent-config/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-agent-config/mcp-gateway/gateway-gate.json": "81f440f9de61c0e15e73f0f35a319f224e773f1d8f6b92dfe95cc65562407ce5",
".chock/compiled/protect-agent-config/pre-tool-use/antigravity-hooks.json": "3fc5c848ba68835a54b756374c6abb73a285b6f0c9586911385e6a00f3ed79a3",
".chock/compiled/protect-agent-config/pre-tool-use/codex_cli-hooks.json": "ba95952f9d8b552175ea360f46c6a4d76670de1033eb7123f6e3513073913e16",
@@ -152,7 +149,6 @@
".chock/compiled/protect-commit-privacy/agent-hooks/agent-hooks.json": "c532957fe3efd114386ced897aec8fffdfc41e8f281a39efb4620f4e6a7d2747",
".chock/compiled/protect-commit-privacy/ambient-rule/ambient.md": "0d747282d92f843a14974765e038a69a41c93c70e1e6e8100a6546d5b48865c4",
".chock/compiled/protect-commit-privacy/git-hook/git-commit-msg.sh": "c4d9679ba23a73ab2fad594b5a3c088fd1a29d2b2444483da6d08023e0fef98a",
- ".chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json": "859d05e0265611518ac5329c0a52141581f55956fd86e952206d6651820f018b",
".chock/compiled/protect-commit-privacy/pre-tool-use/antigravity-hooks.json": "762b527f13d0924e9fdd48b748d1027a1232a25225189e763cabcee208e9055d",
".chock/compiled/protect-commit-privacy/pre-tool-use/codex_cli-hooks.json": "85f228d8d50290015ef3204a73e9ddf3470929ed7fbb0f0ce8bd2d2eb8460f05",
".chock/compiled/protect-commit-privacy/pre-tool-use/cursor-hooks.json": "28d17b33eacbc0e331fc588ee9a129e66f9ad29414dad360066990d1c739e4db",
diff --git a/.chock/bin/launch.sh b/.chock/bin/launch.sh
index 0b9fb10e..22981835 100755
--- a/.chock/bin/launch.sh
+++ b/.chock/bin/launch.sh
@@ -21,17 +21,20 @@ configured="$(git config --get chock.python 2>/dev/null)"
legacy=
case "${OS:-}|${MSYSTEM:-}" in *Windows_NT*|*"|"?*) legacy=1 ;; esac
[ "$runtime" = "-m" ] && legacy=1
+# A script starts with -E -s (-I less -P): no PYTHON* variable or user site changes it; its own folder stays on the path.
+isolate=-Es
+[ "$runtime" = "-m" ] && isolate=
# Only the marker path sets it (to 9); everywhere else an inherited value is cleared, so it never names an fd.
[ -n "$legacy" ] && { CHOCK_START_FD=; export CHOCK_START_FD; }
for candidate in "$configured" python3 python py; do
[ -n "$candidate" ] || continue
if [ -n "$legacy" ]; then
- if probed="$("$candidate" -c 'import sys; print("chock-python"); sys.exit(sys.version_info < (3, 11,))' /dev/null)" && [ "$probed" = "chock-python" ]; then
- exec "$candidate" -X utf8 "$runtime" "$@"
+ if probed="$("$candidate" -I -c 'import sys; print("chock-python"); sys.exit(sys.version_info < (3, 11,))' /dev/null)" && [ "$probed" = "chock-python" ]; then
+ exec "$candidate" ${isolate:+"$isolate"} -X utf8 "$runtime" "$@"
fi
elif command -v "$candidate" >/dev/null 2>&1; then
exec 3>&1
- marker="$(CHOCK_START_FD=9 "$candidate" -X utf8 "$runtime" "$@" 9>&1 1>&3 3>&-)"
+ marker="$(CHOCK_START_FD=9 "$candidate" ${isolate:+"$isolate"} -X utf8 "$runtime" "$@" 9>&1 1>&3 3>&-)"
status=$?
exec 3>&-
[ "$marker" = "chock-python" ] && exit "$status"
diff --git a/.chock/bin/tabnine.py b/.chock/bin/tabnine.py
index 8fd2cb93..29141032 100755
--- a/.chock/bin/tabnine.py
+++ b/.chock/bin/tabnine.py
@@ -782,7 +782,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/.chock/bin/vscode_copilot.py b/.chock/bin/vscode_copilot.py
index d62f569f..bab53915 100755
--- a/.chock/bin/vscode_copilot.py
+++ b/.chock/bin/vscode_copilot.py
@@ -717,7 +717,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/.chock/bin/windsurf.py b/.chock/bin/windsurf.py
index a8672de9..74cee413 100755
--- a/.chock/bin/windsurf.py
+++ b/.chock/bin/windsurf.py
@@ -680,7 +680,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/.chock/compiled/agent-discipline/managed-setting/managed-settings.json b/.chock/compiled/agent-discipline/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/agent-discipline/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/block-destructive-commands/managed-setting/managed-settings.json b/.chock/compiled/block-destructive-commands/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/block-destructive-commands/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/block-invisible-unicode/managed-setting/managed-settings.json b/.chock/compiled/block-invisible-unicode/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/block-invisible-unicode/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/block-no-verify/managed-setting/managed-settings.json b/.chock/compiled/block-no-verify/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/block-no-verify/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/block-wildcard-agent-permissions/managed-setting/managed-settings.json b/.chock/compiled/block-wildcard-agent-permissions/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/block-wildcard-agent-permissions/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/code-safety/managed-setting/managed-settings.json b/.chock/compiled/code-safety/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/code-safety/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/context-hygiene/managed-setting/managed-settings.json b/.chock/compiled/context-hygiene/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/context-hygiene/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/git-safety/managed-setting/managed-settings.json b/.chock/compiled/git-safety/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/git-safety/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/injection-defense/managed-setting/managed-settings.json b/.chock/compiled/injection-defense/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/injection-defense/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/memory-discipline/managed-setting/managed-settings.json b/.chock/compiled/memory-discipline/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/memory-discipline/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/minimal-content/managed-setting/managed-settings.json b/.chock/compiled/minimal-content/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/minimal-content/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/pin-github-actions/managed-setting/managed-settings.json b/.chock/compiled/pin-github-actions/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/pin-github-actions/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/pre-generated-scripts/managed-setting/managed-settings.json b/.chock/compiled/pre-generated-scripts/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/pre-generated-scripts/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/protect-agent-config/managed-setting/managed-settings.json b/.chock/compiled/protect-agent-config/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/protect-agent-config/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json b/.chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/protect-commit-privacy/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/protect-main-branch/managed-setting/managed-settings.json b/.chock/compiled/protect-main-branch/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/protect-main-branch/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/require-review-evidence/managed-setting/managed-settings.json b/.chock/compiled/require-review-evidence/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/require-review-evidence/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/scan-secrets/managed-setting/managed-settings.json b/.chock/compiled/scan-secrets/managed-setting/managed-settings.json
deleted file mode 100644
index 30afb96f..00000000
--- a/.chock/compiled/scan-secrets/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "deny": [
- {
- "type": "file",
- "pattern": "\\.(env|pem|key|p12|pfx|jks|keystore)$",
- "message": "Credential files are denied in the workspace."
- },
- {
- "type": "text",
- "pattern": "(?i)(AKIA[0-9A-Z]{16}|ghp_[a-zA-Z0-9]{36}|xox[bpas]-[0-9A-Za-z-]{10,}|(sk|rk)_live_[0-9A-Za-z]{16,}|sk-ant-[0-9A-Za-z_-]{20,}|AIza[0-9A-Za-z_-]{35}|npm_[0-9A-Za-z]{36}|eyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]*|-----BEGIN .* PRIVATE KEY-----)",
- "message": "Credential-like values are denied in generated or edited files."
- }
- ],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/test-integrity/managed-setting/managed-settings.json b/.chock/compiled/test-integrity/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/test-integrity/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/token-efficiency/managed-setting/managed-settings.json b/.chock/compiled/token-efficiency/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/token-efficiency/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/verify-framework-conformance/managed-setting/managed-settings.json b/.chock/compiled/verify-framework-conformance/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/verify-framework-conformance/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.chock/compiled/yagni/managed-setting/managed-settings.json b/.chock/compiled/yagni/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/.chock/compiled/yagni/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/.claude/settings.json b/.claude/settings.json
index 9017c332..66d547ee 100644
--- a/.claude/settings.json
+++ b/.claude/settings.json
@@ -6,7 +6,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/claude_code.py --multi \".chock/bin/index/claude_code-PreToolUse-3a2134a7.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/claude_code.py --multi \".chock/bin/index/claude_code-PreToolUse-3a2134a7.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c",
"timeout": 45
}
]
@@ -16,7 +16,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/claude_code.py --multi \".chock/bin/index/claude_code-PreToolUse-4acdeb9e.json\" --index-sha256 2ff022397098e742808806927b5c3194e3f0aa0c162d50d22cd98eef4756f022",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/claude_code.py --multi \".chock/bin/index/claude_code-PreToolUse-4acdeb9e.json\" --index-sha256 8083526dfaf2ae5ef67edf44b86db346ca93eaa1808cc9e406c00571d9c97829",
"timeout": 45
}
]
@@ -25,7 +25,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/claude_code.py --multi \".chock/bin/index/claude_code-PreToolUse-185f9750.json\" --index-sha256 8acaa1f45d082758ffa5270a722263da96ccfd24038713be8e13a11220bd4d2d --stop-check",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/claude_code.py --multi \".chock/bin/index/claude_code-PreToolUse-185f9750.json\" --index-sha256 c016a88140574f28f7b73f92fbff992d34969db9af603a7147673d4cceb9133c --stop-check",
"timeout": 45
}
]
diff --git a/.codex/hooks.json b/.codex/hooks.json
index 3b11e557..133886e5 100644
--- a/.codex/hooks.json
+++ b/.codex/hooks.json
@@ -5,8 +5,8 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-14533f34.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a",
- "commandWindows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-14533f34.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-14533f34.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c",
+ "commandWindows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-14533f34.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
"timeout": 45
}
],
@@ -16,8 +16,8 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-d2160b00.json\" --index-sha256 2ff022397098e742808806927b5c3194e3f0aa0c162d50d22cd98eef4756f022",
- "commandWindows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-d2160b00.json\" --index-sha256 2ff022397098e742808806927b5c3194e3f0aa0c162d50d22cd98eef4756f022; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-d2160b00.json\" --index-sha256 8083526dfaf2ae5ef67edf44b86db346ca93eaa1808cc9e406c00571d9c97829",
+ "commandWindows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-d2160b00.json\" --index-sha256 8083526dfaf2ae5ef67edf44b86db346ca93eaa1808cc9e406c00571d9c97829; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
"timeout": 45
}
],
@@ -27,8 +27,8 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-186bd88e.json\" --index-sha256 8acaa1f45d082758ffa5270a722263da96ccfd24038713be8e13a11220bd4d2d --stop-check",
- "commandWindows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-186bd88e.json\" --index-sha256 8acaa1f45d082758ffa5270a722263da96ccfd24038713be8e13a11220bd4d2d --stop-check; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-186bd88e.json\" --index-sha256 c016a88140574f28f7b73f92fbff992d34969db9af603a7147673d4cceb9133c --stop-check",
+ "commandWindows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/codex_cli.py --multi \".chock/bin/index/codex_cli-PreToolUse-186bd88e.json\" --index-sha256 c016a88140574f28f7b73f92fbff992d34969db9af603a7147673d4cceb9133c --stop-check; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
"timeout": 45
}
]
diff --git a/.cursor/hooks.json b/.cursor/hooks.json
index 225f9f54..21039954 100644
--- a/.cursor/hooks.json
+++ b/.cursor/hooks.json
@@ -2,14 +2,14 @@
"hooks": {
"beforeShellExecution": [
{
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/cursor.py --multi \".chock/bin/index/cursor-beforeShellExecution-b6c825df.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/cursor.py --multi \".chock/bin/index/cursor-beforeShellExecution-b6c825df.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c",
"timeout": 45,
"failClosed": true
}
],
"preToolUse": [
{
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/cursor.py --multi \".chock/bin/index/cursor-preToolUse-b6c825df.json\" --index-sha256 5b6164207fceb0f8784ce211241353a3c843037e90d9c5720f4a6f94c721c196 --stop-check",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/cursor.py --multi \".chock/bin/index/cursor-preToolUse-b6c825df.json\" --index-sha256 44e2f370e3ea951657950c54134d86a43b002dfded0c6af5483cade09a21881c --stop-check",
"timeout": 45,
"failClosed": true
}
diff --git a/.devin/hooks.v1.json b/.devin/hooks.v1.json
index 68b3d5fe..10ef28ec 100644
--- a/.devin/hooks.v1.json
+++ b/.devin/hooks.v1.json
@@ -4,7 +4,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/devin.py --multi \".chock/bin/index/devin-PreToolUse-185f9750.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a --stop-check",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/devin.py --multi \".chock/bin/index/devin-PreToolUse-185f9750.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c --stop-check",
"timeout": 45
}
]
diff --git a/.gemini/settings.json b/.gemini/settings.json
index d8e3887b..a4cee683 100644
--- a/.gemini/settings.json
+++ b/.gemini/settings.json
@@ -5,7 +5,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/gemini_cli.py --multi \".chock/bin/index/gemini_cli-BeforeTool-09cc5246.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/gemini_cli.py --multi \".chock/bin/index/gemini_cli-BeforeTool-09cc5246.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c",
"timeout": 45000
}
],
@@ -15,7 +15,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/gemini_cli.py --multi \".chock/bin/index/gemini_cli-BeforeTool-e86eddda.json\" --index-sha256 2ff022397098e742808806927b5c3194e3f0aa0c162d50d22cd98eef4756f022",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/gemini_cli.py --multi \".chock/bin/index/gemini_cli-BeforeTool-e86eddda.json\" --index-sha256 8083526dfaf2ae5ef67edf44b86db346ca93eaa1808cc9e406c00571d9c97829",
"timeout": 45000
}
],
@@ -25,7 +25,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/gemini_cli.py --multi \".chock/bin/index/gemini_cli-BeforeTool-c8f6602b.json\" --index-sha256 8acaa1f45d082758ffa5270a722263da96ccfd24038713be8e13a11220bd4d2d --stop-check",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/gemini_cli.py --multi \".chock/bin/index/gemini_cli-BeforeTool-c8f6602b.json\" --index-sha256 c016a88140574f28f7b73f92fbff992d34969db9af603a7147673d4cceb9133c --stop-check",
"timeout": 45000
}
]
diff --git a/.github/hooks/chock.json b/.github/hooks/chock.json
index d31e9828..6ded7e07 100644
--- a/.github/hooks/chock.json
+++ b/.github/hooks/chock.json
@@ -7,19 +7,19 @@
"matcher": "Edit|Write",
"timeout": 45,
"timeoutSec": 45,
- "bash": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json\" --index-sha256 1693abeab7a1aad4522981978246b0a8c72bc9a6dca83e067f145190d0cda85c",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json\" --index-sha256 1693abeab7a1aad4522981978246b0a8c72bc9a6dca83e067f145190d0cda85c",
- "powershell": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json\" --index-sha256 1693abeab7a1aad4522981978246b0a8c72bc9a6dca83e067f145190d0cda85c; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
- "windows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json\" --index-sha256 1693abeab7a1aad4522981978246b0a8c72bc9a6dca83e067f145190d0cda85c; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE"
+ "bash": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json\" --index-sha256 f18958baa97e9bb3f981bbad57d5475a0d341c6c767c8e25dcba5b0114be88f5",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json\" --index-sha256 f18958baa97e9bb3f981bbad57d5475a0d341c6c767c8e25dcba5b0114be88f5",
+ "powershell": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json\" --index-sha256 f18958baa97e9bb3f981bbad57d5475a0d341c6c767c8e25dcba5b0114be88f5; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
+ "windows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-38a36ef3.json\" --index-sha256 f18958baa97e9bb3f981bbad57d5475a0d341c6c767c8e25dcba5b0114be88f5; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE"
},
{
"type": "command",
"timeout": 45,
"timeoutSec": 45,
- "bash": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json\" --index-sha256 0d7dc4f8d23079d317442722244ae470a1494e9ea81a01267d57d18ac053fe38 --stop-check",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json\" --index-sha256 0d7dc4f8d23079d317442722244ae470a1494e9ea81a01267d57d18ac053fe38 --stop-check",
- "powershell": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json\" --index-sha256 0d7dc4f8d23079d317442722244ae470a1494e9ea81a01267d57d18ac053fe38 --stop-check; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
- "windows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json\" --index-sha256 0d7dc4f8d23079d317442722244ae470a1494e9ea81a01267d57d18ac053fe38 --stop-check; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE"
+ "bash": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json\" --index-sha256 8aee92efb0e0a8adba27114ac3a4be297bbce9df7111dac107bac79ad5b6ece4 --stop-check",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json\" --index-sha256 8aee92efb0e0a8adba27114ac3a4be297bbce9df7111dac107bac79ad5b6ece4 --stop-check",
+ "powershell": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json\" --index-sha256 8aee92efb0e0a8adba27114ac3a4be297bbce9df7111dac107bac79ad5b6ece4 --stop-check; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
+ "windows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-PreToolUse-2b90d191.json\" --index-sha256 8aee92efb0e0a8adba27114ac3a4be297bbce9df7111dac107bac79ad5b6ece4 --stop-check; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE"
}
],
"SessionStart": [
@@ -86,10 +86,10 @@
"matcher": "bash|powershell|pwsh|sh|shell",
"timeout": 45,
"timeoutSec": 45,
- "bash": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a",
- "powershell": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
- "windows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE"
+ "bash": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c",
+ "powershell": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE",
+ "windows": "& git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/vscode_copilot.py --multi \".chock/bin/index/vscode_copilot-preToolUse-3ed8896e.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c; if ($null -eq $LASTEXITCODE) { exit 2 }; exit $LASTEXITCODE"
}
]
}
diff --git a/.github/workflows/windows-paths.yml b/.github/workflows/windows-paths.yml
index 04315d31..40c1e1b6 100644
--- a/.github/workflows/windows-paths.yml
+++ b/.github/workflows/windows-paths.yml
@@ -43,6 +43,7 @@ jobs:
run: >-
pytest -q
tests/test_cursor_windows_write_gate.py
+ tests/test_doctor_live.py
tests/test_repo_stop_gap1d.py
tests/test_pack_hash_platform.py
tests/test_install_command.py
diff --git a/.grok/hooks/agentseam.json b/.grok/hooks/agentseam.json
index ac168698..384b85c9 100644
--- a/.grok/hooks/agentseam.json
+++ b/.grok/hooks/agentseam.json
@@ -5,7 +5,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/grok.py --multi \".chock/bin/index/grok-PreToolUse-185f9750.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a --stop-check",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/grok.py --multi \".chock/bin/index/grok-PreToolUse-185f9750.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c --stop-check",
"timeout": 45
}
]
diff --git a/.tabnine/agent/settings.json b/.tabnine/agent/settings.json
index a261cb93..93ae5116 100644
--- a/.tabnine/agent/settings.json
+++ b/.tabnine/agent/settings.json
@@ -5,7 +5,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/tabnine.py --multi \".chock/bin/index/tabnine-BeforeTool-c8f6602b.json\" --index-sha256 ebfc8620b51af8d70e3d11b25aeab3c58c3f13fedc2dc2c8d07541f2e0bf911a --stop-check",
+ "command": "git -c \"alias.chock-hook=!test -f .chock/bin/launch.sh || { echo chock: no .chock/bin/launch.sh here, run chock sync --repo . >&2; exit 2; }; sh .chock/bin/launch.sh\" chock-hook .chock/bin/tabnine.py --multi \".chock/bin/index/tabnine-BeforeTool-c8f6602b.json\" --index-sha256 5b90d9a49d0efb9369d980cbfb916a6fae927a36c977ae02181a0460f409767c --stop-check",
"name": "agentseam",
"timeout": 45000
}
diff --git a/README.md b/README.md
index f99eca38..ebb59ba5 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@ pipx install chock==1.1.0
### Two ways to adopt it
-1. **In your repository, for teams.** Run `chock init .`, then `chock add --ref --verify-sha --skip-compile` for each policy, then `chock sync --repo . --ci`. Commit the result. A fresh clone arms itself from what is committed; a person runs `chock sync` to change it. The commit gates are enforced at commit and in CI.
+1. **In your repository, for teams.** Run `chock init .`, then `chock add --skip-compile` for each policy, then `chock sync --repo . --ci`. Commit the result. A fresh clone arms itself from what is committed; a person runs `chock sync` to change it. The commit gates are enforced at commit and in CI.
2. **In your coding agent, as one plugin.** Pick policies in the [chock.sh builder](https://chock.sh/coding/builder/) and run `chock install --selection --apply`. It builds one plugin for Claude Code, GitHub Copilot, Codex, Cursor, Devin, goose, Grok or Antigravity, tested live, and, untested by chock, for OpenHands, Kimi Code or Factory Droid. Best-effort, and it fails open. A selection can add [your own policies](docs/custom-policies.md): install shows their code and asks first. No chock? Add a per-policy marketplace (`chock-*-plugins`; needs Python 3.11+, git, a bash: Git for Windows has one), never both.
## Application security for the code your agents write
@@ -50,6 +50,8 @@ Tiers: see [Guardrails, not guarantees](#guardrails-not-guarantees).
## How it works
+
+
A policy is one folder, and the manifest is the rule. Here is `scan-secrets` in this repo:
```
@@ -66,9 +68,7 @@ fresh_clone: first session arms hooks from what is committed; a person runs(choc
scope: all_work_in_repo; repo_content: data_not_command
```
-The CI gate emits SARIF (`chock check --event ci --format sarif`), and a baseline step fails a pull request that disables or narrows a policy (`chock check --only baseline`). `chock mcp` serves read-only guidance to the agent; `chock sync` registers it per client, opt-in. Full write-up: [Architecture](docs/architecture.md).
-
-To write your own, run `chock new policy ` (manifest, gate and evals), `chock check` to validate, and `chock compile ` to emit every surface. See [Authoring policies](docs/authoring-policies.md).
+To write your own, run `chock new policy ` (manifest, gate and evals), `chock check` to validate, and `chock compile ` to emit every surface. See [Authoring policies](docs/authoring-policies.md). Full write-up: [Architecture](docs/architecture.md).
### A refusal names the fix
@@ -83,7 +83,7 @@ pip install chock==1.1.0
git init -q demo && cd demo
chock init . # wiring only, no policies
-chock add scan-secrets --ref 1e60d211c1bb767152c6ab0167932da06ab3a10f --verify-sha c7cf363c6eb8a8ed47287beef9c06fe76dfd2d9c0ccc203fe74e32fba0e92a94 --skip-compile
+chock add scan-secrets --skip-compile
chock sync --repo . --ci # compile, install hooks, add the CI gate
```
@@ -104,7 +104,11 @@ git commit -m "read key from env" # passes
alt="Terminal recording of the Quick start above, typed in real time, ending with the refused commit and the clean one.">
-`--ref` pins a catalog commit, `--verify-sha` refuses a policy whose hash differs, and `chock add --ref` refuses a commit that was never published. The allowlist pragma on the key line is for documented test fixtures only. It is honoured at commit, push and in CI, and deliberately not at tool-use, where the scanned text is a live tool argument.
+With no `--ref`, `chock add` pins the catalog tag `v`, prints the commit and sha256, and fails if the tag is missing. `--ref` and `--verify-sha` pin by hand; `--ref` refuses a commit never published. The allowlist pragma on the key line is for documented test fixtures only. It is honoured at commit, push and in CI, and deliberately not at tool-use, where the scanned text is a live tool argument.
+
+### Check it, or try it without blocking
+
+`chock doctor` and `--live` check your hooks ([Doctor](docs/doctor.md)). `rollout: observe` in `.chock/config.yaml` logs refusals instead of blocking; `chock stop` still holds.
### Shift left, with no model and no tokens
@@ -112,9 +116,7 @@ git commit -m "read key from env" # passes
- With Chock: the check runs as the agent writes, the refusal names the fix, and the agent corrects it in the same turn.
- A check costs no tokens. A passing check adds nothing to the agent's context; a refusal adds one short reason.
- Chock adds no new place your code goes: checks run where the agent writes, on the laptop, in the dev container or in the cloud agent's environment. The agent still sends context to its own model provider. Installing fetches policies once; enforcement makes no network calls.
-- Chock does not replace code review, your SAST suite or a penetration test. It refuses known classes while the agent writes, so they are fixed before review.
-
-To estimate what a late finding costs you, fill in your own numbers: findings per release x share Chock covers x minutes to triage and fix x hourly rate, plus the days a security loop adds.
+- Chock does not replace code review, your SAST suite or a penetration test.
| | Agent defaults | With Chock |
| :--- | :--- | :--- |
@@ -127,14 +129,12 @@ To estimate what a late finding costs you, fill in your own numbers: findings pe
### Supported agents
-Every agent in this table gets the same floor: a git hook, a CI gate and an ambient `AGENTS.md`
-rule, which is why those three columns aren't repeated below. What varies is whether the agent
-also exposes a native hook chock can wire directly into its own tool-call loop, and where the
+Every agent in this table gets the same floor: a git hook, a CI gate and an ambient `AGENTS.md` rule, which is why those three columns aren't repeated below. What varies is whether the agent also exposes a native hook chock can wire directly into its own tool-call loop, and where the
file that wiring lives. A row here is support, not installation — coverage is only credited on
-a given repo once `chock sync` has actually written the file, which is why the CLI's own
+a given repo once `chock sync` has written the file, which is why the CLI's own
`chock status` always beats this table for what's true *here*. Four of the nine surfaces are
absent from this page entirely because they credit no agent today — `managed-setting` is
-compiled but not installed, `gateway` is modelled but not yet emitted, `mcp-gateway` credits
+not installed by chock, `gateway` is modelled but not yet emitted, `mcp-gateway` credits
nothing until its per-client witness ships, and `stop` installs and refuses on eight vendors but is
a deliberate backstop for what a pre-tool hook cannot see, so it is worth no grade of its own.
Full nine-surface matrix and per-agent caveats:
@@ -163,7 +163,7 @@ Full nine-surface matrix and per-agent caveats:
| **Kimi Code** | git hook + CI gate only — home-anchored config, outside chock's repo-scoped install | `~/.kimi-code/config.toml` |
| **Replit** | git hook + CI gate only — no native hook API yet | — |
-Chock tested its repo hooks live in Copilot CLI and VS Code agent mode only; other native hooks follow agentseam's record, untested.
+Repo hooks refused commands live in Copilot CLI and VS Code agent mode and, on Windows, in Claude Code, Cursor and Codex CLI (Codex after the project's hooks were trusted); others follow agentseam's record, untested.
## What it stops
@@ -287,7 +287,7 @@ The 15 public repositories:
-A policy manifest for the guardrail your stack needs is the contribution we want most; send it to the [catalog](https://github.com/open-coder-ai/chock-catalog). An evidence report on what your agent does, or a `policy wanted` entry in the [threat ledger](https://github.com/open-coder-ai/chock-threat-intel/blob/main/reference/agentic-threat-ledger.md), also counts; see [docs/ecosystem.md](docs/ecosystem.md). Run `pytest -q && ruff check . && ruff format --check . && chock check` before a pull request; [`good first issue`](https://github.com/open-coder-ai/chock/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) is where to start. Questions: [Discussions](https://github.com/open-coder-ai/chock/discussions).
+A policy manifest for the guardrail your stack needs is the contribution we want most; send it to the [catalog](https://github.com/open-coder-ai/chock-catalog). An evidence report on what your agent does, or a `policy wanted` entry in the [threat ledger](https://github.com/open-coder-ai/chock-threat-intel/blob/main/reference/agentic-threat-ledger.md), counts; see [docs/ecosystem.md](docs/ecosystem.md). Run `pytest -q && ruff check . && ruff format --check . && chock check` before a pull request; [`good first issue`](https://github.com/open-coder-ai/chock/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) is where to start. Questions: [Discussions](https://github.com/open-coder-ai/chock/discussions).
Chock policies are committed content, so your rules travel with every clone and fork, and the CI gate (`chock sync --ci`) depends on nothing the contributor does. [The full case.](docs/why.md)
diff --git a/changelog.d/add-default-pin.md b/changelog.d/add-default-pin.md
new file mode 100644
index 00000000..764c56fe
--- /dev/null
+++ b/changelog.d/add-default-pin.md
@@ -0,0 +1,5 @@
+- `chock add ` with no `--ref` from the default catalog now fetches the catalog release tag
+ `v`, prints the tag and the commit it resolved to, and records both in
+ `chock.lock`. If that tag does not exist it fails and names `--ref <40-hex commit>` or
+ `--ref main`; it never falls back to the moving branch. `--ref`, and `--from` another catalog,
+ are unchanged.
diff --git a/changelog.d/e1-rename-baseline.md b/changelog.d/e1-rename-baseline.md
new file mode 100644
index 00000000..37a67bb0
--- /dev/null
+++ b/changelog.d/e1-rename-baseline.md
@@ -0,0 +1,4 @@
+- A gate judges a file that git reports as renamed (`-M`) against its old path's content, for a script gate and a
+ `content_regex` gate, at commit, at the turn's end and on the CI range. A pure `git mv` of a file holding an old
+ finding is no longer refused as new work; a new finding added in the move is, and a copy (old path kept) is judged
+ as new, as before.
diff --git a/changelog.d/e1c-rename-name.md b/changelog.d/e1c-rename-name.md
new file mode 100644
index 00000000..c12ce33a
--- /dev/null
+++ b/changelog.d/e1c-rename-name.md
@@ -0,0 +1,3 @@
+- A script gate's baseline for a file git reports as renamed is its old content at its old path. A rename into a
+ refused name (a finding keyed by the new name) is new work again and is refused, while a pure rename of a file
+ holding only old content findings stays allowed.
diff --git a/changelog.d/e2-verdict-from-new.md b/changelog.d/e2-verdict-from-new.md
new file mode 100644
index 00000000..ec007197
--- /dev/null
+++ b/changelog.d/e2-verdict-from-new.md
@@ -0,0 +1,4 @@
+- A script gate's finding may carry a `tier` (`block`, `ask` or `warn`). When every finding the change adds carries
+ one, the verdict is the highest tier among them, so an old block-tier finding in a touched file no longer turns a
+ new ask-tier finding into a block. A script that reports no tier, or tiers only some findings, keeps its exit code
+ as the verdict, as before. See `spec/gate-dsl.md`.
diff --git a/changelog.d/ir-f71-lock-engine-constraint.md b/changelog.d/ir-f71-lock-engine-constraint.md
new file mode 100644
index 00000000..ca70d97d
--- /dev/null
+++ b/changelog.d/ir-f71-lock-engine-constraint.md
@@ -0,0 +1,5 @@
+- `chock.lock`'s `engine` field is now true and read (IR-F71): `sync` writes `>=.,<`
+ derived from the running engine (`>=1.1,<2` at 1.1.x, was the stale `>=0.1,<0.2`), and `chock check --only verify`
+ fails with one line naming the running engine, the lock's constraint and the fix (`pip install` a matching chock,
+ or `chock sync --repo .` with the newer engine) when the engine is outside it. A lock that still says `>=0.1,<0.2`
+ passes with a one-line note to run `chock sync`; a missing or unparseable constraint fails.
diff --git a/changelog.d/ir-f75-f76-quiet-legible-output.md b/changelog.d/ir-f75-f76-quiet-legible-output.md
new file mode 100644
index 00000000..479d6609
--- /dev/null
+++ b/changelog.d/ir-f75-f76-quiet-legible-output.md
@@ -0,0 +1,5 @@
+- Each defaulted manifest field is warned about once per command, always with the artifact's path:
+ `chock check` no longer repeats a skill's eleven `manifest_default` warnings, two copies of them with
+ no path (IR-F75). The registry scan's copy now goes to stderr with the others.
+- On a console stream that is not UTF (a Windows code page such as cp1252), chock prints ASCII for its
+ own symbols: the eval table's truncation reads `...`, not U+2026 shown as another letter (IR-F76).
diff --git a/changelog.d/rd7-readme-picture.md b/changelog.d/rd7-readme-picture.md
new file mode 100644
index 00000000..289da454
--- /dev/null
+++ b/changelog.d/rd7-readme-picture.md
@@ -0,0 +1,8 @@
+- README: "How it works" opens with a picture of a coding agent's harness: component cards in layers (input, core,
+ execution) with short arrows between neighbours, beside the repository and pipeline. The hooks of each component
+ are badges on its card: filled where Chock runs today, hollow where a policy of your own can run; the model has
+ none. No prose was added: the README stays at its budgets. The figure is `docs/assets/readme/v2/where-chock-sits.png`,
+ rendered by `render.mjs` and `where-chock-sits.mjs` from `where-chock-sits.json`. `docs/architecture.md` shows it,
+ lists every hook, and shows the same points in session order (`v2/session-path.png`). Tests assert the badges equal
+ agentseam's events plus the other points, the filled set equals what the engine handles, and that no two shapes of
+ either layout are too close.
diff --git a/changelog.d/rel-d1-docs-evidence.md b/changelog.d/rel-d1-docs-evidence.md
new file mode 100644
index 00000000..2c7ebd81
--- /dev/null
+++ b/changelog.d/rel-d1-docs-evidence.md
@@ -0,0 +1,19 @@
+- README: the quick start's `chock add` line no longer carries `--ref` and `--verify-sha`; the text under
+ it says what the command pins by default (the catalog tag `v`) and that `--ref` and
+ `--verify-sha` still pin by hand. `docs/quickstart.sh` and the panel sources in
+ `docs/assets/readme/render.mjs` follow.
+- README: a short section after the quick start names `chock doctor`, `chock doctor --live` and the
+ `rollout:` line in `.chock/config.yaml`.
+- Witness ledger: one row, Claude Code v2.1.317 on Windows, 2026-11-11: `PreToolUse` refused
+ `git commit --no-verify` on the PowerShell tool and no commit was made (chock `295b38c`). The README
+ sentence on where repo hooks were tested now names it.
+- Witness ledger: a second row, Cursor 3.30.14 on Windows, 2026-11-14: the repo's `beforeShellExecution` hook refused
+ `git commit --no-verify` and no commit was made (chock `cc127e4`). Surface `agent-hooks`, the name the ledger's
+ readers (`sync_notes`, `derive.py`) key on for repo hooks.
+- README: the new section is kept to a short paragraph; the FAQ keeps its six entries. The "estimate what a late
+ finding costs" paragraph and a sentence repeating the comparison link were removed to stay within the README
+ budgets (1,600 words, 300 lines).
+- Witness ledger: a third row, Codex CLI 0.169.0 on Windows, 2026-11-14: the repo's `PreToolUse` hook refused
+ `git commit --no-verify` and no commit was made, after the project's hooks were trusted (chock `cc127e4`).
+ `derive.py` now groups the ledger's clients by the platform each records, without versions, and carries the trust
+ condition.
diff --git a/changelog.d/w1d-doctor-live.md b/changelog.d/w1d-doctor-live.md
new file mode 100644
index 00000000..ffd38f62
--- /dev/null
+++ b/changelog.d/w1d-doctor-live.md
@@ -0,0 +1,13 @@
+- `chock doctor --live` (preview): for each sync-route target `doctor` lists, runs chock's own
+ pre-tool hook commands from the client's config file, as written and from the repo, in the
+ client's shell, on that client's own payload. Only an entry byte-equal to what this engine's
+ installer renders for that target is run, and only when the launcher and vendored runtime are
+ this engine's; any other hook command is counted in an INFO row and never run. The installed
+ policies' guard code runs, as it does in `chock check` evals. It sends the first refusing eval
+ case of the first policy the hook runs (it must be refused, by that policy) and
+ `echo chock-doctor-live` (it must be allowed): two rows, `live: refuses the canary` and
+ `live: allows a harmless command`, each with the fix doctor already prints. Plugin-route targets
+ are skipped. It runs no client, sends nothing anywhere, logs nothing (the probe runs at log level
+ off and in its own session, whose state file it removes), and does not prove the client calls
+ the hook: that is the heartbeat row. The per-vendor payloads and wire denies the tests used are
+ now package data (`chock.doctor.payloads`), one source for the engine and the tests.
diff --git a/changelog.d/w2a1-check-floor.md b/changelog.d/w2a1-check-floor.md
new file mode 100644
index 00000000..a047059d
--- /dev/null
+++ b/changelog.d/w2a1-check-floor.md
@@ -0,0 +1,47 @@
+- `chock check --floor --base [ [--head ]] [--head-ref ] [--format sarif --output ]`
+ (preview): judges what a pull request will land. The base must be an ancestor of the head (pass GitHub's
+ `refs/pull//merge` or the merge queue's head; anything else is undecided). Everything comes from the tree
+ diff `base..head` (no renames, no external diff or textconv) and the commits in it; no merge-base is computed.
+ Exit 0 clean, 1 refused, 2 undecided.
+- Control plane: a change (add, edit, delete, mode) to any path in `src/chock/data/control_plane.json` is
+ reported as `floor/control-plane-changed` with every path, first. The list: `.chock/**`, `chock.lock`, the whole
+ folder of every agent chock or agentseam writes into (`.agents/**`, `.claude/**`, `.codex/**`, `.cursor/**`,
+ `.gemini/**`, `.windsurf/**`, `.github/hooks/**` and the rest, plugin folders such as `.claude-plugin/**`),
+ `.mcp.json`, `.vscode/settings.json`, `.vscode/mcp.json`, `.env` (at any depth), `.devcontainer/**`,
+ `.devcontainer.json`, `.github/workflows/**`, `.github/actions/**`, `CODEOWNERS`; agent folders match at any
+ depth (`**/.claude/**`); matched case-blind. A symlink or gitlink at a parent folder of a pattern
+ (`.gemini -> cfg`) matches. Every symlink at, inside or above the control plane must resolve, link by link
+ from the trees at base and head, to a control-plane path or to nothing; otherwise (and for a loop, an absolute
+ or out-of-repository target, or one through a submodule) the run is undecided (exit 2), naming the link and the
+ fix. A base whose `.chock` is a link or a submodule is undecided, never first adoption. A control-plane path a
+ commit in the range changed is named even when the tree diff leaves it as at the base. Every git call reads
+ attributes from the base (`GIT_ATTR_SOURCE`; git 2.42 or newer, else undecided), so `.gitattributes` is off
+ the list. Root instruction files (`AGENTS.md`, `CLAUDE.md`) are
+ not on it. These files define the guardrails; the floor does not judge whether a change to them is safe. A
+ person decides. The base's `.chock/config.yaml` sets `floor.control_plane`: `refuse` (default, exit 1: every
+ guardrail change, including a policy upgrade, a `chock sync` regeneration or a workflow edit, needs a
+ privileged merge) or `listed` (exit 0, paths still listed and in the SARIF; the adopter relies on code-owner
+ review, and content inside listed paths is not judged). `floor.control_plane_paths: {add, remove}` edits the
+ list; a `remove` entry that names no default pattern is undecided (exit 2); an `add` entry `name/` means
+ `name/**`, a bare folder name is undecided, and an entry matching nothing at base or head is marked so. Every run prints the mode, the
+ number of patterns and the base's additions and removals. The head's config is never read.
+- The list is what chock knows about, not a proof of completeness. If your workflow installs chock from a file in
+ the repository (`requirements*.txt`, `pyproject.toml`, a lockfile, a local action), add that file to the list.
+ Renaming or moving a test file reads as a deletion and is refused by test-integrity.
+- `--repo` may name a folder below the top level; every diff is computed from the top level. A file git cannot
+ read at base or head is undecided (exit 2), never handed to a gate as empty text.
+- Everything else is judged by the base's compiled ci gates and rollout, run by this engine; no head file executes.
+ `ask` refuses; a gate that crashes, times out or cannot be read is undecided whatever the rollout. A waiver counts
+ only on a line present and unchanged in both base and head. Script gates receive deleted paths under `deleted`
+ and an environment of `PATH`, `HOME` (and `SYSTEMROOT`) only (script payload contract version 2,
+ `spec/gate-dsl.md`).
+- A per-commit pass runs the base's content gates (both surfaces) over every blob a commit in `base..head` adds or
+ changes outside the control plane (renames read as a delete and an add), read as latin-1, as utf-8 when valid, and, for a blob with a NUL byte, as
+ utf-16 in both byte orders and alignments, lines split on `\n` only. A range past the commit limit or a blob over
+ 64 MiB is undecided, naming the commit and path. Not seen: other encodings, compressed or encoded content, commit
+ messages, file names.
+- `--sarif` writes a log on every run; an undecided run's says `executionSuccessful: false`. Not covered: a
+ Windows short name (`CLAUDE~1/`), `*.code-workspace`, submodule content (docs/floor.md).
+- It holds only as a required status check the pull request cannot redefine; that is the adopter's setting, which
+ chock does not verify. It judges committed content only.
+- `chock history`'s `load_rules` takes the compiled surfaces to read; its own defaults are unchanged.
diff --git a/changelog.d/w2a1-gate-patterns-exits.md b/changelog.d/w2a1-gate-patterns-exits.md
new file mode 100644
index 00000000..92409ffe
--- /dev/null
+++ b/changelog.d/w2a1-gate-patterns-exits.md
@@ -0,0 +1,8 @@
+- `chock check --floor`: a path listed only because an any-depth pattern matched it below the top level
+ (`node_modules/x/.claude/...`) is followed by the pattern that matched it (`matched **/.claude/**`). A base
+ `remove:` entry that is the old top-level form of a default (`.claude/**`) names the pattern to write
+ (`**/.claude/**`). A base `.chock/config.yaml` that is a folder, a symbolic link, a submodule or not UTF-8 is
+ undecided (exit 2). When base and head are the same commit the run says that nothing changed. The `--floor`
+ help says a link may also open nothing. Release gate G1 (GT-2): regression tests for patterns, config, SARIF,
+ abnormal paths and ordinary pull requests, and a map from every behaviour sentence in `docs/floor.md` and the
+ `--floor` help to the test that proves it.
diff --git a/changelog.d/w2b1-managed-emit-claude.md b/changelog.d/w2b1-managed-emit-claude.md
new file mode 100644
index 00000000..eb0aaca5
--- /dev/null
+++ b/changelog.d/w2b1-managed-emit-claude.md
@@ -0,0 +1,30 @@
+- `chock emit --managed claude_code --python --on-failure block|allow --out `
+ (preview) writes, under `/claude_code/` and nowhere else, a Claude Code managed-settings
+ drop-in (`managed-settings.d/50-chock.json`), the hook bundle it runs (`bundle//scripts/`:
+ runtime, guard or gate), `deploy.json` (where an admin places each part, what every machine needs,
+ what the `--on-failure` choice does, what it does not promise, the undo step) and `labels.json`.
+ Every hook is exec form: it starts the `--python` interpreter directly, so no shell, PATH lookup
+ or git config picks it. `--on-failure` has no default: `block` sets `onFailure: "block"` on the
+ `PreToolUse` hooks and refuses a matched call when the interpreter or a bundle file is missing;
+ `allow` sets neither and lets the call through with a note. The repository stop's every-tool
+ entry is not emitted. The command refuses an `--out` that is a filesystem root or resolves into
+ a system folder (any spelling, case-insensitive on macOS and Windows), names a file, or already
+ holds `claude_code/`; it elevates nothing and deploys nothing. `--lock` adds
+ `allowManagedHooksOnly` (off by default; `deploy.json` lists every effect the vendor documents);
+ `allowManagedPermissionRulesOnly` is never emitted. Every label is `best-effort (vendor-docs)`,
+ unwitnessed, until a `managed` witness row exists. A local administrator can still edit or remove
+ the file. Native `permissions.deny` rules are not emitted yet.
+- `chock compile` no longer writes `managed-setting/managed-settings.json`: that file used a shape
+ Claude Code does not read.
+- Every child interpreter a hook runtime starts (a Python guard, the gate runner, a script gate) now
+ runs isolated (`-I`), with its own folder put on the import path explicitly and every `PYTHON*`
+ variable removed from its environment, on every route. The hook launcher (`launch.sh`) starts a
+ runtime script with `-E -s`, so no `PYTHON*` variable or user site reaches the outer interpreter
+ either (its `-m chock` form keeps the environment: it needs the installed package). A hostile `PYTHONPATH`, `PYTHONHOME`,
+ `PYTHONPLATLIBDIR` or `PYTHONSAFEPATH` no longer lets a refused command through or turns a refusal
+ into a prompt.
+- `chock emit --managed claude_code`: the bootstrap now checks every bundled file, so a missing guard
+ or `chock_shellparse` follows `--on-failure` like any other missing file. `deploy.json` gains
+ `stop_files` (the repository's `.chock/stop.json` and the `~/.chock/stops/` files, each with its
+ effect), `client_versions` (2.1.295 for `onFailure`, 2.1.314 for Monitor commands, each quoted with
+ the date read) and `not_covered`.
diff --git a/chock.lock b/chock.lock
index 22c0800b..5bfb7bea 100644
--- a/chock.lock
+++ b/chock.lock
@@ -1,6 +1,6 @@
{
"lockfile_version": "2",
- "engine": ">=0.1,<0.2",
+ "engine": ">=1.1,<2",
"packs": [
{
"id": "agent-discipline",
@@ -8,7 +8,7 @@
"managed": false,
"sha256": "e41a849bc2b80f5c3c10fa4ea9883795a3e2ef9a626322c97ce7db41bab71bda",
"source": "local",
- "artifacts_sha256": "aa8906f9de0aa4a597077410094b8f3cb5cef5e0e50e438f45a1c689160cf3db"
+ "artifacts_sha256": "17ed5f45decf46868b440f82d698b0c11b8f3e8c8616d20ccb16907d3c692f8b"
},
{
"id": "block-destructive-commands",
@@ -16,7 +16,7 @@
"managed": false,
"sha256": "a5c10785be81bb4a391f4e629359454b2e6212772b8475a2ce2f08b03214bab6",
"source": "local",
- "artifacts_sha256": "606e3ef7e43d9050b317103ae0a0652e2b8548ee8fc2d18aa390539077f8210a"
+ "artifacts_sha256": "9b988a9717063a7ae7698f79d01fbb53b0177fddbcf7194e0db36d573860f1d4"
},
{
"id": "block-invisible-unicode",
@@ -24,7 +24,7 @@
"managed": false,
"sha256": "e34c93313ca3a6352c1d13715c60e8191ad6cdf04542d9f9d6a78cb210e34594",
"source": "local",
- "artifacts_sha256": "33845353b14a3413b48dce1deeabecc9451858702adc4c12f3ad68dfe560be46"
+ "artifacts_sha256": "0c8d0bb624227d674c309b342e8240b2b6be9cba4204d566cc2e8ed5291f3001"
},
{
"id": "block-no-verify",
@@ -32,7 +32,7 @@
"managed": false,
"sha256": "4e4fe3bd5a2b1947851bb390f56701c8129619b5a74a745806684f95d2e2105a",
"source": "local",
- "artifacts_sha256": "8d9fb089051fba248a366e851b77448117bdf54026fb3fdab1abe645bb479861"
+ "artifacts_sha256": "888852399360d4eab3fcc2191ca0406c8e94ff59f23dfa83adf3fc39bc4cb537"
},
{
"id": "block-wildcard-agent-permissions",
@@ -40,7 +40,7 @@
"managed": false,
"sha256": "5a6018554c19e90993f20e5d8a02fd1288c3ebb8431ddcee2967f009f6fab129",
"source": "local",
- "artifacts_sha256": "395d89ad34af4bdb0ed4f0e7a0dce55ebf8ee3d9eada8e90196ffcb190bf1767"
+ "artifacts_sha256": "1731c28f2dd34b569111e3ff0448c218803116ef895927542709fb297c7f4518"
},
{
"id": "code-safety",
@@ -48,7 +48,7 @@
"managed": false,
"sha256": "07a34b6e60452d78f8df0f853d17097e931f5e2e5e4b3fc492277bb99fd651f7",
"source": "local",
- "artifacts_sha256": "2a3465baf6bc0da2f3ae44e01cf1ddcdd400135438c14836368c6bdc7a29a405"
+ "artifacts_sha256": "c4028cdd8092fb374b8efe271b785d2228718264f4e04fc755e966af472248a6"
},
{
"id": "context-hygiene",
@@ -56,7 +56,7 @@
"managed": false,
"sha256": "7d77f634a5b13e199a4e6744d3fc2dadffce3891c7bc6a6a538639e37ae1505d",
"source": "local",
- "artifacts_sha256": "1cbaddfc2bd8e401ac218252c755d5ef9be607f0b88359f2af59c5323992b285"
+ "artifacts_sha256": "5f74ee647666735c5b32974c0d59ab485e2c47c570d3c98d1854d1e1dcb95e68"
},
{
"id": "git-safety",
@@ -64,7 +64,7 @@
"managed": false,
"sha256": "d57e89caab2d9c0608beb4c6acad049c1dc76150fa2caae17f43daa2d77264c4",
"source": "local",
- "artifacts_sha256": "b9db0e16e1009cb85d051c939ff47093497f8540d648adc33b90b6d1a39f08d8"
+ "artifacts_sha256": "c9f84f4d2faad9345307bcae87ef0ed6c2f15173367f1564da144a55a49a4be2"
},
{
"id": "injection-defense",
@@ -72,7 +72,7 @@
"managed": false,
"sha256": "722c6235b5366a0916625a2acb4f7383b07b04f2691a99b3d5cb8203d922fa45",
"source": "local",
- "artifacts_sha256": "a6f82e74b77c04a051dbc1058b1e1124eb8b78d12427af3b947b6d42686331be"
+ "artifacts_sha256": "e272fd293c18788f453b4cd4a6f774483b59b49b7a362a59b7b3d575d16bb881"
},
{
"id": "memory-discipline",
@@ -80,7 +80,7 @@
"managed": false,
"sha256": "e795ef722ee5eb0fdc9af872666d24b90a7a020dff50e56bd8f418a9a868a11a",
"source": "local",
- "artifacts_sha256": "906287d93337b6080f68621350512cbf8a73c381657c08faeeddab8a2ec45a6b"
+ "artifacts_sha256": "30ff9ba99409ecc720a8087341962b9c934070d56c21e34260af180c87643ae0"
},
{
"id": "minimal-content",
@@ -88,7 +88,7 @@
"managed": false,
"sha256": "00bb15c96c603ff92fdb7c7fd9fcc610c36f05fdcd5147763931acbd96818853",
"source": "local",
- "artifacts_sha256": "a6d131a5036887ab769dbdcbe01c761f5825b656a6cae30607f900639cb29ec7"
+ "artifacts_sha256": "bf5246fd47343838f0e6eac62a6a67928641e472b5a0689db101ddd4b1a14cb4"
},
{
"id": "pin-github-actions",
@@ -96,7 +96,7 @@
"managed": false,
"sha256": "a3afaef1791bf3b84cfd48b91c8dd5553a6a2fbd99d0e9df6423cb100a4e68d7",
"source": "local",
- "artifacts_sha256": "99d58c2e84918370cac3b75a6fa2cc8d530c63dfa8189c5a5e4835b06859dfdd"
+ "artifacts_sha256": "df233c2dbcbe2a93c2cdbbcc610c568b5b0c1d32f380b0f7d70d9f2200e19234"
},
{
"id": "pre-generated-scripts",
@@ -104,7 +104,7 @@
"managed": false,
"sha256": "17227f0f6e007ddd445f0ace6457b5d3ffc66ed23f2d52b75af9f9eb669191c5",
"source": "local",
- "artifacts_sha256": "ef6d558f78d7f86bc66b7c755b3eac5324a44db9e240ef29dc24a7d6e27f5380"
+ "artifacts_sha256": "f43a190e1338a7d0eeb219b9625e51f7292e1df84e81933751080901fb30756d"
},
{
"id": "protect-agent-config",
@@ -112,7 +112,7 @@
"managed": false,
"sha256": "dc20b58f82ae4c5c77759d32d15a51a431c76039c3cc34b1d4a892cb2f264aef",
"source": "local",
- "artifacts_sha256": "aa0f584a3da1309770c9fbda7d082970e7d279d298f06ca625520a80d85e278f"
+ "artifacts_sha256": "a7525f05e9b0f287a0eea727e3d2e041228832fdd242553c0df1a039164a7a9b"
},
{
"id": "protect-commit-privacy",
@@ -120,7 +120,7 @@
"managed": false,
"sha256": "07d12989cb3a4a20a2d48579f2b51c5c5d6e14e4367412250d2d3fe682759fdd",
"source": "local",
- "artifacts_sha256": "0aab76e19d6744ed014507bd15d6ed15e2db88d1777cd5bfe2295d557c7bf39b"
+ "artifacts_sha256": "8bf045a0a7d83fafc4f64576cab3aedc418b9dd0ebef196452db1836747846ac"
},
{
"id": "protect-main-branch",
@@ -128,7 +128,7 @@
"managed": false,
"sha256": "d1709293d7ee4ef502457e2e65eb65516daebd6ba5f7172db744bfdd8db63002",
"source": "local",
- "artifacts_sha256": "dd31407d52e400f6f74e515cdacb8b3e188b97133db255f88bf73791bbee2eb4"
+ "artifacts_sha256": "a7d7c8dc2439782632437eee5c407ec95fa5a8b5ac78385a699183d3510c58e2"
},
{
"id": "require-review-evidence",
@@ -136,7 +136,7 @@
"managed": false,
"sha256": "67b76ca30e7e9add2d284b62da210344a828e6de3d28e5f410ff81c5842beaa4",
"source": "local",
- "artifacts_sha256": "b16de533c1019379d5f5c7420bd0934f1430e6716f09faa8677763e20bab5a02"
+ "artifacts_sha256": "d75b06e96f0e001e72a565a1450527b72fb33ff00bbe520cc4244d8aa7d983d6"
},
{
"id": "scan-secrets",
@@ -144,7 +144,7 @@
"managed": false,
"sha256": "d04914f3b1ff3d4a2983ec8bc9fd3465556d5744ec41d03faca61ddd8c4917f0",
"source": "local",
- "artifacts_sha256": "5c9540a8b0ca8ca8bb88dde396adb71fe725eace2e932dc90c18d8c69d6b67f5"
+ "artifacts_sha256": "0c421836338483c280671ad720e58162e737f4ba822bc3c60f49c91ee6aa391a"
},
{
"id": "test-integrity",
@@ -152,7 +152,7 @@
"managed": false,
"sha256": "965b849688591738ddb1b6a7f5d20deaa0483e33c6daa117d37a592126512fca",
"source": "local",
- "artifacts_sha256": "b013983cfca823013ac954817d053c7ce8b7accdaa6b0484a2f7105a655550e8"
+ "artifacts_sha256": "f8516f28439131aa8b5c52c4c08b563425ac1a4336c8dacab17bf2ac8ba716d5"
},
{
"id": "token-efficiency",
@@ -160,7 +160,7 @@
"managed": false,
"sha256": "771cbb776e8b86602d330b878073046bd7becbc44827e47f745bb5970973ceb4",
"source": "local",
- "artifacts_sha256": "c14412edb8abd9e633198f2fc08bc09af74e682939e1a076da1fea32c3fab97a"
+ "artifacts_sha256": "01171e6cefe124c56339d1ec84788c4d82e1e4ef4049e2192ef978cda49fd7df"
},
{
"id": "verify-dependency-exists",
@@ -175,7 +175,7 @@
"managed": false,
"sha256": "8cf8ec272df2d224b264ca662e7ca6798130369a4d70a14d454566654ada9917",
"source": "local",
- "artifacts_sha256": "3c4f69d24ba8acbe41c9c7a1a334dc3fb9d722d39c85f601e6f214a92917210c"
+ "artifacts_sha256": "1c272c78ac73c7014a44eca6a2c5b5df8ef4a84f886d995c51d01c7d363dfe28"
},
{
"id": "yagni",
@@ -183,7 +183,7 @@
"managed": false,
"sha256": "58954cf1e9d3634f67b759d65fc16bb2f97782b1815a71ea558b4dfd47b66628",
"source": "local",
- "artifacts_sha256": "12038a1b15c829fc3326b2a9667e0ea7276278be51620a58b2efdb4b60a019b5"
+ "artifacts_sha256": "d911cbf1dd92b800b121719f306d2cf1964259f71bb35aa2e078e85b76def2a2"
}
]
}
diff --git a/docs/README.md b/docs/README.md
index 2e186dfc..00a100f6 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -24,6 +24,7 @@ Everything you need to understand, use, and extend Chock. New here? Start with
| [Agentic-Risk Coverage](agentic-risk-coverage.md) | Problem-first index: what Chock stops, at which honest tier — and what it doesn't |
| [Agent Plugins](agent-plugins.md) | Package policies for the open standard — and what that does not buy you |
| [Validation](validation.md) | Understand what `chock check` checks |
+| [CI Floor](floor.md) | What `chock check --floor` (preview) claims, the conditions it holds under, and what it does not cover |
| [Registry & Lockfile](registry-and-lockfile.md) | Reproducible, hash-pinned distribution |
| [Compatibility](compatibility.md) | What may change between versions, and what pinning guarantees |
| [Reviewer Evidence](reviewer-evidence.md) | Recording what a review rests on, so the next reader can re-derive it |
diff --git a/docs/architecture.md b/docs/architecture.md
index d477262f..febfe52c 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -4,6 +4,36 @@ Chock has one job: let you **author a governance policy once** and **enforce it
coding agent** that touches your repo — your team's or a contributor's — with proof of
exactly where each guarantee holds.
+
+
+
+
+Each card is a component of a coding agent's harness; the badges on a card are the hooks on that component. A filled badge is a point Chock runs at today; a hollow one is a hook a policy of your own can use. The model has none: Chock never touches it.
+
+- **Session start**: arms the hooks from what is committed. *Where the agent has hooks.*
+- **Session end** (not used): agentseam exposes this point; no shipped Chock code acts on it. *Where the agent has hooks.*
+- **Prompt submitted** (not used): agentseam exposes this point; no shipped Chock code acts on it. *Where the agent has hooks.*
+- **Instructions loaded** (not used): agentseam exposes this point; no shipped Chock code acts on it. *Where the agent has hooks.*
+- **Before context is compacted** (not used): agentseam exposes this point; no shipped Chock code acts on it. *Where the agent has hooks.*
+- **Before a tool runs**: Chock judges the call: allow, ask or block. A refusal goes back to the model with one line on what to do instead. *Where the agent has hooks.*
+- **After a tool runs**: records what ran, for checks that read the session. It never changes a verdict. *Where the agent has hooks.*
+- **After a tool fails**: records the failed call the same way. *Where the agent has hooks.*
+- **A file changes** (not used): agentseam exposes this point; no shipped Chock code acts on it. *Where the agent has hooks.*
+- **Subagent starts** (not used): agentseam exposes this point; no shipped Chock code acts on it. *Where the agent has hooks.*
+- **Subagent stops** (not used): agentseam exposes this point; no shipped Chock code acts on it. *Where the agent has hooks.*
+- **End of the turn**: reads what the turn left in the working tree and refuses to end the turn on a finding. A backstop. *Where the agent has hooks.*
+- **Rules in context**: a short rules block Chock writes into AGENTS.md. Advisory. *Every agent.*
+- **MCP gateway**: a proxy that judges calls to an MCP server. *Where a server is set up through it.*
+- **At git commit**: the git hook. *Every agent, and people.*
+- **At git push**: the pre-push hook. *Every agent, and people.*
+- **In CI**: the same gates on the pull request. *Every agent.*
+
+The same points in session order:
+
+
+
+
+
@@ -26,7 +56,7 @@ supports**, across up to nine [enforcement surfaces](enforcement-surfaces.md):
- `pre-tool-use` (nine agents, Claude Code and Cursor among them) and `agent-hooks`
(Copilot CLI, VS Code) — agent-native hard controls
- `stop` — the end-of-turn backstop that reads what the turn wrote (nine agent names)
-- `managed-setting` — compiled, not yet installed
+- `managed-setting` — not compiled; `chock emit --managed` writes it for an admin to deploy, and it credits nothing
- `gateway` — modeled for budgets/egress (future)
It also writes a **coverage report** (`.chock/coverage.json`) mapping every policy × agent onto
@@ -61,6 +91,8 @@ Actions workflow that invokes it; the coverage report only credits `ci-gate` tow
`enforced-at-commit` once that workflow is actually present, the same check `pre-tool-use` already
gets — a control nothing wires up enforces nothing.
+The CI gate emits SARIF (`chock check --event ci --format sarif`), and a baseline step fails a pull request that disables or narrows a policy (`chock check --only baseline`). `chock mcp` serves read-only guidance to the agent; `chock sync` registers it per client, opt-in.
+
## Why "author once" matters
The AI-agent ecosystem is fragmented: Claude reads `CLAUDE.md`, Cursor reads `.cursor/rules`,
diff --git a/docs/assets/readme/derive.py b/docs/assets/readme/derive.py
index 06010bf1..ff4414a6 100644
--- a/docs/assets/readme/derive.py
+++ b/docs/assets/readme/derive.py
@@ -28,6 +28,9 @@
BLOCK = re.compile(r"()(?P.*?)()", re.DOTALL)
UNTESTED_PREFIX = "Untested:"
DEPRECATED = "deprecated"
+TRUST_CONDITION = "after the project's hooks were trusted"
+CLIENT_VERSION = re.compile(r"\s+v?\d[\d.]*")
+CLIENT_PLATFORM = re.compile(r",\s*(?P[^,]+)$")
ASI = [f"ASI{n:02d}" for n in range(1, 11)]
INCIDENTS = [
("Log4Shell (CVE-2021-44228)", "java-security"),
@@ -128,6 +131,10 @@ def _either(names: list[str]) -> str:
return names[0] if len(names) == 1 else ", ".join(names[:-1]) + " or " + names[-1]
+def _either_and(names: list[str]) -> str:
+ return names[0] if len(names) == 1 else ", ".join(names[:-1]) + " and " + names[-1]
+
+
def _table(head: tuple[str, ...], align: tuple[str, ...], rows: list[tuple[object, ...]]) -> str:
lines = ["| " + " | ".join(head) + " |", "| " + " | ".join(align) + " |"]
lines += ["| " + " | ".join(str(c) for c in row) + " |" for row in rows]
@@ -148,14 +155,32 @@ def plugin_clients() -> tuple[list[str], list[str]]:
return [n for cid, n in names if cid not in untested], [n for cid, n in names if cid in untested]
-def repo_agents() -> tuple[int, int, list[str]]:
- """(agents chock sync wires, those with a native hook, clients its repo hooks were witnessed in)."""
+def witnessed_clients(rows: list) -> str:
+ """Client names from the ledger rows, grouped by the platform each records; versions stay in the ledger."""
+ groups: dict[str, list[str]] = {}
+ notes = []
+ for row in rows:
+ platform = CLIENT_PLATFORM.search(row.client)
+ name = CLIENT_VERSION.sub("", CLIENT_PLATFORM.sub("", row.client)).strip()
+ groups.setdefault(platform["platform"] if platform else "", []).append(name)
+ if TRUST_CONDITION in row.method:
+ notes.append(f"{name.split()[0]} {TRUST_CONDITION}")
+ parts = [
+ _either_and(names) if not platform else f"on {platform}, in {_either_and(names)}"
+ for platform, names in sorted(groups.items(), key=lambda g: g[0] != "")
+ ]
+ text = parts[0] if len(parts) == 1 else ", ".join(parts[:-1]) + " and, " + parts[-1]
+ return text + (f" ({'; '.join(notes)})" if notes else "")
+
+
+def repo_agents() -> tuple[int, int, list]:
+ """(agents chock sync wires, those with a native hook, ledger rows of its repo hooks witnessed live)."""
from chock import evidence # noqa: PLC0415
from chock.compile.surfaces import SURFACE_AGENTS, Surface # noqa: PLC0415
from chock.hooks import sync_notes # noqa: PLC0415
native = sum(1 for s in SURFACE_AGENTS.values() if {Surface.PRE_TOOL_USE, Surface.AGENT_HOOKS} & set(s))
- seen = [w.client for w in evidence.witnesses() if w.surface in sync_notes._HOOK_SURFACES]
+ seen = [w for w in evidence.witnesses() if w.surface in sync_notes._HOOK_SURFACES]
return len(SURFACE_AGENTS), native, seen
@@ -190,7 +215,7 @@ def readme_blocks(data: dict) -> dict[str, str]:
+ _table(("Class of flaw behind", "Policy", "Tier", "Eval cases"), (":---", ":---", ":---", "---:"), incidents)
+ "\n",
"plugins": _fill(t["plugins"], TESTED=_either(tested), UNTESTED=_either(untested)),
- "repo_agents": _fill(t["repo_agents"], WITNESSED="; ".join(seen)),
+ "repo_agents": _fill(t["repo_agents"], WITNESSED=witnessed_clients(seen)),
"faq_agents": _fill(t["faq_agents"], ALL=agents, NATIVE=native, TESTED_N=len(tested), UNTESTED_N=len(untested)),
"repos": f"\n{_fill(t['repos'], COUNT=len(repos))}\n\n"
+ _table(("Repository", "What it is"), (":---", ":---"), repos)
diff --git a/docs/assets/readme/readme-blocks.json b/docs/assets/readme/readme-blocks.json
index eeca89cd..3999142e 100644
--- a/docs/assets/readme/readme-blocks.json
+++ b/docs/assets/readme/readme-blocks.json
@@ -2,7 +2,7 @@
"_": "Templates for derive.py readme: README.md text between and is rewritten from data.json and chock's own data. __TOKEN__ placeholders only.",
"stamp": "From `registry.yaml` in [chock-catalog](https://github.com/open-coder-ai/chock-catalog) at `__SHA__`:",
"plugins": "It builds one plugin for __TESTED__, tested live, and, untested by chock, for __UNTESTED__.",
- "repo_agents": "Chock tested its repo hooks live in __WITNESSED__ only; other native hooks follow agentseam's record, untested.",
+ "repo_agents": "Repo hooks refused commands live in __WITNESSED__; others follow agentseam's record, untested.",
"faq_agents": "All __ALL__ above get a git hook, a CI gate and an `AGENTS.md` rule; __NATIVE__ also get a native hook. As one plugin: __TESTED_N__ tested, __UNTESTED_N__ untested.",
"repos": "The __COUNT__ public repositories:",
"numbers": [
diff --git a/docs/assets/readme/render.mjs b/docs/assets/readme/render.mjs
index 4a40a163..357be95b 100644
--- a/docs/assets/readme/render.mjs
+++ b/docs/assets/readme/render.mjs
@@ -4,6 +4,8 @@ import { chromium } from 'playwright';
import { mkdirSync, readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
+import { where } from './where-chock-sits.mjs';
+import { where as sessionPath } from './session-path.mjs';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const OUT = process.env.OUT_DIR || HERE;
@@ -111,7 +113,7 @@ const ADOPT = page(`
Route 1 for teams
In your repository
-${term([cmd('chock init .'), cmd('chock add <id> --ref <sha> \\'), '
--verify-sha <sha256> --skip-compile
', cmd('chock sync --repo . --ci')])}
+${term([cmd('chock init .'), cmd('chock add <id> --skip-compile'), cmd('chock sync --repo . --ci')])}
Everyone and every agent on the repo. Enforced at commit and in CI. Travels with every clone.
Route 2 no repo changes
@@ -187,7 +189,7 @@ ${layer('Templates', 'chock-quickstart is what chock init leaves behind. chock-e
const QUICKSTART = SECTION('See it work', 'Two commands. Real hooks.
Real refusals. ', `
-${term(['
# set up once
', cmd('chock init .'), cmd('chock add scan-secrets --ref <sha> \\'), '
--verify-sha <sha256> --skip-compile
', cmd('chock sync --repo . --ci')], 'git never clones hooks. Every clone runs chock sync --repo . once.')}
+${term(['
# set up once
', cmd('chock init .'), cmd('chock add scan-secrets --skip-compile'), cmd('chock sync --repo . --ci')], 'git never clones hooks. Every clone runs chock sync --repo . once.')}
${term(['
# the next commit with a credential
', cmd('git commit -m "add config"'), '
✗ Potential secret detected in this change.
', '
- config.py: content pattern
', cmd('git commit -m "read key from env"'), '
✓ passes
'])}
${note('The refusal text is the gate message of scan-secrets in chock-catalog. The recording is in the text version.')}`);
@@ -215,9 +217,12 @@ const HONEST = SECTION('Guardrails, not guarantees', 'And we tell you
`${tag(t)}${p}
`))}
${grid(3, 16, [[A.grades.enforced, 'matrix cells graded “enforced”: no agent reaches it'], [`${D.asi.refused_at_commit.length} of ${D.asi.with_policy}`, 'OWASP Agentic risks with a slice refused at commit'], [D.asi.fully_covered, 'OWASP Agentic risks fully covered: every mapping is partial']].map(([n, l]) => stat(n, l)))}`);
+const FIGURE = JSON.parse(readFileSync(path.join(HERE, 'where-chock-sits.json'), 'utf8'));
+const WHERE = where(page, FIGURE), SESSION_PATH = sessionPath(page, FIGURE);
+
const ALL_NEW = { layers: LAYERS, quickstart: QUICKSTART, matrix: MATRIX, catalog: CATALOG, family: FAMILY, honest: HONEST };
// README v2 panels go under v2/; the titled refusal, roles and contribute PNGs at the old paths stay frozen until RW-7b.
-const V2 = { 'v2/refusal': REFUSAL, 'v2/roles': ROLES, 'v2/contribute': CONTRIBUTE };
+const V2 = { 'v2/refusal': REFUSAL, 'v2/roles': ROLES, 'v2/contribute': CONTRIBUTE, 'v2/where-chock-sits': WHERE, 'v2/session-path': SESSION_PATH };
// 1280x640 social preview banners: the same specs as the covers, laid out for the fixed canvas.
const social = ({ repo, title, sub, chips, right }) => `
diff --git a/docs/assets/readme/session-path.mjs b/docs/assets/readme/session-path.mjs
new file mode 100644
index 00000000..9379b26f
--- /dev/null
+++ b/docs/assets/readme/session-path.mjs
@@ -0,0 +1,118 @@
+// The README "How it works" figure: a session as an ordered path with checkpoints. Every word comes from where-chock-sits.json; positions are computed here by a flow layout, and `layout` also reports every shape so a test can check nothing overlaps.
+const R = 14, TEXT_W = 84, DIAMOND = 20, GAP = 12, T1 = 56, YA = 244, H1 = 414, T2 = T1 + H1 + 40, YR = T2 + 104, H2 = 210, TEXT_TOP = 52;
+const LINES = (text, perLine = 11) => Math.ceil(text.length / perLine);
+const nameW = (s) => Math.ceil(s.length * 6 + 4);
+
+export const layout = (W) => {
+ const shapes = [], arrows = [], diamonds = [];
+ const add = (id, x, y, w, h) => shapes.push({ id, x, y, w, h });
+ const rows = {};
+ const label = (p, x, y) => {
+ add(`${p.id}-diamond`, x - DIAMOND / 2, y - DIAMOND / 2, DIAMOND, DIAMOND);
+ add(`${p.id}-name`, x - nameW(p.label) / 2, y + 26, nameW(p.label), 14);
+ if (p.acts) add(`${p.id}-does`, x - (p.place.of > 1 ? 28 : 40), y - 30 - 32, p.place.of > 1 ? 56 : 80, 32);
+ };
+ const place = (key, x0, x1, y, T) => {
+ const steps = W.path.paths[key].steps;
+ const pts = W.points.filter((p) => p.place?.row === key);
+ const weight = steps.map((_, k) => Math.max(1, ...pts.filter((p) => p.place.into === k).map((p) => (p.place.of > 1 ? p.place.of + 1.5 : 1))));
+ const free = x1 - x0 - steps.length * 2 * R, unit = free / weight.reduce((a, b) => a + b, 0);
+ let cursor = x0;
+ const cx = steps.map((_, k) => { const start = cursor; cursor += weight[k] * unit + 2 * R; arrows.push({ key, k, x1: start, x2: start + weight[k] * unit + R, y }); return start + weight[k] * unit + R; });
+ steps.forEach((s, k) => {
+ s.h = (LINES(s.text) + (s.sub ? LINES(s.sub, 13) : 0)) * 16 + 6;
+ add(`${key}-circle-${k}`, cx[k] - R, y - R, 2 * R, 2 * R);
+ add(`${key}-text-${k}`, cx[k] - TEXT_W / 2, y + TEXT_TOP, TEXT_W, s.h);
+ });
+ pts.forEach((p) => {
+ const a = arrows.find((q) => q.key === key && q.k === p.place.into);
+ const x = a.x1 + ((a.x2 - R - a.x1) * (p.place.slot + 1)) / (p.place.of + 1);
+ diamonds.push({ id: p.id, x, y, acts: p.acts });
+ label(p, x, y);
+ });
+ rows[key] = { cx, y, T };
+ };
+ place('agent', 24, 782, YA, T1);
+ place('repo', 10, 782, YR, T2);
+ const A = rows.agent, tool = A.cx[4], mcp = W.points.find((p) => p.place?.tag), toolText = A.cx.length && W.path.paths.agent.steps[4].h;
+ const lineTop = YA + TEXT_TOP + toolText + 6, mid = lineTop + 28, tagTop = lineTop + 56;
+ add('tag', tool - 76, tagTop, 152, 24);
+ add(`${mcp.id}-diamond`, tool - DIAMOND / 2, mid - DIAMOND / 2, DIAMOND, DIAMOND);
+ add(`${mcp.id}-name`, tool - 22 - nameW(mcp.label) - 8, mid - 7, nameW(mcp.label) + 8, 14);
+ add(`${mcp.id}-does`, tool + 14, mid - 8, 90, 16);
+ diamonds.push({ id: mcp.id, x: tool, y: mid, acts: mcp.acts });
+ const loop = W.path.paths.agent.loop, post = diamonds.find((d) => d.id === loop.after), next = diamonds.find((d) => d.id === 'stop');
+ const xs = (post.x + next.x) / 2, xm = A.cx[loop.to], y0 = YA - R;
+ const yv = YA - 110, p1 = [xs, yv - 55], p2 = [xm - 40, y0 - 140], end = [xm, y0 - 2];
+ const bez = (t) => { const u = 1 - t; return [u ** 3 * xs + 3 * u * u * t * p1[0] + 3 * u * t * t * p2[0] + t ** 3 * end[0], u ** 3 * yv + 3 * u * u * t * p1[1] + 3 * u * t * t * p2[1] + t ** 3 * end[1]]; };
+ const curve = [...Array.from({ length: 20 }, (_, i) => [xs, YA - 4 - ((YA - 4 - yv) * i) / 19]), ...Array.from({ length: 51 }, (_, i) => bez(i / 50))];
+ const loopPath = `M${xs} ${YA - 4} V${yv} C${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]} ${end[0]} ${end[1]}`;
+ add('loop-label', (xs + xm) / 2 - 60, YA - 172, 120, 16);
+ return { shapes, arrows, diamonds, rows, curve, loop: { xs, xm, y0 }, loopPath, mid, lineTop, tagTop };
+};
+
+// Pairs of shapes closer than GAP, the loop arrow passing a label, and arrows with a shaft under 40 px.
+export const crowded = (L) => {
+ const bad = [];
+ const near = (a, b) => a.x < b.x + b.w + GAP && b.x < a.x + a.w + GAP && a.y < b.y + b.h + GAP && b.y < a.y + a.h + GAP;
+ const base = (id) => id.replace(/-(diamond|does|name)$/, '');
+ const own = (a, b) => (base(a.id) === base(b.id) && a.id !== b.id && /-(diamond|does|name)$/.test(a.id) && /-(diamond|does|name)$/.test(b.id)) || (a.id.replace('-circle-', '-text-') === b.id && a.id.includes('-circle-'));
+ L.shapes.forEach((a, i) => L.shapes.slice(i + 1).forEach((b) => { if (!own(a, b) && near(a, b)) bad.push([a.id, b.id]); }));
+ L.shapes.filter((s) => /-(does|name)$/.test(s.id) || s.id === 'loop-label').forEach((s) => { if (L.curve.some(([x, y]) => x > s.x - 8 && x < s.x + s.w + 8 && y > s.y - 8 && y < s.y + s.h + 8)) bad.push([s.id, 'loop-arrow']); });
+ L.arrows.forEach((a) => { if (a.x2 - R - a.x1 - 8 < 40) bad.push([`${a.key}-arrow-${a.k}`, 'short']); });
+ return bad;
+};
+
+export const where = (page, W) => {
+ const L = layout(W), bad = crowded(L);
+ if (bad.length) throw new Error(`figure shapes too close: ${JSON.stringify(bad)}`);
+ const esc = (s) => s.replace(/&/g, '&').replace(/ `
${inner}
`;
+ const diamond = (x, y, acts, s = 14) => abs(x - s / 2, y - s / 2, s, s, `transform:rotate(45deg);box-sizing:border-box;border:2px solid ${acts ? ACCENT : GREY};background:${acts ? ACCENT : PAPER}`, '');
+ const text = (s, css, inner) => abs(s.x, s.y, s.w, s.h, `font-size:12.5px;line-height:1.25;font-weight:600;text-align:center;${css}`, esc(inner));
+ const frame = (y, h, name) => abs(0, y, 840, h, `border:2px dashed ${LINE};border-radius:18px;box-sizing:border-box`, `
${esc(name)}
`);
+ const head = `
`;
+ const line = (d, arrow = true) => `
`;
+ const yr = L.rows.repo.y, last = L.rows.agent.cx[5], tool = L.rows.agent.cx[4];
+ const entry = L.arrows.find((a) => a.key === 'repo' && a.k === 0), ymid = (T1 + H1 + T2) / 2;
+ const paths = [
+ ...L.arrows.map((a) => line(`M${a.x1} ${a.y} H${a.x2 - R}`)),
+ line(L.loopPath),
+ `
`,
+ line(`M${tool} ${L.lineTop} V${L.tagTop}`, false),
+ line(`M${last + R} ${YA} H828 V${ymid} H10 V${yr} H${entry.x2 - R}`),
+ ].join('');
+ const stepHtml = (key) => W.path.paths[key].steps.map((s, k) => {
+ const cx = L.rows[key].cx[k], y = L.rows[key].y, n = key === 'agent' ? k + 1 : k + 7;
+ return abs(cx - R, y - R, 2 * R, 2 * R, `box-sizing:border-box;border:2px solid ${LINE};border-radius:50%;background:#fff;font-size:13px;font-weight:700;display:flex;align-items:center;justify-content:center`, n)
+ + abs(cx - TEXT_W / 2, y + TEXT_TOP, TEXT_W, s.h, `text-align:center;font-size:13.5px;line-height:16px;font-weight:600;color:${INK}`, `${esc(s.text)}${s.sub ? `
${esc(s.sub)}
` : ''}`);
+ }).join('');
+ const marks = W.points.filter((p) => p.place?.row || p.place?.tag).map((p) => {
+ const d = L.diamonds.find((q) => q.id === p.id), get = (suffix) => L.shapes.find((q) => q.id === `${p.id}-${suffix}`);
+ const name = get('name'), does = get('does');
+ return diamond(d.x, d.y, p.acts) + text(name, `color:${GREY};font-size:12px;font-weight:600;white-space:nowrap`, p.label) + (p.acts ? text(does, `color:${ACCENT};display:flex;align-items:flex-end;justify-content:center`, p.does) : '');
+ }).join('');
+ const tagHtml = abs(tool - 76, L.tagTop, 152, 24, `box-sizing:border-box;border:1.5px solid ${LINE};border-radius:999px;background:#fff;font-size:12.5px;font-weight:600;color:${INK};display:flex;align-items:center;justify-content:center`, esc(W.path.paths.agent.steps[4].tag));
+ const loopLabel = text(L.shapes.find((s) => s.id === 'loop-label'), `color:${SOFT}`, W.path.paths.agent.loop.label);
+ const keyRow = (acts, label, y) => `
${diamond(7, 7, acts)} ${esc(label)}
`;
+ const chip = (p) => `
${diamond(5, 5, p.acts, 10)} ${esc(p.label)}`;
+ const more = W.points.filter((p) => p.place?.chip).map(chip).join('');
+ const stop = `padding:4px 6px;border:1.5px solid ${LINE};border-radius:999px;background:#fff;font-size:12.5px;font-weight:600;color:${INK};white-space:nowrap`;
+ const own = `
${esc(W.own.label)}${esc(W.own.command)} `;
+ const stops = W.stops.map((s) => `
${esc(s)} `).join('') + own;
+ const base = T2 + H2 + 22;
+ return page(`
+
${esc(W.path.title)}
+
+${frame(T1, H1, W.path.paths.agent.name)}${frame(T2, H2, W.path.paths.repo.name)}
+
${head} ${paths}
+${stepHtml('agent')}${stepHtml('repo')}${tagHtml}${loopLabel}${marks}
+${keyRow(true, W.path.key.acts, base)}${keyRow(false, W.path.key.exposed, base + 28)}
+
${esc(W.path.more_title)}
+
${more}
+
${esc(W.stops_title)}
+
${stops}
+
${esc(W.footer)}
+
`);
+};
diff --git a/docs/assets/readme/v2/session-path.png b/docs/assets/readme/v2/session-path.png
new file mode 100644
index 00000000..8a50e829
Binary files /dev/null and b/docs/assets/readme/v2/session-path.png differ
diff --git a/docs/assets/readme/v2/where-chock-sits.png b/docs/assets/readme/v2/where-chock-sits.png
new file mode 100644
index 00000000..9848a4ff
Binary files /dev/null and b/docs/assets/readme/v2/where-chock-sits.png differ
diff --git a/docs/assets/readme/where-chock-sits.json b/docs/assets/readme/where-chock-sits.json
new file mode 100644
index 00000000..807ee82f
--- /dev/null
+++ b/docs/assets/readme/where-chock-sits.json
@@ -0,0 +1,60 @@
+{
+ "_": "Text of the README harness figure (v2/where-chock-sits.png) and of the session-path figure in docs/architecture.md (v2/session-path.png); both read by their .mjs. 'points' are the 12 agentseam events (agentseam.contract.EVENTS) plus the five other places Chock acts or could; 'on' is the harness card a point sits on, 'place' where the session-path draws it; 'acts' is true where shipped Chock code acts on the point (filled badge or diamond). tests assert the agentseam points equal agentseam.contract.EVENTS, the acting set equals what the engine handles, and that no two shapes of either layout intersect. 'proof' lists the tests that prove each acting point.",
+ "points": [
+ {"id": "session_start", "label": "session start", "name": "Session start", "line": "arms the hooks from what is committed.", "scope": "where the agent has hooks", "source": "agentseam", "acts": true, "proof": ["tests/test_sessionstart_arm.py"], "place": {"row": "agent", "into": 0, "slot": 0, "of": 1}, "does": "arms the hooks", "on": "session"},
+ {"id": "session_end", "label": "session end", "name": "Session end", "line": "agentseam exposes this point; no shipped Chock code acts on it.", "scope": "where the agent has hooks", "source": "agentseam", "acts": false, "proof": [], "place": {"chip": true}, "on": "session"},
+ {"id": "prompt_submit", "label": "prompt submit", "name": "Prompt submitted", "line": "agentseam exposes this point; no shipped Chock code acts on it.", "scope": "where the agent has hooks", "source": "agentseam", "acts": false, "proof": [], "place": {"row": "agent", "into": 1, "slot": 0, "of": 1}, "on": "prompt"},
+ {"id": "instructions_loaded", "label": "instructions", "name": "Instructions loaded", "line": "agentseam exposes this point; no shipped Chock code acts on it.", "scope": "where the agent has hooks", "source": "agentseam", "acts": false, "proof": [], "place": {"chip": true}, "on": "context"},
+ {"id": "pre_compact", "label": "pre-compact", "name": "Before context is compacted", "line": "agentseam exposes this point; no shipped Chock code acts on it.", "scope": "where the agent has hooks", "source": "agentseam", "acts": false, "proof": [], "place": {"chip": true}, "on": "context"},
+ {"id": "pre_tool", "label": "pre-tool", "name": "Before a tool runs", "line": "Chock judges the call: allow, ask or block. A refusal goes back to the model with one line on what to do instead.", "scope": "where the agent has hooks", "source": "agentseam", "acts": true, "proof": ["tests/test_agent_hooks.py", "tests/test_claude_warn_ask_wire.py"], "place": {"row": "agent", "into": 4, "slot": 0, "of": 1}, "does": "allow, ask or block", "on": "gate"},
+ {"id": "post_tool", "label": "post-tool", "name": "After a tool runs", "line": "records what ran, for checks that read the session. It never changes a verdict.", "scope": "where the agent has hooks", "source": "agentseam", "acts": true, "proof": ["tests/test_session_log.py"], "place": {"row": "agent", "into": 5, "slot": 0, "of": 2}, "does": "records what ran", "on": "gate"},
+ {"id": "tool_failure", "label": "tool failure", "name": "After a tool fails", "line": "records the failed call the same way.", "scope": "where the agent has hooks", "source": "agentseam", "acts": true, "proof": ["tests/test_session_log.py"], "place": {"chip": true}, "on": "gate"},
+ {"id": "file_changed", "label": "file changed", "name": "A file changes", "line": "agentseam exposes this point; no shipped Chock code acts on it.", "scope": "where the agent has hooks", "source": "agentseam", "acts": false, "proof": [], "place": {"chip": true}, "on": "tools"},
+ {"id": "subagent_start", "label": "subagent start", "name": "Subagent starts", "line": "agentseam exposes this point; no shipped Chock code acts on it.", "scope": "where the agent has hooks", "source": "agentseam", "acts": false, "proof": [], "place": {"chip": true}, "on": "subagents"},
+ {"id": "subagent_stop", "label": "subagent stop", "name": "Subagent stops", "line": "agentseam exposes this point; no shipped Chock code acts on it.", "scope": "where the agent has hooks", "source": "agentseam", "acts": false, "proof": [], "place": {"chip": true}, "on": "subagents"},
+ {"id": "stop", "label": "stop", "name": "End of the turn", "line": "reads what the turn left in the working tree and refuses to end the turn on a finding. A backstop.", "scope": "where the agent has hooks", "source": "agentseam", "acts": true, "proof": ["tests/test_stop_surface.py"], "place": {"row": "agent", "into": 5, "slot": 1, "of": 2}, "does": "last check", "on": "loop"},
+ {"id": "ambient-rule", "label": "rules", "name": "Rules in context", "line": "a short rules block Chock writes into AGENTS.md. Advisory.", "scope": "every agent", "source": "chock", "acts": true, "proof": ["tests/test_agents_md_pointer.py"], "place": {"row": "agent", "into": 2, "slot": 0, "of": 1}, "does": "tells it the rules", "on": "context"},
+ {"id": "mcp-gateway", "label": "MCP gateway", "name": "MCP gateway", "line": "a proxy that judges calls to an MCP server.", "scope": "where a server is set up through it", "source": "chock", "acts": true, "proof": ["tests/test_mcp_gateway.py"], "place": {"tag": true}, "does": "judges the call", "on": "external"},
+ {"id": "git-commit", "label": "commit", "name": "At git commit", "line": "the git hook.", "scope": "every agent, and people", "source": "chock", "acts": true, "proof": ["tests/test_hook_gate_and_script.py"], "place": {"row": "repo", "into": 0, "slot": 0, "of": 1}, "does": "refuses a bad change", "on": "commit"},
+ {"id": "git-push", "label": "push", "name": "At git push", "line": "the pre-push hook.", "scope": "every agent, and people", "source": "chock", "acts": true, "proof": ["tests/test_default_hooks.py"], "place": {"row": "repo", "into": 1, "slot": 0, "of": 1}, "does": "refuses a bad push", "on": "push"},
+ {"id": "ci-gate", "label": "CI", "name": "In CI", "line": "the same gates on the pull request.", "scope": "every agent", "source": "chock", "acts": true, "proof": ["tests/test_ci_emitter.py"], "place": {"row": "repo", "into": 2, "slot": 0, "of": 1}, "does": "same checks, every PR", "on": "ci"}
+ ],
+ "stops_title": "What it stops, for example",
+ "stops": ["secrets in code", "root or floating-tag containers", "curl piped to shell", "unapproved egress", "weakened CI checks"],
+ "own": {"label": "+ your own policy", "command": "chock new policy", "proof": ["src/chock/data/commands.json", "tests/test_scaffold_dx.py"]},
+ "footer": "The rules are files in your repository. A person turns them on once with chock sync.",
+ "harness": {
+ "title": "Inside a coding agent's harness, and where Chock plugs in.",
+ "frame": "A coding agent's harness (any vendor)",
+ "repo_frame": "Your repository and pipeline",
+ "layers": ["Input", "Core", "Execution"],
+ "cards": [
+ {"id": "you", "name": "You", "line": "terminal or IDE", "row": 0, "col": 0, "span": 1},
+ {"id": "prompt", "name": "Prompt", "line": "what you typed", "row": 0, "col": 1, "span": 1},
+ {"id": "session", "name": "Session", "line": "starts, resumes, ends", "row": 0, "col": 2, "span": 1},
+ {"id": "context", "name": "Context", "line": "rules, instructions, memory", "row": 1, "col": 0, "span": 1},
+ {"id": "loop", "name": "Agent loop", "line": "read, decide, act, observe", "row": 1, "col": 1, "span": 2},
+ {"id": "model", "name": "Model (LLM)", "line": "proposes the next action", "row": 1, "col": 3, "span": 1},
+ {"id": "subagents", "name": "Subagents", "line": "helpers the loop starts", "row": 2, "col": 0, "span": 1},
+ {"id": "gate", "name": "Tool gate", "line": "asks before a tool runs", "row": 2, "col": 1, "span": 1},
+ {"id": "tools", "name": "Tools", "line": "edit, write, run, git", "row": 2, "col": 2, "span": 1},
+ {"id": "external", "name": "External tools (MCP)", "line": "tools from other programs", "row": 2, "col": 3, "span": 1}
+ ],
+ "repo_cards": [
+ {"id": "commit", "name": "git commit", "line": "saves the change"},
+ {"id": "push", "name": "git push", "line": "sends it on"},
+ {"id": "ci", "name": "CI on the pull request", "line": "runs the checks"},
+ {"id": "main", "name": "main branch", "line": "where it lands"}
+ ],
+ "arrows": {"you-prompt": "asks", "prompt-loop": "request", "session-loop": "opens", "context-loop": "feeds", "loop-model": "plans", "loop-gate": "tool call", "gate-loop": "refused", "gate-tools": "allow", "tools-loop": "result", "tools-external": "calls", "loop-subagents": "starts", "tools-commit": "writes"},
+ "key": {"acts": "Chock runs here: a local program, rules are files in your repository, no model, no tokens", "exposed": "a hook your own policy can use"},
+ "alt": "A coding agent's harness drawn as component cards in three layers: input (you, the prompt, the session), core (context, the agent loop and the model) and execution (the tool gate, tools, external tools over MCP and subagents), with arrows showing how they talk to each other, beside the repository and pipeline (git commit, git push, CI, main branch). Small diamonds on each card are the hooks on that component: filled where Chock runs today, hollow where a policy of your own can run. The model has none, because Chock never touches it."
+ },
+ "path": {
+ "title": "A session, step by step. Chock runs at the marked points.",
+ "paths": {"agent": {"name": "Inside your agent", "steps": [{"text": "You open a session"}, {"text": "You type a request"}, {"text": "The agent loads its rules"}, {"text": "The model picks the next action"}, {"text": "A tool runs", "sub": "edit a file, run a command, git", "tag": "external tools (MCP)"}, {"text": "The agent ends its turn"}], "loop": {"to": 3, "after": "post_tool", "label": "repeats until done"}}, "repo": {"name": "In your repository", "steps": [{"text": "git commit"}, {"text": "git push"}, {"text": "CI on the pull request"}, {"text": "main branch"}]}},
+ "key": {"acts": "Chock runs here: a local program, rules are files in your repository, no model, no tokens", "exposed": "a hook your own policy can use"},
+ "more_title": "More hooks",
+ "alt": "A session as an ordered path with checkpoints. Inside your agent: you open a session, type a request, the agent loads its rules, the model picks the next action, a tool runs (repeating until done) and the agent ends its turn; then in your repository: git commit, git push, CI on the pull request and the main branch. Diamonds on the arrows are the hook points: filled where Chock runs today (session start, rules, before and after a tool, stop, the MCP gateway, commit, push, CI) and hollow where a policy of your own can run; the other agent events sit in a row of more hooks."
+ }
+}
diff --git a/docs/assets/readme/where-chock-sits.mjs b/docs/assets/readme/where-chock-sits.mjs
new file mode 100644
index 00000000..13b8b13d
--- /dev/null
+++ b/docs/assets/readme/where-chock-sits.mjs
@@ -0,0 +1,103 @@
+// The README figure: a coding agent's harness as component cards in layers, with the hooks drawn ON the card they belong to. Every word comes from where-chock-sits.json; positions are computed here, and `layout` reports every shape so a test can check nothing overlaps.
+const HW = 680, PAD = 16, COLS = 4, G = 62, CW = (HW - 2 * PAD - (COLS - 1) * G) / COLS, VG = 56, GAP = 12;
+const RX = 704, RW = 136, RCW = RW - 32;
+const col = (c) => PAD + c * (CW + G);
+const lines = (text, width, per = 6.4) => Math.max(1, Math.ceil((text.length * per) / width));
+const badgeH = () => 20;
+
+export const layout = (W) => {
+ const H = W.harness, shapes = [], segs = [], cards = {}, badges = [];
+ const add = (id, x, y, w, h) => shapes.push({ id, x, y, w, h });
+ const mine = (id) => W.points.filter((p) => p.on === id);
+ const size = (c, width) => {
+ const bs = mine(c.id);
+ c.w = width;
+ c.nameH = lines(c.name, width - 16, 8.2) * 18;
+ c.lineH = lines(c.line, width - 16, 7.8) * 16;
+ c.badgeH = bs.reduce((a, p) => a + badgeH(p.label, width) + 4, bs.length ? 8 : 0);
+ c.h = 12 + c.nameH + 4 + c.lineH + c.badgeH + 8;
+ };
+ H.cards.forEach((c) => size(c, c.span * CW + (c.span - 1) * G));
+ const rowH = [0, 1, 2].map((r) => Math.max(...H.cards.filter((c) => c.row === r).map((c) => c.h)));
+ const rowTop = []; let y = 56;
+ rowH.forEach((h, r) => { if (r < 3) y += r ? 0 : 0; rowTop[r] = y; y += h + VG + (r === 2 ? 0 : 0); });
+ const layerTitleY = [rowTop[0] - 30, rowTop[1] - 30, rowTop[2] - 30];
+ H.layers.forEach((t, i) => add(`layer-${i}`, PAD + 6, layerTitleY[i], t.length * 8 + 4, 14));
+ H.cards.forEach((c) => { c.x = col(c.col); c.y = rowTop[c.row]; cards[c.id] = c; add(`card-${c.id}`, c.x, c.y, c.w, c.h); });
+ H.cards.forEach((c) => { let by = c.y + c.h - 8; [...mine(c.id)].reverse().forEach((p) => { const bh = badgeH(p.label, c.w); by -= bh; badges.push({ p, x: c.x + 4, y: by, w: c.w - 8, h: bh }); by -= 4; }); });
+ // repository cards, top to bottom
+ let ry = 100;
+ H.repo_cards.forEach((c) => { size(c, RCW); c.x = RX + 16; c.y = ry; add(`card-${c.id}`, c.x, c.y, c.w, c.h); cards[c.id] = c; ry += c.h + 34; badges.push(...(() => { let by = c.y + c.h - 8; return mine(c.id).map((p) => { const bh = badgeH(p.label, c.w); by -= bh; const b = { p, x: c.x + 4, y: by, w: c.w - 8, h: bh }; by -= 4; return b; }); })()); });
+ const A = H.arrows, mid = (c) => c.x + c.w / 2, rt = (c) => c.x + c.w, bt = (c) => c.y + c.h, ln = (id, y0 = 26) => cards[id].y + y0;
+ const label = (id, text, x, y, w, anchor = 'center') => { const lw = Math.ceil(text.length * 6 + 2); const lx = anchor === 'center' ? x - lw / 2 : anchor === 'right' ? x - lw : x; add(`label-${id}`, lx, y, lw, 14); return { text, x: lx, y, w: lw }; };
+ const labels = [];
+ const seg = (d, tail = true, both = false) => segs.push({ d, tail, both });
+ const { you, prompt, session, context, loop, model, subagents, gate, tools, external, commit, push, ci, main } = cards;
+ seg(`M${rt(you)} ${ln('you')} H${prompt.x}`); labels.push(label('you-prompt', A['you-prompt'], (rt(you) + prompt.x) / 2, ln('you') - 22));
+ seg(`M${prompt.x + prompt.w / 2} ${bt(prompt)} V${loop.y}`); labels.push(label('prompt-loop', A['prompt-loop'], prompt.x + prompt.w / 2 + 10, (bt(prompt) + loop.y) / 2 - 7, 0, 'left'));
+ seg(`M${mid(session)} ${bt(session)} V${loop.y}`); labels.push(label('session-loop', A['session-loop'], mid(session) + 10, (bt(session) + loop.y) / 2 - 7, 0, 'left'));
+ seg(`M${rt(context)} ${ln('context')} H${loop.x}`); labels.push(label('context-loop', A['context-loop'], (rt(context) + loop.x) / 2, ln('context') - 22));
+ seg(`M${rt(loop)} ${ln('loop')} H${model.x}`, true, true); labels.push(label('loop-model', A['loop-model'], (rt(loop) + model.x) / 2, ln('loop') - 22));
+ const xa = gate.x + 10, xb = gate.x + gate.w - 10, ym = (bt(loop) + gate.y) / 2 - 7;
+ seg(`M${xa} ${bt(loop)} V${gate.y}`); labels.push(label('loop-gate', A['loop-gate'], mid(gate), ym));
+ seg(`M${xb} ${gate.y} V${bt(loop)}`); labels.push(label('gate-loop', A['gate-loop'], xb + 10, ym, 0, 'left'));
+ seg(`M${rt(gate)} ${ln('gate')} H${tools.x}`); labels.push(label('gate-tools', A['gate-tools'], (rt(gate) + tools.x) / 2, ln('gate') - 22));
+ seg(`M${mid(tools)} ${tools.y} V${bt(loop)}`); labels.push(label('tools-loop', A['tools-loop'], mid(tools) + 10, ym, 0, 'left'));
+ seg(`M${rt(tools)} ${ln('tools')} H${external.x}`); labels.push(label('tools-external', A['tools-external'], (rt(tools) + external.x) / 2, ln('tools') - 22));
+ const gx = rt(context) + G / 2, sy = ln('subagents');
+ seg(`M${loop.x} ${loop.y + loop.h - 28} H${gx} V${sy} H${rt(subagents)}`); labels.push(label('loop-subagents', A['loop-subagents'], gx - 10, (bt(context) + subagents.y) / 2 - 7, 0, 'right'));
+ const wx = HW + 12;
+ const yb = rowTop[2] + rowH[2] + 22;
+ seg(`M${mid(tools)} ${bt(tools)} V${yb} H${wx} V${ln('commit')} H${commit.x}`); labels.push(label('tools-commit', A['tools-commit'], (mid(tools) + wx) / 2, yb + 8));
+ [[commit, push], [push, ci], [ci, main]].forEach(([u, v]) => seg(`M${mid(u)} ${bt(u)} V${v.y}`));
+ const Ht = Math.max(rowTop[2] + rowH[2] + 56, ry + 6);
+ return { shapes, segs, cards, badges, labels, rowTop, layerTitleY, Ht, wx, ry };
+};
+
+// Cards, labels and badges closer than GAP; a label too near an arrow line.
+export const crowded = (L) => {
+ const bad = [], near = (a, b, g = GAP) => a.x < b.x + b.w + g && b.x < a.x + a.w + g && a.y < b.y + b.h + g && b.y < a.y + a.h + g;
+ L.shapes.forEach((a, i) => L.shapes.slice(i + 1).forEach((b) => { if (near(a, b)) bad.push([a.id, b.id]); }));
+ L.badges.forEach((b) => L.shapes.filter((s) => s.id.startsWith('label-')).forEach((s) => { if (near(b, s)) bad.push([b.p.id, s.id]); }));
+ L.badges.forEach((b) => { if (b.p.label.length * 6.1 + 20 > b.w) bad.push([b.p.id, 'badge-text']); });
+ L.badges.forEach((b, i) => L.badges.slice(i + 1).forEach((c) => { if (near(b, c, 2)) bad.push([b.p.id, c.p.id]); }));
+ const points = (d) => { const n = [...d.matchAll(/([MHV])(-?[\d.]+)(?: (-?[\d.]+))?/g)]; let x = 0, y = 0; const out = []; n.forEach((m) => { if (m[1] === 'M') { x = +m[2]; y = +m[3]; } else if (m[1] === 'H') x = +m[2]; else y = +m[2]; out.push([x, y]); }); return out; };
+ const hit = (r, i) => r.x <= i.x + i.w && i.x <= r.x + r.w && r.y <= i.y + i.h && i.y <= r.y + r.h;
+ L.segs.forEach((s) => { const p = points(s.d); p.slice(1).forEach((q, i) => { const a = p[i], r = { x: Math.min(a[0], q[0]), y: Math.min(a[1], q[1]), w: Math.abs(q[0] - a[0]), h: Math.abs(q[1] - a[1]) };
+ L.shapes.filter((c) => c.id.startsWith('card-')).forEach((c) => { if (hit(r, { x: c.x + 2, y: c.y + 2, w: c.w - 4, h: c.h - 4 })) bad.push([s.d, c.id]); });
+ L.shapes.filter((l) => l.id.startsWith('label-')).forEach((l) => { if (near(l, r, 6)) bad.push([s.d, l.id]); }); }); });
+ return bad;
+};
+
+export const where = (page, W) => {
+ const L = layout(W), bad = crowded(L), H = W.harness;
+ if (bad.length) throw new Error(`figure shapes too close: ${JSON.stringify(bad)}`);
+ const esc = (s) => s.replace(/&/g, '&').replace(/ `
${inner}
`;
+ const diamond = (x, y, acts, s = 10) => abs(x - s / 2, y - s / 2, s, s, `transform:rotate(45deg);box-sizing:border-box;border:2px solid ${acts ? ACCENT : GREY};background:${acts ? ACCENT : PAPER}`, '');
+ const frame = (x, y, w, h, title, inside = false) => abs(x, y, w, h, `border:2px dashed ${LINE};border-radius:18px;box-sizing:border-box`, inside ? `
${esc(title)}
` : `
${esc(title)}
`);
+ const card = (c) => abs(c.x, c.y, c.w, c.h, `box-sizing:border-box;background:${FILL[c.id]};border:1.5px solid ${LINE};border-radius:12px;padding:10px 8px`, `
${esc(c.name)}
${esc(c.line)}
`);
+ const badge = (b) => abs(b.x, b.y, b.w, b.h, `box-sizing:border-box;display:flex;align-items:center;gap:4px;padding:0 5px;border-radius:999px;background:#fff;white-space:nowrap;font-size:12px;line-height:14px;font-weight:600;color:${b.p.acts ? ACCENT : '#7C7989'}`, `
${diamond(5, 5, b.p.acts)} ${esc(b.p.label)} `);
+ const arrow = `
`;
+ const paths = L.segs.map((s) => `
`).join('');
+ const layerTitles = H.layers.map((t, i) => abs(PAD + 6, L.layerTitleY[i], 120, 14, `font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:${SOFT}`, esc(t))).join('');
+ const labels = L.labels.map((l) => abs(l.x, l.y, l.w, 14, `font-size:12px;line-height:14px;font-weight:600;color:${SOFT};white-space:nowrap`, esc(l.text))).join('');
+ const keyRow = (acts, text, y) => `
${diamond(7, 7, acts, 12)} ${esc(text)}
`;
+ const stop = `padding:4px 6px;border:1.5px solid ${LINE};border-radius:999px;background:#fff;font-size:12.5px;font-weight:600;color:${INK};white-space:nowrap`;
+ const own = `
${esc(W.own.label)}${esc(W.own.command)} `;
+ const stops = W.stops.map((s) => `
${esc(s)} `).join('') + own;
+ const base = L.Ht + 20, total = base + 196;
+ return page(`
+
${esc(H.title)}
+
+${frame(0, 0, HW, L.Ht, H.frame)}${frame(RX, 0, RW, L.Ht, H.repo_frame, true)}
+
${arrow} ${paths}
+${layerTitles}${[...H.cards, ...H.repo_cards].map(card).join('')}${L.badges.map(badge).join('')}${labels}
+${keyRow(true, H.key.acts, base)}${keyRow(false, H.key.exposed, base + 28)}
+
${esc(W.stops_title)}
+
${stops}
+
${esc(W.footer)}
+
`);
+};
diff --git a/docs/assurance-case.md b/docs/assurance-case.md
index 0c68ed96..c4000b52 100644
--- a/docs/assurance-case.md
+++ b/docs/assurance-case.md
@@ -26,7 +26,8 @@ discredits every honest number.
Boundaries: (1) the adopter repository (trusted content, versioned); (2) the agent
session (untrusted executor — it may ignore, misread, or attempt to modify guidance);
(3) the catalog (semi-trusted remote — executable content, trust-on-first-use, hash
-pinned); (4) CI (the enforcement floor — the one surface a local actor cannot bypass).
+pinned); (4) CI (the enforcement floor, and only where its check is a required status check the pull request cannot
+redefine — the repository's setting, which chock does not verify; see [the CI floor](floor.md)).
Threat classes defended against:
diff --git a/docs/cli-reference.md b/docs/cli-reference.md
index c8196d85..983049c8 100644
--- a/docs/cli-reference.md
+++ b/docs/cli-reference.md
@@ -162,12 +162,7 @@ frontmatter *is* its manifest; `new subagent` writes `subagent.yaml`. `new polic
chock compile
[--repo .] [--targets SURFACE ...] [--agents AGENT ...] [--policy-dir DIR] [--output-root DIR]
```
-Compiles one policy into the surfaces each target agent supports (git hook, CI gate,
-pre-tool-use, agent-hooks, managed-setting, `AGENTS.md` rule) and updates the per-agent
-coverage report. `--agents` takes the same comma- or space-separated names as `init`
-and `sync`, defaults to the repo's `supported_agents`, and rejects unknown names.
-`sync` runs this for every enabled policy; reach for `compile` directly only when
-iterating on a single policy's emitted output.
+Compiles one policy into the surfaces each target agent supports (git hook, CI gate, pre-tool-use, agent-hooks, `AGENTS.md` rule; nothing for `managed-setting`, which only `emit` writes) and updates the per-agent coverage report. `--agents` takes the same comma- or space-separated names as `init` and `sync`, defaults to the repo's `supported_agents`, and rejects unknown names. `sync` runs this for every enabled policy; reach for `compile` directly only when iterating on a single policy's emitted output.
### `install-skills` — refresh the bundled authoring skills
@@ -197,24 +192,9 @@ diffs the result to catch a stale registry. See [Registry & Lockfile](registry-a
chock plugin build [--repo .] [--policies-dir base] [--format agent-plugins|claude|copilot|cursor|codex|devin|all] [--out-dir DIST] [--policy ID ...] [--out PATH] [--check]
```
-Renders each policy as a plugin. The default `agent-plugins` format writes an
-[Agent Plugins 1.0.0](https://agent-plugins.org) package into each policy folder — additive,
-`manifest.yaml` stays the source of truth, and a packaged policy is `advisory` wherever it is
-read: v1 defines no enforcement semantics, so packaging changes no value in `coverage.json`.
-
-The five hook formats ship a byte-identical guard and adapter; since 0.11.0 the policy's own gate rides along too
-(`scripts/gate.json`, the stdlib runner, a script gate's `implementations/` tree), as does its `skill/` folder. Only
-the envelope differs. `claude` (`.claude-plugin/`, `PreToolUse` + `Stop`) is read natively by Claude Code, Copilot
-CLI, VS Code and Grok Build; `copilot` is the Agent Plugins 1.0 layout under `com.github.copilot/hooks/` (`Stop`);
-`cursor` (`.cursor-plugin/`) takes `beforeShellExecution` per guard and, per gate, `preToolUse` on the write plus
-`stop`; `codex` (`.codex-plugin/`, `PreToolUse` per guard, `Stop` per gate) reaches a hook engine no other package
-can, both failing **open** without `git`; `devin` (`.devin-plugin/plugin.json` + `hooks.json`, same two events)
-is best-effort by the vendor's own design, fail-open, not enforced. They require `--out-dir` (or `--out`); in-place output is
-refused so a policy folder is never mistaken for a published plugin. `--policies-dir` packages
-a published directory; `--check` judges without writing. `--policy ID` (repeatable; manifest
-`id` or directory name, else a named error) narrows the build and skips `--out-dir`
-stale-package cleanup. `--out PATH` (exactly one `--policy`) writes straight to `PATH` instead
-of `///`.
+Renders each policy as a plugin. The default `agent-plugins` format writes an [Agent Plugins 1.0.0](https://agent-plugins.org) package into each policy folder — additive, `manifest.yaml` stays the source of truth, and a packaged policy is `advisory` wherever it is read: v1 defines no enforcement semantics, so packaging changes no value in `coverage.json`.
+
+The five hook formats ship a byte-identical guard and adapter; since 0.11.0 the policy's own gate rides along too (`scripts/gate.json`, the stdlib runner, a script gate's `implementations/` tree), as does its `skill/` folder. Only the envelope differs. `claude` (`.claude-plugin/`, `PreToolUse` + `Stop`) is read natively by Claude Code, Copilot CLI, VS Code and Grok Build; `copilot` is the Agent Plugins 1.0 layout under `com.github.copilot/hooks/` (`Stop`); `cursor` (`.cursor-plugin/`) takes `beforeShellExecution` per guard and, per gate, `preToolUse` on the write plus `stop`; `codex` (`.codex-plugin/`, `PreToolUse` per guard, `Stop` per gate) reaches a hook engine no other package can, both failing **open** without `git`; `devin` (`.devin-plugin/plugin.json` + `hooks.json`, same two events) is best-effort by the vendor's own design, fail-open, not enforced. They require `--out-dir` (or `--out`); in-place output is refused so a policy folder is never mistaken for a published plugin. `--policies-dir` packages a published directory; `--check` judges without writing. `--policy ID` (repeatable; manifest `id` or directory name, else a named error) narrows the build and skips `--out-dir` stale-package cleanup. `--out PATH` (exactly one `--policy`) writes straight to `PATH` instead of `///`.
### `marketplace build` — index a built plugin tree
@@ -231,6 +211,14 @@ each built plugin, and needs `--url` (the marketplace repo's own git URL — nev
`git remote`). Entries derive from built manifests, never hand-listed; an empty tree exits 2;
`--check` reports drift without writing.
+### `emit` — write a managed-settings bundle for an admin
+
+```bash
+chock emit --managed claude_code --python --on-failure block|allow --out [--repo .] [--policies a,b] [--platform linux|macos|windows] [--deploy-root ] [--lock]
+```
+
+Writes, under `/claude_code/` only: `managed-settings.d/50-chock.json` (the selected policies' guards and gates as exec-form hooks), `bundle/` (each policy's runtime and guard or gate), `deploy.json` (where an administrator places each part, what each machine needs, what `--on-failure` does, the caveats, the undo step) and `labels.json`. It deploys nothing, elevates nothing, and refuses an `--out` that is a filesystem root or resolves into a system folder (the per-OS list in `src/chock/data/managed_channels.json`), names a file, or already holds `claude_code/`. `--python` is required: the absolute interpreter on the target machines, which every hook starts directly, so neither PATH nor git config picks it. `--on-failure` is required: `block` sets `onFailure: "block"` on the `PreToolUse` hooks and refuses a matched call when the interpreter or a bundle file is missing; `allow` sets neither and lets the call through with a note on stderr. `--lock` also emits `allowManagedHooksOnly`, which blocks every user, project and other-plugin hook on the machine (`deploy.json` lists every documented effect); `allowManagedPermissionRulesOnly` is never emitted. Every label is vendor-docs evidence, unwitnessed, at most best-effort; a local administrator can still edit or remove the file, and a machine that also receives server-managed or MDM policy skips it by default.
+
### `gateway run` -- the MCP gateway proxy
`chock gateway run --repo . -- ` wraps one downstream MCP server, refusing matching `tools/call` requests; fails closed (no proxy, no MCP).
diff --git a/docs/compare.md b/docs/compare.md
index f0af9e3a..1397ec75 100644
--- a/docs/compare.md
+++ b/docs/compare.md
@@ -9,7 +9,7 @@ The "Chock adds" column rests on: the git hook and CI gate ([Enforcement Surface
| Tool | What it is, per its own docs | Where it runs | Stronger than Chock at | Chock adds |
| :--- | :--- | :--- | :--- | :--- |
| Plain agent hooks ([Claude Code](https://code.claude.com/docs/en/hooks), [Cursor](https://cursor.com/docs/hooks)) | The host's own hook API | In the agent | Everything the host offers, with no layer between | One policy for many agents; a commit and CI floor; a coverage report |
-| Managed settings ([Claude Code](https://code.claude.com/docs/en/settings)) | Admin-deployed settings a user cannot override | In the agent, org-wide | Precedence: a user or project cannot override a managed key | Repo-level rules that travel with a clone; commit and CI gates |
+| Managed settings ([Claude Code](https://code.claude.com/docs/en/settings)) | Admin-deployed settings, applied above every other settings level | In the agent, org-wide | Precedence over a user's and a project's own settings files; a local administrator can still edit the managed file | Repo-level rules that travel with a clone; commit and CI gates |
| [Cupcake](https://github.com/eqtylab/cupcake) | Policy layer for AI agents, OPA Rego compiled to Wasm | In the agent | Richer in-session decisions, Rego, LLM-as-judge, MCP governance | Commit and CI gates; agents without hooks |
| [agentjail](https://github.com/LuD1161/agentjail) | Policy checks plus OS sandboxing | In the agent and the OS | An OS sandbox: Landlock, network control | Commit and CI gates; more agents |
| [Kastra](https://kastra.ai) | Authorization layer for AI actions | Cloud, self-hosted, air-gap, and on the laptop | Central allow/deny across prompts, tools, shell and APIs; signed audit trail | A local, repo-committed policy and commit and CI gates |
@@ -23,7 +23,7 @@ The "Chock adds" column rests on: the git hook and CI gate ([Enforcement Surface
- **Chock is not a security boundary.** Guards are pattern filters that quoting, aliases and encodings can evade; Chock is a governance layer, not a sandbox ([Assurance Case](assurance-case.md), [Baseline Policies](baseline-policies.md)).
- **Agents without hooks get advice in-session.** They read the compiled `AGENTS.md`; the rules are enforced at commit and in CI, not while the agent works ([Assurance Case](assurance-case.md), [Concepts](concepts.md#coverage-level)).
- **The commit gate can be skipped locally** (`--no-verify`); the CI gate is the backstop, and it holds only once it is a required status check ([Enforcement Surfaces](enforcement-surfaces.md)).
-- **Chock does not install managed settings.** It compiles a `managed-settings.json` that nothing reads ([Enforcement Surfaces](enforcement-surfaces.md)).
+- **Chock does not install managed settings.** `chock emit --managed claude_code` writes a drop-in file and the hook bundle it runs for an administrator to deploy; chock deploys nothing, and its labels are vendor-docs evidence, unwitnessed, best-effort ([CLI reference](cli-reference.md#emit--write-a-managed-settings-bundle-for-an-admin)).
- **MCP is thin.** A `tool_call` gate matches tool name and input text and does not understand what a tool does; the `mcp-gateway` credits no agent yet ([Agentic-Risk Coverage](agentic-risk-coverage.md), [Enforcement Surfaces](enforcement-surfaces.md)).
## Plain agent hooks
@@ -32,7 +32,7 @@ Claude Code hooks can allow, deny, ask, defer or rewrite a tool's input, and inc
## Managed settings
-In Claude Code nothing in a user's own settings files or `--settings` overrides a managed key, and managed settings arrive as a file, an MDM policy or server-managed settings ([settings](https://code.claude.com/docs/en/settings)). Cursor also has enterprise `hooks.json` paths and team hooks synced from a dashboard ([hooks](https://cursor.com/docs/hooks)). Where you control every machine, these are stronger than anything a repository can commit. Chock's rules live in the repo, so they reach contributors whose machines you do not manage ([Why](why.md)).
+In Claude Code the vendor documents that a user's own settings files and `--settings` do not override a managed key (a developer with administrator rights on the machine can still edit the managed file), and managed settings arrive as a file, an MDM policy or server-managed settings ([settings](https://code.claude.com/docs/en/settings)). Cursor also has enterprise `hooks.json` paths and team hooks synced from a dashboard ([hooks](https://cursor.com/docs/hooks)). Where you control every machine, these are stronger than anything a repository can commit. Chock's rules live in the repo, so they reach contributors whose machines you do not manage ([Why](why.md)).
## Cupcake
diff --git a/docs/coverage-levels.md b/docs/coverage-levels.md
index 4ffb9469..a7ff6d0d 100644
--- a/docs/coverage-levels.md
+++ b/docs/coverage-levels.md
@@ -85,7 +85,7 @@ number comparing them would invent a scale that does not exist.
> [Arming a fresh clone](adopting.md#arming-a-fresh-clone).
Example for `protect-main-branch`, whose gate declares `on: [commit, push]` and so targets
-git-hook + CI + ambient-rule + managed-setting, with no pre-tool surface at all. Every agent
+git-hook + CI + ambient-rule + managed-setting (for which the compiler writes nothing), with no pre-tool surface at all. Every agent
reaches the same grade, because the git hook is what earns it:
```json
diff --git a/docs/design/derive-from-vendor-config-map.md b/docs/design/derive-from-vendor-config-map.md
index b4c77838..e4600b83 100644
--- a/docs/design/derive-from-vendor-config-map.md
+++ b/docs/design/derive-from-vendor-config-map.md
@@ -31,7 +31,7 @@ Source-of-truth vocabulary:
| VS Code shell matcher `"bash\|powershell\|pwsh\|sh\|shell"` | `agent_hooks.py:11` | DA | vendor tool vocabulary; **gap**: agentseam's `vscode_copilot` records no `SHELL_TOOLS` today **[v]** — chock's witnessed matcher is the evidence D2 should ingest |
| interpreter-discovery bash/powershell templates | `agent_hooks.py:14-31` | CC | chock policy (find python, refuse silently-missing); the powershell variant should reuse agentseam `adapters/_windows.py` rather than a second copy |
| VS Code entry keys `type/matcher/timeout/timeoutSec/bash/command/powershell/windows` | `agent_hooks.py:45-54` | DA | `hook_entry` `entry_extra`; **divergence** — agentseam emits `{type, command, windows}` (`adapters/vscode_copilot.py:185-193`); see M.5(4) |
-| Claude managed-settings fragment schema | `claude_managed.py:14-40` | CC | claude-only surface, policy-conditional content; no config equivalent upstream |
+| Claude managed-settings fragment schema | `claude_managed.py` (removed in 1.2.0; `chock emit --managed` writes the drop-in, `emitters/managed/claude_code.py`) | CC | claude-only surface, policy-conditional content; no config equivalent upstream |
| `ambient` / `ci` / `git_hook` / `mcp_gateway` emitters | whole files | CC | agent-agnostic **[v]** (no vendor token in any of them) |
### M.2 `hooks/installers.py`, `hooks/*_install.py`
diff --git a/docs/enforcement-surfaces.md b/docs/enforcement-surfaces.md
index d820b2bb..af380fb1 100644
--- a/docs/enforcement-surfaces.md
+++ b/docs/enforcement-surfaces.md
@@ -88,8 +88,8 @@ each guarantee holds.
> nested repository, or a clone never synced) the command exits 2 the same way. Installed entries equal compiled ones exactly, so `chock sync` on any machine
> is a zero diff; entries in the old baked-interpreter form are recognised and replaced.
-**`git-hook` + `ci-gate` are the universal hard floor** every agent shares. `pre-tool-use` and
-`agent-hooks` are the premium tier on agents that expose native controls; membership
+**`git-hook` + `ci-gate` are the universal floor** every agent shares (`ci-gate` holds only as a required check the
+PR cannot redefine: [the CI floor](floor.md)). `pre-tool-use` and `agent-hooks` are the premium tier on agents that expose native controls; membership
derives from agentseam's matrix (see the coverage matrix below).
`gateway` is reserved for cost/egress controls on the roadmap. `mcp-gateway`
([#32](https://github.com/open-coder-ai/chock/issues/32)) governs exactly the MCP slice:
@@ -132,10 +132,10 @@ per gateway process; wrap N servers with N entries.
> clone is not bricked: the launcher finds one or refuses with a fix-it message. The guard
> covers shell commands (`beforeShellExecution`); other tool classes are not intercepted.
-> **`managed-setting` is compiled but not installed.** The compiler writes
-> `.chock/compiled//managed-setting/managed-settings.json` and nothing reads it — there is
-> no installer, so it enforces nothing today. It is excluded from `INSTALLED_SURFACES` in
-> `surfaces.py`, so no policy can raise a coverage claim through it. Read the row below as *what the
+> **`managed-setting` is neither compiled nor installed.** The compiler writes nothing for it; `chock emit --managed claude_code`
+> writes a drop-in and its hook bundle under a folder you name, for an administrator to deploy ([CLI reference](cli-reference.md#emit--write-a-managed-settings-bundle-for-an-admin)).
+> chock deploys nothing. It is excluded from `INSTALLED_SURFACES` in `surfaces.py`, so no policy can raise a coverage claim
+> through it, and the emitted labels are vendor-docs evidence, unwitnessed, best-effort. Read the row below as *what the
> agent could support*, not as something switched on.
> **`ci-gate` needs `chock sync --ci` to actually run.** The compiler always writes
@@ -195,7 +195,7 @@ evidence cap that bounds every grade -- is on its own page: **[Coverage Levels](
## How a policy picks its surfaces
A hook that must stop a command targets `git-hook` + `ci-gate` (the universal floor) and, where available,
-`pre-tool-use` + `managed-setting`. A hook whose `on:` includes `tool_use` is compiled to the `pre-tool-use`
+`pre-tool-use` (Claude Code's target list also names `managed-setting`, for which the compiler writes nothing). A hook whose `on:` includes `tool_use` is compiled to the `pre-tool-use`
surface on agents that support it (thirteen of them, Claude Code and Cursor among them; Copilot CLI and VS Code
get the same guard via `agent-hooks`, and a content gate's write check as a `PreToolUse` entry over `Edit|Write`
there). A hook whose `on:` includes `tool_call` (a `content_regex` or `script` gate with `params.tools`, globs
diff --git a/docs/floor.md b/docs/floor.md
new file mode 100644
index 00000000..088f1cc3
--- /dev/null
+++ b/docs/floor.md
@@ -0,0 +1,69 @@
+# The CI floor: `chock check --floor` (preview)
+
+`chock check --floor --base --head ` judges what a pull request will land, using the
+**base's** gates, run by this engine. It is a preview, and it holds only under the conditions below.
+
+## What it claims
+
+- **Judge what will land.** The base must be an ancestor of the head; pass GitHub's `refs/pull//merge`, or the
+ merge queue's head. Everything comes from the tree diff `base..head` (no renames, no external diff or textconv)
+ and from the commits in it. Every git call reads attributes from the base (`GIT_ATTR_SOURCE`, git 2.42 or newer),
+ so a `.gitattributes` the pull request adds changes nothing the floor sees.
+- **Control plane.** A change (add, edit, delete, mode) to a path on the list in
+ `src/chock/data/control_plane.json` is reported as `floor/control-plane-changed`, every path, one per line. A
+ path that a commit in the range changed, even if a later commit changed it back, is named too. These files
+ define the guardrails; the floor does not judge whether a change to them is safe. A person decides.
+- **Links.** Every symbolic link at, inside or above a control-plane path is resolved from the trees at base and
+ head, link by link. If it opens a path that is itself control plane, or nothing, the run carries on, and each
+ link passed on the way is control plane too. Otherwise the run is undecided (exit 2), naming the link and its
+ target. So is a loop, an absolute target, a target outside the repository, or one that passes through a
+ submodule. The fix: put the target on `floor.control_plane_paths.add` in the base's config, or replace the link
+ with real files. A link above a control-plane path (`pkg -> real`, with `real/.claude/`) carries on when every
+ control-plane path under it opens a control-plane path, and the link is then control plane too. A base whose
+ `.chock` is a link or a submodule is undecided too.
+- **Everything else** is judged by the base's compiled ci gates and rollout. No file from the head executes.
+ `ask` refuses. A gate that crashes, times out or cannot be read is undecided, whatever the rollout. A waiver
+ counts only on a line present and unchanged in both base and head.
+- **History.** The base's content gates read every blob a commit in the range adds or changes outside the control
+ plane.
+- **Exit codes:** 0 clean, 1 refused, 2 undecided. `--sarif ` writes a log on every run, with
+ `executionSuccessful: false` when the run is undecided.
+
+## Configuration (the base's `.chock/config.yaml`; the head's is never read)
+
+```yaml
+floor:
+ control_plane: refuse # default: exit 1 on any listed path. `listed`: exit 0, paths still listed
+ control_plane_paths:
+ add: [infra/] # `name/` or `name/**` is the folder and all in it; a bare folder name is exit 2
+ remove: ["**/.env"] # must name a default pattern exactly, or the run is exit 2
+```
+
+Each run prints the mode, the number of patterns and the base's additions and removals. An added entry that
+matches no path at base or head is marked as matching nothing.
+
+## Conditions and limits
+
+- **A required status check the pull request cannot redefine.** The floor holds only as one. That is the
+ repository's own setting, and chock does not verify it.
+- **Committed content only.**
+- **Under `refuse`,** every guardrail change needs a privileged merge: a policy upgrade, a `chock sync`
+ regeneration or a workflow edit.
+- **Under `listed`,** you rely on code-owner review of the listed paths. The content inside them is not judged.
+- **The list is what chock knows about,** not a proof of completeness. If your workflow installs chock from a file
+ in the repository (`requirements*.txt`, `pyproject.toml`, a lockfile, a local action), add that file to the
+ list.
+- **Renames.** Renaming or moving a test file reads as a deletion, and test-integrity refuses it.
+
+## Not covered
+
+- **Windows short names.** The 8.3 alias of a listed folder (`CLAUDE~1/...` for `.claude/`) is not matched. This
+ is untested on Windows.
+- **`*.code-workspace` files.** They are not on the list: it is not verified that an editor honours hook settings
+ from one.
+- **Submodule content.** Only the pointer is seen. A pointer at or inside a control-plane folder is listed, but a
+ submodule's own agent folders are not read.
+- **What the history pass does not see:** other encodings (utf-32, compressed or encoded content), commit
+ messages and file names.
+- **Back-merges.** A path is named from history when a commit leaves it in a state the base does not have. A
+ branch that merged an older base, from before a later change to that path, is named for it.
diff --git a/docs/quickstart.sh b/docs/quickstart.sh
index 27cb1407..a3b7b4fc 100755
--- a/docs/quickstart.sh
+++ b/docs/quickstart.sh
@@ -8,5 +8,5 @@ pip install chock==1.1.0
git init -q demo && cd demo
chock init . # wiring only, no policies
-chock add scan-secrets --ref 1e60d211c1bb767152c6ab0167932da06ab3a10f --verify-sha c7cf363c6eb8a8ed47287beef9c06fe76dfd2d9c0ccc203fe74e32fba0e92a94 --skip-compile
+chock add scan-secrets --skip-compile
chock sync --repo . --ci # compile, install hooks, add the CI gate
diff --git a/spec/gate-dsl.md b/spec/gate-dsl.md
index 8238017f..1936c562 100644
--- a/spec/gate-dsl.md
+++ b/spec/gate-dsl.md
@@ -227,7 +227,7 @@ script lives beside this gate file" instead of "under the repository root". Only
plugin writes it: there the gate, the runner and the script travel together and no repository
holds them.
-`event` is `commit`, `push`, `tool_use` or (see above) `tool_call`. `session` is present only at the agent events. `writes` is the staged blobs at `commit` and
+Script payload contract **v2** (v1 was unnumbered; v2 adds `ci-floor`, from `chock check --floor`, and nothing elsewhere). `event` is `commit`, `push`, `tool_use`, `ci-floor` or (see above) `tool_call`. `session` is present only at the agent events. At `ci-floor` the payload adds `deleted` (sorted deleted paths; a deletion-only range still runs the script), the environment is only `PATH`, `HOME`, `SYSTEMROOT`, the script is the base's copy, a waiver counts only on a line unchanged in base and head, and `ask` refuses. `writes` is the staged blobs at `commit` and
`push`, and the write itself at `tool_use` -- the file a tool call is about to write, or what
the turn left on disk at its end -- so one script serves every surface, and it reaches the
write path and the turn's end exactly as `content_regex` does. The script answers with its
@@ -258,7 +258,8 @@ introduces:
are for display. An optional `"new": true` makes the finding count as new whatever the
baseline holds, for a script that already compared with HEAD itself. An optional `rule` (string,
`[A-Za-z0-9][A-Za-z0-9 ._:/-]{0,63}`) names the rule for the gate log; a missing or malformed
- `rule` is ignored and never invalidates the document.
+ `rule` is ignored and never invalidates the document. An optional `tier` (`block`, `ask` or `warn`)
+ is the verdict this finding warrants (see Verdict); any other value is ignored.
- A document is valid only when `findings` is a list of objects each carrying string `key`, `path`
and `message`, an integer `line`, and a boolean `new` if present. Anything else on stdout is not
a document, and the script keeps the exit-code contract above exactly (one run).
@@ -271,29 +272,28 @@ introduces:
- **New findings.** Per `path`, each baseline finding cancels one change-run finding with the
same `key`, so a finding is new when its key occurs more often in the change-run than in the
baseline; a second copy of an old violation is new.
-- **Verdict.** No new findings allows, whatever the change-run's exit code. Otherwise the
- change-run's exit code decides (`1` blocks, `3` asks, `4` warns, capped by the declared
- `action`; exit `0` allows; any other code is undecided as above), and the reason lists only the
- new findings as `path:line: message`, not the script's stderr.
+- **Verdict.** No new findings allows, whatever the change-run's exit code. Otherwise, when every new
+ finding carries a `tier`, the highest (`block` over `ask` over `warn`) decides, so an old block-tier
+ finding cannot turn a new ask-tier one into a block; if any lacks one, the change-run's exit code
+ decides (codes as above). The declared `action` caps either; the reason lists only the new
+ findings as `path:line: message`, not the script's stderr. No `tier` anywhere: exactly as before.
- **Baseline text** is the file before the change: `commit`, HEAD; `push` and `ci`, the base of
the range; `tool_use` before the write (PreToolUse), the file on disk, and at the turn's end
(Stop), HEAD. A write outside the repository has the file on disk before the write, or no
baseline when absent. HEAD is read from `repo_root` (`git show HEAD:./`), which may sit
below the git top-level.
+- **A rename's baseline** (a path git reports as renamed, `-M`) is its old content under its OLD path, mapped back to the new path: a finding whose `key` names the new path is new.
- **Baseline failure** (crash, timeout, non-zero exit without a document, non-JSON stdout, no
- git, no HEAD) leaves the baseline findings empty, which errs toward blocking.
-- **Budget.** Both runs share the 30s timeout; the baseline run gets what the change-run left.
+ git, no HEAD) leaves the baseline findings empty, which errs toward blocking. Both runs share the 30s timeout; the baseline run gets what the change-run left.
- The gate log records `new_findings`, `baseline_findings` and, per declared `rule`, `rules`
- (rule to count of new findings). `tool_call` scripts and the
- `hook.script` event scripts are unchanged.
+ (rule to count of new findings). `tool_call` scripts and the `hook.script` event scripts are unchanged.
`chock compile` rewrites `script` to the file's path from the repository root, which is all
the runner has; the ambient line an agent reads keeps the bare name, so the packaged `SKILL.md`
is the same wherever the policy sits. `chock check` refuses a name that is not a bare `.py` file
name, and a script the policy does not ship. The script is deterministic code under
-`implementations/`, so SEC-2 applies to it as to any guard, and `chock check --only evals`
-copies that directory into the throwaway repository a staged-files case is replayed in, where
-the compiled gate names it.
+`implementations/`, so SEC-2 applies to it, and `chock check --only evals` copies that directory
+into the throwaway repository a staged-files case is replayed in, where the compiled gate names it.
## Runtime note
diff --git a/src/chock/cli.py b/src/chock/cli.py
index a77eaf3d..61ad12cc 100644
--- a/src/chock/cli.py
+++ b/src/chock/cli.py
@@ -11,6 +11,7 @@
from pathlib import Path
from chock import __version__
+from chock.output import new_command
from chock.pipe import guard_stdout, silence_interpreter_flush
from chock.resources import package_data_dir
from chock.stop_common import committed_refused, person_only_refused
@@ -97,6 +98,7 @@ def _is_sole_flag_form(command: str, argv: list[str]) -> bool:
def main(argv: list[str] | None = None) -> int:
writer = guard_stdout()
+ new_command()
try:
return _dispatch(list(sys.argv[1:] if argv is None else argv))
finally:
diff --git a/src/chock/compile/compiler.py b/src/chock/compile/compiler.py
index 8f47fdb7..b214c8eb 100644
--- a/src/chock/compile/compiler.py
+++ b/src/chock/compile/compiler.py
@@ -16,7 +16,6 @@
from chock.compile.emitters import (
ambient,
ci,
- claude_managed,
git_hook,
in_agent,
mcp_gateway,
@@ -31,8 +30,8 @@
)
from chock.config import agents_from_config
from chock.hooks.in_agent_install import WIRED_VENDORS, installed_policy_ids
-from chock.manifest import ManifestSourceError, load_manifest
-from chock.output import error, warn
+from chock.manifest import ManifestSourceError, load_manifest, warn_defaults
+from chock.output import error
from chock.policy_id import InvalidPolicyIdError, validate_policy_id
from chock.scaffold.install_ci import ci_workflow_installed
from chock.vendors import CHOCK_AGENT
@@ -44,7 +43,6 @@
Surface.CI_GATE: ci,
Surface.PRE_TOOL_USE: in_agent.pre_tool_use,
Surface.STOP: in_agent.stop,
- Surface.MANAGED_SETTING: claude_managed,
Surface.AMBIENT_RULE: ambient,
Surface.MCP_GATEWAY: mcp_gateway,
Surface.AGENT_HOOKS: in_agent.agent_hooks,
@@ -73,9 +71,8 @@ def _load_manifest(policy_dir: Path) -> dict[str, Any]:
return {}
if result is None:
return {}
- data, _ = result
- for warning in warnings:
- warn(f"{policy_dir}: manifest_default: {warning}")
+ data, manifest_path = result
+ warn_defaults(manifest_path, warnings)
return data
diff --git a/src/chock/compile/emitters/claude_managed.py b/src/chock/compile/emitters/claude_managed.py
deleted file mode 100644
index 69f8000e..00000000
--- a/src/chock/compile/emitters/claude_managed.py
+++ /dev/null
@@ -1,40 +0,0 @@
-"""Emit Claude managed-settings.json fragments for a policy."""
-
-from __future__ import annotations
-
-from pathlib import Path
-from typing import Any
-
-from chock.emit import write_generated_json
-
-
-def emit(policy_dir: Path, output_dir: Path, manifest: dict[str, Any]) -> list[Path]:
- """Write a managed-settings.json fragment reflecting the policy's controls."""
- policy_id = manifest.get("id", policy_dir.name)
- fragments: dict[str, Any] = {"deny": [], "ask": []}
-
- if policy_id == "scan-secrets":
- fragments["deny"].append(
- {
- "type": "file",
- "pattern": "\\.(env|pem|key|p12|pfx|jks|keystore)$",
- "message": "Credential files are denied in the workspace.",
- }
- )
- fragments["deny"].append(
- {
- "type": "text",
- "pattern": (
- "(?i)(AKIA[0-9A-Z]{16}|ghp_[a-zA-Z0-9]{36}|xox[bpas]-[0-9A-Za-z-]{10,}"
- "|(sk|rk)_live_[0-9A-Za-z]{16,}|sk-ant-[0-9A-Za-z_-]{20,}|AIza[0-9A-Za-z_-]{35}"
- "|npm_[0-9A-Za-z]{36}|eyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]*"
- "|-----BEGIN .* PRIVATE KEY-----)"
- ),
- "message": "Credential-like values are denied in generated or edited files.",
- }
- )
-
- output_dir.mkdir(parents=True, exist_ok=True)
- dest = output_dir / "managed-settings.json"
- write_generated_json(dest, fragments)
- return [dest]
diff --git a/src/chock/compile/emitters/data/managed_bootstrap.txt b/src/chock/compile/emitters/data/managed_bootstrap.txt
new file mode 100644
index 00000000..33b46bbb
--- /dev/null
+++ b/src/chock/compile/emitters/data/managed_bootstrap.txt
@@ -0,0 +1 @@
+import sys,os;r=sys.argv[1];m=[p for p in (r,*(os.path.join(os.path.dirname(r),*f.split('/')) for f in __NEEDED__)) if not os.path.isfile(p)];o=sys.version_info<(__MIN_PYTHON__,);w='chock: '+('this hook needs Python __MIN_PYTHON_TEXT__+, '+sys.executable+' is older' if o else 'missing '+', '.join(m))+'; __OUTCOME__\n';(o or m) and (sys.stderr.write(w),sys.exit(__EXIT__));sys.argv=sys.argv[1:];import runpy;runpy.run_path(r,run_name='__main__')
diff --git a/src/chock/compile/emitters/managed/__init__.py b/src/chock/compile/emitters/managed/__init__.py
new file mode 100644
index 00000000..ff65f056
--- /dev/null
+++ b/src/chock/compile/emitters/managed/__init__.py
@@ -0,0 +1,184 @@
+"""Managed emit: a vendor's admin-deployed hook file and the bundle it runs, written only under `--out`."""
+
+from __future__ import annotations
+
+import json
+import os
+import posixpath
+import re
+import sys
+from pathlib import Path, PurePosixPath
+from typing import Any
+
+from agentseam import matrix_terms
+
+from chock import evidence
+from chock.compile.levels import Grade, capped, in_agent_level, render_grade
+from chock.compile.surface_kinds import Surface
+from chock.emit import write_generated
+from chock.resources import package_data_dir
+
+CHANNELS: dict[str, Any] = json.loads(
+ package_data_dir("chock", "data").joinpath("managed_channels.json").read_text(encoding="utf-8")
+)
+PLATFORMS = tuple(CHANNELS["system_roots"])
+VENDORS = tuple(CHANNELS["vendors"])
+#: Every managed label rests on the vendor's own docs until a `managed` witness row says otherwise.
+BASIS = matrix_terms.BASIS_DOCS
+WINDOWS = "windows"
+MACOS = "macos"
+_WINDOWS_ROOT = re.compile(r"[A-Za-z]:/[^/].*")
+#: `//host/c$/...`, an administrative share of a drive.
+_ADMIN_SHARE = re.compile(r"^//[^/]+/([a-z])\$(?=/|$)", re.I)
+#: `\\?\` and `\\.\` device prefixes, and their UNC form, in forward-slash spelling.
+_DEVICE_UNC = re.compile(r"^//[?.]/unc/", re.I)
+_DEVICE = re.compile(r"^//[?.]/")
+_DRIVE_ROOT = re.compile(r"[a-z]:/?")
+_CONTROL = re.compile(r"[\r\n\0]")
+#: Windows system folders that may sit on another drive than C:.
+_WINDOWS_ENV_ROOTS = ("ProgramFiles", "ProgramFiles(x86)", "ProgramData", "SystemRoot")
+
+Files = dict[PurePosixPath, str]
+
+
+class EmitRefusedError(ValueError):
+ """The command would write somewhere it must not, or has nothing true to write."""
+
+
+def facts(vendor: str) -> dict[str, Any]:
+ """`vendor`'s managed-channel facts, as read from its docs on the recorded date."""
+ return CHANNELS["vendors"][vendor]
+
+
+def host_platform() -> str:
+ """This machine's platform, in the data file's words."""
+ if sys.platform == "win32":
+ return WINDOWS
+ return MACOS if sys.platform == "darwin" else "linux"
+
+
+def _system_roots(platform: str) -> list[str]:
+ roots = list(CHANNELS["system_roots"][platform])
+ if platform == WINDOWS:
+ roots += [os.environ[name].replace("\\", "/") for name in _WINDOWS_ENV_ROOTS if os.environ.get(name)]
+ return roots
+
+
+def spelled(text: str, platform: str) -> str:
+ """`text` in one comparable spelling: Windows device and admin-share prefixes removed, case folded where the OS ignores it."""
+ if platform != WINDOWS:
+ text = re.sub(r"^/+", "/", text)
+ return text.casefold() if platform == MACOS else text
+ text = text.replace("\\", "/")
+ text = _DEVICE_UNC.sub("//", text)
+ text = _DEVICE.sub("", text)
+ text = _ADMIN_SHARE.sub(lambda m: f"{m.group(1)}:/", text)
+ return re.sub(r"/+", "/", text).casefold()
+
+
+def _inside(text: str, root: str) -> bool:
+ base = root.rstrip("/")
+ if not base or _DRIVE_ROOT.fullmatch(base): # a filesystem root holds everything: refuse it alone
+ return text.rstrip("/") == base
+ return text == base or text.startswith(f"{base}/")
+
+
+def root_named(text: str, platform: str) -> str | None:
+ """The system path the absolute, resolved `text` names or sits inside, on `platform`, else None."""
+ text = spelled(text, platform)
+ if platform == WINDOWS and _DRIVE_ROOT.fullmatch(text):
+ return text
+ return next((root for root in _system_roots(platform) if _inside(text, spelled(root, platform))), None)
+
+
+def system_root_of(path: Path, platform: str | None = None) -> str | None:
+ """The system path `path` resolves inside (symlinks followed), else None."""
+ return root_named(Path(path).resolve().as_posix(), platform or host_platform())
+
+
+def vendor_out(out: Path, vendor: str) -> Path:
+ """`/`, refused when `out` resolves into a system path, is not a folder, or the folder already exists."""
+ root = system_root_of(out)
+ if root is not None:
+ msg = (
+ f"--out {out} resolves to or inside the system path {root}; chock emit writes only to a folder you "
+ "deploy from, never to where a client reads it"
+ )
+ raise EmitRefusedError(msg)
+ if os.path.lexists(out) and not Path(out).is_dir():
+ msg = f"--out {out} is not a folder"
+ raise EmitRefusedError(msg)
+ dest = Path(out).resolve() / vendor
+ if os.path.lexists(dest):
+ msg = f"{dest} already exists; give a new --out or remove that folder first"
+ raise EmitRefusedError(msg)
+ return dest
+
+
+def _absolute(text: str, platform: str) -> str | None:
+ """`text` as a normalised absolute `platform` path in forward slashes, else None; a line break or NUL is refused."""
+ path = (text.replace("\\", "/") if platform == WINDOWS else text).rstrip("/")
+ absolute = _WINDOWS_ROOT.fullmatch(path) if platform == WINDOWS else len(path) > 1 and path.startswith("/")
+ if not absolute or _CONTROL.search(path):
+ return None
+ return posixpath.normpath(path) if platform != WINDOWS else path[:2] + posixpath.normpath(path[2:])
+
+
+def deploy_root(text: str, platform: str) -> str:
+ """The absolute folder the admin will copy the bundle to, normalised, in forward-slash form."""
+ root = _absolute(text, platform)
+ if root is None:
+ msg = f"--deploy-root {text!r} must be an absolute {platform} folder with no line break"
+ raise EmitRefusedError(msg)
+ return root
+
+
+def interpreter(text: str, platform: str) -> str:
+ """The absolute Python the hooks start on `platform`; nothing on PATH or in git config is consulted."""
+ path = _absolute(text, platform)
+ if path is None:
+ msg = (
+ f"--python {text!r} must be the absolute path of the Python 3.11+ interpreter on the target {platform} "
+ "machines: a managed hook must not take its interpreter from the user's PATH or git config"
+ )
+ raise EmitRefusedError(msg)
+ return path
+
+
+def write_tree(dest: Path, files: Files) -> list[Path]:
+ """Write `files` under the new folder `dest`, refusing any path that would leave it."""
+ dest.mkdir(parents=True)
+ top = dest.resolve()
+ written = []
+ for rel, text in sorted(files.items()):
+ path = dest.joinpath(*rel.parts)
+ if rel.is_absolute() or ".." in rel.parts:
+ msg = f"{rel} is not a path inside {dest}"
+ raise EmitRefusedError(msg)
+ path.parent.mkdir(parents=True, exist_ok=True)
+ if path.is_symlink() or not path.parent.resolve().is_relative_to(top):
+ msg = f"{path} would be written outside {dest}"
+ raise EmitRefusedError(msg)
+ write_generated(path, text)
+ written.append(path)
+ return written
+
+
+def label(policy_id: str, vendor: str, agent: str, halves: list[str]) -> dict[str, Any]:
+ """One (policy, vendor) cell: the in-agent word capped by vendor-docs evidence, with chock's own witness."""
+ level = capped(in_agent_level(agent), [BASIS])
+ grade = Grade(level, BASIS, witnessed=evidence.witness(vendor, evidence.MANAGED) is not None)
+ return {
+ "policy": policy_id,
+ "vendor": vendor,
+ "surface": Surface.MANAGED_SETTING.value,
+ "halves": halves,
+ "level": grade.level,
+ "basis": grade.basis,
+ "witnessed": grade.witnessed,
+ "label": render_grade(grade),
+ }
+
+
+def as_json(data: Any) -> str:
+ return json.dumps(data, indent=2) + "\n"
diff --git a/src/chock/compile/emitters/managed/claude_code.py b/src/chock/compile/emitters/managed/claude_code.py
new file mode 100644
index 00000000..423d517a
--- /dev/null
+++ b/src/chock/compile/emitters/managed/claude_code.py
@@ -0,0 +1,180 @@
+"""Claude Code's managed drop-in: the plugin route's hooks in exec form, run by the admin's interpreter from an absolute deploy folder."""
+
+from __future__ import annotations
+
+import json
+import shlex
+from pathlib import Path, PurePosixPath
+from typing import Any
+
+from agentseam import packaging
+
+from chock.compile.emitters import managed
+from chock.hooks import launch
+from chock.hooks.stop_check import STOP_CHECK_FLAG
+from chock.plugin.claude import claude_plugin_files
+from chock.plugin.multi_plugin import SCRIPTS_DIR
+from chock.resources import package_data_dir
+
+VENDOR = "claude_code"
+AGENT = "claude"
+BUNDLE = "bundle"
+_HOOKS_REL = Path(packaging.supports(VENDOR, packaging.HOOKS))
+#: The plugin-root token the plugin route's commands carry, swapped for the deploy folder.
+ROOT_TOKEN = str(packaging.executable_ref(VENDOR, "x")).removesuffix("/x")
+#: What every plugin-route command starts with: its sh launcher, which the managed file never runs.
+_PLUGIN_PREFIX = launch.plugin_interpreter(f"{ROOT_TOKEN}/{SCRIPTS_DIR}/{launch.PLUGIN_LAUNCHER}") + " "
+_FACTS = managed.facts(VENDOR)
+_FAIL = _FACTS["fail_block"]
+#: --on-failure choices; `block` refuses what cannot be checked, `allow` lets it through with a note.
+BLOCK, ALLOW = "block", "allow"
+ON_FAILURE = (BLOCK, ALLOW)
+_OUTCOME = {
+ BLOCK: ("refusing this call (--on-failure block)", 2),
+ ALLOW: ("this call goes ahead unchecked (--on-failure allow)", 0),
+}
+_BOOTSTRAP = (
+ package_data_dir("chock", "compile", "emitters", "data")
+ .joinpath("managed_bootstrap.txt")
+ .read_text(encoding="utf-8")
+ .strip()
+ .replace("__MIN_PYTHON_TEXT__", ".".join(map(str, launch.MIN_PYTHON)))
+ .replace("__MIN_PYTHON__", ", ".join(map(str, launch.MIN_PYTHON)))
+)
+#: The halves a plugin hook runs, by the flag its argv carries.
+_HALF_FLAGS = {"guard": "--guard", "gate": "--gate"}
+
+
+def bootstrap(on_failure: str, needed: tuple[str, ...] = ()) -> str:
+ """The `-c` program that starts a bundled runtime, or, when it, a `needed` file beside it (relative, `/`-separated)
+ or Python 3.11+ is missing, says so and exits per `on_failure`."""
+ outcome, code = _OUTCOME[on_failure]
+ return _BOOTSTRAP.replace("__OUTCOME__", outcome).replace("__EXIT__", str(code)).replace("__NEEDED__", repr(needed))
+
+
+def _argv(command: str) -> list[str]:
+ """The runtime path and flags of a plugin-route command, its sh launcher prefix dropped."""
+ if not command.startswith(_PLUGIN_PREFIX):
+ msg = f"{command!r} does not start with the plugin launcher this emitter replaces"
+ raise managed.EmitRefusedError(msg)
+ return shlex.split(command.removeprefix(_PLUGIN_PREFIX))
+
+
+def _exec_hook(hook: dict[str, Any], event: str, root: str, options: dict[str, Any]) -> dict[str, Any]:
+ """`hook` in exec form: `python` runs the bootstrap on the runtime rooted at `root`; onFailure only where it acts.
+
+ `options`: python, on_failure, needed (every bundled file beside the runtime, which the bootstrap checks)."""
+ python, on_failure = options["python"], options["on_failure"]
+ argv = [arg.replace(ROOT_TOKEN, root) for arg in _argv(hook["command"])]
+ if any("${" in arg for arg in argv):
+ msg = f"{argv!r} still names a client token after rooting it at {root}"
+ raise managed.EmitRefusedError(msg)
+ blocks = on_failure == BLOCK and event in _FAIL["events"]
+ entry = {
+ "type": hook["type"],
+ "command": python,
+ "args": [*_FACTS["python_flags"], bootstrap(on_failure if blocks else ALLOW, options["needed"]), *argv],
+ }
+ entry.update({key: value for key, value in hook.items() if key not in {"type", "command"}})
+ if blocks:
+ entry[_FAIL["key"]] = _FAIL["value"]
+ return entry
+
+
+def _is_stop_check(group: dict[str, Any]) -> bool:
+ return all(hook["command"].endswith(f" {STOP_CHECK_FLAG}") for hook in group["hooks"])
+
+
+def _policy_parts(policy_dir: Path, manifest: dict[str, Any], repo_root: Path) -> tuple[dict[str, Any], dict] | None:
+ """The plugin route's hooks and scripts for one policy, or None when it runs nothing; its sh launcher is left out."""
+ files = claude_plugin_files(policy_dir, manifest, repo_root, folded=False)
+ if _HOOKS_REL not in files:
+ return None
+ scripts = {
+ PurePosixPath(rel.as_posix()): text
+ for rel, text in files.items()
+ if rel.parts[0] == SCRIPTS_DIR and rel.name != launch.PLUGIN_LAUNCHER
+ }
+ return json.loads(files[_HOOKS_REL])["hooks"], scripts
+
+
+def build(
+ policies: list[tuple[str, Path, dict[str, Any]]], repo_root: Path, options: dict[str, Any]
+) -> tuple[managed.Files, list[dict[str, Any]], list[str]]:
+ """(files under `/claude_code`, one label per emitted policy, the policies with nothing to run).
+
+ `options`: root (deploy folder), python (absolute interpreter), on_failure, lock. The repo stop's matcher-less
+ stop check is never emitted: no policy needs it, and it would run on every tool call.
+ """
+ events: dict[str, list[dict[str, Any]]] = {}
+ files: managed.Files = {}
+ labels, skipped = [], []
+ for policy_id, policy_dir, manifest in policies:
+ parts = _policy_parts(policy_dir, manifest, repo_root)
+ if parts is None:
+ skipped.append(policy_id)
+ continue
+ hooks, scripts = parts
+ flags = set()
+ needed = tuple(sorted(rel.relative_to(SCRIPTS_DIR).as_posix() for rel in scripts))
+ hook_options = {**options, "needed": needed}
+ for event, groups in hooks.items():
+ for group in (group for group in groups if not _is_stop_check(group)):
+ rooted = [
+ _exec_hook(hook, event, f"{options['root']}/{policy_id}", hook_options) for hook in group["hooks"]
+ ]
+ events.setdefault(event, []).append({**group, "hooks": rooted})
+ flags.update(arg for hook in rooted for arg in hook["args"])
+ for rel, text in scripts.items():
+ files[PurePosixPath(BUNDLE, policy_id, rel)] = text
+ labels.append(
+ managed.label(policy_id, VENDOR, AGENT, [half for half, flag in _HALF_FLAGS.items() if flag in flags])
+ )
+ document: dict[str, Any] = {"hooks": events}
+ if options["lock"]:
+ document[_FACTS["lock_key"]] = True
+ files[PurePosixPath(_FACTS["drop_in"])] = managed.as_json(document)
+ return files, labels, skipped
+
+
+def matchers(document: dict[str, Any]) -> list[str]:
+ """The tool matchers of the emitted pre-tool groups, in order, each once."""
+ found = (group.get("matcher") for group in document["hooks"].get("PreToolUse", []))
+ return list(dict.fromkeys(matcher for matcher in found if matcher))
+
+
+def deploy_plan(platform: str, options: dict[str, Any], tools: list[str]) -> dict[str, Any]:
+ """Where an admin places each part, what it needs, what the failure choice does, what it does not promise, and the undo."""
+ root, python, lock = options["root"], options["python"], options["lock"]
+ admin = _FACTS["admin_dir"][platform]
+ place = [
+ {"from": _FACTS["drop_in"], "to": f"{admin}/{_FACTS['drop_in']}"},
+ {"from": f"{BUNDLE}/", "to": f"{root}/"},
+ ]
+ consequence = (
+ _FACTS["on_failure"][options["on_failure"]]
+ .replace("__PYTHON__", python)
+ .replace("__MATCHERS__", ", ".join(tools))
+ )
+ plan: dict[str, Any] = {
+ "vendor": VENDOR,
+ "platform": platform,
+ "deployed": False,
+ "basis": managed.BASIS,
+ "python": python,
+ "on_failure": {"choice": options["on_failure"], "consequence": consequence},
+ "place": place,
+ "undo": [f"delete {step['to']}" for step in place],
+ "requirements": [line.replace("__PYTHON__", python) for line in _FACTS["requirements"]],
+ "caveats": _FACTS["caveats"],
+ "stop_files": _FACTS["stop_files"],
+ "client_versions": _FACTS["client_versions"],
+ "not_covered": _FACTS["not_covered"],
+ "never_emitted": _FACTS["never_emitted"],
+ "notes": [_FACTS["never_note"], *([_FACTS["lock_note"]] if lock else [])],
+ "sources": _FACTS["sources"],
+ "read": _FACTS["read"],
+ }
+ if lock:
+ plan["lock_key"] = _FACTS["lock_key"]
+ return plan
diff --git a/src/chock/compile/emitters/managed/cli.py b/src/chock/compile/emitters/managed/cli.py
new file mode 100644
index 00000000..c827cafd
--- /dev/null
+++ b/src/chock/compile/emitters/managed/cli.py
@@ -0,0 +1,169 @@
+"""`chock emit --managed --out `: write a managed-settings bundle for an admin to deploy; deploy nothing."""
+
+from __future__ import annotations
+
+import argparse
+import json
+import sys
+from pathlib import Path, PurePosixPath
+from typing import Any
+
+from chock.compile.emitters import managed
+from chock.compile.emitters.managed import claude_code
+from chock.config import load_config, policy_status
+from chock.manifest import load_manifest, warn_defaults
+from chock.output import error, legible
+from chock.policies import discover_policy_dirs
+from chock.policy_id import InvalidPolicyIdError, validate_policy_id
+
+BUILDERS = {claude_code.VENDOR: claude_code}
+DEPLOY_FILE = "deploy.json"
+LABELS_FILE = "labels.json"
+
+
+def _parser() -> argparse.ArgumentParser:
+ parser = argparse.ArgumentParser(
+ prog="chock emit",
+ description=(
+ "Write one vendor's managed-settings file, the self-contained hook bundle it runs, deploy.json "
+ "(where an admin places each part, what it needs, what --on-failure does, how to undo it) and "
+ "labels.json, all under --out. It refuses an --out that is a filesystem root or resolves into a "
+ "system folder (per OS: /etc, /usr, /var, /Library, C:/Program Files, C:/Windows and the others in "
+ "chock's managed_channels.json); it elevates nothing and deploys nothing. Every label is vendor-docs "
+ "evidence, unwitnessed, at most best-effort; a local administrator can still edit or remove the file."
+ ),
+ )
+ parser.add_argument("--managed", required=True, choices=managed.VENDORS, help="the vendor to emit for")
+ parser.add_argument(
+ "--out", required=True, type=Path, help="a folder outside any system path; // must not exist"
+ )
+ parser.add_argument(
+ "--repo", type=Path, default=Path(), help="the repository whose policies are emitted (default: .)"
+ )
+ parser.add_argument(
+ "--policies",
+ help="comma-separated policy ids, named ones emitted even if the config disables them "
+ "(default: every enabled policy with a guard or gate)",
+ )
+ parser.add_argument(
+ "--python",
+ required=True,
+ help="absolute path of the Python 3.11+ interpreter on the target machines; the hooks start it directly",
+ )
+ parser.add_argument(
+ "--on-failure",
+ required=True,
+ choices=claude_code.ON_FAILURE,
+ help="when the hook cannot run (no interpreter, a missing bundle file, a crash or timeout): block refuses "
+ "the matched tool call, allow lets it through with a note",
+ )
+ parser.add_argument("--platform", choices=managed.PLATFORMS, help="the OS the file is for (default: this one)")
+ parser.add_argument(
+ "--deploy-root",
+ help="absolute folder the admin copies bundle/ to (default: the vendor's admin folder + /chock)",
+ )
+ parser.add_argument(
+ "--lock",
+ action="store_true",
+ help="also emit the vendor's managed-hooks-only key, which stops every user, project and plugin hook on the machine",
+ )
+ return parser
+
+
+def _manifest(policy_dir: Path) -> dict[str, Any]:
+ warnings: list[str] = []
+ try:
+ result = load_manifest(policy_dir, warnings=warnings)
+ except UnicodeDecodeError as exc:
+ raise managed.EmitRefusedError(_not_utf8(policy_dir, exc)) from exc
+ if result is None:
+ return {}
+ data, path = result
+ warn_defaults(path, warnings)
+ return data
+
+
+def _not_utf8(where: Path, exc: UnicodeDecodeError) -> str:
+ return f"a file of {where} is not UTF-8 text (byte {exc.start}: {exc.reason})"
+
+
+def _selected(repo: Path, wanted: str | None) -> list[tuple[str, Path, dict[str, Any]]]:
+ """(id, folder, manifest) of each policy to emit: the named ones, else every one the config leaves enabled."""
+ if not repo.is_dir():
+ msg = f"--repo {repo} is not a folder"
+ raise managed.EmitRefusedError(msg)
+ found = {path.name: path for path in discover_policy_dirs(repo)}
+ if not found:
+ msg = f"no policy under {repo / '.agents' / 'policies'}"
+ raise managed.EmitRefusedError(msg)
+ names = [name.strip() for name in wanted.split(",") if name.strip()] if wanted else sorted(found)
+ missing = [name for name in names if name not in found]
+ if missing:
+ msg = f"no policy {', '.join(missing)} under {repo / '.agents' / 'policies'}"
+ raise managed.EmitRefusedError(msg)
+ config = load_config(repo)
+ chosen = []
+ for name in names:
+ manifest = _manifest(found[name])
+ policy_id = str(manifest.get("id") or name)
+ try:
+ validate_policy_id(policy_id, name)
+ except InvalidPolicyIdError as exc:
+ raise managed.EmitRefusedError(str(exc)) from exc
+ if wanted or policy_status(config, policy_id, manifest)["state"] != "disabled":
+ chosen.append((policy_id, found[name], manifest))
+ return chosen
+
+
+def _report(dest: Path, plan: dict[str, Any], labels: list[dict[str, Any]], skipped: list[str]) -> str:
+ lines = [f"chock emit: wrote {dest} for {plan['vendor']} on {plan['platform']}; nothing was deployed."]
+ lines += [f" place {step['from']} at {step['to']}" for step in plan["place"]]
+ lines += [
+ f" {row['policy']}: {row['label']}, {'witnessed' if row['witnessed'] else 'unwitnessed'}" for row in labels
+ ]
+ lines += [f" skipped {policy_id}: no shell guard or write gate to run" for policy_id in skipped]
+ lines.append(f" {plan['on_failure']['consequence']}")
+ lines += [f" {note}" for note in plan["notes"]]
+ lines.append(f" {DEPLOY_FILE} lists what each machine needs, what this does not promise, and the undo step.")
+ return "\n".join(lines) + "\n"
+
+
+def emit(args: argparse.Namespace) -> str:
+ """Build in memory, check every refusal, then write the tree; returns the report."""
+ builder = BUILDERS[args.managed]
+ facts = managed.facts(args.managed)
+ platform = args.platform or managed.host_platform()
+ options = {
+ "root": managed.deploy_root(args.deploy_root or facts["deploy_root"][platform], platform),
+ "python": managed.interpreter(args.python, platform),
+ "on_failure": args.on_failure,
+ "lock": args.lock,
+ }
+ dest = managed.vendor_out(args.out, args.managed)
+ repo = args.repo.resolve()
+ selected = _selected(repo, args.policies)
+ try:
+ files, labels, skipped = builder.build(selected, repo, options)
+ except UnicodeDecodeError as exc:
+ raise managed.EmitRefusedError(_not_utf8(repo / ".agents" / "policies", exc)) from exc
+ if not labels:
+ msg = "no selected policy has a shell guard or a write gate, so there is nothing for a managed hook to run"
+ raise managed.EmitRefusedError(msg)
+ tools = builder.matchers(json.loads(files[PurePosixPath(facts["drop_in"])]))
+ plan = builder.deploy_plan(platform, options, tools)
+ plan["deploy_root"] = options["root"]
+ files[PurePosixPath(DEPLOY_FILE)] = managed.as_json(plan)
+ files[PurePosixPath(LABELS_FILE)] = managed.as_json(labels)
+ managed.write_tree(dest, files)
+ return _report(dest, plan, labels, skipped)
+
+
+def main(argv: list[str] | None = None) -> int:
+ args = _parser().parse_args(argv)
+ try:
+ report = emit(args)
+ except (managed.EmitRefusedError, OSError) as exc:
+ error(f"chock emit: {exc}")
+ return 1
+ sys.stdout.write(legible(report))
+ return 0
diff --git a/src/chock/data/commands.json b/src/chock/data/commands.json
index 723cfc90..a5e77a27 100644
--- a/src/chock/data/commands.json
+++ b/src/chock/data/commands.json
@@ -29,7 +29,7 @@
"check": {
"module": "chock.history.cli",
"fn": "check_main",
- "help": "Run every truth check: validate, verify, evals, matrix (--only to narrow; --history scans past commits)"
+ "help": "Run every truth check: validate, verify, evals, matrix (--only to narrow; --history scans past commits; --floor, a preview, judges a pull request's merge result with its base's gates; it holds only as a required check the pull request cannot redefine, and judges committed content only)"
},
"status": {
"module": "chock.lifecycle",
@@ -48,7 +48,7 @@
},
"doctor": {
"module": "chock.doctor.cli",
- "help": "Check each client's hooks on each route: present, current, and seen running (--client X)"
+ "help": "Check each client's hooks on each route: present, current, and seen running (--client X); --live runs each hook on a canary"
},
"incident": {
"module": "chock.incident",
@@ -85,6 +85,10 @@
"help": "Low-level single-policy compile",
"person_only": true
},
+ "emit": {
+ "module": "chock.compile.emitters.managed.cli",
+ "help": "Write a vendor's managed-settings bundle under --out for an admin to deploy (emit --managed claude_code --python --on-failure block|allow --out ); refuses an --out that is a filesystem root or inside a system folder"
+ },
"install-skills": {
"module": "chock.scaffold.skills",
"help": "Install bundled authoring skills into agent skill dirs (write mode; check via CI)"
diff --git a/src/chock/data/control_plane.json b/src/chock/data/control_plane.json
new file mode 100644
index 00000000..426a702d
--- /dev/null
+++ b/src/chock/data/control_plane.json
@@ -0,0 +1,41 @@
+{
+ "$comment": "The paths that define the guardrails (`chock check --floor`, floor/control-plane-changed). Matched with fnmatch after case folding, so `*` crosses `/`; a leading `**/` also matches at the top level; a symlink or gitlink at a parent folder of a pattern matches too. Every symlink the control plane reaches must resolve, through the trees at base and head, to a control-plane path, or the run is undecided. A pull request that adds, changes, deletes or re-modes one, in the tree diff or in any of its commits, is listed; the base's `.chock/config.yaml` decides refuse or listed. Whole folder, at any depth, for every agent chock or agentseam writes into (hooks, permissions, MCP, plugins, skills, subagents), plus the engine's CI workflow and store files; tests/test_floor_control_plane_list.py checks the list against the engine's own data. Instruction files (AGENTS.md, CLAUDE.md) are left out: they steer an agent, they are not guardrails. `.gitattributes` is left out: the floor reads attributes from the base. What chock knows about, not a proof of completeness.",
+ "paths": [
+ ".chock/**",
+ "chock.lock",
+ "**/.agents/**",
+ "**/.claude/**",
+ "**/.clinerules/**",
+ "**/.codex/**",
+ "**/.cursor/**",
+ "**/.devin/**",
+ "**/.factory/**",
+ "**/.gemini/**",
+ "**/.grok/**",
+ "**/.junie/**",
+ "**/.kimi-code/**",
+ "**/.openhands/**",
+ "**/.tabnine/**",
+ "**/.vibe/**",
+ "**/.windsurf/**",
+ ".claude-plugin/**",
+ ".cursor-plugin/**",
+ ".devin-plugin/**",
+ ".factory-plugin/**",
+ ".plugin/**",
+ ".github/hooks/**",
+ ".github/agents/**",
+ ".github/plugin/**",
+ ".mcp.json",
+ ".vscode/settings.json",
+ ".vscode/mcp.json",
+ "**/.env",
+ ".devcontainer/**",
+ ".devcontainer.json",
+ ".github/workflows/**",
+ ".github/actions/**",
+ ".github/CODEOWNERS",
+ "CODEOWNERS",
+ "docs/CODEOWNERS"
+ ]
+}
diff --git a/src/chock/data/managed_channels.json b/src/chock/data/managed_channels.json
new file mode 100644
index 00000000..98bdd19b
--- /dev/null
+++ b/src/chock/data/managed_channels.json
@@ -0,0 +1,156 @@
+{
+ "system_roots": {
+ "linux": [
+ "/",
+ "/etc",
+ "/usr",
+ "/bin",
+ "/sbin",
+ "/lib",
+ "/lib32",
+ "/lib64",
+ "/libx32",
+ "/boot",
+ "/opt",
+ "/var",
+ "/srv",
+ "/run",
+ "/sys",
+ "/proc",
+ "/dev",
+ "/root"
+ ],
+ "macos": [
+ "/",
+ "/Library",
+ "/System",
+ "/Applications",
+ "/etc",
+ "/private/etc",
+ "/usr",
+ "/bin",
+ "/sbin",
+ "/opt",
+ "/cores",
+ "/dev",
+ "/var/root",
+ "/private/var/root",
+ "/var/db",
+ "/private/var/db"
+ ],
+ "windows": [
+ "C:/",
+ "C:/Program Files",
+ "C:/Program Files (x86)",
+ "C:/ProgramData",
+ "C:/Windows"
+ ]
+ },
+ "vendors": {
+ "claude_code": {
+ "read": "2026-11-12",
+ "sources": [
+ "https://code.claude.com/docs/en/managed-settings",
+ "https://code.claude.com/docs/en/hooks",
+ "https://code.claude.com/docs/en/settings-reference"
+ ],
+ "admin_dir": {
+ "linux": "/etc/claude-code",
+ "macos": "/Library/Application Support/ClaudeCode",
+ "windows": "C:/Program Files/ClaudeCode"
+ },
+ "drop_in": "managed-settings.d/50-chock.json",
+ "deploy_root": {
+ "linux": "/etc/claude-code/chock",
+ "macos": "/Library/Application Support/ClaudeCode/chock",
+ "windows": "C:/Program Files/ClaudeCode/chock"
+ },
+ "fail_block": {
+ "key": "onFailure",
+ "value": "block",
+ "events": [
+ "PreToolUse"
+ ],
+ "min_client": "2.1.295"
+ },
+ "python_flags": [
+ "-I",
+ "-X",
+ "utf8",
+ "-c"
+ ],
+ "lock_key": "allowManagedHooksOnly",
+ "never_emitted": [
+ "allowManagedPermissionRulesOnly"
+ ],
+ "on_failure": {
+ "block": "--on-failure block: every tool call these hooks match (__MATCHERS__) is refused on a machine where a bundle file is missing or __PYTHON__ is older than Python 3.11 (the hook exits 2, on any client version), and, on Claude Code 2.1.295 or later, where __PYTHON__ is missing or cannot start, or the hook crashes or times out.",
+ "allow": "--on-failure allow: every tool call these hooks match (__MATCHERS__) goes ahead unchecked on a machine where __PYTHON__ is missing, older than Python 3.11 or cannot start, or a bundle file is missing, and whenever the hook crashes or times out; the note is the hook's own stderr, or Claude Code's hook-error notice when the interpreter cannot start."
+ },
+ "requirements": [
+ "Every machine needs Python 3.11 or later at __PYTHON__ exactly: the hook commands start that file directly (exec form, no shell), so neither PATH, git config nor a shell picks the interpreter.",
+ "onFailure needs Claude Code 2.1.295 or later (client_versions); an older client lets a crashed or timed-out hook through.",
+ "Monitor commands are checked only on Claude Code 2.1.314 or later, and WebSocket watches never (client_versions, not_covered).",
+ "The bundle must sit at deploy_root exactly: the hook commands name it by absolute path.",
+ "The bundle folder and __PYTHON__ must be owned by an administrator and not writable by users: whoever can write them can replace the guard. The vendor docs state no ownership rule for the files a managed hook runs; on who can change the managed source they say \"a developer who is an administrator on the machine can edit the managed source itself\"."
+ ],
+ "caveats": [
+ "Managed settings bind Claude Code only. A local administrator can edit or delete these files.",
+ "On WSL, /etc/claude-code is writable by the user as well.",
+ "By default (managedSourcesBehavior \"first-wins\") a machine that also receives server-managed or MDM policy skips the managed settings files without a warning; /status names the source in use.",
+ "onFailure has no effect on Stop hooks, so the turn-end gate lets the turn end when it cannot run, whatever --on-failure says.",
+ "A repository holding .chock/stop.json (valid or not) makes these hooks refuse every tool call they match while Claude Code works in that repository: the bundled runtime honours chock's repository stop.",
+ "Files under the user's home folder can also stop these hooks: ~/.chock/stops/_everywhere.json (chock stop --everywhere) refuses every tool call they match, in every repository; the other files there refuse calls in their repository; an unreadable ~/.chock/stops refuses every call. The user can create these files, and so can the agent with any tool these hooks do not match (stop_files).",
+ "The bundled runtime runs git from PATH for repository facts (the stop files, the turn-end gate's changed files); the guards' verdicts on a command do not depend on it.",
+ "Hooks write their decision log under the user's home folder (~/.chock/log).",
+ "A file in managed-settings.d that is not valid JSON stops Claude Code from starting.",
+ "The labels are vendor-docs evidence, unwitnessed, best-effort: nobody has watched this file refuse a call yet."
+ ],
+ "lock_note": "--lock adds allowManagedHooksOnly. The vendor docs list what it changes on the machine: only managed hooks, Agent SDK hooks and hooks of plugins the managed settings force-enable run; user, project and local hooks, hooks and mods of other installed plugins (chock's own project hooks and plugins included) and hooks in agent frontmatter are blocked; monitors of other plugins do not start; plugins with a command source are disabled and marketplace headersHelper commands are blocked unless disableCommandPluginSources is set to false; the status line and file suggestion are read from managed settings only; the /goal command cannot run.",
+ "never_note": "allowManagedPermissionRulesOnly is never emitted: it would discard every user and project permission rule.",
+ "client_versions": [
+ {
+ "needed_for": "onFailure (--on-failure block refuses a call when the hook cannot start, crashes or times out)",
+ "min_client": "2.1.295",
+ "quote": "Requires Claude Code v2.1.295 or later",
+ "source": "https://code.claude.com/docs/en/hooks",
+ "read": "2026-11-13"
+ },
+ {
+ "needed_for": "the Bash|PowerShell matcher also checking commands Claude starts with the Monitor tool",
+ "min_client": "2.1.314",
+ "quote": "A `PreToolUse` or `PermissionRequest` hook with a `Bash` matcher also runs on shell commands Claude starts with the Monitor tool. Requires Claude Code v2.1.314 or later.",
+ "source": "https://code.claude.com/docs/en/hooks",
+ "read": "2026-11-13"
+ }
+ ],
+ "not_covered": [
+ "Monitor commands on a client older than 2.1.314: the hook never sees them.",
+ "WebSocket watches started with the Monitor tool, on every client version (vendor docs, read 2026-11-13: \"A hook with a `Bash` matcher doesn't run for a WebSocket watch\").",
+ "MCP tools and any other tool that no emitted matcher names (the shell matcher is Bash|PowerShell), even when it runs a command."
+ ],
+ "stop_files": [
+ {
+ "path": ".chock/stop.json in any repository the call works in or names",
+ "written_by": "chock stop",
+ "effect": "every tool call these hooks match is refused; a stop file that is not valid JSON refuses as well."
+ },
+ {
+ "path": "~/.chock/stops/_everywhere.json in the user's home folder",
+ "written_by": "chock stop --everywhere",
+ "effect": "every tool call these hooks match is refused, whatever the repository or session; any content, {} included, counts."
+ },
+ {
+ "path": "~/.chock/stops/.json in the user's home folder",
+ "written_by": "chock stop (its machine registry entry)",
+ "effect": "tool calls that work in or name that repository are refused, and so is every call while Claude Code names no project folder."
+ },
+ {
+ "path": "~/.chock/stops itself",
+ "written_by": "chock stop",
+ "effect": "if it exists but cannot be listed, or an entry in it cannot be read, every tool call these hooks match is refused."
+ }
+ ]
+ }
+ }
+}
diff --git a/src/chock/data/runtime_payloads.json b/src/chock/data/runtime_payloads.json
new file mode 100644
index 00000000..957efe64
--- /dev/null
+++ b/src/chock/data/runtime_payloads.json
@@ -0,0 +1,157 @@
+{
+ "_doc": "One shell pre-tool payload per vendored runtime (__COMMAND__, __ROOT__ swapped in), and the deny word each one's wire carries: block is the devin-family spelling, exit-2 windsurf's wordless exit-code grammar (G5). The last four payloads are agentseam's golden pre_tool payloads (tests/fixtures/golden at bebbfa6), shell tool.",
+ "payloads": {
+ "claude_code": {
+ "hook_event_name": "PreToolUse",
+ "tool_name": "Bash",
+ "tool_input": {
+ "command": "__COMMAND__"
+ },
+ "session_id": "s",
+ "transcript_path": "/t",
+ "permission_mode": "default"
+ },
+ "vscode_copilot": {
+ "hook_event_name": "PreToolUse",
+ "timestamp": "2026-08-31T00:00:00Z",
+ "tool_name": "Bash",
+ "tool_input": {
+ "command": "__COMMAND__"
+ },
+ "tool_use_id": "1"
+ },
+ "cursor": {
+ "hook_event_name": "beforeShellExecution",
+ "conversation_id": "a",
+ "generation_id": "b",
+ "cursor_version": "3.17.8",
+ "workspace_roots": [
+ "__ROOT__"
+ ],
+ "command": "__COMMAND__",
+ "cwd": "__ROOT__",
+ "sandbox": false
+ },
+ "codex_cli": {
+ "hook_event_name": "PreToolUse",
+ "turn_id": "t1",
+ "tool_name": "Bash",
+ "tool_input": {
+ "command": "__COMMAND__"
+ }
+ },
+ "antigravity": {
+ "toolCall": {
+ "name": "run_command",
+ "args": {
+ "CommandLine": "__COMMAND__",
+ "Cwd": "__ROOT__"
+ }
+ },
+ "conversationId": "c1",
+ "stepIdx": 1,
+ "workspacePaths": [
+ "__ROOT__"
+ ]
+ },
+ "devin": {
+ "hook_event_name": "PreToolUse",
+ "prompt_id": "p1",
+ "tool_name": "Bash",
+ "tool_input": {
+ "command": "__COMMAND__"
+ },
+ "session_id": "s"
+ },
+ "gemini_cli": {
+ "hook_event_name": "BeforeTool",
+ "tool_name": "run_shell_command",
+ "tool_input": {
+ "command": "__COMMAND__"
+ },
+ "session_id": "s"
+ },
+ "grok": {
+ "hookEventName": "PreToolUse",
+ "toolName": "Bash",
+ "toolInput": {
+ "command": "__COMMAND__"
+ },
+ "sessionId": "s"
+ },
+ "tabnine": {
+ "hook_event_name": "BeforeTool",
+ "timestamp": "2026-08-31T00:00:00Z",
+ "tool_name": "shell",
+ "tool_input": {
+ "command": "__COMMAND__"
+ }
+ },
+ "windsurf": {
+ "trajectory_id": "t1",
+ "tool_info": {
+ "command_line": "__COMMAND__"
+ },
+ "cwd": "__ROOT__"
+ },
+ "factory_droid": {
+ "hook_event_name": "PreToolUse",
+ "permission_mode": "auto-medium",
+ "session_id": "s",
+ "transcript_path": "__ROOT__/.factory/projects/x/session.jsonl",
+ "cwd": "__ROOT__",
+ "tool_name": "Execute",
+ "tool_input": {
+ "command": "__COMMAND__"
+ }
+ },
+ "goose": {
+ "event": "PreToolUse",
+ "matcher_context": "shell",
+ "session_id": "s",
+ "tool_call_id": "call-1",
+ "tool_name": "shell",
+ "tool_input": {
+ "command": "__COMMAND__"
+ },
+ "working_dir": "__ROOT__"
+ },
+ "openhands": {
+ "event_type": "PreToolUse",
+ "session_id": "s",
+ "tool_name": "terminal",
+ "tool_input": {
+ "command": "__COMMAND__"
+ },
+ "working_dir": "__ROOT__"
+ },
+ "mistral_vibe": {
+ "hook_event_name": "pre_tool",
+ "parent_session_id": null,
+ "session_id": "s",
+ "tool_call_id": "call-1",
+ "tool_name": "bash",
+ "tool_input": {
+ "command": "__COMMAND__"
+ },
+ "transcript_path": "__ROOT__/.vibe/session.jsonl",
+ "cwd": "__ROOT__"
+ }
+ },
+ "deny_on_the_wire": {
+ "claude_code": "deny",
+ "codex_cli": "deny",
+ "cursor": "deny",
+ "vscode_copilot": "deny",
+ "antigravity": "deny",
+ "devin": "block",
+ "gemini_cli": "deny",
+ "grok": "deny",
+ "tabnine": "deny",
+ "windsurf": "exit-2",
+ "factory_droid": "deny",
+ "goose": "block",
+ "openhands": "deny",
+ "mistral_vibe": "deny"
+ }
+}
diff --git a/src/chock/data/witnesses.json b/src/chock/data/witnesses.json
index 16f05d48..f790bbad 100644
--- a/src/chock/data/witnesses.json
+++ b/src/chock/data/witnesses.json
@@ -68,5 +68,26 @@
"client": "Claude Code, Bash tool (CLAUDECODE=1, AI_AGENT=claude-code__agent)",
"date": "2026-09-29",
"method": "live probe: both variables were in the environment of a pre-commit hook run by `git commit` from the Bash tool (chock 1b0bcdd)"
+ },
+ {
+ "agent": "claude_code",
+ "surface": "agent-hooks",
+ "client": "Claude Code v2.1.317, Windows",
+ "date": "2026-11-11",
+ "method": "live probe: PreToolUse refused `git commit --no-verify` on the PowerShell tool and no commit was made (chock 295b38c)"
+ },
+ {
+ "agent": "cursor",
+ "surface": "agent-hooks",
+ "client": "Cursor 3.30.14, Windows",
+ "date": "2026-11-14",
+ "method": "live probe: the repo's beforeShellExecution hook refused `git commit --no-verify` and no commit was made (chock cc127e4)"
+ },
+ {
+ "agent": "codex_cli",
+ "surface": "agent-hooks",
+ "client": "Codex CLI 0.169.0, Windows",
+ "date": "2026-11-14",
+ "method": "live probe: the repo's PreToolUse hook refused `git commit --no-verify` and no commit was made, after the project's hooks were trusted (chock cc127e4)"
}
]
diff --git a/src/chock/doctor/checks.py b/src/chock/doctor/checks.py
index 44e14cbd..8202aea7 100644
--- a/src/chock/doctor/checks.py
+++ b/src/chock/doctor/checks.py
@@ -34,7 +34,8 @@ class Check:
fix: str = ""
-def _rebuild(target: Target) -> str:
+def rebuild(target: Target) -> str:
+ """The one-line fix for a target whose hooks are missing, stale or broken."""
if target.route == ROUTE_SYNC:
return f"run `chock sync --repo {target.root}`"
return f"rebuild it: `chock install --selection --client {target.client}`"
@@ -44,8 +45,8 @@ def hooks_present(target: Target) -> Check:
if target.wired() and target.runtime.is_file():
return Check(PASS, "hooks", f"{target.hooks} runs {target.runtime.name}")
if target.wired():
- return Check(FAIL, "hooks", f"{target.hooks} runs {target.runtime}, which is missing", _rebuild(target))
- return Check(FAIL, "hooks", f"{target.hooks} does not run {target.runtime.name}", _rebuild(target))
+ return Check(FAIL, "hooks", f"{target.hooks} runs {target.runtime}, which is missing", rebuild(target))
+ return Check(FAIL, "hooks", f"{target.hooks} does not run {target.runtime.name}", rebuild(target))
def _python_version(name: str) -> tuple[int, ...] | None:
@@ -66,7 +67,7 @@ def _python_version(name: str) -> tuple[int, ...] | None:
def launcher(target: Target) -> Check:
if not target.launcher.is_file():
- return Check(FAIL, "launcher", f"{target.launcher} is missing: every hook refuses", _rebuild(target))
+ return Check(FAIL, "launcher", f"{target.launcher} is missing: every hook refuses", rebuild(target))
least = ".".join(map(str, launch.MIN_PYTHON))
usable = [(n, v) for n in PYTHONS if (v := _python_version(n)) is not None and v >= launch.MIN_PYTHON]
if not usable:
@@ -90,16 +91,16 @@ def engine(target: Target) -> Check:
try:
same = path.read_text(encoding="utf-8") == expected
except (OSError, UnicodeDecodeError):
- return Check(FAIL, "engine", f"{path} is unreadable", _rebuild(target))
+ return Check(FAIL, "engine", f"{path} is unreadable", rebuild(target))
if not same:
- return Check(FAIL, "engine", f"{path.name} was not built by {_engine_names()}", _rebuild(target))
+ return Check(FAIL, "engine", f"{path.name} was not built by {_engine_names()}", rebuild(target))
if target.route == ROUTE_SYNC:
return Check(PASS, "engine", f"runtime matches {_engine_names()}")
built = marker_engine(target)
recorded, version = built.get("commit"), built.get("version")
if version != __version__ or (recorded and engine_commit() and recorded != engine_commit()):
what = f"chock {version}" + (f" ({str(recorded)[:12]})" if recorded else "")
- return Check(WARN, "engine", f"runtime matches, but built by {what}, not {_engine_names()}", _rebuild(target))
+ return Check(WARN, "engine", f"runtime matches, but built by {what}, not {_engine_names()}", rebuild(target))
return Check(PASS, "engine", f"runtime matches; built by {_engine_names()}")
@@ -146,7 +147,7 @@ def _heartbeat(target: Target, beats: list[dict], hooks: list[dict], sessions: i
WARN,
"heartbeat",
what,
- f"start a new session; if none appears, the client is not loading it: {_rebuild(target)}",
+ f"start a new session; if none appears, the client is not loading it: {rebuild(target)}",
)
since = beats[-sessions:][0]["ts"]
quiet = not any(r["ts"] >= since for r in hooks)
diff --git a/src/chock/doctor/cli.py b/src/chock/doctor/cli.py
index 7fe57bfe..6a264fd2 100644
--- a/src/chock/doctor/cli.py
+++ b/src/chock/doctor/cli.py
@@ -1,4 +1,4 @@
-"""`chock doctor [--client X] [--repo .]`: each client's hooks on each route, PASS/WARN/FAIL with a fix."""
+"""`chock doctor [--client X] [--repo .] [--live]`: each client's hooks on each route, PASS/WARN/FAIL with a fix."""
from __future__ import annotations
@@ -9,7 +9,7 @@
from pathlib import Path
from chock.display import inert
-from chock.doctor import checks
+from chock.doctor import checks, live
from chock.doctor.targets import plugin_targets, sync_targets
from chock.stop_everywhere import everywhere_line
@@ -18,6 +18,16 @@ def _say(line: str) -> None:
sys.stdout.write(inert(line) + "\n")
+_LIVE_HELP = (
+ "also run chock's own pre-tool hook commands, only those byte-equal to what this engine renders and only when "
+ "the launcher and runtime are this engine's, as the client's config file writes them, from the repo: once on "
+ "the first refusing eval case of the first policy they run (it must refuse) and once on "
+ f"`{live.HARMLESS}` (it must allow). Any other hook command is counted, never run. The installed policies' "
+ "guard code runs, as it does in `chock check` evals. It starts no client, sends nothing anywhere and logs "
+ "nothing. It does not prove the client calls the hook: that is the heartbeat row"
+)
+
+
def _parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(prog="chock doctor", description=__doc__)
parser.add_argument("--repo", default=".", help="the repository whose `chock sync` hooks to check")
@@ -25,6 +35,7 @@ def _parser() -> argparse.ArgumentParser:
parser.add_argument("--client-version", help="the client's version, compared with what agentseam witnessed")
parser.add_argument("--sessions", type=int, default=checks.SESSIONS, help="sessions the heartbeat check covers")
parser.add_argument("--json", action="store_true", help="one JSON object per target")
+ parser.add_argument("--live", action="store_true", help=_LIVE_HELP)
return parser
@@ -43,6 +54,8 @@ def main(argv: list[str] | None = None) -> int:
failed = False
for target in targets:
found = checks.run(target, repo, max(1, args.sessions), args.client_version)
+ if args.live:
+ found += live.run(target, repo)
failed = failed or any(c.status == checks.FAIL for c in found)
if args.json:
row = {"client": target.client, "agent": target.agent, "route": target.route, "root": str(target.root)}
diff --git a/src/chock/doctor/live.py b/src/chock/doctor/live.py
new file mode 100644
index 00000000..aa30d041
--- /dev/null
+++ b/src/chock/doctor/live.py
@@ -0,0 +1,274 @@
+"""`chock doctor --live`: run chock's own installed pre-tool hooks as the client calls them, on a canary and a harmless command."""
+
+from __future__ import annotations
+
+import json
+import os
+import re
+import shutil
+import subprocess
+import tempfile
+import tomllib
+from collections.abc import Iterator
+from pathlib import Path
+from typing import Any
+
+import yaml
+
+from chock import vendors
+from chock.doctor.checks import FAIL, INFO, PASS, Check, engine, rebuild
+from chock.doctor.payloads import DENY_ON_THE_WIRE, EXIT_2, payload
+from chock.doctor.targets import ROUTE_SYNC, Target
+from chock.gate.guard_runner import bash_candidates
+from chock.gate.runner.journal import LOG_LEVEL_ENV, LOG_OFF
+from chock.hooks import launch
+from chock.hooks.in_agent_install import install_hooks
+from chock.plugin import hook_dir, store
+from chock.plugin.clients import CLIENTS
+from chock.policies import discover_policy_dirs
+from chock.vendored import vendored_differences
+
+REFUSES, ALLOWS, LIVE = "live: refuses the canary", "live: allows a harmless command", "live"
+#: A command every policy lets through: it reads nothing and writes nothing.
+HARMLESS = "echo chock-doctor-live"
+#: Seconds one hook command may take; a client's own timeouts are of this order.
+TIMEOUT = 60
+#: The exit code every client reads as a refusal.
+REFUSAL_EXIT = 2
+#: The probe logs nothing, so the decision log never holds a refusal no agent asked for.
+QUIET = {LOG_LEVEL_ENV: LOG_OFF}
+_REFERENCE = re.compile(r'--(guard|multi)\s+"?([^"\s]+)"?')
+_TOOL_KEYS = ("tool_name", "toolName")
+_ANY = (None, "", "*")
+#: The per-shell keys a hook entry may carry in place of `command` (Copilot's `bash` and `powershell`).
+BASH, POWERSHELL = "bash", "powershell"
+#: The probe's own session: its calls never join a real session's log, and that file is removed afterwards.
+PROBE_SESSION = "chock-doctor-live"
+_SESSION_KEYS = ("session_id", "sessionId", "conversation_id", "conversationId", "trajectory_id")
+_STATE = (".chock", "state")
+
+
+def _document(path: Path) -> Any:
+ text = path.read_text(encoding="utf-8")
+ return tomllib.loads(text) if path.suffix == ".toml" else json.loads(text)
+
+
+def _matches(matcher: Any, tool: str | None) -> bool:
+ if matcher in _ANY or tool is None or not isinstance(matcher, str):
+ return True
+ try:
+ return re.fullmatch(matcher, tool) is not None
+ except re.error:
+ return True
+
+
+def _entry(node: dict[str, Any]) -> tuple[str, str] | None:
+ """(the key it was read from, the command) the client runs for one hook entry on this OS."""
+ for key in ("command", POWERSHELL if os.name == "nt" else BASH):
+ if isinstance(node.get(key), str):
+ return key, node[key]
+ return None
+
+
+def _collect(node: Any, tool: str | None, matcher: Any = None) -> Iterator[tuple[str, str]]:
+ if isinstance(node, dict):
+ matcher = node.get("matcher", matcher)
+ entry = _entry(node)
+ if entry is not None and _matches(matcher, tool):
+ yield entry
+ for value in node.values():
+ yield from _collect(value, tool, matcher)
+ elif isinstance(node, list):
+ for item in node:
+ yield from _collect(item, tool, matcher)
+
+
+def _under(node: Any, event: str) -> Iterator[Any]:
+ if isinstance(node, dict):
+ for key, value in node.items():
+ if key == event:
+ yield value
+ else:
+ yield from _under(value, event)
+ elif isinstance(node, list):
+ for item in node:
+ yield from _under(item, event)
+
+
+def commands(target: Target) -> list[tuple[str, str]]:
+ """The pre-tool entries the client runs for its shell tool, read from the very file it reads."""
+ doc = _document(target.hooks)
+ sample = payload(target.agent, HARMLESS) if target.agent in DENY_ON_THE_WIRE else {}
+ tool = next((sample[k] for k in _TOOL_KEYS if isinstance(sample.get(k), str)), None)
+ return [c for part in _under(doc, vendors.shell_gate_event(target.agent)) for c in _collect(part, tool)]
+
+
+def rendered(target: Target) -> set[tuple[str, str]]:
+ """Every entry this engine's installer writes for the target, rendered from the repo's policies into a scratch copy."""
+ rel = target.hooks.relative_to(target.root)
+ with tempfile.TemporaryDirectory(prefix="chock-live-") as tmp:
+ shadow = Path(tmp)
+ compiled = target.root / ".chock" / "compiled"
+ if compiled.is_dir():
+ shutil.copytree(compiled, shadow / ".chock" / "compiled")
+ for pack in discover_policy_dirs(target.root):
+ shutil.copytree(pack, shadow / pack.relative_to(target.root), dirs_exist_ok=True)
+ install_hooks(shadow, target.agent)
+ written = shadow / rel
+ return set(_collect(_document(written), None)) if written.is_file() else set()
+
+
+def own_runtime(target: Target) -> bool:
+ """Whether the launcher and every vendored runtime are byte-equal to what this engine renders."""
+ try:
+ same_launcher = target.launcher.read_text(encoding="utf-8") == launch.launcher_text()
+ except (OSError, UnicodeDecodeError):
+ return False
+ return same_launcher and engine(target).status == PASS and not vendored_differences(target.root)
+
+
+def _guards(command: str, root: Path) -> Iterator[Path]:
+ for flag, ref in _REFERENCE.findall(command):
+ path = Path(ref) if Path(ref).is_absolute() else root / ref
+ if flag == "guard":
+ yield path
+ continue
+ try:
+ members = json.loads(path.read_text(encoding="utf-8")).get("members") or []
+ except (OSError, ValueError, AttributeError):
+ continue
+ for member in members:
+ argv = (member.get("argv") if isinstance(member, dict) else None) or []
+ yield from (root / argv[i + 1] for i, word in enumerate(argv[:-1]) if word == "--guard")
+
+
+def _first_block(suite: Path) -> str | None:
+ try:
+ cases = (yaml.safe_load(suite.read_text(encoding="utf-8")) or {}).get("suite", {}).get("cases") or []
+ except (OSError, yaml.YAMLError, AttributeError):
+ return None
+ for case in cases:
+ run = case.get("execute") if isinstance(case, dict) else None
+ if isinstance(run, dict) and run.get("expect") == "block" and isinstance(run.get("command"), str):
+ return run["command"]
+ return None
+
+
+def canary(target: Target, repo: Path, found: list[tuple[str, str]]) -> tuple[str, str] | None:
+ """(policy id, command): the first installed guard's own first refusing eval case; None when no guard has one."""
+ for _key, command in found:
+ for guard in _guards(command, target.root):
+ policy = guard.parent.parent if guard.parent.name == "implementations" else None
+ suites = [policy / "evals" / "suite.yaml"] if policy else []
+ suites.append(repo / ".agents" / "policies" / guard.stem / "evals" / "suite.yaml")
+ for suite in suites:
+ case = _first_block(suite)
+ if case is not None:
+ return suite.parent.parent.name, case
+ return None
+
+
+def _argv(agent: str, key: str, command: str) -> list[str] | str:
+ """The shell the client runs a hook in on this OS: sh on POSIX; on Windows PowerShell for a `powershell` entry,
+ cmd.exe where the store says so, else Git Bash."""
+ if os.name != "nt":
+ return [shutil.which("sh") or "sh", "-c", command]
+ if key == POWERSHELL:
+ return [shutil.which("powershell") or "powershell", "-NoProfile", "-Command", command]
+ cmd = any(c.agent == agent and store.windows_hook_command(f) == hook_dir.QUOTE_FREE for f, c in CLIENTS.items())
+ bash = [] if cmd else bash_candidates()
+ return [bash[0], "-c", command] if bash else command
+
+
+def _probe(agent: str, asked: str, repo: Path) -> dict[str, Any]:
+ sent = payload(agent, asked, repo.as_posix())
+ named = [key for key in _SESSION_KEYS if key in sent] or [_SESSION_KEYS[0]]
+ return {**sent, **dict.fromkeys(named, PROBE_SESSION)}
+
+
+def _call(target: Target, repo: Path, entry: tuple[str, str], asked: str) -> subprocess.CompletedProcess | str:
+ """One hook command's answer to `asked`, or why it gave none."""
+ argv = _argv(target.agent, *entry)
+ try:
+ return subprocess.run( # noqa: S603 -- a hook command this engine rendered, byte-equal, as the client runs it
+ argv,
+ shell=isinstance(argv, str),
+ cwd=repo,
+ env={**os.environ, **QUIET},
+ input=json.dumps(_probe(target.agent, asked, repo)),
+ capture_output=True,
+ text=True,
+ encoding="utf-8",
+ errors="replace",
+ timeout=TIMEOUT,
+ check=False,
+ )
+ except (OSError, subprocess.TimeoutExpired) as exc:
+ return f"{type(exc).__name__}: {exc}"
+
+
+def refused(agent: str, done: subprocess.CompletedProcess) -> bool:
+ """Whether the answer is a refusal in `agent`'s grammar: its deny word on stdout, or exit 2."""
+ word = DENY_ON_THE_WIRE[agent]
+ return done.returncode == REFUSAL_EXIT or (word != EXIT_2 and done.returncode == 0 and f'"{word}"' in done.stdout)
+
+
+def _said(done: subprocess.CompletedProcess | str) -> str:
+ if isinstance(done, str):
+ return done
+ text = (done.stderr.strip() or done.stdout.strip()).splitlines()
+ return f"exit {done.returncode}" + (f": {text[0][:160]}" if text else "")
+
+
+def _refuses(target: Target, repo: Path, found: list[tuple[str, str]], probe: tuple[str, str] | None) -> Check:
+ if probe is None:
+ return Check(INFO, LIVE, "skipped (no in-agent policy installed on its shell tool)")
+ policy, case = probe
+ answers = [_call(target, repo, c, case) for c in found]
+ for done in answers:
+ if not isinstance(done, str) and refused(target.agent, done) and policy in done.stdout + done.stderr:
+ return Check(PASS, REFUSES, f"{policy} refused `{case}`")
+ return Check(FAIL, REFUSES, f"{policy} did not refuse `{case}`: {_said(answers[0])}", rebuild(target))
+
+
+def _allows(target: Target, repo: Path, found: list[tuple[str, str]]) -> Check:
+ for done in (_call(target, repo, c, HARMLESS) for c in found):
+ if isinstance(done, str) or done.returncode != 0 or refused(target.agent, done):
+ return Check(FAIL, ALLOWS, f"`{HARMLESS}` was not allowed: {_said(done)}", rebuild(target))
+ return Check(PASS, ALLOWS, f"`{HARMLESS}` allowed by {len(found)} hook command(s)")
+
+
+def _runnable(target: Target) -> tuple[list[tuple[str, str]], list[Check]]:
+ """(chock's own pre-tool entries, the rows that say what was not run); no entries when nothing may run."""
+ if target.route != ROUTE_SYNC:
+ return [], [Check(INFO, LIVE, "skipped (plugin route: chock cannot re-render a plugin's hook commands)")]
+ if target.agent not in DENY_ON_THE_WIRE:
+ return [], [Check(INFO, LIVE, f"skipped (no recorded {target.agent} pre-tool payload)")]
+ if not own_runtime(target):
+ return [], [Check(INFO, LIVE, "skipped (runtime is not this engine's)", rebuild(target))]
+ try:
+ found, ours = commands(target), rendered(target)
+ except (OSError, ValueError, tomllib.TOMLDecodeError) as exc:
+ return [], [Check(FAIL, LIVE, f"{target.hooks} is unreadable ({exc})", rebuild(target))]
+ mine = [entry for entry in found if entry in ours]
+ other = len(found) - len(mine)
+ rows = [Check(INFO, LIVE, f"{other} other hook command(s) not run (not chock's)")] if other else []
+ if not mine:
+ rows.append(Check(FAIL, LIVE, f"{target.hooks} holds no pre-tool command chock renders", rebuild(target)))
+ return mine, rows
+
+
+def run(target: Target, repo: Path) -> list[Check]:
+ """The two live rows for one target, after a row for anything not run; or the one row that says why nothing ran."""
+ found, rows = _runnable(target)
+ if not found:
+ return rows
+ logs = [
+ base.joinpath(*_STATE, PROBE_SESSION + suffix) for base in {repo, target.root} for suffix in (".jsonl", ".tmp")
+ ]
+ fresh = [path for path in logs if not path.exists()]
+ try:
+ return [*rows, _refuses(target, repo, found, canary(target, repo, found)), _allows(target, repo, found)]
+ finally:
+ for path in fresh:
+ path.unlink(missing_ok=True)
diff --git a/src/chock/doctor/payloads.py b/src/chock/doctor/payloads.py
new file mode 100644
index 00000000..8769cee5
--- /dev/null
+++ b/src/chock/doctor/payloads.py
@@ -0,0 +1,36 @@
+"""Each vendored runtime's own shell pre-tool payload, and the deny its wire carries: read by `doctor --live` and the tests."""
+
+from __future__ import annotations
+
+import json
+from functools import partial
+from typing import Any
+
+from chock.resources import package_data_dir
+
+COMMAND, ROOT = "__COMMAND__", "__ROOT__"
+#: The root a payload names when the caller gives none: what the tests swap for their own repository.
+DEFAULT_ROOT = "/x"
+#: The wordless deny: the client reads exit code 2 as the refusal.
+EXIT_2 = "exit-2"
+
+_DATA = json.loads(package_data_dir("chock", "data").joinpath("runtime_payloads.json").read_text(encoding="utf-8"))
+
+
+def _fill(value: Any, command: str, root: str) -> Any:
+ if isinstance(value, str):
+ return command if value == COMMAND else value.replace(ROOT, root)
+ if isinstance(value, list):
+ return [_fill(item, command, root) for item in value]
+ if isinstance(value, dict):
+ return {key: _fill(item, command, root) for key, item in value.items()}
+ return value
+
+
+def payload(agent: str, command: str, root: str = DEFAULT_ROOT) -> dict[str, Any]:
+ """`agent`'s pre-tool payload for one shell `command`, its paths naming `root`."""
+ return _fill(_DATA["payloads"][agent], command, root)
+
+
+PAYLOADS = {agent: partial(payload, agent) for agent in _DATA["payloads"]}
+DENY_ON_THE_WIRE: dict[str, str] = dict(_DATA["deny_on_the_wire"])
diff --git a/src/chock/eval/report.py b/src/chock/eval/report.py
index 632431d4..6d0b5c6c 100644
--- a/src/chock/eval/report.py
+++ b/src/chock/eval/report.py
@@ -6,6 +6,7 @@
from typing import Any
from chock.eval.model import PolicyResult
+from chock.output import ellipsis
MARK = {"pass": "PASS", "fail": "FAIL", "pending": "PEND", "skipped": "SKIP", "error": "ERR "}
@@ -13,7 +14,7 @@
def _trim(detail: str) -> str:
- return detail if len(detail) <= _DETAIL_WIDTH else detail[: _DETAIL_WIDTH - 1] + "…"
+ return detail if len(detail) <= _DETAIL_WIDTH else detail[: _DETAIL_WIDTH - len(ellipsis())] + ellipsis()
def render_text(policies: list[PolicyResult], *, verbose: bool = False) -> str:
diff --git a/src/chock/evidence.py b/src/chock/evidence.py
index 96609a63..d9b20ae1 100644
--- a/src/chock/evidence.py
+++ b/src/chock/evidence.py
@@ -25,7 +25,9 @@
#: Not a place chock blocks: the environment a vendor's shell hands a git hook, which is how an
#: agent's commit is recognised. A row here witnesses a marker, never a capability.
GIT_HOOK_ENV = "git-hook-env"
-WITNESS_SURFACES = ("pre-tool-use", "agent-hooks", PLUGIN_HOOK, GIT_HOOK_ENV)
+#: A vendor's admin-deployed file (`chock emit --managed`); until a row lands, every managed label stays vendor-docs.
+MANAGED = "managed"
+WITNESS_SURFACES = ("pre-tool-use", "agent-hooks", PLUGIN_HOOK, GIT_HOOK_ENV, MANAGED)
HONOURS_ASK = "honours_ask"
CLAIM_NAMES = (HONOURS_ASK,)
diff --git a/src/chock/gate/budget.py b/src/chock/gate/budget.py
index e821fd43..332b11ed 100644
--- a/src/chock/gate/budget.py
+++ b/src/chock/gate/budget.py
@@ -30,6 +30,14 @@
#: Added to the environment of every policy script, so running a gate never writes bytecode into its pack.
BYTECODE_OFF = {"PYTHONDONTWRITEBYTECODE": "1"}
+#: Starts a child script under `-I` with only the script's own folder on sys.path, as running it directly would.
+ISOLATED_START = (
+ "import os, runpy, sys\n"
+ "sys.argv = sys.argv[1:]\n"
+ "sys.path.insert(0, os.path.dirname(os.path.abspath(sys.argv[0])))\n"
+ "runpy.run_path(sys.argv[0], run_name='__main__')\n"
+)
+
#: Seconds a gate's patterns may spend on one judgement (one commit's lines, one write, one blob)
#: before the gate refuses naming itself: a repo-supplied pattern can be catastrophic.
PATTERN_SECONDS = 10
@@ -142,6 +150,19 @@ def run_tree(argv, *, timeout=None, **options):
return subprocess.CompletedProcess(argv, proc.returncode, out, err)
+def python_free_env(env=None):
+ """`env` (this process's by default) without any `PYTHON*` variable, plus bytecode off for grandchildren."""
+ base = os.environ if env is None else env
+ return {**{k: v for k, v in base.items() if not k.upper().startswith("PYTHON")}, **BYTECODE_OFF}
+
+
+def isolated_child(argv, env=None):
+ """(argv, env) that run the Python child `[interpreter, script, *args]` isolated: no PYTHON* variable,
+ user site or current folder can change what it imports; its own folder is put on sys.path explicitly."""
+ interpreter, script, *args = argv
+ return [interpreter, "-I", "-B", "-X", "utf8", "-c", ISOLATED_START, str(script), *args], python_free_env(env)
+
+
def engine_remaining(deadline):
"""Seconds left before `deadline`, never negative."""
return max(deadline - time.monotonic(), 0.0)
diff --git a/src/chock/gate/guard_runner.py b/src/chock/gate/guard_runner.py
index a34be713..7adf565e 100644
--- a/src/chock/gate/guard_runner.py
+++ b/src/chock/gate/guard_runner.py
@@ -12,11 +12,12 @@
from pathlib import Path
from .budget import (
- BYTECODE_OFF,
ENGINE_BUDGET_SECONDS,
engine_deadline,
engine_remaining,
+ isolated_child,
last_state,
+ python_free_env,
run_tree,
time_left,
)
@@ -101,7 +102,7 @@ def bash_candidates() -> list[str]:
def interpreter_env(interpreter: str) -> dict[str, str]:
"""The environment a guard runs in: on Windows, Git's usr/bin ahead on PATH for sed and grep."""
- env = {**os.environ, **BYTECODE_OFF}
+ env = python_free_env()
env.pop(CAN_ASK_ENV, None) # only a caller that knows the client may say; never inherited
if os.name != _WINDOWS:
return env
@@ -167,6 +168,12 @@ def split_command(command: str) -> tuple[list[str], bool]:
return command.split(), True
+def _guard_start(interpreter: str, guard: Path, args: list[str], env: dict[str, str]):
+ """(argv, env) for the guard: a Python guard starts isolated, a shell guard as given."""
+ argv = [interpreter, str(guard), *args]
+ return isolated_child(argv, env) if guard.suffix == PYTHON_SUFFIX else (argv, env)
+
+
def run_guard(guard: Path, command: str, tool: str = "") -> str:
"""`GUARD_BLOCKED` / `GUARD_ASKED` / `GUARD_CLEAN` when the guard ran, otherwise why it did not."""
return run_guard_detailed(guard, command, tool)[0]
@@ -198,8 +205,9 @@ def run_guard_detailed(guard: Path, command: str, tool: str = "", *, can_ask: bo
if fallback:
env[ARGV_FALLBACK_ENV] = "1"
env.update({} if can_ask is None else {CAN_ASK_ENV: "1" if can_ask else "0"})
+ argv, env = _guard_start(interpreter, guard, args, env)
proc = run_tree(
- [interpreter, str(guard), *args],
+ argv,
capture_output=True,
text=True,
encoding="utf-8",
diff --git a/src/chock/gate/runner/__init__.py b/src/chock/gate/runner/__init__.py
index 85dcda59..a73809a1 100644
--- a/src/chock/gate/runner/__init__.py
+++ b/src/chock/gate/runner/__init__.py
@@ -21,6 +21,7 @@
CONFIG_AGENT_ENV_KEY,
EXIT_ASK,
EXIT_WARN,
+ FLOOR_EVENT,
GATE_LOG_ENV,
HEAD_WAIVER_EVENTS,
POLICIES_PREFIX,
@@ -57,6 +58,7 @@
"EXIT_ASK",
"EXIT_WARN",
"EXTRACTORS",
+ "FLOOR_EVENT",
"GATE_LOG_ENV",
"HEAD_WAIVER_EVENTS",
"KINDS",
diff --git a/src/chock/gate/runner/constants.py b/src/chock/gate/runner/constants.py
index 4088852b..29762718 100644
--- a/src/chock/gate/runner/constants.py
+++ b/src/chock/gate/runner/constants.py
@@ -22,6 +22,7 @@
"CONFIG_AGENT_ENV_KEY",
"EXIT_ASK",
"EXIT_WARN",
+ "FLOOR_EVENT",
"GATE_LOG_ENV",
"HEAD_WAIVER_EVENTS",
"POLICIES_PREFIX",
@@ -107,8 +108,12 @@
#: adds is not honoured. Coverage (`on: [commit]`) is still decided by the name `commit`.
AGENT_COMMIT_EVENT = "agent-commit"
+#: The event `chock check --floor` judges at: the change under judgement may be the refused party's, so a
+#: waiver counts only when the base already has that line (the floor's `committed_blob` reads the base).
+FLOOR_EVENT = "ci-floor"
+
#: Events where the actor may be the refused agent: a waiver counts only when HEAD already has that line.
-HEAD_WAIVER_EVENTS = frozenset({AGENT_COMMIT_EVENT, TOOL_USE_EVENT})
+HEAD_WAIVER_EVENTS = frozenset({AGENT_COMMIT_EVENT, TOOL_USE_EVENT, FLOOR_EVENT})
_HUMAN_ENV = frozenset({"0", "false", "no", "off"})
diff --git a/src/chock/gate/runner/context.py b/src/chock/gate/runner/context.py
index 46b00539..95354462 100644
--- a/src/chock/gate/runner/context.py
+++ b/src/chock/gate/runner/context.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import contextlib
import difflib
import fnmatch
import shutil
@@ -67,6 +68,7 @@ def __init__(
self.scope = tuple(scope or ())
#: Path prefixes this gate never judges: its own policy's source and compiled folders.
self.own = tuple(own)
+ self._rename_map: dict[str, str] | None = None
def is_own(self, path: str) -> bool:
"""Whether `path` is in this policy's own source or compiled folder."""
@@ -133,9 +135,28 @@ def staged_paths(self, diff_filter: str = "ACMRT", *, judge_own: bool = False) -
paths = self._listing("diff", *self._range(), "--name-only", f"--diff-filter={diff_filter}")
return [path for path in paths if self.in_scope(path, judge_own=judge_own)]
+ def _rename_range(self) -> list[str] | None:
+ """The git-diff scope whose renames the baseline follows; None when this context has none."""
+ return self._range()
+
+ def _renames(self) -> dict[str, str]:
+ """{new path: old path} for what git itself reports as renamed (`-M`, default similarity); never a guess.
+
+ A listing that fails or does not parse says no rename, which leaves the baseline at the path (stricter).
+ """
+ if self._rename_map is None:
+ scope, tokens = self._rename_range(), []
+ if scope is not None:
+ with contextlib.suppress(ListingError):
+ tokens = self._listing("diff", *scope, "-M", "--relative", "--name-status", "--diff-filter=R")
+ self._rename_map = {tokens[i + 2]: tokens[i + 1] for i in range(0, len(tokens) - 2, 3)}
+ return self._rename_map
+
def _diff_text(self, path: str) -> str:
"""`path`'s `-U0` diff as git writes it, unconverted; raises DiffError when git fails."""
- args = ("diff", *self._range(), "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--", path)
+ old = self._renames().get(path)
+ paths = (path, old) if old else (path,)
+ args = ("diff", *self._range(), "-M", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--", *paths)
try:
proc = subprocess.run( # noqa: S603 -- reading repo facts via git is this class's whole job
[_GIT, "--literal-pathspecs", *args],
@@ -163,16 +184,19 @@ def staged_blob(self, path: str) -> str:
"""The proposed content: staged in index mode, committed at HEAD in range mode."""
return self._git("show", f"HEAD:{path}" if self.base else f":{path}")
+ def renamed_from(self, path: str) -> str: # the old path git reports, else `path`
+ return self._renames().get(path, path)
+
def head_blob(self, path: str) -> str:
- """Content before the change, or "" when the path is new in it."""
- return self._git("show", f"{self.base or 'HEAD'}:{path}")
+ """Content before the change ("" when new); a renamed path reads its old path."""
+ return self._git("show", f"{self.base or 'HEAD'}:{self.renamed_from(path)}")
def committed_blob(self, path: str) -> str:
"""The file as HEAD has it, or "" when HEAD does not."""
return self._git("show", f"HEAD:{path}")
def net_added_lines(self, path: str) -> list[str]:
- """The lines this change introduces; at a commit that is what `added_lines` already says."""
+ """The lines this change introduces: at a commit, `added_lines`."""
return self.added_lines(path)
def current_branch(self) -> str:
@@ -234,6 +258,10 @@ def __init__(
self._added = dict(added or {})
self._stop = stop
+ def _rename_range(self) -> list[str] | None:
+ """At the turn's end, HEAD against the index and tree; a write before the tool runs has no rename."""
+ return ["HEAD"] if self._stop else None
+
def staged_paths(self, diff_filter: str = "ACMRT", *, judge_own: bool = False) -> list[str]:
"""Every write is a present file, so a filter asking only for deletions finds none."""
if not set(diff_filter) & set("ACMRT"):
@@ -265,7 +293,7 @@ def committed_blob(self, path: str) -> str:
def head_blob(self, path: str) -> str:
"""The baseline: HEAD at the turn's end, else what is on disk now, which this write would replace."""
if self._stop:
- return self.committed_blob(path)
+ return self.committed_blob(self.renamed_from(path))
try:
return (self.repo_root / path).read_text(encoding="utf-8")
except (OSError, UnicodeDecodeError):
diff --git a/src/chock/gate/runner/script.py b/src/chock/gate/runner/script.py
index 098d3805..165e6d90 100644
--- a/src/chock/gate/runner/script.py
+++ b/src/chock/gate/runner/script.py
@@ -12,6 +12,7 @@
from pathlib import Path
from ..budget import ENGINE_BUDGET_SECONDS, run_tree
+from .constants import FLOOR_EVENT
from .context import GateContext, GateResult
# >>> gate.py 07
@@ -34,6 +35,15 @@
_FINDINGS_KEY = "findings"
+#: All a script gate's environment holds at the floor: no token, secret or runner variable reaches it.
+_FLOOR_ENV_KEYS = ("PATH", "HOME", "SYSTEMROOT")
+
+
+def _env(event: object) -> dict[str, str]:
+ if event == FLOOR_EVENT:
+ return {key: os.environ[key] for key in _FLOOR_ENV_KEYS if key in os.environ} | _BYTECODE_OFF
+ return {**os.environ, **_BYTECODE_OFF}
+
def _spawn(script: Path, ctx: GateContext, payload: dict, timeout: float) -> subprocess.CompletedProcess[str]:
return run_tree(
@@ -44,7 +54,7 @@ def _spawn(script: Path, ctx: GateContext, payload: dict, timeout: float) -> sub
encoding="utf-8",
errors="replace",
cwd=ctx.repo_root,
- env={**os.environ, **_BYTECODE_OFF},
+ env=_env(payload.get("event")),
timeout=timeout,
check=False,
)
@@ -99,13 +109,35 @@ def _new_findings(found: list[dict], baseline: list[dict]) -> list[dict]:
return fresh
+#: A finding's optional `tier`, ranked; a verdict is the highest among the findings the change adds.
+_TIER_RANK = {"warn": 1, "ask": 2, "block": 3}
+
+
+def _tier_verdict(fresh: list[dict]) -> str | None:
+ """The verdict word ("" blocks) when every kept finding carries a known tier, else None: the exit code decides."""
+ tiers = [item.get("tier") for item in fresh]
+ if not all(isinstance(tier, str) and tier in _TIER_RANK for tier in tiers):
+ return None
+ top = max(tiers, key=_TIER_RANK.__getitem__)
+ return "" if top == "block" else top
+
+
def _baseline_findings(ctx: GateContext, script: Path, material: dict, started: float) -> list[dict]:
"""What the script finds in the baseline text of the change's files; empty when it cannot say.
- A new file has no baseline and is left out. A run that fails, times out, prints no findings
- document, or has no budget left contributes nothing, which errs toward blocking.
+ A new file has no baseline and is left out. A renamed file is judged as it was before the change:
+ its old content at its OLD path, so a finding that exists because of the new name is not in the
+ baseline; findings are mapped back to the new path, where a content finding is the same one.
+ A run that fails, times out, prints no findings document, or has no budget left contributes
+ nothing, which errs toward blocking.
"""
- texts = {path: text for path in material["writes"] if (text := ctx.head_blob(path))}
+ writes, texts, back = material["writes"], {}, {}
+ for path in writes:
+ if not (text := ctx.head_blob(path)):
+ continue
+ old = ctx.renamed_from(path)
+ old = path if old in writes or old in texts else old # never shadow another file in the same run
+ texts[old], back[old] = text, path
remaining = _SCRIPT_TIMEOUT_SECONDS - (time.monotonic() - started)
if not texts or remaining <= 0:
return []
@@ -113,7 +145,9 @@ def _baseline_findings(ctx: GateContext, script: Path, material: dict, started:
proc = _spawn(script, ctx, {**material, "writes": texts, "baseline": True}, remaining)
except (subprocess.TimeoutExpired, OSError):
return []
- return _findings_document(proc.stdout or "") or []
+ return [
+ {**item, "path": back.get(item["path"], item["path"])} for item in _findings_document(proc.stdout or "") or []
+ ]
def _exit_verdict(script: Path, proc: subprocess.CompletedProcess[str]) -> GateResult:
@@ -137,7 +171,7 @@ def _exit_verdict(script: Path, proc: subprocess.CompletedProcess[str]) -> GateR
def _judge_findings(
ctx: GateContext, script: Path, material: dict, proc: subprocess.CompletedProcess[str], started: float
) -> GateResult:
- """Judge only the findings the change introduces; the change-run's exit code is the verdict for them."""
+ """Judge only the findings the change introduces: the highest tier among them, else the change-run's exit code."""
if proc.returncode not in (_SCRIPT_ALLOW, _SCRIPT_BLOCK, _SCRIPT_ASK, _SCRIPT_WARN):
# A document followed by a crash or an unknown exit is undecided, never a clean pass.
return _exit_verdict(script, proc)
@@ -150,7 +184,9 @@ def _judge_findings(
if not fresh or proc.returncode == _SCRIPT_ALLOW:
return GateResult(allowed=True, detail=counts)
lines = [f"{item['path']}:{item['line']}: {item['message']}" for item in fresh]
- verdict = {_SCRIPT_ASK: "ask", _SCRIPT_WARN: "warn"}.get(proc.returncode, "")
+ verdict = _tier_verdict(fresh)
+ if verdict is None:
+ verdict = {_SCRIPT_ASK: "ask", _SCRIPT_WARN: "warn"}.get(proc.returncode, "")
return GateResult(
allowed=False, matches=lines, verdict=verdict, detail=counts, rules=_rule_ids(fresh), findings=fresh
)
@@ -159,7 +195,7 @@ def _judge_findings(
def _kind_script(ctx: GateContext, params: dict, event: str) -> GateResult:
"""Hand the material to the policy's own script and carry back its verdict.
- The script reads `{"event", "repo_root", "writes": {path: text}}` on stdin -- the staged
+ The script reads `{"event", "repo_root", "writes": {path: text}}` on stdin (plus `deleted` at the floor) -- the staged
blobs at commit and push, the write itself at tool use and at the turn's end -- so one
script serves every surface the declarative kinds do, and reads them the same way. It
answers with an exit code: 0 allows; 1 refuses, 3 asks, 4 warns, with its own words on stderr.
@@ -175,9 +211,13 @@ def _kind_script(ctx: GateContext, params: dict, event: str) -> GateResult:
if not script.is_file():
return GateResult(allowed=False, message=f"script gate: {named!r} is not installed{_UNDECIDED}")
writes = {path: ctx.staged_blob(path) for path in ctx.staged_paths()}
- if not writes:
+ # Only the floor hands a script the deleted paths: the contract every other event has is unchanged.
+ deleted = sorted(ctx.staged_paths("D")) if event == FLOOR_EVENT else []
+ if not writes and not deleted:
return GateResult(allowed=True)
material = {"event": event, "repo_root": str(ctx.repo_root), "writes": writes}
+ if event == FLOOR_EVENT:
+ material["deleted"] = deleted
if ctx.session:
material["session"] = ctx.session
started = time.monotonic()
diff --git a/src/chock/gate/sarif.py b/src/chock/gate/sarif.py
index e7b4ae2a..8d9aaa49 100644
--- a/src/chock/gate/sarif.py
+++ b/src/chock/gate/sarif.py
@@ -6,6 +6,7 @@
from __future__ import annotations
+import argparse
import hashlib
import json
import re
@@ -282,3 +283,12 @@ def emit(repo: Path, base: str, head_ref: str | None, output: str | None) -> int
return 2
sys.stderr.write(f"sarif: {len(log['runs'][0]['results'])} result(s) written to {output}\n")
return code
+
+
+def check_main(args: argparse.Namespace, parser: argparse.ArgumentParser) -> int:
+ """`chock check --format sarif`; the exit code is the gate step's own (0, 1 on a block, 2 undecided)."""
+ if args.format != "sarif":
+ parser.error("--output and --head-ref go with --format sarif")
+ if args.event != "ci" or not args.base or args.only or args.mode:
+ parser.error("--format sarif needs --event ci and --base, and takes no --only or --mode")
+ return emit(Path(args.repo), args.base, args.head_ref, args.output)
diff --git a/src/chock/gate/tool_call_gate.py b/src/chock/gate/tool_call_gate.py
index 9a8c63a8..2fdd473a 100644
--- a/src/chock/gate/tool_call_gate.py
+++ b/src/chock/gate/tool_call_gate.py
@@ -11,18 +11,17 @@
import fnmatch
import json
-import os
import subprocess
import sys
from pathlib import Path
from .budget import (
- BYTECODE_OFF,
PATTERN_SECONDS,
allowed_seconds,
close_judge,
engine_deadline,
engine_remaining,
+ isolated_child,
judge_patterns,
pattern_judge,
run_tree,
@@ -98,7 +97,7 @@ def _tool_call_script(spec, root, payload, deadline=None):
if not script.is_file():
return ("deny", f"script gate: {named!r} is not installed{_TOOL_CALL_UNDECIDED}")
deadline = engine_deadline() if deadline is None else deadline
- argv = [sys.executable, str(script)]
+ argv, env = isolated_child([sys.executable, str(script)])
try:
proc = run_tree(
argv,
@@ -108,7 +107,7 @@ def _tool_call_script(spec, root, payload, deadline=None):
encoding="utf-8",
errors="replace",
cwd=str(root),
- env={**os.environ, **BYTECODE_OFF},
+ env=env,
timeout=time_left(deadline, argv),
check=False,
)
diff --git a/src/chock/gate/write_gate.py b/src/chock/gate/write_gate.py
index f6aaef80..3879fa09 100644
--- a/src/chock/gate/write_gate.py
+++ b/src/chock/gate/write_gate.py
@@ -16,7 +16,7 @@
import sys
from pathlib import Path
-from .budget import allowed_seconds, engine_deadline, last_state, run_tree, time_left
+from .budget import allowed_seconds, engine_deadline, isolated_child, last_state, run_tree, time_left
from .decision_log import GATE_LAST
from .decision_target import dlog_fields
from .edit_image import added_from_event, created_text, edited_text
@@ -167,10 +167,11 @@ def run_gate(gate, writes, event, run_in, deadline):
runner = runner_for(gate)
if runner is None:
return GATE_ERRORED, "the vendored gate runner is not installed beside this gate"
- argv = [sys.executable, str(runner), "run", "--gate", str(gate), "--event", event]
+ argv, env = isolated_child([sys.executable, str(runner), "run", "--gate", str(gate), "--event", event])
try:
proc = run_tree(
argv,
+ env=env,
input=json.dumps({"writes": writes, **(extra or {})}),
capture_output=True,
text=True,
diff --git a/src/chock/history/gates.py b/src/chock/history/gates.py
index e39b83fd..be73efad 100644
--- a/src/chock/history/gates.py
+++ b/src/chock/history/gates.py
@@ -65,10 +65,22 @@ def _rule(repo: Path, gate_path: Path, spec: dict) -> Rule:
)
-def load_rules(repo: Path) -> tuple[list[Rule], list[str]]:
- """(applicable rules, ids of installed commit gates this scan cannot apply), both in policy order."""
+def _same(one: Rule, other: Rule) -> bool:
+ shape = ("policy", "content_pattern", "path_pattern", "pragma_pattern")
+ same = all(getattr(one, key) == getattr(other, key) for key in shape)
+ return same and (one.judge.scope, one.judge.own) == (other.judge.scope, other.judge.own)
+
+
+def load_rules(repo: Path, surfaces: tuple[str, ...] = (GATE_FILE[0],)) -> tuple[list[Rule], list[str]]:
+ """(applicable rules, ids of installed commit gates this scan cannot apply), both in policy order.
+
+ `surfaces` are the compiled surfaces read (the git-hook one by default); a rule two surfaces share is kept once.
+ """
root = repo.joinpath(*COMPILED)
- gates = sorted(root.glob("*/" + "/".join(GATE_FILE))) if root.is_dir() else []
+ found = (
+ {path for surface in surfaces for path in root.glob(f"*/{surface}/{GATE_FILE[1]}")} if root.is_dir() else set()
+ )
+ gates = sorted(found)
rules: list[Rule] = []
skipped: list[str] = []
for gate_path in gates:
@@ -82,8 +94,10 @@ def load_rules(repo: Path) -> tuple[list[Rule], list[str]]:
if EVENT not in spec.get("on", []):
continue
if spec.get("kind") == KIND:
- rules.append(_rule(repo, gate_path, spec))
- else:
+ rule = _rule(repo, gate_path, spec)
+ if not any(_same(rule, kept) for kept in rules):
+ rules.append(rule)
+ elif name not in skipped:
skipped.append(gate_path.parents[1].name)
if not rules:
raise HistoryError("no installed content gates found under .chock/compiled; run `chock sync` first")
diff --git a/src/chock/history/gitlog.py b/src/chock/history/gitlog.py
index 885de0ef..d0dea963 100644
--- a/src/chock/history/gitlog.py
+++ b/src/chock/history/gitlog.py
@@ -112,12 +112,12 @@ def is_shallow(repo: Path) -> bool:
return _git(repo, ["rev-parse", "--is-shallow-repository"]).decode().strip() == "true"
-def _range(since: str | None) -> list[str]:
- return [f"{since}..HEAD"] if since else ["HEAD"]
+def _range(since: str | None, head: str = "HEAD") -> list[str]:
+ return [f"{since}..{head}"] if since else [head]
-def count_commits(repo: Path, since: str | None) -> int:
- return int(_git(repo, ["rev-list", "--count", *_range(since), "--"]).decode().strip() or 0)
+def count_commits(repo: Path, since: str | None, head: str = "HEAD") -> int:
+ return int(_git(repo, ["rev-list", "--count", *_range(since, head), "--"]).decode().strip() or 0)
def _stream_tokens(proc: subprocess.Popen[bytes]) -> Iterator[bytes]:
@@ -152,12 +152,12 @@ def _records(tokens: Iterator[bytes], log: Log) -> Iterator[tuple[str, str, str]
yield commit, fields[3], path
-def touches(repo: Path, since: str | None, max_commits: int) -> Log:
+def touches(repo: Path, since: str | None, max_commits: int, head: str = "HEAD", *, renames: bool = True) -> Log:
"""Blobs added or changed per commit, oldest commit first (the newest `max_commits` of the range)."""
args = [
- "log", "-z", "--raw", "-m", "-M", "--topo-order", "--reverse", "--no-abbrev",
+ "log", "-z", "--raw", "-m", "-M" if renames else "--no-renames", "--topo-order", "--reverse", "--no-abbrev",
"--no-ext-diff", "--no-textconv", "--no-show-signature", "--diff-filter=ACMRT",
- "-n", str(max_commits), "--format=%x01%H", *_range(since), "--",
+ "-n", str(max_commits), "--format=%x01%H", *_range(since, head), "--",
] # fmt: skip
result = Log()
seen: set[Touch] = set()
diff --git a/src/chock/history/scan.py b/src/chock/history/scan.py
index db6e3fee..b67254e5 100644
--- a/src/chock/history/scan.py
+++ b/src/chock/history/scan.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import contextlib
import hashlib
import shutil
import sys
@@ -31,6 +32,8 @@ class Finding:
line: int | None
rule: str
policy: str
+ #: The matched line's digest (the forbidden-path rule's name for a path finding), as the scan read it.
+ key: str = ""
def as_dict(self) -> dict[str, object]:
return {"commit": self.commit, "path": self.path, "line": self.line, "rule": self.rule, "policy": self.policy}
@@ -46,6 +49,9 @@ class Report:
skipped_submodules: int = 0
truncated: bool = False
shallow: bool = False
+ #: (commit, path, why) of every introduced blob this scan did not judge; filled when Limits.judge_binary is set.
+ unread: list[tuple[str, str, str]] = field(default_factory=list)
+ _unread_oids: dict[str, str] = field(default_factory=dict)
@dataclass(frozen=True)
@@ -54,6 +60,11 @@ class Limits:
max_blob_bytes: int = DEFAULT_MAX_BLOB_BYTES
allow_shallow: bool = False
time_budget: int = DEFAULT_TIME_BUDGET
+ #: The floor's reader: every blob is judged (binary too) in each of `floor_texts`, and a blob still not
+ #: judged (over max_blob_bytes) is named in Report.unread.
+ judge_binary: bool = False
+ #: False reads a rename as a delete and an add (`--no-renames`), as the floor's tree diff does.
+ renames: bool = True
def _say(message: str) -> None:
@@ -85,10 +96,35 @@ def _judged(judge: dict, policy: str, jobs: list[tuple[str, list[str]]]) -> list
return [set(found) for found in hits]
-def _judge_blob(rules: list[Rule], data: bytes, judge: dict) -> tuple[list[tuple[int, int, str]], set[int]]:
+_UTF16 = ("utf-16-le", "utf-16-be")
+
+
+def floor_texts(data: bytes) -> list[str]:
+ """Every reading the floor judges: latin-1 (lossless), utf-8 when the bytes are utf-8, and, when the blob
+ holds a NUL byte, utf-16 in both byte orders at both alignments (a BOM decodes to U+FEFF, a stray byte shifts)."""
+ texts = [data.decode("latin-1")]
+ with contextlib.suppress(UnicodeDecodeError):
+ texts.append(data.decode("utf-8"))
+ if b"\0" in data:
+ texts += [data[skip:].decode(codec, "replace") for codec in _UTF16 for skip in (0, 1)]
+ return texts
+
+
+def floor_lines(data: bytes) -> list[str]:
+ """`floor_texts`, each split on `\\n` only: one line list, so a line number never needs a second count."""
+ return [line for text in floor_texts(data) for line in text.split("\n")]
+
+
+def _judge_blob(
+ rules: list[Rule], data: bytes, judge: dict, *, lossless: bool = False
+) -> tuple[list[tuple[int, int, str]], set[int]]:
"""(rule index, line number, line digest) per hit, and the rules whose waiver pragma the blob carries."""
- text = data.decode("utf-8", "replace")
- lines = text.splitlines()
+ if lossless:
+ lines = floor_lines(data)
+ text = "\n".join(lines)
+ else:
+ text = data.decode("utf-8", "replace")
+ lines = text.splitlines()
hits: list[tuple[int, int, str]] = []
waived: set[int] = set()
for index, rule in enumerate(rules):
@@ -109,6 +145,14 @@ def _read_judged(repo: Path, rules: list[Rule], oids: list[str], limits: Limits,
if missing:
raise gitlog.HistoryError(f"{len(missing)} blob(s) missing from the object database, e.g. {missing[0]}")
report.skipped_oversize = sum(1 for o in oids if sizes[o] > limits.max_blob_bytes)
+ if limits.judge_binary:
+ report._unread_oids.update(
+ {
+ o: f"{sizes[o]} bytes, over the {limits.max_blob_bytes}-byte limit"
+ for o in oids
+ if sizes[o] > limits.max_blob_bytes
+ }
+ )
wanted = [o for o in oids if 0 < sizes[o] <= limits.max_blob_bytes]
deadline = time.monotonic() + limits.time_budget
judged: Judged = {}
@@ -119,10 +163,10 @@ def _read_judged(repo: Path, rules: list[Rule], oids: list[str], limits: Limits,
raise gitlog.HistoryError(
f"time budget of {limits.time_budget}s exceeded; narrow with --since or --max-commits"
)
- if gitlog.is_binary(data):
+ if gitlog.is_binary(data) and not limits.judge_binary:
report.skipped_binary += 1
else:
- judged[oid] = _judge_blob(rules, data, judge)
+ judged[oid] = _judge_blob(rules, data, judge, lossless=limits.judge_binary)
report.blobs_scanned += 1
if done % _PROGRESS_EVERY == 0:
_say(f"history: read {done}/{len(wanted)} blobs")
@@ -155,7 +199,7 @@ def add(item: gitlog.Touch, rule: Rule, kind: str, line: int | None, key: str) -
marker = (item.path, rule.policy, key)
if marker not in seen:
seen.add(marker)
- found.append(Finding(item.commit, item.path, line, kind, rule.policy))
+ found.append(Finding(item.commit, item.path, line, kind, rule.policy, key))
for item in touched:
hits, waived = judged.get(item.oid, ([], set()))
@@ -168,7 +212,7 @@ def add(item: gitlog.Touch, rule: Rule, kind: str, line: int | None, key: str) -
return found
-def scan(repo: Path, rules: list[Rule], since: str | None, limits: Limits) -> Report:
+def scan(repo: Path, rules: list[Rule], since: str | None, limits: Limits, head: str = "HEAD") -> Report:
report = Report(shallow=gitlog.is_shallow(repo))
if report.shallow:
if not limits.allow_shallow:
@@ -177,16 +221,19 @@ def scan(repo: Path, rules: list[Rule], since: str | None, limits: Limits) -> Re
"would claim too much. Fetch full history (git fetch --unshallow) or pass --allow-shallow."
)
_say("history: WARNING shallow clone; commits beyond the shallow boundary were not scanned")
- in_range = gitlog.count_commits(repo, since)
+ in_range = gitlog.count_commits(repo, since, head)
report.truncated = in_range > limits.max_commits
report.commits = min(in_range, limits.max_commits)
_say(f"history: listing up to {report.commits} of {in_range} commits")
- log = gitlog.touches(repo, since, limits.max_commits)
+ log = gitlog.touches(repo, since, limits.max_commits, head, renames=limits.renames)
report.skipped_submodules = log.submodules
oids = sorted({t.oid for t in log.touches})
_say(f"history: {len(log.touches)} changed paths, {len(oids)} distinct blobs")
judged = _read_judged(repo, rules, oids, limits, report)
report.findings = _collect(log.touches, rules, judged)
+ report.unread = [
+ (t.commit, t.path, report._unread_oids[t.oid]) for t in log.touches if t.oid in report._unread_oids
+ ]
_say(
f"history: skipped {report.skipped_binary} binary, {report.skipped_oversize} oversize blobs "
f"and {report.skipped_submodules} submodule pointers (not scanned)"
diff --git a/src/chock/hooks/data/launch.sh b/src/chock/hooks/data/launch.sh
index e3cd4948..fe887da2 100644
--- a/src/chock/hooks/data/launch.sh
+++ b/src/chock/hooks/data/launch.sh
@@ -21,17 +21,20 @@ configured="$(git config --get chock.python 2>/dev/null)"
legacy=
case "${OS:-}|${MSYSTEM:-}" in *Windows_NT*|*"|"?*) legacy=1 ;; esac
[ "$runtime" = "-m" ] && legacy=1
+# A script starts with -E -s (-I less -P): no PYTHON* variable or user site changes it; its own folder stays on the path.
+isolate=-Es
+[ "$runtime" = "-m" ] && isolate=
# Only the marker path sets it (to 9); everywhere else an inherited value is cleared, so it never names an fd.
[ -n "$legacy" ] && { CHOCK_START_FD=; export CHOCK_START_FD; }
for candidate in "$configured" python3 python py; do
[ -n "$candidate" ] || continue
if [ -n "$legacy" ]; then
- if probed="$("$candidate" -c 'import sys; print("chock-python"); sys.exit(sys.version_info < (__MIN_PYTHON__,))' /dev/null)" && [ "$probed" = "chock-python" ]; then
- exec "$candidate" -X utf8 "$runtime" "$@"
+ if probed="$("$candidate" -I -c 'import sys; print("chock-python"); sys.exit(sys.version_info < (__MIN_PYTHON__,))' /dev/null)" && [ "$probed" = "chock-python" ]; then
+ exec "$candidate" ${isolate:+"$isolate"} -X utf8 "$runtime" "$@"
fi
elif command -v "$candidate" >/dev/null 2>&1; then
exec 3>&1
- marker="$(CHOCK_START_FD=9 "$candidate" -X utf8 "$runtime" "$@" 9>&1 1>&3 3>&-)"
+ marker="$(CHOCK_START_FD=9 "$candidate" ${isolate:+"$isolate"} -X utf8 "$runtime" "$@" 9>&1 1>&3 3>&-)"
status=$?
exec 3>&-
[ "$marker" = "chock-python" ] && exit "$status"
diff --git a/src/chock/index/builder.py b/src/chock/index/builder.py
index 067987b3..1599a4df 100644
--- a/src/chock/index/builder.py
+++ b/src/chock/index/builder.py
@@ -12,7 +12,7 @@
from chock.compile.surface_kinds import Surface
from chock.config import _disabled_list, load_config, policy_status
from chock.gate.build import build_gate_json
-from chock.manifest import ManifestSourceError, load_manifest
+from chock.manifest import ManifestSourceError, load_manifest, warn_defaults
from chock.output import warn
_ENFORCEMENT_ORDER = {"block": 0, "verify": 1, "advise": 2}
@@ -47,15 +47,17 @@ def _default_id(artifact_dir: Path, manifest: dict[str, Any]) -> str:
def _load_policy(root: Path, artifact_dir: Path, warnings: list[str]) -> tuple[dict[str, Any], str] | None:
- """Return (manifest, manifest_relative_path) or None on any failure."""
+ """Return (manifest, manifest_relative_path) or None on any failure; defaulted fields are printed, once, here."""
+ defaults: list[str] = []
try:
- result = load_manifest(artifact_dir, warnings=warnings)
+ result = load_manifest(artifact_dir, warnings=defaults)
except (yaml.YAMLError, OSError, ManifestSourceError) as exc:
warnings.append(f"{artifact_dir}: manifest_parse: {exc}")
return None
if result is None:
return None
manifest, manifest_path = result
+ warn_defaults(manifest_path, defaults)
rel_path = manifest_path.relative_to(root).as_posix()
return manifest, rel_path
diff --git a/src/chock/lifecycle.py b/src/chock/lifecycle.py
index 2319dceb..f76df67d 100644
--- a/src/chock/lifecycle.py
+++ b/src/chock/lifecycle.py
@@ -102,17 +102,6 @@ def _run_mechanisms(args: argparse.Namespace) -> int:
return _run("matrix mechanisms", mechanisms_main, ["--repo", args.repo])
-def _sarif_main(args: argparse.Namespace, parser: argparse.ArgumentParser) -> int:
- """The ci gates' findings as SARIF; the exit code is the gate step's own (0, 1 on a block, 2 undecided)."""
- if args.format != "sarif":
- parser.error("--output and --head-ref go with --format sarif")
- if args.event != "ci" or not args.base or args.only or args.mode:
- parser.error("--format sarif needs --event ci and --base, and takes no --only or --mode")
- from chock.gate.sarif import emit
-
- return emit(Path(args.repo), args.base, args.head_ref, args.output)
-
-
def _check_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(prog="chock check")
parser.add_argument("--repo", default=".", help="Repo root")
@@ -127,9 +116,10 @@ def _check_parser() -> argparse.ArgumentParser:
help="sarif: run the compiled ci gates (needs --event ci and --base) and print their findings as SARIF 2.1.0",
)
parser.add_argument("--output", default=None, help="With --format sarif: write the log to this file, not stdout")
- parser.add_argument(
- "--head-ref", default=None, help="With --format sarif: the branch under test ($GITHUB_HEAD_REF)"
- )
+ parser.add_argument("--head-ref", default=None, help="With --format sarif or --floor: the branch under test")
+ from chock.validation.floor_cli import add_arguments
+
+ add_arguments(parser)
return parser
@@ -161,8 +151,14 @@ def check_main(argv: list[str] | None) -> int:
"""Run every truth check: validate, verify, evals, matrix, index freshness, conflicts."""
parser = _check_parser()
args = parser.parse_args(argv)
+ if args.floor or args.head:
+ from chock.validation.floor_cli import from_check
+
+ return from_check(args, parser)
if args.format == "sarif" or args.output or args.head_ref:
- return _sarif_main(args, parser)
+ from chock.gate.sarif import check_main as sarif_main
+
+ return sarif_main(args, parser)
selected = _selected_checks(args.only)
if selected is None:
diff --git a/src/chock/lock.py b/src/chock/lock.py
index 1a0e1b5b..e55c3249 100644
--- a/src/chock/lock.py
+++ b/src/chock/lock.py
@@ -9,13 +9,12 @@
from pathlib import Path
from typing import Any
+from chock.lock_engine import LOCKFILE_NAME, engine_constraint, engine_failures
from chock.policies import discover_policy_dirs
from chock.scaffold.pin import is_remote_source
from chock.vendored import vendored_differences
-LOCKFILE_NAME = "chock.lock"
LOCKFILE_VERSION = "2"
-ENGINE_CONSTRAINT = ">=0.1,<0.2"
POLICIES_REL = Path(".agents") / "policies"
LOCAL_SOURCE = "local"
_PROVENANCE_KEYS = ("source", "source_commit", "source_ref")
@@ -121,7 +120,7 @@ def read_lock(repo_root: Path | None = None) -> dict[str, Any]:
repo_root = repo_root or Path.cwd().resolve()
path = repo_root / LOCKFILE_NAME
if not path.exists():
- return {"lockfile_version": LOCKFILE_VERSION, "engine": ENGINE_CONSTRAINT, "packs": []}
+ return {"lockfile_version": LOCKFILE_VERSION, "engine": engine_constraint(), "packs": []}
try:
loaded = json.loads(path.read_text(encoding="utf-8"))
except (json.JSONDecodeError, UnicodeDecodeError) as exc:
@@ -189,7 +188,7 @@ def build_lock(repo_root: Path) -> dict[str, Any]:
prior = _prior_provenance(repo_root)
lock: dict[str, Any] = {
"lockfile_version": LOCKFILE_VERSION,
- "engine": ENGINE_CONSTRAINT,
+ "engine": engine_constraint(),
"packs": [],
}
for pack_dir in discover_policy_dirs(repo_root):
@@ -213,14 +212,14 @@ def build_lock(repo_root: Path) -> dict[str, Any]:
return lock
-def verify_lock(repo_root: Path | None = None) -> tuple[bool, list[str]]:
- """Recompute pack and compiled-artifact hashes and report drift."""
+def verify_lock(repo_root: Path | None = None, notes: list[str] | None = None) -> tuple[bool, list[str]]:
+ """Check the running engine against the lock's constraint, recompute hashes, and report drift."""
repo_root = repo_root or Path.cwd().resolve()
try:
lock = read_lock(repo_root)
except LockError as exc:
return False, [str(exc)]
- failures: list[str] = []
+ failures = engine_failures(lock, notes)
failures += [
f"vendored runtime modified ({d}) -- this is what executes gates" for d in vendored_differences(repo_root)
@@ -284,7 +283,10 @@ def main(argv: list[str] | None = None) -> int:
print(f"Wrote {LOCKFILE_NAME} with {len(lock['packs'])} pack(s)")
return 0
if args.command == "verify":
- ok, failures = verify_lock(repo_root)
+ notes: list[str] = []
+ ok, failures = verify_lock(repo_root, notes)
+ for note in notes:
+ print(note)
if ok:
print("verify: all packs match lockfile")
return 0
diff --git a/src/chock/lock_engine.py b/src/chock/lock_engine.py
new file mode 100644
index 00000000..c92bb954
--- /dev/null
+++ b/src/chock/lock_engine.py
@@ -0,0 +1,69 @@
+"""chock.lock's `engine` constraint: derived from the running engine, checked against it (IR-F71)."""
+
+from __future__ import annotations
+
+import re
+from typing import Any
+
+from chock import __version__
+
+LOCKFILE_NAME = "chock.lock"
+#: What every lock said before the field was read; such a lock passes with a note to re-lock.
+LEGACY_ENGINE_CONSTRAINT = ">=0.1,<0.2"
+_VERSION_PREFIX = re.compile(r"(\d+)\.(\d+)(?:\.(\d+))?")
+_CONSTRAINT_RE = re.compile(r"\s*>=\s*(\d+(?:\.\d+){0,2})\s*,\s*<\s*(\d+(?:\.\d+){0,2})\s*")
+
+
+def _version_tuple(version: str) -> tuple[int, int, int] | None:
+ """(major, minor, patch) from the leading digits of a version string; None when it has none."""
+ match = _VERSION_PREFIX.match(version.strip())
+ if not match:
+ return None
+ major, minor, patch = match.groups()
+ return int(major), int(minor), int(patch or 0)
+
+
+def _padded(dotted: str) -> tuple[int, int, int]:
+ """A constraint bound as (major, minor, patch), missing parts 0."""
+ major, minor, patch, *_ = [*(int(p) for p in dotted.split(".")), 0, 0]
+ return major, minor, patch
+
+
+def engine_constraint(version: str = __version__) -> str:
+ """The constraint a lock written by engine `version` carries: `>=.,<`."""
+ parsed = _version_tuple(version)
+ if parsed is None:
+ msg = f"engine version {version!r} has no . prefix"
+ raise ValueError(msg)
+ major, minor, _patch = parsed
+ return f">={major}.{minor},<{major + 1}"
+
+
+def check_engine(constraint: object, version: str = __version__) -> tuple[str | None, str | None]:
+ """(failure, note) for the running engine against a lock's `engine` field; both None when it satisfies it."""
+ relock = "or run `chock sync --repo .` with the newer engine to re-lock"
+ if constraint == LEGACY_ENGINE_CONSTRAINT:
+ return None, (
+ f"note: {LOCKFILE_NAME} engine constraint {constraint!r} was written before constraints were read; "
+ "run `chock sync --repo .` to record this engine's constraint"
+ )
+ match = _CONSTRAINT_RE.fullmatch(constraint) if isinstance(constraint, str) else None
+ running = _version_tuple(version)
+ if match is None or running is None:
+ what = f"engine {version}" if running is None else f"{LOCKFILE_NAME} engine constraint {constraint!r}"
+ return f"{what} cannot be read; expected `>=X.Y, list[str]:
+ """`check_engine` on a lock: its failure as a list, its note appended to `notes` when given."""
+ failure, note = check_engine(lock.get("engine"))
+ if note and notes is not None:
+ notes.append(note)
+ return [failure] if failure else []
diff --git a/src/chock/manifest.py b/src/chock/manifest.py
index f58ada09..1a26c5a9 100644
--- a/src/chock/manifest.py
+++ b/src/chock/manifest.py
@@ -8,6 +8,7 @@
import yaml
from chock import yamlio
+from chock.output import warn_once
from chock.skill_metadata import _as_bool, _as_list, _chock_metadata
CANONICAL_MANIFEST = "manifest.yaml"
@@ -20,6 +21,10 @@
DETERMINIZATION_REVIEWED_KEY = "determinization_reviewed"
AGENT_SPECIFIC_VOCABULARY_KEY = "agent_specific_vocabulary"
+#: Finding check name for a field the manifest left out and chock filled in.
+MANIFEST_DEFAULT = "manifest_default"
+_ARTIFACT_FILES = frozenset({CANONICAL_MANIFEST, SKILL_MD, INTERFACE_YAML})
+
#: Longest a manifest/frontmatter `name` may be before it's flagged.
_MAX_NAME_LENGTH = 128
@@ -28,6 +33,27 @@ class ManifestSourceError(Exception):
"""A manifest directory has an ambiguous or incomplete source of truth."""
+def artifact_key(path: Path | str) -> str:
+ """One artifact's identity whether a caller names its folder or its manifest file."""
+ found = Path(path)
+ return (found.parent if found.name in _ARTIFACT_FILES else found).resolve().as_posix()
+
+
+def shown_path(path: Path | str) -> str:
+ """`path` relative to the working directory when it is under it."""
+ found = Path(path)
+ try:
+ return found.resolve().relative_to(Path.cwd().resolve()).as_posix()
+ except ValueError:
+ return found.as_posix()
+
+
+def warn_defaults(path: Path | str, warnings: list[str]) -> None:
+ """Print each defaulted field once per command, always with the artifact's path."""
+ for warning in warnings:
+ warn_once((artifact_key(path), warning), f"{shown_path(path)}: {MANIFEST_DEFAULT}: {warning}")
+
+
def _set_or_default(
data: dict[str, Any],
dotted_path: str,
diff --git a/src/chock/output.py b/src/chock/output.py
index 30779923..cb5c35e1 100644
--- a/src/chock/output.py
+++ b/src/chock/output.py
@@ -1,8 +1,10 @@
-"""Shared stderr diagnostics: one place owning the `[WARN]`/`[ERROR]` prefix convention."""
+"""Shared console output: the `[WARN]`/`[ERROR]` prefix, say-once diagnostics, and text a console can show."""
from __future__ import annotations
+import codecs
import sys
+from typing import TextIO
# CodeQL (py/clear-text-logging-sensitive-data) flags both prints below by name-based
# heuristic, not by an actual credential flow: every caller passes a diagnostic string --
@@ -16,12 +18,77 @@
# pyproject.toml: this is the designated output surface, and the codeql[...] suppression
# comments below read as commented-out code to ERA001.
+#: Every non-ASCII character chock's own strings print, and its ASCII stand-in.
+ASCII_FOR = str.maketrans(
+ {
+ "\u2026": "...",
+ "\u2014": "--",
+ "\u2013": "-",
+ "\u2192": "->",
+ "\u2190": "<-",
+ "\u2264": "<=",
+ "\u2265": ">=",
+ "\u2208": " in ",
+ "\u2227": " and ",
+ "\u00a7": "s.",
+ "\u2500": "-",
+ "\u2502": "|",
+ "\u251c": "+",
+ "\u2514": "+",
+ "\u200c": "",
+ "\u200d": "",
+ "\ufeff": "",
+ }
+)
+
+_said: set[tuple[str, ...]] = set()
+
+
+def unicode_ok(stream: TextIO | None = None) -> bool:
+ """True only for a UTF stream: a legacy code page (cp1252) can encode U+2026 yet the console shows it as another letter."""
+ encoding = getattr(stream if stream is not None else sys.stdout, "encoding", None)
+ try:
+ return codecs.lookup(encoding or "ascii").name.startswith("utf")
+ except LookupError:
+ return False
+
+
+def legible(text: str, stream: TextIO | None = None) -> str:
+ """`text` for `stream`: on a non-UTF stream chock's own symbols become ASCII; other text is the stream's to encode."""
+ if text.isascii() or unicode_ok(stream):
+ return text
+ return text.translate(ASCII_FOR)
+
+
+def ellipsis(stream: TextIO | None = None) -> str:
+ return legible("\u2026", stream)
+
+
+def first_time(key: tuple[str, ...]) -> bool:
+ """True the first time this process asks about `key`; a fact is then said once per command."""
+ if key in _said:
+ return False
+ _said.add(key)
+ return True
+
+
+def new_command() -> None:
+ """Forget what was said: the once-per-command rule restarts with each `chock` command run in this process."""
+ _said.clear()
+
+
+def warn_once(key: tuple[str, ...], message: str) -> None:
+ if first_time(key):
+ warn(message)
+
def warn(message: str) -> None:
+ message = legible(message, sys.stderr)
# codeql[py/clear-text-logging-sensitive-data]
print(f"[WARN] {message}", file=sys.stderr)
def error(message: str) -> None:
+ message = legible(message, sys.stderr)
# codeql[py/clear-text-logging-sensitive-data]
print(f"[ERROR] {message}", file=sys.stderr)
diff --git a/src/chock/pipe.py b/src/chock/pipe.py
index b5b06606..b62efe71 100644
--- a/src/chock/pipe.py
+++ b/src/chock/pipe.py
@@ -7,6 +7,8 @@
import sys
from typing import Any, TextIO
+from chock.output import legible
+
def _is_broken_pipe(exc: OSError) -> bool:
return isinstance(exc, BrokenPipeError) or exc.errno in (errno.EPIPE, errno.EINVAL)
@@ -24,7 +26,7 @@ def write(self, text: str) -> int:
return len(text)
try:
try:
- return self._stream.write(text)
+ return self._stream.write(legible(text, self._stream))
except UnicodeEncodeError:
encoding = getattr(self._stream, "encoding", None) or "ascii"
return self._stream.write(text.encode(encoding, "backslashreplace").decode(encoding))
diff --git a/src/chock/registry/core.py b/src/chock/registry/core.py
index 4d4814e9..11014ef2 100644
--- a/src/chock/registry/core.py
+++ b/src/chock/registry/core.py
@@ -16,6 +16,7 @@
ManifestSourceError,
load_manifest,
resolve_manifest_path,
+ warn_defaults,
)
REGISTRY_DIR = Path(".chock")
@@ -195,8 +196,7 @@ def scan(
except (yaml.YAMLError, OSError, ManifestSourceError) as exc:
skips.append(SkippedManifest(manifest, f"{type(exc).__name__}: {exc}"))
continue
- for warning in warnings:
- print(f"[WARN] {entry.path} :: manifest_default: {warning}")
+ warn_defaults(manifest, warnings)
entries.setdefault(entry.id, []).append(entry)
return entries, skips
diff --git a/src/chock/scaffold/add.py b/src/chock/scaffold/add.py
index 2e815611..3ff2253c 100644
--- a/src/chock/scaffold/add.py
+++ b/src/chock/scaffold/add.py
@@ -12,6 +12,7 @@
import yaml
+from chock import __version__ as engine_version
from chock import yamlio
from chock.config import agents_from_config as _agents_from_config
from chock.lock import (
@@ -24,7 +25,7 @@
write_lock,
)
from chock.output import error
-from chock.scaffold.pin import PinError, fetch_catalog, redact_source
+from chock.scaffold.pin import PinError, fetch_catalog, redact_source, tag_commit
from chock.scaffold.recompile import BookkeepingError, recompile
@@ -178,6 +179,43 @@ def record_provenance(repo_root: Path, artifact_id: str, source: str, ref: str |
return
+def is_default_catalog(source: str) -> bool:
+ """True when `source` names the default catalog, however its URL ends."""
+
+ def bare(url: str) -> str:
+ return url.rstrip("/").removesuffix(".git")
+
+ return bare(source) == bare(DEFAULT_CATALOG)
+
+
+def default_tag(source: str, ref: str | None) -> str | None:
+ """The catalog release tag to fetch when none was asked for: the default catalog only."""
+ return f"v{engine_version}" if ref is None and is_default_catalog(source) else None
+
+
+def resolve_default_ref(source: str, tag: str) -> str:
+ """The commit the default catalog's release tag names; refuse rather than take the moving branch."""
+ commit = tag_commit(source, tag)
+ if commit is None:
+ msg = (
+ f"chock add: catalog {redact_source(source)} has no tag {tag} for this chock; "
+ "pin --ref <40-hex commit>, or --ref main to take the moving branch on purpose (nothing installed)"
+ )
+ raise PinError(msg)
+ return commit
+
+
+def _report(args: argparse.Namespace, added: Added, tag: str | None) -> None:
+ if added.commit:
+ print(f" from {redact_source(args.source)} at {added.commit}" + (f" (tag {tag})" if tag else ""))
+ print(f" sha256 {added.sha256}")
+ pin = f"--ref {added.commit}, or --verify-sha {added.sha256}"
+ if tag and added.commit:
+ print(f" (a tag can move; the strong pin is {pin})")
+ elif not args.ref and added.commit:
+ print(f" (unpinned: a later run may fetch another commit. Pin with {pin})")
+
+
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(
prog="chock add", description="Install a policy or skill from a catalog and compile it"
@@ -185,7 +223,12 @@ def main(argv: list[str] | None = None) -> int:
parser.add_argument("artifact_id", help="Policy or skill id, e.g. protect-main-branch")
parser.add_argument("--repo", default=".", help="Target repo root")
parser.add_argument("--from", dest="source", default=DEFAULT_CATALOG, help="Catalog URL or local path")
- parser.add_argument("--ref", default=None, help="Full 40-hex commit SHA (recommended), or a branch/tag (mutable)")
+ parser.add_argument(
+ "--ref",
+ default=None,
+ help="Full 40-hex commit SHA (recommended), or a branch/tag (mutable). "
+ "Default for the default catalog: the tag v; elsewhere: the default branch",
+ )
parser.add_argument("--force", action="store_true", help="Replace an artifact that is already installed")
parser.add_argument("--skip-compile", action="store_true", help="Copy only; do not compile or install hooks")
parser.add_argument(
@@ -197,8 +240,10 @@ def main(argv: list[str] | None = None) -> int:
args = parser.parse_args(argv)
repo_root = Path(args.repo).resolve()
+ tag = default_tag(args.source, args.ref)
try:
- added = add(repo_root, args.artifact_id, args.source, args.ref, force=args.force, verify_sha=args.verify_sha)
+ ref = resolve_default_ref(args.source, tag) if tag else args.ref
+ added = add(repo_root, args.artifact_id, args.source, ref, force=args.force, verify_sha=args.verify_sha)
except PinError as exc:
print(exc, file=sys.stderr)
return 2
@@ -208,13 +253,7 @@ def main(argv: list[str] | None = None) -> int:
rel = added.path.relative_to(repo_root).as_posix()
print(f"Added {args.artifact_id} to {rel}")
-
- if added.commit:
- print(f" from {redact_source(args.source)} at {added.commit}")
- print(f" sha256 {added.sha256}")
- if not args.ref and added.commit:
- pin = f"Pin with --ref {added.commit}, or --verify-sha {added.sha256}"
- print(f" (unpinned: a later run may fetch another commit. {pin})")
+ _report(args, added, tag)
if args.skip_compile:
print("Run `chock sync --repo .` to compile it.")
@@ -230,7 +269,7 @@ def main(argv: list[str] | None = None) -> int:
except BookkeepingError as exc:
error(str(exc))
return 1
- record_provenance(repo_root, args.artifact_id, args.source, args.ref, added)
+ record_provenance(repo_root, args.artifact_id, args.source, tag or args.ref, added)
print("Compiled. Run `chock sync --repo .` to activate commit-time enforcement.")
return 0
diff --git a/src/chock/scaffold/pin.py b/src/chock/scaffold/pin.py
index ab3cb775..ea825909 100644
--- a/src/chock/scaffold/pin.py
+++ b/src/chock/scaffold/pin.py
@@ -160,6 +160,19 @@ def _require_published(source: str, remote: str, sha: str, into: Path) -> None:
raise _pin_error(source, sha, why)
+def tag_commit(source: str, tag: str) -> str | None:
+ """The commit tag `tag` of `source` names (peeled), or None when the source has no such tag."""
+ _check_ref_syntax(source, tag)
+ remote = str(local.resolve()) if (local := local_source(source)) is not None else source
+ name = f"refs/tags/{tag}"
+ listed = _run(["git", *INERT, "ls-remote", "--tags", "--", remote, name, f"{name}^{{}}"], REMOTE_TIMEOUT)
+ if listed.returncode != 0:
+ msg = f"could not list the tags of catalog {redact_source(source)}: {_scrub(listed.stderr.strip(), source)}"
+ raise RuntimeError(msg)
+ found = {ref: sha for sha, _, ref in (line.partition("\t") for line in listed.stdout.splitlines())}
+ return next((found[k].lower() for k in (f"{name}^{{}}", name) if _FULL_SHA.fullmatch(found.get(k, ""))), None)
+
+
def _clone_ref(source: str, remote: str, ref: str | None, into: Path) -> str | None:
args = ["git", *INERT, "clone", "--quiet", "--depth", "1", "--template="]
if ref:
diff --git a/src/chock/toggles.py b/src/chock/toggles.py
index 93d21baa..19dae6f0 100644
--- a/src/chock/toggles.py
+++ b/src/chock/toggles.py
@@ -17,8 +17,8 @@
from chock.display import inert
from chock.gate.build import CatastrophicPatternError
from chock.index.cli import cmd_refresh
-from chock.manifest import ManifestSourceError, load_manifest
-from chock.output import error, warn
+from chock.manifest import ManifestSourceError, load_manifest, warn_defaults
+from chock.output import error
from chock.policies import discover_policy_dirs
from chock.scaffold.adapters import parse_agent_selection
from chock.scaffold.recompile import BookkeepingError, compiled_differences, recompile
@@ -44,9 +44,8 @@ def _load_manifest(pack_dir: Path) -> dict[str, Any]:
return {}
if result is None:
return {}
- data, _ = result
- for warning in warnings:
- warn(f"{pack_dir}: manifest_default: {warning}")
+ data, manifest_path = result
+ warn_defaults(manifest_path, warnings)
return data
diff --git a/src/chock/validation/checks_floor.py b/src/chock/validation/checks_floor.py
new file mode 100644
index 00000000..16a44c7a
--- /dev/null
+++ b/src/chock/validation/checks_floor.py
@@ -0,0 +1,296 @@
+"""`chock check --floor` (preview): judge what a pull request will land with the base's gates, run by this engine.
+
+base must be an ancestor of head (pass the merge result); everything comes from the tree diff base..head and
+the commits in it. A changed control-plane path is listed (`floor/control-plane-changed`), never read for
+meaning; the base's gates judge everything else and no head file executes.
+Exit 0 clean, 1 any refusal (each naming its rule or policy and path), 2 undecided.
+"""
+
+from __future__ import annotations
+
+import argparse
+import json
+import sys
+import tempfile
+from dataclasses import dataclass
+from pathlib import Path
+
+from chock.display import inert
+from chock.gate.runner import (
+ ACTION_ASK,
+ ACTION_BLOCK,
+ COMPILED_PREFIX,
+ FLOOR_EVENT,
+ KINDS,
+ SCRIPT_BASE_GATE,
+ GateResult,
+ committed_rollout,
+)
+from chock.gate.runner.constants import _ACTION_RANK, _DEPENDENCY_KIND, _ROLLOUT_CEILING
+from chock.gate.runner.context import ListingError
+from chock.gate.runner.kinds import PatternDeadlineError
+from chock.gate.runner.report import _reason
+from chock.gate.runner.script import _UNDECIDED
+from chock.validation import control_plane as cp
+from chock.validation import floor_sarif
+from chock.validation.floor_context import FloorContext
+from chock.validation.floor_git import (
+ FloorError,
+ Revision,
+ attributes_from,
+ require_ancestor,
+ resolve,
+ toplevel,
+)
+from chock.validation.floor_history import history_findings
+from chock.validation.floor_outcome import Outcome
+
+EXIT_REFUSED, EXIT_UNDECIDED = 1, 2
+_CI_GATE = "ci-gate/gate.json"
+_SURFACES = ("ci-gate", "git-hook")
+_SCRIPT, _DEPENDENCY, _REF = "script", _DEPENDENCY_KIND, "forbidden_ref"
+_REFUSING = (ACTION_BLOCK, ACTION_ASK)
+_CHOCK = ".chock"
+_HISTORY_ONLY = " (in a commit of the range only; the tree diff leaves it as at the base)"
+_FIRST_ADOPTION = "floor: base has no chock gates; nothing was judged"
+_NO_GATES = "floor: the base has no compiled ci gates; no gate judged the content (the control-plane rule still ran)"
+_CONTROL_PLANE = (
+ "{rule} ({mode}): {count} path(s) -- these files define the guardrails; the floor does not judge "
+ "whether a change to them is safe. A person decides."
+)
+_LISTED_GAP = "{rule}: under `listed` the content of these paths was not judged; code-owner review is the check"
+_NOT_REQUIRED = (
+ "floor (preview): a floor only where this check is a required status check the pull request cannot "
+ "redefine; that is the repository's own setting, unverified by chock. It judges committed content only."
+)
+
+
+def _out(line: str) -> None:
+ sys.stdout.write(line + "\n")
+
+
+def _err(line: str) -> None:
+ sys.stderr.write(line + "\n")
+
+
+@dataclass(frozen=True)
+class Gate:
+ """One compiled ci gate as the base commits it."""
+
+ policy: str
+ rev: Revision
+ path: str
+ spec: dict
+
+
+def base_gates(base: Revision) -> list[Gate]:
+ found: list[Gate] = []
+ for path in base.paths(COMPILED_PREFIX):
+ policy, _, tail = path.removeprefix(COMPILED_PREFIX).partition("/")
+ if tail != _CI_GATE:
+ continue
+ try:
+ spec = json.loads(base.text(path) or "")
+ except ValueError:
+ spec = None
+ found.append(Gate(policy, base, path, spec if isinstance(spec, dict) else {}))
+ return found
+
+
+def _relative(named: str) -> str:
+ """`named` when it is a path inside the repository; FloorError (undecided) for an absolute or escaping one."""
+ if not named or Path(named).is_absolute() or ".." in Path(named).parts or "\\" in named or ":" in named:
+ msg = f"gate names {named!r}, which is not a path inside the repository"
+ raise FloorError(msg)
+ return named
+
+
+def _params(gate: Gate, tree: Path) -> dict:
+ """The gate's params, with every file it names taken from the base, materialised under `tree`."""
+ params = dict(gate.spec.get("params") or {})
+ if gate.spec.get("kind") == _SCRIPT:
+ if gate.spec.get("script_base") == SCRIPT_BASE_GATE:
+ folder = gate.path.rsplit("/", 1)[0]
+ script = f"{folder}/{params.get('script', '')}"
+ else:
+ script = _relative(str(params.get("script", "")))
+ folder = script.rsplit("/", 1)[0] if "/" in script else ""
+ gate.rev.materialise(f"{folder}/" if folder else script, tree)
+ params["script"] = str(tree / script)
+ if gate.spec.get("kind") == _DEPENDENCY and params.get("allowlist_file"):
+ named = _relative(str(params["allowlist_file"]))
+ gate.rev.materialise(named, tree)
+ params["allowlist_file"] = str(tree / named)
+ return params
+
+
+def _judge(gate: Gate, ctx: FloorContext, tree: Path) -> GateResult | str:
+ """The gate's result, or why it could not judge."""
+ spec, label = gate.spec, f"{gate.policy} [base]"
+ kind = KINDS.get(spec.get("kind"))
+ if not spec or kind is None or spec.get("action", ACTION_BLOCK) not in _ACTION_RANK:
+ return f"{label}: unreadable gate, unknown kind or unknown action"
+ if spec.get("kind") == _REF and not ctx.head_ref:
+ return f"{label}: a branch gate needs --head-ref "
+ try:
+ result = kind(ctx, _params(gate, tree), FLOOR_EVENT)
+ except (ListingError, PatternDeadlineError, FloorError) as exc:
+ return f"{label}: {inert(str(exc))}"
+ if not result.allowed and (result.message or "").endswith(_UNDECIDED):
+ return f"{label}: {inert(result.message or '')}" # could not judge: undecided whatever the rollout
+ return result
+
+
+def _verdict(result: GateResult, declared: str, level: str) -> str:
+ if result.allowed:
+ return "allow"
+ return min(result.verdict or declared, declared, _ROLLOUT_CEILING[level], key=_ACTION_RANK.__getitem__)
+
+
+def judge_gates( # noqa: PLR0913 -- the range, the branch, what it excludes and the level
+ repo: Path, base: Revision, head: Revision, head_ref: str | None, *, plane: cp.ControlPlane, level: str
+) -> Outcome:
+ """Run the base's ci gates over base..head; `ask` refuses, since nobody can be asked in CI.
+
+ A gate that cannot judge is undecided before the rollout applies: `observe` softens refusals, never that.
+ """
+ outcome = Outcome()
+ with tempfile.TemporaryDirectory(prefix="chock-floor-") as scratch:
+ for gate in base_gates(base):
+ if "commit" not in (gate.spec.get("on") or []) and gate.spec:
+ continue
+ ctx = FloorContext(
+ repo, base=base, head=head, head_ref=head_ref, scope=gate.spec.get("paths"),
+ control_plane=plane.covers,
+ ) # fmt: skip
+ result = _judge(gate, ctx, Path(scratch))
+ if isinstance(result, str):
+ outcome.undecided.append(result)
+ continue
+ verdict = _verdict(result, gate.spec.get("action", ACTION_BLOCK), level)
+ if verdict == "allow":
+ continue
+ line = f"{gate.policy} [base] ({verdict}): {_reason(result, gate.spec, FLOOR_EVENT, gate.policy)}"
+ (outcome.refusals if verdict in _REFUSING else outcome.notes).append(line)
+ return outcome
+
+
+def _declared(base: Revision, policy: str) -> str:
+ """The strictest action the base's compiled gates of `policy` declare, on either surface."""
+ actions = []
+ for surface in _SURFACES:
+ try:
+ spec = json.loads(base.text(f"{COMPILED_PREFIX}{policy}/{surface}/gate.json") or "null")
+ except ValueError:
+ spec = None
+ if isinstance(spec, dict) and spec.get("action", ACTION_BLOCK) in _ACTION_RANK:
+ actions.append(spec.get("action", ACTION_BLOCK))
+ return max(actions or [ACTION_BLOCK], key=_ACTION_RANK.__getitem__)
+
+
+def _judged(repo: Path, base: Revision, head: Revision, branch: str | None) -> Outcome:
+ plane = cp.closed_under_links(cp.from_base(base, head), base, head)
+ listed, history_only = plane.changes(repo, base, head)
+ level = committed_rollout(repo, base.sha)
+ outcome = judge_gates(repo, base, head, branch, plane=plane, level=level)
+ outcome.listed, outcome.history_only, outcome.mode, outcome.in_force = (
+ listed,
+ history_only,
+ plane.mode,
+ plane.summary(),
+ )
+ outcome.deep = {path: why for path in listed if (why := plane.deep_match(path))}
+ if not base_gates(base):
+ outcome.notes.append(_NO_GATES)
+ try:
+ history, notes = history_findings(repo, base, head, plane.covers)
+ except FloorError as exc:
+ history, notes = [], []
+ outcome.undecided.append(inert(str(exc)))
+ for policy, finding in history:
+ verdict = min(_declared(base, policy), _ROLLOUT_CEILING[level], key=_ACTION_RANK.__getitem__)
+ (outcome.refusals if verdict in _REFUSING else outcome.notes).append(
+ f"{policy} [history] ({verdict}): {finding}"
+ )
+ outcome.notes += notes
+ return outcome
+
+
+def _print(outcome: Outcome) -> None:
+ _out(outcome.in_force)
+ if outcome.listed:
+ head = "FAIL" if outcome.mode == cp.REFUSE else "LISTED"
+ text = _CONTROL_PLANE.format(rule=cp.RULE, mode=outcome.mode, count=len(outcome.listed))
+ _out(f"{head} {text}")
+ for path in outcome.listed:
+ _out(f" {inert(path)}{_HISTORY_ONLY if path in outcome.history_only else ''}")
+ if path in outcome.deep:
+ _out(f" matched {inert(outcome.deep[path])}")
+ if outcome.mode == cp.LISTED:
+ _out(f"note: {_LISTED_GAP.format(rule=cp.RULE)}")
+ for line in outcome.notes:
+ _out(f"note: {line}")
+ for line in outcome.refusals:
+ _out(f"FAIL {line}")
+ for line in outcome.undecided:
+ _err(f"UNDECIDED {line}")
+ _out(_NOT_REQUIRED)
+
+
+def _code(outcome: Outcome) -> int:
+ if outcome.undecided:
+ return EXIT_UNDECIDED
+ refused = outcome.refusals or (outcome.listed and outcome.mode == cp.REFUSE)
+ return EXIT_REFUSED if refused else 0
+
+
+def _base_chock(base: Revision) -> bool:
+ """Whether the base commits chock gates; FloorError (undecided) when its `.chock` is a link or a submodule."""
+ if base.state(_CHOCK) is not None:
+ msg = f"the base's {_CHOCK} is a symbolic link or a submodule; the floor reads gates only from files under {_CHOCK}/"
+ raise FloorError(msg)
+ return bool(base.paths(f"{_CHOCK}/"))
+
+
+def floor(repo: Path, base_ref: str, head_ref_rev: str, branch: str | None) -> Outcome:
+ base_sha, head_sha = resolve(repo, base_ref, "base"), resolve(repo, head_ref_rev, "head")
+ require_ancestor(repo, base_sha, head_sha)
+ _out(f"== floor (preview): base {base_sha[:12]}, head {head_sha[:12]}")
+ if base_sha == head_sha:
+ _out("floor: base and head are the same commit; nothing changed")
+ base, head = Revision(repo, base_sha), Revision(repo, head_sha)
+ if not _base_chock(base):
+ return Outcome(first_adoption=True)
+ return _judged(repo, base, head, branch)
+
+
+def _run(repo: Path, args: argparse.Namespace) -> tuple[Outcome, Path]:
+ """(outcome, top level), every attribute read from the base; an error that stops the run is one undecided line."""
+ try:
+ repo = toplevel(repo)
+ with attributes_from(repo, args.base):
+ return floor(repo, args.base, args.head, args.head_ref), repo
+ except FloorError as exc:
+ why = inert(str(exc))
+ except Exception as exc: # noqa: BLE001 -- 1 means refused; anything undecided is 2, naming only the type
+ why = f"no verdict was established ({type(exc).__name__})"
+ return Outcome(undecided=[f"floor: {why}"], stopped=True), repo
+
+
+def main(argv: list[str] | None = None) -> int:
+ parser = argparse.ArgumentParser(prog="chock check --floor")
+ parser.add_argument("--repo", default=".")
+ parser.add_argument("--base", required=True, help="The pull request's base: its gates, waivers and rules bind")
+ parser.add_argument("--head", default="HEAD", help="The merge result under test, read as objects only")
+ parser.add_argument("--head-ref", default=None, help="The branch under test, for branch gates")
+ parser.add_argument("--sarif", default=None, help="Also write the result as SARIF 2.1.0 to this file")
+ args = parser.parse_args(argv)
+ outcome, repo = _run(Path(args.repo), args)
+ if outcome.first_adoption:
+ _out(_FIRST_ADOPTION)
+ elif outcome.stopped:
+ _err(f"UNDECIDED {outcome.undecided[0]}")
+ else:
+ _print(outcome)
+ code = _code(outcome)
+ return floor_sarif.write(repo, args.sarif, outcome, code) if args.sarif else code
diff --git a/src/chock/validation/checks_policy_toggles.py b/src/chock/validation/checks_policy_toggles.py
index ed524a9b..6e37d983 100644
--- a/src/chock/validation/checks_policy_toggles.py
+++ b/src/chock/validation/checks_policy_toggles.py
@@ -9,7 +9,7 @@
from chock.compile.surface_kinds import Surface
from chock.config import load_config
-from chock.manifest import CANONICAL_MANIFEST, ManifestSourceError, load_manifest
+from chock.manifest import CANONICAL_MANIFEST, MANIFEST_DEFAULT, ManifestSourceError, load_manifest
from chock.scaffold.recompile import discover_policy_dirs
from chock.validation.report import Finding, Report
@@ -30,7 +30,7 @@ def _load_manifest(pack_dir: Path, report: Report | None = None) -> dict[str, An
data, manifest_path = result
if report is not None:
for warning in warnings:
- report.add(Finding(str(manifest_path), "manifest_default", "warning", warning))
+ report.add(Finding(str(manifest_path), MANIFEST_DEFAULT, "warning", warning))
return data
diff --git a/src/chock/validation/control_plane.py b/src/chock/validation/control_plane.py
new file mode 100644
index 00000000..10f00d18
--- /dev/null
+++ b/src/chock/validation/control_plane.py
@@ -0,0 +1,278 @@
+"""The floor's control plane: the paths that define the guardrails, and what the base says to do when one changes.
+
+No file is read for meaning: a listed path that changed is reported, whatever the change. The base's
+`.chock/config.yaml` alone sets the outcome and the patterns; the head's config is never read.
+"""
+
+from __future__ import annotations
+
+import bisect
+import dataclasses
+import fnmatch
+import functools
+import json
+import unicodedata
+from dataclasses import dataclass
+from importlib import resources
+from pathlib import Path
+
+import yaml
+
+from chock import yamlio
+from chock.validation.floor_git import FloorError, Revision, changed_paths, history_states
+
+RULE = "floor/control-plane-changed"
+REFUSE, LISTED = "refuse", "listed"
+_MODES = (REFUSE, LISTED)
+_CONFIG = ".chock/config.yaml"
+_SECTION, _MODE, _PATHS = "floor", "control_plane", "control_plane_paths"
+_EDITS = ("add", "remove")
+_FORMAT = "Cf"
+_SYMLINK = "120000"
+_REGULAR = ("100644", "100755")
+_GLOB = frozenset("*?[")
+_ANY_DEPTH = "**/"
+_MAX_HOPS = 32
+
+
+def default_patterns() -> tuple[str, ...]:
+ text = resources.files("chock").joinpath("data/control_plane.json").read_text(encoding="utf-8")
+ return tuple(json.loads(text)["paths"])
+
+
+@functools.lru_cache(maxsize=8192)
+def folded(path: str) -> str:
+ """`path` as a case-blind, normalising filesystem may open it: NFC, no format characters, case folded,
+ and no trailing dot or space on any component (Windows drops them)."""
+ text = "".join(c for c in unicodedata.normalize("NFC", path) if unicodedata.category(c) != _FORMAT)
+ return "/".join(part.rstrip(". ") for part in text.casefold().split("/"))
+
+
+@functools.cache
+def _parents(pattern: str) -> set[str]:
+ """The folders a pattern lies under, up to its first glob: a symlink or gitlink there redirects the pattern."""
+ parts = folded(pattern).split("/")
+ literal = parts[: next((i for i, p in enumerate(parts) if _GLOB & set(p)), len(parts))]
+ return {"/".join(literal[:k]) for k in range(1, len(literal) + 1) if k < len(parts)}
+
+
+def _match(name: str, pattern: str) -> bool:
+ """fnmatch on folded text; a leading `**/` also matches at the top level."""
+ pat = folded(pattern)
+ return fnmatch.fnmatchcase(name, pat) or (pat.startswith(_ANY_DEPTH) and fnmatch.fnmatchcase(name, pat[3:]))
+
+
+@dataclass(frozen=True)
+class ControlPlane:
+ mode: str
+ patterns: tuple[str, ...]
+ added: tuple[str, ...] = ()
+ removed: tuple[str, ...] = ()
+ #: Entries of `added` that match no path at base or head, named as such in the summary.
+ unmatched: tuple[str, ...] = ()
+ #: Folded paths of the symlinks resolving a control-plane link passes through, at base or head.
+ hops: frozenset[str] = frozenset()
+
+ def _direct(self, name: str) -> bool:
+ return any(_match(name, p) or _match(f"{name}/", p) or name in _parents(p) for p in self.patterns)
+
+ def covers(self, path: str) -> bool:
+ """Whether `path`, a folder above it that a client opens it through, or a link on the way, is control plane."""
+ name = folded(path)
+ return name in self.hops or self._direct(name)
+
+ def deep_match(self, path: str) -> str | None:
+ """The any-depth pattern that matches `path` only below the top level, so the output can say why."""
+ name = folded(path)
+ deep = (p for p in self.patterns if p.startswith(_ANY_DEPTH) and not fnmatch.fnmatchcase(name, folded(p)[3:]))
+ return next((p for p in deep if _match(name, p) or _match(f"{name}/", p)), None)
+
+ def changes(self, repo: Path, base: Revision, head: Revision) -> tuple[list[str], set[str]]:
+ """(paths of the plane the tree diff changes or any commit leaves in a state the base lacks, those only
+ in history)."""
+ diff = {path for path in changed_paths(repo, base.sha, head.sha) if self.covers(path)}
+ states = history_states(repo, base.sha, head.sha)
+ history = {p for p, state in states if p not in diff and self.covers(p) and state != base.state(p)}
+ return sorted(diff | history), history
+
+ def summary(self) -> str:
+ """The list in force: mode, size, and the base's own edits to the defaults."""
+ shown = [f"{p} (matches nothing at base or head)" if p in self.unmatched else p for p in self.added]
+ added, removed = ", ".join(shown) or "none", ", ".join(self.removed) or "none"
+ return (
+ f"control plane: {self.mode}, {len(self.patterns)} pattern(s); base added: {added}; base removed: {removed}"
+ )
+
+
+class _Tree:
+ """One revision's symlinks, gitlinks and paths, folded, for resolving links from tree data alone."""
+
+ def __init__(self, rev: Revision) -> None:
+ entries = rev.entries()
+ self.rev = rev
+ self.links = {folded(p): p for p, (mode, _) in entries.items() if mode == _SYMLINK}
+ self.gitlinks = {folded(p) for p in rev.gitlinks()}
+ self.files = {folded(p) for p in entries} | self.gitlinks
+ self.folders = {f.rsplit("/", k)[0] for f in self.files for k in range(1, f.count("/") + 1)}
+ self._sorted = sorted(self.files)
+
+ def resolve(self, link: str) -> tuple[str, list[str]]:
+ """(folded in-repo path `link` opens, links passed); FloorError naming the link when it cannot resolve."""
+ todo, done, hops = link.split("/"), [], []
+ while todo:
+ part = todo.pop(0)
+ part = part if part == ".." else folded(part)
+ if not part:
+ continue
+ if part == "..":
+ if not done:
+ raise _unresolved(link, self.rev, "its target leaves the repository")
+ done.pop()
+ continue
+ here = "/".join([*done, part])
+ if here in self.gitlinks and todo:
+ raise _unresolved(link, self.rev, f"its target passes through the submodule {here}")
+ if here not in self.links:
+ done.append(part)
+ continue
+ hops.append(here)
+ if len(hops) > _MAX_HOPS:
+ raise _unresolved(link, self.rev, f"more than {_MAX_HOPS} links (a loop?)")
+ target = (self.rev.blob(self.links[here]) or b"").decode("utf-8", "replace")
+ if not target or target.startswith("/") or "\\" in target or ":" in target.split("/")[0]:
+ raise _unresolved(link, self.rev, f"{here} has the absolute or empty target {target!r}")
+ todo[:0] = target.split("/")
+ return "/".join(done), hops
+
+ def exists(self, name: str) -> bool:
+ return not name or name in self.files or name in self.folders
+
+ def below(self, folder: str) -> list[str]:
+ """The folded paths under `folder` (the root when "")."""
+ if not folder:
+ return self._sorted
+ start = bisect.bisect_left(self._sorted, f"{folder}/")
+ return self._sorted[start : bisect.bisect_left(self._sorted, f"{folder}0")] # "0" sorts right after "/"
+
+
+def _unresolved(link: str, rev: Revision, why: str) -> FloorError:
+ return FloorError(
+ f"control plane: the symbolic link {link} at {rev.sha[:12]} does not resolve inside the repository: {why}; "
+ "replace the link with real files"
+ )
+
+
+def _opens_control_plane(plane: ControlPlane, tree: _Tree, name: str) -> tuple[str, list[str]] | None:
+ """(what must be control plane, links passed) when the link `name` is a control-plane root, inside one, or above
+ one; else None. Above one, every control-plane path under it must open one: else its target is returned."""
+ if plane.covers(name):
+ return tree.resolve(tree.links[name])
+ try:
+ target, passed = tree.resolve(tree.links[name])
+ except FloorError:
+ return None # leaves the repository: nothing committed lies under it
+ rests = [f[len(target) :] if target else f"/{f}" for f in tree.below(target)]
+ reached = [rest for rest in rests if plane.covers(name + rest)]
+ if not reached:
+ return None
+ opened = [f"{target}{rest}" if target else rest[1:] for rest in reached]
+ return next((target for path in opened if not plane.covers(path)), opened[0]), passed
+
+
+def closed_under_links(plane: ControlPlane, *revisions: Revision) -> ControlPlane:
+ """`plane` plus every link a control-plane link passes through, once each link at, inside or above the control
+ plane at each of `revisions` opens a control-plane path or nothing; FloorError (undecided) naming one that does not."""
+ hops: set[str] = set()
+ for rev in revisions:
+ tree = _Tree(rev)
+ for name, link in sorted(tree.links.items()):
+ found = _opens_control_plane(plane, tree, name)
+ if found is None:
+ continue
+ target, passed = found
+ hops.update(passed)
+ if tree.exists(target) and not plane.covers(target):
+ shown = target or "."
+ msg = (
+ f"control plane: the symbolic link {link} at {rev.sha[:12]} opens {shown}, which is not control "
+ f"plane; put {shown}/** on floor.{_PATHS}.add in the base's {_CONFIG}, or replace the link with "
+ "real files"
+ )
+ raise FloorError(msg)
+ return dataclasses.replace(plane, hops=frozenset(hops))
+
+
+def _invalid(what: str) -> FloorError:
+ return FloorError(f"the base's {_CONFIG} {_SECTION}.{what}")
+
+
+def _section(base: Revision) -> dict:
+ state = base.state(_CONFIG)
+ if base.paths(f"{_CONFIG}/") or (state is not None and state[0] not in _REGULAR):
+ msg = (
+ f"the base's {_CONFIG} is a folder, a symbolic link or a submodule, not a file; the floor reads only a file"
+ )
+ raise FloorError(msg)
+ try:
+ text = (base.blob(_CONFIG) or b"").decode("utf-8")
+ doc = yamlio.safe_load(text) if text else None
+ except UnicodeDecodeError as exc:
+ msg = f"the base's {_CONFIG} is not UTF-8"
+ raise FloorError(msg) from exc
+ except yaml.YAMLError as exc:
+ msg = "could not be read as YAML"
+ raise _invalid(msg) from exc
+ section = doc.get(_SECTION) if isinstance(doc, dict) else None
+ if section is not None and not isinstance(section, dict):
+ msg = "is not a mapping"
+ raise _invalid(msg)
+ return section or {}
+
+
+def _edits(section: dict) -> dict[str, list[str]]:
+ edits = section.get(_PATHS) or {}
+ if not isinstance(edits, dict) or set(edits) - set(_EDITS):
+ msg = f"{_PATHS} takes only {' and '.join(_EDITS)}"
+ raise _invalid(msg)
+ found = {key: edits.get(key) or [] for key in _EDITS}
+ if any(not isinstance(v, list) or not all(isinstance(p, str) and p for p in v) for v in found.values()):
+ msg = f"{_PATHS} lists must hold path patterns"
+ raise _invalid(msg)
+ return found
+
+
+def _added(entries: list[str], revisions: tuple[Revision, ...]) -> tuple[tuple[str, ...], tuple[str, ...]]:
+ """(patterns, entries matching no path at any of `revisions`) for the base's `add:`; `name/` means `name/**`.
+ FloorError (undecided) for a bare entry naming a folder, which as written would match only the folder itself."""
+ trees = [_Tree(rev) for rev in revisions] if entries else []
+ patterns, unmatched = [], []
+ for entry in entries:
+ if not _GLOB & set(entry) and not entry.endswith("/") and any(folded(entry) in t.folders for t in trees):
+ msg = f"{_PATHS}.add names {entry!r}, a folder; write {entry + '/**'!r} for the folder and everything in it"
+ raise _invalid(msg)
+ pattern = f"{entry}**" if entry.endswith("/") else entry
+ alone = ControlPlane(REFUSE, (pattern,))
+ if not any(alone.covers(f) for t in trees for f in t.files | t.folders):
+ unmatched.append(entry)
+ patterns.append(pattern)
+ return tuple(patterns), tuple(unmatched)
+
+
+def from_base(base: Revision, head: Revision) -> ControlPlane:
+ """The control plane the base defines; FloorError (undecided) for a `floor:` section it cannot read."""
+ section = _section(base)
+ mode = section.get(_MODE, REFUSE)
+ if mode not in _MODES:
+ msg = f"{_MODE} is {mode!r}; it takes {' or '.join(_MODES)}"
+ raise _invalid(msg)
+ edits, defaults = _edits(section), default_patterns()
+ unknown = [p for p in edits["remove"] if p not in defaults]
+ if unknown:
+ hint = [f"{_ANY_DEPTH}{p}" for p in unknown if f"{_ANY_DEPTH}{p}" in defaults]
+ msg = f"{_PATHS}.remove names {unknown!r}, which is no default pattern" + (
+ f"; write {hint[0]!r}" if hint else ""
+ )
+ raise _invalid(msg)
+ kept = tuple(p for p in defaults if p not in edits["remove"])
+ added, unmatched = _added(edits["add"], (base, head))
+ return ControlPlane(mode, kept + added, tuple(edits["add"]), tuple(edits["remove"]), unmatched)
diff --git a/src/chock/validation/engine.py b/src/chock/validation/engine.py
index 90ff07ad..80797f01 100644
--- a/src/chock/validation/engine.py
+++ b/src/chock/validation/engine.py
@@ -10,7 +10,7 @@
import yaml
-from chock.manifest import MANIFEST_NAMES, ManifestSourceError, load_manifest
+from chock.manifest import MANIFEST_DEFAULT, MANIFEST_NAMES, ManifestSourceError, load_manifest
from chock.validation.checks_content import (
check_description_parity,
check_no_agent_specific_leakage,
@@ -87,7 +87,7 @@ def validate_artifact(
manifest, manifest_path = result
for warning in warnings:
- report.add(Finding(str(manifest_path or artifact_dir), "manifest_default", "warning", warning))
+ report.add(Finding(str(manifest_path or artifact_dir), MANIFEST_DEFAULT, "warning", warning))
schema_name = {
"rule": MANIFEST_SCHEMA,
diff --git a/src/chock/validation/floor_cli.py b/src/chock/validation/floor_cli.py
new file mode 100644
index 00000000..ecbcbb92
--- /dev/null
+++ b/src/chock/validation/floor_cli.py
@@ -0,0 +1,34 @@
+"""`chock check --floor`'s flags on the check parser, and its dispatch from `chock check`."""
+
+from __future__ import annotations
+
+import argparse
+
+from chock.validation.checks_floor import main
+
+
+def add_arguments(parser: argparse.ArgumentParser) -> None:
+ parser.add_argument(
+ "--floor",
+ action="store_true",
+ help="Preview: judge base..head (base an ancestor of head: pass the merge result) with the base's gates, "
+ "run by this engine; a changed guardrail path is listed and, by default, refused (needs --base; runs alone). "
+ "It holds only as a required check the pull request cannot redefine (your setting, unverified by chock) and "
+ "judges committed content only; under `listed` you rely on code-owner review of the listed paths. The list is "
+ "what chock knows about, not a proof of completeness (a file your workflow installs chock from belongs on it: "
+ "floor.control_plane_paths.add); a symlink at, inside or above the list must open a listed path or nothing, or "
+ "the run is undecided; a renamed or moved test file reads as a deletion and is refused (docs/floor.md)",
+ )
+ parser.add_argument("--head", default=None, help="With --floor: the merge result under test (default HEAD)")
+
+
+def from_check(args: argparse.Namespace, parser: argparse.ArgumentParser) -> int:
+ """The floor runs alone: every other check reads, and the evals run, the head's own files."""
+ if not args.floor:
+ parser.error("--head goes with --floor")
+ sarif = args.format == "sarif"
+ if not args.base or args.only or args.mode or args.event or bool(args.output) != sarif:
+ parser.error("--floor needs --base, takes --format sarif only with --output, and no --only, --mode or --event")
+ argv = ["--repo", args.repo, "--base", args.base, "--head", args.head or "HEAD"]
+ argv += ["--head-ref", args.head_ref] if args.head_ref else []
+ return main(argv + (["--sarif", args.output] if sarif else []))
diff --git a/src/chock/validation/floor_context.py b/src/chock/validation/floor_context.py
new file mode 100644
index 00000000..a1daefd6
--- /dev/null
+++ b/src/chock/validation/floor_context.py
@@ -0,0 +1,77 @@
+"""The material a gate judges at the floor: the tree diff base..head, read by revision, never from the working tree."""
+
+from __future__ import annotations
+
+import subprocess
+from collections.abc import Callable, Sequence
+from pathlib import Path
+
+from chock.gate.runner import GateContext
+from chock.gate.runner.context import _GIT
+from chock.gate.runner.gitparse import DiffError, _diff_sides
+from chock.validation.floor_git import Revision
+
+
+class FloorContext(GateContext):
+ """`base..head` as the change; the head's files as the proposal; the base's as what a waiver must already be in.
+
+ Every read is a blob by revision (unreadable is undecided), so a head file is data and never reaches a program as code.
+ Diffs run with `--text` and `--no-renames`, so neither a NUL byte, a head `.gitattributes` nor a rename
+ hides a line or a deletion. A control-plane path is never judged here: the control-plane rule owns it.
+ """
+
+ def __init__( # noqa: PLR0913 -- the range and what it excludes, beside GateContext's own
+ self,
+ repo_root: Path,
+ *,
+ base: Revision,
+ head: Revision,
+ head_ref: str | None,
+ scope: Sequence[str] | None,
+ control_plane: Callable[[str], bool],
+ ) -> None:
+ super().__init__(repo_root=repo_root, base=base.sha, head_ref=head_ref, scope=scope)
+ self.head, self._revisions = head.sha, (base, head)
+ self.control_plane = control_plane
+
+ def in_scope(self, path: str, *, judge_own: bool = False) -> bool:
+ return not self.control_plane(path) and super().in_scope(path, judge_own=judge_own)
+
+ def _range(self) -> list[str]:
+ return ["--no-renames", str(self.base), self.head]
+
+ def _diff_text(self, path: str) -> str:
+ args = ("diff", *self._range(), "--text", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", "--", path)
+ try:
+ proc = subprocess.run( # noqa: S603 -- reading committed revisions is this class's whole job
+ [_GIT, "--literal-pathspecs", *args], cwd=str(self.repo_root), capture_output=True, check=False
+ )
+ except OSError as exc:
+ msg = f"git could not run ({exc})"
+ raise DiffError(msg) from exc
+ if proc.returncode:
+ first = (proc.stderr.decode("utf-8", "replace").strip().splitlines() or [""])[0]
+ msg = f"git diff failed (exit {proc.returncode}): {first}"
+ raise DiffError(msg)
+ return proc.stdout.decode("utf-8", "replace")
+
+ def staged_blob(self, path: str) -> str:
+ """The proposal: the file at the head; "" only when the head has no such file, FloorError when unreadable."""
+ return self._revisions[1].text(path) or ""
+
+ def head_blob(self, path: str) -> str:
+ """Before the change: the file at the base; "" only when the base has no such file, FloorError when unreadable."""
+ return self._revisions[0].text(path) or ""
+
+ def committed_blob(self, path: str) -> str:
+ """Where a waiver must be for the floor to honour it: the lines present and unchanged in both base and
+ head. A line the pull request adds, changes or removes never carries a waiver, even a copy of a base line."""
+ added, removed = _diff_sides(self._diff_text(path))
+ touched = set(added) | set(removed)
+ kept = set(self.staged_blob(path).splitlines())
+ lines = self.head_blob(path).splitlines()
+ return "\n".join(line for line in lines if line in kept and line not in touched)
+
+ def current_branch(self) -> str:
+ """The branch under test is the one named; the checkout's own branch is the base's, never the head's."""
+ return self.head_ref or ""
diff --git a/src/chock/validation/floor_git.py b/src/chock/validation/floor_git.py
new file mode 100644
index 00000000..de90dad5
--- /dev/null
+++ b/src/chock/validation/floor_git.py
@@ -0,0 +1,189 @@
+"""Read-only git access for `chock check --floor`: committed files by revision, never the working tree."""
+
+from __future__ import annotations
+
+import contextlib
+import os
+import subprocess
+from collections.abc import Iterator
+from dataclasses import dataclass, field
+from pathlib import Path
+
+_GIT_TIMEOUT = 120
+_ATTR_SOURCE = "GIT_ATTR_SOURCE"
+_ATTR_GIT = "2.42"
+_NO_SUCH_TREE = "chock-floor-no-such-tree"
+_TREE_FIELDS = 2
+_BLOB, _COMMIT, _GITLINK = "blob", "commit", "160000"
+_ABSENT = "000000"
+_REGULAR_MODES = ("100644", "100755")
+
+
+class FloorError(RuntimeError):
+ """The floor cannot reach a verdict: exit 2, never a pass."""
+
+
+def git(repo: Path, *args: str, data: bytes | None = None) -> subprocess.CompletedProcess[bytes]:
+ try:
+ return subprocess.run( # noqa: S603 -- reading committed revisions is this module's whole job
+ ["git", "-C", str(repo), "--literal-pathspecs", *args], # noqa: S607
+ input=data,
+ capture_output=True,
+ check=False,
+ timeout=_GIT_TIMEOUT,
+ )
+ except (OSError, subprocess.SubprocessError) as exc:
+ msg = f"git could not run ({type(exc).__name__})"
+ raise FloorError(msg) from exc
+
+
+def toplevel(repo: Path) -> Path:
+ """The repository's top level, so a `--repo` below it sees every path; FloorError when `repo` is in none."""
+ proc = git(repo.resolve(), "rev-parse", "--show-toplevel")
+ top = os.fsdecode(proc.stdout).strip()
+ if proc.returncode or not top:
+ msg = f"{repo} is not inside a git repository"
+ raise FloorError(msg)
+ return Path(top).resolve()
+
+
+def resolve(repo: Path, rev: str, what: str) -> str:
+ """The commit `rev` names; FloorError when it names none."""
+ proc = git(repo, "rev-parse", "--verify", "--quiet", f"{rev}^{{commit}}")
+ sha = proc.stdout.decode("ascii", "replace").strip()
+ if proc.returncode or not sha:
+ msg = f"{what} ref {rev!r} does not resolve -- refusing to judge an empty range. Fetch it (fetch-depth: 0)."
+ raise FloorError(msg)
+ return sha
+
+
+@dataclass
+class Revision:
+ """One commit's tree, read through git: path listing and file text, each read once."""
+
+ repo: Path
+ sha: str
+ _entries: dict[str, tuple[str, str]] | None = None
+ _gitlinks: dict[str, str] = field(default_factory=dict)
+ _texts: dict[str, str | None] = field(default_factory=dict)
+
+ def entries(self) -> dict[str, tuple[str, str]]:
+ """path -> (mode, blob oid) for every regular file and symlink in the tree."""
+ if self._entries is None:
+ proc = git(self.repo, "ls-tree", "-r", "-z", "--full-tree", self.sha)
+ if proc.returncode:
+ msg = f"git ls-tree {self.sha[:12]} failed"
+ raise FloorError(msg)
+ found: dict[str, tuple[str, str]] = {}
+ for record in proc.stdout.split(b"\0"):
+ meta, _, raw_path = record.partition(b"\t")
+ parts = meta.decode("ascii", "replace").split()
+ if len(parts) > _TREE_FIELDS and parts[1] == _BLOB:
+ found[os.fsdecode(raw_path)] = (parts[0], parts[2])
+ elif len(parts) > _TREE_FIELDS and parts[1] == _COMMIT:
+ self._gitlinks[os.fsdecode(raw_path)] = parts[2]
+ self._entries = found
+ return self._entries
+
+ def gitlinks(self) -> dict[str, str]:
+ """path -> commit oid for every submodule pointer in the tree."""
+ self.entries()
+ return self._gitlinks
+
+ def state(self, path: str) -> tuple[str, str] | None:
+ """(mode, oid) of `path` here, a submodule pointer included; None when absent."""
+ if path in self.gitlinks():
+ return _GITLINK, self._gitlinks[path]
+ return self.entries().get(path)
+
+ def paths(self, prefix: str = "") -> list[str]:
+ return sorted(path for path in self.entries() if path.startswith(prefix))
+
+ def has(self, path: str) -> bool:
+ return path in self.entries()
+
+ def blob(self, path: str) -> bytes | None:
+ """The file's bytes as committed; None when the tree has no such file."""
+ entry = self.entries().get(path)
+ if entry is None:
+ return None
+ proc = git(self.repo, "cat-file", "blob", entry[1])
+ if proc.returncode:
+ msg = f"git cat-file {path} at {self.sha[:12]} failed"
+ raise FloorError(msg)
+ return proc.stdout
+
+ def text(self, path: str) -> str | None:
+ """The file as committed, decoded as utf-8 with replacement; None when the tree has no such file."""
+ if path not in self._texts:
+ data = self.blob(path)
+ self._texts[path] = None if data is None else data.decode("utf-8", "replace")
+ return self._texts[path]
+
+ def materialise(self, prefix: str, into: Path) -> None:
+ """Write the regular files under `prefix` into `into` (symlinks are left out: never followed, never made)."""
+ for path in self.paths(prefix):
+ mode, _ = self.entries()[path]
+ if mode not in _REGULAR_MODES or ".." in Path(path).parts:
+ continue
+ target = into / path
+ target.parent.mkdir(parents=True, exist_ok=True)
+ target.write_bytes(self.blob(path) or b"")
+
+
+def require_ancestor(repo: Path, base: str, head: str) -> None:
+ """FloorError (undecided) unless `base` is an ancestor of `head`: the floor judges what will land, not a branch."""
+ proc = git(repo, "merge-base", "--is-ancestor", base, head)
+ if proc.returncode:
+ msg = (
+ f"base {base[:12]} is not an ancestor of head {head[:12]}; pass the pull request's merge result "
+ "as --head (refs/pull//merge, or the merge queue's head)"
+ )
+ raise FloorError(msg)
+
+
+def changed_paths(repo: Path, base: str, head: str) -> list[str]:
+ """Every path the tree diff base..head adds, changes, deletes or re-modes; renames are a delete and an add."""
+ args = ("--no-renames", "--no-ext-diff", "--no-textconv", "--no-relative", "--ignore-submodules=none")
+ proc = git(repo, "diff", "--name-only", "-z", *args, base, head, "--")
+ if proc.returncode:
+ msg = f"git diff {base[:12]} {head[:12]} failed"
+ raise FloorError(msg)
+ return sorted(os.fsdecode(raw) for raw in proc.stdout.split(b"\0") if raw)
+
+
+def history_states(repo: Path, base: str, head: str) -> list[tuple[str, tuple[str, str] | None]]:
+ """(path, (mode, oid) or None when deleted) for every entry each commit in base..head writes, a merge read
+ against each parent, as the history pass reads them."""
+ args = ("log", "-z", "--raw", "-m", "--no-renames", "--no-abbrev", "--no-ext-diff", "--no-textconv")
+ proc = git(repo, *args, "--format=", f"{base}..{head}", "--")
+ if proc.returncode:
+ msg = f"git log {base[:12]}..{head[:12]} failed"
+ raise FloorError(msg)
+ tokens, found = iter(proc.stdout.split(b"\0")), []
+ for raw in tokens:
+ meta = raw.lstrip(b"\n").decode("ascii", "replace")
+ if not meta.startswith(":"):
+ continue
+ mode, oid = meta[1:].split(" ")[1], meta[1:].split(" ")[3]
+ found.append((os.fsdecode(next(tokens, b"")), None if mode == _ABSENT else (mode, oid)))
+ return found
+
+
+@contextlib.contextmanager
+def attributes_from(repo: Path, base_ref: str) -> Iterator[None]:
+ """Every git the floor runs reads attributes from the base's tree, never the checkout's or the head's;
+ FloorError (undecided) when this git ignores `GIT_ATTR_SOURCE`."""
+ saved = os.environ.get(_ATTR_SOURCE)
+ os.environ[_ATTR_SOURCE] = _NO_SUCH_TREE
+ try:
+ if git(repo, "-c", "core.fsmonitor=false", "check-attr", "-a", "--", "probe").returncode == 0:
+ msg = f"this git ignores {_ATTR_SOURCE}; the floor needs git {_ATTR_GIT} or newer to read attributes from the base"
+ raise FloorError(msg)
+ os.environ[_ATTR_SOURCE] = resolve(repo, base_ref, "base")
+ yield
+ finally:
+ if saved is None:
+ os.environ.pop(_ATTR_SOURCE, None)
+ else:
+ os.environ[_ATTR_SOURCE] = saved
diff --git a/src/chock/validation/floor_history.py b/src/chock/validation/floor_history.py
new file mode 100644
index 00000000..ff650211
--- /dev/null
+++ b/src/chock/validation/floor_history.py
@@ -0,0 +1,88 @@
+"""The floor's per-commit pass: each commit in base..head judged with the base's content gates.
+
+The cumulative diff misses a secret added in one commit and removed in the next; this pass does not.
+Each blob a commit adds or changes outside the control plane is judged whole, in every reading of
+`scan.floor_texts`, with no waiver; a finding whose line (same reading, same digest) the base already
+has at that path is not the pull request's. It fails closed: a range past the commit limit, or a blob
+over the size limit, is undecided, naming the commit and path.
+Not seen: other encodings (utf-32, compressed or encoded content), commit messages, file names.
+"""
+
+from __future__ import annotations
+
+import dataclasses
+import tempfile
+from collections.abc import Callable
+from pathlib import Path
+
+from chock.display import inert
+from chock.gate.runner import GateContext
+from chock.history import gitlog
+from chock.history.gates import RULE_CONTENT, load_rules
+from chock.history.scan import Finding, Limits, _digest, floor_lines, scan
+from chock.validation.floor_git import FloorError, Revision
+
+_COMPILED = ".chock/compiled/"
+_SURFACES = ("ci-gate", "git-hook")
+_SHORT = 12
+#: The largest blob the floor reads into memory to judge; a larger one is undecided, named by commit and path.
+FLOOR_MAX_BLOB_BYTES = 64 * 1024 * 1024
+NO_CONTENT_GATES = "history: the base has no content gates on either surface; per-commit pass not run"
+
+
+def _introduced(finding: Finding, base: Revision) -> bool:
+ """Whether the finding is the pull request's: its line (or, for a path finding, its path) is not at the base."""
+ if finding.rule != RULE_CONTENT:
+ return not base.has(finding.path)
+ data = base.blob(finding.path)
+ return data is None or finding.key not in {_digest(line) for line in floor_lines(data)}
+
+
+def _report(repo: Path, base: Revision, head: Revision, limits: Limits):
+ with tempfile.TemporaryDirectory(prefix="chock-floor-history-") as scratch:
+ root = Path(scratch)
+ base.materialise(_COMPILED, root)
+ try:
+ rules, _skipped = load_rules(root, _SURFACES)
+ except gitlog.HistoryError as exc:
+ if "no installed content gates" in str(exc):
+ return None
+ msg = f"history: {exc}"
+ raise FloorError(msg) from exc
+ rules = [
+ dataclasses.replace(rule, pragma_pattern=None, judge=GateContext(repo_root=repo, scope=rule.judge.scope))
+ for rule in rules
+ ]
+ try:
+ return scan(repo, rules, base.sha, limits, head.sha)
+ except gitlog.HistoryError as exc:
+ msg = f"history: {exc}"
+ raise FloorError(msg) from exc
+
+
+def history_findings(
+ repo: Path, base: Revision, head: Revision, control_plane: Callable[[str], bool]
+) -> tuple[list[tuple[str, str]], list[str]]:
+ """((policy, finding) per refusal candidate, notes) of the per-commit pass; FloorError (undecided) when it
+ cannot judge all of it."""
+ limits = Limits(max_blob_bytes=FLOOR_MAX_BLOB_BYTES, judge_binary=True, renames=False)
+ report = _report(repo, base, head, limits)
+ if report is None:
+ return [], [NO_CONTENT_GATES]
+ if report.truncated:
+ msg = (
+ f"history: {base.sha[:_SHORT]}..{head.sha[:_SHORT]} holds more than {limits.max_commits} commits; "
+ "the commits past the limit were not judged"
+ )
+ raise FloorError(msg)
+ unread = [(c, p, why) for c, p, why in report.unread if not control_plane(p)]
+ if unread:
+ named = "; ".join(f"{c[:_SHORT]} {inert(p)} ({why})" for c, p, why in unread)
+ msg = f"history: blobs not judged: {named}"
+ raise FloorError(msg)
+ found = [
+ (f.policy, f"{f.commit[:_SHORT]} {inert(f.path)}{f':{f.line}' if f.line else ''} ({f.rule})")
+ for f in report.findings
+ if not control_plane(f.path) and _introduced(f, base)
+ ]
+ return found, []
diff --git a/src/chock/validation/floor_outcome.py b/src/chock/validation/floor_outcome.py
new file mode 100644
index 00000000..7cda70cd
--- /dev/null
+++ b/src/chock/validation/floor_outcome.py
@@ -0,0 +1,25 @@
+"""What `chock check --floor` found: the refusals, undecided lines, notes and listed control-plane paths."""
+
+from __future__ import annotations
+
+from dataclasses import dataclass, field
+
+from chock.validation import control_plane as cp
+
+
+@dataclass
+class Outcome:
+ refusals: list[str] = field(default_factory=list)
+ undecided: list[str] = field(default_factory=list)
+ notes: list[str] = field(default_factory=list)
+ listed: list[str] = field(default_factory=list)
+ mode: str = cp.REFUSE
+ in_force: str = ""
+ #: Listed paths that only a commit of the range changed; the tree diff leaves them as at the base.
+ history_only: set[str] = field(default_factory=set)
+ #: Listed path -> the any-depth pattern that matched it below the top level (the cost of matching at depth).
+ deep: dict[str, str] = field(default_factory=dict)
+ #: The base has no `.chock`: nothing was judged (V6).
+ first_adoption: bool = False
+ #: An error stopped the run before any verdict; `undecided` holds its one line.
+ stopped: bool = False
diff --git a/src/chock/validation/floor_sarif.py b/src/chock/validation/floor_sarif.py
new file mode 100644
index 00000000..6b219e57
--- /dev/null
+++ b/src/chock/validation/floor_sarif.py
@@ -0,0 +1,48 @@
+"""`chock check --floor --sarif `: the floor's result as one SARIF 2.1.0 log; the exit code is unchanged."""
+
+from __future__ import annotations
+
+import json
+import sys
+from pathlib import Path
+
+from chock import __version__
+from chock.gate.sarif import INFORMATION_URI, SARIF_SCHEMA, safe_text
+from chock.gate.sarif_output import write_output
+from chock.validation import control_plane as cp
+from chock.validation.floor_outcome import Outcome
+
+_REFUSED = "floor/refused"
+_UNDECIDED_EXIT = 2
+
+
+def _result(rule: str, level: str, text: str, path: str | None = None) -> dict:
+ result: dict = {"ruleId": rule, "level": level, "message": {"text": safe_text(text)}}
+ if path is not None:
+ result["locations"] = [{"physicalLocation": {"artifactLocation": {"uri": safe_text(path)}}}]
+ return result
+
+
+def log(outcome: Outcome) -> dict:
+ """Control-plane paths first, one result each; then every refusal; undecided lines as notifications."""
+ level = "error" if outcome.mode == cp.REFUSE else "note"
+ why = f"control-plane path changed ({outcome.mode}); the floor does not judge whether this is safe"
+ results = [_result(cp.RULE, level, why, path) for path in outcome.listed]
+ results += [_result(_REFUSED, "error", line) for line in outcome.refusals]
+ notes = [{"level": "error", "message": {"text": safe_text(line)}} for line in outcome.undecided]
+ driver = {"name": "chock", "version": __version__, "informationUri": INFORMATION_URI}
+ run = {
+ "tool": {"driver": driver},
+ "invocations": [{"executionSuccessful": not outcome.undecided, "toolExecutionNotifications": notes}],
+ "results": results,
+ }
+ return {"$schema": SARIF_SCHEMA, "version": "2.1.0", "runs": [run]}
+
+
+def write(repo: Path, output: str, outcome: Outcome, code: int) -> int:
+ """Write the log; `code` stands unless the file cannot be written, which is undecided."""
+ text = json.dumps(log(outcome), indent=2) + "\n"
+ if failure := write_output(Path(output), text, repo):
+ sys.stderr.write(f"UNDECIDED floor: cannot write --sarif: {failure}\n")
+ return _UNDECIDED_EXIT
+ return code
diff --git a/src/chock/validation/report.py b/src/chock/validation/report.py
index 084a14eb..29bebbdc 100644
--- a/src/chock/validation/report.py
+++ b/src/chock/validation/report.py
@@ -5,6 +5,9 @@
import json
from dataclasses import dataclass, field
+from chock.manifest import MANIFEST_DEFAULT, artifact_key
+from chock.output import first_time
+
@dataclass
class Finding:
@@ -19,8 +22,14 @@ class Report:
errors: list[Finding] = field(default_factory=list)
warnings: list[Finding] = field(default_factory=list)
infos: list[Finding] = field(default_factory=list)
+ _defaults: set[tuple[str, str]] = field(default_factory=set, repr=False)
def add(self, finding: Finding) -> None:
+ if finding.check == MANIFEST_DEFAULT:
+ key = (artifact_key(finding.path), finding.message)
+ if key in self._defaults:
+ return
+ self._defaults.add(key)
if finding.severity == "error":
self.errors.append(finding)
elif finding.severity == "warning":
@@ -57,6 +66,8 @@ def emit(report: Report, *, use_json: bool) -> None:
for finding in report.errors:
print(f" [ERROR] {finding.path} :: {finding.check}: {finding.message}")
for finding in report.warnings:
+ if finding.check == MANIFEST_DEFAULT and not first_time((artifact_key(finding.path), finding.message)):
+ continue # already printed, with its path, earlier in this command
print(f" [WARN] {finding.path} :: {finding.check}: {finding.message}")
for finding in report.infos:
print(f" [INFO] {finding.path} :: {finding.check}: {finding.message}")
diff --git a/tests/fixtures/cli_help_golden.txt b/tests/fixtures/cli_help_golden.txt
index 9c48e9ee..d87c3ca0 100644
--- a/tests/fixtures/cli_help_golden.txt
+++ b/tests/fixtures/cli_help_golden.txt
@@ -8,11 +8,11 @@ Everyday:
install Build a chock.sh selection into one plugin for one agent (install --selection [--client C])
remove Remove an installed policy and resync
sync Recompile + rewire so the repo matches its policies (--ci/--skills for extras)
- check Run every truth check: validate, verify, evals, matrix (--only to narrow; --history scans past commits)
+ check Run every truth check: validate, verify, evals, matrix (--only to narrow; --history scans past commits; --floor, a preview, judges a pull request's merge result with its base's gates; it holds only as a required check the pull request cannot redefine, and judges committed content only)
status Policy states and coverage (--only registry,log for more)
stop Refuse every agent tool call, commit and push here until resume (--agent C for one client)
resume Lift a stop: agents are judged by the policies again
- doctor Check each client's hooks on each route: present, current, and seen running (--client X)
+ doctor Check each client's hooks on each route: present, current, and seen running (--client X); --live runs each hook on a canary
incident An ordered, redacted timeline from the local decision log (incident --since T [--until T] [--share])
witness Export one client's redacted decision log for its agentseam evidence issue (witness export --client C)
enable Enable a policy by id
@@ -22,6 +22,7 @@ Everyday:
Authoring:
new Create a deterministic artifact skeleton
compile Low-level single-policy compile
+ emit Write a vendor's managed-settings bundle under --out for an admin to deploy (emit --managed claude_code --python --on-failure block|allow --out ); refuses an --out that is a filesystem root or inside a system folder
install-skills Install bundled authoring skills into agent skill dirs (write mode; check via CI)
registry Scan/list/resolve the artifact registry
plugin Package policies as installable plugins (plugin build [--format claude] [--check])
diff --git a/tests/fixtures/emitter_stability/golden/stability-hook/managed-setting/managed-settings.json b/tests/fixtures/emitter_stability/golden/stability-hook/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/tests/fixtures/emitter_stability/golden/stability-hook/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/tests/fixtures/emitter_stability/golden/stability-rule/managed-setting/managed-settings.json b/tests/fixtures/emitter_stability/golden/stability-rule/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/tests/fixtures/emitter_stability/golden/stability-rule/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/tests/fixtures/emitter_stability/golden/stability-script/managed-setting/managed-settings.json b/tests/fixtures/emitter_stability/golden/stability-script/managed-setting/managed-settings.json
deleted file mode 100644
index 8efb266a..00000000
--- a/tests/fixtures/emitter_stability/golden/stability-script/managed-setting/managed-settings.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "deny": [],
- "ask": []
-}
\ No newline at end of file
diff --git a/tests/fixtures/managed_emit/block-no-verify.json b/tests/fixtures/managed_emit/block-no-verify.json
new file mode 100644
index 00000000..ce9a2c20
--- /dev/null
+++ b/tests/fixtures/managed_emit/block-no-verify.json
@@ -0,0 +1,27 @@
+{
+ "hooks": {
+ "PreToolUse": [
+ {
+ "matcher": "Bash|PowerShell",
+ "hooks": [
+ {
+ "type": "command",
+ "command": "/usr/bin/python3",
+ "args": [
+ "-I",
+ "-X",
+ "utf8",
+ "-c",
+ "import sys,os;r=sys.argv[1];m=[p for p in (r,*(os.path.join(os.path.dirname(r),*f.split('/')) for f in ('_chock_runtime.py', 'block-no-verify.py', 'chock_shellparse/__init__.py', 'chock_shellparse/args.py', 'chock_shellparse/parse.py', 'chock_shellparse/targets.py', 'chock_shellparse/writes.py', 'claude_code.py'))) if not os.path.isfile(p)];o=sys.version_info<(3, 11,);w='chock: '+('this hook needs Python 3.11+, '+sys.executable+' is older' if o else 'missing '+', '.join(m))+'; refusing this call (--on-failure block)\\n';(o or m) and (sys.stderr.write(w),sys.exit(2));sys.argv=sys.argv[1:];import runpy;runpy.run_path(r,run_name='__main__')",
+ "/srv/chock-managed/block-no-verify/scripts/claude_code.py",
+ "--guard",
+ "/srv/chock-managed/block-no-verify/scripts/block-no-verify.py"
+ ],
+ "timeout": 45,
+ "onFailure": "block"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/tests/fixtures/managed_emit/scan-secrets.json b/tests/fixtures/managed_emit/scan-secrets.json
new file mode 100644
index 00000000..e918e589
--- /dev/null
+++ b/tests/fixtures/managed_emit/scan-secrets.json
@@ -0,0 +1,49 @@
+{
+ "hooks": {
+ "PreToolUse": [
+ {
+ "matcher": "Write|Edit|MultiEdit|NotebookEdit",
+ "hooks": [
+ {
+ "type": "command",
+ "command": "/usr/bin/python3",
+ "args": [
+ "-I",
+ "-X",
+ "utf8",
+ "-c",
+ "import sys,os;r=sys.argv[1];m=[p for p in (r,*(os.path.join(os.path.dirname(r),*f.split('/')) for f in ('_chock_runtime.py', 'claude_code.py', 'gate.json', 'gate.py'))) if not os.path.isfile(p)];o=sys.version_info<(3, 11,);w='chock: '+('this hook needs Python 3.11+, '+sys.executable+' is older' if o else 'missing '+', '.join(m))+'; refusing this call (--on-failure block)\\n';(o or m) and (sys.stderr.write(w),sys.exit(2));sys.argv=sys.argv[1:];import runpy;runpy.run_path(r,run_name='__main__')",
+ "/srv/chock-managed/scan-secrets/scripts/claude_code.py",
+ "--gate",
+ "/srv/chock-managed/scan-secrets/scripts/gate.json"
+ ],
+ "timeout": 45,
+ "onFailure": "block"
+ }
+ ]
+ }
+ ],
+ "Stop": [
+ {
+ "hooks": [
+ {
+ "type": "command",
+ "command": "/usr/bin/python3",
+ "args": [
+ "-I",
+ "-X",
+ "utf8",
+ "-c",
+ "import sys,os;r=sys.argv[1];m=[p for p in (r,*(os.path.join(os.path.dirname(r),*f.split('/')) for f in ('_chock_runtime.py', 'claude_code.py', 'gate.json', 'gate.py'))) if not os.path.isfile(p)];o=sys.version_info<(3, 11,);w='chock: '+('this hook needs Python 3.11+, '+sys.executable+' is older' if o else 'missing '+', '.join(m))+'; this call goes ahead unchecked (--on-failure allow)\\n';(o or m) and (sys.stderr.write(w),sys.exit(0));sys.argv=sys.argv[1:];import runpy;runpy.run_path(r,run_name='__main__')",
+ "/srv/chock-managed/scan-secrets/scripts/claude_code.py",
+ "--gate",
+ "/srv/chock-managed/scan-secrets/scripts/gate.json",
+ "--stop"
+ ],
+ "timeout": 45
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/tests/fixtures/plugin_targets/antigravity.json b/tests/fixtures/plugin_targets/antigravity.json
index ce84eab1..3a86e1a3 100644
--- a/tests/fixtures/plugin_targets/antigravity.json
+++ b/tests/fixtures/plugin_targets/antigravity.json
@@ -41,7 +41,7 @@
"Stop": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/antigravity.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/Stop-501fc3f8.json\" --index-sha256 e1a30025412bd51fc9294802aec6f3f90f87a006577b73a0fbd3a754379bcbae --root \"__CHOCK_PLUGIN_ROOT__\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/antigravity.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/Stop-501fc3f8.json\" --index-sha256 0723fe19cf149e5cfb81c4212a4a48e6dd9087a4503e8e06c4700b6050f48707 --root \"__CHOCK_PLUGIN_ROOT__\"",
"timeout": 45
},
{
@@ -55,7 +55,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/antigravity.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/PreToolUse-b4ab2f9e.json\" --index-sha256 654471a853e58075776985e5cb35e276eb57b86dcc39cb934351dd5559dcb8a1 --root \"__CHOCK_PLUGIN_ROOT__\" --stop-check",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/antigravity.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/PreToolUse-b4ab2f9e.json\" --index-sha256 953302045b1f8ba8218f7147da4f3fa6c806e361ab15b22a82cd4b0a096fc2f3 --root \"__CHOCK_PLUGIN_ROOT__\" --stop-check",
"timeout": 45
}
],
diff --git a/tests/fixtures/plugin_targets/droid.json b/tests/fixtures/plugin_targets/droid.json
index 9f231a64..b12c9460 100644
--- a/tests/fixtures/plugin_targets/droid.json
+++ b/tests/fixtures/plugin_targets/droid.json
@@ -44,7 +44,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${DROID_PLUGIN_ROOT}/scripts/launch.sh\" \"${DROID_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${DROID_PLUGIN_ROOT}/scripts/factory_droid.py\" --multi \"${DROID_PLUGIN_ROOT}/scripts/chock_index/PreToolUse-f8a1fdfc.json\" --index-sha256 79f98b11b926dbebaa76c2a28e5bfe44b7e9eb49d4a6b3038f2f5933210af36e --root \"${DROID_PLUGIN_ROOT}\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${DROID_PLUGIN_ROOT}/scripts/launch.sh\" \"${DROID_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${DROID_PLUGIN_ROOT}/scripts/factory_droid.py\" --multi \"${DROID_PLUGIN_ROOT}/scripts/chock_index/PreToolUse-f8a1fdfc.json\" --index-sha256 1fe6eafa07fd4ac4378bd7836ed75ee30f83b2022d9f8d0717b26d8f5dde71ff --root \"${DROID_PLUGIN_ROOT}\"",
"timeout": 45
}
],
@@ -54,7 +54,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${DROID_PLUGIN_ROOT}/scripts/launch.sh\" \"${DROID_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${DROID_PLUGIN_ROOT}/scripts/factory_droid.py\" --multi \"${DROID_PLUGIN_ROOT}/scripts/chock_index/PreToolUse-91dc9fe9.json\" --index-sha256 654471a853e58075776985e5cb35e276eb57b86dcc39cb934351dd5559dcb8a1 --root \"${DROID_PLUGIN_ROOT}\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${DROID_PLUGIN_ROOT}/scripts/launch.sh\" \"${DROID_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${DROID_PLUGIN_ROOT}/scripts/factory_droid.py\" --multi \"${DROID_PLUGIN_ROOT}/scripts/chock_index/PreToolUse-91dc9fe9.json\" --index-sha256 953302045b1f8ba8218f7147da4f3fa6c806e361ab15b22a82cd4b0a096fc2f3 --root \"${DROID_PLUGIN_ROOT}\"",
"timeout": 45
}
],
@@ -75,7 +75,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${DROID_PLUGIN_ROOT}/scripts/launch.sh\" \"${DROID_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${DROID_PLUGIN_ROOT}/scripts/factory_droid.py\" --multi \"${DROID_PLUGIN_ROOT}/scripts/chock_index/Stop-185f9750.json\" --index-sha256 e1a30025412bd51fc9294802aec6f3f90f87a006577b73a0fbd3a754379bcbae --root \"${DROID_PLUGIN_ROOT}\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${DROID_PLUGIN_ROOT}/scripts/launch.sh\" \"${DROID_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${DROID_PLUGIN_ROOT}/scripts/factory_droid.py\" --multi \"${DROID_PLUGIN_ROOT}/scripts/chock_index/Stop-185f9750.json\" --index-sha256 0723fe19cf149e5cfb81c4212a4a48e6dd9087a4503e8e06c4700b6050f48707 --root \"${DROID_PLUGIN_ROOT}\"",
"timeout": 45
}
]
diff --git a/tests/fixtures/plugin_targets/goose.json b/tests/fixtures/plugin_targets/goose.json
index 3083fc6e..99e841ce 100644
--- a/tests/fixtures/plugin_targets/goose.json
+++ b/tests/fixtures/plugin_targets/goose.json
@@ -40,7 +40,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${PLUGIN_ROOT}/scripts/launch.sh\" \"${PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${PLUGIN_ROOT}/scripts/goose.py\" --multi \"${PLUGIN_ROOT}/scripts/chock_index/PreToolUse-b6718bef.json\" --index-sha256 79f98b11b926dbebaa76c2a28e5bfe44b7e9eb49d4a6b3038f2f5933210af36e --root \"${PLUGIN_ROOT}\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${PLUGIN_ROOT}/scripts/launch.sh\" \"${PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${PLUGIN_ROOT}/scripts/goose.py\" --multi \"${PLUGIN_ROOT}/scripts/chock_index/PreToolUse-b6718bef.json\" --index-sha256 1fe6eafa07fd4ac4378bd7836ed75ee30f83b2022d9f8d0717b26d8f5dde71ff --root \"${PLUGIN_ROOT}\"",
"on_failure": "block",
"timeout": 45
}
@@ -51,7 +51,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${PLUGIN_ROOT}/scripts/launch.sh\" \"${PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${PLUGIN_ROOT}/scripts/goose.py\" --multi \"${PLUGIN_ROOT}/scripts/chock_index/PreToolUse-031b12f7.json\" --index-sha256 654471a853e58075776985e5cb35e276eb57b86dcc39cb934351dd5559dcb8a1 --root \"${PLUGIN_ROOT}\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${PLUGIN_ROOT}/scripts/launch.sh\" \"${PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${PLUGIN_ROOT}/scripts/goose.py\" --multi \"${PLUGIN_ROOT}/scripts/chock_index/PreToolUse-031b12f7.json\" --index-sha256 953302045b1f8ba8218f7147da4f3fa6c806e361ab15b22a82cd4b0a096fc2f3 --root \"${PLUGIN_ROOT}\"",
"on_failure": "block",
"timeout": 45
}
@@ -74,7 +74,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${PLUGIN_ROOT}/scripts/launch.sh\" \"${PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${PLUGIN_ROOT}/scripts/goose.py\" --multi \"${PLUGIN_ROOT}/scripts/chock_index/Stop-4cd5d275.json\" --index-sha256 e1a30025412bd51fc9294802aec6f3f90f87a006577b73a0fbd3a754379bcbae --root \"${PLUGIN_ROOT}\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${PLUGIN_ROOT}/scripts/launch.sh\" \"${PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${PLUGIN_ROOT}/scripts/goose.py\" --multi \"${PLUGIN_ROOT}/scripts/chock_index/Stop-4cd5d275.json\" --index-sha256 0723fe19cf149e5cfb81c4212a4a48e6dd9087a4503e8e06c4700b6050f48707 --root \"${PLUGIN_ROOT}\"",
"on_failure": "block",
"timeout": 45
}
diff --git a/tests/fixtures/plugin_targets/kimi.json b/tests/fixtures/plugin_targets/kimi.json
index d51fb906..7521273c 100644
--- a/tests/fixtures/plugin_targets/kimi.json
+++ b/tests/fixtures/plugin_targets/kimi.json
@@ -39,12 +39,12 @@
"hooks": [
{
"event": "Stop",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${KIMI_PLUGIN_ROOT}/scripts/launch.sh\" \"${KIMI_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${KIMI_PLUGIN_ROOT}/scripts/kimi_code.py\" --multi \"${KIMI_PLUGIN_ROOT}/scripts/chock_index/hooks-55aaba09.json\" --index-sha256 e1a30025412bd51fc9294802aec6f3f90f87a006577b73a0fbd3a754379bcbae --root \"${KIMI_PLUGIN_ROOT}\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${KIMI_PLUGIN_ROOT}/scripts/launch.sh\" \"${KIMI_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${KIMI_PLUGIN_ROOT}/scripts/kimi_code.py\" --multi \"${KIMI_PLUGIN_ROOT}/scripts/chock_index/hooks-55aaba09.json\" --index-sha256 0723fe19cf149e5cfb81c4212a4a48e6dd9087a4503e8e06c4700b6050f48707 --root \"${KIMI_PLUGIN_ROOT}\"",
"timeout": 45
},
{
"event": "PreToolUse",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${KIMI_PLUGIN_ROOT}/scripts/launch.sh\" \"${KIMI_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${KIMI_PLUGIN_ROOT}/scripts/kimi_code.py\" --multi \"${KIMI_PLUGIN_ROOT}/scripts/chock_index/hooks-c573a7ea.json\" --index-sha256 654471a853e58075776985e5cb35e276eb57b86dcc39cb934351dd5559dcb8a1 --root \"${KIMI_PLUGIN_ROOT}\" --stop-check",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${KIMI_PLUGIN_ROOT}/scripts/launch.sh\" \"${KIMI_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${KIMI_PLUGIN_ROOT}/scripts/kimi_code.py\" --multi \"${KIMI_PLUGIN_ROOT}/scripts/chock_index/hooks-c573a7ea.json\" --index-sha256 953302045b1f8ba8218f7147da4f3fa6c806e361ab15b22a82cd4b0a096fc2f3 --root \"${KIMI_PLUGIN_ROOT}\" --stop-check",
"timeout": 45
},
{
@@ -62,12 +62,12 @@
"hooks": [
{
"event": "Stop",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${KIMI_PLUGIN_ROOT}/scripts/launch.sh\" \"${KIMI_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${KIMI_PLUGIN_ROOT}/scripts/kimi_code.py\" --multi \"${KIMI_PLUGIN_ROOT}/scripts/chock_index/hooks-55aaba09.json\" --index-sha256 e1a30025412bd51fc9294802aec6f3f90f87a006577b73a0fbd3a754379bcbae --root \"${KIMI_PLUGIN_ROOT}\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${KIMI_PLUGIN_ROOT}/scripts/launch.sh\" \"${KIMI_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${KIMI_PLUGIN_ROOT}/scripts/kimi_code.py\" --multi \"${KIMI_PLUGIN_ROOT}/scripts/chock_index/hooks-55aaba09.json\" --index-sha256 0723fe19cf149e5cfb81c4212a4a48e6dd9087a4503e8e06c4700b6050f48707 --root \"${KIMI_PLUGIN_ROOT}\"",
"timeout": 45
},
{
"event": "PreToolUse",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${KIMI_PLUGIN_ROOT}/scripts/launch.sh\" \"${KIMI_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${KIMI_PLUGIN_ROOT}/scripts/kimi_code.py\" --multi \"${KIMI_PLUGIN_ROOT}/scripts/chock_index/hooks-c573a7ea.json\" --index-sha256 654471a853e58075776985e5cb35e276eb57b86dcc39cb934351dd5559dcb8a1 --root \"${KIMI_PLUGIN_ROOT}\" --stop-check",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"${KIMI_PLUGIN_ROOT}/scripts/launch.sh\" \"${KIMI_PLUGIN_ROOT}/scripts/chock_bundle.py\" --bundle demo-bundle --members \"${KIMI_PLUGIN_ROOT}/scripts/kimi_code.py\" --multi \"${KIMI_PLUGIN_ROOT}/scripts/chock_index/hooks-c573a7ea.json\" --index-sha256 953302045b1f8ba8218f7147da4f3fa6c806e361ab15b22a82cd4b0a096fc2f3 --root \"${KIMI_PLUGIN_ROOT}\" --stop-check",
"timeout": 45
},
{
diff --git a/tests/fixtures/plugin_targets/openhands.json b/tests/fixtures/plugin_targets/openhands.json
index 7d5085f3..e30482c8 100644
--- a/tests/fixtures/plugin_targets/openhands.json
+++ b/tests/fixtures/plugin_targets/openhands.json
@@ -45,7 +45,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/openhands.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/PreToolUse-b310004d.json\" --index-sha256 79f98b11b926dbebaa76c2a28e5bfe44b7e9eb49d4a6b3038f2f5933210af36e --root \"__CHOCK_PLUGIN_ROOT__\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/openhands.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/PreToolUse-b310004d.json\" --index-sha256 1fe6eafa07fd4ac4378bd7836ed75ee30f83b2022d9f8d0717b26d8f5dde71ff --root \"__CHOCK_PLUGIN_ROOT__\"",
"timeout": 45
}
],
@@ -55,7 +55,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/openhands.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/PreToolUse-81fe7457.json\" --index-sha256 654471a853e58075776985e5cb35e276eb57b86dcc39cb934351dd5559dcb8a1 --root \"__CHOCK_PLUGIN_ROOT__\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/openhands.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/PreToolUse-81fe7457.json\" --index-sha256 953302045b1f8ba8218f7147da4f3fa6c806e361ab15b22a82cd4b0a096fc2f3 --root \"__CHOCK_PLUGIN_ROOT__\"",
"timeout": 45
}
],
@@ -76,7 +76,7 @@
"hooks": [
{
"type": "command",
- "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/openhands.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/Stop-185f9750.json\" --index-sha256 e1a30025412bd51fc9294802aec6f3f90f87a006577b73a0fbd3a754379bcbae --root \"__CHOCK_PLUGIN_ROOT__\"",
+ "command": "git -c 'alias.chock-sh=!set -f; IFS=; test -f $1 || { echo chock: the plugin launcher is missing, so this call cannot be checked. Refusing. >&2; exit 2; }; sh' chock-sh \"__CHOCK_PLUGIN_ROOT__/scripts/launch.sh\" \"__CHOCK_PLUGIN_ROOT__/scripts/chock_bundle.py\" --bundle demo-bundle --members \"__CHOCK_PLUGIN_ROOT__/scripts/openhands.py\" --multi \"__CHOCK_PLUGIN_ROOT__/scripts/chock_index/Stop-185f9750.json\" --index-sha256 0723fe19cf149e5cfb81c4212a4a48e6dd9087a4503e8e06c4700b6050f48707 --root \"__CHOCK_PLUGIN_ROOT__\"",
"timeout": 45
}
]
diff --git a/tests/fixtures/runtime_goldens/_chock_runtime.py b/tests/fixtures/runtime_goldens/_chock_runtime.py
index 36926292..233ffb4c 100644
--- a/tests/fixtures/runtime_goldens/_chock_runtime.py
+++ b/tests/fixtures/runtime_goldens/_chock_runtime.py
@@ -32,6 +32,8 @@
BYTECODE_OFF = {'PYTHONDONTWRITEBYTECODE': '1'}
+ISOLATED_START = "import os, runpy, sys\nsys.argv = sys.argv[1:]\nsys.path.insert(0, os.path.dirname(os.path.abspath(sys.argv[0])))\nrunpy.run_path(sys.argv[0], run_name='__main__')\n"
+
PATTERN_SECONDS = 10
PATTERN_START_SECONDS = 10
@@ -111,6 +113,17 @@ def run_tree(argv, *, timeout=None, **options):
untrack_tree(proc)
return _chock_subprocess.CompletedProcess(argv, proc.returncode, out, err)
+def python_free_env(env=None):
+ """`env` (this process's by default) without any `PYTHON*` variable, plus bytecode off for grandchildren."""
+ base = _chock_os.environ if env is None else env
+ return {**{k: v for k, v in base.items() if not k.upper().startswith('PYTHON')}, **BYTECODE_OFF}
+
+def isolated_child(argv, env=None):
+ """(argv, env) that run the Python child `[interpreter, script, *args]` isolated: no PYTHON* variable,
+ user site or current folder can change what it imports; its own folder is put on sys.path explicitly."""
+ interpreter, script, *args = argv
+ return ([interpreter, '-I', '-B', '-X', 'utf8', '-c', ISOLATED_START, str(script), *args], python_free_env(env))
+
def engine_remaining(deadline):
"""Seconds left before `deadline`, never negative."""
return max(deadline - _chock_time.monotonic(), 0.0)
@@ -803,7 +816,7 @@ def bash_candidates() -> list[str]:
def interpreter_env(interpreter: str) -> dict[str, str]:
"""The environment a guard runs in: on Windows, Git's usr/bin ahead on PATH for sed and grep."""
- env = {**_chock_os.environ, **BYTECODE_OFF}
+ env = python_free_env()
env.pop(CAN_ASK_ENV, None)
if _chock_os.name != _WINDOWS:
return env
@@ -861,6 +874,11 @@ def split_command(command: str) -> tuple[list[str], bool]:
except ValueError:
return (command.split(), True)
+def _guard_start(interpreter: str, guard: _chock_Path, args: list[str], env: dict[str, str]):
+ """(argv, env) for the guard: a Python guard starts isolated, a shell guard as given."""
+ argv = [interpreter, str(guard), *args]
+ return isolated_child(argv, env) if guard.suffix == PYTHON_SUFFIX else (argv, env)
+
def run_guard(guard: _chock_Path, command: str, tool: str='') -> str:
"""`GUARD_BLOCKED` / `GUARD_ASKED` / `GUARD_CLEAN` when the guard ran, otherwise why it did not."""
return run_guard_detailed(guard, command, tool)[0]
@@ -888,7 +906,8 @@ def run_guard_detailed(guard: _chock_Path, command: str, tool: str='', *, can_as
if fallback:
env[ARGV_FALLBACK_ENV] = '1'
env.update({} if can_ask is None else {CAN_ASK_ENV: '1' if can_ask else '0'})
- proc = run_tree([interpreter, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=time_left(deadline, [interpreter, str(guard)]), check=False)
+ argv, env = _guard_start(interpreter, guard, args, env)
+ proc = run_tree(argv, capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=time_left(deadline, [interpreter, str(guard)]), check=False)
except _chock_subprocess.TimeoutExpired:
print(f'chock: guard timed out after {ENGINE_BUDGET_SECONDS}s, not checked', file=sys.stderr)
return (GUARD_ERRORED, '')
@@ -2624,9 +2643,9 @@ def run_gate(gate, writes, event, run_in, deadline):
runner = runner_for(gate)
if runner is None:
return (GATE_ERRORED, 'the vendored gate runner is not installed beside this gate')
- argv = [sys.executable, str(runner), 'run', '--gate', str(gate), '--event', event]
+ argv, env = isolated_child([sys.executable, str(runner), 'run', '--gate', str(gate), '--event', event])
try:
- proc = run_tree(argv, input=json.dumps({'writes': writes, **(extra or {})}), capture_output=True, text=True, encoding=_UTF8, errors='replace', timeout=time_left(deadline, argv), check=False, cwd=str(root) if root is not None else None)
+ proc = run_tree(argv, env=env, input=json.dumps({'writes': writes, **(extra or {})}), capture_output=True, text=True, encoding=_UTF8, errors='replace', timeout=time_left(deadline, argv), check=False, cwd=str(root) if root is not None else None)
except _chock_subprocess.TimeoutExpired as exc:
return (GATE_ERRORED, f'the gate runner gave no verdict within {allowed_seconds(exc)}')
except (OSError, _chock_subprocess.SubprocessError) as exc:
@@ -2767,9 +2786,9 @@ def _tool_call_script(spec, root, payload, deadline=None):
if not script.is_file():
return ('deny', f'script gate: {named!r} is not installed{_TOOL_CALL_UNDECIDED}')
deadline = engine_deadline() if deadline is None else deadline
- argv = [sys.executable, str(script)]
+ argv, env = isolated_child([sys.executable, str(script)])
try:
- proc = run_tree(argv, input=json.dumps(payload), capture_output=True, text=True, encoding='utf-8', errors='replace', cwd=str(root), env={**_chock_os.environ, **BYTECODE_OFF}, timeout=time_left(deadline, argv), check=False)
+ proc = run_tree(argv, input=json.dumps(payload), capture_output=True, text=True, encoding='utf-8', errors='replace', cwd=str(root), env=env, timeout=time_left(deadline, argv), check=False)
except _chock_subprocess.TimeoutExpired as exc:
budget = f'gave no verdict within {allowed_seconds(exc)}'
return ('deny', f'script gate: {script.name} {budget}{_TOOL_CALL_UNDECIDED}')
diff --git a/tests/fixtures/runtime_goldens/antigravity.py b/tests/fixtures/runtime_goldens/antigravity.py
index 87741342..f9e41494 100644
--- a/tests/fixtures/runtime_goldens/antigravity.py
+++ b/tests/fixtures/runtime_goldens/antigravity.py
@@ -748,7 +748,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/claude_code.py b/tests/fixtures/runtime_goldens/claude_code.py
index 558e7fbc..86885f6d 100644
--- a/tests/fixtures/runtime_goldens/claude_code.py
+++ b/tests/fixtures/runtime_goldens/claude_code.py
@@ -855,7 +855,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/codex_cli.py b/tests/fixtures/runtime_goldens/codex_cli.py
index 3cbb9f52..0a9db955 100644
--- a/tests/fixtures/runtime_goldens/codex_cli.py
+++ b/tests/fixtures/runtime_goldens/codex_cli.py
@@ -823,7 +823,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/cursor.py b/tests/fixtures/runtime_goldens/cursor.py
index 6db1a9cd..42fab5ed 100644
--- a/tests/fixtures/runtime_goldens/cursor.py
+++ b/tests/fixtures/runtime_goldens/cursor.py
@@ -721,7 +721,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/devin.py b/tests/fixtures/runtime_goldens/devin.py
index cccf63ea..19b17565 100644
--- a/tests/fixtures/runtime_goldens/devin.py
+++ b/tests/fixtures/runtime_goldens/devin.py
@@ -826,7 +826,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/factory_droid.py b/tests/fixtures/runtime_goldens/factory_droid.py
index bc4eb977..c78e01c2 100644
--- a/tests/fixtures/runtime_goldens/factory_droid.py
+++ b/tests/fixtures/runtime_goldens/factory_droid.py
@@ -809,7 +809,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/gemini_cli.py b/tests/fixtures/runtime_goldens/gemini_cli.py
index 964ae941..9a290d83 100644
--- a/tests/fixtures/runtime_goldens/gemini_cli.py
+++ b/tests/fixtures/runtime_goldens/gemini_cli.py
@@ -826,7 +826,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/goose.py b/tests/fixtures/runtime_goldens/goose.py
index ba78ed46..81e9e529 100644
--- a/tests/fixtures/runtime_goldens/goose.py
+++ b/tests/fixtures/runtime_goldens/goose.py
@@ -782,7 +782,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/grok.py b/tests/fixtures/runtime_goldens/grok.py
index f262f001..39616f2a 100644
--- a/tests/fixtures/runtime_goldens/grok.py
+++ b/tests/fixtures/runtime_goldens/grok.py
@@ -826,7 +826,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/mistral_vibe.py b/tests/fixtures/runtime_goldens/mistral_vibe.py
index 3b865f11..e6fe07a3 100644
--- a/tests/fixtures/runtime_goldens/mistral_vibe.py
+++ b/tests/fixtures/runtime_goldens/mistral_vibe.py
@@ -809,7 +809,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/openhands.py b/tests/fixtures/runtime_goldens/openhands.py
index f852c40f..c6f71ac7 100644
--- a/tests/fixtures/runtime_goldens/openhands.py
+++ b/tests/fixtures/runtime_goldens/openhands.py
@@ -782,7 +782,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/tabnine.py b/tests/fixtures/runtime_goldens/tabnine.py
index 8fd2cb93..29141032 100644
--- a/tests/fixtures/runtime_goldens/tabnine.py
+++ b/tests/fixtures/runtime_goldens/tabnine.py
@@ -782,7 +782,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/vscode_copilot.py b/tests/fixtures/runtime_goldens/vscode_copilot.py
index d62f569f..bab53915 100644
--- a/tests/fixtures/runtime_goldens/vscode_copilot.py
+++ b/tests/fixtures/runtime_goldens/vscode_copilot.py
@@ -717,7 +717,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/fixtures/runtime_goldens/windsurf.py b/tests/fixtures/runtime_goldens/windsurf.py
index a8672de9..74cee413 100644
--- a/tests/fixtures/runtime_goldens/windsurf.py
+++ b/tests/fixtures/runtime_goldens/windsurf.py
@@ -680,7 +680,7 @@ def degrade(decision, event):
# Not self-contained: chock's guard logic lives in the sibling _chock_runtime.py, loaded from this
# file's own folder and pinned to the sha256 of that file's bytes (CRLF read as LF), hashed before they are executed.
# Missing, unreadable, another version, or failing to import: every call refuses (_CHOCK_RUNTIME_FAULT), never allows.
-_CHOCK_RUNTIME_PIN = '8e3b4b73f866de5887946c8afe0dee895548a5d67146470d63350fa84b08b5f2'
+_CHOCK_RUNTIME_PIN = '791b92ce3802e2b71819589bced3f7c5fd079bf535cf469a785480a3a31c91f7'
def _chock_load_runtime():
diff --git a/tests/floor_support.py b/tests/floor_support.py
new file mode 100644
index 00000000..52bac271
--- /dev/null
+++ b/tests/floor_support.py
@@ -0,0 +1,159 @@
+"""Fixture repositories for `chock check --floor`: a base commit on `main`, a pull request on `pr`."""
+
+from __future__ import annotations
+
+import json
+import subprocess
+from pathlib import Path
+
+from chock.validation.checks_floor import main as floor_main
+
+TOKEN_PATTERN = "FLOOR-TOKEN-[0-9]+"
+TEST_PRAGMA = "chock: test-removal-reviewed"
+CHECKOUT = "actions/checkout@" + "0" * 40
+INDEX_PIN = "ab" * 32
+
+TEST_INTEGRITY = {
+ "kind": "test_integrity",
+ "on": ["commit"],
+ "action": "block",
+ "message": "Tests were weakened, not fixed.",
+ "params": {
+ "test_path_regex": "(^|/)tests?/",
+ "assertion_pattern": "\\bassert\\b",
+ "allowlist_pragma": TEST_PRAGMA,
+ },
+}
+FLOOR_TOKEN = {
+ "kind": "content_regex",
+ "on": ["commit", "tool_use"],
+ "action": "block",
+ "message": "No floor tokens.",
+ "params": {"content_pattern": TOKEN_PATTERN},
+}
+PROBE = {
+ "kind": "script",
+ "on": ["commit"],
+ "action": "block",
+ "message": "probe",
+ "params": {"script": ".agents/policies/probe/implementations/probe.py"},
+}
+PROBE_SCRIPT = """import json, os, sys
+payload = json.load(sys.stdin)
+if os.environ.get("FLOOR_PROBE_SECRET"):
+ sys.stderr.write("probe: the environment reached the script\\n")
+ sys.exit(1)
+if payload.get("deleted"):
+ sys.stderr.write("probe: deleted " + ",".join(payload["deleted"]) + "\\n")
+ sys.exit(1)
+sys.exit(0)
+"""
+MARKER_SCRIPT = """import pathlib, sys
+pathlib.Path("MARKER").write_text("ran", encoding="utf-8")
+sys.exit(0)
+"""
+CLAUDE = {
+ "hooks": {
+ "PreToolUse": [
+ {
+ "matcher": "Bash",
+ "hooks": [
+ {
+ "type": "command",
+ "command": f"sh .chock/bin/launch.sh claude.py --multi x.json --index-sha256 {INDEX_PIN}",
+ }
+ ],
+ },
+ {
+ "matcher": "Write|Edit",
+ "hooks": [{"type": "command", "command": "sh .chock/bin/launch.sh claude.py --write"}],
+ },
+ ]
+ }
+}
+CURSOR = {"version": 1, "hooks": {"beforeShellExecution": [{"command": "sh .chock/bin/launch.sh cursor.py"}]}}
+LOCK = {"lockfile_version": "2", "engine": ">=1.2,<2", "packs": [{"id": "test-integrity"}, {"id": "floor-token"}]}
+WORKFLOW = f"""name: chock-floor
+on:
+ pull_request_target:
+ merge_group:
+jobs:
+ floor:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: {CHECKOUT}
+ - name: Floor
+ run: chock check --floor --base "$BASE_SHA" --head "$HEAD_SHA"
+"""
+TEST_FILE = "def test_a():\n assert 1 + 1 == 2\n assert 2 * 2 == 4\n"
+
+
+def git(repo: Path, *args: str) -> str:
+ proc = subprocess.run(["git", "-C", str(repo), *args], check=True, capture_output=True, text=True)
+ return proc.stdout.strip()
+
+
+def write(repo: Path, rel: str, content: object) -> None:
+ path = repo / rel
+ path.parent.mkdir(parents=True, exist_ok=True)
+ text = content if isinstance(content, str) else json.dumps(content, indent=2) + "\n"
+ path.write_text(text, encoding="utf-8")
+
+
+def gate(repo: Path, policy: str, spec: dict, *, surfaces: tuple[str, ...] = ("ci-gate", "git-hook")) -> None:
+ for surface in surfaces:
+ write(repo, f".chock/compiled/{policy}/{surface}/gate.json", spec)
+
+
+def commit(repo: Path, message: str) -> str:
+ git(repo, "add", "-A")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@example.com", "commit", "-q", "--no-gpg-sign", "-m", message)
+ return git(repo, "rev-parse", "HEAD")
+
+
+CONTROL_PLANE = "floor/control-plane-changed"
+
+
+def base_repo(tmp_path: Path, mode: str = "refuse") -> Path:
+ """`main` carries two gates, a probe script gate, hook files, a lock, a runtime, a workflow and a test; `pr` is
+ checked out. `mode` is the base's floor.control_plane (refuse is the default and writes no config)."""
+ repo = tmp_path / "repo"
+ repo.mkdir(parents=True)
+ git(repo, "init", "-q", "-b", "main")
+ gate(repo, "test-integrity", TEST_INTEGRITY)
+ gate(repo, "floor-token", FLOOR_TOKEN)
+ gate(repo, "probe", PROBE, surfaces=("ci-gate",))
+ write(repo, PROBE["params"]["script"], PROBE_SCRIPT)
+ write(repo, ".claude/settings.json", CLAUDE)
+ write(repo, ".cursor/hooks.json", CURSOR)
+ write(repo, "chock.lock", LOCK)
+ write(repo, ".chock/bin/gate.py", "print('runner')\n")
+ write(repo, ".chock/bin/index/claude-PreToolUse-3a2134a7.json", "{}\n")
+ write(repo, ".github/workflows/chock.yml", WORKFLOW)
+ write(repo, "tests/test_core.py", TEST_FILE)
+ write(repo, "src/app.py", "VALUE = 1\n")
+ if mode != "refuse":
+ write(repo, ".chock/config.yaml", f"floor:\n control_plane: {mode}\n")
+ commit(repo, "base")
+ git(repo, "checkout", "-q", "-b", "pr")
+ return repo
+
+
+def run_floor(repo: Path, capsys, *extra: str) -> tuple[int, str]:
+ """The floor's exit code and everything it printed."""
+ code = floor_main(["--repo", str(repo), "--base", "main", *extra])
+ out = capsys.readouterr()
+ return code, out.out + out.err
+
+
+def control_plane_change(tmp_path: Path, capsys, change, *paths: str, extra: tuple[str, ...] = ()) -> None:
+ """`change(repo)` as the pull request: exit 1 under `refuse`, exit 0 under `listed`, each listing every path."""
+ for mode, owed in (("refuse", 1), ("listed", 0)):
+ repo = base_repo(tmp_path / mode, mode)
+ change(repo)
+ code, out = run_floor(repo, capsys, *extra)
+ assert code == owed, f"{mode}: {out}"
+ assert f"{CONTROL_PLANE} ({mode})" in out, out
+ assert out.index(CONTROL_PLANE) < out.index("floor (preview): a floor only"), out
+ for path in paths:
+ assert f"\n {path}\n" in out, f"{mode}: {path} not listed\n{out}"
diff --git a/tests/floor_support4.py b/tests/floor_support4.py
new file mode 100644
index 00000000..e4245208
--- /dev/null
+++ b/tests/floor_support4.py
@@ -0,0 +1,60 @@
+"""Review 4 helpers (pass-4 proofs): rewrite the base on `main`, then branch `pr` from it."""
+
+from __future__ import annotations
+
+import os
+import shutil
+from pathlib import Path
+
+from floor_support import commit, git, run_floor
+
+FAKE_A = "1" * 40
+FAKE_B = "2" * 40
+
+
+def rebase_main(repo: Path, change) -> None:
+ """Apply `change(repo)` on main as a new base commit, then put `pr` back on it."""
+ git(repo, "checkout", "-q", "main")
+ change(repo)
+ commit(repo, "base edit")
+ git(repo, "checkout", "-q", "-B", "pr")
+
+
+def raw_commit(repo: Path, message: str) -> str:
+ """Commit the index as it stands (no `add -A`), so a hand-made gitlink survives."""
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@example.com", "commit", "-q", "--no-gpg-sign", "-m", message)
+ return git(repo, "rev-parse", "HEAD")
+
+
+def gitlink(repo: Path, path: str, sha: str) -> None:
+ git(repo, "update-index", "--add", "--cacheinfo", f"160000,{sha},{path}")
+
+
+def symlink(repo: Path, path: str, target: str) -> None:
+ link = repo / path
+ link.parent.mkdir(parents=True, exist_ok=True)
+ if link.is_symlink() or link.is_file():
+ link.unlink()
+ elif link.is_dir():
+ shutil.rmtree(link)
+ os.symlink(target, link)
+
+
+def rm(repo: Path, path: str) -> None:
+ p = repo / path
+ if p.is_symlink() or p.is_file():
+ p.unlink()
+ elif p.is_dir():
+ shutil.rmtree(p)
+
+
+HOOKLESS = {"hooks": {}}
+
+
+def undecided(repo: Path, capsys, link: str) -> str:
+ """S1: exit 2, naming the link that does not stay on the control plane, and the fix."""
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert f"symbolic link {link} at" in out, out
+ assert "replace the link with real files" in out, out
+ return out
diff --git a/tests/managed_emit_helpers.py b/tests/managed_emit_helpers.py
new file mode 100644
index 00000000..7e8d39f7
--- /dev/null
+++ b/tests/managed_emit_helpers.py
@@ -0,0 +1,130 @@
+"""Shared fixture and helpers for the `chock emit --managed claude_code` tests."""
+
+from __future__ import annotations
+
+import json
+import os
+import re
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+from conftest import baseline_policy
+
+from chock import cli
+from chock.doctor.payloads import payload
+
+FIXTURES = Path(__file__).resolve().parent / "fixtures" / "managed_emit"
+POLICIES = ("block-no-verify", "scan-secrets")
+DEPLOY_ROOT = "/srv/chock-managed"
+DROP_IN = Path("managed-settings.d") / "50-chock.json"
+PERMISSION_RULE = re.compile(r"^[A-Za-z]+\(.*\)$")
+OVERRIDE_CLAIM = re.compile(r"(cannot|can't|can not|unable to) (be )?overrid", re.IGNORECASE)
+
+
+def make_repo(tmp_path: Path) -> Path:
+ """A repository holding the two golden policies and one advisory policy with nothing to run."""
+ root = tmp_path / "repo"
+ for policy_id in (*POLICIES, "yagni"):
+ shutil.copytree(baseline_policy(policy_id), root / ".agents" / "policies" / policy_id)
+ return root
+
+
+PYTHON = "/usr/bin/python3"
+ROOT = Path(__file__).resolve().parents[1]
+DOCS = ROOT / "docs"
+FAIL_CLOSED = re.compile(r"fail(s|ing|ed)?[- ]closed|cannot be (bypassed|disabled)|\benforced\b", re.IGNORECASE)
+
+
+def emit(repo: Path, out: Path, *extra: str, python: str = PYTHON, on_failure: str = "block") -> int:
+ return cli.main(
+ [
+ "emit",
+ "--managed",
+ "claude_code",
+ "--out",
+ str(out),
+ "--repo",
+ str(repo),
+ "--python",
+ python,
+ "--on-failure",
+ on_failure,
+ *extra,
+ ]
+ )
+
+
+def linux(repo: Path, out: Path, *extra: str, on_failure: str = "block") -> int:
+ return emit(repo, out, "--platform", "linux", "--deploy-root", DEPLOY_ROOT, *extra, on_failure=on_failure)
+
+
+def drop_in(out: Path) -> dict:
+ return json.loads((out / "claude_code" / DROP_IN).read_text(encoding="utf-8"))
+
+
+def handlers(doc: dict) -> list[tuple[str, dict]]:
+ return [(event, hook) for event, groups in doc["hooks"].items() for group in groups for hook in group["hooks"]]
+
+
+def tree(root: Path, skip: Path) -> dict[str, bytes]:
+ return {
+ p.relative_to(root).as_posix(): p.read_bytes()
+ for p in root.rglob("*")
+ if p.is_file() and skip not in p.parents and "__pycache__" not in p.parts
+ }
+
+
+def bundle_hook(repo: Path, tmp_path: Path, on_failure: str = "block") -> tuple[Path, dict]:
+ """The block-no-verify guard's handler, emitted with this test's Python and rooted at the bundle itself."""
+ out = tmp_path / "out"
+ bundle = (out / "claude_code" / "bundle").as_posix()
+ assert (
+ emit(
+ repo,
+ out,
+ "--policies",
+ "block-no-verify",
+ "--deploy-root",
+ bundle,
+ python=sys.executable,
+ on_failure=on_failure,
+ )
+ == 0
+ )
+ [(_, hook), *_] = handlers(drop_in(out))
+ return out / "claude_code" / "bundle", hook
+
+
+def env_for(tmp_path: Path, **extra: str) -> dict[str, str]:
+ env = {k: v for k, v in os.environ.items() if k not in ("CLAUDECODE", "AI_AGENT", "CHOCK_AGENT_COMMIT")}
+ home = tmp_path / "home"
+ home.mkdir(exist_ok=True)
+ env["HOME"] = env["USERPROFILE"] = str(home)
+ return {**env, **extra}
+
+
+def run_hook(hook: dict, command: str, cwd: Path, env: dict[str, str]) -> subprocess.CompletedProcess:
+ """Run `hook` the way the client runs exec form: `command` spawned with `args`, no shell."""
+ return subprocess.run(
+ [hook["command"], *hook["args"]],
+ input=json.dumps(payload("claude_code", command, cwd.as_posix())),
+ capture_output=True,
+ text=True,
+ cwd=cwd,
+ env=env,
+ check=False,
+ timeout=60,
+ )
+
+
+def one_line_refusal(capsys: pytest.CaptureFixture[str]) -> str:
+ err = capsys.readouterr().err
+ assert "Traceback" not in err and len(err.strip().splitlines()) == 1, err
+ return err
+
+
+def plan_of(out: Path) -> dict:
+ return json.loads((out / "claude_code" / "deploy.json").read_text(encoding="utf-8"))
diff --git a/tests/readme_figure_support.py b/tests/readme_figure_support.py
new file mode 100644
index 00000000..43c7645c
--- /dev/null
+++ b/tests/readme_figure_support.py
@@ -0,0 +1,53 @@
+"""Shared by the README figure tests: the figure data, the engine-derived set of acting points and the node layout checks."""
+
+from __future__ import annotations
+
+import json
+import re
+import shutil
+import subprocess
+from pathlib import Path
+
+import pytest
+
+ROOT = Path(__file__).resolve().parents[1]
+ASSETS = ROOT / "docs" / "assets" / "readme"
+FIGURE = json.loads((ASSETS / "where-chock-sits.json").read_text(encoding="utf-8"))
+OTHER_POINTS = {"ambient-rule", "mcp-gateway", "git-commit", "git-push", "ci-gate"}
+GIT_POINTS = {"commit": "git-commit", "commit-msg": "git-commit", "push": "git-push"}
+
+
+def engine_acts() -> set[str]:
+ """Every point the engine acts on: the agentseam events used in src/chock, the surfaces and the git events."""
+ from agentseam import contract
+
+ from chock.compile.emitters import SCRIPT_EVENTS
+ from chock.compile.surface_kinds import Surface
+
+ wanted = {event.upper(): event for event in contract.EVENTS}
+ used = {
+ wanted[name]
+ for path in (ROOT / "src" / "chock").rglob("*.py")
+ for name in re.findall(r"_contract\.([A-Z_]+)", path.read_text(encoding="utf-8"))
+ if name in wanted
+ }
+ surfaces = {s.value for s in Surface} & {"ambient-rule", "mcp-gateway", "ci-gate"}
+ return used | surfaces | {GIT_POINTS[event] for event in SCRIPT_EVENTS}
+
+
+def crowded(module: str) -> list:
+ """The shape pairs the figure module's own layout reports as too close; skips when node is missing."""
+ node = shutil.which("node")
+ if not node:
+ pytest.skip("node is not installed")
+ script = (
+ f"import {{layout, crowded}} from './docs/assets/readme/{module}.mjs';"
+ "import {readFileSync} from 'node:fs';"
+ "const W = JSON.parse(readFileSync('docs/assets/readme/where-chock-sits.json', 'utf8'));"
+ "console.log(JSON.stringify(crowded(layout(W))));"
+ )
+ done = subprocess.run(
+ [node, "--input-type=module", "-e", script], cwd=ROOT, capture_output=True, text=True, check=False
+ )
+ assert done.returncode == 0, done.stderr
+ return json.loads(done.stdout)
diff --git a/tests/runtime_payloads.py b/tests/runtime_payloads.py
index b2efa3cb..651faec2 100644
--- a/tests/runtime_payloads.py
+++ b/tests/runtime_payloads.py
@@ -1,128 +1,7 @@
-"""One shell pre-tool payload per vendored runtime, and the deny word each one's wire carries."""
+"""The runtime payloads and wire denies live in the package (`chock.doctor.payloads`); this keeps the old import path."""
from __future__ import annotations
-PAYLOADS = {
- "claude_code": lambda c: {
- "hook_event_name": "PreToolUse",
- "tool_name": "Bash",
- "tool_input": {"command": c},
- "session_id": "s",
- "transcript_path": "/t",
- "permission_mode": "default",
- },
- "vscode_copilot": lambda c: {
- "hook_event_name": "PreToolUse",
- "timestamp": "2026-08-31T00:00:00Z",
- "tool_name": "Bash",
- "tool_input": {"command": c},
- "tool_use_id": "1",
- },
- "cursor": lambda c: {
- "hook_event_name": "beforeShellExecution",
- "conversation_id": "a",
- "generation_id": "b",
- "cursor_version": "3.17.8",
- "workspace_roots": ["/x"],
- "command": c,
- "cwd": "/x",
- "sandbox": False,
- },
- "codex_cli": lambda c: {
- "hook_event_name": "PreToolUse",
- "turn_id": "t1",
- "tool_name": "Bash",
- "tool_input": {"command": c},
- },
- "antigravity": lambda c: {
- "toolCall": {"name": "run_command", "args": {"CommandLine": c, "Cwd": "/x"}},
- "conversationId": "c1",
- "stepIdx": 1,
- "workspacePaths": ["/x"],
- },
- "devin": lambda c: {
- "hook_event_name": "PreToolUse",
- "prompt_id": "p1",
- "tool_name": "Bash",
- "tool_input": {"command": c},
- "session_id": "s",
- },
- "gemini_cli": lambda c: {
- "hook_event_name": "BeforeTool",
- "tool_name": "run_shell_command",
- "tool_input": {"command": c},
- "session_id": "s",
- },
- "grok": lambda c: {
- "hookEventName": "PreToolUse",
- "toolName": "Bash",
- "toolInput": {"command": c},
- "sessionId": "s",
- },
- "tabnine": lambda c: {
- "hook_event_name": "BeforeTool",
- "timestamp": "2026-08-31T00:00:00Z",
- "tool_name": "shell",
- "tool_input": {"command": c},
- },
- "windsurf": lambda c: {
- "trajectory_id": "t1",
- "tool_info": {"command_line": c},
- "cwd": "/x",
- },
- # The next four: agentseam's golden pre_tool payloads (tests/fixtures/golden at bebbfa6), shell tool.
- "factory_droid": lambda c: {
- "hook_event_name": "PreToolUse",
- "permission_mode": "auto-medium",
- "session_id": "s",
- "transcript_path": "/x/.factory/projects/x/session.jsonl",
- "cwd": "/x",
- "tool_name": "Execute",
- "tool_input": {"command": c},
- },
- "goose": lambda c: {
- "event": "PreToolUse",
- "matcher_context": "shell",
- "session_id": "s",
- "tool_call_id": "call-1",
- "tool_name": "shell",
- "tool_input": {"command": c},
- "working_dir": "/x",
- },
- "openhands": lambda c: {
- "event_type": "PreToolUse",
- "session_id": "s",
- "tool_name": "terminal",
- "tool_input": {"command": c},
- "working_dir": "/x",
- },
- "mistral_vibe": lambda c: {
- "hook_event_name": "pre_tool",
- "parent_session_id": None,
- "session_id": "s",
- "tool_call_id": "call-1",
- "tool_name": "bash",
- "tool_input": {"command": c},
- "transcript_path": "/x/.vibe/session.jsonl",
- "cwd": "/x",
- },
-}
+from chock.doctor.payloads import DENY_ON_THE_WIRE, PAYLOADS
-#: The deny each vendor's wire actually carries, witnessed by the deny-guard fixture below:
-#: `block` is the devin-family spelling, `exit-2` windsurf's wordless exit-code grammar (G5).
-DENY_ON_THE_WIRE = {
- "claude_code": "deny",
- "codex_cli": "deny",
- "cursor": "deny",
- "vscode_copilot": "deny",
- "antigravity": "deny",
- "devin": "block",
- "gemini_cli": "deny",
- "grok": "deny",
- "tabnine": "deny",
- "windsurf": "exit-2",
- "factory_droid": "deny",
- "goose": "block",
- "openhands": "deny",
- "mistral_vibe": "deny",
-}
+__all__ = ["DENY_ON_THE_WIRE", "PAYLOADS"]
diff --git a/tests/test_add_default_pin.py b/tests/test_add_default_pin.py
new file mode 100644
index 00000000..4268cfa5
--- /dev/null
+++ b/tests/test_add_default_pin.py
@@ -0,0 +1,125 @@
+"""`chock add ` with no `--ref` takes the default catalog's release tag, never its moving branch."""
+
+from __future__ import annotations
+
+import json
+import shutil
+from pathlib import Path
+
+import pytest
+from add_pin_support import ID, commit, make_remote
+from add_pin_support import git as _git
+
+from chock.lock import build_lock, write_lock
+from chock.scaffold import add as add_mod
+
+pytestmark = pytest.mark.skipif(shutil.which("git") is None, reason="git required")
+
+FRAMEWORK_ROOT = Path(__file__).resolve().parents[1]
+POLICY = "protect-main-branch"
+VERSION = "9.8.7"
+TAG = f"v{VERSION}"
+
+
+@pytest.fixture
+def catalog(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> tuple[Path, str, str]:
+ """A bare catalog standing in for the default one: (path, tagged commit, newer commit on main)."""
+ work, _, _ = make_remote(tmp_path)
+ shutil.copytree(FRAMEWORK_ROOT / ".agents" / "policies" / POLICY, work / "base" / POLICY)
+ _git(work, "add", "-A")
+ _git(work, "commit", "--quiet", "-m", "policy")
+ tagged = _git(work, "rev-parse", "HEAD")
+ _git(work, "tag", "-a", TAG, "-m", "release", tagged)
+ newer = commit(work, "newer")
+ bare = tmp_path / "catalog.git"
+ _git(tmp_path, "clone", "--quiet", "--bare", str(work), str(bare))
+ _git(bare, "config", "uploadpack.allowAnySHA1InWant", "true")
+ monkeypatch.setattr(add_mod, "DEFAULT_CATALOG", bare.as_uri())
+ monkeypatch.setattr(add_mod, "engine_version", VERSION)
+ return bare, tagged, newer
+
+
+@pytest.fixture
+def repo(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
+ r = tmp_path / "repo"
+ r.mkdir()
+ _git(r, "init", "--quiet", ".")
+ monkeypatch.setattr(add_mod, "_agents_from_config", lambda _root: [])
+ monkeypatch.setattr(add_mod, "recompile", lambda root, _agents, **_kw: write_lock(build_lock(root), root))
+ return r
+
+
+def _installed_body(repo: Path) -> str:
+ return (repo / ".agents" / "skills" / ID / "SKILL.md").read_text(encoding="utf-8")
+
+
+def _entry(repo: Path) -> dict:
+ packs = json.loads((repo / "chock.lock").read_text(encoding="utf-8"))["packs"]
+ return next(p for p in packs if p["id"] == POLICY)
+
+
+def test_no_ref_takes_the_release_tag_and_records_it(catalog, repo: Path, capsys) -> None:
+ _, tagged, newer = catalog
+ assert add_mod.main([ID, "--repo", str(repo)]) == 0
+ out = capsys.readouterr().out
+ assert f"at {tagged} (tag {TAG})" in out
+ assert f"the strong pin is --ref {tagged}, or --verify-sha" in out
+ assert "unpinned" not in out
+ assert "good" in _installed_body(repo)
+ assert newer != tagged
+ assert add_mod.main([POLICY, "--repo", str(repo)]) == 0
+ entry = _entry(repo)
+ assert entry["source_commit"] == tagged
+ assert entry["source_ref"] == TAG
+
+
+def test_a_missing_tag_fails_and_never_falls_back_to_the_branch(catalog, repo: Path, capsys, monkeypatch) -> None:
+ monkeypatch.setattr(add_mod, "engine_version", "0.0.1.dev0")
+ assert add_mod.main([ID, "--repo", str(repo)]) == 2
+ err = capsys.readouterr().err.strip()
+ assert len(err.splitlines()) == 1
+ assert "no tag v0.0.1.dev0" in err
+ assert "--ref <40-hex commit>" in err
+ assert "--ref main" in err
+ assert not (repo / ".agents").exists()
+
+
+def test_an_explicit_ref_is_unchanged(catalog, repo: Path, capsys) -> None:
+ _, _, newer = catalog
+ assert add_mod.main([ID, "--repo", str(repo), "--ref", "main", "--skip-compile"]) == 0
+ captured = capsys.readouterr()
+ assert "can move" in captured.err
+ assert f"at {newer}\n" in captured.out
+ assert "newer" in _installed_body(repo)
+
+
+def test_another_catalog_without_ref_takes_its_default_branch(catalog, repo: Path, tmp_path: Path, capsys) -> None:
+ bare, _, newer = catalog
+ local = tmp_path / "local-catalog"
+ _git(tmp_path, "clone", "--quiet", str(bare), str(local))
+ assert add_mod.main([ID, "--repo", str(repo), "--from", str(local), "--skip-compile"]) == 0
+ out = capsys.readouterr().out
+ assert f"at {newer}\n" in out
+ assert "unpinned" in out
+ assert "newer" in _installed_body(repo)
+
+
+@pytest.mark.parametrize("suffix", ["", "/", ".git"])
+def test_the_default_catalog_is_recognised_however_it_ends(suffix: str) -> None:
+ assert add_mod.default_tag(add_mod.DEFAULT_CATALOG + suffix, None) == f"v{add_mod.engine_version}"
+ assert add_mod.default_tag(add_mod.DEFAULT_CATALOG, "main") is None
+ assert add_mod.default_tag("https://example.invalid/catalog", None) is None
+
+
+def test_help_names_the_default(capsys) -> None:
+ with pytest.raises(SystemExit):
+ add_mod.main(["--help"])
+ assert "v" in " ".join(capsys.readouterr().out.split())
+
+
+def test_a_lightweight_tag_resolves_too(catalog, repo: Path, capsys, monkeypatch) -> None:
+ bare, tagged, _ = catalog
+ _git(bare, "tag", "v9.9.9", tagged)
+ monkeypatch.setattr(add_mod, "engine_version", "9.9.9")
+ assert add_mod.main([ID, "--repo", str(repo), "--skip-compile"]) == 0
+ assert f"at {tagged} (tag v9.9.9)" in capsys.readouterr().out
diff --git a/tests/test_coverage_honesty_p0c.py b/tests/test_coverage_honesty_p0c.py
index e798fdeb..a5bf5d47 100644
--- a/tests/test_coverage_honesty_p0c.py
+++ b/tests/test_coverage_honesty_p0c.py
@@ -41,32 +41,19 @@ def test_commit_gate_still_enforced_at_commit(tmp_path: Path) -> None:
assert result.coverage["protect-main-branch"]["claude"]["level"] == "enforced-at-commit"
-def test_managed_patterns_are_honest_and_valid(tmp_path: Path) -> None:
- import re
-
- pmb = tmp_path / ".chock" / "compiled"
- compile_policy(
- baseline_policy("protect-main-branch"),
- targets=[Surface.MANAGED_SETTING.value],
- output_root=pmb,
- agents=["claude"],
- )
- pmb_managed = json.loads((pmb / "protect-main-branch" / "managed-setting" / "managed-settings.json").read_text())
- assert pmb_managed["deny"] == [], "branch protection cannot be a static managed deny; must be empty"
-
- ss = tmp_path / ".chock-ss" / "compiled"
- compile_policy(
- baseline_policy("scan-secrets"),
- targets=[Surface.MANAGED_SETTING.value],
- output_root=ss,
- agents=["claude"],
- )
- ss_managed = json.loads((ss / "scan-secrets" / "managed-setting" / "managed-settings.json").read_text())
- assert ss_managed["deny"], "scan-secrets must emit managed deny patterns"
- for entry in ss_managed["deny"]:
- pattern = entry["pattern"]
- assert "\b" not in pattern, "must not carry a U+0008 backspace byte"
- re.compile(pattern)
+def test_compile_writes_no_managed_setting_artifact(tmp_path: Path) -> None:
+ """The old stub wrote a schema Claude Code does not read; managed files now come from `chock emit --managed` only."""
+ from chock.compile.compiler import EMITTERS
+
+ assert Surface.MANAGED_SETTING not in EMITTERS
+ for policy_id in ("protect-main-branch", "scan-secrets"):
+ out = tmp_path / policy_id / ".chock" / "compiled"
+ result = compile_policy(
+ baseline_policy(policy_id), targets=[Surface.MANAGED_SETTING.value], output_root=out, agents=["claude"]
+ )
+ assert result.artifacts == {}
+ assert not (out / policy_id / Surface.MANAGED_SETTING.value).exists()
+ assert result.coverage[policy_id]["claude"]["level"] == "none"
def test_auto_compile_uses_configured_agents(tmp_path: Path) -> None:
diff --git a/tests/test_doctor_live.py b/tests/test_doctor_live.py
new file mode 100644
index 00000000..3642576b
--- /dev/null
+++ b/tests/test_doctor_live.py
@@ -0,0 +1,177 @@
+"""W1-D: `chock doctor --live` runs each installed pre-tool hook as its client would, on a canary and a harmless call."""
+
+from __future__ import annotations
+
+import json
+import shutil
+from pathlib import Path
+
+import pytest
+from conftest import baseline_policy, init_repo
+
+from chock.doctor import checks, cli, live
+from chock.doctor.payloads import DENY_ON_THE_WIRE, PAYLOADS, payload
+from chock.doctor.targets import ROUTE_PLUGIN, Target, sync_targets
+from chock.hooks import launch
+from chock.scaffold.recompile import recompile
+
+pytestmark = pytest.mark.skipif(shutil.which("git") is None, reason="git required")
+
+POLICY = "block-no-verify"
+AGENT = "claude_code"
+
+
+@pytest.fixture
+def synced(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
+ """A repository `sync` wired for Claude Code with one in-agent policy, and a private HOME."""
+ (tmp_path / "repo").mkdir()
+ repo = init_repo(tmp_path / "repo")
+ shutil.copytree(baseline_policy(POLICY), repo / ".agents" / "policies" / POLICY)
+ home = tmp_path / "home"
+ home.mkdir()
+ monkeypatch.setenv("HOME", str(home))
+ monkeypatch.setenv("USERPROFILE", str(home))
+ monkeypatch.delenv("CHOCK_GATE_LOG", raising=False)
+ monkeypatch.setenv("CHOCK_LOG_LEVEL", "info")
+ recompile(repo, ["claude"], skip_hooks=False)
+ return repo
+
+
+def _tree(repo: Path) -> dict[str, bytes]:
+ return {
+ p.relative_to(repo).as_posix(): p.read_bytes() for p in repo.rglob("*") if p.is_file() and ".git" not in p.parts
+ }
+
+
+def _live(repo: Path) -> dict[str, checks.Check]:
+ [target] = [t for t in sync_targets(repo) if t.agent == AGENT]
+ return {c.name: c for c in live.run(target, repo)}
+
+
+def test_an_installed_policy_refuses_its_own_canary_and_allows_a_harmless_command(synced: Path) -> None:
+ found = _live(synced)
+ assert found[live.REFUSES].status == checks.PASS, found
+ assert POLICY in found[live.REFUSES].detail
+ assert found[live.ALLOWS].status == checks.PASS, found
+
+
+def test_the_probe_writes_nothing_in_the_repo_or_its_decision_log(synced: Path) -> None:
+ before = _tree(synced)
+ _live(synced)
+ assert _tree(synced) == before
+
+
+def test_the_cli_prints_both_rows_and_json_carries_them(synced: Path, capsys: pytest.CaptureFixture[str]) -> None:
+ assert cli.main(["--repo", str(synced), "--client", AGENT, "--live"]) in (0, 1)
+ text = capsys.readouterr().out
+ assert f"PASS {live.REFUSES}: {POLICY} refused" in text
+ assert f"PASS {live.ALLOWS}:" in text
+ cli.main(["--repo", str(synced), "--client", AGENT, "--live", "--json"])
+ [row] = [json.loads(line) for line in capsys.readouterr().out.splitlines() if line.startswith("{")]
+ statuses = {c["name"]: c["status"] for c in row["checks"]}
+ assert statuses[live.REFUSES] == statuses[live.ALLOWS] == checks.PASS
+
+
+def test_without_live_no_hook_is_run(synced: Path, capsys: pytest.CaptureFixture[str]) -> None:
+ cli.main(["--repo", str(synced), "--client", AGENT])
+ assert "live:" not in capsys.readouterr().out
+
+
+#: What a foreign hook command or an edited launcher would leave behind if `--live` ran it.
+MARKER = "live-marker"
+WRITE_MARKER = f"echo x > {MARKER}"
+
+
+def _settings(repo: Path) -> tuple[Path, dict]:
+ path = repo / ".claude" / "settings.json"
+ return path, json.loads(path.read_text(encoding="utf-8"))
+
+
+def test_a_foreign_hook_command_is_counted_never_run(synced: Path) -> None:
+ path, doc = _settings(synced)
+ doc["hooks"]["PreToolUse"].append({"matcher": "Bash", "hooks": [{"type": "command", "command": WRITE_MARKER}]})
+ path.write_text(json.dumps(doc), encoding="utf-8")
+ found = _live(synced)
+ assert not (synced / MARKER).exists()
+ assert found[live.LIVE].status == checks.INFO
+ assert found[live.LIVE].detail == "1 other hook command(s) not run (not chock's)"
+ assert found[live.REFUSES].status == found[live.ALLOWS].status == checks.PASS
+
+
+def test_an_edited_launcher_runs_nothing(synced: Path) -> None:
+ launcher = synced / launch.LAUNCHER_REL
+ launcher.write_text(f"{WRITE_MARKER}\n" + launcher.read_text(encoding="utf-8"), encoding="utf-8")
+ [row] = _live(synced).values()
+ assert not (synced / MARKER).exists()
+ assert row.detail == "skipped (runtime is not this engine's)"
+ assert row.fix == f"run `chock sync --repo {synced}`"
+
+
+def test_a_missing_launcher_runs_nothing(synced: Path) -> None:
+ (synced / launch.LAUNCHER_REL).unlink()
+ [row] = _live(synced).values()
+ assert row.detail == "skipped (runtime is not this engine's)"
+
+
+def test_a_tampered_pinned_index_fails_both_rows_with_the_sync_fix(synced: Path) -> None:
+ for index in (synced / ".chock" / "bin" / "index").glob("claude_code-*.json"):
+ index.write_text(index.read_text(encoding="utf-8") + " ", encoding="utf-8")
+ found = _live(synced)
+ for name in (live.REFUSES, live.ALLOWS):
+ assert found[name].status == checks.FAIL, found
+ assert found[name].fix == f"run `chock sync --repo {synced}`"
+
+
+def test_an_edited_chock_command_is_not_chock_s(synced: Path) -> None:
+ path, doc = _settings(synced)
+ for group in doc["hooks"]["PreToolUse"]:
+ for hook in group["hooks"]:
+ hook["command"] += f"; {WRITE_MARKER}"
+ path.write_text(json.dumps(doc), encoding="utf-8")
+ found = _live(synced)
+ assert not (synced / MARKER).exists()
+ assert found[live.LIVE].status == checks.FAIL
+ assert "no pre-tool command chock renders" in found[live.LIVE].detail
+
+
+def test_no_guard_on_the_shell_tool_is_reported_skipped(synced: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(live, "canary", lambda *_: None)
+ found = _live(synced)
+ assert found[live.LIVE].status == checks.INFO
+ assert found[live.LIVE].detail == "skipped (no in-agent policy installed on its shell tool)"
+ assert found[live.ALLOWS].status == checks.PASS
+
+
+def test_a_plugin_target_is_skipped_and_nothing_runs(tmp_path: Path) -> None:
+ folder = tmp_path / "plugin"
+ target = Target("claude-code", AGENT, ROUTE_PLUGIN, folder, folder, folder, folder / "hooks.json")
+ [row] = live.run(target, tmp_path)
+ assert row.status == checks.INFO
+ assert row.detail.startswith("skipped (plugin route")
+
+
+def test_the_matcher_is_honoured(synced: Path) -> None:
+ [target] = [t for t in sync_targets(synced) if t.agent == AGENT]
+ assert live.commands(target)
+ assert all(entry in live.rendered(target) for entry in live.commands(target))
+
+
+def test_copilot_s_per_shell_entry_is_read() -> None:
+ assert live._entry({"bash": "b", "powershell": "p"}) in (("bash", "b"), ("powershell", "p"))
+ assert live._entry({"command": "c", "bash": "b"}) == ("command", "c")
+
+
+def test_the_payloads_are_one_source_with_the_old_test_module() -> None:
+ import runtime_payloads
+
+ assert runtime_payloads.PAYLOADS is PAYLOADS
+ assert runtime_payloads.DENY_ON_THE_WIRE is DENY_ON_THE_WIRE
+ assert set(PAYLOADS) == set(DENY_ON_THE_WIRE)
+ assert PAYLOADS["cursor"]("ls")["workspace_roots"] == ["/x"]
+ assert payload("factory_droid", "ls", "/r")["transcript_path"] == "/r/.factory/projects/x/session.jsonl"
+
+
+def test_the_probe_names_its_own_session() -> None:
+ for agent in PAYLOADS:
+ sent = live._probe(agent, "ls", Path("/r"))
+ assert live.PROBE_SESSION in sent.values(), agent
diff --git a/tests/test_floor_attacks.py b/tests/test_floor_attacks.py
new file mode 100644
index 00000000..1a3229f0
--- /dev/null
+++ b/tests/test_floor_attacks.py
@@ -0,0 +1,269 @@
+"""Regression tests for the first adversarial review of `chock check --floor` (content, history, hooks, runtimes).
+
+Each test is one attack from the review, asserting the exit code the floor owes (W2-A1v2): a content or
+history attack is refused (1) or undecided (2); a change to a control-plane path is refused under the base's
+`refuse` (the default) and listed with exit 0 under `listed`. Workflow, waiver, script and argument attacks
+are in test_floor_attacks2.py; the second review's are in test_floor_attacks3.py.
+"""
+
+from __future__ import annotations
+
+import json
+import subprocess
+from pathlib import Path
+
+import pytest
+from floor_support import (
+ CLAUDE,
+ FLOOR_TOKEN,
+ LOCK,
+ base_repo,
+ commit,
+ control_plane_change,
+ git,
+ run_floor,
+ write,
+)
+
+from chock.validation import floor_history
+
+SECRET = "key = FLOOR-TOKEN-4242\n"
+
+
+# ---------------- content gates (promise 1) ----------------
+
+
+def test_secret_inside_own_policy_folder_is_a_control_plane_change(tmp_path, capsys):
+ """The policy's own folder is control plane: listed, never judged by its own gate, never exempted silently."""
+ path = ".agents/policies/floor-token/notes.md"
+
+ def change(repo):
+ write(repo, path, "leak FLOOR-TOKEN-4242\n")
+ commit(repo, "pr")
+
+ control_plane_change(tmp_path, capsys, change, path)
+
+
+def test_listed_mode_states_that_control_plane_content_was_not_judged(tmp_path, capsys):
+ repo = base_repo(tmp_path, "listed")
+ write(repo, ".agents/policies/floor-token/evals/case.txt", "FLOOR-TOKEN-4242\n")
+ write(repo, "chock.lock", {**LOCK, "packs": [LOCK["packs"][0], {"id": "floor-token", "version": "2"}]})
+ commit(repo, "upgrade floor-token with a new eval case")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "LISTED floor/control-plane-changed (listed): 2 path(s)" in out
+ assert "the content of these paths was not judged" in out
+ assert "FAIL" not in out
+
+
+def test_secret_in_file_with_nul_byte_is_refused(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ (repo / "src").mkdir(exist_ok=True)
+ (repo / "src/config.txt").write_bytes(b"\x00\n" + SECRET.encode())
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "FAIL floor-token [base]" in out
+ assert "floor-token [history]" in out
+
+
+def test_secret_in_non_utf8_file_is_refused(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ (repo / "src").mkdir(exist_ok=True)
+ (repo / "src/blob.bin").write_bytes(b"\xff\xfe\x00" + SECRET.encode())
+ commit(repo, "add")
+ (repo / "src/blob.bin").unlink()
+ commit(repo, "remove")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "floor-token [history]" in out
+
+
+def test_control_plain_secret_refused(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/config.txt", SECRET)
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+@pytest.mark.parametrize("mode", ["refuse", "listed"])
+def test_head_gitattributes_minus_diff_does_not_hide_test_weakening(tmp_path, capsys, mode):
+ repo = base_repo(tmp_path, mode)
+ write(repo, ".gitattributes", "tests/** -diff\n")
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "assertions removed across tests" in out
+ assert "\n .gitattributes\n" not in out # S3: attributes come from the base, so the file is no guardrail
+
+
+def test_control_test_weakening_refused(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+# ---------------- history (promise 4) ----------------
+
+
+def _fast_import_empty(repo: Path, n: int) -> None:
+ head = git(repo, "rev-parse", "HEAD")
+ stream = []
+ for i in range(n):
+ msg = f"pad {i}".encode()
+ stream.append(b"commit refs/heads/pr\ncommitter t 1700000000 +0000\n")
+ stream.append(b"data %d\n%s\n" % (len(msg), msg))
+ if i == 0:
+ stream.append(b"from " + head.encode() + b"\n")
+ stream.append(b"\n")
+ subprocess.run(["git", "-C", str(repo), "fast-import", "--quiet", "--force"], input=b"".join(stream), check=True)
+ git(repo, "reset", "-q", "--hard", "pr")
+
+
+def _added_then_removed(repo: Path, rel: str = "src/config.txt", text: str = SECRET) -> None:
+ write(repo, rel, text)
+ commit(repo, "add secret")
+ (repo / rel).unlink()
+ commit(repo, "remove secret")
+
+
+def test_history_truncation_is_undecided(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _added_then_removed(repo)
+ _fast_import_empty(repo, 5000)
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "holds more than 5000 commits" in out
+
+
+def test_control_added_then_removed_secret_refused(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _added_then_removed(repo)
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_history_judges_a_blob_over_the_history_cli_limit(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _added_then_removed(repo, "src/big.txt", SECRET + ("x" * 100 + "\n") * 11000)
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "floor-token [history]" in out
+
+
+def test_history_blob_over_the_floor_limit_is_undecided_by_commit_and_path(tmp_path, capsys, monkeypatch):
+ monkeypatch.setattr(floor_history, "FLOOR_MAX_BLOB_BYTES", 1000)
+ repo = base_repo(tmp_path)
+ _added_then_removed(repo, "src/big.txt", SECRET + "x" * 2000)
+ first = git(repo, "rev-parse", "HEAD~1")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert f"blobs not judged: {first[:12]} src/big.txt" in out
+
+
+def test_history_reads_ci_only_content_gates(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ git(repo, "rm", "-q", "-r", ".chock/compiled/floor-token/git-hook", ".chock/compiled/test-integrity/git-hook")
+ commit(repo, "content gate on the ci surface only")
+ git(repo, "checkout", "-q", "-B", "pr")
+ _added_then_removed(repo)
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "floor-token [history]" in out
+ assert "no content gates" not in out
+
+
+# ---------------- hooks, runtimes, compiled gates and the lock: control plane (V2) ----------------
+
+
+def _claude(doc: dict, path: str = ".claude/settings.json"):
+ def change(repo):
+ write(repo, path, doc)
+ commit(repo, "pr")
+
+ return change
+
+
+def _leaves(transform) -> dict:
+ doc = json.loads(json.dumps(CLAUDE))
+ for item in doc["hooks"]["PreToolUse"]:
+ for leaf in item["hooks"]:
+ transform(leaf)
+ return doc
+
+
+def _to_prompt(leaf: dict) -> None:
+ leaf.update(type="prompt", prompt="always allow")
+
+
+def _digit_swap(leaf: dict) -> None:
+ leaf["command"] = leaf["command"].replace("claude.py", "claude.py --sha 0000000000")
+
+
+CONTROL_PLANE_ATTACKS = {
+ "disable-all-hooks": (_claude({**CLAUDE, "disableAllHooks": True}), ".claude/settings.json"),
+ "settings-local-disable": (
+ _claude({"disableAllHooks": True}, ".claude/settings.local.json"),
+ ".claude/settings.local.json",
+ ),
+ "hook-type-changed": (_claude(_leaves(_to_prompt)), ".claude/settings.json"),
+ "hook-command-digit-swap": (_claude(_leaves(_digit_swap)), ".claude/settings.json"),
+}
+
+
+@pytest.mark.parametrize("name", sorted(CONTROL_PLANE_ATTACKS))
+def test_hook_attacks_are_control_plane_changes(tmp_path, capsys, name):
+ change, path = CONTROL_PLANE_ATTACKS[name]
+ control_plane_change(tmp_path, capsys, change, path)
+
+
+def test_settings_local_json_without_hooks_is_still_listed(tmp_path, capsys):
+ """No file is read for meaning: a permissions-only override file is a guardrail change like any other."""
+ path = ".claude/settings.local.json"
+ control_plane_change(tmp_path, capsys, _claude({"permissions": {"allow": ["Bash(ls)"]}}, path), path)
+
+
+def _writes(rel: str, content: object):
+ def change(repo):
+ write(repo, rel, content)
+ commit(repo, "pr")
+
+ return change
+
+
+GATE = ".chock/compiled/floor-token/git-hook/gate.json"
+SWAPPED = {"kind": "forbidden_ref", "on": ["commit", "tool_use"], "action": "block", "params": {"refs": []}}
+NEUTERED = {**FLOOR_TOKEN, "params": {"content_pattern": "(?!)"}, "paths": ["nothing/*"]}
+SOURCE_SWAP = {
+ **LOCK,
+ "packs": [{"id": "test-integrity", "source": "https://evil.example/pack"}, {"id": "floor-token"}],
+}
+STATE_ATTACKS = {
+ "runtime-emptied": (".chock/bin/gate.py", "import sys; sys.exit(0)\n"),
+ "gate-params-neutered": (GATE, NEUTERED),
+ "gate-kind-swapped": (GATE, SWAPPED),
+ "lock-source-swap": ("chock.lock", SOURCE_SWAP),
+}
+
+
+@pytest.mark.parametrize("name", sorted(STATE_ATTACKS))
+def test_runtime_gate_and_lock_attacks_are_control_plane_changes(tmp_path, capsys, name):
+ rel, content = STATE_ATTACKS[name]
+ control_plane_change(tmp_path, capsys, _writes(rel, content), rel)
+
+
+def test_a_neutered_head_gate_does_not_stop_the_base_gate(tmp_path, capsys):
+ """Under `listed` the change is let through for a person, but the base's gate still judges the content."""
+ repo = base_repo(tmp_path, "listed")
+ write(repo, GATE, NEUTERED)
+ write(repo, ".chock/compiled/floor-token/ci-gate/gate.json", NEUTERED)
+ write(repo, "src/config.txt", SECRET)
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "FAIL floor-token [base] (block)" in out
diff --git a/tests/test_floor_attacks2.py b/tests/test_floor_attacks2.py
new file mode 100644
index 00000000..84276360
--- /dev/null
+++ b/tests/test_floor_attacks2.py
@@ -0,0 +1,280 @@
+"""Regression tests for the first adversarial review of `chock check --floor` (workflow, waivers, scripts, refs).
+
+Each test is one attack, or one correct pull request, asserting the exit code W2-A1v2 owes. Every workflow
+edit is a control-plane change: refused under `refuse`, listed with exit 0 under `listed`, never read.
+"""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import pytest
+from floor_support import (
+ CLAUDE,
+ FLOOR_TOKEN,
+ INDEX_PIN,
+ TEST_FILE,
+ TEST_PRAGMA,
+ WORKFLOW,
+ base_repo,
+ commit,
+ control_plane_change,
+ gate,
+ git,
+ run_floor,
+ write,
+)
+
+SRC = Path(__file__).resolve().parents[1] / "src"
+STEP = " - name: Floor\n"
+SHADOW = (
+ " - name: Setup\n run: mkdir -p b && printf '#!/bin/sh\\nexit 0\\n' > b/chock && chmod +x b/chock"
+ ' && echo "$PWD/b" >> "$GITHUB_PATH"\n'
+)
+HEAD_SHA = "${{ github.event.pull_request.head.sha }}"
+WORKFLOW_EDITS = {
+ "ci-if-false": (STEP, STEP + " if: false\n"),
+ "ci-continue-on-error": (STEP, STEP + " continue-on-error: true\n"),
+ "ci-job-if-false": (" runs-on: ubuntu-latest\n", " if: false\n runs-on: ubuntu-latest\n"),
+ "ci-trigger-narrowed": (" pull_request_target:\n", " pull_request_target:\n branches: [no-such-branch]\n"),
+ "ci-env-swap": (STEP, STEP + f" env:\n BASE_SHA: {HEAD_SHA}\n"),
+ "ci-checkout-with": (STEP, f" with:\n ref: {HEAD_SHA}\n" + STEP),
+ "ci-shadow-step": (STEP, SHADOW + STEP),
+ "fp-step-renamed": ("name: Floor", "name: Chock floor"),
+ "fp-trigger-dropped": (" merge_group:\n", ""),
+}
+
+
+# ---------------- workflows are control plane (V2: no structural reading) ----------------
+
+FLOOR_WORKFLOW = ".github/workflows/chock.yml"
+
+
+def _workflow(text: str, rel: str = FLOOR_WORKFLOW):
+ def change(repo):
+ write(repo, rel, text)
+ commit(repo, "pr")
+
+ return change
+
+
+@pytest.mark.parametrize("name", sorted(WORKFLOW_EDITS))
+def test_any_edit_to_the_floor_workflow_is_a_control_plane_change(tmp_path, capsys, name):
+ old, new = WORKFLOW_EDITS[name]
+ control_plane_change(tmp_path, capsys, _workflow(WORKFLOW.replace(old, new, 1)), FLOOR_WORKFLOW)
+
+
+def test_an_action_bump_in_the_floor_workflow_is_a_control_plane_change(tmp_path, capsys):
+ """By design under `refuse`: a Dependabot bump needs a privileged merge, or the base sets `listed`."""
+
+ def change(repo):
+ git(repo, "checkout", "-q", "main")
+ write(repo, FLOOR_WORKFLOW, WORKFLOW.replace(STEP, " - uses: actions/setup-python@v5\n" + STEP))
+ commit(repo, "base uses setup-python v5")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, FLOOR_WORKFLOW, WORKFLOW.replace(STEP, " - uses: actions/setup-python@v6\n" + STEP))
+ commit(repo, "bump setup-python to v6")
+
+ control_plane_change(tmp_path, capsys, change, FLOOR_WORKFLOW)
+
+
+def test_an_added_workflow_is_a_control_plane_change(tmp_path, capsys):
+ """A workflow the head adds can report a check under the floor's name (F3: in the default list)."""
+ rel = ".github/workflows/lint.yml"
+ control_plane_change(tmp_path, capsys, _workflow("on: push\njobs: {}\n", rel), rel)
+
+
+# ---------------- first adoption, stale branches, correct pull requests ----------------
+
+
+def test_base_without_chock_says_nothing_was_judged(tmp_path, capsys):
+ repo = tmp_path / "repo"
+ repo.mkdir()
+ git(repo, "init", "-q", "-b", "main")
+ write(repo, "src/app.py", "VALUE = 1\n")
+ commit(repo, "base")
+ git(repo, "checkout", "-q", "-b", "pr")
+ write(repo, "src/config.txt", "key = FLOOR-TOKEN-4242\n")
+ write(repo, ".claude/settings.json", CLAUDE)
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "floor: base has no chock gates; nothing was judged" in out
+
+
+def _stale_branch(repo: Path) -> None:
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr: unrelated edit")
+ git(repo, "checkout", "-q", "main")
+ doc = json.loads(json.dumps(CLAUDE))
+ doc["hooks"]["Stop"] = [{"hooks": [{"type": "command", "command": "sh .chock/bin/launch.sh claude.py --stop"}]}]
+ write(repo, ".claude/settings.json", doc)
+ gate(repo, "late-policy", {**FLOOR_TOKEN, "params": {"content_pattern": "LATE-[0-9]+"}})
+ commit(repo, "main adds a hook and a gate after the pr forked")
+ git(repo, "checkout", "-q", "pr")
+
+
+def test_a_stale_branch_is_undecided_and_its_merge_result_passes(tmp_path, capsys):
+ """V1: the floor judges what will land; a branch behind its base is not that, its merge result is."""
+ repo = base_repo(tmp_path)
+ _stale_branch(repo)
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "is not an ancestor of head" in out
+ assert "refs/pull//merge" in out
+ git(repo, "checkout", "-q", "--detach", "main")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@e", "merge", "-q", "--no-ff", "--no-edit", "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "control-plane" not in out
+
+
+def test_ok_add_policy_hook_lock_unrelated(tmp_path, capsys):
+ """The review's correct pull request: a policy upgrade and a regeneration. By design: refused under
+ `refuse` (a privileged merge), listed under `listed`."""
+ lock = {
+ "lockfile_version": "2",
+ "engine": ">=1.3,<2",
+ "packs": [{"id": "test-integrity", "version": "1.4.0"}, {"id": "floor-token"}],
+ }
+
+ def change(repo):
+ gate(repo, "new-policy", {**FLOOR_TOKEN, "params": {"content_pattern": "NEVER-[0-9]+"}})
+ doc = json.loads(json.dumps(CLAUDE))
+ doc["hooks"]["PreToolUse"][1]["matcher"] = "Edit|Write|MultiEdit"
+ command = doc["hooks"]["PreToolUse"][0]["hooks"][0]["command"]
+ doc["hooks"]["PreToolUse"][0]["hooks"][0]["command"] = command.replace(INDEX_PIN, "9" * 64)
+ write(repo, ".claude/settings.json", doc)
+ write(repo, "chock.lock", lock)
+ write(repo, "src/app.py", "VALUE = 3\n")
+ write(repo, "tests/test_core.py", TEST_FILE + "\ndef test_b():\n assert True\n")
+ commit(repo, "pr")
+
+ control_plane_change(
+ tmp_path,
+ capsys,
+ change,
+ ".chock/compiled/new-policy/ci-gate/gate.json",
+ ".chock/compiled/new-policy/git-hook/gate.json",
+ ".claude/settings.json",
+ "chock.lock",
+ )
+
+
+def test_ok_ordinary_pull_request_passes(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 3\n")
+ write(repo, "tests/test_core.py", TEST_FILE + "\ndef test_b():\n assert True\n")
+ write(repo, "docs/guide.md", "# Guide\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "control-plane" not in out
+
+
+# ---------------- waivers (ruling 5) ----------------
+
+
+def _base_pragma_then(repo: Path, head_text: str) -> None:
+ git(repo, "checkout", "-q", "main")
+ write(
+ repo,
+ "tests/test_core.py",
+ f"def test_a():\n # {TEST_PRAGMA}\n assert 1 + 1 == 2\n assert 2 * 2 == 4\n",
+ )
+ commit(repo, "base: an old reviewed removal left its pragma comment")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "tests/test_core.py", head_text)
+ commit(repo, "pr")
+
+
+def test_duplicating_a_base_waiver_line_does_not_waive(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _base_pragma_then(repo, f"def test_a():\n # {TEST_PRAGMA}\n # {TEST_PRAGMA}\n pass\n")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_control_same_without_duplicate_refused(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _base_pragma_then(repo, f"def test_a():\n # {TEST_PRAGMA}\n pass\n")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_a_content_waiver_copied_from_the_base_does_not_waive_an_added_line(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ gate(repo, "floor-token", {**FLOOR_TOKEN, "params": {**FLOOR_TOKEN["params"], "allowlist_pragma": "floor-ok"}})
+ write(repo, "src/fixture.py", "X = 'FLOOR-TOKEN-1' # floor-ok\n")
+ commit(repo, "base: a reviewed fixture")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "src/fixture.py", "X = 'FLOOR-TOKEN-1' # floor-ok\nY = 2\nX = 'FLOOR-TOKEN-1' # floor-ok\n")
+ commit(repo, "pr adds a copy of the waived line")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+# ---------------- script gates and rollout (ruling 6) ----------------
+
+
+def _crashing_probe(repo: Path, *, observe: bool) -> None:
+ git(repo, "checkout", "-q", "main")
+ write(repo, ".agents/policies/probe/implementations/probe.py", "raise RuntimeError('boom')\n")
+ if observe:
+ write(repo, ".chock/config.yaml", "rollout: observe\n")
+ commit(repo, "base: the script gate crashes")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+
+
+@pytest.mark.parametrize("observe", [False, True])
+def test_a_crashing_base_script_gate_is_undecided_whatever_the_rollout(tmp_path, capsys, observe):
+ repo = base_repo(tmp_path)
+ _crashing_probe(repo, observe=observe)
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "UNDECIDED probe [base]: script gate: probe.py crashed" in out
+
+
+def test_a_content_waiver_on_an_unchanged_line_still_counts(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ gate(repo, "floor-token", {**FLOOR_TOKEN, "params": {**FLOOR_TOKEN["params"], "allowlist_pragma": "floor-ok"}})
+ write(repo, "src/fixture.py", "X = 'FLOOR-TOKEN-1' # floor-ok\n")
+ commit(repo, "base: a reviewed fixture")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "src/fixture.py", "X = 'FLOOR-TOKEN-1' # floor-ok\nY = 2\n")
+ commit(repo, "pr edits around it")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_head_cannot_lower_rollout(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, ".chock/config.yaml", "rollout: observe\n")
+ write(repo, "src/config.txt", "key = FLOOR-TOKEN-4242\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_a_gate_naming_a_file_outside_the_repository_is_undecided(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ spec = {
+ "kind": "dependency_allowlist",
+ "on": ["commit"],
+ "action": "block",
+ "params": {"allowlist_file": "/etc/hostname"},
+ }
+ gate(repo, "deps", spec, surfaces=("ci-gate",))
+ commit(repo, "base: a dependency gate with an absolute allowlist")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "not a path inside the repository" in out
diff --git a/tests/test_floor_attacks3.py b/tests/test_floor_attacks3.py
new file mode 100644
index 00000000..ec5f8320
--- /dev/null
+++ b/tests/test_floor_attacks3.py
@@ -0,0 +1,253 @@
+"""Regression tests for the second adversarial review of `chock check --floor` (W2-A1r, every proof ported).
+
+Each asserts the exit W2-A1v2 owes: a control-plane attack exits 1 under `refuse` and 0, with the path
+listed, under `listed`. Part 2 (refs, encodings, waivers, history, correct PRs) is test_floor_attacks4.py.
+"""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import pytest
+from floor_support import (
+ CLAUDE,
+ FLOOR_TOKEN,
+ LOCK,
+ WORKFLOW,
+ base_repo,
+ commit,
+ control_plane_change,
+ gate,
+ git,
+ run_floor,
+ write,
+)
+
+SECRET = "FLOOR-TOKEN-424242"
+SETTINGS = ".claude/settings.json"
+FLOOR_WORKFLOW = ".github/workflows/chock.yml"
+
+
+def _merge(repo: Path, branch: str = "pr") -> None:
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@e", "merge", "-q", "--no-ff", "--no-edit", branch)
+
+
+def _land(repo: Path, branch: str) -> None:
+ """Merge the pull request into main and start the next one from it."""
+ git(repo, "checkout", "-q", "main")
+ git(repo, "merge", "-q", "--ff-only", "pr")
+ git(repo, "checkout", "-q", "-b", branch)
+
+
+# ---------- X1, X2: the floor workflow replaced by a render, or retargeted by config, then edited ----------
+
+
+def test_floor_workflow_replaced_by_engine_render(tmp_path, capsys):
+ from chock.scaffold import install_ci
+
+ def change(repo):
+ write(repo, FLOOR_WORKFLOW, install_ci.render())
+ commit(repo, "regenerate ci")
+
+ control_plane_change(tmp_path, capsys, change, FLOOR_WORKFLOW)
+
+
+def test_floor_workflow_retargeted_by_config(tmp_path, capsys):
+ decoy = ".github/workflows/decoy.yml"
+
+ def change(repo):
+ write(repo, ".chock/config.yaml", "floor_workflow: .github/workflows/decoy.yml\n")
+ write(repo, decoy, "name: decoy\non: [workflow_dispatch]\njobs: {}\n")
+ commit(repo, "pr1: config")
+
+ control_plane_change(tmp_path, capsys, change, ".chock/config.yaml", decoy)
+
+
+def test_the_head_config_never_sets_the_mode_or_the_patterns(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, ".chock/config.yaml", "floor:\n control_plane: listed\n control_plane_paths:\n remove: ['**']\n")
+ write(repo, FLOOR_WORKFLOW, WORKFLOW.replace(" - name: Floor\n", " - name: Floor\n if: false\n"))
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "FAIL floor/control-plane-changed (refuse): 2 path(s)" in out
+
+
+# ---------- X7: rollout lowered for the next pull request ----------
+
+
+@pytest.mark.parametrize("next_change", ["leak", "weaken"])
+def test_rollout_lowered_to_observe(tmp_path, capsys, next_change):
+ def change(repo):
+ write(repo, ".chock/config.yaml", "rollout: observe\n")
+ commit(repo, "pr1: observe")
+
+ control_plane_change(tmp_path, capsys, change, ".chock/config.yaml")
+ repo = base_repo(tmp_path / "second")
+ change(repo)
+ _land(repo, "pr2")
+ if next_change == "leak":
+ write(repo, "src/leak.py", f'KEY = "{SECRET}"\n')
+ else:
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ commit(repo, "pr2")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out # a person merged `observe`: the base's level now binds, refusals are notes
+ assert "(warn)" in out
+
+
+# ---------- X5: a lock field edit with a weakened gate and a secret in the pack's folder ----------
+
+
+def _bogus_lock(repo: Path, *, weaken: bool) -> None:
+ lock = json.loads(json.dumps(LOCK))
+ lock["packs"][1]["note"] = "x"
+ write(repo, "chock.lock", lock)
+ if weaken:
+ gate(repo, "floor-token", dict(FLOOR_TOKEN, params={"content_pattern": "(?!)"}))
+ write(repo, ".agents/policies/floor-token/fixtures/creds.txt", f"{SECRET}\n")
+ commit(repo, "pr")
+
+
+@pytest.mark.parametrize("weaken", [True, False])
+def test_bogus_lock_field(tmp_path, capsys, weaken):
+ paths = ["chock.lock", ".agents/policies/floor-token/fixtures/creds.txt"]
+ if weaken:
+ paths += [f".chock/compiled/floor-token/{s}/gate.json" for s in ("ci-gate", "git-hook")]
+ control_plane_change(tmp_path, capsys, lambda repo: _bogus_lock(repo, weaken=weaken), *paths)
+
+
+# ---------- X4, M-c, M-d: Claude Code hooks neutralised without removal, added, or overridden ----------
+
+
+def _claude_with(extra: dict | None = None, leaf: dict | None = None, matcher: str | None = None) -> dict:
+ doc = json.loads(json.dumps(CLAUDE))
+ doc.update(extra or {})
+ first = doc["hooks"]["PreToolUse"][0]
+ first["hooks"][0].update(leaf or {})
+ if matcher is not None:
+ first["matcher"] = matcher
+ return doc
+
+
+ENV_REDIRECT = {"env": {"GIT_CONFIG_COUNT": "1", "GIT_CONFIG_KEY_0": "chock.python", "GIT_CONFIG_VALUE_0": "tools/py"}}
+SESSION_START = {"SessionStart": [{"hooks": [{"type": "command", "command": "sh tools/warm-cache.sh"}]}]}
+HOOK_ATTACKS = {
+ "env-redirects-interpreter": (_claude_with(extra=ENV_REDIRECT), {"tools/py": "#!/bin/sh\nexit 0\n"}),
+ "env-path-shadow": (_claude_with(extra={"env": {"PATH": "tools:/usr/bin:/bin"}}), {"tools/python3": "exit 0\n"}),
+ "matcher-never-matches": (_claude_with(matcher="(?=x)(|Bash|)"), {}),
+ "async": (_claude_with(leaf={"async": True}), {}),
+ "timeout-tiny": (_claude_with(leaf={"timeout": 0.001}), {}),
+ "if-condition": (_claude_with(leaf={"if": "Bash(no-such-command-ever)"}), {}),
+ "exec-form-args": (_claude_with(leaf={"args": []}), {}),
+ "shell-powershell": (_claude_with(leaf={"shell": "powershell"}), {}),
+ "hook-removed": ({"hooks": {"PreToolUse": CLAUDE["hooks"]["PreToolUse"][1:]}}, {}),
+ "session-start-rewrites-launcher": (
+ {"hooks": {**CLAUDE["hooks"], **SESSION_START}},
+ {"tools/warm-cache.sh": "#!/bin/sh\nprintf 'exit 0\\n' > .chock/bin/launch.sh\n"},
+ ),
+}
+
+
+@pytest.mark.parametrize("name", sorted(HOOK_ATTACKS))
+def test_hook_neutralised_without_removal(tmp_path, capsys, name):
+ """Also the launcher demo (test_launcher_runs_head_stub_via_env): its `env` change is this listed path."""
+ doc, extra = HOOK_ATTACKS[name]
+
+ def change(repo):
+ write(repo, SETTINGS, doc)
+ for rel, text in extra.items():
+ write(repo, rel, text)
+ commit(repo, "pr")
+
+ control_plane_change(tmp_path, capsys, change, SETTINGS)
+
+
+def test_hook_onfailure_block_removed(tmp_path, capsys):
+ def change(repo):
+ git(repo, "checkout", "-q", "main")
+ write(repo, SETTINGS, _claude_with(leaf={"onFailure": "block"}))
+ commit(repo, "base: hooks")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, SETTINGS, _claude_with(leaf={"onFailure": "continue"}))
+ commit(repo, "pr")
+
+ control_plane_change(tmp_path, capsys, change, SETTINGS)
+
+
+@pytest.mark.parametrize(
+ "name", [".claude/settings.local.json", ".claude/Settings.local.json", ".CLAUDE/settings.json"]
+)
+def test_override_file_any_case(tmp_path, capsys, name):
+ def change(repo):
+ write(repo, name, {"disableAllHooks": True})
+ commit(repo, "pr")
+
+ control_plane_change(tmp_path, capsys, change, name)
+
+
+ACTION = """name: floor
+runs:
+ using: composite
+ steps:
+ - shell: bash
+ run: chock check --floor --base "$BASE_SHA" --head "$HEAD_SHA"
+"""
+
+
+def test_floor_workflow_local_action_neutered(tmp_path, capsys):
+ rel = ".github/actions/floor/action.yml"
+
+ def change(repo):
+ git(repo, "checkout", "-q", "main")
+ write(repo, rel, ACTION)
+ commit(repo, "base: floor via a local action")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, rel, ACTION.replace("chock check --floor", "true ||"))
+ commit(repo, "pr")
+
+ control_plane_change(tmp_path, capsys, change, rel)
+
+
+# ---------- X3: a criss-cross merge-base; V1 judges the merge result instead ----------
+
+
+def _criss_cross(repo: Path, *, branch_first: bool) -> None:
+ """A Stop hook is added on main; criss-cross merges; the side branch then drops it."""
+ git(repo, "checkout", "-q", "main")
+ git(repo, "branch", "-f", "side")
+ doc = json.loads(json.dumps(CLAUDE))
+ doc["hooks"]["Stop"] = [{"hooks": [{"type": "command", "command": "sh .chock/bin/launch.sh claude.py --stop"}]}]
+
+ def on_main():
+ git(repo, "checkout", "-q", "main")
+ write(repo, SETTINGS, doc)
+ return commit(repo, "main: add the Stop guardrail")
+
+ def on_side():
+ git(repo, "checkout", "-q", "side")
+ write(repo, "src/side.py", "S = 1\n")
+ return commit(repo, "side: unrelated")
+
+ m1, p1 = (on_side(), on_main())[::-1] if branch_first else (on_main(), on_side())
+ git(repo, "checkout", "-q", "main")
+ _merge(repo, p1)
+ git(repo, "checkout", "-q", "side")
+ _merge(repo, m1)
+ write(repo, SETTINGS, CLAUDE)
+ commit(repo, "side: drop Stop")
+
+
+@pytest.mark.parametrize("branch_first", [False, True])
+def test_criss_cross_drop_guardrail(tmp_path, capsys, branch_first):
+ repo = base_repo(tmp_path)
+ _criss_cross(repo, branch_first=branch_first)
+ code, out = run_floor(repo, capsys, "--head", "side")
+ assert code == 2, out # main is not an ancestor of side: no merge-base is ever picked
+ git(repo, "checkout", "-q", "--detach", "main")
+ _merge(repo, "side")
+ landed = git(repo, "show", f"HEAD:{SETTINGS}") != git(repo, "show", f"main:{SETTINGS}")
+ code, out = run_floor(repo, capsys)
+ assert code == (1 if landed else 0), out
+ assert (f"\n {SETTINGS}\n" in out) == landed, out
diff --git a/tests/test_floor_attacks4.py b/tests/test_floor_attacks4.py
new file mode 100644
index 00000000..684632b5
--- /dev/null
+++ b/tests/test_floor_attacks4.py
@@ -0,0 +1,232 @@
+"""Second adversarial review of `chock check --floor`, part 2: refs, encodings, waivers, history, correct PRs.
+
+Each asserts the exit W2-A1v2 owes. Control-plane proofs of the same review are in test_floor_attacks3.py.
+"""
+
+from __future__ import annotations
+
+import json
+import os
+import subprocess
+import time
+from pathlib import Path
+
+import pytest
+from floor_support import (
+ FLOOR_TOKEN,
+ LOCK,
+ TEST_FILE,
+ TEST_PRAGMA,
+ base_repo,
+ commit,
+ control_plane_change,
+ gate,
+ git,
+ run_floor,
+ write,
+)
+
+SECRET = "FLOOR-TOKEN-424242"
+
+
+def _merge(repo: Path, branch: str = "pr") -> None:
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@e", "merge", "-q", "--no-ff", "--no-edit", branch)
+
+
+# ---------- shallow clone and unrelated history ----------
+
+
+def test_shallow_clone_is_undecided(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr1")
+ write(repo, "src/app.py", "VALUE = 3\n")
+ commit(repo, "pr2")
+ clone = tmp_path / "clone"
+ subprocess.run(
+ ["git", "clone", "-q", "--depth", "1", "--no-single-branch", f"file://{repo}", str(clone)], check=True
+ )
+ code, out = run_floor(clone, capsys, "--base", "origin/main", "--head", "origin/pr")
+ assert code == 2, out
+
+
+def test_unrelated_history_is_undecided(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "--orphan", "alien")
+ git(repo, "rm", "-rq", "--cached", ".")
+ write(repo, "x.txt", f"{SECRET}\n")
+ git(repo, "add", "x.txt")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@e", "commit", "-q", "-m", "alien")
+ code, out = run_floor(repo, capsys, "--head", "alien")
+ assert code == 2, out
+
+
+# ---------- M-f, X6: encodings and line counting in the history pass ----------
+
+
+def test_utf16_secret(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ (repo / "src/notes.txt").write_bytes(f"key = {SECRET}\n".encode("utf-16"))
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "floor-token [history] (block)" in out
+
+
+def test_utf16_secret_shifted_by_one_byte(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ (repo / "src/notes.bin").write_bytes(b"\x01" + f"key = {SECRET}\n".encode("utf-16-le"))
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_secret_as_symlink_target_added_then_removed(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ os.symlink(SECRET, repo / "link")
+ commit(repo, "add link")
+ (repo / "link").unlink()
+ commit(repo, "remove link")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+@pytest.mark.parametrize("prefix", [b"\x85\x85", b"\xff\xff", b"\x1c\x1d\x1e"])
+def test_history_line_number_mismatch_drops_no_secret(tmp_path, capsys, prefix):
+ """U+0085 and the separators splitlines() knows are not line breaks to the floor: one reader, one count."""
+ repo = base_repo(tmp_path)
+ (repo / "src/app.py").write_bytes(prefix + b"FLOOR-TOKEN-777\nVALUE = 1\nVALUE = 1\n")
+ commit(repo, "pr: add (hidden)")
+ write(repo, "src/app.py", "VALUE = 1\n")
+ commit(repo, "pr: restore")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "src/app.py:1 (content-pattern)" in out
+
+
+# ---------- M-a, M-b: waivers on removed lines, renames hiding deletions ----------
+
+
+def _base_then_pr(repo: Path, base_text: str, head_text: str) -> None:
+ git(repo, "checkout", "-q", "main")
+ write(repo, "tests/test_core.py", base_text)
+ commit(repo, "base")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "tests/test_core.py", head_text)
+ commit(repo, "pr")
+
+
+def test_removed_assertion_carrying_base_pragma_is_not_waived(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ pragma = TEST_FILE.replace("assert 2 * 2 == 4", f"assert 2 * 2 == 4 # {TEST_PRAGMA}")
+ _base_then_pr(repo, pragma, "def test_a():\n assert 1 + 1 == 2\n")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_removed_pragma_assertions_two_lines(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ body = TEST_FILE.replace("== 2\n", f"== 2 # {TEST_PRAGMA}\n").replace("== 4\n", f"== 4 # {TEST_PRAGMA}\n")
+ _base_then_pr(repo, body, "def test_a():\n pass\n")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+@pytest.mark.parametrize("how", ["rename", "delete", "weaken"])
+def test_test_file_moved_deleted_or_weakened_is_refused(tmp_path, capsys, how):
+ repo = base_repo(tmp_path)
+ if how == "rename":
+ git(repo, "mv", "tests/test_core.py", "attic_core.py")
+ elif how == "delete":
+ git(repo, "rm", "-q", "tests/test_core.py")
+ else:
+ write(repo, "tests/test_core.py", "def test_a():\n assert 1 + 1 == 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+# ---------- first adoption ----------
+
+
+def test_first_adoption_output(tmp_path, capsys):
+ repo = tmp_path / "repo"
+ repo.mkdir()
+ git(repo, "init", "-q", "-b", "main")
+ write(repo, "src/app.py", "V = 1\n")
+ commit(repo, "base")
+ git(repo, "checkout", "-q", "-b", "pr")
+ write(repo, "src/leak.py", "K = 'FLOOR-TOKEN-1'\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "base has no chock gates; nothing was judged" in out
+
+
+# ---------- correct pull requests and wall time ----------
+
+
+@pytest.mark.parametrize("megabytes", [8, 40])
+def test_large_correct_blob(tmp_path, capsys, megabytes):
+ repo = base_repo(tmp_path)
+ line = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0123456789\n"
+ (repo / "data.csv").write_text(line * (megabytes * 1024 * 1024 // len(line)))
+ commit(repo, "pr: data")
+ started = time.monotonic()
+ code, out = run_floor(repo, capsys)
+ print(f"{megabytes} MB: exit {code} in {time.monotonic() - started:.1f}s")
+ assert code == 0, out
+
+
+def test_ok_merge_base_into_branch_and_revert(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/feature.py", "F = 1\n")
+ commit(repo, "pr: feature")
+ git(repo, "checkout", "-q", "main")
+ write(repo, "src/other.py", "O = 1\n")
+ commit(repo, "main moves on")
+ git(repo, "checkout", "-q", "pr")
+ _merge(repo, "main")
+ write(repo, "src/feature.py", "F = 2\n")
+ commit(repo, "pr: change")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@e", "revert", "--no-edit", "HEAD")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_policy_added_with_lock_entry_is_a_control_plane_change(tmp_path, capsys):
+ """By design under `refuse` (a privileged merge); under `listed` its own gate never judges its own source."""
+
+ def change(repo):
+ lock = json.loads(json.dumps(LOCK))
+ lock["packs"].append({"id": "no-todo"})
+ write(repo, "chock.lock", lock)
+ gate(repo, "no-todo", dict(FLOOR_TOKEN, message="no TODO", params={"content_pattern": "TODO-NEVER"}))
+ write(repo, ".agents/policies/no-todo/policy.md", "# no-todo\n")
+ commit(repo, "pr: add policy")
+
+ control_plane_change(tmp_path, capsys, change, "chock.lock", ".agents/policies/no-todo/policy.md")
+
+
+def test_docs_quoting_a_policy_example_in_its_own_folder(tmp_path, capsys):
+ rel = ".agents/policies/floor-token/README.md"
+
+ def change(repo):
+ write(repo, rel, "Example that is refused: FLOOR-TOKEN-1\n")
+ commit(repo, "pr: docs")
+
+ control_plane_change(tmp_path, capsys, change, rel)
+
+
+def test_ok_rename_file_with_base_waiver(tmp_path, capsys):
+ """A rename is a delete and an add (V1); the fixture's probe gate refuses every delete, so it goes first."""
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ git(repo, "rm", "-q", "-r", ".chock/compiled/probe")
+ write(repo, "src/legacy.py", "X = 1\n")
+ commit(repo, "base")
+ git(repo, "checkout", "-q", "-B", "pr")
+ git(repo, "mv", "src/legacy.py", "src/legacy2.py")
+ commit(repo, "pr: rename")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
diff --git a/tests/test_floor_check.py b/tests/test_floor_check.py
new file mode 100644
index 00000000..4ee3b842
--- /dev/null
+++ b/tests/test_floor_check.py
@@ -0,0 +1,223 @@
+"""`chock check --floor`: the base's gates bind, waivers count only from the base, ask refuses, nothing of the head runs."""
+
+from __future__ import annotations
+
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+from floor_support import (
+ FLOOR_TOKEN,
+ MARKER_SCRIPT,
+ PROBE,
+ TEST_FILE,
+ TEST_PRAGMA,
+ base_repo,
+ commit,
+ gate,
+ git,
+ run_floor,
+ write,
+)
+
+from chock.lifecycle import check_main
+
+SRC = Path(__file__).resolve().parents[1] / "src"
+
+NO_OP = {"kind": "content_regex", "on": ["commit"], "action": "warn", "params": {"content_pattern": "(?!)"}}
+
+
+def test_a_head_rewrite_of_the_gate_does_not_stop_the_base_gate(tmp_path, capsys) -> None:
+ repo = base_repo(tmp_path)
+ gate(repo, "test-integrity", NO_OP)
+ (repo / "tests/test_core.py").unlink()
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1
+ assert "FAIL test-integrity [base] (block)" in out
+ assert "tests/test_core.py: test file deleted" in out
+
+
+def test_a_waiver_the_pull_request_adds_is_not_honoured(tmp_path, capsys) -> None:
+ repo = base_repo(tmp_path)
+ write(repo, "tests/test_core.py", f"def test_a():\n # {TEST_PRAGMA}\n assert 1 + 1 == 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1
+ assert "assertions removed across tests" in out
+
+
+def test_a_base_waiver_on_a_line_the_pull_request_removes_is_not_honoured(tmp_path, capsys) -> None:
+ """V4: a waiver counts only on a line present and unchanged in both base and head."""
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ write(repo, "tests/test_core.py", TEST_FILE.replace("== 4\n", f"== 4 # {TEST_PRAGMA}\n"))
+ commit(repo, "base waiver")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "tests/test_core.py", "def test_a():\n assert 1 + 1 == 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "assertions removed across tests" in out
+
+
+def test_ask_counts_as_a_refusal(tmp_path, capsys) -> None:
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ gate(repo, "floor-token", {**FLOOR_TOKEN, "action": "ask"})
+ commit(repo, "ask")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-1'\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1
+ assert "FAIL floor-token [base] (ask)" in out
+
+
+def test_a_secret_added_then_removed_is_found_by_the_history_pass(tmp_path, capsys) -> None:
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-7'\n")
+ first = commit(repo, "add")
+ write(repo, "src/app.py", "VALUE = 1\n")
+ commit(repo, "remove")
+ code, out = run_floor(repo, capsys)
+ assert code == 1
+ assert f"FAIL floor-token [history] (block): {first[:12]} src/app.py:1 (content-pattern)" in out
+
+
+def test_a_line_already_at_the_base_is_not_the_pull_requests(tmp_path, capsys) -> None:
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-3'\n")
+ commit(repo, "before adoption")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-3'\nOTHER = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_a_script_gate_gets_deleted_paths_and_no_environment(tmp_path, capsys, monkeypatch) -> None:
+ repo = base_repo(tmp_path)
+ (repo / "src/app.py").unlink()
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1
+ assert "probe: deleted src/app.py" in out
+ write(repo, "src/app.py", "VALUE = 1\n")
+ commit(repo, "restore")
+ monkeypatch.setenv("FLOOR_PROBE_SECRET", "1")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_no_head_file_is_executed(tmp_path, capsys) -> None:
+ repo = base_repo(tmp_path)
+ write(repo, PROBE["params"]["script"], MARKER_SCRIPT)
+ gate(repo, "new-probe", {**PROBE, "params": {"script": "tools/new_probe.py"}}, surfaces=("ci-gate",))
+ write(repo, "tools/new_probe.py", MARKER_SCRIPT)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert not (repo / "MARKER").exists()
+ assert "new-probe" not in out.replace(".chock/compiled/new-probe/", "")
+ assert code == 1, out
+ assert f"\n {PROBE['params']['script']}\n" in out
+
+
+def test_the_head_is_read_as_objects_from_a_base_checkout(tmp_path, capsys) -> None:
+ repo = base_repo(tmp_path)
+ (repo / ".cursor/hooks.json").unlink()
+ commit(repo, "pr")
+ git(repo, "checkout", "-q", "main")
+ code, out = run_floor(repo, capsys, "--head", "pr")
+ assert code == 1
+ assert "FAIL floor/control-plane-changed (refuse): 1 path(s)" in out
+ assert "\n .cursor/hooks.json\n" in out
+
+
+def test_an_unresolvable_base_is_undecided(tmp_path, capsys) -> None:
+ repo = base_repo(tmp_path)
+ code = check_main(["--repo", str(repo), "--floor", "--base", "no-such-ref"])
+ assert code == 2
+ assert "does not resolve" in capsys.readouterr().err
+
+
+def test_a_branch_gate_without_the_branch_is_undecided(tmp_path, capsys) -> None:
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ gate(
+ repo,
+ "protect-main",
+ {"kind": "forbidden_ref", "on": ["commit"], "action": "block", "params": {"refs": ["main"]}},
+ )
+ commit(repo, "ref gate")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "src/other.py", "X = 1\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 2
+ assert "needs --head-ref" in out
+ code, out = run_floor(repo, capsys, "--head-ref", "pr")
+ assert code == 0, out
+ code, out = run_floor(repo, capsys, "--head-ref", "main")
+ assert code == 1
+
+
+@pytest.mark.parametrize(
+ "argv",
+ [
+ ["--floor"],
+ ["--floor", "--base", "main", "--only", "verify"],
+ ["--head", "x"],
+ ["--floor", "--base", "m", "--format", "sarif"],
+ ],
+)
+def test_the_floor_runs_alone_and_needs_a_base(tmp_path, argv) -> None:
+ with pytest.raises(SystemExit) as exc:
+ check_main(["--repo", str(tmp_path), *argv])
+ assert exc.value.code == 2
+
+
+def test_no_coverage_tier_is_credited_for_the_floor() -> None:
+ """A floor is the adopter's required-check setting, which chock cannot see: nothing grades it."""
+ from chock.evidence import CLAIMS_PATH
+
+ assert "floor" not in CLAIMS_PATH.read_text(encoding="utf-8").lower()
+ from chock.compile import surfaces
+
+ assert not [name for name in vars(surfaces) if "floor" in name.lower()]
+
+
+def test_head_not_descendant_of_base_is_undecided(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ write(repo, "src/app.py", "VALUE = 9\n")
+ commit(repo, "main moves on")
+ git(repo, "checkout", "-q", "pr")
+ code, out = run_floor(repo, capsys, "--head", "pr")
+ assert code == 2, out
+ assert "is not an ancestor of head" in out
+
+
+def _cli(repo: Path, *args: str) -> int:
+ env = {"PATH": os.environ.get("PATH", ""), "PYTHONPATH": str(SRC), "HOME": str(repo.parent)}
+ code = "import sys; from chock.lifecycle import check_main; sys.exit(check_main(sys.argv[1:]))"
+ proc = subprocess.run(
+ [sys.executable, "-c", code, "--repo", str(repo), *args], capture_output=True, text=True, env=env, check=False
+ )
+ return proc.returncode
+
+
+def test_ref_arguments(tmp_path):
+ repo = base_repo(tmp_path)
+ write(repo, "src/config.txt", "key = FLOOR-TOKEN-4242\n")
+ commit(repo, "pr")
+ assert _cli(repo, "--floor", "--base", "main", "--head", "pr") == 1
+ assert _cli(repo, "--floor", "--base", "no-such-ref", "--head", "pr") == 2
+ assert _cli(repo, "--floor", "--base=--all", "--head", "pr") == 2
+ assert _cli(repo, "--floor", "--base=--since=2000-01-01", "--head", "pr") == 2
+ assert _cli(repo, "--floor", "--base", "main", f"--head=--output={tmp_path / 'x'}") == 2
+ assert _cli(repo, "--floor", "--base", "pr", "--head", "pr") == 0
diff --git a/tests/test_floor_control_plane.py b/tests/test_floor_control_plane.py
new file mode 100644
index 00000000..575f06ef
--- /dev/null
+++ b/tests/test_floor_control_plane.py
@@ -0,0 +1,177 @@
+"""The floor's control-plane rule (W2-A1v2 V2): which paths, how they match, what the base's config decides."""
+
+from __future__ import annotations
+
+import json
+import os
+
+import pytest
+from agentseam.vendor_config import VENDOR_CONFIG
+from floor_support import WORKFLOW, base_repo, commit, git, run_floor, write
+
+from chock import vendors
+from chock.validation import control_plane as cp
+
+FLOOR_WORKFLOW = ".github/workflows/chock.yml"
+DEFAULT = cp.ControlPlane(cp.REFUSE, cp.default_patterns())
+
+
+@pytest.mark.parametrize("vendor", sorted(v for v in VENDOR_CONFIG if not vendors.config_path(v).startswith("~")))
+def test_every_repo_relative_vendor_hook_file_is_control_plane(vendor):
+ path = vendors.config_path(vendor)
+ assert DEFAULT.covers(path) or DEFAULT.covers(f"{path}/hook.sh"), path
+
+
+@pytest.mark.parametrize(
+ "path",
+ [
+ ".chock/config.yaml",
+ ".chock/bin/launch.sh",
+ "chock.lock",
+ ".agents/policies/x/manifest.yaml",
+ ".claude/settings.local.json",
+ ".claude/commands/x.md",
+ ".claude/skills/x/SKILL.md",
+ ".github/hooks/chock.json",
+ ".github/workflows/any.yml",
+ ".github/actions/floor/action.yml",
+ ".github/CODEOWNERS",
+ "CODEOWNERS",
+ "docs/CODEOWNERS",
+ "pkg/.claude/settings.json",
+ "a/b/.codex/config.toml",
+ "pkg/.env",
+ ".devcontainer/devcontainer.json",
+ ".Chock/Config.yaml",
+ ".claude/SETTINGS.json",
+ ".claude/settings.json.",
+ ".claude/settings.json",
+ ],
+)
+def test_guardrail_paths_match_in_any_spelling_a_filesystem_may_open(path):
+ assert DEFAULT.covers(path)
+
+
+@pytest.mark.parametrize(
+ "path",
+ [
+ "src/app.py",
+ "AGENTS.md",
+ "CLAUDE.md",
+ "docs/guide.md",
+ "chock.lock.bak",
+ "tests/x",
+ ".envrc",
+ ".gitattributes",
+ "src/.gitattributes",
+ ".env.example",
+ "x.env",
+ ],
+)
+def test_ordinary_paths_are_not_control_plane(path):
+ assert not DEFAULT.covers(path)
+
+
+def test_mode_and_deletion_changes_are_listed(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ (repo / ".chock/bin/gate.py").chmod(0o755)
+ git(repo, "rm", "-q", ".cursor/hooks.json")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "\n .chock/bin/gate.py\n .cursor/hooks.json\n" in out
+
+
+def test_the_base_config_adds_and_removes_patterns(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ config = "floor:\n control_plane_paths:\n add: ['infra/**']\n remove: ['.github/workflows/**']\n"
+ write(repo, ".chock/config.yaml", config)
+ commit(repo, "base: own patterns")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, FLOOR_WORKFLOW, WORKFLOW + "# edited\n")
+ write(repo, "infra/main.tf", "x = 1\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "FAIL floor/control-plane-changed (refuse): 1 path(s)" in out
+ assert "\n infra/main.tf\n" in out
+
+
+@pytest.mark.parametrize(
+ "config",
+ [
+ "floor:\n control_plane: off\n",
+ "floor: listed\n",
+ "floor:\n control_plane_paths: ['x']\n",
+ "floor:\n control_plane_paths:\n add: [1]\n",
+ "floor: [\n",
+ ],
+)
+def test_a_base_config_the_floor_cannot_read_is_undecided(tmp_path, capsys, config):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ write(repo, ".chock/config.yaml", config)
+ commit(repo, "base: bad floor config")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "UNDECIDED floor: the base's .chock/config.yaml floor" in out
+
+
+@pytest.mark.parametrize(("mode", "owed", "level"), [("refuse", 1, "error"), ("listed", 0, "note")])
+def test_sarif_lists_control_plane_paths_first(tmp_path, capsys, mode, owed, level):
+ repo = base_repo(tmp_path, mode)
+ write(repo, FLOOR_WORKFLOW, WORKFLOW + "# edited\n")
+ write(repo, "src/config.txt", "key = FLOOR-TOKEN-1\n")
+ commit(repo, "pr")
+ out = tmp_path / "floor.sarif"
+ code, text = run_floor(repo, capsys, "--sarif", str(out))
+ assert code == 1, text # the secret refuses in both modes
+ results = json.loads(out.read_text(encoding="utf-8"))["runs"][0]["results"]
+ assert results[0]["ruleId"] == cp.RULE
+ assert results[0]["level"] == level
+ assert results[0]["locations"][0]["physicalLocation"]["artifactLocation"]["uri"] == FLOOR_WORKFLOW
+ assert {r["ruleId"] for r in results[1:]} == {"floor/refused"}
+ assert owed in (0, 1)
+
+
+def test_check_routes_format_sarif_to_the_floor(tmp_path, capsys):
+ from chock.lifecycle import check_main
+
+ repo = base_repo(tmp_path, "listed")
+ write(repo, FLOOR_WORKFLOW, WORKFLOW + "# edited\n")
+ commit(repo, "pr")
+ out = tmp_path / "floor.sarif"
+ argv = ["--repo", str(repo), "--floor", "--base", "main", "--format", "sarif", "--output", str(out)]
+ assert check_main(argv) == 0, capsys.readouterr().out
+ assert json.loads(out.read_text(encoding="utf-8"))["runs"][0]["results"][0]["ruleId"] == cp.RULE
+
+
+def test_a_base_observe_rollout_softens_history_and_a_warn_gate_never_refuses(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ write(repo, ".chock/config.yaml", "rollout: observe\n")
+ commit(repo, "base: observe")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-9'\n")
+ commit(repo, "add")
+ write(repo, "src/app.py", "VALUE = 1\n")
+ commit(repo, "remove")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "note: floor-token [history] (warn)" in out
+
+
+def test_no_head_file_reaches_the_working_tree(tmp_path, capsys):
+ """Read as objects: nothing under the head's control plane is written or run, even under `listed`."""
+ repo = base_repo(tmp_path, "listed")
+ write(repo, ".chock/bin/gate.py", "import pathlib; pathlib.Path('MARKER').write_text('ran')\n")
+ commit(repo, "pr")
+ git(repo, "checkout", "-q", "main")
+ before = sorted(os.listdir(repo))
+ code, out = run_floor(repo, capsys, "--head", "pr")
+ assert code == 0, out
+ assert sorted(os.listdir(repo)) == before
diff --git a/tests/test_floor_control_plane_list.py b/tests/test_floor_control_plane_list.py
new file mode 100644
index 00000000..62c9a118
--- /dev/null
+++ b/tests/test_floor_control_plane_list.py
@@ -0,0 +1,91 @@
+"""The floor's default control-plane list (W2-A1v2.1 L1) against every repo-relative path the engine writes."""
+
+from __future__ import annotations
+
+import json
+from importlib import resources
+
+import pytest
+from agentseam import instructions, permissions_data
+from agentseam.vendor_config import VENDOR_CONFIG
+
+from chock import vendors
+from chock.config import CONFIG_DIR
+from chock.gate.runner.constants import COMPILED_PREFIX, POLICIES_PREFIX
+from chock.guardrails.toggle import FILENAME as GUARDRAILS_TOGGLE
+from chock.hooks.launch import LAUNCHER_REL
+from chock.plugin.marketplace_core import TREES
+from chock.plugin.marketplace_devin import DEVIN_ROOT_MANIFEST_REL
+from chock.scaffold.install_ci import DEFAULT_PATH as CI_WORKFLOW
+from chock.validation import control_plane as cp
+
+DEFAULT = cp.ControlPlane(cp.REFUSE, cp.default_patterns())
+_REPO_SCOPES = ("project", "local")
+
+
+def _data(package: str, rel: str) -> dict:
+ return json.loads(resources.files(package).joinpath(rel).read_text(encoding="utf-8"))
+
+
+def _hook_files() -> list[str]:
+ return sorted({p for p in map(vendors.config_path, VENDOR_CONFIG) if not p.startswith("~")})
+
+
+def _engine_paths() -> list[str]:
+ """Every repo-relative file or folder chock or agentseam writes hooks, permissions, MCP servers, plugins,
+ CI or its own state into. A folder is given with a trailing `/`."""
+ found = set(_hook_files())
+ found |= {
+ e["path"] for files in permissions_data.CONFIG_FILES.values() for e in files if e["scope"] in _REPO_SCOPES
+ }
+ found |= {c["path"] for c in _data("chock", "data/mcp_clients.json").values()}
+ found |= {p.as_posix() for tree in TREES.values() for p in tree["index_paths"]} | {
+ DEVIN_ROOT_MANIFEST_REL.as_posix()
+ }
+ install = _data("chock.install", "data/install.json")
+ found |= {i["path"] for client in install["clients"].values() for i in client.get("index", [])}
+ stores = resources.files("chock.plugin").joinpath("data/stores")
+ layouts = [json.loads(f.read_text(encoding="utf-8")).get("layout", {}) for f in stores.iterdir()]
+ # A plugin manifest in its own folder (`.factory-plugin/plugin.json`); a bare `plugin.json` is the package root's.
+ found |= {m for layout in layouts if "/" in (m := layout.get("manifest") or "")}
+ found |= {CI_WORKFLOW, LAUNCHER_REL, GUARDRAILS_TOGGLE, COMPILED_PREFIX, POLICIES_PREFIX, f"{CONFIG_DIR}/"}
+ return sorted(found)
+
+
+def _agent_folder(path: str) -> str:
+ parts = path.split("/")
+ return "/".join(parts[:2] if parts[0] == ".github" else parts[:1])
+
+
+@pytest.mark.parametrize("path", _engine_paths())
+def test_every_path_the_engine_writes_is_control_plane(path):
+ assert path.startswith(".") or "/" not in path, path # repo-relative, never a home path
+ assert DEFAULT.covers(path) or DEFAULT.covers(f"{path.rstrip('/')}/x"), path
+
+
+@pytest.mark.parametrize("folder", sorted({_agent_folder(p) for p in _hook_files() if "/" in p}))
+def test_every_agent_folder_is_control_plane_whole(folder):
+ for rel in ("skills/x/SKILL.md", "agents/x.md", "cli.json", ".env", "rules/x.md", "x"):
+ assert DEFAULT.covers(f"{folder}/{rel}"), f"{folder}/{rel}"
+ assert DEFAULT.covers(folder), f"a symlink or gitlink at {folder} is not matched"
+
+
+@pytest.mark.parametrize(
+ "path",
+ sorted({f for e in instructions.INSTRUCTION_FILES.values() for f in e["files"] if "/" in f}),
+)
+def test_instruction_files_inside_an_agent_folder_are_covered_by_it(path):
+ """Whole folders: an instruction file inside one is listed with it; one beside them (`.github/x.md`) is not."""
+ assert DEFAULT.covers(path) == DEFAULT.covers(f"{_agent_folder(path)}/x"), path
+
+
+@pytest.mark.parametrize(
+ "path", sorted({f for e in instructions.INSTRUCTION_FILES.values() for f in e["files"] if "/" not in f})
+)
+def test_root_instruction_files_stay_out(path):
+ assert not DEFAULT.covers(path), path
+
+
+@pytest.mark.parametrize("path", [".mcp.json", ".vscode/settings.json", ".vscode/mcp.json", ".env", ".cursor/cli.json"])
+def test_client_config_and_env_files_named_by_the_review_are_control_plane(path):
+ assert DEFAULT.covers(path)
diff --git a/tests/test_floor_gate_attrs.py b/tests/test_floor_gate_attrs.py
new file mode 100644
index 00000000..a5689327
--- /dev/null
+++ b/tests/test_floor_gate_attrs.py
@@ -0,0 +1,62 @@
+"""Release gate G1, GT-1 attributes (S3), scenarios C1-C3: each test asserts the exit the plan owes.
+
+Every git call the floor makes reads attributes from the base, so a `.gitattributes` the head adds changes nothing
+the floor sees, and is not itself listed."""
+
+from __future__ import annotations
+
+import os
+import shutil
+
+import pytest
+from floor_support import base_repo, commit, git, run_floor, write
+from floor_support4 import raw_commit, rebase_main
+
+VIOLATION = "VALUE = 'FLOOR-TOKEN-7'\n"
+C1_ATTRIBUTES = ("-diff", "binary", "filter=x", "diff=x", "eol=crlf", "working-tree-encoding=UTF-16", "export-ignore")
+C1_PLACES = {"root": (".gitattributes", "src/bad.py"), "nested": ("src/.gitattributes", "bad.py")}
+
+
+@pytest.mark.parametrize("place", list(C1_PLACES))
+@pytest.mark.parametrize("attribute", C1_ATTRIBUTES)
+def test_c1_head_gitattributes_cannot_hide_a_content_violation(tmp_path, capsys, attribute, place):
+ attrs, pattern = C1_PLACES[place]
+ repo = base_repo(tmp_path)
+ write(repo, "src/bad.py", VIOLATION)
+ commit(repo, "pr: a violation") # staged before the attributes exist, so no filter rewrites the blob
+ write(repo, attrs, f"{pattern} {attribute}\n")
+ git(repo, "add", attrs) # by path: `add -A` would re-read bad.py through the new attribute
+ raw_commit(repo, f"pr: mark it {attribute}")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, (attribute, place, out)
+ assert "floor-token" in out, out
+ assert f"\n {attrs}\n" not in out, out
+
+
+@pytest.mark.parametrize("attribute", ["-diff", "binary"])
+def test_c2_base_gitattributes_marking_a_path_never_hides_a_violation_there(tmp_path, capsys, attribute):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: write(r, ".gitattributes", f"src/** {attribute}\n"))
+ write(repo, "src/bad.py", VIOLATION)
+ commit(repo, "pr: a violation under a base attribute")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, (attribute, out)
+ assert "floor-token" in out, out
+
+
+def test_c3_git_without_the_attribute_source_option_is_2_naming_the_version(tmp_path, capsys, monkeypatch):
+ """A `git` wrapper earlier on PATH that drops GIT_ATTR_SOURCE, as a git older than 2.42 ignores it."""
+ repo = base_repo(tmp_path)
+ real = shutil.which("git")
+ bin_dir = tmp_path / "old-git"
+ bin_dir.mkdir()
+ wrapper = bin_dir / "git"
+ wrapper.write_text(f'#!/bin/sh\nunset GIT_ATTR_SOURCE\nexec "{real}" "$@"\n', encoding="utf-8")
+ wrapper.chmod(0o755)
+ monkeypatch.setenv("PATH", f"{bin_dir}{os.pathsep}{os.environ['PATH']}")
+ assert shutil.which("git") == str(wrapper)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr: ordinary")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "git 2.42 or newer" in out, out
diff --git a/tests/test_floor_gate_config.py b/tests/test_floor_gate_config.py
new file mode 100644
index 00000000..c8527cdb
--- /dev/null
+++ b/tests/test_floor_gate_config.py
@@ -0,0 +1,158 @@
+"""Release gate G1, GT-2 config (S5) and SARIF (S6): E1-E4, each from the base's `.chock/config.yaml`."""
+
+from __future__ import annotations
+
+import itertools
+import json
+import os
+import shutil
+
+import pytest
+from floor_support import CONTROL_PLANE, base_repo, commit, git, run_floor, write
+from floor_support4 import rebase_main, rm
+
+_NOT_REQUIRED = "floor (preview): a floor only"
+
+
+def _config(tmp_path, text):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: write(r, ".chock/config.yaml", text))
+ return repo
+
+
+@pytest.mark.parametrize(
+ ("entry", "change", "owed", "said"),
+ [
+ ("infra/", "infra/deploy.sh", 1, "base added: infra/;"),
+ ("infra", "infra/deploy.sh", 2, "write 'infra/**' for the folder"),
+ ("infra/**", "infra/deploy.sh", 1, "base added: infra/**;"),
+ ("Makefile", "Makefile", 1, "base added: Makefile;"),
+ ],
+ ids=["E1-trailing-slash", "E1-bare-folder", "E1-glob", "E1-file"],
+)
+def test_e1_added_entries(tmp_path, capsys, entry, change, owed, said):
+ repo = _config(tmp_path, f"floor:\n control_plane_paths:\n add: ['{entry}']\n")
+ write(repo, "infra/deploy.sh", "echo base\n") if change == "Makefile" else None
+ write(repo, change, "echo changed\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == owed, out
+ assert said in out, out
+ if owed == 1:
+ assert f"\n {change}\n" in out, out
+
+
+def test_e2_listed_mode_is_clean_and_lists_first(tmp_path, capsys):
+ repo = _config(tmp_path, "floor:\n control_plane: listed\n")
+ write(repo, ".claude/settings.json", "{}\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ first, listing = out.index("control plane: listed, "), out.index(f"LISTED {CONTROL_PLANE} (listed)")
+ assert first < listing < out.index("\n .claude/settings.json\n") < out.index(_NOT_REQUIRED), out
+
+
+@pytest.mark.parametrize(
+ "value", ["Listed", "yes", "", "''", "3"], ids=["E2-capital", "E2-yes", "E2-empty", "E2-empty-string", "E2-number"]
+)
+def test_e2_a_mode_that_is_not_refuse_or_listed_is_undecided(tmp_path, capsys, value):
+ repo = _config(tmp_path, f"floor:\n control_plane: {value}\n")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "control_plane is " in out and "it takes refuse or listed" in out, out
+
+
+def _directory(r):
+ write(r, ".chock/config.yaml/floor.yaml", "floor:\n control_plane: listed\n")
+
+
+def _symlink(r):
+ write(r, "cfg/config.yaml", "floor:\n control_plane: listed\n")
+ os.symlink("../cfg/config.yaml", r / ".chock/config.yaml")
+
+
+def _not_utf8(r):
+ (r / ".chock/config.yaml").write_bytes(b"floor:\n control_plane: listed\n# \xff\xfe\n")
+
+
+@pytest.mark.parametrize("shape", [_directory, _symlink, _not_utf8], ids=["E3-directory", "E3-symlink", "E3-not-utf8"])
+def test_e3_a_base_config_that_is_not_a_utf8_file_is_undecided(tmp_path, capsys, shape):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, shape)
+ write(repo, ".claude/settings.json", "{}\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert ".chock/config.yaml" in out, out
+
+
+def _clean(tmp_path):
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ return repo
+
+
+def _refused(tmp_path):
+ repo = base_repo(tmp_path)
+ write(repo, ".claude/settings.json", "{}\n")
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-1'\n")
+ commit(repo, "pr")
+ return repo
+
+
+def _listed(tmp_path):
+ repo = base_repo(tmp_path, "listed")
+ write(repo, ".cursor/hooks.json", "{}\n")
+ commit(repo, "pr")
+ return repo
+
+
+def _undecided(tmp_path):
+ repo = _config(tmp_path, "floor:\n control_plane: Listed\n")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ return repo
+
+
+def _first_adoption(tmp_path):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ rebase_main(repo, lambda r: (shutil.rmtree(r / ".chock"), rm(r, "chock.lock")))
+ write(repo, ".claude/settings.json", "{}\n")
+ commit(repo, "pr")
+ return repo
+
+
+@pytest.mark.parametrize(
+ ("build", "owed"),
+ [(_clean, 0), (_refused, 1), (_listed, 0), (_undecided, 2), (_first_adoption, 0)],
+ ids=["E4-clean", "E4-refusal", "E4-listed", "E4-undecided", "E4-first-adoption"],
+)
+def test_e4_text_and_sarif_agree_and_sarif_never_changes_the_exit(tmp_path, capsys, build, owed):
+ repo = build(tmp_path)
+ plain, text = run_floor(repo, capsys)
+ sarif = tmp_path / "floor.sarif"
+ code, with_sarif = run_floor(repo, capsys, "--sarif", str(sarif))
+ assert plain == code == owed, (plain, code, text)
+ assert with_sarif == text
+ run = json.loads(sarif.read_text(encoding="utf-8"))["runs"][0]
+ assert run["invocations"][0]["executionSuccessful"] is (code != 2), run
+ uris = [
+ r["locations"][0]["physicalLocation"]["artifactLocation"]["uri"] for r in run["results"] if "locations" in r
+ ]
+ lines = text.splitlines()
+ start = next((i + 1 for i, line in enumerate(lines) if CONTROL_PLANE + " (" in line), len(lines))
+ listed = [line[2:] for line in itertools.takewhile(lambda line: line.startswith(" "), lines[start:])]
+ listed = [path for path in listed if not path.startswith(" ")]
+ assert uris == listed, (uris, text)
+ levels = {r["level"] for r in run["results"]}
+ assert levels == ({"error"} if code == 1 else {"note"} if uris else set()), (levels, text)
+ refusals = [r["message"]["text"] for r in run["results"] if r["ruleId"] == "floor/refused"]
+ fails = [line for line in text.splitlines() if line.startswith("FAIL ") and CONTROL_PLANE not in line]
+ # SARIF carries a refusal on one line; the text puts each finding under its FAIL line.
+ assert len(fails) == len(refusals) and all(r.startswith(f[5:]) for f, r in zip(fails, refusals)), refusals
+ notes = [n["message"]["text"] for n in run["invocations"][0]["toolExecutionNotifications"]]
+ assert [f"UNDECIDED {n}" for n in notes] == [line for line in text.splitlines() if line.startswith("UNDECIDED ")]
diff --git a/tests/test_floor_gate_docs.py b/tests/test_floor_gate_docs.py
new file mode 100644
index 00000000..e5a72728
--- /dev/null
+++ b/tests/test_floor_gate_docs.py
@@ -0,0 +1,156 @@
+"""Release gate G1, GT-2 docs: every sentence of `docs/floor.md` and of the `--floor` help that states a behaviour
+names the test that proves it, as test_managed_emit_deploy_text.py does for deploy.json. A new sentence fails here
+until it names its proof; a proof that no longer exists fails too."""
+
+from __future__ import annotations
+
+import argparse
+import re
+from pathlib import Path
+
+import pytest
+
+from chock.validation import floor_cli
+
+ROOT = Path(__file__).resolve().parents[1]
+SUITE = Path(__file__).parent
+#: A sentence that states no behaviour of the floor (a disclaimer or a note on testing), so no test can prove it.
+NO_BEHAVIOUR = "states no behaviour"
+
+#: docs/floor.md, by each sentence's opening words (bold markers dropped, whitespace collapsed).
+DOC_PROOF = {
+ "`chock check --floor --base --head ` judges": "test_a_head_rewrite_of_the_gate_does_not_stop_the_base_gate, test_head_cannot_lower_rollout",
+ "It is a preview, and it holds only": "test_docs_every_run_says_it_is_a_preview_and_states_its_conditions",
+ "Judge what will land. The base must be an ancestor": "test_head_not_descendant_of_base_is_undecided, test_a_stale_branch_is_undecided_and_its_merge_result_passes",
+ "Everything comes from the tree diff": "test_renaming_or_moving_a_test_file_is_refused_as_a_deletion, test_docs_external_diff_and_textconv_never_reach_the_floor, test_a_secret_added_then_removed_is_found_by_the_history_pass",
+ "Every git call reads attributes from the base": "test_attributes_come_from_the_base, test_a_git_that_ignores_attr_source_is_undecided",
+ "Control plane. A change (add, edit, delete, mode)": "test_mode_and_deletion_changes_are_listed, test_d1_agent_config_at_any_depth_is_refused_and_named",
+ "A path that a commit in the range changed": "test_a_guardrail_changed_and_changed_back_is_named",
+ "These files define the guardrails": "test_docs_a_listing_says_the_floor_does_not_judge_safety_and_a_person_decides",
+ "A person decides.": "test_docs_a_listing_says_the_floor_does_not_judge_safety_and_a_person_decides",
+ "Links. Every symbolic link at, inside or above": "test_a7_link_at_an_ancestor_of_a_root_anchored_pattern_is_2, test_a7_link_above_a_plane_path_whose_target_is_not_plane_is_2, test_a_chain_of_symlinks_is_followed",
+ "A link above a control-plane path": "test_a7_link_whose_target_tree_holds_an_agent_folder_is_0, test_a7_link_above_the_plane_is_itself_plane_when_changed",
+ "If it opens a path that is itself control plane, or nothing": "test_a_link_to_another_control_plane_folder_carries_on, test_a_dangling_control_plane_link_carries_on_until_the_head_fills_it, test_a_non_control_plane_hop_is_listed_when_retargeted",
+ "Otherwise the run is undecided (exit 2), naming the link": "test_a_dangling_control_plane_link_carries_on_until_the_head_fills_it, test_a7_link_at_an_ancestor_of_a_root_anchored_pattern_is_2, test_a7_link_above_a_plane_path_whose_target_is_not_plane_is_2",
+ "So is a loop, an absolute target": "test_a_control_plane_link_that_cannot_resolve_is_undecided, test_symlinked_agent_folder_into_a_submodule_bump_is_named",
+ "The fix: put the target on": "test_a_base_link_whose_target_the_base_adds_to_the_plane_lists_the_target, test_a7_link_at_an_ancestor_of_a_root_anchored_pattern_is_2, test_a7_link_above_a_plane_path_whose_target_is_not_plane_is_2",
+ "A base whose `.chock` is a link or a submodule": "test_symlinked_chock_folder_at_base_is_not_first_adoption, test_docs_a_base_whose_chock_is_a_submodule_is_undecided",
+ "Everything else is judged by the base's compiled ci gates and rollout": "test_a_head_rewrite_of_the_gate_does_not_stop_the_base_gate, test_head_cannot_lower_rollout, test_a_base_observe_rollout_softens_history_and_a_warn_gate_never_refuses",
+ "No file from the head executes.": "test_no_head_file_is_executed, test_no_head_file_runs",
+ "`ask` refuses.": "test_ask_counts_as_a_refusal",
+ "A gate that crashes, times out or cannot be read": "test_a_crashing_base_script_gate_is_undecided_whatever_the_rollout, test_docs_a_gate_that_times_out_is_undecided_whatever_the_rollout, test_invalid_json_gate_at_base",
+ "A waiver counts only on a line present and unchanged": "test_a_base_waiver_on_a_line_the_pull_request_removes_is_not_honoured, test_a_waiver_the_pull_request_adds_is_not_honoured, test_a_content_waiver_on_an_unchanged_line_still_counts",
+ "History. The base's content gates read every blob": "test_a_secret_added_then_removed_is_found_by_the_history_pass, test_control_plane_change_and_revert_secret_in_history",
+ "Exit codes: 0 clean, 1 refused, 2 undecided.": "test_e4_text_and_sarif_agree_and_sarif_never_changes_the_exit",
+ "`--sarif ` writes a log on every run": "test_e4_text_and_sarif_agree_and_sarif_never_changes_the_exit, test_an_undecided_run_replaces_a_stale_sarif",
+ "default: exit 1 on any listed path.": "test_d1_agent_config_at_any_depth_is_refused_and_named",
+ "`listed`: exit 0, paths still listed": "test_e2_listed_mode_is_clean_and_lists_first",
+ "`name/` or `name/**` is the folder and all in it": "test_e1_added_entries",
+ "must name a default pattern exactly": "test_d5_removing_the_old_style_pattern_is_undecided_and_names_the_one_to_write, test_a_removal_that_names_no_default_pattern_is_undecided",
+ "Each run prints the mode, the number of patterns": "test_mode_and_size_are_stated_when_nothing_is_listed, test_d6_removing_the_any_depth_pattern_lets_the_change_through_and_says_so",
+ "An added entry that matches no path at base or head": "test_add_folder_forms",
+ "A required status check the pull request cannot redefine. The floor holds only as one.": "test_docs_every_run_says_it_is_a_preview_and_states_its_conditions",
+ "That is the repository's own setting, and chock does not verify it.": "test_docs_every_run_says_it_is_a_preview_and_states_its_conditions, test_no_coverage_tier_is_credited_for_the_floor",
+ "Committed content only.": "test_docs_only_committed_content_is_judged, test_no_head_file_reaches_the_working_tree",
+ "Under `refuse`, every guardrail change needs a privileged merge": "test_ok_add_policy_hook_lock_unrelated, test_an_action_bump_in_the_floor_workflow_is_a_control_plane_change",
+ "Under `listed`, you rely on code-owner review": "test_listed_mode_content_gap_is_stated",
+ "The content inside them is not judged.": "test_listed_mode_content_gap_is_stated",
+ "The list is what chock knows about, not a proof": NO_BEHAVIOUR,
+ "If your workflow installs chock from a file": "test_docs_a_file_the_workflow_installs_chock_from_can_be_put_on_the_list",
+ "Renames. Renaming or moving a test file": "test_renaming_or_moving_a_test_file_is_refused_as_a_deletion",
+ "Windows short names. The 8.3 alias": "test_docs_paths_the_list_does_not_cover",
+ "This is untested on Windows.": NO_BEHAVIOUR,
+ "`*.code-workspace` files. They are not on the list": "test_docs_paths_the_list_does_not_cover",
+ "Submodule content. Only the pointer is seen.": "test_docs_only_a_submodule_pointer_is_seen",
+ "A pointer at or inside a control-plane folder is listed": "test_a_gitlink_inside_a_control_plane_folder_is_listed, test_gitlink_at_a_vendor_folder_is_named, test_docs_only_a_submodule_pointer_is_seen",
+ "What the history pass does not see:": "test_docs_the_history_pass_does_not_see_other_encodings_commit_messages_or_file_names",
+ "Back-merges. A path is named from history": "test_a_guardrail_changed_and_changed_back_is_named, test_a_pull_request_merge_of_a_behind_branch_names_nothing_from_the_base",
+ "A branch that merged an older base": "test_docs_a_branch_that_merged_an_older_base_is_named_for_a_later_base_change",
+}
+
+#: The `--floor` help, by each clause's opening words (clauses split at `; ` and `. ` outside parentheses).
+HELP_PROOF = {
+ "Preview: judge base..head": "test_head_not_descendant_of_base_is_undecided, test_a_head_rewrite_of_the_gate_does_not_stop_the_base_gate",
+ "a changed guardrail path is listed and, by default, refused": "test_d1_agent_config_at_any_depth_is_refused_and_named, test_the_floor_runs_alone_and_needs_a_base",
+ "It holds only as a required check": "test_docs_every_run_says_it_is_a_preview_and_states_its_conditions, test_docs_only_committed_content_is_judged",
+ "under `listed` you rely on code-owner review": "test_listed_mode_content_gap_is_stated",
+ "The list is what chock knows about": "test_docs_a_file_the_workflow_installs_chock_from_can_be_put_on_the_list",
+ "a symlink at, inside or above the list must open a listed path or nothing": "test_a_link_to_another_control_plane_folder_carries_on, test_a_dangling_control_plane_link_carries_on_until_the_head_fills_it, test_a7_link_at_an_ancestor_of_a_root_anchored_pattern_is_2, test_a7_link_above_a_plane_path_whose_target_is_not_plane_is_2",
+ "a renamed or moved test file reads as a deletion": "test_renaming_or_moving_a_test_file_is_refused_as_a_deletion",
+}
+
+
+def _flat(text: str) -> str:
+ return re.sub(r"\s+", " ", re.sub(r"(? list[str]:
+ """Every sentence of docs/floor.md outside headings, with each YAML comment in its code block as one sentence."""
+ blocks, fence, current = [], False, []
+ for line in (ROOT / "docs/floor.md").read_text(encoding="utf-8").splitlines():
+ if line.startswith("```"):
+ fence = not fence
+ elif fence and "#" in line:
+ blocks.append(line.split("#", 1)[1].strip())
+ elif not fence and (line.startswith(("#", "- ")) or not line.strip()):
+ blocks.append(" ".join(current))
+ current = [line[2:]] if line.startswith("- ") else []
+ elif not fence:
+ current.append(line)
+ blocks.append(" ".join(current))
+ found: list[str] = []
+ for block in blocks:
+ start = len(found)
+ for part in re.split(r"(?<=\.|\*)\s+(?=[A-Z`*])", re.sub(r"\s+", " ", block).strip()):
+ # A bold lead ("**Renames.**") opens the sentence after it rather than standing alone.
+ joined = found.pop() + " " + part if len(found) > start and found[-1].endswith(".**") else part
+ found.append(joined)
+ return [_flat(sentence) for sentence in found if sentence]
+
+
+def help_clauses() -> list[str]:
+ parser = argparse.ArgumentParser()
+ floor_cli.add_arguments(parser)
+ [text] = [a.help for a in parser._actions if "--floor" in a.option_strings]
+ clauses, depth, current = [], 0, ""
+ for i, char in enumerate(text):
+ depth += {"(": 1, ")": -1}.get(char, 0)
+ if char in ";." and depth == 0 and text[i + 1 : i + 2] in (" ", ""):
+ clauses.append(current.strip())
+ current = ""
+ else:
+ current += char
+ return [c for c in [*clauses, current.strip()] if c]
+
+
+def _proof_for(sentence: str, proofs: dict[str, str]) -> str:
+ owned = [proof for opening, proof in proofs.items() if sentence.startswith(opening)]
+ assert len(owned) == 1, f"{len(owned)} proofs for: {sentence}"
+ return owned[0]
+
+
+def _sources() -> str:
+ return "".join(path.read_text(encoding="utf-8") for path in sorted(SUITE.glob("test_floor_*.py")))
+
+
+@pytest.mark.parametrize(
+ ("source", "proofs"), [(doc_sentences, DOC_PROOF), (help_clauses, HELP_PROOF)], ids=["docs", "help"]
+)
+def test_every_behaviour_sentence_has_a_proof_that_exists(source, proofs):
+ sources, used = _sources(), set()
+ for sentence in source():
+ proof = _proof_for(sentence, proofs)
+ used.add(proof)
+ for name in (part.strip() for part in proof.split(",") if proof != NO_BEHAVIOUR):
+ assert f"def {name}(" in sources, (sentence, name)
+ stale = [
+ opening
+ for opening, proof in proofs.items()
+ if proof not in used or not any(s.startswith(opening) for s in source())
+ ]
+ assert not stale, f"no sentence opens with: {stale}"
+
+
+def test_the_splitters_see_every_sentence():
+ """The maps are only as good as the split: the docs give 47 sentences and the help 7 clauses."""
+ assert (len(doc_sentences()), len(help_clauses())) == (len(DOC_PROOF), len(HELP_PROOF))
diff --git a/tests/test_floor_gate_docs_proofs.py b/tests/test_floor_gate_docs_proofs.py
new file mode 100644
index 00000000..39ffb1b1
--- /dev/null
+++ b/tests/test_floor_gate_docs_proofs.py
@@ -0,0 +1,168 @@
+"""Release gate G1, GT-2 docs: the proofs for `docs/floor.md` and `--floor` help sentences no other floor test proves.
+The map from each sentence to its proof is in test_floor_gate_docs.py."""
+
+from __future__ import annotations
+
+import shutil
+
+import pytest
+from floor_support import CONTROL_PLANE, PROBE, TEST_FILE, base_repo, commit, git, run_floor, write
+from floor_support4 import FAKE_A, FAKE_B, gitlink, raw_commit, rebase_main
+
+from chock.gate.runner import script
+
+NOT_REQUIRED = (
+ "floor (preview): a floor only where this check is a required status check the pull request cannot "
+ "redefine; that is the repository's own setting, unverified by chock. It judges committed content only."
+)
+A_PERSON_DECIDES = (
+ "these files define the guardrails; the floor does not judge whether a change to them is safe. A person decides."
+)
+
+
+def _pr(repo, path, content):
+ write(repo, path, content)
+ commit(repo, "pr")
+ return repo
+
+
+def test_docs_every_run_says_it_is_a_preview_and_states_its_conditions(tmp_path, capsys):
+ code, out = run_floor(_pr(base_repo(tmp_path), "src/app.py", "VALUE = 2\n"), capsys)
+ assert code == 0, out
+ assert out.startswith("== floor (preview): base "), out
+ assert NOT_REQUIRED in out, out
+
+
+def test_docs_a_listing_says_the_floor_does_not_judge_safety_and_a_person_decides(tmp_path, capsys):
+ code, out = run_floor(_pr(base_repo(tmp_path), ".cursor/hooks.json", "{}\n"), capsys)
+ assert code == 1, out
+ assert f"FAIL {CONTROL_PLANE} (refuse): 1 path(s) -- {A_PERSON_DECIDES}" in out, out
+
+
+def test_docs_external_diff_and_textconv_never_reach_the_floor(tmp_path, capsys):
+ """The base's attributes point tests at a textconv that drops asserts, and the clone sets an external diff."""
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: write(r, ".gitattributes", "tests/*.py diff=strip\n"))
+ git(repo, "config", "diff.strip.textconv", "sed /assert/d")
+ git(repo, "config", "diff.external", "true")
+ code, out = run_floor(_pr(repo, "tests/test_core.py", "def test_a():\n pass\n"), capsys)
+ assert code == 1, out
+ assert "FAIL test-integrity [base] (block): Tests were weakened, not fixed." in out, out
+
+
+@pytest.mark.parametrize("observe", [False, True], ids=["enforce", "observe"])
+def test_docs_a_gate_that_times_out_is_undecided_whatever_the_rollout(tmp_path, capsys, monkeypatch, observe):
+ repo = base_repo(tmp_path)
+ rebase_main(
+ repo,
+ lambda r: (
+ write(r, PROBE["params"]["script"], "import time\ntime.sleep(30)\n"),
+ write(r, ".chock/config.yaml", "rollout: observe\n") if observe else None,
+ ),
+ )
+ monkeypatch.setattr(script, "_SCRIPT_TIMEOUT_SECONDS", 1)
+ code, out = run_floor(_pr(repo, "src/app.py", "VALUE = 2\n"), capsys)
+ assert code == 2, out
+ assert "UNDECIDED probe [base]:" in out, out
+
+
+def test_docs_only_committed_content_is_judged(tmp_path, capsys):
+ """The working tree holds a token and a weakened test; the committed head holds neither."""
+ repo = _pr(base_repo(tmp_path), "src/app.py", "VALUE = 2\n")
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-9'\n")
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ write(repo, ".claude/settings.json", "{}\n")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+@pytest.mark.parametrize(("listed", "owed"), [(False, 0), (True, 1)], ids=["default-list", "added-by-the-base"])
+def test_docs_a_file_the_workflow_installs_chock_from_can_be_put_on_the_list(tmp_path, capsys, listed, owed):
+ repo = base_repo(tmp_path)
+ config = "floor:\n control_plane_paths:\n add: ['requirements-ci.txt']\n"
+ rebase_main(
+ repo,
+ lambda r: (
+ write(r, "requirements-ci.txt", "chock==1.1.0\n"),
+ listed and write(r, ".chock/config.yaml", config),
+ ),
+ )
+ code, out = run_floor(_pr(repo, "requirements-ci.txt", "chock @ git+https://example.invalid/fork\n"), capsys)
+ assert code == owed, out
+ assert ("\n requirements-ci.txt\n" in out) is listed, out
+
+
+@pytest.mark.parametrize("path", ["CLAUDE~1/settings.json", "project.code-workspace"], ids=["short-name", "workspace"])
+def test_docs_paths_the_list_does_not_cover(tmp_path, capsys, path):
+ """Not covered: a Windows 8.3 alias of a listed folder, and `*.code-workspace` files."""
+ code, out = run_floor(_pr(base_repo(tmp_path), path, '{"settings": {"hooks": {}}}\n'), capsys)
+ assert code == 0, out
+ assert CONTROL_PLANE not in out, out
+
+
+def test_docs_only_a_submodule_pointer_is_seen(tmp_path, capsys):
+ """A submodule outside the plane moves (it may hold agent folders of its own): nothing is listed or read."""
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ gitlink(repo, "vendor/agents", FAKE_A)
+ raw_commit(repo, "base: a submodule")
+ git(repo, "checkout", "-q", "-B", "pr")
+ gitlink(repo, "vendor/agents", FAKE_B)
+ raw_commit(repo, "pr: bump it")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "vendor/agents" not in out.split("history:")[0], out
+
+
+@pytest.mark.parametrize("shape", ["utf-32", "commit-message", "file-name"])
+def test_docs_the_history_pass_does_not_see_other_encodings_commit_messages_or_file_names(tmp_path, capsys, shape):
+ """Each commit pair adds, then removes, a token the history pass cannot see; the tree diff is clean."""
+ repo = base_repo(tmp_path)
+ if shape == "utf-32":
+ (repo / "src/u32.txt").write_bytes("X = 'FLOOR-TOKEN-3'\n".encode("utf-32"))
+ elif shape == "file-name":
+ write(repo, "src/FLOOR-TOKEN-4.txt", "x\n")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "FLOOR-TOKEN-5 in the message" if shape == "commit-message" else "pr: add")
+ for path in ("src/u32.txt", "src/FLOOR-TOKEN-4.txt"):
+ (repo / path).unlink(missing_ok=True)
+ write(repo, "src/app.py", "VALUE = 3\n")
+ commit(repo, "pr: remove")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_docs_a_branch_that_merged_an_older_base_is_named_for_a_later_base_change(tmp_path, capsys):
+ """The branch merges main at M1 (workflow X), main moves to M2 (workflow Y); the merge left X, which M2 lacks."""
+ repo = base_repo(tmp_path)
+ wf = ".github/workflows/chock.yml"
+ git(repo, "checkout", "-q", "main")
+ write(repo, wf, (repo / wf).read_text(encoding="utf-8") + "# X\n")
+ commit(repo, "M1")
+ git(repo, "checkout", "-q", "pr")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr: work")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@example.com", "merge", "-q", "--no-edit", "main")
+ git(repo, "checkout", "-q", "main")
+ write(repo, wf, (repo / wf).read_text(encoding="utf-8") + "# Y\n")
+ commit(repo, "M2")
+ git(repo, "checkout", "-q", "--detach", "main")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@example.com", "merge", "-q", "--no-edit", "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert f"\n {wf} (in a commit of the range only" in out, out
+
+
+def test_docs_a_base_whose_chock_is_a_submodule_is_undecided(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ git(repo, "rm", "-r", "-q", "--cached", ".chock")
+ shutil.rmtree(repo / ".chock")
+ gitlink(repo, ".chock", FAKE_A)
+ raw_commit(repo, "base: .chock is a submodule")
+ git(repo, "checkout", "-q", "-B", "pr")
+ write(repo, "tests/test_core.py", TEST_FILE.replace("== 4", "== 4.0"))
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "the base's .chock is a symbolic link or a submodule" in out, out
diff --git a/tests/test_floor_gate_exits.py b/tests/test_floor_gate_exits.py
new file mode 100644
index 00000000..ea892054
--- /dev/null
+++ b/tests/test_floor_gate_exits.py
@@ -0,0 +1,109 @@
+"""Release gate G1, GT-2 abnormal paths: F1-F2. None may end as 0 unless the scenario owes it."""
+
+from __future__ import annotations
+
+import os
+import subprocess
+import sys
+
+import pytest
+from floor_support import base_repo, commit, git, run_floor, write
+
+from chock.validation import checks_floor
+
+
+def _main(capsys, *argv: str) -> tuple[int, str]:
+ code = checks_floor.main(list(argv))
+ out = capsys.readouterr()
+ return code, out.out + out.err
+
+
+def _pr(tmp_path, path="src/app.py", content="VALUE = 2\n"):
+ repo = base_repo(tmp_path)
+ write(repo, path, content)
+ commit(repo, "pr")
+ return repo
+
+
+def test_f1_base_equal_to_head_is_clean_and_says_nothing_changed(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ code, out = _main(capsys, "--repo", str(repo), "--base", "main", "--head", "main")
+ assert code == 0, out
+ assert "base and head are the same commit; nothing changed" in out, out
+
+
+def test_f1_a_repository_with_no_commits_is_undecided(tmp_path, capsys):
+ repo = tmp_path / "empty"
+ repo.mkdir()
+ git(repo, "init", "-q", "-b", "main")
+ code, out = _main(capsys, "--repo", str(repo), "--base", "main", "--head", "HEAD")
+ assert code == 2, out
+ assert "does not resolve" in out, out
+
+
+@pytest.mark.parametrize("which", ["--base", "--head"])
+def test_f1_a_ref_that_does_not_exist_is_undecided(tmp_path, capsys, which):
+ repo = _pr(tmp_path)
+ refs = {"--base": "main", "--head": "pr", which: "no-such-ref"}
+ code, out = _main(capsys, "--repo", str(repo), "--base", refs["--base"], "--head", refs["--head"])
+ assert code == 2, out
+ assert "'no-such-ref' does not resolve" in out, out
+
+
+@pytest.mark.parametrize("obj", ["pr^{tree}", "pr:src/app.py"], ids=["F1-tree", "F1-blob"])
+def test_f1_a_head_that_is_a_tree_or_blob_is_undecided(tmp_path, capsys, obj):
+ repo = _pr(tmp_path)
+ code, out = _main(capsys, "--repo", str(repo), "--base", "main", "--head", git(repo, "rev-parse", obj))
+ assert code == 2, out
+ assert "does not resolve" in out, out
+
+
+def test_f1_a_head_that_is_an_annotated_tag_is_judged_as_its_commit(tmp_path, capsys):
+ repo = _pr(tmp_path, ".claude/settings.json", "{}\n")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@example.com", "tag", "-a", "-m", "t", "v-pr", "pr")
+ by_commit = _main(capsys, "--repo", str(repo), "--base", "main", "--head", "pr")
+ by_tag = _main(capsys, "--repo", str(repo), "--base", "main", "--head", "v-pr")
+ assert by_tag == by_commit and by_tag[0] == 1, by_tag
+ assert f"head {git(repo, 'rev-parse', 'pr')[:12]}" in by_tag[1], by_tag
+
+
+def test_f2_a_missing_object_is_undecided(tmp_path, capsys):
+ """A loose blob of the head deleted from a scratch copy: the floor cannot read it, so it cannot pass it."""
+ repo = _pr(tmp_path, "src/new.py", "print('new')\n")
+ oid = git(repo, "rev-parse", "pr:src/new.py")
+ loose = repo / ".git/objects" / oid[:2] / oid[2:]
+ loose.unlink()
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+
+
+def test_f2_repo_that_is_not_a_repository_is_undecided(tmp_path, capsys):
+ plain = tmp_path / "plain"
+ plain.mkdir()
+ code, out = _main(capsys, "--repo", str(plain), "--base", "main")
+ assert code == 2, out
+ assert "is not inside a git repository" in out, out
+
+
+def test_f2_git_absent_from_path_is_undecided(tmp_path):
+ repo = _pr(tmp_path)
+ env = {"PATH": str(tmp_path / "empty"), "HOME": os.environ["HOME"], "PYTHONPATH": os.pathsep.join(sys.path)}
+ script = "import sys; from chock.validation.checks_floor import main; sys.exit(main(sys.argv[1:]))"
+ proc = subprocess.run(
+ [sys.executable, "-c", script, "--repo", str(repo), "--base", "main"],
+ env=env,
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+ assert proc.returncode == 2, proc.stdout + proc.stderr
+ assert "git could not run" in proc.stderr, proc.stderr
+
+
+@pytest.mark.parametrize("target", ["missing/x.sarif", "adir"], ids=["F2-no-parent", "F2-a-directory"])
+def test_f2_an_unwritable_sarif_path_is_non_zero_and_says_why(tmp_path, capsys, target):
+ repo = _pr(tmp_path)
+ (tmp_path / "adir").mkdir()
+ code, out = run_floor(repo, capsys, "--sarif", str(tmp_path / target))
+ assert code != 0, out
+ assert "UNDECIDED floor: cannot write --sarif: " in out, out
diff --git a/tests/test_floor_gate_history.py b/tests/test_floor_gate_history.py
new file mode 100644
index 00000000..c6fca847
--- /dev/null
+++ b/tests/test_floor_gate_history.py
@@ -0,0 +1,135 @@
+"""Release gate G1, GT-1 history (S2), scenarios B1-B8: each test asserts the exit the plan owes.
+
+A commit is named when it changes a plane path to a state that differs from the base's, even if the tree diff
+base..head is empty for it."""
+
+from __future__ import annotations
+
+from floor_support import CLAUDE, base_repo, commit, git, run_floor, write
+from floor_support4 import HOOKLESS, rebase_main
+
+SETTINGS = ".claude/settings.json"
+HISTORY_ONLY = " (in a commit of the range only"
+USER = ("-c", "user.name=t", "-c", "user.email=t@example.com")
+
+
+def _named(repo, capsys, path, *extra):
+ code, out = run_floor(repo, capsys, *extra)
+ assert code == 1, out
+ assert f"\n {path}{HISTORY_ONLY}" in out, out
+ return out
+
+
+def _merge(repo, *branches):
+ git(repo, *USER, "merge", "-q", "--no-ff", "--no-edit", *branches)
+
+
+def _off_and_on(repo):
+ write(repo, SETTINGS, HOOKLESS)
+ commit(repo, "hooks off")
+ write(repo, SETTINGS, CLAUDE)
+ commit(repo, "hooks back on")
+
+
+def test_b1_plane_file_changed_and_restored_is_1_named(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _off_and_on(repo)
+ _named(repo, capsys, SETTINGS)
+
+
+def test_b2_change_and_restore_on_a_merged_side_branch_is_1(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr: ordinary")
+ git(repo, "checkout", "-q", "-b", "side")
+ _off_and_on(repo)
+ git(repo, "checkout", "-q", "pr")
+ _merge(repo, "side")
+ _named(repo, capsys, SETTINGS)
+
+
+def test_b3_plane_file_created_and_deleted_is_1(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, ".claude/agents/helper.md", "# helper\n")
+ commit(repo, "add an agent")
+ git(repo, "rm", "-q", ".claude/agents/helper.md")
+ commit(repo, "remove it")
+ _named(repo, capsys, ".claude/agents/helper.md")
+
+
+def test_b4_mode_only_change_and_its_revert_is_1(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ (repo / SETTINGS).chmod(0o755)
+ commit(repo, "make it executable")
+ (repo / SETTINGS).chmod(0o644)
+ commit(repo, "and back")
+ _named(repo, capsys, SETTINGS)
+
+
+def test_b5_rename_into_a_plane_folder_and_back_out_is_1(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "mv", "src/app.py", ".claude/app.py")
+ commit(repo, "move into the agent folder")
+ git(repo, "mv", ".claude/app.py", "src/app.py")
+ commit(repo, "move back")
+ _named(repo, capsys, ".claude/app.py")
+
+
+def _base_moves_on(repo):
+ """main changes a plane file after `pr` branched; the pull request's own commits never touch the plane."""
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr: ordinary")
+ git(repo, "checkout", "-q", "main")
+ write(repo, ".github/workflows/chock.yml", "name: changed on main\n")
+ commit(repo, "main: workflow")
+
+
+def test_b6_branch_that_merged_a_newer_base_is_0(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _base_moves_on(repo)
+ git(repo, "checkout", "-q", "pr")
+ _merge(repo, "main")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_b6_branch_made_before_the_base_changed_judged_as_merge_result_is_0(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _base_moves_on(repo)
+ git(repo, "checkout", "-q", "-b", "merge-ref")
+ _merge(repo, "pr")
+ code, out = run_floor(repo, capsys, "--head", "merge-ref")
+ assert code == 0, out
+
+
+def test_b7_revert_of_an_unrelated_commit_is_0(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: write(r, "src/app.py", "VALUE = 5\n"))
+ git(repo, *USER, "revert", "--no-edit", "HEAD")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_b7_cherry_pick_of_a_commit_outside_the_plane_is_0(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "-b", "other")
+ write(repo, "src/other.py", "OTHER = 1\n")
+ picked = commit(repo, "other: source only")
+ git(repo, "checkout", "-q", "pr")
+ git(repo, *USER, "cherry-pick", picked)
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_b8_octopus_merge_bringing_a_plane_change_reverted_later_is_1(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ for name, rel, content in (("a", SETTINGS, HOOKLESS), ("b", "src/b.py", "B = 1\n"), ("c", "src/c.py", "C = 1\n")):
+ git(repo, "checkout", "-q", "-b", name, "pr")
+ write(repo, rel, content)
+ commit(repo, f"{name}: change")
+ git(repo, "checkout", "-q", "pr")
+ _merge(repo, "a", "b", "c")
+ assert len(git(repo, "rev-parse", "HEAD^@").split()) == 4 # an octopus: pr and three branches
+ write(repo, SETTINGS, CLAUDE)
+ commit(repo, "revert the hooks change the octopus brought")
+ _named(repo, capsys, SETTINGS)
diff --git a/tests/test_floor_gate_links.py b/tests/test_floor_gate_links.py
new file mode 100644
index 00000000..e00e01e0
--- /dev/null
+++ b/tests/test_floor_gate_links.py
@@ -0,0 +1,161 @@
+"""Release gate G1, GT-1 links (S1), scenarios A1-A6: each test asserts the exit the plan owes.
+
+A link at or inside a control-plane folder must open a control-plane path, or nothing, at base and head; else the
+run is undecided (2) naming the link. A7-A11 are in test_floor_gate_links2.py."""
+
+from __future__ import annotations
+
+import pytest
+from floor_support import CLAUDE, base_repo, commit, git, run_floor, write
+from floor_support4 import FAKE_A, gitlink, raw_commit, rebase_main, rm, symlink, undecided
+
+PLANE_FILE = ".codex/settings.json"
+LIMIT = 32 # control_plane._MAX_HOPS: the most links one resolution may pass
+
+
+def pr_source(repo):
+ """A pull request touching only source, staged by path so a hand-made index entry survives."""
+ write(repo, "src/app.py", "VALUE = 2\n")
+ git(repo, "add", "src/app.py")
+ raw_commit(repo, "pr: source only")
+
+
+def raw_base(repo, change):
+ """`change(repo)` stages the base by hand (gitlinks, empty links); commit it on main, put `pr` on it."""
+ git(repo, "checkout", "-q", "main")
+ change(repo)
+ raw_commit(repo, "base edit")
+ git(repo, "checkout", "-q", "-B", "pr")
+
+
+def test_a1_link_between_plane_folders_with_source_only_pr_is_0(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ write(r, ".agents/skills/x/SKILL.md", "# x\n")
+ symlink(r, ".claude/skills", "../.agents/skills")
+
+ rebase_main(repo, base)
+ pr_source(repo)
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_a2_plane_link_to_ordinary_folder_at_base_is_2_naming_link_and_target(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: symlink(r, ".claude/x", "../src"))
+ pr_source(repo)
+ out = undecided(repo, capsys, ".claude/x")
+ assert "opens src, which is not control plane" in out, out
+
+
+def test_a3_plane_link_to_ordinary_folder_added_at_head_is_nonzero_naming_link(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ symlink(repo, ".claude/x", "../src")
+ commit(repo, "pr: link the agent folder to source")
+ code, out = run_floor(repo, capsys)
+ assert code != 0, out
+ assert ".claude/x" in out, out
+
+
+def _link(r, link, target):
+ if link == ".claude":
+ rm(r, ".claude")
+ git(r, "rm", "-q", "-r", "--cached", "--ignore-unmatch", ".claude")
+ symlink(r, link, target)
+ git(r, "add", "-A")
+
+
+def _chain(r, link, up, count):
+ """`link` -> c1 -> ... -> c -> .codex: `count` links in all, ending at a real plane folder."""
+ write(r, PLANE_FILE, CLAUDE)
+ _link(r, link, f"{up}c1" if count > 1 else f"{up}.codex")
+ for i in range(1, count):
+ symlink(r, f"c{i}", f"c{i + 1}" if i < count - 1 else ".codex")
+ git(r, "add", "-A")
+
+
+def _empty(r, link, _up):
+ _link(r, link, "placeholder")
+ empty = r.parent / "empty"
+ empty.write_bytes(b"")
+ oid = git(r, "hash-object", "-w", str(empty))
+ git(r, "update-index", "--cacheinfo", f"120000,{oid},{link}")
+
+
+def _submodule(r, link, up):
+ _link(r, link, f"{up}vendor/sub/x")
+ gitlink(r, "vendor/sub", FAKE_A)
+
+
+A4_UNRESOLVED = {
+ "absolute": (lambda r, link, _up: _link(r, link, "/etc/agent"), "absolute or empty target '/etc/agent'"),
+ "climbs-out": (lambda r, link, up: _link(r, link, f"{up}../outside"), "leaves the repository"),
+ "loop": (lambda r, link, _up: _link(r, link, link.rsplit("/", 1)[-1]), f"more than {LIMIT} links"),
+ "empty": (_empty, "absolute or empty target ''"),
+ "submodule": (_submodule, "passes through the submodule vendor/sub"),
+ "chain-over-limit": (lambda r, link, up: _chain(r, link, up, LIMIT + 1), f"more than {LIMIT} links"),
+}
+WHERE = {"at": (".claude", ""), "inside": (".claude/hooks", "../")}
+
+
+@pytest.mark.parametrize("where", list(WHERE))
+@pytest.mark.parametrize("case", list(A4_UNRESOLVED))
+def test_a4_plane_link_that_cannot_resolve_is_2(tmp_path, capsys, case, where):
+ build, why = A4_UNRESOLVED[case]
+ link, up = WHERE[where]
+ repo = base_repo(tmp_path)
+ raw_base(repo, lambda r: build(r, link, up))
+ pr_source(repo)
+ out = undecided(repo, capsys, link)
+ assert why in out, out
+
+
+@pytest.mark.parametrize("where", list(WHERE))
+def test_a4_chain_at_the_limit_ending_in_a_plane_path_is_0(tmp_path, capsys, where):
+ link, up = WHERE[where]
+ repo = base_repo(tmp_path)
+ raw_base(repo, lambda r: _chain(r, link, up, LIMIT))
+ pr_source(repo)
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+A5_SPELLINGS = {
+ "dot-slash": "./../.agents/skills",
+ "doubled-slashes": "..//.agents//skills",
+ "trailing-slash": "../.agents/skills/",
+ "climb-and-return": "../src/../.agents/skills",
+ "case-only": "../.AGENTS/Skills",
+}
+
+
+@pytest.mark.parametrize("case", list(A5_SPELLINGS))
+def test_a5_odd_spelling_of_a_plane_target_is_0(tmp_path, capsys, case):
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ write(r, ".agents/skills/x/SKILL.md", "# x\n")
+ symlink(r, ".claude/skills", A5_SPELLINGS[case])
+
+ rebase_main(repo, base)
+ pr_source(repo)
+ code, out = run_floor(repo, capsys)
+ assert code == 0, (case, out)
+
+
+def test_a6_dangling_plane_link_is_0(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: symlink(r, ".claude/hooks", "../cfg"))
+ pr_source(repo)
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_a6_target_absent_at_base_and_ordinary_at_head_is_2(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: symlink(r, ".claude/hooks", "../cfg"))
+ write(repo, "cfg/guard.sh", "#!/bin/sh\nexit 0\n")
+ commit(repo, "pr: fill the dangling target off the plane")
+ out = undecided(repo, capsys, ".claude/hooks")
+ assert "opens cfg, which is not control plane" in out, out
diff --git a/tests/test_floor_gate_links2.py b/tests/test_floor_gate_links2.py
new file mode 100644
index 00000000..1d2cd29c
--- /dev/null
+++ b/tests/test_floor_gate_links2.py
@@ -0,0 +1,152 @@
+"""Release gate G1, GT-1 links (S1), scenarios A7-A11: each test asserts the exit the plan owes."""
+
+from __future__ import annotations
+
+import time
+
+import pytest
+from floor_support import CLAUDE, base_repo, commit, git, run_floor, write
+from floor_support4 import FAKE_A, FAKE_B, gitlink, raw_commit, rebase_main, rm, symlink, undecided
+from test_floor_gate_links import pr_source, raw_base
+
+A11_LINKS = 2000
+A11_SECONDS = 60 # an explicit bound in place of a suite-wide pytest timeout, which this repository does not set
+
+
+def test_a7_link_at_an_ancestor_of_a_root_anchored_pattern_is_2(tmp_path, capsys):
+ """`.github -> gh`: the client opens gh/workflows/** as .github/workflows/**, and gh/ is not plane."""
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ (r / ".github").rename(r / "gh")
+ symlink(r, ".github", "gh")
+
+ rebase_main(repo, base)
+ pr_source(repo)
+ out = undecided(repo, capsys, ".github")
+ assert "opens gh, which is not control plane" in out, out
+
+
+def test_a7_link_whose_target_tree_holds_an_agent_folder_is_0(tmp_path, capsys):
+ """`pkg -> real` with `real/.claude/`: real/.claude/** is plane by itself, so the link opens only plane paths."""
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ write(r, "real/.claude/settings.json", CLAUDE)
+ symlink(r, "pkg", "real")
+
+ rebase_main(repo, base)
+ pr_source(repo)
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_a8_plane_folder_replaced_by_a_link_to_an_identical_copy_is_nonzero(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "copy/claude/settings.json", CLAUDE)
+ rm(repo, ".claude")
+ symlink(repo, ".claude", "copy/claude")
+ commit(repo, "pr: the agent folder becomes a link to the same bytes")
+ code, out = run_floor(repo, capsys)
+ assert code != 0, out
+ assert ".claude" in out, out
+
+
+def test_a9_ordinary_link_to_a_plane_file_is_0(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ symlink(repo, "docs/s", "../.claude/settings.json")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr: a docs link to the settings file")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_a10_submodule_added_at_a_plane_path_is_1_named(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ gitlink(repo, ".claude/shared", FAKE_A)
+ raw_commit(repo, "pr: add a submodule in the agent folder")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "\n .claude/shared\n" in out, out
+
+
+def _base_submodule(repo):
+ raw_base(repo, lambda r: gitlink(r, ".claude/shared", FAKE_A))
+
+
+def test_a10_unchanged_submodule_inside_the_plane_is_0(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _base_submodule(repo)
+ pr_source(repo)
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_a10_moved_submodule_pointer_inside_the_plane_is_1_named(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _base_submodule(repo)
+ gitlink(repo, ".claude/shared", FAKE_B)
+ raw_commit(repo, "pr: bump the submodule")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "\n .claude/shared\n" in out, out
+
+
+def test_a11_two_thousand_plane_links_within_the_plane_is_0_in_bounded_time(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ write(r, ".codex/settings.json", CLAUDE)
+ for i in range(A11_LINKS):
+ symlink(r, f".claude/links/l{i:04d}", "../../.codex/settings.json")
+
+ rebase_main(repo, base)
+ assert len(git(repo, "ls-files", ".claude/links").splitlines()) == A11_LINKS
+ pr_source(repo)
+ start = time.monotonic()
+ code, out = run_floor(repo, capsys)
+ elapsed = time.monotonic() - start
+ print(f"A11: {A11_LINKS} links, exit {code} in {elapsed:.1f}s")
+ assert code == 0, out[-800:]
+ assert elapsed < A11_SECONDS, elapsed
+
+
+def _real_and_other(r):
+ write(r, "real/.claude/settings.json", CLAUDE)
+ write(r, "other/.claude/settings.json", CLAUDE)
+
+
+A7_LINK_CHANGES = {
+ "added": (_real_and_other, lambda r: symlink(r, "pkg", "real")),
+ "removed": (lambda r: (_real_and_other(r), symlink(r, "pkg", "real")), lambda r: rm(r, "pkg")),
+ "retargeted": (lambda r: (_real_and_other(r), symlink(r, "pkg", "real")), lambda r: symlink(r, "pkg", "other")),
+}
+
+
+@pytest.mark.parametrize("case", list(A7_LINK_CHANGES))
+def test_a7_link_above_the_plane_is_itself_plane_when_changed(tmp_path, capsys, case):
+ """Orchestrator ruling on A7: the link above the plane counts as a hop, so adding, removing or retargeting it
+ (even to another folder holding an agent folder) is named."""
+ base, change = A7_LINK_CHANGES[case]
+ repo = base_repo(tmp_path)
+ rebase_main(repo, base)
+ change(repo)
+ commit(repo, f"pr: link {case}")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, (case, out)
+ assert "\n pkg\n" in out, (case, out)
+
+
+def test_a7_link_above_a_plane_path_whose_target_is_not_plane_is_2(tmp_path, capsys):
+ """Ruling on A7, condition 1: `p*/secret/**` covers pkg/secret/x but not real/secret/x, which pkg opens."""
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ write(r, ".chock/config.yaml", "floor:\n control_plane_paths:\n add: ['p*/secret/**']\n")
+ write(r, "real/secret/x", "x\n")
+ symlink(r, "pkg", "real")
+
+ rebase_main(repo, base)
+ pr_source(repo)
+ out = undecided(repo, capsys, "pkg")
+ assert "opens real, which is not control plane" in out, out
diff --git a/tests/test_floor_gate_ordinary.py b/tests/test_floor_gate_ordinary.py
new file mode 100644
index 00000000..aa89ea0b
--- /dev/null
+++ b/tests/test_floor_gate_ordinary.py
@@ -0,0 +1,72 @@
+"""Release gate G1, GT-2 ordinary pull requests: each touches no control-plane path and is owed exit 0."""
+
+from __future__ import annotations
+
+import random
+
+import pytest
+from floor_support import TEST_FILE, base_repo, commit, git, run_floor, write
+
+from chock.validation.floor_history import FLOOR_MAX_BLOB_BYTES
+
+
+def _bytes(repo, rel, data):
+ path = repo / rel
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_bytes(data)
+
+
+def _merge_base_into_branch(repo):
+ """main moves on (a source edit), the branch edits a test, then merges main in: the merge is the head."""
+ write(repo, "src/feature.py", "FEATURE = 1\n")
+ commit(repo, "pr: feature")
+ git(repo, "checkout", "-q", "main")
+ write(repo, "src/other.py", "OTHER = 1\n")
+ commit(repo, "main moves")
+ git(repo, "checkout", "-q", "pr")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@example.com", "merge", "-q", "--no-ff", "--no-edit", "main")
+
+
+def _revert(repo):
+ write(repo, "src/app.py", "VALUE = 3\n")
+ commit(repo, "pr: change")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@example.com", "revert", "--no-edit", "HEAD")
+
+
+GENERATED = b"generated_value_0123456789 = 'abcdefghijklmnopqrstuvwxyz'\n" * (4 * 2**20 // 58)
+
+CASES = {
+ "source-edit": lambda r: write(r, "src/app.py", "VALUE = 2\n"),
+ "new-test-file": lambda r: write(r, "tests/test_new.py", "def test_b():\n assert 3 > 2\n"),
+ "test-gains-assertions": lambda r: write(r, "tests/test_core.py", TEST_FILE + " assert 3 * 3 == 9\n"),
+ "docs-edit": lambda r: write(r, "docs/guide.md", "# Guide\n\nHow to run it.\n"),
+ "lockfile-bump": lambda r: write(r, "uv.lock", 'version = 1\n[[package]]\nname = "x"\nversion = "1.1"\n'),
+ "new-directory": lambda r: write(r, "pkg/sub/mod.py", "X = 1\n"),
+ "binary-asset": lambda r: _bytes(r, "assets/logo.png", b"\x89PNG\r\n\x1a\n" + random.Random(7).randbytes(65536)), # noqa: S311
+ "large-generated-file": lambda r: _bytes(r, "src/generated_table.py", GENERATED),
+ "crlf-file": lambda r: _bytes(r, "src/win.py", b"A = 1\r\nB = 2\r\n"),
+ "bom-file": lambda r: _bytes(r, "src/bom.py", b"\xef\xbb\xbfA = 1\n"),
+}
+
+
+@pytest.mark.parametrize("name", list(CASES))
+def test_ordinary_pull_request_is_clean(tmp_path, capsys, name):
+ repo = base_repo(tmp_path)
+ CASES[name](repo)
+ commit(repo, f"pr: {name}")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "floor/control-plane-changed" not in out, out
+
+
+def test_ordinary_large_generated_file_is_under_the_limit():
+ assert 2**20 < len(GENERATED) < FLOOR_MAX_BLOB_BYTES # large, and judged rather than skipped
+
+
+@pytest.mark.parametrize("build", [_merge_base_into_branch, _revert], ids=["merge-of-base", "revert-commit"])
+def test_ordinary_history_shapes_are_clean(tmp_path, capsys, build):
+ repo = base_repo(tmp_path)
+ build(repo)
+ code, out = run_floor(repo, capsys, "--head", "pr")
+ assert code == 0, out
+ assert "floor/control-plane-changed" not in out, out
diff --git a/tests/test_floor_gate_patterns.py b/tests/test_floor_gate_patterns.py
new file mode 100644
index 00000000..0f2a10a7
--- /dev/null
+++ b/tests/test_floor_gate_patterns.py
@@ -0,0 +1,87 @@
+"""Release gate G1, GT-2 patterns (S4): D1-D6. Each case builds B and H with the floor fixtures and asserts the owed exit."""
+
+from __future__ import annotations
+
+import pytest
+from floor_support import CONTROL_PLANE, base_repo, commit, run_floor, write
+from floor_support4 import HOOKLESS, rebase_main
+
+
+def _changed(tmp_path, capsys, path, content="{}\n"):
+ repo = base_repo(tmp_path)
+ write(repo, path, content)
+ commit(repo, "pr")
+ return run_floor(repo, capsys)
+
+
+@pytest.mark.parametrize("path", [".claude/settings.json", "pkg/.claude/settings.json", "a/b/c/.codex/config.toml"])
+def test_d1_agent_config_at_any_depth_is_refused_and_named(tmp_path, capsys, path):
+ code, out = _changed(tmp_path, capsys, path, '{"hooks": {}}\n')
+ assert code == 1, out
+ assert f"FAIL {CONTROL_PLANE} (refuse)" in out, out
+ assert f"\n {path}\n" in out, out
+
+
+@pytest.mark.parametrize(
+ ("path", "pattern"),
+ [("node_modules/x/.claude/settings.json", "**/.claude/**"), ("tests/fixtures/.cursor/hooks.json", "**/.cursor/**")],
+)
+def test_d2_a_deep_match_names_the_path_and_the_pattern(tmp_path, capsys, path, pattern):
+ """The stated cost of matching at any depth: a vendored or fixture agent folder is refused, and says why."""
+ code, out = _changed(tmp_path, capsys, path)
+ assert code == 1, out
+ assert f"\n {path}\n" in out, out
+ assert f" matched {pattern}\n" in out, out
+
+
+@pytest.mark.parametrize(
+ ("path", "owed"),
+ [
+ (".env", 1),
+ ("sub/.env", 1),
+ (".ENV", 1), # matched case-blind
+ (".env.local", 0),
+ (".env.example", 0),
+ # The list folds every name as Windows opens it, dropping a trailing dot or space (control_plane.folded),
+ # so `.env.` and `.env ` are `.env`: 1.
+ (".env.", 1),
+ (".env ", 1),
+ ],
+)
+def test_d3_env_files(tmp_path, capsys, path, owed):
+ code, out = _changed(tmp_path, capsys, path, "TOKEN=x\n")
+ assert code == owed, out
+ if owed:
+ assert f"\n {path}\n" in out, out
+
+
+@pytest.mark.parametrize("path", [".devcontainer.json", ".devcontainer/devcontainer.json", ".devcontainer/sub/x"])
+def test_d4_devcontainer(tmp_path, capsys, path):
+ code, out = _changed(tmp_path, capsys, path)
+ assert code == 1, out
+ assert f"\n {path}\n" in out, out
+
+
+def _config(tmp_path, text):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: write(r, ".chock/config.yaml", text))
+ return repo
+
+
+def test_d5_removing_the_old_style_pattern_is_undecided_and_names_the_one_to_write(tmp_path, capsys):
+ repo = _config(tmp_path, "floor:\n control_plane_paths:\n remove: ['.claude/**']\n")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "'.claude/**'" in out and "write '**/.claude/**'" in out, out
+
+
+def test_d6_removing_the_any_depth_pattern_lets_the_change_through_and_says_so(tmp_path, capsys):
+ repo = _config(tmp_path, "floor:\n control_plane_paths:\n remove: ['**/.claude/**']\n")
+ write(repo, ".claude/settings.json", HOOKLESS)
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "control plane: refuse, " in out and "base removed: **/.claude/**" in out, out
+ assert ".claude/settings.json" not in out, out
diff --git a/tests/test_floor_review3_exit.py b/tests/test_floor_review3_exit.py
new file mode 100644
index 00000000..3cf110a0
--- /dev/null
+++ b/tests/test_floor_review3_exit.py
@@ -0,0 +1,200 @@
+"""Review 3 of the floor (W2-A1v2.1 L3, L4, L6, L7): fault paths, ordinary pull requests, no head file runs."""
+
+from __future__ import annotations
+
+import os
+import shutil
+from pathlib import Path
+
+import pytest
+from floor_support import PROBE, TEST_FILE, base_repo, commit, git, run_floor, write
+
+from chock.validation import checks_floor, control_plane, floor_git
+from chock.validation.checks_floor import main as floor_main
+
+_IDENT = ("-c", "user.name=t", "-c", "user.email=t@example.com")
+
+
+def _drop_object(repo: Path, oid: str) -> None:
+ (repo / ".git/objects" / oid[:2] / oid[2:]).unlink()
+
+
+def _base_without(tmp_path: Path, *policies: str) -> Path:
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ for policy in policies:
+ shutil.rmtree(repo / ".chock/compiled" / policy)
+ commit(repo, f"base: without {', '.join(policies)}")
+ git(repo, "checkout", "-q", "-B", "pr")
+ return repo
+
+
+@pytest.mark.parametrize("without", [("floor-token", "test-integrity"), ()])
+def test_an_unreadable_head_blob_is_undecided(tmp_path, capsys, without):
+ """L3: with a script gate only (no history pass) as with content gates, never '' handed to a gate."""
+ repo = _base_without(tmp_path, *without) if without else base_repo(tmp_path)
+ write(repo, "src/new.py", "print('x')\n")
+ commit(repo, "pr")
+ _drop_object(repo, git(repo, "rev-parse", "HEAD:src/new.py"))
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "src/new.py" in out, out
+
+
+@pytest.mark.parametrize("below", ["src", "tests"])
+def test_repo_given_as_a_subdirectory_still_sees_removed_assertions(tmp_path, capsys, below):
+ """L4: a workflow with `working-directory:` set, or --repo below the top level."""
+ repo = base_repo(tmp_path)
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ commit(repo, "pr")
+ code = checks_floor.main(["--repo", str(repo / below), "--base", "main"])
+ out = capsys.readouterr()
+ assert code == 1, out.out + out.err
+ assert "test-integrity" in out.out, out.out
+
+
+def test_repo_outside_any_repository_is_undecided(tmp_path, capsys):
+ (tmp_path / "plain").mkdir()
+ code = checks_floor.main(["--repo", str(tmp_path / "plain"), "--base", "main"])
+ assert code == 2, capsys.readouterr()
+
+
+def test_keyboard_interrupt_never_returns_zero(tmp_path, monkeypatch):
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+
+ def boom(*_a, **_k):
+ raise KeyboardInterrupt
+
+ monkeypatch.setattr(floor_git, "changed_paths", boom)
+ monkeypatch.setattr(control_plane, "changed_paths", boom)
+ with pytest.raises(KeyboardInterrupt):
+ checks_floor.main(["--repo", str(repo), "--base", "main"])
+
+
+def _ordinary(repo: Path, change: str) -> None:
+ if change == "source":
+ write(repo, "src/app.py", "VALUE = 2\n")
+ elif change == "test-added":
+ write(repo, "tests/test_more.py", "def test_b():\n assert True\n")
+ elif change == "docs":
+ write(repo, "docs/guide.md", "# Guide\n")
+ elif change == "dependency":
+ write(repo, "requirements.txt", "requests==2.32.3\n")
+ elif change == "instructions":
+ write(repo, "AGENTS.md", "# Rules\n")
+ elif change == "rename-source":
+ git(repo, "mv", "src/app.py", "src/core.py")
+ commit(repo, change)
+
+
+@pytest.mark.parametrize("change", ["source", "test-added", "docs", "dependency", "instructions", "rename-source"])
+def test_ordinary_pull_request_passes(tmp_path, capsys, change):
+ """V7. rename-source runs without the fixture's probe gate, which refuses every deletion by design."""
+ repo = _base_without(tmp_path, "probe") if change == "rename-source" else base_repo(tmp_path)
+ _ordinary(repo, change)
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+@pytest.mark.parametrize("dest", ["tests/test_main.py", "tests/unit/test_core.py"])
+def test_renaming_or_moving_a_test_file_is_refused_as_a_deletion(tmp_path, capsys, dest):
+ """L6, a stated cost: --no-renames reads the move as a deleted test file."""
+ repo = _base_without(tmp_path, "probe")
+ (repo / dest).parent.mkdir(parents=True, exist_ok=True)
+ git(repo, "mv", "tests/test_core.py", dest)
+ commit(repo, "move")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "test-integrity" in out, out
+
+
+def test_history_pass_reads_a_rename_as_a_delete_and_an_add(tmp_path, capsys):
+ """L5: a secret moved in one commit and removed in the next is judged at the path it was added under."""
+ repo = _base_without(tmp_path, "probe", "test-integrity")
+ write(repo, "src/a.txt", "key = FLOOR-TOKEN-7\n")
+ commit(repo, "add")
+ git(repo, "mv", "src/a.txt", "src/b.txt")
+ commit(repo, "move")
+ git(repo, "rm", "-q", "src/b.txt")
+ commit(repo, "drop")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "src/a.txt" in out, out
+
+
+def test_branch_that_merged_an_advanced_base_passes(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/feature.py", "X = 1\n")
+ commit(repo, "pr work")
+ git(repo, "checkout", "-q", "main")
+ write(repo, ".github/workflows/chock.yml", "name: changed by a maintainer\n")
+ commit(repo, "base advanced")
+ git(repo, "checkout", "-q", "pr")
+ git(repo, *_IDENT, "merge", "-q", "--no-edit", "main")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_merge_result_against_advanced_base_passes(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/feature.py", "X = 1\n")
+ commit(repo, "pr work")
+ git(repo, "checkout", "-q", "main")
+ write(repo, ".github/workflows/chock.yml", "name: changed by a maintainer\n")
+ write(repo, "tests/test_core.py", TEST_FILE.replace(" assert 2 * 2 == 4\n", ""))
+ commit(repo, "base advanced (a maintainer trimmed a test)")
+ git(repo, "checkout", "-q", "-b", "merge-ref")
+ git(repo, *_IDENT, "merge", "-q", "--no-edit", "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def _marker_py(marks: Path, name: str) -> str:
+ return f"import pathlib\npathlib.Path({str(marks / name)!r}).write_text('ran')\n"
+
+
+def _marker_sh(marks: Path, name: str) -> str:
+ return f"#!/bin/sh\necho ran > {marks / name}\ncat\n"
+
+
+@pytest.mark.parametrize("checkout", ["head", "base"])
+def test_no_head_file_runs(tmp_path, capsys, checkout):
+ marks = tmp_path / "marks"
+ marks.mkdir()
+ repo = base_repo(tmp_path)
+ write(repo, PROBE["params"]["script"], _marker_py(marks, "head-probe"))
+ write(repo, ".agents/policies/probe/implementations/sitecustomize.py", _marker_py(marks, "head-site-impl"))
+ for rel, name in (("sitecustomize.py", "site"), ("usercustomize.py", "usersite"), ("json.py", "json")):
+ write(repo, rel, _marker_py(marks, name))
+ write(repo, ".chock/bin/gate.py", _marker_py(marks, "head-runner"))
+ write(repo, ".chock/compiled/evil/ci-gate/gate.json",
+ {"kind": "script", "on": ["commit"], "action": "block", "message": "m",
+ "params": {"script": "evil.py"}, "script_base": "gate"}) # fmt: skip
+ write(repo, ".chock/compiled/evil/ci-gate/evil.py", _marker_py(marks, "head-gate"))
+ write(repo, ".gitattributes", "* diff=evil filter=evil\n")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ write(repo, ".githooks/post-checkout", _marker_sh(marks, "hook"))
+ commit(repo, "pr")
+ args = ["--repo", str(repo), "--base", "main"]
+ if checkout == "base":
+ git(repo, "checkout", "-q", "main")
+ args += ["--head", "pr"]
+ for name in ("textconv", "diffcmd", "clean", "smudge", "process", "fsmonitor"):
+ script = tmp_path / f"{name}.sh"
+ script.write_text(_marker_sh(marks, name))
+ script.chmod(0o755)
+ for key, name in (("diff.evil.textconv", "textconv"), ("diff.evil.command", "diffcmd"),
+ ("filter.evil.clean", "clean"), ("filter.evil.smudge", "smudge"),
+ ("filter.evil.process", "process"), ("core.fsmonitor", "fsmonitor")): # fmt: skip
+ git(repo, "config", key, str(tmp_path / f"{name}.sh"))
+ cwd = os.getcwd()
+ os.chdir(repo)
+ try:
+ code = floor_main(args)
+ finally:
+ os.chdir(cwd)
+ out = capsys.readouterr()
+ assert sorted(p.name for p in marks.iterdir()) == [], out.out + out.err
+ assert code == 1, out.out + out.err
diff --git a/tests/test_floor_review3_plane.py b/tests/test_floor_review3_plane.py
new file mode 100644
index 00000000..ebe54179
--- /dev/null
+++ b/tests/test_floor_review3_plane.py
@@ -0,0 +1,190 @@
+"""Review 3 of the floor (W2-A1v2.1 L1, L2, L5, L7): guardrail files the list missed, symlinks, the list in force."""
+
+from __future__ import annotations
+
+import os
+
+import pytest
+from floor_support import CONTROL_PLANE, base_repo, commit, git, run_floor, write
+
+GATEWAY_MCP = {
+ "mcpServers": {"fetch": {"command": "chock", "args": ["gateway", "run", "--repo", ".", "--", "fetch-mcp"]}}
+}
+UNWRAPPED_MCP = {"mcpServers": {"fetch": {"command": "fetch-mcp"}}}
+SKILL_HOOK = (
+ "---\nname: x\ndescription: x\nhooks:\n PreToolUse:\n - matcher: Bash\n hooks:\n"
+ " - type: command\n command: ./rewrite-input.sh\n---\nbody\n"
+)
+GEMINI_OFF = {"hooksConfig": {"enabled": False}, "tools": {"allowed": ["run_shell_command"]}}
+
+
+def _pr(repo, files):
+ for rel, content in files.items():
+ write(repo, rel, content)
+ commit(repo, "pr")
+
+
+def _refused(repo, capsys, *paths: str) -> str:
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert f"{CONTROL_PLANE} (refuse)" in out, out
+ for path in paths:
+ assert f"\n {path}\n" in out, f"{path} not listed\n{out}"
+ return out
+
+
+def _undecided(repo, capsys, link: str) -> str:
+ """S1: a control-plane link that opens a path off the control plane is undecided, naming the link and the fix."""
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert f"symbolic link {link} at" in out, out
+ assert "floor.control_plane_paths.add" in out or "replace the link with real files" in out, out
+ return out
+
+
+@pytest.mark.parametrize("rel", [".mcp.json", ".cursor/mcp.json", ".vscode/mcp.json"])
+def test_unwrapping_the_mcp_gateway_is_named(tmp_path, capsys, rel):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ _pr(repo, {rel: GATEWAY_MCP})
+ git(repo, "checkout", "-q", "-B", "pr")
+ _pr(repo, {rel: UNWRAPPED_MCP})
+ _refused(repo, capsys, rel)
+
+
+@pytest.mark.parametrize(
+ ("rel", "content"),
+ [
+ (".cursor/cli.json", {"permissions": {"allow": ["Shell(*)"], "deny": []}}),
+ (".vscode/settings.json", {"chat.hookFilesLocations": {"elsewhere": True}, "chat.useClaudeHooks": False}),
+ (".gemini/.env", "PATH=/tmp/evil:/usr/bin\n"),
+ (".env", "PYTHONPATH=/tmp/evil\n"),
+ ("pkg/.env", "PYTHONPATH=/tmp/evil\n"),
+ (".claude/skills/x/SKILL.md", SKILL_HOOK),
+ (".claude/agents/x.md", SKILL_HOOK),
+ (".github/agents/x.agent.md", SKILL_HOOK),
+ ],
+)
+def test_other_hook_permission_or_env_files_are_named(tmp_path, capsys, rel, content):
+ repo = base_repo(tmp_path)
+ _pr(repo, {rel: content})
+ _refused(repo, capsys, rel)
+
+
+def test_symlinked_vendor_folder_adds_a_settings_file_named(tmp_path, capsys):
+ """`.gemini -> cfg` then `cfg/settings.json`: the client opens `.gemini/settings.json`."""
+ repo = base_repo(tmp_path)
+ write(repo, "cfg/settings.json", GEMINI_OFF)
+ os.symlink("cfg", repo / ".gemini")
+ commit(repo, "pr")
+ _undecided(repo, capsys, ".gemini")
+
+
+def test_a_base_symlinked_vendor_folder_makes_its_target_control_plane(tmp_path, capsys):
+ """The link is at the base and unchanged; the pull request edits only the target."""
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ write(repo, "cfg/settings.json", {"hooksConfig": {"enabled": True}})
+ os.symlink("cfg", repo / ".gemini")
+ commit(repo, "base: linked settings")
+ git(repo, "checkout", "-q", "-B", "pr")
+ _pr(repo, {"cfg/settings.json": GEMINI_OFF})
+ _undecided(repo, capsys, ".gemini")
+
+
+def test_a_base_link_whose_target_the_base_adds_to_the_plane_lists_the_target(tmp_path, capsys):
+ """The fix S1 names: the base puts the link's target on its own list, so an edit there is listed."""
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ write(repo, "cfg/settings.json", {"hooksConfig": {"enabled": True}})
+ os.symlink("cfg", repo / ".gemini")
+ write(repo, ".chock/config.yaml", "floor:\n control_plane_paths:\n add: [cfg/]\n")
+ commit(repo, "base: linked settings, target listed")
+ git(repo, "checkout", "-q", "-B", "pr")
+ _pr(repo, {"cfg/settings.json": GEMINI_OFF})
+ out = _refused(repo, capsys, "cfg/settings.json")
+ assert "\n .gemini\n" not in out, out
+
+
+def test_a_chain_of_symlinks_is_followed(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ os.symlink("a", repo / ".codex")
+ os.symlink("b", repo / "a")
+ write(repo, "b/keep.txt", "x\n")
+ commit(repo, "base: links")
+ git(repo, "checkout", "-q", "-B", "pr")
+ _pr(repo, {"b/hooks.json": {"hooks": {}}})
+ _undecided(repo, capsys, ".codex")
+
+
+def test_a_vendor_folder_linked_to_the_root_makes_the_root_control_plane(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ os.symlink(".", repo / ".windsurf")
+ commit(repo, "base: link to the root")
+ git(repo, "checkout", "-q", "-B", "pr")
+ _pr(repo, {"hooks.json": {"hooks": {}}})
+ _undecided(repo, capsys, ".windsurf")
+
+
+def test_a_symlink_out_of_the_repository_is_undecided(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ os.symlink("../elsewhere", repo / ".gemini")
+ commit(repo, "base: link out")
+ git(repo, "checkout", "-q", "-B", "pr")
+ _pr(repo, {"src/app.py": "VALUE = 2\n"})
+ out = _undecided(repo, capsys, ".gemini")
+ assert "leaves the repository" in out, out
+
+
+def test_gitlink_at_a_vendor_folder_is_named(tmp_path, capsys):
+ """A submodule mounted at `.codex` supplies `.codex/hooks.json` on a recursive clone."""
+ repo = base_repo(tmp_path)
+ sha = git(repo, "rev-parse", "HEAD")
+ git(repo, "update-index", "--add", "--cacheinfo", f"160000,{sha},.codex")
+ write(repo, ".gitmodules", '[submodule "c"]\n\tpath = .codex\n\turl = https://example.com/x.git\n')
+ git(repo, "add", ".gitmodules")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@example.com", "commit", "-q", "--no-gpg-sign", "-m", "pr")
+ _refused(repo, capsys, ".codex")
+
+
+def test_listed_mode_states_a_narrowed_list(tmp_path, capsys):
+ """A base that removed a default pattern: a later workflow edit passes, and the output says the list was narrowed."""
+ repo = base_repo(tmp_path, "listed")
+ git(repo, "checkout", "-q", "main")
+ write(
+ repo,
+ ".chock/config.yaml",
+ "floor:\n control_plane: refuse\n control_plane_paths:\n remove: ['.github/workflows/**']\n",
+ )
+ commit(repo, "base narrows")
+ git(repo, "checkout", "-q", "-B", "pr")
+ _pr(repo, {".github/workflows/chock.yml": "name: x\non: push\njobs: {}\n"})
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "control plane: refuse," in out, out
+ assert "base removed: .github/workflows/**" in out, out
+
+
+@pytest.mark.parametrize("mode", ["refuse", "listed"])
+def test_mode_and_size_are_stated_when_nothing_is_listed(tmp_path, capsys, mode):
+ repo = base_repo(tmp_path, mode)
+ _pr(repo, {"src/app.py": "VALUE = 2\n"})
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert f"control plane: {mode}, " in out, out
+ assert "pattern(s); base added: none; base removed: none" in out, out
+
+
+def test_a_removal_that_names_no_default_pattern_is_undecided(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ write(repo, ".chock/config.yaml", "floor:\n control_plane_paths:\n remove: ['.github/workflow/**']\n")
+ commit(repo, "base: typo")
+ git(repo, "checkout", "-q", "-B", "pr")
+ _pr(repo, {"src/app.py": "VALUE = 2\n"})
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "which is no default pattern" in out, out
diff --git a/tests/test_floor_review4_config.py b/tests/test_floor_review4_config.py
new file mode 100644
index 00000000..92088083
--- /dev/null
+++ b/tests/test_floor_review4_config.py
@@ -0,0 +1,109 @@
+"""Review 4, L5: the base's floor config. Each case asserts the owed exit and checks the 'in force' line."""
+
+from __future__ import annotations
+
+import pytest
+from floor_support import base_repo, commit, run_floor, write
+from floor_support4 import HOOKLESS, rebase_main
+
+
+def _with_config(tmp_path, text):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: write(r, ".chock/config.yaml", text))
+ return repo
+
+
+CASES = [
+ # (id, config text, change, owed exit, text the in-force line must hold or None)
+ ("remove-other-case", "floor:\n control_plane_paths:\n remove: ['.CLAUDE/**']\n", "claude", 2, None),
+ ("remove-trailing-slash", "floor:\n control_plane_paths:\n remove: ['.claude/**/']\n", "claude", 2, None),
+ (
+ "remove-exact",
+ "floor:\n control_plane_paths:\n remove: ['**/.claude/**']\n",
+ "claude",
+ 0,
+ "base removed: **/.claude/**",
+ ),
+ ("add-everything", "floor:\n control_plane_paths:\n add: ['*']\n", "src", 1, "base added: *"),
+ ("add-empty-string", "floor:\n control_plane_paths:\n add: ['']\n", "src", 2, None),
+ ("add-non-string", "floor:\n control_plane_paths:\n add: [1]\n", "src", 2, None),
+ ("mode-capitalised", "floor:\n control_plane: Listed\n", "claude", 2, None),
+ ("mode-bool", "floor:\n control_plane: yes\n", "claude", 2, None),
+ ("mode-null", "floor:\n control_plane:\n", "claude", 2, None),
+ ("mode-list", "floor:\n control_plane: [listed]\n", "claude", 2, None),
+ (
+ "dup-key-last-wins",
+ "floor:\n control_plane: refuse\n control_plane: listed\n",
+ "claude",
+ 0,
+ "control plane: listed",
+ ),
+ (
+ "dup-section",
+ "floor:\n control_plane: listed\nfloor:\n control_plane: refuse\n",
+ "claude",
+ 1,
+ "control plane: refuse",
+ ),
+ ("anchor-merge", "x: &m\n control_plane: listed\nfloor:\n <<: *m\n", "claude", 0, "control plane: listed"),
+ ("not-yaml", "floor: [\n", "claude", 2, None),
+ ("floor-is-list", "floor: [1]\n", "claude", 2, None),
+ ("paths-is-list", "floor:\n control_plane_paths: ['x']\n", "claude", 2, None),
+ ("paths-unknown-key", "floor:\n control_plane_paths:\n drop: ['x']\n", "claude", 2, None),
+ ("bom", "floor:\n control_plane: listed\n", "claude", 0, "control plane: listed"),
+ ("tab-indent", "floor:\n\tcontrol_plane: listed\n", "claude", 2, None),
+ ("top-level-list", "- floor\n", "claude", 1, "control plane: refuse"),
+ ("upper-section", "Floor:\n control_plane: listed\n", "claude", 1, "control plane: refuse"),
+ ("deep-nesting", "floor:\n x: " + "[" * 20000 + "]" * 20000 + "\n", "claude", 2, None),
+]
+
+
+@pytest.mark.parametrize(("config", "change", "owed", "line"), [c[1:] for c in CASES], ids=[c[0] for c in CASES])
+def test_base_config(tmp_path, capsys, config, change, owed, line):
+ repo = _with_config(tmp_path, config)
+ if change == "claude":
+ write(repo, ".claude/settings.json", HOOKLESS)
+ else:
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == owed, out
+ if line:
+ assert line in out, out
+
+
+@pytest.mark.parametrize(
+ ("pat", "owed", "said"),
+ [
+ ("infra", 2, "write 'infra/**' for the folder"), # S5: a bare folder name asks for name/**
+ ("infra/", 1, "base added: infra/;"), # S5: a trailing slash is the folder and everything in it
+ ("/infra/**", 0, "base added: /infra/** (matches nothing at base or head)"), # S5: never shown as matching
+ ],
+)
+def test_add_folder_forms(tmp_path, capsys, pat, owed, said):
+ """m1: `add: [infra]`, `[infra/]` or `[/infra/**]`; each is either the folder, a question, or shown as matching nothing."""
+ repo = _with_config(tmp_path, f"floor:\n control_plane_paths:\n add: ['{pat}']\n")
+ write(repo, "infra/deploy.sh", "rm -rf /\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == owed, out
+ assert said in out, out
+
+
+def test_listed_mode_content_gap_is_stated(tmp_path, capsys):
+ """V3: under listed, a floor token inside a control-plane file passes, and the output says it was not judged."""
+ repo = _with_config(tmp_path, "floor:\n control_plane: listed\n")
+ write(repo, ".claude/settings.local.json", '{"x": "FLOOR-TOKEN-1"}\n')
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "not judged" in out, out
+
+
+def test_base_add_pattern_judged_by_content_gate_under_listed(tmp_path, capsys):
+ repo = _with_config(tmp_path, "floor:\n control_plane: listed\n control_plane_paths:\n add: ['src/**']\n")
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-7'\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ assert "not judged" in out and "src/app.py" in out, out
diff --git a/tests/test_floor_review4_exit.py b/tests/test_floor_review4_exit.py
new file mode 100644
index 00000000..43ad24d8
--- /dev/null
+++ b/tests/test_floor_review4_exit.py
@@ -0,0 +1,238 @@
+"""Review 4: abnormal paths (L3, L4, item 5). None may end as 0; SARIF and text must agree."""
+
+from __future__ import annotations
+
+import json
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+import zlib
+from pathlib import Path
+
+from floor_support import base_repo, commit, git, run_floor, write
+from floor_support4 import rebase_main
+
+from chock.validation import checks_floor
+
+W = Path(__file__).resolve().parents[1] / "floor-review"
+
+
+def _obj(repo: Path, oid: str) -> Path:
+ return repo / ".git/objects" / oid[:2] / oid[2:]
+
+
+def _corrupt(repo: Path, oid: str, how: str) -> None:
+ path = _obj(repo, oid)
+ os.chmod(path, 0o600) # writable by the owner, so the object can be corrupted
+ raw = zlib.decompress(path.read_bytes())
+ if how == "garbage":
+ path.write_bytes(b"not zlib at all")
+ elif how == "truncated":
+ path.write_bytes(zlib.compress(raw)[:-6])
+ elif how == "wrong-type":
+ body = raw.split(b"\0", 1)[1]
+ path.write_bytes(zlib.compress(b"tree %d\0" % len(body) + body))
+ elif how == "wrong-size":
+ body = raw.split(b"\0", 1)[1]
+ path.write_bytes(zlib.compress(b"blob %d\0" % (len(body) + 50) + body))
+
+
+def _script_only(tmp_path: Path) -> Path:
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ for policy in ("floor-token", "test-integrity"):
+ shutil.rmtree(r / ".chock/compiled" / policy)
+
+ rebase_main(repo, base)
+ return repo
+
+
+def test_corrupt_head_blob_every_way(tmp_path, capsys):
+ for how in ("garbage", "truncated", "wrong-type"): # wrong-size: git returns the true bytes (rc 0); not a finding
+ for shape in ("content", "script"):
+ repo = (base_repo if shape == "content" else _script_only)(tmp_path / f"{how}-{shape}")
+ write(repo, "src/new.py", "print('x')\n")
+ commit(repo, "pr")
+ _corrupt(repo, git(repo, "rev-parse", "HEAD:src/new.py"), how)
+ code, out = run_floor(repo, capsys)
+ assert code == 2, (how, shape, out)
+
+
+def test_corrupt_head_tree(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/new.py", "print('x')\n")
+ commit(repo, "pr")
+ _corrupt(repo, git(repo, "rev-parse", "HEAD:src"), "garbage")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+
+
+def test_corrupt_base_config_blob(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: write(r, ".chock/config.yaml", "floor:\n control_plane: listed\n"))
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ _corrupt(repo, git(repo, "rev-parse", "main:.chock/config.yaml"), "garbage")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+
+
+def test_invalid_json_gate_at_base(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ rebase_main(repo, lambda r: write(r, ".chock/compiled/floor-token/ci-gate/gate.json", "{not json"))
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+
+
+def test_git_missing_from_path(tmp_path):
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ env = {"PATH": str(tmp_path / "empty"), "HOME": os.environ["HOME"], "PYTHONPATH": os.environ.get("PYTHONPATH", "")}
+ proc = subprocess.run(
+ [
+ sys.executable,
+ "-c",
+ "import sys; from chock.validation.checks_floor import main; sys.exit(main(sys.argv[1:]))",
+ "--repo",
+ str(repo),
+ "--base",
+ "main",
+ ],
+ env=env,
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+ assert proc.returncode == 2, proc.stdout + proc.stderr
+
+
+def test_temp_dir_full(tmp_path, capsys, monkeypatch):
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+
+ def full(*_a, **_k):
+ raise OSError(28, "No space left on device")
+
+ monkeypatch.setattr(tempfile, "TemporaryDirectory", full)
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+
+
+def test_unusable_tmpdir_env(tmp_path):
+ repo = base_repo(tmp_path)
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ commit(repo, "pr")
+ bad = tmp_path / "ro"
+ bad.mkdir()
+ bad.chmod(0o500)
+ env = {**os.environ, "TMPDIR": str(bad / "missing")}
+ proc = subprocess.run(
+ [
+ sys.executable,
+ "-c",
+ "import sys; from chock.validation.checks_floor import main; sys.exit(main(sys.argv[1:]))",
+ "--repo",
+ str(repo),
+ "--base",
+ "main",
+ ],
+ env=env,
+ capture_output=True,
+ text=True,
+ check=False,
+ )
+ assert proc.returncode in (1, 2), proc.stdout + proc.stderr
+
+
+def test_sarif_unwritable_targets(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ (tmp_path / "adir").mkdir()
+ for target in (tmp_path / "missing/x.sarif", tmp_path / "adir"):
+ code, out = run_floor(repo, capsys, "--sarif", str(target))
+ assert code == 2, (target, out)
+
+
+def test_sarif_agrees_with_exit_on_every_outcome(tmp_path, capsys):
+ """refuse+listed -> error results; listed -> note results and exit 0; undecided -> executionSuccessful false."""
+ repo = base_repo(tmp_path)
+ write(repo, ".claude/settings.json", "{}\n")
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ commit(repo, "pr")
+ sarif = tmp_path / "o.sarif"
+ code, _ = run_floor(repo, capsys, "--sarif", str(sarif))
+ doc = json.loads(sarif.read_text())
+ levels = {r["level"] for r in doc["runs"][0]["results"]}
+ assert code == 1 and levels == {"error"}, (code, levels)
+
+
+def test_an_undecided_run_replaces_a_stale_sarif(tmp_path, capsys):
+ """S6: the output path holds a clean SARIF (as a head checkout could); an undecided run overwrites it."""
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ sarif = tmp_path / "o.sarif"
+ sarif.write_text(json.dumps({"version": "2.1.0", "runs": [{"results": []}]}))
+ code = checks_floor.main(["--repo", str(repo), "--base", "no-such-ref", "--sarif", str(sarif)])
+ capsys.readouterr()
+ assert code == 2
+ doc = json.loads(sarif.read_text())
+ invocation = doc["runs"][0]["invocations"][0]
+ assert invocation["executionSuccessful"] is False, doc
+ assert "does not resolve" in invocation["toolExecutionNotifications"][0]["message"]["text"], doc
+
+
+def test_repo_forms(tmp_path, capsys):
+ repo = base_repo(tmp_path / "with space")
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ commit(repo, "pr")
+ link = tmp_path / "link"
+ os.symlink(repo, link)
+ wt = tmp_path / "wt dir"
+ git(repo, "worktree", "add", "-q", "--detach", str(wt), "pr")
+ (repo / "src/deep/er").mkdir(parents=True)
+ for form in (repo, link, link / "src", wt, wt / "tests", repo / "src/deep/er"):
+ code = checks_floor.main(["--repo", str(form), "--base", "main", "--head", "pr"])
+ out = capsys.readouterr()
+ assert code == 1, (form, out.out + out.err)
+ bare = tmp_path / "bare.git"
+ git(repo, "clone", "-q", "--bare", str(repo), str(bare))
+ code = checks_floor.main(["--repo", str(bare), "--base", "main", "--head", "pr"])
+ out = capsys.readouterr()
+ assert code in (1, 2), out.out + out.err
+
+
+def test_ref_forms(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@e", "tag", "-a", "-m", "t", "v1", "main")
+ git(repo, "tag", "light", "main")
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ commit(repo, "pr")
+ short = git(repo, "rev-parse", "--short=7", "main")
+ git(repo, "branch", "we/ird-n@me", "main")
+ for base in ("v1", "light", short, "HEAD~1", "pr~1", "we/ird-n@me", "refs/heads/main", "main^{commit}"):
+ code = checks_floor.main(["--repo", str(repo), "--base", base])
+ out = capsys.readouterr()
+ assert code == 1, (base, out.out + out.err)
+ for base in ("--all", "-h", "main..pr", "main...pr", "", "@{-1}", ":/base"):
+ try:
+ code = checks_floor.main(["--repo", str(repo), f"--base={base}"])
+ except SystemExit as exc:
+ code = exc.code
+ out = capsys.readouterr()
+ assert code in (1, 2), (base, code, out.out + out.err)
+
+
+def test_head_equal_to_base_is_clean(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ code = checks_floor.main(["--repo", str(repo), "--base", "main", "--head", "main"])
+ out = capsys.readouterr()
+ assert code == 0, out.out
diff --git a/tests/test_floor_review4_interact.py b/tests/test_floor_review4_interact.py
new file mode 100644
index 00000000..1a78bd61
--- /dev/null
+++ b/tests/test_floor_review4_interact.py
@@ -0,0 +1,120 @@
+"""Review 4, item 4: interactions. Each asserts the exit the spec owes (or, where marked, the exit observed by design)."""
+
+from __future__ import annotations
+
+import contextlib
+import os
+import shutil
+import time
+
+from floor_support import base_repo, commit, git, run_floor, write
+from floor_support4 import raw_commit
+
+
+def test_head_deletes_whole_chock_tree(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ shutil.rmtree(repo / ".chock")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_mode_only_changes(tmp_path, capsys):
+ for i, (path, owed) in enumerate(
+ (("src/app.py", 0), (".claude/settings.json", 1), (".agents/policies/probe/implementations/probe.py", 1))
+ ):
+ repo = base_repo(tmp_path / str(i))
+ (repo / path).chmod(0o755)
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == owed, (path, out)
+
+
+def test_merge_resolution_introduces_a_token_neither_parent_has(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 'left'\n")
+ commit(repo, "left")
+ git(repo, "checkout", "-q", "-b", "right", "main")
+ write(repo, "src/app.py", "VALUE = 'right'\n")
+ commit(repo, "right")
+ git(repo, "checkout", "-q", "pr")
+ with contextlib.suppress(Exception): # a conflict is expected
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@e", "merge", "-q", "--no-edit", "right")
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-99'\n")
+ git(repo, "add", "-A")
+ raw_commit(repo, "merge with an evil resolution")
+ assert len(git(repo, "rev-list", "--parents", "-n1", "HEAD").split()) == 3
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_clean_merge_resolution_with_token_in_resolution_only_history(tmp_path, capsys):
+ """Token added by the merge commit and removed in the next commit: only the history pass can see it."""
+ repo = base_repo(tmp_path)
+ write(repo, "src/a.py", "A = 1\n")
+ commit(repo, "left")
+ git(repo, "checkout", "-q", "-b", "right", "main")
+ write(repo, "src/b.py", "B = 1\n")
+ commit(repo, "right")
+ git(repo, "checkout", "-q", "pr")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@e", "merge", "-q", "--no-commit", "right")
+ write(repo, "src/c.py", "C = 'FLOOR-TOKEN-5'\n")
+ git(repo, "add", "-A")
+ raw_commit(repo, "merge")
+ os.remove(repo / "src/c.py")
+ commit(repo, "remove it")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_control_plane_change_and_revert_secret_in_history(tmp_path, capsys):
+ """Commit 1 puts a token in .claude/notes.json, commit 2 removes it: the tree diff is empty. S2: still named."""
+ repo = base_repo(tmp_path)
+ write(repo, ".claude/notes.json", '{"k": "FLOOR-TOKEN-42"}\n')
+ commit(repo, "add")
+ os.remove(repo / ".claude/notes.json")
+ commit(repo, "remove")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "\n .claude/notes.json (in a commit of the range only" in out, out
+
+
+def test_same_outside_the_control_plane_for_contrast(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "src/notes.json", '{"k": "FLOOR-TOKEN-42"}\n')
+ commit(repo, "add")
+ os.remove(repo / "src/notes.json")
+ commit(repo, "remove")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_first_adoption_with_violation(tmp_path, capsys):
+ """V6: base without .chock exits 0 even when the head adds .chock and a token."""
+ repo = tmp_path / "repo"
+ repo.mkdir()
+ git(repo, "init", "-q", "-b", "main")
+ write(repo, "src/app.py", "VALUE = 1\n")
+ commit(repo, "base")
+ git(repo, "checkout", "-q", "-b", "pr")
+ write(repo, ".chock/config.yaml", "rollout: enforce\n")
+ write(repo, "src/app.py", "VALUE = 'FLOOR-TOKEN-1'\n")
+ write(repo, ".claude/settings.json", "{}\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0 and "nothing was judged" in out, out
+
+
+def test_many_files(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ for i in range(3000):
+ write(repo, f"gen/f{i:05d}.py", f"V{i} = {i}\n")
+ commit(repo, "pr")
+ start = time.monotonic()
+ code, out = run_floor(repo, capsys)
+ print(f"3000 files: exit {code} in {time.monotonic() - start:.1f}s")
+ assert code == 0, out[-800:]
+ write(repo, "gen/f01234.py", "V = 'FLOOR-TOKEN-3'\n")
+ commit(repo, "pr2")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out[-800:]
diff --git a/tests/test_floor_review4_links.py b/tests/test_floor_review4_links.py
new file mode 100644
index 00000000..b4e78eaf
--- /dev/null
+++ b/tests/test_floor_review4_links.py
@@ -0,0 +1,202 @@
+"""Review 4, L2 matching: symlink chains, gitlink targets, base/head asymmetry, spellings. Each asserts the owed exit.
+
+S1: a link at, inside or above the control plane must open a control-plane path (or nothing) at base and head,
+else the run is undecided (2) naming the link. The suspected Windows short-name case (`CLAUDE~1/`) is not ported:
+docs list it as not covered until it is tested on Windows."""
+
+from __future__ import annotations
+
+from floor_support import CLAUDE, TEST_FILE, base_repo, commit, git, run_floor, write
+from floor_support4 import FAKE_A, FAKE_B, HOOKLESS, gitlink, raw_commit, rebase_main, rm, symlink, undecided
+
+
+def _chain_base(repo):
+ rm(repo, ".claude")
+ symlink(repo, ".claude", "cfg/claude")
+ symlink(repo, "cfg", "real")
+ write(repo, "real/claude/settings.json", CLAUDE)
+
+
+def test_two_hop_symlink_chain_target_is_named(tmp_path, capsys):
+ """L2: `.claude -> cfg/claude`, `cfg -> real`. The client reads real/claude/settings.json as .claude/settings.json."""
+ repo = base_repo(tmp_path)
+ rebase_main(repo, _chain_base)
+ write(repo, "real/claude/settings.json", HOOKLESS)
+ commit(repo, "pr: drop every hook through the chain")
+ undecided(repo, capsys, ".claude")
+
+
+def test_one_hop_symlink_target_is_named_for_contrast(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ rm(r, ".claude")
+ symlink(r, ".claude", "real/claude")
+ write(r, "real/claude/settings.json", CLAUDE)
+
+ rebase_main(repo, base)
+ write(repo, "real/claude/settings.json", HOOKLESS)
+ commit(repo, "pr")
+ undecided(repo, capsys, ".claude")
+
+
+def test_hooks_folder_symlinked_through_a_symlinked_parent(tmp_path, capsys):
+ """`.claude/hooks -> ../tools/hooks` and `tools -> vendor/tools`: editing the hook script the client runs."""
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ symlink(r, ".claude/hooks", "../tools/hooks")
+ symlink(r, "tools", "vendor/tools")
+ write(r, "vendor/tools/hooks/guard.sh", "#!/bin/sh\nexit 2\n")
+
+ rebase_main(repo, base)
+ write(repo, "vendor/tools/hooks/guard.sh", "#!/bin/sh\nexit 0\n")
+ commit(repo, "pr: guard now allows everything")
+ undecided(repo, capsys, ".claude/hooks")
+
+
+def _submodule_base(repo):
+ rm(repo, ".claude")
+ symlink(repo, ".claude", "vendor/agentcfg/.claude")
+ git(repo, "add", "-A")
+ gitlink(repo, "vendor/agentcfg", FAKE_A)
+
+
+def test_symlinked_agent_folder_into_a_submodule_bump_is_named(tmp_path, capsys):
+ """L2: the control-plane folder's target lies inside a gitlink; the PR moves the gitlink."""
+ repo = base_repo(tmp_path)
+ git(repo, "checkout", "-q", "main")
+ _submodule_base(repo)
+ raw_commit(repo, "base: shared agent config from a submodule")
+ git(repo, "checkout", "-q", "-B", "pr")
+ gitlink(repo, "vendor/agentcfg", FAKE_B)
+ raw_commit(repo, "pr: bump the agent-config submodule")
+ out = undecided(repo, capsys, ".claude")
+ assert "passes through the submodule vendor/agentcfg" in out, out
+
+
+def test_symlinked_chock_folder_at_base_is_not_first_adoption(tmp_path, capsys):
+ """V6 says 'B has no .chock'. Here B has .chock, as a symlink to the real folder."""
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ (r / ".chock").rename(r / "chockcfg")
+ symlink(r, ".chock", "chockcfg")
+
+ rebase_main(repo, base)
+ write(repo, "tests/test_core.py", "def test_a():\n pass\n")
+ write(repo, ".claude/settings.json", HOOKLESS)
+ commit(repo, "pr: hooks off and assertions gone")
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "base has no chock gates" not in out, out
+ assert "the base's .chock is a symbolic link" in out, out
+
+
+def test_symlink_replaced_by_directory_is_named(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ rm(r, ".claude")
+ symlink(r, ".claude", "real/claude")
+ write(r, "real/claude/settings.json", CLAUDE)
+
+ rebase_main(repo, base)
+ rm(repo, ".claude")
+ write(repo, ".claude/settings.json", HOOKLESS)
+ commit(repo, "pr")
+ undecided(repo, capsys, ".claude")
+
+
+def test_directory_replaced_by_symlink_is_named(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ write(repo, "elsewhere/settings.json", HOOKLESS)
+ rm(repo, ".claude")
+ symlink(repo, ".claude", "elsewhere")
+ commit(repo, "pr")
+ undecided(repo, capsys, ".claude")
+
+
+def test_rename_away_and_replace_in_one_pr_is_named(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "mv", ".claude", "old-claude")
+ write(repo, ".claude/settings.json", HOOKLESS)
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_retargeted_link_is_named(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ rm(r, ".claude")
+ symlink(r, ".claude", "a")
+ write(r, "a/settings.json", CLAUDE)
+ write(r, "b/settings.json", HOOKLESS)
+
+ rebase_main(repo, base)
+ symlink(repo, ".claude", "b")
+ commit(repo, "pr")
+ undecided(repo, capsys, ".claude")
+
+
+def test_link_only_at_head_into_existing_folder(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+
+ def base(r):
+ write(r, "b/settings.json", HOOKLESS)
+
+ rebase_main(repo, base)
+ symlink(repo, ".gemini", "b")
+ commit(repo, "pr")
+ undecided(repo, capsys, ".gemini")
+
+
+def test_case_and_trailing_dot_space_spellings_are_named(tmp_path, capsys):
+ for i, name in enumerate(
+ (
+ ".Claude/settings.json",
+ ".claude./settings.local.json",
+ ".claude /x.json",
+ ".CHOCK/compiled/x/ci-gate/gate.json",
+ ".Vscode/Settings.JSON.",
+ )
+ ):
+ repo = base_repo(tmp_path / str(i))
+ write(repo, name, "{}\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, (name, out)
+
+
+def test_zero_width_and_nfd_spellings_are_named(tmp_path, capsys):
+ for i, name in enumerate((".claude/settings.json", ".ćlaude-x/y", ".vscode/settings.json")):
+ repo = base_repo(tmp_path / str(i))
+ write(repo, name, "{}\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ # .ćlaude-x is a different name on every filesystem: owed 0; the others fold to listed paths.
+ assert code == (0 if "laude-x" in name else 1), (name, out)
+
+
+def test_gitlink_at_github_workflows_is_named(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ git(repo, "rm", "-q", "-r", "--cached", ".github/workflows")
+ rm(repo, ".github/workflows")
+ gitlink(repo, ".github/workflows", FAKE_A)
+ raw_commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+
+
+def test_test_file_replaced_by_gitlink_is_refused(tmp_path, capsys):
+ """L3-ish: a gitlink where a test was. The head 'blob' is a commit git cannot show as text."""
+ repo = base_repo(tmp_path)
+ git(repo, "rm", "-q", "--cached", "tests/test_core.py")
+ rm(repo, "tests/test_core.py")
+ gitlink(repo, "tests/test_core.py", FAKE_A)
+ raw_commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code != 0, out
+ assert TEST_FILE
diff --git a/tests/test_floor_review4_list.py b/tests/test_floor_review4_list.py
new file mode 100644
index 00000000..75bef275
--- /dev/null
+++ b/tests/test_floor_review4_list.py
@@ -0,0 +1,34 @@
+"""Review 4, item 6: files vendor docs say can disable or pre-empt guardrails; S4 puts each on the default list.
+`*.code-workspace` is not listed (not verified that an editor honours hook settings from it; docs, not covered)."""
+
+from __future__ import annotations
+
+import pytest
+from floor_support import base_repo, commit, run_floor, write
+
+GAPS = {
+ "nested-claude-skill-hooks": (
+ "pkg/.claude/skills/x/SKILL.md",
+ "---\nname: x\nallowed-tools: Bash(*)\nhooks: {}\n---\nx\n",
+ ),
+ "nested-claude-settings": ("pkg/.claude/settings.json", '{"permissions": {"allow": ["Bash(*)"]}}\n'),
+ "nested-codex-config": (
+ "pkg/.codex/config.toml",
+ 'approval_policy = "never"\nsandbox_mode = "danger-full-access"\n',
+ ),
+ "nested-dotenv": ("pkg/.env", "PATH=./bin:/usr/bin\n"),
+ "devcontainer": (
+ ".devcontainer/devcontainer.json",
+ '{"postCreateCommand": "git config chock.python ./bin/fakepy", "remoteEnv": {"PATH": "./bin:${containerEnv:PATH}"}}\n',
+ ),
+}
+
+
+@pytest.mark.parametrize("name", list(GAPS))
+def test_listed(tmp_path, capsys, name):
+ path, text = GAPS[name]
+ repo = base_repo(tmp_path)
+ write(repo, path, text)
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
diff --git a/tests/test_floor_review4_ordinary.py b/tests/test_floor_review4_ordinary.py
new file mode 100644
index 00000000..3d310ba4
--- /dev/null
+++ b/tests/test_floor_review4_ordinary.py
@@ -0,0 +1,86 @@
+"""Review 4, item 7: ordinary pull requests touching no control-plane path. Owed exit 0 (V7)."""
+
+from __future__ import annotations
+
+import random
+import time
+
+import pytest
+from floor_support import TEST_FILE, base_repo, commit, run_floor, write
+
+
+def _bytes(repo, rel, data):
+ p = repo / rel
+ p.parent.mkdir(parents=True, exist_ok=True)
+ p.write_bytes(data)
+
+
+def _rand(n, seed=7):
+ return random.Random(seed).randbytes(n) # noqa: S311 -- incompressible filler, not a secret
+
+
+CASES = {
+ "source-edit": lambda r: write(r, "src/app.py", "VALUE = 2\n"),
+ "new-directory": lambda r: write(r, "pkg/sub/mod.py", "X = 1\n"),
+ "docs": lambda r: write(r, "docs/guide.md", "# Guide\n"),
+ "readme": lambda r: write(r, "README.md", "# Project\n"),
+ "package-lock": lambda r: write(r, "package-lock.json", '{"lockfileVersion": 3, "packages": {"": {}}}\n'),
+ "uv-lock": lambda r: write(r, "uv.lock", 'version = 1\n[[package]]\nname = "x"\nversion = "1.0"\n'),
+ "test-added": lambda r: write(r, "tests/test_new.py", "def test_b():\n assert True\n"),
+ "test-edited-values": lambda r: write(r, "tests/test_core.py", TEST_FILE.replace("== 4", "== 4.0")),
+ "test-assert-moved": lambda r: write(
+ r, "tests/test_core.py", "def test_a():\n assert 2 * 2 == 4\n x = 1\n assert 1 + 1 == 2\n"
+ ),
+ "crlf-file": lambda r: _bytes(r, "src/win.py", b"A = 1\r\nB = 2\r\n"),
+ "crlf-normalised-test": lambda r: _bytes(r, "tests/test_core.py", TEST_FILE.replace("\n", "\r\n").encode()),
+ "utf8-bom": lambda r: _bytes(r, "src/bom.py", b"\xef\xbb\xbfA = 1\n"),
+ "utf16-bom-text": lambda r: _bytes(r, "src/u16.txt", "hello\nworld\n".encode("utf-16")),
+ "png": lambda r: _bytes(r, "assets/logo.png", b"\x89PNG\r\n\x1a\n" + _rand(200_000)),
+ "env-example": lambda r: write(r, ".env.example", "DATABASE_URL=\n"),
+ "nested-gitattributes": lambda r: write(r, "assets/.gitattributes", "*.png binary\n"),
+ "docs-codeowners-word": lambda r: write(r, "docs/codeowners.md", "Who owns what\n"),
+ "agents-md": lambda r: write(r, "AGENTS.md", "Be nice.\n"),
+ "exec-bit-script": lambda r: (write(r, "scripts/run.sh", "#!/bin/sh\n"), (r / "scripts/run.sh").chmod(0o755)),
+}
+
+
+@pytest.mark.parametrize("name", list(CASES))
+def test_ordinary(tmp_path, capsys, name):
+ repo = base_repo(tmp_path)
+ CASES[name](repo)
+ commit(repo, f"pr: {name}")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+@pytest.mark.parametrize(
+ ("name", "size", "binary"),
+ [
+ ("text-20MiB", 20 * 2**20, False),
+ ("binary-8MiB", 8 * 2**20, True),
+ ("binary-40MiB", 40 * 2**20, True),
+ ],
+)
+def test_large_file_under_the_limit(tmp_path, capsys, name, size, binary):
+ repo = base_repo(tmp_path)
+ if binary:
+ _bytes(repo, f"assets/{name}.bin", _rand(size))
+ else:
+ line = b"generated_value_0123456789 = 'abcdefghijklmnopqrstuvwxyz'\n"
+ _bytes(repo, f"src/{name}.py", line * (size // len(line)))
+ commit(repo, "pr")
+ start = time.monotonic()
+ code, out = run_floor(repo, capsys)
+ took = time.monotonic() - start
+ print(f"{name}: exit {code} in {took:.1f}s")
+ assert code == 0, (took, out[-1500:])
+
+
+def test_binary_60mib_under_the_64mib_limit(tmp_path, capsys):
+ repo = base_repo(tmp_path)
+ _bytes(repo, "assets/model.bin", _rand(60 * 2**20))
+ commit(repo, "pr")
+ start = time.monotonic()
+ code, out = run_floor(repo, capsys)
+ print(f"binary-60MiB: exit {code} in {time.monotonic() - start:.1f}s")
+ assert code == 0, out[-1500:]
diff --git a/tests/test_floor_review4_rulings.py b/tests/test_floor_review4_rulings.py
new file mode 100644
index 00000000..71801b90
--- /dev/null
+++ b/tests/test_floor_review4_rulings.py
@@ -0,0 +1,203 @@
+"""Rulings S1-S6 of the floor's fourth pass (W2-A1v2.2), beyond the ported proofs. Each asserts the owed exit."""
+
+from __future__ import annotations
+
+import json
+import os
+import subprocess
+
+import pytest
+from floor_support import CLAUDE, TEST_FILE, base_repo, commit, git, run_floor, write
+from floor_support4 import FAKE_A, HOOKLESS, gitlink, raw_commit, rebase_main, rm, symlink, undecided
+
+from chock.validation import checks_floor, floor_git
+
+LISTED = "floor/control-plane-changed (refuse)"
+
+
+def _base_link(repo, path, target, *files):
+ def change(r):
+ if path == ".claude":
+ rm(r, ".claude")
+ for rel in files:
+ write(r, rel, CLAUDE)
+ symlink(r, path, target)
+
+ rebase_main(repo, change)
+
+
+@pytest.mark.parametrize(
+ ("link", "target", "why"),
+ [
+ (".claude", ".claude", "more than 32 links"),
+ (".claude", "/etc/claude", "absolute or empty target"),
+ (".claude", "../../outside", "leaves the repository"),
+ (".claude/hooks", "../x/../../up", "leaves the repository"),
+ ],
+)
+def test_a_control_plane_link_that_cannot_resolve_is_undecided(tmp_path, capsys, link, target, why):
+ """S1: a loop, an absolute target or a target outside the repository is a failure to resolve."""
+ repo = base_repo(tmp_path)
+ _base_link(repo, link, target)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr: an ordinary change")
+ out = undecided(repo, capsys, link)
+ assert why in out, out
+
+
+def test_a_link_to_another_control_plane_folder_carries_on(tmp_path, capsys):
+ """S1: `.claude -> .codex` stays on the control plane; an ordinary change passes, an edit there is listed."""
+ repo = base_repo(tmp_path)
+ _base_link(repo, ".claude", ".codex", ".codex/settings.json")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+ write(repo, ".codex/settings.json", HOOKLESS)
+ commit(repo, "pr: through the link")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "\n .codex/settings.json\n" in out, out
+
+
+def test_a_dangling_control_plane_link_carries_on_until_the_head_fills_it(tmp_path, capsys):
+ """S1: a link to nothing is fine; once the head creates its target off the plane, it is undecided."""
+ repo = base_repo(tmp_path)
+ _base_link(repo, ".gemini", "cfg")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ assert run_floor(repo, capsys)[0] == 0
+ write(repo, "cfg/settings.json", HOOKLESS)
+ commit(repo, "pr: fill the target")
+ undecided(repo, capsys, ".gemini")
+
+
+def test_a_non_control_plane_hop_is_listed_when_retargeted(tmp_path, capsys):
+ """`.claude -> cfg`, `cfg -> .codex`: moving `cfg` to `.cursor` changes what `.claude` opens, so `cfg` is listed."""
+ repo = base_repo(tmp_path)
+
+ def change(r):
+ rm(r, ".claude")
+ write(r, ".codex/settings.json", CLAUDE)
+ symlink(r, "cfg", ".codex")
+ symlink(r, ".claude", "cfg")
+
+ rebase_main(repo, change)
+ symlink(repo, "cfg", ".cursor")
+ commit(repo, "pr: retarget the middle link")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "\n cfg\n" in out, out
+
+
+def test_a_link_above_a_nested_agent_folder_that_opens_only_plane_paths_carries_on(tmp_path, capsys):
+ """S1 as amended by G1 A7: `pkg -> vendor` with `vendor/.claude/`: pkg/.claude opens vendor/.claude, which is
+ control plane by itself, so an ordinary change is 0."""
+ repo = base_repo(tmp_path)
+ _base_link(repo, "pkg", "vendor", "vendor/.claude/settings.json")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_an_unrelated_link_out_of_the_repository_is_not_judged(tmp_path, capsys):
+ """S1 asks only about links at, inside or above the control plane; others owe no refusal."""
+ repo = base_repo(tmp_path)
+ _base_link(repo, "docs/shared", "/usr/share/doc")
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 0, out
+
+
+def test_a_gitlink_inside_a_control_plane_folder_is_listed(tmp_path, capsys):
+ """S1: a submodule at or inside a control-plane folder is named like any other change to it."""
+ repo = base_repo(tmp_path)
+ gitlink(repo, ".claude/shared", FAKE_A)
+ raw_commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "\n .claude/shared\n" in out, out
+
+
+def test_a_guardrail_changed_and_changed_back_is_named(tmp_path, capsys):
+ """S2: hooks off in one commit, back on in the next; the tree diff is empty, the path is still named."""
+ repo = base_repo(tmp_path)
+ write(repo, ".claude/settings.json", HOOKLESS)
+ commit(repo, "off")
+ write(repo, ".claude/settings.json", CLAUDE)
+ commit(repo, "on again")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "\n .claude/settings.json (in a commit of the range only" in out, out
+
+
+def test_a_pull_request_merge_of_a_behind_branch_names_nothing_from_the_base(tmp_path, capsys):
+ """S2 reads states the base does not have: main's own workflow change, merged into the PR ref, is not the PR's."""
+ repo = base_repo(tmp_path)
+ write(repo, "src/app.py", "VALUE = 2\n")
+ commit(repo, "pr: ordinary")
+ git(repo, "checkout", "-q", "main")
+ write(repo, ".github/workflows/chock.yml", "name: changed on main\n")
+ commit(repo, "main: workflow")
+ git(repo, "checkout", "-q", "-b", "merge-ref")
+ git(repo, "-c", "user.name=t", "-c", "user.email=t@e", "merge", "-q", "--no-edit", "pr")
+ code, out = run_floor(repo, capsys, "--head", "merge-ref")
+ assert code == 0, out
+
+
+def test_attributes_come_from_the_base(tmp_path, capsys):
+ """S3: a head `.gitattributes` marking tests binary neither hides a removed assertion nor is itself listed."""
+ repo = base_repo(tmp_path)
+ write(repo, ".gitattributes", "tests/** binary -diff -text\n")
+ write(repo, "tests/test_core.py", TEST_FILE.replace(" assert", " pass #"))
+ commit(repo, "pr")
+ code, out = run_floor(repo, capsys)
+ assert code == 1, out
+ assert "\n .gitattributes\n" not in out, out
+ assert "GIT_ATTR_SOURCE" not in os.environ
+
+
+def test_a_git_that_ignores_attr_source_is_undecided(tmp_path, capsys, monkeypatch):
+ """S3: a git too old to read attributes from the base is exit 2, naming the version needed."""
+ repo = base_repo(tmp_path)
+ real = floor_git.git
+
+ def old_git(repo_, *args, data=None):
+ if "check-attr" in args:
+ return subprocess.CompletedProcess(args, 0, b"", b"")
+ return real(repo_, *args, data=data)
+
+ monkeypatch.setattr(floor_git, "git", old_git)
+ code, out = run_floor(repo, capsys)
+ assert code == 2, out
+ assert "git 2.42 or newer" in out, out
+
+
+def test_first_adoption_writes_a_clean_sarif(tmp_path, capsys):
+ """S6: every run writes the file it was asked for, so a stale one never stands in for this run."""
+ repo = tmp_path / "repo"
+ repo.mkdir()
+ git(repo, "init", "-q", "-b", "main")
+ write(repo, "src/app.py", "VALUE = 1\n")
+ commit(repo, "base")
+ sarif = tmp_path / "o.sarif"
+ sarif.write_text('{"stale": true}\n')
+ code = checks_floor.main(["--repo", str(repo), "--base", "main", "--sarif", str(sarif)])
+ assert code == 0, capsys.readouterr()
+ doc = json.loads(sarif.read_text())
+ assert doc["runs"][0]["invocations"][0]["executionSuccessful"] is True, doc
+ assert doc["runs"][0]["results"] == [], doc
+
+
+def test_an_undecided_link_writes_an_undecided_sarif(tmp_path, capsys):
+ """S6: text and SARIF agree on an undecided run."""
+ repo = base_repo(tmp_path)
+ _base_link(repo, ".claude", "cfg/claude", "cfg/claude/settings.json")
+ sarif = tmp_path / "o.sarif"
+ code = checks_floor.main(["--repo", str(repo), "--base", "main", "--sarif", str(sarif)])
+ assert code == 2, capsys.readouterr()
+ invocation = json.loads(sarif.read_text())["runs"][0]["invocations"][0]
+ assert invocation["executionSuccessful"] is False
+ assert "symbolic link .claude" in invocation["toolExecutionNotifications"][0]["message"]["text"]
diff --git a/tests/test_gate_rename_baseline.py b/tests/test_gate_rename_baseline.py
new file mode 100644
index 00000000..e879c8a9
--- /dev/null
+++ b/tests/test_gate_rename_baseline.py
@@ -0,0 +1,129 @@
+"""A file git reports as renamed is judged against its old path's content, on a real git repository.
+
+A pure `git mv` of a file holding an old finding adds nothing; a copy (old path kept) is new work.
+Each case runs for a script gate and a `content_regex` gate, at commit, at the turn's end and on the CI range.
+"""
+
+from __future__ import annotations
+
+import subprocess
+from collections.abc import Callable
+from pathlib import Path
+
+import pytest
+from conftest import write_gate
+from findings_support import make_gate, repo_with
+
+from chock.gate.runner import run
+
+PAD = "a = 1\nb = 2\nc = 3\nd = 4\n"
+OLD = PAD + "x = BAD\n"
+BASE = "trunk"
+REGEX = {"kind": "content_regex", "on": ["commit", "tool_use"], "action": "block", "message": "m"}
+REGEX["params"] = {"scan": "added_lines", "content_pattern": "BAD"}
+
+Gate = Callable[[Path, Path], Path]
+Surface = Callable[[Path, Path, dict[str, str]], int]
+
+
+def _git(repo: Path, *args: str) -> None:
+ subprocess.run(["git", *args], cwd=repo, check=True, capture_output=True)
+
+
+def _script_gate(repo: Path, _tmp: Path) -> Path:
+ return make_gate(repo)
+
+
+def _regex_gate(_repo: Path, tmp: Path) -> Path:
+ return write_gate(tmp, REGEX)
+
+
+def _put(repo: Path, files: dict[str, str]) -> None:
+ for rel, text in files.items():
+ (repo / rel).write_text(text, encoding="utf-8")
+
+
+def _commit_surface(gate: Path, repo: Path, files: dict[str, str]) -> int:
+ _put(repo, files)
+ _git(repo, "add", "-A", "--", *files)
+ return run(gate, "commit", None, repo)
+
+
+def _stop_surface(gate: Path, repo: Path, files: dict[str, str]) -> int:
+ _put(repo, files)
+ return run(gate, "stop", None, repo, writes=files)
+
+
+def _ci_surface(gate: Path, repo: Path, files: dict[str, str]) -> int:
+ _git(repo, "checkout", "-q", "-b", "feature")
+ _put(repo, files)
+ _git(repo, "add", "-A", "--", *files)
+ _git(repo, "commit", "-qm", "move")
+ return run(gate, "ci", None, repo, base=BASE)
+
+
+def _start(tmp_path: Path) -> Path:
+ repo = repo_with(tmp_path, **{"old.py": OLD, "keep.py": "k = 1\n"})
+ _git(repo, "branch", "-M", BASE)
+ return repo
+
+
+def _move(repo: Path, text: str | None, *, copy: bool = False) -> dict[str, str]:
+ """Move (or copy) old.py to new.py, returning the new file's text for the surface to judge."""
+ if copy:
+ (repo / "new.py").write_text(OLD, encoding="utf-8")
+ _git(repo, "add", "new.py")
+ else:
+ _git(repo, "mv", "old.py", "new.py")
+ return {"new.py": OLD if text is None else text}
+
+
+GATES = [pytest.param(_script_gate, id="script"), pytest.param(_regex_gate, id="content_regex")]
+SURFACES = [
+ pytest.param(_commit_surface, id="commit"),
+ pytest.param(_stop_surface, id="stop"),
+ pytest.param(_ci_surface, id="ci"),
+]
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+@pytest.mark.parametrize("make", GATES)
+def test_a_pure_rename_of_an_old_finding_is_allowed(tmp_path: Path, make: Gate, surface: Surface) -> None:
+ repo = _start(tmp_path)
+ gate = make(repo, tmp_path)
+ assert surface(gate, repo, _move(repo, None)) == 0
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+@pytest.mark.parametrize("make", GATES)
+def test_a_rename_that_adds_a_finding_refuses_the_new_one(tmp_path: Path, make: Gate, surface: Surface) -> None:
+ repo = _start(tmp_path)
+ gate = make(repo, tmp_path)
+ assert surface(gate, repo, _move(repo, OLD + "y = BAD two\n")) == 1
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+@pytest.mark.parametrize("make", GATES)
+def test_a_rename_that_removes_a_finding_is_allowed(tmp_path: Path, make: Gate, surface: Surface) -> None:
+ repo = _start(tmp_path)
+ gate = make(repo, tmp_path)
+ assert surface(gate, repo, _move(repo, PAD + "x = 1\n")) == 0
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+@pytest.mark.parametrize("make", GATES)
+def test_a_copy_with_the_old_path_kept_is_judged_as_new(tmp_path: Path, make: Gate, surface: Surface) -> None:
+ repo = _start(tmp_path)
+ gate = make(repo, tmp_path)
+ assert surface(gate, repo, _move(repo, None, copy=True)) == 1
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+def test_the_script_gate_names_only_the_added_finding_after_a_rename(
+ tmp_path: Path, surface: Surface, capsys: pytest.CaptureFixture
+) -> None:
+ repo = _start(tmp_path)
+ assert surface(make_gate(repo), repo, _move(repo, OLD + "y = BAD two\n")) == 1
+ err = capsys.readouterr().err
+ assert "new.py:6: bad y = BAD two" in err
+ assert "x = BAD" not in err
diff --git a/tests/test_gate_rename_name.py b/tests/test_gate_rename_name.py
new file mode 100644
index 00000000..78da8d2e
--- /dev/null
+++ b/tests/test_gate_rename_name.py
@@ -0,0 +1,147 @@
+"""A rename into a refused name is new work, even when the content is old, on a real git repository.
+
+The toy script gate reports a finding for a path whose NAME matches a pattern (keyed by the name, as the
+catalog's name gates key theirs) and another for a line whose CONTENT matches. Each case runs at commit, at
+the turn's end and on the CI range. E-1's content rule is kept: a pure rename of an old content finding is allowed.
+"""
+
+from __future__ import annotations
+
+import json
+import subprocess
+import textwrap
+from collections.abc import Callable
+from pathlib import Path
+
+import pytest
+from conftest import init_repo
+
+from chock.gate.runner import run
+
+PAD = "a = 1\nb = 2\nc = 3\nd = 4\n"
+OLD = PAD + "x = BAD\n"
+BASE = "trunk"
+SCRIPT = "namegate.py"
+
+#: A path whose basename holds `REFUSED` is a name finding, keyed by the path; a line holding BAD is a content finding.
+TOY = textwrap.dedent(
+ """\
+ import json, sys
+ payload = json.load(sys.stdin)
+ found = []
+ for path, text in payload["writes"].items():
+ if "REFUSED" in path.rsplit("/", 1)[-1]:
+ found.append({"key": "name|" + path, "path": path, "line": 1, "message": "refused name " + path})
+ for number, line in enumerate(text.splitlines(), 1):
+ if "BAD" in line:
+ found.append({"key": "bad:" + line, "path": path, "line": number, "message": "bad " + line})
+ print(json.dumps({"findings": found}))
+ if found:
+ print("RAW-STDERR", file=sys.stderr)
+ sys.exit(1)
+ """
+)
+
+Surface = Callable[[Path, Path, dict[str, str]], int]
+
+
+def _git(repo: Path, *args: str) -> None:
+ subprocess.run(["git", *args], cwd=repo, check=True, capture_output=True)
+
+
+def _repo(tmp_path: Path, **head: str) -> Path:
+ (tmp_path / "repo").mkdir()
+ repo = init_repo(tmp_path / "repo")
+ for rel, text in {**head, "keep.py": "k = 1\n"}.items():
+ (repo / rel).write_text(text, encoding="utf-8")
+ _git(repo, "add", "-A")
+ _git(repo, "commit", "-qm", "base")
+ _git(repo, "branch", "-M", BASE)
+ (repo / SCRIPT).write_text(TOY, encoding="utf-8")
+ gate = repo / "gate.json"
+ spec = {"kind": "script", "on": ["commit", "tool_use"], "action": "block", "message": "m"}
+ gate.write_text(json.dumps({**spec, "params": {"script": SCRIPT}}), encoding="utf-8")
+ return repo
+
+
+def _put(repo: Path, files: dict[str, str]) -> None:
+ for rel, text in files.items():
+ (repo / rel).write_text(text, encoding="utf-8")
+
+
+def _commit_surface(gate: Path, repo: Path, files: dict[str, str]) -> int:
+ _put(repo, files)
+ _git(repo, "add", "-A", "--", *files)
+ return run(gate, "commit", None, repo)
+
+
+def _stop_surface(gate: Path, repo: Path, files: dict[str, str]) -> int:
+ _put(repo, files)
+ return run(gate, "stop", None, repo, writes=files)
+
+
+def _ci_surface(gate: Path, repo: Path, files: dict[str, str]) -> int:
+ _git(repo, "checkout", "-q", "-b", "feature")
+ _put(repo, files)
+ _git(repo, "add", "-A", "--", *files)
+ _git(repo, "commit", "-qm", "move")
+ return run(gate, "ci", None, repo, base=BASE)
+
+
+SURFACES = [
+ pytest.param(_commit_surface, id="commit"),
+ pytest.param(_stop_surface, id="stop"),
+ pytest.param(_ci_surface, id="ci"),
+]
+
+
+def _mv(repo: Path, old: str, new: str, text: str) -> dict[str, str]:
+ _git(repo, "mv", old, new)
+ return {new: text}
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+def test_a_pure_rename_from_a_clean_name_into_a_refused_name_is_refused(tmp_path: Path, surface: Surface) -> None:
+ repo = _repo(tmp_path, **{"old.py": PAD})
+ assert surface(repo / "gate.json", repo, _mv(repo, "old.py", "REFUSED.py", PAD)) == 1
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+def test_a_rename_from_a_refused_name_to_another_refused_name_is_refused(tmp_path: Path, surface: Surface) -> None:
+ repo = _repo(tmp_path, **{"REFUSED_a.py": PAD})
+ assert surface(repo / "gate.json", repo, _mv(repo, "REFUSED_a.py", "REFUSED_b.py", PAD)) == 1
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+def test_a_rename_from_a_refused_name_to_a_clean_name_is_allowed(tmp_path: Path, surface: Surface) -> None:
+ repo = _repo(tmp_path, **{"REFUSED.py": PAD})
+ assert surface(repo / "gate.json", repo, _mv(repo, "REFUSED.py", "clean.py", PAD)) == 0
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+def test_a_pure_rename_of_a_file_whose_only_finding_is_content_is_allowed(tmp_path: Path, surface: Surface) -> None:
+ repo = _repo(tmp_path, **{"old.py": OLD})
+ assert surface(repo / "gate.json", repo, _mv(repo, "old.py", "new.py", OLD)) == 0
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+def test_a_rename_that_adds_a_content_finding_is_refused_and_names_only_that_finding(
+ tmp_path: Path, surface: Surface, capsys: pytest.CaptureFixture
+) -> None:
+ repo = _repo(tmp_path, **{"old.py": OLD})
+ text = OLD + "y = BAD two\n"
+ assert surface(repo / "gate.json", repo, _mv(repo, "old.py", "new.py", text)) == 1
+ err = capsys.readouterr().err
+ assert "new.py:6: bad y = BAD two" in err
+ assert "x = BAD" not in err
+
+
+@pytest.mark.parametrize("surface", SURFACES)
+def test_a_rename_into_a_refused_name_names_the_name_and_not_the_old_content_finding(
+ tmp_path: Path, surface: Surface, capsys: pytest.CaptureFixture
+) -> None:
+ repo = _repo(tmp_path, **{"old.py": OLD})
+ assert surface(repo / "gate.json", repo, _mv(repo, "old.py", "REFUSED.py", OLD)) == 1
+ err = capsys.readouterr().err
+ assert "refused name REFUSED.py" in err
+ assert "x = BAD" not in err
diff --git a/tests/test_generated_newlines.py b/tests/test_generated_newlines.py
index 853b4872..ad800341 100644
--- a/tests/test_generated_newlines.py
+++ b/tests/test_generated_newlines.py
@@ -15,7 +15,7 @@
GENERATED_WRITERS = [
"src/chock/compile/emitters/ambient.py",
- "src/chock/compile/emitters/claude_managed.py",
+ "src/chock/compile/emitters/managed/__init__.py",
"src/chock/compile/emitters/in_agent.py",
"src/chock/compile/emitters/git_hook.py",
"src/chock/index/cli.py",
diff --git a/tests/test_lock_engine.py b/tests/test_lock_engine.py
new file mode 100644
index 00000000..186c88c8
--- /dev/null
+++ b/tests/test_lock_engine.py
@@ -0,0 +1,112 @@
+"""chock.lock's `engine` field is derived from the running engine and enforced by `check --only verify` (IR-F71)."""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import pytest
+
+from chock import __version__, lock
+from chock.lifecycle import check_main
+from chock.lock import build_lock, verify_lock, write_lock
+from chock.lock_engine import LEGACY_ENGINE_CONSTRAINT, check_engine, engine_constraint
+
+
+def _locked(repo: Path, constraint: object) -> Path:
+ (repo / ".agents" / "policies").mkdir(parents=True)
+ write_lock({"lockfile_version": "2", "engine": constraint, "packs": []}, repo)
+ return repo
+
+
+@pytest.mark.parametrize(
+ ("version", "expected"),
+ [("1.2.0", ">=1.2,<2"), ("1.2.7", ">=1.2,<2"), ("2.0.0rc1", ">=2.0,<3"), ("0.0.1", ">=0.0,<1")],
+)
+def test_constraint_is_derived_from_the_engine_version(version: str, expected: str) -> None:
+ assert engine_constraint(version) == expected
+
+
+def test_written_lock_carries_the_running_engines_constraint(tmp_path: Path) -> None:
+ (tmp_path / ".agents" / "policies").mkdir(parents=True)
+ assert build_lock(tmp_path)["engine"] == engine_constraint(__version__)
+ assert engine_constraint(__version__) != LEGACY_ENGINE_CONSTRAINT
+
+
+@pytest.mark.parametrize("version", ["1.2.0", "1.2.9", "1.9.0"])
+def test_engine_inside_the_constraint_passes(version: str) -> None:
+ assert check_engine(">=1.2,<2", version) == (None, None)
+
+
+@pytest.mark.parametrize(("version", "side"), [("1.1.9", "below"), ("2.0.0", "above"), ("3.1.0", "above")])
+def test_engine_outside_the_constraint_fails_naming_engine_lock_and_fix(version: str, side: str) -> None:
+ failure, note = check_engine(">=1.2,<2", version)
+ assert note is None, side
+ assert failure is not None
+ assert "\n" not in failure
+ assert f"engine {version}" in failure
+ assert "'>=1.2,<2'" in failure
+ assert 'pip install "chock>=1.2,<2"' in failure
+ assert "chock sync --repo ." in failure
+
+
+def test_legacy_constraint_passes_with_a_note_to_resync() -> None:
+ failure, note = check_engine(LEGACY_ENGINE_CONSTRAINT, "1.2.0")
+ assert failure is None
+ assert note is not None
+ assert "chock sync --repo ." in note
+
+
+@pytest.mark.parametrize("constraint", ["x", "", "^1.2", ">=1.2", "<2,>=1.2", None, 12, ["1.2"]])
+def test_unparseable_constraint_fails(constraint: object) -> None:
+ failure, note = check_engine(constraint, "1.2.0")
+ assert note is None
+ assert failure is not None
+ assert "cannot be read" in failure
+
+
+def test_verify_fails_when_the_running_engine_is_outside_the_lock(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
+) -> None:
+ repo = _locked(tmp_path, ">=9.0,<10")
+ ok, failures = verify_lock(repo)
+ assert not ok
+ assert len(failures) == 1
+ assert "outside chock.lock's constraint '>=9.0,<10'" in failures[0]
+ monkeypatch.chdir(repo)
+ assert check_main(["--only", "verify", "--repo", str(repo)]) == 1
+ err = capsys.readouterr().err
+ assert err.count("verify FAIL:") == 1
+ assert f"engine {__version__} is outside" in err
+
+
+def test_verify_passes_inside_the_lock(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
+ repo = _locked(tmp_path, engine_constraint(__version__))
+ assert verify_lock(repo) == (True, [])
+ assert lock.main(["verify", "--repo", str(repo)]) == 0
+ assert "note:" not in capsys.readouterr().out
+
+
+def test_verify_passes_a_legacy_lock_with_one_note(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
+ repo = _locked(tmp_path, LEGACY_ENGINE_CONSTRAINT)
+ notes: list[str] = []
+ assert verify_lock(repo, notes) == (True, [])
+ assert len(notes) == 1
+ assert lock.main(["verify", "--repo", str(repo)]) == 0
+ assert capsys.readouterr().out.count("note:") == 1
+
+
+def test_verify_fails_an_unparseable_constraint(tmp_path: Path) -> None:
+ repo = _locked(tmp_path, ">=one, None:
+ repo = tmp_path
+ (repo / ".agents" / "policies").mkdir(parents=True)
+ (repo / "chock.lock").write_text(json.dumps({"lockfile_version": "2", "packs": []}), encoding="utf-8")
+ ok, failures = verify_lock(repo)
+ assert not ok
+ assert "cannot be read" in failures[0]
diff --git a/tests/test_managed_emit_claude.py b/tests/test_managed_emit_claude.py
new file mode 100644
index 00000000..a8fa1373
--- /dev/null
+++ b/tests/test_managed_emit_claude.py
@@ -0,0 +1,276 @@
+"""`chock emit --managed claude_code`: a valid drop-in, honest labels, docs and wording, and nothing outside --out."""
+
+from __future__ import annotations
+
+import json
+import os
+import sys
+from pathlib import Path
+
+import pytest
+from managed_emit_helpers import (
+ DEPLOY_ROOT,
+ DOCS,
+ DROP_IN,
+ FAIL_CLOSED,
+ FIXTURES,
+ OVERRIDE_CLAIM,
+ PERMISSION_RULE,
+ POLICIES,
+ PYTHON,
+ ROOT,
+ drop_in,
+ emit,
+ handlers,
+ linux,
+ make_repo,
+ tree,
+)
+
+from chock import cli
+from chock.compile.emitters import managed
+from chock.compile.emitters.in_agent_hooks import TIMEOUT_SECONDS
+from chock.compile.emitters.managed import claude_code
+from chock.compile.levels import cap_for, level_rank
+
+
+@pytest.fixture
+def repo(tmp_path: Path) -> Path:
+ return make_repo(tmp_path)
+
+
+def test_nothing_outside_out_changes(repo: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ """Acceptance 1: HOME and cwd in tmp; every file there but --out is byte-identical after the run."""
+ home = tmp_path / "home"
+ home.mkdir()
+ monkeypatch.setenv("HOME", str(home))
+ monkeypatch.setenv("USERPROFILE", str(home))
+ monkeypatch.chdir(tmp_path)
+ out = tmp_path / "out"
+ before = tree(tmp_path, out)
+ assert linux(repo, out) == 0
+ assert tree(tmp_path, out) == before
+ assert sorted(p.name for p in out.iterdir()) == ["claude_code"]
+
+
+def _system_out() -> Path:
+ return Path(managed.CHANNELS["system_roots"][managed.host_platform()][1]) / "chock-emit-test"
+
+
+def test_out_under_a_system_path_is_refused(repo: Path, capsys: pytest.CaptureFixture[str]) -> None:
+ """Acceptance 2: no file is written and the exit is non-zero."""
+ out = _system_out()
+ assert emit(repo, out) == 1
+ assert "resolves to or inside the system path" in capsys.readouterr().err
+ assert not out.exists()
+
+
+@pytest.mark.skipif(sys.platform == "win32", reason="a symlink needs a privilege on Windows")
+def test_out_through_a_symlink_into_a_system_path_is_refused(repo: Path, tmp_path: Path) -> None:
+ link = tmp_path / "innocent"
+ link.symlink_to(_system_out().parent)
+ assert emit(repo, link) == 1
+ assert not (_system_out().parent / "claude_code").exists()
+
+
+def test_an_existing_vendor_folder_is_never_written_into(repo: Path, tmp_path: Path) -> None:
+ out = tmp_path / "out"
+ (out / "claude_code").mkdir(parents=True)
+ (out / "claude_code" / "mine.txt").write_text("keep", encoding="utf-8")
+ assert linux(repo, out) == 1
+ assert [p.name for p in (out / "claude_code").iterdir()] == ["mine.txt"]
+
+
+@pytest.mark.parametrize("root", ["relative/dir", "/has\nnewline", "/"])
+def test_a_deploy_root_that_is_not_an_absolute_folder_is_refused(repo: Path, tmp_path: Path, root: str) -> None:
+ assert emit(repo, tmp_path / "out", "--platform", "linux", "--deploy-root", root) == 1
+ assert not (tmp_path / "out" / "claude_code").exists()
+
+
+def test_a_deploy_root_with_shell_characters_is_one_argument(repo: Path, tmp_path: Path) -> None:
+ """Finding 8: exec form, no shell, so quote, $ and backquote reach the client as written."""
+ root = '/srv/a"b$c`d e'
+ assert emit(repo, tmp_path / "out", "--platform", "linux", "--deploy-root", root) == 0
+ args = [arg for _, hook in handlers(drop_in(tmp_path / "out")) for arg in hook["args"]]
+ assert f"{root}/block-no-verify/scripts/claude_code.py" in args
+
+
+def test_a_deploy_root_is_normalised() -> None:
+ """Finding 9: deploy.json never shows a `..` target."""
+ assert managed.deploy_root("/etc/claude-code/../../srv/x/", "linux") == "/srv/x"
+
+
+def test_a_windows_deploy_root_is_written_with_forward_slashes() -> None:
+ assert (
+ managed.deploy_root("C:\\Program Files\\ClaudeCode\\chock\\", "windows") == "C:/Program Files/ClaudeCode/chock"
+ )
+
+
+def test_the_drop_in_follows_the_documented_schema(repo: Path, tmp_path: Path) -> None:
+ """Acceptance 3: JSON object; PreToolUse handlers block on failure with chock's timeout; Stop takes no onFailure."""
+ out = tmp_path / "out"
+ assert linux(repo, out) == 0
+ doc = drop_in(out)
+ assert all(PERMISSION_RULE.match(rule) for rule in doc.get("permissions", {}).get("deny", []))
+ found = handlers(doc)
+ assert {event for event, _ in found} == {"PreToolUse", "Stop"}
+ for event, hook in found:
+ assert hook["type"] == "command"
+ assert hook["timeout"] == TIMEOUT_SECONDS == 45
+ assert hook.get("onFailure") == ("block" if event == "PreToolUse" else None)
+
+
+def test_hooks_are_exec_form_started_by_the_given_python(repo: Path, tmp_path: Path) -> None:
+ """Findings 1, 8: the command is --python itself; no git, sh, launcher or PATH lookup stands in between."""
+ assert linux(repo, tmp_path / "out") == 0
+ for _, hook in handlers(drop_in(tmp_path / "out")):
+ assert hook["command"] == PYTHON
+ assert hook["args"][:4] == ["-I", "-X", "utf8", "-c"]
+ assert not [arg for arg in hook["args"] if "launch.sh" in arg or "chock.python" in arg or "git -c" in arg]
+ assert not list((tmp_path / "out").rglob("launch.sh"))
+
+
+@pytest.mark.parametrize("python", ["python3", "bin/python3", ""])
+def test_python_must_be_an_absolute_path(repo: Path, tmp_path: Path, python: str, capsys) -> None:
+ """Ruling 1: the interpreter is never taken from PATH."""
+ assert emit(repo, tmp_path / "out", "--platform", "linux", python=python) == 1
+ assert "must be the absolute path of the Python 3.11+ interpreter" in capsys.readouterr().err
+ assert not (tmp_path / "out").exists()
+
+
+@pytest.mark.parametrize("missing", ["--python", "--on-failure"])
+def test_python_and_on_failure_have_no_default(repo: Path, tmp_path: Path, missing: str, capsys) -> None:
+ """Rulings 1, 2: the admin names both; without either the command fails and says which."""
+ argv = ["emit", "--managed", "claude_code", "--out", str(tmp_path / "out"), "--repo", str(repo)]
+ argv += [flag for pair in (("--python", PYTHON), ("--on-failure", "block")) if pair[0] != missing for flag in pair]
+ with pytest.raises(SystemExit) as exc:
+ cli.main(argv)
+ assert exc.value.code == 2
+ assert missing in capsys.readouterr().err
+ assert not (tmp_path / "out").exists()
+
+
+def test_on_failure_allow_emits_no_failure_key(repo: Path, tmp_path: Path) -> None:
+ """Ruling 2: `allow` emits no onFailure anywhere."""
+ assert linux(repo, tmp_path / "out", on_failure="allow") == 0
+ assert not [hook for _, hook in handlers(drop_in(tmp_path / "out")) if "onFailure" in hook]
+
+
+def test_no_matcherless_stop_check_is_emitted(repo: Path, tmp_path: Path) -> None:
+ """Finding 2: every pre-tool group names its tools; the repo stop's every-tool entry is left out."""
+ assert linux(repo, tmp_path / "out") == 0
+ doc = drop_in(tmp_path / "out")
+ assert all(group.get("matcher") for group in doc["hooks"]["PreToolUse"])
+ assert not [hook for _, hook in handlers(doc) if "--stop-check" in hook["args"]]
+
+
+@pytest.mark.parametrize("choice", ["block", "allow"])
+def test_the_failure_consequence_is_stated_in_deploy_json_and_output(
+ repo: Path, tmp_path: Path, choice: str, capsys
+) -> None:
+ """Ruling 2: one sentence each, naming the interpreter and the matched tools."""
+ assert linux(repo, tmp_path / "out", on_failure=choice) == 0
+ plan = json.loads((tmp_path / "out" / "claude_code" / "deploy.json").read_text(encoding="utf-8"))
+ sentence = plan["on_failure"]["consequence"]
+ assert plan["on_failure"]["choice"] == choice
+ assert sentence.startswith(f"--on-failure {choice}:") and PYTHON in sentence
+ assert "Bash|PowerShell, Write|Edit|MultiEdit|NotebookEdit" in sentence
+ assert ("is refused" if choice == "block" else "goes ahead unchecked") in sentence
+ assert sentence in capsys.readouterr().out
+
+
+def test_no_managed_only_key_without_lock(repo: Path, tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
+ """Acceptance 4: no allowManaged* key by default; --lock adds the hooks key alone, never the permission-rules one."""
+ assert linux(repo, tmp_path / "plain") == 0
+ assert not [key for key in drop_in(tmp_path / "plain") if key.startswith("allowManaged")]
+ assert linux(repo, tmp_path / "locked", "--lock") == 0
+ assert [key for key in drop_in(tmp_path / "locked") if key.startswith("allowManaged")] == ["allowManagedHooksOnly"]
+ text = capsys.readouterr().out
+ assert "allowManagedPermissionRulesOnly is never emitted" in text
+ assert "chock's own project hooks and plugins included" in text
+
+
+def test_hook_commands_name_only_the_deploy_root(repo: Path, tmp_path: Path) -> None:
+ """Acceptance 5: no repo-relative path, every path argument under the deploy root and in the bundle."""
+ out = tmp_path / "out"
+ assert linux(repo, out) == 0
+ for _, hook in handlers(drop_in(out)):
+ paths = [arg for arg in hook["args"][5:] if not arg.startswith("--")]
+ assert paths and all(path.startswith(f"{DEPLOY_ROOT}/") for path in paths)
+ for path in paths:
+ assert (out / "claude_code" / "bundle" / path.removeprefix(f"{DEPLOY_ROOT}/")).is_file(), path
+
+
+@pytest.mark.parametrize("policy_id", POLICIES)
+def test_drop_in_golden(repo: Path, tmp_path: Path, policy_id: str) -> None:
+ """Acceptance 6: the file for one policy, byte for byte."""
+ out = tmp_path / "out"
+ assert linux(repo, out, "--policies", policy_id) == 0
+ actual = (out / "claude_code" / DROP_IN).read_text(encoding="utf-8")
+ golden = FIXTURES / f"{policy_id}.json"
+ if os.environ.get("CHOCK_REGEN_GOLDENS") == "1":
+ golden.parent.mkdir(parents=True, exist_ok=True)
+ golden.write_text(actual, encoding="utf-8", newline="\n")
+ assert actual == golden.read_text(encoding="utf-8")
+
+
+def test_labels_are_vendor_docs_unwitnessed_and_capped(repo: Path, tmp_path: Path) -> None:
+ """Acceptance 7: every emitted cell rests on vendor docs, is unwitnessed, and is at most best-effort."""
+ out = tmp_path / "out"
+ assert linux(repo, out) == 0
+ labels = json.loads((out / "claude_code" / "labels.json").read_text(encoding="utf-8"))
+ assert [row["policy"] for row in labels] == list(POLICIES)
+ for row in labels:
+ assert row["basis"] == "vendor-docs" and row["witnessed"] is False
+ assert level_rank(row["level"]) <= level_rank(cap_for("vendor-docs")) == level_rank("best-effort")
+ assert row["label"] == f"{row['level']} (vendor-docs)"
+ assert {row["policy"]: row["halves"] for row in labels} == {"block-no-verify": ["guard"], "scan-secrets": ["gate"]}
+
+
+def test_nothing_written_or_printed_claims_users_cannot_override(
+ repo: Path, tmp_path: Path, capsys: pytest.CaptureFixture[str]
+) -> None:
+ out = tmp_path / "out"
+ assert linux(repo, out, "--lock") == 0
+ texts = [capsys.readouterr().out, *(p.read_text(encoding="utf-8") for p in (out / "claude_code").glob("*.json"))]
+ texts.append((out / "claude_code" / DROP_IN).read_text(encoding="utf-8"))
+ texts.append(json.dumps(managed.CHANNELS))
+ assert not [text for text in texts if OVERRIDE_CLAIM.search(text)]
+ plan = json.loads((out / "claude_code" / "deploy.json").read_text(encoding="utf-8"))
+ assert plan["deployed"] is False and plan["basis"] == "vendor-docs"
+ assert any("local administrator can edit or delete" in caveat for caveat in plan["caveats"])
+ assert plan["place"][0]["to"] == "/etc/claude-code/managed-settings.d/50-chock.json"
+ assert plan["undo"] == [f"delete {step['to']}" for step in plan["place"]]
+
+
+def test_a_selection_with_nothing_to_run_writes_nothing(repo: Path, tmp_path: Path) -> None:
+ assert linux(repo, tmp_path / "out", "--policies", "yagni") == 1
+ assert not (tmp_path / "out").exists()
+
+
+def test_no_wording_stronger_than_the_label(repo: Path, tmp_path: Path, capsys) -> None:
+ """Ruling 7 (finding 6): no fail-closed, enforced or cannot-override claim in output, help, data, docstrings or changelog."""
+ assert linux(repo, tmp_path / "out", "--lock") == 0
+ with pytest.raises(SystemExit):
+ cli.main(["emit", "--help"])
+ texts = [
+ capsys.readouterr().out,
+ *(p.read_text(encoding="utf-8") for p in (tmp_path / "out" / "claude_code").rglob("*.json")),
+ ]
+ texts += [json.dumps(managed.CHANNELS), managed.__doc__ or "", claude_code.__doc__ or ""]
+ texts += [p.read_text(encoding="utf-8") for p in (ROOT / "changelog.d").glob("w2b1*.md")]
+ texts += [
+ p.read_text(encoding="utf-8")
+ for p in (ROOT / "src" / "chock" / "compile" / "emitters" / "managed").glob("*.py")
+ ]
+ assert not [text for text in texts if FAIL_CLOSED.search(text) or OVERRIDE_CLAIM.search(text)]
+ assert "writes no system path" not in "".join(texts)
+
+
+def test_docs_say_what_the_code_does() -> None:
+ """Ruling 3 (finding 3): no compiled managed-settings file, `chock emit` documented, no cannot-override claim."""
+ pages = {p.name: p.read_text(encoding="utf-8") for p in DOCS.rglob("*.md")}
+ assert not [name for name, text in pages.items() if "managed-setting/managed-settings.json" in text]
+ assert "chock emit --managed" in pages["cli-reference.md"]
+ assert not OVERRIDE_CLAIM.search(pages["compare.md"])
+ assert "a user cannot override" not in pages["compare.md"].lower()
diff --git a/tests/test_managed_emit_deploy_text.py b/tests/test_managed_emit_deploy_text.py
new file mode 100644
index 00000000..a85f8fc9
--- /dev/null
+++ b/tests/test_managed_emit_deploy_text.py
@@ -0,0 +1,186 @@
+"""Rulings 10-13: deploy.json names every stop file and client version, says what happens, and odd paths still run."""
+
+from __future__ import annotations
+
+import hashlib
+import os
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+from managed_emit_helpers import bundle_hook, drop_in, emit, env_for, handlers, linux, make_repo, plan_of, run_hook
+
+from chock.compile.emitters import managed
+
+CANARY = "git commit --no-verify -m x"
+DENY = '"permissionDecision": "deny"'
+HOOKS_DOC = "https://code.claude.com/docs/en/hooks"
+POSIX_GIT = pytest.mark.skipif(sys.platform == "win32" or not shutil.which("git"), reason="POSIX paths, git")
+
+#: Every deploy.json sentence that states a behaviour (by its opening words), and the test that proves it. A
+#: sentence about the vendor's own behaviour is proven by its quote: "vendor docs".
+SENTENCE_PROOF = {
+ "--on-failure block:": "test_a_missing_bundle_file_follows_on_failure, test_a_missing_guard_or_parser_follows_on_failure",
+ "--on-failure allow:": "test_a_missing_bundle_file_follows_on_failure, test_a_missing_guard_or_parser_follows_on_failure",
+ "Every machine needs Python 3.11": "test_too_old_a_python_follows_on_failure, test_user_interpreter_settings_do_not_switch_the_hook_off",
+ "onFailure needs Claude Code 2.1.295": "test_client_versions_are_quoted_with_the_date_read",
+ "Monitor commands are checked only": "test_client_versions_are_quoted_with_the_date_read",
+ "The bundle must sit at deploy_root": "test_odd_deploy_root_and_python_paths_still_start_the_bundle",
+ "The bundle folder and __PYTHON__": "vendor docs",
+ "Managed settings bind Claude Code only.": "vendor docs",
+ "On WSL,": "vendor docs",
+ "By default (managedSourcesBehavior": "vendor docs",
+ "onFailure has no effect on Stop hooks": "test_the_stop_gate_never_refuses_for_a_missing_runtime",
+ "A repository holding .chock/stop.json": "test_a_repo_stop_file_refuses_matched_calls_as_deploy_json_says",
+ "Files under the user's home folder": "test_each_user_stop_file_refuses_as_deploy_json_says",
+ "The bundled runtime runs git from PATH": "test_user_interpreter_settings_do_not_switch_the_hook_off",
+ "Hooks write their decision log": "test_the_decision_log_lands_under_the_users_home",
+ "A file in managed-settings.d": "vendor docs",
+ "The labels are vendor-docs evidence": "test_labels_are_vendor_docs_unwitnessed_and_capped",
+}
+SUITE = Path(__file__).parent
+
+
+def stated(plan: dict) -> list[str]:
+ return [plan["on_failure"]["consequence"], *plan["requirements"], *plan["caveats"]]
+
+
+@pytest.fixture
+def repo(tmp_path: Path) -> Path:
+ return make_repo(tmp_path)
+
+
+@pytest.mark.parametrize("choice", ["block", "allow"])
+def test_every_behaviour_sentence_has_a_proof(repo: Path, tmp_path: Path, choice: str) -> None:
+ """Ruling 12: a new sentence fails here until it names its test, and each named test exists."""
+ assert linux(repo, tmp_path / "out", on_failure=choice) == 0
+ sources = "".join(path.read_text(encoding="utf-8") for path in SUITE.glob("test_managed_emit_*.py"))
+ for sentence in stated(plan_of(tmp_path / "out")):
+ [proof] = [proof for opening, proof in SENTENCE_PROOF.items() if sentence.startswith(opening.split("__")[0])]
+ for name in (part.strip() for part in proof.split(",") if proof != "vendor docs"):
+ assert f"def {name}(" in sources, (sentence, name)
+
+
+@pytest.mark.parametrize(("choice", "code"), [("block", 2), ("allow", 0)])
+@pytest.mark.parametrize("missing", ["block-no-verify.py", "chock_shellparse"])
+def test_a_missing_guard_or_parser_follows_on_failure(repo, tmp_path, choice, code, missing) -> None:
+ """Ruling 12: allow lets the call through with a note, block refuses (exit 2), never an ask or a guard deny."""
+ bundle, hook = bundle_hook(repo, tmp_path, on_failure=choice)
+ target = bundle / "block-no-verify" / "scripts" / missing
+ shutil.rmtree(target) if target.is_dir() else target.unlink()
+ for command in (CANARY, "git status"):
+ done = run_hook(hook, command, tmp_path, env_for(tmp_path))
+ assert done.returncode == code and "permissionDecision" not in done.stdout, done.stdout + done.stderr
+ assert f"missing {target.as_posix()}" in done.stderr.replace("\\", "/") or missing in done.stderr
+ assert f"(--on-failure {choice})" in done.stderr
+
+
+def test_deploy_json_names_every_stop_file_with_its_effect(repo: Path, tmp_path: Path) -> None:
+ """Ruling 10: the repository's stop, the machine-wide stop, each registry entry, the unreadable registry."""
+ assert linux(repo, tmp_path / "out") == 0
+ stops = plan_of(tmp_path / "out")["stop_files"]
+ by_writer = {entry["path"].split(" ")[0]: entry for entry in stops}
+ assert set(by_writer) == {
+ ".chock/stop.json",
+ "~/.chock/stops/_everywhere.json",
+ "~/.chock/stops/.json",
+ "~/.chock/stops",
+ }
+ assert by_writer["~/.chock/stops/_everywhere.json"]["written_by"] == "chock stop --everywhere"
+ assert all(entry["effect"] and "refused" in entry["effect"] for entry in stops)
+
+
+@POSIX_GIT
+@pytest.mark.parametrize("which", ["everywhere", "registry", "unreadable"])
+def test_each_user_stop_file_refuses_as_deploy_json_says(repo: Path, tmp_path: Path, which: str) -> None:
+ """Ruling 10 / finding 3: each file under ~/.chock/stops refuses a harmless call; nothing there allows it."""
+ _, hook = bundle_hook(repo, tmp_path)
+ work = tmp_path / "work"
+ subprocess.run(["git", "init", "-q", str(work)], check=True)
+ env = env_for(tmp_path)
+ stops = Path(env["HOME"]) / ".chock" / "stops"
+ stops.parent.mkdir(parents=True, exist_ok=True)
+ if which == "unreadable":
+ stops.write_text("a file where the folder should be", encoding="utf-8")
+ else:
+ stops.mkdir()
+ key = hashlib.sha256(os.path.realpath(work).encode("utf-8")).hexdigest()
+ name = "_everywhere.json" if which == "everywhere" else f"{key}.json"
+ (stops / name).write_text("{}" if which == "everywhere" else '{"scope": "all"}', encoding="utf-8")
+ assert run_hook(hook, "git status", work, {**env, "CLAUDE_PROJECT_DIR": str(work)}).stdout.count(DENY) == 1
+
+
+@POSIX_GIT
+def test_the_decision_log_lands_under_the_users_home(repo: Path, tmp_path: Path) -> None:
+ _, hook = bundle_hook(repo, tmp_path)
+ env = {k: v for k, v in env_for(tmp_path).items() if not k.startswith("CHOCK_")} # the suite turns logging off
+ assert DENY in run_hook(hook, CANARY, tmp_path, env).stdout
+ assert any((Path(env["HOME"]) / ".chock" / "log").rglob("*")), "no decision record under ~/.chock/log"
+
+
+def test_client_versions_are_quoted_with_the_date_read(repo: Path, tmp_path: Path) -> None:
+ """Ruling 11: the failure key's and the Monitor matcher's client versions, quoted and dated; what is not covered."""
+ assert linux(repo, tmp_path / "out") == 0
+ plan = plan_of(tmp_path / "out")
+ versions = {entry["min_client"]: entry for entry in plan["client_versions"]}
+ assert set(versions) == {"2.1.295", "2.1.314"}
+ for version, entry in versions.items():
+ assert f"Claude Code v{version} or later" in entry["quote"] and entry["source"] == HOOKS_DOC
+ assert entry["read"] == "2026-11-13"
+ assert "Monitor" in versions["2.1.314"]["quote"]
+ text = " ".join(plan["not_covered"])
+ for gap in ("older than 2.1.314", "WebSocket watches", "MCP tools"):
+ assert gap in text, gap
+ matchers = "|".join(group["matcher"] for group in drop_in(tmp_path / "out")["hooks"]["PreToolUse"])
+ assert "Bash|PowerShell" in matchers and "mcp__" not in matchers and "Monitor" not in matchers
+
+
+ODD = "odd dir 'q' \"dq\" $HOME `tick` ünï"
+
+
+@pytest.mark.skipif(sys.platform == "win32", reason="POSIX symlink and file names")
+def test_odd_deploy_root_and_python_paths_still_start_the_bundle(repo: Path, tmp_path: Path) -> None:
+ """Ruling 13: spaces, quotes, `$`, a backquote and non-ASCII in both paths; the emitted argv still runs."""
+ base = tmp_path / ODD
+ base.mkdir()
+ python = base / f"py {ODD}"
+ python.symlink_to(sys.executable)
+ out = base / "out"
+ root = (out / "claude_code" / "bundle").as_posix()
+ assert emit(repo, out, "--policies", "block-no-verify", "--deploy-root", root, python=str(python)) == 0
+ [(_, hook), *_] = handlers(drop_in(out))
+ assert hook["command"] == str(python) and any(arg.startswith(root) for arg in hook["args"])
+ env = env_for(tmp_path)
+ assert DENY in run_hook(hook, CANARY, tmp_path, env).stdout
+ allowed = run_hook(hook, "git status", tmp_path, env)
+ assert allowed.returncode == 0 and "permissionDecision" not in allowed.stdout, allowed.stderr
+
+
+#: (path as given, platform, its comparable spelling, the system root it names or None for an ordinary folder).
+SPELLINGS = [
+ ("//etc//x", "linux", "/etc//x", "/etc"),
+ ("/Etc/x", "linux", "/Etc/x", None),
+ ("/etcetera/x", "linux", "/etcetera/x", None),
+ ("/home/me/etc", "linux", "/home/me/etc", None),
+ ("/srv-data/x", "linux", "/srv-data/x", None),
+ ("/LIBRARY/x", "macos", "/library/x", "/Library"),
+ ("/Users/me/Library/x", "macos", "/users/me/library/x", None),
+ ("/Volumes/Data/out", "macos", "/volumes/data/out", None),
+ ("C:\\Program Files\\x", "windows", "c:/program files/x", "C:/Program Files"),
+ ("\\\\?\\C:\\Windows\\x", "windows", "c:/windows/x", "C:/Windows"),
+ ("\\\\host\\D$\\x", "windows", "d:/x", None),
+ ("\\\\?\\UNC\\host\\c$\\ProgramData", "windows", "c:/programdata", "C:/ProgramData"),
+ ("C:/Users//Me/out", "windows", "c:/users/me/out", None),
+ ("C:/Users/me/Program Files/x", "windows", "c:/users/me/program files/x", None),
+ ("C:/ProgramDataX/x", "windows", "c:/programdatax/x", None),
+ ("D:/out", "windows", "d:/out", None),
+]
+
+
+@pytest.mark.parametrize(("given", "platform", "spelling", "root"), SPELLINGS)
+def test_output_guard_normalisation_table(given: str, platform: str, spelling: str, root: str | None) -> None:
+ """Ruling 13: each spelling the guard compares, and whether it is refused; ordinary folders stay allowed."""
+ assert managed.spelled(given, platform) == spelling
+ assert managed.root_named(given, platform) == root
diff --git a/tests/test_managed_emit_isolation.py b/tests/test_managed_emit_isolation.py
new file mode 100644
index 00000000..e60a04e6
--- /dev/null
+++ b/tests/test_managed_emit_isolation.py
@@ -0,0 +1,142 @@
+"""Ruling 9: every child interpreter the shared runtime starts is isolated; hostile PYTHON* values change no verdict."""
+
+from __future__ import annotations
+
+import json
+import os
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+from managed_emit_helpers import bundle_hook, env_for, make_repo, run_hook
+
+from chock.doctor.payloads import payload
+from chock.gate import budget
+from chock.hooks import launch
+
+CANARY = "git commit --no-verify -m x"
+HARMLESS = "git status"
+#: Each variable the review proved or suspected: ends the guard early, breaks its start-up, or drops its folder.
+POSIX_GIT = pytest.mark.skipif(sys.platform == "win32" or not shutil.which("git"), reason="POSIX sh and git")
+HOSTILE = ("PYTHONPATH", "PYTHONHOME", "PYTHONPLATLIBDIR", "PYTHONSAFEPATH", "PYTHONSTARTUP")
+
+
+def hostile_value(name: str, evil: Path) -> str:
+ return {
+ "PYTHONPATH": str(evil),
+ "PYTHONHOME": str(evil / "no-such-home"),
+ "PYTHONPLATLIBDIR": "nope",
+ "PYTHONSAFEPATH": "1",
+ "PYTHONSTARTUP": str(evil / "sitecustomize.py"),
+ }[name]
+
+
+@pytest.fixture
+def evil(tmp_path: Path) -> Path:
+ """A folder whose sitecustomize ends any interpreter that loads it with exit 0 and no decision."""
+ folder = tmp_path / "evil"
+ folder.mkdir()
+ (folder / "sitecustomize.py").write_text("import os\nos._exit(0)\n", encoding="utf-8")
+ return folder
+
+
+@pytest.fixture
+def bundle(tmp_path: Path) -> tuple[Path, dict]:
+ return bundle_hook(make_repo(tmp_path), tmp_path)
+
+
+def project_hook(scripts: Path, command: str, cwd: Path, env: dict[str, str]) -> subprocess.CompletedProcess:
+ """The project entry (`claude_code.py --guard ...`) started isolated, so only its children see `env`'s PYTHON*."""
+ return subprocess.run(
+ [sys.executable, "-I", str(scripts / "claude_code.py"), "--guard", str(scripts / "block-no-verify.py")],
+ input=json.dumps(payload("claude_code", command, cwd.as_posix())),
+ capture_output=True,
+ text=True,
+ cwd=cwd,
+ env=env,
+ check=False,
+ timeout=60,
+ )
+
+
+def assert_verdicts(denied: subprocess.CompletedProcess, allowed: subprocess.CompletedProcess) -> None:
+ assert denied.returncode == allowed.returncode == 0, denied.stderr + allowed.stderr
+ assert '"permissionDecision": "deny"' in denied.stdout, denied.stdout + denied.stderr
+ assert "permissionDecision" not in allowed.stdout, allowed.stdout + allowed.stderr
+
+
+@pytest.mark.parametrize("name", HOSTILE)
+def test_managed_route_ignores_hostile_python_variables(name, bundle, evil, tmp_path) -> None:
+ """The reviewer's proof (t_batch1.py section 5): the canary is still refused, a harmless call still allowed."""
+ _, hook = bundle
+ env = env_for(tmp_path, **{name: hostile_value(name, evil)})
+ assert_verdicts(run_hook(hook, CANARY, tmp_path, env), run_hook(hook, HARMLESS, tmp_path, env))
+
+
+@pytest.mark.parametrize("name", HOSTILE)
+def test_project_route_children_ignore_hostile_python_variables(name, bundle, evil, tmp_path) -> None:
+ """The project entry hands the guard child the same hostile environment; the child is isolated all the same."""
+ root, _ = bundle
+ scripts = root / "block-no-verify" / "scripts"
+ env = env_for(tmp_path, **{name: hostile_value(name, evil)})
+ assert_verdicts(project_hook(scripts, CANARY, tmp_path, env), project_hook(scripts, HARMLESS, tmp_path, env))
+
+
+def test_isolated_child_drops_every_python_variable_and_keeps_bytecode_off(tmp_path: Path) -> None:
+ script = tmp_path / "s.py"
+ argv, env = budget.isolated_child(
+ [sys.executable, script, "a"], {"PYTHONPATH": "x", "pythonhome": "y", "PATH": "/bin", "HOME": "/h"}
+ )
+ assert argv[:2] == [sys.executable, "-I"] and argv[-2:] == [str(script), "a"]
+ assert env == {"PATH": "/bin", "HOME": "/h", **budget.BYTECODE_OFF}
+
+
+def test_an_isolated_child_imports_from_its_own_folder_only(tmp_path: Path, evil: Path) -> None:
+ """Its own folder is on sys.path (a guard's chock_shellparse), the current folder and PYTHONPATH are not."""
+ own = tmp_path / "own"
+ own.mkdir()
+ (own / "helper.py").write_text("WHO = 'own'\n", encoding="utf-8")
+ (evil / "helper.py").write_text("WHO = 'evil'\n", encoding="utf-8")
+ (own / "main.py").write_text("import sys, helper\nprint(helper.WHO, sys.argv[1:])\n", encoding="utf-8")
+ argv, env = budget.isolated_child([sys.executable, own / "main.py", "x y"], dict(os.environ))
+ done = subprocess.run(
+ argv, env={**env, "PYTHONPATH": str(evil)}, cwd=evil, capture_output=True, text=True, check=False
+ )
+ assert done.stdout.strip() == "own ['x y']", done.stderr
+
+
+def launched(folder: Path, command: str, cwd: Path, env: dict[str, str]) -> subprocess.CompletedProcess:
+ """The runtime in `folder` started through chock's launcher, as a project or plugin hook command starts it."""
+ return subprocess.run(
+ [
+ "sh",
+ str(folder / "launch.sh"),
+ str(folder / "claude_code.py"),
+ "--guard",
+ str(folder / "block-no-verify.py"),
+ ],
+ input=json.dumps(payload("claude_code", command, cwd.as_posix())),
+ capture_output=True,
+ text=True,
+ cwd=cwd,
+ env=env,
+ check=False,
+ timeout=60,
+ )
+
+
+@POSIX_GIT
+@pytest.mark.parametrize("route", ["project", "plugin"])
+@pytest.mark.parametrize("name", [None, *HOSTILE])
+def test_the_launcher_starts_the_runtime_isolated(route, name, bundle, evil, tmp_path) -> None:
+ """Ruling 9 on the launcher routes: the outer interpreter is isolated too, before and with each hostile value."""
+ root, _ = bundle
+ work = tmp_path / "work"
+ subprocess.run(["git", "init", "-q", str(work)], check=True)
+ folder = work / ".chock" / "bin" if route == "project" else tmp_path / "plugin" / "scripts"
+ shutil.copytree(root / "block-no-verify" / "scripts", folder)
+ (folder / "launch.sh").write_text(launch.launcher_text(), encoding="utf-8", newline="\n")
+ env = env_for(tmp_path, **({} if name is None else {name: hostile_value(name, evil)}))
+ assert_verdicts(launched(folder, CANARY, work, env), launched(folder, HARMLESS, work, env))
diff --git a/tests/test_managed_emit_runs.py b/tests/test_managed_emit_runs.py
new file mode 100644
index 00000000..c8a7719b
--- /dev/null
+++ b/tests/test_managed_emit_runs.py
@@ -0,0 +1,198 @@
+"""`chock emit --managed claude_code`: the emitted hooks run as stated, the guard refuses system paths, refusals are clean."""
+
+from __future__ import annotations
+
+import json
+import os
+import shutil
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+from managed_emit_helpers import (
+ bundle_hook,
+ drop_in,
+ env_for,
+ handlers,
+ linux,
+ make_repo,
+ one_line_refusal,
+ plan_of,
+ run_hook,
+)
+
+from chock.compile.emitters import managed
+from chock.compile.emitters.managed import claude_code
+
+
+@pytest.fixture
+def repo(tmp_path: Path) -> Path:
+ return make_repo(tmp_path)
+
+
+def test_the_bundle_runs_on_its_own(repo: Path, tmp_path: Path) -> None:
+ """The emitted handler, rooted at the bundle itself, refuses the canary and allows a harmless call."""
+ _, hook = bundle_hook(repo, tmp_path)
+ env = env_for(tmp_path)
+ denied, allowed = (
+ run_hook(hook, "git commit --no-verify -m x", tmp_path, env),
+ run_hook(hook, "git status", tmp_path, env),
+ )
+ assert denied.returncode == allowed.returncode == 0, denied.stderr + allowed.stderr
+ assert '"permissionDecision": "deny"' in denied.stdout
+ assert "deny" not in allowed.stdout
+
+
+@pytest.mark.skipif(sys.platform == "win32" or not shutil.which("git"), reason="POSIX stubs and git config")
+def test_user_interpreter_settings_do_not_switch_the_hook_off(repo: Path, tmp_path: Path) -> None:
+ """Finding 1: chock.python set to a stub (local and global) and stub python3, python, sh, git first on PATH."""
+ _, hook = bundle_hook(repo, tmp_path)
+ stubs = tmp_path / "stubs"
+ stubs.mkdir()
+ for name in ("python3", "python", "py", "sh", "git"):
+ stub = stubs / name
+ stub.write_text("#!/bin/sh\nprintf chock-python >&9 2>/dev/null; exit 0\n", encoding="utf-8")
+ stub.chmod(0o755)
+ work = tmp_path / "work"
+ work.mkdir()
+ subprocess.run(["git", "init", "-q", str(work)], check=True)
+ subprocess.run(["git", "-C", str(work), "config", "chock.python", str(stubs / "python3")], check=True)
+ global_config = tmp_path / "gitconfig"
+ global_config.write_text(f"[chock]\n\tpython = {stubs / 'python3'}\n", encoding="utf-8")
+ env = env_for(
+ tmp_path,
+ PATH=f"{stubs}{os.pathsep}{os.environ.get('PATH', '')}",
+ GIT_CONFIG_GLOBAL=str(global_config),
+ PYTHONPATH=str(stubs),
+ PYTHONSTARTUP=str(stubs / "python3"),
+ )
+ for cwd in (work, tmp_path):
+ done = run_hook(hook, "git commit --no-verify -m x", cwd, env)
+ assert done.returncode == 0, done.stderr
+ assert '"permissionDecision": "deny"' in done.stdout
+
+
+@pytest.mark.parametrize(("choice", "code"), [("block", 2), ("allow", 0)])
+def test_a_missing_bundle_file_follows_on_failure(repo: Path, tmp_path: Path, choice: str, code: int) -> None:
+ """Ruling 2: block refuses (exit 2) and allow lets the call through, each with a note on stderr."""
+ bundle, hook = bundle_hook(repo, tmp_path, on_failure=choice)
+ (bundle / "block-no-verify" / "scripts" / "_chock_runtime.py").unlink()
+ done = run_hook(hook, "git status", tmp_path, env_for(tmp_path))
+ assert done.returncode == code
+ assert done.stderr.startswith("chock: missing ") and f"--on-failure {choice}" in done.stderr
+ assert done.stdout == ""
+
+
+@pytest.mark.parametrize(("choice", "code"), [("block", 2), ("allow", 0)])
+def test_too_old_a_python_follows_on_failure(choice: str, code: int) -> None:
+ """Ruling 2: the version check runs before any runtime code; here the minimum is raised past this Python."""
+ program = claude_code.bootstrap(choice).replace("(3, 11,)", "(99,)")
+ done = subprocess.run(
+ [sys.executable, "-I", "-c", program, __file__], capture_output=True, text=True, check=False, timeout=60
+ )
+ assert done.returncode == code
+ assert "this hook needs Python" in done.stderr and f"--on-failure {choice}" in done.stderr
+
+
+def test_the_stop_gate_never_refuses_for_a_missing_runtime(repo: Path, tmp_path: Path) -> None:
+ """onFailure has no effect on Stop, and exit 2 there sends Claude back to work: the turn-end gate notes and exits 0."""
+ assert linux(repo, tmp_path / "out", "--policies", "scan-secrets") == 0
+ stop = [hook for event, hook in handlers(drop_in(tmp_path / "out")) if event == "Stop"]
+ assert stop and all("sys.exit(0)" in hook["args"][4] for hook in stop)
+
+
+@pytest.mark.parametrize(
+ ("path", "platform"),
+ [
+ ("/", "linux"),
+ ("//etc/x", "linux"),
+ ("/var/lib/x", "linux"),
+ ("/srv/x", "linux"),
+ ("/root/x", "linux"),
+ ("/run/x", "linux"),
+ ("/sys/x", "linux"),
+ ("/proc/x", "linux"),
+ ("/", "macos"),
+ ("/LIBRARY/Application Support/ClaudeCode/x", "macos"),
+ ("/system/x", "macos"),
+ ("/private/etc/x", "macos"),
+ ("C:/", "windows"),
+ ("D:\\", "windows"),
+ ("c:\\program files\\ClaudeCode", "windows"),
+ ("\\\\?\\C:\\Program Files\\x", "windows"),
+ ("\\\\.\\C:\\Windows\\x", "windows"),
+ ("\\\\localhost\\C$\\Program Files\\x", "windows"),
+ ("\\\\?\\UNC\\server\\c$\\Windows", "windows"),
+ ],
+)
+def test_every_system_spelling_is_refused(path: str, platform: str) -> None:
+ """Finding 4: filesystem roots, the listed trees, case-insensitive spellings, device and admin-share prefixes."""
+ assert managed.root_named(path, platform) is not None
+
+
+@pytest.mark.parametrize(
+ ("path", "platform"),
+ [("/home/me/out", "linux"), ("/tmp/out", "linux"), ("/Users/me/out", "macos"), ("C:/Users/me/out", "windows")],
+)
+def test_ordinary_folders_are_allowed(path: str, platform: str) -> None:
+ assert managed.root_named(path, platform) is None
+
+
+def test_out_naming_a_file_is_refused_cleanly(repo: Path, tmp_path: Path, capsys) -> None:
+ """Finding 5."""
+ afile = tmp_path / "afile"
+ afile.write_text("x", encoding="utf-8")
+ assert linux(repo, afile) == 1
+ assert "is not a folder" in one_line_refusal(capsys)
+ assert afile.read_text(encoding="utf-8") == "x"
+
+
+@pytest.mark.parametrize("name", ["manifest.yaml", "block-no-verify.py"])
+def test_a_non_utf8_policy_file_is_refused_cleanly(repo: Path, tmp_path: Path, name: str, capsys) -> None:
+ """Finding 5: a non-UTF-8 manifest or guard."""
+ [target] = list((repo / ".agents" / "policies" / "block-no-verify").rglob(name))
+ target.write_bytes(target.read_bytes() + b"\xe9\n")
+ assert linux(repo, tmp_path / "out", "--policies", "block-no-verify") == 1
+ assert "is not UTF-8 text" in one_line_refusal(capsys)
+ assert not (tmp_path / "out").exists()
+
+
+def test_a_missing_repo_is_refused_cleanly(tmp_path: Path, capsys) -> None:
+ """Findings 5, 9: says the folder is missing, not that no policy has a guard."""
+ assert linux(tmp_path / "does-not-exist", tmp_path / "out") == 1
+ assert "is not a folder" in one_line_refusal(capsys)
+
+
+def test_deploy_json_states_ownership_stop_file_and_lock_effects(repo: Path, tmp_path: Path) -> None:
+ """Ruling 6 (findings 7, 9): admin-owned bundle with the vendor's words, the repo stop, every --lock side effect."""
+ assert linux(repo, tmp_path / "out", "--lock") == 0
+ plan = plan_of(tmp_path / "out")
+ text = json.dumps(plan)
+ assert any("owned by an administrator and not writable by users" in line for line in plan["requirements"])
+ assert "can edit the managed source itself" in text
+ assert any(".chock/stop.json" in line and "refuse every tool call" in line for line in plan["caveats"])
+ lock = plan["notes"][-1]
+ for effect in (
+ "user, project and local hooks",
+ "hooks in agent frontmatter",
+ "monitors of other plugins",
+ "command source are disabled",
+ "headersHelper",
+ "status line and file suggestion",
+ "/goal",
+ "force-enable",
+ ):
+ assert effect in lock, effect
+
+
+@pytest.mark.skipif(sys.platform == "win32" or not shutil.which("git"), reason="POSIX paths, a git repository")
+def test_a_repo_stop_file_refuses_matched_calls_as_deploy_json_says(repo: Path, tmp_path: Path) -> None:
+ """Finding 7: the behaviour the caveat states, proven."""
+ _, hook = bundle_hook(repo, tmp_path)
+ work = tmp_path / "stopped"
+ (work / ".chock").mkdir(parents=True)
+ (work / ".chock" / "stop.json").write_text("not json", encoding="utf-8")
+ subprocess.run(["git", "init", "-q", str(work)], check=True)
+ done = run_hook(hook, "ls", work, env_for(tmp_path))
+ assert done.returncode == 0 and '"permissionDecision": "deny"' in done.stdout
diff --git a/tests/test_output_legible_once.py b/tests/test_output_legible_once.py
new file mode 100644
index 00000000..1308e405
--- /dev/null
+++ b/tests/test_output_legible_once.py
@@ -0,0 +1,98 @@
+"""IR-F75: each defaulted manifest field is said once per command, with its path. IR-F76: no character a console cannot show."""
+
+from __future__ import annotations
+
+import io
+import re
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+from chock.cli import main
+from chock.eval.model import Case, CaseResult, PolicyResult
+from chock.eval.report import render_text
+from chock.output import ellipsis, legible, new_command, warn
+from chock.pipe import PipeTolerantWriter
+
+DEFAULTED = re.compile(r"defaulted (\S+) to ")
+SKILL = ".agents/skills/demo"
+
+
+def _repo_with_bare_skill(root: Path) -> Path:
+ subprocess.run(["git", "init", "-q", str(root)], check=True)
+ skill = root / SKILL
+ skill.mkdir(parents=True)
+ (skill / "SKILL.md").write_text("---\nname: demo\ndescription: A demo skill.\n---\n# Demo\n", encoding="utf-8")
+ return root
+
+
+def _cp1252() -> io.TextIOWrapper:
+ return io.TextIOWrapper(io.BytesIO(), encoding="cp1252")
+
+
+def test_check_says_each_defaulted_field_once_and_names_the_skill(tmp_path: Path, capsys, monkeypatch) -> None:
+ repo = _repo_with_bare_skill(tmp_path)
+ monkeypatch.chdir(repo)
+
+ main(["check", "--repo", "."])
+
+ captured = capsys.readouterr()
+ lines = (captured.err + captured.out).splitlines()
+ defaulted = [line for line in lines if DEFAULTED.search(line)]
+ fields = [DEFAULTED.search(line).group(1) for line in defaulted]
+ assert "version" in fields
+ assert len(fields) == len(set(fields)), defaulted
+ assert all(SKILL in line for line in defaulted), defaulted
+
+
+def test_a_second_command_in_the_same_process_says_them_again(tmp_path: Path, capsys, monkeypatch) -> None:
+ repo = _repo_with_bare_skill(tmp_path)
+ monkeypatch.chdir(repo)
+ counts = []
+ for _ in range(2):
+ main(["check", "--repo", "."])
+ captured = capsys.readouterr()
+ counts.append(sum("defaulted version" in line for line in (captured.out + captured.err).splitlines()))
+ assert counts == [1, 1]
+
+
+def _long_result() -> PolicyResult:
+ case = Case(id="c1", category="block", prompt="p", expect="block", policy_id="demo")
+ return PolicyResult("demo", "deterministic", [CaseResult(case, "fail", detail="x" * 200)])
+
+
+def test_the_eval_table_on_a_cp1252_stream_has_no_ellipsis_character(monkeypatch) -> None:
+ stream = _cp1252()
+ monkeypatch.setattr(sys, "stdout", stream)
+
+ PipeTolerantWriter(stream).write(render_text([_long_result()]))
+ stream.flush()
+
+ text = stream.buffer.getvalue().decode("cp1252")
+ assert "\u2026" not in text
+ assert "x" * 60 + "..." in text
+
+
+def test_a_utf8_stream_keeps_the_ellipsis(monkeypatch) -> None:
+ monkeypatch.setattr(sys, "stdout", io.TextIOWrapper(io.BytesIO(), encoding="utf-8"))
+ assert ellipsis() == "\u2026"
+ assert "\u2026" in render_text([_long_result()])
+
+
+@pytest.mark.parametrize(
+ ("text", "shown"),
+ [("a \u2014 b", "a -- b"), ("x \u2192 y", "x -> y"), ("\u00a75", "s.5"), ("caf\u00e9 \u20ac", "caf\u00e9 \u20ac")],
+)
+def test_legible_turns_chock_symbols_into_ascii_on_a_legacy_code_page(text: str, shown: str) -> None:
+ assert legible(text, _cp1252()) == shown
+
+
+def test_warn_on_a_cp1252_stderr_never_raises_and_prints_ascii(monkeypatch) -> None:
+ stream = _cp1252()
+ monkeypatch.setattr(sys, "stderr", stream)
+ new_command()
+ warn("lock \u2014 run the regen \u2026")
+ stream.flush()
+ assert stream.buffer.getvalue().decode("ascii") == "[WARN] lock -- run the regen ...\n"
diff --git a/tests/test_readme_derived.py b/tests/test_readme_derived.py
index 7cdbcd0c..f3a78e51 100644
--- a/tests/test_readme_derived.py
+++ b/tests/test_readme_derived.py
@@ -76,3 +76,21 @@ def entry(pid: str, status: str) -> dict:
assert data["eval_cases"] == 3 * live
assert data["eval_executed"] == 2 * live
assert sum(data["tiers"].values()) == live
+
+
+def test_witnessed_clients_group_by_the_platform_the_ledger_records() -> None:
+ from chock.evidence import Witness
+
+ trusted = "x, after the project's hooks were trusted (y)"
+ rows = [
+ Witness("vscode_copilot", "agent-hooks", "Copilot CLI and VS Code agent mode", "2026-08-23", "live probe"),
+ Witness("claude_code", "agent-hooks", "Claude Code v2.1.317, Windows", "2026-11-11", "live probe"),
+ Witness("codex_cli", "agent-hooks", "Codex CLI 0.169.0, Windows", "2026-11-14", trusted),
+ ]
+ text = _derive().witnessed_clients(rows)
+ assert text == (
+ "Copilot CLI and VS Code agent mode and, on Windows, in Claude Code and Codex CLI "
+ "(Codex after the project's hooks were trusted)"
+ )
+ assert text.index("Windows") > text.index("Copilot CLI and VS Code agent mode")
+ assert _derive().witnessed_clients(rows[1:2]) == "on Windows, in Claude Code"
diff --git a/tests/test_readme_picture.py b/tests/test_readme_picture.py
new file mode 100644
index 00000000..29ec2141
--- /dev/null
+++ b/tests/test_readme_picture.py
@@ -0,0 +1,88 @@
+"""The README's 'How it works' harness figure is tied to its data file, the agentseam events, the engine and the docs."""
+
+from __future__ import annotations
+
+import json
+
+from readme_figure_support import FIGURE, OTHER_POINTS, ROOT, crowded, engine_acts
+
+PNG = "docs/assets/readme/v2/where-chock-sits.png"
+HARNESS = FIGURE["harness"]
+CARDS = {c["id"] for c in HARNESS["cards"] + HARNESS["repo_cards"]}
+
+
+def test_figure_sits_directly_under_how_it_works_with_the_data_alt() -> None:
+ text = (ROOT / "README.md").read_text(encoding="utf-8")
+ first = text.split("## How it works\n\n", 1)[1].split("\n", 1)[0]
+ assert first.startswith(" None:
+ from agentseam import contract
+
+ points = FIGURE["points"]
+ assert {p["id"] for p in points if p["source"] == "agentseam"} == set(contract.EVENTS)
+ assert {p["id"] for p in points if p["source"] == "chock"} == OTHER_POINTS
+ assert len({p["id"] for p in points}) == len(points)
+
+
+def test_every_badge_sits_on_exactly_one_card_and_the_model_has_none() -> None:
+ assert all(p["on"] in CARDS for p in FIGURE["points"])
+ assert not [p for p in FIGURE["points"] if p["on"] == "model"]
+ mapping = {p["id"]: p["on"] for p in FIGURE["points"]}
+ assert mapping["pre_tool"] == mapping["post_tool"] == mapping["tool_failure"] == "gate"
+ assert mapping["stop"] == "loop" and mapping["mcp-gateway"] == "external"
+ assert {mapping[i] for i in ("git-commit", "git-push", "ci-gate")} == {"commit", "push", "ci"}
+
+
+def test_filled_badges_equal_what_the_engine_acts_on_and_each_has_a_proving_test() -> None:
+ assert {p["id"] for p in FIGURE["points"] if p["acts"]} == engine_acts()
+ for point in FIGURE["points"]:
+ assert bool(point["proof"]) == point["acts"], point["id"]
+ for rel in point["proof"]:
+ assert (ROOT / rel).is_file(), rel
+
+
+def test_card_lines_are_at_most_six_words_and_arrow_labels_two() -> None:
+ assert all(len(c["line"].split()) <= 6 for c in HARNESS["cards"] + HARNESS["repo_cards"])
+ assert all(len(label.split()) <= 2 for label in HARNESS["arrows"].values())
+
+
+def test_no_prompt_submit_hook_is_wired_so_none_is_filled() -> None:
+ sources = " ".join(p.read_text(encoding="utf-8") for p in (ROOT / "src" / "chock").rglob("*.py"))
+ assert "PROMPT_SUBMIT" not in sources
+ assert not [p for p in FIGURE["points"] if p["id"] == "prompt_submit" and p["acts"]]
+
+
+def test_no_two_shapes_of_the_harness_layout_are_too_close() -> None:
+ assert crowded("where-chock-sits") == []
+
+
+def test_components_are_generic_and_the_stops_end_with_a_sixth_chip() -> None:
+ text = str({k: v for k, v in FIGURE.items() if k not in ("_", "points")}).lower()
+ for vendor in ("claude", "cursor", "copilot", "codex", "gemini", "devin"):
+ assert vendor not in text, vendor
+ own = FIGURE["own"]
+ assert own["label"] == "+ your own policy" and own["command"] == "chock new policy"
+ assert FIGURE["stops_title"] == "What it stops, for example"
+ assert len(FIGURE["stops"]) == 5 and own["label"] not in FIGURE["stops"]
+ assert all(len(chip.split()) <= 4 for chip in FIGURE["stops"])
+ commands = json.loads((ROOT / "src" / "chock" / "data" / "commands.json").read_text(encoding="utf-8"))
+ assert "new" in commands["authoring"]
+
+
+def test_architecture_doc_shows_the_harness_then_the_session_path_and_lists_every_point() -> None:
+ doc = (ROOT / "docs" / "architecture.md").read_text(encoding="utf-8")
+ assert doc.index("assets/readme/v2/where-chock-sits.png") < doc.index("assets/readme/v2/session-path.png")
+ assert doc.index("assets/readme/v2/session-path.png") < doc.index("assets/architecture.svg")
+ assert f'alt="{HARNESS["alt"]}"' in doc and f'alt="{FIGURE["path"]["alt"]}"' in doc
+ for point in FIGURE["points"]:
+ assert f"**{point['name']}**" in doc and point["line"] in doc, point["id"]
+
+
+def test_renderer_registers_both_figures() -> None:
+ render = (ROOT / "docs" / "assets" / "readme" / "render.mjs").read_text(encoding="utf-8")
+ assert "'v2/where-chock-sits': WHERE" in render and "'v2/session-path': SESSION_PATH" in render
+ for name in ("where-chock-sits", "session-path"):
+ assert (ROOT / "docs" / "assets" / "readme" / "v2" / f"{name}.png").stat().st_size > 10_000
diff --git a/tests/test_script_gate_tiers.py b/tests/test_script_gate_tiers.py
new file mode 100644
index 00000000..f3018244
--- /dev/null
+++ b/tests/test_script_gate_tiers.py
@@ -0,0 +1,127 @@
+"""A script gate whose findings carry a tier takes its verdict from the findings the change adds.
+
+The toy script computes its exit code over every finding in the files, old ones included, as real
+scripts do; the tier on each finding is what lets the engine ignore the old ones.
+"""
+
+from __future__ import annotations
+
+import json
+import subprocess
+import textwrap
+from pathlib import Path
+
+import pytest
+from findings_support import repo_with
+
+from chock.gate.runner.verdict import judge
+
+#: BLOCKME lines are block-tier findings, ASKME lines ask-tier, WARNME lines warn-tier, ODDME a tier the protocol lacks.
+#: TOY_TIERS=off drops the tier field; TOY_TIERS=partial drops it from ASKME findings only.
+TOY = textwrap.dedent(
+ """\
+ import json, os, sys
+ payload = json.load(sys.stdin)
+ tiers = {"BLOCKME": "block", "ASKME": "ask", "WARNME": "warn", "ODDME": "severe"}
+ mode = os.environ.get("TOY_TIERS", "on")
+ findings = []
+ for path, text in payload["writes"].items():
+ for number, line in enumerate(text.splitlines(), 1):
+ for word, tier in tiers.items():
+ if word in line:
+ item = {"key": word + ":" + line.strip(), "path": path, "line": number, "message": tier + " " + line}
+ if mode == "on" or (mode == "partial" and word != "ASKME"):
+ item["tier"] = tier
+ findings.append(item)
+ print(json.dumps({"findings": findings}))
+ kinds = {item["message"].split()[0] for item in findings}
+ if "block" in kinds or "severe" in kinds:
+ sys.exit(1)
+ sys.exit(3 if "ask" in kinds else 4 if kinds else 0)
+ """
+)
+
+OLD = "x = BLOCKME\n"
+COMMIT, WRITE = "commit", "pre-tool-use"
+
+
+def _gate(repo: Path, action: str = "block") -> Path:
+ (repo / "toy.py").write_text(TOY, encoding="utf-8")
+ gate = repo / "gate.json"
+ spec = {"kind": "script", "on": ["commit", "tool_use"], "action": action, "message": "m"}
+ gate.write_text(json.dumps({**spec, "params": {"script": "toy.py"}}), encoding="utf-8")
+ return gate
+
+
+def _verdict(gate: Path, repo: Path, event: str, text: str) -> str:
+ """The verdict of changing app.py to `text`, as a commit stages it or an agent writes it."""
+ if event == COMMIT:
+ (repo / "app.py").write_text(text, encoding="utf-8")
+ subprocess.run(["git", "add", "app.py"], cwd=repo, check=True)
+ return judge(gate, COMMIT, None, repo)[1]
+ return judge(gate, event, None, repo, writes={"app.py": text})[1]
+
+
+@pytest.fixture(params=[COMMIT, WRITE])
+def event(request: pytest.FixtureRequest) -> str:
+ return request.param
+
+
+def test_a_new_ask_finding_beside_an_old_block_finding_asks(tmp_path: Path, event: str) -> None:
+ repo = repo_with(tmp_path, **{"app.py": OLD})
+ assert _verdict(_gate(repo), repo, event, OLD + "y = ASKME\n") == "ask"
+
+
+def test_a_new_block_finding_beside_an_old_one_blocks(tmp_path: Path, event: str) -> None:
+ repo = repo_with(tmp_path, **{"app.py": OLD})
+ assert _verdict(_gate(repo), repo, event, OLD + "y = BLOCKME two\n") == "block"
+
+
+def test_touching_only_old_findings_allows(tmp_path: Path, event: str) -> None:
+ repo = repo_with(tmp_path, **{"app.py": OLD})
+ assert _verdict(_gate(repo), repo, event, "# top\n" + OLD) == "allow"
+
+
+def test_the_highest_tier_among_new_findings_decides(tmp_path: Path, event: str) -> None:
+ repo = repo_with(tmp_path, **{"app.py": "x = 1\n"})
+ assert _verdict(_gate(repo), repo, event, "a = WARNME\nb = ASKME\n") == "ask"
+ assert _verdict(_gate(repo), repo, event, "a = WARNME\n") == "warn"
+
+
+def test_the_refusal_text_lists_only_the_new_finding(tmp_path: Path, capsys: pytest.CaptureFixture) -> None:
+ repo = repo_with(tmp_path, **{"app.py": OLD})
+ _verdict(_gate(repo), repo, WRITE, OLD + "y = ASKME\n")
+ err = capsys.readouterr().err
+ assert "app.py:2: ask y = ASKME" in err
+ assert "x = BLOCKME" not in err
+
+
+def test_the_declared_action_still_caps_a_block_tier_finding(tmp_path: Path, event: str) -> None:
+ repo = repo_with(tmp_path, **{"app.py": "x = 1\n"})
+ assert _verdict(_gate(repo, "ask"), repo, event, "y = BLOCKME\n") == "ask"
+
+
+def test_a_script_with_no_tiers_keeps_its_exit_code(
+ tmp_path: Path, event: str, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ monkeypatch.setenv("TOY_TIERS", "off")
+ repo = repo_with(tmp_path, **{"app.py": OLD})
+ assert _verdict(_gate(repo), repo, event, OLD + "y = ASKME\n") == "block"
+
+
+def test_one_finding_without_a_tier_hands_the_verdict_back_to_the_exit_code(
+ tmp_path: Path, event: str, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ monkeypatch.setenv("TOY_TIERS", "partial")
+ repo = repo_with(tmp_path, **{"app.py": OLD})
+ assert _verdict(_gate(repo), repo, event, OLD + "y = ASKME\n") == "block"
+
+
+def test_a_tier_the_protocol_lacks_is_ignored(tmp_path: Path, event: str) -> None:
+ repo = repo_with(tmp_path, **{"app.py": OLD})
+ assert _verdict(_gate(repo), repo, event, OLD + "y = ODDME\nz = ASKME\n") == "block"
+
+
+def test_a_new_file_with_an_ask_finding_asks(tmp_path: Path, event: str) -> None:
+ repo = repo_with(tmp_path, **{"keep.py": OLD})
+ assert _verdict(_gate(repo), repo, event, "y = ASKME\n") == "ask"
diff --git a/tests/test_session_path.py b/tests/test_session_path.py
new file mode 100644
index 00000000..1d3f924b
--- /dev/null
+++ b/tests/test_session_path.py
@@ -0,0 +1,29 @@
+"""The session-path figure in docs/architecture.md: the same points in session order, with the same engine checks."""
+
+from __future__ import annotations
+
+from readme_figure_support import FIGURE, crowded, engine_acts
+
+PATH = FIGURE["path"]
+
+
+def test_diamonds_and_chips_cover_every_point_once() -> None:
+ points = FIGURE["points"]
+ assert all(len(p["place"]) >= 1 for p in points)
+ diamonds = {p["id"] for p in points if p["place"].get("row") or p["place"].get("tag")}
+ chips = {p["id"] for p in points if p["place"].get("chip")}
+ assert not diamonds & chips and len(diamonds | chips) == len(points)
+
+
+def test_filled_diamonds_are_the_engine_set_and_notes_are_at_most_four_words() -> None:
+ assert {p["id"] for p in FIGURE["points"] if p["acts"]} == engine_acts()
+ assert all(len(p["does"].split()) <= 4 for p in FIGURE["points"] if p["acts"] and "does" in p)
+
+
+def test_the_loop_runs_from_after_post_tool_to_the_model_step() -> None:
+ loop = PATH["paths"]["agent"]["loop"]
+ assert loop["after"] == "post_tool" and PATH["paths"]["agent"]["steps"][loop["to"]]["text"].startswith("The model")
+
+
+def test_no_two_shapes_of_the_path_layout_are_too_close() -> None:
+ assert crowded("session-path") == []
diff --git a/tests/test_surface_doc_matches_code.py b/tests/test_surface_doc_matches_code.py
index 31c7edc8..c8fa2784 100644
--- a/tests/test_surface_doc_matches_code.py
+++ b/tests/test_surface_doc_matches_code.py
@@ -148,7 +148,7 @@ def test_readme_enforces_column_matches_the_code() -> None:
#: What README's one omission paragraph owes each surface it drops. Ordered by where the
#: names appear in that paragraph, which `_reason_for` slices on.
README_OMITTED = {
- Surface.MANAGED_SETTING: "compiled but not installed",
+ Surface.MANAGED_SETTING: "not installed by chock",
Surface.GATEWAY: "modelled but not yet emitted",
Surface.MCP_GATEWAY: "per-client witness",
Surface.STOP: "worth no grade of its own",
@@ -186,6 +186,7 @@ def test_readme_says_why_the_absent_surfaces_are_absent() -> None:
assert not crediting, f"{surface.value} now credits {crediting}; the README owes it a column"
assert Surface.MANAGED_SETTING not in INSTALLED_SURFACES, "an installer landed; 'not installed' is now false"
+ assert Surface.MANAGED_SETTING not in EMITTERS, "the compiler writes it again; the README wording is stale"
assert Surface.GATEWAY not in EMITTERS, "gateway emits now; 'not yet emitted' is now false"
supporting = [a for a, s in SURFACE_AGENTS.items() if Surface.MCP_GATEWAY in s]
assert not supporting, f"mcp-gateway is now supported by {supporting}; the per-client wording is stale"
@@ -262,7 +263,10 @@ def test_managed_setting_is_disclosed_as_not_installed() -> None:
from chock.compile.surfaces import INSTALLED_SURFACES
assert Surface.MANAGED_SETTING not in INSTALLED_SURFACES, "an installer landed; drop the caveat"
- assert "compiled but not installed" in DOC.read_text(encoding="utf-8")
+ from chock.compile.compiler import EMITTERS
+
+ assert Surface.MANAGED_SETTING not in EMITTERS, "the compiler writes it again; 'neither compiled' is now false"
+ assert "neither compiled nor installed" in DOC.read_text(encoding="utf-8")
def test_ci_gate_is_disclosed_as_needing_its_installer() -> None:
diff --git a/tests/test_sync_every_adapter.py b/tests/test_sync_every_adapter.py
index 44ef2cb0..18324e74 100644
--- a/tests/test_sync_every_adapter.py
+++ b/tests/test_sync_every_adapter.py
@@ -157,13 +157,14 @@ def test_sync_says_agentseams_row_and_that_the_agent_is_untested(vendor: str) ->
assert any("Untested" in line for line in lines)
-def test_a_witnessed_agent_is_not_called_untested() -> None:
- assert evidence.witness("vscode_copilot", "agent-hooks"), "the ledger's repo-hook row this test rests on"
- assert sync_notes.witnessed("vscode_copilot")
- assert not any("Untested" in line for line in sync_notes.notes("vscode_copilot"))
+@pytest.mark.parametrize("vendor", ("vscode_copilot", "claude_code", "cursor", "codex_cli"))
+def test_a_witnessed_agent_is_not_called_untested(vendor: str) -> None:
+ assert evidence.witness(vendor, "agent-hooks"), "the ledger's repo-hook row this test rests on"
+ assert sync_notes.witnessed(vendor)
+ assert not any("Untested" in line for line in sync_notes.notes(vendor))
-@pytest.mark.parametrize("vendor", ("claude_code", "codex_cli", "cursor", "devin"))
+@pytest.mark.parametrize("vendor", ("devin",))
def test_a_plugin_witness_does_not_make_sync_say_tested(vendor: str) -> None:
"""A plugin-hook row witnesses `chock install`; sync wires repo hooks nobody saw run there."""
assert evidence.witness(vendor, evidence.PLUGIN_HOOK)
diff --git a/tests/test_witness_ledger.py b/tests/test_witness_ledger.py
index 3cf50e07..8e4c9cb7 100644
--- a/tests/test_witness_ledger.py
+++ b/tests/test_witness_ledger.py
@@ -114,7 +114,7 @@ def test_the_in_agent_surfaces_the_ledger_accepts_are_the_compilers_own() -> Non
"""A surface renamed in the compiler must not leave the ledger accepting a dead token."""
in_agent = {Surface.PRE_TOOL_USE.value, Surface.AGENT_HOOKS.value}
assert in_agent < set(evidence.WITNESS_SURFACES)
- assert set(evidence.WITNESS_SURFACES) - in_agent == {evidence.PLUGIN_HOOK, evidence.GIT_HOOK_ENV}
+ assert set(evidence.WITNESS_SURFACES) - in_agent == {evidence.PLUGIN_HOOK, evidence.GIT_HOOK_ENV, evidence.MANAGED}
@pytest.mark.parametrize("agent", sorted(RENDERS))