# IP Evolution 10: Continuous Governance Attestation

**Date:** 2026-10-04 · **Status:** PRE-PRODUCTION. Library + CLI + clean-room verifier. Not routed, not deployed, not published.

**Scope:** the Governance Contract Fabric over RIG, OpenShell, MemVault and SCITT, plus the code that decides for it. The 30-day four-product directive applies, so the other 16 Frontier-20 products are out of scope. Their status for every E10 capability is **UNSUPPORTED**.

## 1. Forensic baseline: what was already enforced

`decide()` (`platform-gateway/cain_governance_contract.py:765`) re-checks the following live state on **every** invocation. Each one ends in a receipted DENY:

| Drift | decide() reason |
|---|---|
| identity key substituted | `IDENTITY_SUBSTITUTION` |
| RIG chain revoked, missing or unavailable | `AUTHORITY_REVOKED` / `AUTHORITY_UNKNOWN_AGENT` / `AUTHORITY_UNAVAILABLE` |
| any ancestor narrower than the contract | `AUTHORITY_AMPLIFICATION` |
| declared model/runtime digest changed | `MODEL_SUBSTITUTION` |
| python minor, machine or adapter set changed | `ENVIRONMENT_DRIFT` |
| product policy digest changed | `POLICY_DRIFT` / `POLICY_UNAVAILABLE` |
| governance epoch bumped | `STALE_EPOCH` |

E10 does not duplicate any of these.

## 2. Gaps found (measured, not assumed)

| # | Gap | Evidence |
|---|---|---|
| G1 | **Decision-path code drift is invisible at runtime.** Changing decide(), RIG, the forecast gate, the quorum or a product engine leaves every ACTIVE contract ALLOWing. | `test_decision_code_change_hits_every_live_contract_and_e7_proofs` (the old contract still ALLOWs after the code digest changes) |
| G2 | **E7 proof coverage is partial.** At the time of writing, no E7 property depends on `contract_forecast`, `contract_keys`, `contract_quorum`, `openshell` or `memvault`. `openshell` (d8a5ab1) and `scitt` (72ee3df) changed after E7 (8fd9a82), and E7 still reports VALID. | `results/proof_coverage.json`, `results/detect_since_e7.json`, `results/e7_status.json`. The E7 owner (session -2b) is adding the three product engines to `TEMPORAL_TRACE_PROPERTIES`. decide() itself does not call forecast, quorum or the engines, so its conformance proof is unaffected. |
| G3 | **The store is trusted for lifecycle state.** Setting a REVOKED contract back to `ACTIVE` in SQLite makes decide() ALLOW again. | `test_terminal_contract_resurrected_in_store_is_contained_although_decide_would_allow`. The transition chain is MAC'd, but nothing checks it at invoke time. E10 detects the resurrection against the envelope. |
| G4 | **Policy direction is unknown to decide().** A restrictive OpenShell change and an expanding one both produce `POLICY_DRIFT`. An operator re-issuing contracts cannot tell which kind happened. | `policy_change_direction` and its tests |
| G5 | **Evidence regression is not checked.** Deleting receipts or transitions, or rolling back the epoch, is not detected by decide(). | `test_evidence_deletion_is_contained`, `test_epoch_rollback_is_contained` |

## 3. What was built

`platform-gateway/cain_governance_attestation.py`:

- **Governance BOM.** Covers 13 governance-relevant source files, each with a SHA-256, an AST digest (docstrings stripped) and a role: decision, execution, evidence, verification or compiler. It also records critical dependency versions (`cryptography`, `z3-solver`, python, sqlite), the E7 proof status and an explicit `not_covered` list. It is **not** SPDX or CycloneDX.
- **Agent BOM.** Records identity, the RIG chain, the model digest (labelled **DECLARED**, because CAIN never sees the model), contracts with their bodies, the semantic product policy, code, dependencies, the environment, and evidence counters including E8 health.
- **Fingerprint.** 11 per-dimension digests plus a composite digest. The composite is documented as integrity of the representation only, not truth.
- **Change detector.** Classifies changes using the 14-class taxonomy:
  - Equal AST with different bytes is **COSMETIC**.
  - Any other change to decision-path code is **SECURITY_RELEVANT + UNKNOWN_IMPACT**. Code semantics are not analysed here; that is the job of the E4 differential and E7.
