# CAIN-42 L5 Autonomous Agent Governance Fabric Architecture (Part 39)

**Document:** `CAIN42_L5_REFERENCE_ARCHITECTURE.md`
**Title:** CAIN-42 L5 Autonomous Agent Governance Fabric Architecture
**Audience:** Senior security engineers and architects who do not know this codebase.
**Status:** Architecture reference, 2026-09-28. No capability is described as implemented unless code and
tests support it; where it is not implemented, this document says so.
**Companion documents:** `CAIN42_L5_THREAT_MODEL.md` (Part 29), `CAIN42_L5_AUTONOMY_SPEC.md`,
`CAIN45_THREAT_MODEL.md`, `docs/architecture/CAIN-7-MOATS.md`,
`CAIN42_ENTERPRISE_REFERENCE_ARCHITECTURE.md` (broader enterprise planes).

> **SUPERSEDING ADDENDUM (same session, after the Evolution-2 wiring landed).** The body below was written
> before the Evolution-2 wiring and is superseded where it says the L5 boundary/caller-auth/intent modules
> are "untested/unwired". They are now **tested** (`tests/test_cain42_l5_wiring.py`, 11 passing) and **wired
> restriction-only** into `cain45/hypervisor.py` and `cain/mcp_proxy.py` (library + interceptor). The
> architecture is unchanged in the way that matters: `cain45/l5/` is still **not wired into the hosted
> gateway process**, and no real LLM agent is governed end-to-end.

> **How to read this document.** Every architectural element is tagged `LIVE`, `TESTED library`, or
> `SIMULATED`. These are not marketing labels; they are the labels used by the repository's own forensic
> baseline (`CAIN42_L5_BASELINE.json`). A component is `LIVE` only when it runs and was observed; `TESTED
> library` when it exists and is exercised by tests on this host but is not deployed; `SIMULATED` when it is
> an in-process model. The full status vocabulary is in Appendix A.

---

## 1. Executive summary

CAIN-42 is a **runtime trust and control fabric** that sits between autonomous AI agents and consequential
real-world actions. It governs the **execution channel** (MCP tool calls, shell commands, APIs, data and
compute), not merely the conversational prompt.

The architecture is a single unbroken pipeline:

```
L5-CLASS AGENT
      │  proposes an action (never authority)
      ▼
CAIN-42 GOVERNANCE FABRIC
      │  identity · policy · trust · authority · delegation · trajectory · risk · quorum · evidence
      ▼
MCPGate (enforcement boundary)
      │  fail-closed: ALLOW only when every mandatory governed condition holds
      ▼
TOOLS / APIs / COMPUTE / DATA
      │  the effect is attempted
      ▼
REAL-WORLD EFFECT
      │  postcondition checked, evidence sealed, trust updated
      ▼
EVIDENCE REMEMBERS
```

**Canonical doctrine (the only sentence that matters operationally):**

> `AGENT PROPOSES → CAIN DECIDES → MCPGATE ENFORCES → SYSTEM EXECUTES → EVIDENCE REMEMBERS`
>
> `NO AUTHORIZATION → NO EXECUTION`

**The three load-bearing ideas:**

1. **Capability ≠ authority.** A model may know an action; a tool may be able to perform it; an agent may
   request it; a sandbox may permit the process to attempt it. None of these is authority. Authority is
   computed only from governed state (`cain45/l5/authority.py`).
2. **Autonomy level is descriptive metadata.** Setting an agent to "L5" changes nothing about what is
   authorized; the decision never reads the level (`cain45/l5/invariants.py`, I19).
3. **Fail-closed, reason-bearing denial.** `UNKNOWN`, `ERROR`, missing certificate, missing quorum, expired
   lease and unreadable state all deny or revalidate — never allow — and every denial carries a
   machine-readable reason (`cain45/l5/authority.py:Reason`).

**Honest one-line scope statement.** The *hosted* enforcement path runs in enforce mode with five blocking
stages; the *L5 autonomy kernel* is a tested library not yet wired into that path; the *federated
multi-provider, hardware-rooted, third-party-reviewed* properties do not exist. Details follow.

---

## 2. What runs where (ground truth)

