interplane.Get Omega
Read in your language

aien-protocols-mv

Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem

Brought by drakestapleton

GitHub aien-dev/aien-protocols-mv#53 (code only)

closed derived fb220ed0b925dc6e #53

Imported from GitHub aien-dev/aien-protocols-mv#53 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 361a2b58d9840d96a31de7023144b212b38605c5 · Head 2b566c83159e124349315226f282ac68b8577284

github-advanced-security[bot] commented on specs/discovery-capsule/tools/dcp_verify.c line 361 on 2026-10-24 20:53 UTC

github-advanced-security[bot] commented on specs/microjob/tools/mjb_verify.c line 495 on 2026-10-24 20:53 UTC

github-advanced-security[bot] reviewed (COMMENTED) on 2026-10-24 20:53 UTC

Fetch it

A git bundle of the pull request's head, 109346 bytes.

curl -fsSL https://interplane.io/drakestapleton/aien-protocols-mv/patches/fb220ed0b925dc6e.bundle -o fb220ed0b925dc6e.bundle
git fetch fb220ed0b925dc6e.bundle refs/pull/53/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-protocols-mv
53
2b566c83159e124349315226f282ac68b8577284
{"kind":"github-import","owner":"aien-dev","repo":"aien-protocols-mv","number":53,"url":"https://github.com/aien-dev/aien-protocols-mv/pull/53","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:46Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 844c21a..84ba626 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -36,6 +36,32 @@ VERSIONING.md.
 
 ### Specifications
 
+- `specs/microjob` and `crates/aien-microjob` (SI-MICROFORGE C1,
+  aien-protocols-mv#50): MJB1 Draft v0.1, the typed bounded microjob DAG
+  (192-byte header, 448-byte nodes, at most 64 nodes): token profiles ZERO,
+  64/16, 128/32, 256/64, 512/128 with explicit `MJB_NEEDS_EXPANSION` instead
+  of truncation, time/fuel/memory/work caps and header budgets, a required
+  verifier, retry and cancel classes, typed operand references (Cortex,
+  World, content, capsule, experience), effect ceiling bound to the original
+  approval, acyclicity and generation checks, and a canonical Kahn order.
+  MJR1 receipt (404 bytes, P-256 signed) and the `DagRun` ledger: input
+  binding, double-commit, retry, cancel and restart-by-replay rules. C
+  checker `tools/mjb_verify.c` with 104 vectors and 58 mutants, all killed;
+  the Rust crate gives the same verdict on every vector and re-encodes every
+  accepted document byte for byte.
+- `specs/discovery-capsule` and `crates/aien-discovery-capsule` (SI GENESIS
+  C2, aien-protocols-mv#51): DCP1 family Draft v0.1: `DiscoveryCapsuleV1`,
+  `OwnerConsentV1`, `OwnerRetractionV1` (no erasure claim allowed),
+  `RetractionAckV1` and `ExperienceLineageV1`. Distinct DISCOVER, READ,
+  REDISTRIBUTE and TRAIN bits, PRIVATE by default, closed license registry,
+  capsule never self-authorizes. Recipient rules: owner retraction chain
+  (replay, conflict, custodian), use checks for serving, training and
+  republication, execution admission only on the recipient's own verdict and
+  grant, honest PENDING / ACKNOWLEDGED / UNREACHABLE delivery status, and
+  lineage withdrawal with affected-descendant marking. C checker
+  `tools/dcp_verify.c` with 96 vectors and 62 mutants, all killed.
+- `crates/aien-provenance`: `p256_compressed_key`, `p256_sign_low_s` and
+  `p256_verify_low_s` for the fixed-width records above (low-S only).
 - `specs/osh-platform`: OSH Platform ABI v1 DRAFT revision 2, still not
   frozen and still `abi_version` 1 (aien-protocols-mv#43). New
   `STREAM_TASK.md` makes streams and tasks precise: platform call frame and
diff --git a/Cargo.lock b/Cargo.lock
index f86df5d..39d755c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -30,6 +30,15 @@ dependencies = [
  "uuid",
 ]
 
+[[package]]
+name = "aien-discovery-capsule"
+version = "0.1.0"
+dependencies = [
+ "aien-provenance",
+ "p256",
+ "sha2 0.10.9",
+]
+
 [[package]]
 name = "aien-evaluation-protocol"
 version = "0.1.0"
@@ -87,6 +96,15 @@ dependencies = [
  "uuid",
 ]
 
+[[package]]
+name = "aien-microjob"
+version = "0.1.0"
+dependencies = [
+ "aien-provenance",
+ "p256",
+ "sha2 0.10.9",
+]
+
 [[package]]
 name = "aien-pi-spark-task"
 version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index 0cfbcc6..2d5f31a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,8 @@ members = [
     "crates/aien-provenance",
     "crates/aien-probe",
     "crates/aien-pi-spark-task",
+    "crates/aien-microjob",
+    "crates/aien-discovery-capsule",
 ]
 
 [workspace.package]
diff --git a/README.md b/README.md
index d28ea6c..487b209 100644
--- a/README.md
+++ b/README.md
@@ -23,12 +23,14 @@ The status column quotes the `Status` line at the top of each specification on `
 | [osc-unit-artifact](specs/osc-unit-artifact/OSC_UNIT_ARTIFACT.md) | Signed container for a compiled Omega unit | v1 FROZEN, 2026-10-08 | `tools/check-vectors.sh` (see [vectors/README.md](specs/osc-unit-artifact/vectors/README.md)) |
 | [osh-platform](specs/osh-platform/OSH_PLATFORM_ABI.md) | Boundary between the Omega shell core and its platform | v1 DRAFT, not frozen | vector generator only (see [vectors/README.md](specs/osh-platform/vectors/README.md)) |
 | [pi-spark-task](specs/pi-spark-task/SPEC.md) | PST1, the task message between a Pi and the Spark | Draft v0.1, 2026-10-16; not yet produced or read by any runtime | `tools/check-vectors.sh` (C checker, 23 header vectors) and the Rust crate `aien-pi-spark-task` |
+| [microjob](specs/microjob/SPEC.md) | MJB1 typed bounded microjob DAG (token profiles 64/16 to 512/128 or zero-neural, resource caps, required verifier, retry and cancel) and the MJR1 receipt | Draft v0.1, 2026-10-24; not yet produced or read by any runtime | `tools/check-vectors.sh` (C checker, 104 document vectors, 58 mutants) and the Rust crate `aien-microjob` (vectors plus receipt-ledger tests) |
+| [discovery-capsule](specs/discovery-capsule/SPEC.md) | DCP1 family: Discovery Capsule, owner consent, signed retraction, retraction ack and experience lineage | Draft v0.1, 2026-10-24; not yet produced or read by any runtime | `tools/check-vectors.sh` (C checker, 96 record vectors, 62 mutants) and the Rust crate `aien-discovery-capsule` (vectors plus two-owner lifecycle tests) |
 
 The vector counts come from [CHANGELOG.md](CHANGELOG.md). Where a contract has an implementation, it lives with its owner, not here. On 2026-10-19 the `main` branches showed these: omega keeps pinned copies of the VC1 golden vectors and the CRB1 vectors (`tests/vcstore/golden/PIN`, `tests/crumbline/crb1/PIN`) and runs the 20 OSH vectors in `tests/osh/`; aienos has an OSC unit admission check in C (`native/kernel/artifact/osc_unit.c`) with a copy of the osc-unit-artifact vectors. This repository does not run those tests.
 
 ## Reference crates
 
-All ten crates are Apache-2.0 (from `cargo metadata`). They follow aien-architecture [ADR 0024](https://github.com/aien-dev/aien-architecture-mv/blob/main/docs/adr/0024-rust-scaffolding-omega-destination.md): Rust is scaffolding and Omega is the destination, so the specifications are the lasting part.
+All twelve crates are Apache-2.0 (from `cargo metadata`). They follow aien-architecture [ADR 0024](https://github.com/aien-dev/aien-architecture-mv/blob/main/docs/adr/0024-rust-scaffolding-omega-destination.md): Rust is scaffolding and Omega is the destination, so the specifications are the lasting part.
 
 The purpose column is shortened from the `description` field in each crate's `Cargo.toml`.
 
@@ -44,6 +46,8 @@ The purpose column is shortened from the `description` field in each crate's `Ca
 | `aien-provenance` | Digests, Merkle trees and signature checks |
 | `aien-probe` | Probe evaluation engine (see [its README](crates/aien-probe/README.md)) |
 | `aien-pi-spark-task` | Reader and writer for the PST1 header; its test reads every PST1 vector |
+| `aien-microjob` | MJB1 microjob DAG reader, writer and checker, and the MJR1 receipt ledger; its test reads every MJB1 vector |
+| `aien-discovery-capsule` | DCP1 family reader, P-256 signature checks and recipient rules (retraction chain, use checks, execution admission, lineage); its test reads every DCP1 vector |
 
 Who uses which crate is recorded in [CONSUMERS.md](CONSUMERS.md).
 
@@ -108,9 +112,11 @@ bash specs/verified-crumb/tools/check-golden.sh
 bash specs/osc-unit-artifact/tools/check-vectors.sh
 bash specs/execution-transcript/tools/check-corpus.sh
 bash specs/pi-spark-task/tools/check-vectors.sh
+bash specs/microjob/tools/check-vectors.sh
+bash specs/discovery-capsule/tools/check-vectors.sh
 ```
 
-`tests/gates/run.sh <step>` runs one gate step by name. The steps are `crumb-verify`, `fmt`, `check`, `clippy`, `test`, `zero-disk-secrets`, `anti-slop` and `c-vectors`. The `c-vectors` step runs every `specs/*/tools/check-*.sh` (the four above) and passes only when all of them pass. The `anti-slop` step fails on any em dash or en dash in `crates/`, `docs/`, `README.md` and `ANTI_ENCLOSURE.md`.
+`tests/gates/run.sh <step>` runs one gate step by name. The steps are `crumb-verify`, `fmt`, `check`, `clippy`, `test`, `zero-disk-secrets`, `anti-slop` and `c-vectors`. The `c-vectors` step runs every `specs/*/tools/check-*.sh` (the checkers above) and passes only when all of them pass. The `anti-slop` step fails on any em dash or en dash in `crates/`, `docs/`, `README.md` and `ANTI_ENCLOSURE.md`.
 
 On 2026-10-19 all of the commands above passed on the Spark on `main` at `fb5fca9`, and `crumb verify .` printed `OK: 41 crumbs current`.
 
diff --git a/crates/aien-discovery-capsule/.crumb b/crates/aien-discovery-capsule/.crumb
new file mode 100644
index 0000000..b0fdbb7
--- /dev/null
+++ b/crates/aien-discovery-capsule/.crumb
@@ -0,0 +1,6 @@
+{
+  "layer": "crates/aien-discovery-capsule",
+  "name": "crates/aien-discovery-capsule",
+  "purpose": "DCP1 family reader that must match the C checker, signature checks and recipient rules",
+  "schema_version": "1.0.0"
+}
diff --git a/crates/aien-discovery-capsule/Cargo.toml b/crates/aien-discovery-capsule/Cargo.toml
new file mode 100644
index 0000000..e22d219
--- /dev/null
+++ b/crates/aien-discovery-capsule/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "aien-discovery-capsule"
+version = "0.1.0"
+edition = "2021"
+license = "Apache-2.0"
+description = "DCP1 family: Discovery Capsule, owner consent, signed retraction, acks and experience lineage; reader, signature checks and recipient rules (specs/discovery-capsule)"
+
+[dependencies]
+aien-provenance = { path = "../aien-provenance" }
+p256 = { workspace = true }
+sha2 = { workspace = true }
diff --git a/crates/aien-discovery-capsule/src/.crumb b/crates/aien-discovery-capsule/src/.crumb
new file mode 100644
index 0000000..7d0fcda
--- /dev/null
+++ b/crates/aien-discovery-capsule/src/.crumb
@@ -0,0 +1,6 @@
+{
+  "layer": "crates/aien-discovery-capsule/src",
+  "name": "crates/aien-discovery-capsule/src",
+  "purpose": "DCP1 family decode, encode, sign, open; owner retraction chain, use checks, execution admission, retraction tracker, lineage index",
+  "schema_version": "1.0.0"
+}
diff --git a/crates/aien-discovery-capsule/src/lib.rs b/crates/aien-discovery-capsule/src/lib.rs
new file mode 100644
index 0000000..b5f136c
--- /dev/null
+++ b/crates/aien-discovery-capsule/src/lib.rs
@@ -0,0 +1,841 @@
+//! The DCP1 family: Discovery Capsule, owner consent, signed retraction,
+//! retraction acknowledgement and experience lineage.
+//!
+//! Spec: `specs/discovery-capsule/SPEC.md` (Draft v0.1, contract 0.1.0, wire
+//! version 1). The C reference checker `specs/discovery-capsule/tools/dcp_verify.c`
+//! pins the static rules (section 10); [`decode`] gives the same verdict on
+//! the same bytes (`tests/vectors.rs`). Signatures and the stateful recipient
+//! rules of section 11 live here and in [`recipient`].
+//!
+//! A capsule never authorizes itself: nothing in this crate turns a capsule
+//! into a grant. [`recipient::admit_execution`] needs the recipient's own
+//! passing verdict and the recipient's own capability grant.
+#![forbid(unsafe_code)]
+
+pub mod recipient;
+
+use aien_provenance::{p256_compressed_key, p256_sign_low_s, p256_verify_low_s};
+use p256::ecdsa::SigningKey;
+use sha2::{Digest, Sha256};
+
+/// The only wire version.
+pub const VERSION: u8 = 1;
+/// Record lengths (SPEC.md section 1).
+pub const CAPSULE_LEN: usize = 676;
+pub const CONSENT_LEN: usize = 388;
+pub const RETRACTION_LEN: usize = 284;
+pub const ACK_LEN: usize = 148;
+pub const LINEAGE_LEN: usize = 588;
+
+/// `share_scope` values.
+pub mod scope {
+    pub const PRIVATE: u8 = 0;
+    pub const NAMED: u8 = 1;
+    pub const COMMUNITY: u8 = 2;
+    pub const PUBLIC: u8 = 3;
+}
+/// `permissions` / `purposes` bits.
+pub mod perm {
+    pub const DISCOVER: u8 = 0x01;
+    pub const READ: u8 = 0x02;
+    pub const REDISTRIBUTE: u8 = 0x04;
+    pub const TRAIN: u8 = 0x08;
+    pub const ALL: u8 = 0x0F;
+}
+/// Retraction `scope` bits.
+pub mod retract {
+    pub const FUTURE_AVAILABILITY: u8 = 0x01;
+    pub const RETRIEVAL: u8 = 0x02;
+    pub const TRAINING: u8 = 0x04;
+    pub const REPUBLICATION: u8 = 0x08;
+    pub const ALL: u8 = 0x0F;
+}
+/// `required_capabilities` bits (a request, never a grant).
+pub mod cap {
+    pub const CPU_COMPUTE: u32 = 1 << 0;
+    pub const GPU_COMPUTE: u32 = 1 << 1;
+    pub const CORTEX_READ: u32 = 1 << 2;
+    pub const WORLD_READ: u32 = 1 << 3;
+    pub const WORLD_EFFECT: u32 = 1 << 4;
+    pub const NETWORK: u32 = 1 << 5;
+    pub const ALL: u32 = 0x3F;
+}
+/// `license` registry.
+pub mod license {
+    pub const APACHE_2_0: u16 = 1;
+    pub const MIT: u16 = 2;
+    pub const CC_BY_4_0: u16 = 3;
+    pub const CC_BY_SA_4_0: u16 = 4;
+    pub const CDLA_PERMISSIVE_2_0: u16 = 5;
+    pub const OWNER_CONSENT_ONLY: u16 = 6;
+}
+/// Ack `status` values.
+pub mod ack_status {
+    pub const ENFORCED: u8 = 1;
+    pub const ENFORCED_WITH_RETAINED: u8 = 2;
+}
+
+/// A refusal code from SPEC.md section 12.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Refusal {
+    BadLength,
+    BadMagic,
+    Downgrade,
+    BadVersion,
+    ReservedNonzero,
+    BadEnum,
+    UnknownLicense,
+    FalseErasureClaim,
+    MissingField,
+    BadKey,
+    BadValidity,
+    Inconsistent,
+    ScopeConflict,
+    PermissionAmplification,
+    NoConsent,
+    AncestorCycle,
+    Duplicate,
+    BadSignature,
+    OwnerMismatch,
+    Private,
+    NotRecipient,
+    Expired,
+    Stale,
+    Revoked,
+    NotPermitted,
+    Conflict,
+    UnknownCustodian,
+    SelfAuthorized,
+    Unverified,
+    CapabilityDenied,
+    CrossDataset,
+    UnknownParent,
+}
+
+impl Refusal {
+    /// The code name as written in SPEC.md and printed by the C checker.
+    pub fn name(self) -> &'static str {
+        match self {
+            Refusal::BadLength => "DCP_BAD_LENGTH",
+            Refusal::BadMagic => "DCP_BAD_MAGIC",
+            Refusal::Downgrade => "DCP_DOWNGRADE",
+            Refusal::BadVersion => "DCP_BAD_VERSION",
+            Refusal::ReservedNonzero => "DCP_RESERVED_NONZERO",
+            Refusal::BadEnum => "DCP_BAD_ENUM",
+            Refusal::UnknownLicense => "DCP_UNKNOWN_LICENSE",
+            Refusal::FalseErasureClaim => "DCP_FALSE_ERASURE_CLAIM",
+            Refusal::MissingField => "DCP_MISSING_FIELD",
+            Refusal::BadKey => "DCP_BAD_KEY",
+            Refusal::BadValidity => "DCP_BAD_VALIDITY",
+            Refusal::Inconsistent => "DCP_INCONSISTENT",
+            Refusal::ScopeConflict => "DCP_SCOPE_CONFLICT",
+            Refusal::PermissionAmplification => "DCP_PERMISSION_AMPLIFICATION",
+            Refusal::NoConsent => "DCP_NO_CONSENT",
+            Refusal::AncestorCycle => "DCP_ANCESTOR_CYCLE",
+            Refusal::Duplicate => "DCP_DUPLICATE",
+            Refusal::BadSignature => "DCP_BAD_SIGNATURE",
+            Refusal::OwnerMismatch => "DCP_OWNER_MISMATCH",
+            Refusal::Private => "DCP_PRIVATE",
+            Refusal::NotRecipient => "DCP_NOT_RECIPIENT",
+            Refusal::Expired => "DCP_EXPIRED",
+            Refusal::Stale => "DCP_STALE",
+            Refusal::Revoked => "DCP_REVOKED",
+            Refusal::NotPermitted => "DCP_NOT_PERMITTED",
+            Refusal::Conflict => "DCP_CONFLICT",
+            Refusal::UnknownCustodian => "DCP_UNKNOWN_CUSTODIAN",
+            Refusal::SelfAuthorized => "DCP_SELF_AUTHORIZED",
+            Refusal::Unverified => "DCP_UNVERIFIED",
+            Refusal::CapabilityDenied => "DCP_CAPABILITY_DENIED",
+            Refusal::CrossDataset => "DCP_CROSS_DATASET",
+            Refusal::UnknownParent => "DCP_UNKNOWN_PARENT",
+        }
+    }
+}
+
+/// `DiscoveryCapsuleV1` (section 5).
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Capsule {
+    pub share_scope: u8,
+    pub permissions: u8,
+    pub precision: u8,
+    pub license: u16,
+    pub failure_count: u16,
+    pub abi_version: u32,
+    pub required_capabilities: u32,
+    pub precondition_rank: u8,
+    pub precondition_dims: [u32; 4],
+    pub valid_from: u64,
+    pub expires_at: u64,
+    pub revocation_seq: u64,
+    pub meaning_digest: [u8; 32],
+    pub source_digest: [u8; 32],
+    pub compiler_digest: [u8; 32],
+    pub executable_digest: [u8; 32],
+    pub preconditions_digest: [u8; 32],
+    pub verifier_ref: [u8; 32],
+    pub evidence_digest: [u8; 32],
+    pub failure_cases_digest: [u8; 32],
+    pub utility_verdict_ref: [u8; 32],
+    pub science_verdict_ref: [u8; 32],
+    pub recipient_policy_digest: [u8; 32],
+    pub recipient_set_digest: [u8; 32],
+    pub consent_ref: [u8; 32],
+    pub revocation_head: [u8; 32],
+    pub parent_capsule: [u8; 32],
+    pub microjob_ref: [u8; 32],
+    pub owner_key: [u8; 33],
+    pub signature: [u8; 64],
+}
+
+/// `OwnerConsentV1` (section 6). `custodians` holds the used slots.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Consent {
+    pub purposes: u8,
+    pub consent_version: u32,
+    pub notice_seconds: u32,
+    pub issued_at: u64,
+    pub retention_end: u64,
+    pub provenance_digest: [u8; 32],
+    pub recipient_digest: [u8; 32],
+    pub fragment_digest: [u8; 32],
+    pub payload_digest: [u8; 32],
+    pub custodians: Vec<[u8; 32]>,
+    pub owner_key: [u8; 33],
+    pub signature: [u8; 64],
+}
+
+/// `OwnerRetractionV1` (section 7). `erasure_claim` is always written as 0.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Retraction {
+    pub scope: u8,
+    pub seq: u64,
+    pub effective_at: u64,
+    pub target_digest: [u8; 32],
+    pub prev_retraction: [u8; 32],
+    pub provenance_digest: [u8; 32],
+    pub tombstone_digest: [u8; 32],
+    pub owner_key: [u8; 33],
+    pub signer_key: [u8; 33],
+    pub signature: [u8; 64],
+}
+
+/// `RetractionAckV1` (section 8).
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Ack {
+    pub status: u8,
+    pub acked_at: u64,
+    pub retraction_digest: [u8; 32],
+    pub recipient_key: [u8; 33],
+    pub signature: [u8; 64],
+}
+
+/// `ExperienceLineageV1` (section 9). `parents` and `influenced` hold the
+/// used slots.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Lineage {
+    pub content_digest: [u8; 32],
+    pub dataset_id: [u8; 32],
+    pub consent_ref: [u8; 32],
+    pub parents: Vec<[u8; 32]>,
+    pub influenced: Vec<[u8; 32]>,
+    pub owner_key: [u8; 33],
+    pub signature: [u8; 64],
+}
+
+/// Any record of the family.
+#[derive(Debug, Clone, PartialEq, Eq)]
+// Records are decoded once and moved into `Verified`; boxing the capsule
+// would add a heap allocation per decode for no gain.
+#[allow(clippy::large_enum_variant)]
+pub enum Record {
+    Capsule(Capsule),
+    Consent(Consent),
+    Retraction(Retraction),
+    Ack(Ack),
+    Lineage(Lineage),
+}
+
+fn u16_at(b: &[u8], at: usize) -> u16 {
+    u16::from_be_bytes([b[at], b[at + 1]])
+}
+fn u32_at(b: &[u8], at: usize) -> u32 {
+    u32::from_be_bytes(arr(b, at))
+}
+fn u64_at(b: &[u8], at: usize) -> u64 {
+    u64::from_be_bytes(arr(b, at))
+}
+fn arr<const N: usize>(b: &[u8], at: usize) -> [u8; N] {
+    let mut out = [0u8; N];
+    out.copy_from_slice(&b[at..at + N]);
+    out
+}
+fn z(b: &[u8]) -> bool {
+    b.iter().all(|&x| x == 0)
+}
+fn z32(b: &[u8], at: usize) -> bool {
+    z(&b[at..at + 32])
+}
+fn key_ok(b: &[u8], at: usize) -> bool {
+    b[at] == 0x02 || b[at] == 0x03
+}
+
+/// Length, signing-key offset and signature offset of a record type.
+fn layout(magic: &[u8]) -> Option<(usize, usize, usize)> {
+    match magic {
+        b"DCP1" => Some((CAPSULE_LEN, 576, 612)),
+        b"DCC1" => Some((CONSENT_LEN, 288, 324)),
+        b"DCR1" => Some((RETRACTION_LEN, 185, 220)),
+        b"DCA1" => Some((ACK_LEN, 48, 84)),
+        b"DCL1" => Some((LINEAGE_LEN, 488, 524)),
+        _ => None,
+    }
+}
+
+/// Decode and check one record against the static rules of SPEC.md section
+/// 10, in the same order as the C checker. Signatures are not checked here
+/// (see [`open`]).
+pub fn decode(b: &[u8]) -> Result<Record, Refusal> {
+    if b.len() < 5 {
+        return Err(Refusal::BadLength);
+    }
+    let (len, _, _) = layout(&b[0..4]).ok_or(Refusal::BadMagic)?;
+    if b[4] == 0 {
+        return Err(Refusal::Downgrade);
+    }
+    if b[4] > VERSION {
+        return Err(Refusal::BadVersion);
+    }
+    if b.len() != len {
+        return Err(Refusal::BadLength);
+    }
+    match &b[0..4] {
+        b"DCP1" => check_capsule(b).map(Record::Capsule),
+        b"DCC1" => check_consent(b).map(Record::Consent),
+        b"DCR1" => check_retraction(b).map(Record::Retraction),
+        b"DCA1" => check_ack(b).map(Record::Ack),
+        _ => check_lineage(b).map(Record::Lineage),
+    }
+}
+
+fn check_capsule(b: &[u8]) -> Result<Capsule, Refusal> {
+    let rank = b[20] as usize;
+    let dims_bad = (rank.min(4)..4).any(|d| u32_at(b, 24 + 4 * d) != 0);
+    if !z(&b[21..24]) || !z(&b[609..612]) || dims_bad {
+        return Err(Refusal::ReservedNonzero);
+    }
+    let caps = u32_at(b, 16);
+    if b[5] > scope::PUBLIC
+        || b[6] & !perm::ALL != 0
+        || b[7] > 6
+        || caps & !cap::ALL != 0
+        || rank > 4
+    {
+        return Err(Refusal::BadEnum);
+    }
+    let lic = u16_at(b, 8);
+    if !(1..=6).contains(&lic) {
+        return Err(Refusal::UnknownLicense);
+    }
+    if u32_at(b, 12) == 0 || (64..288).step_by(32).any(|at| z32(b, at)) || z32(b, 384) {
+        return Err(Refusal::MissingField);
+    }
+    if !key_ok(b, 576) {
+        return Err(Refusal::BadKey);
+    }
+    let (from, until) = (u64_at(b, 40), u64_at(b, 48));
+    if from == 0 || until <= from {
+        return Err(Refusal::BadValidity);
+    }
+    if (u16_at(b, 10) != 0) == z32(b, 288) || (u64_at(b, 56) != 0) == z32(b, 480) {
+        return Err(Refusal::Inconsistent);
+    }
+    let (sc, perms) = (b[5], b[6]);
+    if (sc == scope::PRIVATE && perms != 0) || ((sc == scope::NAMED) == z32(b, 416)) {
+        return Err(Refusal::ScopeConflict);
+    }
+    if perms & (perm::REDISTRIBUTE | perm::TRAIN) != 0 && perms & perm::READ == 0 {
+        return Err(Refusal::PermissionAmplification);
+    }
+    let needs_consent =
+        perms & (perm::READ | perm::REDISTRIBUTE | perm::TRAIN) != 0 || sc != scope::PRIVATE;
+    if needs_consent && z32(b, 448) {
+        return Err(Refusal::NoConsent);
+    }
+    Ok(Capsule {
+        share_scope: sc,
+        permissions: perms,
+        precision: b[7],
+        license: lic,
+        failure_count: u16_at(b, 10),
+        abi_version: u32_at(b, 12),
+        required_capabilities: caps,
+        precondition_rank: b[20],
+        precondition_dims: [u32_at(b, 24), u32_at(b, 28), u32_at(b, 32), u32_at(b, 36)],
+        valid_from: from,
+        expires_at: until,
+        revocation_seq: u64_at(b, 56),
+        meaning_digest: arr(b, 64),
+        source_digest: arr(b, 96),
+        compiler_digest: arr(b, 128),
+        executable_digest: arr(b, 160),
+        preconditions_digest: arr(b, 192),
+        verifier_ref: arr(b, 224),
+        evidence_digest: arr(b, 256),
+        failure_cases_digest: arr(b, 288),
+        utility_verdict_ref: arr(b, 320),
+        science_verdict_ref: arr(b, 352),
+        recipient_policy_digest: arr(b, 384),
+        recipient_set_digest: arr(b, 416),
+        consent_ref: arr(b, 448),
+        revocation_head: arr(b, 480),
+        parent_capsule: arr(b, 512),
+        microjob_ref: arr(b, 544),
+        owner_key: arr(b, 576),
+        signature: arr(b, 612),
+    })
+}
+
+fn check_consent(b: &[u8]) -> Result<Consent, Refusal> {
+    let n = b[6] as usize;
+    let slots_bad = (n.min(4)..4).any(|s| !z32(b, 160 + 32 * s));
+    if b[7] != 0 || !z(&b[321..324]) || slots_bad {
+        return Err(Refusal::ReservedNonzero);
+    }
+    if b[5] == 0 || b[5] & !perm::ALL != 0 || n > 4 {
+        return Err(Refusal::BadEnum);
+    }
+    if u32_at(b, 8) == 0
+        || [32, 64, 96, 128].iter().any(|&at| z32(b, at))
+        || (0..n).any(|s| z32(b, 160 + 32 * s))
+    {
+        return Err(Refusal::MissingField);
+    }
+    if !key_ok(b, 288) {
+        return Err(Refusal::BadKey);
+    }
+    let (issued, until) = (u64_at(b, 16), u64_at(b, 24));
+    if issued == 0 || until <= issued {
+        return Err(Refusal::BadValidity);
+    }
+    if b[5] & (perm::REDISTRIBUTE | perm::TRAIN) != 0 && b[5] & perm::READ == 0 {
+        return Err(Refusal::PermissionAmplification);
+    }
+    Ok(Consent {
+        purposes: b[5],
+        consent_version: u32_at(b, 8),
+        notice_seconds: u32_at(b, 12),
+        issued_at: issued,
+        retention_end: until,
+        provenance_digest: arr(b, 32),
+        recipient_digest: arr(b, 64),
+        fragment_digest: arr(b, 96),
+        payload_digest: arr(b, 128),
+        custodians: (0..n).map(|s| arr(b, 160 + 32 * s)).collect(),
+        owner_key: arr(b, 288),
+        signature: arr(b, 324),
+    })
+}
+
+fn check_retraction(b: &[u8]) -> Result<Retraction, Refusal> {
+    if b[7] != 0 || !z(&b[218..220]) {
+        return Err(Refusal::ReservedNonzero);
+    }
+    if b[5] == 0 || b[5] & !retract::ALL != 0 {
+        return Err(Refusal::BadEnum);
+    }
+    if b[6] != 0 {
+        return Err(Refusal::FalseErasureClaim);
+    }
+    let seq = u64_at(b, 8);
+    if seq == 0 || z32(b, 24) || z32(b, 88) || z32(b, 120) {
+        return Err(Refusal::MissingField);
+    }
+    if !key_ok(b, 152) || !key_ok(b, 185) {
+        return Err(Refusal::BadKey);
+    }
+    if u64_at(b, 16) == 0 {
+        return Err(Refusal::BadValidity);
+    }
+    if (seq == 1) != z32(b, 56) {
+        return Err(Refusal::Inconsistent);
+    }
+    Ok(Retraction {
+        scope: b[5],
+        seq,
+        effective_at: u64_at(b, 16),
+        target_digest: arr(b, 24),
+        prev_retraction: arr(b, 56),
+        provenance_digest: arr(b, 88),
+        tombstone_digest: arr(b, 120),
+        owner_key: arr(b, 152),
+        signer_key: arr(b, 185),
+        signature: arr(b, 220),
+    })
+}
+
+fn check_ack(b: &[u8]) -> Result<Ack, Refusal> {
+    if !z(&b[6..8]) || !z(&b[81..84]) {
+        return Err(Refusal::ReservedNonzero);
+    }
+    if !(1..=2).contains(&b[5]) {
+        return Err(Refusal::BadEnum);
+    }
+    if z32(b, 16) {
+        return Err(Refusal::MissingField);
+    }
+    if !key_ok(b, 48) {
+        return Err(Refusal::BadKey);
+    }
+    if u64_at(b, 8) == 0 {
+        return Err(Refusal::BadValidity);
+    }
+    Ok(Ack {
+        status: b[5],
+        acked_at: u64_at(b, 8),
+        retraction_digest: arr(b, 16),
+        recipient_key: arr(b, 48),
+        signature: arr(b, 84),
+    })
+}
+
+fn check_lineage(b: &[u8]) -> Result<Lineage, Refusal> {
+    let (np, ni) = (b[5] as usize, b[6] as usize);
+    let parents_bad = (np.min(4)..4).any(|s| !z32(b, 104 + 32 * s));
+    let infl_bad = (ni.min(8)..8).any(|s| !z32(b, 232 + 32 * s));
+    if b[7] != 0 || !z(&b[521..524]) || parents_bad || infl_bad {
+        return Err(Refusal::ReservedNonzero);
+    }
+    if np > 4 || ni > 8 {
+        return Err(Refusal::BadEnum);
+    }
+    if z32(b, 8)
+        || z32(b, 40)
+        || z32(b, 72)
+        || (0..np).any(|s| z32(b, 104 + 32 * s))
+        || (0..ni).any(|s| z32(b, 232 + 32 * s))
+    {
+        return Err(Refusal::MissingField);
+    }
+    if !key_ok(b, 488) {
+        return Err(Refusal::BadKey);
+    }
+    let parents: Vec<[u8; 32]> = (0..np).map(|s| arr(b, 104 + 32 * s)).collect();
+    let content: [u8; 32] = arr(b, 8);
+    if parents.contains(&content) {
+        return Err(Refusal::AncestorCycle);
+    }
+    for i in 0..np {
+        if parents[i + 1..].contains(&parents[i]) {
+            return Err(Refusal::Duplicate);
+        }
+    }
+    Ok(Lineage {
+        content_digest: content,
+        dataset_id: arr(b, 40),
+        consent_ref: arr(b, 72),
+        parents,
+        influenced: (0..ni).map(|s| arr(b, 232 + 32 * s)).collect(),
+        owner_key: arr(b, 488),
+        signature: arr(b, 524),
+    })
+}
+
+fn put32(b: &mut [u8], at: usize, v: &[u8; 32]) {
+    b[at..at + 32].copy_from_slice(v);
+}
+
+impl Capsule {
+    /// Write the record, signature included.
+    pub fn encode(&self) -> Vec<u8> {
+        let mut b = vec![0u8; CAPSULE_LEN];
+        b[0..4].copy_from_slice(b"DCP1");
+        b[4] = VERSION;
+        b[5] = self.share_scope;
+        b[6] = self.permissions;
+        b[7] = self.precision;
+        b[8..10].copy_from_slice(&self.license.to_be_bytes());
+        b[10..12].copy_from_slice(&self.failure_count.to_be_bytes());
+        b[12..16].copy_from_slice(&self.abi_version.to_be_bytes());
+        b[16..20].copy_from_slice(&self.required_capabilities.to_be_bytes());
+        b[20] = self.precondition_rank;
+        for (d, v) in self.precondition_dims.iter().enumerate() {
+            b[24 + 4 * d..28 + 4 * d].copy_from_slice(&v.to_be_bytes());
+        }
+        b[40..48].copy_from_slice(&self.valid_from.to_be_bytes());
+        b[48..56].copy_from_slice(&self.expires_at.to_be_bytes());
+        b[56..64].copy_from_slice(&self.revocation_seq.to_be_bytes());
+        let digests = [
+            &self.meaning_digest,
+            &self.source_digest,
+            &self.compiler_digest,
+            &self.executable_digest,
+            &self.preconditions_digest,
+            &self.verifier_ref,
+            &self.evidence_digest,
+            &self.failure_cases_digest,
+            &self.utility_verdict_ref,
+            &self.science_verdict_ref,
+            &self.recipient_policy_digest,
+            &self.recipient_set_digest,
+            &self.consent_ref,
+            &self.revocation_head,
+            &self.parent_capsule,
+            &self.microjob_ref,
+        ];
+        for (k, d) in digests.iter().enumerate() {
+            put32(&mut b, 64 + 32 * k, d);
+        }
+        b[576..609].copy_from_slice(&self.owner_key);
+        b[612..676].copy_from_slice(&self.signature);
+        b
+    }
+
+    /// Set `owner_key` from `key` and sign.
+    pub fn sign(&mut self, key: &SigningKey) {
+        self.owner_key = p256_compressed_key(key);
+        self.signature = p256_sign_low_s(key, &self.encode()[..612]);
+    }
+
+    /// `record_digest` (signature excluded).
+    pub fn digest(&self) -> [u8; 32] {
+        record_digest(&self.encode())
+    }
+}
+
+impl Consent {
+    /// Write the record, signature included.
+    pub fn encode(&self) -> Vec<u8> {
+        let mut b = vec![0u8; CONSENT_LEN];
+        b[0..4].copy_from_slice(b"DCC1");
+        b[4] = VERSION;
+        b[5] = self.purposes;
+        b[6] = self.custodians.len() as u8;
+        b[8..12].copy_from_slice(&self.consent_version.to_be_bytes());
+        b[12..16].copy_from_slice(&self.notice_seconds.to_be_bytes());
+        b[16..24].copy_from_slice(&self.issued_at.to_be_bytes());
+        b[24..32].copy_from_slice(&self.retention_end.to_be_bytes());
+        put32(&mut b, 32, &self.provenance_digest);
+        put32(&mut b, 64, &self.recipient_digest);
+        put32(&mut b, 96, &self.fragment_digest);
+        put32(&mut b, 128, &self.payload_digest);
+        for (s, c) in self.custodians.iter().take(4).enumerate() {
+            put32(&mut b, 160 + 32 * s, c);
+        }
+        b[288..321].copy_from_slice(&self.owner_key);
+        b[324..388].copy_from_slice(&self.signature);
+        b
+    }
+
+    /// Set `owner_key` from `key` and sign.
+    pub fn sign(&mut self, key: &SigningKey) {
+        self.owner_key = p256_compressed_key(key);
+        self.signature = p256_sign_low_s(key, &self.encode()[..324]);
+    }
+
+    /// `record_digest` (signature excluded).
+    pub fn digest(&self) -> [u8; 32] {
+        record_digest(&self.encode())
+    }
+}
+
+impl Retraction {
+    /// Write the record, signature included (`erasure_claim` is 0).
+    pub fn encode(&self) -> Vec<u8> {
+        let mut b = vec![0u8; RETRACTION_LEN];
+        b[0..4].copy_from_slice(b"DCR1");
+        b[4] = VERSION;
+        b[5] = self.scope;
+        b[8..16].copy_from_slice(&self.seq.to_be_bytes());
+        b[16..24].copy_from_slice(&self.effective_at.to_be_bytes());
+        put32(&mut b, 24, &self.target_digest);
+        put32(&mut b, 56, &self.prev_retraction);
+        put32(&mut b, 88, &self.provenance_digest);
+        put32(&mut b, 120, &self.tombstone_digest);
+        b[152..185].copy_from_slice(&self.owner_key);
+        b[185..218].copy_from_slice(&self.signer_key);
+        b[220..284].copy_from_slice(&self.signature);
+        b
+    }
+
+    /// Set `signer_key` from `key` and sign (`owner_key` is left as set).
+    pub fn sign(&mut self, key: &SigningKey) {
+        self.signer_key = p256_compressed_key(key);
+        self.signature = p256_sign_low_s(key, &self.encode()[..220]);
+    }
+
+    /// `record_digest` (signature excluded).
+    pub fn digest(&self) -> [u8; 32] {
+        record_digest(&self.encode())
+    }
+}
+
+impl Ack {
+    /// Write the record, signature included.
+    pub fn encode(&self) -> Vec<u8> {
+        let mut b = vec![0u8; ACK_LEN];
+        b[0..4].copy_from_slice(b"DCA1");
+        b[4] = VERSION;
+        b[5] = self.status;
+        b[8..16].copy_from_slice(&self.acked_at.to_be_bytes());
+        put32(&mut b, 16, &self.retraction_digest);
+        b[48..81].copy_from_slice(&self.recipient_key);
+        b[84..148].copy_from_slice(&self.signature);
+        b
+    }
+
+    /// Set `recipient_key` from `key` and sign.
+    pub fn sign(&mut self, key: &SigningKey) {
+        self.recipient_key = p256_compressed_key(key);
+        self.signature = p256_sign_low_s(key, &self.encode()[..84]);
+    }
+}
+
+impl Lineage {
+    /// Write the record, signature included.
+    pub fn encode(&self) -> Vec<u8> {
+        let mut b = vec![0u8; LINEAGE_LEN];
+        b[0..4].copy_from_slice(b"DCL1");
+        b[4] = VERSION;
+        b[5] = self.parents.len() as u8;
+        b[6] = self.influenced.len() as u8;
+        put32(&mut b, 8, &self.content_digest);
+        put32(&mut b, 40, &self.dataset_id);
+        put32(&mut b, 72, &self.consent_ref);
+        for (s, p) in self.parents.iter().take(4).enumerate() {
+            put32(&mut b, 104 + 32 * s, p);
+        }
+        for (s, p) in self.influenced.iter().take(8).enumerate() {
+            put32(&mut b, 232 + 32 * s, p);
+        }
+        b[488..521].copy_from_slice(&self.owner_key);
+        b[524..588].copy_from_slice(&self.signature);
+        b
+    }
+
+    /// Set `owner_key` from `key` and sign.
+    pub fn sign(&mut self, key: &SigningKey) {
+        self.owner_key = p256_compressed_key(key);
+        self.signature = p256_sign_low_s(key, &self.encode()[..524]);
+    }
+}
+
+impl Record {
+    /// Write the record, signature included.
+    pub fn encode(&self) -> Vec<u8> {
+        match self {
+            Record::Capsule(x) => x.encode(),
+            Record::Consent(x) => x.encode(),
+            Record::Retraction(x) => x.encode(),
+            Record::Ack(x) => x.encode(),
+            Record::Lineage(x) => x.encode(),
+        }
+    }
+}
+
+/// `record_digest`: SHA-256 of every byte before the signature. `bytes`
+/// must be a record of known type and length.
+pub fn record_digest(bytes: &[u8]) -> [u8; 32] {
+    let (_, _, sig) = layout(&bytes[0..4]).expect("record of a known type");
+    Sha256::digest(&bytes[..sig]).into()
+}
+
+/// A record whose static rules and signature both passed. Only [`open`]
+/// makes one, so a recipient rule can never be fed unchecked fields.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Verified<T> {
+    inner: T,
+    digest: [u8; 32],
+}
+
+impl<T> Verified<T> {
+    /// The checked record.
+    pub fn get(&self) -> &T {
+        &self.inner
+    }
+    /// Its `record_digest`.
+    pub fn digest(&self) -> [u8; 32] {
+        self.digest
+    }
+}
+
+/// Check one record's static rules and its signature under the signing key
+/// the record names (owner, signer or recipient key).
+pub fn open(bytes: &[u8]) -> Result<Verified<Record>, Refusal> {
+    let record = decode(bytes)?;
+    let (_, key_at, sig_at) = layout(&bytes[0..4]).expect("decode checked the magic");
+    let key: [u8; 33] = arr(bytes, key_at);
+    let sig: [u8; 64] = arr(bytes, sig_at);
+    p256_verify_low_s(&key, &bytes[..sig_at], &sig).map_err(|_| Refusal::BadSignature)?;
+    Ok(Verified {
+        inner: record,
+        digest: record_digest(bytes),
+    })
+}
+
+macro_rules! open_as {
+    ($name:ident, $variant:ident, $ty:ty) => {
+        /// [`open`] for one record type; another type is `DCP_BAD_MAGIC`.
+        pub fn $name(bytes: &[u8]) -> Result<Verified<$ty>, Refusal> {
+            let v = open(bytes)?;
+            match v.inner {
+                Record::$variant(x) => Ok(Verified {
+                    inner: x,
+                    digest: v.digest,
+                }),
+                _ => Err(Refusal::BadMagic),
+            }
+        }
+    };
+}
+open_as!(open_capsule, Capsule, Capsule);
+open_as!(open_consent, Consent, Consent);
+open_as!(open_retraction, Retraction, Retraction);
+open_as!(open_ack, Ack, Ack);
+open_as!(open_lineage, Lineage, Lineage);
+
+/// `recipient_set_digest` of a NAMED capsule: keys sorted bytewise, no
+/// duplicates (SPEC.md section 9).
+pub fn recipients_digest(keys: &[[u8; 33]]) -> [u8; 32] {
+    let mut sorted = keys.to_vec();
+    sorted.sort();
+    sorted.dedup();
+    let mut h = Sha256::new();
+    h.update(b"DCP1-RECIPIENTS");
+    for k in &sorted {
+        h.update(k);
+    }
+    h.finalize().into()
+}
+
+/// SHA-256 of a key, the form a consent declares custodians in.
+pub fn key_digest(key: &[u8; 33]) -> [u8; 32] {
+    Sha256::digest(key).into()
+}
+
+fn hex(out: &mut String, bytes: &[u8]) {
+    const H: &[u8; 16] = b"0123456789abcdef";
+    for &x in bytes {
+        out.push(H[(x >> 4) as usize] as char);
+        out.push(H[(x & 15) as usize] as char);
+    }
+}
+
+/// The verdict line in the exact format of `dcp_verify FILE` and
+/// `vectors/expected.txt`: `ok type=MAGIC digest=H64 key=H66` (the signing
+/// key) or `refuse CODE`.
+pub fn verdict_line(bytes: &[u8]) -> String {
+    match decode(bytes) {
+        Err(r) => format!("refuse {}", r.name()),
+        Ok(_) => {
+            let (_, key_at, _) = layout(&bytes[0..4]).expect("decoded");
+            let mut s = format!(
+                "ok type={} digest=",
+                std::str::from_utf8(&bytes[0..4]).unwrap()
+            );
+            hex(&mut s, &record_digest(bytes));
+            s.push_str(" key=");
+            hex(&mut s, &bytes[key_at..key_at + 33]);
+            s
+        }
+    }
+}
diff --git a/crates/aien-discovery-capsule/src/recipient.rs b/crates/aien-discovery-capsule/src/recipient.rs
new file mode 100644
index 0000000..4329838
--- /dev/null
+++ b/crates/aien-discovery-capsule/src/recipient.rs
@@ -0,0 +1,489 @@
+//! Stateful recipient rules of SPEC.md section 11: the owner's retraction
+//! chain, use checks for serving / training / republication, execution
+//! admission, honest retraction delivery status, and experience lineage.
+//!
+//! Every function takes [`Verified`] records, so static rules and signatures
+//! have always been checked first. A refusal changes no state.
+
+use std::collections::HashMap;
+
+use crate::{
+    key_digest, perm, recipients_digest, retract, scope, Ack, Capsule, Consent, Lineage, Refusal,
+    Retraction, Verified,
+};
+
+/// Whether an apply changed state.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Applied {
+    New,
+    Replay,
+}
+
+/// One owner's retraction chain as one node knows it.
+#[derive(Debug, Clone)]
+pub struct OwnerChain {
+    owner: [u8; 33],
+    custodians: Vec<[u8; 32]>,
+    entries: Vec<(Retraction, [u8; 32])>,
+}
+
+impl OwnerChain {
+    /// An empty chain for `consent`'s owner, with the custodians that consent
+    /// declares (and no others).
+    pub fn new(consent: &Verified<Consent>) -> Self {
+        OwnerChain {
+            owner: consent.get().owner_key,
+            custodians: consent.get().custodians.clone(),
+            entries: Vec::new(),
+        }
+    }
+
+    /// The owner whose chain this is.
+    pub fn owner(&self) -> [u8; 33] {
+        self.owner
+    }
+
+    /// Sequence of the newest retraction, 0 when none.
+    pub fn head_seq(&self) -> u64 {
+        self.entries.len() as u64
+    }
+
+    /// `record_digest` of the retraction at `seq` (1-based).
+    pub fn digest_at(&self, seq: u64) -> Option<[u8; 32]> {
+        if seq == 0 {
+            return None;
+        }
+        self.entries.get(seq as usize - 1).map(|(_, d)| *d)
+    }
+
+    /// Append one retraction. Concurrent conflicting operations, gaps and a
+    /// wrong `prev_retraction` fail closed (`DCP_CONFLICT`).
+    pub fn apply(&mut self, r: &Verified<Retraction>) -> Result<Applied, Refusal> {
+        let x = r.get();
+        if x.owner_key != self.owner {
+            return Err(Refusal::OwnerMismatch);
+        }
+        if x.signer_key != self.owner && !self.custodians.contains(&key_digest(&x.signer_key)) {
+            return Err(Refusal::UnknownCustodian);
+        }
+        let head = self.head_seq();
+        if x.seq <= head {
+            return if self.digest_at(x.seq) == Some(r.digest()) {
+                Ok(Applied::Replay)
+            } else {
+                Err(Refusal::Conflict)
+            };
+        }
+        let prev_ok = if x.seq == 1 {
+            true
+        } else {
+            self.digest_at(head) == Some(x.prev_retraction)
+        };
+        if x.seq != head + 1 || !prev_ok {
+            return Err(Refusal::Conflict);
+        }
+        self.entries.push((x.clone(), r.digest()));
+        Ok(Applied::New)
+    }
+
+    /// Whether a retraction in effect at `now` targets `target` with any of
+    /// `scope_bits`.
+    pub fn retracts(&self, target: &[u8; 32], scope_bits: u8, now: u64) -> bool {
+        self.entries.iter().any(|(r, _)| {
+            &r.target_digest == target && r.scope & scope_bits != 0 && r.effective_at <= now
+        })
+    }
+}
+
+/// The use a recipient asks to make of a capsule.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Use {
+    /// Retrieve and read.
+    Serve,
+    /// Make it training-eligible.
+    Train,
+    /// Pass it on.
+    Republish,
+}
+
+impl Use {
+    fn permission(self) -> u8 {
+        match self {
+            Use::Serve => perm::READ,
+            Use::Train => perm::TRAIN,
+            Use::Republish => perm::REDISTRIBUTE,
+        }
+    }
+    fn retraction_scope(self) -> u8 {
+        match self {
+            Use::Serve => retract::FUTURE_AVAILABILITY | retract::RETRIEVAL,
+            Use::Train => retract::TRAINING,
+            Use::Republish => retract::REPUBLICATION,
+        }
+    }
+}
+
+/// What the recipient knows when it asks.
+#[derive(Debug, Clone)]
+pub struct UseRequest<'a> {
+    pub use_: Use,
+    pub requester: [u8; 33],
+    /// The full NAMED recipient list, when the capsule is NAMED.
+    pub named_recipients: &'a [[u8; 33]],
+    pub now: u64,
+    /// The newest `consent_version` this node knows for the same fragment.
+    pub newest_consent_version: u32,
+    /// The parent capsule, when `parent_capsule` is not zero.
+    pub parent: Option<&'a Verified<Capsule>>,
+}
+
+/// Check one use of a capsule against its consent and the owner's chain
+/// (SPEC.md section 11). `Ok` means "this use is not refused by the capsule
+/// contract"; it is not an authorization for any effect.
+pub fn check_use(
+    capsule: &Verified<Capsule>,
+    consent: Option<&Verified<Consent>>,
+    chain: &OwnerChain,
+    req: &UseRequest<'_>,
+) -> Result<(), Refusal> {
+    let c = capsule.get();
+    if chain.owner() != c.owner_key || consent.is_some_and(|k| k.get().owner_key != c.owner_key) {
+        return Err(Refusal::OwnerMismatch);
+    }
+    if c.share_scope == scope::PRIVATE && req.requester != c.owner_key {
+        return Err(Refusal::Private);
+    }
+    let needs_consent = c.permissions & (perm::READ | perm::REDISTRIBUTE | perm::TRAIN) != 0
+        || c.share_scope != scope::PRIVATE;
+    if needs_consent {
+        match consent {
+            Some(k)
+                if k.digest() == c.consent_ref && k.get().fragment_digest == c.meaning_digest => {}
+            _ => return Err(Refusal::NoConsent),
+        }
+    }
+    if let Some(k) = consent {
+        if c.permissions & !k.get().purposes != 0 {
+            return Err(Refusal::PermissionAmplification);
+        }
+    }
+    if c.parent_capsule != [0; 32] {
+        match req.parent {
+            Some(p) if p.digest() == c.parent_capsule => {
+                if c.permissions & !p.get().permissions != 0 {
+                    return Err(Refusal::PermissionAmplification);
+                }
+            }
+            _ => return Err(Refusal::UnknownParent),
+        }
+    }
+    if req.requester != c.owner_key && c.permissions & req.use_.permission() == 0 {
+        return Err(Refusal::NotPermitted);
+    }
+    if c.share_scope == scope::NAMED
+        && req.requester != c.owner_key
+        && (recipients_digest(req.named_recipients) != c.recipient_set_digest
+            || !req.named_recipients.contains(&req.requester))
+    {
+        return Err(Refusal::NotRecipient);
+    }
+    if req.now < c.valid_from
+        || req.now > c.expires_at
+        || consent.is_some_and(|k| req.now > k.get().retention_end)
+    {
+        return Err(Refusal::Expired);
+    }
+    if c.revocation_seq > chain.head_seq()
+        || consent.is_some_and(|k| req.newest_consent_version > k.get().consent_version)
+    {
+        return Err(Refusal::Stale);
+    }
+    if c.revocation_seq > 0 && chain.digest_at(c.revocation_seq) != Some(c.revocation_head) {
+        return Err(Refusal::Conflict);
+    }
+    let bits = req.use_.retraction_scope();
+    if chain.retracts(&capsule.digest(), bits, req.now)
+        || chain.retracts(&c.meaning_digest, bits, req.now)
+    {
+        return Err(Refusal::Revoked);
+    }
+    Ok(())
+}
+
+/// A verdict from the recipient's own independent verifier, run on the
+/// recipient's platform. Local to the recipient; not a wire record.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct RecipientVerdict {
+    pub capsule_digest: [u8; 32],
+    pub platform_digest: [u8; 32],
+    pub verifier_key: [u8; 33],
+    pub passed: bool,
+}
+
+/// The result of [`admit_execution`]: which capsule may run, on which
+/// platform, within which requested capabilities. Effects still need AEGIS.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct ExecutionAdmission {
+    pub capsule_digest: [u8; 32],
+    pub platform_digest: [u8; 32],
+    pub capabilities: u32,
+}
+
+/// Admit a capsule for execution on `platform_digest`: only with a passing
+/// verdict from a verifier that is not the owner, for this exact capsule and
+/// platform, and only within `granted` capabilities.
+pub fn admit_execution(
+    capsule: &Verified<Capsule>,
+    verdict: &RecipientVerdict,
+    platform_digest: [u8; 32],
+    granted: u32,
+) -> Result<ExecutionAdmission, Refusal> {
+    let c = capsule.get();
+    if verdict.verifier_key == c.owner_key {
+        return Err(Refusal::SelfAuthorized);
+    }
+    if !verdict.passed
+        || verdict.capsule_digest != capsule.digest()
+        || verdict.platform_digest != platform_digest
+    {
+        return Err(Refusal::Unverified);
+    }
+    if c.required_capabilities & !granted != 0 {
+        return Err(Refusal::CapabilityDenied);
+    }
+    Ok(ExecutionAdmission {
+        capsule_digest: capsule.digest(),
+        platform_digest,
+        capabilities: c.required_capabilities,
+    })
+}
+
+/// Delivery status of one retraction at one recipient. There is no "erased".
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Delivery {
+    Pending,
+    Acknowledged { status: u8, acked_at: u64 },
+    Unreachable,
+}
+
+/// The owner-side view of one retraction's propagation (section 11.1).
+#[derive(Debug, Clone)]
+pub struct RetractionTracker {
+    retraction: [u8; 32],
+    recipients: Vec<([u8; 33], Delivery, Option<[u8; 32]>)>,
+}
+
+impl RetractionTracker {
+    /// Track `retraction` as sent to `recipients`; every one starts PENDING.
+    pub fn new(retraction: &Verified<Retraction>, recipients: &[[u8; 33]]) -> Self {
+        RetractionTracker {
+            retraction: retraction.digest(),
+            recipients: recipients
+                .iter()
+                .map(|k| (*k, Delivery::Pending, None))
+                .collect(),
+        }
+    }
+
+    /// Record one signed acknowledgement.
+    pub fn apply_ack(&mut self, ack: &Verified<Ack>) -> Result<Applied, Refusal> {
+        let a = ack.get();
+        if a.retraction_digest != self.retraction {
+            return Err(Refusal::Conflict);
+        }
+        let slot = self
+            .recipients
+            .iter_mut()
+            .find(|(k, _, _)| *k == a.recipient_key)
+            .ok_or(Refusal::NotRecipient)?;
+        match slot.2 {
+            Some(d) if d == ack.digest() => Ok(Applied::Replay),
+            Some(_) => Err(Refusal::Conflict),
+            None => {
+                slot.1 = Delivery::Acknowledged {
+                    status: a.status,
+                    acked_at: a.acked_at,
+                };
+                slot.2 = Some(ack.digest());
+                Ok(Applied::New)
+            }
+        }
+    }
+
+    /// Mark a recipient that cannot be reached; it is never shown as
+    /// acknowledged.
+    pub fn mark_unreachable(&mut self, key: &[u8; 33]) -> Result<(), Refusal> {
+        let slot = self
+            .recipients
+            .iter_mut()
+            .find(|(k, _, _)| k == key)
+            .ok_or(Refusal::NotRecipient)?;
+        if slot.2.is_none() {
+            slot.1 = Delivery::Unreachable;
+        }
+        Ok(())
+    }
+
+    /// Delivery status of one recipient.
+    pub fn status(&self, key: &[u8; 33]) -> Option<Delivery> {
+        self.recipients
+            .iter()
+            .find(|(k, _, _)| k == key)
+            .map(|(_, d, _)| *d)
+    }
+
+    /// Recipients still PENDING.
+    pub fn pending(&self) -> Vec<[u8; 33]> {
+        self.filter(|d| d == Delivery::Pending)
+    }
+
+    /// Recipients that acknowledged but retain copies or trained descendants.
+    pub fn retained(&self) -> Vec<[u8; 33]> {
+        self.filter(|d| {
+            matches!(
+                d,
+                Delivery::Acknowledged {
+                    status: crate::ack_status::ENFORCED_WITH_RETAINED,
+                    ..
+                }
+            )
+        })
+    }
+
+    /// True only when every recipient acknowledged. Even then this says
+    /// "future use stopped at compliant recipients", never "erased".
+    pub fn all_acknowledged(&self) -> bool {
+        self.recipients
+            .iter()
+            .all(|(_, d, _)| matches!(d, Delivery::Acknowledged { .. }))
+    }
+
+    fn filter(&self, f: impl Fn(Delivery) -> bool) -> Vec<[u8; 33]> {
+        self.recipients
+            .iter()
+            .filter(|(_, d, _)| f(*d))
+            .map(|(k, _, _)| *k)
+            .collect()
+    }
+}
+
+/// Experience lineage known to one node, keyed by `content_digest`.
+#[derive(Debug, Clone, Default)]
+pub struct LineageIndex {
+    records: HashMap<[u8; 32], (Lineage, [u8; 32])>,
+}
+
+impl LineageIndex {
+    pub fn new() -> Self {
+        Self::default()
+    }
+
+    /// Add one record. A second, different record for one content is
+    /// `DCP_DUPLICATE`; a known parent from another dataset is
+    /// `DCP_CROSS_DATASET`; a parent chain that leads back here is
+    /// `DCP_ANCESTOR_CYCLE`. Unknown parents are allowed here (offline sync)
+    /// and refused when ancestry is needed.
+    pub fn add(&mut self, l: &Verified<Lineage>) -> Result<Applied, Refusal> {
+        let x = l.get();
+        if let Some((_, d)) = self.records.get(&x.content_digest) {
+            return if *d == l.digest() {
+                Ok(Applied::Replay)
+            } else {
+                Err(Refusal::Duplicate)
+            };
+        }
+        for p in &x.parents {
+            if let Some((parent, _)) = self.records.get(p) {
+                if parent.dataset_id != x.dataset_id {
+                    return Err(Refusal::CrossDataset);
+                }
+            }
+        }
+        let mut stack: Vec<[u8; 32]> = x.parents.clone();
+        let mut seen: Vec<[u8; 32]> = Vec::new();
+        while let Some(c) = stack.pop() {
+            if c == x.content_digest {
+                return Err(Refusal::AncestorCycle);
+            }
+            if seen.contains(&c) {
+                continue;
+            }
+            seen.push(c);
+            if let Some((r, _)) = self.records.get(&c) {
+                stack.extend(r.parents.iter().copied());
+            }
+        }
+        self.records
+            .insert(x.content_digest, (x.clone(), l.digest()));
+        Ok(Applied::New)
+    }
+
+    /// `content` and all its ancestors. Every ancestor must be held.
+    pub fn ancestry(&self, content: &[u8; 32]) -> Result<Vec<[u8; 32]>, Refusal> {
+        let mut out: Vec<[u8; 32]> = Vec::new();
+        let mut stack = vec![*content];
+        while let Some(c) = stack.pop() {
+            if out.contains(&c) {
+                continue;
+            }
+            let (r, _) = self.records.get(&c).ok_or(Refusal::UnknownParent)?;
+            out.push(c);
+            stack.extend(r.parents.iter().copied());
+        }
+        Ok(out)
+    }
+
+    /// Whether `content` may be used for training: every ancestor held, in
+    /// one dataset, and none retracted for TRAINING in its owner's chain.
+    pub fn training_eligible(
+        &self,
+        content: &[u8; 32],
+        chains: &[&OwnerChain],
+        now: u64,
+    ) -> Result<(), Refusal> {
+        let all = self.ancestry(content)?;
+        let dataset = self.records[content].0.dataset_id;
+        for c in &all {
+            let (r, _) = &self.records[c];
+            if r.dataset_id != dataset {
+                return Err(Refusal::CrossDataset);
+            }
+            let chain = chains
+                .iter()
+                .find(|ch| ch.owner() == r.owner_key)
+                .ok_or(Refusal::Stale)?;
+            if chain.retracts(c, retract::TRAINING, now) {
+                return Err(Refusal::Revoked);
+            }
+        }
+        Ok(())
+    }
+
+    /// The checkpoints and capsules influenced by `target` or any of its
+    /// descendants: what must be marked affected after a retraction.
+    pub fn affected(&self, target: &[u8; 32]) -> Vec<[u8; 32]> {
+        let mut hit: Vec<[u8; 32]> = vec![*target];
+        let mut grew = true;
+        while grew {
+            grew = false;
+            for (c, (r, _)) in &self.records {
+                if !hit.contains(c) && r.parents.iter().any(|p| hit.contains(p)) {
+                    hit.push(*c);
+                    grew = true;
+                }
+            }
+        }
+        let mut out: Vec<[u8; 32]> = Vec::new();
+        for c in &hit {
+            if let Some((r, _)) = self.records.get(c) {
+                for i in &r.influenced {
+                    if !out.contains(i) {
+                        out.push(*i);
+                    }
+                }
+            }
+        }
+        out.sort();
+        out
+    }
+}
diff --git a/crates/aien-discovery-capsule/tests/.crumb b/crates/aien-discovery-capsule/tests/.crumb
new file mode 100644
index 0000000..f53e85f
--- /dev/null
+++ b/crates/aien-discovery-capsule/tests/.crumb
@@ -0,0 +1,6 @@
+{
+  "layer": "crates/aien-discovery-capsule/tests",
+  "name": "crates/aien-discovery-capsule/tests",
+  "purpose": "Parity test against specs/discovery-capsule/vectors and the two-owner publish, audit, revoke lifecycle",
+  "schema_version": "1.0.0"
+}
diff --git a/crates/aien-discovery-capsule/tests/lifecycle.rs b/crates/aien-discovery-capsule/tests/lifecycle.rs
new file mode 100644
index 0000000..c817dc6
--- /dev/null
+++ b/crates/aien-discovery-capsule/tests/lifecycle.rs
@@ -0,0 +1,788 @@
+//! Recipient rules of SPEC.md section 11 and the synthetic two-owner
+//! lifecycle of aien-protocols-mv#51: publish, recipient audit, acknowledged
+//! revocation, refused retrieval and training after it, an offline recipient
+//! that stays PENDING, and lineage withdrawal. All keys are TEST keys.
+
+use aien_discovery_capsule::recipient::*;
+use aien_discovery_capsule::*;
+use aien_provenance::p256_compressed_key;
+use p256::ecdsa::SigningKey;
+use sha2::{Digest, Sha256};
+
+const NOW: u64 = 1_850_000_000;
+
+fn sk(seed: u8) -> SigningKey {
+    SigningKey::from_slice(&[seed; 32]).unwrap()
+}
+fn pk(seed: u8) -> [u8; 33] {
+    p256_compressed_key(&sk(seed))
+}
+fn sha(b: &[u8]) -> [u8; 32] {
+    Sha256::digest(b).into()
+}
+fn d(seed: u8) -> [u8; 32] {
+    let mut out = [0u8; 32];
+    for (i, x) in out.iter_mut().enumerate() {
+        *x = seed.wrapping_add((7 * i) as u8);
+    }
+    out
+}
+
+const OWNER_A: u8 = 0xA0;
+const OWNER_B: u8 = 0xB0;
+const R1: u8 = 0x11;
+const R2: u8 = 0x12;
+const R3: u8 = 0x13;
+const CUSTODIAN: u8 = 0xC0;
+const R1_VERIFIER: u8 = 0x1F;
+
+/// The private trace a capsule is about. Its bytes must never appear in any
+/// record; only its digest does.
+const PRIVATE_TRACE: &[u8] =
+    b"PRIVATE-TRACE: greenhouse owner diary, heater fault at 03:12, BP 142/91";
+
+fn consent(owner: u8, meaning: [u8; 32], purposes: u8, custodians: &[u8], version: u32) -> Vec<u8> {
+    let mut c = Consent {
+        purposes,
+        consent_version: version,
+        notice_seconds: 86_400,
+        issued_at: NOW - 1000,
+        retention_end: NOW + 10_000_000,
+        provenance_digest: d(0x61),
+        recipient_digest: d(0x62),
+        fragment_digest: meaning,
+        payload_digest: sha(PRIVATE_TRACE),
+        custodians: custodians.iter().map(|&s| key_digest(&pk(s))).collect(),
+        owner_key: [0; 33],
+        signature: [0; 64],
+    };
+    c.sign(&sk(owner));
+    c.encode()
+}
+
+fn capsule_base(meaning: [u8; 32], consent_ref: [u8; 32]) -> Capsule {
+    Capsule {
+        share_scope: scope::NAMED,
+        permissions: perm::DISCOVER | perm::READ | perm::TRAIN,
+        precision: 0,
+        license: license::APACHE_2_0,
+        failure_count: 1,
+        abi_version: 1,
+        required_capabilities: cap::CPU_COMPUTE | cap::CORTEX_READ,
+        precondition_rank: 1,
+        precondition_dims: [6, 0, 0, 0],
+        valid_from: NOW - 500,
+        expires_at: NOW + 5_000_000,
+        revocation_seq: 0,
+        meaning_digest: meaning,
+        source_digest: d(0x21),
+        compiler_digest: d(0x22),
+        executable_digest: d(0x23),
+        preconditions_digest: d(0x24),
+        verifier_ref: d(0x25),
+        evidence_digest: d(0x26),
+        failure_cases_digest: d(0x27),
+        utility_verdict_ref: [0; 32],
+        science_verdict_ref: [0; 32],
+        recipient_policy_digest: d(0x28),
+        recipient_set_digest: recipients_digest(&[pk(R1), pk(R2)]),
+        consent_ref,
+        revocation_head: [0; 32],
+        parent_capsule: [0; 32],
+        microjob_ref: d(0x29),
+        owner_key: [0; 33],
+        signature: [0; 64],
+    }
+}
+
+fn signed_capsule(mut c: Capsule, owner: u8) -> Vec<u8> {
+    c.sign(&sk(owner));
+    c.encode()
+}
+
+fn retraction(
+    owner: u8,
+    signer: u8,
+    seq: u64,
+    prev: [u8; 32],
+    target: [u8; 32],
+    sc: u8,
+) -> Vec<u8> {
+    let mut r = Retraction {
+        scope: sc,
+        seq,
+        effective_at: NOW,
+        target_digest: target,
+        prev_retraction: prev,
+        provenance_digest: d(0x73),
+        tombstone_digest: d(0x74),
+        owner_key: pk(owner),
+        signer_key: [0; 33],
+        signature: [0; 64],
+    };
+    r.sign(&sk(signer));
+    r.encode()
+}
+
+fn ack(recipient: u8, retraction_digest: [u8; 32], status: u8) -> Vec<u8> {
+    let mut a = Ack {
+        status,
+        acked_at: NOW + 60,
+        retraction_digest,
+        recipient_key: [0; 33],
+        signature: [0; 64],
+    };
+    a.sign(&sk(recipient));
+    a.encode()
+}
+
+fn req(use_: Use, requester: u8, named: &[[u8; 33]]) -> UseRequest<'_> {
+    UseRequest {
+        use_,
+        requester: pk(requester),
+        named_recipients: named,
+        now: NOW + 100,
+        newest_consent_version: 1,
+        parent: None,
+    }
+}
+
+struct World {
+    meaning_a: [u8; 32],
+    consent_a: Verified<Consent>,
+    capsule_a: Verified<Capsule>,
+    consent_b: Verified<Consent>,
+    capsule_b: Verified<Capsule>,
+    named: Vec<[u8; 33]>,
+}
+
+fn world() -> World {
+    let meaning_a = sha(b"om: claim mean_milli(readings) is exact for 6 sensors");
+    let consent_a = open_consent(&consent(
+        OWNER_A,
+        meaning_a,
+        perm::DISCOVER | perm::READ | perm::TRAIN,
+        &[CUSTODIAN],
+        1,
+    ))
+    .unwrap();
+    let capsule_a = open_capsule(&signed_capsule(
+        capsule_base(meaning_a, consent_a.digest()),
+        OWNER_A,
+    ))
+    .unwrap();
+    let meaning_b = sha(b"om: procedure heater_duty_cycle(limit)");
+    let consent_b = open_consent(&consent(
+        OWNER_B,
+        meaning_b,
+        perm::DISCOVER | perm::READ,
+        &[],
+        1,
+    ))
+    .unwrap();
+    let mut cb = capsule_base(meaning_b, consent_b.digest());
+    cb.share_scope = scope::PUBLIC;
+    cb.permissions = perm::DISCOVER | perm::READ;
+    cb.recipient_set_digest = [0; 32];
+    let capsule_b = open_capsule(&signed_capsule(cb, OWNER_B)).unwrap();
+    World {
+        meaning_a,
+        consent_a,
+        capsule_a,
+        consent_b,
+        capsule_b,
+        named: vec![pk(R2), pk(R1)],
+    }
+}
+
+#[test]
+fn two_owner_publish_audit_revoke_lifecycle() {
+    let w = world();
+    let mut chain_a_r1 = OwnerChain::new(&w.consent_a);
+    let chain_b_r1 = OwnerChain::new(&w.consent_b);
+    let chain_a_r2 = OwnerChain::new(&w.consent_a);
+
+    // Publish and recipient audit.
+    let serve = req(Use::Serve, R1, &w.named);
+    check_use(&w.capsule_a, Some(&w.consent_a), &chain_a_r1, &serve).unwrap();
+    check_use(
+        &w.capsule_a,
+        Some(&w.consent_a),
+        &chain_a_r1,
+        &req(Use::Train, R1, &w.named),
+    )
+    .unwrap();
+    assert_eq!(
+        check_use(
+            &w.capsule_a,
+            Some(&w.consent_a),
+            &chain_a_r1,
+            &req(Use::Republish, R1, &w.named)
+        ),
+        Err(Refusal::NotPermitted)
+    );
+    assert_eq!(
+        check_use(
+            &w.capsule_a,
+            Some(&w.consent_a),
+            &chain_a_r1,
+            &req(Use::Serve, R3, &w.named)
+        ),
+        Err(Refusal::NotRecipient)
+    );
+    check_use(
+        &w.capsule_b,
+        Some(&w.consent_b),
+        &chain_b_r1,
+        &req(Use::Serve, R3, &[]),
+    )
+    .unwrap();
+
+    // R1 runs its own verifier on its own platform before any execution.
+    let platform = d(0xF1);
+    let verdict = RecipientVerdict {
+        capsule_digest: w.capsule_a.digest(),
+        platform_digest: platform,
+        verifier_key: pk(R1_VERIFIER),
+        passed: true,
+    };
+    let granted = cap::CPU_COMPUTE | cap::CORTEX_READ;
+    let adm = admit_execution(&w.capsule_a, &verdict, platform, granted).unwrap();
+    assert_eq!(adm.capabilities, granted);
+
+    // Revocation by owner A, sent to R1 and R2.
+    let r1_bytes = retraction(
+        OWNER_A,
+        OWNER_A,
+        1,
+        [0; 32],
+        w.capsule_a.digest(),
+        retract::RETRIEVAL | retract::TRAINING,
+    );
+    let r1 = open_retraction(&r1_bytes).unwrap();
+    let mut tracker = RetractionTracker::new(&r1, &[pk(R1), pk(R2)]);
+    assert_eq!(chain_a_r1.apply(&r1), Ok(Applied::New));
+    assert_eq!(chain_a_r1.apply(&r1), Ok(Applied::Replay));
+    let a1 = open_ack(&ack(R1, r1.digest(), ack_status::ENFORCED)).unwrap();
+    assert_eq!(tracker.apply_ack(&a1), Ok(Applied::New));
+    assert_eq!(tracker.apply_ack(&a1), Ok(Applied::Replay));
+
+    // Subsequent retrieval and training at R1 refuse; owner B is unaffected.
+    assert_eq!(
+        check_use(&w.capsule_a, Some(&w.consent_a), &chain_a_r1, &serve),
+        Err(Refusal::Revoked)
+    );
+    assert_eq!(
+        check_use(
+            &w.capsule_a,
+            Some(&w.consent_a),
+            &chain_a_r1,
+            &req(Use::Train, R1, &w.named)
+        ),
+        Err(Refusal::Revoked)
+    );
+    check_use(
+        &w.capsule_b,
+        Some(&w.consent_b),
+        &chain_b_r1,
+        &req(Use::Serve, R1, &[]),
+    )
+    .unwrap();
+
+    // R2 is offline: it is PENDING, never shown as acknowledged or erased.
+    assert_eq!(tracker.status(&pk(R2)), Some(Delivery::Pending));
+    assert_eq!(tracker.pending(), vec![pk(R2)]);
+    assert!(!tracker.all_acknowledged());
+    tracker.mark_unreachable(&pk(R2)).unwrap();
+    assert_eq!(tracker.status(&pk(R2)), Some(Delivery::Unreachable));
+    assert!(!tracker.all_acknowledged());
+    // An unreachable acknowledged recipient keeps its ack.
+    tracker.mark_unreachable(&pk(R1)).unwrap();
+    assert!(matches!(
+        tracker.status(&pk(R1)),
+        Some(Delivery::Acknowledged {
+            status: ack_status::ENFORCED,
+            ..
+        })
+    ));
+
+    // A new capsule revision signed after the retraction: R1 (synced) may
+    // serve it; R2 (behind) must sync first.
+    let meaning_v2 = sha(b"om: claim mean_milli(readings) is exact for 6 sensors, v2");
+    let consent_v2 = open_consent(&consent(
+        OWNER_A,
+        meaning_v2,
+        perm::DISCOVER | perm::READ | perm::TRAIN,
+        &[CUSTODIAN],
+        1,
+    ))
+    .unwrap();
+    let mut c2 = capsule_base(meaning_v2, consent_v2.digest());
+    c2.revocation_seq = 1;
+    c2.revocation_head = r1.digest();
+    let capsule_v2 = open_capsule(&signed_capsule(c2, OWNER_A)).unwrap();
+    check_use(&capsule_v2, Some(&consent_v2), &chain_a_r1, &serve).unwrap();
+    assert_eq!(
+        check_use(
+            &capsule_v2,
+            Some(&consent_v2),
+            &chain_a_r2,
+            &req(Use::Serve, R2, &w.named)
+        ),
+        Err(Refusal::Stale)
+    );
+}
+
+#[test]
+fn retained_copies_are_reported_not_hidden() {
+    let w = world();
+    let r = open_retraction(&retraction(
+        OWNER_A,
+        OWNER_A,
+        1,
+        [0; 32],
+        w.capsule_a.digest(),
+        retract::TRAINING,
+    ))
+    .unwrap();
+    let mut tracker = RetractionTracker::new(&r, &[pk(R1), pk(R2)]);
+    let a = open_ack(&ack(R1, r.digest(), ack_status::ENFORCED_WITH_RETAINED)).unwrap();
+    tracker.apply_ack(&a).unwrap();
+    assert_eq!(tracker.retained(), vec![pk(R1)]);
+    // A different second ack from the same recipient fails closed.
+    let other = open_ack(&ack(R1, r.digest(), ack_status::ENFORCED)).unwrap();
+    assert_eq!(tracker.apply_ack(&other), Err(Refusal::Conflict));
+    // An ack from a key the retraction was not sent to.
+    let stranger = open_ack(&ack(R3, r.digest(), ack_status::ENFORCED)).unwrap();
+    assert_eq!(tracker.apply_ack(&stranger), Err(Refusal::NotRecipient));
+    // An ack for another retraction.
+    let wrong = open_ack(&ack(R2, d(0x99), ack_status::ENFORCED)).unwrap();
+    assert_eq!(tracker.apply_ack(&wrong), Err(Refusal::Conflict));
+    // A forged ack.
+    let mut bytes = ack(R2, r.digest(), ack_status::ENFORCED);
+    bytes[9] ^= 1;
+    assert_eq!(open_ack(&bytes).err(), Some(Refusal::BadSignature));
+}
+
+#[test]
+fn retraction_chain_fails_closed() {
+    let w = world();
+    let mut chain = OwnerChain::new(&w.consent_a);
+    let target = w.capsule_a.digest();
+    let first = open_retraction(&retraction(
+        OWNER_A,
+        OWNER_A,
+        1,
+        [0; 32],
+        target,
+        retract::RETRIEVAL,
+    ))
+    .unwrap();
+    chain.apply(&first).unwrap();
+    // Concurrent conflicting operation: another seq 1.
+    let other1 = open_retraction(&retraction(
+        OWNER_A,
+        OWNER_A,
+        1,
+        [0; 32],
+        target,
+        retract::TRAINING,
+    ))
+    .unwrap();
+    assert_eq!(chain.apply(&other1), Err(Refusal::Conflict));
+    // Gap.
+    let gap = open_retraction(&retraction(
+        OWNER_A,
+        OWNER_A,
+        3,
+        first.digest(),
+        target,
+        retract::TRAINING,
+    ))
+    .unwrap();
+    assert_eq!(chain.apply(&gap), Err(Refusal::Conflict));
+    // Wrong previous head.
+    let fork = open_retraction(&retraction(
+        OWNER_A,
+        OWNER_A,
+        2,
+        d(0x55),
+        target,
+        retract::TRAINING,
+    ))
+    .unwrap();
+    assert_eq!(chain.apply(&fork), Err(Refusal::Conflict));
+    // A key that is neither the owner nor a declared custodian.
+    let rogue = open_retraction(&retraction(
+        OWNER_A,
+        R3,
+        2,
+        first.digest(),
+        target,
+        retract::TRAINING,
+    ))
+    .unwrap();
+    assert_eq!(chain.apply(&rogue), Err(Refusal::UnknownCustodian));
+    // The declared custodian may continue the chain.
+    let by_custodian = open_retraction(&retraction(
+        OWNER_A,
+        CUSTODIAN,
+        2,
+        first.digest(),
+        target,
+        retract::TRAINING,
+    ))
+    .unwrap();
+    assert_eq!(chain.apply(&by_custodian), Ok(Applied::New));
+    assert_eq!(chain.head_seq(), 2);
+    // Another owner's retraction does not enter this chain.
+    let foreign = open_retraction(&retraction(
+        OWNER_B,
+        OWNER_B,
+        3,
+        by_custodian.digest(),
+        target,
+        1,
+    ))
+    .unwrap();
+    assert_eq!(chain.apply(&foreign), Err(Refusal::OwnerMismatch));
+    // A capsule whose revocation head disagrees with the chain is a fork.
+    let mut c = capsule_base(w.meaning_a, w.consent_a.digest());
+    c.revocation_seq = 1;
+    c.revocation_head = d(0x44);
+    let forked = open_capsule(&signed_capsule(c, OWNER_A)).unwrap();
+    assert_eq!(
+        check_use(
+            &forked,
+            Some(&w.consent_a),
+            &chain,
+            &req(Use::Serve, R1, &w.named)
+        ),
+        Err(Refusal::Conflict)
+    );
+}
+
+#[test]
+fn erasure_claims_are_refused() {
+    let w = world();
+    let mut bytes = retraction(
+        OWNER_A,
+        OWNER_A,
+        1,
+        [0; 32],
+        w.capsule_a.digest(),
+        retract::ALL,
+    );
+    bytes[6] = 1;
+    assert_eq!(decode(&bytes).err(), Some(Refusal::FalseErasureClaim));
+}
+
+#[test]
+fn edited_capsules_and_consents_fail_signature() {
+    let w = world();
+    let mut bytes = w.capsule_a.get().encode();
+    bytes[16 + 3] |= cap::GPU_COMPUTE as u8; // quietly ask for the GPU
+    assert_eq!(open_capsule(&bytes).err(), Some(Refusal::BadSignature));
+    let mut bytes = w.consent_a.get().encode();
+    bytes[5] |= perm::REDISTRIBUTE;
+    assert_eq!(open_consent(&bytes).err(), Some(Refusal::BadSignature));
+    // Re-signed by someone else: the owner key no longer matches the chain.
+    let mut stolen = w.capsule_a.get().clone();
+    stolen.sign(&sk(R3));
+    let stolen = open_capsule(&stolen.encode()).unwrap();
+    let chain = OwnerChain::new(&w.consent_a);
+    assert_eq!(
+        check_use(
+            &stolen,
+            Some(&w.consent_a),
+            &chain,
+            &req(Use::Serve, R1, &w.named)
+        ),
+        Err(Refusal::OwnerMismatch)
+    );
+}
+
+#[test]
+fn capsule_never_authorizes_itself() {
+    let w = world();
+    let platform = d(0xF1);
+    let granted = cap::ALL;
+    let mut v = RecipientVerdict {
+        capsule_digest: w.capsule_a.digest(),
+        platform_digest: platform,
+        verifier_key: pk(OWNER_A),
+        passed: true,
+    };
+    assert_eq!(
+        admit_execution(&w.capsule_a, &v, platform, granted),
+        Err(Refusal::SelfAuthorized)
+    );
+    v.verifier_key = pk(R1_VERIFIER);
+    v.passed = false;
+    assert_eq!(
+        admit_execution(&w.capsule_a, &v, platform, granted),
+        Err(Refusal::Unverified)
+    );
+    v.passed = true;
+    assert_eq!(
+        admit_execution(&w.capsule_a, &v, d(0xF2), granted),
+        Err(Refusal::Unverified)
+    );
+    v.capsule_digest = w.capsule_b.digest();
+    assert_eq!(
+        admit_execution(&w.capsule_a, &v, platform, granted),
+        Err(Refusal::Unverified)
+    );
+    v.capsule_digest = w.capsule_a.digest();
+    assert_eq!(
+        admit_execution(&w.capsule_a, &v, platform, cap::CPU_COMPUTE),
+        Err(Refusal::CapabilityDenied)
+    );
+}
+
+#[test]
+fn permission_amplification_is_refused() {
+    let w = world();
+    // The consent allows READ only; the capsule claims TRAIN as well.
+    let narrow = open_consent(&consent(OWNER_A, w.meaning_a, perm::READ, &[], 1)).unwrap();
+    let wide = open_capsule(&signed_capsule(
+        capsule_base(w.meaning_a, narrow.digest()),
+        OWNER_A,
+    ))
+    .unwrap();
+    let chain = OwnerChain::new(&narrow);
+    assert_eq!(
+        check_use(&wide, Some(&narrow), &chain, &req(Use::Serve, R1, &w.named)),
+        Err(Refusal::PermissionAmplification)
+    );
+    // A derived capsule may not be wider than its parent.
+    let mut parent = capsule_base(w.meaning_a, w.consent_a.digest());
+    parent.permissions = perm::DISCOVER | perm::READ;
+    let parent = open_capsule(&signed_capsule(parent, OWNER_A)).unwrap();
+    let mut child = capsule_base(w.meaning_a, w.consent_a.digest());
+    child.parent_capsule = parent.digest();
+    let child = open_capsule(&signed_capsule(child, OWNER_A)).unwrap();
+    let chain = OwnerChain::new(&w.consent_a);
+    let mut r = req(Use::Serve, R1, &w.named);
+    assert_eq!(
+        check_use(&child, Some(&w.consent_a), &chain, &r),
+        Err(Refusal::UnknownParent)
+    );
+    r.parent = Some(&parent);
+    assert_eq!(
+        check_use(&child, Some(&w.consent_a), &chain, &r),
+        Err(Refusal::PermissionAmplification)
+    );
+}
+
+#[test]
+fn consent_binding_scope_time_and_staleness() {
+    let w = world();
+    let chain = OwnerChain::new(&w.consent_a);
+    let r = req(Use::Serve, R1, &w.named);
+    // Missing or wrong consent.
+    assert_eq!(
+        check_use(&w.capsule_a, None, &chain, &r),
+        Err(Refusal::NoConsent)
+    );
+    let other = open_consent(&consent(OWNER_A, d(0x01), perm::ALL, &[], 1)).unwrap();
+    assert_eq!(
+        check_use(&w.capsule_a, Some(&other), &chain, &r),
+        Err(Refusal::NoConsent)
+    );
+    // Consent from another owner.
+    assert_eq!(
+        check_use(&w.capsule_a, Some(&w.consent_b), &chain, &r),
+        Err(Refusal::OwnerMismatch)
+    );
+    // Expired capsule.
+    let mut late = r.clone();
+    late.now = w.capsule_a.get().expires_at + 1;
+    assert_eq!(
+        check_use(&w.capsule_a, Some(&w.consent_a), &chain, &late),
+        Err(Refusal::Expired)
+    );
+    // A newer consent version for the fragment is known.
+    let mut newer = r.clone();
+    newer.newest_consent_version = 2;
+    assert_eq!(
+        check_use(&w.capsule_a, Some(&w.consent_a), &chain, &newer),
+        Err(Refusal::Stale)
+    );
+    // Named list that does not match the digest the capsule binds.
+    let wrong_list = vec![pk(R1), pk(R3)];
+    assert_eq!(
+        check_use(
+            &w.capsule_a,
+            Some(&w.consent_a),
+            &chain,
+            &req(Use::Serve, R1, &wrong_list)
+        ),
+        Err(Refusal::NotRecipient)
+    );
+}
+
+#[test]
+fn private_is_the_default_and_stays_with_the_owner() {
+    let w = world();
+    let mut c = capsule_base(w.meaning_a, [0; 32]);
+    c.share_scope = scope::PRIVATE;
+    c.permissions = 0;
+    c.recipient_set_digest = [0; 32];
+    let private = open_capsule(&signed_capsule(c, OWNER_A)).unwrap();
+    let chain = OwnerChain::new(&w.consent_a);
+    assert_eq!(
+        check_use(&private, None, &chain, &req(Use::Serve, R1, &[])),
+        Err(Refusal::Private)
+    );
+    check_use(&private, None, &chain, &req(Use::Serve, OWNER_A, &[])).unwrap();
+}
+
+#[test]
+fn unknown_license_scope_and_versions_fail_closed() {
+    let w = world();
+    let mut bytes = w.capsule_a.get().encode();
+    bytes[9] = 9;
+    assert_eq!(decode(&bytes).err(), Some(Refusal::UnknownLicense));
+    let mut bytes = w.capsule_a.get().encode();
+    bytes[5] = 7;
+    assert_eq!(decode(&bytes).err(), Some(Refusal::BadEnum));
+    let mut bytes = w.capsule_a.get().encode();
+    bytes[4] = 2;
+    assert_eq!(decode(&bytes).err(), Some(Refusal::BadVersion));
+    assert_eq!(decode(&bytes[..600]).err(), Some(Refusal::BadVersion));
+    bytes[4] = 1;
+    assert_eq!(decode(&bytes[..600]).err(), Some(Refusal::BadLength));
+}
+
+#[test]
+fn private_bytes_never_appear_in_records() {
+    let w = world();
+    let r = retraction(
+        OWNER_A,
+        OWNER_A,
+        1,
+        [0; 32],
+        w.capsule_a.digest(),
+        retract::ALL,
+    );
+    let a = ack(R1, sha(&r), ack_status::ENFORCED);
+    let records = [
+        w.capsule_a.get().encode(),
+        w.consent_a.get().encode(),
+        r,
+        a,
+        lineage(OWNER_A, sha(PRIVATE_TRACE), d(0xD1), &[], &[]),
+    ];
+    for rec in &records {
+        assert!(
+            !rec.windows(PRIVATE_TRACE.len())
+                .any(|win| win == PRIVATE_TRACE),
+            "private trace bytes leaked into a record"
+        );
+        assert!(!rec.windows(6).any(|win| win == b"142/91"));
+    }
+    assert_eq!(w.consent_a.get().payload_digest, sha(PRIVATE_TRACE));
+}
+
+fn lineage(
+    owner: u8,
+    content: [u8; 32],
+    dataset: [u8; 32],
+    parents: &[[u8; 32]],
+    influenced: &[[u8; 32]],
+) -> Vec<u8> {
+    let mut l = Lineage {
+        content_digest: content,
+        dataset_id: dataset,
+        consent_ref: d(0xCC),
+        parents: parents.to_vec(),
+        influenced: influenced.to_vec(),
+        owner_key: [0; 33],
+        signature: [0; 64],
+    };
+    l.sign(&sk(owner));
+    l.encode()
+}
+
+#[test]
+fn lineage_withdrawal_blocks_training_and_marks_descendants() {
+    let w = world();
+    let ds = d(0xD1);
+    let (e1, e2, e3, e4) = (sha(b"exp-1"), sha(b"exp-2"), sha(b"exp-3"), sha(b"exp-4"));
+    let (ckpt_x, capsule_y, ckpt_z) = (d(0xE1), d(0xE2), d(0xE3));
+    let mut idx = LineageIndex::new();
+    for bytes in [
+        lineage(OWNER_A, e1, ds, &[], &[]),
+        lineage(OWNER_A, e2, ds, &[e1], &[ckpt_z]),
+        lineage(OWNER_A, e3, ds, &[e2], &[ckpt_x]),
+        lineage(OWNER_A, e4, ds, &[e1], &[capsule_y]),
+    ] {
+        assert_eq!(idx.add(&open_lineage(&bytes).unwrap()), Ok(Applied::New));
+    }
+    let mut chain = OwnerChain::new(&w.consent_a);
+    idx.training_eligible(&e3, &[&chain], NOW).unwrap();
+
+    // The owner withdraws experience e1 from training.
+    let r = open_retraction(&retraction(
+        OWNER_A,
+        OWNER_A,
+        1,
+        [0; 32],
+        e1,
+        retract::TRAINING,
+    ))
+    .unwrap();
+    chain.apply(&r).unwrap();
+    assert_eq!(
+        idx.training_eligible(&e3, &[&chain], NOW),
+        Err(Refusal::Revoked)
+    );
+    assert_eq!(
+        idx.training_eligible(&e1, &[&chain], NOW),
+        Err(Refusal::Revoked)
+    );
+    // Every checkpoint and capsule influenced downstream is marked affected.
+    let mut want = vec![ckpt_x, capsule_y, ckpt_z];
+    want.sort();
+    assert_eq!(idx.affected(&e1), want);
+    assert_eq!(idx.affected(&e3), vec![ckpt_x]);
+    // No owner chain known for an ancestor: fail closed.
+    assert_eq!(idx.training_eligible(&e3, &[], NOW), Err(Refusal::Stale));
+}
+
+#[test]
+fn lineage_duplicate_cross_dataset_cycle_and_unknown_parent() {
+    let ds = d(0xD1);
+    let (e1, e2) = (sha(b"exp-1"), sha(b"exp-2"));
+    let mut idx = LineageIndex::new();
+    let first = lineage(OWNER_A, e1, ds, &[], &[]);
+    idx.add(&open_lineage(&first).unwrap()).unwrap();
+    assert_eq!(idx.add(&open_lineage(&first).unwrap()), Ok(Applied::Replay));
+    let dup = lineage(OWNER_A, e1, ds, &[], &[d(0xE9)]);
+    assert_eq!(
+        idx.add(&open_lineage(&dup).unwrap()),
+        Err(Refusal::Duplicate)
+    );
+    // Injection from another dataset.
+    let inject = lineage(OWNER_A, e2, d(0xD2), &[e1], &[]);
+    assert_eq!(
+        idx.add(&open_lineage(&inject).unwrap()),
+        Err(Refusal::CrossDataset)
+    );
+    // Ancestor cycle across records: a -> b (unknown yet), then b -> a.
+    let (a, b) = (sha(b"exp-a"), sha(b"exp-b"));
+    idx.add(&open_lineage(&lineage(OWNER_A, a, ds, &[b], &[])).unwrap())
+        .unwrap();
+    assert_eq!(
+        idx.add(&open_lineage(&lineage(OWNER_A, b, ds, &[a], &[])).unwrap()),
+        Err(Refusal::AncestorCycle)
+    );
+    // `a` names a parent this node does not hold.
+    let w = world();
+    let chain = OwnerChain::new(&w.consent_a);
+    assert_eq!(
+        idx.training_eligible(&a, &[&chain], NOW),
+        Err(Refusal::UnknownParent)
+    );
+}
diff --git a/crates/aien-discovery-capsule/tests/vectors.rs b/crates/aien-discovery-capsule/tests/vectors.rs
new file mode 100644
index 0000000..4a4db60
--- /dev/null
+++ b/crates/aien-discovery-capsule/tests/vectors.rs
@@ -0,0 +1,56 @@
+//! Walks `specs/discovery-capsule/vectors/expected.txt` and requires the Rust reader to
+//! print the same verdict line as the C reference checker
+//! (`tools/dcp_verify.c`) for every file, and to write every accepted record
+//! back out as the identical bytes.
+
+use std::path::PathBuf;
+
+use aien_discovery_capsule::{decode, verdict_line};
+
+fn vectors_dir() -> PathBuf {
+    PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../specs/discovery-capsule/vectors")
+}
+
+#[test]
+fn every_expected_line_matches_the_c_checker() {
+    let dir = vectors_dir();
+    let list = std::fs::read_to_string(dir.join("expected.txt")).expect("read expected.txt");
+    let mut checked = 0usize;
+    let mut accepted = 0usize;
+    let mut failures = Vec::new();
+    for line in list.lines() {
+        if line.is_empty() || line.starts_with('#') {
+            continue;
+        }
+        let (name, want) = line
+            .split_once(' ')
+            .expect("line has a file name and a verdict");
+        let bytes = std::fs::read(dir.join(name)).expect("read vector");
+        let got = verdict_line(&bytes);
+        if got != want {
+            failures.push(format!("{name}\n  expected: {want}\n  got:      {got}"));
+        }
+        if let Ok(record) = decode(&bytes) {
+            let again = record.encode();
+            if again != bytes {
+                failures.push(format!("{name}: round trip gave different bytes"));
+            }
+            accepted += 1;
+        }
+        checked += 1;
+    }
+    assert!(
+        failures.is_empty(),
+        "{} of {checked} vectors differ:\n{}",
+        failures.len(),
+        failures.join("\n")
+    );
+    assert!(
+        checked >= 90,
+        "expected at least 90 vectors, found {checked}"
+    );
+    assert!(
+        accepted >= 13,
+        "expected at least 13 accepted vectors, found {accepted}"
+    );
+}
diff --git a/crates/aien-microjob/.crumb b/crates/aien-microjob/.crumb
new file mode 100644
index 0000000..a462799
--- /dev/null
+++ b/crates/aien-microjob/.crumb
@@ -0,0 +1,6 @@
+{
+  "layer": "crates/aien-microjob",
+  "name": "crates/aien-microjob",
+  "purpose": "MJB1 microjob DAG reader, writer and checker that must match the C checker, plus the MJR1 receipt ledger",
+  "schema_version": "1.0.0"
+}
diff --git a/crates/aien-microjob/Cargo.toml b/crates/aien-microjob/Cargo.toml
new file mode 100644
index 0000000..043578b
--- /dev/null
+++ b/crates/aien-microjob/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "aien-microjob"
+version = "0.1.0"
+edition = "2021"
+license = "Apache-2.0"
+description = "MJB1 typed bounded microjob DAG and MJR1 receipt: reader, writer, checker and receipt ledger (specs/microjob)"
+
+[dependencies]
+aien-provenance = { path = "../aien-provenance" }
+p256 = { workspace = true }
+sha2 = { workspace = true }
diff --git a/crates/aien-microjob/src/.crumb b/crates/aien-microjob/src/.crumb
new file mode 100644
index 0000000..05ded4a
--- /dev/null
+++ b/crates/aien-microjob/src/.crumb
@@ -0,0 +1,6 @@
+{
+  "layer": "crates/aien-microjob/src",
+  "name": "crates/aien-microjob/src",
+  "purpose": "MJB1 decode, encode, canonical order and verdict line; MJR1 receipts, signatures and the DagRun ledger",
+  "schema_version": "1.0.0"
+}
diff --git a/crates/aien-microjob/src/lib.rs b/crates/aien-microjob/src/lib.rs
new file mode 100644
index 0000000..8145956
--- /dev/null
+++ b/crates/aien-microjob/src/lib.rs
@@ -0,0 +1,1229 @@
+//! MJB1, the typed bounded microjob DAG, and MJR1, its receipt.
+//!
+//! Spec: `specs/microjob/SPEC.md` (Draft v0.1, contract 0.1.0, wire version
+//! 1). The C reference checker is `specs/microjob/tools/mjb_verify.c`; this
+//! crate gives the same verdict on the same document bytes (the test in
+//! `tests/vectors.rs` walks the shared vectors).
+//!
+//! A valid document is a proposal, not an authorization, and a node is not a
+//! receipt. [`DagRun`] is the receipt ledger of section 5: it derives node
+//! state from accepted bytes and chooses nothing (it is not a scheduler).
+#![forbid(unsafe_code)]
+
+use aien_provenance::{p256_compressed_key, p256_sign_low_s, p256_verify_low_s};
+use p256::ecdsa::SigningKey;
+use sha2::{Digest, Sha256};
+
+/// Bytes in the document header.
+pub const HEADER_LEN: usize = 192;
+/// Bytes in one node record.
+pub const NODE_LEN: usize = 448;
+/// Most nodes in one document.
+pub const MAX_NODES: usize = 64;
+/// Dependency slots per node.
+pub const MAX_DEPS: usize = 8;
+/// Operand slots per node.
+pub const MAX_OPERANDS: usize = 4;
+/// Largest document.
+pub const MAX_DOCUMENT: usize = HEADER_LEN + MAX_NODES * NODE_LEN;
+/// The four bytes that open a document.
+pub const MAGIC: [u8; 4] = *b"MJB1";
+/// The four bytes that open a receipt.
+pub const RECEIPT_MAGIC: [u8; 4] = *b"MJR1";
+/// The only wire version.
+pub const VERSION: u8 = 1;
+/// Bytes in one receipt.
+pub const RECEIPT_LEN: usize = 404;
+/// Bytes of a receipt covered by its signature and its digest.
+pub const RECEIPT_SIGNED_LEN: usize = 340;
+
+/// Node `kind` values.
+pub mod kind {
+    pub const COMPUTE: u8 = 1;
+    pub const NEURAL: u8 = 2;
+}
+/// COMPUTE `op` values.
+pub mod compute_op {
+    pub const ARITH: u8 = 1;
+    pub const MATMUL: u8 = 2;
+    pub const REDUCE: u8 = 3;
+    pub const COMPARE: u8 = 4;
+    pub const COMPILE: u8 = 5;
+    pub const VERIFY: u8 = 6;
+}
+/// NEURAL `op` values.
+pub mod neural_op {
+    pub const ROUTE: u8 = 1;
+    pub const EXTRACT: u8 = 2;
+    pub const PROPOSE: u8 = 3;
+    pub const SUMMARIZE: u8 = 4;
+}
+/// Token `profile` values (section 4.3).
+pub mod profile {
+    pub const ZERO: u8 = 0;
+    pub const MINIMAL: u8 = 1;
+    pub const DEFAULT: u8 = 2;
+    pub const LARGE: u8 = 3;
+    pub const SPECIALIST: u8 = 4;
+}
+/// `effect_class` and `effect_ceiling` values (same as PST1).
+pub mod effect {
+    pub const NONE: u8 = 0;
+    pub const COMPUTE: u8 = 1;
+    pub const EFFECT: u8 = 2;
+}
+/// `verifier_kind` values.
+pub mod verifier {
+    pub const RECOMPUTE: u8 = 1;
+    pub const CHECKER: u8 = 2;
+    pub const JUDGE: u8 = 3;
+}
+/// `retry_class` values.
+pub mod retry {
+    pub const NEVER: u8 = 1;
+    pub const IDEMPOTENT: u8 = 2;
+    pub const RECONCILE_FIRST: u8 = 3;
+}
+/// `cancel_mode` values.
+pub mod cancel {
+    pub const DISCARD: u8 = 1;
+    pub const CHECKPOINT: u8 = 2;
+}
+/// Operand `kind` values.
+pub mod operand {
+    pub const CORTEX_STATE: u8 = 1;
+    pub const WORLD_STATE: u8 = 2;
+    pub const CONTENT: u8 = 3;
+    pub const CAPSULE: u8 = 4;
+    pub const EXPERIENCE: u8 = 5;
+}
+/// Receipt `outcome` values.
+pub mod outcome {
+    pub const COMPLETED: u8 = 1;
+    pub const REFUSED: u8 = 2;
+    pub const FAILED: u8 = 3;
+    pub const CANCELLED: u8 = 4;
+    pub const UNCERTAIN: u8 = 5;
+}
+
+/// Input and output token caps of a profile, `None` for an unknown profile.
+pub fn profile_caps(p: u8) -> Option<(u16, u16)> {
+    match p {
+        profile::ZERO => Some((0, 0)),
+        profile::MINIMAL => Some((64, 16)),
+        profile::DEFAULT => Some((128, 32)),
+        profile::LARGE => Some((256, 64)),
+        profile::SPECIALIST => Some((512, 128)),
+        _ => None,
+    }
+}
+
+/// A refusal code from SPEC.md section 6.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Refusal {
+    BadLength,
+    BadMagic,
+    Downgrade,
+    BadVersion,
+    BadCount,
+    ReservedNonzero,
+    BadEnum,
+    NoObjective,
+    NoTenant,
+    NoSubject,
+    NoApproval,
+    BadExpiry,
+    NoJob,
+    CrossTenant,
+    NoCapability,
+    UnauthorizedEffect,
+    NoVerifier,
+    Impure,
+    TokenProfile,
+    NeedsExpansion,
+    BadRetry,
+    ZeroCap,
+    MissingOperand,
+    DuplicateJob,
+    MissingDep,
+    StaleGeneration,
+    Cycle,
+    OverBudget,
+    BadReceipt,
+    ForgedReceipt,
+    WrongDag,
+    UnknownJob,
+    ModelMismatch,
+    ReceiptOverBudget,
+    DepNotDone,
+    BindingMismatch,
+    DoubleCommit,
+    Cancelled,
+}
+
+impl Refusal {
+    /// The code name as written in SPEC.md and printed by the C checker.
+    pub fn name(self) -> &'static str {
+        match self {
+            Refusal::BadLength => "MJB_BAD_LENGTH",
+            Refusal::BadMagic => "MJB_BAD_MAGIC",
+            Refusal::Downgrade => "MJB_DOWNGRADE",
+            Refusal::BadVersion => "MJB_BAD_VERSION",
+            Refusal::BadCount => "MJB_BAD_COUNT",
+            Refusal::ReservedNonzero => "MJB_RESERVED_NONZERO",
+            Refusal::BadEnum => "MJB_BAD_ENUM",
+            Refusal::NoObjective => "MJB_NO_OBJECTIVE",
+            Refusal::NoTenant => "MJB_NO_TENANT",
+            Refusal::NoSubject => "MJB_NO_SUBJECT",
+            Refusal::NoApproval => "MJB_NO_APPROVAL",
+            Refusal::BadExpiry => "MJB_BAD_EXPIRY",
+            Refusal::NoJob => "MJB_NO_JOB",
+            Refusal::CrossTenant => "MJB_CROSS_TENANT",
+            Refusal::NoCapability => "MJB_NO_CAPABILITY",
+            Refusal::UnauthorizedEffect => "MJB_UNAUTHORIZED_EFFECT",
+            Refusal::NoVerifier => "MJB_NO_VERIFIER",
+            Refusal::Impure => "MJB_IMPURE",
+            Refusal::TokenProfile => "MJB_TOKEN_PROFILE",
+            Refusal::NeedsExpansion => "MJB_NEEDS_EXPANSION",
+            Refusal::BadRetry => "MJB_BAD_RETRY",
+            Refusal::ZeroCap => "MJB_ZERO_CAP",
+            Refusal::MissingOperand => "MJB_MISSING_OPERAND",
+            Refusal::DuplicateJob => "MJB_DUPLICATE_JOB",
+            Refusal::MissingDep => "MJB_MISSING_DEP",
+            Refusal::StaleGeneration => "MJB_STALE_GENERATION",
+            Refusal::Cycle => "MJB_CYCLE",
+            Refusal::OverBudget => "MJB_OVER_BUDGET",
+            Refusal::BadReceipt => "MJB_BAD_RECEIPT",
+            Refusal::ForgedReceipt => "MJB_FORGED_RECEIPT",
+            Refusal::WrongDag => "MJB_WRONG_DAG",
+            Refusal::UnknownJob => "MJB_UNKNOWN_JOB",
+            Refusal::ModelMismatch => "MJB_MODEL_MISMATCH",
+            Refusal::ReceiptOverBudget => "MJB_RECEIPT_OVER_BUDGET",
+            Refusal::DepNotDone => "MJB_DEP_NOT_DONE",
+            Refusal::BindingMismatch => "MJB_BINDING_MISMATCH",
+            Refusal::DoubleCommit => "MJB_DOUBLE_COMMIT",
+            Refusal::Cancelled => "MJB_CANCELLED",
+        }
+    }
+}
+
+/// The document header (section 4.1).
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Header {
+    pub effect_ceiling: u8,
+    pub objective_id: [u8; 32],
+    pub tenant_id: [u8; 32],
+    pub subject_id: [u8; 32],
+    pub approval_ref: [u8; 32],
+    pub incarnation: u32,
+    pub expires_at: u64,
+    pub budget_time_ms: u64,
+    pub budget_fuel: u64,
+    pub budget_memory: u64,
+    pub budget_work: u64,
+    pub budget_input_tokens: u32,
+    pub budget_output_tokens: u32,
+}
+
+/// One dependency slot: a node of the same document and the generation of
+/// that node this node was planned against.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct Dep {
+    pub index: u16,
+    pub generation: u32,
+}
+
+/// One typed operand reference.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct Operand {
+    pub kind: u8,
+    pub generation: u32,
+    pub digest: [u8; 32],
+}
+
+/// One node record (section 4.2). `deps` and `operands` hold the used slots.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Node {
+    pub job_id: [u8; 16],
+    pub idempotence_key: [u8; 16],
+    pub generation: u32,
+    pub kind: u8,
+    pub op: u8,
+    pub profile: u8,
+    pub effect_class: u8,
+    pub input_tokens: u16,
+    pub output_tokens: u16,
+    pub required_input_tokens: u16,
+    pub required_output_tokens: u16,
+    pub verifier_kind: u8,
+    pub retry_class: u8,
+    pub max_attempts: u8,
+    pub cancel_mode: u8,
+    pub precision: u8,
+    pub substrate_mask: u8,
+    pub result_type: u8,
+    pub result_rank: u8,
+    pub pure: bool,
+    pub time_ms: u32,
+    pub fuel: u64,
+    pub memory: u64,
+    pub work: u64,
+    pub expires_at: u64,
+    pub result_dims: [u32; 4],
+    pub capability_ref: [u8; 32],
+    pub tenant_id: [u8; 32],
+    pub model_ref: [u8; 32],
+    pub verifier_ref: [u8; 32],
+    pub deps: Vec<Dep>,
+    pub operands: Vec<Operand>,
+}
+
+/// One accepted document.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Dag {
+    pub header: Header,
+    pub nodes: Vec<Node>,
+}
+
+/// Why [`encode`] could not write a document.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum EncodeError {
+    TooManyNodes,
+    TooManyDeps,
+    TooManyOperands,
+}
+
+fn u16_at(b: &[u8], at: usize) -> u16 {
+    u16::from_be_bytes([b[at], b[at + 1]])
+}
+fn u32_at(b: &[u8], at: usize) -> u32 {
+    u32::from_be_bytes(arr(b, at))
+}
+fn u64_at(b: &[u8], at: usize) -> u64 {
+    u64::from_be_bytes(arr(b, at))
+}
+fn arr<const N: usize>(b: &[u8], at: usize) -> [u8; N] {
+    let mut out = [0u8; N];
+    out.copy_from_slice(&b[at..at + N]);
+    out
+}
+fn all_zero(b: &[u8]) -> bool {
+    b.iter().all(|&x| x == 0)
+}
+
+const H_MAGIC: usize = 0;
+const H_VERSION: usize = 4;
+const H_CEILING: usize = 5;
+const H_COUNT: usize = 6;
+const H_OBJECTIVE: usize = 8;
+const H_TENANT: usize = 40;
+const H_SUBJECT: usize = 72;
+const H_APPROVAL: usize = 104;
+const H_INCARNATION: usize = 136;
+const H_RES0: usize = 140;
+const H_EXPIRES: usize = 144;
+const H_B_TIME: usize = 152;
+const H_B_FUEL: usize = 160;
+const H_B_MEMORY: usize = 168;
+const H_B_WORK: usize = 176;
+const H_B_IN: usize = 184;
+const H_B_OUT: usize = 188;
+
+const N_JOB: usize = 0;
+const N_IDEM: usize = 16;
+const N_GEN: usize = 32;
+const N_KIND: usize = 36;
+const N_OP: usize = 37;
+const N_PROFILE: usize = 38;
+const N_EFFECT: usize = 39;
+const N_IN: usize = 40;
+const N_OUT: usize = 42;
+const N_REQ_IN: usize = 44;
+const N_REQ_OUT: usize = 46;
+const N_VERIFIER: usize = 48;
+const N_RETRY: usize = 49;
+const N_ATTEMPTS: usize = 50;
+const N_CANCEL: usize = 51;
+const N_PRECISION: usize = 52;
+const N_SUBSTRATE: usize = 53;
+const N_DEPS_N: usize = 54;
+const N_OPS_N: usize = 55;
+const N_RTYPE: usize = 56;
+const N_RANK: usize = 57;
+const N_PURE: usize = 58;
+const N_RES1: usize = 59;
+const N_TIME: usize = 60;
+const N_FUEL: usize = 64;
+const N_MEMORY: usize = 72;
+const N_WORK: usize = 80;
+const N_EXPIRES: usize = 88;
+const N_DIMS: usize = 96;
+const N_CAP: usize = 112;
+const N_TENANT: usize = 144;
+const N_MODEL: usize = 176;
+const N_VREF: usize = 208;
+const N_DEPS: usize = 240;
+const DEP_LEN: usize = 6;
+const N_OPERANDS: usize = 288;
+const OPERAND_LEN: usize = 40;
+
+/// Static per-node checks (section 4.4 rules 10 to 23) on the raw record.
+fn check_node(n: &[u8], h: &[u8]) -> Result<(), Refusal> {
+    // Rule 10.
+    if all_zero(&n[N_JOB..N_JOB + 16]) || all_zero(&n[N_IDEM..N_IDEM + 16]) || u32_at(n, N_GEN) == 0
+    {
+        return Err(Refusal::NoJob);
+    }
+    let dep_count = n[N_DEPS_N] as usize;
+    let op_count = n[N_OPS_N] as usize;
+    let rank = n[N_RANK] as usize;
+    // Rule 11.
+    let mut reserved_bad = n[N_RES1] != 0;
+    for s in dep_count.min(MAX_DEPS)..MAX_DEPS {
+        let at = N_DEPS + s * DEP_LEN;
+        reserved_bad |= !all_zero(&n[at..at + DEP_LEN]);
+    }
+    for s in 0..MAX_OPERANDS {
+        let at = N_OPERANDS + s * OPERAND_LEN;
+        if s < op_count {
+            reserved_bad |= !all_zero(&n[at + 1..at + 4]);
+        } else {
+            reserved_bad |= !all_zero(&n[at..at + OPERAND_LEN]);
+        }
+    }
+    for d in rank.min(4)..4 {
+        reserved_bad |= u32_at(n, N_DIMS + 4 * d) != 0;
+    }
+    if reserved_bad {
+        return Err(Refusal::ReservedNonzero);
+    }
+    // Rule 12.
+    let k = n[N_KIND];
+    let op = n[N_OP];
+    let op_ok = match k {
+        kind::COMPUTE => (1..=6).contains(&op),
+        kind::NEURAL => (1..=4).contains(&op),
+        _ => false,
+    };
+    let operand_kinds_ok =
+        (0..op_count.min(MAX_OPERANDS)).all(|s| (1..=5).contains(&n[N_OPERANDS + s * OPERAND_LEN]));
+    if !op_ok
+        || n[N_PROFILE] > profile::SPECIALIST
+        || n[N_EFFECT] > effect::EFFECT
+        || n[N_VERIFIER] > verifier::JUDGE
+        || !(1..=3).contains(&n[N_RETRY])
+        || !(1..=8).contains(&n[N_ATTEMPTS])
+        || !(1..=2).contains(&n[N_CANCEL])
+        || n[N_PRECISION] > 6
+        || n[N_SUBSTRATE] == 0
+        || n[N_SUBSTRATE] & 0xF8 != 0
+        || dep_count > MAX_DEPS
+        || op_count > MAX_OPERANDS
+        || !(1..=7).contains(&n[N_RTYPE])
+        || rank > 4
+        || n[N_PURE] > 1
+        || !operand_kinds_ok
+    {
+        return Err(Refusal::BadEnum);
+    }
+    // Rule 13.
+    if n[N_TENANT..N_TENANT + 32] != h[H_TENANT..H_TENANT + 32] {
+        return Err(Refusal::CrossTenant);
+    }
+    // Rule 14.
+    if all_zero(&n[N_CAP..N_CAP + 32]) {
+        return Err(Refusal::NoCapability);
+    }
+    // Rule 15.
+    if n[N_EFFECT] > h[H_CEILING] {
+        return Err(Refusal::UnauthorizedEffect);
+    }
+    // Rule 16.
+    let vk = n[N_VERIFIER];
+    let vref_zero = all_zero(&n[N_VREF..N_VREF + 32]);
+    let pure = n[N_PURE] == 1;
+    if vk == 0
+        || (vk != verifier::RECOMPUTE && vref_zero)
+        || (vk == verifier::RECOMPUTE && (!vref_zero || !pure))
+    {
+        return Err(Refusal::NoVerifier);
+    }
+    // Rule 17.
+    if pure && (k == kind::NEURAL || n[N_EFFECT] == effect::EFFECT) {
+        return Err(Refusal::Impure);
+    }
+    // Rule 18.
+    let (cap_in, cap_out) = profile_caps(n[N_PROFILE]).unwrap_or((0, 0));
+    let tin = u16_at(n, N_IN);
+    let tout = u16_at(n, N_OUT);
+    let rin = u16_at(n, N_REQ_IN);
+    let rout = u16_at(n, N_REQ_OUT);
+    let model_zero = all_zero(&n[N_MODEL..N_MODEL + 32]);
+    let profile_bad = if k == kind::COMPUTE {
+        n[N_PROFILE] != profile::ZERO
+            || tin != 0
+            || tout != 0
+            || rin != 0
+            || rout != 0
+            || !model_zero
+    } else {
+        n[N_PROFILE] == profile::ZERO
+            || tin == 0
+            || tout == 0
+            || tin > cap_in
+            || tout > cap_out
+            || model_zero
+    };
+    if profile_bad {
+        return Err(Refusal::TokenProfile);
+    }
+    // Rule 19.
+    if rin > tin || rout > tout {
+        return Err(Refusal::NeedsExpansion);
+    }
+    // Rule 20.
+    if (n[N_RETRY] == retry::NEVER && n[N_ATTEMPTS] > 1)
+        || (n[N_EFFECT] == effect::EFFECT && n[N_RETRY] == retry::IDEMPOTENT)
+    {
+        return Err(Refusal::BadRetry);
+    }
+    // Rule 21.
+    if u32_at(n, N_TIME) == 0
+        || u64_at(n, N_FUEL) == 0
+        || u64_at(n, N_MEMORY) == 0
+        || u64_at(n, N_WORK) == 0
+    {
+        return Err(Refusal::ZeroCap);
+    }
+    // Rule 22.
+    let exp = u64_at(n, N_EXPIRES);
+    if exp == 0 || exp > u64_at(h, H_EXPIRES) {
+        return Err(Refusal::BadExpiry);
+    }
+    // Rule 23.
+    for s in 0..op_count {
+        let at = N_OPERANDS + s * OPERAND_LEN;
+        if u32_at(n, at + 4) == 0 || all_zero(&n[at + 8..at + 40]) {
+            return Err(Refusal::MissingOperand);
+        }
+    }
+    Ok(())
+}
+
+fn parse_node(n: &[u8]) -> Node {
+    let deps = (0..n[N_DEPS_N] as usize)
+        .map(|s| {
+            let at = N_DEPS + s * DEP_LEN;
+            Dep {
+                index: u16_at(n, at),
+                generation: u32_at(n, at + 2),
+            }
+        })
+        .collect();
+    let operands = (0..n[N_OPS_N] as usize)
+        .map(|s| {
+            let at = N_OPERANDS + s * OPERAND_LEN;
+            Operand {
+                kind: n[at],
+                generation: u32_at(n, at + 4),
+                digest: arr(n, at + 8),
+            }
+        })
+        .collect();
+    Node {
+        job_id: arr(n, N_JOB),
+        idempotence_key: arr(n, N_IDEM),
+        generation: u32_at(n, N_GEN),
+        kind: n[N_KIND],
+        op: n[N_OP],
+        profile: n[N_PROFILE],
+        effect_class: n[N_EFFECT],
+        input_tokens: u16_at(n, N_IN),
+        output_tokens: u16_at(n, N_OUT),
+        required_input_tokens: u16_at(n, N_REQ_IN),
+        required_output_tokens: u16_at(n, N_REQ_OUT),
+        verifier_kind: n[N_VERIFIER],
+        retry_class: n[N_RETRY],
+        max_attempts: n[N_ATTEMPTS],
+        cancel_mode: n[N_CANCEL],
+        precision: n[N_PRECISION],
+        substrate_mask: n[N_SUBSTRATE],
+        result_type: n[N_RTYPE],
+        result_rank: n[N_RANK],
+        pure: n[N_PURE] == 1,
+        time_ms: u32_at(n, N_TIME),
+        fuel: u64_at(n, N_FUEL),
+        memory: u64_at(n, N_MEMORY),
+        work: u64_at(n, N_WORK),
+        expires_at: u64_at(n, N_EXPIRES),
+        result_dims: [
+            u32_at(n, N_DIMS),
+            u32_at(n, N_DIMS + 4),
+            u32_at(n, N_DIMS + 8),
+            u32_at(n, N_DIMS + 12),
+        ],
+        capability_ref: arr(n, N_CAP),
+        tenant_id: arr(n, N_TENANT),
+        model_ref: arr(n, N_MODEL),
+        verifier_ref: arr(n, N_VREF),
+        deps,
+        operands,
+    }
+}
+
+/// The canonical execution order: Kahn's algorithm taking the lowest-index
+/// ready node first. `None` when the graph has a cycle. Dependency indexes
+/// must already be in range.
+pub fn canonical_order(nodes: &[Node]) -> Option<Vec<usize>> {
+    let n = nodes.len();
+    let mut indeg: Vec<usize> = nodes.iter().map(|x| x.deps.len()).collect();
+    let mut emitted = vec![false; n];
+    let mut order = Vec::with_capacity(n);
+    while order.len() < n {
+        let next = (0..n).find(|&i| !emitted[i] && indeg[i] == 0)?;
+        emitted[next] = true;
+        order.push(next);
+        for (i, node) in nodes.iter().enumerate() {
+            for d in &node.deps {
+                if d.index as usize == next {
+                    indeg[i] -= 1;
+                }
+            }
+        }
+    }
+    Some(order)
+}
+
+/// Decode and check one document in the order of SPEC.md section 4.4, the
+/// same order as the C checker, so the same bytes give the same code.
+pub fn decode(b: &[u8]) -> Result<Dag, Refusal> {
+    if b.len() < HEADER_LEN {
+        return Err(Refusal::BadLength);
+    }
+    if b[H_MAGIC..H_MAGIC + 4] != MAGIC {
+        return Err(Refusal::BadMagic);
+    }
+    if b[H_VERSION] == 0 {
+        return Err(Refusal::Downgrade);
+    }
+    if b[H_VERSION] > VERSION {
+        return Err(Refusal::BadVersion);
+    }
+    let count = u16_at(b, H_COUNT) as usize;
+    if count == 0 || count > MAX_NODES {
+        return Err(Refusal::BadCount);
+    }
+    if b.len() != HEADER_LEN + count * NODE_LEN {
+        return Err(Refusal::BadLength);
+    }
+    if !all_zero(&b[H_RES0..H_RES0 + 4]) {
+        return Err(Refusal::ReservedNonzero);
+    }
+    if b[H_CEILING] > effect::EFFECT {
+        return Err(Refusal::BadEnum);
+    }
+    if all_zero(&b[H_OBJECTIVE..H_OBJECTIVE + 32]) {
+        return Err(Refusal::NoObjective);
+    }
+    if all_zero(&b[H_TENANT..H_TENANT + 32]) {
+        return Err(Refusal::NoTenant);
+    }
+    if all_zero(&b[H_SUBJECT..H_SUBJECT + 32]) {
+        return Err(Refusal::NoSubject);
+    }
+    if all_zero(&b[H_APPROVAL..H_APPROVAL + 32]) {
+        return Err(Refusal::NoApproval);
+    }
+    if u32_at(b, H_INCARNATION) == 0 {
+        return Err(Refusal::NoObjective);
+    }
+    let h = &b[..HEADER_LEN];
+    let mut nodes = Vec::with_capacity(count);
+    for i in 0..count {
+        let rec = &b[HEADER_LEN + i * NODE_LEN..HEADER_LEN + (i + 1) * NODE_LEN];
+        check_node(rec, h)?;
+        nodes.push(parse_node(rec));
+    }
+    // Rule 24.
+    for i in 0..count {
+        for j in i + 1..count {
+            if nodes[i].job_id == nodes[j].job_id
+                || nodes[i].idempotence_key == nodes[j].idempotence_key
+            {
+                return Err(Refusal::DuplicateJob);
+            }
+        }
+    }
+    // Rule 25.
+    for (i, node) in nodes.iter().enumerate() {
+        if node
+            .deps
+            .iter()
+            .any(|d| d.index as usize == i || d.index as usize >= count)
+        {
+            return Err(Refusal::MissingDep);
+        }
+    }
+    // Rule 26.
+    for node in &nodes {
+        if node
+            .deps
+            .iter()
+            .any(|d| d.generation != nodes[d.index as usize].generation)
+        {
+            return Err(Refusal::StaleGeneration);
+        }
+    }
+    // Rule 27.
+    if canonical_order(&nodes).is_none() {
+        return Err(Refusal::Cycle);
+    }
+    // Rule 28.
+    let sum = |f: &dyn Fn(&Node) -> u128| nodes.iter().map(f).sum::<u128>();
+    let header = Header {
+        effect_ceiling: b[H_CEILING],
+        objective_id: arr(b, H_OBJECTIVE),
+        tenant_id: arr(b, H_TENANT),
+        subject_id: arr(b, H_SUBJECT),
+        approval_ref: arr(b, H_APPROVAL),
+        incarnation: u32_at(b, H_INCARNATION),
+        expires_at: u64_at(b, H_EXPIRES),
+        budget_time_ms: u64_at(b, H_B_TIME),
+        budget_fuel: u64_at(b, H_B_FUEL),
+        budget_memory: u64_at(b, H_B_MEMORY),
+        budget_work: u64_at(b, H_B_WORK),
+        budget_input_tokens: u32_at(b, H_B_IN),
+        budget_output_tokens: u32_at(b, H_B_OUT),
+    };
+    if sum(&|x| x.time_ms as u128) > header.budget_time_ms as u128
+        || sum(&|x| x.fuel as u128) > header.budget_fuel as u128
+        || sum(&|x| x.work as u128) > header.budget_work as u128
+        || sum(&|x| x.input_tokens as u128) > header.budget_input_tokens as u128
+        || sum(&|x| x.output_tokens as u128) > header.budget_output_tokens as u128
+        || nodes.iter().any(|x| x.memory > header.budget_memory)
+    {
+        return Err(Refusal::OverBudget);
+    }
+    Ok(Dag { header, nodes })
+}
+
+/// Write one document. Fields are written exactly as given; nothing is
+/// checked beyond the slot counts (use [`decode`] to check).
+pub fn encode(d: &Dag) -> Result<Vec<u8>, EncodeError> {
+    if d.nodes.len() > MAX_NODES {
+        return Err(EncodeError::TooManyNodes);
+    }
+    let mut b = vec![0u8; HEADER_LEN + d.nodes.len() * NODE_LEN];
+    let h = &d.header;
+    b[H_MAGIC..H_MAGIC + 4].copy_from_slice(&MAGIC);
+    b[H_VERSION] = VERSION;
+    b[H_CEILING] = h.effect_ceiling;
+    b[H_COUNT..H_COUNT + 2].copy_from_slice(&(d.nodes.len() as u16).to_be_bytes());
+    b[H_OBJECTIVE..H_OBJECTIVE + 32].copy_from_slice(&h.objective_id);
+    b[H_TENANT..H_TENANT + 32].copy_from_slice(&h.tenant_id);
+    b[H_SUBJECT..H_SUBJECT + 32].copy_from_slice(&h.subject_id);
+    b[H_APPROVAL..H_APPROVAL + 32].copy_from_slice(&h.approval_ref);
+    b[H_INCARNATION..H_INCARNATION + 4].copy_from_slice(&h.incarnation.to_be_bytes());
+    b[H_EXPIRES..H_EXPIRES + 8].copy_from_slice(&h.expires_at.to_be_bytes());
+    b[H_B_TIME..H_B_TIME + 8].copy_from_slice(&h.budget_time_ms.to_be_bytes());
+    b[H_B_FUEL..H_B_FUEL + 8].copy_from_slice(&h.budget_fuel.to_be_bytes());
+    b[H_B_MEMORY..H_B_MEMORY + 8].copy_from_slice(&h.budget_memory.to_be_bytes());
+    b[H_B_WORK..H_B_WORK + 8].copy_from_slice(&h.budget_work.to_be_bytes());
+    b[H_B_IN..H_B_IN + 4].copy_from_slice(&h.budget_input_tokens.to_be_bytes());
+    b[H_B_OUT..H_B_OUT + 4].copy_from_slice(&h.budget_output_tokens.to_be_bytes());
+    for (i, x) in d.nodes.iter().enumerate() {
+        if x.deps.len() > MAX_DEPS {
+            return Err(EncodeError::TooManyDeps);
+        }
+        if x.operands.len() > MAX_OPERANDS {
+            return Err(EncodeError::TooManyOperands);
+        }
+        let n = &mut b[HEADER_LEN + i * NODE_LEN..HEADER_LEN + (i + 1) * NODE_LEN];
+        n[N_JOB..N_JOB + 16].copy_from_slice(&x.job_id);
+        n[N_IDEM..N_IDEM + 16].copy_from_slice(&x.idempotence_key);
+        n[N_GEN..N_GEN + 4].copy_from_slice(&x.generation.to_be_bytes());
+        n[N_KIND] = x.kind;
+        n[N_OP] = x.op;
+        n[N_PROFILE] = x.profile;
+        n[N_EFFECT] = x.effect_class;
+        n[N_IN..N_IN + 2].copy_from_slice(&x.input_tokens.to_be_bytes());
+        n[N_OUT..N_OUT + 2].copy_from_slice(&x.output_tokens.to_be_bytes());
+        n[N_REQ_IN..N_REQ_IN + 2].copy_from_slice(&x.required_input_tokens.to_be_bytes());
+        n[N_REQ_OUT..N_REQ_OUT + 2].copy_from_slice(&x.required_output_tokens.to_be_bytes());
+        n[N_VERIFIER] = x.verifier_kind;
+        n[N_RETRY] = x.retry_class;
+        n[N_ATTEMPTS] = x.max_attempts;
+        n[N_CANCEL] = x.cancel_mode;
+        n[N_PRECISION] = x.precision;
+        n[N_SUBSTRATE] = x.substrate_mask;
+        n[N_DEPS_N] = x.deps.len() as u8;
+        n[N_OPS_N] = x.operands.len() as u8;
+        n[N_RTYPE] = x.result_type;
+        n[N_RANK] = x.result_rank;
+        n[N_PURE] = x.pure as u8;
+        n[N_TIME..N_TIME + 4].copy_from_slice(&x.time_ms.to_be_bytes());
+        n[N_FUEL..N_FUEL + 8].copy_from_slice(&x.fuel.to_be_bytes());
+        n[N_MEMORY..N_MEMORY + 8].copy_from_slice(&x.memory.to_be_bytes());
+        n[N_WORK..N_WORK + 8].copy_from_slice(&x.work.to_be_bytes());
+        n[N_EXPIRES..N_EXPIRES + 8].copy_from_slice(&x.expires_at.to_be_bytes());
+        for (k, dim) in x.result_dims.iter().enumerate() {
+            n[N_DIMS + 4 * k..N_DIMS + 4 * k + 4].copy_from_slice(&dim.to_be_bytes());
+        }
+        n[N_CAP..N_CAP + 32].copy_from_slice(&x.capability_ref);
+        n[N_TENANT..N_TENANT + 32].copy_from_slice(&x.tenant_id);
+        n[N_MODEL..N_MODEL + 32].copy_from_slice(&x.model_ref);
+        n[N_VREF..N_VREF + 32].copy_from_slice(&x.verifier_ref);
+        for (s, dep) in x.deps.iter().enumerate() {
+            let at = N_DEPS + s * DEP_LEN;
+            n[at..at + 2].copy_from_slice(&dep.index.to_be_bytes());
+            n[at + 2..at + 6].copy_from_slice(&dep.generation.to_be_bytes());
+        }
+        for (s, op) in x.operands.iter().enumerate() {
+            let at = N_OPERANDS + s * OPERAND_LEN;
+            n[at] = op.kind;
+            n[at + 4..at + 8].copy_from_slice(&op.generation.to_be_bytes());
+            n[at + 8..at + 40].copy_from_slice(&op.digest);
+        }
+    }
+    Ok(b)
+}
+
+/// `dag_digest`: SHA-256 of the document bytes (section 3, rule 4).
+pub fn dag_digest(document: &[u8]) -> [u8; 32] {
+    Sha256::digest(document).into()
+}
+
+fn hex(out: &mut String, bytes: &[u8]) {
+    const H: &[u8; 16] = b"0123456789abcdef";
+    for &x in bytes {
+        out.push(H[(x >> 4) as usize] as char);
+        out.push(H[(x & 15) as usize] as char);
+    }
+}
+
+/// The verdict line in the exact format of `mjb_verify FILE` and
+/// `vectors/expected.txt`.
+pub fn verdict_line(document: &[u8]) -> String {
+    match decode(document) {
+        Err(r) => format!("refuse {}", r.name()),
+        Ok(d) => {
+            let mut s = format!(
+                "ok nodes={} incarnation={} ceiling={} objective=",
+                d.nodes.len(),
+                d.header.incarnation,
+                d.header.effect_ceiling
+            );
+            hex(&mut s, &d.header.objective_id);
+            s.push_str(" tenant=");
+            hex(&mut s, &d.header.tenant_id);
+            s.push_str(" digest=");
+            hex(&mut s, &dag_digest(document));
+            s.push_str(" order=");
+            let order = canonical_order(&d.nodes).expect("decode checked acyclic");
+            let parts: Vec<String> = order.iter().map(|i| i.to_string()).collect();
+            s.push_str(&parts.join(","));
+            s
+        }
+    }
+}
+
+/// One MJR1 receipt (section 5).
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Receipt {
+    pub outcome: u8,
+    pub attempt: u8,
+    pub dag_digest: [u8; 32],
+    pub job_id: [u8; 16],
+    pub idempotence_key: [u8; 16],
+    pub generation: u32,
+    pub used_time_ms: u32,
+    pub used_input_tokens: u16,
+    pub used_output_tokens: u16,
+    pub used_fuel: u64,
+    pub used_memory: u64,
+    pub used_work: u64,
+    pub input_binding: [u8; 32],
+    pub output_digest: [u8; 32],
+    pub source_hash: [u8; 32],
+    pub model_hash: [u8; 32],
+    pub policy_hash: [u8; 32],
+    pub verifier_verdict: [u8; 32],
+    pub signer_key: [u8; 33],
+    pub signature: [u8; 64],
+}
+
+/// Write one receipt.
+pub fn encode_receipt(r: &Receipt) -> [u8; RECEIPT_LEN] {
+    let mut b = [0u8; RECEIPT_LEN];
+    b[0..4].copy_from_slice(&RECEIPT_MAGIC);
+    b[4] = VERSION;
+    b[5] = r.outcome;
+    b[6] = r.attempt;
+    b[8..40].copy_from_slice(&r.dag_digest);
+    b[40..56].copy_from_slice(&r.job_id);
+    b[56..72].copy_from_slice(&r.idempotence_key);
+    b[72..76].copy_from_slice(&r.generation.to_be_bytes());
+    b[76..80].copy_from_slice(&r.used_time_ms.to_be_bytes());
+    b[80..82].copy_from_slice(&r.used_input_tokens.to_be_bytes());
+    b[82..84].copy_from_slice(&r.used_output_tokens.to_be_bytes());
+    b[88..96].copy_from_slice(&r.used_fuel.to_be_bytes());
+    b[96..104].copy_from_slice(&r.used_memory.to_be_bytes());
+    b[104..112].copy_from_slice(&r.used_work.to_be_bytes());
+    b[112..144].copy_from_slice(&r.input_binding);
+    b[144..176].copy_from_slice(&r.output_digest);
+    b[176..208].copy_from_slice(&r.source_hash);
+    b[208..240].copy_from_slice(&r.model_hash);
+    b[240..272].copy_from_slice(&r.policy_hash);
+    b[272..304].copy_from_slice(&r.verifier_verdict);
+    b[304..337].copy_from_slice(&r.signer_key);
+    b[340..404].copy_from_slice(&r.signature);
+    b
+}
+
+/// Decode one receipt and apply the static rules of section 5.2
+/// (`MJB_BAD_RECEIPT`). The signature is not checked here.
+pub fn decode_receipt(b: &[u8]) -> Result<Receipt, Refusal> {
+    if b.len() != RECEIPT_LEN
+        || b[0..4] != RECEIPT_MAGIC
+        || b[4] != VERSION
+        || b[7] != 0
+        || !all_zero(&b[84..88])
+        || !all_zero(&b[337..340])
+        || !(outcome::COMPLETED..=outcome::UNCERTAIN).contains(&b[5])
+        || b[6] == 0
+        || (b[304] != 0x02 && b[304] != 0x03)
+        || all_zero(&b[176..208])
+        || all_zero(&b[240..272])
+    {
+        return Err(Refusal::BadReceipt);
+    }
+    let completed = b[5] == outcome::COMPLETED;
+    if completed == all_zero(&b[144..176]) || (completed && all_zero(&b[272..304])) {
+        return Err(Refusal::BadReceipt);
+    }
+    Ok(Receipt {
+        outcome: b[5],
+        attempt: b[6],
+        dag_digest: arr(b, 8),
+        job_id: arr(b, 40),
+        idempotence_key: arr(b, 56),
+        generation: u32_at(b, 72),
+        used_time_ms: u32_at(b, 76),
+        used_input_tokens: u16_at(b, 80),
+        used_output_tokens: u16_at(b, 82),
+        used_fuel: u64_at(b, 88),
+        used_memory: u64_at(b, 96),
+        used_work: u64_at(b, 104),
+        input_binding: arr(b, 112),
+        output_digest: arr(b, 144),
+        source_hash: arr(b, 176),
+        model_hash: arr(b, 208),
+        policy_hash: arr(b, 240),
+        verifier_verdict: arr(b, 272),
+        signer_key: arr(b, 304),
+        signature: arr(b, 340),
+    })
+}
+
+/// `receipt_digest`: SHA-256 of the signed region (the signature excluded).
+pub fn receipt_digest(r: &Receipt) -> [u8; 32] {
+    Sha256::digest(&encode_receipt(r)[..RECEIPT_SIGNED_LEN]).into()
+}
+
+/// Fill `signer_key` from `key` and sign the receipt.
+pub fn sign_receipt(r: &mut Receipt, key: &SigningKey) {
+    r.signer_key = p256_compressed_key(key);
+    let bytes = encode_receipt(r);
+    r.signature = p256_sign_low_s(key, &bytes[..RECEIPT_SIGNED_LEN]);
+}
+
+/// The input binding of section 5.1 from dependency receipt digests (in slot
+/// order) and the node's operands.
+pub fn input_binding(dep_receipt_digests: &[[u8; 32]], operands: &[Operand]) -> [u8; 32] {
+    let mut h = Sha256::new();
+    h.update(b"MJR1-BIND");
+    for d in dep_receipt_digests {
+        h.update(d);
+    }
+    for op in operands {
+        h.update([op.kind]);
+        h.update(op.generation.to_be_bytes());
+        h.update(op.digest);
+    }
+    h.finalize().into()
+}
+
+/// Derived node state (section 5.3).
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum NodeState {
+    /// Some dependency is not yet DONE.
+    Waiting,
+    /// Every dependency is DONE and no terminal receipt exists.
+    Ready,
+    /// A COMPLETED receipt was applied.
+    Done,
+    /// A REFUSED receipt was applied.
+    Refused,
+    /// A CANCELLED receipt was applied, or the objective was cancelled.
+    Cancelled,
+    /// FAILED or UNCERTAIN on the last allowed attempt.
+    Exhausted,
+    /// The last attempt is UNCERTAIN and another is allowed after
+    /// reconciliation against the effect ledger.
+    Uncertain,
+    /// A dependency is REFUSED, CANCELLED, EXHAUSTED or BLOCKED.
+    Blocked,
+}
+
+/// Whether [`DagRun::apply`] changed state.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Applied {
+    New,
+    Replay,
+}
+
+#[derive(Debug, Clone, Default)]
+struct Slot {
+    /// Every receipt applied to this node, in order.
+    applied: Vec<[u8; RECEIPT_LEN]>,
+    last_outcome: u8,
+    last_attempt: u8,
+    /// Digest of the COMPLETED receipt.
+    done: Option<[u8; 32]>,
+    output: Option<[u8; 32]>,
+}
+
+/// The receipt ledger of one accepted document (section 5.2).
+#[derive(Debug, Clone)]
+pub struct DagRun {
+    dag: Dag,
+    digest: [u8; 32],
+    trusted: Vec<[u8; 33]>,
+    slots: Vec<Slot>,
+    cancelled: bool,
+    log: Vec<[u8; RECEIPT_LEN]>,
+}
+
+impl DagRun {
+    /// Admit a document at the receiver's clock `now` (Unix seconds) with the
+    /// receiver's own trusted executor keys. Expired documents are refused.
+    pub fn admit(document: &[u8], trusted: Vec<[u8; 33]>, now: u64) -> Result<Self, Refusal> {
+        let dag = decode(document)?;
+        if dag.header.expires_at < now {
+            return Err(Refusal::BadExpiry);
+        }
+        let n = dag.nodes.len();
+        Ok(DagRun {
+            dag,
+            digest: dag_digest(document),
+            trusted,
+            slots: vec![Slot::default(); n],
+            cancelled: false,
+            log: Vec::new(),
+        })
+    }
+
+    /// Rebuild the ledger after a restart by replaying the stored receipt log.
+    pub fn restore(
+        document: &[u8],
+        trusted: Vec<[u8; 33]>,
+        now: u64,
+        log: &[[u8; RECEIPT_LEN]],
+    ) -> Result<Self, Refusal> {
+        let mut run = Self::admit(document, trusted, now)?;
+        for r in log {
+            run.apply(r)?;
+        }
+        Ok(run)
+    }
+
+    /// The accepted document.
+    pub fn dag(&self) -> &Dag {
+        &self.dag
+    }
+
+    /// The `dag_digest` receipts must name.
+    pub fn digest(&self) -> [u8; 32] {
+        self.digest
+    }
+
+    /// Every newly applied receipt in order: what a receiver stores to
+    /// survive a restart.
+    pub fn log(&self) -> &[[u8; RECEIPT_LEN]] {
+        &self.log
+    }
+
+    /// The `output_digest` of a DONE node.
+    pub fn output(&self, i: usize) -> Option<[u8; 32]> {
+        self.slots[i].output
+    }
+
+    /// The binding a receipt for node `i` must carry, once every dependency
+    /// is DONE.
+    pub fn expected_binding(&self, i: usize) -> Option<[u8; 32]> {
+        let node = &self.dag.nodes[i];
+        let mut deps = Vec::with_capacity(node.deps.len());
+        for d in &node.deps {
+            deps.push(self.slots[d.index as usize].done?);
+        }
+        Some(input_binding(&deps, &node.operands))
+    }
+
+    /// Cancel the objective: every receipt applied so far stands, every later
+    /// receipt is refused, every non-terminal node becomes CANCELLED.
+    pub fn cancel(&mut self) {
+        self.cancelled = true;
+    }
+
+    /// Apply one receipt (section 5.2). A refusal changes nothing.
+    pub fn apply(&mut self, bytes: &[u8]) -> Result<Applied, Refusal> {
+        let r = decode_receipt(bytes)?;
+        if !self.trusted.contains(&r.signer_key)
+            || p256_verify_low_s(&r.signer_key, &bytes[..RECEIPT_SIGNED_LEN], &r.signature).is_err()
+        {
+            return Err(Refusal::ForgedReceipt);
+        }
+        if r.dag_digest != self.digest {
+            return Err(Refusal::WrongDag);
+        }
+        let i = self
+            .dag
+            .nodes
+            .iter()
+            .position(|n| n.job_id == r.job_id)
+            .ok_or(Refusal::UnknownJob)?;
+        let node = &self.dag.nodes[i];
+        if node.idempotence_key != r.idempotence_key {
+            return Err(Refusal::UnknownJob);
+        }
+        if node.generation != r.generation {
+            return Err(Refusal::StaleGeneration);
+        }
+        if node.model_ref != r.model_hash {
+            return Err(Refusal::ModelMismatch);
+        }
+        let slot = &self.slots[i];
+        if slot.applied.iter().any(|a| a[..] == bytes[..]) {
+            return Ok(Applied::Replay);
+        }
+        if self.cancelled {
+            return Err(Refusal::Cancelled);
+        }
+        if is_terminal(slot.last_outcome) {
+            return Err(Refusal::DoubleCommit);
+        }
+        if r.attempt != slot.last_attempt.saturating_add(1) || r.attempt > node.max_attempts {
+            return Err(Refusal::BadRetry);
+        }
+        if r.used_time_ms > node.time_ms
+            || r.used_input_tokens > node.input_tokens
+            || r.used_output_tokens > node.output_tokens
+            || r.used_fuel > node.fuel
+            || r.used_memory > node.memory
+            || r.used_work > node.work
+        {
+            return Err(Refusal::ReceiptOverBudget);
+        }
+        match self.expected_binding(i) {
+            Some(b) if b != r.input_binding => return Err(Refusal::BindingMismatch),
+            None if r.outcome == outcome::COMPLETED => return Err(Refusal::DepNotDone),
+            _ => {}
+        }
+        let mut stored = [0u8; RECEIPT_LEN];
+        stored.copy_from_slice(bytes);
+        let slot = &mut self.slots[i];
+        slot.applied.push(stored);
+        slot.last_outcome = r.outcome;
+        slot.last_attempt = r.attempt;
+        if r.outcome == outcome::COMPLETED {
+            slot.done = Some(receipt_digest(&r));
+            slot.output = Some(r.output_digest);
+        }
+        self.log.push(stored);
+        Ok(Applied::New)
+    }
+
+    /// The derived state of node `i` (section 5.3).
+    pub fn state(&self, i: usize) -> NodeState {
+        let order = canonical_order(&self.dag.nodes).expect("admitted documents are acyclic");
+        let mut states = vec![NodeState::Waiting; self.dag.nodes.len()];
+        for &k in &order {
+            states[k] = self.own_state(k, &states);
+        }
+        states[i]
+    }
+
+    /// The derived state of every node, by index.
+    pub fn states(&self) -> Vec<NodeState> {
+        (0..self.dag.nodes.len()).map(|i| self.state(i)).collect()
+    }
+
+    fn own_state(&self, k: usize, states: &[NodeState]) -> NodeState {
+        let slot = &self.slots[k];
+        let node = &self.dag.nodes[k];
+        match slot.last_outcome {
+            outcome::COMPLETED => return NodeState::Done,
+            outcome::REFUSED => return NodeState::Refused,
+            outcome::CANCELLED => return NodeState::Cancelled,
+            _ => {}
+        }
+        let out_of_attempts = slot.last_attempt >= node.max_attempts
+            && matches!(slot.last_outcome, outcome::FAILED | outcome::UNCERTAIN);
+        if out_of_attempts {
+            return NodeState::Exhausted;
+        }
+        if self.cancelled {
+            return NodeState::Cancelled;
+        }
+        let dep_states = node.deps.iter().map(|d| states[d.index as usize]);
+        if dep_states.clone().any(|s| {
+            matches!(
+                s,
+                NodeState::Refused
+                    | NodeState::Cancelled
+                    | NodeState::Exhausted
+                    | NodeState::Blocked
+            )
+        }) {
+            return NodeState::Blocked;
+        }
+        if slot.last_outcome == outcome::UNCERTAIN {
+            return NodeState::Uncertain;
+        }
+        if dep_states.clone().all(|s| s == NodeState::Done) {
+            NodeState::Ready
+        } else {
+            NodeState::Waiting
+        }
+    }
+}
+
+fn is_terminal(o: u8) -> bool {
+    matches!(
+        o,
+        outcome::COMPLETED | outcome::REFUSED | outcome::CANCELLED
+    )
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn profile_table_matches_the_issue() {
+        assert_eq!(profile_caps(profile::ZERO), Some((0, 0)));
+        assert_eq!(profile_caps(profile::MINIMAL), Some((64, 16)));
+        assert_eq!(profile_caps(profile::DEFAULT), Some((128, 32)));
+        assert_eq!(profile_caps(profile::LARGE), Some((256, 64)));
+        assert_eq!(profile_caps(profile::SPECIALIST), Some((512, 128)));
+        assert_eq!(profile_caps(5), None);
+    }
+
+    #[test]
+    fn layout_constants() {
+        assert_eq!(N_OPERANDS + MAX_OPERANDS * OPERAND_LEN, NODE_LEN);
+        assert_eq!(N_DEPS + MAX_DEPS * DEP_LEN, N_OPERANDS);
+        assert_eq!(H_B_OUT + 4, HEADER_LEN);
+        assert_eq!(MAX_DOCUMENT, 28864);
+    }
+}
diff --git a/crates/aien-microjob/tests/.crumb b/crates/aien-microjob/tests/.crumb
new file mode 100644
index 0000000..9802d93
--- /dev/null
+++ b/crates/aien-microjob/tests/.crumb
@@ -0,0 +1,6 @@
+{
+  "layer": "crates/aien-microjob/tests",
+  "name": "crates/aien-microjob/tests",
+  "purpose": "Parity test against specs/microjob/vectors and receipt-ledger tests including the 11-node offline sample",
+  "schema_version": "1.0.0"
+}
diff --git a/crates/aien-microjob/tests/ledger.rs b/crates/aien-microjob/tests/ledger.rs
new file mode 100644
index 0000000..a4ae37c
--- /dev/null
+++ b/crates/aien-microjob/tests/ledger.rs
@@ -0,0 +1,753 @@
+//! Receipt ledger (SPEC.md section 5) and the offline sample of
+//! aien-protocols-mv#50: an 11-node DAG with a long objective, independent
+//! numeric nodes, two neural route nodes, a refused node with a blocked
+//! dependent, an interrupt and restart, and a checked aggregate answer.
+//!
+//! COMPUTE nodes are executed for real here (integer arithmetic over operand
+//! bytes fetched by digest). NEURAL node outputs are fixed fixture bytes: no
+//! model runs in this test, and none is claimed.
+
+use std::collections::HashMap;
+
+use aien_microjob::*;
+use p256::ecdsa::SigningKey;
+use sha2::{Digest, Sha256};
+
+const NOW: u64 = 1_800_000_000;
+const EXPIRES: u64 = 2_000_000_000;
+
+fn sha(b: &[u8]) -> [u8; 32] {
+    Sha256::digest(b).into()
+}
+
+fn fill<const N: usize>(seed: u8) -> [u8; N] {
+    let mut out = [0u8; N];
+    for (i, x) in out.iter_mut().enumerate() {
+        *x = seed.wrapping_add((7 * i) as u8);
+    }
+    out
+}
+
+fn id16(seed: u8, i: usize) -> [u8; 16] {
+    let mut out: [u8; 16] = fill(seed);
+    out[14..].copy_from_slice(&(i as u16 + 1).to_be_bytes());
+    out
+}
+
+fn tenant() -> [u8; 32] {
+    fill(0x7E)
+}
+
+fn header(ceiling: u8, objective_id: [u8; 32]) -> Header {
+    Header {
+        effect_ceiling: ceiling,
+        objective_id,
+        tenant_id: tenant(),
+        subject_id: fill(0x5B),
+        approval_ref: fill(0xA9),
+        incarnation: 1,
+        expires_at: EXPIRES,
+        budget_time_ms: 100_000,
+        budget_fuel: 1_000_000,
+        budget_memory: 1 << 30,
+        budget_work: 1_000_000,
+        budget_input_tokens: 4096,
+        budget_output_tokens: 1024,
+    }
+}
+
+fn compute_node(i: usize, op: u8) -> Node {
+    Node {
+        job_id: id16(0x4A, i),
+        idempotence_key: id16(0x1D, i),
+        generation: 1,
+        kind: kind::COMPUTE,
+        op,
+        profile: profile::ZERO,
+        effect_class: effect::COMPUTE,
+        input_tokens: 0,
+        output_tokens: 0,
+        required_input_tokens: 0,
+        required_output_tokens: 0,
+        verifier_kind: verifier::RECOMPUTE,
+        retry_class: retry::IDEMPOTENT,
+        max_attempts: 3,
+        cancel_mode: cancel::DISCARD,
+        precision: 0,
+        substrate_mask: 1,
+        result_type: 2,
+        result_rank: 0,
+        pure: true,
+        time_ms: 100,
+        fuel: 1000,
+        memory: 1 << 20,
+        work: 1000,
+        expires_at: EXPIRES - 1,
+        result_dims: [0; 4],
+        capability_ref: fill(0xCA),
+        tenant_id: tenant(),
+        model_ref: [0; 32],
+        verifier_ref: [0; 32],
+        deps: Vec::new(),
+        operands: Vec::new(),
+    }
+}
+
+fn neural_node(i: usize, op: u8, prof: u8, caps: (u16, u16), required: (u16, u16)) -> Node {
+    Node {
+        kind: kind::NEURAL,
+        op,
+        profile: prof,
+        effect_class: effect::NONE,
+        input_tokens: caps.0,
+        output_tokens: caps.1,
+        required_input_tokens: required.0,
+        required_output_tokens: required.1,
+        verifier_kind: verifier::CHECKER,
+        verifier_ref: fill(0x5E),
+        max_attempts: 2,
+        precision: 2,
+        substrate_mask: 3,
+        result_type: 6,
+        pure: false,
+        model_ref: fill(0x3D),
+        ..compute_node(i, 1)
+    }
+}
+
+fn with_deps(mut n: Node, nodes: &[Node], deps: &[usize]) -> Node {
+    n.deps = deps
+        .iter()
+        .map(|&d| Dep {
+            index: d as u16,
+            generation: nodes[d].generation,
+        })
+        .collect();
+    n
+}
+
+fn content(store: &mut HashMap<[u8; 32], Vec<u8>>, bytes: &[u8]) -> Operand {
+    let digest = sha(bytes);
+    store.insert(digest, bytes.to_vec());
+    Operand {
+        kind: operand::CONTENT,
+        generation: 1,
+        digest,
+    }
+}
+
+fn executor_key() -> SigningKey {
+    // TEST key only: a fixed scalar so receipts are reproducible.
+    SigningKey::from_slice(&[0x42u8; 32]).unwrap()
+}
+
+fn trusted() -> Vec<[u8; 33]> {
+    vec![aien_provenance::p256_compressed_key(&executor_key())]
+}
+
+/// A receipt for node `i` of `run` with the binding the ledger expects (or a
+/// zero binding when dependencies are not all DONE).
+fn receipt(run: &DagRun, i: usize, outcome_code: u8, attempt: u8, output: &[u8]) -> Receipt {
+    let node = &run.dag().nodes[i];
+    let completed = outcome_code == outcome::COMPLETED;
+    Receipt {
+        outcome: outcome_code,
+        attempt,
+        dag_digest: run.digest(),
+        job_id: node.job_id,
+        idempotence_key: node.idempotence_key,
+        generation: node.generation,
+        used_time_ms: node.time_ms / 2,
+        used_input_tokens: node.input_tokens / 2,
+        used_output_tokens: node.output_tokens / 2,
+        used_fuel: node.fuel / 2,
+        used_memory: node.memory / 2,
+        used_work: node.work / 2,
+        input_binding: run.expected_binding(i).unwrap_or([0; 32]),
+        output_digest: if completed { sha(output) } else { [0; 32] },
+        source_hash: fill(0x50),
+        model_hash: node.model_ref,
+        policy_hash: fill(0x60),
+        verifier_verdict: if completed { fill(0x70) } else { [0; 32] },
+        signer_key: [0; 33],
+        signature: [0; 64],
+    }
+}
+
+fn signed(mut r: Receipt) -> [u8; RECEIPT_LEN] {
+    sign_receipt(&mut r, &executor_key());
+    encode_receipt(&r)
+}
+
+fn parse_list(b: &[u8]) -> Vec<i64> {
+    std::str::from_utf8(b)
+        .unwrap()
+        .split(',')
+        .map(|x| x.trim().parse().unwrap())
+        .collect()
+}
+
+fn int_bytes(v: i64) -> Vec<u8> {
+    v.to_be_bytes().to_vec()
+}
+
+fn int_of(b: &[u8]) -> i64 {
+    i64::from_be_bytes(b.try_into().unwrap())
+}
+
+struct Sample {
+    document: Vec<u8>,
+    store: HashMap<[u8; 32], Vec<u8>>,
+    readings_a: Vec<u8>,
+    readings_b: Vec<u8>,
+}
+
+/// The 11-node offline sample. The objective text is long; every node stays
+/// inside its small per-node contract.
+fn sample() -> Sample {
+    let mut objective = String::from("AIEN_E2E_OBJECTIVE_V1\n");
+    for k in 0..40 {
+        objective.push_str(&format!(
+            "Step {k}: read the six greenhouse temperature sensors from the two typed content records, \
+             compute their exact mean in milli-degrees, compare it to the agreed threshold, route the \
+             request to the thermal skill and report in the brief style. "
+        ));
+    }
+    assert!(objective.len() > 8000, "the objective is long");
+    let objective_id = sha(objective.as_bytes());
+
+    let mut store = HashMap::new();
+    let readings_a = b"21,23,22".to_vec();
+    let readings_b = b"25,24,26".to_vec();
+    let op_a = content(&mut store, &readings_a);
+    let op_b = content(&mut store, &readings_b);
+    let op_count = content(&mut store, b"6");
+    let op_threshold = content(&mut store, b"23000");
+    let op_request = content(&mut store, b"Is the greenhouse too warm?");
+    let cortex = Operand {
+        kind: operand::CORTEX_STATE,
+        generation: 3,
+        digest: fill(0xC0),
+    };
+
+    let mut nodes: Vec<Node> = Vec::new();
+    let mut n0 = compute_node(0, compute_op::ARITH);
+    n0.operands = vec![op_a];
+    nodes.push(n0);
+    let mut n1 = compute_node(1, compute_op::ARITH);
+    n1.operands = vec![op_b];
+    nodes.push(n1);
+    let n2 = with_deps(compute_node(2, compute_op::REDUCE), &nodes, &[0, 1]);
+    nodes.push(n2);
+    let mut n3 = with_deps(compute_node(3, compute_op::ARITH), &nodes, &[2]);
+    n3.operands = vec![op_count];
+    nodes.push(n3);
+    let mut n4 = with_deps(compute_node(4, compute_op::COMPARE), &nodes, &[3]);
+    n4.operands = vec![op_threshold];
+    n4.result_type = 5;
+    nodes.push(n4);
+    let mut n5 = neural_node(5, neural_op::ROUTE, profile::MINIMAL, (64, 16), (12, 4));
+    n5.operands = vec![op_request];
+    nodes.push(n5);
+    let mut n6 = neural_node(6, neural_op::ROUTE, profile::DEFAULT, (128, 32), (90, 4));
+    n6.operands = vec![cortex];
+    nodes.push(n6);
+    let mut n7 = with_deps(compute_node(7, compute_op::VERIFY), &nodes, &[3]);
+    n7.operands = vec![op_a, op_b];
+    n7.verifier_kind = verifier::CHECKER;
+    n7.verifier_ref = fill(0x77);
+    n7.result_type = 5;
+    nodes.push(n7);
+    let n8 = with_deps(
+        neural_node(
+            8,
+            neural_op::SUMMARIZE,
+            profile::LARGE,
+            (256, 64),
+            (200, 60),
+        ),
+        &nodes,
+        &[4, 5, 6],
+    );
+    nodes.push(n8);
+    let n9 = with_deps(compute_node(9, compute_op::COMPILE), &nodes, &[8]);
+    nodes.push(n9);
+    let mut n10 = with_deps(compute_node(10, compute_op::ARITH), &nodes, &[4, 7]);
+    n10.result_type = 1;
+    nodes.push(n10);
+
+    let dag = Dag {
+        header: header(effect::COMPUTE, objective_id),
+        nodes,
+    };
+    Sample {
+        document: encode(&dag).unwrap(),
+        store,
+        readings_a,
+        readings_b,
+    }
+}
+
+/// Run a COMPUTE node for real: fetch operands by digest (refuse when one is
+/// missing) and dependency outputs by digest.
+fn run_compute(
+    run: &DagRun,
+    i: usize,
+    store: &HashMap<[u8; 32], Vec<u8>>,
+    outputs: &HashMap<[u8; 32], Vec<u8>>,
+) -> Option<Vec<u8>> {
+    let node = &run.dag().nodes[i];
+    let ops: Option<Vec<&Vec<u8>>> = node.operands.iter().map(|o| store.get(&o.digest)).collect();
+    let ops = ops?;
+    let deps: Vec<&Vec<u8>> = node
+        .deps
+        .iter()
+        .map(|d| &outputs[&run.output(d.index as usize).unwrap()])
+        .collect();
+    Some(match i {
+        0 | 1 => int_bytes(parse_list(ops[0]).iter().sum()),
+        2 => int_bytes(int_of(deps[0]) + int_of(deps[1])),
+        3 => {
+            let count: i64 = std::str::from_utf8(ops[0]).unwrap().parse().unwrap();
+            int_bytes(int_of(deps[0]) * 1000 / count)
+        }
+        4 => {
+            let threshold: i64 = std::str::from_utf8(ops[0]).unwrap().parse().unwrap();
+            vec![(int_of(deps[0]) > threshold) as u8]
+        }
+        7 => {
+            // Independent check: recompute the mean from the raw readings.
+            let all: Vec<i64> = parse_list(ops[0])
+                .into_iter()
+                .chain(parse_list(ops[1]))
+                .collect();
+            let mean = all.iter().sum::<i64>() * 1000 / all.len() as i64;
+            vec![(mean == int_of(deps[0])) as u8]
+        }
+        10 => {
+            assert_eq!(deps[1], &vec![1u8], "the independent check passed");
+            let mean = int_of(&outputs[&run.output(3).unwrap()]);
+            format!("mean_milli={mean};exceeds={}", deps[0][0]).into_bytes()
+        }
+        _ => return None,
+    })
+}
+
+fn execute(
+    run: &mut DagRun,
+    i: usize,
+    store: &HashMap<[u8; 32], Vec<u8>>,
+    outputs: &mut HashMap<[u8; 32], Vec<u8>>,
+) -> [u8; RECEIPT_LEN] {
+    assert_eq!(run.state(i), NodeState::Ready, "node {i} must be ready");
+    let out = run_compute(run, i, store, outputs).expect("operands present");
+    let bytes = signed(receipt(run, i, outcome::COMPLETED, 1, &out));
+    assert_eq!(run.apply(&bytes), Ok(Applied::New), "node {i}");
+    outputs.insert(sha(&out), out);
+    bytes
+}
+
+#[test]
+fn offline_sample_eleven_nodes_with_restart_and_checked_answer() {
+    let s = sample();
+    let mut outputs = HashMap::new();
+    let mut run = DagRun::admit(&s.document, trusted(), NOW).expect("sample admitted");
+    assert_eq!(run.dag().nodes.len(), 11);
+    assert_eq!(
+        canonical_order(&run.dag().nodes).unwrap(),
+        vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+    );
+    assert_eq!(run.state(0), NodeState::Ready);
+    assert_eq!(run.state(5), NodeState::Ready);
+    assert_eq!(run.state(2), NodeState::Waiting);
+
+    let mut stored = Vec::new();
+    for i in [0, 1, 2, 3, 4] {
+        stored.push(execute(&mut run, i, &s.store, &mut outputs));
+    }
+
+    // Interrupt: the receiver loses its memory and replays its stored log.
+    let log: Vec<[u8; RECEIPT_LEN]> = run.log().to_vec();
+    assert_eq!(log.len(), 5);
+    drop(run);
+    let mut run = DagRun::restore(&s.document, trusted(), NOW, &log).expect("restore");
+    for (i, st) in run.states().iter().enumerate() {
+        let want = match i {
+            0..=4 => NodeState::Done,
+            5 | 6 => NodeState::Ready,
+            7 => NodeState::Ready,
+            _ => NodeState::Waiting,
+        };
+        assert_eq!(*st, want, "node {i} after restart");
+    }
+    // Resume: the executor re-sends a receipt it is unsure arrived.
+    assert_eq!(run.apply(&stored[2]), Ok(Applied::Replay));
+    // A second, different commit of a finished node is refused.
+    let mut other = receipt(&run, 2, outcome::COMPLETED, 1, &int_bytes(999));
+    other.input_binding = run.expected_binding(2).unwrap();
+    assert_eq!(run.apply(&signed(other)), Err(Refusal::DoubleCommit));
+
+    // Two neural route nodes: fixture outputs, no model runs here.
+    for (i, text) in [(5usize, &b"skill:thermal"[..]), (6, &b"style:brief"[..])] {
+        let r = signed(receipt(&run, i, outcome::COMPLETED, 1, text));
+        assert_eq!(run.apply(&r), Ok(Applied::New));
+        outputs.insert(sha(text), text.to_vec());
+    }
+    execute(&mut run, 7, &s.store, &mut outputs);
+
+    // Node 8 is refused by its executor; node 9 is then blocked.
+    assert_eq!(run.state(8), NodeState::Ready);
+    let refused = signed(receipt(&run, 8, outcome::REFUSED, 1, b""));
+    assert_eq!(run.apply(&refused), Ok(Applied::New));
+    assert_eq!(run.state(8), NodeState::Refused);
+    assert_eq!(run.state(9), NodeState::Blocked);
+    let early = signed(receipt(&run, 9, outcome::COMPLETED, 1, b"x"));
+    assert_eq!(run.apply(&early), Err(Refusal::DepNotDone));
+
+    execute(&mut run, 10, &s.store, &mut outputs);
+
+    // The aggregate answer, checked against an independent computation.
+    let answer = &outputs[&run.output(10).unwrap()];
+    let all: Vec<i64> = parse_list(&s.readings_a)
+        .into_iter()
+        .chain(parse_list(&s.readings_b))
+        .collect();
+    let mean_milli = all.iter().sum::<i64>() * 1000 / all.len() as i64;
+    let expected = format!(
+        "mean_milli={mean_milli};exceeds={}",
+        (mean_milli > 23000) as u8
+    );
+    assert_eq!(answer, expected.as_bytes());
+    assert_eq!(expected, "mean_milli=23500;exceeds=1");
+
+    let states = run.states();
+    assert_eq!(
+        states,
+        vec![
+            NodeState::Done,
+            NodeState::Done,
+            NodeState::Done,
+            NodeState::Done,
+            NodeState::Done,
+            NodeState::Done,
+            NodeState::Done,
+            NodeState::Done,
+            NodeState::Refused,
+            NodeState::Blocked,
+            NodeState::Done,
+        ]
+    );
+    // Every input was available by digest.
+    for n in &run.dag().nodes {
+        for o in &n.operands {
+            if o.kind == operand::CONTENT {
+                assert!(s.store.contains_key(&o.digest));
+            }
+        }
+    }
+}
+
+#[test]
+fn pure_nodes_recompute_deterministically() {
+    let s = sample();
+    let mut outputs = HashMap::new();
+    let mut run = DagRun::admit(&s.document, trusted(), NOW).unwrap();
+    execute(&mut run, 0, &s.store, &mut outputs);
+    let again = run_compute(&run, 0, &s.store, &outputs).unwrap();
+    assert!(run.dag().nodes[0].pure);
+    assert_eq!(Some(sha(&again)), run.output(0));
+}
+
+#[test]
+fn missing_operand_is_refused_not_truncated() {
+    let mut s = sample();
+    let digest = sha(b"21,23,22");
+    s.store.remove(&digest);
+    let run = DagRun::admit(&s.document, trusted(), NOW).unwrap();
+    assert!(run_compute(&run, 0, &s.store, &HashMap::new()).is_none());
+}
+
+#[test]
+fn replaced_or_missing_operand_breaks_the_binding() {
+    let s = sample();
+    let mut run = DagRun::admit(&s.document, trusted(), NOW).unwrap();
+    let node = run.dag().nodes[0].clone();
+    // Replaced operand: computed from other bytes than the declared digest.
+    let mut swapped = node.operands.clone();
+    swapped[0].digest = sha(b"99,99,99");
+    let mut r = receipt(&run, 0, outcome::COMPLETED, 1, &int_bytes(297));
+    r.input_binding = input_binding(&[], &swapped);
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::BindingMismatch));
+    // Missing operand: binding computed without it.
+    let mut r = receipt(&run, 0, outcome::COMPLETED, 1, &int_bytes(0));
+    r.input_binding = input_binding(&[], &[]);
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::BindingMismatch));
+    // The honest receipt still applies: refusals changed nothing.
+    let ok = signed(receipt(&run, 0, outcome::COMPLETED, 1, &int_bytes(66)));
+    assert_eq!(run.apply(&ok), Ok(Applied::New));
+}
+
+#[test]
+fn forged_receipts_are_refused() {
+    let s = sample();
+    let mut run = DagRun::admit(&s.document, trusted(), NOW).unwrap();
+    // Signed by a key the receiver does not trust.
+    let mut r = receipt(&run, 0, outcome::COMPLETED, 1, &int_bytes(66));
+    sign_receipt(&mut r, &SigningKey::from_slice(&[0x13u8; 32]).unwrap());
+    assert_eq!(run.apply(&encode_receipt(&r)), Err(Refusal::ForgedReceipt));
+    // Trusted signer, then one signed byte changed.
+    let mut bytes = signed(receipt(&run, 0, outcome::COMPLETED, 1, &int_bytes(66)));
+    bytes[150] ^= 1;
+    assert_eq!(run.apply(&bytes), Err(Refusal::ForgedReceipt));
+    // Signature bytes changed.
+    let mut bytes = signed(receipt(&run, 0, outcome::COMPLETED, 1, &int_bytes(66)));
+    bytes[RECEIPT_LEN - 1] ^= 1;
+    assert_eq!(run.apply(&bytes), Err(Refusal::ForgedReceipt));
+}
+
+#[test]
+fn receipt_binding_rules() {
+    let s = sample();
+    let mut run = DagRun::admit(&s.document, trusted(), NOW).unwrap();
+    let base = receipt(&run, 0, outcome::COMPLETED, 1, &int_bytes(66));
+
+    let mut r = base.clone();
+    r.dag_digest = [9; 32];
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::WrongDag));
+
+    let mut r = base.clone();
+    r.job_id = [3; 16];
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::UnknownJob));
+
+    let mut r = base.clone();
+    r.idempotence_key = [3; 16];
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::UnknownJob));
+
+    let mut r = base.clone();
+    r.generation = 2;
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::StaleGeneration));
+
+    let mut r = base.clone();
+    r.model_hash = fill(0x3D);
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::ModelMismatch));
+
+    // Time and word (token) budget overruns.
+    let mut r = base.clone();
+    r.used_time_ms = run.dag().nodes[0].time_ms + 1;
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::ReceiptOverBudget));
+    let mut r = receipt(&run, 5, outcome::COMPLETED, 1, b"skill:thermal");
+    r.used_output_tokens = 17;
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::ReceiptOverBudget));
+
+    // Dependencies first.
+    let r = receipt(&run, 2, outcome::COMPLETED, 1, &int_bytes(141));
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::DepNotDone));
+
+    // Static receipt rules and unknown receipt version.
+    let mut bytes = signed(base.clone());
+    bytes[4] = 2;
+    assert_eq!(run.apply(&bytes), Err(Refusal::BadReceipt));
+    let mut r = base.clone();
+    r.output_digest = [0; 32];
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::BadReceipt));
+    let mut r = base.clone();
+    r.verifier_verdict = [0; 32];
+    assert_eq!(run.apply(&signed(r)), Err(Refusal::BadReceipt));
+    assert_eq!(run.apply(&[0u8; 10]), Err(Refusal::BadReceipt));
+
+    // A proposal is not a receipt: nothing above changed state.
+    assert!(run.log().is_empty());
+    assert_eq!(run.apply(&signed(base)), Ok(Applied::New));
+}
+
+#[test]
+fn retry_and_exhaustion() {
+    let s = sample();
+    let mut run = DagRun::admit(&s.document, trusted(), NOW).unwrap();
+    // Node 0: IDEMPOTENT, 3 attempts.
+    let f1 = signed(receipt(&run, 0, outcome::FAILED, 1, b""));
+    assert_eq!(run.apply(&f1), Ok(Applied::New));
+    assert_eq!(run.state(0), NodeState::Ready);
+    let mut again = receipt(&run, 0, outcome::FAILED, 1, b"");
+    again.used_work = 1;
+    assert_eq!(run.apply(&signed(again)), Err(Refusal::BadRetry));
+    let skip = signed(receipt(&run, 0, outcome::FAILED, 3, b""));
+    assert_eq!(run.apply(&skip), Err(Refusal::BadRetry));
+    let f2 = signed(receipt(&run, 0, outcome::FAILED, 2, b""));
+    let f3 = signed(receipt(&run, 0, outcome::FAILED, 3, b""));
+    assert_eq!(run.apply(&f2), Ok(Applied::New));
+    assert_eq!(run.apply(&f3), Ok(Applied::New));
+    assert_eq!(run.state(0), NodeState::Exhausted);
+    assert_eq!(run.state(2), NodeState::Blocked);
+    let f4 = signed(receipt(&run, 0, outcome::FAILED, 4, b""));
+    assert_eq!(run.apply(&f4), Err(Refusal::BadRetry));
+}
+
+fn effect_doc(retry_class: u8, attempts: u8) -> Vec<u8> {
+    let mut n = compute_node(0, compute_op::ARITH);
+    n.effect_class = effect::EFFECT;
+    n.pure = false;
+    n.verifier_kind = verifier::JUDGE;
+    n.verifier_ref = fill(0x99);
+    n.retry_class = retry_class;
+    n.max_attempts = attempts;
+    n.cancel_mode = cancel::CHECKPOINT;
+    n.operands = vec![Operand {
+        kind: operand::WORLD_STATE,
+        generation: 1,
+        digest: fill(0xE0),
+    }];
+    encode(&Dag {
+        header: header(effect::EFFECT, fill(0x0B)),
+        nodes: vec![n],
+    })
+    .unwrap()
+}
+
+#[test]
+fn uncertain_effect_needs_reconcile_first_and_never_blind_retry() {
+    let doc = effect_doc(retry::RECONCILE_FIRST, 2);
+    let mut run = DagRun::admit(&doc, trusted(), NOW).unwrap();
+    let u = signed(receipt(&run, 0, outcome::UNCERTAIN, 1, b""));
+    assert_eq!(run.apply(&u), Ok(Applied::New));
+    assert_eq!(run.state(0), NodeState::Uncertain);
+    let done = signed(receipt(&run, 0, outcome::COMPLETED, 2, b"written"));
+    assert_eq!(run.apply(&done), Ok(Applied::New));
+    assert_eq!(run.state(0), NodeState::Done);
+
+    // NEVER: one attempt only; an UNCERTAIN outcome is final.
+    let doc = effect_doc(retry::NEVER, 1);
+    let mut run = DagRun::admit(&doc, trusted(), NOW).unwrap();
+    let u = signed(receipt(&run, 0, outcome::UNCERTAIN, 1, b""));
+    assert_eq!(run.apply(&u), Ok(Applied::New));
+    assert_eq!(run.state(0), NodeState::Exhausted);
+    let retry = signed(receipt(&run, 0, outcome::COMPLETED, 2, b"written"));
+    assert_eq!(run.apply(&retry), Err(Refusal::BadRetry));
+
+    // An EFFECT node may never be IDEMPOTENT.
+    assert_eq!(
+        decode(&effect_doc(retry::IDEMPOTENT, 2)),
+        Err(Refusal::BadRetry)
+    );
+}
+
+#[test]
+fn cancel_is_atomic_with_receipts() {
+    let s = sample();
+    let mut outputs = HashMap::new();
+    let mut run = DagRun::admit(&s.document, trusted(), NOW).unwrap();
+    let r0 = execute(&mut run, 0, &s.store, &mut outputs);
+    run.cancel();
+    let late = signed(receipt(&run, 1, outcome::COMPLETED, 1, &int_bytes(75)));
+    assert_eq!(run.apply(&late), Err(Refusal::Cancelled));
+    assert_eq!(run.apply(&r0), Ok(Applied::Replay));
+    assert_eq!(run.state(0), NodeState::Done);
+    assert_eq!(run.state(1), NodeState::Cancelled);
+    assert_eq!(run.state(10), NodeState::Cancelled);
+}
+
+#[test]
+fn effects_are_never_wider_than_the_approval() {
+    let mut doc = effect_doc(retry::RECONCILE_FIRST, 2);
+    doc[5] = effect::COMPUTE; // the approval covers COMPUTE only
+    assert_eq!(decode(&doc), Err(Refusal::UnauthorizedEffect));
+}
+
+#[test]
+fn cross_tenant_node_is_refused() {
+    let s = sample();
+    let mut dag = decode(&s.document).unwrap();
+    dag.nodes[6].tenant_id = fill(0x11);
+    assert_eq!(decode(&encode(&dag).unwrap()), Err(Refusal::CrossTenant));
+}
+
+#[test]
+fn minimal_profile_refuses_instead_of_truncating_then_expands() {
+    let mut store = HashMap::new();
+    let request = "Summarise the effect of the three failed greenhouse heater runs on the next \
+                   planting window, keeping every sensor id and timestamp exact.";
+    let op = content(&mut store, request.as_bytes());
+    // The planner measured 90 essential input tokens: 64/16 cannot hold them.
+    let mut n = neural_node(0, neural_op::EXTRACT, profile::MINIMAL, (64, 16), (90, 12));
+    n.operands = vec![op];
+    let mut dag = Dag {
+        header: header(effect::NONE, fill(0x0B)),
+        nodes: vec![n],
+    };
+    assert_eq!(decode(&encode(&dag).unwrap()), Err(Refusal::NeedsExpansion));
+    // Explicit expansion to the DEFAULT profile, nothing trimmed.
+    dag.nodes[0].profile = profile::DEFAULT;
+    dag.nodes[0].input_tokens = 128;
+    dag.nodes[0].output_tokens = 32;
+    let accepted = decode(&encode(&dag).unwrap()).unwrap();
+    assert_eq!(accepted.nodes[0].required_input_tokens, 90);
+    assert_eq!(
+        accepted.nodes[0].operands[0].digest,
+        sha(request.as_bytes())
+    );
+}
+
+#[test]
+fn dependency_version_invalidation() {
+    let s = sample();
+    let mut outputs = HashMap::new();
+    let mut run = DagRun::admit(&s.document, trusted(), NOW).unwrap();
+    let r0 = execute(&mut run, 0, &s.store, &mut outputs);
+
+    // Node 0's input changes: it takes generation 2. A dependent still naming
+    // generation 1 is stale.
+    let mut dag = decode(&s.document).unwrap();
+    dag.nodes[0].generation = 2;
+    assert_eq!(
+        decode(&encode(&dag).unwrap()),
+        Err(Refusal::StaleGeneration)
+    );
+    // Re-plan: the dependent names the new generation; new document digest.
+    dag.nodes[2].deps[0].generation = 2;
+    dag.header.incarnation = 2;
+    let doc2 = encode(&dag).unwrap();
+    let mut run2 = DagRun::admit(&doc2, trusted(), NOW).unwrap();
+    assert_ne!(run2.digest(), run.digest());
+    assert_eq!(run2.apply(&r0), Err(Refusal::WrongDag));
+}
+
+#[test]
+fn unknown_versions_and_expired_documents() {
+    let s = sample();
+    let mut doc = s.document.clone();
+    doc[4] = 2;
+    assert_eq!(decode(&doc), Err(Refusal::BadVersion));
+    doc[4] = 0;
+    assert_eq!(decode(&doc), Err(Refusal::Downgrade));
+    assert_eq!(
+        DagRun::admit(&s.document, trusted(), EXPIRES + 1).err(),
+        Some(Refusal::BadExpiry)
+    );
+}
+
+#[test]
+fn cycles_are_refused() {
+    let s = sample();
+    let mut dag = decode(&s.document).unwrap();
+    dag.nodes[0].deps = vec![Dep {
+        index: 10,
+        generation: 1,
+    }];
+    assert_eq!(decode(&encode(&dag).unwrap()), Err(Refusal::Cycle));
+}
+
+#[test]
+fn verifier_is_required() {
+    let s = sample();
+    let mut dag = decode(&s.document).unwrap();
+    dag.nodes[5].verifier_kind = 0;
+    assert_eq!(decode(&encode(&dag).unwrap()), Err(Refusal::NoVerifier));
+}
+
+#[test]
+fn over_budget_documents_are_refused() {
+    let s = sample();
+    let mut dag = decode(&s.document).unwrap();
+    dag.header.budget_time_ms = 11 * 100 - 1;
+    assert_eq!(decode(&encode(&dag).unwrap()), Err(Refusal::OverBudget));
+}
diff --git a/crates/aien-microjob/tests/vectors.rs b/crates/aien-microjob/tests/vectors.rs
new file mode 100644
index 0000000..05a9d25
--- /dev/null
+++ b/crates/aien-microjob/tests/vectors.rs
@@ -0,0 +1,56 @@
+//! Walks `specs/microjob/vectors/expected.txt` and requires the Rust reader to
+//! print the same verdict line as the C reference checker
+//! (`tools/mjb_verify.c`) for every file, and to write every accepted document
+//! back out as the identical bytes.
+
+use std::path::PathBuf;
+
+use aien_microjob::{decode, encode, verdict_line};
+
+fn vectors_dir() -> PathBuf {
+    PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../specs/microjob/vectors")
+}
+
+#[test]
+fn every_expected_line_matches_the_c_checker() {
+    let dir = vectors_dir();
+    let list = std::fs::read_to_string(dir.join("expected.txt")).expect("read expected.txt");
+    let mut checked = 0usize;
+    let mut accepted = 0usize;
+    let mut failures = Vec::new();
+    for line in list.lines() {
+        if line.is_empty() || line.starts_with('#') {
+            continue;
+        }
+        let (name, want) = line
+            .split_once(' ')
+            .expect("line has a file name and a verdict");
+        let bytes = std::fs::read(dir.join(name)).expect("read vector");
+        let got = verdict_line(&bytes);
+        if got != want {
+            failures.push(format!("{name}\n  expected: {want}\n  got:      {got}"));
+        }
+        if let Ok(dag) = decode(&bytes) {
+            let again = encode(&dag).expect("re-encode accepted document");
+            if again != bytes {
+                failures.push(format!("{name}: round trip gave different bytes"));
+            }
+            accepted += 1;
+        }
+        checked += 1;
+    }
+    assert!(
+        failures.is_empty(),
+        "{} of {checked} vectors differ:\n{}",
+        failures.len(),
+        failures.join("\n")
+    );
+    assert!(
+        checked >= 100,
+        "expected at least 100 vectors, found {checked}"
+    );
+    assert!(
+        accepted >= 8,
+        "expected at least 8 accepted vectors, found {accepted}"
+    );
+}
diff --git a/crates/aien-provenance/src/lib.rs b/crates/aien-provenance/src/lib.rs
index 0ff2075..1fc54ac 100644
--- a/crates/aien-provenance/src/lib.rs
+++ b/crates/aien-provenance/src/lib.rs
@@ -198,6 +198,55 @@ impl SourceGrant {
     }
 }
 
+/// Bytes in a SEC1 compressed P-256 public key (first byte 0x02 or 0x03).
+pub const P256_KEY_LEN: usize = 33;
+/// Bytes in a raw P-256 ECDSA signature, `r` then `s`.
+pub const P256_SIG_LEN: usize = 64;
+
+/// The SEC1 compressed encoding of the verifying key of `key`, the form the
+/// fixed-width records of `specs/microjob` and `specs/discovery-capsule` carry.
+pub fn p256_compressed_key(key: &SigningKey) -> [u8; P256_KEY_LEN] {
+    let point = VerifyingKey::from(key).to_sec1_point(true);
+    let mut out = [0u8; P256_KEY_LEN];
+    out.copy_from_slice(point.as_bytes());
+    out
+}
+
+/// ECDSA P-256 / SHA-256 signature over `message`, normalized to low S so one
+/// message and key have one accepted signature form per nonce.
+pub fn p256_sign_low_s(key: &SigningKey, message: &[u8]) -> [u8; P256_SIG_LEN] {
+    let sig: Signature = key.sign(message);
+    let mut out = [0u8; P256_SIG_LEN];
+    out.copy_from_slice(&sig.normalize_s().to_bytes());
+    out
+}
+
+/// Verify a raw low-S ECDSA P-256 / SHA-256 signature over `message` against
+/// a SEC1 compressed public key. A high-S signature is refused even when it
+/// is mathematically valid (malleability).
+pub fn p256_verify_low_s(
+    public_key: &[u8; P256_KEY_LEN],
+    message: &[u8],
+    signature: &[u8; P256_SIG_LEN],
+) -> Result<(), ProvenanceError> {
+    if public_key[0] != 0x02 && public_key[0] != 0x03 {
+        return Err(ProvenanceError::InvalidSignatureFormat(
+            "public key is not SEC1 compressed".into(),
+        ));
+    }
+    let vk = VerifyingKey::from_sec1_bytes(public_key)
+        .map_err(|e| ProvenanceError::InvalidSignatureFormat(e.to_string()))?;
+    let sig = Signature::from_slice(signature)
+        .map_err(|e| ProvenanceError::InvalidSignatureFormat(e.to_string()))?;
+    if sig.normalize_s() != sig {
+        return Err(ProvenanceError::InvalidSignatureFormat(
+            "high-S signature".into(),
+        ));
+    }
+    vk.verify(message, &sig)
+        .map_err(|e| ProvenanceError::SignatureVerificationFailed(e.to_string()))
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
@@ -270,6 +319,24 @@ mod tests {
             .is_ok());
     }
 
+    #[test]
+    fn test_p256_region_signature_low_s() {
+        let key = SigningKey::from_slice(&[7u8; 32]).unwrap();
+        let pubkey = p256_compressed_key(&key);
+        assert!(pubkey[0] == 0x02 || pubkey[0] == 0x03);
+        let sig = p256_sign_low_s(&key, b"region");
+        assert!(p256_verify_low_s(&pubkey, b"region", &sig).is_ok());
+        assert!(p256_verify_low_s(&pubkey, b"regioN", &sig).is_err());
+
+        // The high-S twin of a valid signature is refused.
+        let parsed = Signature::from_slice(&sig).unwrap();
+        let (r, s) = parsed.split_scalars();
+        let high = Signature::from_scalars(r, -*s).unwrap();
+        let mut high_bytes = [0u8; P256_SIG_LEN];
+        high_bytes.copy_from_slice(&high.to_bytes());
+        assert!(p256_verify_low_s(&pubkey, b"region", &high_bytes).is_err());
+    }
+
     #[test]
     fn signed_grant_boundary_substitution_is_refused() {
         let signing_key = SigningKey::from_slice(&[33u8; 32]).unwrap();
diff --git a/specs/discovery-capsule/.crumb b/specs/discovery-capsule/.crumb
new file mode 100644
index 0000000..8f9f6df
--- /dev/null
+++ b/specs/discovery-capsule/.crumb
@@ -0,0 +1,5 @@
+{
+  "name": "discovery-capsule",
+  "purpose": "DCP1 family: Discovery Capsule, owner consent, retraction, ack and experience lineage format (draft), C checker, vectors and mutants",
+  "schema_version": "1.0.0"
+}
diff --git a/specs/discovery-capsule/SPEC.md b/specs/discovery-capsule/SPEC.md
new file mode 100644
index 0000000..8db7a3a
--- /dev/null
+++ b/specs/discovery-capsule/SPEC.md
@@ -0,0 +1,229 @@
+# Discovery Capsule, Owner Consent, Retraction and Experience Lineage: DCP1 family
+
+**Status**: Draft v0.1 (SI GENESIS C2, 2026-10-24). Not yet produced or read by any runtime. Reference checker and vectors: `tools/dcp_verify.c`, `vectors/`. Rust reader, signature checks and recipient rules: `crates/aien-discovery-capsule`.
+**Contract version**: 0.1.0 (major zero: may change by minor bump, see VERSIONING.md)
+**Wire version**: 1 (the `version` byte of every record)
+**License**: Community Specification License 1.0
+**Tracking**: aien-dev/aien-protocols-mv#51 (C2), parent aien-dev/aien-architecture-mv#307; consumes the microjob ABI of #50 (`specs/microjob/`) by digest; bootstrap issues aien-architecture-mv#310 (si-genesis) and #312 (si-legacy) consume this contract and must not define a second schema.
+**Not in this document**: transport and publication (Open Humanity), storage (Omega Cortex is the one local store), effect approval (AEGIS), scientific gain (Spark RSI and the independent judge), spendable credit (Sovereign Core ledger), a new cryptosystem.
+
+## 1. Purpose
+
+A Discovery Capsule carries one reusable, proof-carrying result (a typed `.om` claim or procedure, or a reference to it) from the owner who found it to recipients who may check and reuse it. It binds exactly what was found, how it was built, under which preconditions it holds, how it was independently verified, where it fails, what the owner consents to, and where the owner's retraction chain stood when it was signed.
+
+Five fixed-width records make up the family:
+
+| Magic | Record | Signed by | Length |
+|---|---|---|---|
+| `DCP1` | `DiscoveryCapsuleV1` | owner | 676 |
+| `DCC1` | `OwnerConsentV1` | owner | 388 |
+| `DCR1` | `OwnerRetractionV1` | owner or a declared custodian | 284 |
+| `DCA1` | `RetractionAckV1` | recipient | 148 |
+| `DCL1` | `ExperienceLineageV1` | owner | 588 |
+
+## 2. What a capsule is not
+
+1. **A capsule never authorizes itself.** It has no approval field, no grant, no capability token. Possessing a capsule, or its digest, gives no tool access, no GPU code execution and no proof. A recipient may execute a capsule only after its *own* independent verifier, run under the recipient's platform, passes it, and only within capabilities the recipient's authority (AEGIS, Omega skill / World authorization) grants. A verdict produced by the capsule's owner key is refused as self-authorization.
+2. Discoverability, reproducible correctness (the verifier and evidence references), the source signature, consent to **read**, consent to **redistribute** and permission to **train** are distinct fields. None implies another, except that redistributing or training requires reading.
+3. **Private is the default.** A `PRIVATE` capsule carries no permission bit. Nothing in this family uploads Cortex content; a capsule carries digests and a typed reference, and the bytes behind a reference move only through Open Humanity under the owner's consent.
+4. **Retraction is not deletion.** A retraction stops future availability, retrieval, training eligibility and republication at every compliant recipient that acknowledges it. It does not and cannot delete disconnected third-party copies or undo training already absorbed into weights. The wire format has no "erased" state, and a retraction that claims erasure is refused (`DCP_FALSE_ERASURE_CLAIM`).
+
+## 3. Inventory of what already exists
+
+| Existing piece | Where | Reused? | Reason |
+|---|---|---|---|
+| P-256 ECDSA / SHA-256 | `crates/aien-provenance` | Yes | Same primitive as the signed source grants of this repository; low-S only. No new cryptosystem. |
+| `GrantPermissions` (READ, TRAIN, REDISTRIBUTE...) | `crates/aien-provenance` | Pattern only | Its bits are a JSON grant; this family needs fixed-width bytes and a separate DISCOVER bit. Bit names match where they overlap. |
+| MJB1 microjob DAG | `specs/microjob/` (#50) | Yes, by digest | `microjob_ref` names the MJB1 `dag_digest` that produced the capsule; an MJB1 operand of kind CAPSULE names a capsule digest. |
+| PST1 / OSH stream ABI | `specs/pi-spark-task/`, `specs/osh-platform/` (#43) | Carrier only | Records travel as opaque bytes; this family defines no transport. |
+| Open Humanity consent and retraction | open-humanity #26/#27/#28, #33, #34 | Owner of transport and human approval | This family is the wire contract they carry; OH owns publishing, privacy and delivery. |
+| Omega experience event | omega-mv#699 | Yes, by digest | `ExperienceLineageV1.content_digest` names one verified experience. |
+
+## 4. Encoding rules
+
+1. All integers are big-endian and unsigned. Digests are 32 raw bytes (SHA-256). Keys are 33-byte SEC1 compressed P-256 points (first byte 0x02 or 0x03).
+2. Every reserved byte and every unused slot is zero on send and refused if non-zero on receipt. Every enumerated byte or bit set is closed; an unknown value is refused.
+3. Each record ends in a 64-byte signature: ECDSA P-256 / SHA-256 over every byte before it, `r` then `s`, low-S only.
+4. A record's identity is `record_digest = SHA-256(every byte before the signature)`. The signature is excluded, so re-signing never changes identity.
+
+## 5. DiscoveryCapsuleV1 (`DCP1`), 676 bytes
+
+| Offset | Size | Field | Allowed values |
+|---|---|---|---|
+| 0 | 4 | `magic` | `DCP1` |
+| 4 | 1 | `version` | 1 |
+| 5 | 1 | `share_scope` | 0 PRIVATE, 1 NAMED, 2 COMMUNITY, 3 PUBLIC |
+| 6 | 1 | `permissions` | bit 0 DISCOVER, bit 1 READ, bit 2 REDISTRIBUTE, bit 3 TRAIN; bits 4 to 7 zero |
+| 7 | 1 | `precision` | 0 EXACT, 1 FP32, 2 BF16, 3 FP16, 4 FP8, 5 INT8, 6 INT4 |
+| 8 | 2 | `license` | 1 Apache-2.0, 2 MIT, 3 CC-BY-4.0, 4 CC-BY-SA-4.0, 5 CDLA-Permissive-2.0, 6 OWNER-CONSENT-ONLY |
+| 10 | 2 | `failure_count` | Number of known counterexamples / failure cases |
+| 12 | 4 | `abi_version` | Not zero: the Omega / OSC ABI the executable targets |
+| 16 | 4 | `required_capabilities` | bit 0 CPU_COMPUTE, 1 GPU_COMPUTE, 2 CORTEX_READ, 3 WORLD_READ, 4 WORLD_EFFECT, 5 NETWORK; bits 6 to 31 zero. A request, never a grant |
+| 20 | 1 | `precondition_rank` | 0 to 4 |
+| 21 | 3 | `reserved0` | 0 |
+| 24 | 16 | `precondition_dims` | 4 x u32; entries past the rank are zero |
+| 40 | 8 | `valid_from` | Unix seconds, not zero |
+| 48 | 8 | `expires_at` | Above `valid_from` |
+| 56 | 8 | `revocation_seq` | The owner's retraction chain head sequence when signed; 0 = no retraction yet |
+| 64 | 32 | `meaning_digest` | Not zero: the typed `.om` claim / procedure (the published fragment) |
+| 96 | 32 | `source_digest` | Not zero |
+| 128 | 32 | `compiler_digest` | Not zero |
+| 160 | 32 | `executable_digest` | Not zero |
+| 192 | 32 | `preconditions_digest` | Not zero: valid input preconditions and shape |
+| 224 | 32 | `verifier_ref` | Not zero: the independent verifier |
+| 256 | 32 | `evidence_digest` | Not zero: benchmark provenance and verification evidence |
+| 288 | 32 | `failure_cases_digest` | Not zero exactly when `failure_count` is not zero |
+| 320 | 32 | `utility_verdict_ref` | Quality / utility verdict reference; zero = NOT_RUN |
+| 352 | 32 | `science_verdict_ref` | Strict scientific-T verdict reference; zero = NOT_RUN. Never implied by the other fields |
+| 384 | 32 | `recipient_policy_digest` | Not zero: the policy a recipient must run before reuse |
+| 416 | 32 | `recipient_set_digest` | Not zero exactly when `share_scope` is NAMED (section 9) |
+| 448 | 32 | `consent_ref` | `record_digest` of the `OwnerConsentV1`; required when any of READ, REDISTRIBUTE, TRAIN is set or the scope is not PRIVATE |
+| 480 | 32 | `revocation_head` | `record_digest` of the retraction at `revocation_seq`; zero exactly when `revocation_seq` is 0 |
+| 512 | 32 | `parent_capsule` | `record_digest` of the capsule this one derives from; zero = none |
+| 544 | 32 | `microjob_ref` | MJB1 `dag_digest` that produced it; zero = none |
+| 576 | 33 | `owner_key` | Pseudonymous owner key |
+| 609 | 3 | `reserved1` | 0 |
+| 612 | 64 | `signature` | By `owner_key` |
+
+## 6. OwnerConsentV1 (`DCC1`), 388 bytes
+
+| Offset | Size | Field | Allowed values |
+|---|---|---|---|
+| 0 | 4 | `magic` | `DCC1` |
+| 4 | 1 | `version` | 1 |
+| 5 | 1 | `purposes` | Same bits as `permissions`; not zero |
+| 6 | 1 | `custodian_count` | 0 to 4 |
+| 7 | 1 | `reserved0` | 0 |
+| 8 | 4 | `consent_version` | At least 1; a newer consent for the same fragment has a higher version |
+| 12 | 4 | `notice_seconds` | Advance notice the owner gives before a change takes effect |
+| 16 | 8 | `issued_at` | Unix seconds, not zero |
+| 24 | 8 | `retention_end` | Above `issued_at`; no use after it |
+| 32 | 32 | `provenance_digest` | Not zero |
+| 64 | 32 | `recipient_digest` | Not zero: the exact recipient or destination set |
+| 96 | 32 | `fragment_digest` | Not zero: the published fragment (equals the capsule `meaning_digest`) |
+| 128 | 32 | `payload_digest` | Not zero: the canonical payload digest |
+| 160 | 128 | `custodians` | 4 slots of SHA-256(custodian key); used slots not zero, unused slots zero. Successors or custodians exist only when declared here |
+| 288 | 33 | `owner_key` | |
+| 321 | 3 | `reserved1` | 0 |
+| 324 | 64 | `signature` | By `owner_key` |
+
+## 7. OwnerRetractionV1 (`DCR1`), 284 bytes
+
+| Offset | Size | Field | Allowed values |
+|---|---|---|---|
+| 0 | 4 | `magic` | `DCR1` |
+| 4 | 1 | `version` | 1 |
+| 5 | 1 | `scope` | bit 0 FUTURE_AVAILABILITY, bit 1 RETRIEVAL, bit 2 TRAINING, bit 3 REPUBLICATION; not zero; bits 4 to 7 zero |
+| 6 | 1 | `erasure_claim` | 0 (NONE). Any other value is refused: no record may claim deletion of copies or trained weights |
+| 7 | 1 | `reserved0` | 0 |
+| 8 | 8 | `seq` | At least 1; the owner's chain is strictly monotonic |
+| 16 | 8 | `effective_at` | Unix seconds, not zero |
+| 24 | 32 | `target_digest` | Not zero: a capsule `record_digest`, a capsule `meaning_digest`, or an experience `content_digest` (the lineage root) |
+| 56 | 32 | `prev_retraction` | `record_digest` of the retraction at `seq - 1`; zero exactly when `seq` is 1 |
+| 88 | 32 | `provenance_digest` | Not zero |
+| 120 | 32 | `tombstone_digest` | Not zero: digest of the minimal privacy-safe tombstone (no private bytes) |
+| 152 | 33 | `owner_key` | Whose chain this is |
+| 185 | 33 | `signer_key` | `owner_key`, or a custodian declared in the owner's consent |
+| 218 | 2 | `reserved1` | 0 |
+| 220 | 64 | `signature` | By `signer_key` |
+
+## 8. RetractionAckV1 (`DCA1`), 148 bytes
+
+| Offset | Size | Field | Allowed values |
+|---|---|---|---|
+| 0 | 4 | `magic` | `DCA1` |
+| 4 | 1 | `version` | 1 |
+| 5 | 1 | `status` | 1 ENFORCED (future use stopped, no retained derived artifacts), 2 ENFORCED_WITH_RETAINED (future use stopped; the recipient holds copies or trained descendants it marks affected) |
+| 6 | 2 | `reserved0` | 0 |
+| 8 | 8 | `acked_at` | Unix seconds, not zero |
+| 16 | 32 | `retraction_digest` | Not zero: the `record_digest` acknowledged |
+| 48 | 33 | `recipient_key` | |
+| 81 | 3 | `reserved1` | 0 |
+| 84 | 64 | `signature` | By `recipient_key` |
+
+## 9. ExperienceLineageV1 (`DCL1`), 588 bytes
+
+| Offset | Size | Field | Allowed values |
+|---|---|---|---|
+| 0 | 4 | `magic` | `DCL1` |
+| 4 | 1 | `version` | 1 |
+| 5 | 1 | `parent_count` | 0 to 4 |
+| 6 | 1 | `influenced_count` | 0 to 8 |
+| 7 | 1 | `reserved0` | 0 |
+| 8 | 32 | `content_digest` | Not zero: one verified experience (omega-mv#699 event) |
+| 40 | 32 | `dataset_id` | Not zero: the dataset this experience belongs to |
+| 72 | 32 | `consent_ref` | Not zero: the owner's consent record |
+| 104 | 128 | `parents` | 4 slots: `content_digest` of parent experiences; used slots not zero, distinct and not this record's own `content_digest`; unused zero |
+| 232 | 256 | `influenced` | 8 slots: checkpoint or capsule digests this experience influenced; used not zero, unused zero |
+| 488 | 33 | `owner_key` | |
+| 521 | 3 | `reserved1` | 0 |
+| 524 | 64 | `signature` | By `owner_key` |
+
+Named recipient set: `recipient_set_digest = SHA-256("DCP1-RECIPIENTS" || keys)`, keys sorted bytewise ascending, no duplicates.
+
+## 10. Static check order
+
+One checker reads any record of the family and reports the first failing rule:
+
+1. Fewer than 5 bytes: `DCP_BAD_LENGTH`.
+2. Magic not one of the five: `DCP_BAD_MAGIC`.
+3. `version` 0: `DCP_DOWNGRADE`; above 1: `DCP_BAD_VERSION`.
+4. Length differs from the record length: `DCP_BAD_LENGTH`.
+5. A reserved byte, an unused slot or a dimension past the rank is not zero: `DCP_RESERVED_NONZERO`.
+6. An enumerated value or bit set is outside its closed set, including a zero `purposes` or `scope`, or a count above its slot count: `DCP_BAD_ENUM`.
+7. (`DCP1`) `license` is not 1 to 6: `DCP_UNKNOWN_LICENSE`.
+8. (`DCR1`) `erasure_claim` is not 0: `DCP_FALSE_ERASURE_CLAIM`.
+9. A field marked "not zero" is zero (including `abi_version`, `consent_version`, `seq`, a used slot): `DCP_MISSING_FIELD`.
+10. A key whose first byte is not 0x02 or 0x03: `DCP_BAD_KEY`.
+11. A time rule fails (`valid_from` zero or `expires_at` not above it; `retention_end` not above `issued_at`; `issued_at`, `effective_at` or `acked_at` zero): `DCP_BAD_VALIDITY`.
+12. A paired rule fails (`failure_count` vs `failure_cases_digest`; `revocation_seq` vs `revocation_head`; `seq` vs `prev_retraction`): `DCP_INCONSISTENT`.
+13. (`DCP1`) PRIVATE with any permission bit; or `recipient_set_digest` zero for NAMED, or not zero for another scope: `DCP_SCOPE_CONFLICT`.
+14. (`DCP1`, `DCC1`) REDISTRIBUTE or TRAIN without READ: `DCP_PERMISSION_AMPLIFICATION`.
+15. (`DCP1`) `consent_ref` zero while READ, REDISTRIBUTE or TRAIN is set or the scope is not PRIVATE: `DCP_NO_CONSENT`.
+16. (`DCL1`) A parent equal to the record's own `content_digest`: `DCP_ANCESTOR_CYCLE`. The same parent twice: `DCP_DUPLICATE`.
+
+## 11. Recipient rules (stateful)
+
+These need keys, a clock and the recipient's own records, so they live in the Rust crate, not the C checker. A refusal changes no state.
+
+| Code | Rule |
+|---|---|
+| `DCP_BAD_SIGNATURE` | The signature does not verify under the record's signing key, or is high-S. An edited capsule lands here |
+| `DCP_OWNER_MISMATCH` | Consent, retraction or lineage owner differs from the capsule owner |
+| `DCP_NO_CONSENT` | `consent_ref` is not the digest of the consent supplied, or the consent `fragment_digest` is not the capsule `meaning_digest` |
+| `DCP_PERMISSION_AMPLIFICATION` | Capsule permissions not a subset of the consent purposes, or of the parent capsule's permissions |
+| `DCP_PRIVATE` | A PRIVATE capsule offered to anyone but its owner |
+| `DCP_NOT_RECIPIENT` | NAMED scope and the recipient is not in the set whose digest the capsule binds; or an ack from a key that was not sent the retraction |
+| `DCP_EXPIRED` | Outside `[valid_from, expires_at]`, or after the consent `retention_end` |
+| `DCP_STALE` | The capsule names a `revocation_seq` the recipient's copy of the owner's chain has not reached (the recipient must sync first), a newer `consent_version` for the same fragment is known, or the recipient holds no chain for the owner of a lineage ancestor |
+| `DCP_REVOKED` | A retraction in the owner's chain targets the capsule (record or meaning digest) or a lineage ancestor, with a scope covering the requested use: serving needs neither FUTURE_AVAILABILITY nor RETRIEVAL; training needs no TRAINING; republication needs no REPUBLICATION |
+| `DCP_NOT_PERMITTED` | The requested use (READ, REDISTRIBUTE, TRAIN) is not in the capsule permissions |
+| `DCP_CONFLICT` | A retraction with a sequence already used but different bytes (concurrent conflicting owner operations), a sequence gap, a `prev_retraction` that is not the current head, a capsule whose `revocation_head` differs from the chain at its `revocation_seq`, a second different ack from one recipient, or an ack for another retraction. Fails closed |
+| `DCP_UNKNOWN_CUSTODIAN` | A retraction signed by a key that is neither the owner nor a custodian declared in the owner's consent |
+| `DCP_SELF_AUTHORIZED` | An execution verdict produced by the capsule owner's key |
+| `DCP_UNVERIFIED` | No passing verdict from the recipient's own verifier for this exact capsule digest and recipient platform |
+| `DCP_CAPABILITY_DENIED` | The recipient's grant does not cover `required_capabilities` |
+| `DCP_DUPLICATE` | Two different lineage records for one `content_digest` |
+| `DCP_CROSS_DATASET` | A lineage parent from another `dataset_id` (cross-dataset injection) |
+| `DCP_ANCESTOR_CYCLE` | The lineage parents form a cycle |
+| `DCP_UNKNOWN_PARENT` | A lineage parent the recipient does not hold when checking ancestry for training, or a `parent_capsule` the recipient was not given |
+
+A byte-identical repeat of an applied retraction or ack is a replay: accepted, no state change.
+
+### 11.1 Retraction status is honest
+
+For each retraction the owner's node tracks every recipient it was sent to as PENDING, ACKNOWLEDGED (with the ack status) or UNREACHABLE. A recipient that never answers stays PENDING; an offline recipient is never shown as acknowledged, and no state anywhere says "erased". ENFORCED_WITH_RETAINED acks are listed separately, with the influenced checkpoints of the affected lineage, so trained descendants can be quarantined, rebuilt or retired by their owner (aien-train#20).
+
+## 12. Refusal codes
+
+`DCP_BAD_LENGTH`, `DCP_BAD_MAGIC`, `DCP_DOWNGRADE`, `DCP_BAD_VERSION`, `DCP_RESERVED_NONZERO`, `DCP_BAD_ENUM`, `DCP_UNKNOWN_LICENSE`, `DCP_FALSE_ERASURE_CLAIM`, `DCP_MISSING_FIELD`, `DCP_BAD_KEY`, `DCP_BAD_VALIDITY`, `DCP_INCONSISTENT`, `DCP_SCOPE_CONFLICT`, `DCP_PERMISSION_AMPLIFICATION`, `DCP_NO_CONSENT`, `DCP_ANCESTOR_CYCLE`, `DCP_DUPLICATE` (static, section 10) and `DCP_BAD_SIGNATURE`, `DCP_OWNER_MISMATCH`, `DCP_PRIVATE`, `DCP_NOT_RECIPIENT`, `DCP_EXPIRED`, `DCP_STALE`, `DCP_REVOKED`, `DCP_NOT_PERMITTED`, `DCP_CONFLICT`, `DCP_UNKNOWN_CUSTODIAN`, `DCP_SELF_AUTHORIZED`, `DCP_UNVERIFIED`, `DCP_CAPABILITY_DENIED`, `DCP_CROSS_DATASET`, `DCP_UNKNOWN_PARENT` (recipient, section 11).
+
+## 13. Privacy
+
+No record carries private bytes: only digests, keys, counts, times and closed enumerations. The tombstone is referenced by digest and holds only what is needed to recognise the retracted target. Receipts and public metadata that cite a capsule cite its `record_digest`.
+
+## 14. Open questions
+
+1. The license registry (6 entries) and the capability bits (6) are first-cut closed sets; additions are a minor version bump.
+2. Whether a custodian may also issue consent (today only retractions).
+3. How Open Humanity maps its transport identities to the 33-byte keys (owner: open-humanity#33/#34).
diff --git a/specs/discovery-capsule/tools/check-vectors.sh b/specs/discovery-capsule/tools/check-vectors.sh
new file mode 100644
index 0000000..23db877
--- /dev/null
+++ b/specs/discovery-capsule/tools/check-vectors.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# check-vectors.sh: build the DCP1 reference checker and check the vectors.
+#
+# Usage: check-vectors.sh [CC]        (default CC: cc)
+#
+# 1. Builds tools/dcp_verify.c with warnings as errors (C99, libc only).
+# 2. Regenerates the vectors into a scratch directory (dcp_verify
+#    --make-vectors) and requires them byte-identical to vectors/, so a stale
+#    or hand-edited vector fails here.
+# 3. Runs every vectors/expected.txt line (and re-encodes every accepted
+#    message, which must give the same bytes), plus an ASan/UBSan build when
+#    the compiler supports it.
+# 4. Runs tools/mutate-verifier.sh: every check must be caught by a vector.
+# Host-only check: no hardware. Shell and C only. Found by the PROTO-C-VECTORS
+# gate (tests/gates/run.sh c-vectors) because its name matches check-*.sh.
+set -eu
+export LC_ALL=C
+here=$(cd "$(dirname "$0")" && pwd)
+vec="$here/../vectors"
+CC=${1:-cc}
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+
+"$CC" -std=c99 -O2 -Wall -Wextra -Werror -pedantic -o "$tmp/dcp_verify" "$here/dcp_verify.c"
+
+mkdir -p "$tmp/regen"
+"$tmp/dcp_verify" --make-vectors "$tmp/regen"
+ignore="-x .crumb -x .crumb.local -x .gitattributes"
+if ! diff -r $ignore "$vec" "$tmp/regen" >/dev/null; then
+    echo "DCP1_VECTORS_STALE: vectors/ differs from dcp_verify --make-vectors output" >&2
+    diff -rq $ignore "$vec" "$tmp/regen" >&2 || true
+    exit 1
+fi
+echo "DCP1_VECTORS_REGEN identical"
+
+"$tmp/dcp_verify" --corpus "$vec"
+
+if "$CC" -std=c99 -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all \
+        -o "$tmp/dcp_verify_san" "$here/dcp_verify.c" 2>/dev/null; then
+    "$tmp/dcp_verify_san" --corpus "$vec" | sed 's/^DCP1_CONFORMANCE impl=c/DCP1_CONFORMANCE impl=c-asan-ubsan/'
+    test "${PIPESTATUS[0]}" -eq 0
+else
+    echo "DCP1_SANITIZER NOT_RUN (compiler lacks -fsanitize=address,undefined)"
+fi
+
+bash "$here/mutate-verifier.sh" "$CC"
+echo "DCP1_VECTORS_PASS"
diff --git a/specs/discovery-capsule/tools/dcp_verify.c b/specs/discovery-capsule/tools/dcp_verify.c
new file mode 100644
index 0000000..54c4165
--- /dev/null
+++ b/specs/discovery-capsule/tools/dcp_verify.c
@@ -0,0 +1,621 @@
+/* dcp_verify.c: reference checker for the DCP1 family (Discovery Capsule,
+ * owner consent, retraction, retraction ack, experience lineage).
+ * Spec: ../SPEC.md (Draft v0.1, contract 0.1.0, wire version 1).
+ *
+ * Self-contained C99: its own SHA-256 (FIPS 180-4), libc only, no heap, no
+ * clock. dcp_check() is a pure function of one read-only buffer and pins the
+ * static rules of SPEC.md section 10 with vectors. Signatures (P-256) and the
+ * stateful recipient rules of section 11 are checked by the Rust crate
+ * crates/aien-discovery-capsule, not here: the signature bytes of the vectors
+ * are fixed filler.
+ *
+ * Usage:
+ *   dcp_verify FILE                print one verdict line
+ *   dcp_verify --corpus DIR        check every DIR/expected.txt line, print
+ *                                  DCP1_CONFORMANCE impl=c pass=N fail=M
+ *   dcp_verify --make-vectors DIR  write the vector files and DIR/expected.txt
+ *
+ * Verdict line:
+ *   ok type=MAGIC digest=H64 key=H66   (record digest, signature excluded;
+ *                                       the signing key)
+ *   refuse CODE                        (CODE from SPEC.md section 12)
+ *
+ * Exit status: 0 on accept / all corpus lines agree, 1 otherwise, 2 on usage
+ * or I/O error.
+ *
+ * Mutation hooks: -DDCP_MUTANT=K disables check K; tools/mutate-verifier.sh
+ * requires the vectors to catch every mutant.
+ */
+#define _POSIX_C_SOURCE 200809L
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifndef DCP_MUTANT
+#define DCP_MUTANT 0
+#endif
+#define CHECK(k) (DCP_MUTANT != (k))
+
+enum {
+    CHK_MIN_LEN = 1, CHK_MAGIC, CHK_DOWNGRADE, CHK_VERSION, CHK_EXACT_LEN,
+    CHK_P_RES0, CHK_P_RES1, CHK_P_DIMS, CHK_P_SCOPE, CHK_P_PERMS, CHK_P_PRECISION,
+    CHK_P_CAPS, CHK_P_RANK, CHK_P_LICENSE, CHK_P_ABI, CHK_P_DIGESTS, CHK_P_POLICY,
+    CHK_P_KEY, CHK_P_VALID_FROM, CHK_P_EXPIRES, CHK_P_FAILURES, CHK_P_REVOCATION,
+    CHK_P_PRIVATE, CHK_P_RECIPIENTS, CHK_P_AMPLIFY, CHK_P_CONSENT,
+    CHK_C_RES0, CHK_C_RES1, CHK_C_SLOTS, CHK_C_PURPOSES, CHK_C_COUNT, CHK_C_VERSION,
+    CHK_C_DIGESTS, CHK_C_USED, CHK_C_KEY, CHK_C_ISSUED, CHK_C_RETENTION, CHK_C_AMPLIFY,
+    CHK_R_RES0, CHK_R_RES1, CHK_R_SCOPE, CHK_R_ERASURE, CHK_R_SEQ, CHK_R_DIGESTS,
+    CHK_R_OWNER_KEY, CHK_R_SIGNER_KEY, CHK_R_EFFECTIVE, CHK_R_PREV,
+    CHK_A_RES, CHK_A_STATUS, CHK_A_DIGEST, CHK_A_KEY, CHK_A_TIME,
+    CHK_L_RES, CHK_L_PARENT_SLOTS, CHK_L_INFL_SLOTS, CHK_L_COUNTS, CHK_L_FIELDS,
+    CHK_L_USED, CHK_L_KEY, CHK_L_SELF, CHK_L_DUP,
+    CHK_LAST
+};
+
+enum {
+    DCP_OK = 0, DCP_BAD_LENGTH, DCP_BAD_MAGIC, DCP_DOWNGRADE, DCP_BAD_VERSION,
+    DCP_RESERVED_NONZERO, DCP_BAD_ENUM, DCP_UNKNOWN_LICENSE, DCP_FALSE_ERASURE_CLAIM,
+    DCP_MISSING_FIELD, DCP_BAD_KEY, DCP_BAD_VALIDITY, DCP_INCONSISTENT,
+    DCP_SCOPE_CONFLICT, DCP_PERMISSION_AMPLIFICATION, DCP_NO_CONSENT,
+    DCP_ANCESTOR_CYCLE, DCP_DUPLICATE, DCP_CODE_COUNT
+};
+static const char *const code_names[DCP_CODE_COUNT] = {
+    "OK", "DCP_BAD_LENGTH", "DCP_BAD_MAGIC", "DCP_DOWNGRADE", "DCP_BAD_VERSION",
+    "DCP_RESERVED_NONZERO", "DCP_BAD_ENUM", "DCP_UNKNOWN_LICENSE", "DCP_FALSE_ERASURE_CLAIM",
+    "DCP_MISSING_FIELD", "DCP_BAD_KEY", "DCP_BAD_VALIDITY", "DCP_INCONSISTENT",
+    "DCP_SCOPE_CONFLICT", "DCP_PERMISSION_AMPLIFICATION", "DCP_NO_CONSENT",
+    "DCP_ANCESTOR_CYCLE", "DCP_DUPLICATE"
+};
+
+/* ---- SHA-256 ------------------------------------------------------------ */
+typedef struct { uint32_t h[8]; uint64_t n; uint8_t b[64]; uint32_t used; } sha256;
+
+static const uint32_t K256[64] = {
+    0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
+    0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
+    0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
+    0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
+    0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
+    0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
+    0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
+    0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
+};
+#define ROR(x, r) (((x) >> (r)) | ((x) << (32 - (r))))
+
+static void sha_block(sha256 *s, const uint8_t *p) {
+    uint32_t w[64], a, b, c, d, e, f, g, h;
+    for (int i = 0; i < 16; i++)
+        w[i] = (uint32_t)p[4*i] << 24 | (uint32_t)p[4*i+1] << 16 | (uint32_t)p[4*i+2] << 8 | p[4*i+3];
+    for (int i = 16; i < 64; i++) {
+        uint32_t s0 = ROR(w[i-15], 7) ^ ROR(w[i-15], 18) ^ (w[i-15] >> 3);
+        uint32_t s1 = ROR(w[i-2], 17) ^ ROR(w[i-2], 19) ^ (w[i-2] >> 10);
+        w[i] = w[i-16] + s0 + w[i-7] + s1;
+    }
+    a = s->h[0]; b = s->h[1]; c = s->h[2]; d = s->h[3];
+    e = s->h[4]; f = s->h[5]; g = s->h[6]; h = s->h[7];
+    for (int i = 0; i < 64; i++) {
+        uint32_t t1 = h + (ROR(e, 6) ^ ROR(e, 11) ^ ROR(e, 25)) + ((e & f) ^ (~e & g)) + K256[i] + w[i];
+        uint32_t t2 = (ROR(a, 2) ^ ROR(a, 13) ^ ROR(a, 22)) + ((a & b) ^ (a & c) ^ (b & c));
+        h = g; g = f; f = e; e = d + t1; d = c; c = b; b = a; a = t1 + t2;
+    }
+    s->h[0] += a; s->h[1] += b; s->h[2] += c; s->h[3] += d;
+    s->h[4] += e; s->h[5] += f; s->h[6] += g; s->h[7] += h;
+}
+static void sha_init(sha256 *s) {
+    static const uint32_t iv[8] = { 0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,
+                                    0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19 };
+    memcpy(s->h, iv, sizeof iv); s->n = 0; s->used = 0;
+}
+static void sha_update(sha256 *s, const void *data, size_t len) {
+    const uint8_t *p = data;
+    s->n += len;
+    while (len) {
+        uint32_t k = 64 - s->used;
+        if (k > len) k = (uint32_t)len;
+        memcpy(s->b + s->used, p, k);
+        s->used += k; p += k; len -= k;
+        if (s->used == 64) { sha_block(s, s->b); s->used = 0; }
+    }
+}
+static void sha_final(sha256 *s, uint8_t out[32]) {
+    uint64_t bits = s->n * 8;
+    uint8_t pad = 0x80, z = 0, l[8];
+    sha_update(s, &pad, 1);
+    while (s->used != 56) sha_update(s, &z, 1);
+    for (int i = 0; i < 8; i++) l[i] = (uint8_t)(bits >> (56 - 8 * i));
+    sha_update(s, l, 8);
+    for (int i = 0; i < 8; i++) {
+        out[4*i] = (uint8_t)(s->h[i] >> 24); out[4*i+1] = (uint8_t)(s->h[i] >> 16);
+        out[4*i+2] = (uint8_t)(s->h[i] >> 8); out[4*i+3] = (uint8_t)s->h[i];
+    }
+}
+static void sha_once(const void *p, size_t n, uint8_t out[32]) {
+    sha256 s; sha_init(&s); sha_update(&s, p, n); sha_final(&s, out);
+}
+
+/* ---- big-endian helpers -------------------------------------------------- */
+static uint16_t g16(const uint8_t *p) { return (uint16_t)(p[0] << 8 | p[1]); }
+static uint32_t g32(const uint8_t *p) { return (uint32_t)p[0] << 24 | (uint32_t)p[1] << 16 | (uint32_t)p[2] << 8 | p[3]; }
+static uint64_t g64(const uint8_t *p) { return (uint64_t)g32(p) << 32 | g32(p + 4); }
+static void p16(uint8_t *p, uint16_t v) { p[0] = (uint8_t)(v >> 8); p[1] = (uint8_t)v; }
+static void p32(uint8_t *p, uint32_t v) { p[0] = (uint8_t)(v >> 24); p[1] = (uint8_t)(v >> 16); p[2] = (uint8_t)(v >> 8); p[3] = (uint8_t)v; }
+static void p64(uint8_t *p, uint64_t v) { p32(p, (uint32_t)(v >> 32)); p32(p + 4, (uint32_t)v); }
+static int all_zero(const uint8_t *p, size_t n) { while (n--) if (*p++) return 0; return 1; }
+static int z32(const uint8_t *b, size_t at) { return all_zero(b + at, 32); }
+static int key_ok(const uint8_t *b, size_t at) { return b[at] == 0x02 || b[at] == 0x03; }
+
+/* ---- record types (spec section 1) ----------------------------------------- */
+typedef struct { const char *magic; size_t len, key_at, sig_at; } layout;
+static const layout layouts[5] = {
+    { "DCP1", 676, 576, 612 }, { "DCC1", 388, 288, 324 }, { "DCR1", 284, 185, 220 },
+    { "DCA1", 148, 48, 84 },   { "DCL1", 588, 488, 524 }
+};
+static const layout *find_layout(const uint8_t *b) {
+    for (int i = 0; i < 5; i++) if (!memcmp(b, layouts[i].magic, 4)) return &layouts[i];
+    return NULL;
+}
+
+#define P_READ 0x02u
+#define P_REDIST 0x04u
+#define P_TRAIN 0x08u
+
+static int check_capsule(const uint8_t *b) {
+    unsigned rank = b[20], sc = b[5], perms = b[6], d, lic = g16(b + 8);
+    uint64_t from = g64(b + 40), until = g64(b + 48);
+    if (CHECK(CHK_P_RES0) && !all_zero(b + 21, 3)) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_P_RES1) && !all_zero(b + 609, 3)) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_P_DIMS)) for (d = rank < 4 ? rank : 4; d < 4; d++) if (g32(b + 24 + 4 * d)) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_P_SCOPE) && sc > 3) return DCP_BAD_ENUM;
+    if (CHECK(CHK_P_PERMS) && (perms & 0xF0u)) return DCP_BAD_ENUM;
+    if (CHECK(CHK_P_PRECISION) && b[7] > 6) return DCP_BAD_ENUM;
+    if (CHECK(CHK_P_CAPS) && (g32(b + 16) & ~0x3Fu)) return DCP_BAD_ENUM;
+    if (CHECK(CHK_P_RANK) && rank > 4) return DCP_BAD_ENUM;
+    if (CHECK(CHK_P_LICENSE) && (lic < 1 || lic > 6)) return DCP_UNKNOWN_LICENSE;
+    if (CHECK(CHK_P_ABI) && g32(b + 12) == 0) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_P_DIGESTS)) for (d = 64; d < 288; d += 32) if (z32(b, d)) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_P_POLICY) && z32(b, 384)) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_P_KEY) && !key_ok(b, 576)) return DCP_BAD_KEY;
+    if (CHECK(CHK_P_VALID_FROM) && from == 0) return DCP_BAD_VALIDITY;
+    if (CHECK(CHK_P_EXPIRES) && until <= from) return DCP_BAD_VALIDITY;
+    if (CHECK(CHK_P_FAILURES) && (g16(b + 10) != 0) == z32(b, 288)) return DCP_INCONSISTENT;
+    if (CHECK(CHK_P_REVOCATION) && (g64(b + 56) != 0) == z32(b, 480)) return DCP_INCONSISTENT;
+    if (CHECK(CHK_P_PRIVATE) && sc == 0 && perms != 0) return DCP_SCOPE_CONFLICT;
+    if (CHECK(CHK_P_RECIPIENTS) && (sc == 1) == z32(b, 416)) return DCP_SCOPE_CONFLICT;
+    if (CHECK(CHK_P_AMPLIFY) && (perms & (P_REDIST | P_TRAIN)) && !(perms & P_READ)) return DCP_PERMISSION_AMPLIFICATION;
+    if (CHECK(CHK_P_CONSENT) && ((perms & (P_READ | P_REDIST | P_TRAIN)) || sc != 0) && z32(b, 448)) return DCP_NO_CONSENT;
+    return DCP_OK;
+}
+
+static int check_consent(const uint8_t *b) {
+    unsigned n = b[6], lim = n < 4 ? n : 4, s;
+    if (CHECK(CHK_C_RES0) && b[7]) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_C_RES1) && !all_zero(b + 321, 3)) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_C_SLOTS)) for (s = lim; s < 4; s++) if (!z32(b, 160 + 32 * s)) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_C_PURPOSES) && (b[5] == 0 || (b[5] & 0xF0u))) return DCP_BAD_ENUM;
+    if (CHECK(CHK_C_COUNT) && n > 4) return DCP_BAD_ENUM;
+    if (CHECK(CHK_C_VERSION) && g32(b + 8) == 0) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_C_DIGESTS) && (z32(b, 32) || z32(b, 64) || z32(b, 96) || z32(b, 128))) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_C_USED)) for (s = 0; s < lim; s++) if (z32(b, 160 + 32 * s)) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_C_KEY) && !key_ok(b, 288)) return DCP_BAD_KEY;
+    if (CHECK(CHK_C_ISSUED) && g64(b + 16) == 0) return DCP_BAD_VALIDITY;
+    if (CHECK(CHK_C_RETENTION) && g64(b + 24) <= g64(b + 16)) return DCP_BAD_VALIDITY;
+    if (CHECK(CHK_C_AMPLIFY) && (b[5] & (P_REDIST | P_TRAIN)) && !(b[5] & P_READ)) return DCP_PERMISSION_AMPLIFICATION;
+    return DCP_OK;
+}
+
+static int check_retraction(const uint8_t *b) {
+    uint64_t seq = g64(b + 8);
+    if (CHECK(CHK_R_RES0) && b[7]) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_R_RES1) && !all_zero(b + 218, 2)) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_R_SCOPE) && (b[5] == 0 || (b[5] & 0xF0u))) return DCP_BAD_ENUM;
+    if (CHECK(CHK_R_ERASURE) && b[6]) return DCP_FALSE_ERASURE_CLAIM;
+    if (CHECK(CHK_R_SEQ) && seq == 0) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_R_DIGESTS) && (z32(b, 24) || z32(b, 88) || z32(b, 120))) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_R_OWNER_KEY) && !key_ok(b, 152)) return DCP_BAD_KEY;
+    if (CHECK(CHK_R_SIGNER_KEY) && !key_ok(b, 185)) return DCP_BAD_KEY;
+    if (CHECK(CHK_R_EFFECTIVE) && g64(b + 16) == 0) return DCP_BAD_VALIDITY;
+    if (CHECK(CHK_R_PREV) && (seq == 1) != z32(b, 56)) return DCP_INCONSISTENT;
+    return DCP_OK;
+}
+
+static int check_ack(const uint8_t *b) {
+    if (CHECK(CHK_A_RES) && (!all_zero(b + 6, 2) || !all_zero(b + 81, 3))) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_A_STATUS) && (b[5] < 1 || b[5] > 2)) return DCP_BAD_ENUM;
+    if (CHECK(CHK_A_DIGEST) && z32(b, 16)) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_A_KEY) && !key_ok(b, 48)) return DCP_BAD_KEY;
+    if (CHECK(CHK_A_TIME) && g64(b + 8) == 0) return DCP_BAD_VALIDITY;
+    return DCP_OK;
+}
+
+static int check_lineage(const uint8_t *b) {
+    unsigned np = b[5], ni = b[6], pl = np < 4 ? np : 4, il = ni < 8 ? ni : 8, s, t;
+    if (CHECK(CHK_L_RES) && (b[7] || !all_zero(b + 521, 3))) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_L_PARENT_SLOTS)) for (s = pl; s < 4; s++) if (!z32(b, 104 + 32 * s)) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_L_INFL_SLOTS)) for (s = il; s < 8; s++) if (!z32(b, 232 + 32 * s)) return DCP_RESERVED_NONZERO;
+    if (CHECK(CHK_L_COUNTS) && (np > 4 || ni > 8)) return DCP_BAD_ENUM;
+    if (CHECK(CHK_L_FIELDS) && (z32(b, 8) || z32(b, 40) || z32(b, 72))) return DCP_MISSING_FIELD;
+    if (CHECK(CHK_L_USED)) {
+        for (s = 0; s < pl; s++) if (z32(b, 104 + 32 * s)) return DCP_MISSING_FIELD;
+        for (s = 0; s < il; s++) if (z32(b, 232 + 32 * s)) return DCP_MISSING_FIELD;
+    }
+    if (CHECK(CHK_L_KEY) && !key_ok(b, 488)) return DCP_BAD_KEY;
+    if (CHECK(CHK_L_SELF)) for (s = 0; s < pl; s++) if (!memcmp(b + 104 + 32 * s, b + 8, 32)) return DCP_ANCESTOR_CYCLE;
+    if (CHECK(CHK_L_DUP))
+        for (s = 0; s < pl; s++)
+            for (t = s + 1; t < pl; t++) if (!memcmp(b + 104 + 32 * s, b + 104 + 32 * t, 32)) return DCP_DUPLICATE;
+    return DCP_OK;
+}
+
+static int dcp_check(const uint8_t *b, size_t len, const layout **out) {
+    const layout *l;
+    *out = NULL;
+    if (CHECK(CHK_MIN_LEN) && len < 5) return DCP_BAD_LENGTH;
+    l = find_layout(b);
+    if (!l) {
+        if (CHECK(CHK_MAGIC)) return DCP_BAD_MAGIC;
+        l = &layouts[0]; /* mutant only: read an unknown record as a capsule */
+    }
+    if (CHECK(CHK_DOWNGRADE) && b[4] == 0) return DCP_DOWNGRADE;
+    if (CHECK(CHK_VERSION) && b[4] > 1) return DCP_BAD_VERSION;
+    if (CHECK(CHK_EXACT_LEN) && len != l->len) return DCP_BAD_LENGTH;
+    *out = l;
+    switch (l->magic[2]) {
+    case 'P': return check_capsule(b);
+    case 'C': return check_consent(b);
+    case 'R': return check_retraction(b);
+    case 'A': return check_ack(b);
+    default:  return check_lineage(b);
+    }
+}
+
+static void hex(char *out, const uint8_t *p, size_t n) {
+    static const char H[] = "0123456789abcdef";
+    for (size_t i = 0; i < n; i++) { out[2*i] = H[p[i] >> 4]; out[2*i+1] = H[p[i] & 15]; }
+    out[2*n] = 0;
+}
+
+static void ok_line(const uint8_t *b, const layout *l, char *line, size_t cap) {
+    char dig[65], key[67];
+    uint8_t d[32];
+    sha_once(b, l->sig_at, d);
+    hex(dig, d, 32);
+    hex(key, b + l->key_at, 33);
+    snprintf(line, cap, "ok type=%s digest=%s key=%s", l->magic, dig, key);
+}
+
+static void verdict_line(const uint8_t *b, size_t len, char *line, size_t cap) {
+    const layout *l;
+    int code = dcp_check(b, len, &l);
+    if (code != DCP_OK) snprintf(line, cap, "refuse %s", code_names[code]);
+    else ok_line(b, l, line, cap);
+}
+
+/* ---- file I/O ------------------------------------------------------------------ */
+#define FILE_CAP 4096u
+static uint8_t file_buf[FILE_CAP];
+
+static int slurp(const char *path, size_t *n) {
+    FILE *f = fopen(path, "rb");
+    size_t k;
+    memset(file_buf, 0, sizeof file_buf);
+    if (!f) return -1;
+    k = fread(file_buf, 1, FILE_CAP, f);
+    if (k == FILE_CAP && fgetc(f) != EOF) { fclose(f); return -1; }
+    fclose(f);
+    *n = k;
+    return 0;
+}
+
+static void rstrip(char *s) { size_t n = strlen(s); while (n && (s[n-1] == '\n' || s[n-1] == '\r')) s[--n] = 0; }
+static int plain_name(const char *s) { return s[0] && s[0] != '.' && !strchr(s, '/'); }
+
+static FILE *create_file(const char *path, const char *mode) {
+    int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+    FILE *f;
+    if (fd < 0) return NULL;
+    if (!(f = fdopen(fd, mode))) close(fd);
+    return f;
+}
+
+/* The corpus walk opens only names that readdir reports in DIR; expected.txt
+ * names are lookup keys, never paths. An expected name with no file in DIR is
+ * a failure ("missing"), as is a duplicate expected name. */
+#define CORPUS_CAP 512u
+struct expect { char name[256]; char want[1024]; int seen; };
+static struct expect expects[CORPUS_CAP];
+
+static int corpus(const char *dir) {
+    char path[4096], line[1024], got[1024];
+    unsigned pass = 0, fail = 0, count = 0, i;
+    size_t n;
+    FILE *f;
+    DIR *d;
+    struct dirent *e;
+    snprintf(path, sizeof path, "%s/expected.txt", dir);
+    if (!(f = fopen(path, "r"))) { fprintf(stderr, "cannot read %s\n", path); return 2; }
+    while (fgets(line, sizeof line, f)) {
+        char *sp;
+        rstrip(line);
+        if (!line[0] || line[0] == '#') continue;
+        if (!(sp = strchr(line, ' '))) { fprintf(stderr, "bad line: %s\n", line); fail++; continue; }
+        *sp = 0;
+        if (!plain_name(line) || strlen(line) >= sizeof expects[0].name) { fprintf(stderr, "not a plain file name: %s\n", line); fail++; continue; }
+        for (i = 0; i < count && strcmp(expects[i].name, line) != 0; i++) ;
+        if (i < count) { fprintf(stderr, "duplicate name: %s\n", line); fail++; continue; }
+        if (count == CORPUS_CAP) { fprintf(stderr, "too many lines: %s\n", line); fail++; continue; }
+        snprintf(expects[count].name, sizeof expects[count].name, "%s", line);
+        snprintf(expects[count].want, sizeof expects[count].want, "%s", sp + 1);
+        expects[count].seen = 0;
+        count++;
+    }
+    fclose(f);
+    if (!(d = opendir(dir))) { fprintf(stderr, "cannot read %s\n", dir); return 2; }
+    while ((e = readdir(d))) {
+        for (i = 0; i < count && strcmp(expects[i].name, e->d_name) != 0; i++) ;
+        if (i == count) continue;
+        expects[i].seen = 1;
+        snprintf(path, sizeof path, "%s/%s", dir, e->d_name);
+        if (slurp(path, &n)) { fprintf(stderr, "cannot read %s\n", path); fail++; continue; }
+        verdict_line(file_buf, n, got, sizeof got);
+        if (strcmp(got, expects[i].want) != 0) { fail++; printf("MISMATCH %s\n  expected: %s\n  got:      %s\n", e->d_name, expects[i].want, got); }
+        else pass++;
+    }
+    closedir(d);
+    for (i = 0; i < count; i++)
+        if (!expects[i].seen) { fprintf(stderr, "missing: %s\n", expects[i].name); fail++; }
+    printf("DCP1_CONFORMANCE impl=c pass=%u fail=%u\n", pass, fail);
+    return fail || !pass ? 1 : 0;
+}
+
+/* ---- vector generator ------------------------------------------------------------ */
+/* Every refused vector is one well-formed record with one change. Signature
+ * bytes are fixed filler: this checker does not verify signatures. The
+ * expected line of an accepted vector is built from the layout table, not from
+ * dcp_check. */
+static uint8_t rec[1024];
+static size_t rec_len;
+static FILE *gen_expected;
+static int gen_fail;
+static const char *gen_dir;
+
+static void fill(uint8_t *p, size_t n, uint8_t seed) { for (size_t i = 0; i < n; i++) p[i] = (uint8_t)(seed + 7 * i); }
+static void key(size_t at, uint8_t seed) { rec[at] = 0x02 | (seed & 1); fill(rec + at + 1, 32, seed); }
+
+static void start(const char *magic, size_t len) {
+    memset(rec, 0, sizeof rec);
+    memcpy(rec, magic, 4);
+    rec[4] = 1;
+    rec_len = len;
+}
+
+/* NAMED, DISCOVER|READ|TRAIN, one known failure, no retraction yet. */
+static void capsule(void) {
+    size_t at;
+    start("DCP1", 676);
+    rec[5] = 1; rec[6] = 0x0B; rec[7] = 0;
+    p16(rec + 8, 1); p16(rec + 10, 1);
+    p32(rec + 12, 7); p32(rec + 16, 0x05);
+    rec[20] = 2; p32(rec + 24, 16); p32(rec + 28, 16);
+    p64(rec + 40, 1800000000u); p64(rec + 48, 1900000000u);
+    for (at = 64; at < 576; at += 32) fill(rec + at, 32, (uint8_t)(at / 32 + 0x20));
+    memset(rec + 320, 0, 32);           /* utility verdict: NOT_RUN */
+    memset(rec + 352, 0, 32);           /* scientific-T verdict: NOT_RUN */
+    memset(rec + 480, 0, 32);           /* revocation head: none */
+    memset(rec + 512, 0, 32);           /* no parent */
+    key(576, 0xA1);
+    fill(rec + 612, 64, 0x51);
+}
+
+static void consent(void) {
+    start("DCC1", 388);
+    rec[5] = 0x0B; rec[6] = 2;
+    p32(rec + 8, 1); p32(rec + 12, 86400);
+    p64(rec + 16, 1800000000u); p64(rec + 24, 1950000000u);
+    fill(rec + 32, 32, 0x61); fill(rec + 64, 32, 0x62); fill(rec + 96, 32, 0x63); fill(rec + 128, 32, 0x64);
+    fill(rec + 160, 32, 0x65); fill(rec + 192, 32, 0x66);
+    key(288, 0xA1);
+    fill(rec + 324, 64, 0x52);
+}
+
+static void retraction(uint64_t seq) {
+    start("DCR1", 284);
+    rec[5] = 0x06;
+    p64(rec + 8, seq); p64(rec + 16, 1850000000u);
+    fill(rec + 24, 32, 0x71);
+    if (seq != 1) fill(rec + 56, 32, 0x72);
+    fill(rec + 88, 32, 0x73); fill(rec + 120, 32, 0x74);
+    key(152, 0xA1); key(185, 0xA1);
+    fill(rec + 220, 64, 0x53);
+}
+
+static void ack(void) {
+    start("DCA1", 148);
+    rec[5] = 1;
+    p64(rec + 8, 1850000100u);
+    fill(rec + 16, 32, 0x81);
+    key(48, 0xB2);
+    fill(rec + 84, 64, 0x54);
+}
+
+static void lineage(unsigned parents, unsigned influenced) {
+    unsigned s;
+    start("DCL1", 588);
+    rec[5] = (uint8_t)parents; rec[6] = (uint8_t)influenced;
+    fill(rec + 8, 32, 0x91); fill(rec + 40, 32, 0x92); fill(rec + 72, 32, 0x93);
+    for (s = 0; s < parents; s++) fill(rec + 104 + 32 * s, 32, (uint8_t)(0xA0 + s));
+    for (s = 0; s < influenced; s++) fill(rec + 232 + 32 * s, 32, (uint8_t)(0xC0 + s));
+    key(488, 0xA1);
+    fill(rec + 524, 64, 0x55);
+}
+
+static void emit(const char *name, size_t n, const char *expect) {
+    char path[4096];
+    FILE *f;
+    snprintf(path, sizeof path, "%s/%s", gen_dir, name);
+    if (!(f = create_file(path, "wb")) || fwrite(rec, 1, n, f) != n || fclose(f) != 0) {
+        fprintf(stderr, "cannot write %s\n", path);
+        gen_fail = 1;
+        return;
+    }
+    fprintf(gen_expected, "%s %s\n", name, expect);
+}
+
+static void ok(const char *name) {
+    char line[1024];
+    ok_line(rec, find_layout(rec), line, sizeof line);
+    emit(name, rec_len, line);
+}
+static void bad_len(const char *name, size_t n, const char *code) {
+    char line[128];
+    snprintf(line, sizeof line, "refuse %s", code);
+    emit(name, n, line);
+}
+static void bad(const char *name, const char *code) { bad_len(name, rec_len, code); }
+
+static int make_vectors(const char *dir) {
+    char path[4096];
+    gen_dir = dir;
+    snprintf(path, sizeof path, "%s/expected.txt", dir);
+    if (!(gen_expected = create_file(path, "w"))) { fprintf(stderr, "cannot write %s\n", path); return 2; }
+    fprintf(gen_expected,
+        "# DCP1 family vectors. Spec: ../SPEC.md (Draft v0.1, wire version 1).\n"
+        "# Line: <file> <verdict line>, verdict line as printed by tools/dcp_verify.c:\n"
+        "#   ok type=MAGIC digest=H64 key=H66   (digest excludes the signature)\n"
+        "#   refuse <code from SPEC.md section 12>\n"
+        "# Signature bytes are filler; signatures are checked by the Rust crate.\n"
+        "# Generated by tools/dcp_verify.c --make-vectors; do not edit by hand.\n");
+
+    /* ---- accepted ---- */
+    capsule(); ok("ok-capsule-named.dcp");
+    capsule(); rec[5] = 0; rec[6] = 0; memset(rec + 416, 0, 32); memset(rec + 448, 0, 32);
+    ok("ok-capsule-private-default.dcp");
+    capsule(); rec[5] = 3; rec[6] = 0x0F; memset(rec + 416, 0, 32); p16(rec + 10, 0); memset(rec + 288, 0, 32);
+    p64(rec + 56, 3); fill(rec + 480, 32, 0x3E); fill(rec + 512, 32, 0x3F); p16(rec + 8, 6);
+    ok("ok-capsule-public-after-retractions.dcp");
+    capsule(); rec[6] = 0x01; ok("ok-capsule-named-discover-only.dcp");
+    consent(); ok("ok-consent-two-custodians.dcp");
+    consent(); rec[6] = 0; memset(rec + 160, 0, 64); rec[5] = 0x02; ok("ok-consent-read-only.dcp");
+    retraction(1); ok("ok-retraction-first.dcp");
+    retraction(2); key(185, 0xB4); ok("ok-retraction-by-custodian.dcp");
+    ack(); ok("ok-ack-enforced.dcp");
+    ack(); rec[5] = 2; ok("ok-ack-enforced-with-retained.dcp");
+    lineage(0, 0); ok("ok-lineage-root.dcp");
+    lineage(2, 3); ok("ok-lineage-parents-influenced.dcp");
+    lineage(4, 8); ok("ok-lineage-full.dcp");
+
+    /* ---- refused: generic ---- */
+    capsule(); bad_len("bad-length-short.dcp", 4, "DCP_BAD_LENGTH");
+    capsule(); bad_len("bad-length-empty.dcp", 0, "DCP_BAD_LENGTH");
+    capsule(); rec[3] = '9'; bad("bad-magic.dcp", "DCP_BAD_MAGIC");
+    capsule(); rec[4] = 0; bad("bad-version-downgrade.dcp", "DCP_DOWNGRADE");
+    capsule(); rec[4] = 2; bad("bad-version-unknown.dcp", "DCP_BAD_VERSION");
+    capsule(); bad_len("bad-length-capsule-short.dcp", 675, "DCP_BAD_LENGTH");
+    retraction(1); bad_len("bad-length-retraction-trailing.dcp", 285, "DCP_BAD_LENGTH");
+
+    /* ---- refused: capsule ---- */
+    capsule(); rec[22] = 1; bad("bad-capsule-reserved0.dcp", "DCP_RESERVED_NONZERO");
+    capsule(); rec[610] = 1; bad("bad-capsule-reserved1.dcp", "DCP_RESERVED_NONZERO");
+    capsule(); p32(rec + 32, 1); bad("bad-capsule-dims-past-rank.dcp", "DCP_RESERVED_NONZERO");
+    capsule(); rec[5] = 4; bad("bad-capsule-scope.dcp", "DCP_BAD_ENUM");
+    capsule(); rec[6] = 0x1B; bad("bad-capsule-permission-bit.dcp", "DCP_BAD_ENUM");
+    capsule(); rec[7] = 7; bad("bad-capsule-precision.dcp", "DCP_BAD_ENUM");
+    capsule(); p32(rec + 16, 0x45); bad("bad-capsule-capability-bit.dcp", "DCP_BAD_ENUM");
+    capsule(); rec[20] = 5; bad("bad-capsule-rank.dcp", "DCP_BAD_ENUM");
+    capsule(); p16(rec + 8, 0); bad("bad-capsule-license-unknown-zero.dcp", "DCP_UNKNOWN_LICENSE");
+    capsule(); p16(rec + 8, 7); bad("bad-capsule-license-unknown-seven.dcp", "DCP_UNKNOWN_LICENSE");
+    capsule(); p32(rec + 12, 0); bad("bad-capsule-no-abi.dcp", "DCP_MISSING_FIELD");
+    capsule(); memset(rec + 64, 0, 32); bad("bad-capsule-no-meaning.dcp", "DCP_MISSING_FIELD");
+    capsule(); memset(rec + 224, 0, 32); bad("bad-capsule-no-verifier.dcp", "DCP_MISSING_FIELD");
+    capsule(); memset(rec + 256, 0, 32); bad("bad-capsule-no-evidence.dcp", "DCP_MISSING_FIELD");
+    capsule(); memset(rec + 384, 0, 32); bad("bad-capsule-no-recipient-policy.dcp", "DCP_MISSING_FIELD");
+    capsule(); rec[576] = 0x04; bad("bad-capsule-owner-key.dcp", "DCP_BAD_KEY");
+    capsule(); p64(rec + 40, 0); bad("bad-capsule-valid-from-zero.dcp", "DCP_BAD_VALIDITY");
+    capsule(); p64(rec + 48, 1800000000u); bad("bad-capsule-expires-not-after.dcp", "DCP_BAD_VALIDITY");
+    capsule(); memset(rec + 288, 0, 32); bad("bad-capsule-failures-without-digest.dcp", "DCP_INCONSISTENT");
+    capsule(); p16(rec + 10, 0); bad("bad-capsule-failure-digest-without-count.dcp", "DCP_INCONSISTENT");
+    capsule(); p64(rec + 56, 2); bad("bad-capsule-revocation-seq-without-head.dcp", "DCP_INCONSISTENT");
+    capsule(); fill(rec + 480, 32, 0x3E); bad("bad-capsule-revocation-head-without-seq.dcp", "DCP_INCONSISTENT");
+    capsule(); rec[5] = 0; rec[6] = 0x02; memset(rec + 416, 0, 32); bad("bad-capsule-private-with-read.dcp", "DCP_SCOPE_CONFLICT");
+    capsule(); memset(rec + 416, 0, 32); bad("bad-capsule-named-without-set.dcp", "DCP_SCOPE_CONFLICT");
+    capsule(); rec[5] = 3; bad("bad-capsule-public-with-set.dcp", "DCP_SCOPE_CONFLICT");
+    capsule(); rec[6] = 0x09; bad("bad-capsule-train-without-read.dcp", "DCP_PERMISSION_AMPLIFICATION");
+    capsule(); rec[6] = 0x04; bad("bad-capsule-redistribute-without-read.dcp", "DCP_PERMISSION_AMPLIFICATION");
+    capsule(); memset(rec + 448, 0, 32); bad("bad-capsule-no-consent.dcp", "DCP_NO_CONSENT");
+    capsule(); rec[6] = 0x01; memset(rec + 448, 0, 32); bad("bad-capsule-named-discover-no-consent.dcp", "DCP_NO_CONSENT");
+
+    /* ---- refused: consent ---- */
+    consent(); rec[7] = 1; bad("bad-consent-reserved0.dcp", "DCP_RESERVED_NONZERO");
+    consent(); rec[322] = 1; bad("bad-consent-reserved1.dcp", "DCP_RESERVED_NONZERO");
+    consent(); fill(rec + 224, 32, 0x67); bad("bad-consent-undeclared-custodian-slot.dcp", "DCP_RESERVED_NONZERO");
+    consent(); rec[5] = 0; bad("bad-consent-no-purpose.dcp", "DCP_BAD_ENUM");
+    consent(); rec[5] = 0x1B; bad("bad-consent-purpose-bit.dcp", "DCP_BAD_ENUM");
+    consent(); fill(rec + 224, 32, 0x67); fill(rec + 256, 32, 0x68); rec[6] = 5; bad("bad-consent-custodian-count.dcp", "DCP_BAD_ENUM");
+    consent(); p32(rec + 8, 0); bad("bad-consent-no-version.dcp", "DCP_MISSING_FIELD");
+    consent(); memset(rec + 64, 0, 32); bad("bad-consent-no-recipient.dcp", "DCP_MISSING_FIELD");
+    consent(); memset(rec + 192, 0, 32); bad("bad-consent-empty-declared-custodian.dcp", "DCP_MISSING_FIELD");
+    consent(); rec[288] = 0x00; bad("bad-consent-owner-key.dcp", "DCP_BAD_KEY");
+    consent(); p64(rec + 16, 0); bad("bad-consent-issued-zero.dcp", "DCP_BAD_VALIDITY");
+    consent(); p64(rec + 24, 1800000000u); bad("bad-consent-retention-not-after.dcp", "DCP_BAD_VALIDITY");
+    consent(); rec[5] = 0x09; bad("bad-consent-train-without-read.dcp", "DCP_PERMISSION_AMPLIFICATION");
+
+    /* ---- refused: retraction ---- */
+    retraction(1); rec[7] = 1; bad("bad-retraction-reserved0.dcp", "DCP_RESERVED_NONZERO");
+    retraction(1); rec[219] = 1; bad("bad-retraction-reserved1.dcp", "DCP_RESERVED_NONZERO");
+    retraction(1); rec[5] = 0; bad("bad-retraction-no-scope.dcp", "DCP_BAD_ENUM");
+    retraction(1); rec[5] = 0x16; bad("bad-retraction-scope-bit.dcp", "DCP_BAD_ENUM");
+    retraction(1); rec[6] = 1; bad("bad-retraction-claims-erasure.dcp", "DCP_FALSE_ERASURE_CLAIM");
+    retraction(1); p64(rec + 8, 0); bad("bad-retraction-seq-zero.dcp", "DCP_MISSING_FIELD");
+    retraction(1); memset(rec + 24, 0, 32); bad("bad-retraction-no-target.dcp", "DCP_MISSING_FIELD");
+    retraction(1); memset(rec + 120, 0, 32); bad("bad-retraction-no-tombstone.dcp", "DCP_MISSING_FIELD");
+    retraction(1); rec[152] = 0x05; bad("bad-retraction-owner-key.dcp", "DCP_BAD_KEY");
+    retraction(1); rec[185] = 0x05; bad("bad-retraction-signer-key.dcp", "DCP_BAD_KEY");
+    retraction(1); p64(rec + 16, 0); bad("bad-retraction-effective-zero.dcp", "DCP_BAD_VALIDITY");
+    retraction(2); memset(rec + 56, 0, 32); bad("bad-retraction-seq2-without-prev.dcp", "DCP_INCONSISTENT");
+    retraction(1); fill(rec + 56, 32, 0x72); bad("bad-retraction-seq1-with-prev.dcp", "DCP_INCONSISTENT");
+
+    /* ---- refused: ack ---- */
+    ack(); rec[7] = 1; bad("bad-ack-reserved0.dcp", "DCP_RESERVED_NONZERO");
+    ack(); rec[82] = 1; bad("bad-ack-reserved1.dcp", "DCP_RESERVED_NONZERO");
+    ack(); rec[5] = 0; bad("bad-ack-status-zero.dcp", "DCP_BAD_ENUM");
+    ack(); rec[5] = 3; bad("bad-ack-status-erased.dcp", "DCP_BAD_ENUM");
+    ack(); memset(rec + 16, 0, 32); bad("bad-ack-no-retraction.dcp", "DCP_MISSING_FIELD");
+    ack(); rec[48] = 0x04; bad("bad-ack-key.dcp", "DCP_BAD_KEY");
+    ack(); p64(rec + 8, 0); bad("bad-ack-time-zero.dcp", "DCP_BAD_VALIDITY");
+
+    /* ---- refused: lineage ---- */
+    lineage(2, 3); rec[7] = 1; bad("bad-lineage-reserved0.dcp", "DCP_RESERVED_NONZERO");
+    lineage(2, 3); rec[523] = 1; bad("bad-lineage-reserved1.dcp", "DCP_RESERVED_NONZERO");
+    lineage(2, 3); fill(rec + 104 + 64, 32, 0xAF); bad("bad-lineage-unused-parent-slot.dcp", "DCP_RESERVED_NONZERO");
+    lineage(2, 3); fill(rec + 232 + 96, 32, 0xCF); bad("bad-lineage-unused-influenced-slot.dcp", "DCP_RESERVED_NONZERO");
+    lineage(4, 3); rec[5] = 5; bad("bad-lineage-parent-count.dcp", "DCP_BAD_ENUM");
+    lineage(2, 8); rec[6] = 9; bad("bad-lineage-influenced-count.dcp", "DCP_BAD_ENUM");
+    lineage(2, 3); memset(rec + 8, 0, 32); bad("bad-lineage-no-content.dcp", "DCP_MISSING_FIELD");
+    lineage(2, 3); memset(rec + 40, 0, 32); bad("bad-lineage-no-dataset.dcp", "DCP_MISSING_FIELD");
+    lineage(2, 3); memset(rec + 72, 0, 32); bad("bad-lineage-no-consent.dcp", "DCP_MISSING_FIELD");
+    lineage(2, 3); memset(rec + 136, 0, 32); bad("bad-lineage-empty-parent.dcp", "DCP_MISSING_FIELD");
+    lineage(2, 3); memset(rec + 264, 0, 32); bad("bad-lineage-empty-influenced.dcp", "DCP_MISSING_FIELD");
+    lineage(2, 3); rec[488] = 0x01; bad("bad-lineage-key.dcp", "DCP_BAD_KEY");
+    lineage(2, 3); memcpy(rec + 136, rec + 8, 32); bad("bad-lineage-self-parent.dcp", "DCP_ANCESTOR_CYCLE");
+    lineage(3, 3); memcpy(rec + 168, rec + 104, 32); bad("bad-lineage-duplicate-parent.dcp", "DCP_DUPLICATE");
+
+    if (fclose(gen_expected) != 0) gen_fail = 1;
+    return gen_fail ? 2 : 0;
+}
+
+int main(int argc, char **argv) {
+    char out[1024];
+    size_t n;
+    if (argc == 2 && argv[1][0] != '-') {
+        if (slurp(argv[1], &n)) { fprintf(stderr, "cannot read %s\n", argv[1]); return 2; }
+        verdict_line(file_buf, n, out, sizeof out);
+        puts(out);
+        return strncmp(out, "ok ", 3) == 0 ? 0 : 1;
+    }
+    if (argc == 3 && strcmp(argv[1], "--corpus") == 0) return corpus(argv[2]);
+    if (argc == 3 && strcmp(argv[1], "--make-vectors") == 0) return make_vectors(argv[2]);
+    fprintf(stderr, "usage: dcp_verify FILE | --corpus DIR | --make-vectors DIR\n");
+    return 2;
+}
diff --git a/specs/discovery-capsule/tools/mutate-verifier.sh b/specs/discovery-capsule/tools/mutate-verifier.sh
new file mode 100644
index 0000000..09733f8
--- /dev/null
+++ b/specs/discovery-capsule/tools/mutate-verifier.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# mutate-verifier.sh: show that every check in dcp_verify.c is exercised by
+# the vectors. Builds one checker per check with that check disabled
+# (-DDCP_MUTANT=K) and requires the vectors to report at least one miss.
+# A mutant the vectors do not notice is a SURVIVOR and fails this script.
+#
+# Usage: mutate-verifier.sh [CC]
+set -eu
+export LC_ALL=C
+here=$(cd "$(dirname "$0")" && pwd)
+vec="$here/../vectors"
+CC=${1:-cc}
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+names=$(sed -n '/CHK_MIN_LEN = 1/,/CHK_LAST/p' "$here/dcp_verify.c" | tr -d ' \n' | sed 's/CHK_MIN_LEN=1/CHK_MIN_LEN/; s/,CHK_LAST.*//' | tr ',' ' ')
+test -n "$names" || { echo "cannot read the check list" >&2; exit 2; }
+k=0 killed=0 survived=0
+for name in $names; do
+    k=$((k + 1))
+    "$CC" -std=c99 -O1 -w -DDCP_MUTANT=$k -o "$tmp/m$k" "$here/dcp_verify.c"
+    if "$tmp/m$k" --corpus "$vec" >"$tmp/out$k" 2>&1; then
+        echo "SURVIVOR $k $name"
+        survived=$((survived + 1))
+    else
+        echo "killed $k $name: $(grep -c 'MISMATCH' "$tmp/out$k") vector(s) differ"
+        killed=$((killed + 1))
+    fi
+done
+echo "DCP1_VERIFIER_MUTANTS total=$k killed=$killed survived=$survived"
+test "$survived" -eq 0 && test "$k" -gt 0
diff --git a/specs/discovery-capsule/vectors/.gitattributes b/specs/discovery-capsule/vectors/.gitattributes
new file mode 100644
index 0000000..323d9e5
--- /dev/null
+++ b/specs/discovery-capsule/vectors/.gitattributes
@@ -0,0 +1 @@
+*.dcp binary
diff --git a/specs/discovery-capsule/vectors/bad-ack-key.dcp b/specs/discovery-capsule/vectors/bad-ack-key.dcp
new file mode 100644
index 0000000..bd236d7
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-ack-key.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-ack-no-retraction.dcp b/specs/discovery-capsule/vectors/bad-ack-no-retraction.dcp
new file mode 100644
index 0000000..1889804
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-ack-no-retraction.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-ack-reserved0.dcp b/specs/discovery-capsule/vectors/bad-ack-reserved0.dcp
new file mode 100644
index 0000000..023b6ef
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-ack-reserved0.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-ack-reserved1.dcp b/specs/discovery-capsule/vectors/bad-ack-reserved1.dcp
new file mode 100644
index 0000000..35d2af8
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-ack-reserved1.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-ack-status-erased.dcp b/specs/discovery-capsule/vectors/bad-ack-status-erased.dcp
new file mode 100644
index 0000000..b26f774
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-ack-status-erased.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-ack-status-zero.dcp b/specs/discovery-capsule/vectors/bad-ack-status-zero.dcp
new file mode 100644
index 0000000..a383f98
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-ack-status-zero.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-ack-time-zero.dcp b/specs/discovery-capsule/vectors/bad-ack-time-zero.dcp
new file mode 100644
index 0000000..b46a001
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-ack-time-zero.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-capability-bit.dcp b/specs/discovery-capsule/vectors/bad-capsule-capability-bit.dcp
new file mode 100644
index 0000000..eab6ccc
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-capability-bit.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-dims-past-rank.dcp b/specs/discovery-capsule/vectors/bad-capsule-dims-past-rank.dcp
new file mode 100644
index 0000000..81b6a5c
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-dims-past-rank.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-expires-not-after.dcp b/specs/discovery-capsule/vectors/bad-capsule-expires-not-after.dcp
new file mode 100644
index 0000000..94e698c
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-expires-not-after.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-failure-digest-without-count.dcp b/specs/discovery-capsule/vectors/bad-capsule-failure-digest-without-count.dcp
new file mode 100644
index 0000000..cf409bc
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-failure-digest-without-count.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-failures-without-digest.dcp b/specs/discovery-capsule/vectors/bad-capsule-failures-without-digest.dcp
new file mode 100644
index 0000000..c1d78bb
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-failures-without-digest.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-license-unknown-seven.dcp b/specs/discovery-capsule/vectors/bad-capsule-license-unknown-seven.dcp
new file mode 100644
index 0000000..b7a84b2
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-license-unknown-seven.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-license-unknown-zero.dcp b/specs/discovery-capsule/vectors/bad-capsule-license-unknown-zero.dcp
new file mode 100644
index 0000000..a72e4a9
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-license-unknown-zero.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-named-discover-no-consent.dcp b/specs/discovery-capsule/vectors/bad-capsule-named-discover-no-consent.dcp
new file mode 100644
index 0000000..ec8c42c
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-named-discover-no-consent.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-named-without-set.dcp b/specs/discovery-capsule/vectors/bad-capsule-named-without-set.dcp
new file mode 100644
index 0000000..8e861f1
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-named-without-set.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-no-abi.dcp b/specs/discovery-capsule/vectors/bad-capsule-no-abi.dcp
new file mode 100644
index 0000000..12ecde9
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-no-abi.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-no-consent.dcp b/specs/discovery-capsule/vectors/bad-capsule-no-consent.dcp
new file mode 100644
index 0000000..ef15712
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-no-consent.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-no-evidence.dcp b/specs/discovery-capsule/vectors/bad-capsule-no-evidence.dcp
new file mode 100644
index 0000000..cda9598
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-no-evidence.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-no-meaning.dcp b/specs/discovery-capsule/vectors/bad-capsule-no-meaning.dcp
new file mode 100644
index 0000000..90c4081
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-no-meaning.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-no-recipient-policy.dcp b/specs/discovery-capsule/vectors/bad-capsule-no-recipient-policy.dcp
new file mode 100644
index 0000000..7045c49
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-no-recipient-policy.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-no-verifier.dcp b/specs/discovery-capsule/vectors/bad-capsule-no-verifier.dcp
new file mode 100644
index 0000000..87e49d4
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-no-verifier.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-owner-key.dcp b/specs/discovery-capsule/vectors/bad-capsule-owner-key.dcp
new file mode 100644
index 0000000..3f2c8aa
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-owner-key.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-permission-bit.dcp b/specs/discovery-capsule/vectors/bad-capsule-permission-bit.dcp
new file mode 100644
index 0000000..a799411
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-permission-bit.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-precision.dcp b/specs/discovery-capsule/vectors/bad-capsule-precision.dcp
new file mode 100644
index 0000000..c94256f
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-precision.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-private-with-read.dcp b/specs/discovery-capsule/vectors/bad-capsule-private-with-read.dcp
new file mode 100644
index 0000000..a35ebc4
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-private-with-read.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-public-with-set.dcp b/specs/discovery-capsule/vectors/bad-capsule-public-with-set.dcp
new file mode 100644
index 0000000..87a5123
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-public-with-set.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-rank.dcp b/specs/discovery-capsule/vectors/bad-capsule-rank.dcp
new file mode 100644
index 0000000..d57c10d
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-rank.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-redistribute-without-read.dcp b/specs/discovery-capsule/vectors/bad-capsule-redistribute-without-read.dcp
new file mode 100644
index 0000000..59e05f5
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-redistribute-without-read.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-reserved0.dcp b/specs/discovery-capsule/vectors/bad-capsule-reserved0.dcp
new file mode 100644
index 0000000..c2a67e9
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-reserved0.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-reserved1.dcp b/specs/discovery-capsule/vectors/bad-capsule-reserved1.dcp
new file mode 100644
index 0000000..630554f
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-reserved1.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-revocation-head-without-seq.dcp b/specs/discovery-capsule/vectors/bad-capsule-revocation-head-without-seq.dcp
new file mode 100644
index 0000000..e7ee856
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-revocation-head-without-seq.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-revocation-seq-without-head.dcp b/specs/discovery-capsule/vectors/bad-capsule-revocation-seq-without-head.dcp
new file mode 100644
index 0000000..061bbaa
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-revocation-seq-without-head.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-scope.dcp b/specs/discovery-capsule/vectors/bad-capsule-scope.dcp
new file mode 100644
index 0000000..8de2a74
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-scope.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-train-without-read.dcp b/specs/discovery-capsule/vectors/bad-capsule-train-without-read.dcp
new file mode 100644
index 0000000..ebc59f0
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-train-without-read.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-capsule-valid-from-zero.dcp b/specs/discovery-capsule/vectors/bad-capsule-valid-from-zero.dcp
new file mode 100644
index 0000000..9778b14
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-capsule-valid-from-zero.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-custodian-count.dcp b/specs/discovery-capsule/vectors/bad-consent-custodian-count.dcp
new file mode 100644
index 0000000..a786dae
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-custodian-count.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-empty-declared-custodian.dcp b/specs/discovery-capsule/vectors/bad-consent-empty-declared-custodian.dcp
new file mode 100644
index 0000000..a8296a4
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-empty-declared-custodian.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-issued-zero.dcp b/specs/discovery-capsule/vectors/bad-consent-issued-zero.dcp
new file mode 100644
index 0000000..e71f04a
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-issued-zero.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-no-purpose.dcp b/specs/discovery-capsule/vectors/bad-consent-no-purpose.dcp
new file mode 100644
index 0000000..072db7b
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-no-purpose.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-no-recipient.dcp b/specs/discovery-capsule/vectors/bad-consent-no-recipient.dcp
new file mode 100644
index 0000000..478d8c7
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-no-recipient.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-no-version.dcp b/specs/discovery-capsule/vectors/bad-consent-no-version.dcp
new file mode 100644
index 0000000..5d5ad32
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-no-version.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-owner-key.dcp b/specs/discovery-capsule/vectors/bad-consent-owner-key.dcp
new file mode 100644
index 0000000..6a4b364
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-owner-key.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-purpose-bit.dcp b/specs/discovery-capsule/vectors/bad-consent-purpose-bit.dcp
new file mode 100644
index 0000000..de395c5
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-purpose-bit.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-reserved0.dcp b/specs/discovery-capsule/vectors/bad-consent-reserved0.dcp
new file mode 100644
index 0000000..782ca0a
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-reserved0.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-reserved1.dcp b/specs/discovery-capsule/vectors/bad-consent-reserved1.dcp
new file mode 100644
index 0000000..7d36f3f
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-reserved1.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-retention-not-after.dcp b/specs/discovery-capsule/vectors/bad-consent-retention-not-after.dcp
new file mode 100644
index 0000000..6ab21b0
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-retention-not-after.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-train-without-read.dcp b/specs/discovery-capsule/vectors/bad-consent-train-without-read.dcp
new file mode 100644
index 0000000..b28e538
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-train-without-read.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-consent-undeclared-custodian-slot.dcp b/specs/discovery-capsule/vectors/bad-consent-undeclared-custodian-slot.dcp
new file mode 100644
index 0000000..473aa82
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-consent-undeclared-custodian-slot.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-length-capsule-short.dcp b/specs/discovery-capsule/vectors/bad-length-capsule-short.dcp
new file mode 100644
index 0000000..8a68cc6
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-length-capsule-short.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-length-empty.dcp b/specs/discovery-capsule/vectors/bad-length-empty.dcp
new file mode 100644
index 0000000..e69de29
diff --git a/specs/discovery-capsule/vectors/bad-length-retraction-trailing.dcp b/specs/discovery-capsule/vectors/bad-length-retraction-trailing.dcp
new file mode 100644
index 0000000..6b998b0
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-length-retraction-trailing.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-length-short.dcp b/specs/discovery-capsule/vectors/bad-length-short.dcp
new file mode 100644
index 0000000..3b08580
--- /dev/null
+++ b/specs/discovery-capsule/vectors/bad-length-short.dcp
@@ -0,0 +1 @@
+DCP1
\ No newline at end of file
diff --git a/specs/discovery-capsule/vectors/bad-lineage-duplicate-parent.dcp b/specs/discovery-capsule/vectors/bad-lineage-duplicate-parent.dcp
new file mode 100644
index 0000000..9f812df
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-duplicate-parent.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-empty-influenced.dcp b/specs/discovery-capsule/vectors/bad-lineage-empty-influenced.dcp
new file mode 100644
index 0000000..6bf3d6f
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-empty-influenced.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-empty-parent.dcp b/specs/discovery-capsule/vectors/bad-lineage-empty-parent.dcp
new file mode 100644
index 0000000..5f37cfb
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-empty-parent.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-influenced-count.dcp b/specs/discovery-capsule/vectors/bad-lineage-influenced-count.dcp
new file mode 100644
index 0000000..57cfffd
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-influenced-count.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-key.dcp b/specs/discovery-capsule/vectors/bad-lineage-key.dcp
new file mode 100644
index 0000000..77398b7
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-key.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-no-consent.dcp b/specs/discovery-capsule/vectors/bad-lineage-no-consent.dcp
new file mode 100644
index 0000000..3b00a3b
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-no-consent.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-no-content.dcp b/specs/discovery-capsule/vectors/bad-lineage-no-content.dcp
new file mode 100644
index 0000000..0b8917d
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-no-content.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-no-dataset.dcp b/specs/discovery-capsule/vectors/bad-lineage-no-dataset.dcp
new file mode 100644
index 0000000..32e2112
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-no-dataset.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-parent-count.dcp b/specs/discovery-capsule/vectors/bad-lineage-parent-count.dcp
new file mode 100644
index 0000000..b463d13
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-parent-count.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-reserved0.dcp b/specs/discovery-capsule/vectors/bad-lineage-reserved0.dcp
new file mode 100644
index 0000000..20af07f
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-reserved0.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-reserved1.dcp b/specs/discovery-capsule/vectors/bad-lineage-reserved1.dcp
new file mode 100644
index 0000000..4506d2d
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-reserved1.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-self-parent.dcp b/specs/discovery-capsule/vectors/bad-lineage-self-parent.dcp
new file mode 100644
index 0000000..45cf23f
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-self-parent.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-unused-influenced-slot.dcp b/specs/discovery-capsule/vectors/bad-lineage-unused-influenced-slot.dcp
new file mode 100644
index 0000000..205dd66
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-unused-influenced-slot.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-lineage-unused-parent-slot.dcp b/specs/discovery-capsule/vectors/bad-lineage-unused-parent-slot.dcp
new file mode 100644
index 0000000..0e61ac9
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-lineage-unused-parent-slot.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-magic.dcp b/specs/discovery-capsule/vectors/bad-magic.dcp
new file mode 100644
index 0000000..19a87f1
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-magic.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-claims-erasure.dcp b/specs/discovery-capsule/vectors/bad-retraction-claims-erasure.dcp
new file mode 100644
index 0000000..6af93f6
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-claims-erasure.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-effective-zero.dcp b/specs/discovery-capsule/vectors/bad-retraction-effective-zero.dcp
new file mode 100644
index 0000000..8eb2f83
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-effective-zero.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-no-scope.dcp b/specs/discovery-capsule/vectors/bad-retraction-no-scope.dcp
new file mode 100644
index 0000000..5548716
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-no-scope.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-no-target.dcp b/specs/discovery-capsule/vectors/bad-retraction-no-target.dcp
new file mode 100644
index 0000000..2dd456e
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-no-target.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-no-tombstone.dcp b/specs/discovery-capsule/vectors/bad-retraction-no-tombstone.dcp
new file mode 100644
index 0000000..bf5d541
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-no-tombstone.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-owner-key.dcp b/specs/discovery-capsule/vectors/bad-retraction-owner-key.dcp
new file mode 100644
index 0000000..0f7f50e
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-owner-key.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-reserved0.dcp b/specs/discovery-capsule/vectors/bad-retraction-reserved0.dcp
new file mode 100644
index 0000000..c18c860
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-reserved0.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-reserved1.dcp b/specs/discovery-capsule/vectors/bad-retraction-reserved1.dcp
new file mode 100644
index 0000000..5d15c47
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-reserved1.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-scope-bit.dcp b/specs/discovery-capsule/vectors/bad-retraction-scope-bit.dcp
new file mode 100644
index 0000000..2a04a6c
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-scope-bit.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-seq-zero.dcp b/specs/discovery-capsule/vectors/bad-retraction-seq-zero.dcp
new file mode 100644
index 0000000..6e6c2e5
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-seq-zero.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-seq1-with-prev.dcp b/specs/discovery-capsule/vectors/bad-retraction-seq1-with-prev.dcp
new file mode 100644
index 0000000..2a84523
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-seq1-with-prev.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-seq2-without-prev.dcp b/specs/discovery-capsule/vectors/bad-retraction-seq2-without-prev.dcp
new file mode 100644
index 0000000..32a0764
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-seq2-without-prev.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-retraction-signer-key.dcp b/specs/discovery-capsule/vectors/bad-retraction-signer-key.dcp
new file mode 100644
index 0000000..5887974
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-retraction-signer-key.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-version-downgrade.dcp b/specs/discovery-capsule/vectors/bad-version-downgrade.dcp
new file mode 100644
index 0000000..4615c8d
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-version-downgrade.dcp differ
diff --git a/specs/discovery-capsule/vectors/bad-version-unknown.dcp b/specs/discovery-capsule/vectors/bad-version-unknown.dcp
new file mode 100644
index 0000000..5936b07
Binary files /dev/null and b/specs/discovery-capsule/vectors/bad-version-unknown.dcp differ
diff --git a/specs/discovery-capsule/vectors/expected.txt b/specs/discovery-capsule/vectors/expected.txt
new file mode 100644
index 0000000..96ca61f
--- /dev/null
+++ b/specs/discovery-capsule/vectors/expected.txt
@@ -0,0 +1,102 @@
+# DCP1 family vectors. Spec: ../SPEC.md (Draft v0.1, wire version 1).
+# Line: <file> <verdict line>, verdict line as printed by tools/dcp_verify.c:
+#   ok type=MAGIC digest=H64 key=H66   (digest excludes the signature)
+#   refuse <code from SPEC.md section 12>
+# Signature bytes are filler; signatures are checked by the Rust crate.
+# Generated by tools/dcp_verify.c --make-vectors; do not edit by hand.
+ok-capsule-named.dcp ok type=DCP1 digest=f159058fb214940605dcee50fc73984e00279329b6b994d17376958afd651ce2 key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+ok-capsule-private-default.dcp ok type=DCP1 digest=84c52fdb34530572e848b89b5887291bd828be550e1afa8283806c1a4aebb649 key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+ok-capsule-public-after-retractions.dcp ok type=DCP1 digest=95eafac8c4f344cdb006ba7f36b5ec312165a9f59b5cfdd0df275d6bd5a9a447 key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+ok-capsule-named-discover-only.dcp ok type=DCP1 digest=4c27a1ec8e876cf0de751a7424bf7c67853f92ae0e0f94159fa9cf88597492b6 key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+ok-consent-two-custodians.dcp ok type=DCC1 digest=ac6256d6ea5a4101bbfd143f399e18fd534e3eb743cfc7d2451f853ce4126197 key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+ok-consent-read-only.dcp ok type=DCC1 digest=c6e33ee4c0738106049b4dc2533faf83af06310f2e9b0f539d9ac0e20c6f1291 key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+ok-retraction-first.dcp ok type=DCR1 digest=a6837acbc4ad0bc106ef7444117a87a6d6c39f856adf13157d5df26a29bb1b98 key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+ok-retraction-by-custodian.dcp ok type=DCR1 digest=2511451c584a1123bb4f3a2d3f3a6f743eb5d3cc9292c6e4c9dc317adda69c43 key=02b4bbc2c9d0d7dee5ecf3fa01080f161d242b323940474e555c636a71787f868d
+ok-ack-enforced.dcp ok type=DCA1 digest=bd486fee1dcfb4fdec812841e77b57eccccf44595e6fc01d91583c8521986afb key=02b2b9c0c7ced5dce3eaf1f8ff060d141b222930373e454c535a61686f767d848b
+ok-ack-enforced-with-retained.dcp ok type=DCA1 digest=f102575aae4b0aa51e1341c97b3ed01f6ac59fdc56cd4f2757911d38574172fa key=02b2b9c0c7ced5dce3eaf1f8ff060d141b222930373e454c535a61686f767d848b
+ok-lineage-root.dcp ok type=DCL1 digest=3a156cc1afe5395b2ff5b68abef24017db72685e953235d3b55f71feb479ff99 key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+ok-lineage-parents-influenced.dcp ok type=DCL1 digest=7b943f8ce9255ec9085ade2a9447b8954b34f74ada0e072e976e258120182a81 key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+ok-lineage-full.dcp ok type=DCL1 digest=95e5ec3de1331356bf0e3120cc72f4375a20743433fb23abb76f0e8faa5fe80d key=03a1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b424950575e656c737a
+bad-length-short.dcp refuse DCP_BAD_LENGTH
+bad-length-empty.dcp refuse DCP_BAD_LENGTH
+bad-magic.dcp refuse DCP_BAD_MAGIC
+bad-version-downgrade.dcp refuse DCP_DOWNGRADE
+bad-version-unknown.dcp refuse DCP_BAD_VERSION
+bad-length-capsule-short.dcp refuse DCP_BAD_LENGTH
+bad-length-retraction-trailing.dcp refuse DCP_BAD_LENGTH
+bad-capsule-reserved0.dcp refuse DCP_RESERVED_NONZERO
+bad-capsule-reserved1.dcp refuse DCP_RESERVED_NONZERO
+bad-capsule-dims-past-rank.dcp refuse DCP_RESERVED_NONZERO
+bad-capsule-scope.dcp refuse DCP_BAD_ENUM
+bad-capsule-permission-bit.dcp refuse DCP_BAD_ENUM
+bad-capsule-precision.dcp refuse DCP_BAD_ENUM
+bad-capsule-capability-bit.dcp refuse DCP_BAD_ENUM
+bad-capsule-rank.dcp refuse DCP_BAD_ENUM
+bad-capsule-license-unknown-zero.dcp refuse DCP_UNKNOWN_LICENSE
+bad-capsule-license-unknown-seven.dcp refuse DCP_UNKNOWN_LICENSE
+bad-capsule-no-abi.dcp refuse DCP_MISSING_FIELD
+bad-capsule-no-meaning.dcp refuse DCP_MISSING_FIELD
+bad-capsule-no-verifier.dcp refuse DCP_MISSING_FIELD
+bad-capsule-no-evidence.dcp refuse DCP_MISSING_FIELD
+bad-capsule-no-recipient-policy.dcp refuse DCP_MISSING_FIELD
+bad-capsule-owner-key.dcp refuse DCP_BAD_KEY
+bad-capsule-valid-from-zero.dcp refuse DCP_BAD_VALIDITY
+bad-capsule-expires-not-after.dcp refuse DCP_BAD_VALIDITY
+bad-capsule-failures-without-digest.dcp refuse DCP_INCONSISTENT
+bad-capsule-failure-digest-without-count.dcp refuse DCP_INCONSISTENT
+bad-capsule-revocation-seq-without-head.dcp refuse DCP_INCONSISTENT
+bad-capsule-revocation-head-without-seq.dcp refuse DCP_INCONSISTENT
+bad-capsule-private-with-read.dcp refuse DCP_SCOPE_CONFLICT
+bad-capsule-named-without-set.dcp refuse DCP_SCOPE_CONFLICT
+bad-capsule-public-with-set.dcp refuse DCP_SCOPE_CONFLICT
+bad-capsule-train-without-read.dcp refuse DCP_PERMISSION_AMPLIFICATION
+bad-capsule-redistribute-without-read.dcp refuse DCP_PERMISSION_AMPLIFICATION
+bad-capsule-no-consent.dcp refuse DCP_NO_CONSENT
+bad-capsule-named-discover-no-consent.dcp refuse DCP_NO_CONSENT
+bad-consent-reserved0.dcp refuse DCP_RESERVED_NONZERO
+bad-consent-reserved1.dcp refuse DCP_RESERVED_NONZERO
+bad-consent-undeclared-custodian-slot.dcp refuse DCP_RESERVED_NONZERO
+bad-consent-no-purpose.dcp refuse DCP_BAD_ENUM
+bad-consent-purpose-bit.dcp refuse DCP_BAD_ENUM
+bad-consent-custodian-count.dcp refuse DCP_BAD_ENUM
+bad-consent-no-version.dcp refuse DCP_MISSING_FIELD
+bad-consent-no-recipient.dcp refuse DCP_MISSING_FIELD
+bad-consent-empty-declared-custodian.dcp refuse DCP_MISSING_FIELD
+bad-consent-owner-key.dcp refuse DCP_BAD_KEY
+bad-consent-issued-zero.dcp refuse DCP_BAD_VALIDITY
+bad-consent-retention-not-after.dcp refuse DCP_BAD_VALIDITY
+bad-consent-train-without-read.dcp refuse DCP_PERMISSION_AMPLIFICATION
+bad-retraction-reserved0.dcp refuse DCP_RESERVED_NONZERO
+bad-retraction-reserved1.dcp refuse DCP_RESERVED_NONZERO
+bad-retraction-no-scope.dcp refuse DCP_BAD_ENUM
+bad-retraction-scope-bit.dcp refuse DCP_BAD_ENUM
+bad-retraction-claims-erasure.dcp refuse DCP_FALSE_ERASURE_CLAIM
+bad-retraction-seq-zero.dcp refuse DCP_MISSING_FIELD
+bad-retraction-no-target.dcp refuse DCP_MISSING_FIELD
+bad-retraction-no-tombstone.dcp refuse DCP_MISSING_FIELD
+bad-retraction-owner-key.dcp refuse DCP_BAD_KEY
+bad-retraction-signer-key.dcp refuse DCP_BAD_KEY
+bad-retraction-effective-zero.dcp refuse DCP_BAD_VALIDITY
+bad-retraction-seq2-without-prev.dcp refuse DCP_INCONSISTENT
+bad-retraction-seq1-with-prev.dcp refuse DCP_INCONSISTENT
+bad-ack-reserved0.dcp refuse DCP_RESERVED_NONZERO
+bad-ack-reserved1.dcp refuse DCP_RESERVED_NONZERO
+bad-ack-status-zero.dcp refuse DCP_BAD_ENUM
+bad-ack-status-erased.dcp refuse DCP_BAD_ENUM
+bad-ack-no-retraction.dcp refuse DCP_MISSING_FIELD
+bad-ack-key.dcp refuse DCP_BAD_KEY
+bad-ack-time-zero.dcp refuse DCP_BAD_VALIDITY
+bad-lineage-reserved0.dcp refuse DCP_RESERVED_NONZERO
+bad-lineage-reserved1.dcp refuse DCP_RESERVED_NONZERO
+bad-lineage-unused-parent-slot.dcp refuse DCP_RESERVED_NONZERO
+bad-lineage-unused-influenced-slot.dcp refuse DCP_RESERVED_NONZERO
+bad-lineage-parent-count.dcp refuse DCP_BAD_ENUM
+bad-lineage-influenced-count.dcp refuse DCP_BAD_ENUM
+bad-lineage-no-content.dcp refuse DCP_MISSING_FIELD
+bad-lineage-no-dataset.dcp refuse DCP_MISSING_FIELD
+bad-lineage-no-consent.dcp refuse DCP_MISSING_FIELD
+bad-lineage-empty-parent.dcp refuse DCP_MISSING_FIELD
+bad-lineage-empty-influenced.dcp refuse DCP_MISSING_FIELD
+bad-lineage-key.dcp refuse DCP_BAD_KEY
+bad-lineage-self-parent.dcp refuse DCP_ANCESTOR_CYCLE
+bad-lineage-duplicate-parent.dcp refuse DCP_DUPLICATE
diff --git a/specs/discovery-capsule/vectors/ok-ack-enforced-with-retained.dcp b/specs/discovery-capsule/vectors/ok-ack-enforced-with-retained.dcp
new file mode 100644
index 0000000..537d41a
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-ack-enforced-with-retained.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-ack-enforced.dcp b/specs/discovery-capsule/vectors/ok-ack-enforced.dcp
new file mode 100644
index 0000000..9f2f5e4
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-ack-enforced.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-capsule-named-discover-only.dcp b/specs/discovery-capsule/vectors/ok-capsule-named-discover-only.dcp
new file mode 100644
index 0000000..5a235fe
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-capsule-named-discover-only.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-capsule-named.dcp b/specs/discovery-capsule/vectors/ok-capsule-named.dcp
new file mode 100644
index 0000000..195ed6c
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-capsule-named.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-capsule-private-default.dcp b/specs/discovery-capsule/vectors/ok-capsule-private-default.dcp
new file mode 100644
index 0000000..5a89704
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-capsule-private-default.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-capsule-public-after-retractions.dcp b/specs/discovery-capsule/vectors/ok-capsule-public-after-retractions.dcp
new file mode 100644
index 0000000..cf28982
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-capsule-public-after-retractions.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-consent-read-only.dcp b/specs/discovery-capsule/vectors/ok-consent-read-only.dcp
new file mode 100644
index 0000000..f105500
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-consent-read-only.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-consent-two-custodians.dcp b/specs/discovery-capsule/vectors/ok-consent-two-custodians.dcp
new file mode 100644
index 0000000..f220bac
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-consent-two-custodians.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-lineage-full.dcp b/specs/discovery-capsule/vectors/ok-lineage-full.dcp
new file mode 100644
index 0000000..1fb383a
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-lineage-full.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-lineage-parents-influenced.dcp b/specs/discovery-capsule/vectors/ok-lineage-parents-influenced.dcp
new file mode 100644
index 0000000..0708473
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-lineage-parents-influenced.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-lineage-root.dcp b/specs/discovery-capsule/vectors/ok-lineage-root.dcp
new file mode 100644
index 0000000..412fdec
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-lineage-root.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-retraction-by-custodian.dcp b/specs/discovery-capsule/vectors/ok-retraction-by-custodian.dcp
new file mode 100644
index 0000000..034f469
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-retraction-by-custodian.dcp differ
diff --git a/specs/discovery-capsule/vectors/ok-retraction-first.dcp b/specs/discovery-capsule/vectors/ok-retraction-first.dcp
new file mode 100644
index 0000000..aaaed8f
Binary files /dev/null and b/specs/discovery-capsule/vectors/ok-retraction-first.dcp differ
diff --git a/specs/microjob/.crumb b/specs/microjob/.crumb
new file mode 100644
index 0000000..482e9b6
--- /dev/null
+++ b/specs/microjob/.crumb
@@ -0,0 +1,5 @@
+{
+  "name": "microjob",
+  "purpose": "MJB1 typed bounded microjob DAG and MJR1 receipt format (draft), C checker, vectors and mutants",
+  "schema_version": "1.0.0"
+}
diff --git a/specs/microjob/SPEC.md b/specs/microjob/SPEC.md
new file mode 100644
index 0000000..7807d9f
--- /dev/null
+++ b/specs/microjob/SPEC.md
@@ -0,0 +1,249 @@
+# Typed Bounded Microjob DAG and Receipt: MJB1 / MJR1
+
+**Status**: Draft v0.1 (SI-MICROFORGE C1, 2026-10-24). Not yet produced or read by any runtime. Reference checker and vectors: `tools/mjb_verify.c`, `vectors/`. Rust reader, writer and receipt ledger: `crates/aien-microjob`.
+**Contract version**: 0.1.0 (major zero: may change by minor bump, see VERSIONING.md)
+**Wire version**: 1 (the `version` byte of both records)
+**License**: Community Specification License 1.0
+**Tracking**: aien-dev/aien-protocols-mv#50 (C1), parent aien-dev/aien-architecture-mv#307 and #306. Binds the Discovery Capsule ABI of aien-protocols-mv#51 (`specs/discovery-capsule/`) by digest only.
+**Not in this document**: who plans the DAG (Allen, allen#13), who runs a node (Omega scheduler, FORGE placement), who approves an effect (AEGIS / the Spark approval desk), the network carrier (PST1, OSH stream ABI #43), payment of any kind.
+
+## 1. Purpose
+
+Allen and SI Fusion need one portable typed envelope for small computational steps instead of one prose prompt per agent operation. MJB1 is that envelope: one objective expressed as an explicit, bounded, acyclic dependency graph of typed microjobs, each with hard token, time, fuel, memory and work caps, a required verifier and explicit cancel and retry semantics. MJR1 is the receipt that binds what one microjob actually produced and consumed.
+
+MJB1 is a proposal format. A valid MJB1 document is **not** an authorization, and an MJB1 node is not a receipt. No field in MJB1 or MJR1 grants a capability (section 9).
+
+## 2. Inventory of what already exists
+
+| Existing piece | Where | Reused? | Reason |
+|---|---|---|---|
+| PST1 task message | `specs/pi-spark-task/` | Yes, as carrier and house pattern | A PST1 `request` payload is at most 800 bytes, so an MJB1 document travels by digest in the PST1 header (`objective_id`, `payload_digest`) and its bytes through the content store. Same byte order (big-endian), same check-order discipline, same C checker plus vectors plus mutants pattern. |
+| Objective id | aien-sovereign-core `crates/aien-runtime/src/objective.rs` | Yes, as a header field | Copied, never minted by a receiver. |
+| ALLEN subject | AIENOS ADR 0018 | Yes, as `subject_id` | 32-byte subject reference; no key material. |
+| Effect classes | PST1 section 4 (`effect_class`) | Yes, same values | 0 NONE, 1 COMPUTE, 2 EFFECT. |
+| Effect ledger | aien-sovereign-core `crates/aien-runtime/src/effects.rs` | Yes, as reconciliation authority | An UNCERTAIN effect is reconciled there before any new attempt. |
+| P-256 ECDSA signatures | `crates/aien-provenance` (`p256`) | Yes, same primitive | MJR1 signatures use the curve and hash already used by the signed source grants of this repository. No new cryptosystem. |
+| OSH stream and task ABI | `specs/osh-platform/STREAM_TASK.md` (#43) | Not changed | MJB1 does not define streams; a node result travels as a typed content reference. |
+
+## 3. Encoding rules
+
+1. All integers are big-endian and unsigned. Digests are 32 raw bytes (SHA-256), printed as 64 lower-case hex digits.
+2. Every reserved byte, every unused dependency slot, every unused operand slot and every unused shape dimension is zero on send and refused if non-zero on receipt.
+3. Every enumerated byte has a closed value set. An unknown value is refused (`MJB_BAD_ENUM`).
+4. The canonical identity of an MJB1 document is `dag_digest = SHA-256(all document bytes)`. Every byte is defined, so one document has exactly one encoding. The canonical identity of an MJR1 receipt is `receipt_digest = SHA-256(receipt bytes [0, 340))`; the signature is excluded.
+
+## 4. MJB1 document
+
+One document is a 192-byte header followed by exactly `node_count` node records of 448 bytes each. Largest document: 192 + 64 x 448 = 28864 bytes.
+
+### 4.1 Header, 192 bytes
+
+| Offset | Size | Field | Allowed values |
+|---|---|---|---|
+| 0 | 4 | `magic` | ASCII `MJB1` |
+| 4 | 1 | `version` | 1 |
+| 5 | 1 | `effect_ceiling` | 0 NONE, 1 COMPUTE, 2 EFFECT: the widest effect the original user approval covers |
+| 6 | 2 | `node_count` | 1 to 64 |
+| 8 | 32 | `objective_id` | Not all zero |
+| 40 | 32 | `tenant_id` | Not all zero: the privacy and tenant scope of the whole objective |
+| 72 | 32 | `subject_id` | Not all zero: the ALLEN subject the work is for |
+| 104 | 32 | `approval_ref` | Not all zero: digest of the original approval record held by the approval desk |
+| 136 | 4 | `incarnation` | At least 1; a re-plan of the same objective takes a higher incarnation |
+| 140 | 4 | `reserved0` | 0 |
+| 144 | 8 | `expires_at` | Unix seconds, not zero |
+| 152 | 8 | `budget_time_ms` | Upper bound on the sum of node `time_ms` caps |
+| 160 | 8 | `budget_fuel` | Upper bound on the sum of node `fuel` caps |
+| 168 | 8 | `budget_memory` | Upper bound on every single node `memory` cap (peak, not sum) |
+| 176 | 8 | `budget_work` | Upper bound on the sum of node `work` caps |
+| 184 | 4 | `budget_input_tokens` | Upper bound on the sum of node `input_tokens` caps |
+| 188 | 4 | `budget_output_tokens` | Upper bound on the sum of node `output_tokens` caps |
+
+### 4.2 Node record, 448 bytes
+
+Node `i` (zero-based) starts at offset `192 + 448 i`.
+
+| Offset | Size | Field | Allowed values |
+|---|---|---|---|
+| 0 | 16 | `job_id` | Not all zero; unique in the document |
+| 16 | 16 | `idempotence_key` | Not all zero; unique in the document |
+| 32 | 4 | `generation` | At least 1; the version of this node's inputs and definition |
+| 36 | 1 | `kind` | 1 COMPUTE (zero neural tokens), 2 NEURAL |
+| 37 | 1 | `op` | COMPUTE: 1 ARITH, 2 MATMUL, 3 REDUCE, 4 COMPARE, 5 COMPILE, 6 VERIFY. NEURAL: 1 ROUTE, 2 EXTRACT, 3 PROPOSE, 4 SUMMARIZE |
+| 38 | 1 | `profile` | 0 ZERO, 1 MINIMAL 64/16, 2 DEFAULT 128/32, 3 LARGE 256/64, 4 SPECIALIST 512/128 (input/output tokens) |
+| 39 | 1 | `effect_class` | 0 NONE, 1 COMPUTE, 2 EFFECT |
+| 40 | 2 | `input_tokens` | Input token cap |
+| 42 | 2 | `output_tokens` | Output token cap |
+| 44 | 2 | `required_input_tokens` | Smallest input that carries the node's essential operands without loss, as measured by the planner |
+| 46 | 2 | `required_output_tokens` | Smallest output that can represent the declared result type |
+| 48 | 1 | `verifier_kind` | 1 RECOMPUTE, 2 CHECKER, 3 JUDGE (0 is the missing-verifier refusal) |
+| 49 | 1 | `retry_class` | 1 NEVER, 2 IDEMPOTENT, 3 RECONCILE_FIRST |
+| 50 | 1 | `max_attempts` | 1 to 8 |
+| 51 | 1 | `cancel_mode` | 1 DISCARD (no partial state survives), 2 CHECKPOINT (resumable; the commit is atomic with the receipt) |
+| 52 | 1 | `precision` | 0 EXACT, 1 FP32, 2 BF16, 3 FP16, 4 FP8, 5 INT8, 6 INT4 |
+| 53 | 1 | `substrate_mask` | Bit 0 CPU, bit 1 GPU, bit 2 NPU; not zero; bits 3 to 7 zero |
+| 54 | 1 | `dep_count` | 0 to 8 |
+| 55 | 1 | `operand_count` | 0 to 4 |
+| 56 | 1 | `result_type` | 1 BYTES, 2 INT, 3 FLOAT, 4 TENSOR, 5 BOOL, 6 TEXT, 7 DIGEST |
+| 57 | 1 | `result_rank` | 0 to 4 |
+| 58 | 1 | `pure` | 0 or 1: 1 means deterministic recomputation is admissible |
+| 59 | 1 | `reserved1` | 0 |
+| 60 | 4 | `time_ms` | Not zero |
+| 64 | 8 | `fuel` | Not zero |
+| 72 | 8 | `memory` | Bytes, not zero |
+| 80 | 8 | `work` | Abstract work units, not zero |
+| 88 | 8 | `expires_at` | Unix seconds, not zero, at most the header `expires_at` |
+| 96 | 16 | `result_dims` | 4 x u32; dimensions past `result_rank` are zero |
+| 112 | 32 | `capability_ref` | Not all zero: the currently authorized capability (Omega skill / World authorization) the node runs under |
+| 144 | 32 | `tenant_id` | Equal to the header `tenant_id` |
+| 176 | 32 | `model_ref` | All zero for COMPUTE; not all zero for NEURAL (model, tokenizer and quantization digest) |
+| 208 | 32 | `verifier_ref` | All zero for RECOMPUTE; not all zero for CHECKER and JUDGE |
+| 240 | 48 | `deps` | 8 slots of 6 bytes: `index` u16 (a node of this document), `generation` u32 (the generation of that node this node was planned against) |
+| 288 | 160 | `operands` | 4 slots of 40 bytes: `kind` u8, `reserved` 3 bytes (zero), `generation` u32 (at least 1), `digest` 32 bytes (not all zero) |
+
+Operand kinds: 1 CORTEX_STATE (typed Cortex record, Omega), 2 WORLD_STATE (World / J-Space state digest), 3 CONTENT (typed content blob in the content store), 4 CAPSULE (a DCP1 capsule digest, `specs/discovery-capsule/`), 5 EXPERIENCE (an Omega experience event digest, omega-mv#699). An operand is a typed reference, never inline bytes; essential context is passed this way and is never truncated to fit a token cap.
+
+### 4.3 Token profiles
+
+| Code | Name | Input cap | Output cap |
+|---|---|---|---|
+| 0 | ZERO | 0 | 0 |
+| 1 | MINIMAL | 64 | 16 |
+| 2 | DEFAULT | 128 | 32 |
+| 3 | LARGE | 256 | 64 |
+| 4 | SPECIALIST | 512 | 128 |
+
+A COMPUTE node uses profile ZERO with both caps 0 and `model_ref` all zero: deterministic math spends no neural tokens. A NEURAL node uses profile 1 to 4, with caps not zero and not above the profile; the optimizer may choose caps below the profile. The profile is a per-node contract, not a limit on the objective or on global context: a long objective is many small nodes.
+
+**No silent truncation.** If `required_input_tokens > input_tokens` or `required_output_tokens > output_tokens` the node is refused with `MJB_NEEDS_EXPANSION`. The planner must then choose a larger profile or split the node. A receiver never trims an operand to fit.
+
+### 4.4 Check order
+
+A receiver checks one document in this order and reports the first rule that fails. The C reference checker and the Rust reader follow the same order, so the same bytes always give the same code.
+
+Header:
+
+1. Fewer than 192 bytes: `MJB_BAD_LENGTH`.
+2. `magic` is not `MJB1`: `MJB_BAD_MAGIC`.
+3. `version` 0: `MJB_DOWNGRADE`; above 1: `MJB_BAD_VERSION`.
+4. `node_count` 0 or above 64: `MJB_BAD_COUNT`.
+5. Length differs from `192 + 448 node_count`: `MJB_BAD_LENGTH`.
+6. `reserved0` not zero: `MJB_RESERVED_NONZERO`.
+7. `effect_ceiling` above 2: `MJB_BAD_ENUM`.
+8. `objective_id` all zero: `MJB_NO_OBJECTIVE`. `tenant_id` all zero: `MJB_NO_TENANT`. `subject_id` all zero: `MJB_NO_SUBJECT`. `approval_ref` all zero: `MJB_NO_APPROVAL`. `incarnation` 0: `MJB_NO_OBJECTIVE`.
+9. `expires_at` 0 has no rule of its own: every node then fails rule 22 with `MJB_BAD_EXPIRY`.
+
+Then each node in index order, all rules for node 0 before node 1:
+
+10. `job_id`, `idempotence_key` all zero, or `generation` 0: `MJB_NO_JOB`.
+11. `reserved1`, any byte of an unused dependency slot, any byte of an unused operand slot, the reserved bytes of a used operand slot, or a `result_dims` entry past `result_rank`: `MJB_RESERVED_NONZERO`.
+12. Out-of-range `kind`, `op` (for that kind), `profile`, `effect_class`, `verifier_kind` above 3, `retry_class`, `max_attempts`, `cancel_mode`, `precision`, `substrate_mask`, `dep_count`, `operand_count`, `result_type`, `result_rank`, `pure`, or an operand `kind`: `MJB_BAD_ENUM`.
+13. `tenant_id` differs from the header: `MJB_CROSS_TENANT`.
+14. `capability_ref` all zero: `MJB_NO_CAPABILITY`.
+15. `effect_class` above the header `effect_ceiling`: `MJB_UNAUTHORIZED_EFFECT`.
+16. `verifier_kind` 0; or CHECKER or JUDGE with `verifier_ref` all zero; or RECOMPUTE with `verifier_ref` not zero; or RECOMPUTE on a node that is not `pure`: `MJB_NO_VERIFIER`.
+17. `pure` is 1 on a NEURAL node or on an EFFECT node: `MJB_IMPURE`.
+18. COMPUTE with profile not ZERO, a token cap not zero, a required token count not zero, or `model_ref` not zero; NEURAL with profile ZERO, a zero token cap, a cap above the profile, or `model_ref` all zero: `MJB_TOKEN_PROFILE`.
+19. `required_input_tokens > input_tokens` or `required_output_tokens > output_tokens`: `MJB_NEEDS_EXPANSION`.
+20. `retry_class` NEVER with `max_attempts` above 1; or EFFECT with `retry_class` IDEMPOTENT: `MJB_BAD_RETRY`.
+21. `time_ms`, `fuel`, `memory` or `work` zero: `MJB_ZERO_CAP`.
+22. `expires_at` zero or above the header `expires_at`: `MJB_BAD_EXPIRY`.
+23. A used operand with `generation` 0 or `digest` all zero: `MJB_MISSING_OPERAND`.
+
+Then the whole graph:
+
+24. Two nodes share a `job_id` or an `idempotence_key`: `MJB_DUPLICATE_JOB`.
+25. A dependency `index` that is the node itself or not below `node_count` (an orphaned required input): `MJB_MISSING_DEP`.
+26. A dependency `generation` that differs from the `generation` of the node it names: `MJB_STALE_GENERATION`.
+27. The dependency graph has a cycle: `MJB_CYCLE`.
+28. A sum of node caps above its header budget (time, fuel, work, input tokens, output tokens; sums are exact, and a sum that does not fit in 64 bits is over budget), or one node `memory` above `budget_memory`: `MJB_OVER_BUDGET`.
+
+An accepted document has one canonical execution order: Kahn's algorithm, always taking the lowest-index ready node first. The checker prints it.
+
+## 5. MJR1 receipt, 404 bytes
+
+| Offset | Size | Field | Allowed values |
+|---|---|---|---|
+| 0 | 4 | `magic` | ASCII `MJR1` |
+| 4 | 1 | `version` | 1 |
+| 5 | 1 | `outcome` | 1 COMPLETED, 2 REFUSED, 3 FAILED, 4 CANCELLED, 5 UNCERTAIN |
+| 6 | 1 | `attempt` | 1 to `max_attempts` of the node |
+| 7 | 1 | `reserved0` | 0 |
+| 8 | 32 | `dag_digest` | The MJB1 `dag_digest` |
+| 40 | 16 | `job_id` | The node's `job_id` |
+| 56 | 16 | `idempotence_key` | The node's `idempotence_key` |
+| 72 | 4 | `generation` | The node's `generation` |
+| 76 | 4 | `used_time_ms` | Consumed wall time |
+| 80 | 2 | `used_input_tokens` | Consumed |
+| 82 | 2 | `used_output_tokens` | Consumed |
+| 84 | 4 | `reserved1` | 0 |
+| 88 | 8 | `used_fuel` | Consumed |
+| 96 | 8 | `used_memory` | Peak bytes |
+| 104 | 8 | `used_work` | Consumed |
+| 112 | 32 | `input_binding` | Section 5.1 |
+| 144 | 32 | `output_digest` | Not zero for COMPLETED; zero otherwise |
+| 176 | 32 | `source_hash` | Not zero: the program / `.om` source that ran |
+| 208 | 32 | `model_hash` | Equal to `model_ref` (zero for COMPUTE) |
+| 240 | 32 | `policy_hash` | Not zero: the routing / admission policy in force |
+| 272 | 32 | `verifier_verdict` | Not zero for COMPLETED: digest of the verifier verdict |
+| 304 | 33 | `signer_key` | SEC1 compressed P-256 key of the executor (first byte 0x02 or 0x03) |
+| 337 | 3 | `reserved2` | 0 |
+| 340 | 64 | `signature` | ECDSA P-256 / SHA-256 over bytes `[0, 340)`, `r` then `s`, 32 bytes each, low-S only |
+
+### 5.1 Input binding
+
+`input_binding = SHA-256("MJR1-BIND" || for each dependency in slot order: receipt_digest of that dependency's COMPLETED receipt || for each operand in slot order: kind (1 byte) || generation (4 bytes) || digest (32 bytes))`.
+
+A receipt whose binding differs from the binding recomputed from the receiver's own accepted dependency receipts and the node's declared operands was computed from a missing or replaced operand and is refused (`MJB_BINDING_MISMATCH`).
+
+### 5.2 Receipt rules
+
+A receiver keeps one ledger per accepted document and applies receipts one at a time. It refuses a receipt, with no state change, when:
+
+| Code | Rule |
+|---|---|
+| `MJB_BAD_RECEIPT` | Wrong length, magic, version, reserved byte, outcome, or signer key prefix; or the COMPLETED / non-COMPLETED zero rules on `output_digest`, `verifier_verdict` are broken; or `source_hash` / `policy_hash` zero |
+| `MJB_FORGED_RECEIPT` | The signer is not in the receiver's local trusted executor set, or the signature does not verify, or is high-S |
+| `MJB_WRONG_DAG` | `dag_digest` is not this document |
+| `MJB_UNKNOWN_JOB` | No node has this `job_id`, or its `idempotence_key` differs |
+| `MJB_STALE_GENERATION` | `generation` differs from the node |
+| `MJB_MODEL_MISMATCH` | `model_hash` differs from the node `model_ref` |
+| `MJB_RECEIPT_OVER_BUDGET` | Any `used_*` value above the node cap |
+| `MJB_DEP_NOT_DONE` | A COMPLETED receipt for a node whose dependencies are not all COMPLETED |
+| `MJB_BINDING_MISMATCH` | Section 5.1 |
+| `MJB_DOUBLE_COMMIT` | The node is already terminal and the receipt is not byte-identical to the one that made it so |
+| `MJB_BAD_RETRY` | A further attempt on a node whose `retry_class` is NEVER, an attempt number not above the last one, or above `max_attempts` |
+| `MJB_CANCELLED` | The objective was cancelled before this receipt was applied |
+
+A byte-identical repeat of an applied receipt is a replay: accepted, no state change. This is what makes interrupt and resume safe: a restarted receiver replays its stored receipts and arrives at the same state, and a second commit of the same node with different bytes is refused.
+
+COMPLETED, REFUSED and CANCELLED are terminal. FAILED and UNCERTAIN are not: another attempt may follow when `retry_class` allows it. An UNCERTAIN effect is reconciled against the effect ledger before the next attempt; a possibly committed effect is never re-run on the strength of a retry alone, which is why EFFECT nodes may not be IDEMPOTENT.
+
+### 5.3 Derived node state
+
+From the document and the ledger a receiver derives, per node: DONE (COMPLETED receipt), REFUSED, CANCELLED, BLOCKED (a dependency is REFUSED, CANCELLED, BLOCKED or out of attempts), READY (every dependency DONE), WAITING otherwise. This is a pure function of accepted bytes; it is not a scheduler and chooses nothing.
+
+Cancellation is atomic with respect to receipts: a receipt applied before the cancel stands, a receipt arriving after it is refused with `MJB_CANCELLED`, and every non-terminal node becomes CANCELLED.
+
+Dependency-version invalidation: a node whose inputs change takes a higher `generation`, and every node that depends on it must name the new generation (rule 26), which changes the document and so its `dag_digest`. Receipts of the old document are refused (`MJB_WRONG_DAG`). A pure node whose bytes and whose ancestors' bytes are unchanged may be recomputed deterministically and must give the same `output_digest`.
+
+## 6. Refusal codes
+
+`MJB_BAD_LENGTH`, `MJB_BAD_MAGIC`, `MJB_DOWNGRADE`, `MJB_BAD_VERSION`, `MJB_BAD_COUNT`, `MJB_RESERVED_NONZERO`, `MJB_BAD_ENUM`, `MJB_NO_OBJECTIVE`, `MJB_NO_TENANT`, `MJB_NO_SUBJECT`, `MJB_NO_APPROVAL`, `MJB_BAD_EXPIRY`, `MJB_NO_JOB`, `MJB_CROSS_TENANT`, `MJB_NO_CAPABILITY`, `MJB_UNAUTHORIZED_EFFECT`, `MJB_NO_VERIFIER`, `MJB_IMPURE`, `MJB_TOKEN_PROFILE`, `MJB_NEEDS_EXPANSION`, `MJB_BAD_RETRY`, `MJB_ZERO_CAP`, `MJB_MISSING_OPERAND`, `MJB_DUPLICATE_JOB`, `MJB_MISSING_DEP`, `MJB_STALE_GENERATION`, `MJB_CYCLE`, `MJB_OVER_BUDGET` (document, section 4.4) and `MJB_BAD_RECEIPT`, `MJB_FORGED_RECEIPT`, `MJB_WRONG_DAG`, `MJB_UNKNOWN_JOB`, `MJB_MODEL_MISMATCH`, `MJB_RECEIPT_OVER_BUDGET`, `MJB_DEP_NOT_DONE`, `MJB_BINDING_MISMATCH`, `MJB_DOUBLE_COMMIT`, `MJB_CANCELLED` (receipts, section 5.2).
+
+## 7. Expiry
+
+Expiry is checked by the receiver against its own clock at admission (`MJB_BAD_EXPIRY` when `expires_at` is in the past). The C checker has no clock and checks only the static rules of section 4.4.
+
+## 8. Relation to the Turing Compute Network
+
+The same document can later ride a voluntary compute network. This pilot contract has **no wallet, currency, price, public job market or escrow field**. Spendable credit stays with the existing Sovereign Core ledger (aien-sovereign-core-mv#734); a receipt is evidence of execution, never of novelty or scientific gain.
+
+## 9. No capability, no permission
+
+No field grants anything. `capability_ref` and `approval_ref` name authorizations that the receiver checks against the real authority (Omega skill / World authorization, AEGIS, the approval desk); a reference it cannot resolve is a refusal at admission. A node's effect can never be wider than `effect_ceiling`, and `effect_ceiling` can never be wider than the original user approval it names. Model output, a routing choice, a valid document or a valid receipt is never an authorization.
+
+## 10. Open questions
+
+1. Node count cap (64) and slot counts (8 dependencies, 4 operands) are first-cut bounds without a measurement; a wider fan-in is expressed today by a REDUCE node chain.
+2. Whether Omega carries the same layout as a seeded `.om` value or as an opaque byte record (owner: omega-mv).
+3. Whether the executor signer set is per tenant or per host (owner: the Spark receipt signer).
diff --git a/specs/microjob/tools/check-vectors.sh b/specs/microjob/tools/check-vectors.sh
new file mode 100644
index 0000000..89b20e9
--- /dev/null
+++ b/specs/microjob/tools/check-vectors.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# check-vectors.sh: build the MJB1 reference checker and check the vectors.
+#
+# Usage: check-vectors.sh [CC]        (default CC: cc)
+#
+# 1. Builds tools/mjb_verify.c with warnings as errors (C99, libc only).
+# 2. Regenerates the vectors into a scratch directory (mjb_verify
+#    --make-vectors) and requires them byte-identical to vectors/, so a stale
+#    or hand-edited vector fails here.
+# 3. Runs every vectors/expected.txt line (and re-encodes every accepted
+#    message, which must give the same bytes), plus an ASan/UBSan build when
+#    the compiler supports it.
+# 4. Runs tools/mutate-verifier.sh: every check must be caught by a vector.
+# Host-only check: no hardware. Shell and C only. Found by the PROTO-C-VECTORS
+# gate (tests/gates/run.sh c-vectors) because its name matches check-*.sh.
+set -eu
+export LC_ALL=C
+here=$(cd "$(dirname "$0")" && pwd)
+vec="$here/../vectors"
+CC=${1:-cc}
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+
+"$CC" -std=c99 -O2 -Wall -Wextra -Werror -pedantic -o "$tmp/mjb_verify" "$here/mjb_verify.c"
+
+mkdir -p "$tmp/regen"
+"$tmp/mjb_verify" --make-vectors "$tmp/regen"
+ignore="-x .crumb -x .crumb.local -x .gitattributes"
+if ! diff -r $ignore "$vec" "$tmp/regen" >/dev/null; then
+    echo "MJB1_VECTORS_STALE: vectors/ differs from mjb_verify --make-vectors output" >&2
+    diff -rq $ignore "$vec" "$tmp/regen" >&2 || true
+    exit 1
+fi
+echo "MJB1_VECTORS_REGEN identical"
+
+"$tmp/mjb_verify" --corpus "$vec"
+
+if "$CC" -std=c99 -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all \
+        -o "$tmp/mjb_verify_san" "$here/mjb_verify.c" 2>/dev/null; then
+    "$tmp/mjb_verify_san" --corpus "$vec" | sed 's/^MJB1_CONFORMANCE impl=c/MJB1_CONFORMANCE impl=c-asan-ubsan/'
+    test "${PIPESTATUS[0]}" -eq 0
+else
+    echo "MJB1_SANITIZER NOT_RUN (compiler lacks -fsanitize=address,undefined)"
+fi
+
+bash "$here/mutate-verifier.sh" "$CC"
+echo "MJB1_VECTORS_PASS"
diff --git a/specs/microjob/tools/mjb_verify.c b/specs/microjob/tools/mjb_verify.c
new file mode 100644
index 0000000..b37f35f
--- /dev/null
+++ b/specs/microjob/tools/mjb_verify.c
@@ -0,0 +1,819 @@
+/* mjb_verify.c: reference checker for MJB1, the typed bounded microjob DAG.
+ * Spec: ../SPEC.md (Draft v0.1, contract 0.1.0, wire version 1).
+ *
+ * Self-contained C99: its own SHA-256 (FIPS 180-4), libc only, no heap
+ * (static buffers), no clock. mjb_check() is a pure function of one
+ * read-only buffer. It pins the static document rules of SPEC.md section 4.4
+ * with vectors; it is not linked into any runtime. Receipt rules (section 5)
+ * are stateful and live in the Rust ledger (crates/aien-microjob).
+ *
+ * Usage:
+ *   mjb_verify FILE                print one verdict line
+ *   mjb_verify --corpus DIR        check every DIR/expected.txt line, print
+ *                                  MJB1_CONFORMANCE impl=c pass=N fail=M
+ *   mjb_verify --make-vectors DIR  write the vector files and DIR/expected.txt
+ *
+ * Verdict line (the format expected.txt pins):
+ *   ok nodes=N incarnation=I ceiling=C objective=H64 tenant=H64 digest=H64
+ *      order=i,j,...              (one line; canonical Kahn order, lowest index first)
+ *   refuse CODE                    (CODE is a name from SPEC.md section 6)
+ *
+ * Exit status: 0 on accept / all corpus lines agree, 1 otherwise, 2 on usage
+ * or I/O error.
+ *
+ * Mutation hooks: building with -DMJB_MUTANT=K disables check K (the CHK_*
+ * numbers below). tools/mutate-verifier.sh builds every mutant and requires
+ * the vectors to fail each one, which shows every check is exercised.
+ */
+#define _POSIX_C_SOURCE 200809L /* open, fdopen, close under -std=c99 */
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifndef MJB_MUTANT
+#define MJB_MUTANT 0
+#endif
+#define CHECK(k) (MJB_MUTANT != (k))
+
+enum {
+    CHK_MIN_LEN = 1, CHK_MAGIC, CHK_DOWNGRADE, CHK_VERSION, CHK_COUNT, CHK_EXACT_LEN,
+    CHK_RES0, CHK_CEILING, CHK_OBJECTIVE, CHK_TENANT, CHK_SUBJECT, CHK_APPROVAL,
+    CHK_INCARNATION, CHK_JOB, CHK_IDEM, CHK_GEN, CHK_RES1, CHK_DEP_SLOTS,
+    CHK_OPERAND_SLOTS, CHK_OPERAND_PAD, CHK_DIMS, CHK_E_KIND_OP, CHK_E_PROFILE,
+    CHK_E_EFFECT, CHK_E_VERIFIER, CHK_E_RETRY, CHK_E_ATTEMPTS, CHK_E_CANCEL,
+    CHK_E_PRECISION, CHK_E_SUBSTRATE, CHK_E_DEPN, CHK_E_OPN, CHK_E_RTYPE, CHK_E_RANK,
+    CHK_E_PURE, CHK_E_OPKIND, CHK_TENANT_MATCH, CHK_CAPABILITY, CHK_EFFECT_CEIL,
+    CHK_VERIFIER_ZERO, CHK_VERIFIER_REF, CHK_RECOMPUTE_REF, CHK_RECOMPUTE_PURE,
+    CHK_IMPURE_NEURAL, CHK_IMPURE_EFFECT, CHK_COMPUTE_TOKENS, CHK_NEURAL_TOKENS,
+    CHK_EXPANSION, CHK_RETRY_NEVER, CHK_RETRY_EFFECT, CHK_ZERO_CAP, CHK_NODE_EXPIRY,
+    CHK_OPERAND_MISSING, CHK_DUP, CHK_DEP_RANGE, CHK_STALE, CHK_CYCLE, CHK_BUDGET,
+    CHK_LAST
+};
+
+/* ---- refusal codes (spec section 6, document part) ------------------------ */
+enum {
+    MJB_OK = 0, MJB_BAD_LENGTH, MJB_BAD_MAGIC, MJB_DOWNGRADE, MJB_BAD_VERSION,
+    MJB_BAD_COUNT, MJB_RESERVED_NONZERO, MJB_BAD_ENUM, MJB_NO_OBJECTIVE, MJB_NO_TENANT,
+    MJB_NO_SUBJECT, MJB_NO_APPROVAL, MJB_BAD_EXPIRY, MJB_NO_JOB, MJB_CROSS_TENANT,
+    MJB_NO_CAPABILITY, MJB_UNAUTHORIZED_EFFECT, MJB_NO_VERIFIER, MJB_IMPURE,
+    MJB_TOKEN_PROFILE, MJB_NEEDS_EXPANSION, MJB_BAD_RETRY, MJB_ZERO_CAP,
+    MJB_MISSING_OPERAND, MJB_DUPLICATE_JOB, MJB_MISSING_DEP, MJB_STALE_GENERATION,
+    MJB_CYCLE, MJB_OVER_BUDGET, MJB_CODE_COUNT
+};
+static const char *const code_names[MJB_CODE_COUNT] = {
+    "OK", "MJB_BAD_LENGTH", "MJB_BAD_MAGIC", "MJB_DOWNGRADE", "MJB_BAD_VERSION",
+    "MJB_BAD_COUNT", "MJB_RESERVED_NONZERO", "MJB_BAD_ENUM", "MJB_NO_OBJECTIVE",
+    "MJB_NO_TENANT", "MJB_NO_SUBJECT", "MJB_NO_APPROVAL", "MJB_BAD_EXPIRY", "MJB_NO_JOB",
+    "MJB_CROSS_TENANT", "MJB_NO_CAPABILITY", "MJB_UNAUTHORIZED_EFFECT", "MJB_NO_VERIFIER",
+    "MJB_IMPURE", "MJB_TOKEN_PROFILE", "MJB_NEEDS_EXPANSION", "MJB_BAD_RETRY",
+    "MJB_ZERO_CAP", "MJB_MISSING_OPERAND", "MJB_DUPLICATE_JOB", "MJB_MISSING_DEP",
+    "MJB_STALE_GENERATION", "MJB_CYCLE", "MJB_OVER_BUDGET"
+};
+
+/* ---- SHA-256 ------------------------------------------------------------ */
+typedef struct { uint32_t h[8]; uint64_t n; uint8_t b[64]; uint32_t used; } sha256;
+
+static const uint32_t K256[64] = {
+    0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
+    0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
+    0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
+    0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
+    0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
+    0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
+    0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
+    0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
+};
+#define ROR(x, r) (((x) >> (r)) | ((x) << (32 - (r))))
+
+static void sha_block(sha256 *s, const uint8_t *p) {
+    uint32_t w[64], a, b, c, d, e, f, g, h;
+    for (int i = 0; i < 16; i++)
+        w[i] = (uint32_t)p[4*i] << 24 | (uint32_t)p[4*i+1] << 16 | (uint32_t)p[4*i+2] << 8 | p[4*i+3];
+    for (int i = 16; i < 64; i++) {
+        uint32_t s0 = ROR(w[i-15], 7) ^ ROR(w[i-15], 18) ^ (w[i-15] >> 3);
+        uint32_t s1 = ROR(w[i-2], 17) ^ ROR(w[i-2], 19) ^ (w[i-2] >> 10);
+        w[i] = w[i-16] + s0 + w[i-7] + s1;
+    }
+    a = s->h[0]; b = s->h[1]; c = s->h[2]; d = s->h[3];
+    e = s->h[4]; f = s->h[5]; g = s->h[6]; h = s->h[7];
+    for (int i = 0; i < 64; i++) {
+        uint32_t t1 = h + (ROR(e, 6) ^ ROR(e, 11) ^ ROR(e, 25)) + ((e & f) ^ (~e & g)) + K256[i] + w[i];
+        uint32_t t2 = (ROR(a, 2) ^ ROR(a, 13) ^ ROR(a, 22)) + ((a & b) ^ (a & c) ^ (b & c));
+        h = g; g = f; f = e; e = d + t1; d = c; c = b; b = a; a = t1 + t2;
+    }
+    s->h[0] += a; s->h[1] += b; s->h[2] += c; s->h[3] += d;
+    s->h[4] += e; s->h[5] += f; s->h[6] += g; s->h[7] += h;
+}
+static void sha_init(sha256 *s) {
+    static const uint32_t iv[8] = { 0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,
+                                    0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19 };
+    memcpy(s->h, iv, sizeof iv); s->n = 0; s->used = 0;
+}
+static void sha_update(sha256 *s, const void *data, size_t len) {
+    const uint8_t *p = data;
+    s->n += len;
+    while (len) {
+        uint32_t k = 64 - s->used;
+        if (k > len) k = (uint32_t)len;
+        memcpy(s->b + s->used, p, k);
+        s->used += k; p += k; len -= k;
+        if (s->used == 64) { sha_block(s, s->b); s->used = 0; }
+    }
+}
+static void sha_final(sha256 *s, uint8_t out[32]) {
+    uint64_t bits = s->n * 8;
+    uint8_t pad = 0x80, z = 0, l[8];
+    sha_update(s, &pad, 1);
+    while (s->used != 56) sha_update(s, &z, 1);
+    for (int i = 0; i < 8; i++) l[i] = (uint8_t)(bits >> (56 - 8 * i));
+    sha_update(s, l, 8);
+    for (int i = 0; i < 8; i++) {
+        out[4*i] = (uint8_t)(s->h[i] >> 24); out[4*i+1] = (uint8_t)(s->h[i] >> 16);
+        out[4*i+2] = (uint8_t)(s->h[i] >> 8); out[4*i+3] = (uint8_t)s->h[i];
+    }
+}
+static void sha_once(const void *p, size_t n, uint8_t out[32]) {
+    sha256 s; sha_init(&s); sha_update(&s, p, n); sha_final(&s, out);
+}
+
+/* ---- big-endian helpers -------------------------------------------------- */
+static uint16_t g16(const uint8_t *p) { return (uint16_t)(p[0] << 8 | p[1]); }
+static uint32_t g32(const uint8_t *p) { return (uint32_t)p[0] << 24 | (uint32_t)p[1] << 16 | (uint32_t)p[2] << 8 | p[3]; }
+static uint64_t g64(const uint8_t *p) { return (uint64_t)g32(p) << 32 | g32(p + 4); }
+static void p16(uint8_t *p, uint16_t v) { p[0] = (uint8_t)(v >> 8); p[1] = (uint8_t)v; }
+static void p32(uint8_t *p, uint32_t v) { p[0] = (uint8_t)(v >> 24); p[1] = (uint8_t)(v >> 16); p[2] = (uint8_t)(v >> 8); p[3] = (uint8_t)v; }
+static void p64(uint8_t *p, uint64_t v) { p32(p, (uint32_t)(v >> 32)); p32(p + 4, (uint32_t)v); }
+static int all_zero(const uint8_t *p, size_t n) { while (n--) if (*p++) return 0; return 1; }
+
+/* ---- the format (spec section 4) ------------------------------------------ */
+#define HDR     192u
+#define NODE    448u
+#define MAXN    64u
+#define MAXDEP  8u
+#define MAXOPS  4u
+#define DEPLEN  6u
+#define OPLEN   40u
+#define MAXDOC  (HDR + MAXN * NODE)
+
+#define H_VERSION 4
+#define H_CEILING 5
+#define H_COUNT 6
+#define H_OBJECTIVE 8
+#define H_TENANT 40
+#define H_SUBJECT 72
+#define H_APPROVAL 104
+#define H_INCARNATION 136
+#define H_RES0 140
+#define H_EXPIRES 144
+#define H_B_TIME 152
+#define H_B_FUEL 160
+#define H_B_MEMORY 168
+#define H_B_WORK 176
+#define H_B_IN 184
+#define H_B_OUT 188
+
+#define N_JOB 0
+#define N_IDEM 16
+#define N_GEN 32
+#define N_KIND 36
+#define N_OP 37
+#define N_PROFILE 38
+#define N_EFFECT 39
+#define N_IN 40
+#define N_OUT 42
+#define N_REQ_IN 44
+#define N_REQ_OUT 46
+#define N_VERIFIER 48
+#define N_RETRY 49
+#define N_ATTEMPTS 50
+#define N_CANCEL 51
+#define N_PRECISION 52
+#define N_SUBSTRATE 53
+#define N_DEPS_N 54
+#define N_OPS_N 55
+#define N_RTYPE 56
+#define N_RANK 57
+#define N_PURE 58
+#define N_RES1 59
+#define N_TIME 60
+#define N_FUEL 64
+#define N_MEMORY 72
+#define N_WORK 80
+#define N_EXPIRES 88
+#define N_DIMS 96
+#define N_CAP 112
+#define N_TENANT 144
+#define N_MODEL 176
+#define N_VREF 208
+#define N_DEPS 240
+#define N_OPERANDS 288
+
+static const uint16_t cap_in[5] = { 0, 64, 128, 256, 512 };
+static const uint16_t cap_out[5] = { 0, 16, 32, 64, 128 };
+
+/* Rules 10 to 23 for one node record. Loops are clamped to the slot counts so
+ * that every mutant stays memory-safe. */
+static int check_node(const uint8_t *n, const uint8_t *h) {
+    unsigned depn = n[N_DEPS_N], opn = n[N_OPS_N], rank = n[N_RANK];
+    unsigned dlim = depn < MAXDEP ? depn : MAXDEP, olim = opn < MAXOPS ? opn : MAXOPS;
+    unsigned k = n[N_KIND], op = n[N_OP], prof = n[N_PROFILE], vk = n[N_VERIFIER], s;
+    unsigned pidx = prof <= 4 ? prof : 0;
+    int pure = n[N_PURE] == 1, vz = all_zero(n + N_VREF, 32), mz = all_zero(n + N_MODEL, 32);
+    uint16_t tin = g16(n + N_IN), tout = g16(n + N_OUT), rin = g16(n + N_REQ_IN), rout = g16(n + N_REQ_OUT);
+    uint64_t exp = g64(n + N_EXPIRES);
+
+    if (CHECK(CHK_JOB) && all_zero(n + N_JOB, 16)) return MJB_NO_JOB;
+    if (CHECK(CHK_IDEM) && all_zero(n + N_IDEM, 16)) return MJB_NO_JOB;
+    if (CHECK(CHK_GEN) && g32(n + N_GEN) == 0) return MJB_NO_JOB;
+
+    if (CHECK(CHK_RES1) && n[N_RES1]) return MJB_RESERVED_NONZERO;
+    if (CHECK(CHK_DEP_SLOTS))
+        for (s = dlim; s < MAXDEP; s++) if (!all_zero(n + N_DEPS + DEPLEN * s, DEPLEN)) return MJB_RESERVED_NONZERO;
+    if (CHECK(CHK_OPERAND_SLOTS))
+        for (s = olim; s < MAXOPS; s++) if (!all_zero(n + N_OPERANDS + OPLEN * s, OPLEN)) return MJB_RESERVED_NONZERO;
+    if (CHECK(CHK_OPERAND_PAD))
+        for (s = 0; s < olim; s++) if (!all_zero(n + N_OPERANDS + OPLEN * s + 1, 3)) return MJB_RESERVED_NONZERO;
+    if (CHECK(CHK_DIMS))
+        for (s = rank < 4 ? rank : 4; s < 4; s++) if (g32(n + N_DIMS + 4 * s)) return MJB_RESERVED_NONZERO;
+
+    if (CHECK(CHK_E_KIND_OP) && !((k == 1 && op >= 1 && op <= 6) || (k == 2 && op >= 1 && op <= 4))) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_PROFILE) && prof > 4) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_EFFECT) && n[N_EFFECT] > 2) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_VERIFIER) && vk > 3) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_RETRY) && (n[N_RETRY] < 1 || n[N_RETRY] > 3)) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_ATTEMPTS) && (n[N_ATTEMPTS] < 1 || n[N_ATTEMPTS] > 8)) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_CANCEL) && (n[N_CANCEL] < 1 || n[N_CANCEL] > 2)) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_PRECISION) && n[N_PRECISION] > 6) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_SUBSTRATE) && (n[N_SUBSTRATE] == 0 || (n[N_SUBSTRATE] & 0xF8))) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_DEPN) && depn > MAXDEP) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_OPN) && opn > MAXOPS) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_RTYPE) && (n[N_RTYPE] < 1 || n[N_RTYPE] > 7)) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_RANK) && rank > 4) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_PURE) && n[N_PURE] > 1) return MJB_BAD_ENUM;
+    if (CHECK(CHK_E_OPKIND))
+        for (s = 0; s < olim; s++) {
+            uint8_t ok = n[N_OPERANDS + OPLEN * s];
+            if (ok < 1 || ok > 5) return MJB_BAD_ENUM;
+        }
+
+    if (CHECK(CHK_TENANT_MATCH) && memcmp(n + N_TENANT, h + H_TENANT, 32) != 0) return MJB_CROSS_TENANT;
+    if (CHECK(CHK_CAPABILITY) && all_zero(n + N_CAP, 32)) return MJB_NO_CAPABILITY;
+    if (CHECK(CHK_EFFECT_CEIL) && n[N_EFFECT] > h[H_CEILING]) return MJB_UNAUTHORIZED_EFFECT;
+
+    if (CHECK(CHK_VERIFIER_ZERO) && vk == 0) return MJB_NO_VERIFIER;
+    if (CHECK(CHK_VERIFIER_REF) && vk != 1 && vz) return MJB_NO_VERIFIER;
+    if (CHECK(CHK_RECOMPUTE_REF) && vk == 1 && !vz) return MJB_NO_VERIFIER;
+    if (CHECK(CHK_RECOMPUTE_PURE) && vk == 1 && !pure) return MJB_NO_VERIFIER;
+
+    if (CHECK(CHK_IMPURE_NEURAL) && pure && k == 2) return MJB_IMPURE;
+    if (CHECK(CHK_IMPURE_EFFECT) && pure && n[N_EFFECT] == 2) return MJB_IMPURE;
+
+    if (k == 1) {
+        if (CHECK(CHK_COMPUTE_TOKENS) && (prof != 0 || tin || tout || rin || rout || !mz)) return MJB_TOKEN_PROFILE;
+    } else {
+        if (CHECK(CHK_NEURAL_TOKENS) && (prof == 0 || tin == 0 || tout == 0 || tin > cap_in[pidx] || tout > cap_out[pidx] || mz))
+            return MJB_TOKEN_PROFILE;
+    }
+    if (CHECK(CHK_EXPANSION) && (rin > tin || rout > tout)) return MJB_NEEDS_EXPANSION;
+
+    if (CHECK(CHK_RETRY_NEVER) && n[N_RETRY] == 1 && n[N_ATTEMPTS] > 1) return MJB_BAD_RETRY;
+    if (CHECK(CHK_RETRY_EFFECT) && n[N_EFFECT] == 2 && n[N_RETRY] == 2) return MJB_BAD_RETRY;
+
+    if (CHECK(CHK_ZERO_CAP) && (g32(n + N_TIME) == 0 || g64(n + N_FUEL) == 0 || g64(n + N_MEMORY) == 0 || g64(n + N_WORK) == 0))
+        return MJB_ZERO_CAP;
+    if (CHECK(CHK_NODE_EXPIRY) && (exp == 0 || exp > g64(h + H_EXPIRES))) return MJB_BAD_EXPIRY;
+    if (CHECK(CHK_OPERAND_MISSING))
+        for (s = 0; s < olim; s++) {
+            const uint8_t *o = n + N_OPERANDS + OPLEN * s;
+            if (g32(o + 4) == 0 || all_zero(o + 8, 32)) return MJB_MISSING_OPERAND;
+        }
+    return MJB_OK;
+}
+
+/* Exact sum: *over is set when the total does not fit in 64 bits. */
+static uint64_t add_exact(uint64_t a, uint64_t b, int *over) {
+    if (a > UINT64_MAX - b) *over = 1;
+    return a + b;
+}
+
+/* Kahn's algorithm, lowest index first. Returns the number of nodes emitted. */
+static unsigned kahn(const uint8_t *b, unsigned count, unsigned *order) {
+    unsigned indeg[MAXN], emitted[MAXN] = { 0 }, done = 0, i, s;
+    for (i = 0; i < count; i++) {
+        unsigned d = b[HDR + NODE * i + N_DEPS_N];
+        indeg[i] = d < MAXDEP ? d : MAXDEP;
+    }
+    while (done < count) {
+        unsigned next = count;
+        for (i = 0; i < count; i++) if (!emitted[i] && indeg[i] == 0) { next = i; break; }
+        if (next == count) break;
+        emitted[next] = 1;
+        order[done++] = next;
+        for (i = 0; i < count; i++) {
+            const uint8_t *n = b + HDR + NODE * i;
+            unsigned d = n[N_DEPS_N] < MAXDEP ? n[N_DEPS_N] : MAXDEP;
+            for (s = 0; s < d; s++) if (g16(n + N_DEPS + DEPLEN * s) == next) indeg[i]--;
+        }
+    }
+    return done;
+}
+
+static int mjb_check(const uint8_t *b, size_t len, unsigned *order, unsigned *count_out) {
+    unsigned count, i, j, s;
+    int rc, over = 0;
+    uint64_t t = 0, fu = 0, wk = 0, ti = 0, to = 0;
+    *count_out = 0;
+    if (CHECK(CHK_MIN_LEN) && len < HDR) return MJB_BAD_LENGTH;
+    if (CHECK(CHK_MAGIC) && memcmp(b, "MJB1", 4) != 0) return MJB_BAD_MAGIC;
+    if (CHECK(CHK_DOWNGRADE) && b[H_VERSION] == 0) return MJB_DOWNGRADE;
+    if (CHECK(CHK_VERSION) && b[H_VERSION] > 1) return MJB_BAD_VERSION;
+    count = g16(b + H_COUNT);
+    if (CHECK(CHK_COUNT) && (count == 0 || count > MAXN)) return MJB_BAD_COUNT;
+    if (CHECK(CHK_EXACT_LEN) && len != HDR + (size_t)count * NODE) return MJB_BAD_LENGTH;
+    if (count > MAXN) return MJB_BAD_COUNT; /* array bound for mutants, not a rule of its own */
+    if (CHECK(CHK_RES0) && !all_zero(b + H_RES0, 4)) return MJB_RESERVED_NONZERO;
+    if (CHECK(CHK_CEILING) && b[H_CEILING] > 2) return MJB_BAD_ENUM;
+    if (CHECK(CHK_OBJECTIVE) && all_zero(b + H_OBJECTIVE, 32)) return MJB_NO_OBJECTIVE;
+    if (CHECK(CHK_TENANT) && all_zero(b + H_TENANT, 32)) return MJB_NO_TENANT;
+    if (CHECK(CHK_SUBJECT) && all_zero(b + H_SUBJECT, 32)) return MJB_NO_SUBJECT;
+    if (CHECK(CHK_APPROVAL) && all_zero(b + H_APPROVAL, 32)) return MJB_NO_APPROVAL;
+    if (CHECK(CHK_INCARNATION) && g32(b + H_INCARNATION) == 0) return MJB_NO_OBJECTIVE;
+    /* A header expires_at of 0 needs no rule of its own: every node then fails
+     * rule 22 (node expiry above the header), with the same code. */
+
+    for (i = 0; i < count; i++)
+        if ((rc = check_node(b + HDR + NODE * i, b)) != MJB_OK) return rc;
+
+    if (CHECK(CHK_DUP))
+        for (i = 0; i < count; i++)
+            for (j = i + 1; j < count; j++) {
+                const uint8_t *x = b + HDR + NODE * i, *y = b + HDR + NODE * j;
+                if (!memcmp(x + N_JOB, y + N_JOB, 16) || !memcmp(x + N_IDEM, y + N_IDEM, 16)) return MJB_DUPLICATE_JOB;
+            }
+    if (CHECK(CHK_DEP_RANGE))
+        for (i = 0; i < count; i++) {
+            const uint8_t *n = b + HDR + NODE * i;
+            unsigned d = n[N_DEPS_N] < MAXDEP ? n[N_DEPS_N] : MAXDEP;
+            for (s = 0; s < d; s++) {
+                unsigned idx = g16(n + N_DEPS + DEPLEN * s);
+                if (idx == i || idx >= count) return MJB_MISSING_DEP;
+            }
+        }
+    if (CHECK(CHK_STALE))
+        for (i = 0; i < count; i++) {
+            const uint8_t *n = b + HDR + NODE * i;
+            unsigned d = n[N_DEPS_N] < MAXDEP ? n[N_DEPS_N] : MAXDEP;
+            for (s = 0; s < d; s++) {
+                unsigned idx = g16(n + N_DEPS + DEPLEN * s);
+                if (idx < count && g32(n + N_DEPS + DEPLEN * s + 2) != g32(b + HDR + NODE * idx + N_GEN))
+                    return MJB_STALE_GENERATION;
+            }
+        }
+    if (CHECK(CHK_CYCLE) && kahn(b, count, order) != count) return MJB_CYCLE;
+    if (CHECK(CHK_BUDGET)) {
+        for (i = 0; i < count; i++) {
+            const uint8_t *n = b + HDR + NODE * i;
+            t = add_exact(t, g32(n + N_TIME), &over);
+            fu = add_exact(fu, g64(n + N_FUEL), &over);
+            wk = add_exact(wk, g64(n + N_WORK), &over);
+            ti += g16(n + N_IN);
+            to += g16(n + N_OUT);
+            if (g64(n + N_MEMORY) > g64(b + H_B_MEMORY)) over = 1;
+        }
+        if (over || t > g64(b + H_B_TIME) || fu > g64(b + H_B_FUEL) || wk > g64(b + H_B_WORK)
+            || ti > g32(b + H_B_IN) || to > g32(b + H_B_OUT))
+            return MJB_OVER_BUDGET;
+    }
+    kahn(b, count, order);
+    *count_out = count;
+    return MJB_OK;
+}
+
+static void hex(char *out, const uint8_t *p, size_t n) {
+    static const char H[] = "0123456789abcdef";
+    for (size_t i = 0; i < n; i++) { out[2*i] = H[p[i] >> 4]; out[2*i+1] = H[p[i] & 15]; }
+    out[2*n] = 0;
+}
+
+static void ok_line(const uint8_t *b, size_t len, const char *order, char *line, size_t cap) {
+    char obj[65], ten[65], dig[65];
+    uint8_t d[32];
+    sha_once(b, len, d);
+    hex(obj, b + H_OBJECTIVE, 32);
+    hex(ten, b + H_TENANT, 32);
+    hex(dig, d, 32);
+    snprintf(line, cap, "ok nodes=%u incarnation=%lu ceiling=%u objective=%s tenant=%s digest=%s order=%s",
+             (unsigned)g16(b + H_COUNT), (unsigned long)g32(b + H_INCARNATION), (unsigned)b[H_CEILING], obj, ten, dig, order);
+}
+
+static void order_text(const unsigned *order, unsigned count, char *out, size_t cap) {
+    size_t at = 0;
+    out[0] = 0;
+    for (unsigned i = 0; i < count && at + 8 < cap; i++)
+        at += (size_t)snprintf(out + at, cap - at, i ? ",%u" : "%u", order[i]);
+}
+
+static void verdict_line(const uint8_t *b, size_t len, char *line, size_t cap) {
+    unsigned order[MAXN], count;
+    char ord[512];
+    int code = mjb_check(b, len, order, &count);
+    if (code != MJB_OK) { snprintf(line, cap, "refuse %s", code_names[code]); return; }
+    order_text(order, count, ord, sizeof ord);
+    ok_line(b, len, ord, line, cap);
+}
+
+/* ---- file I/O (outside the checker) ---------------------------------------- */
+#define FILE_CAP 65536u
+static uint8_t file_buf[FILE_CAP];
+
+/* Reads the whole file into file_buf (zeroed first). Returns 0, or -1 on I/O
+ * error or a file larger than FILE_CAP (no vector is that large). */
+static int slurp(const char *path, size_t *n) {
+    FILE *f = fopen(path, "rb");
+    size_t k;
+    memset(file_buf, 0, sizeof file_buf);
+    if (!f) return -1;
+    k = fread(file_buf, 1, FILE_CAP, f);
+    if (k == FILE_CAP && fgetc(f) != EOF) { fclose(f); return -1; }
+    fclose(f);
+    *n = k;
+    return 0;
+}
+
+static void rstrip(char *s) { size_t n = strlen(s); while (n && (s[n-1] == '\n' || s[n-1] == '\r')) s[--n] = 0; }
+static int plain_name(const char *s) { return s[0] && s[0] != '.' && !strchr(s, '/'); }
+
+static FILE *create_file(const char *path, const char *mode) {
+    int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+    FILE *f;
+    if (fd < 0) return NULL;
+    if (!(f = fdopen(fd, mode))) close(fd);
+    return f;
+}
+
+/* The corpus walk opens only names that readdir reports in DIR; expected.txt
+ * names are lookup keys, never paths. An expected name with no file in DIR is
+ * a failure ("missing"), as is a duplicate expected name. */
+#define CORPUS_CAP 512u
+struct expect { char name[256]; char want[1024]; int seen; };
+static struct expect expects[CORPUS_CAP];
+
+static int corpus(const char *dir) {
+    char path[4096], line[1024], got[1024];
+    unsigned pass = 0, fail = 0, count = 0, i;
+    size_t n;
+    FILE *f;
+    DIR *d;
+    struct dirent *e;
+    snprintf(path, sizeof path, "%s/expected.txt", dir);
+    if (!(f = fopen(path, "r"))) { fprintf(stderr, "cannot read %s\n", path); return 2; }
+    while (fgets(line, sizeof line, f)) {
+        char *sp;
+        rstrip(line);
+        if (!line[0] || line[0] == '#') continue;
+        if (!(sp = strchr(line, ' '))) { fprintf(stderr, "bad line: %s\n", line); fail++; continue; }
+        *sp = 0;
+        if (!plain_name(line) || strlen(line) >= sizeof expects[0].name) { fprintf(stderr, "not a plain file name: %s\n", line); fail++; continue; }
+        for (i = 0; i < count && strcmp(expects[i].name, line) != 0; i++) ;
+        if (i < count) { fprintf(stderr, "duplicate name: %s\n", line); fail++; continue; }
+        if (count == CORPUS_CAP) { fprintf(stderr, "too many lines: %s\n", line); fail++; continue; }
+        snprintf(expects[count].name, sizeof expects[count].name, "%s", line);
+        snprintf(expects[count].want, sizeof expects[count].want, "%s", sp + 1);
+        expects[count].seen = 0;
+        count++;
+    }
+    fclose(f);
+    if (!(d = opendir(dir))) { fprintf(stderr, "cannot read %s\n", dir); return 2; }
+    while ((e = readdir(d))) {
+        for (i = 0; i < count && strcmp(expects[i].name, e->d_name) != 0; i++) ;
+        if (i == count) continue;
+        expects[i].seen = 1;
+        snprintf(path, sizeof path, "%s/%s", dir, e->d_name);
+        if (slurp(path, &n)) { fprintf(stderr, "cannot read %s\n", path); fail++; continue; }
+        verdict_line(file_buf, n, got, sizeof got);
+        if (strcmp(got, expects[i].want) != 0) { fail++; printf("MISMATCH %s\n  expected: %s\n  got:      %s\n", e->d_name, expects[i].want, got); }
+        else pass++;
+    }
+    closedir(d);
+    for (i = 0; i < count; i++)
+        if (!expects[i].seen) { fprintf(stderr, "missing: %s\n", expects[i].name); fail++; }
+    printf("MJB1_CONFORMANCE impl=c pass=%u fail=%u\n", pass, fail);
+    return fail || !pass ? 1 : 0;
+}
+
+/* ---- vector generator -------------------------------------------------------- */
+/* Every refused vector starts from one well-formed document and changes one
+ * thing. The expected line of an accepted vector takes its order from the
+ * generator's intent, not from mjb_check, so the checker is tested against it. */
+static uint8_t doc[MAXDOC + 64];
+static unsigned doc_n;
+static FILE *gen_expected;
+static int gen_fail;
+static const char *gen_dir;
+
+static void fill(uint8_t *p, size_t n, uint8_t seed) { for (size_t i = 0; i < n; i++) p[i] = (uint8_t)(seed + 7 * i); }
+static uint8_t *nd(unsigned i) { return doc + HDR + NODE * i; }
+static size_t doc_len(void) { return HDR + (size_t)doc_n * NODE; }
+
+static void header(unsigned count, uint8_t ceiling) {
+    memset(doc, 0, sizeof doc);
+    doc_n = count;
+    memcpy(doc, "MJB1", 4);
+    doc[H_VERSION] = 1;
+    doc[H_CEILING] = ceiling;
+    p16(doc + H_COUNT, (uint16_t)count);
+    fill(doc + H_OBJECTIVE, 32, 0x0B);
+    fill(doc + H_TENANT, 32, 0x7E);
+    fill(doc + H_SUBJECT, 32, 0x5B);
+    fill(doc + H_APPROVAL, 32, 0xA9);
+    p32(doc + H_INCARNATION, 1);
+    p64(doc + H_EXPIRES, 2000000000u);
+    p64(doc + H_B_TIME, 10000);
+    p64(doc + H_B_FUEL, 1000000);
+    p64(doc + H_B_MEMORY, (uint64_t)1 << 30);
+    p64(doc + H_B_WORK, 1000000);
+    p32(doc + H_B_IN, 4096);
+    p32(doc + H_B_OUT, 1024);
+}
+
+static void common(unsigned i) {
+    uint8_t *n = nd(i);
+    fill(n + N_JOB, 14, 0x4A); p16(n + N_JOB + 14, (uint16_t)(i + 1));
+    fill(n + N_IDEM, 14, 0x1D); p16(n + N_IDEM + 14, (uint16_t)(i + 1));
+    p32(n + N_GEN, 1);
+    n[N_CANCEL] = 1;
+    p32(n + N_TIME, 100);
+    p64(n + N_FUEL, 1000);
+    p64(n + N_MEMORY, (uint64_t)1 << 20);
+    p64(n + N_WORK, 1000);
+    p64(n + N_EXPIRES, 1999999999u);
+    fill(n + N_CAP, 32, 0xCA);
+    memcpy(n + N_TENANT, doc + H_TENANT, 32);
+}
+
+static void compute(unsigned i, uint8_t op) {
+    uint8_t *n = nd(i);
+    common(i);
+    n[N_KIND] = 1; n[N_OP] = op; n[N_PROFILE] = 0; n[N_EFFECT] = 1;
+    n[N_VERIFIER] = 1; n[N_RETRY] = 2; n[N_ATTEMPTS] = 3;
+    n[N_PRECISION] = 0; n[N_SUBSTRATE] = 1; n[N_RTYPE] = 2; n[N_PURE] = 1;
+}
+
+static void neural(unsigned i, uint8_t op, uint8_t prof, uint16_t tin, uint16_t tout, uint16_t rin, uint16_t rout) {
+    uint8_t *n = nd(i);
+    common(i);
+    n[N_KIND] = 2; n[N_OP] = op; n[N_PROFILE] = prof; n[N_EFFECT] = 0;
+    p16(n + N_IN, tin); p16(n + N_OUT, tout); p16(n + N_REQ_IN, rin); p16(n + N_REQ_OUT, rout);
+    n[N_VERIFIER] = 2; fill(n + N_VREF, 32, 0x5E);
+    n[N_RETRY] = 2; n[N_ATTEMPTS] = 2;
+    n[N_PRECISION] = 2; n[N_SUBSTRATE] = 3; n[N_RTYPE] = 6; n[N_PURE] = 0;
+    fill(n + N_MODEL, 32, 0x3D);
+}
+
+static void dep(unsigned i, unsigned on) {
+    uint8_t *n = nd(i);
+    unsigned s = n[N_DEPS_N]++;
+    p16(n + N_DEPS + DEPLEN * s, (uint16_t)on);
+    p32(n + N_DEPS + DEPLEN * s + 2, g32(nd(on) + N_GEN));
+}
+
+static void operand(unsigned i, uint8_t kind, uint8_t seed) {
+    uint8_t *n = nd(i);
+    unsigned s = n[N_OPS_N]++;
+    uint8_t *o = n + N_OPERANDS + OPLEN * s;
+    o[0] = kind;
+    p32(o + 4, 1);
+    fill(o + 8, 32, seed);
+}
+
+/* compute(ARITH, 1 CONTENT operand) -> compute(REDUCE) -> neural ROUTE 64/16 */
+static void base3(void) {
+    header(3, 1);
+    compute(0, 1); operand(0, 3, 0x21);
+    compute(1, 3); dep(1, 0);
+    neural(2, 1, 1, 64, 16, 40, 8); dep(2, 1); operand(2, 1, 0x31);
+}
+
+static void emit(const char *name, size_t n, const char *expect) {
+    char path[4096];
+    FILE *f;
+    snprintf(path, sizeof path, "%s/%s", gen_dir, name);
+    if (!(f = create_file(path, "wb")) || fwrite(doc, 1, n, f) != n || fclose(f) != 0) {
+        fprintf(stderr, "cannot write %s\n", path);
+        gen_fail = 1;
+        return;
+    }
+    fprintf(gen_expected, "%s %s\n", name, expect);
+}
+
+static void ok(const char *name, const char *order) {
+    char line[1024];
+    ok_line(doc, doc_len(), order, line, sizeof line);
+    emit(name, doc_len(), line);
+}
+
+static void bad_len(const char *name, size_t n, const char *code) {
+    char line[128];
+    snprintf(line, sizeof line, "refuse %s", code);
+    emit(name, n, line);
+}
+static void bad(const char *name, const char *code) { bad_len(name, doc_len(), code); }
+
+static int make_vectors(const char *dir) {
+    char path[4096];
+    unsigned i;
+    gen_dir = dir;
+    snprintf(path, sizeof path, "%s/expected.txt", dir);
+    if (!(gen_expected = create_file(path, "w"))) { fprintf(stderr, "cannot write %s\n", path); return 2; }
+    fprintf(gen_expected,
+        "# MJB1 document vectors. Spec: ../SPEC.md (Draft v0.1, wire version 1).\n"
+        "# Line: <file> <verdict line>, verdict line as printed by tools/mjb_verify.c:\n"
+        "#   ok nodes=N incarnation=I ceiling=C objective=H64 tenant=H64 digest=H64 order=i,j,...\n"
+        "#   refuse <code from SPEC.md section 6>\n"
+        "# Generated by tools/mjb_verify.c --make-vectors; do not edit by hand.\n");
+
+    /* ---- accepted ---- */
+    base3();
+    ok("ok-base3.mjb", "0,1,2");
+
+    /* 11 nodes: two independent sums, reduce, mean, compare, two neural
+     * routes, an independent numeric check, a summary, a compile step and
+     * one EFFECT node under an EFFECT ceiling. */
+    header(11, 2);
+    compute(0, 1); operand(0, 3, 0x41);
+    compute(1, 1); operand(1, 3, 0x42);
+    compute(2, 3); dep(2, 0); dep(2, 1);
+    compute(3, 1); dep(3, 2);
+    compute(4, 4); dep(4, 3); operand(4, 3, 0x43);
+    neural(5, 1, 1, 64, 16, 48, 4); operand(5, 3, 0x44);
+    neural(6, 1, 2, 128, 32, 100, 4); operand(6, 1, 0x45);
+    compute(7, 6); dep(7, 3); nd(7)[N_VERIFIER] = 2; fill(nd(7) + N_VREF, 32, 0x77);
+    neural(8, 4, 3, 256, 64, 200, 60); dep(8, 4); dep(8, 5); dep(8, 6); operand(8, 5, 0x46);
+    compute(9, 5); dep(9, 8); operand(9, 4, 0x47);
+    compute(10, 1); dep(10, 4); dep(10, 7); operand(10, 2, 0x48);
+    nd(10)[N_EFFECT] = 2; nd(10)[N_PURE] = 0; nd(10)[N_VERIFIER] = 3; fill(nd(10) + N_VREF, 32, 0x99);
+    nd(10)[N_RETRY] = 3; nd(10)[N_ATTEMPTS] = 2; nd(10)[N_CANCEL] = 2;
+    ok("ok-sample-11.mjb", "0,1,2,3,4,5,6,7,8,9,10");
+
+    header(64, 1);
+    for (i = 0; i < 64; i++) { compute(i, 1); if (i) dep(i, i - 1); else operand(0, 3, 0x51); }
+    {
+        char ord[512];
+        unsigned o[64];
+        for (i = 0; i < 64; i++) o[i] = i;
+        order_text(o, 64, ord, sizeof ord);
+        ok("ok-chain-64.mjb", ord);
+    }
+
+    header(4, 1);
+    compute(2, 1); operand(2, 3, 0x61);
+    compute(3, 1); dep(3, 2);
+    compute(0, 1); dep(0, 3);
+    compute(1, 1); dep(1, 3);
+    ok("ok-reverse-order.mjb", "2,3,0,1");
+
+    header(9, 1);
+    for (i = 0; i < 8; i++) { compute(i, 1); operand(i, 3, (uint8_t)(0x70 + i)); }
+    compute(8, 2);
+    for (i = 0; i < 8; i++) dep(8, i);
+    operand(8, 1, 0x81); operand(8, 2, 0x82); operand(8, 4, 0x83); operand(8, 5, 0x84);
+    nd(8)[N_RTYPE] = 4; nd(8)[N_RANK] = 4; nd(8)[N_PRECISION] = 1;
+    p32(nd(8) + N_DIMS, 2); p32(nd(8) + N_DIMS + 4, 3); p32(nd(8) + N_DIMS + 8, 4); p32(nd(8) + N_DIMS + 12, 5);
+    ok("ok-fanin-8-tensor.mjb", "0,1,2,3,4,5,6,7,8");
+
+    header(1, 0);
+    neural(0, 2, 1, 64, 16, 64, 16); operand(0, 3, 0x91);
+    ok("ok-minimal-exact-64-16.mjb", "0");
+
+    header(1, 0);
+    neural(0, 3, 4, 512, 128, 300, 100); operand(0, 3, 0x92);
+    ok("ok-specialist-512-128.mjb", "0");
+
+    header(1, 0);
+    neural(0, 1, 2, 40, 10, 40, 10); operand(0, 3, 0x93);
+    ok("ok-optimizer-smaller-caps.mjb", "0");
+
+    /* ---- refused: header, in check order ---- */
+    base3(); bad_len("bad-length-short.mjb", 100, "MJB_BAD_LENGTH");
+    base3(); bad_len("bad-length-empty.mjb", 0, "MJB_BAD_LENGTH");
+    base3(); doc[3] = '2'; bad("bad-magic.mjb", "MJB_BAD_MAGIC");
+    base3(); doc[H_VERSION] = 0; bad("bad-version-downgrade.mjb", "MJB_DOWNGRADE");
+    base3(); doc[H_VERSION] = 2; bad("bad-version-unknown.mjb", "MJB_BAD_VERSION");
+    base3(); p16(doc + H_COUNT, 0); bad_len("bad-count-zero.mjb", HDR, "MJB_BAD_COUNT");
+    base3(); p16(doc + H_COUNT, 65); bad_len("bad-count-65.mjb", HDR, "MJB_BAD_COUNT");
+    base3(); bad_len("bad-length-mismatch.mjb", doc_len() - 1, "MJB_BAD_LENGTH");
+    base3(); bad_len("bad-length-trailing.mjb", doc_len() + 1, "MJB_BAD_LENGTH");
+    base3(); doc[H_RES0 + 1] = 1; bad("bad-reserved0.mjb", "MJB_RESERVED_NONZERO");
+    base3(); doc[H_CEILING] = 3; bad("bad-ceiling-enum.mjb", "MJB_BAD_ENUM");
+    base3(); memset(doc + H_OBJECTIVE, 0, 32); bad("bad-no-objective.mjb", "MJB_NO_OBJECTIVE");
+    base3(); memset(doc + H_TENANT, 0, 32); bad("bad-no-tenant.mjb", "MJB_NO_TENANT");
+    base3(); memset(doc + H_SUBJECT, 0, 32); bad("bad-no-subject.mjb", "MJB_NO_SUBJECT");
+    base3(); memset(doc + H_APPROVAL, 0, 32); bad("bad-no-approval.mjb", "MJB_NO_APPROVAL");
+    base3(); p32(doc + H_INCARNATION, 0); bad("bad-no-incarnation.mjb", "MJB_NO_OBJECTIVE");
+    base3(); p64(doc + H_EXPIRES, 0); bad("bad-header-expiry-zero.mjb", "MJB_BAD_EXPIRY");
+
+    /* ---- refused: one node rule each ---- */
+    base3(); memset(nd(1) + N_JOB, 0, 16); bad("bad-no-job-id.mjb", "MJB_NO_JOB");
+    base3(); memset(nd(1) + N_IDEM, 0, 16); bad("bad-no-idempotence-key.mjb", "MJB_NO_JOB");
+    base3(); p32(nd(0) + N_GEN, 0); bad("bad-no-generation.mjb", "MJB_NO_JOB");
+    base3(); nd(1)[N_RES1] = 1; bad("bad-reserved1.mjb", "MJB_RESERVED_NONZERO");
+    base3(); nd(0)[N_DEPS + 1] = 1; bad("bad-reserved-unused-dep.mjb", "MJB_RESERVED_NONZERO");
+    base3(); nd(1)[N_DEPS + DEPLEN + 5] = 1; bad("bad-reserved-unused-dep-generation.mjb", "MJB_RESERVED_NONZERO");
+    base3(); nd(1)[N_OPERANDS + 20] = 1; bad("bad-reserved-unused-operand.mjb", "MJB_RESERVED_NONZERO");
+    base3(); nd(0)[N_OPERANDS + 2] = 1; bad("bad-reserved-operand-pad.mjb", "MJB_RESERVED_NONZERO");
+    base3(); p32(nd(0) + N_DIMS, 1); bad("bad-reserved-dims.mjb", "MJB_RESERVED_NONZERO");
+    base3(); nd(0)[N_KIND] = 3; bad("bad-enum-kind.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_OP] = 7; bad("bad-enum-op-compute.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_OP] = 0; bad("bad-enum-op-zero.mjb", "MJB_BAD_ENUM");
+    base3(); nd(2)[N_OP] = 5; bad("bad-enum-op-neural.mjb", "MJB_BAD_ENUM");
+    base3(); nd(2)[N_PROFILE] = 5; bad("bad-enum-profile.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_EFFECT] = 3; bad("bad-enum-effect.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_VERIFIER] = 4; bad("bad-enum-verifier.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_RETRY] = 0; bad("bad-enum-retry-zero.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_RETRY] = 4; bad("bad-enum-retry-four.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_ATTEMPTS] = 0; bad("bad-enum-attempts-zero.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_ATTEMPTS] = 9; bad("bad-enum-attempts-nine.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_CANCEL] = 0; bad("bad-enum-cancel-zero.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_CANCEL] = 3; bad("bad-enum-cancel-three.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_PRECISION] = 7; bad("bad-enum-precision.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_SUBSTRATE] = 0; bad("bad-enum-substrate-zero.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_SUBSTRATE] = 0x09; bad("bad-enum-substrate-high.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_DEPS_N] = 9; bad("bad-enum-dep-count.mjb", "MJB_BAD_ENUM");
+    base3(); operand(0, 3, 0x22); operand(0, 3, 0x23); operand(0, 3, 0x24); nd(0)[N_OPS_N] = 5;
+    bad("bad-enum-operand-count.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_RTYPE] = 0; bad("bad-enum-result-type-zero.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_RTYPE] = 8; bad("bad-enum-result-type-eight.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_RANK] = 5; bad("bad-enum-rank.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_PURE] = 2; bad("bad-enum-pure.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_OPERANDS] = 6; bad("bad-enum-operand-kind-six.mjb", "MJB_BAD_ENUM");
+    base3(); nd(0)[N_OPERANDS] = 0; bad("bad-enum-operand-kind-zero.mjb", "MJB_BAD_ENUM");
+    base3(); nd(1)[N_TENANT + 31] ^= 1; bad("bad-cross-tenant.mjb", "MJB_CROSS_TENANT");
+    base3(); memset(nd(1) + N_CAP, 0, 32); bad("bad-no-capability.mjb", "MJB_NO_CAPABILITY");
+    base3(); nd(0)[N_EFFECT] = 2; bad("bad-unauthorized-effect.mjb", "MJB_UNAUTHORIZED_EFFECT");
+    base3(); doc[H_CEILING] = 0; bad("bad-unauthorized-compute-under-none.mjb", "MJB_UNAUTHORIZED_EFFECT");
+    base3(); nd(2)[N_VERIFIER] = 0; bad("bad-no-verifier-kind-zero.mjb", "MJB_NO_VERIFIER");
+    base3(); nd(0)[N_VERIFIER] = 0; bad("bad-no-verifier-kind-zero-no-ref.mjb", "MJB_NO_VERIFIER");
+    base3(); memset(nd(2) + N_VREF, 0, 32); bad("bad-no-verifier-checker-no-ref.mjb", "MJB_NO_VERIFIER");
+    base3(); fill(nd(0) + N_VREF, 32, 0x55); bad("bad-no-verifier-recompute-with-ref.mjb", "MJB_NO_VERIFIER");
+    base3(); nd(0)[N_PURE] = 0; bad("bad-no-verifier-recompute-impure.mjb", "MJB_NO_VERIFIER");
+    base3(); nd(2)[N_PURE] = 1; bad("bad-impure-neural.mjb", "MJB_IMPURE");
+    base3(); doc[H_CEILING] = 2; nd(0)[N_EFFECT] = 2; bad("bad-impure-effect.mjb", "MJB_IMPURE");
+    base3(); p16(nd(0) + N_IN, 10); bad("bad-token-compute-with-tokens.mjb", "MJB_TOKEN_PROFILE");
+    base3(); nd(0)[N_PROFILE] = 1; bad("bad-token-compute-with-profile.mjb", "MJB_TOKEN_PROFILE");
+    base3(); fill(nd(0) + N_MODEL, 32, 0x3D); bad("bad-token-compute-with-model.mjb", "MJB_TOKEN_PROFILE");
+    base3(); p16(nd(0) + N_REQ_IN, 5); bad("bad-token-compute-required.mjb", "MJB_TOKEN_PROFILE");
+    base3(); nd(2)[N_PROFILE] = 0; bad("bad-token-neural-zero-profile.mjb", "MJB_TOKEN_PROFILE");
+    base3(); p16(nd(2) + N_IN, 65); bad("bad-token-neural-over-profile-input.mjb", "MJB_TOKEN_PROFILE");
+    base3(); p16(nd(2) + N_OUT, 17); bad("bad-token-neural-over-profile-output.mjb", "MJB_TOKEN_PROFILE");
+    base3(); p16(nd(2) + N_OUT, 0); p16(nd(2) + N_REQ_OUT, 0); bad("bad-token-neural-zero-cap.mjb", "MJB_TOKEN_PROFILE");
+    base3(); memset(nd(2) + N_MODEL, 0, 32); bad("bad-token-neural-no-model.mjb", "MJB_TOKEN_PROFILE");
+    base3(); p16(nd(2) + N_REQ_IN, 90); bad("bad-needs-expansion-64-16-input.mjb", "MJB_NEEDS_EXPANSION");
+    base3(); p16(nd(2) + N_REQ_OUT, 20); bad("bad-needs-expansion-64-16-output.mjb", "MJB_NEEDS_EXPANSION");
+    base3(); nd(0)[N_RETRY] = 1; nd(0)[N_ATTEMPTS] = 2; bad("bad-retry-never-multi.mjb", "MJB_BAD_RETRY");
+    base3(); doc[H_CEILING] = 2; nd(2)[N_EFFECT] = 2; bad("bad-retry-effect-idempotent.mjb", "MJB_BAD_RETRY");
+    base3(); p32(nd(1) + N_TIME, 0); bad("bad-zero-cap-time.mjb", "MJB_ZERO_CAP");
+    base3(); p64(nd(1) + N_FUEL, 0); bad("bad-zero-cap-fuel.mjb", "MJB_ZERO_CAP");
+    base3(); p64(nd(1) + N_MEMORY, 0); bad("bad-zero-cap-memory.mjb", "MJB_ZERO_CAP");
+    base3(); p64(nd(1) + N_WORK, 0); bad("bad-zero-cap-work.mjb", "MJB_ZERO_CAP");
+    base3(); p64(nd(1) + N_EXPIRES, 0); bad("bad-node-expiry-zero.mjb", "MJB_BAD_EXPIRY");
+    base3(); p64(nd(1) + N_EXPIRES, 2000000001u); bad("bad-node-expiry-after-header.mjb", "MJB_BAD_EXPIRY");
+    base3(); memset(nd(0) + N_OPERANDS + 8, 0, 32); bad("bad-missing-operand-digest.mjb", "MJB_MISSING_OPERAND");
+    base3(); p32(nd(0) + N_OPERANDS + 4, 0); bad("bad-missing-operand-generation.mjb", "MJB_MISSING_OPERAND");
+
+    /* ---- refused: whole graph ---- */
+    base3(); memcpy(nd(2) + N_JOB, nd(1) + N_JOB, 16); bad("bad-duplicate-job.mjb", "MJB_DUPLICATE_JOB");
+    base3(); memcpy(nd(2) + N_IDEM, nd(1) + N_IDEM, 16); bad("bad-duplicate-idempotence-key.mjb", "MJB_DUPLICATE_JOB");
+    base3(); p16(nd(1) + N_DEPS, 1); bad("bad-missing-dep-self.mjb", "MJB_MISSING_DEP");
+    base3(); p16(nd(1) + N_DEPS, 3); bad("bad-missing-dep-out-of-range.mjb", "MJB_MISSING_DEP");
+    base3(); p32(nd(0) + N_GEN, 2); bad("bad-stale-generation.mjb", "MJB_STALE_GENERATION");
+    base3(); dep(0, 1); bad("bad-cycle-two.mjb", "MJB_CYCLE");
+    base3(); dep(0, 2); bad("bad-cycle-three.mjb", "MJB_CYCLE");
+    base3(); p64(doc + H_B_TIME, 299); bad("bad-over-budget-time.mjb", "MJB_OVER_BUDGET");
+    base3(); p64(doc + H_B_FUEL, 2999); bad("bad-over-budget-fuel.mjb", "MJB_OVER_BUDGET");
+    base3(); p64(doc + H_B_WORK, 2999); bad("bad-over-budget-work.mjb", "MJB_OVER_BUDGET");
+    base3(); p32(doc + H_B_IN, 63); bad("bad-over-budget-input-tokens.mjb", "MJB_OVER_BUDGET");
+    base3(); p32(doc + H_B_OUT, 15); bad("bad-over-budget-output-tokens.mjb", "MJB_OVER_BUDGET");
+    base3(); p64(doc + H_B_MEMORY, ((uint64_t)1 << 20) - 1); bad("bad-over-budget-memory.mjb", "MJB_OVER_BUDGET");
+    base3(); p64(doc + H_B_FUEL, UINT64_MAX); p64(nd(0) + N_FUEL, UINT64_MAX); bad("bad-over-budget-overflow.mjb", "MJB_OVER_BUDGET");
+
+    if (fclose(gen_expected) != 0) gen_fail = 1;
+    return gen_fail ? 2 : 0;
+}
+
+int main(int argc, char **argv) {
+    char out[1024];
+    size_t n;
+    if (argc == 2 && argv[1][0] != '-') {
+        if (slurp(argv[1], &n)) { fprintf(stderr, "cannot read %s\n", argv[1]); return 2; }
+        verdict_line(file_buf, n, out, sizeof out);
+        puts(out);
+        return strncmp(out, "ok ", 3) == 0 ? 0 : 1;
+    }
+    if (argc == 3 && strcmp(argv[1], "--corpus") == 0) return corpus(argv[2]);
+    if (argc == 3 && strcmp(argv[1], "--make-vectors") == 0) return make_vectors(argv[2]);
+    fprintf(stderr, "usage: mjb_verify FILE | --corpus DIR | --make-vectors DIR\n");
+    return 2;
+}
diff --git a/specs/microjob/tools/mutate-verifier.sh b/specs/microjob/tools/mutate-verifier.sh
new file mode 100644
index 0000000..8f52282
--- /dev/null
+++ b/specs/microjob/tools/mutate-verifier.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# mutate-verifier.sh: show that every check in mjb_verify.c is exercised by
+# the vectors. Builds one checker per check with that check disabled
+# (-DMJB_MUTANT=K) and requires the vectors to report at least one miss.
+# A mutant the vectors do not notice is a SURVIVOR and fails this script.
+#
+# Usage: mutate-verifier.sh [CC]
+set -eu
+export LC_ALL=C
+here=$(cd "$(dirname "$0")" && pwd)
+vec="$here/../vectors"
+CC=${1:-cc}
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+names=$(sed -n '/CHK_MIN_LEN = 1/,/CHK_LAST/p' "$here/mjb_verify.c" | tr -d ' \n' | sed 's/CHK_MIN_LEN=1/CHK_MIN_LEN/; s/,CHK_LAST.*//' | tr ',' ' ')
+test -n "$names" || { echo "cannot read the check list" >&2; exit 2; }
+k=0 killed=0 survived=0
+for name in $names; do
+    k=$((k + 1))
+    "$CC" -std=c99 -O1 -w -DMJB_MUTANT=$k -o "$tmp/m$k" "$here/mjb_verify.c"
+    if "$tmp/m$k" --corpus "$vec" >"$tmp/out$k" 2>&1; then
+        echo "SURVIVOR $k $name"
+        survived=$((survived + 1))
+    else
+        echo "killed $k $name: $(grep -c 'MISMATCH' "$tmp/out$k") vector(s) differ"
+        killed=$((killed + 1))
+    fi
+done
+echo "MJB1_VERIFIER_MUTANTS total=$k killed=$killed survived=$survived"
+test "$survived" -eq 0 && test "$k" -gt 0
diff --git a/specs/microjob/vectors/.gitattributes b/specs/microjob/vectors/.gitattributes
new file mode 100644
index 0000000..d94040c
--- /dev/null
+++ b/specs/microjob/vectors/.gitattributes
@@ -0,0 +1 @@
+*.mjb binary
diff --git a/specs/microjob/vectors/bad-ceiling-enum.mjb b/specs/microjob/vectors/bad-ceiling-enum.mjb
new file mode 100644
index 0000000..ec797bd
Binary files /dev/null and b/specs/microjob/vectors/bad-ceiling-enum.mjb differ
diff --git a/specs/microjob/vectors/bad-count-65.mjb b/specs/microjob/vectors/bad-count-65.mjb
new file mode 100644
index 0000000..a4d5499
Binary files /dev/null and b/specs/microjob/vectors/bad-count-65.mjb differ
diff --git a/specs/microjob/vectors/bad-count-zero.mjb b/specs/microjob/vectors/bad-count-zero.mjb
new file mode 100644
index 0000000..87cf3fb
Binary files /dev/null and b/specs/microjob/vectors/bad-count-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-cross-tenant.mjb b/specs/microjob/vectors/bad-cross-tenant.mjb
new file mode 100644
index 0000000..4b7ed83
Binary files /dev/null and b/specs/microjob/vectors/bad-cross-tenant.mjb differ
diff --git a/specs/microjob/vectors/bad-cycle-three.mjb b/specs/microjob/vectors/bad-cycle-three.mjb
new file mode 100644
index 0000000..bec91a9
Binary files /dev/null and b/specs/microjob/vectors/bad-cycle-three.mjb differ
diff --git a/specs/microjob/vectors/bad-cycle-two.mjb b/specs/microjob/vectors/bad-cycle-two.mjb
new file mode 100644
index 0000000..220f24c
Binary files /dev/null and b/specs/microjob/vectors/bad-cycle-two.mjb differ
diff --git a/specs/microjob/vectors/bad-duplicate-idempotence-key.mjb b/specs/microjob/vectors/bad-duplicate-idempotence-key.mjb
new file mode 100644
index 0000000..2c7307a
Binary files /dev/null and b/specs/microjob/vectors/bad-duplicate-idempotence-key.mjb differ
diff --git a/specs/microjob/vectors/bad-duplicate-job.mjb b/specs/microjob/vectors/bad-duplicate-job.mjb
new file mode 100644
index 0000000..3a8ffab
Binary files /dev/null and b/specs/microjob/vectors/bad-duplicate-job.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-attempts-nine.mjb b/specs/microjob/vectors/bad-enum-attempts-nine.mjb
new file mode 100644
index 0000000..21dce3b
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-attempts-nine.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-attempts-zero.mjb b/specs/microjob/vectors/bad-enum-attempts-zero.mjb
new file mode 100644
index 0000000..cb090ec
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-attempts-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-cancel-three.mjb b/specs/microjob/vectors/bad-enum-cancel-three.mjb
new file mode 100644
index 0000000..ec2a94f
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-cancel-three.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-cancel-zero.mjb b/specs/microjob/vectors/bad-enum-cancel-zero.mjb
new file mode 100644
index 0000000..dec8729
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-cancel-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-dep-count.mjb b/specs/microjob/vectors/bad-enum-dep-count.mjb
new file mode 100644
index 0000000..5166769
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-dep-count.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-effect.mjb b/specs/microjob/vectors/bad-enum-effect.mjb
new file mode 100644
index 0000000..9a03323
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-effect.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-kind.mjb b/specs/microjob/vectors/bad-enum-kind.mjb
new file mode 100644
index 0000000..377f27e
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-kind.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-op-compute.mjb b/specs/microjob/vectors/bad-enum-op-compute.mjb
new file mode 100644
index 0000000..b4effc7
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-op-compute.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-op-neural.mjb b/specs/microjob/vectors/bad-enum-op-neural.mjb
new file mode 100644
index 0000000..49721c9
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-op-neural.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-op-zero.mjb b/specs/microjob/vectors/bad-enum-op-zero.mjb
new file mode 100644
index 0000000..3276d8d
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-op-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-operand-count.mjb b/specs/microjob/vectors/bad-enum-operand-count.mjb
new file mode 100644
index 0000000..7092a06
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-operand-count.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-operand-kind-six.mjb b/specs/microjob/vectors/bad-enum-operand-kind-six.mjb
new file mode 100644
index 0000000..d98dddb
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-operand-kind-six.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-operand-kind-zero.mjb b/specs/microjob/vectors/bad-enum-operand-kind-zero.mjb
new file mode 100644
index 0000000..dca00da
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-operand-kind-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-precision.mjb b/specs/microjob/vectors/bad-enum-precision.mjb
new file mode 100644
index 0000000..4b172d9
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-precision.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-profile.mjb b/specs/microjob/vectors/bad-enum-profile.mjb
new file mode 100644
index 0000000..9154d11
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-profile.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-pure.mjb b/specs/microjob/vectors/bad-enum-pure.mjb
new file mode 100644
index 0000000..8fe5111
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-pure.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-rank.mjb b/specs/microjob/vectors/bad-enum-rank.mjb
new file mode 100644
index 0000000..ff6916e
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-rank.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-result-type-eight.mjb b/specs/microjob/vectors/bad-enum-result-type-eight.mjb
new file mode 100644
index 0000000..977ccb6
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-result-type-eight.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-result-type-zero.mjb b/specs/microjob/vectors/bad-enum-result-type-zero.mjb
new file mode 100644
index 0000000..7763a80
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-result-type-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-retry-four.mjb b/specs/microjob/vectors/bad-enum-retry-four.mjb
new file mode 100644
index 0000000..74efb70
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-retry-four.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-retry-zero.mjb b/specs/microjob/vectors/bad-enum-retry-zero.mjb
new file mode 100644
index 0000000..c186d04
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-retry-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-substrate-high.mjb b/specs/microjob/vectors/bad-enum-substrate-high.mjb
new file mode 100644
index 0000000..ba92781
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-substrate-high.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-substrate-zero.mjb b/specs/microjob/vectors/bad-enum-substrate-zero.mjb
new file mode 100644
index 0000000..fc6d7f6
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-substrate-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-enum-verifier.mjb b/specs/microjob/vectors/bad-enum-verifier.mjb
new file mode 100644
index 0000000..e198c07
Binary files /dev/null and b/specs/microjob/vectors/bad-enum-verifier.mjb differ
diff --git a/specs/microjob/vectors/bad-header-expiry-zero.mjb b/specs/microjob/vectors/bad-header-expiry-zero.mjb
new file mode 100644
index 0000000..3feeb5c
Binary files /dev/null and b/specs/microjob/vectors/bad-header-expiry-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-impure-effect.mjb b/specs/microjob/vectors/bad-impure-effect.mjb
new file mode 100644
index 0000000..61ba898
Binary files /dev/null and b/specs/microjob/vectors/bad-impure-effect.mjb differ
diff --git a/specs/microjob/vectors/bad-impure-neural.mjb b/specs/microjob/vectors/bad-impure-neural.mjb
new file mode 100644
index 0000000..08e5880
Binary files /dev/null and b/specs/microjob/vectors/bad-impure-neural.mjb differ
diff --git a/specs/microjob/vectors/bad-length-empty.mjb b/specs/microjob/vectors/bad-length-empty.mjb
new file mode 100644
index 0000000..e69de29
diff --git a/specs/microjob/vectors/bad-length-mismatch.mjb b/specs/microjob/vectors/bad-length-mismatch.mjb
new file mode 100644
index 0000000..760945b
Binary files /dev/null and b/specs/microjob/vectors/bad-length-mismatch.mjb differ
diff --git a/specs/microjob/vectors/bad-length-short.mjb b/specs/microjob/vectors/bad-length-short.mjb
new file mode 100644
index 0000000..19d58d0
Binary files /dev/null and b/specs/microjob/vectors/bad-length-short.mjb differ
diff --git a/specs/microjob/vectors/bad-length-trailing.mjb b/specs/microjob/vectors/bad-length-trailing.mjb
new file mode 100644
index 0000000..1bc18b0
Binary files /dev/null and b/specs/microjob/vectors/bad-length-trailing.mjb differ
diff --git a/specs/microjob/vectors/bad-magic.mjb b/specs/microjob/vectors/bad-magic.mjb
new file mode 100644
index 0000000..20f8e1a
Binary files /dev/null and b/specs/microjob/vectors/bad-magic.mjb differ
diff --git a/specs/microjob/vectors/bad-missing-dep-out-of-range.mjb b/specs/microjob/vectors/bad-missing-dep-out-of-range.mjb
new file mode 100644
index 0000000..2939863
Binary files /dev/null and b/specs/microjob/vectors/bad-missing-dep-out-of-range.mjb differ
diff --git a/specs/microjob/vectors/bad-missing-dep-self.mjb b/specs/microjob/vectors/bad-missing-dep-self.mjb
new file mode 100644
index 0000000..1e38356
Binary files /dev/null and b/specs/microjob/vectors/bad-missing-dep-self.mjb differ
diff --git a/specs/microjob/vectors/bad-missing-operand-digest.mjb b/specs/microjob/vectors/bad-missing-operand-digest.mjb
new file mode 100644
index 0000000..3ede9ad
Binary files /dev/null and b/specs/microjob/vectors/bad-missing-operand-digest.mjb differ
diff --git a/specs/microjob/vectors/bad-missing-operand-generation.mjb b/specs/microjob/vectors/bad-missing-operand-generation.mjb
new file mode 100644
index 0000000..845a7ee
Binary files /dev/null and b/specs/microjob/vectors/bad-missing-operand-generation.mjb differ
diff --git a/specs/microjob/vectors/bad-needs-expansion-64-16-input.mjb b/specs/microjob/vectors/bad-needs-expansion-64-16-input.mjb
new file mode 100644
index 0000000..bbfd7c8
Binary files /dev/null and b/specs/microjob/vectors/bad-needs-expansion-64-16-input.mjb differ
diff --git a/specs/microjob/vectors/bad-needs-expansion-64-16-output.mjb b/specs/microjob/vectors/bad-needs-expansion-64-16-output.mjb
new file mode 100644
index 0000000..907fbec
Binary files /dev/null and b/specs/microjob/vectors/bad-needs-expansion-64-16-output.mjb differ
diff --git a/specs/microjob/vectors/bad-no-approval.mjb b/specs/microjob/vectors/bad-no-approval.mjb
new file mode 100644
index 0000000..43bdf7e
Binary files /dev/null and b/specs/microjob/vectors/bad-no-approval.mjb differ
diff --git a/specs/microjob/vectors/bad-no-capability.mjb b/specs/microjob/vectors/bad-no-capability.mjb
new file mode 100644
index 0000000..ed34827
Binary files /dev/null and b/specs/microjob/vectors/bad-no-capability.mjb differ
diff --git a/specs/microjob/vectors/bad-no-generation.mjb b/specs/microjob/vectors/bad-no-generation.mjb
new file mode 100644
index 0000000..bed5150
Binary files /dev/null and b/specs/microjob/vectors/bad-no-generation.mjb differ
diff --git a/specs/microjob/vectors/bad-no-idempotence-key.mjb b/specs/microjob/vectors/bad-no-idempotence-key.mjb
new file mode 100644
index 0000000..1b2ee70
Binary files /dev/null and b/specs/microjob/vectors/bad-no-idempotence-key.mjb differ
diff --git a/specs/microjob/vectors/bad-no-incarnation.mjb b/specs/microjob/vectors/bad-no-incarnation.mjb
new file mode 100644
index 0000000..398310a
Binary files /dev/null and b/specs/microjob/vectors/bad-no-incarnation.mjb differ
diff --git a/specs/microjob/vectors/bad-no-job-id.mjb b/specs/microjob/vectors/bad-no-job-id.mjb
new file mode 100644
index 0000000..a320d69
Binary files /dev/null and b/specs/microjob/vectors/bad-no-job-id.mjb differ
diff --git a/specs/microjob/vectors/bad-no-objective.mjb b/specs/microjob/vectors/bad-no-objective.mjb
new file mode 100644
index 0000000..ca94f96
Binary files /dev/null and b/specs/microjob/vectors/bad-no-objective.mjb differ
diff --git a/specs/microjob/vectors/bad-no-subject.mjb b/specs/microjob/vectors/bad-no-subject.mjb
new file mode 100644
index 0000000..bdf2ad0
Binary files /dev/null and b/specs/microjob/vectors/bad-no-subject.mjb differ
diff --git a/specs/microjob/vectors/bad-no-tenant.mjb b/specs/microjob/vectors/bad-no-tenant.mjb
new file mode 100644
index 0000000..39dcb1d
Binary files /dev/null and b/specs/microjob/vectors/bad-no-tenant.mjb differ
diff --git a/specs/microjob/vectors/bad-no-verifier-checker-no-ref.mjb b/specs/microjob/vectors/bad-no-verifier-checker-no-ref.mjb
new file mode 100644
index 0000000..e28c663
Binary files /dev/null and b/specs/microjob/vectors/bad-no-verifier-checker-no-ref.mjb differ
diff --git a/specs/microjob/vectors/bad-no-verifier-kind-zero-no-ref.mjb b/specs/microjob/vectors/bad-no-verifier-kind-zero-no-ref.mjb
new file mode 100644
index 0000000..50646f0
Binary files /dev/null and b/specs/microjob/vectors/bad-no-verifier-kind-zero-no-ref.mjb differ
diff --git a/specs/microjob/vectors/bad-no-verifier-kind-zero.mjb b/specs/microjob/vectors/bad-no-verifier-kind-zero.mjb
new file mode 100644
index 0000000..b4131db
Binary files /dev/null and b/specs/microjob/vectors/bad-no-verifier-kind-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-no-verifier-recompute-impure.mjb b/specs/microjob/vectors/bad-no-verifier-recompute-impure.mjb
new file mode 100644
index 0000000..6138b5a
Binary files /dev/null and b/specs/microjob/vectors/bad-no-verifier-recompute-impure.mjb differ
diff --git a/specs/microjob/vectors/bad-no-verifier-recompute-with-ref.mjb b/specs/microjob/vectors/bad-no-verifier-recompute-with-ref.mjb
new file mode 100644
index 0000000..d9cb959
Binary files /dev/null and b/specs/microjob/vectors/bad-no-verifier-recompute-with-ref.mjb differ
diff --git a/specs/microjob/vectors/bad-node-expiry-after-header.mjb b/specs/microjob/vectors/bad-node-expiry-after-header.mjb
new file mode 100644
index 0000000..a13a66c
Binary files /dev/null and b/specs/microjob/vectors/bad-node-expiry-after-header.mjb differ
diff --git a/specs/microjob/vectors/bad-node-expiry-zero.mjb b/specs/microjob/vectors/bad-node-expiry-zero.mjb
new file mode 100644
index 0000000..61e26c2
Binary files /dev/null and b/specs/microjob/vectors/bad-node-expiry-zero.mjb differ
diff --git a/specs/microjob/vectors/bad-over-budget-fuel.mjb b/specs/microjob/vectors/bad-over-budget-fuel.mjb
new file mode 100644
index 0000000..6b518a5
Binary files /dev/null and b/specs/microjob/vectors/bad-over-budget-fuel.mjb differ
diff --git a/specs/microjob/vectors/bad-over-budget-input-tokens.mjb b/specs/microjob/vectors/bad-over-budget-input-tokens.mjb
new file mode 100644
index 0000000..c997183
Binary files /dev/null and b/specs/microjob/vectors/bad-over-budget-input-tokens.mjb differ
diff --git a/specs/microjob/vectors/bad-over-budget-memory.mjb b/specs/microjob/vectors/bad-over-budget-memory.mjb
new file mode 100644
index 0000000..40eb155
Binary files /dev/null and b/specs/microjob/vectors/bad-over-budget-memory.mjb differ
diff --git a/specs/microjob/vectors/bad-over-budget-output-tokens.mjb b/specs/microjob/vectors/bad-over-budget-output-tokens.mjb
new file mode 100644
index 0000000..9b792d5
Binary files /dev/null and b/specs/microjob/vectors/bad-over-budget-output-tokens.mjb differ
diff --git a/specs/microjob/vectors/bad-over-budget-overflow.mjb b/specs/microjob/vectors/bad-over-budget-overflow.mjb
new file mode 100644
index 0000000..db3e60e
Binary files /dev/null and b/specs/microjob/vectors/bad-over-budget-overflow.mjb differ
diff --git a/specs/microjob/vectors/bad-over-budget-time.mjb b/specs/microjob/vectors/bad-over-budget-time.mjb
new file mode 100644
index 0000000..370ec7f
Binary files /dev/null and b/specs/microjob/vectors/bad-over-budget-time.mjb differ
diff --git a/specs/microjob/vectors/bad-over-budget-work.mjb b/specs/microjob/vectors/bad-over-budget-work.mjb
new file mode 100644
index 0000000..0e70eb3
Binary files /dev/null and b/specs/microjob/vectors/bad-over-budget-work.mjb differ
diff --git a/specs/microjob/vectors/bad-reserved-dims.mjb b/specs/microjob/vectors/bad-reserved-dims.mjb
new file mode 100644
index 0000000..6f61c25
Binary files /dev/null and b/specs/microjob/vectors/bad-reserved-dims.mjb differ
diff --git a/specs/microjob/vectors/bad-reserved-operand-pad.mjb b/specs/microjob/vectors/bad-reserved-operand-pad.mjb
new file mode 100644
index 0000000..72b24a7
Binary files /dev/null and b/specs/microjob/vectors/bad-reserved-operand-pad.mjb differ
diff --git a/specs/microjob/vectors/bad-reserved-unused-dep-generation.mjb b/specs/microjob/vectors/bad-reserved-unused-dep-generation.mjb
new file mode 100644
index 0000000..7fecc6e
Binary files /dev/null and b/specs/microjob/vectors/bad-reserved-unused-dep-generation.mjb differ
diff --git a/specs/microjob/vectors/bad-reserved-unused-dep.mjb b/specs/microjob/vectors/bad-reserved-unused-dep.mjb
new file mode 100644
index 0000000..7566054
Binary files /dev/null and b/specs/microjob/vectors/bad-reserved-unused-dep.mjb differ
diff --git a/specs/microjob/vectors/bad-reserved-unused-operand.mjb b/specs/microjob/vectors/bad-reserved-unused-operand.mjb
new file mode 100644
index 0000000..303fb1b
Binary files /dev/null and b/specs/microjob/vectors/bad-reserved-unused-operand.mjb differ
diff --git a/specs/microjob/vectors/bad-reserved0.mjb b/specs/microjob/vectors/bad-reserved0.mjb
new file mode 100644
index 0000000..6930686
Binary files /dev/null and b/specs/microjob/vectors/bad-reserved0.mjb differ
diff --git a/specs/microjob/vectors/bad-reserved1.mjb b/specs/microjob/vectors/bad-reserved1.mjb
new file mode 100644
index 0000000..11dfcf7
Binary files /dev/null and b/specs/microjob/vectors/bad-reserved1.mjb differ
diff --git a/specs/microjob/vectors/bad-retry-effect-idempotent.mjb b/specs/microjob/vectors/bad-retry-effect-idempotent.mjb
new file mode 100644
index 0000000..6493c8d
Binary files /dev/null and b/specs/microjob/vectors/bad-retry-effect-idempotent.mjb differ
diff --git a/specs/microjob/vectors/bad-retry-never-multi.mjb b/specs/microjob/vectors/bad-retry-never-multi.mjb
new file mode 100644
index 0000000..9167420
Binary files /dev/null and b/specs/microjob/vectors/bad-retry-never-multi.mjb differ
diff --git a/specs/microjob/vectors/bad-stale-generation.mjb b/specs/microjob/vectors/bad-stale-generation.mjb
new file mode 100644
index 0000000..ecb26c5
Binary files /dev/null and b/specs/microjob/vectors/bad-stale-generation.mjb differ
diff --git a/specs/microjob/vectors/bad-token-compute-required.mjb b/specs/microjob/vectors/bad-token-compute-required.mjb
new file mode 100644
index 0000000..c134b7d
Binary files /dev/null and b/specs/microjob/vectors/bad-token-compute-required.mjb differ
diff --git a/specs/microjob/vectors/bad-token-compute-with-model.mjb b/specs/microjob/vectors/bad-token-compute-with-model.mjb
new file mode 100644
index 0000000..85c585f
Binary files /dev/null and b/specs/microjob/vectors/bad-token-compute-with-model.mjb differ
diff --git a/specs/microjob/vectors/bad-token-compute-with-profile.mjb b/specs/microjob/vectors/bad-token-compute-with-profile.mjb
new file mode 100644
index 0000000..b413e1e
Binary files /dev/null and b/specs/microjob/vectors/bad-token-compute-with-profile.mjb differ
diff --git a/specs/microjob/vectors/bad-token-compute-with-tokens.mjb b/specs/microjob/vectors/bad-token-compute-with-tokens.mjb
new file mode 100644
index 0000000..bb0c8a0
Binary files /dev/null and b/specs/microjob/vectors/bad-token-compute-with-tokens.mjb differ
diff --git a/specs/microjob/vectors/bad-token-neural-no-model.mjb b/specs/microjob/vectors/bad-token-neural-no-model.mjb
new file mode 100644
index 0000000..67f66fd
Binary files /dev/null and b/specs/microjob/vectors/bad-token-neural-no-model.mjb differ
diff --git a/specs/microjob/vectors/bad-token-neural-over-profile-input.mjb b/specs/microjob/vectors/bad-token-neural-over-profile-input.mjb
new file mode 100644
index 0000000..f5c68fa
Binary files /dev/null and b/specs/microjob/vectors/bad-token-neural-over-profile-input.mjb differ
diff --git a/specs/microjob/vectors/bad-token-neural-over-profile-output.mjb b/specs/microjob/vectors/bad-token-neural-over-profile-output.mjb
new file mode 100644
index 0000000..76533bb
Binary files /dev/null and b/specs/microjob/vectors/bad-token-neural-over-profile-output.mjb differ
diff --git a/specs/microjob/vectors/bad-token-neural-zero-cap.mjb b/specs/microjob/vectors/bad-token-neural-zero-cap.mjb
new file mode 100644
index 0000000..21a298a
Binary files /dev/null and b/specs/microjob/vectors/bad-token-neural-zero-cap.mjb differ
diff --git a/specs/microjob/vectors/bad-token-neural-zero-profile.mjb b/specs/microjob/vectors/bad-token-neural-zero-profile.mjb
new file mode 100644
index 0000000..18d9598
Binary files /dev/null and b/specs/microjob/vectors/bad-token-neural-zero-profile.mjb differ
diff --git a/specs/microjob/vectors/bad-unauthorized-compute-under-none.mjb b/specs/microjob/vectors/bad-unauthorized-compute-under-none.mjb
new file mode 100644
index 0000000..f6bb15e
Binary files /dev/null and b/specs/microjob/vectors/bad-unauthorized-compute-under-none.mjb differ
diff --git a/specs/microjob/vectors/bad-unauthorized-effect.mjb b/specs/microjob/vectors/bad-unauthorized-effect.mjb
new file mode 100644
index 0000000..b2a05ce
Binary files /dev/null and b/specs/microjob/vectors/bad-unauthorized-effect.mjb differ
diff --git a/specs/microjob/vectors/bad-version-downgrade.mjb b/specs/microjob/vectors/bad-version-downgrade.mjb
new file mode 100644
index 0000000..e259eab
Binary files /dev/null and b/specs/microjob/vectors/bad-version-downgrade.mjb differ
diff --git a/specs/microjob/vectors/bad-version-unknown.mjb b/specs/microjob/vectors/bad-version-unknown.mjb
new file mode 100644
index 0000000..e827971
Binary files /dev/null and b/specs/microjob/vectors/bad-version-unknown.mjb differ
diff --git a/specs/microjob/vectors/bad-zero-cap-fuel.mjb b/specs/microjob/vectors/bad-zero-cap-fuel.mjb
new file mode 100644
index 0000000..276486d
Binary files /dev/null and b/specs/microjob/vectors/bad-zero-cap-fuel.mjb differ
diff --git a/specs/microjob/vectors/bad-zero-cap-memory.mjb b/specs/microjob/vectors/bad-zero-cap-memory.mjb
new file mode 100644
index 0000000..0776403
Binary files /dev/null and b/specs/microjob/vectors/bad-zero-cap-memory.mjb differ
diff --git a/specs/microjob/vectors/bad-zero-cap-time.mjb b/specs/microjob/vectors/bad-zero-cap-time.mjb
new file mode 100644
index 0000000..3a5929e
Binary files /dev/null and b/specs/microjob/vectors/bad-zero-cap-time.mjb differ
diff --git a/specs/microjob/vectors/bad-zero-cap-work.mjb b/specs/microjob/vectors/bad-zero-cap-work.mjb
new file mode 100644
index 0000000..87a0a7f
Binary files /dev/null and b/specs/microjob/vectors/bad-zero-cap-work.mjb differ
diff --git a/specs/microjob/vectors/expected.txt b/specs/microjob/vectors/expected.txt
new file mode 100644
index 0000000..e3ad91e
--- /dev/null
+++ b/specs/microjob/vectors/expected.txt
@@ -0,0 +1,109 @@
+# MJB1 document vectors. Spec: ../SPEC.md (Draft v0.1, wire version 1).
+# Line: <file> <verdict line>, verdict line as printed by tools/mjb_verify.c:
+#   ok nodes=N incarnation=I ceiling=C objective=H64 tenant=H64 digest=H64 order=i,j,...
+#   refuse <code from SPEC.md section 6>
+# Generated by tools/mjb_verify.c --make-vectors; do not edit by hand.
+ok-base3.mjb ok nodes=3 incarnation=1 ceiling=1 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 tenant=7e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b42495057 digest=98096c1a0934850c1727bf197ce491c0151f3a8e9b0e533dc0bde372b15a8137 order=0,1,2
+ok-sample-11.mjb ok nodes=11 incarnation=1 ceiling=2 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 tenant=7e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b42495057 digest=1994d71c01bda3745719836b2afb6febed624767fc2341d0d5e6f1b112abb531 order=0,1,2,3,4,5,6,7,8,9,10
+ok-chain-64.mjb ok nodes=64 incarnation=1 ceiling=1 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 tenant=7e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b42495057 digest=25974df77207485167c2a8e655dae0a05d2c937753d507b98406a50b05bad9d6 order=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
+ok-reverse-order.mjb ok nodes=4 incarnation=1 ceiling=1 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 tenant=7e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b42495057 digest=320ab43c430378d36c3ea75c67879f922d054af7cc6710ac3b977901f8fb2521 order=2,3,0,1
+ok-fanin-8-tensor.mjb ok nodes=9 incarnation=1 ceiling=1 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 tenant=7e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b42495057 digest=a7116cc64cc6c4b74e74e0fa5fde8bdb3bdd3fbd1e307fc6f33cbec4a8455db5 order=0,1,2,3,4,5,6,7,8
+ok-minimal-exact-64-16.mjb ok nodes=1 incarnation=1 ceiling=0 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 tenant=7e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b42495057 digest=3ba2c976d50c8d5d6af57d6b7c79399a0a7bcc14f8d40b218955a6a038f2b9cc order=0
+ok-specialist-512-128.mjb ok nodes=1 incarnation=1 ceiling=0 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 tenant=7e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b42495057 digest=5cc911456cd3f91c0a9ac63f7d5d463370e16044f94129b8c65408584cb03a94 order=0
+ok-optimizer-smaller-caps.mjb ok nodes=1 incarnation=1 ceiling=0 objective=0b121920272e353c434a51585f666d747b828990979ea5acb3bac1c8cfd6dde4 tenant=7e858c939aa1a8afb6bdc4cbd2d9e0e7eef5fc030a11181f262d343b42495057 digest=a54745a0a70fd6c7211841e390b59b38096630a473ba06c816e10d178bbd628d order=0
+bad-length-short.mjb refuse MJB_BAD_LENGTH
+bad-length-empty.mjb refuse MJB_BAD_LENGTH
+bad-magic.mjb refuse MJB_BAD_MAGIC
+bad-version-downgrade.mjb refuse MJB_DOWNGRADE
+bad-version-unknown.mjb refuse MJB_BAD_VERSION
+bad-count-zero.mjb refuse MJB_BAD_COUNT
+bad-count-65.mjb refuse MJB_BAD_COUNT
+bad-length-mismatch.mjb refuse MJB_BAD_LENGTH
+bad-length-trailing.mjb refuse MJB_BAD_LENGTH
+bad-reserved0.mjb refuse MJB_RESERVED_NONZERO
+bad-ceiling-enum.mjb refuse MJB_BAD_ENUM
+bad-no-objective.mjb refuse MJB_NO_OBJECTIVE
+bad-no-tenant.mjb refuse MJB_NO_TENANT
+bad-no-subject.mjb refuse MJB_NO_SUBJECT
+bad-no-approval.mjb refuse MJB_NO_APPROVAL
+bad-no-incarnation.mjb refuse MJB_NO_OBJECTIVE
+bad-header-expiry-zero.mjb refuse MJB_BAD_EXPIRY
+bad-no-job-id.mjb refuse MJB_NO_JOB
+bad-no-idempotence-key.mjb refuse MJB_NO_JOB
+bad-no-generation.mjb refuse MJB_NO_JOB
+bad-reserved1.mjb refuse MJB_RESERVED_NONZERO
+bad-reserved-unused-dep.mjb refuse MJB_RESERVED_NONZERO
+bad-reserved-unused-dep-generation.mjb refuse MJB_RESERVED_NONZERO
+bad-reserved-unused-operand.mjb refuse MJB_RESERVED_NONZERO
+bad-reserved-operand-pad.mjb refuse MJB_RESERVED_NONZERO
+bad-reserved-dims.mjb refuse MJB_RESERVED_NONZERO
+bad-enum-kind.mjb refuse MJB_BAD_ENUM
+bad-enum-op-compute.mjb refuse MJB_BAD_ENUM
+bad-enum-op-zero.mjb refuse MJB_BAD_ENUM
+bad-enum-op-neural.mjb refuse MJB_BAD_ENUM
+bad-enum-profile.mjb refuse MJB_BAD_ENUM
+bad-enum-effect.mjb refuse MJB_BAD_ENUM
+bad-enum-verifier.mjb refuse MJB_BAD_ENUM
+bad-enum-retry-zero.mjb refuse MJB_BAD_ENUM
+bad-enum-retry-four.mjb refuse MJB_BAD_ENUM
+bad-enum-attempts-zero.mjb refuse MJB_BAD_ENUM
+bad-enum-attempts-nine.mjb refuse MJB_BAD_ENUM
+bad-enum-cancel-zero.mjb refuse MJB_BAD_ENUM
+bad-enum-cancel-three.mjb refuse MJB_BAD_ENUM
+bad-enum-precision.mjb refuse MJB_BAD_ENUM
+bad-enum-substrate-zero.mjb refuse MJB_BAD_ENUM
+bad-enum-substrate-high.mjb refuse MJB_BAD_ENUM
+bad-enum-dep-count.mjb refuse MJB_BAD_ENUM
+bad-enum-operand-count.mjb refuse MJB_BAD_ENUM
+bad-enum-result-type-zero.mjb refuse MJB_BAD_ENUM
+bad-enum-result-type-eight.mjb refuse MJB_BAD_ENUM
+bad-enum-rank.mjb refuse MJB_BAD_ENUM
+bad-enum-pure.mjb refuse MJB_BAD_ENUM
+bad-enum-operand-kind-six.mjb refuse MJB_BAD_ENUM
+bad-enum-operand-kind-zero.mjb refuse MJB_BAD_ENUM
+bad-cross-tenant.mjb refuse MJB_CROSS_TENANT
+bad-no-capability.mjb refuse MJB_NO_CAPABILITY
+bad-unauthorized-effect.mjb refuse MJB_UNAUTHORIZED_EFFECT
+bad-unauthorized-compute-under-none.mjb refuse MJB_UNAUTHORIZED_EFFECT
+bad-no-verifier-kind-zero.mjb refuse MJB_NO_VERIFIER
+bad-no-verifier-kind-zero-no-ref.mjb refuse MJB_NO_VERIFIER
+bad-no-verifier-checker-no-ref.mjb refuse MJB_NO_VERIFIER
+bad-no-verifier-recompute-with-ref.mjb refuse MJB_NO_VERIFIER
+bad-no-verifier-recompute-impure.mjb refuse MJB_NO_VERIFIER
+bad-impure-neural.mjb refuse MJB_IMPURE
+bad-impure-effect.mjb refuse MJB_IMPURE
+bad-token-compute-with-tokens.mjb refuse MJB_TOKEN_PROFILE
+bad-token-compute-with-profile.mjb refuse MJB_TOKEN_PROFILE
+bad-token-compute-with-model.mjb refuse MJB_TOKEN_PROFILE
+bad-token-compute-required.mjb refuse MJB_TOKEN_PROFILE
+bad-token-neural-zero-profile.mjb refuse MJB_TOKEN_PROFILE
+bad-token-neural-over-profile-input.mjb refuse MJB_TOKEN_PROFILE
+bad-token-neural-over-profile-output.mjb refuse MJB_TOKEN_PROFILE
+bad-token-neural-zero-cap.mjb refuse MJB_TOKEN_PROFILE
+bad-token-neural-no-model.mjb refuse MJB_TOKEN_PROFILE
+bad-needs-expansion-64-16-input.mjb refuse MJB_NEEDS_EXPANSION
+bad-needs-expansion-64-16-output.mjb refuse MJB_NEEDS_EXPANSION
+bad-retry-never-multi.mjb refuse MJB_BAD_RETRY
+bad-retry-effect-idempotent.mjb refuse MJB_BAD_RETRY
+bad-zero-cap-time.mjb refuse MJB_ZERO_CAP
+bad-zero-cap-fuel.mjb refuse MJB_ZERO_CAP
+bad-zero-cap-memory.mjb refuse MJB_ZERO_CAP
+bad-zero-cap-work.mjb refuse MJB_ZERO_CAP
+bad-node-expiry-zero.mjb refuse MJB_BAD_EXPIRY
+bad-node-expiry-after-header.mjb refuse MJB_BAD_EXPIRY
+bad-missing-operand-digest.mjb refuse MJB_MISSING_OPERAND
+bad-missing-operand-generation.mjb refuse MJB_MISSING_OPERAND
+bad-duplicate-job.mjb refuse MJB_DUPLICATE_JOB
+bad-duplicate-idempotence-key.mjb refuse MJB_DUPLICATE_JOB
+bad-missing-dep-self.mjb refuse MJB_MISSING_DEP
+bad-missing-dep-out-of-range.mjb refuse MJB_MISSING_DEP
+bad-stale-generation.mjb refuse MJB_STALE_GENERATION
+bad-cycle-two.mjb refuse MJB_CYCLE
+bad-cycle-three.mjb refuse MJB_CYCLE
+bad-over-budget-time.mjb refuse MJB_OVER_BUDGET
+bad-over-budget-fuel.mjb refuse MJB_OVER_BUDGET
+bad-over-budget-work.mjb refuse MJB_OVER_BUDGET
+bad-over-budget-input-tokens.mjb refuse MJB_OVER_BUDGET
+bad-over-budget-output-tokens.mjb refuse MJB_OVER_BUDGET
+bad-over-budget-memory.mjb refuse MJB_OVER_BUDGET
+bad-over-budget-overflow.mjb refuse MJB_OVER_BUDGET
diff --git a/specs/microjob/vectors/ok-base3.mjb b/specs/microjob/vectors/ok-base3.mjb
new file mode 100644
index 0000000..17d0fbf
Binary files /dev/null and b/specs/microjob/vectors/ok-base3.mjb differ
diff --git a/specs/microjob/vectors/ok-chain-64.mjb b/specs/microjob/vectors/ok-chain-64.mjb
new file mode 100644
index 0000000..12c0a9a
Binary files /dev/null and b/specs/microjob/vectors/ok-chain-64.mjb differ
diff --git a/specs/microjob/vectors/ok-fanin-8-tensor.mjb b/specs/microjob/vectors/ok-fanin-8-tensor.mjb
new file mode 100644
index 0000000..874eb3c
Binary files /dev/null and b/specs/microjob/vectors/ok-fanin-8-tensor.mjb differ
diff --git a/specs/microjob/vectors/ok-minimal-exact-64-16.mjb b/specs/microjob/vectors/ok-minimal-exact-64-16.mjb
new file mode 100644
index 0000000..a24f741
Binary files /dev/null and b/specs/microjob/vectors/ok-minimal-exact-64-16.mjb differ
diff --git a/specs/microjob/vectors/ok-optimizer-smaller-caps.mjb b/specs/microjob/vectors/ok-optimizer-smaller-caps.mjb
new file mode 100644
index 0000000..74b7ada
Binary files /dev/null and b/specs/microjob/vectors/ok-optimizer-smaller-caps.mjb differ
diff --git a/specs/microjob/vectors/ok-reverse-order.mjb b/specs/microjob/vectors/ok-reverse-order.mjb
new file mode 100644
index 0000000..35428cb
Binary files /dev/null and b/specs/microjob/vectors/ok-reverse-order.mjb differ
diff --git a/specs/microjob/vectors/ok-sample-11.mjb b/specs/microjob/vectors/ok-sample-11.mjb
new file mode 100644
index 0000000..c4cd213
Binary files /dev/null and b/specs/microjob/vectors/ok-sample-11.mjb differ
diff --git a/specs/microjob/vectors/ok-specialist-512-128.mjb b/specs/microjob/vectors/ok-specialist-512-128.mjb
new file mode 100644
index 0000000..7482066
Binary files /dev/null and b/specs/microjob/vectors/ok-specialist-512-128.mjb differ