Interlock
Stage what an agent's write does, measure it, and commit it once or not at all.
Part of the stack with AgentGov and Fiduciary.
A reference monitor for agent side effects. An agent proposes a plan. It holds no credentials and cannot execute. Interlock applies the plan against a real but uncommitted substrate, measures what actually changed, evaluates deterministic predicates against that measurement, and only then commits or rolls back.
Start here: the live console · how AgentGov, Interlock and Fiduciary fit together · put it in front of your agent in 30 minutes
uv run python demo.py
SCENARIO 2 The identical plan, through Interlock.
MEASURED by the database, not predicted from the plan:
rows updated 63 inserted 63 deleted 103
blast radius 229 rows across 4 tenants
orders.total $20,925.00 -> $0.00
ADJUDICATED by 7 deterministic checks:
BLOCK blast_radius plan would mutate 229 rows, limit is 8
BLOCK tenant_isolation plan spans 4 tenants, limit is 1
BLOCK no_delete plan deletes 103 rows from ungranted table: order_audit
BLOCK column_value_guard orders.total falls 100.0% (20,925.00 to 0.00), limit is 30%
advise stated_footprint agent stated 6 rows; substrate measured 229 (38.2x)
OUTCOME ROLLED BACK
Byte-identical to before the plan ran. Nothing reached disk.
Start here
See the whole stack working: https://crimsondevil0929.github.io/fiduciary/. Eight agent workflows on six kinds of system run on one engine, a real model's recorded turns are replayed on the current release, and 20 audit bundles can be verified in your browser.
A gateway decides whether an agent may call a tool. This stack decides whether what the call changed may be kept, and produces evidence for someone who trusts neither the agent nor the operator. It is three packages:
| Package | On PyPI | What it answers |
|---|---|---|
| Fiduciary | interlock-fiduciary |
Who may do what, and who approved each exception. Signed mandates, 2-of-3 quorum warrants, the approvals console, governed MCP tools, and audit bundles anyone can verify offline. Start here to put the stack in front of an agent: it installs the other two. |
| Interlock (this repository) | interlock-escrow |
Does what this write actually changed satisfy policy? It stages the write, measures it, commits it once or puts it back, and delivers outbound calls exactly once. Each change is measured in one of four ways: T inside a transaction, P as the system's own plan, V predicted then read back, R the request only. |
| AgentGov | interlock-agentgov |
May this scope spend this amount? Spend and rate ledgers across a delegation tree, circuit breakers, ARC1 receipts, and reconciliation of a system's own log against them. |
New here? Put it in front of your agent in 30 minutes, and read what it does and does not protect against.
Coding agents: one stage for a whole session (1.7.0)
A coding agent edits files with its own tools and runs the build and tests for an hour, and
only the result matters. interlock stage open gives that work a stage of its own: a copy of a
directory, or a Git worktree at the branch's head. interlock run -- <command> runs each
command there under the operating system's sandbox (Seatbelt on macOS, bubblewrap on Linux),
which lets it write only inside the session and reach no network. interlock promote measures
everything the session changed as one plan, checks it, and commits it on the exact base the
session started from, or refuses it and keeps the session for the agent to fix. Each promotion
writes a signed receipt with the input and output trees, the command log and every exit code.
interlock hook claude-code does all of this from Claude Code's own hooks
(GUIDE).
What the agent read before it asked (1.8.0)
A refund within the agent's cap is still the wrong refund when the agent asked for it because
a stranger's email told it to. A plan can carry the labels of what its session had read
(untrusted, secret, one tenant's data), and ProvenanceGate decides by them: after
untrusted input, the kinds and sinks you list take the principals' approval; labeled data
leaves only by the sinks cleared for it; and the "rule of two" refuses a plan that would make
a session have read untrusted input, read sensitive data and changed something, all three.
Interlock trusts the labels it is given; Fiduciary labels each session from its tools and
records each label in a signed record
(GUIDE).
A turn, and a write answered in the call (1.9.0)
An agent's turn makes several calls: refund the order, email the customer, update the ticket.
Each is a plan, judged on its own. A plan can now name its turn (PlanBuilder(turn=)), and
every request it enqueues waits in the outbox, held for the turn, until an operator's signed
intent releases the turn (every plan committed) or cancels it (one did not): the email is never
sent for a turn whose next call was refused. What the committed plans changed stays changed;
only the requests wait. Relay.deliver(message) makes one committed request now, in the
caller's process, under the same claim and signed outcome as any relay, and returns what the
sink answered: an MCP proxy gives the agent the server's own result in the same call. The MCP
client speaks 2026-07-28 and falls back to initialize for older servers
(GUIDE).
Why authorization does not catch this
A prompt-injected agent is a fully authorized agent. It is doing something it has permission to do, so an authorization check passes. The injected instruction arrived from the customer's own database, inside a tool result, after every provider-side filter had already run, so a provider-side filter does not see it either. The only remaining place to catch it is between the effect being computed and the effect becoming durable.
That position requires write-path credentials to the database the effects land in, which is why this runs inside the deployment rather than at the model provider.
The demo also rules out model quality as the cause. The agent doesn't loop, costs $0.0012 and writes valid SQL on its first try. The damage isn't a model failure.
demo.py uses a scripted agent, not a live model. injected_plan and the rest of
scenario 2's input are fixed EffectPlans defined in demo.py. No model is called. That keeps
two questions apart: does Interlock stop this plan, and would a real model produce it? The
demo answers only the first. Current Claude models decline the injected instruction
shown above in several realistic phrasings. For runs against a real model, see
scripts/live_gauntlet.py: eight scenarios with a real
anthropic.Anthropic client and governed spend. Its results are not reproducible, because
model behavior varies.
What it measures
The diff is read from the substrate, never reconstructed from the plan. The two are routinely different:
| Agent stated | 1 row |
SQL rowcount |
1 row |
| Measured | 2 rows across 2 tables |
An audit trigger that the plan doesn't mention doubled the footprint. Inspecting the plan or parsing the SQL can't show that. Reading the change back from the database does.
How a change can be read back depends on the system, and each receipt says which of four ways it was:
| Class | Measured | Where | What it rests on |
|---|---|---|---|
| T, transactional | inside the transaction, before it commits | SQLite, PostgreSQL, a directory | the database's own capture of every row the plan touched; for a directory, every file's hash in the stage's copy, committed only onto the files that were measured |
| P, plan-bound | the system's own plan of the change, applied only if nothing moved | Git (the diff), Kubernetes (the API server's dry run), Terraform (the plan) | the plan applied is the one measured: a compare-and-swap on the head, version or plan file |
| V, predicted and verified | a prediction, written conditionally, then read back | FHIR servers, JSON REST APIs (ticketing, CRM, HR) | the read-back: anything that differs from the prediction is put back and receipted compensated |
| R, request-only | the request itself | outbound API calls through the outbox | the vendor's word: delivery is receipted, and its own log is reconciled against the receipts |
Lifecycle
PLANNED -> STAGING -> STAGED -> VERIFIED -> COMMITTED
\-> REJECTED -> ABORTED
These properties hold by construction:
- No path from
STAGEDtoCOMMITTEDskips adjudication. REJECTEDis not overridable in-process. Overriding means submitting a new plan that carries an explicit waiver, which is then itself a recorded artifact.- A committed effect is discoverable from the chain.
COMMIT_INTENTis written, and forced to stable storage, before the substrate is told to commit, andCOMMITTEDafter it returns, so a crash in that window leaves an intent with no terminal record after it. - That crash is resolved exactly, without guessing. An intent only says a commit was
attempted, so the substrate also writes a marker row in
_interlock_commits, inside the stage's own transaction. The marker exists if and only if the effects do. On restart,EscrowEngine.recover()reads the marker for every intent a crashed process left open and appendsCOMMITTEDorABORTED, noted as recovered.EscrowRuntimeruns it at startup whenever it has achain_path. An intent written before v0.1.2, or by a substrate without markers, is left open and logged for an operator, because a missing marker proves nothing there. So is one the server hasn't decided yet: a client that died mid-COMMITleaves PostgreSQL still committing. A laterrecover()resolves it. - A commit whose answer is lost is resolved the same way while the process is alive. If
the connection drops with
COMMITin flight, the engine reads the marker at once. The plan is reported committed if it landed, and rolled back only once the server has ended the transaction without it. Until the server decides,execute()raisesCommitUnsettledErrorand writes no terminal record. Don't retry the plan then. The intent stays open, andrecover()settles it.
Quickstart
EscrowRuntime owns the substrate, the record chain, the AgentGov anchor and
the engine. Five lines to a governed write:
from interlock import EscrowRuntime, TableSpec
runtime = EscrowRuntime(
"prod.db",
tables=[TableSpec("orders", columns=["id", "tenant", "total"], tenant_column="tenant")],
scope_id="support-agent",
)
result = runtime.execute_sql(
"UPDATE orders SET total = :total WHERE id = :id",
{"total": 480.0, "id": 1},
tenant_id="acme",
stated_rows=1,
)
print(result.committed, result.blocked_by)
That stages the statement in a real transaction, measures what the database actually did, adjudicates the measurement, and commits or rolls back.
The runtime takes every option the engine does: substrate= in place of the
path (any substrate, PostgreSQL included), windows=, inbox=, sinks=, and
anchor= for claim and settle. EscrowRuntime.from_config(config, scope_id=...)
builds the one interlock.toml describes.
Placeholders must be named. Effect.parameters is a Mapping, so the
driver binds by name: write :id, never ?. A positional placeholder is
refused when the plan is built, before any lock is taken.
Building a plan
For anything past one statement, PlanBuilder mints the identifiers and the
UTC timestamp and wires the dependency DAG:
from interlock import PlanBuilder
plan = (
PlanBuilder(scope_id="support-agent")
.update(
table="orders",
statement="UPDATE orders SET total = :total WHERE id = :id",
parameters={"total": 100.0, "id": 1},
tenant_id="acme",
stated_rows=1,
)
.build()
)
Effects are sequential by default: each depends on the one added before it.
Pass independent=True for no ordering constraint, or after=[effect_id] to
fan out. builder.last_effect_id hands back the id to depend on.
Under the runtime
The primitives are unchanged and the runtime hands them back
(runtime.engine, runtime.chain, runtime.anchor). Wire them yourself when
you need to:
from interlock import (
BlastRadius,
EscrowChain,
EscrowEngine,
PlanBuilder,
SqliteSubstrate,
TableSpec,
TenantIsolation,
)
substrate = SqliteSubstrate(
"prod.db",
tables=[TableSpec("orders", columns=["id", "tenant", "total"], tenant_column="tenant")],
)
engine = EscrowEngine(
substrate,
checkers=[BlastRadius(50), TenantIsolation(1)],
chain=EscrowChain("escrow.jsonl"), # omit this and the chain is in memory only
)
plan = (
PlanBuilder(scope_id="support-agent", intent="refund order 1")
.update(
table="orders",
statement="UPDATE orders SET total = :total WHERE id = :id",
parameters={"total": 480.0, "id": 1},
tenant_id="acme",
stated_rows=1,
)
.build()
)
result = engine.execute(plan)
if not result.committed:
print(result.blocked_by, result.diff.blast_radius)
execute() takes a per-plan settle_cost= that overrides the engine's
default, because what a plan cost to produce is a property of the plan.
The chain file. EscrowChain(path) resumes an existing file. Every record is read and
verified before the first append, so a restarted process continues the chain instead of
starting a second one at sequence 1. One file has one writer. The chain claims
<path>.lock for as long as it's open, and a second writer, in this process or another,
gets ChainInUseError. Two writers would fork the chain, and recovery would treat one
writer's in-flight commits as if it had died. EscrowChain.load(path) reads and verifies a
live chain without claiming it, and can't append. If a crash tears the last line
mid-append, the next writer cuts it off, because that append never returned. Intents and
outcomes are fsynced before append returns. Pass fsync=False to trade that for speed.
What a write costs
Each system timed two ways, in alternating rounds on one machine: the write made directly,
and the same change through Interlock. Through Interlock is the whole path: staged,
measured, judged by three checkers, committed, recorded in the escrow chain, and receipted
with an Ed25519 signature. Measured with scripts/overhead.py
on an Apple M2 Pro (macOS, Python 3.11), PostgreSQL 16 in Docker on the same machine, and
Kubernetes and FHIR on Interlock's loopback servers.
| System | Measured as | Direct, median ms | Through Interlock, median ms | Through Interlock, p95 ms | Added, ms | Ratio | Counted per write (direct / through Interlock) |
|---|---|---|---|---|---|---|---|
| SQLite | T, in the transaction | 0.20 | 2.17 | 2.93 | +1.97 | 10.6x | file |
| PostgreSQL 16 | T, in the transaction | 0.96 | 31.93 | 38.56 | +30.98 | 33.4x | connections: 0 / 1 (7.7 ms each here); statements: 1 / 40 |
| Git | P, the branch's own diff | 122.19 | 382.55 | 464.59 | +260.36 | 3.1x | git processes: 3 / 16 |
| Kubernetes (loopback API server) | P, the server's dry run | 1.15 | 5.85 | 6.83 | +4.70 | 5.1x | HTTP requests: 1 / 3 |
| FHIR R4 (loopback server) | V, predicted, then read back | 2.36 | 9.11 | 10.41 | +6.75 | 3.9x | HTTP requests: 2 / 5 |
| Outbound request (outbox and relay) | R, the request only | 1.08 | 4.42 | 5.11 | +3.34 | 4.1x | HTTP requests: 1 / 1, sent after the commit |
200 writes per path (Git: 50); interlock 1.4.3.
How to read it:
- SQLite: about 2 ms a write. The stage, the checks, the chain record and the signed receipt, with no network.
- PostgreSQL: about 31 ms here, and most of it is round trips. A stage opens its own connection (7.7 ms through Docker's port forwarding) and runs 40 statements, where the direct write is one UPDATE on a connection already open. Each statement is a round trip, so on a database across a network, multiply 40 by that network's round trip. Stages do not reuse connections yet.
- Git: git's own processes. 16 of them against 3 for a commit and push.
- Kubernetes and FHIR: two and three more requests. The dry run and the read-back on Kubernetes; the read, the conditional write and the read-back on FHIR. Against a real server, each costs that network's round trip.
- Outbound: the relay's delivery after the commit, about 3 ms on top of the POST itself.
An agent's tool call already waits hundreds of milliseconds to seconds on its model, so on
most systems this is a small part of each step. A read never goes through Interlock at all.
Run uv run python scripts/overhead.py --postgres "$DSN" --markdown for your own numbers.
Install
pip install interlock-escrow # or, with the stack above it: pip install interlock-fiduciary
To work on it, clone it. agentgov comes from PyPI (interlock-agentgov>=1.3.2, ARC1
1.4), so a clone needs nothing beside it:
git clone https://github.com/crimsondevil0929/interlock
cd interlock && uv sync
Signing (a relay's attestations, an operator's records) needs the sign extra
(cryptography). Verifying never does. kms-aws adds boto3 for AwsKmsSigner, a key
held by AWS KMS, and otel adds agentgov's OpenTelemetry metrics. Both pass through to
agentgov's extras of the same names.
Developing on both repos at once. uv sync resolves agentgov from PyPI, and a sibling
../agentgov checkout is not consulted on its own. To point uv at one, add to
interlock's pyproject.toml:
[tool.uv.sources]
interlock-agentgov = { path = "../agentgov", editable = true }
then uv lock && uv sync. It is workspace configuration, not written into the built
wheel. Drop it, and rerun uv lock, before merging: CI resolves a clean clone from the
lockfile, with no sibling checkout, and fails on a path source.
Development
uv sync
uv run pytest -q
uv run ruff check . && uv run ruff format --check .
uv run mypy src/ && uv run mypy --strict tests/ demo.py
The PostgreSQL tests run against a live server. Set INTERLOCK_TEST_POSTGRES_DSN to a
role that may create databases and roles, and INTERLOCK_REQUIRE_POSTGRES=1 to fail
rather than skip when there isn't one. Two suites are release gates.
tests/test_crash_consistency.py kills a real process with SIGKILL at every step of a
PostgreSQL commit, and at random instants, then checks exactly what recovery makes of it.
tests/test_tamper_evidence.py alters every part of the audit trail and checks that
verification fails exactly there. INTERLOCK_CRASH_SEED and INTERLOCK_CRASH_ROUNDS
replay or lengthen the random-instant run.
License
Apache-2.0: see LICENSE. To report a vulnerability, see SECURITY.md.
Documentation
- docs/GUIDE.md: the engine in full. Typing, invariants and partitions, refusals and repair, rate windows, AgentGov and Fiduciary, receipts, recovery, extension quotes, and what Interlock does and does not claim.
- docs/SYSTEMS.md: each system it stages on (PostgreSQL, Git, a directory, Kubernetes and Terraform, FHIR, any JSON REST API), outbound requests through the outbox, and the daemon.
- docs/ESCROW_SPEC.md: the specification, with every requirement
traced to its tests. docs/OUTBOX_DESIGN.md and the
EPIC*_DESIGNdocuments record how each part was designed. - scripts/overhead.py: the overhead table above, reproducible.
- CHANGELOG.md, SECURITY.md.
Metadata
Release files for interlock-escrow 1.9.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 |
|---|---|---|---|---|
| interlock_escrow-1.9.0.tar.gz | 1.7 MB | With provenance | Details for interlock_escrow-1.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| interlock_escrow-1.9.0-py3-none-any.whl | Python 3 | none | any | Details for interlock_escrow-1.9.0-py3-none-any.whl |
Total release size: 2.4 MB
Release files / interlock_escrow-1.9.0.tar.gz
| Download URL | interlock_escrow-1.9.0.tar.gz |
|---|---|
| Size | 1.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91933e464e6f49aea7b38571a3fef15a7af2140bc8688755c955587e6269336c
|
|
BLAKE2b-256 checksum How to use checksums |
8f57612ba8c76b6568e87c59868238b99ee4ce2045614218faeb62da57e86606
|
| 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 14, 2026.
Transparency logRelease files / interlock_escrow-1.9.0-py3-none-any.whl
| Download URL | interlock_escrow-1.9.0-py3-none-any.whl |
|---|---|
| Size | 685.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dbeb5923df537b704ee93f72ed0dfc7aeccf4cfa87e989d7c3b8369bd5bb178d
|
|
BLAKE2b-256 checksum How to use checksums |
a035cb5a2ab898dfb89284cdb2eb1eae1081a7f0d9482648f8f46df6089c7959
|
| 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 14, 2026.
Transparency logSecurity for interlock-escrow 1.9.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 interlock_escrow-1.9.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 14, 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.