Skip to main content

Dual-layer audit system combining automated scoring (left brain) with manual qualitative grading (right brain) and reconciliation.

Project description

Two-Brain Audit

A dual-layer audit system that combines automated quantitative scoring (left brain) with manual qualitative grading (right brain) and reconciles them automatically.

  LEFT BRAIN (Auto)              RIGHT BRAIN (Manual)
  ─────────────────              ────────────────────
  pytest pass rate    ──┐    ┌── Human grade (A)
  ruff lint score     ──┤    ├── LLM review findings
  semgrep scan        ──┤    ├── User feedback (4.2/5)
  endpoint health     ──┘    └── Team notes
                        │    │
                        ▼    ▼
                    ┌──────────┐
                    │RECONCILER│
                    └────┬─────┘
                         │
              ┌──────────┼──────────┐
              ▼          ▼          ▼
           Aligned    Diverged    Failing
           (green)    (yellow)     (red)

Why Two Brains?

Scenario Auto catches it Manual catches it
Test coverage drops silently Yes Maybe
"Feels slow" but metrics are fine No Yes
Stale manual grade after major refactor Yes (divergence) No
Security vuln in dependency Yes (scanner) No
UX regression that tests can't express No Yes
Reviewer optimism ("looks good to me") Yes (cross-validation) No

Quick Start

pip install two-brain-audit

two-brain-audit init                      # create DB + baseline sidecar
two-brain-audit register --preset python  # 8 dimensions for Python projects
two-brain-audit run light                 # first scan (~2s)
two-brain-audit status                    # view scores + divergences
Dimension                  Auto   Grade  Manual  Status
-----------------------------------------------------------------
  test_coverage            0.930      A      —   ok
  lint_score               1.000      S      —   ok
  type_coverage            0.720     B-      —   ok
  security                 0.500      D      —   ok

Overall: B+ (0.788)

Web Dashboard

pip install two-brain-audit[dashboard]
two-brain-audit dashboard                 # http://localhost:8484/audit/

Dark-mode UI with grade ring, score bars, divergence alerts, tier triggers, and a feedback widget. Zero external dependencies.

Full walkthrough with examples → docs/QUICKSTART.md

Features

  • 12-grade scale (S through F) with automatic score-to-grade conversion
  • 4 audit tiers — light (CI), medium (on-demand), daily (scheduled), weekly (deep scan)
  • Divergence detection — auto vs manual disagreement surfaces automatically
  • Ratchet rules — prevent silent score regression per dimension
  • User feedback — star rating + free text, optionally classified by LLM
  • 5 presets — Python, REST API, Database, Infrastructure, ML Pipeline
  • 4 integrations — GitHub, semgrep, PyPI, Ollama (pluggable)
  • 3 exporters — JSON, CSV, Markdown reports
  • Web dashboard — self-contained Flask blueprint, embed anywhere
  • CLIinit, run, status, health, export, dashboard
  • CI-friendlytwo-brain-audit health returns exit code 0/1 + JSON

Python API

from two_brain_audit import AuditEngine, Dimension, Tier

engine = AuditEngine(db_path="audit.db", baseline_path="audit_baseline.json")

engine.register(Dimension(
    name="test_coverage",
    check=lambda: (passed / total, {"passed": passed, "total": total}),
    confidence=0.95,
    tier=Tier.LIGHT,
))

results = engine.run_tier("daily")
health = engine.health_check()        # {"ok": True, "grade": "A", ...}
engine.record_feedback(score=0.8, text="Looking good")

Flask Integration

from two_brain_audit.dashboard import create_blueprint
app.register_blueprint(create_blueprint(engine), url_prefix="/audit")

Presets

Preset Dimensions Best for
python test coverage, lint, types, deps, docs, security, complexity, imports Python repos
api endpoint health, latency, errors, auth, schema, rate limits, CORS, TLS REST APIs
database schema, indexes, queries, backups, replication, pool, migrations Databases
infrastructure uptime, certs, resources, config drift, secrets, DNS, CDN, containers DevOps
ml_pipeline model freshness, data drift, latency, accuracy, features, GPU, experiments ML workflows

Docs

Origin

Extracted from BigEd CC after production use on a 125-skill AI fleet with 12 audit dimensions, 4 tiers, and automated daily/weekly scheduling.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

two_brain_audit-0.2.0.tar.gz (51.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

two_brain_audit-0.2.0-py3-none-any.whl (45.5 kB view details)

Uploaded Python 3

File details

Details for the file two_brain_audit-0.2.0.tar.gz.

File metadata

  • Download URL: two_brain_audit-0.2.0.tar.gz
  • Upload date:
  • Size: 51.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for two_brain_audit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9fb8da6f27f2a38a19958cb4bea82b35f5311bbc004e703851242b4595f4fcb6
MD5 612a904393de0172db5c66c82259628f
BLAKE2b-256 c680bf64f1f036f57199c91e14bed544f42edcef864e3816b460a56b0f0311f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for two_brain_audit-0.2.0.tar.gz:

Publisher: publish.yml on SwiftWing21/two-brain-audit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file two_brain_audit-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for two_brain_audit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12c09c28b742c01c9c620f5b48d4bf8d17739deee8632d1611120b60d612cd42
MD5 7e389061e367ad02f16c2efd955ebfd7
BLAKE2b-256 4c1b0de53bca39c7f5d5f72208b39d5e01444909548022053e454a1e66068190

See more details on using hashes here.

Provenance

The following attestation bundles were made for two_brain_audit-0.2.0-py3-none-any.whl:

Publisher: publish.yml on SwiftWing21/two-brain-audit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page