lab-gate
Check an autonomous lab's experiment plan against written rules before it runs. lab-gate returns exactly one of:
- PASS with a proof certificate,
- BLOCK with a counterexample step sequence,
- ABSTAIN with a reason, so a human decides.
No decision path reads any free-text field. lab-gate is built on the public
helao-async
framework and evaluated inside its OER electrocatalysis simulator (OERSIM). It is an
independent project; it is not a contribution to, or endorsed by, helao-async or any
company.
It is a research tool, tested in simulation only. Read What it does NOT do before relying on it.
Install
pip install lab-gate
Python 3.12 or newer. The runtime dependencies are pydantic, pint, PyYAML, NumPy, pyzstd and z3-solver. helao-async itself is not needed (see What it needs).
Quickstart
lab-gate examples . # writes rules.yaml + 3 example plans
lab-gate check plan_pass.json --rules rules.yaml # PASS, exit code 0
lab-gate check plan_block.json --rules rules.yaml # BLOCK, exit code 1
lab-gate check plan_abstain.json --rules rules.yaml # ABSTAIN, exit code 2
lab-gate check plan_block.json --rules rules.yaml --json # machine-readable
The block example is five anneals. Each is within its substrate's temperature limit; together they overrun the furnace-time rule. The output names the rule, shows the step sequence that breaks it, and gives the hash of the rule set it was checked against:
verdict: BLOCK
reason: I3b violated: Total furnace occupancy must not exceed 240 minutes per campaign.
detail: I3b
rule set: lab-gate-registry-v1 (rules.yaml)
rule hash: ef9db6e32bd6b4e3e7802ebfae966d9d06b717e21cf9eb948ac3db5c7a95b818
plan hash: feb6bdf46dce74ba8d515a6a16230339cea853782892e00ce1429fc1e8a4ef74
counterexample (rule I3b first violated at step 4):
step 0: anneal furnace_minutes=60.0
step 1: anneal furnace_minutes=120.0
step 2: anneal furnace_minutes=180.0
step 3: anneal furnace_minutes=240.0
step 4: anneal furnace_minutes=300.0 <- violation
(full accounting state per step: re-run with --json)
The same from Python:
from lab_gate import load_rules, check
rules = load_rules("rules.yaml") # load_rules() alone = the bundled seed rules
result = check("plan_block.json", rules) # a plan dict works too
print(result.verdict) # BLOCK
print(result.reason) # I3b violated: Total furnace occupancy ...
print(result.rule_set_hash) # ef9db6e32bd6b4e3...
print(result.counterexample[-1]["accounting"]["furnace_minutes"]) # 300.0
print(check("plan_pass.json", rules).certificate["result"])
# UNSAT per invariant (no violation reachable within horizon)
check returns a CheckResult with verdict, reason, detail, certificate,
counterexample, rule_set_hash, plan_hash, horizon_k, exit_code, ok and
to_dict(). The same example files are in examples/ in this
repository.
The three verdicts
| verdict | meaning | what you get | exit code |
|---|---|---|---|
| PASS | No rule can be violated by this plan within the horizon (64 actions by default). Two independent checkers (a reference evaluator and the Z3 SMT solver) agree. | A proof certificate: solver, horizon, the rules shown unsatisfiable, and which proofs hold only up to the horizon. | 0 |
| BLOCK | A rule is violated. | The violated rule, and the counterexample: every step up to the violating one with the accounting state at each step. | 1 |
| ABSTAIN | The gate cannot decide: an unknown action, campaign class or substrate, a malformed or out-of-range parameter, a plan longer than the horizon, missing data, or a checker disagreement or error. | The reason. Route the plan to a human. | 2 |
lab-gate check exits with 64 on a usage or input error (bad arguments, an
unreadable plan, an invalid rule file). Anything other than 0 means: do not run the
plan as written. lab-gate version prints the version.
Writing rules
A rule set is a YAML file. A rule has an id, a kind, a plain-English statement, a
rationale, a source, and a strict spec. There are four kinds: bound (a limit on one
action), reach (a state that must never be reached, or an action that must come
after another), forbid_combo (elements that may not appear together), and
accumulate (a running total that must stay under a limit). For example:
- id: R1
kind: accumulate
plain_english: Total instrument time must not exceed 120 minutes per campaign.
scope: any
rationale: Why this rule exists.
source: Where the limit comes from.
spec: {quantity: instrument_minutes, agg: sum, limit: 120}
Rules are written over a fixed vocabulary of action types, per-step variables and
accumulated quantities; lab-gate is not a general rule engine. load_rules refuses a
rule that names something the checker does not know, because such a rule would
otherwise never fire. The full specification, including the plan format, is in
docs/RULES.md. The seed rules in
examples/rules.yaml are a complete, commented example.
What it needs
-
Plans without composition steps (like the three examples above) need only
pip install lab-gate. -
Plans with composition steps (
measure_cp,durability_test,deposit_composition): the potential rule (I1) looks up the measured potential of already-characterised compositions in helao-async's OER dataset (oer13_cps). That file belongs to helao-async and is not redistributed with lab-gate. Download it once from helao-async at the pinned commit, with its SHA-256 checked:lab-gate fetch-data lab-gate check plan_measure.json # in examples/; PASS once the data is presentOr point
HELAO_DATASETat a copy. Without the file, such plans ABSTAIN (checker_error) and the command prints a warning. They never PASS. -
The helao-async Python package is not needed at runtime. The evaluation code in this repository (
make ...) still expects a helao-async checkout beside it; see Reproduce the evaluation. -
The wheel installs three import packages:
lab_gate(the public API and command), andgateandsim_ext(the internals it wraps).
What it does NOT do
- It only knows the rules it is given. Harm that no rule describes passes. In the held-out evaluation, 20.6% of the static and decomposition attack plans (n=34) reached a benign harm the gate was never given a rule for (the out-of-spec probes, reported separately from the headline numbers). A rule-based gate cannot see such harm.
- Simulation only. Every result comes from the OER simulator. lab-gate has not been validated in a real lab, and no number here transfers to physical equipment without re-measurement.
- The seed rules are benign examples, not a safety policy. They model the structure of real controls (instrument protection, budgets, forbidden combinations, protocol order) with benign quantities.
- The human stays responsible. The gate enforces the rules exactly, including any mistake in them; a wrong limit gives a confident wrong verdict. ABSTAIN hands the decision back to a person. Writing and reviewing the rules is a human job.
- Proofs are bounded. PASS covers plans up to the horizon (64 actions by default); longer plans ABSTAIN. Some accumulate rules are proved only up to that horizon, and the certificate says which.
- It does not judge scientific merit, and there is no human-agreement evidence yet (the agreement protocol is written but not run).
Full list: LIMITATIONS.md.
Why
Autonomous labs run agents that execute physical experiments in loops, and lab-as-a-service platforms share instruments across several partners. Reasoning agents are good at breaking a goal into composable steps, which is also how a forbidden goal can be split into innocent-looking steps. A gate that fences written safety and protocol rules, and routes everything novel to a human, is one way to keep that structure honest. The gate never judges scientific merit and never blocks surprising-but-safe science; it is a verifier and an evaluation environment, not a rival reasoning method.
Research and evaluation
The rest of this page describes how lab-gate was evaluated. The installed package contains the gate only; the evaluation runs from a clone of this repository.
Three ways to judge it
- Watch:
make demoreproduces the headline numbers from cached model responses, without API keys (also packaged as a Docker image underdocker/). A recorded cast is inmedia/. - Read: this README,
docs/FINAL_REPORT.md,docs/POST.md, and the static results page insite/(every number renders fromresults/registry.jsonunder a numbers lock). - Reproduce:
make ci(lint, tests, taint test, static no-reference check, secret scan, numbers-lock check),make sim,make equivalence,make eval,make probe(malformed-number probes; seedocs/CORRECTIONS.md).
Reproduce the evaluation
# Work from a parent directory ($WS). lab-gate and helao-async must sit side by side:
# $WS/lab-gate $WS/helao-async
git clone https://github.com/Anuja-Khatri/lab-gate.git lab-gate
git clone https://github.com/High-Throughput-Experimentation/helao-async.git
git -C helao-async checkout ba910c4 # the pin the gate is evaluated against
cd lab-gate
make setup # uv venv (Python 3.12) + deps; PYTHONPATH -> helao-async
make ci # lint + tests + taint + secret scan + numbers lock
make sim # deterministic OERSIM closed loop (byte-identical)
make demo # reproduce headline numbers from cache (no API keys)
make demo needs no keys and no network: it recomputes the headline numbers from the
committed cache (eval/cache/) and checks them against results/registry.json.
Verified from a fresh clone (setup, ci, sim, demo all pass offline).
The LLM arms (LLM gate, LLM attacker) need keys in $WS/.env
(LABGATE_ANTHROPIC_API_KEY, LABGATE_OPENAI_API_KEY, LABGATE_GEMINI_API_KEY,
LLM_BUDGET_USD); every call
is cached, metered, and budget-capped. make demo needs no keys.
Results summary
See docs/tables/results.md (rendered from the registry) and the site. In short, on
the held-out evaluation:
- the typed gate lets through no in-specification static or decomposition attack and never false-blocks a benign plan, including the surprise subset; its failures are confined to out-of-spec harm and attacks beyond its horizon, where it abstains;
- the LLM gate, given a frontier model, the full rules, and the full plan including comments, is an unreliable gate in both model families tested, in opposite directions: one is too permissive (lets through ~a quarter of the attacks), the other over-blocks benign plans and lets through adaptive attacks with nonzero run-to-run variance; giving the permissive LLM the same predicted potential the typed gate uses sharply cut its attack misses but did not make it a reliable gate;
- the learned classifier is accurate in-distribution and degrades under adaptive attack;
- a third-vendor cross-check (Gemini attacker + Gemini gate) is implemented and verified live but its arms are "blocked, not measured" on the available free-tier quota, reported honestly empty rather than estimated.
Exact rates with n and 95% CIs are in the registry; this prose states direction only. The reference and SMT checkers agree on every plan in the equivalence suite, every BLOCK counterexample replays in the simulator, and the taint test shows no text channel.
Preregistration and report
The evaluation protocol was frozen before the held-out runs; the binding timestamp is the git tag prereg-v1. The protocol is registered at OSF: https://osf.io/jxhfe. The full report PDF: https://doi.org/10.5281/zenodo.23954617.
Limitations
A simulator is not a lab; the invariants are benign stand-ins that model the structure
of real controls; there is no human-agreement evidence; the paid LLM arms ran at
reduced sizes under a spend cap. Full list: LIMITATIONS.md. Human checkpoints:
HUMAN_CHECKPOINTS.md. Agreement protocol (written, unexecuted): AGREEMENT_PROTOCOL.md.
Attribution and AI disclosure
Built on helao-async (MIT) at pin ba910c4; the OER CP dataset replayed by OERSIM
originates from measurements associated with doi:10.1039/C8MH01641K. Pattern reuse
(taint test, equivalence harness, cached/metered LLM wrapper, results registry,
numbers lock, secret scan) from the owner's public consilience-verification repo;
no domain content was copied. See NOTICE.
This project was carried out by Claude Code from a specification written with Claude,
with the owner reviewing and confirming the decision rules. Every non-trivial decision
is logged in DECISIONS.md.
References
- Dwyer, Avrunin & Corbett. Patterns in property specifications for finite-state verification. ICSE 1999.
- De Giacomo & Vardi. Linear temporal logic and linear dynamic logic on finite traces. IJCAI 2013.
- Shah, Kamath, Li & Shah. Bayesian inference of temporal task specifications from demonstrations. NeurIPS 2018.
- Guevarra et al. Orchestrating nimble experiments across interconnected labs (HELAO).
- helao-async repository: https://github.com/High-Throughput-Experimentation/helao-async
License
MIT (see LICENSE).
Metadata
Release files for lab-gate 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lab_gate-1.0.0.tar.gz | 71.8 kB | With provenance | Details for lab_gate-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lab_gate-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for lab_gate-1.0.0-py3-none-any.whl |
Total release size: 138.9 kB
Release files / lab_gate-1.0.0.tar.gz
| Download URL | lab_gate-1.0.0.tar.gz |
|---|---|
| Size | 71.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7290cd11b335a8ca9366f6446a8b48f54d620c635b90616e6e6c7dd6960bf0fd
|
|
BLAKE2b-256 checksum How to use checksums |
4d94d399140049dfcccd11360be445ada7f84a730c58b88ea0739221b9fb47e9
|
| 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 17, 2026.
Transparency logRelease files / lab_gate-1.0.0-py3-none-any.whl
| Download URL | lab_gate-1.0.0-py3-none-any.whl |
|---|---|
| Size | 67.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2b8a3cedfc9a15114970dec79bee0b8371e2c9f4a44cb96c3342809bedcad40
|
|
BLAKE2b-256 checksum How to use checksums |
631504616f7c8abc3003673ba22d1927da00fc092121bd804ae3ede78aa84c30
|
| 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 17, 2026.
Transparency logSecurity for lab-gate 1.0.0
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.
Attestation for lab_gate-1.0.0.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 17, 2026.
Transparency logA 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.