| Layer | Component | Where | Status |
|---|---|---|---|
| Hosted control plane | `platform-gateway/main.py`, `/fabric` (`mode=enforce`) | live sites | `LIVE_PRODUCTION_OBSERVED` — no customer traffic |
| Hosted blocking stages | identity, authorization, consensus, mcpgate, execution | `/fabric`, `platform-gateway/fabric_control_plane.py` | `LIVE_PRODUCTION_OBSERVED` |
| Hosted record-only stages | actionproof, approval, evidence, intent, policy, risk, verification | `/fabric` | `PRE_PRODUCTION` / `SHADOW` — record, do not block |
| Trust kernel | `platform-gateway/cain_trust_kernel.py` (2361 lines) | library | `TESTED` — not a live service |
| Enforcement boundary | `cain/mcp_proxy.py` `MCPTransparentInterceptor` (1037 lines) | operator-run | `VERIFIED` (operator test, not customer calls) |
| Fabric gate | `platform-gateway/cain_fabric_gate_42.py` (273 lines) | library/config | `TESTED` — can only tighten |
| Agent Hypervisor / ZoD | `cain45/hypervisor.py` (802 lines) | library operator runs | `PRE_PRODUCTION` |
| Confinement | `cain45/confine.py` (206 lines) | operator host | `VERIFIED` (seccomp-BPF, bwrap, cgroups) |
| Authoritative state | `cain45/authoritative_state.py` (977 lines) | library + live cluster | `VERIFIED` |
| Consensus | `scripts/cain42_bft/`, `cain45/consensus.py` | two live clusters | `LIVE_PRODUCTION_OBSERVED` |
| L5 governance kernel | `cain45/l5/` (8 modules + `__init__.py`, ~1800 lines) | **library only** | `TESTED` — restriction-only wiring into the hypervisor library + MCPGate interceptor; NOT wired to the hosted gateway |
| Governed memory / world model / fabrics | `cain45/memory.py`, `world_model.py`, `swarm.py`, `tooling.py`, `economics.py`, `stopping.py`, `trajectory.py` | libraries | `TESTED` — not hosted |
| Quarantine / kill-switch | `cain/quarantine.py` (651 lines) | library | `TESTED` (SQLite WAL) |

Evidence bundles proving the `VERIFIED` / `LIVE` rows: `clawx-site/evidence/e6-live-lease-2026-09-28/`,
`e7-lease-2026-09-28/`, `e7-seccomp-2026-09-28/`, `e8-governance-2026-09-28/`,
`cain45-zod-live-2026-09-27/`, `mcpgate-live-2026-09-27/`, `e7-replay-2026-09-28/`, `e7-bench-2026-09-28/`.

**Repository-honesty note.** `cain45/l5/` and its published artifacts are currently **untracked in git**
(`git ls-files cain45/l5/` is empty). Three Evolution-2 modules — `boundary.py`, `caller_auth.py`,
`intent.py` — are newer than the published L5 evidence bundle (06:16) and have **no tests** and **no
wiring**. This document treats them as unproven library code.

---

## 3. The end-to-end pipeline, stage by stage

The hosted fabric records a decision as a sequence of ordered stages
(`platform-gateway/fabric_control_plane.py:record_decision`). Which stages *block* versus *record* is set by
the live runtime and published in `CAIN42_TRUTH_REGISTRY.json`.

| # | Stage | Question | Enforced by | Hosted behavior |
|---|---|---|---|---|
| 1 | Agent proposal / intent | What is being asked? | `cain45/l5/intent.py:ActionIntent` (library) | intent text is never an authority input |
| 2 | Identity | Who is acting (agent, instance, human, tool)? | `cain45/identity.py`, identity stage | **BLOCK** |
| 3 | Authorization | Is there valid, current authority? | `cain45/hypervisor.py:authorize`, `cain45/l5/governance.py` | **BLOCK** |
| 4 | Consensus | Was it ordered with a valid quorum certificate? | `cain45/consensus.py`, `authoritative_state.py` | **BLOCK** |
| 5 | Policy | Does it fit the governed ceiling? | `cain45/governance.py:PolicyGovernor` | record |
| 6 | Trust | Is trust above the required floor? | `cain_trust_kernel.py:TemporalTrustEvaluator` | record |
| 7 | Risk / blast radius | Is the budget exceeded? | hypervisor `_charge`, `economics.py` | record |
| 8 | Trajectory | Does the action stay on the authorized trajectory? | `cain45/trajectory.py`, kernel `CausalTrajectorySecurityEngine` | record |
| 9 | Delegation | Is `child ≤ parent`? | `zod.py:child_within_parent`, `l5/governance.py` | record |
| 10 | MCPGate | Is the specific tool call permitted? | `cain/mcp_proxy.py`, `cain_fabric_gate_42.py` | **BLOCK** |
| 11 | Execution | Does it run inside the confinement? | `cain45/confine.py`, `cain45/hypervisor.py:run` | **BLOCK** |
| 12 | Effect / postcondition | Did the claimed effect actually occur? | `mcp_proxy.py` postcondition checkers | record (`UNVERIFIED` without a checker) |
| 13 | Evidence | Is the causal chain sealed and signed? | `cain45/evidence.py`, WORM export | record (append-only) |
| 14 | Verification | Can a third party recompute it? | clean-room verifiers | operator-run |
| 15 | Recovery | Can trust/state be restored? | `authoritative_state.py:AuthoritativeRecoveryManager` | library |
| 16 | Trust update | Does experience change future trust? | `TemporalTrustEvaluator`, trust loop | library |

Blocking decisions are fail-closed: an error inside a gate is a `DENY` and a legacy `DENY` is never loosened
(`cain/mcp_proxy.py`, `platform-gateway/cain_fabric_gate_42.py`).

---

## 4. The twelve models

Each model below defines the concept, its invariants, the real modules that implement it, and its status.

### 4.1 Threat model

**Definition.** The explicit set of adversary and fault assumptions, and for each, what CAIN guarantees and
what it does not.

**Where.** `CAIN42_L5_THREAT_MODEL.md` (this evolution, Part 29), `CAIN45_THREAT_MODEL.md`,
`CAIN42_THREAT_MODEL.json`. Adversaries covered: honest nodes, Byzantine nodes, compromised agents,
compromised tools, malicious users, malicious delegated agents, compromised credentials, network partition,
replay, stale state, malicious policy, malicious model output, poisoned memory, poisoned context.

