omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tools / adapters / retarget
| 1 | #!/usr/bin/env python3 |
| 2 | """Transparent host dispatch; decoding, family checks and retargeting run in seeded native Omega.""" |
| 3 | from pathlib import Path |
| 4 | import hashlib,json,os,sys |
| 5 | root=Path(__file__).resolve().parents[2] |
| 6 | closure={'src/source-aware/vendor/sha256.om','src/source-aware/core-v2.om','src/adapters/upper-retarget.om'} |
| 7 | try: |
| 8 | build=root/'build/L833';m=json.loads((build/'build.json').read_text());exe=build/'retarget' |
| 9 | if m['compiler_sha256']!='734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61':raise ValueError('compiler identity') |
| 10 | if set(m['inputs'])!=closure:raise ValueError('source closure') |
| 11 | for rel,digest in m['inputs'].items(): |
| 12 | if hashlib.sha256((root/rel).read_bytes()).hexdigest()!=digest:raise ValueError('changed source') |
| 13 | if hashlib.sha256(exe.read_bytes()).hexdigest()!=m['binary_sha256']:raise ValueError('changed artifact') |
| 14 | except (OSError,ValueError,KeyError) as exc: |
| 15 | print('RETARGET_STALE_OR_MISSING_BUILD: '+str(exc),file=sys.stderr);raise SystemExit(78) |
| 16 | # The member argument M is passed through; the native tool validates it (64 on refusal). |
| 17 | os.execv(exe,[str(exe)]+sys.argv[1:]) |