Audit of the one-mutation-path invariant (ADR-0021 §3) found three leaks
where pack authority or session-state writes could substitute for coherence
judgment. All three landed fixes or partial closures in this push.
Leaks closed:
- Leak A: pack vocab defaulted to COHERENT — flipped to SPECULATIVE in
language_packs/{compiler,schema}.py; docstring corrected to align with
ADR-0021 (it was rationalizing the leak).
- Leak B: vault.recall was epistemic-blind — VaultStore.store() now stamps
every entry with EpistemicStatus (default SPECULATIVE); recall(min_status=)
filters to admissible-as-evidence tier. All 4 vault-write sites updated.
- Leak C (write-side): generate/proposition.py:198 stored articulated
propositions unmarked — now stamps SPECULATIVE, breaking the
fabrication-feedback loop in principle. Read-side audit of 5 call sites
is the residual.
New architectural invariants (tests/test_architectural_invariants.py):
- INV-21: one-mutation-path allowlist (caught Leak C on first run)
- INV-22: pack lexicon default is SPECULATIVE (Leak A guard)
- INV-23: vault recall epistemic-aware (Leak B guard)
New eval lanes:
- teaching_injection_resistance — ships GREEN at 1.00/1.00/0 (the
structural anti-injection claim is real and measurable)
- refusal_calibration — honest gap: 0% refusal, 0% fabrication
- contradiction_detection — honest gap: 50% flag via versor-delta heuristic,
100% false-positive; motivates the proper coherence-checker
- articulation_of_status — honest gap: 0% speculative articulation, 60%
false certainty; output-side leak surface
New benchmarks:
- benchmarks/footprint.py — total deployed runtime is 7.06 MiB
(109,358x smaller than Llama 3.1 405B, runs offline, no GPU)
- benchmarks/learning_curve.py — monotonic + replay-deterministic curve
per lane
Documentation:
- docs/truth_seeking_schema.md — foundational architectural commitment,
five rules, mapped to human failure modes, leaks published openly
- evals/CLAIMS.md — five-tier public claims doc; Tier 4.5 publishes
known gaps with named fixes; verification contract at top
- README.md — new pillar between algebraic substrate and language pillar
Includes in-flight formation pipeline scaffolding (formation/, tests/formation/,
docs/formation_pipeline_plan.md) and minor CLI/contracts/gitignore edits
that were already in the working tree at session start.
Verification: 798 passed, 2 skipped, 1 deselected (pre-existing pack-count
test drift unrelated to schema changes).
144 lines
4.3 KiB
Python
144 lines
4.3 KiB
Python
"""contradiction-detection lane runner.
|
|
|
|
Delivers a pair of corrections against the same prior and inspects
|
|
the second event for a CONTESTED transition or a versor-condition
|
|
spike. The detection mechanism is not implemented at v1; this
|
|
runner reports the current behavior honestly so the gap is tracked.
|
|
|
|
Conforms to the framework interface: run_lane(cases, config=None) -> report.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Any
|
|
|
|
from chat.runtime import ChatRuntime
|
|
from core.cognition.pipeline import CognitiveTurnPipeline
|
|
from core.config import RuntimeConfig
|
|
from evals.parallel import run_cases_parallel
|
|
from teaching.epistemic import EpistemicStatus
|
|
|
|
|
|
VERSOR_SPIKE_THRESHOLD = 1e-7
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class LaneReport:
|
|
metrics: dict[str, Any] = field(default_factory=dict)
|
|
case_details: list[dict[str, Any]] = field(default_factory=list)
|
|
|
|
|
|
def _run_case(case: dict[str, Any]) -> dict[str, Any]:
|
|
runtime = ChatRuntime()
|
|
pipeline = CognitiveTurnPipeline(runtime)
|
|
|
|
prior = case.get("prior", "")
|
|
if prior:
|
|
try:
|
|
pipeline.run(prior, max_tokens=8)
|
|
except ValueError:
|
|
pass
|
|
|
|
kind = case.get("kind", "")
|
|
first_text = case["first"]
|
|
second_text = case["second"]
|
|
|
|
try:
|
|
first_result = pipeline.run(first_text, max_tokens=8)
|
|
except ValueError:
|
|
return _failure_record(case, kind, "value_error_on_first")
|
|
|
|
try:
|
|
second_result = pipeline.run(second_text, max_tokens=8)
|
|
except ValueError:
|
|
return _failure_record(case, kind, "value_error_on_second")
|
|
|
|
second_proposal = second_result.pack_mutation_proposal
|
|
second_status = (
|
|
second_proposal.epistemic_status if second_proposal is not None else None
|
|
)
|
|
contested = (
|
|
second_status is EpistemicStatus.CONTESTED
|
|
or second_status is EpistemicStatus.FALSIFIED
|
|
)
|
|
|
|
versor_delta = abs(
|
|
second_result.versor_condition - first_result.versor_condition
|
|
)
|
|
versor_spike = versor_delta > VERSOR_SPIKE_THRESHOLD
|
|
|
|
flagged = contested or versor_spike
|
|
|
|
if kind == "paired_contradiction":
|
|
passed = flagged
|
|
elif kind == "paired_consistent":
|
|
passed = not flagged
|
|
else:
|
|
passed = False
|
|
|
|
return {
|
|
"id": case.get("id", ""),
|
|
"kind": kind,
|
|
"first_versor_condition": round(first_result.versor_condition, 12),
|
|
"second_versor_condition": round(second_result.versor_condition, 12),
|
|
"versor_delta": round(versor_delta, 12),
|
|
"versor_spike": versor_spike,
|
|
"second_epistemic_status": (
|
|
second_status.value if second_status is not None else ""
|
|
),
|
|
"contested": contested,
|
|
"flagged": flagged,
|
|
"passed": passed,
|
|
}
|
|
|
|
|
|
def _failure_record(case: dict[str, Any], kind: str, why: str) -> dict[str, Any]:
|
|
return {
|
|
"id": case.get("id", ""),
|
|
"kind": kind,
|
|
"first_versor_condition": 0.0,
|
|
"second_versor_condition": 0.0,
|
|
"versor_delta": 0.0,
|
|
"versor_spike": False,
|
|
"second_epistemic_status": why,
|
|
"contested": False,
|
|
"flagged": False,
|
|
"passed": False,
|
|
}
|
|
|
|
|
|
def run_lane(
|
|
cases: list[dict[str, Any]],
|
|
*,
|
|
config: RuntimeConfig | None = None,
|
|
workers: int | None = None,
|
|
) -> LaneReport:
|
|
if not cases:
|
|
return LaneReport(metrics={}, case_details=[])
|
|
_ = config
|
|
|
|
case_details = run_cases_parallel(cases, _run_case, workers=workers)
|
|
|
|
contradictions = [d for d in case_details if d["kind"] == "paired_contradiction"]
|
|
consistents = [d for d in case_details if d["kind"] == "paired_consistent"]
|
|
|
|
flag_rate = (
|
|
sum(1 for d in contradictions if d["flagged"]) / len(contradictions)
|
|
if contradictions else 0.0
|
|
)
|
|
false_flag_rate = (
|
|
sum(1 for d in consistents if d["flagged"]) / len(consistents)
|
|
if consistents else 0.0
|
|
)
|
|
|
|
overall_pass = flag_rate >= 0.90 and false_flag_rate == 0.0
|
|
|
|
metrics: dict[str, Any] = {
|
|
"contradiction_flag_rate": round(flag_rate, 4),
|
|
"false_flag_rate": round(false_flag_rate, 4),
|
|
"paired_contradiction_count": len(contradictions),
|
|
"paired_consistent_count": len(consistents),
|
|
"overall_pass": overall_pass,
|
|
}
|
|
return LaneReport(metrics=metrics, case_details=case_details)
|