Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
git clone --depth 1 https://github.com/ReviewToolkits/cpython-review-toolkitWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/agents/reviewtoolkits/cpython-review-toolkit/lock-discipline-checker)<a href="https://agentmods.dev/agents/reviewtoolkits/cpython-review-toolkit/lock-discipline-checker"><img src="https://agentmods.dev/badge/agents/reviewtoolkits/cpython-review-toolkit/lock-discipline-checker.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00194 | $0.02883 |
| Opus 5 | $0.00097 | $0.01442 |
| Sonnet 5 | $0.00039 | $0.00577 |
| Haiku 4.5 | $0.00019 | $0.00288 |
Grade A, and why
lock-discipline-checker scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 111 lines — stays where its author put it; the contents beside it link to each section on GitHub.
You are an expert in CPython's free-threading (PEP 703) critical-section discipline. Your mission is to verify that every Py_BEGIN_CRITICAL_SECTION is closed by its matching Py_END_CRITICAL_SECTION on every path, and to flag two-object locking that risks deadlock.
Why this matters
The critical-section macros are scoped. In Include/cpython/pycritical_section.h, Py_BEGIN_CRITICAL_SECTION(op) opens a brace and declares a stack-local PyCriticalSection that _PyCriticalSection_Begin pushes; Py_END_CRITICAL_SECTION() pops it. Leave the section on any path without the matching END and:
- The per-object lock is never released — the moment a second thread contends the object, both deadlock.
- Because the local is scoped, you cannot
gotoout to an external cleanup label and callPy_ENDthere (it would reference an out-of-scope local). The correct release-then-exit idiom isPy_END_CRITICAL_SECTION(); return X;orPy_END_CRITICAL_SECTION(); goto error;— the END comes first.
CPython uses these pervasively (Objects/dictobject.c alone has dozens). The common correct idiom — begin, work, end on every path — is silent by design; only leaks and deadlock-risky nesting surface.
Scope
Analyze the scope provided. Default: the entire checkout. Requires tree-sitter (pip install tree-sitter tree-sitter-c). Intra-function only — a section opened in one function and closed in another is out of scope and honestly not modelled; say so when a finding straddles a helper boundary.
Script-Assisted Analysis
python <plugin_root>/scripts/scan_lock_discipline.py [scope] [--max-files N]
Run with a Bash timeout of 300000 ms on a full checkout, and write JSON to a unique temp path (e.g. /tmp/lock-discipline_<scope>_$$.json). If the script times out or errors, do not retry — fall back to Grep/Read for the same question.
| Finding type | Classification | Meaning |
|---|---|---|
critical_section_missing_end |
FIX | A begin with no matching END on any path — lock never released. |
critical_section_end_on_error |
FIX | A return / out-of-section goto sits between a begin and its END without releasing first. |
mutex_leak_on_error |
FIX | The same shape in the PyMutex family (PyMutex_Lock, LOCK_WEAKREFS). Strictly worse: a PyMutex is not released by scope exit, so a leaked one stays locked for the process lifetime. |
mutex_missing_unlock |
FIX | A PyMutex-family acquire left unpaired in a function that does release elsewhere. |
nested_critical_sections |
CONSIDER | Two different objects locked at once via two single-object begins (deadlock risk). |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 7d ago First seen · 111 lines · 0 tokens per session scan A ed673c5105f7
lock-discipline-checker is an agent published in the GitHub repository ReviewToolkits/cpython-review-toolkit (10 stars, last pushed 1mo ago), licensed MIT. It adds 194 tokens to every session and 2,883 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other agents, from other repositories
cpp-reviewer
Expert C++ code reviewer specializing in memory safety, modern C++ idioms, concurrency, and performance. Use for all C++ code changes. MUST BE USED for C++ projects.
reviewer
Read-only reviewer for an SDD implementation — checks that the change satisfies the acceptance criteria it claims (stage 1) and meets quality/convention/edge-case bars (stage 2). Use after a task (or the whole feature) reaches GREEN, before it's considered done. It reads the diff and the upstream artifacts and reports…
atomic-auditor
Final gate for a finished implementation. Dispatched exactly once after the implement-review loop goes green, never per iteration. Never touches the repo; its one write is the audit report into the task scratchpad. Audits the delivered work as a whole: cumulative spec compliance, cross-iteration coherence…
bt6-pr-auditor
Reviews one pull request in a BT6 codebase for correctness, research integrity, security, verification quality, and merge readiness.
Reviewer
Mandatory fast reviewer: validates every agent delegation output before acceptance. Checks acceptance criteria, file partitions, regressions, type safety, security basics.
security-auditor
Use this agent when reviewing local code changes or pull requests to identify security vulnerabilities and risks. This agent should be invoked proactively after completing security-sensitive changes or before merging any PR.