Skip to main content

Certify the Decision, Not the Outcome: Bayesian Experimental Design on Search Graphs (dagcert)

PyPI CI License: MIT Python 3.10+ Manuscript Lean 4

Installable Python library (dagcert), full experimental suite (experiment/), bundled benchmark datasets, SHA-256-verified run archives (results/), Lean 4 formalizations (lean/), and complete reproduction scripts for Certify the Decision, Not the Outcome: Bayesian Experimental Design on Search Graphs.

Shared outcomes change what can invalidate a root decision

Shared outcomes change what can invalidate a root decision: a terminal that the chosen action can still reach cannot count against it, so only excluded outcomes matter.


Overview

In sequential decision-making, an initial commitment can be certified as $\varepsilon$-optimal long before its best full continuation is known. Many real search spaces — combinatorial protein design, agentic workflow configuration, routing, and puzzle lookahead — are directed acyclic graphs (DAGs) in which different action sequences reach overlapping terminal sets, and evidence about terminal outcomes is statistically correlated.

Joint Root Certification directly certifies that a root action $a$ retains access to an $\varepsilon$-optimal terminal outcome:

A commitment can be invalidated only by an excluded terminal $z \notin S(a)$ that beats every retained continuation $y \in S(a)$ by more than $\varepsilon$ under the same plausible environment.

Key methodological contributions implemented in dagcert:

  1. Structural sharing (exact outside-support regret): Evaluating all outcomes under a single common environment cancels shared continuations, replacing loose marginal action-value bounds with exact outside-vs-inside certificates.
  2. Statistical sharing (sparse ellipsoidal dual & CD-Joint): Under correlated Gaussian or fixed-feature uncertainty sets, worst-case decision regret admits an exact sparse conic dual (supported on at most $d+1$ inside witnesses). CD-Joint (Contrast-Directed Joint acquisition) targets the variance of the active outside–inside contrast, exploiting even low-valued but informative off-witness proxies while safeguarding against inside-witness stalling.
  3. Stopping-regime awareness: The library supports matched Bayesian joint credible ellipsoids (with exact contrast rank $r = \operatorname{rank}(\text{contrast } \Sigma)$ and radius $\sqrt{\chi^2_{r,1-\delta}}$), direct posterior-risk stopping, anytime-valid fixed-feature ellipsoids, unknown-variance sparse-refresh tracking (V34) with native C++17 outward-certified branch-and-bound, calibrated EB+LOO GP stopping, and formal distribution-free (Hoeffding / Empirical Bernstein) confidence boxes.

Installation & Python Library Quickstart

Requires Python 3.10 or newer. The core library depends only on NumPy and SciPy.

1. Install dagcert

pip install dagcert

Optional extras:

pip install "dagcert[audit]"         # CVXPY/Clarabel reference solvers (solver="cvxpy_socp") and oracle audits
pip install "dagcert[experiments]"   # matplotlib, pandas, requests, networkx: paper experiments and figures
pip install "dagcert[llm]"           # PyTorch / Transformers for the live Qwen3-0.6B workflow suites
pip install "dagcert[all]"           # everything, plus pytest, build and twine

To reproduce the paper, install from source instead:

git clone https://github.com/AI-MathPhys/dag-cert.git
cd dag-cert
python -m venv .venv
source .venv/bin/activate            # Windows PowerShell: .\.venv\Scripts\Activate.ps1
python -m pip install -e ".[dev,audit,experiments]"

Native C++17 accelerators (optional): when $CXX, g++ or clang++ is available, dagcert compiles its four -O3 C++17 kernels on first use and caches the shared libraries in the system temporary directory (exact correlated KG, outward-certified branch-and-bound for unknown-variance tracking, graph-maintenance kernels, and SameGame playouts). Exact correlated KG falls back to a pure-Python implementation with identical results; the other three are research accelerators that require a compiler, and their tests are skipped when none is found.

2. Minimal Library Usage

import numpy as np
from dagcert import (
    SearchDAG,
    certify_root_action,
    exact_rectangular_regret,
)

# 1. Exact shared-support rectangular certificate (Figure 1b)
# Root action 0 reaches {0, 1}; root action 1 reaches {1, 2}. Shared terminal 1 cancels!
dag = SearchDAG.from_supports([{0, 1}, {1, 2}])
lo = np.array([0.72, 0.40, 0.30])
hi = np.array([0.80, 0.95, 0.55])
best_a, min_reg, regrets = exact_rectangular_regret(dag, lo, hi)
print(f"Best root action: {best_a}, exact regrets: {regrets.tolist()}")
# -> Best root action: 0, exact regrets: [0.0, 0.4]

