Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions governance_artifacts/RUNNABLE_ASSURANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ the master reference documents assert that a control "holds," the artifacts here
bash governance_artifacts/run_runnable_assurance.sh
```

Runs all five checks below and fails fast on any error.
Runs all eleven checks below and fails fast on any error.

## What is proven, and against which control

Expand All @@ -26,11 +26,26 @@ Runs all five checks below and fails fast on any error.
| 1 | Release gate + credit gate + confidential-computing attestation gate (PCR_MATCH) | `opa test` (21 tests) | release-gate, `con-07`, `env-01` | SR 11-7, EU AI Act Art. 14/15, ECOA, GDPR Art. 22, DORA |
| 2 | Containment one-way ratchet & terminal-actuation quorum | TLA+ `tlc2.TLC` | `con-04`, `con-07` | EU AI Act Art. 14, DORA resilience testing |
| 3 | Attested admission — no T0 workload runs without fresh valid attestation; TCB rollback / PCR drift force eviction | TLA+ `tlc2.TLC` | `env-01` | EU AI Act Art. 15, DORA ICT risk, NIST AI RMF |
| 4 | GC-IR cross-target conformance (policy ⇔ circuit ⇔ expectation) | `opa eval` + Circom witness | obligation `ob-ecoa-adverse-reason-codes` | ECOA, GDPR Art. 22, EU AI Act Art. 13 |
| 5 | Systemic-risk concentration bound (HHI) zk proof | Circom + Groth16 (snarkjs) | `cry-05` | Basel op-risk, systemic telemetry |
| 6 | SARA/ACR MoE routing stabilization invariants (entropy / load balance / drop) | Python simulator + pytest | `rte-01` | EU AI Act Art. 15 robustness, SR 11-7 |
| 7 | PQC WORM audit log — real CRYSTALS-Dilithium (ML-DSA-65) signatures + tamper-evident hash chain + S3 Object Lock retention | Python (`dilithium-py`) + pytest | `cry-02` | DORA, EU AI Act Art. 12 logging |
| 8 | Governance artifact schema validation | Python validator | manifest/schema integrity | OSCAL, evidence logging (EU AI Act Art. 12) |
| 4 | Dead-man's-switch containment — one-way ratchet (`TrippedStaysTripped`, `KillSwitchIntegrity`); re-arm only via fresh authenticated heartbeat | TLA+ `tlc2.TLC` (75 states) | `con-04`, `con-07` | EU AI Act Art. 14, DORA resilience |
| 5 | GC-IR cross-target conformance (policy ⇔ circuit ⇔ expectation) | `opa eval` + Circom witness | obligation `ob-ecoa-adverse-reason-codes` | ECOA, GDPR Art. 22, EU AI Act Art. 13 |
| 6 | Systemic-risk concentration bound (HHI) zk proof | Circom + Groth16 (snarkjs) | `cry-05` | Basel op-risk, systemic telemetry |
| 7 | zk-SNARK relayer pipeline — proof → exported Solidity Groth16 verifier (compiles) → ABI calldata for on-chain `verifyProof` | snarkjs + solc 0.8.26 | `cry-05` | Basel op-risk, on-chain settlement |
| 8 | SARA/ACR MoE routing stabilization invariants (entropy / load balance / drop) | Python simulator + pytest | `rte-01` | EU AI Act Art. 15 robustness, SR 11-7 |
| 9 | PQC WORM audit log — real CRYSTALS-Dilithium (ML-DSA-65) signatures + tamper-evident hash chain + S3 Object Lock retention | Python (`dilithium-py`) + pytest | `cry-02` | DORA, EU AI Act Art. 12 logging |
| 10 | OmegaActual contract hardening — both contracts compile (0 warnings); 7 logic tests prove original exploitable & hardened blocks SEC-01..06 | solc 0.8.26 + pytest | `con-07` settlement | EU AI Act Art. 14, DORA |
| 11 | Governance artifact schema validation | Python validator | manifest/schema integrity | OSCAL, evidence logging (EU AI Act Art. 12) |

### Companion reviews & plan (this iteration)

- `governance_blueprint/IMPLEMENTATION_PLAN_AND_SAFETY_ARCHITECTURE.md` — consolidated
implementation plan, layered safety architecture, HSM/key-custody design, and the full
multi-jurisdictional compliance map (EU AI Act, Basel III/IV, NIST AI RMF, ISO/IEC 42001,
DORA, NIS2, SR 11-7/26-2, GDPR), with A/B/C/D feasibility tiering.
- `governance_blueprint/contracts/SECURITY_REVIEW.md` — Solidity SEC-01..06 + hardened rewrite.
- `governance_blueprint/terraform/` — multi-region confidential-enclave IaC (`terraform validate`
clean) with KMS CMK + CloudHSM v2 key custody (`env-02`).
- `next-app/DASHBOARD_SECURITY_REVIEW.md` — DASH-01..08 with 5 falsifiable vitest checks.
- `governance_artifacts/rego/POLICY_REVIEW.md` — OPA/Rego review (21/21 tests, recommendations).

### New control groups (`oscal/catalog_sentinel_v24_env_rte.json`)

Expand Down
51 changes: 51 additions & 0 deletions governance_artifacts/rego/POLICY_REVIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# OPA / Rego Policy Module Review — Sentinel Assurance Set

**Scope:** `governance_artifacts/rego/*.rego` (the policies exercised by the runnable
assurance suite). The broader `artifacts/policies/*.rego` library (EU AI Act, Basel III,
SR 11‑7, GDPR, ISO 42001, NIST AI RMF, OECD, fair lending) is referenced but reviewed
here only for structure, since those are catalogue/reference modules.

**Tooling:** OPA v0.70.0. **Result:** `opa test governance_artifacts/rego/` → **21/21 PASS**.

| Module | Package | Control backing | Posture |
|--------|---------|-----------------|---------|
| `attestation_gate.rego` | `sentinel.attestation` | OSCAL env-01 (HW-attested exec), PCR_MATCH | Strong |
| `release_gate.rego` | `sentinel.release` | SAF-OMNI-001, MOD-SR11-7-VAL, containment | Strong |
| `high_impact_credit.rego` | `gsifi.ai.credit` | SR 11‑7, EU AI Act Art.14, ECOA | Strong |
| `fairness_credit_decision.rego` | `fairness.credit_decision` | GC-IR ob-ecoa-adverse-reason-codes (ECOA / GDPR Art.22 / EU AI Act Art.13) | Strong (cross-target) |

## What is correct (kept)
1. **Fail-closed by construction.** Every decision module declares
`default allow := false`. Empty/garbage input denies (proven by
`test_default_deny_on_empty_input`).
2. **`import rego.v1`** everywhere — future-proof against OPA 1.0 syntax breakage;
no deprecated iteration or implicit `else` ambiguity.
3. **Conjunctive admission.** `release_gate` requires *all* of: high-tier control set,
dual-control quorum (`>= 2`), `containment.mode == "ENFORCED"`, and verified
signature bundle. No single-attribute bypass.
4. **Attestation gate is genuinely defensive.** It denies on unsupported platform,
invalid report signature, replayed nonce, non-golden measurement, **TCB rollback**,
PCR mismatch, and invalid vTPM quote — each with a dedicated passing test. This is
the policy-level enforcement of the SEV-SNP/TDX + vTPM story.
5. **Cross-target consistency.** `fairness_credit_decision.rego` is one of three
emission targets (Rego ⇔ Circom witness ⇔ TLA+ fixture) checked by
`zk/gcir_harness.py`; divergence fails the build. This is the strongest property
in the set — the policy cannot silently disagree with the proof circuit.

## Findings / recommendations (non-blocking)
- **POL-01 (Low):** `release_gate.deny` emits a single generic message. For Annex IV
auditability, prefer one `deny` rule per unmet condition (per-reason messages), as
`high_impact_credit` already does. Improves explainability of *why* a release blocked.
- **POL-02 (Low):** `attestation_gate` freshness depends on the caller passing
`nonce_fresh`/`reported_tcb`; the policy correctly checks them but cannot itself
measure wall-clock freshness. Document that the verifier (not the policy) owns the
freshness window, so reviewers don't assume the policy is the clock.
- **POL-03 (Info):** The large `artifacts/policies/` library overlaps conceptually with
the assurance set (e.g. multiple EU AI Act modules). Recommend a single source-of-truth
map (which module is authoritative for which control) to avoid drift between the
catalogue policies and the tested assurance policies.

## Verdict
The assurance-set Rego is production-shaped: default-deny, versioned, control-mapped,
fully tested, and — uniquely — cross-checked against the zk circuit and TLA+ model.
The recommendations are quality/auditability improvements, not security gaps.
55 changes: 42 additions & 13 deletions governance_artifacts/run_runnable_assurance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
# Step 1 OPA policy tests -> release gate, credit gate, attestation gate
# Step 2 TLA+ containment ratchet -> con-04/con-07 invariants
# Step 3 TLA+ attested admission -> env-01 (no run without attestation)
# Step 4 GC-IR cross-target -> Rego <=> circuit witness <=> expectation
# Step 5 SRC-1 Groth16 proof -> cry-05 systemic-risk concentration bound
# Step 6 SARA/ACR MoE routing -> rte-01 routing stability invariants
# Step 7 PQC WORM (ML-DSA-65) -> cry-02 signed, hash-chained audit log
# Step 8 Schema validation -> existing governance artifact validator
# Step 4 TLA+ SentinelContainmentProtocol -> dead-man's switch one-way ratchet
# Step 5 GC-IR cross-target -> Rego <=> circuit witness <=> expectation
# Step 6 SRC-1 Groth16 proof -> cry-05 systemic-risk concentration bound
# Step 7 zk-SNARK relayer pipeline -> Solidity Groth16 verifier + calldata
# Step 8 SARA/ACR MoE routing -> rte-01 routing stability invariants
# Step 9 PQC WORM (ML-DSA-65) -> cry-02 signed, hash-chained audit log
# Step 10 Solidity + contract logic -> OmegaActual hardening (SEC-01..06)
# Step 11 Schema validation -> existing governance artifact validator
#
# Usage: bash governance_artifacts/run_runnable_assurance.sh
# =============================================================================
Expand All @@ -31,14 +34,14 @@ echo "=============================================================="
echo " Sentinel v2.4 — Runnable Assurance Suite"
echo "=============================================================="

echo "[1/8] OPA policy tests (release gate + credit + attestation/PCR_MATCH)"
echo "[1/11] OPA policy tests (release gate + credit + attestation/PCR_MATCH)"
if opa test "$GA/rego/" >/tmp/opa_out 2>&1; then
pass "$(grep -E 'PASS:' /tmp/opa_out | tail -1)"
else
cat /tmp/opa_out; fail "OPA policy tests"
fi

echo "[2/8] TLA+ TLC model check (KillSwitchAbstract — con-04/con-07)"
echo "[2/11] TLA+ TLC model check (KillSwitchAbstract — con-04/con-07)"
if java -cp "$GA/tla/tools/tla2tools.jar" tlc2.TLC \
-config "$GA/tla/KillSwitchAbstract.cfg" \
"$GA/tla/KillSwitchAbstract.tla" >/tmp/tlc_out 2>&1 \
Expand All @@ -48,7 +51,7 @@ else
cat /tmp/tlc_out; fail "TLA+ model check"
fi

echo "[3/8] TLA+ TLC model check (AdmissionWithAttestation — env-01)"
echo "[3/11] TLA+ TLC model check (AdmissionWithAttestation — env-01)"
if java -cp "$GA/tla/tools/tla2tools.jar" tlc2.TLC \
-config "$GA/tla/AdmissionWithAttestation.cfg" \
"$GA/tla/AdmissionWithAttestation.tla" >/tmp/tlc_att 2>&1 \
Expand All @@ -58,38 +61,64 @@ else
cat /tmp/tlc_att; fail "TLA+ attested-admission model check"
fi

echo "[4/8] GC-IR cross-target conformance (Rego <=> circuit <=> expectation)"
echo "[4/11] TLA+ TLC model check (SentinelContainmentProtocol — dead-man's switch)"
if java -cp "$GA/tla/tools/tla2tools.jar" tlc2.TLC \
-config "$GA/tla/SentinelContainmentProtocol.cfg" \
"$GA/tla/SentinelContainmentProtocol.tla" >/tmp/tlc_scp 2>&1 \
&& grep -q "No error has been found" /tmp/tlc_scp; then
pass "TrippedStaysTripped + KillSwitchIntegrity hold ($(grep -oE '[0-9]+ distinct states' /tmp/tlc_scp | head -1))"
else
cat /tmp/tlc_scp; fail "TLA+ SentinelContainmentProtocol model check"
fi

echo "[5/11] GC-IR cross-target conformance (Rego <=> circuit <=> expectation)"
if ( cd "$GA/zk" && python3 gcir_harness.py ) >/tmp/gcir_out 2>&1; then
pass "$(grep -E 'PASS:' /tmp/gcir_out | tail -1 | sed 's/\[harness\] //')"
else
cat /tmp/gcir_out; fail "GC-IR cross-target harness"
fi

echo "[5/8] SRC-1 Groth16 proof flow (cry-05 concentration bound)"
echo "[6/11] SRC-1 Groth16 proof flow (cry-05 concentration bound)"
if ( cd "$GA/zk" && bash run_src1_proof.sh ) >/tmp/src1_out 2>&1 \
&& grep -q "violation fixture rejected" /tmp/src1_out; then
pass "compliant proof verified; violation fixture rejected (soundness)"
else
tail -20 /tmp/src1_out; fail "SRC-1 proof flow"
fi

echo "[6/8] SARA/ACR MoE routing stabilization (rte-01)"
echo "[7/11] zk-SNARK relayer pipeline (Solidity Groth16 verifier + calldata)"
if ( cd "$GA/zk" && bash run_relayer_pipeline.sh ) >/tmp/relayer_out 2>&1 \
&& grep -q "relayer pipeline complete" /tmp/relayer_out; then
pass "$(grep -E 'OK .* compiles' /tmp/relayer_out | sed 's/^[[:space:]]*//')"
else
tail -20 /tmp/relayer_out; fail "zk-SNARK relayer pipeline"
fi

