# CAIN-42 Top-100 Remediation Log

Real, evidence-backed hardening done product by product. Each entry records the defect
found, the fix, the tests, and the honest grade change. Grades are re-derived from
evidence; no label is assigned that the code and tests do not support, and the A+++/A++++
requests remain declined (see `FRONTIER_20_FINAL_GRADES.md` and `AGENTS.md`).

---

## #1 — Meta-Verification Engine (`platform-gateway/cain_meta_verification.py`)

- **Defect 1:** `test_replay_cache_integrity()` was tautological — it asserted a key it had
  just inserted into a local dict, so it could never fail and verified nothing.
  → now drives the real MCP-boundary primitive `cain.mcp_proxy._consume_capability_nonce`
  and fails closed if it is unavailable.
- **Defect 2:** `run_meta_verification()` called `sha256("".join(sorted(digests)))` a
  "merkle_root" — a flat hash, not a tree. → real RFC 6962 Merkle Tree Hash.
- **Added:** live read-only endpoint `GET /api/v4/kernel/meta-verification`;
  16 dedicated tests (`tests/test_meta_verification_engine.py`).
- **Grade: B- → B.** Remaining: deploy the endpoint (gateway restart), publish an evidence
  bundle, third-party verification.
- Detail: `CAIN42_TOP1_META_VERIFICATION_REMEDIATION.md`.

---

## #8 — Independent Verifier (`platform-gateway/cain_independent_verifier.py`)

- **Defect (real, reproduced):** malformed nested passport fields raised `AttributeError`
  out of `verify_passport()` (→ HTTP 500) instead of returning a fail-closed verdict:
  - `subject_identity = "not-an-object"` → `'str' object has no attribute 'get'`
  - `validity_period = "soon"` → same
  - `issuer_identity = "nope"` → same
  A hostile or buggy caller could therefore turn a verification into a server error rather
  than a clean `INVALID`.
  → added structural guards returning `INVALID` with `MALFORMED_*` errors.
- **Checked, not a defect:** the RFC 6962 `compute_rfc6962_merkle_root()` implementation
  matches an independent recursive reference for n = 1..17 — no change made.
- **Checked, flagged, not changed:** `verify_causal_chain([])` returns `VALID`
  ("trivially valid"). This is contradicted by a hard rule in the enforcement-total
  doctrine, but it is a *documented contract* exercised by
  `tests/test_cain_trust_kernel_3.py::test_primitive_api_all_14_primitives_operational`.
  Changing it broke that contract, so it was reverted and documented instead. A future,
  deliberate change should update the primitive contract and the test together.
- **Added:** 12 adversarial/regression tests
  (`tests/test_independent_verifier_hardening.py`), including a positive signed-passport
  path, untrusted-key rejection, payload-tamper detection, malformed-field fail-closed,
  RFC 6962 reference equivalence, and unsigned/expired/NaN PCAA tokens.
- **Grade: B+ → A-.** It is on the live kernel-API path and is now hardened; the only
  remaining gap to A is independent third-party verification.

---

## #6 — Trust Runtime Kernel (`platform-gateway/cain_trust_kernel.py`)

- **Defect (documented in `AGENTS.md`, reproduced):** `FormalTrustKernelInvariantChecker`
  reported skipped checks as `satisfied=True`. With the optional inputs omitted, invariants
  8 (authority widening), 11 (expired authorization) and 12 (replay) were returned as
  satisfied without being exercised, so a run could read as **26/26** when only 23 checks ran.
  Two related live-surface issues: `kernel_health` hardcoded `formal_invariants_active: 20`
  while the engine enforces 26.
  → added `FormalInvariantResult.applicable` (default True, backward compatible) and
  `FormalTrustKernelInvariantChecker.summarize()`, which reports
  `applicable / passed / failed / not_applicable` and never counts a skipped check as passed.
  Marked invariants 8/11/12 not-applicable when their inputs are omitted.
  Single-sourced the count via `INVARIANT_COUNT = 26`; `kernel_health` now reports it.
- **Checked, not changed:** `FormalInvariantResult.satisfied` stays True for skipped checks
  so existing callers (`sum(r.satisfied …)`, conformance protocol) are unaffected.
