Metadata-Version: 2.4
Name: zmb-audit
Version: 0.3.1
Summary: Zero-dependency Python AST auditor for AI-generated orphan modules, unresolved calls, and silent fallbacks
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`)

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**: Non-test Python modules that exist in the repo but are never imported by anything.
2. **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).
3. **Silent Exception Fallbacks**: Broad `except Exception:` / `except:` blocks that swallow errors and return `[]`, `{}`, `None`, `""`, or `pass`, turning fatal runtime bugs into false-green tests.
4. **Git Pre-Commit Guard Status**: Checks whether out-of-process pre-commit protection is active.

## Requirements

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

## Installation (`v0.2.0`)

```bash
# Install CLI command directly from GitHub
pip install git+https://github.com/ADevBelgie/zmb-audit.git

# Or run standalone with zero install
curl -sLO https://raw.githubusercontent.com/ADevBelgie/zmb-audit/main/zmb_audit.py
```

## Usage

```bash
# Run via installed CLI entry point
zmb-audit . --strict

# Or run standalone script directly
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

# Output SARIF v2.1.0 for GitHub Code Scanning
zmb-audit /path/to/repository --sarif --out zmb-audit.sarif

# Exclude custom directories
python zmb_audit.py /path/to/repository --exclude legacy_code experimental
```

## Example Output

```text
================================================================
[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 Marketplace & Code Scanning (SARIF)

```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.3.1
        with:
          strict: "true"
          sarif-file: zmb-audit.sarif
      - if: always()
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: zmb-audit.sarif
```

## PyPI Trusted Publishing

Releases published from `main` trigger [`.github/workflows/publish-pypi.yml`](.github/workflows/publish-pypi.yml) (`python -m build`, `twine check`, and OIDC `pypa/gh-action-pypi-publish`). Configure a PyPI Trusted Publisher pointing at `ADevBelgie/zmb-audit` (`environment: pypi`) once, then publish a GitHub Release for `v0.3.1`.

## 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](https://devresser.gumroad.com/l/zmb-failure-mode-report)**
