# CAIN HERMES — Governance Compiler

`cain/hermes/compiler.py`.

```
ORGANIZATIONAL INTENT → GOVERNANCE SPEC → SEMANTIC POLICY GRAPH → AUTHORITY GRAPH →
ENFORCEMENT PLAN → TARGET-RUNTIME POLICIES → COVERAGE GRAPH → VERIFICATION → GOVERNANCE CERTIFICATE
```

## Behaviour

- For each rule, lowers to per-target controls using the declared `enforcement_targets`.
- Builds the **authority graph** (per subject: actions, resources, tightest budget, delegation depth, ceiling).
- Runs **cross-target semantic preservation** per rule.
- Builds a **coverage proof** per rule and the aggregate **coverage graph**.
- Produces a deterministic `plan_digest` and a signed coverage certificate (when a key is given).
- `verification` reports weakened rules and critical gaps.

## Determinism

Compiling the same spec twice yields the same `plan_digest` (P135).

## Adapters

MCP, A2A, HTTP, CAIN_AUTHORITY, EFFECT_CONTRACT, APPROVAL (see `HERMES_ARCHITECTURE.md` for boundaries). Each
adapter declares its enforcement point, implementation, observability source and boundary. A target that is not
requested is simply absent — visible as a coverage gap, never hidden.

## Non-goals

The compiler **never grants authority**. It lowers intent to controls and produces proofs; the CAIN decision path
and MCPGate still enforce at runtime.

## Status

IMPLEMENTED, TESTED. Kubernetes/cloud-IAM/OpenShell/database adapters: DESIGN / NOT IMPLEMENTED.
