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.1.0.tar.gz (40.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.1.0-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: two_brain_audit-0.1.0.tar.gz
  • Upload date:
  • Size: 40.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.1.0.tar.gz
Algorithm Hash digest
SHA256 a90f796c7823ce17bb5ff9bdb155760f92d20ef18643ec8d4606bf30b7d62fc3
MD5 88217980afdb32ce41c1ff3d232c5831
BLAKE2b-256 14ee7b656b616de3e64e7ea593a8cae687faa62db5cfd3db765ddb9618885f6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for two_brain_audit-0.1.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for two_brain_audit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2099953d796a6f2ed21677d8912ad9f1eddde0ce21d8b0448926f8da389db6a5
MD5 adbd19e9a4f6b010c24d8a6960f90e83
BLAKE2b-256 cb310662a47ae86c07fa302f83d3d798def46a7d6e2ee1ff820af32fe538bc7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for two_brain_audit-0.1.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