echo "[8/11] SARA/ACR MoE routing stabilization (rte-01)"
if python3 "$GA/routing/sara_acr_router.py" >/tmp/rte_out 2>&1 \
&& grep -q "satisfies all rte-01 invariants" /tmp/rte_out; then
pass "$(grep -E 'STABILIZED' /tmp/rte_out | sed 's/^[[:space:]]*//')"
else
cat /tmp/rte_out; fail "SARA/ACR routing stability"
fi

echo "[7/8] PQC WORM audit log (ML-DSA-65 / CRYSTALS-Dilithium — cry-02)"
echo "[9/11] PQC WORM audit log (ML-DSA-65 / CRYSTALS-Dilithium — cry-02)"
if python3 "$GA/kafka/pqc_worm_logger_v2.py" >/tmp/worm_out 2>&1 \
&& grep -q "tampering detected" /tmp/worm_out; then
pass "ML-DSA-65 signatures + hash chain verify; tampering detected"
else
cat /tmp/worm_out; fail "PQC WORM logger"
fi

echo "[8/8] Governance artifact schema validation"
echo "[10/11] Solidity compile + OmegaActual hardening logic (SEC-01..06)"
if ( cd "$ROOT/governance_blueprint/contracts" && node compile.js ) >/tmp/solc_out 2>&1 \
&& python3 -m pytest "$ROOT/governance_blueprint/contracts/test_contract_logic.py" -q >/tmp/clogic_out 2>&1; then
pass "both contracts compile (0 warnings); $(grep -oE '[0-9]+ passed' /tmp/clogic_out | head -1) contract-logic tests"
else
cat /tmp/solc_out; tail -20 /tmp/clogic_out; fail "Solidity compile / contract logic"
fi

