core/evals/miner_loop_closure/contract.md
Shay 7dc7e9d5eb feat(teaching): implement ADR-0095 — Miner-Sourced Teaching Proposals
Closes the Phase-5 contemplation loop in code. Articulation-quality,
contradiction-detection, and frontier-compare miners (already shipping)
now have a route to file PackMutationProposal candidates that traverse
the single reviewed teaching path. Construction-only; never promotes
to coherent.

- new teaching/from_miner.py: from_finding() / from_findings() turn
  ContemplationFinding records (kind=PACK_MUTATION_CANDIDATE) into
  PackMutationProposal candidates with source.kind="miner",
  source.source_id=<miner_id>, status=SPECULATIVE
- proposal_id = SHA-256(canonical(miner_id, finding, revision))[:16]
  — same inputs → byte-identical proposal_id; different miner_id or
  revision → different id
- identity-pack defense AT CONSTRUCTION: reuses teaching.review.
  _is_identity_override() against finding.subject AND
  finding.proposed_action; miner-sourced identity-override attempts
  never reach the proposal log
- pluggable ReplayEquivalenceChecker Protocol with ReplayEquivalenceResult;
  NoOpReplayChecker default explicitly notes "deferred to production
  checker"; production checker integration is downstream of this ADR
- from_findings() batch path collects identity-override and
  replay-equivalence rejections in a typed rejection log rather than
  raising, so a mixed batch can proceed with audit evidence
- serialize_proposal_emitted_event() emits ADR-0040-compliant redacted
  telemetry shape: type, proposal_id, source.serialize(),
  epistemic_status only (no raw subject/correction_text)
- 22 unit tests covering positive construction, identity defense in
  subject+proposed_action, malformed input, determinism (same inputs,
  different revision, different miner_id, batch stream), replay
  pre-gate (single + batch), telemetry redaction, and the structural
  grep gate enforcing miner_proposal_single_review_path (only
  teaching/review.py and teaching/store.py may promote to COHERENT)
- new evals/miner_loop_closure/ lane: 6 case classes (positive_basic,
  identity_override_subject, identity_override_action,
  replay_equivalence_failed, wrong_finding_kind, determinism) passing
  6/6 with byte-identical SHA-256 across runs
- smoke 67/67, teaching 17/17, cognition 120/121 (1 pre-existing skip);
  cognition eval byte-identical 100/100/100/100
2026-05-21 18:18:51 -07:00

2.3 KiB

evals/miner_loop_closure — Lane Contract

ADR: ADR-0095 Invariants:

  • miner_proposal_replay_equivalence
  • miner_proposal_single_review_path

Purpose

Prove that Phase-5 contemplation miners can emit :class:PackMutationProposal candidates that traverse the existing reviewed teaching path without violating ADR-0095 hard constraints.

The lane asserts:

  1. A legitimate PACK_MUTATION_CANDIDATE finding produces a miner-sourced proposal with source.kind="miner" and epistemic_status=SPECULATIVE.
  2. Identity-override findings are rejected at construction, before review, so the proposal never reaches the proposal log.
  3. A finding whose replay-equivalence check fails is rejected at construction; its finding_id appears in the batch's rejections list with reason replay_equivalence_failed.
  4. A non-PACK_MUTATION_CANDIDATE finding raises :class:MinerProposalError; the miner cannot promote diagnostic findings into pack mutations.
  5. Random/under-threshold observations (coincidence control) never produce proposals — they are filtered upstream by the miner's recurrence thresholds and never reach from_finding.
  6. Same finding stream + same miner_id + same revision → byte-identical proposal id stream across two runs.

Cases

The runner iterates over case fixtures declared in :mod:runner:

  • positive_basic — single coherent PACK_MUTATION_CANDIDATE finding → proposal emitted with miner source.
  • identity_override_subject — finding subject contains an identity-override pattern → rejected at construction.
  • identity_override_action — finding proposed_action contains an identity-override pattern → rejected at construction.
  • replay_equivalence_failed — finding sent through a checker that reports trace-hash divergence → rejected at construction.
  • wrong_finding_kind — non-PACK_MUTATION_CANDIDATE finding → raises MinerProposalError.
  • determinism — three findings emitted twice; proposal-id streams must be identical between the runs.

Determinism

The runner emits results/v1_dev.json with case results and a SHA-256 of the canonical report bytes. Two consecutive runs against the same fixtures must produce identical bytes.

Exit code

Non-zero on any divergence between expected and actual outcomes.