interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / AUDIT_SCOPE.md

226 lines · 15065 bytes Raw Blame History Rendered
1# Audit scope
2
3Written for an outside, independent security audit. Revision described:
4`2954d46866f9867dea6d62853f68273773f01805`, which is `main` at
5`4ad48c45` plus the conformance change that keeps the CPU run off the GPU, 2026-11-05. Everything
6below is taken from the repository's own files at that revision. Every command under "Run every
7test" was run from a clean clone of that revision on 2026-11-05; the logs, the exit-code table and
8the tool versions are in `evidence/audit/2026-11-05-2954d46/`. Items marked NOT_RUN were not
9executed.
10
11## What this repository is
12
13Omega Bridge is a compiler written in Omega that emits executable C (GNU C11, POSIX) and Python 3
14from a checked, bounded subset of Omega (ABI v0). `src/native.om` generates C bindings so C, C++,
15Python, Rust, Zig and Go can call machine code produced by the seeded Omega compiler (native call
16ABI v1 for OM-1 units and ABI v2 for OM-2 units, `docs/NATIVE-ABI.md`). `tools/native
17--freestanding` emits an AArch64 object with no hosted runtime for pure integer-scalar OM-1 units
18and, since #45, for OM-2 units without host effects (outputs `freest` and `fapic`).
19`tools/native --target x86linux` emits hosted x86-64 SysV Linux bindings from a separately pinned
20x86 compiler; that path is EXERCISED under emulation only (`evidence/native-x86-be8c5130.json`)
21and native x86-64 execution is NOT_RUN. `src/gpu_adapter.om` is an opt-in GPU adapter that
22negotiates and admits artifacts; it opens no device and converts no host program. `max-cpu/` runs
23an Omega kernel as a Modular MAX 26.7.0 CPU custom op (status EXERCISED on a host CPU;
24`evidence/MAX-CPU/README.md`). The default target is Linux AArch64. There is no C or
25Python input frontend. The Python under `tests/` and `conformance/` is test infrastructure and
26does not ship. Status: local differential tests and caller demos; independent review required
27before release.
28
29## What to review, in priority order
30
311. `src/toc.om`. Lexer, type and name tables, typed expression nodes, and the C and Python
32 emitters. Check that every runtime check in the source language (array bounds, signed
33 overflow trap 1, division trap 2, shift trap 7, loop guards, 128-active-call limit) is emitted
34 in both targets, that capacity exhaustion refuses with error 13, 14, 23 or 24 and writes no
35 partial output, and that refused features (`docs/CAPABILITIES.md`) are refused.
362. `tools/bridge`. The shell entry point snapshots the input once, runs the pinned seed's
37 whole-unit check, then generates from the same bytes, and refuses to run if
38 `build/compiler.sha256` no longer matches. Check the snapshot cannot be swapped (time of check
39 to time of use) and that output reaches stdout only after success.
403. `src/native.om` and `docs/NATIVE-ABI.md`. Generated C bindings for foreign callers: argument
41 and length marshalling, aliasing of inputs and results, stack size requirement (eight MiB),
42 BTI on C callers.
434. `src/gpu_adapter.om` and `docs/GPU-ADAPTER.md`. A `key=value` wire protocol on stdin/stdout.
44 Check that unknown, duplicate or out-of-order keys are refused, that `REFUSE` is final, and
45 that the adapter never returns a device pointer, address or handle.
465. `tools/bootstrap.sh`, `tools/build.sh`, `tools/build-gpu-adapter.sh`. Supply chain: fetch of
47 the pinned Omega commit, seed growth, fixpoint check, and sha256 enforcement of `OMEGA_SEED`.
486. `tools/run-device-window.sh` and `conformance/`. Device-run wrapper (AGENTS.md: never resets
49 the GPU, changes the driver or touches a serving process) and the Omega versus Modular MAX
50 conformance test suite.
517. Test integrity: `tools/test.sh`, `tests/differential.py`, `tests/refusals.py`,
52 `tests/attachments.py`, `tests/controls.py`, `tests/robustness.py`, `tests/native/run.sh`,
53 `tests/native/v2/run.sh` (ABI v2 and freestanding), `tests/native/kinds.sh` (f32 and ushort
54 array kinds), `tests/native/test_freestanding.py`, `tests/native/x86/run.sh` (x86linux,
55 EMULATED), `tests/native/test_build_failures.sh`, `tests/gpu/test_gpu_adapter.py`,
56 `max-cpu/run.sh` and `max-cpu/test_run_evidence.py`.
57
58`.github/workflows/ci.yml` (added by the audit-readiness change) replays the compiler from
59source with `tools/bootstrap.sh` and runs `sh tools/test.sh` on a GitHub-hosted arm64 runner;
60`tests/gpu` stays NOT_RUN there. A second job publishes an SPDX SBOM artifact. Every action is
61pinned by commit sha and the token is read-only.
62
63## Trust boundaries
64
65- Untrusted input: the `.om` source given to `tools/bridge` (size limit in `docs/CAPABILITIES.md`),
66 requests on the GPU adapter's stdin, and arguments passed by foreign callers to generated bindings.
67- Trusted: the pinned seed compiler (sha256 enforced) and the Omega source commit it grows from;
68 the C compiler and Python interpreter that consume generated output.
69- The README tells users to inspect generated output before linking or importing it. Conversion
70 writes isolated temporary build files and never installs or replaces an application.
71- Isolated: the GPU adapter has no daemon, no environment hook, no network, no telemetry and no
72 install path.
73
74## Threat model summary
75
76- Assets: the safety properties of the Omega source (bounds, overflow, loop guards) carried into
77 generated C and Python; the integrity of the compiler chain; callers' memory.
78- Attackers considered: a hostile or malformed `.om` input; a hostile GPU adapter request; a
79 substituted seed compiler; byte-prefix truncations and capacity-exhausting sources (225 cases in
80 `tests/robustness.py` per `evidence/README.md`).
81- Defended: whole-unit validation before either backend; refusal instead of partial output;
82 pinned compiler digests; checked bounds in generated code; differential testing of native vs C
83 (UBSan) vs Python, with AddressSanitizer on bounds mutants.
84- Not defended / explicitly out of scope (from the repository's own text): no independent
85 checker2 receipt, independent compiler audit, diverse double compilation, cross-architecture
86 verification, installer or public-release qualification; the bootstrap fixpoint is not DDC;
87 native and generated stack exhaustion thresholds differ; Python uses its host heap; no speedup
88 claim; GPU hardware execution NOT_RUN.
89
90## Build from source at a pin
91
92Needs Linux AArch64, `git`, `sh`, `file`, `sha256sum`, `gcc` and `python3`. The bootstrap uses no
93C compiler, assembler or linker.
94
95- Omega source commit (`docs/PROVENANCE.md`): `29b12760f4c962606411d6bf25032aedef063301`.
96- Bootstrap seed `build/bootstrap/omc` sha256:
97 `191b776ef98821597c3e30655da6d680a9b66edbc9ceaca3c39c61ea6df098e9`.
98- Seeded compiler for native call tests (`OMEGA_NATIVE_OMC`, omega-mv `seed/out/omc`) sha256:
99 `734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61`.
100
101```sh
102sh tools/bootstrap.sh # ends with: bootstrap fixpoint RC=0
103tools/build.sh # builds build/bridge from src/toc.om
104```
105
106`OMEGA_SOURCE` may point at an existing Omega checkout (read only); otherwise the bootstrap needs
107network access to the upstream repository. On a shared build host the README prefixes commands
108with `quiet-build`; without it, run the scripts directly.
109
110## Run every test
111
112Each command below lists every environment variable it reads; the values CI uses are in
113`.github/workflows/portable.yml`. `OMC` is omega-mv `seed/out/omc` (sha256 `734f0a39…`, the
114`PIN` line of `tools/native`), `OMC2` is omega-mv `hoist/865-main` @ `7286d61d`
115(`07820046…`), `HOST_OMC2` is #1008 @ `2992a68b` (`c000ec02…`), `XOMC` is the x86
116compiler (the `X86_PIN` line, `be8c5130…`), and `SOMC` is the
117seeded compiler for `tests/seeded*.py` and `tests/freest.py` (omega-mv `e5b32567`, `2c824805…`).
118The three native-v2 compiler roles are digest-checked. `DEVICE_OMC2` is the context-format
119compiler (`6d1b1cf5…`); `DEVICE_SOURCE` is its `seed/omc/omc.om`, checked by rebuilding the fingerprint.
120Exact pins and seed-only rebuilds: [AArch64 qualification](docs/NATIVE-ABI.md#aarch64-qualification).
121On the shared Spark, run every command below inside
122`bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10`.
123
124```sh
125tools/test.sh
126python3 tests/attachments.py
127OMEGA_NATIVE_OMC=$OMC sh tests/native/run.sh
128OMEGA_NATIVE_OMC=$OMC OMEGA_NATIVE_OMC2=$OMC2 OMEGA_NATIVE_HOST_OMC2=$HOST_OMC2 OMEGA_NATIVE_DEVICE_OMC2=$DEVICE_OMC2 OMEGA_NATIVE_OMC2_SOURCE=$DEVICE_SOURCE sh tests/native/v2/run.sh
129python3 tests/native/v2/test_verdict.py
130OMEGA_NATIVE_OMC=$OMC sh tests/native/kinds.sh
131OMEGA_NATIVE_OMC=$OMC sh tests/native/g1/run.sh
132OMEGA_NATIVE_OMC=$OMC OMEGA_NATIVE_X86_OMC=$XOMC QEMU_X86_64=/path/to/qemu-10.0.14/qemu-x86_64 \
133 OMEGA_NATIVE_X86_PYTHON=/path/to/x86/python3.12 OMEGA_NATIVE_X86_LIBPATH=/path/to/x86/python/lib \
134 sh tests/native/x86/run.sh
135OMEGA_NATIVE_OMC=$OMC ZIG=/path/to/zig GO=/path/to/go sh tests/native/test_build_failures.sh
136<same five x86 variables> OMEGA_NATIVE_X86_BAD_QEMU=/path/to/qemu-8.2.2/qemu-x86_64 \
137 python3 tests/native/x86/test_build_failures.py
138OMEGA_SEEDED_OMC=$SOMC OMEGA_SEED=build/bootstrap/omc python3 tests/seeded.py
139OMEGA_SEEDED_OMC=$SOMC python3 tests/seeded_float.py
140OMEGA_SEEDED_OMC=$SOMC OMEGA_SEED=build/bootstrap/omc FREEST_CUDAPP_ROOT=/path/to/CUDApp \
141 python3 tests/freest.py
142<same three> CC=x86_64-linux-gnu-gcc FREEST_RUNNER='qemu-x86_64 -L /usr/x86_64-linux-gnu' \
143 python3 tests/freest.py
144OMEGA_SEEDED_OMC=$SOMC OMEGA_SEED=build/bootstrap/omc python3 tests/freest_views.py
145OMEGA_SEED=build/bootstrap/omc sh tools/build-gpu-adapter.sh
146python3 tests/gpu/test_gpu_adapter.py
147MAXPY=/path/to/venv/bin/python conformance/run.sh # needs ../../cudapp built: make all
148python3 max-cpu/test_run_evidence.py
149MAXPY=/path/to/venv/bin/python OMEGA_REPO=/path/to/omega-mv max-cpu/run.sh
150conformance/run.sh --device
151tools/run-device-window.sh --ledger <ID>
152```
153
154- `tests/native/run.sh` prints `NATIVE-CALL PASS` only after all seven required callers build and
155 run; a missing toolchain prints NOT_RUN and exits nonzero.
156- `tests/native/v2/run.sh` covers ABI v2 (OM-2) bindings and the `--freestanding` objects
157 (`tests/native/test_freestanding_om2.py`, step 10b) and host-word gating (section 11). Without
158 any required compiler role it exits 2. All three roles are required; the current paired-compiler
159 PASS is in `evidence/native-v2-compiler-profile/`; the older audit receipt predates these gates.
160- `tests/native/x86/run.sh` and its controls are EMULATED only; physical x86-64 is NOT_RUN. The
161 suite refuses a QEMU that fails its `/proc/self/maps` and signal-frame probes; Ubuntu's
162 QEMU 8.2.2 is the known-bad oracle used by the refusal control.
163- `conformance/run.sh` without `--device` runs the CPU fixtures with `CUDA_VISIBLE_DEVICES=` and
164 `conformance/max_runner.py` refuses (exit 2) a CPU run that can see an accelerator. Before
165 `2954d46` the CPU run used whatever GPU was visible. `conformance/build.sh` exits 1 with
166 `CUDApp library missing` unless the sibling CUDApp (`CUDAPP`, default `../../cudapp`) is built.
167- `max-cpu/run.sh` needs `OMEGA_REPO`, an omega-mv clone containing `55f9b0af` and `ec07d25d`.
168 `max-cpu/mogg-cache-repro.sh` is an observation script, not a test.
169- `conformance/run.sh --device` and `tools/run-device-window.sh` need the NVIDIA GB10 on a DGX
170 Spark inside an authorized window.
171
172Results from a clean clone of `2954d46` on 2026-11-05 (Linux AArch64 host, rustc 1.98.1, Go
1731.27.3, Zig 0.13.0, GCC 13.3.0, MAX 26.7.0; `evidence/audit/2026-11-05-2954d46/`):
174
175| Command | Exit | Final line |
176|---|---|---|
177| `tools/test.sh` | 0 | `ALL SUITES RC=0` (113 + 50 + 2 + 7 + 225 = 397 cases, 0 failures) |
178| `tests/attachments.py` | 0 | `attachment cases=2 failures=0 RC=0` |
179| `tests/native/run.sh` | 0 | `NATIVE-CALL PASS (not run: none)` |
180| `tests/native/v2/run.sh` | 0 | `NATIVE-V2 PASS (not run: none)` |
181| `tests/native/v2/test_verdict.py` | 0 | 5 tests OK |
182| `tests/native/kinds.sh` | 0 | `NATIVE-KINDS PASS` |
183| `tests/native/g1/run.sh` | 0 | `G1-CALC PASS (not run: none)` |
184| `tests/native/x86/run.sh` | 0 | `NATIVE-X86 EMULATED PASS`; native x86 NOT_RUN |
185| `tests/native/test_build_failures.sh` | 0 | `PASS native callers: Zig and Go built and executed` |
186| `tests/native/x86/test_build_failures.py` | 0 | `NATIVE-X86 CONTROLS PASS (EMULATED; native x86 NOT_RUN)` |
187| `tests/seeded.py` | 0 | `SEEDED CONVERTER differential C/Python/native/x86 and pin/arithmetic/ABI controls PASS; device NOT_RUN` |
188| `tests/seeded_float.py` | 0 | `PASS seeded binary32 byte differential; …` |
189| `tests/freest.py`, AArch64 and x86 user-mode | 0, 0 | `PASS direct structural converter refusals …` |
190| `tools/build-gpu-adapter.sh`, `tests/gpu/test_gpu_adapter.py` | 0, 0 | `{"checks": 47, "fail": 0}` |
191| `conformance/run.sh` | 0 | `CONFORMANCE HARNESS PASS`; device runs NOT_RUN |
192| `max-cpu/test_run_evidence.py`, `max-cpu/run.sh` | 0, 0 | `OMEGA MAX CPU: PASS (controls green, negatives red as expected)` |
193| `conformance/run.sh --device`, `tools/run-device-window.sh` | — | NOT_RUN (GPU window not authorized for this refresh) |
194
195## Known limitations and NOT_RUN
196
197- Capacity limits: 32 functions, four parameters, eight globals (texts included), 32,768 decoded
198 text bytes, eight-character names, 4,194,304 bytes of output, 32 KiB local arrays per function.
199- Read-only text constants convert in the baseline `tools/bridge` only (`tests/text.py`); inline
200 text literals, floats, heap, concurrency, external calls and other targets are refused.
201- Native differential tests share the seed's checker; they are not independent frontends
202 (`docs/PROVENANCE.md`).
203- Intermediate red logs in `evidence/` are development traces; the final qualification is the
204 final manifest plus final gate output.
205- GPU hardware load and execution: NOT_RUN (`docs/GPU-SUPPORT-MATRIX.md`).
206
207## Dependencies and provenance
208
209- No lockfile. No compiler binary is committed; the bootstrap rebuilds it from source.
210- `src/toc.om` was recovered from omega `seed/toc/toc.om` at the pinned commit; original digest in
211 `docs/RECOVERY.json`. Inherited fixtures come from omega `seed/rung4/tests/` at the same commit.
212- Test oracles: GCC with UBSan and ASan, Python 3, Modular MAX for conformance and `max-cpu/`,
213 the Rust, Zig, Go and C++ caller toolchains, `x86_64-linux-gnu-gcc`, the QEMU 10.0.14 x86
214 user-mode oracle and the sibling CUDApp build. They do not ship.
215- External services: GitHub fetch of the pinned Omega commit at bootstrap; Python package index
216 for the MAX venv, if built.
217
218## Evidence
219
220Raw logs and manifests live in `evidence/` (numbered red and green logs, `manifest.json`,
221`differential-results.json`, `control-results.json`, `files.sha256`, `native-call-v1/`,
222`MAX-INTEROP/`, and the clean-clone runs of this document in `audit/2026-11-05-2954d46/`).
223AGENTS.md: keep the failing log beside the passing one, and never rewrite an
224existing evidence log. Cross-repository receipts, where filed, belong under
225`aien-dev/aien-receipts` `omega-bridge/<sha>/`; whether any exist is unknown from the repository.
226Receipts are append-only and never edited.