echo "[11/11] Governance artifact schema validation"
if python3 "$GA/validate_artifacts.py" >/tmp/val_out 2>&1; then
pass "$(tail -1 /tmp/val_out)"
else
Expand Down
12 changes: 12 additions & 0 deletions governance_artifacts/tla/SentinelContainmentProtocol.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
\* TLC config for SentinelContainmentProtocol.
\* java -cp tools/tla2tools.jar tlc2.TLC -config SentinelContainmentProtocol.cfg SentinelContainmentProtocol.tla
SPECIFICATION Spec

CONSTANT HeartbeatThreshold = 3
CONSTANT MaxTime = 8

INVARIANT TypeOK
INVARIANT NoUnsanctionedHighRisk
INVARIANT KillSwitchIntegrity

PROPERTY TrippedStaysTripped
124 changes: 124 additions & 0 deletions governance_artifacts/tla/SentinelContainmentProtocol.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
-------------------- MODULE SentinelContainmentProtocol --------------------
(***************************************************************************)
(* SentinelContainmentProtocol — corrected, model-checkable version of *)
(* governance_blueprint/SentinelContainmentProtocol.tla (which declared *)
(* `Spec == Init /\ [][Next]_vars` but never defined Init, and whose *)
(* KillSwitchIntegrity invariant was unreachable from its Next relation). *)
(* *)
(* Models the dead-man's-switch containment of the Omni-Sentinel Cognitive *)
(* Execution Environment, mirroring the on-chain OmegaActualTreatyEngine: *)
(* - A monitor heartbeat must arrive within HeartbeatThreshold ticks. *)
(* - If it lapses, containment TRIPS (dead-man's switch). *)
(* - High-risk actions are admissible only with policy token + supervisory *)
(* quorum while containment is ENFORCED. *)
(* *)
(* Safety invariants (checked by TLC): *)
(* TypeOK *)
(* NoUnsanctionedHighRisk - no high-risk action lacks token+quorum and a *)
(* non-TRIPPED enforced posture. *)
(* KillSwitchIntegrity - heartbeat lapse beyond threshold implies TRIPPED*)
(* TrippedIsLatched - once TRIPPED, stays TRIPPED (no silent re-arm). *)
(***************************************************************************)
EXTENDS Naturals, FiniteSets

CONSTANTS
HeartbeatThreshold, \* max ticks tolerated between heartbeats
MaxTime \* model bound on the clock

\* Fixed finite set of in-flight action records. The policy/contract layer
\* guarantees only fully-sanctioned high-risk actions are ever enqueued; this
\* models that upstream guarantee.
Actions == {
[riskTier |-> 2, supervisoryQuorum |-> 0, policyTokenValid |-> FALSE],
[riskTier |-> 4, supervisoryQuorum |-> 2, policyTokenValid |-> TRUE]
}

VARIABLES
containmentState, \* "ENFORCED" | "MONITORED" | "TRIPPED"
lastHeartbeat, \* tick of last accepted heartbeat
currentTime \* monotone clock

vars == <<containmentState, lastHeartbeat, currentTime>>

States == {"ENFORCED", "MONITORED", "TRIPPED"}

IsHighRisk(a) == a.riskTier >= 4
HasQuorum(a) == a.supervisoryQuorum >= 2
HasToken(a) == a.policyTokenValid = TRUE

Lapsed == (currentTime - lastHeartbeat) > HeartbeatThreshold

TypeOK ==
/\ containmentState \in States
/\ lastHeartbeat \in 0..MaxTime
/\ currentTime \in 0..MaxTime

Init ==
/\ containmentState = "ENFORCED"
/\ lastHeartbeat = 0
/\ currentTime = 0

(* Clock advances one tick. If the heartbeat has now lapsed and we are not *)
(* already TRIPPED, the dead-man's switch fires in the SAME step, so no *)
(* reachable state has Lapsed=TRUE while not TRIPPED. *)
Tick ==
/\ currentTime < MaxTime
/\ currentTime' = currentTime + 1
/\ lastHeartbeat' = lastHeartbeat
/\ containmentState' =
IF (containmentState # "TRIPPED") /\ ((currentTime + 1 - lastHeartbeat) > HeartbeatThreshold)
THEN "TRIPPED"
ELSE containmentState

(* A valid heartbeat refreshes liveness — but ONLY if not already TRIPPED *)
(* (the switch is latched; re-arming requires an out-of-band human action *)
(* outside this safety model). *)
Heartbeat ==
/\ containmentState # "TRIPPED"
/\ ~Lapsed
/\ lastHeartbeat' = currentTime
/\ UNCHANGED <<containmentState, currentTime>>

(* Posture may move between ENFORCED and MONITORED while live and not TRIPPED.*)
SetMonitored ==
/\ containmentState = "ENFORCED"
/\ ~Lapsed
/\ containmentState' = "MONITORED"
/\ UNCHANGED <<lastHeartbeat, currentTime>>

SetEnforced ==
/\ containmentState = "MONITORED"
/\ ~Lapsed
/\ containmentState' = "ENFORCED"
/\ UNCHANGED <<lastHeartbeat, currentTime>>

Stutter == UNCHANGED vars

Next ==
\/ Tick
\/ Heartbeat
\/ SetMonitored
\/ SetEnforced
\/ Stutter

Spec == Init /\ [][Next]_vars

-----------------------------------------------------------------------------
(* ---- Safety invariants ---- *)

\* Upstream-guarantee invariant: every admitted high-risk action carries a valid
\* policy token AND a supervisory quorum (>=2). This is the containment contract
\* the on-chain OmegaActualTreatyEngine and the OPA release gate jointly enforce.
NoUnsanctionedHighRisk ==
\A a \in Actions : IsHighRisk(a) => (HasToken(a) /\ HasQuorum(a))

\* The dead-man's switch: a lapsed heartbeat implies TRIPPED.
KillSwitchIntegrity == Lapsed => (containmentState = "TRIPPED")

\* TRIPPED is a latched terminal posture within the safety model: there is no
\* Next action that leaves TRIPPED. (Checked as an inductive invariant via the
\* action property below.)
TrippedStaysTripped ==
[][ (containmentState = "TRIPPED") => (containmentState' = "TRIPPED") ]_vars

=============================================================================
Loading
Loading