"""Single guarded phase-one probe; no automatic retry or real-part expansion.""" import hashlib import json import os from pathlib import Path import resource import sys import time from gre24_job_guard import supervise, save def main(): root = Path(sys.argv[1]).resolve() settings = json.loads((root/'settings-before-run.json').read_text()) freeze = json.loads((root/'source-freeze.json').read_text()) for row in freeze: assert hashlib.sha256(Path(row['path']).read_bytes()).hexdigest() == row['sha256'] assert not (root/'launch.json').exists(), 'No duplicate launch' resource.setrlimit(resource.RLIMIT_CPU, (300, 7200)) save(root/'launch.json', {'pid': os.getpid(), 'unix': time.time(), 'scope': settings['scope'], 'source_pins_pass': True}) save(root/'ledger.json', {'cpu_seconds_charged': 600., 'attempts': [], 'allowances': {'all_preparation_cpu_seconds_reserved': 300., 'supervisor_cpu_seconds_reserved': 300.}, 'note': '600 is a conservative reserved charge, not measured CPU. Worker measured separately; no prior scientific attempt.'}) receipt = supervise([sys.executable, str(Path(__file__).with_name('phase1_wallpair_probe.py')), str(root)], root, 'synthetic', {'job_cpu_seconds': 6500, 'job_wall_seconds': 1800, 'tree_rss_bytes': 1024**3, 'max_processes': 1, 'disk_bytes': 1024**3, 'total_cpu_seconds': 7200}, poll=.1) own = resource.getrusage(resource.RUSAGE_SELF) save(root/'guard-complete.json', {'status': receipt['status'], 'worker_cpu_seconds': receipt['cpu_seconds'], 'supervisor_measured_cpu_seconds': own.ru_utime+own.ru_stime, 'charged_with_preparation_and_supervisor_reserves': 600.+receipt['cpu_seconds'], 'total_cap_seconds': 7200, 'preparation_and_supervisor_each_reserved_seconds': 300, 'no_real_parts_launched': True, 'no_retry': True}) return 0 if receipt['status'] == 'PASS' else 1 if __name__ == '__main__': raise SystemExit(main())