"""Run actual local version checks; rejected candidates never call materialize.""" import argparse import json from pathlib import Path import shutil import tempfile from unittest.mock import patch from versions import HERE, INPUTS, Registry, History, snapshot, manifest_id, run_locked, minute CUTOFF = minute('2026-01-08T12:00:00Z') PUBLISHED = minute('2026-01-08T12:30:00Z') def record(): registry = Registry() try: locked = snapshot(HERE) expected = manifest_id(locked) baseline = run_locked(HERE, locked, expected, registry, CUTOFF, PUBLISHED) probes = [] for name in ('dataset', 'schema', 'feature'): with tempfile.TemporaryDirectory() as tmp: for file in INPUTS: shutil.copyfile(HERE/file, Path(tmp)/file) target = Path(tmp)/(name+'.json') value = json.loads(target.read_text()) if name == 'dataset': value['events'][0]['arrived_at'] = '2026-01-07T16:00:00Z' elif name == 'schema': value['version'] = 2 else: value['window_days'] = 2 target.write_text(json.dumps(value, indent=2)+'\n') with patch.object(History, 'materialize') as materialize: try: run_locked(tmp, locked, expected, registry, CUTOFF, PUBLISHED) except ValueError as error: probes.append({'changed': name, 'refused': True, 'reason': str(error), 'compute_calls': materialize.call_count}) else: raise AssertionError('changed input was accepted') with tempfile.TemporaryDirectory() as tmp: for file in INPUTS: shutil.copyfile(HERE/file, Path(tmp)/file) path=Path(tmp)/'feature.json';spec=json.loads(path.read_text());spec['window_days']=2 path.write_text(json.dumps(spec,indent=2)+'\n') renamed=snapshot(tmp) try: run_locked(tmp,renamed,manifest_id(renamed),registry,CUTOFF,PUBLISHED) except ValueError as error: conflict=str(error) else: raise AssertionError('same feature version was rebound') spec['version']=2;path.write_text(json.dumps(spec,indent=2)+'\n') next_manifest=snapshot(tmp) next_result=run_locked(tmp,next_manifest,manifest_id(next_manifest),registry,CUTOFF,PUBLISHED) return {'mode':'local version checks; synthetic events; no model training', 'baseline':baseline, 'changed_input_probes':probes, 'same_version_conflict':conflict,'explicit_feature_v2':next_result, 'manifest':locked} finally: registry.close() def main(): parser=argparse.ArgumentParser();parser.add_argument('--check',action='store_true');parser.add_argument('--save',type=Path) args=parser.parse_args();result=record() if args.check and result!=json.loads((HERE/'result.json').read_text()): raise SystemExit('version checks differ from bundled result') if args.save:args.save.write_text(json.dumps(result,indent=2)+'\n') print('Dataset v1 + schema v1 + feature v1: user-02 count =',result['baseline']['user_02']['value']) for row in result['changed_input_probes']: print(f"Changed {row['changed']}: refused={row['refused']}; compute_calls={row['compute_calls']}") print('New manifest with reused feature v1: refused; immutable identity conflict') print('Explicit feature v2 (two-day window): user-02 count =',result['explicit_feature_v2']['user_02']['value']) print('Manifest identities differ:',result['baseline']['manifest_id']!=result['explicit_feature_v2']['manifest_id']) print('Hashes bind inputs and implementation; they do not prove data quality or authorship.') if __name__=='__main__':main()