**Load-bearing invariant.** No control is claimed beyond its evidence; where a control is absent the model
says `OPEN` / `NOT_IMPLEMENTED`. `CAIN42_SELF_CRITIQUE.json` is the machine-readable self-audit that names
the weakest links (single host, zero validator diversity, caller-supplied identity, self-attested
manifest).

**Status:** working model, continuously corrected by the self-critique artifacts.

### 4.2 Trust model

**Definition.** Trust is evidence-derived, time-aware, domain-isolated state — never an LLM opinion, never a
single additive score.

**Mechanics** (`platform-gateway/cain_trust_kernel.py:TemporalTrustEvaluator`):
- Exponential half-life decay: `T(t) = T₀ · 2^(−Δt / t½)`, default half-life 24 h.
- Asymmetric update: a **positive** event is capped at `+0.05` (and further paced by a 60 s recovery
  interval); a **negative** event can drop as much as `−0.50`, with negative dominance (loss always outweighs
  recovery).
- Freshness window 5 minutes; domain/resource isolation (trust is not transferable across domains).
- Hysteresis thresholds prevent flip-flopping.

**Invariants.** Unknown/error never becomes trusted; a trust below the requirement yields
`TRUST_BELOW_THRESHOLD`; the authority ceiling is reduced by open system trust/evidence debt
(`cain_fabric_gate_42.py` `DebtLedger`).

**Status:** `TESTED` (`BASE-011`), deterministic; no live trust service reads. The 20-kernel-invariant
checker includes temporal decay (I13) and asymmetric recovery (I14) as structural predicates — these are
structural checks, not statistical guarantees.

### 4.3 Authority model

**Definition.** Authority is the bounded, externally governed permission for *this specific action under
these exact conditions for this period*. It is not a score, not a level, and not something an agent can
create.

**Components:**
- **Authority root** (`cain45/l5/authority.py:AUTHORITY_ROOT`): a domain-separated digest over **ten**
  governed state roots — `identity_state, policy_state, trust_state, quorum_state, delegation_state,
  resource_state, risk_state, trajectory_state, environment_state, certificate_state`. A missing state raises:
  an unknown state is never silently trusted.
- **Effective authority** (`effective_l5_authority`): a **minimum** over independently governed dimensions,
  never an additive sum. One failed mandatory condition can reduce authority to `DENY` or `REVALIDATE`.
- **Autonomy vector** (`cain45/l5/autonomy.py`): twelve dimensions (A1 TASK, A2 PLANNING, A3 TOOL,
  A4 EXECUTION, A5 DELEGATION, A6 MEMORY, A7 LEARNING, A8 RESOURCE, A9 RECOVERY, A10 SELF_MODIFICATION,
  A11 MULTI_AGENT, A12 ENVIRONMENTAL), each with `current ≤ maximum ≤ policy_ceiling`. There is **no single
  score**, because an agent may be L5 in task autonomy and L2 in self-modification autonomy.
- **Certificate** (`cain45/l5/certificate.py:AutonomyCertificate`): a signed, bounded, expiring statement
  about one action envelope; never perpetual. The published evidence bundle uses an **ephemeral** signing key
  and says so (`CAIN42_L5_EVIDENCE_BUNDLE.json:warning`).
- **Lease** (`AutonomyLease`): a short-lived grant of a single bounded task; renewal requires **external**
  authority and cannot self-renew.
- **Downgrade rules** (`authority.py:DEGRADE_RULES`, `downgrade`): deterministic, can only lower.
- **Emergency override** (`EmergencyOverride`): may only **restrict** (`READ_ONLY` / `QUARANTINED` /
  `STOPPED`); it can never grant authority.

**Denial reasons** are machine-readable (33 `Reason` values, e.g. `IDENTITY_UNVERIFIED`, `POLICY_CHANGED`,
`QUORUM_UNAVAILABLE`, `CERTIFICATE_TAMPERED`, `AUTHORITY_LEASE_EXPIRED`, `TRAJECTORY_DRIFT`,
`DELEGATION_EXCEEDS_PARENT`, `STALE_STATE`, `CLOCK_ROLLBACK`, `SELF_AUTHORIZATION_ATTEMPT`). The kernel never
returns a bare `DENIED`.

**Status:** `TESTED` library (`BASE-039`–`BASE-048`); not wired into the hosted path or the hypervisor.
The hosted authorization stage *is* live, but it is the fabric/hypervisor path, not the L5 kernel.

### 4.4 Delegation model

**Definition.** Authority may be divided among child agents but never created. A child is always a subset of
its parent.

**Invariants:**
- `CHILD_AUTHORITY ≤ PARENT_AUTHORITY` and `CHILD_SCOPE ≤ PARENT_SCOPE`, checked at issue time
  (`cain45/zod.py:child_within_parent`, `l5/governance.py`).
- The parent's budget is shared: a child that exhausts the parent's budget blocks the parent too
  (`cain45/economics.py`, hypervisor `_ancestor_problem`).
- Quarantining a parent cascades to children (`hypervisor.py:_cascade`; live evidence
  `e6-live-lease-2026-09-28` "delegating parent quarantined").
