SL

sipyourdrink-ltd/bernstein

Developer tools
1.2K stars Quality 70 Trend 23Apache-2.0

"To achieve great things, two things are needed: a plan and not quite enough time." - attributed to Leonard Bernstein

Overview

"To achieve great things, two things are needed: a plan and not quite enough time." - attributed to Leonard Bernstein

README


Status: beta. Solo-maintained, under active development. The version number counts releases, not maturity - minor versions may change interfaces. Pin the version for anything you depend on; regressions get fixed fast, file them.

Bernstein is an open-source governance layer for AI agents. It runs on policy as code: you write the policy - who may do what, what needs approval, what must be recorded - and Bernstein enforces it and produces the verifiable record. A deterministic scheduler - no model in the coordination loop - runs agents in parallel, gates what they produce, and records every step, so a run can be verified after the fact, offline, from the artifacts alone. CLI coding agents work out of the box (Claude Code, Codex, Gemini CLI and others), and the same layer governs any agent workload: the deliverable can be a diff, a research report, a dataset, or an audit evidence pack. Air-gap install profile included. Apache-2.0.

install in 30 seconds

uv tool install bernstein    # or: pipx install bernstein
bernstein demo               # zero-key local run (4 mock tasks); prints project path & run_id
# Inside the printed demo directory, sign and verify your own receipt offline:
openssl genpkey -algorithm ED25519 -out demo.key && openssl pkey -in demo.key -pubout -out demo.pub
bernstein verify run  --signing-key-path demo.key
bernstein verify receipt .sdd/runs//run-receipt.json --public-key demo.pub

To run against your own repository with an installed CLI agent, run bernstein init, set goal:, cli:, and internal_llm_provider: none in bernstein.yaml, switch to a working branch (git switch -c bernstein/first-run), check bernstein doctor, and run bernstein run --worker backend. Bernstein merges verified changes into the working branch and refuses merge-capable runs from the default branch.

pipx, pip, brew, dnf, npm, and Docker are covered in the install guide; the air-gapped wheelhouse has its own air-gap guide. Operational checks (doctor --json, worktrees sweep, and declaration quarantine) live in the doctor, worktrees, and quarantine guides.

GHCR · GitHub Codespaces

The recording above is a real run, and it ships with its own proof. The cast, the signed run receipt derived from that run’s journal, and the public key that pins it all live in docs/assets/demo-run/. Verify the committed sample offline (or test tamper detection by editing a copy — bernstein verify receipt exits 2 with TAMPER DETECTED):

bernstein verify receipt docs/assets/demo-run/run-receipt.json \
    --public-key docs/assets/demo-run/run-receipt.pub.pem

The committed receipt can be re-checked at any time with the command above, and a tampered copy fails the same check. scripts/record_demo.sh regenerates the recording, receipt, and key from a fresh real run; nothing inside the terminal is synthesised.

A run in flight is watchable from either operator surface. Both read the same task API, so neither is a lagging mirror of the other. In bernstein live, the left and right columns scroll independently as whole panes, so widgets below the fold remain reachable in shorter terminals. Per-task progress percentages are clamped to 0-100: a task reporting more completed steps than its total, or a negative count, shows 100% or 0% rather than overshooting the bar.

BERNSTEIN_SERVER_URL="" bernstein live — the terminal dashboard, including remote cluster workers /ui/ — browser dashboard already served by bernstein run when GUI assets are installed. Use bernstein gui serve only as a standalone server when no run is active on port 8052.

