Skip to main content
Glama

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.


Related MCP server: shield-kya

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides permission gates and tamper-evident audit logging for AI agent tool executions, with declarative policies, consent ladders, and hash-chained verification.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      A local gate that lets agents submit risky tool actions for policy evaluation and receive ALLOW, DENY, or REQUIRE_APPROVE decisions before executing irreversible side effects. It can also open human approval holds and record an activity trail without executing the side effect itself.
      1,427 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Gives AI coding agents a local, mechanical workflow authority: an agent's issue claim is recorded, every subsequent write and irreversible step (push, merge, tag, release) is re-verified against that record, and review verdicts are bound to exact commit bytes so a later push invalidates them. Refusals report what was read and what to do next, keeping an unreadable tracker distinct from a forbidden action.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to route every action through a pre-execution gate that returns allow, escalate-to-human, or deny verdicts, backed by deterministic hard-rule blocks plus probabilistic gray-zone scoring, and to run a resumable orchestration loop covering routing, quality gates, stop-loss, acceptance, and escalation. Every decision, arbitration between conflicting agents, and human approval is written to an append-only hash-chained, Ed25519-signed ledger that can be postmortemed, calibrated, alert-scanned, and exported as offline verification bundles or OTel spans.
      1
      MIT