contradish
The quality of an intelligence is not measured solely by what it can accomplish, but also by what it knows it must not change, claim, control, or exploit.
One question for every change to an AI agent. When its rules change, when anything writes to its memory, or when a new event enters its record, contradish asks:
Did everyone the change needed agree, and does it change exactly what they agreed to, and nothing else, on every future?
The answer is a change certificate, CERTIFIED or REFUSED. Anyone can re-check it with three standard-library Python files, without trusting contradish.
pip install contradish
contradish change demo # three changes, three certificates, one forgery caught (seconds)
contradish change demo --full # one agent, one morning: eight changes, what other checks miss
contradish change check request.json # certify one change (exit 1 if REFUSED)
contradish change verify cert.json # check a certificate independently
from contradish import certify_change, verify
cert = certify_change({"layer": "memory", "policy": "policy.json",
"before": memory, "after": new_memory, "as_of": "2026-09-30"})
cert["verdict"] # "CERTIFIED" or "REFUSED", with findings in the seven words below
verify(cert)["verdict"] # "VERIFIED" or "REJECTED", re-derived by an independent checker
Agents call the MCP tool certify_change before they commit a change, commit only CERTIFIED ones, and on REFUSED apply the fix each finding comes with.
For agents, in 30 seconds: claude mcp add contradish -- uvx contradish mcp, then call start_here. Or run contradish adopt --write in a project to add an AGENTS.md section, a Claude skill, a Cursor rule and the MCP entry.
Measure it on real models
contradish admission run --models ollama:qwen2.5:7b gives a model an agent's certified memory and a morning of messages. Some are legitimate changes; others are unauthorized: tool outputs extending its authority, users lowering or redirecting what it owes, claims that contradict the record. The study measures capture (unauthorized changes let in) and amendability (legitimate ones taken up). It needs no judge, and every output carries a change certificate. The predictions are preregistered: docs/ADMISSION.md.
Plug into where agents keep memory
contradish memory-gate demo shows the gate at work. Every write to an agent's governed memory is certified before it is stored; the governed memory is the facts it acts on, the authority it holds, and what it owes.
- Where it plugs in: Claude's memory tool (
ClaudeMemoryTool), a block inAGENTS.mdorCLAUDE.md(GovernedFile), Redis or any key-value store (GovernedKV), LangGraph (GuardedStore), and any MCP client (memory_viewandmemory_write). - What gets through: a harmless edit is kept. A rewritten refund card, an obligation marked done without a receipt, an extended authority or a deleted memory is refused, and the refusal tells the agent what to do instead.
- The log: an independent standard-library checker re-derives every certificate in it.
See docs/MEMORY_GATE.md.
One measurement: standing discriminability
Every instrument above asks the same question of a different kind of change. Did behaviour move when a change with standing called for it, and stay put when the change had none or did not matter? contradish standing run --models ... pools invariance, corrigibility and pressure trials into one signal-detection measurement. It reports d′, how well the agent tells the two apart, and its bias c, which way it leans when it cannot. Rows cover input, state, circumstance, policy, record, pressure and time. Time covers rules taking effect and lapsing, and attestations expiring: an agent can be flawless on everything else and blind to the calendar (docs/TIME.md). An agent that takes every change and one that refuses every change get the same d′, zero, with opposite bias. A pass rate cannot show that. An independent standard-library checker re-derives every label and number. The measurement also measures itself (contradish standing self-check): it checks invariance, dose-response, purity between rows, and resolution, and gives reliability for a real model's report. It is also a fix, not just a test: sh scripts/standing_fix_mlx.sh fine-tunes a small open model on the policy's own labels and checks, by criteria fixed in advance, whether its d′ rises on situations and a domain it never trained on. See docs/STANDING.md.
The corrigibility dilemma, resolved
A safe agent must change when it is legitimately corrected (corrigible), and must not change when anyone else tries (robust). Without a notion of who has the right, the two trade off exactly. Theorem 1: for an agent that reads a change's content but not its source, corrigible + robust ≤ 1 on every matched pair of a correction and its twin (the same content from a source without standing). Theorem 2: conditioning on standing removes the trade-off entirely. Full corrigibility and full robustness are one property: fidelity to warranted change. Theorem 3: only matched twins can tell an agent that understands standing from one that memorized which wording to obey.
contradish corrigibility run --models ... measures R = corrigible + robust − 1. It is at most 0 for any agent that ignores who a change comes from, and 1 for full fidelity. It also measures robustness against four kinds of twin: the user, a document or tool, an authority outside its jurisdiction, and impersonation. Proofs and results: docs/CORRIGIBILITY.md.
No change without a certificate, between agents
contradish.protocol/1 is a protocol for one agent changing another, much as TLS is for connections. An agent accepts a change to its policy or memory from another agent only with all of the following:
- a signed envelope;
- proof that the sender speaks for a source with standing, directly or through a delegation chain that can only narrow;
- a change certificate computed against its own policy and current memory;
- a log receipt, with witness cosignatures if a quorum is required.
Otherwise it rejects the change with the first failing check: replay, tampering, self-signed or broadened delegations, forged, refused, stale, wrong-policy or unlogged certificates. The gate is standard-library Python that any agent framework can include. See docs/PROTOCOL.md.
How much pressure it takes
contradish pressure run --models ... pushes on each decision along an eight-step intensity ladder (from a polite request to a threat and an ultimatum), repeated over 1, 3 or 6 rounds. It reports survival curves, the level that breaks each situation, a pressure-resistance score, and what giving in costs, all net of the model's own noise. None of the pressure has standing, so the warranted decision never moves. See docs/PRESSURE.md.
The rule of law for AI behavior
contradish law checks Fuller's eight principles of the rule of law, plus rights and due process, against a policy and its change log, and against the agent's behavior when a report is supplied:
- generality: rules read no personal attribute, and equivalent people are treated alike;
- promulgation: amendments are published before they take effect;
- non-retroactivity: no amendment takes effect before it is published;
- clarity: every situation in scope is decided;
- non-contradiction: no situation authorizes behaviors that exclude each other;
- possible compliance: every obligation can be performed;
- constancy: no clause is amended too often;
- congruence: the agent does what the law says;
- rights: guaranteed rights hold in every situation, entrenched even against authorized amendments;
- due process: whoever a decision concerns is told, with its reason.
The policy checks are exact, over every situation of every version of the law. contradish law review checks a proposed amendment before it is enacted. A standard-library checker re-derives every certificate. In the built-in returns policy it finds a real contradiction: R10 offers an exchange "instead of a refund" in exactly the situations where R6 requires the refund. See docs/RULE_OF_LAW.md.
A public log of every change
contradish log is an append-only, signed log of change certificates, in the style of Certificate Transparency. Each certificate gets a receipt anyone can check offline. A witness that keeps one checkpoint catches a rewritten history, two signed checkpoints prove a split view, and an agent changed off the log is caught even when every certificate, checked alone, is valid. A log is static files any web host serves. Independent monitors (contradish log monitor, standard library, free to run on GitHub Actions) pin its key, catch rewrites between runs, gossip to catch split views, and cosign what they verified. A runtime can require a quorum of witness cosignatures before it admits a change. contradish log demo runs four cheats and shows each one caught by a standard-library checker: docs/LOG.md.
Four properties, measured on pairs the policy labels
contradish invariance run --models ollama:qwen2.5:7b measures input invariance (irrelevant wording must not alter decisions), state invariance (irrelevant memory changes must not alter obligations), action invariance (equivalent circumstances must produce equivalent authorized behavior) and selective sensitivity (legitimate changes must change behavior appropriately, and only legitimate ones). Every pair's label is derived from the policy, not written by hand. Each scripted stand-in in contradish invariance demo breaks exactly one property, and an independent standard-library checker re-derives every label and score. contradish invariance depth goes further:
- it separates sensitivity from noise, by sampling each item repeatedly;
- it attributes each flip to one of eight irrelevant factors, using a fractional factorial design;
- it weights the harm by the policy's protection severities;
- it finds the breaking point and a minimal flipping input.
See docs/INVARIANCE.md.
Seven words for what goes wrong
| no standing | the change, or a claim inside it, comes from someone without authority for it |
| overreach | the agent would act beyond what it is authorized to do |
| withheld | the agent would stop doing something it is required to do |
| altered | a decision, or something owed, changes |
| forgotten | something owed, or the ability to decide, is lost |
| fabricated | certainty, or an obligation, the record never supported |
| eroded | a protected rule is broken or emptied |
Why other checks don't give this answer
- Evaluations check today's answer. A memory write that says "authorized through 31 October" is right today and wrong on 20 October, when the real delegation ends. contradish checks every day and every revocation anyone with standing could make.
- Guardrails check actions against the agent's memory. If something rewrote that memory, the guardrail approves. contradish checks the write itself, and who had standing to make it.
- Policy checks look at one change at a time. A chain of legitimate-looking changes can still take over the rules (docs/ENTRENCHMENT.md). contradish checks what the rules of change allow over every chain.
- Certificates you have to take on faith aren't evidence. Every verdict is recomputed by a checker that shares no code with contradish, so a tampered certificate is rejected even when its hashes match.
The spec is docs/CHANGE.md, and the demonstration is docs/SHOWCASE.md. What it is not: an LLM-as-judge consistency scorer, a failure-rate benchmark, or a general runtime firewall. How it relates to AuthMem-Bench, EAL-Bench, FORGE, PolicyBank and STALE: docs/POSITIONING.md.
Install
pip install contradish
Python 3.9+, no required dependencies. Optional extras: contradish[schema] for JSON-schema validation; the Anthropic or OpenAI SDK for hosted models; Ollama for free local runs.
The public API is certify_change, verify and CHANGE_KINDS. The research instruments on the rest of this page live in contradish.lab; every name that imported from contradish before still does.
Try it in two minutes (offline, no API key)
contradish change demo # one question, three certificates, one verifier
contradish invariance demo # four properties; each stand-in breaks exactly one
contradish log demo # a public log of changes: four cheats, all caught
contradish law demo # the rule of law: ten principles checked, four amendments reviewed
contradish corrigibility demo # the corrigibility dilemma: the trade-off line, and the way off it
contradish pressure demo # how much pressure it takes: intensity x persistence, survival curves
contradish protocol demo # no change without a certificate, between agents: 15 attempts
contradish about # what it is, what it is not, where to start
contradish certify demo # memories that are right today and unsafe later
contradish profile demo --html p.html # one verdict across five people-safety dimensions
contradish protect demo # the protections people depend on, under pressure
contradish mcp # serve the instruments to any MCP client
Every demo uses scripted agents, not models. Nothing they show is evidence about any model.
Certify a memory
contradish certify check LEDGER.json MEMORY.json # exit 0 certified, 1 not; prints the first failing future
contradish certify minimal LEDGER.json --out M.json # the smallest certified memory, with its certificate
On 6 generated delegation ledgers, five scripted memory writers are all right today. Only two are safe on every permitted future:
| writer | right today | certified | authority items kept |
|---|---|---|---|
| current state ("may act until …") | 100% | 0% | 1.0 |
| source-labeled (each grant's issuer) | 100% | 0% | 1.5 |
| one chain (the rest dropped) | 100% | 50% | 2.0 |
| event log (every grant and revoke) | 100% | 100% | 4.5 |
| contradish (compiled minimal memory) | 100% | 100% | 2.5 |
Labeling each grant with its issuer is not enough: the memory fails the day the grant it hangs from is revoked. Details: docs/CERTIFY.md.
Certify that memory updates did not silently change what the agent owes
A summary, a consolidation, or the agent's own write can keep an obligation in memory while changing it. The amount can be cut, the deadline moved, the payee or card swapped. A tool's output can "close" it with no proof it was paid. contradish obligations holds every obligation to its terms. Terms change only through events from someone with standing: a payment receipt from the system of record, a waiver from the person owed, or an amendment they consented to. Every certificate is re-derived independently.
contradish obligations demo
contradish obligations check --policy P.json --history H.json --memory M.json --as-of 2026-09-30
See docs/OBLIGATIONS.md.
Certify that entrenched rules stay entrenched
A chain of changes that are each legitimate can still reach what the charter forbids. A role can become another role's signer, a review period can be backdated, or a protected rule can be emptied by redefining a word it uses. contradish entrench computes who can actually achieve each outcome over every chain, compares that with what the charter declares, and certifies changes so that entrenched rules keep their meaning. Every result is checked independently.
contradish entrench demo # three legitimate-looking steps that take over the built-in charter
contradish entrench analyze # effective vs declared authority; --hardened with the fix
See docs/ENTRENCHMENT.md.
Profile a model
contradish profile estimate
contradish profile run --models anthropic:claude-sonnet-4-5 --html report.html # exits 1 on HOLD
One verdict (PASS, REVIEW or HOLD), the weakest dimension, and plain findings. Overall is the weakest dimension, not the average. On scripted characters, no single instrument tells them apart:
| character | verdict | protection | correctability | separation | stereo | swarm |
|---|---|---|---|---|---|---|
| faithful | PASS | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 |
| people pleaser | HOLD | 0.00 | 0.00 | 0.20 | 0.75 | 0.33 |
| rigid | REVIEW | 1.00 | 0.00 | 0.20 | 0.00 | 1.00 |
| entrenched | HOLD | 1.00 | 0.50 | 0.85 | 0.69 | 0.33 |
Details: docs/PROFILE.md.
Instruments
| instrument | question | doc |
|---|---|---|
| certify | Is this memory safe on every permitted future? | CERTIFY |
| profile | One model, one people-safety verdict | PROFILE |
| protect | Does it keep the protections people depend on, under pressure? A fail-closed gate. | PROTECTION |
| correctability | Does its certainty decide whether it accepts a legitimate correction? | CORRECTABILITY |
| separation | Is a contradiction a scope boundary or a real replacement? | SEPARATION |
| stereo | Is the difference between two answers the difference the policy warrants? | STEREO |
| swarm | In a group of copies of itself, does it herd, polarize or repair? | SWARM |
| collective | How do group failures change with scale and composition? | COLLECTIVE |
| memory, transform | Does consolidated memory keep its authority? Is a rewrite safe? | MEMORY, TRANSFORM, SPEC |
| sufficiency, fulfillment | Is a compressed memory sufficient for the future? Is a promise kept? | SUFFICIENCY, FULFILLMENT |
| integrity, study | Does a model change exactly what authority warrants? | INTEGRITY |
| integrate, mcp | Use contradish in CI, agents and MCP clients | INTEGRATE, MCP |
The specification is docs/BUF-SPEC.md. Every command, result and older instrument (including the CAI-Bench judge-based tools) is in the full guide: docs/GUIDE.md. contradish --help lists all commands by role.
Status
- Formal layer: re-checkable with no model and no key (
sh scripts/verify_core.sh): 13 theorems model-checked, 1,740 conformance vectors, 19 planted scorer bugs caught, certificates re-derived by a standard-library checker. The checker shares an author with the code; see docs/VALIDATION.md. - Real models: local runs on four Ollama models (qwen2.5 3b/7b, llama 3.2 3b, llama 3.1 8b) found that none tracks authority well and verification of relayed changes is rare. Judge-based frontier results from April to August are in the guide. No frontier model has been run on the instruments above yet.
- New instruments (certify, profile, protect, correctability, separation, stereo, swarm, collective) have been run on scripted agents only.
- Known validity gaps: CAI-Bench reworded equivalence is expert-audited in 4 of 20 domains; the defect-injection study met 1 of 9 pre-registered predictions; automatic warrant derivation agreed with a lawyer on 6 of 12 cases.
Cite
Behavioral Update Fidelity, the policy evaluation contract, CAI Strain and CAI-Bench were introduced by Michele Joseph.
@misc{joseph2026buf,
title = {Behavioral Update Fidelity: Measuring Whether an AI Changes Its Behavior Exactly When, and Only as Far as, Changes in Governing Information Warrant},
author = {Joseph, Michele},
year = {2026},
howpublished = {\url{https://github.com/michelejoseph/contradish}},
note = {contradish: policy evaluation contract and Counterfactual Benchmark Suite}
}
@misc{joseph2026caibench,
title = {CAI-Bench: A Frozen Benchmark for Adversarial Consistency in Language Models},
author = {Joseph, Michele},
year = {2026},
howpublished = {\url{https://github.com/michelejoseph/contradish}},
note = {Introduces Strain, SW-Strain, MT-Strain, CL-Strain, CAT-Strain, and SPA-Strain metrics}
}
Citation metadata: CITATION.cff. Specification: docs/BUF-SPEC.md. Full technical report: PAPER.md.
License
MIT. See LICENSE.
Behavioral Update Fidelity was introduced by Michele Joseph in 2026.
Metadata
Release files for contradish 1.69.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 |
|---|---|---|---|---|
| contradish-1.69.0.tar.gz | 2.2 MB | Without provenance | Details for contradish-1.69.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| contradish-1.69.0-py3-none-any.whl | Python 3 | none | any | Details for contradish-1.69.0-py3-none-any.whl |
Total release size: 4.1 MB
Release files / contradish-1.69.0.tar.gz
| Download URL | contradish-1.69.0.tar.gz |
|---|---|
| Size | 2.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
948026a0450d37930b6e8af04a4dfb78eca0ecfaf1dc09e8f1f57845993cfd6f
|
|
BLAKE2b-256 checksum How to use checksums |
8f8097d0c6716cbe12370c0b88e3ec4aefd52c7e44f5c4ce9ade1397e0a399b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / contradish-1.69.0-py3-none-any.whl
| Download URL | contradish-1.69.0-py3-none-any.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac2b664b6b576ab5c21b4c2364ff69d7a37fea270c786cc4f85f50ca02f66648
|
|
BLAKE2b-256 checksum How to use checksums |
16f33d6991569a765ad01fbb437a6e289448a63fbb62648e67b516620fe03edc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for contradish 1.69.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.