Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5175469
Adopt the Sonar/Checkstyle/FindBugs ruff rule-family bar
claude Sep 2, 2026
ccf35d1
Fix mechanical lint findings: stale noqa, dunder-all order, misc
claude Sep 2, 2026
545ff58
Fix SIM105/B905: contextlib.suppress, explicit zip(strict=)
claude Sep 2, 2026
f30fb1e
Correct the previous commit: restore noqa comments RUF100 wrongly fla…
claude Sep 2, 2026
8a120cc
Fix misc small-count findings batch
claude Sep 2, 2026
971266a
PLR2004: name the magic values as module constants
claude Sep 2, 2026
af6647f
Add literal-duplication check tool and fix the repeated-literal baseline
claude Sep 2, 2026
654f1f0
Fix TRY003: extract raise messages to a local before raising
claude Sep 2, 2026
98a3d32
Fix BLE001/S110: narrow or justify remaining broad excepts
claude Sep 2, 2026
61f73a6
Fix FBT001/002/003: boolean params keyword-only, no positional bools
claude Sep 2, 2026
5480ac2
Fix ARG001: mark unused-by-design interface args, drop one dead param
claude Sep 2, 2026
7996e94
Fix S101: justify internal-invariant asserts with noqa + reason
claude Sep 2, 2026
27ca13b
Fix PLW1510/S603/S607: explicit check=, resolved git executable
claude Sep 2, 2026
6dcdc42
Fix PLC0415: hoist import-outside-top-level, keep test-mockpoint impo…
claude Sep 2, 2026
fff02ba
Consolidate [WARN]/[ERROR] stderr prints into a designated output module
claude Sep 2, 2026
526569d
T201: per-file-ignore the 35 files that are genuine CLI/render surfaces
claude Sep 2, 2026
6593e9f
Defer C901/PLR091x complexity findings, per-file-ignore with TODO
claude Sep 2, 2026
98d8167
Record static_analysis as a hard rule beside code_comments/externaliz…
claude Sep 2, 2026
d4f9cdf
Scope the new ruff bar's out-of-repo-scope debt with per-file-ignores
claude Sep 2, 2026
33434f6
Fix fuzz harness after policy_id's InvalidPolicyId -> InvalidPolicyId…
claude Sep 2, 2026
d8910c2
Address CodeQL findings on the new output module and an existing empt…
claude Sep 2, 2026
5964bc7
Fix version-drift PLR0917 findings; give up on lgtm suppression, docu…
claude Sep 2, 2026
8b2f86e
fix(ci): use the repo's real CodeQL alert-suppression syntax on outpu…
claude Sep 2, 2026
f9eca6a
fix(ci): the codeql[] suppression cannot carry a trailing noqa; ERA00…
claude Sep 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .chock/bin/antigravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import os as _chock_os
import shlex as _chock_shlex
import shutil as _chock_shutil
import subprocess as _chock_subprocess
from datetime import datetime as _chock_datetime, timezone as _chock_timezone
from pathlib import Path as _chock_Path
Expand Down Expand Up @@ -608,7 +609,7 @@ def find_bash(guard: _chock_Path) -> str | None:
"""First interpreter that can actually see `guard`, or None."""
for candidate in _BASH_CANDIDATES:
try:
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10)
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10, check=False)
except (OSError, _chock_subprocess.SubprocessError):
continue
if proc.returncode == 0:
Expand All @@ -630,7 +631,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_UNCHECKED
try:
env = {**_chock_os.environ, 'CHOCK_RAW_COMMAND': command}
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS)
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS, check=False)
except _chock_subprocess.TimeoutExpired:
print(f'chock: guard timed out after {_GUARD_TIMEOUT_SECONDS}s, not checked', file=sys.stderr)
return GUARD_ERRORED
Expand All @@ -649,7 +650,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_ERRORED
return GUARD_CLEAN

