Verification Registry
"Verified" is only ever verified against a specific set of checks. When that set grows, this registry automatically flags every claim checked against the old, smaller set as stale — codified directly from the real lesson the laundering vulnerability discovery taught.
The real distinction this module exists to draw
This is explicitly not the same thing as monotonicity elsewhere in this architecture (confirmed mastery can't be dragged back down). Nothing here goes backward — a claim that was true against an old, smaller invariant set is still true against it. What changes is the invariant set itself growing, which is a different, real event: schema evolution, not state decay. The module's own docstring states this distinction directly, and it's preserved here rather than paraphrased.
Source
"""
verification_registry.py
Codifies the lesson from the Claim 1 laundering discovery: a claim marked
"verified" is only verified AGAINST A SPECIFIC SET OF INVARIANTS. If that
set later grows (a new check gets discovered, like "trace value
provenance, not just source labels"), every claim that was verified
against the OLD, smaller set needs to be flagged for re-verification --
not silently left marked "done" under a definition of done that's no
longer current.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Dict, FrozenSet, List, Optional
import hashlib
import time
@dataclass(frozen=True)
class Invariant:
name: str
description: str
added_at: float
@dataclass(frozen=True)
class VerificationRecord:
claim_id: str
invariant_set_hash: str
invariant_names_checked: FrozenSet[str]
verified_at: float
passed: bool
class VerificationRegistry:
"""Tracks the current, growing set of invariants and every claim's
verification history against specific snapshots of that set."""
def __init__(self):
self._invariants: Dict[str, Invariant] = {}
self._records: List[VerificationRecord] = []
def _current_hash(self) -> str:
names = sorted(self._invariants.keys())
return hashlib.sha256(",".join(names).encode()).hexdigest()[:12]
def register_invariant(self, name: str, description: str) -> None:
self._invariants[name] = Invariant(name, description, time.time())
def record_verification(self, claim_id: str, invariant_names_checked: List[str], passed: bool) -> VerificationRecord:
record = VerificationRecord(
claim_id=claim_id,
invariant_set_hash=self._current_hash(),
invariant_names_checked=frozenset(invariant_names_checked),
verified_at=time.time(),
passed=passed,
)
self._records.append(record)
return record
def latest_record(self, claim_id: str) -> Optional[VerificationRecord]:
matches = [r for r in self._records if r.claim_id == claim_id]
return matches[-1] if matches else None
def is_stale(self, claim_id: str) -> bool:
"""A claim is stale if its most recent verification didn't cover
every invariant currently known -- i.e. the spec grew since it
was last checked."""
record = self.latest_record(claim_id)
if record is None:
return True # never verified at all
current_invariants = frozenset(self._invariants.keys())
missing = current_invariants - record.invariant_names_checked
return len(missing) > 0
def missing_invariants(self, claim_id: str) -> FrozenSet[str]:
record = self.latest_record(claim_id)
current_invariants = frozenset(self._invariants.keys())
if record is None:
return current_invariants
return current_invariants - record.invariant_names_checked
def all_stale_claims(self, known_claim_ids: List[str]) -> List[str]:
return [cid for cid in known_claim_ids if self.is_stale(cid)]
Real execution — the exact scenario the docstring describes, actually run
reg = VerificationRegistry()
reg.register_invariant("source_label_check", "Value's declared source matches an allowed channel")
reg.register_invariant("value_range_check", "Value falls within the expected numeric range")
reg.record_verification("claim_A_laundering_fix", ["source_label_check", "value_range_check"], passed=True)
print(reg.is_stale("claim_A_laundering_fix"))
>>> False
# The spec grows -- the real Claim 1 laundering discovery event
reg.register_invariant("provenance_trace_check", "Value's full computational provenance is traced, not just its label")
print(reg.is_stale("claim_A_laundering_fix"))
>>> True
print(reg.missing_invariants("claim_A_laundering_fix"))
>>> frozenset({'provenance_trace_check'})
print(reg.all_stale_claims(["claim_A_laundering_fix", "claim_never_checked", "claim_B_other"]))
>>> ['claim_A_laundering_fix', 'claim_never_checked', 'claim_B_other']
The claim was fully verified, then automatically flagged stale the moment a new invariant was discovered — without anyone manually going back to mark it. That's the actual mechanism, run, not described.