Observation Kernels
Turns VerificationRegistry data into a real evidence-completeness measurement — the layer that feeds the Research State Kernel with numbers instead of hand-typed test values.
Source
def evidence_completeness_observer(registry, claim_id):
total_invariants = len(registry._invariants)
if total_invariants == 0:
return {"evidence_fraction": 0.0, "reason": "No invariants registered yet -- nothing to measure against."}
matching_records = [r for r in registry._records if r.claim_id == claim_id]
if not matching_records:
return {"evidence_fraction": 0.0, "reason": "No verification records found for '%s'." % claim_id}
most_recent = matching_records[-1]
if not most_recent.passed:
return {"evidence_fraction": 0.0, "reason": "Most recent verification for '%s' did not pass." % claim_id}
checked = len(most_recent.invariant_names_checked)
fraction = checked / total_invariants
return {
"evidence_fraction": round(fraction, 3),
"checked": checked,
"total_invariants": total_invariants,
"is_stale": registry.is_stale(claim_id),
"reason": "%d of %d currently-registered invariants checked and passed." % (checked, total_invariants),
}
def verification_status_observer(registry, claim_id):
result = evidence_completeness_observer(registry, claim_id)
if result["evidence_fraction"] == 0.0:
return "none"
if result.get("is_stale", True):
return "partial"
if result["evidence_fraction"] >= 0.99:
return "full"
return "partial"
Real execution output
Run directly against a fresh VerificationRegistry, three invariants registered in sequence — not a mock, the real class.
=== Real test: claim checked against ALL current invariants ===
{'evidence_fraction': 1.0, 'checked': 2, 'total_invariants': 2, 'is_stale': False,
'reason': '2 of 2 currently-registered invariants checked and passed.'}
Status: full
=== Real test: claim checked against only SOME current invariants (should be lower fraction) ===
{'evidence_fraction': 0.5, 'checked': 1, 'total_invariants': 2, 'is_stale': True,
'reason': '1 of 2 currently-registered invariants checked and passed.'}
Status: partial
=== Real test: a NEW invariant gets added -- claim_A should now be genuinely stale/partial ===
{'evidence_fraction': 0.667, 'checked': 2, 'total_invariants': 3, 'is_stale': True,
'reason': '2 of 3 currently-registered invariants checked and passed.'}
Status: partial
=== Real test: claim with no records at all ===
{'evidence_fraction': 0.0, 'reason': "No verification records found for 'never_checked_claim'."}
The third test is the one that actually proves something: adding a third invariant
correctly dropped a previously-full claim to partial, without
that claim's own history changing at all. This is the staleness mechanism working
end to end, not just in isolation.