test: preserve bounded historical replay and document versioned assessment

This commit is contained in:
TRON committed 2026-10-18 10:44:56 -07:00
1 parent 236994926f
commit 2359605b7a
3 files changed
+68 -1

No files matched your search

+21 -1
View File
@@ -42,6 +42,23 @@ def official_reference(path):
artificial_fields='mass/flux placeholders only; official archive is not used to certify conservation')
def frozen_replay_difference(current_cycles, archived_cycles):
"""Integrity-only FP replay allowance, not a physical acceptance threshold."""
if len(current_cycles) != len(archived_cycles):
raise ValueError('Frozen cycle count differs from original')
deltas=[]
for current, archived in zip(current_cycles, archived_cycles):
if current.keys()!=archived.keys(): raise ValueError('Frozen cycle schema differs')
for key in current:
x=np.asarray(current[key]); y=np.asarray(archived[key])
if x.shape!=y.shape or not np.isfinite(x).all() or not np.isfinite(y).all():
raise ValueError('Frozen cycle shape or finite-state mismatch')
deltas.append(float(np.max(np.abs(x-y))))
difference=max(deltas,default=0.)
if difference>1e-10: raise ValueError('Frozen replay exceeds FP integrity allowance')
return difference
def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--official-archive',type=Path,required=True)
@@ -62,16 +79,19 @@ def main():
source_receipt=json.loads(source_receipt_path.read_text())
if rows != source_receipt.get('history'):
raise ValueError('CSV differs from original summary history')
v2.validate_rows(rows)
old=frozen.assess(rows); new=v2.assess(rows)
for key in ('periodic', 'checks', 'cycles'):
for key in ('periodic', 'checks'):
if old[key] != source_receipt.get(key):
raise ValueError('Frozen reassessment differs from original summary')
replay_difference=frozen_replay_difference(old['cycles'],source_receipt['cycles'])
old_comparison=frozen.compare(old['cycles'][-1],old_ref) if old['cycles'] else None
new_comparison=v2.compare(new['cycles'][-1],reference) if new['cycles'] else None
# This is assessment of recorded observables, not proof of unrecorded population health.
healthy=bool(rows and all(.5<=r['rho_min']<=r['rho_max']<=1.5 and 0<=r['max_mach']<=.2 for r in rows))
cases.append(dict(label=label,input_csv_sha256=sha(path),
original_summary_sha256=sha(source_receipt_path),
frozen_cycle_max_absolute_replay_difference=replay_difference,
original_identity={k:source_receipt[k] for k in ('case','collision','observation_mode','numerical_source_commit','checkout','checkout_revision','mode','status') if k in source_receipt},
observations=len(rows),
recorded_end_tstar=rows[-1]['tstar'] if rows else None,recorded_observations_healthy=healthy,