Commit Graph

1 Commits

Author SHA1 Message Date
Bo 2c5d93e16b feat(ci): scripts/check-proof-coherence.sh (soc-57hbj #proof-coherence) (#647)
## What

Proof-coherence gate for the reconciliation engine (Wave 3C). Two axes
(plan: `.agents/plans/2026-05-07-reconciliation-engine-full-arc.md`):
claim coherence (advisory) and **proof coherence** (claim-ledger row →
daemon criterion-verdict event, **blocking for L2/L3 claims**). This PR
ships proof coherence.

## Coherence predicate

For every L2/L3 claim-ledger row, each `evidence_event_refs[]` entry
must:
1. resolve to a daemon event matching `event_type`+`run_id`
(+`criterion_id` if named) — else **DANGLING**;
2. carry `verdict: pass` — else **FAILED** (demote).

An L2/L3 row with zero refs is **UNBACKED**. L0/L1 rows are not gated.

## Forward-compatible

Wave 1's claim ledger and Wave 3B's `evidence_event_refs` schema haven't
landed, so with no ledger present the gate is a **PASS no-op** — it
lands as blocking CI surface now and becomes load-bearing automatically
once L2/L3 rows appear. Inputs auto-discover
(`docs/contracts/factory-claim-ledger{,.example}.json`,
`cli/.agents/daemon/ledger.jsonl`), overridable via
`--ledger`/`--events`.

## Output / exit codes

Text (default) + `--json`. Exit `0` coherent / no ledger · `1`
incoherent · `2` usage|env.

## Tests

`tests/scripts/check-proof-coherence.bats` — 13 hermetic cases, exact
exit codes + messages, both drift directions (missing event + failed
verdict), unbacked L2/L3, L0/L1 ungated, no-ledger no-op, JSON
pass/fail, malformed-ledger + bad-flag env errors.

## Gates

- `shellcheck -S warning scripts/check-proof-coherence.sh` — clean.
- `bats tests/scripts/check-proof-coherence.bats` — 13/13 pass.
- `git diff origin/main --stat` — scope-only (the two intended files).

## Scope note

validate.yml wiring deferred: a no-op until the ledger ships (Wave 1/3B
precondition); wiring lands with the first L2/L3 ledger row.

Closes-scenario: soc-57hbj#proof-coherence
Bounded-context: BC2-Validation
Evidence: scripts/check-proof-coherence.sh
2026-05-31 12:49:54 -04:00