Original text(via HN AI)
Repository files navigation
ZMB Standalone Codebase Auditor (zmb_audit.py)
A zero-dependency, standard-library-only static AST auditor that catches the exact failure modes AI coding agents introduce while passing unit tests.
What It Catches
- Orphan Modules: Non-test Python modules that exist in the repo but are never imported by anything.
- Unresolved Repo-Class Attribute Calls: Method calls on classes defined inside your repository where the method does not exist (zero false positives on stdlib or third-party objects).
- Silent Exception Fallbacks: Broad except Exception: / except: blocks that swallow errors and return [], {}, None, "", or pass, turning fatal runtime bugs into false-green tests.
- Git Pre-Commit Guard Status: Checks whether out-of-process pre-commit protection is active.
Requirements
- Python 3.8+ (Stdlib only — zero pip dependencies).
Usage
# Audit current directory
python zmb_audit.py
# Audit specific repository path
python zmb_audit.py /path/to/repository
# CI mode: exit 1 if orphan modules or unresolved repo-class calls are detected
python zmb_audit.py /path/to/repository --strict
# Output structured JSON
python zmb_audit.py /path/to/repository --json
# Exclude custom directories
python zmb_audit.py /path/to/repository --exclude legacy_code experimental
Example Output
================================================================
[AUDIT] ZMB STANDALONE REPOSITORY AUDIT: /path/to/repo
================================================================
[*] Health Score: 97/100
[*] Total Python Files: 42
[*] Pre-Commit Guard: PROTECTED
----------------------------------------------------------------
[OK] Zero Orphan Modules detected.
[OK] Zero unresolved repo-class attribute calls.
[!] Silent Exception Fallbacks (1):
- app/fetcher.py (line 44: broad except returns empty default)
================================================================
Drop-In GitHub Actions CI
name: Agent Code Audit
on: [pull_request]
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python zmb_audit.py . --strict
Full Report & CI Governance Kit
For the 10-chapter empirical postmortem (144+ autonomous cycles), Python 3.14 sys.monitoring live-path reachability tracer, pre-commit cryptographic guard, and two-arm benchmark starter:
Get the ZMB Failure-Mode Report & Governance Kit