- **Added:** 8 tests (`tests/test_trust_kernel_invariant_honesty.py`) proving the skipped
  checks are not counted as passed, that all 26 are applicable when inputs are supplied, and
  that widening / expired-capability / replayed-nonce each genuinely trip their invariant.
- **Grade: A- (unchanged).** The kernel was already at the A- ceiling; this closes a latent
  honesty defect rather than changing the letter. No third-party verification exists, so it
  cannot rise to A.

---

## #21 — CAIN‑45 Agent Hypervisor (`cain45/hypervisor.py`)

- **Defects (reproduced):** malformed caller input raised out of the hypervisor instead of
  producing an evidenced `Denied` — a boundary that errors on crafted input is not
  fail-closed (no `DENIED` record is written and the caller sees a server fault, not a refusal):
  - `authorize(zod, None, …)` → `AttributeError: 'NoneType' object has no attribute 'get'`
  - `authorize(zod, [], …)` → `AttributeError: 'list' object has no attribute 'get'`
  - `authorize(…, approval="x")` → `AttributeError`
  - `grant(zod, "EXECUTE_CODE", None)` → `TypeError: expected string or bytes-like object`
  - `run(zod, "not-a-grant", …)` / `call_tool` → `AttributeError` (reachable from the public doors)
  → added type guards that emit a clean, hash-chained `DENIED`: decision/approval must be
  objects; grant must be an object; capability/resource/tool must be strings; argv must be a
  list of strings; tool arguments must be an object.
- **Checked, not a defect:** the RFC-style runtime checks (consensus-certificate binding,
  grant non-transferability, budget cascade, trajectory continuity, clock high-water mark,
  cascade quarantine) were already present and correct.
- **Added:** 6 tests appended to `tests/test_cain45_hypervisor.py` (the existing suite for
  this component) covering each malformed-input path and asserting the refusal is recorded
  as evidence.
- **Grade: A- (unchanged).** Already at the ceiling; hardened against a real fail-open class.

---

## #42 — E39 World-Bound Authorization (`cain/govreality/authorize.py`)

- **Defects (reproduced):** a crafted PAAO raised out of the safety governor instead of returning
  `BLOCK` — `{"key":"posx"}` (no type) → `KeyError: 'type'`; `{"type":"fact_within",...}` with no key
  → `KeyError: 'key'`; `{"type":"fresh",...}` with no keys → `KeyError: 'keys'`. A signed world body
  with a malformed fact also raised. A safety governor that throws on crafted input returns no
  verdict at all.
  → `evaluate_conditions` now fails closed (`MALFORMED_CONDITION:*`): non-mapping conditions are
  rejected, the per-condition dispatch is guarded, and `fact_ok` validates that a fact is a mapping
  with a well-formed `safety_hull`.
- **Added:** 11 tests (`tests/test_e39_world_bound_authorization.py`) — this module had **no**
  dedicated test module. Covers valid allow, malformed conditions, unknown condition type,
  malformed fact, out-of-hull condition, PAAO tamper, and expired grant.
- **Grade: B+ → A-.** It is on the live path and now tested and hardened.

---

## #58 — Zero-Trust Kernel Self-Defense (`platform-gateway/cain_kernel_self_defense.py`)

- **Defects (reproduced):**
  - `add_approval(..., signature_b64=<invalid base64 or None>)` raised `binascii.Error`/`TypeError`
    — the base64 decode sat **outside** the verification `try`, so a malformed approval crashed
    the dual-custody engine instead of raising `SecurityInvariantViolation`.
  - `create_proposal(parameters={... non-JSON ...})` (a set / `NaN` / bytes) raised
    `TypeError`/`ValueError` out of `canonical_json_bytes`.
  - `audit_event_chain([1, 2, 3])` raised `AttributeError: 'int' object has no attribute 'get'`.
  → `add_approval` now validates and decodes inside the guarded block (`validate=True`);
  `create_proposal` rejects non-canonical parameters; `audit_event_chain` reports malformed
  events as errors and fails closed.
- **Added:** 10 tests appended to `tests/test_cain_kernel_self_defense.py`.
- **Grade: B+ → A-.**

---

## #57 — The Authority Ledger (`cain/acp/ledger.py`)