# 2. Decision-aware Bayesian experimental design (CD-Joint vs. GP-OS vs. Correlated KG)
rng = np.random.default_rng(7)
dag = SearchDAG.from_supports([{0, 1, 2, 3}, {2, 3, 4, 5}, {4, 5, 6, 7}])
features = rng.normal(size=(8, 4))
kernel = features @ features.T + 0.05 * np.eye(8)
true_means = np.array([0.78, 0.72, 0.55, 0.50, 0.48, 0.42, 0.40, 0.35])

for policy in ("cd_joint", "gp_os", "kg"):
    noise = np.random.default_rng(123)
    res = certify_root_action(
        dag=dag,
        observe_fn=lambda z, r=noise: float(true_means[z] + r.normal(0.0, 0.15)),
        kernel=kernel,
        prior_mean=0.5,
        obs_std=0.15,
        policy=policy,
        stopping="credible_ellipsoid",   # rank-corrected sqrt(chi2_{r, 1-delta})
        epsilon=0.03,
        delta=0.05,
        max_evals=500,
    )
    print(f"{policy:9s} | certified={res.certified} | action={res.action} | evals={res.steps}")

3. Library Architecture (dagcert/)

Module Paper Concepts Key Public Exports
dagcert/graph.py Finite all-MAX search DAG, shared root supports, support overlap SearchDAG (.from_supports, .root_supports, .root_regrets, .support_overlap_matrix), DAG, Problem, SupportStructure
dagcert/certificates.py Exact rectangular regret, conic ellipsoidal dual, dual witness covers, bounded residuals exact_rectangular_regret, JointEllipsoidCertifier, check_ellipsoid_stopping, DualWitnessCovers, CanonicalIntervals, NestedIntervals, RobustAwareJointCertifier
dagcert/posteriors.py Conjugate Gaussian posterior, contrast rank $r$, $\sqrt{\chi^2_{r,1-\delta}}$, valid anytime posterior-risk MC SharedGaussianPosterior, contrast_rank_of_kernel, chi2_credible_beta, contrast_ellipsoid_coverage, eval_direct_posterior_risk_valid
dagcert/acquisition.py Decision-aware BED & BO baselines under matched posteriors certify_root_action, MatchedModelBEDSession, CDJointPolicy, CorrelatedKGPolicy, GPOSPolicy, BayesianVOIPolicy, GPUCBPolicy, GPTSPolicy, NoisyGPEIPolicy
dagcert/tracking.py Optimal information tracking ($T_*^\varepsilon$), unknown-variance sparse V34 tracker RegularizedInfoTrackerSession, run_v34_tracker, CppV34BnBRunner, compute_characteristic_rate, solve_action_design_certified
dagcert/search.py Passive trajectory-coupled UCT/PUCT certification monitors TrajectoryCoupledUCT, RootPUCT, RecursivePUCT, CertifiedSearchSession, CppKernelRunner
dagcert/benchmarks/ Bundled synthetic, GB1/TmTrpB protein, WorFBench workflow & SameGame DAG loaders OverlapCorrelationDAGProblem, OffWitnessProxyDAGProblem, GB1MutationCampaignProblem, TrpBMutationCampaignProblem, WorFBenchWorkflowProblem, load_standard_samegame_boards
dagcert/_native/ Optional auto-compiled -O3 C++17 accelerators _cpp_v12_kg.cpp, _cpp_v34_bnb.cpp, _cpp_kernels.cpp, _cpp_samegame.cpp

Standalone runnable library examples live in examples/:

python examples/quickstart_cd_joint.py   # Fig. 1b + CD-Joint vs. GP-OS vs. KG + distribution-free
python examples/correlated_proxy.py      # Low-valued off-witness proxy allocation (Fig. 2e)
python examples/protein_dag_demo.py      # GB1 combinatorial mutation DAG certification
python examples/certify.py               # Trajectory-coupled passive UCT monitor parity

Headline Paper Results (Complete Coverage)

Every main-paper and appendix result is backed by executable code in experiment/ and SHA-256-verified logs in results/.