- Each running instance has its own identity/key; compromise of one instance authorizes nothing for another
  (`cain45/identity.py:AgentInstance`).
- `verify_delegation_chain` re-checks monotonic attenuation on the execution path
  (`platform-gateway/cain_trust_kernel.py`).

**Status:** `TESTED` (`BASE-022`, `BASE-015`-adjacent); not hosted. Collusion and delegation-drift detections
exist in the kernel (`CausalAuthorityGraphEngine`, `SELF_AUTHORIZATION_ATTEMPT`), but the delegation model's
guarantees are per-hop, not compositional (see the threat model).

### 4.5 Policy model

**Definition.** Policy is the per-tenant authority ceiling — which capabilities a Zone of Decision may ever
hold and the largest risk and blast-radius budgets it may be given. Policy changes are governed, not
written.

**State machine** (`cain45/governance.py`):
```
PROPOSED --validate/diff--> REJECTED | AWAITING_APPROVAL | APPROVED
AWAITING_APPROVAL --signed approval by a registered HUMAN != proposer--> APPROVED
APPROVED --live cluster commits the activation (quorum certificate verified)--> ACTIVE
```
- A **restriction-only** proposal (fewer capabilities, smaller budgets) needs no human: authority may always
  go down.
- An **expansion** needs a human approval over exactly that proposal, from someone other than the proposer
  ("self-improvement cannot self-authorize").
- Unknown fields and unknown capabilities are **refused at compile time** — "a field the compiler does not
  understand is refused."
- Activations are hash-chained per tenant and re-verified on every read; an unknown or broken chain is **no
  policy at all**, and the hypervisor then refuses.

**Status:** `VERIFIED` library on the gateway host (`BASE-021`), with live evidence
`e8-governance-2026-09-28` (human-approved activation committed by cluster `cain-mr-01`, sequence 16148). In
the hosted path the policy stage **records but does not block**.

### 4.6 Trajectory model

**Definition.** An agent's run is a hash-chained sequence of causal steps bound to one authorized trajectory.
Reordering, forking, substitution and gradual drift are detectable.

**Mechanics** (`cain45/trajectory.py`, `platform-gateway/cain_trust_kernel.py:CausalTrajectorySecurityEngine`):
- SHA-256 hash chaining: `Hₖ = SHA256(Hₖ₋₁ ‖ Event)`.
- Drift detection against a planned action set; a drift yields `TRAJECTORY_DRIFT` → `PAUSE` / `REVALIDATE`.
- **Salami defense:** cumulative sliding-window aggregation of spend and risk across many sub-threshold
  actions; exceeding the window trips `SALAMI_ATTACK` (`max_cumulative_cost_cents`, `max_cumulative_risk`).
- The trajectory identity is bound into the authorization certificate (`trajectory_root`, `_advance_trajectory`).

**Status:** `TESTED` (`BASE-018`); the trajectory firewall is **not wired into the hosted path**. The hosted
trajectory stage records, it does not block.

### 4.7 Execution model

**Definition.** Execution is the point where a decision becomes a real-world effect. It must be confined,
bounded and revocable.

**Mechanics** (`cain45/hypervisor.py`, `cain45/confine.py`):
- A Zone of Decision (ZoD) is a confined process tree: bubblewrap namespaces (new user/pid/ipc/uts/cgroup/
  **network**), no network interface but loopback, read-only root, tmpfs workspace, `uid 65534`, all
  capabilities dropped.
- cgroup v2 limits: `memory.max` (memory bombs killed), `pids.max` (fork bombs bounded), `cpu.max`, and a
  wall clock.
- Classic-BPF **seccomp** filter refuses escape syscalls with `EPERM` (mount, ptrace, keyctl, io_uring, perf,
  namespace creation, foreign-arch/x32). This is cBPF, **not eBPF**.
- `suspend` = `cgroup.freeze` (whole tree); `terminate` = `cgroup.kill` + persisted tombstone + revocation.
- The agent has exactly one channel out (the broker); tools are reachable only through the broker/MCPGate.

**Status:** confinement `VERIFIED` (`BASE-010`; `cain45-zod-live-2026-09-27`, `e7-seccomp-2026-09-28`, 8/8);
the hypervisor itself is `PRE_PRODUCTION` (a library the operator runs, not a hosted service). Namespace
confinement is kernel isolation, not a VM.

### 4.8 Evidence model

**Definition.** Every consequential decision and effect leaves a signed, append-only, causally linked record
that can reconstruct what happened.

**Mechanics:**
- `cain45/evidence.py`: `entry_hash = SHA256(canonical{domain, seq, prev_hash, at, zod_id, event, data})`;
  Ed25519 signature per entry; an **append-only high-water mark** so a truncated or rolled-back log fails
  verification (`EvidenceIntegrityError`).
- `platform-gateway/cain_trust_kernel.py`: 16-stage causal context, RFC 8785 canonical JSON, RFC 6962 binary
  Merkle root, Ed25519 node attestation.
- **Five-layer fact segregation:** `OBSERVED`, `VERIFIED`, `DERIVED`, `UNVERIFIED`, `SIMULATED`,
  `COUNTERFACTUAL` (`FactLayer`); `EXPECTED_EFFECT != OBSERVED_EFFECT → RECONCILIATION_REQUIRED`,
  `UNVERIFIED_PROOF != VERIFIED_PROOF`.