For an authenticated server, set BERNSTEIN_AUTH_TOKEN for bernstein live and /api/v1/* requests, or sign in via the browser login screen. GUI authentication.

at a glance

Five things set it apart; everything after is detail.

  • No LLM in the coordination loop. Scheduling is plain Python, so a run is reproducible end to end. Replay yesterday’s plan and get yesterday’s task graph.
  • Hardware key evidence. Offline PIV custody and FIDO2 approval verifiers share the receipt protocol, with pinned trust and explicit time. Token custody does not raise TRACE trust levels. See hardware key evidence.
  • Checkable after the fact. The replay journal records every run, and the always-on lineage spine records every lineage-bearing step; the opt-in HMAC-chained audit log (BERNSTEIN_AUDIT=1) adds receipts you verify offline. Non-determinism surfaces as a hash mismatch at the exact step, not a flaky re-run. Non-code deliverables get the same treatment: a task can declare an artifact contract (report, dataset, action log, ops result) and completes on a signed lineage receipt rather than a git commit.
  • Isolated by construction. Each coding task gets its own git worktree behind merge gates; artifact-mode tasks get a working directory under .sdd/workspaces/. Agents share no mutable workspace by default; the only shared state is the task backlog, which is claimed atomically. Stricter filesystem enforcement is opt-in, from the sandbox backends. Disable worktrees and every task runs in the shared checkout.
  • Broad and local. 55 selectable CLI agent adapter names (26 listed below; full catalogue via bernstein adapters list), including the generic --prompt wrapper, file-based state, no SaaS hop, no third-party data plane.

The full list is on the capabilities page; the feature matrix is the exhaustive index.

The task server supports a persistent operator-controlled gate for new task claims; see the guide.

Role-adapter policy supports an optional default allow-list for unlisted roles; see the guide.

what a run looks like

One YAML file declares the run: phases, roles, dependencies, and the conditions under which a node runs at all. The scheduler executes it as plain Python - nothing in the file is a prompt, and no model decides what happens next. This graph produces an audit evidence pack; the full file ships at .bernstein/workflows/audit-evidence-pack.yaml.

name: audit-evidence-pack
version: "1.0.0"

phases:
  - name: scope
    allowed_roles: [manager, architect]
  - name: collect
  - name: validate
    allowed_roles: [qa, security]
  - name: deliver
    allowed_roles: [security, manager]

nodes:
  define-control-inventory:
    phase: scope
    role: architect

  collect-audit-logs:
    phase: collect
    role: security
    depends_on: [define-control-inventory]

  # three more evidence streams collect in parallel:
  # collect-sboms-and-attestations, collect-runbooks-and-policies,
  # collect-eval-results

  assemble-pack:
    phase: validate
    role: docs
    depends_on:
      - collect-audit-logs
      - collect-sboms-and-attestations
      - collect-runbooks-and-policies
      - collect-eval-results

  mock-auditor-pass:
    phase: validate
    role: qa
    depends_on: [assemble-pack]

  remediate-findings:
    phase: collect
    role: docs
    depends_on:
      - source: mock-auditor-pass
        condition: "status == 'failed'"
    retry:
      max_attempts: 3
      until: "status == 'done'"

  sign-and-deliver:
    phase: deliver
    role: security
    depends_on:
      - source: mock-auditor-pass
        condition: "status == 'done'"
flowchart LR
    inv[define-control-inventory] --> logs[collect-audit-logs]
    inv --> sbom[collect-sboms-and-attestations]
    inv --> rb[collect-runbooks-and-policies]
    inv --> ev[collect-eval-results]
    logs --> pack[assemble-pack]
    sbom --> pack
    rb --> pack
    ev --> pack
    pack --> gate{mock-auditor-pass}
    gate -->|failed| fix["remediate-findings (retry x3)"]
    gate -->|done| sign[sign-and-deliver]

Each node is claimed by an agent whose role the phase allows; role fences and approval gates hold no matter what the agent does inside the task. A coding node completes behind merge gates in its own git worktree. The nodes above complete differently: an artifact contract names the deliverable (report, dataset, scan, action log), and the node finishes on a signed lineage receipt instead of a commit. Same scheduler, same journal, same offline verification - whether the graph ships code, research, an ops change, or a mix of all three. Ready-made graphs for software, research, docs, enterprise, and contributor workflows live in .bernstein/scenarios/.

Retries preserve dispatch_tier; reopening a task can explicitly select a tier. See the dispatch-tier contract.

prove a run

Determinism here is something you check, not something you take on faith. Run once with audit enabled, then verify what was recorded:

BERNSTEIN_AUDIT=1 bernstein -g "fix the failing test in tests/test_foo.py"
bernstein replay list                 # run ids recorded on disk
bernstein replay latest --verify      # recompute the journal head, name the first divergent step
bernstein lineage verify      # recompute the always-on lineage spine
bernstein audit verify                # HMAC chain + Merkle seal (written because audit was enabled)
bernstein audit diagnose  --signal gate --sign-key KEY
                                      # name the exact step a failure entered the run, as a signed receipt
bernstein verify run  --signing-key-path key.pem   # sign one portable run receipt
bernstein verify receipt .sdd/runs//run-receipt.json  # verify it offline: file only

The journal is written on every run; the lineage spine is always on and gains an entry for each lineage-bearing step, so a short run can finish with a valid, empty spine. bernstein audit verify only has a chain to check when the run was started with BERNSTEIN_AUDIT=1, a compliance preset, or bernstein run --audit. The --audit flag belongs to bernstein run; on the bernstein -g form above, set the environment variable.

One run receipt binds the journal head, the lineage-spine head when the run wrote spine entries, and, opt-in, an audit-chain range, under a single Ed25519-signed subject with the public key embedded. A reviewer holding that file and the operator’s public key can confirm the embedded actions and chains were not changed: no HMAC key, no live .sdd/, and exit 2 naming the first divergent step on tamper. That receipt identifies the journal state it embeds; proving that state is the complete finished journal additionally requires an independent head/count seal. With the file alone and no --public-key pin, the check is integrity-only — it proves the receipt is internally consistent, not who signed it, and the verdict says so. Details in deterministic replay.

In the web UI, open Governance and use Verify a receipt to check a run receipt with the server. The browser shows the integrity-only verdict and the key source. See the Governance operator guide.

The same checkability applies to evaluation numbers. bernstein bench run --reliability k (also spelled bernstein eval --reliability k) runs every task k times under fixed coordination, then reports a pass^k floor (all k attempts must pass) alongside the pass@1 ceiling. That result is sealed in a signed receipt which bernstein bench reliability-verify recomputes offline, so a fabricated floor fails verification. Details: pass^k reliability floor.

Use bernstein govern audit --format json or --format sarif for machine-readable findings and --strict --quiet for a CI gate. See govern audit. The cosai evidence pack includes the MCP threat classes from the pinned 2026-01-08 paper and states the remaining coverage gaps.

bernstein delegation verify RUN compares the receipt chain with the final head and hop count sealed in the run manifest with the audit-key HMAC, detecting tail deletion, substitution and post-close growth, including keyless rewrites of the declaration. Removing the declaration leaves the run incomplete (exit 3), never valid. This does not detect replay of an older authentic snapshot or protect against a writer holding the audit key. See the delegation verification workflow.

how it works

Each goal moves through four stages:

  1. Decompose. The manager breaks your goal into tasks with roles, owned files, and completion signals. One LLM call, then plain Python from there.
  2. Spawn. Agents start in isolated git worktrees, one per coding task; an artifact-mode task gets a plain working directory instead. Main branch stays clean.
  3. Verify. The janitor checks concrete signals: tests pass, files exist, lint clean, types correct.
  4. Merge. Verified work lands in main. Failed tasks get retried or routed to a different model.

Why the scheduler is plain Python, and what that trades away: why deterministic.

The cost tracker’s can_spawn() check returns False when corrected cumulative spending reaches or exceeds the configured budget stop threshold, even if no new tokens were reported. After a restart, saved token counts alone cannot reconstruct the exact cumulative cost previously reported for a given agent, task and model.

everyday commands

cd your-project
bernstein init                    # creates .sdd/ workspace, bernstein.yaml + templates/
bernstein -g "Add rate limiting"  # agents spawn, work in parallel, verify, exit
bernstein live                    # watch progress in the TUI dashboard
bernstein run plan.yaml           # multi-stage plan: skip LLM planning, execute directly
bernstein stop                    # graceful shutdown with drain

If a task in a detached SSH run exits with a nonzero code, the task and the run fail. The task receipt records the exit code, and later tasks stay pending.

The full operator surface (PR automation, schedules, chat bridges, the autofix daemon) is in operator commands.

bernstein workflow runs declarative YAML DAGs of agent, command, and loop nodes - with resume support for interrupted runs:

bernstein workflow run idea-to-pr -g "Add JWT auth"   # prints run_id
bernstein workflow resume  -g "Add JWT auth" # picks up at the first non-completed node

Run state checkpoints to .sdd/runs// on every node. Resume validates the manifest digest at run start, so a spec change is refused rather than silently executing a different manifest. Cleanup nodes may set always_run: true to execute after a command or dispatch failure without turning an aborted run into a success (agent completion gating is tracked in #6639). See workflow manifests. Supply the same -g value again on resume so {goal} is substituted in prompts for unfinished nodes.

bernstein compliance controls lists benchmark suites for each control and shows the latest complete measurement, when available. Benchmark coverage

Repository hygiene gates: bernstein readme-l10n verify fails a PR whose translated READMEs drifted from the English source (naming the stale section), bernstein readme-l10n sync rebinds them after an English edit. See readme-l10n.

supported agents

Claude Code, Codex CLI, Gemini CLI, GitHub Copilot CLI, Cursor, Aider, Goose, Muse Code, OpenAI Agents SDK, Amp, Cody, Continue, Devin Terminal, Junie, Kilo, Kiro, AWS Q Developer, Ollama, OpenCode, OpenHands, Open Interpreter, gptme, Plandex, AIChat, Letta Code, Qwen, and more. The adapter index carries install commands for 30 of them. bernstein integrations list enumerates all 57 wired-in integrations from src/bernstein/adapters/registry.py, the single source of truth for what resolves. 55 of them are selectable agent adapters; the other two rows are the mock test stub and the self-hosted-endpoints endpoint profile. bernstein adapters list prints Selectable CLI agent adapter names: 55. This counts selectable registry names, including the agy/antigravity alias pair and generic; it does not count unique upstream tools or prove that binaries are installed or admitted. Anything else with a --prompt flag works through the generic wrapper.

Mix agents in the same run: cheap local models for boilerplate, heavier cloud models for architecture. bernstein integrations list --installed shows what is available on your machine.

beyond the front page

Everything deep lives on the docs site:

page what it covers
capabilities the full capability list: MCP server mode, signed agent cards, sandbox backends, artifact sinks, regulatory mappings
Agent Manifest export bernstein manifest export-agent · composition-only · agent-manifest==0.12.0
bernstein_create_task POST /api/v1/tasks → bernstein_claim → bernstein_complete
MCP server local stdio server, plus a hosted read-only endpoint at mcp.bernstein.run for receipt verification with no install; questions about this repo can be asked over MCP through DeepWiki
who this is for where the value lands, and where Bernstein is the wrong tool
workflows declarative YAML DAGs of agent / command / loop nodes
web UI browser dashboard with task creation and review on the same API the TUI uses
cluster worker health (bernstein worker) workers pause new task claims while their reported disk space, memory use or mesh latency is outside the configured thresholds
datasources read-only query receipts, plus a query driver that binds each result to the schema snapshot it was derived against
agent catalogs point roles at agent definitions outside the built-in templates - a generic YAML/SKILL.md directory, or a Claude Code plugin-layout tree
integrations what Bernstein bridges to, by the name you call it: SCIM, OIDC, Vault, OPA/Cedar, SPIFFE, OpenTelemetry, MCP, A2A - with what is shipped, what is wired, and what is not planned
companion plugins (bernstein-addons) optional companion plugins (role-pack, sandcastle, brand-gate) installed from source after trying core Bernstein
plugins plugin list and installation instructions
security scorecard, fuzzing, hardening
architecture how it works under the hood

why the name?

Bernstein is named after Leonard Bernstein, the American conductor and composer. The orchestrator coordinates a crew of AI agents the way Bernstein conducted the New York Philharmonic: every player on cue, the score deterministic, the conductor accountable for the result. The conductor metaphor describes Bernstein’s orchestration capability for agent workloads that produce code, research reports, or datasets.

Bernstein started as a deterministic harness to prevent nondeterministic merges and unverified state across parallel coding agents. Apache-2.0. Releases and documentation: bernstein.run.

contributing, support, license

PRs welcome; CONTRIBUTING.md has setup and code style. Security reports go through SECURITY.md. Contact: [email protected].

Citation metadata lives in CITATION.cff. License: Apache-2.0; the project name is covered separately in TRADEMARKS.md.


Alex Chernysh · GitHub · X · bernstein.run · task notifications

View the full README on GitHub

Recommended Tools

Try a different keyword or remove a filter.

Install

npx skillfish add sipyourdrink-ltd/bernstein
New to MCP? Start with the mcpskill.org guide →