Paper Location Finding Domain & Suite
§2.3, Table 1 Lazy conic certificate updates scale from $0.70\text{ ms}$ ($M=64$) to $25.7\text{ ms}$ ($M=4{,}096$) simulated (e6)
§3.1, Table 3; App. G.1 (Tables 7–9, Fig. 3) Matched-model $M=64, K=8$ factorial: CD-Joint needs $2{,}358$ vs. Correlated KG $5{,}056$ capped evals ($2.14\times$ reduction; $2.53\times$ with overlap + correlation); $1.65\times$ under anytime-valid $d=8$ frequentist stopping simulated (v12)
§3.1, Fig. 2d, Table 10 Exact outside-support stopping needs $0.054\times$ the queries of marginal stopping at $M=256$, overlap $.88$ ($18.4\times$) simulated (exp1)
§3.1, Fig. 2e, Tables 11 & 13 CD-Joint routes $76.8%$ of queries to a low-valued proxy vs. $0.6%$ for direct-witness sampling; up to $48.5\times$ lower median cost simulated (e0, v8_3)
§3.2, Fig. 2f–h, Table 4; App. H (Tables 24–26, Fig. 8) 410 paired GB1 ($n=200$) & TmTrpB ($n=210$) campaigns: under rank-corrected $\sqrt{\chi^2_{r,.95}}$ ellipsoid, CD-Joint needs $17{,}678$ [70%] / $3{,}629$ [100%] assays vs. KG $25{,}000^*$ [0%] / $9{,}337$ [85.7%] ($2.57\times$ on TmTrpB); ranking reverses under direct posterior risk (KG $130$/$63$ vs. CD-Joint $240$/$92$) and independent-arm DF ($0%$ for GP-only CD-Joint) protein_engineering (v14, v13)
§3.2, Table 27 Empirical-Bayes protein audit: simultaneous terminal coverage $91.5%$ / $82.9%$, yet $100%$ root-regret-bound coverage across 410 campaigns protein_engineering (v11_1)
§3.3, Table 5 (offline), Table 35 WorFBench offline ($3^4=81$ workflows): OS certifies $100%$ in $1{,}937$ median evals ($0.95\text{ M}$ tokens) vs. Flat-LUCB $8{,}486$ ($4.78\text{ M}$ tokens) at identical held-out $F_1 = 0.529$ agentic_workflows (exp12)
§3.3, Table 5 (live), Table 37, Fig. 9 36 fresh uncached Qwen3-0.6B campaigns across 4 domains: formal DF stops $0/36$ by 60 evals; model-based EB+LOO certifies $36/36$ in median $24$ evals ($14{,}291$ tokens, held-out $F_1 = 0.4717$) agentic_workflows (v11_2)
App. J.3, Table 43, Fig. 13a Unknown-variance sparse-refresh + action-local IUT tracker (V34): $50.4\times$ speedup at $K=64$, rank 2 ($34.0\text{ s} \to 0.675\text{ s}$) simulated (v9_1)
App. L.5–L.6, Tables 68–69, Fig. 14 Native C++17 outward-certified B&B achieves $31$–$82\times$ end-to-end speedup; zero-shared-code independent numerical-oracle audit passes $5/5$ checks simulated (v10_1, v11_3)

Reproducing the Paper (experiment/)

All experiments rely directly on the installed dagcert package and are organized into three domain folders mirroring Section 3 of the paper, plus unified plotting (experiment/plots/) and CLI (experiment/run_all.py):

Fast Verification (~2 minutes, CPU only, offline)

# 1. Check bundled datasets, optional Hugging Face cache, and C++17 compiler
python scripts/fetch_data.py --check

# 2. Cryptographically verify SHA-256 manifests for ALL archived suites (v1--v14, zero gaps)
python experiment/run_all.py verify

# 3. Run all 88 unit, parity, library-API, and independent-oracle tests
python experiment/run_all.py test

# 4. Regenerate all 14 manuscript data figures (Figures 2–14: `figures/fig*.pdf`, `figures/supp_*.pdf`)
python experiment/run_all.py figures

Running Individual Domains or Suites

# List all 41 suites grouped by domain
python experiment/run_all.py list

# Fast non-destructive smoke tests (writes only to OS tempdir, never modifies results/)
python experiment/run_all.py benchmark --only v12 --smoke
python experiment/run_all.py benchmark --only v14 --smoke
python experiment/run_all.py benchmark --only e4  --smoke

# Re-run a full suite (or regenerate its CSV summaries from archived JSONL logs)
python experiment/run_all.py summaries --only v14
python experiment/run_all.py benchmark --domain protein_engineering --only v14

Paper Section to Suite Key Map

See REPRODUCIBILITY.md for the complete table-by-table mapping across Tables 1–69 and Figures 1–14.

