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 / om / evidence / README.md

108 lines · 8537 bytes Raw Blame History Rendered
1# om/evidence: seeded Omega port of omega_vector.c and omega_evidence.c
2
3`evidence.om` ports the computing parts of `src/omega_vector.c` (113 lines) and `src/omega_evidence.c`
4(195 lines) to seeded Omega (aien-dev/omega-mv#726, aien-dev/aien-architecture-mv#300/#316). The part
5above the line `note ==== parity harness` is the library: 13 functions with array parameters and integer
6results, bindable through the omega-bridge native call ABI v1. The part below it is a program-mode parity
7harness. The harness also performs the C's process and file effects, because Omega allows host words
8only in program mode.
9
10Reproduce from a fresh clone:
11
12```
13OMEGA_OMC=/path/to/seed/out/omc [OMEGA_BRIDGE=/path/to/omega-bridge@012860db] sh om/evidence/parity/run.sh
14```
15
16`run.sh` compares the .om output with C oracle hashes recorded in `parity/expected.txt`. The C oracle
17driver is not in the tree. It takes about 6 s on the Spark. The pathtree and digtree listings omit
18directory sizes, which depend on the filesystem under `TMPDIR` (ext4 and tmpfs differ), so any `TMPDIR` works.
19
20## What the C files contain, and what is ported
21
22The task spec described "vector construction/hashing" over vectors of 0..4096 elements and "evidence
23record formatting" with random fields. The C does not match that description. This port follows the C:
24
25| C function | port | notes |
26|---|---|---|
27| `omega_vector_spec_init` | `vecspec` | name `strncpy` 63, SHA-256 of `"OMEGA_VECADD_U32"` ‖ width u16 LE ‖ count u32 LE ‖ overflow u8; the four fixed fields come back in `fld` |
28| `omega_vector_oracle_u32` | `vecadd` | |
29| `omega_vector_verify_oracle` | `vecver` | `idx` is written only on a mismatch |
30| `omega_vector_generate_deterministic` | `vecgen` | |
31| `omega_vector_build_spec_graph` | **not ported** | builds an OmegaGraph through `omega_core.c`/`omega_canonical.c` (`omega_build_*`, `omega_compute_semantic_id`). It is a port of the graph core, not of this file; it has 1 caller (`callsites.txt`) |
32| `trim_line` + `popen_read_line` length rule, `omega_evidence_physics_commit` | `lnacc` | operates on the 256-byte buffer `fgets` filled |
33| `omega_evidence_run_commit` | `cmtacc` | |
34| `omega_evidence_run_id` | `runid` | `gmtime_r` (civil-from-days) + `strftime("%Y%m%dT%H%M%SZ")` + `"-"` + sha or `"unknown"` |
35| `omega_evidence_path` | `evpath` | the string and both length limits; `mkdir_p_for_file` stays with the caller (harness: `mkdirp`) |
36| `omega_evidence_write_digest` | `digrel` + `shainit/shaupd/shafin` | the content name; the `O_EXCL` 0444 create and write loop stay with the caller (harness: `excl`) |
37| `omega_evidence_hardware_from_nvrm` | `hwhex` | `compute_class`/`sm_version` are copies and `alias` is the literal `"sm_121"`, so both stay with the caller |
38| `omega_evidence_tree_dirty` | **caller** | "any line from popen, or popen failed" has no computation to port; the harness reproduces it |
39| `omega_evidence_self_binary` | **not ported** | readlink(`/proc/self/exe`) + `getenv("OUT_DIR")` + `access`, which are effects only. It is not in the corpus: its result depends on the running binary |
40
41`omega_evidence.h` also declares `omega_run_m4_gates` .. `omega_get_m19_gate_snapshot`. These are
42defined in `tools/omegatool.c`, not in `omega_evidence.c`, and are out of scope.
43
44SHA-256 is adapted from `tools/zero-legacy/sha256.om` (arch-316-closure), with the state moved into
45parameters. There is no `import`, so the code is copied. `om/sha256/sha256.om` (bound as `omega_omsha`,
46already used by `src/sha256.c`) is the other existing Omega SHA-256. A cutover can call it instead of
47`shainit/shaupd/shafin`.
48
49## Oracle
50
51The C at omega-mv `acb3f15cd`: `omega_vector.c` `77057d59…7ed1`, `omega_vector.h` `b50a9218…9f43`,
52`omega_evidence.c` `7d533625…fa94`, `omega_evidence.h` `57b3e231…94c0`, `sha256.c` `ea8ae1c8…1ed15` (which
53itself calls `om/sha256` through `src/omega_om_units.inc`). `nvrm.h` comes from physics `048e5f5e`
54(physics.lock). Compiler: gcc 13.3.0 `-std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2`, the Makefile
55CFLAGS, aarch64. `.text` sha256: omega_vector `124ee068…d23d`, omega_evidence `dc7725ea…adb`. The objects
56are unchanged. The driver interposes `popen`/`pclose`/`time` at link time: `popen` returns the record's
57bytes through `fmemopen`, so `fgets` is the real libc one. `run_id` runs in a forked child per record,
58because it is cached in a static. `physics_commit` reads a real `physics.lock` file. `path` and
59`write_digest` run for real in an empty directory, and the tree they leave is compared as well (names,
60types, modes, sizes and file sha256). In program mode the harness does the same effects with the same
61flags (`O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC`, mode 0444, directories 0755, umask 022).
62
63omc sha256 `3ad9f10f…3194` (the previous pins `b4f45121…9b55`, `be8c5130…448a`, `24caacf4…abb7`, `90c8884c…3983`, `469532a5…79bc`, `1578b357…dbe1` and `62775d2a…712b` emit the same bytes). `evidence.om` compiles to a 35,032-byte program.
64
65| stream | function(s) | records | result |
66|---|---|---|---|
67| vspec | `vecspec` | 300: NULL name, n 0, n 1/2/4096/2^31/2^32-1, NUL inside the name, 60..67-byte names around the 63 cut, random 0..100-byte names | 300/300 |
68| vadd | `vecadd` `vecver` | 500 vectors, n 0..4096 (0, 1, 2, 4095, 4096), wrap-heavy inputs, exact, 1-bit flip, all poison, last element, two mismatches | 500/500 (c bytes, rc, first index) |
69| vgen | `vecgen` | 40 lengths 0..4096 | 40/40 (a, b, c) |
70| line | `cmtacc` `lnacc` | 324: run_commit with popen ok/NULL, physics.lock present/absent (n 0..300, trimmed length n-2..n), tree_dirty; empty, `\n` only, CR/space trims, 39/41 chars, NUL inside, >255 bytes, two lines | 324/324 |
71| runid | `runid` | 200: years 1 and 9999, the epoch, -1, 2^31 edges, random; good, bad and failing sha lines | 200/200 |
72| hw | `hwhex` | 100: NULL rm, zero and random uuids | 100/100 |
73| path | `evpath` | 300: NULL rel, n 0, path length 1022..1025 around the 1024 limit, n = len-1/len/len+1, random | 300/300 + tree (7,676 lines) |
74| digest | `digrel` `sha*` | 200: NULL stem/ext/buf (len 0 accepted, len 5 refused), rel length around 768, buffer 0..20000 with 55/56/63/64/4096/4097/8192 edges, exact repeats (rc 1) | 200/200 + tree (1,880 lines) |
75
76Sixteen small mutants are part of the verdict. Each must change its stream's hash. All are killed, for
77example the overflow byte in the spec digest (280 lines), a 64-byte name cut (98), `trim_line` without
78CR (14), `>=` → `>` in the length rule (8), non-floor division for negative times (42), the leap month
79(14), uppercase hex (94), the 1024 limit (300), directory mode (pathtree), the EEXIST return (12), SHA
80padding at 55 bytes (17) and file mode (digtree). See `parity/run.sh`.
81
82## Limits
83
84- Fixed ABI arrays: vectors are at most 4096 uint32 (16384 LE bytes). A larger `n` traps 3 where the C
85 would loop over the caller's arrays. A name enters as its first 64 bytes, a `relpath` as 1024 bytes,
86 stem and ext as 768 bytes each, the fgets buffer as 256 bytes, the run id as 96 bytes. Longer C
87 strings give -1 in the C anyway, so the adapter passes the length and the port refuses before it
88 reads past the array.
89- NULL pointers cannot be expressed. `vecspec` takes `has` for a NULL name. In `evpath` and `digrel`,
90 the NULL `relpath`, `stem`, `ext`, `out` and `buf`-with-`len`, and `n == 0`, are the adapter's
91 checks, as the harness does them.
92- `vecspec` `n` above 2^32-1 traps 5 (the C parameter is uint32). `runid` `secs` outside years 1..9999
93 traps 4 (glibc `%Y` beyond that is not modelled). A 256-byte fgets buffer without a NUL traps 4 (fgets
94 always writes one).
95- `evpath` returns -2 when the path is built but does not fit `n`. The C still creates the directories
96 in that case, so the adapter must call `mkdir_p` before refusing.
97- `shaupd` takes multiples of 64 bytes (trap 4 otherwise). Callers pass 4096-byte pieces and give the
98 rest to `shafin`.
99- Not ported: `omega_vector_build_spec_graph`, `omega_evidence_self_binary`, and the effect halves
100 (popen, fopen, mkdir, open/write/unlink, the static run-id cache). No C file or caller changes here.
101 The C adapters, and removing the two objects through omega-bridge #8, are future work. A cutover that
102 keeps the C entry-point names as adapters needs no caller changes. `callsites.txt` lists the 150
103 callers (file:line) by function.
104
105## NOT_RUN
106
107- No GPU, model or serving test: nothing here runs on the device.
108- No `make test`. The C files and every C caller are unchanged.