Files
ARCADIA-Studio/harness/experiments/analysis-source3-bridge-windows-20260913/evidence/.local/admit-analysis-bridge-gate.py
T

59 lines
3.6 KiB
Python

"""Admit the four independently named bridge cases and retained S0/S1 cases."""
from pathlib import Path
import hashlib, json, re, subprocess, sys
base=Path(__file__).resolve().parent.parent
root=base/'.local/analysis-core-worktree-20260911'
folder=base/'.local/analysis-source-gates-20260913'
name=sys.argv[1]
assert re.fullmatch(r'[a-zA-Z0-9-]+',name)
path=folder/(name+'.result.json'); record=json.loads(path.read_bytes())
assert record['exit']==0 and not record['changed_inputs'] and record['source']==record['head_after']
assert subprocess.check_output(['git','rev-parse','HEAD'],cwd=root).decode().strip()==record['source']
inputs_path=folder/record['inputs']; inputs=json.loads(inputs_path.read_bytes())
assert inputs['source']==record['source'] and len(inputs['inputs'])==520
for entry in inputs['inputs']:
raw=(root/entry['path']).read_bytes()
assert len(raw)==entry['bytes'] and hashlib.sha256(raw).hexdigest()==entry['sha256']
assert len(record['artifacts'])==1
artifact=record['artifacts'][0]; raw=Path(artifact['path']).read_bytes()
assert len(raw)==artifact['bytes'] and hashlib.sha256(raw).hexdigest()==artifact['sha256']
log_path=folder/(name+'.log'); log=log_path.read_text(encoding='utf-8')
if record['command'][-1]=='--list':
original_path=folder/'list-2c515cf-r2.result.json'
original=json.loads(original_path.read_bytes())
admission=json.loads((folder/'list-2c515cf-r2.admission.json').read_bytes())
assert admission['result_sha256']==hashlib.sha256(original_path.read_bytes()).hexdigest()
assert len(original['listing_members'])==114
new_names={ 'language::source3_bridge::tests::'+n for n in [
'frozen_source3_and_json3_have_complete_model_and_migration_parity',
'frozen_wire_still_rejects_new_unknown_and_duplicate_fields',
'old_review_prose_survives_without_admitting_semantic_fields',
'scratch_bridge_refuses_to_discard_current_only_data'] }
names=record['listing_members']
assert len(names)==len(set(names))==118
assert set(names)==set(original['listing_members'])|new_names
assert re.findall(r'^(\d+) tests, (\d+) benchmarks\s*$',log,re.M)==[('118','0')]
mode='list'
else:
listing_name,selector=sys.argv[2:4]
listing_path=folder/(listing_name+'.result.json'); listing=json.loads(listing_path.read_bytes())
admission=json.loads((folder/(listing_name+'.admission.json')).read_bytes())
assert admission['result_sha256']==hashlib.sha256(listing_path.read_bytes()).hexdigest()
assert admission['source']==listing['source']==record['source']
assert admission['artifact']==artifact and admission['mode']=='list'
assert selector in record['command']
names=[n for n in listing['listing_members'] if selector in n]
actual=re.findall(r'^test ([^\r\n]+) \.\.\. ok\s*$',log,re.M)
assert names and len(actual)==len(set(actual)) and set(actual)==set(names)
assert re.search(rf'test result: ok\. {len(actual)} passed; 0 failed; 0 ignored;',log)
mode='focused'
receipt={'source':record['source'],'mode':mode,'artifact':artifact,'names':names,
'result_sha256':hashlib.sha256(path.read_bytes()).hexdigest(),
'inputs_sha256':hashlib.sha256(inputs_path.read_bytes()).hexdigest(),
'log_sha256':hashlib.sha256(log_path.read_bytes()).hexdigest(),
'verified_inputs':len(inputs['inputs']),
'admission_helper_sha256':hashlib.sha256(Path(__file__).read_bytes()).hexdigest()}
with (folder/(name+'.admission.json')).open('x',encoding='utf-8',newline='\n') as stream:
stream.write(json.dumps(receipt,indent=2)+'\n')
print(json.dumps({'name':name,'mode':mode,'members':len(names),'source':record['source']}))