Paper Section Tables / Figures Domain Suite Keys
§2.3, App. L.1 (conic update scaling & break-even) Tables 1, 57, 58 simulated e6, v8_4
§3.1, App. G.1, App. L.1 (matched BED vs. KG/VOI/BO & $d=8$ anytime) Table 3, Tables 7–9, 14, 59; Fig. 3 simulated v12
§3.1, App. G.2–G.3 (structural overlap & correlated proxy mechanisms) Fig. 2d–e, Tables 10–13, 15; Figs. 4–5 simulated exp1, e0, e1, e2, v8_3
App. G.4–G.5 (DF baselines, witness ablations, SameGame & routing) Tables 16–23; Figs. 6–7 simulated exp5, exp6, exp8–exp11, v8_6
§3.2, App. H.1–H.4 (matched GB1 & TmTrpB BED vs. KG & $\chi^2_{r,.95}$ audit) Fig. 2f–h, Table 4, Tables 24–26; Fig. 8 protein_engineering v14, v13
§3.2, App. H.5–H.6 (calibration, validity ablation, extended GB1/TmTrpB) Tables 27–34; Fig. 11 protein_engineering v11_1, v8_1, exp12–exp14, e3
§3.3, App. I (WorFBench offline & live uncached Qwen3-0.6B workflows) Table 5, Tables 35–39; Figs. 9, 14c agentic_workflows exp12, exp13, v11_2, v10_3, v8_5
App. J.1–J.4 (info tracking, unknown variance V34, heteroscedastic bridge) Tables 40–50; Figs. 10–13, 14b simulated / protein_engineering v8_2, e5, v8_1, v9_1–v9_4, v10_2, v11_1
App. J.5, L.2–L.4 (passive UCT/PUCT, C++ maintenance kernels, memory) Tables 51–56, 60–67 simulated passive_uct/, exp2–exp4, exp7
App. L.5–L.6 (native C++17 B&B scaling, independent oracle audit) Tables 68–69; Fig. 14a simulated v10_1, v11_3

External Data & Models (scripts/fetch_data.py)

Four compact preprocessed .npz archives (dagcert/benchmarks/data/, 1.7 MB) and the 20-board SameGame set are bundled in Git so installation, verification, unit tests, and all CPU experiments run offline. Every upstream source can also be downloaded and rebuilt from scratch:

Dataset / Asset Upstream Source Bundled File Rebuild Command
GB1 (149,361 four-site variants; Wu et al. 2016) FLIP dagcert/benchmarks/data/gb1_wu2016_measured.npz python scripts/fetch_data.py --proteins
TmTrpB (159,129 four-site variants; Johnston et al. 2024) Zenodo 15203754 dagcert/benchmarks/data/trpb_johnston2024_measured.npz python scripts/fetch_data.py --proteins
WorFBench raw trajectories (4 domains) zjunlp/WorfBench cached in dagcert/benchmarks/data/worfbench_raw/ python scripts/fetch_data.py --worfbench-tasks
Qwen/Qwen3-0.6B & Qwen/Qwen3-Embedding-0.6B Hugging Face Hub local Hugging Face cache python scripts/fetch_data.py --models
WorFBench $81\times 64$ & $81\times 32$ score matrices generated from above dagcert/benchmarks/data/worfbench_qwen3_*.npz python scripts/fetch_data.py --rebuild-worfbench

Pass --out-dir build/rebuilt_data to rebuild alongside the bundled files for comparison, or --all to fetch everything. After caching models and trajectories, set HF_HUB_OFFLINE=1 to run live LLM suites offline.


Lean 4 Formalizations (lean/)

The lean/ directory holds a Lean 4 + Mathlib formalization of the paper's numbered results, with no sorry and no added axioms. Of the 62 results, 62 are proved as written up to harmless differences, 0 are false as written, 0 are proved only in a corrected or reformulated form because the manuscript statement is not established as written, and 0 are open, according to independent clause-by-clause reviews. lean/README.md gives, for every result, the Lean theorem names and exactly how the formal statement relates to the manuscript, a list of hypotheses the manuscript leaves implicit, and the limits of the formalization (for example: algorithms are specified by their selection rules, numerical oracles enter through the paper's contract, and running-time claims hold in an explicit step-counting model).

Build with cd lean && lake exe cache get && lake build (Lean toolchain pinned in lean/lean-toolchain).


Repository Structure