- **Finding:** the deterministic replicated state machine is genuinely hardened — fuzzing all 38
  transition kinds × malformed bodies found **no** escaping exception (handlers reject malformed
  input via `Reject`/SchemaError/KeyError/TypeError). The residual gap: `apply()` documents
  *"Never raises on bad input"* and `evaluate()` *"UNKNOWN never allows"*, but both caught only a
  narrow exception set. A handler raising an unlisted type (`AttributeError`, `IndexError`, …) would
  escape, and on a replicated state machine an exception is a divergence / halt risk.
  → added a catch-all `except Exception` to both (`REJECTED` / `DENY` with `MALFORMED`), so the
  documented guarantee is actually enforced and any residual fault fails closed, never allows.
- **Added:** a fuzz regression test (`tests/acp/test_acp_ledger.py`) asserting `apply()` never raises
  across all kinds × malformed bodies, plus a positive-path check.
- **Grade: B+ → A-.** Live on the path; now the never-raises guarantee is real, not just intended.

---

## #56 — Continuous Governance Attestation (`platform-gateway/cain_governance_attestation.py`)

- **Defect (reproduced):** `assess()` — the function that decides CONTINUE / REVERIFY_REQUIRED /
  CONTAIN for an agent against its verified envelope — raised on a malformed *current* BOM instead of
  returning a verdict. 11/11 malformed inputs escaped: `{}` → `KeyError: 'agent_id'`;
  `{"authority":"x"}` → `TypeError: string indices must be integers`;
  `{"identity":None}` → `TypeError: 'NoneType' object is not subscriptable`; `{"code":[]}` →
  `AttributeError: 'list' object has no attribute 'get'`; and more. An attestation engine with no
  verdict on an unparseable state is not fail-closed.
  → split `assess` into a thin fail-closed wrapper over `_assess`, with `_malformed_assessment()`
  returning a deterministic **CONTAIN** (level 0, `grants_authority: False`, signed
  `assessment_digest`, reason `MALFORMED_CURRENT_STATE`). The valid path still returns CONTINUE.
- **Added:** 13 tests appended to `tests/test_governance_attestation.py` (10 malformed-current cases,
  positive path, and digest recomputation).
- **Grade: B+ → A-.**

---

## #59 — Governance Conformance Engine (`platform-gateway/cain_governance_conformance.py`)

- **Defect (reproduced):** `verify_log()` — a public verifier reachable at
  `routers/governance_assurance.py` and used by the clean-room verifier — **raised** on a malformed
  log instead of returning problems. 6/6 crafted logs escaped: `{"entries":None}` → `TypeError`,
  `{"entries":"abc"}` → `TypeError: string indices must be integers`, `{"entries":[1,2]}` →
  `TypeError: 'int' object is not subscriptable`, `{"entries":[{}]}` → `KeyError: 'result'`,
  `result=None` → `AttributeError`. Worse, a missing/empty `entries` list returned `[]`, which the
  route renders as **"chain intact, every entry signed"** — a fail-open.
  → `verify_log()` now fails closed: non-mapping log → `MALFORMED:log`; missing/non-list `entries` →
  `MALFORMED:entries`; a non-object or incomplete entry → `MALFORMED_ENTRY:N`; each entry body is
  wrapped so no malformed entry can escape. `verify_result()` already had this guard.
- **Also hardened:** `import_sdk_report()` now rejects a non-object report / non-list checks with a
  clean `ValueError` instead of crashing.
- **Added:** 14 tests to `tests/test_governance_assurance_cleanroom.py`.
- **Grade: B+ → A-.**

---

## #44 — E13 Clean-Room BPF Governance Verifier (`verification/govbpf/verify_e13.py`)

- **Defect (reproduced, severe):** the verifier did not validate the quorum `threshold` it took from
  genesis. `qc_ok` returns `len(seen) >= t`, so **threshold 0** makes the quorum check trivially true,
  and the checkpoint quorum `len(signed) >= threshold` is likewise trivially true. A bundle with
  `{"threshold": 0}`, **no replicas, no events, no signatures, no checkpoint** verified as **INTACT** —
  a clean-room verifier accepting a forgery, the exact class this repo has been fixing.
  → `verify_dir` now validates genesis explicitly: `replicas` a non-empty mapping and `threshold` an
  integer in `1..len(replicas)`, else PROBLEMS; `events` must be a list. `main` also wraps `verify_dir`
  so a malformed/unreadable bundle is a clean PROBLEMS (exit 1), never a traceback.
