interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tools / adapters / c-import

18 lines · 1232 bytes Raw Blame History
1#!/usr/bin/env python3
2"""Transparent host dispatch; parsing and hashing run in seeded native Omega."""
3from pathlib import Path
4import hashlib,json,os,sys
5root=Path(__file__).resolve().parents[2]
6if len(sys.argv)!=1:
7 print('C_IMPORT_BAD_COMMAND: use stdin source; no arguments',file=sys.stderr);raise SystemExit(64)
8try:
9 build=root/'build/L589';m=json.loads((build/'build.json').read_text());exe=build/'c-import'
10 if m['compiler_sha256']!='191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9':raise ValueError('compiler identity')
11 for rel,digest in m['inputs'].items():
12 if rel not in ['src/source-aware/vendor/sha256.om','src/adapters/c-u64-import.om']:raise ValueError('source closure')
13 if hashlib.sha256((root/rel).read_bytes()).hexdigest()!=digest:raise ValueError('changed source')
14 if set(m['inputs'])!={'src/source-aware/vendor/sha256.om','src/adapters/c-u64-import.om'}:raise ValueError('missing source')
15 if hashlib.sha256(exe.read_bytes()).hexdigest()!=m['binary_sha256']:raise ValueError('changed artifact')
16except (OSError,ValueError,KeyError) as exc:
17 print('C_IMPORT_STALE_OR_MISSING_BUILD: '+str(exc),file=sys.stderr);raise SystemExit(78)
18os.execv(exe,[str(exe)])