# Architecture: Governance Contract Fabric (IP Evolution 1)

```
            agent (holds Ed25519 key registered in RIG)
              │  consent sig over fingerprint, invocation PoP per use
              ▼
┌──────────────────────── GovernanceContractFabric (per tenant, SQLite WAL) ────────────────────────┐
│ draft ─ propose ─ validate/compile ─ authorize ─ activate ─ invoke ─ revoke / expire / supersede   │
│   │                      │              │                     │                                   │
│   │ RIG snapshot         │ risk score   │ RIG chain covers?   │ decide() — pure, replayable       │
│   │ policy digest        │ conditions   │ issuer Ed25519 sig  │ decision receipt (same tx)        │
│   │ env digest           │ plan digest  │                     │ adapter.execute → outcome receipt  │
└───┼──────────────────────┼──────────────┼─────────────────────┼───────────────────────────────────┘
    ▼                      ▼              ▼                     ▼
  RIG (authority)    (closed operator  RIG again          OpenShell │ MemVault │ SCITT
                      set)                                (exec)      (memory)   (evidence + receipt log)
                                                                      │
                                       every decision/outcome receipt ┴──► SCITT RFC 9162 log (signed checkpoint)

 offline: contract_verify_offline.py (0 CAIN imports) — re-derives fingerprint, signatures, structure, risk and every
 decision from an export; tests diff it against the runtime on 400 mutated decisions.
```

Where it sits in the 7-moat doctrine (no new moat; it extends existing ones):

| Moat | What the fabric adds |
|---|---|
| 2: Security-Context Continuity | identity, authority, policy, environment and model digests carried in one signed object from issue to execution |
| 4: Execution Provenance | decision and outcome receipts bound to the exact request, with replay |
| 1: Trust State | the authority snapshot digest at each decision |

Module: `platform-gateway/cain_governance_contract.py`, about 1.3k non-blank lines.

The engines are injected, so the gateway can pass its tenant-bound instances from `cain_frontier_tenancy.engine(...)`.
Adapters call only the products' public methods:

| Adapter | Calls |
|---|---|
| OpenShell | `execute_sandboxed_command`, `get_policy` |
| MemVault | `inspect_and_guard_write`, `search_similar` |
| SCITT | `register_statement`, `notary_public_keys` |
| RIG | `get_agent` |

Defence in depth is preserved. A contract ALLOW still runs through each product's own checks: OpenShell argument and
path vetting, MemVault injection detection and quarantine. Tests confirm that OpenShell still refuses `cat /etc/shadow`
under a contract that allows `cat`.
