Files
TheTree_mock/docs/plans/original-completion-2026-10-02/execution/drive-offload-canonical-r05-20261015/tree-offload-canonical-r05-retire.py
T

16 lines
2.6 KiB
Python

globals().update(__import__('runpy').run_path('/private/tmp/tree-offload-canonical-r05.py',run_name='offload_library'))
m=json.loads((D/'MANIFEST.json').read_bytes());s=json.loads((D/'SOURCE_RECHECK.json').read_bytes());assert s['all_sources_rehashed_and_unchanged']and s['manifest_sha256']==sha(D/'MANIFEST.json')and time.time()-s['unix']<3600;assert json.loads((D/'COVERAGE_CHECK.json').read_bytes())['all_objects_available_in_verified_r04_cloud']
for n in ['MANIFEST.json','CLOUD_OBJECT_REUSE.json','restore.py','RESTORE.md']:
j=json.loads((D/('READBACK-'+n+'.json')).read_bytes());assert j['actual_cloud_readback_verified']and j['sha256']==sha(D/n)
assert not(D/'RETIREMENT.json').exists();check_idle();current=B/'p08-03-code/.runtime/P08-03/build';alias=parent/'validated-current-proof-alias';link=os.readlink(alias);assert Path(link).is_dir();protected={str(x):sha(x)for x in current.rglob('*.json')if 'stage'not in x.parts and 'profile'not in x.parts};assert protected
for x in m['members']:
q=B/x['path'];st=q.lstat();assert not q.is_symlink()and(q.is_file()if x['type']=='file'else q.is_dir());assert st.st_mtime_ns==x['mtime_ns']and st.st_mode&0o7777==x['mode'];assert x['type']!='file'or st.st_size==x['bytes']
free=shutil.disk_usage(R).free;save(D/'RETIREMENT_INTENT.json',dict(unix=time.time(),manifest_sha256=sha(D/'MANIFEST.json'),all_sources_rehashed_and_stat_rechecked=True,only_cold_canonical_roots=m['roots'],current_alias_target=link,current_build_json_guards=protected))
for x in m['members']:
if x['type']=='file':(B/x['path']).unlink()
for x in sorted(m['members'],key=lambda x:len(Path(x['path']).parts),reverse=True):
if x['type']=='directory':(B/x['path']).rmdir()
assert os.readlink(alias)==link and Path(link).is_dir();assert all(sha(Path(p))==h for p,h in protected.items());assert all(not(B/x).exists()for x in m['roots'])
save(parent/'CLOUD_HISTORY_R05.json',dict(state='cloud_archived',roots=m['roots'],folder_url='https://drive.google.com/drive/folders/1Xa2b6rQmwBFq4jWIDFcJgiCbcNYfWXsK',manifest=str(D/'MANIFEST.json'),restore=str(D/'RESTORE.md'),source_archive_sha256=m['source_r04_archive_sha256'],alias_and_current_build_retained=True,formal_credit=0))
r=dict(unix=time.time(),files=m['files'],logical_bytes=m['logical_bytes'],free_before_selection=m['free_before'],free_before_retirement=free,free_after=shutil.disk_usage(R).free,net_free_change_from_selection=shutil.disk_usage(R).free-m['free_before'],new_payload_upload_bytes=0,all_sources_and_cloud_object_hashes_verified=True,current_alias_and_build_receipts_unchanged=True,formal_credit=0);save(D/'RETIREMENT.json',r);print(json.dumps(r),flush=True)