- **Authority-expansion detector.** Uses witness points at every scope boundary. It separates **EXPLICIT** expansion (the subject's own record widened) from **IMPLICIT** expansion (an ancestor widened, a policy loosened, or the epoch rolled back).
- **Impact analysis.** Reports DIRECT, POTENTIAL and UNKNOWN impact on contracts, agents, tenants and E7 properties, with a migration plan: continue / reverify / reissue / revoke / remain blocked.
- **Change policy.** Each dimension gets `LOCK`, `REVERIFY` or `ALLOW_RESTRICTIVE`. A floor applies under every policy:
  - CRITICAL or UNAUTHORIZED changes always lead to CONTAIN.
  - UNKNOWN changes and any expansion never lead to CONTINUE.
- **Envelope.** An Ed25519-signed envelope with a validity window of 60 s to 30 days. It records L3 only if the E7 proofs are VALID; otherwise L2.
- **assess().** Returns CONTINUE / REVERIFY_REQUIRED / CONTAIN / UNKNOWN with the worst severity per dimension. Nothing is averaged. Containment is *recommended* as exact fabric calls and never executed.
- **rollback_check().** A rollback cannot restore revoked agents, terminal contracts, a lower epoch, retired notary keys, dropped evidence, or code on a known-bad list.
- **AttestationLog.** Append-only and hash-chained, with signed statements and no mutation API.
  - `continuous_level` gives L4 only for an unbroken window of CONTINUE attestations at L3.
  - L5 additionally needs an independent verification flag.
- **EnvelopeGuard.** An opt-in wrapper that calls `fab.invoke` only while the envelope assessment is CONTINUE. It is **not wired into any route.**

Supporting files:

- `scripts/attestation_verify_offline.py`: clean-room verifier with zero CAIN imports.
- `scripts/cain_attest.py`: read-only CLI with `bom`, `coverage`, `proofs` and `detect --base REF`.
- `scripts/bench_governance_attestation.py`: the benchmark.

## 4. Tests

`tests/test_governance_attestation.py` (109) and `tests/test_governance_attestation_cleanroom.py` (18): **127 passed, 0 failed** (`results/junit.xml`).

They run against the real RIG, OpenShell, MemVault and SCITT engines and the real fabric in temp dirs. Tamper tests edit the SQLite stores directly, which is the attacker model.

The prompt's targets (2,000+ per category, about 25,000 in total) were **not met and not pursued**. Parametrised permutations were kept only where each case exercises a different rule.

## 5. Security acceptance gate (§46), in scope only

| Path | Status |
|---|---|
| silent authority expansion | DETECTED: explicit and implicit, CONTAIN. decide() also denies RIG amplification. |
| tenant escape | decide() denies `TENANT_MISMATCH`; the BOM is tenant-filtered (test). Cross-tenant comparison is CRITICAL. |
| stale authorization | decide() handles epoch and expiry; E10 envelope expiry leads to REVERIFY. |
| unverified runtime continuation | DETECTED by E10 (G1). **ENFORCED only through the opt-in EnvelopeGuard. The live route is NOT guarded.** |
| model substitution | decide() denies; E10 locks the model dimension by default. Model is DECLARED only. |
| dependency substitution | DETECTED for named critical deps only. Transitive and OS dependencies are NOT covered. |
| policy weakening | decide() denies; E10 classifies the direction. |
| proof invalidation | DETECTED through E7 status, plus code digests for E7-unproven components (G2). |
| evidence deletion | DETECTED (counter regression, E8 faults). Not prevented: it is an SQLite file. |
| rollback of revoked authority | `rollback_check` blocks it (tests). |
| compiler / verifier substitution | DETECTED by digest; requires reverification against known answers. |
| hidden execution-boundary bypass | **OPEN.** E10 sees only the fabric path. Direct OpenShell/MemVault routes that bypass contracts are outside it. |
| fail-open on critical failure | The assessment never returns CONTINUE on error or UNKNOWN (tests). |

## 6. Performance (single host, 4 vCPU, `results/bench.json`)

**Real stores, one contract per agent:**

| Agents | agent_bom p50 | agent_bom p99 | assess p50 | Full sweep |
|---|---|---|---|---|
| 10 | 2.3 ms | — | 9.7 ms | — |
| 100 | 3.9 ms | — | — | 0.6 s |
| 1,000 | 13 ms | 76 ms | 15 ms | 16 s |

- **Profiled bottleneck (fixed):** `_contracts` parsed every contract body in the tenant for each agent, which was 74% of the time. It now filters with `json_extract` in SQLite. The 1,000-agent sweep went from 37 s to 16 s.
- **Remaining cost:** per-agent RIG and E8 reads.
- **Not measured:** 10,000 and 100,000 agents with real stores. Setup alone would take hours on this host.

**Pure, in memory:**

- Fingerprinting costs about 0.25–0.3 ms per agent; 100,000 agents take 28 s and about 2 GB RSS.
- Detection on an unchanged BOM costs about 20 µs.
- assess() costs about 1.5 ms, most of it the Ed25519 envelope check and re-fingerprinting.

## 7. Limitations

- Code semantics are not analysed. A non-cosmetic change is UNKNOWN_IMPACT until E7 is re-run and the E4 differential compares the versions.
- The authority witness method assumes RIG-normalised prefix scopes. E7's CX-E7-001 shows raw scopes break `_scope_within`.
- The model is DECLARED. CAIN has no model attestation.
- There is no behavioural drift detection (§21), canary or blue/green (§22–23), patch compiler (§27), incident engine (§25), Studio UI (§37) or SDK surface (§38).
- Nothing is continuous yet: no scheduler runs assess(), and no attestation key is provisioned on the server.

## 8. IP and engineering value (not a valuation)

**Engineering replacement, for this evolution alone:** about 1 senior engineer for 1–2 weeks, given the existing fabric. It reuses E1/E2 contract primitives, E2 `diff_intelligence`, E7 `check_artifact`, and the RIG chain semantics.

The value is in the integration, not the size. It is the only component that joins decision-path code identity, proof freshness and live contract state into one signed, offline-verifiable statement.

**Candidate novel mechanisms (for counsel; patentability is not claimed):**

1. Envelope assessment that separates explicit from implicit authority expansion across a delegation chain, using scope-boundary witnesses.
2. A proof-coverage map that flags decision-path components no formal property depends on, so a proof can be VALID while the code it governs has changed.
3. A rollback admissibility check that keeps irreversible security state (revocations, terminal contracts, the epoch, evidence counts) across code rollback.

The $100K–$10M+ scenarios in the prompt are **not supported** by this evolution on its own.