- WORM export for court-admissible records (`cain/worm_export.py`).

**Status:** `VERIFIED` (`BASE-016`); clean-room verifiers `IMPLEMENTED` (`BASE-017`); no third-party
reproduction.

### 4.9 Byzantine model

**Definition.** The consensus rules that let a small cluster agree on ordering despite up to `f` faulty
replicas, with safety prioritized over liveness.

**Parameters:** `n=4, f=1, q=2f+1=3`; `n ≥ 3f+1`; any two quorums intersect in `≥ f+1 = 2` members
(`CAIN42_QUORUM_MODEL.json`).

**Mechanics:**
- **Formal model:** `scripts/cain42_bft/formal_quorum_model.py` exhaustively enumerates quorums, Byzantine
  sets and small message traces to verify the quorum-intersection lemma, vote uniqueness and the commit
  rule — for the **rules**, not the implementation.
- **Verification:** `cain45/authoritative_state.py:verify_authoritative_certificate` rejects insufficient,
  forged, duplicated, unknown-member, stale-epoch/view, lineage-broken and cross-ZoD certificates; requires
  ≥ `min_quorum` distinct valid signatures over the exact body.
- **Ordering:** `cain45/hypervisor.py:authorize` requires a commit QC before a ZoD becomes `AUTHORIZED`;
  `cain45/consensus.py:configuration` recomputes membership from replica reports and requires ≥ quorum
  agreement.
- **Equivocation / view-change / flood defenses** and the PBFT engine live under `scripts/cain42_bft/`
  (`byzantine_boundary.py`, `byzantine_health.py`, `pbft_fuzz.py`, `multi_region_byzantine_test.py`, and the
  `pbft_tool.py` CLI).

**Where consensus is and is not used** — see `CAIN42_L5_THREAT_MODEL.md` §4. In short: consensus orders ZoD
authorizations, policy activations and hosted fabric decisions; it does **not** back the L5 library gate,
local trust scoring, evidence append, the quarantine kill-switch, or customer tool calls.

**Status:** `LIVE_PRODUCTION_OBSERVED` (two operator-run clusters), `VERIFIED` engine; operator-run, one
provider, one image digest — so the *cryptographic* BFT property holds for the rules while the *deployment*
gives no provider-level protection.

### 4.10 Containment model

**Definition.** The ability to stop an agent, a trajectory, a swarm or the whole fleet before it causes
further harm — fail-closed and evidenced.

**Mechanics:**
- Hypervisor containment: `suspend`, `revalidate`, `quarantine` (+ cascade to descendants), `terminate`;
  each is a logged state transition.
- `cain/quarantine.py:SwarmFleetQuarantine`: thread-safe in-memory cache synchronized with a durable **SQLite WAL** ledger, so
  containment is visible across worker processes and CLI invocations; a cluster-wide emergency kill-switch
  requires an authorization confirmation token.
- `cain/mcp_proxy.py:check_still_authorized` re-reads containment on every call; an error reading it is a
  **revocation**, never a pass.
- The kernel can execute autonomous interventions (`QUARANTINE_AGENT`, `QUARANTINE_TRAJECTORY`,
  `REVOKE_CAPABILITY_TOKENS`, `REQUIRE_DUAL_KEY_RECOVERY`) with signed immutable receipts.

**Status:** library `TESTED`; freeze/kill behavior `VERIFIED` in the escape suite (`test_cain45_escape.py`).

### 4.11 Verification model

**Definition.** A party other than the one who produced a decision can recompute it and detect tampering.

**Mechanics:**
- Clean-room verifiers deliberately omit CAIN imports: `scripts/cain42_bft/clean_room_verifier.py`,
  `independent_verifier_2.py`, `scripts/cain42_l5/verify_l5_bundle.py`.
- Per-bundle verifiers: `verify_pbft_qc_bundle.py`, `verify_e6_lease.py`, `verify_e7_lease.py`,
  `verify_e8_governance.py`, `verify_cain45_zod.py`, `verify_host_loss_bundle.py`,
  `verify_multi_region_bundle.py`, `verify_zod_replay.py`, and others under `scripts/cain42_bft/`.
- The published claims registry pins artifact hashes and re-computes them (`verify_claims.py`,
  `public_evidence_firewall.py`).
- The L5 bundle ships with a clean-room verifier that accepts the good bundle and rejects a tampered bundle
  and a tampered authority root (`tests/test_cain42_l5_soak_and_verifier.py`, 5 tests).

**Status:** `IMPLEMENTED`; L5 verification is `CLEAN_ROOM_LOCAL`. **No independent third party has ever
reproduced any of it** (`BASE-037` `NOT_IMPLEMENTED`). "Verified" in this repository means
*independently re-computable by the same operator*.

### 4.12 Conformance model

**Definition.** A machine-checkable matrix that decides whether the system may claim a given level. A single
mandatory failure blocks admission.

