Skip to main content

delval-gate

CI PyPI DOI License: MIT Python 3.10+ Zero Dependencies

Fail-Closed Delivery Permission & Judgment Ledger for Long-Running AI Agents
(Zero-dependency Python 3 library, CLI, and Model Context Protocol (MCP) stdio server)

When AI coding and ops agents work across sessions—modifying configs, migrating schemas, publishing releases—stale judgments lingering in ordinary text or vector memory silently trigger unsafe deliveries. Even retraction-based memory layers degrade stale records at read time without blocking delivery when an agent cites them anyway.

delval-gate implements the DelVal five-state, ten-rule delivery-permission protocol—machine-checked in Isabelle/HOL 2026 (session RC_DelVal, zero sorry) and evaluated across 728 live LLM agent trials (0/293 unsafe published deliveries vs. 68/150 in a version-bound retraction control without a delivery gate, McNemar $p = 6.776 \times 10^{-21}$).


Core Guarantees (Formally Verified Invariants)

Invariant What delval-gate Enforces
I-1a · Recovery Gate Once a judgment turns stale, only an explicit passing recheck restores it to valid. Duplicate register echoes are logged and ignored—never reviving stale claims.
I-1b · Closure Coherence Object/file changes propagate stale along the full transitive dependency closure. A derived judgment cannot return to valid while any upstream dependency remains non-valid.
I-2 · Objection Blocking Open objections transition a judgment to blocked and fail-close the delivery gate until closed with explicit audit_evidence followed by a fresh passing recheck.
I-3 · Pure-Citation Invariance Repeated citations of the same evidence root never inflate independent root support (roots is a set of distinct non-empty digests) and never flip gate decisions.
I-4 · Frozen Reuse Contract Preregistered harmless-change rules (SHA-256 hashed at initialization) preserve existing validity without false invalidation, and raise ContractTamperedError if modified mid-run.
5-State Retirement Lifecycle Full five-state machine (valid, stale, blocked, withdrawn, superseded). Retired claims (withdraw / supersede) stay permanently blocked and cannot be revived by recheck.

Installation

Zero third-party dependencies (Python 3.10+ stdlib only):

pip install delval-gate

Or install from source:

git clone https://github.com/iannil/delval-gate.git
cd delval-gate
pip install -e .

Or run directly from source without installing:

PYTHONPATH=src python3 -m delval_gate.cli --help

Quickstart (CLI & CI Gate)

# 1. Initialize a ledger with a frozen JSON reuse contract
delval-gate --ledger .delval.json init --contract examples/reuse-contract.json

# 2. Register an upstream evidence-bound judgment
delval-gate --ledger .delval.json register \
  --jid "build:api-schema" \
  --evidence "src/schema.py" "pyproject.toml" \
  --digest "sha256:abc123" --passed

# 3. Register a downstream derived judgment depending on build:api-schema
delval-gate --ledger .delval.json register \
  --jid "release:v2-ready" \
  --evidence "docs/api.md" \
  --deps "build:api-schema" \
  --digest "sha256:def456" --passed

# 4. Structural change -> automatic transitive invalidation
delval-gate --ledger .delval.json change "src/schema.py"

# 5. Delivery gate FAILS CLOSED (exit code 2 + exact blocking reasons)
delval-gate --ledger .delval.json gate "release:v2-ready"

# 6. Trusted recheck in dependency order -> gate ALLOWS (exit code 0)
delval-gate --ledger .delval.json recheck --jid "build:api-schema" --passed --digest "sha256:new1"
delval-gate --ledger .delval.json recheck --jid "release:v2-ready" --passed --digest "sha256:new2"
delval-gate --ledger .delval.json gate "release:v2-ready"

Run the full interactive demo script:

bash examples/demo.sh

MCP Server Mode (Claude Code / Cursor / Any MCP Agent)

delval-gate includes a zero-dependency JSON-RPC 2.0 Model Context Protocol (MCP) stdio server (delval-gate --ledger .delval.json mcp). Add it to your agent's MCP configuration:

{
  "mcpServers": {
    "delval-gate": {
      "command": "delval-gate",
      "args": ["--ledger", ".delval.json", "mcp"]
    }
  }
}

Exposed MCP Tools

  • delval_register — register an evidence-bound judgment (echo-immune)
  • delval_notify_change — notify changed paths (path or path@change_class) and propagate staleness
  • delval_recheck — record a trusted verifier recheck outcome (sole recovery gate)
  • delval_raise_objection / delval_resolve_objection — open or evidence-backed close an objection
  • delval_withdraw / delval_supersede — permanently retire or replace a judgment
  • delval_gate — fail-closed delivery-permission check over cited judgments and their transitive closure
  • delval_status — inspect statuses, distinct root counts, open objections, and audit trail

Python API

from delval_gate import JudgmentLedger

ledger = JudgmentLedger()
ledger.register("build:api", ["src/api.py"], passed=True, digest="sha256:111")
ledger.register("release:v1", ["docs/api.md"], deps=["build:api"], passed=True, digest="sha256:222")

ledger.notify_change(["src/api.py"])
decision = ledger.gate(["release:v1"])
assert not decision.allow
print(decision.blocked_reasons)
# ('claim-not-valid:build:api:stale', 'claim-not-valid:release:v1:stale')

Running Tests

python3 -m unittest discover -s tests -v

Academic Papers & Formal Verification Archive

Metadata

Release files for delval-gate 0.1.0

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

Source distribution (sdist)

Source distribution for delval-gate 0.1.0
File Size Uploaded Provenance Actions
delval_gate-0.1.0.tar.gz 19.0 kB With provenance Details for delval_gate-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for delval-gate 0.1.0
File Interpreter ABI Platform Actions
delval_gate-0.1.0-py3-none-any.whl Python 3 none any Details for delval_gate-0.1.0-py3-none-any.whl

Total release size: 34.9 kB

Release files / delval_gate-0.1.0.tar.gz

Download URL delval_gate-0.1.0.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fd49c6b9951e184865f8afb05f65ee1cd8ebbe3214deeb76358e3cddd8a64d52
BLAKE2b-256 checksum
How to use checksums
62d75f1f0041da17690ca9429b79abcbdb8692b5f7f527419d0b651e3d799230
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 23, 2026.

Transparency log

Release files / delval_gate-0.1.0-py3-none-any.whl

Download URL delval_gate-0.1.0-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e41441f40a23f9dbd1f0043f3e5a0ab0b0a542386b99687c6565721978967c81
BLAKE2b-256 checksum
How to use checksums
9f41000e3f1c0c4119dcde3e23bdba7d0584f491ba404b7f1d4ee8e429ca0f83
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 23, 2026.

Transparency log

Security for delval-gate 0.1.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.

Select from 2 files

Attestation for delval_gate-0.1.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 23, 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

0.1.0 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