dag-cert/
├── dagcert/                         # Installable Python library (`pip install dagcert` / `-e .`)
│   ├── graph.py                     # SearchDAG, SupportStructure, regret & overlap utilities
│   ├── certificates.py              # Rectangular, conic ellipsoidal, witness-cover & DF bounds
│   ├── posteriors.py                # SharedGaussianPosterior, contrast rank, chi2 beta, post.-risk MC
│   ├── acquisition.py               # certify_root_action, CD-Joint, Correlated KG, GP-OS, VOI, BO
│   ├── tracking.py                  # Info-tracking (T_*^eps) & V34 unknown-variance sparse tracker
│   ├── search.py                    # Trajectory-coupled passive UCT & PUCT certification
│   ├── benchmarks/                  # Synthetic, GB1/TmTrpB, WorFBench & SameGame loaders + data/
│   ├── _native/                     # Optional auto-compiled -O3 C++17 accelerators
│   └── _core/                       # Verified low-level numerical engines
├── experiment/                      # Complete paper experiments organized by domain
│   ├── run_all.py                   # Unified CLI: list, verify, test, summaries, figures, benchmark
│   ├── simulated/                   # §3.1 + App. G, J, L (27 suites + passive_uct/ v1 archive)
│   ├── protein_engineering/         # §3.2 + App. H (10 GB1 & TmTrpB suites)
│   ├── agentic_workflows/           # §3.3 + App. I (WorFBench offline & live Qwen3-0.6B suites)
│   └── plots/                       # Generates manuscript Figures 2–14 + detailed suite plots
├── examples/                        # Standalone library quickstart & domain demos
├── tests/                           # 88 unit, parity, library-API & oracle tests (v1--v14)
├── results/                         # SHA-256-verified run archives, CSV summaries & manifests
├── figures/                         # README overview PNG + manuscript Figures 2–14 (vector PDF)
├── scripts/fetch_data.py            # Offline verifier & upstream data/model rebuild utility
├── lean/                            # Lean 4 + Mathlib formal proofs (status in lean/README.md)
├── manuscript/                      # Paper PDF & LaTeX source
├── reference/tables/                # Reference LaTeX tables for passive UCT archive
├── .github/workflows/               # CI (Linux and macOS) and PyPI release on version tags
├── pyproject.toml                   # Package metadata and optional extras
├── CITATION.cff                     # Machine-readable citation metadata
└── REPRODUCIBILITY.md               # Complete Table 1--69 & Figure 1--14 artifact map

Statistical Scope & Notes

  • Validity depends on the stopping model. Bounded-observation Hoeffding and Empirical Bernstein boxes are distribution-free; fixed-feature ellipsoids and unknown-variance nuisance-KL e-processes provide anytime frequentist coverage under their respective parametric assumptions; bounded-residual ellipsoids require a misspecification bound $|b|\le\xi$; Bayesian credible ellipsoids, direct posterior risk, and EB+LOO stopping are model-based and do not inherit distribution-free validity (Table 2 and Appendix C).
  • Protein & live-LLM experiments. Protein benchmarks simulate noisy assays against published measured GB1 and TmTrpB landscapes (no new wet-lab experiments). Live workflow suites execute fresh, uncached Qwen3-0.6B inference on task pools strictly disjoint from calibration.
  • Determinism vs. timing. Statistical trajectories, operation counts, and SHA-256 manifests are deterministic; wall-clock times and wall-capped rates depend on host hardware.

Citation

If you use dagcert or this codebase in your research, please cite the accompanying manuscript (see also CITATION.cff):

@misc{pelissier2026dagcert,
  title  = {Certify the Decision, Not the Outcome: Bayesian Experimental Design on Search Graphs},
  author = {P{\'e}lissier, Aur{\'e}lien},
  year   = {2026},
  url    = {https://github.com/AI-MathPhys/dag-cert}
}

Metadata

Release files for dagcert 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dagcert 1.0.1
File Size Uploaded Provenance Actions
dagcert-1.0.1.tar.gz 1.7 MB With provenance Details for dagcert-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dagcert 1.0.1
File Interpreter ABI Platform Actions
dagcert-1.0.1-py3-none-any.whl Python 3 none any Details for dagcert-1.0.1-py3-none-any.whl

Total release size: 3.3 MB

Release files / dagcert-1.0.1.tar.gz

Download URL dagcert-1.0.1.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
83b4c5b9b4bddcb0350a7fe3988cef510c39efe5e2f5683d0b16e5c6e3631ea8
BLAKE2b-256 checksum
How to use checksums
6a88fde98011aa04c85af58b3919f9cb41450b1bd392be8e4c8ea6fb2ac07ce4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / dagcert-1.0.1-py3-none-any.whl

Download URL dagcert-1.0.1-py3-none-any.whl
Size 1.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
29c0767c493522dec53ad9744d67fadacfaa9e113e98dd625f90fc802329ba4d
BLAKE2b-256 checksum
How to use checksums
d8adcac667a9ff49b28dcffe42651b7653f22a638dd8d9e462eb91737de51240
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for dagcert 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dagcert-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page