# CAIN-42 — Evolution 01: Byzantine Governance Kernel — Report

## A. What existed before
E20–E26 governance primitives (canonical state, verifiable transitions, state-bound execution,
single-use permits, authority conservation, distributed settlement, control loop), the prior
`cain/frontier` kernel/ABI, the live gateway with E23 SHADOW + E26 canary, 20 Frontier products, and a
large legacy service/codebase. Authority models were spread across several modules with partly
overlapping representations.

## B. What was changed
Added `cain/govkernel/` — one canonical ABI + action model that **reuses** the existing primitives
(imports E20 canon, E21 quorum certificate shape, E22 permits, E25 delegation) rather than
reimplementing them. No existing test was removed; no security control weakened.

## C. What is genuinely new
- A single **canonical governed-action identity** (`GovernedAction`) whose digest binds identity,
  action, parameters, resource scope, policy version, trust epoch, risk, governance epoch and
  model/tool identity.
- An **authorization object cryptographically bound to that exact action**, verified fail-closed.
- A **canonical governed-action state machine** with guards on EXECUTED/QUORUM/PERMIT.

## D. New architectural primitives
`AgentIdentity, ResourceScope, Capability, ModelToolIdentity, Intent, TrustState, RiskState,
PolicyDecision, Authority, QuorumDecision, Delegation, Revocation, CausalLink, EvidenceRecord,
GovernanceEvent, TenantBoundary, GovernedAction, Authorization, GovernanceStateTransition` — as
immutable, canonically-serializable dataclasses with stable digests.

## E. New security properties (verified)
Stale, replayed, revoked, scope-expanded, parameter-mutated, policy-invalidated, epoch-invalid,
trust-stale, wrong-signature and model/tool-substituted authorizations **all fail closed**; the
executor is never called on denial (`tests/govkernel`, 26/26).

## F. New Byzantine properties
Quorum decisions are bound into the authorization hash; an insufficient/invalid quorum fails closed
(INV-06). A Byzantine replica cannot unilaterally produce a valid quorum decision because the
authorization commits to the quorum certificate hash.

## G. New formal invariants
INV-01…INV-12 implemented as executable runtime checks (12/12 PASS). Labelled **runtime checks**, not
formal proofs. A TLA+ model of the state machine is a recommended next step (not claimed).

## H. New tests
`tests/govkernel/test_govkernel.py` — 26 tests: happy path, 12 fail-closed cases, state-machine
guards, determinism, invariants, clean-room verifier positive + negative.

## I. New measurable performance
Kernel gate latency is recorded per run in `GOVKERNEL_GATE_RESULTS.json`. Baseline-vs-post-kernel
arena benchmarking is **NOT_MEASURED** in this pass (labelled as such).

## J. New evidence
`artifacts/govkernel/` — `GOVKERNEL_GATE_RESULTS.json`, `GOVKERNEL_INVARIANTS.json`,
`AUTHORIZATION_PROOF.json`, `GOVKERNEL_EVIDENCE_BUNDLE.json`; clean-room verifier
`verification/govkernel/cleanroom/verifier.py` (zero CAIN imports).

## K. New reproducibility cost
The extra barrier is modest but real: a competitor must reproduce the **canonical action digest**,
the **binding checks**, the **state machine guards**, and the **clean-room verifier** consistently.

## L. Potentially defensible IP concepts
Canonical action-identity binding; fail-closed authorization covering the full tuple; governed-action
state machine with quorum/permit guards. (See `docs/ip/CAIN42_PATENT_CANDIDATES.md`.)

## M. Existing prior-art risks
BFT/PBFT, Merkle proofs, capability tokens and two-phase commit are well-known; the candidate is the
**composition + canonical binding**. Prior-art search required.

## N. Remaining limitations
- No TLA+ model yet (runtime checks only).
- Performance baseline NOT_MEASURED.
- Kernel not yet wired into the live request path as the canonical authority boundary (E23 SHADOW +
  E26 canary remain the live surfaces).
- Migration of the legacy duplicated authority representations is **partial** — a full migration to
  the canonical model is Evolution 02 work.

## O. What should become EVOLUTION 02
1. Wire the kernel as the live canonical authorization boundary (feature-flagged), migrating the
   legacy authority paths.
2. Add a TLA+ model of the governed-action state machine + invariants.
3. Baseline-vs-kernel performance benchmark (latency/throughput/memory) and failure-mode comparison.
4. Complete the migration of duplicated authority models to the canonical ABI, with compatibility
   shims and regression proof.
