#!/usr/bin/python3.12 """Final independent static/process/GPU/protected/accounting checks. No physics.""" import pathlib,json,hashlib,sys,time,datetime,ctypes A=pathlib.Path(__file__).resolve().parent;D=A.parent read=lambda p:json.loads(p.read_text());sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() seal=read(A/'package-verification.json');P=pathlib.Path(seal['package']);S=pathlib.Path(read(A/'staging.json')['root']);scope=read(A/'scope.json');assert not (A/'task-complete.json').exists() assert sha(pathlib.Path(seal['archive']))==seal['archive_sha256'] for line in (P/'SHA256SUMS').read_text().splitlines(): h,n=line.split(' ',1);assert sha(P/n)==h,n auth=read(A/'runs/display-S1-05/campaign/approval.json')['sources'];assert all(sha(P/n)==sha(S/n)==sha(D/n)==h for n,h in auth.items()) protected=read(A/'protected-registration.json')['protected'];bad=[n for n,h in protected.items() if not pathlib.Path(n).is_file() or sha(pathlib.Path(n))!=h];assert not bad,bad identities=[];intervals=[];cases=[] for r in (A/'runs').iterdir(): c=read(r/'campaign/campaign-result.json');o=read(r/'observer/result.json');identities += [i for row in c['rows'] for i in row['owned_identities']];intervals.append({'case':r.name,'begin_wall':o['began_wall'],'end_wall':o['ended_wall'],'Kit':len(c['rows'])});cases.append(c) intervals.sort(key=lambda x:x['begin_wall']);assert all(x['end_wall']<=y['begin_wall'] for x,y in zip(intervals,intervals[1:])),intervals alive=[] for pid,birth in identities: try: st=pathlib.Path(f'/proc/{pid}/stat').read_text() if int(st[st.rfind(')')+2:].split()[19])==birth:alive.append([pid,birth]) except FileNotFoundError:pass assert not alive,alive sys.path.insert(0,str(S/'scripts'));import functional_flow_launch_v2 as f identity=read(A/'runs/headless-S1-06/campaign/approval.json')['gpu_identity'];gpu=f.ownership.GPUOwnership(identity);review=gpu.check(type('EmptyOwned',(),{'discover':lambda self:{}})(),final=True);clients={k:sorted(v) for k,v in gpu.clients().items()};assert not clients['compute'] # This scan is a final owned-storage inventory, not a claim to monitor all # shared caches continuously. pytest root is conservatively counted even if # it includes unrelated tests. Symlinks are listed but never followed. entries=[];seen=set();bytes_=0;gaps=[] roots=[A,pathlib.Path('/tmp/pytest-of-cen')] for root in roots: if not root.exists():continue for p in root.rglob('*'): if p.is_symlink():continue try: if p.is_file(): n=str(p.resolve()) if n not in seen: seen.add(n);s=p.stat().st_size;bytes_+=s;entries.append({'path':n,'bytes':s,'sha256':sha(p) if root==A else None,'scope':'task-root' if root==A else 'conservative-shared-pytest-temp'}) except (FileNotFoundError,PermissionError) as e:gaps.append({'path':str(p),'error':type(e).__name__}) for p in [D/'setup-preflight.json',*(D/n for n in auth),D/'docs/contact_cycle_sim_performance_v042_result.md']: n=str(p.resolve()) if n not in seen:seen.add(n);s=p.stat().st_size;bytes_+=s;entries.append({'path':n,'bytes':s,'sha256':sha(p),'scope':'additional-source/probe/result'}) reserve=16*1024**2;accounted=bytes_+reserve;elapsed=time.time()-datetime.datetime.fromisoformat(scope['start']).timestamp();kits=sum(len(c['rows']) for c in cases);actual=sum(c['actual_final_physics_calls'] for c in cases);reserved=sum(c['reserved_physics_calls'] for c in cases) assert kits==11 and actual==67500 and reserved==73500 assert kits<=scope['limits']['kit_launches'] and reserved<=scope['limits']['physics_calls'] and accounted<=scope['limits']['owned_bytes'] and elapsed