repo-health
Read-only repository health scanners: definition drift, unwired-module reachability, prompt bloat, evidence-gate calibration, and registration completeness — as a CLI and an MCP server.
A codebase rots silently. The most damaging defects are the ones no test, type checker, or linter catches:
- a concept defined in two places where only one copy gets updated (drift),
- a module written but never wired up (unreachable),
- a fixed-injected prompt segment quietly eating the context (bloat),
- an extension point that exists but is never registered (registration).
repo-health is five read-only scanners that watch for exactly these. It is the extracted, generalized core of the quality-guard tooling behind a large production agent system, repackaged so any repository can run it.
Install
pip install "dsh-repo-health" # CLI
pip install "dsh-repo-health[mcp]" # + MCP server
Requires Python 3.11+ (the registration scanner uses tomllib; the others run on 3.10+).
Quick start
repo-health drift --root /path/to/repo # definition drift report
repo-health reach --root /path/to/repo # unwired-module report
repo-health prompt-bloat --root /path/to/repo # prompt segment shares
repo-health evidence --path logs/evidence_gate.jsonl
repo-health registration --root /path/to/repo --config registration.toml
repo-health all --root /path/to/repo # run every scanner
Every scanner also ships a --selftest that verifies the tool itself against a
synthetic fixture before it is trusted to judge your code — the predecessor of
these scanners shipped versions that produced pretty-but-wrong numbers, and
only known-answer fixtures caught them.
The five scanners
drift — multi-source definition drift
Detects the same name defined in more than one place with overlapping member structure, and flags it when one copy changes but the other does not.
- A class (guarded): same name and structure overlap ≥ 0.5 — watched for drift.
- B class (not guarded): same name, disjoint structure — a name collision, confusing but not a data hazard.
- Sync changes pass. If someone diligently updates both copies, that is correct behavior; a guard that punishes it gets disabled.
repo-health drift --root . # report
repo-health drift --root . --write-baseline # freeze a baseline
repo-health drift --root . --check # exit 1 on drift / new pairs
reach — unwired-module reachability
Builds the import graph and BFS-searches from startup entrypoints
(__main__.py, if __name__ == "__main__" guards, main.py, launch scripts).
Modules that cannot be reached are "wired but dead".
Its baseline carries auditable reasons: every unreachable module needs a
structured {verdict, anchor} entry, validated deterministically (V1–V7) so a
single wrong reason can never permanently hide code from every mechanism.
repo-health reach --root . # report
repo-health reach --root . --write-baseline # freeze
repo-health reach --root . --check # exit 1 on new unwired modules
repo-health reach --root . --audit-reasons # validate baseline reasons
prompt-bloat — prompt segment share baseline
Reads prompt-inspection JSONL logs ({segments: [{name, pct, kind}]}) and
watches the median share per segment, not the absolute size (absolute size
varies naturally with task complexity; share reflects structural bloat).
repo-health prompt-bloat --root . --check --json
evidence — evidence-gate decision log calibration
Summarizes a decision log ({passed, suggested_action, tool, issues} JSONL) to
answer "is the gate calibrated yet?" — insufficient samples or a
false-positive-prone tool block any conclusion.
registration — config-driven registration completeness
Declares your architecture's extension points in a TOML config and verifies
every defined item appears in its registry. See
config/registration.example.toml for an
annotated example covering agent roles, checkers, API routers, sidebar pages,
and LLM providers.
MCP server (DeepSeek Harness & any MCP client)
pip install "dsh-repo-health[mcp]"
python -m repo_health.mcp_server
Exposes the scanners as read-only MCP tools (drift_scan, reach_scan,
reach_reason_audit, prompt_bloat, evidence_calibration, registration).
Register it in DeepSeek Harness's MCP settings (or any MCP client) to let an
agent diagnose its own repository. Large repositories may exceed MCP's default
tool timeout — pass narrower root values or raise the client timeout.
Methodology (why this is not "yet another linter")
The scanners share a discipline learned the hard way:
- Watch events, not states. "Duplicated" is a state; "one side changed and the other didn't" is the event that actually corrupts data.
- Guard must not punish correct behavior. Sync updates pass; else the guard gets disabled within a week.
- Never freeze a baseline from insufficient samples. A median from three records is not a fact — a baseline frozen from it is false confidence.
- Reasons must be checkable. Free-text baseline justifications are how
code permanently hides from every mechanism; make them
{verdict, anchor}. - Self-test the scanner before it judges anything. Known-answer fixtures are the only thing that caught the predecessor's wrong-but-plausible output.
Known limitations
driftscans Python only (.pyunder the configured package dirs).reachis module-granular: a reachable module whose functions are never called is not reported; dynamic imports (importlib, plugin loaders) are invisible and belong in the baseline.evidenceandprompt-bloatconsume a specific JSONL schema; adapt your logger to emit it (examples in the docstrings).
License
MIT © 2026 Chen (Jarry) Pan
Metadata
Release files for dsh-repo-health 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dsh_repo_health-0.1.1.tar.gz | 39.0 kB | Without provenance | Details for dsh_repo_health-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dsh_repo_health-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for dsh_repo_health-0.1.1-py3-none-any.whl |
Total release size: 78.5 kB
Release files / dsh_repo_health-0.1.1.tar.gz
| Download URL | dsh_repo_health-0.1.1.tar.gz |
|---|---|
| Size | 39.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1160f3b1fc3b060d5350a0d5e4f5bdf037d82b8a59c985e77c4ae191f3964941
|
|
BLAKE2b-256 checksum How to use checksums |
d0f5e1ae87694f66e13905ca419bdf0f9ca5f48cf5e969770c1980ac2234c82a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Release files / dsh_repo_health-0.1.1-py3-none-any.whl
| Download URL | dsh_repo_health-0.1.1-py3-none-any.whl |
|---|---|
| Size | 39.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d65db988d7972035ad94a03f71f9f4255c6af590ab874fef6447bba20f4c87f
|
|
BLAKE2b-256 checksum How to use checksums |
808ea56c1264aedd2779f0cc9b2cfb3bc4856fb6ac2d80344fa87ef44775f322
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.11
|
Security for dsh-repo-health 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.