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 / lower-s2

19 lines · 1233 bytes Raw Blame History
1#!/usr/bin/env python3
2"""Transparent host dispatch; validation, hashing and S2 lowering run in seeded native Omega (spec/universal/translation-s2-v1.md)."""
3from pathlib import Path
4import hashlib,json,os,sys
5root=Path(__file__).resolve().parents[2]
6NAME='lower-s2'
7PIN='734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61'
8CLOSURE={'src/source-aware/vendor/sha256.om','src/source-aware/core-v3.om','src/adapters/upper-lower-s2.om'}
9# The optional NAME is passed through; the native tool validates it (64 on refusal).
10try:
11 build=root/'build/S2';m=json.loads((build/'build.json').read_text());exe=build/NAME;a=m['artifacts'][NAME]
12 if a['compiler_sha256']!=PIN:raise ValueError('compiler identity')
13 if set(a['inputs'])!=CLOSURE:raise ValueError('source closure')
14 for rel,digest in a['inputs'].items():
15 if hashlib.sha256((root/rel).read_bytes()).hexdigest()!=digest:raise ValueError('changed source '+rel)
16 if hashlib.sha256(exe.read_bytes()).hexdigest()!=a['binary_sha256']:raise ValueError('changed artifact')
17except (OSError,ValueError,KeyError,TypeError) as exc:
18 print('LOWER_STALE_OR_MISSING_BUILD: '+str(exc),file=sys.stderr);raise SystemExit(78)
19os.execv(exe,[str(exe)]+sys.argv[1:])