- **Evidence-immutability note:** the published `e13-bpf-governance-execution-2026-10-05` bundle embeds
  the *pre-fix* verifier (`verify_e13.py.txt`) and is covered by its `bundle_hashes.json`. It was **not
  rewritten** (evidence is superseded, never edited). The fixed verifier is captured, with its hash, in
  the `top100-remediation-2026-10-07` bundle; that supersedes it.
- **Added:** 9 tests to `tests/govbpf/test_govbpf.py`, including a positive check that the real
  published bundle (threshold 3 of 4 replicas) still verifies INTACT.
- **Grade: B+ → A-.**

---

## #34 — PBFT-E4 DAG Dissemination (`platform-gateway/cain_pbft_dag.py`)

- **Defect (reproduced):** `Vertex.from_dict` did `int(d["batch_size"])` / `float(d["created_at"])`
  without a finiteness check. JSON permits `Infinity`/`NaN`, and `int(inf)` raises **OverflowError**,
  which is *not* a `ValueError` — so it escaped the `except (ValueError, TypeError, KeyError)` clauses
  of `verify_availability_certificate` and `verify_equivocation_evidence`. A Byzantine peer could send
  a crafted availability certificate (`batch_size: Infinity`) and **crash the DAG verifier**.
  → `Vertex.from_dict` now requires `batch_size`/`created_at` to be finite numbers (rejecting bools),
  and both verifiers catch `Exception`, so a malformed vertex/certificate is refused, never an escape.
- **Added:** 8 tests to `tests/test_cain42_pbft_evolution4_dag.py`.
- **Grade: B+ → A-.**

---

## #36 — Trust Kernel Primitive API (`platform-gateway/cain_trust_kernel_api.py`)

- **Defect (reproduced):** the 14 primitives are on the live request path but did not guard their
  inputs, so malformed JSON raised out of the API instead of returning a FAILED receipt:
  `reconstruct(None)`/`reconstruct(123)` → `TypeError: not subscriptable`; `record({1,2})` →
  `TypeError: set is not JSON serializable`; `verify("PASSPORT", None)` → `AttributeError: 'NoneType'
  object has no attribute 'get'`; `enforce(None,...)` → `AttributeError`; `update_trust(..., nan/inf)`
  returned `UPDATED` with a non-finite severity.
  → added a `_bad()` helper; `verify`/`enforce`/`attest`/`record` require objects, `record` requires
  canonical JSON, `reconstruct` coerces/validates `incident_id`, `update_trust` requires a finite
  severity. All now return `PrimitiveReceipt(..., "MALFORMED_INPUT", False, ...)`.
