"""Small source-only Worker release; no scenes, observations, models or wheels. Output is a task-owned intermediate; caller removes its own staging after remote identity verification. Worker retains the installed source manifest. """ import argparse import hashlib import json import shutil from pathlib import Path def main(): parser = argparse.ArgumentParser() parser.add_argument("output", type=Path) args = parser.parse_args() root = Path(__file__).resolve().parents[1] if args.output.exists(): raise ValueError("Refusing to overwrite an existing release staging") sources = list((root / "simulation/semantic-learning").glob("*.py")) sources += [root / "simulation/semantic-learning/install.ps1"] sources += [ root / "simulation/ai-polygon" / name for name in ( "core_client.py", "local_state.py", "infrastructure_gaussian_sources.py", "infrastructure_sources.py", ) ] sources += [ root / "simulation/urban-mapping" / name for name in ("mapping.py", "validation.py") ] sources += [ root / "src/k1link/simulation/ai_polygon/semantic_objects.py", root / "src/k1link/simulation/ai_polygon/semantic_vectors.py", root / "src/k1link/simulation/ai_polygon/marking-templates.json", ] files = {p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in sources} identity = hashlib.sha256(json.dumps(files, sort_keys=True).encode()).hexdigest() args.output.mkdir(parents=True) for path in sources: shutil.copyfile(path, args.output / path.name) manifest = dict( schema_version="missioncore.semantic-learning-release/v1", id=identity, files=files, image="sha256:925b093545e15c270d95d4076139ad8ed48e790eccd9434a58495d58c97671d0", ) (args.output / "release.json").write_text(json.dumps(manifest, indent=2)) print( json.dumps( { "release": identity, "files": len(files), "bytes": sum(p.stat().st_size for p in args.output.iterdir()), } ) ) if __name__ == "__main__": main()