def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
def log_outcome(guard: _chock_Path, tool: str, *, blocked: bool) -> None:
"""Append one outcome record. Best effort: never raises, never changes the verdict."""
try:
if _chock_os.environ.get(GATE_LOG_ENV) == '0':
Expand All @@ -669,7 +670,6 @@ def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
log_path = log_dir / 'gate-events.jsonl'
if log_path.exists() and log_path.stat().st_size > _LOG_MAX_BYTES:
log_path.replace(log_dir / 'gate-events.1.jsonl')
import json
record = {'ts': _chock_datetime.now(_chock_timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ'), 'policy_id': guard.parent.parent.name, 'surface': 'pre-tool-use', 'event': 'tool_use', 'kind': guard.stem, 'tool': tool, 'verdict': 'block' if blocked else 'allow'}
with log_path.open('a', encoding='utf-8') as fh:
fh.write(json.dumps(record, ensure_ascii=False) + '\n')
Expand All @@ -683,7 +683,7 @@ def evaluate(argv: list[str], command: str, tool: str='') -> tuple[str, str] | N
return None
verdict = run_guard(guard, command)
if verdict in (GUARD_BLOCKED, GUARD_CLEAN):
log_outcome(guard, tool, verdict == GUARD_BLOCKED)
log_outcome(guard, tool, blocked=verdict == GUARD_BLOCKED)
if verdict == GUARD_BLOCKED:
return (VERDICT_DENY, f'Blocked by chock policy: {guard.stem}')
if verdict == GUARD_ERRORED:
Expand Down
14 changes: 8 additions & 6 deletions .chock/bin/claude_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import os as _chock_os
import shlex as _chock_shlex
import shutil as _chock_shutil
import subprocess as _chock_subprocess
from datetime import datetime as _chock_datetime, timezone as _chock_timezone
from pathlib import Path as _chock_Path
Expand Down Expand Up @@ -663,7 +664,7 @@ def find_bash(guard: _chock_Path) -> str | None:
"""First interpreter that can actually see `guard`, or None."""
for candidate in _BASH_CANDIDATES:
try:
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10)
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10, check=False)
except (OSError, _chock_subprocess.SubprocessError):
continue
if proc.returncode == 0:
Expand All @@ -685,7 +686,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_UNCHECKED
try:
env = {**_chock_os.environ, 'CHOCK_RAW_COMMAND': command}
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS)
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS, check=False)
except _chock_subprocess.TimeoutExpired:
print(f'chock: guard timed out after {_GUARD_TIMEOUT_SECONDS}s, not checked', file=sys.stderr)
return GUARD_ERRORED
Expand All @@ -704,7 +705,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_ERRORED
return GUARD_CLEAN

def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
def log_outcome(guard: _chock_Path, tool: str, *, blocked: bool) -> None:
"""Append one outcome record. Best effort: never raises, never changes the verdict."""
try:
if _chock_os.environ.get(GATE_LOG_ENV) == '0':
Expand All @@ -724,7 +725,6 @@ def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
log_path = log_dir / 'gate-events.jsonl'
if log_path.exists() and log_path.stat().st_size > _LOG_MAX_BYTES:
log_path.replace(log_dir / 'gate-events.1.jsonl')
import json
record = {'ts': _chock_datetime.now(_chock_timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ'), 'policy_id': guard.parent.parent.name, 'surface': 'pre-tool-use', 'event': 'tool_use', 'kind': guard.stem, 'tool': tool, 'verdict': 'block' if blocked else 'allow'}
with log_path.open('a', encoding='utf-8') as fh:
fh.write(json.dumps(record, ensure_ascii=False) + '\n')
Expand All @@ -738,13 +738,15 @@ def evaluate(argv: list[str], command: str, tool: str='') -> tuple[str, str] | N
return None
verdict = run_guard(guard, command)
if verdict in (GUARD_BLOCKED, GUARD_CLEAN):
log_outcome(guard, tool, verdict == GUARD_BLOCKED)
log_outcome(guard, tool, blocked=verdict == GUARD_BLOCKED)
if verdict == GUARD_BLOCKED:
return (VERDICT_DENY, f'Blocked by chock policy: {guard.stem}')
if verdict == GUARD_ERRORED:
return (VERDICT_ESCALATE, f"chock could not check this command: the {guard.stem} guard did not complete (see this hook's stderr). Approving runs it unchecked.")
return None

_GIT = _chock_shutil.which('git') or 'git'

_INSTRUCTION = "Chock: this clone's git hooks are NOT installed -- git never clones hooks, so commit-time gates will not run locally until someone runs:\n pip install chock && chock sync --repo .\nRun that before the first commit. (The repo's CI gate, where wired, enforces regardless.)"

def _repo_root() -> _chock_Path:
Expand All @@ -754,7 +756,7 @@ def _repo_root() -> _chock_Path:
def _hooks_pre_commit(repo_root: _chock_Path) -> _chock_Path | None:
"""The active pre-commit hook path, honouring core.hooksPath. None when git is absent."""
try:
proc = _chock_subprocess.run(['git', 'rev-parse', '--git-path', 'hooks'], cwd=repo_root, capture_output=True, text=True, timeout=15)
proc = _chock_subprocess.run([_GIT, 'rev-parse', '--git-path', 'hooks'], cwd=repo_root, capture_output=True, text=True, timeout=15, check=False)
except (OSError, _chock_subprocess.TimeoutExpired):
return None
if proc.returncode != 0:
Expand Down
10 changes: 5 additions & 5 deletions .chock/bin/codex_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import os as _chock_os
import shlex as _chock_shlex
import shutil as _chock_shutil
import subprocess as _chock_subprocess
from datetime import datetime as _chock_datetime, timezone as _chock_timezone
from pathlib import Path as _chock_Path
Expand Down Expand Up @@ -650,7 +651,7 @@ def find_bash(guard: _chock_Path) -> str | None:
"""First interpreter that can actually see `guard`, or None."""
for candidate in _BASH_CANDIDATES:
try:
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10)
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10, check=False)
except (OSError, _chock_subprocess.SubprocessError):
continue
if proc.returncode == 0:
Expand All @@ -672,7 +673,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_UNCHECKED
try:
env = {**_chock_os.environ, 'CHOCK_RAW_COMMAND': command}
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS)
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS, check=False)
except _chock_subprocess.TimeoutExpired:
print(f'chock: guard timed out after {_GUARD_TIMEOUT_SECONDS}s, not checked', file=sys.stderr)
return GUARD_ERRORED
Expand All @@ -691,7 +692,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_ERRORED
return GUARD_CLEAN

