Evidence

verify cycle.py

Download source fileOpen in research workspace
#!/usr/bin/env python3
"""Verify the portable evidence packet and all50 recorded actions."""
from pathlib import Path
import argparse, hashlib, importlib.util, json, sys
sys.dont_write_bytecode=True
root=Path(__file__).resolve().parent
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--require-50',action='store_true')
args=parser.parse_args()
manifest_path=root/'MANIFEST.json'
verified=0
if manifest_path.exists():
    manifest=json.loads(manifest_path.read_text())
    for name,record in manifest['files'].items():
        p=root/name
        if not p.is_file():raise AssertionError('Missing payload: '+name)
        data=p.read_bytes()
        if len(data)!=record['bytes'] or hashlib.sha256(data).hexdigest()!=record['sha256']:
            raise AssertionError('Payload mismatch: '+name)
        verified+=1
spec=importlib.util.spec_from_file_location('independent_cycle_verifier',root/'agents/verify_cycle_algebra.py')
module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module)
v=module.verify(root,args.require_50)
print(json.dumps({'status':v['status'],'actions':v['journal_steps_verified'],'first':v['first_step'],'last':v['last_step'],'groups':v['group_count'],'models':len(v['covered_models']),'uncovered':v['uncovered_models'],'manifest_payloads':verified,'last_record_sha256':v['last_record_sha256']},indent=2))
Edition and provenance

verify_cycle.py

SHA-256 68f6307a67fc6879bba5bbb24768cebd4ba42c7a1e1a2a582481bc3762f5b35b

C480–C1634/Research_Cycles/C1585_C1634/verify_cycle.py