#!/usr/bin/env python3 """Summarize completed focused evidence without executing tests.""" import datetime import hashlib import json import math from pathlib import Path HERE=Path(__file__).resolve().parent RUN=HERE/'run3-focused' def main(): results=json.loads((RUN/'files/results.json').read_text()) assert len(results['steps'])==27 assert all(s['code']==0 and not s['timeout'] and s['counts'].get('fail')==0 for s in results['steps']) header=(RUN/'controller.log').read_text().splitlines() assert json.loads(header[0])=={k:results[k] for k in ['grant','head','manifest']} assert json.loads(header[1])['authority']=='sage-2709' named=[] basis={} lines=['# Focused27 whole-file results','','| Whole file | Pass/fail/skip | Wall seconds | Command limit seconds | Next3x plus120 basis |','|---|---:|---:|---:|---:|'] for s in results['steps']: command=json.loads(Path(s['log']).with_suffix('.command.json').read_text()) expected=900 if s['file'].startswith('packages/cli/') else 300 assert command==['timeout','-k','10',str(expected),'node','--test','--test-reporter=tap',s['file']] c=s['counts'];limit=math.ceil(3*s['seconds'])+120 basis[s['file']]=dict(recorded_seconds=s['seconds'],receipt=s['log'],next_limit_seconds=limit,derivation='ceil(3*measured whole-file seconds)+120') lines.append(f"| {s['file']} | {c['pass']}/{c['fail']}/{c['skipped']} | {s['seconds']} | {expected} | {limit} |") named += [dict(file=s['file'],line=line) for line in s['named_skips']] case2=next(s for s in results['steps'] if s['file'].endswith('/case2-unit.test.mjs')) n9=[line for line in Path(case2['log']).read_text().splitlines() if 'inside a session' in line and 'ok ' in line] assert len(n9)==1 result=dict(status='GREEN',grant=results['grant'],candidate=results['head'],manifest=results['manifest'],counts={k:sum(s['counts'].get(k,0) for s in results['steps']) for k in ['pass','fail','skipped']},steps=results['steps'],named_skips=named,n9_exact_line=n9[0],file_seconds_sum=round(sum(s['seconds'] for s in results['steps']),3),next_file_limits=basis,timeout_count=0,source_manifest_verified=True) (RUN/'SUMMARY.json').write_text(json.dumps(result,indent=2)+'\n') (RUN/'RESULTS.md').write_text('\n'.join(lines)+'\n\nN9 verbatim: '+n9[0]+'\n\nEvery skip:\n\n'+'\n'.join('- '+s['line'] for s in named)+'\n') (RUN/'MEASURED-FILE-LIMITS.json').write_text(json.dumps(basis,indent=2)+'\n') print(json.dumps({k:result[k] for k in ['counts','named_skips','n9_exact_line','file_seconds_sum']},indent=2)) if __name__=='__main__':main()