def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
def log_outcome(guard: _chock_Path, tool: str, *, blocked: bool) -> None:
"""Append one outcome record. Best effort: never raises, never changes the verdict."""
try:
if _chock_os.environ.get(GATE_LOG_ENV) == '0':
Expand All @@ -711,7 +712,6 @@ def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
log_path = log_dir / 'gate-events.jsonl'
if log_path.exists() and log_path.stat().st_size > _LOG_MAX_BYTES:
log_path.replace(log_dir / 'gate-events.1.jsonl')
import json
record = {'ts': _chock_datetime.now(_chock_timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ'), 'policy_id': guard.parent.parent.name, 'surface': 'pre-tool-use', 'event': 'tool_use', 'kind': guard.stem, 'tool': tool, 'verdict': 'block' if blocked else 'allow'}
with log_path.open('a', encoding='utf-8') as fh:
fh.write(json.dumps(record, ensure_ascii=False) + '\n')
Expand All @@ -725,7 +725,7 @@ def evaluate(argv: list[str], command: str, tool: str='') -> tuple[str, str] | N
return None
verdict = run_guard(guard, command)
if verdict in (GUARD_BLOCKED, GUARD_CLEAN):
log_outcome(guard, tool, verdict == GUARD_BLOCKED)
log_outcome(guard, tool, blocked=verdict == GUARD_BLOCKED)
if verdict == GUARD_BLOCKED:
return (VERDICT_DENY, f'Blocked by chock policy: {guard.stem}')
if verdict == GUARD_ERRORED:
Expand Down
10 changes: 5 additions & 5 deletions .chock/bin/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import os as _chock_os
import shlex as _chock_shlex
import shutil as _chock_shutil
import subprocess as _chock_subprocess
from datetime import datetime as _chock_datetime, timezone as _chock_timezone
from pathlib import Path as _chock_Path
Expand Down Expand Up @@ -573,7 +574,7 @@ def find_bash(guard: _chock_Path) -> str | None:
"""First interpreter that can actually see `guard`, or None."""
for candidate in _BASH_CANDIDATES:
try:
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10)
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10, check=False)
except (OSError, _chock_subprocess.SubprocessError):
continue
if proc.returncode == 0:
Expand All @@ -595,7 +596,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_UNCHECKED
try:
env = {**_chock_os.environ, 'CHOCK_RAW_COMMAND': command}
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS)
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS, check=False)
except _chock_subprocess.TimeoutExpired:
print(f'chock: guard timed out after {_GUARD_TIMEOUT_SECONDS}s, not checked', file=sys.stderr)
return GUARD_ERRORED
Expand All @@ -614,7 +615,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_ERRORED
return GUARD_CLEAN

