# EVOLUTION7_POLICY_SEMANTICS.md

**Module:** `cain/action_commit/policy.py` · **Domain:** `CAIN42/ACTION-COMMIT/POLICY-SET/v1`

## Semantics

A `PolicySet` is a versioned, digest-committed tuple of `PolicyRule`s with a `default` (CAIN uses `DENY`). A rule matches
an action when every non-`*` selector matches (glob), requested capabilities ⊆ rule capabilities, `risk_class ≤ max_risk`,
`delegation_depth ≤ max_delegation_depth`, and the environment matches. Evaluation is **total and deterministic**:
- no matching rule → `DENY` (`DEFAULT_DENY`)
- among matches, highest priority wins; at equal priority **DENY dominates** (fail closed)
- `require_approval` raises an obligation that a bound approval must discharge

An LLM is never the final authority. `Decision` carries `outcome, reason, rule_id, policy_version, policy_digest` plus a
`ref_digest()` a verifier can commit to.

## Bounded static analysis (`DeterministicPolicyEngine.analyze`)
Detects: missing default-deny, duplicate rule ids, potential contradiction (same priority, overlapping selectors,
opposite effect), shadowed rules, low-priority capability grants, excessive delegation depth, tenant-crossing grants.
It is explicitly **a bounded analysis, NOT a formal proof**; absence of findings is not absence of risk.

## Known semantics gaps vs. FORGE
- No recursion / transitive closure (FORGE's `Supervises` example is not expressible here).
- No assume/guarantee correctness theorem.
- Equivalent-canonical-action consistency is checked structurally, not by query containment.
