Metadata-Version: 2.4
Name: zmb-audit
Version: 0.4.1
Summary: Zero-dependency Python AST auditor for AI-generated orphan modules, unresolved calls, silent fallbacks, and .zmb-audit.toml CI policies
Author: Arthur Devresse & Zero Man Business (ZMB)
License: MIT License
        
        Copyright (c) 2026 Arthur Devresse & Zero Man Business (ZMB)
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/ADevBelgie/zmb-audit
Project-URL: Repository, https://github.com/ADevBelgie/zmb-audit
Keywords: ast,static-analysis,linter,ai-agents,python,dead-code
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# ZMB Standalone Codebase Auditor (`zmb_audit.py`)

[![PyPI version](https://img.shields.io/pypi/v/zmb-audit)](https://pypi.org/project/zmb-audit/)
[![GitHub release](https://img.shields.io/github/v/release/ADevBelgie/zmb-audit)](https://github.com/ADevBelgie/zmb-audit/releases)

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

1. **Orphan Modules (`ZMB001`)**: Non-test Python modules imported by nothing across the repo (`allow_orphan_modules` configurable).
2. **Unresolved Repo-Class Attribute Calls (`ZMB002`)**: Method calls on classes defined inside your repository where the method does not exist (zero false positives on stdlib or third-party objects).
3. **Silent Exception Fallbacks (`ZMB003`)**: Broad `except Exception:` / `except:` blocks that swallow errors and return `[]`, `{}`, `None`, `""`, or `pass`, turning fatal runtime bugs into false-green tests.
4. **Custom `.zmb-audit.toml` Policy Rules (`ZMB004`, `ZMB005`)**: Enforce `forbidden_imports`, `banned_calls`, `ignore_paths`, `min_health_score`, `max_orphans`, `max_unresolved`, and `max_silent_fallbacks`.
5. **Multi-Repo Audits & PR Markdown Summaries**: Audit multiple repositories in one command (`zmb-audit repo_a repo_b --markdown`) and populate GitHub Step Summaries automatically.

## Requirements

- Python 3.8+ (Stdlib only, zero runtime dependencies).

## Installation (`v0.4.1`)

```bash
# Run immediately with pipx (zero manual install)
pipx run zmb-audit . --strict

# Or install from PyPI
pip install zmb-audit

# Or download the standalone single-file script directly
curl -sLO https://raw.githubusercontent.com/ADevBelgie/zmb-audit/main/zmb_audit.py
```

## Usage

```bash
# Run via installed CLI entry point (auto-loads .zmb-audit.toml if present)
zmb-audit . --strict

# Explicitly pass a policy file & generate PR Markdown summary
zmb-audit . --config .zmb-audit.toml --markdown --out pr-summary.md --strict

# Audit multiple repositories together
zmb-audit ./service-a ./service-b ./agent-worker --markdown

# Output structured JSON
zmb-audit . --json

# Output SARIF v2.1.0 for GitHub Code Scanning
zmb-audit . --sarif --out zmb-audit.sarif

# Ignore repository .zmb-audit.toml for a clean baseline run
zmb-audit . --no-config
```

## Example `.zmb-audit.toml` Policy

```toml
[policy]
min_health_score = 80
max_orphans = 0
max_unresolved = 0
max_silent_fallbacks = 3
ignore_paths = ["migrations/*", "legacy/*"]
allow_orphan_modules = ["wsgi", "asgi", "*_cli"]
forbidden_imports = ["pickle", "telnetlib"]
banned_calls = ["eval", "exec", "os.system"]
```

## Drop-In GitHub Actions Marketplace & Code Scanning (SARIF + Step Summary)

```yaml
name: Agent Code Audit
on: [pull_request]
permissions:
  security-events: write
jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ADevBelgie/zmb-audit@v0.4.1
        with:
          strict: "true"
          config: ".zmb-audit.toml"
          sarif-file: zmb-audit.sarif
          markdown-file: zmb-summary.md
          write-step-summary: "true"
      - if: always()
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: zmb-audit.sarif
```

## Full Report, Governance Kit & Team/CI Policy Pack

- **[Failure-Mode Report & Core Governance Kit (EUR 14)](https://devresser.gumroad.com/l/zmb-failure-mode-report)**: 10-chapter empirical postmortem (144+ autonomous cycles), Python 3.14 `sys.monitoring` live-path reachability tracer, cryptographic pre-commit guard, and two-arm benchmark starter.
- **Team/CI Policy Pack (`EUR 29`)**: Pre-tuned `.zmb-audit.toml` rulesets for LangChain, CrewAI, AutoGen, OpenAI Agents SDK, Pydantic AI, and Claude Code + sticky PR comment workflow + multi-repo HTML scorecard generator.
