Gating AI-Generated Python PRs with Zero-Dependency .zmb-audit.toml Policies
Gating AI-Generated Python PRs with Zero-Dependency .zmb-audit.toml Policies When coding agents open pull requests, standard linters and test suites often pass on structural decay: Orphan modules (ZMB001): helper fi
Gating AI-Generated Python PRs with Zero-Dependency .zmb-audit.toml Policies
When coding agents open pull requests, standard linters and test suites often pass on structural decay:
-
Orphan modules (
ZMB001): helper files created for a single test run that nothing in production imports. -
Unresolved internal calls (
ZMB002): methods called on local repository classes that do not exist because mocks hid the bug. -
Silent broad-exception fallbacks (
ZMB003):except Exception: return []orpassblocks that convert real crashes into green CI runs.
In zmb-audit v0.4.0 (zero runtime dependencies, Python 3.8+ stdlib AST only), you can now enforce declarative rules per repository with .zmb-audit.toml, generate GitHub Step Summaries automatically, and scan multiple repositories in one pass.
1. Define Explicit Thresholds & Banned Patterns in .zmb-audit.toml
Drop a .zmb-audit.toml file at the root of your Python repository:
[policy]
min_health_score = 85
max_orphans = 0
max_unresolved = 0
max_silent_fallbacks = 3
ignore_paths = ["scratch/*", "migrations/*"]
allow_orphan_modules = ["app", "wsgi", "*_cli"]
forbidden_imports = ["pickle", "telnetlib"]
banned_calls = ["eval", "exec", "os.system", "pickle.loads"]
Then run:
pipx run zmb-audit . --strict --markdown --out pr-summary.md
When .zmb-audit.toml is present, zmb-audit v0.4.0 loads it automatically (pass --no-config to bypass or --config path/to/policy.toml to share one centralized policy across services). Forbidden imports emit SARIF rule ZMB004 and banned calls emit ZMB005.
2. Multi-Repo Health Roll-Ups
Engineering teams maintaining multiple agent microservices can scan them together cleanly:
zmb-audit ./service-api ./agent-worker ./mcp-server --markdown
This prints a single Markdown comparison table with file counts, health scores (0-100), orphan modules, unresolved calls, silent fallbacks, and per-repo policy gate verdicts (PASS / FAIL).
3. GitHub Actions Integration With Step Summaries + SARIF
ADevBelgie/[email protected] writes directly to $GITHUB_STEP_SUMMARY by default and exports health-score, policy-passed, and sarif-file outputs:
- uses: ADevBelgie/[email protected]
with:
strict: "true"
config: ".zmb-audit.toml"
sarif-file: zmb-audit.sarif
markdown-file: zmb-summary.md
4. Open-Source CLI & Team/CI Policy Pack
-
Free CLI (MIT, zero dependencies):
pip install zmb-auditorpipx run zmb-audit . --strict(GitHub | PyPI) - Core Failure-Mode Report & Kernel Governance Kit (EUR 14): Available on Gumroad
-
Team & CI Policy Pack (EUR 29): Available on Gumroad with pre-tuned
.zmb-audit.tomlpresets for LangChain, CrewAI, OpenAI Agents SDK, Pydantic AI, and Claude Code/MCP + sticky PR comment workflow + zero-dependency HTML executive scorecard generator.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.