- **Also fixed (completes #8):** the Independent Verifier still crashed on a non-object top-level
  target (`verify_passport(None)`, `verify_causal_chain("x")`, `verify_pcaa(None,...)`) — #8 had
  guarded nested fields but not the top-level type. Now each returns INVALID.
- **Added:** 3 tests to `tests/test_cain_trust_kernel_3.py`, 1 to `tests/test_independent_verifier_hardening.py`.
- **Grade: B+ → A-.**

---

## #15 / #16 — E25 Universal Machine Agency Fabric (`cain45/l5/agency_fabric.py`)

- **Defect (reproduced):** the fabric's engine methods take a `UniversalAgencyEnvelope` by contract,
  but a caller that passed anything else crashed with `AttributeError` instead of a verdict:
  `authorize(None)`/`authorize({})`, `evaluate(None)`, `snapshot(None)`, `current(None)`,
  `facts(None, None)` all raised `'NoneType'/'dict' object has no attribute ...`. The policy decision
  path likewise: `UniversalPolicyCompiler.evaluate(None, {})` and `evaluate({"ir": None}, {})` raised
  `TypeError`; `diff(None, None)` raised `TypeError`.
  → `authorize`/`evaluate` now return a signed **DENY** (`ENVELOPE_MALFORMED`) for a non-envelope;
  `snapshot`/`current`/`facts` return `{}`; `UniversalPolicyCompiler.evaluate` returns
  `{"effect": "deny", "reasons": ["POLICY_MALFORMED"]}` and `diff` raises `PolicyError` for a
  malformed compiled policy. Valid envelopes are unchanged (still ALLOW).
- **Added:** 3 tests + 5 parametrized cases to `tests/test_cain42_e25_agency.py`.
- **Grade (both listings #15 and #16): B+ → A-.**

---

## #89 — Standalone DAG-Bundle Verifier

- **Defect:** the verifier's `verify_bundle()` accessed `b["membership"]`, `b["nodes"]`, … directly
  and `main()` had no guard, so a malformed bundle produced a traceback instead of a verdict;
  `verify_cert` caught only `(KeyError, TypeError, ValueError)`.
- **Evidence-immutability constraint:** the verifier lives inside the **signed** published bundle
  `mcpgate-live-2026-09-27`, whose signed `manifest.json` covers its SHA-256. It was therefore **not
  edited in place** (verified: the file is byte-identical to the manifest hash). The hardened,
  superseding copy is published at `verification/mcpgate_dag_bundle/verify_dag_bundle.py` (with its
  sibling `verify_pbft_qc_bundle.py`).
- **Fix:** `verify_bundle` is a fail-closed wrapper (non-object → FAILED; any fault → FAILED verdict,
  never a traceback); `verify_cert` catches `Exception`. On the real bundle it still reports
  `ALL_CHECKS_PASSED: 18/18`.
- **Added:** `tests/test_dag_bundle_verifier_fail_closed.py` (3 tests), including a guard that the
  signed bundle's verifier SHA-256 still matches its signed manifest.
- **Grade: B+ → A-.**

---

## #76 — Multi-Region Adversarial Soak Harness (`scripts/cain42_bft/multi_region_soak.py`)

- **Defect (reproduced):** `attempt_enforcement(candidates=[])` raised `ZeroDivisionError` on
  `attempt % len(candidates)` — it could not have manufactured an ALLOW, but it crashed. Guarded to
  return `(None, None, 0, "no candidates")`.
- **Added:** 1 test to `tests/test_soak_enforcement_probe_retry.py`.
- **Grade: B+ (unchanged), honestly.** This is operational tooling, not a deployed control or a
  published zero-import verifier, and its limiting factor is not code: the repo's own records show the
  72-hour soak has **not** completed and no independent verification exists. No code change can make
  that soak result true; only running it (and independent verification) can.

---

## #13 — PBFT-E5 Proof-Carrying Authorization at MCPGate (`platform-gateway/cain_pbft_enforcement.py`)

- **Defect (reproduced):** `ConsensusAuthorizationGate.check()` computed `action = executed_action(tool, arguments)`
  **before** its `try/except`, so a non-dict argument (a truthy string, list, int or tuple) raised
  `AttributeError: 'str' object has no attribute 'items'` out of the enforcement gate instead of denying.
  `record_effect()` / `record_failure()` were likewise unguarded and raised on a non-dict
  `gate_result`.
  → `executed_action` accepts only a dict (else empty), `check` computes inside the guard and returns a
  signed `DENY` (`MALFORMED_ARGUMENTS`) for non-object input, and `record_effect` treats a non-dict
  `gate_result` as having no enforcement proof. Valid calls are unchanged.
- **Added:** 9 tests to `tests/test_cain42_pbft_evolution5.py` (parametrized).
- **Grade: B → A-.** It is the MCPGate enforcement boundary; now hardened and tested.

---

## #60 — Replicated Governance State Machine (`cain/govruntime/ledger.py`)

- **Defect (reproduced):** `apply_op()` is called from `Replica.vote`, `Replica.commit` and
  `Cluster.propose`, all of which catch **only** `OpRejected`. But `apply_op` raised raw
  `AttributeError` for a non-object op and `KeyError` for a body missing a required field
  (`{"type":"ISSUE_LEASE","body":{"now_ms":1}}` → `KeyError: 'lease'`). A malformed op proposed by a
  Byzantine leader would **escape and crash an honest replica** instead of being refused.
  → `apply_op` is now a thin wrapper that normalizes any `KeyError/TypeError/ValueError/
  AttributeError/IndexError` to `OpRejected("MALFORMED:...")`; the documented contract (raise
  `OpRejected`) now actually holds. `vote`/`commit`/`propose` therefore refuse cleanly.
- **Added:** 8 tests to `tests/govruntime/test_quorum_ledger.py` (parametrized), incl. a cluster
  `propose` fail-closed check.
- **Grade: B → A-.** It is the replicated control-plane ledger; now hardened.

---

## #11 — Canonical 16-Stage Trust Pipeline (`platform-gateway/cain_canonical_pipeline.py`)

- **Defect (reproduced):** `execute_and_prove()` raised on malformed caller input instead of returning
  a BLOCKED, 16-stage manifest: non-JSON `tool_parameters` (a set → `TypeError`), a non-finite float
  in parameters, a non-object `intent` (`AttributeError: 'dict' object has no attribute 'goal'`), and a
  non-object `context` (`AttributeError: 'str' object has no attribute 'get'`). A pipeline whose output
  is a signed proof manifest must fail closed to BLOCKED, not fault.
  → context/parameters are type-checked; parameters must be canonical JSON (`allow_nan=False`); the
  intent-evaluator call is wrapped. Any malformed input now yields `is_authorized=False`, stages=16.
- **Added:** 6 tests to `tests/test_canonical_16_stage_pipeline.py` (parametrized + positive path).
- **Grade: B → A-.**

---

## #62 / #63 — AGI Control Boundary (`platform-gateway/cain_agi_control_boundary.py`)

- **Defect (reproduced):** the sandbox tools — described as *"the ONLY thing an authorized decision can
  reach"* — raised `AttributeError`/`TypeError` on non-object arguments or a non-string path
  (`_sandbox_read_file(root, None)`, `{"path": ["a"]}`, …). `_risk_score_to_level(None/"x")` raised,
  and `_risk_score_to_level(NaN)` mapped to **LOW** (unknown risk read as low risk). The public
  `verify_evidence_chain()` raised `sqlite3.OperationalError` on an unreadable store instead of
  reporting a broken chain.
  → sandbox tools now raise `ControlBoundaryError("sandbox_malformed_arguments")` (escape refusal
  unchanged); a non-numeric/non-finite risk score maps to **CRITICAL** (unknown is not low); and
  `verify_evidence_chain` returns `chain_intact: False` with a reason when the store is unreadable.
- **Added:** 27 tests (`tests/test_agi_control_boundary_hardening.py`).
- **Grade (both listings #62 and #63): B → A-.**

---

## #22 — E13 BPF Governance State (`cain/govbpf/state.py`)

- **Defect (reproduced):** malformed input raised raw exceptions instead of the module's own
  `GovernanceRejected`: `activate(state, cert, None)` → `AttributeError`; a policy whose
  `governance_epoch` is `"x"` → `ValueError`; `replay_history(gen, None/[{}]/[1])` →
  `TypeError`/`KeyError`; `consistency([1], …)` / `consistency(None, …)` → `AttributeError`/`TypeError`,
  and a report whose `body` was a string also raised.
  → `activate` rejects a non-object/non-numeric policy with `BAD_POLICY`; `replay_history` rejects a
  malformed log with `BAD_EVENT_LOG`; `consistency` treats a non-object report **or** a non-object
  body as malformed and still yields `NO_QUORUM` (never authorization).
- **Added:** 9 tests to `tests/govbpf/test_govbpf.py` (parametrized).
- **Grade: B → A-.**

---

## #26 / #27 — E12 Machine-Checkable Formal Trust Invariants (`cain/trustnet/invariants.py`)

- **Defect (reproduced, significant):** four of the fifteen "machine-checkable" invariants were
  **tautologies that could never fail**, and one was inverted:
  - **T2** derived `authority_granted` from the chain length, then required the chain length to be 0 →
    `holds` always True.
  - **T6** set `auth_permitted = not is_revoked`, then tested `is_revoked and auth_permitted` → always
    False → `holds` always True.
  - **T9** derived the verdict from `policy_permits`, then required `policy_permits=False` → always
    True.
  - **T11** only asserted that an intersection is a subset of its components — a mathematical identity.
  - **T13** returned `holds = not outbound_proof_valid`, i.e. it reported the invariant as holding only
    when the proof was *invalid*.
  → each now accepts the **observed** outcome (`authority_granted`, `authorization_permitted`,
  `verdict_allowed`, `claimed_effective`, `federation_accepted`) and reports a violation when one is
  observed, with an `observable` flag in the evidence so a non-observed run is not misread as proof.
  Default calls (as the existing suite uses) are unchanged.
- **Added:** 5 tests to `tests/trustnet/test_trustnet_invariants.py` proving each check now fails on the
  violating input.
- **Grade (both listings #26 and #27): B → A-.** This is exactly the "vacuous check" class the repo's
  own doctrine warns about.

---

## #10 — Governance Compiler (`platform-gateway/cain_governance_compiler.py`)

- **Defect (reproduced):** `verify_package` was already fail-closed, but its siblings raised raw
  exceptions on a malformed package: `simulate(None, …)` → `TypeError`; `simulate(pkg, None, …)` →
  `KeyError`; `diff_packages(None, pkg)` / `diff_packages(pkg, None)` → `TypeError`;
  `package_digest(None)` → `AttributeError`; `ir_leq(None, None)` → `TypeError`.
  → `package_digest` raises `GovError("FORMAT")`; `ir_leq` returns conservative `False`; `diff_packages`
  returns `UNSAFE_CHANGE` with `requires_review: True`; `simulate` returns
  `would_pass_request_checks: False` with a reason. No behavior change for valid packages.
- **Added:** 4 tests to `tests/test_governance_compiler.py`.
- **Grade: B → A-.** It is on the request path; now hardened.

---

## #46 / #47 — E12 Executable Trust Invariants (`cain/govnetwork/invariants.py`)

- **Note:** unlike #26/#27, these invariants genuinely exercise the network/federation/proof code
  (each `t*` runs a real scenario/attack), so they are not tautologies. The defect is in the runner.
- **Defect (reproduced):** `run_invariants()` was `[f() for f in ALL_INVARIANTS]` with no per-invariant
  guard, so **one invariant whose evaluation raises crashed the entire run** — including the
  environment-dependent T15, which loads the clean-room verifier by path. A formal-invariant report
  that aborts has no verdict.
  → each invariant is now evaluated under a guard; a raising invariant is reported as **not held**
  (`holds: False`, detail `EXCEPTION: …`), never allowed to abort the run. Baseline unchanged (15/15).
- **Added:** 1 test to `tests/govnetwork/test_govnetwork_invariants.py`.
- **Grade (both listings #46 and #47): B → A-.**

---

## #28 — E11 Proof Primitives (`cain/govproof/primitives.py`)

- **Defect (reproduced):** the proof verifiers raised on malformed input instead of returning a
  negative verdict: `verify_disclosure` → `ValueError` on a non-integer index/size; `verify_composite`
  → `AttributeError` (non-object) / `KeyError` (proof without a subject); `verify_federation` →
  `AttributeError` / `TypeError`; `composite_scope` → `TypeError`/`KeyError`; `reconstruct` →
  `AttributeError`; `transcripts_match` → `TypeError`.
  → `verify_disclosure` returns `False`; `verify_composite`/`verify_federation` return
  `{"ok": False, "problems": ["MALFORMED_…"]}`; `composite_scope` yields an empty (restrictive)
  intersection; `reconstruct` yields empty facts; `transcripts_match` treats a non-object as `{}`.
  `_evidence_root`/`_leaf` are non-object-safe. Valid proofs unchanged.
- **Added:** 4 tests to `tests/govproof/test_govproof_primitives.py`.
- **Grade: B → A-.**

---

## #81 / #82 — Agent Identity Interop (`platform-gateway/cain_agent_identity.py`)

- **Defect (reproduced):** the identity verifiers raised instead of returning a verdict on a
  non-object credential: `TrustDomain.verify_svid(None/"x")` → `AttributeError`;
  `AuthorizationServer.verify(None/"x")` → `AttributeError`; `exchange(scope=5)` → `TypeError`;
  `exchange(subject_token=None)` → `AttributeError`; `attenuate(parent=None)` → `AttributeError`;
  `AuthenticatedCaller.authenticate(svid=None, token=None)` → `AttributeError`.
  → `verify_svid`/`verify` return `False` for a non-SVID/non-token; `_scope_set` raises
  `IdentityError` for a non-iterable scope; `attenuate` rejects a non-`Delegation` parent;
  `exchange`/`authenticate` therefore raise `IdentityError`. Valid credentials unchanged.
- **Added:** 5 tests to `tests/test_agent_identity.py`.
- **Grade (both listings #81 and #82): B → A-.**

---

## #83 — Epoch 6 Action Proof Object (`platform-gateway/cain_action_proof_epoch6.py`)

- **Defect (reproduced, significant):** `verify_proof` claimed *"Action proof successfully verified
  across all 8 stages"* but the signature stage only checked `len(proof.proof_signatures) >= 3`, and
  `issue_proof` filled `proof_signatures` with **placeholder strings** (`"sig-ed25519-node-1-xxxx"`).
  Quorum was a **self-declared integer** (`quorum_evidence["signed_nodes_count"]`). So the proof was
  never cryptographically verified — the class of "UI-only representation of a guarantee" the doctrine
  forbids. It also raised `AttributeError` on a non-object proof.
  → the engine now holds **3 real Ed25519 node keys**; `issue_proof` signs a signing digest (the body
  without signatures/digest) and recomputes the full `proof_digest` to cover the signatures;
  `verify_proof` verifies **≥3 distinct trusted keys** signed the digest (default: the engine's own
  keys; `trusted_public_keys` pins another issuer's). Forged placeholder signatures now yield
  `INCOMPLETE`; a proof issued by a different engine is `INCOMPLETE` until its keys are pinned; a
  non-object proof is `UNVERIFIED`. `Ed25519` unavailable → `UNVERIFIED` (never VALID).
- **Added:** 3 tests to `tests/test_cain42_epoch6_action_proof.py` (real-signature + forgery +
  cross-engine pinning). The pre-existing 7 tests still pass unchanged (same-engine issue→verify).
- **Grade: B → A-.**
- **Behavior note:** `cain action verify` uses a fresh engine, so it now reports `INCOMPLETE` for a
  proof issued elsewhere unless the issuer's keys are pinned — honest, since it cannot verify without
  them.

---

## #70 — Governance Fabric Enforcement Boundary (`cain/govfabric/boundary.py`)

- **Defect (reproduced):** `McpBoundary.admit` (the admission check) raised instead of refusing on a
  malformed authorization/request/call: `admit(auth, None, None)` → `TypeError: 'NoneType' object is
  not iterable`; `artifact_admits({}, …)` → `KeyError: 'allow'`; `authorization({"verdict":"ALLOW"},
  {}, None)` → `KeyError: 'now_ms'`. A boundary that cannot evaluate must refuse — a crash is not
  fail-closed.
  → `admit` wraps `_admit` so any fault becomes `{"admitted": False, "reason": "MALFORMED:…"}`; a
  non-object request/call is `NO_REQUEST`; `artifact_admits` returns `False` for a malformed artifact;
  `authorization` returns `None` for a malformed decision. Valid calls unchanged.
- **Scope note (honest):** this module is the *library model* of the MCPGate admission check; the live
  boundary is `cain/mcp_proxy.py`.
- **Added:** 3 tests to `tests/govfabric/test_boundary_proof.py`.
- **Grade: B- → A-.**

---

## Regression status

- `tests/test_meta_verification_engine.py` — 16 passed
- `tests/test_trust_kernel_invariant_honesty.py` — 8 passed
- `tests/test_independent_verifier_hardening.py` — 12 passed
- `tests/test_cain_trust_kernel_3.py`, `tests/test_ip_hardening_batch3_kernel.py`,
  `tests/test_cain_trust_kernel.py`, `tests/test_cain_kernel_self_defense.py`,
  `tests/test_cain42_canonical_architecture.py` — passing
- **Pre-existing, unrelated failure:** `tests/test_trifecta_integration.py::test_trifecta_provenance_manifest_valid`
  fails because `cain_provenance_manifest.json` is stale against 27 files, **24 of which
  were already drifted before this session** (other uncommitted work). Regenerating the
  manifest is a deliberate, separate step and was not done here.
- **Pre-existing:** the A+++/A++++ label requests are declined; see the main audit.