**Mechanics:**
- `CAIN42_L5_CONFORMANCE_MATRIX.json`: 22 PASS, 5 FAIL, 2 NOT_TESTED, 1 UNPROVEN; `l5_admitted: false`.
  Mandatory failures include: continuous authorization in the hosted path, real (non-scripted) long-horizon
  test, independent third-party verification, real LLM agent governed, caller-to-subject authentication,
  hardware root of trust, multi-provider/diverse validators, three-site claim sync.
- `CAIN42_L5_ACCEPTANCE_GATE.json`: 21 PASS / 3 partial / 24, `l5_production_claim: NONE`.
- `CAIN42_L5_BASELINE.json`: 48 capabilities with independent statuses; no category upgrades another.
- `CAIN42_L5_ATTACK_MATRIX.json`: 30 attacks, 24 executed at kernel level and passed, 6 `NOT_TESTED`
  (they need live infrastructure) — and `NOT_TESTED` is never recorded as PASS.
- Three-site reconciliation (`CAIN42_THREE_SITE_RECONCILIATION.json`) checks that the public sites agree
  with the cluster state root.

**Status:** `PARTIAL`. This is the model that keeps the other eleven honest.

---

## 5. The enforcement boundary: MCPGate

MCPGate is where a decision becomes physics. `cain/mcp_proxy.py:MCPTransparentInterceptor` intercepts
JSON-RPC `tools/call` messages.

**Ordered checks (all must pass; first refusal wins):**

1. **Legacy / default-deny** — a tool not on the allowlist and not otherwise authorized is held for
   approval, never silently allowed (`allowed_tools`, `CAIN_ALLOWED_ACTIONS`, fnmatch).
2. **Fabric gate** — `cain_fabric_gate_42.py:FabricGate.check`: the tool must be mapped; the resource must be
   safely derivable from arguments (path traversal / null byte / absolute-path smuggling → deny); an amount
   must be numeric; an identity must hold a non-revoked grant matching `(action, resource, amount)`;
   the trust ceiling must meet the risk requirement; open system debt lowers the ceiling; a durable action
   journal enforces idempotency and refuses replay or in-doubt effects. **The gate can only tighten a legacy
   `DENY`; any gate error is a `DENY`.**
3. **Consensus / containment** — `check_still_authorized` re-reads quarantine and kill-switch state.
4. **Identity binding / plan conformance** (opt-in CAIN-16) — if enabled, a valid runtime attestation is
   required, and if a plan is committed the call must conform to it.
5. **Continuous reauthorization** — mid-flight trust/context/trajectory changes suspend and block.
6. **Single-use token** — an `ALLOW` mints a JIT capability token with a nonce and microsecond-to-second TTL;
   a consumed nonce is rejected (`cain/jit_capability.py`).
7. **Postcondition** — the downstream result is `VERIFIED` only if a registered checker confirms it;
   otherwise `UNVERIFIED`; a downstream failure is `UNKNOWN`, never assumed absent.

**Evidence:** `clawx-site/evidence/mcpgate-live-2026-09-27/` — every call sent over HTTP through the MCPGate
proxy to a separate MCP server process; "forwarded" read from the server's own execution log. The manifest
explicitly lists what is **not claimed**: hosted gateway enforcing it for customers, a customer MCP server,
hardware attestation, independent operators, third-party review.

---

## 6. The L5 governance kernel

`cain45/l5/` (version `42.1.0`) is the clearest expression of the doctrine. It is a **library**, tested,
**not wired into the hosted path**.

| Module | Lines | Responsibility |
|---|---|---|
| `autonomy.py` | 239 | 12-dimension autonomy vector; `widen()` reports any dimension raised |
| `authority.py` | 179 | `authority_root` over 10 governed states; MIN-based effective authority; `Reason`; downgrade |
| `certificate.py` | 331 | signed bounded `AutonomyCertificate`; non-self-renewing `AutonomyLease`; restrict-only `EmergencyOverride` |
| `governance.py` | 383 | `L5AgentRegistry`, `L5AdmissionGate`, fail-closed `L5ExecutionGate`, change control, delegation |
| `invariants.py` | 216 | `check_all()` → I01–I20 executable invariants |
| `boundary.py` | 141 | **Ev2, tested (restriction-only), not hosted:** restriction-only bridge for hypervisor/MCPGate |
| `caller_auth.py` | 154 | **Ev2, tested (restriction-only), not hosted:** signed `CallerAssertion` binding caller→subject |
| `intent.py` | 130 | **Ev2, tested (restriction-only), not hosted:** canonical hash-chained `ActionIntent` |

**The execution gate** (`L5ExecutionGate.evaluate`) is fail-closed and returns a deterministic decision plus
machine-readable reasons. `ALLOW` requires identity, policy, certificate (present, unexpired, bound to the
authority root and policy root), lease (present, unexpired, scope-matching), trust ≥ requirement, a quorum
boolean + certificate, resource scope, risk ≤ ceiling, blast radius ≤ ceiling, trajectory, environment,
memory, world model, evidence state, and no clock rollback. Beyond `ALLOW`/`DENY`/`REVALIDATE` it produces
`PAUSE` (trajectory drift), `QUARANTINE` (no quorum), and `ESCALATE` (required autonomy level not permitted).
Every decision carries a `decision_digest`.

