"""Relocate only explicitly selected reproducible simulation caches, preserving every verified byte. Run --apply only while the simulation coordinator is idle. Original source packages, run evidence, credentials and scheduled-task configuration are untouched. """ import argparse import hashlib import json from pathlib import Path import shutil import subprocess def sha(path): with path.open('rb') as stream: return hashlib.file_digest(stream, 'sha256').hexdigest() def main(): parser=argparse.ArgumentParser() parser.add_argument('--runtime',type=Path,required=True) parser.add_argument('--destination',type=Path,required=True) parser.add_argument('--apply',action='store_true') parser.add_argument('--cache',choices=['project','isaac-derived-data'],default='project') parser.add_argument('--fresh',action='store_true') args=parser.parse_args() state=args.runtime/'state' source=(state/'project-packages' if args.cache=='project' else args.runtime/'isaac-sim-6.1.0/kit/cache/DerivedDataCache') if args.fresh and args.cache!='isaac-derived-data': raise ValueError('Fresh cache is reserved for invalidated renderer-derived data') for name in ('active.json','editor-active.json','route-active.json'): if (state/name).exists(): raise RuntimeError('Worker must be idle: '+name) if source.is_symlink() or source.is_junction(): raise RuntimeError('Cache already redirected; inspect its destination') target=args.destination.resolve() if target==source.resolve() or source.resolve() in target.parents: raise ValueError('Destination must be outside the source cache') files=sorted(p for p in source.rglob('*') if p.is_file()) if any(p.is_symlink() or p.is_junction() for p in source.rglob('*')): raise RuntimeError('Nested cache links are unsupported') size=sum(p.stat().st_size for p in files) existing=next(p for p in [target,*target.parents] if p.exists()) report=dict(source=str(source),destination=str(target),files=len(files),bytes=size, destination_free_bytes=shutil.disk_usage(existing).free,applied=False) if report['destination_free_bytes']