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.1.tar.gz (43.7 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.1-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: two_brain_audit-0.1.1.tar.gz
  • Upload date:
  • Size: 43.7 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.1.tar.gz
Algorithm Hash digest
SHA256 bd97c01cce139a7248bcf2414e0c125236fe4b2d6e2ae6cb5f0caab656f94fc8
MD5 f69b0e892d6b072a8d53ebbce8f3d07f
BLAKE2b-256 ad65f0c75477d48720d6727ed57513adf2b19338c16e35a318127ee6a15e0eca

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for two_brain_audit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df1d734c1c614cdcde16deb6b77cc504fcf595c304260a13ea850bd2fe2e90b5
MD5 7ef89d0468908b5d25e5e039c9dd2135
BLAKE2b-256 6e1196cc87a4fa20d1a5fcf0a987d2da4e26e148174827d342275528a89f24b2

See more details on using hashes here.

Provenance

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