**I01–I20** (all hold in the unit tests; `CAIN42_L5_EVIDENCE_BUNDLE.json:invariants`): no valid identity /
policy / lease / unexpired lease / unrevoked lease / sufficient trust / sufficient quorum → no authority;
trajectory, tool, model, policy or memory change → revalidation; world-model uncertainty → risk reassessment;
`child ≤ parent` authority and scope; simulation / prediction / agent-consensus are not authority;
self-modification is not authorization; no current authority → no consequential execution.

**What the L5 kernel is not:** it is not a running governance service; its quorum is an input; its evidence
bundle is signed with an ephemeral key; and its Ev2 adapter modules have no tests and no consumer.

---

## 7. Live vs tested library vs simulated

### LIVE (observed; no customer traffic)
- Hosted `/fabric` enforce mode with 5 blocking stages (`CAIN42_TRUTH_REGISTRY.json`).
- Two PBFT clusters `cain-mr-01` / `cain-mr-02`, `n=4, f=1, q=3` (`LIVE_PRODUCTION_OBSERVED`).
- Public HTTP APIs (20/20 endpoints HTTP 200; `BASE-027`).

### VERIFIED (implemented and exercised, evidence re-runnable)
- Quorum certificate verification (`BASE-007`).
- Authority-lease lapse on 14 conditions (`BASE-009`): e6 9/9 PASS, e7 8/8 PASS; the truth registry records
  14 real trips refused and 3 injected.
- Confined execution / seccomp-BPF (`BASE-010`).
- MCPGate tool-call interception (`BASE-015`).
- Hash-chained Ed25519 evidence (`BASE-016`).
- Governed policy evolution (`BASE-021`), live e8.
- Published evidence bundles (`BASE-032`; 18/31 signed claims VERIFIED).

### TESTED library (real code path, tested, not deployed)
- L5 kernel: vector, authority root, certificate, leases, gate, registry, admission, change control,
  invariants, emergency override (`BASE-039`–`BASE-048`); 54 tests collected.
- Trust dynamics (`BASE-011`), trust kernel (`BASE-012`).
- Delegation attenuation, governed memory, world model, trajectory firewall, swarm/economics/stopping/tooling
  fabrics (`BASE-018`, `BASE-022`–`BASE-025`).
- Confinement libraries and the agent escape suite (`tests/test_cain45_escape.py`, 43 tests).
- Quarantine / kill-switch.

### SIMULATED
- Long-horizon autonomy: 1000 scripted sessions in seconds (`BASE-034`,
  `CAIN42_E14_LONG_HORIZON.json`).
- The L5 soak runs in-process (`mode=SIMULATED_IN_PROCESS`, `live=false`,
  `scripts/cain42_l5/l5_soak.py`).
- World-model predictions (`BASE-024`, authority `NONE`).
- eBPF profiles, where referenced in older material, are simulated — the live filter is seccomp-BPF.

### NOT_IMPLEMENTED / OPEN
- Hardware root of trust (`BASE-035`).
- Multi-provider diversity (`BASE-036`).
- Independent third-party review (`BASE-037`).
- Caller-to-subject authentication **on the hosted path** (`BASE-013`).
- MCP-server identity binding / tool-poisoning closure (OPEN in `CAIN45_THREAT_MODEL.md`).

---

## 8. Module reference map

| Concern | Module |
|---|---|
| Trust kernel / 16-stage context / temporal trust / salami | `platform-gateway/cain_trust_kernel.py` |
| Hosted decision recording / stages / approvals / kill-switch | `platform-gateway/fabric_control_plane.py` |
| Enforcement boundary (MCP JSON-RPC) | `cain/mcp_proxy.py` |
| Fabric authority gate | `platform-gateway/cain_fabric_gate_42.py` |
| Agent Hypervisor / Zone of Decision | `cain45/hypervisor.py` |
| Process confinement (bwrap/cgroup/seccomp) | `cain45/confine.py` |
| Authoritative state machine + quorum certificates | `cain45/authoritative_state.py` |
| Consensus client / membership | `cain45/consensus.py`, `platform-gateway/cain_mr_client.py` |
| Governed policy evolution | `cain45/governance.py` |
| Governed memory | `cain45/memory.py` |
| World model | `cain45/world_model.py` |
| Trajectory | `cain45/trajectory.py` |
| Identity (agent/instance/human/service/tool) | `cain45/identity.py` |
| Canonical serialization / keys / signatures | `cain45/canon.py` |
| ZoD spec / capabilities / attenuation | `cain45/zod.py` |
| Swarm / tool / economics / stopping fabrics | `cain45/swarm.py`, `tooling.py`, `economics.py`, `stopping.py` |
| Evidence log | `cain45/evidence.py` |
| Quarantine / kill-switch | `cain/quarantine.py` |
| JIT capability tokens | `cain/jit_capability.py` |
| L5 governance kernel | `cain45/l5/` |
| Byzantine/PBFT lab, formal model, verifiers | `scripts/cain42_bft/` |
| L5 artifact builder / soak / verifier | `scripts/cain42_l5/` |
| Tests | `tests/test_cain42_l5_*.py`, `tests/test_cain45_*.py`, `platform-gateway/tests/` |

---

## 9. Evidence bundles