def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
def log_outcome(guard: _chock_Path, tool: str, *, blocked: bool) -> None:
"""Append one outcome record. Best effort: never raises, never changes the verdict."""
try:
if _chock_os.environ.get(GATE_LOG_ENV) == '0':
Expand All @@ -634,7 +635,6 @@ def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
log_path = log_dir / 'gate-events.jsonl'
if log_path.exists() and log_path.stat().st_size > _LOG_MAX_BYTES:
log_path.replace(log_dir / 'gate-events.1.jsonl')
import json
record = {'ts': _chock_datetime.now(_chock_timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ'), 'policy_id': guard.parent.parent.name, 'surface': 'pre-tool-use', 'event': 'tool_use', 'kind': guard.stem, 'tool': tool, 'verdict': 'block' if blocked else 'allow'}
with log_path.open('a', encoding='utf-8') as fh:
fh.write(json.dumps(record, ensure_ascii=False) + '\n')
Expand All @@ -648,7 +648,7 @@ def evaluate(argv: list[str], command: str, tool: str='') -> tuple[str, str] | N
return None
verdict = run_guard(guard, command)
if verdict in (GUARD_BLOCKED, GUARD_CLEAN):
log_outcome(guard, tool, verdict == GUARD_BLOCKED)
log_outcome(guard, tool, blocked=verdict == GUARD_BLOCKED)
if verdict == GUARD_BLOCKED:
return (VERDICT_DENY, f'Blocked by chock policy: {guard.stem}')
if verdict == GUARD_ERRORED:
Expand Down
10 changes: 5 additions & 5 deletions .chock/bin/devin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import os as _chock_os
import shlex as _chock_shlex
import shutil as _chock_shutil
import subprocess as _chock_subprocess
from datetime import datetime as _chock_datetime, timezone as _chock_timezone
from pathlib import Path as _chock_Path
Expand Down Expand Up @@ -634,7 +635,7 @@ def find_bash(guard: _chock_Path) -> str | None:
"""First interpreter that can actually see `guard`, or None."""
for candidate in _BASH_CANDIDATES:
try:
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10)
proc = _chock_subprocess.run([candidate, '-c', f'test -f "{guard.as_posix()}"'], capture_output=True, timeout=10, check=False)
except (OSError, _chock_subprocess.SubprocessError):
continue
if proc.returncode == 0:
Expand All @@ -656,7 +657,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_UNCHECKED
try:
env = {**_chock_os.environ, 'CHOCK_RAW_COMMAND': command}
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS)
proc = _chock_subprocess.run([bash, str(guard), *args], capture_output=True, text=True, encoding='utf-8', errors='replace', env=env, timeout=_GUARD_TIMEOUT_SECONDS, check=False)
except _chock_subprocess.TimeoutExpired:
print(f'chock: guard timed out after {_GUARD_TIMEOUT_SECONDS}s, not checked', file=sys.stderr)
return GUARD_ERRORED
Expand All @@ -675,7 +676,7 @@ def run_guard(guard: _chock_Path, command: str) -> str:
return GUARD_ERRORED
return GUARD_CLEAN

def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
def log_outcome(guard: _chock_Path, tool: str, *, blocked: bool) -> None:
"""Append one outcome record. Best effort: never raises, never changes the verdict."""
try:
if _chock_os.environ.get(GATE_LOG_ENV) == '0':
Expand All @@ -695,7 +696,6 @@ def log_outcome(guard: _chock_Path, tool: str, blocked: bool) -> None:
log_path = log_dir / 'gate-events.jsonl'
if log_path.exists() and log_path.stat().st_size > _LOG_MAX_BYTES:
log_path.replace(log_dir / 'gate-events.1.jsonl')
import json
record = {'ts': _chock_datetime.now(_chock_timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ'), 'policy_id': guard.parent.parent.name, 'surface': 'pre-tool-use', 'event': 'tool_use', 'kind': guard.stem, 'tool': tool, 'verdict': 'block' if blocked else 'allow'}
with log_path.open('a', encoding='utf-8') as fh:
fh.write(json.dumps(record, ensure_ascii=False) + '\n')
Expand All @@ -709,7 +709,7 @@ def evaluate(argv: list[str], command: str, tool: str='') -> tuple[str, str] | N
return None
verdict = run_guard(guard, command)
if verdict in (GUARD_BLOCKED, GUARD_CLEAN):
log_outcome(guard, tool, verdict == GUARD_BLOCKED)
log_outcome(guard, tool, blocked=verdict == GUARD_BLOCKED)
if verdict == GUARD_BLOCKED:
return (VERDICT_DENY, f'Blocked by chock policy: {guard.stem}')
if verdict == GUARD_ERRORED:
Expand Down
Loading