| Bundle | Proves | Limits (from the bundle itself) |
|---|---|---|
| `e6-live-lease-2026-09-28` | 9 authority-lapse conditions refused, 0 tools ran after the trip; decisions verified against the live cluster | chain-derived / one self-reported; operator-run |
| `e7-lease-2026-09-28` | policy / membership / epoch / risk / blast-radius lapses; 8 conditions PASS | membership/epoch change **injected**, not re-keyed |
| `e7-seccomp-2026-09-28` | seccomp-BPF refuses escape syscalls, 8/8, live authority | cBPF not eBPF; operator-asserted |
| `e8-governance-2026-09-28` | human-approved policy activation committed by live cluster; 8 cases PASS | library on gateway host |
| `cain45-zod-live-2026-09-27` | ZoD authorized by live cluster, confined, terminated | operator-run |
| `mcpgate-live-2026-09-27` | real MCP calls through MCPGate, live QC per call | sandbox MCP server; not customer calls; declared attestation |
| `e7-replay-2026-09-28` | independent replay of every published ZoD bundle | **21/22 match, 1 divergence reported** |
| `e7-bench-2026-09-28` | authority-path benchmark (Evo7 Phases 33/34) | conditions stated |

All bundles are mirrored under `clawx-site/evidence/` and `platform-gateway/frontend/proof/bundle/`, and the
public inventory is `CAIN42_PUBLIC_EVIDENCE_INVENTORY.json`.

---

## 10. What is NOT guaranteed

1. **No production L5.** The L5 kernel is a `TESTED` library; `l5_admitted: false`; not wired to the hosted
   gateway or hypervisor. CAIN-42 is not claimed to be L5.
2. **No third-party verification.** All clean-room verification is same-operator (`BASE-037`).
3. **No provider-level or host-level fault tolerance.** One provider (Vultr); `cain-mr-01` puts 2 of 4
   replicas on one host; historic deployment was one host.
4. **No implementation diversity.** All validators run one image digest.
5. **No hardware root of trust.** No TPM/TEE/SGX/TDX/SEV; attestation is a declared hash.
6. **No caller-to-subject authentication on the hosted path.** Caller-supplied agent/session/tenant strings
   are trusted (`BASE-013`); the untracked, unwired, untested `caller_auth.py` does not change the live
   posture.
7. **No defense against `f ≥ 2` Byzantine replicas or a compromised operator/key.**
8. **No defense against host root or a kernel exploit** inside a ZoD; confinement is kernel isolation, not a
   VM.
9. **No prompt-injection content firewall.** Injection is neutralized as an authority input, not as an
   influence on what is requested.
10. **No semantic correctness.** CAIN bounds authority, not the quality of a decision.
11. **No live LLM agent governed** and no live long-horizon test (mandatory FAIL / SIMULATED).
12. **No multi-process single-use guarantee.** Anti-replay / JIT caches are in-memory; restarts can re-admit
    a token within TTL.
13. **No head-pinned memory rollback defense.** `cain45/memory.py` has no head pinning; the unpinned-head
    family was 0% contained in the lab.
14. **No guarantee of availability under ≥2 simultaneous replica faults** (fail-closed is intended, but
    availability is not promised).
15. **No live epoch re-keying proof** (membership/epoch invalidation used an injected change).
16. **No reliable hosted blocking for policy/risk/intent/verification/approval** — those stages record, they
    do not block.
17. **No MCP-server identity binding / tool-poisoning closure.**
18. **No exact evidence replay.** 21/22 matched; 1 divergence is disclosed.
19. **No published signed claims for the L5 Evolution-2 modules** (`boundary.py`, `caller_auth.py`,
    `intent.py`): untracked, unwired, untested.

---

## Appendix A — status vocabulary

From `CAIN42_L5_BASELINE.json`: `LIVE_PRODUCTION_VERIFIED`, `LIVE_PRODUCTION_OBSERVED`, `VERIFIED`,
`TESTED`, `IMPLEMENTED`, `PARTIAL`, `SIMULATED`, `SHADOW`, `PRE_PRODUCTION`, `UNVERIFIED`, `SUPERSEDED`,
`NOT_IMPLEMENTED`.

Interpretation used here:
- **LIVE** — runs in production and was observed. No customer traffic is claimed.
- **VERIFIED** — implemented and exercised, with re-runnable evidence.
- **TESTED library** — real code path exercised by tests on this host, but not deployed.
- **IMPLEMENTED** — code exists but the verification level is lower than VERIFIED.
- **SIMULATED** — in-process model, not production.
- **NOT_IMPLEMENTED / OPEN** — not there.

## Appendix B — reproducibility

- Build L5 artifacts: `scripts/cain42_l5/build_l5_artifacts.py`.
- L5 tests: `pytest tests/test_cain42_l5_constitution.py tests/test_cain42_l5_soak_and_verifier.py`
  (54 collected).
- L5 clean-room verification: `scripts/cain42_l5/verify_l5_bundle.py` → `VALID`.
- Confinement escape suite: `pytest tests/test_cain45_escape.py` (43 tests).
- Evidence bundles ship a `REPRODUCE.txt` and a verifier per bundle under `scripts/cain42_bft/`.
- Public inventory: `CAIN42_PUBLIC_EVIDENCE_INVENTORY.json`; claims: `CAIN42_PUBLIC_CLAIMS_MATRIX.json`.
