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 / seed / host / README.md

256 lines · 15153 bytes Raw Blame History Rendered
1# Native host operations
2
3Drake authorized extending Omega before rewriting benchmarks-mv on 2026-10-23,
4with no outside implementation help. These operations are implemented in
5`seed/omc/omc.om`. That Omega compiler emits the machine instructions itself.
6The seed chain builds it and it rebuilds itself to identical bytes. No C/Rust
7implementation, translator, external model, foreign compiler, assembler or
8linker implements or builds these additions.
9
10The existing shell seed loader remains the first bootstrap step, as described
11in `seed/README.md`. Shell scripts coordinate builds and tests; they do not
12implement the host operations. Programs call the Linux ARM64 kernel directly,
13as the original `read`, `write` and `exit` already do. This is Linux-hosted
14operation, not a native AienOS qualification or a GPU qualification.
15
16The language contract is [OMEGESE section 10](../../docs/one_layer/OMEGESE.md).
17
18## CPU scheduler words (draft)
19
20`cpuset`, `cpuget`, `cpunow`, `setprio` and `getprio` provide checked Linux CPU
21affinity and priority without a taskset/nice child wrapper. They are program-only
22on AArch64 and x86linux, retain kernel permissions and return minus errno.
23See [the draft contract](../../spec/omegese-cpu-workers.md) and the complete
24`seed/host/affinity/sched.cases` gate, included in `check.sh`.
25
26## Qualification
27
28From the repository root on Linux ARM64:
29
30```sh
31make -j2 build/omegese/omegese build/omega_emit/omega_emit build/checker2/checker2
32quiet-build sh seed/host/check.sh
33```
34
35On a machine without the Spark build coordinator, run the script directly.
36Missing IR oracles return `NOT_RUN` with status 3 before rebuilding; they cannot
37produce host qualification. The script rebuilds the seed chain, proves compiler
38self-reproduction, runs the independent C-reference IR gate, exercises native
39Omega fixtures, rejects malformed inputs, and compares the reviewed original
40fixture baseline against the original native parent. The fixture gate itself is
41`seed/host/gate.om`, compiled by `seed/out/omc`; the remaining shell step only
42builds and launches it.
43
44The `devcall` fixture uses image-backed parameter storage and a harmless memfd,
45not a device descriptor. It requires Linux ENOTTY for 16384-byte, 55888-byte
46and inclusive 1048576-byte spans, and trap 3 for 1048577 bytes or a slice past
47the array. The same host check runs `devcall-mutants.cases` through the Omega
48conductor and requires attribution of both killed compiler mutants:
49an off-by-one rejection at the cap and a removed cap check. No GPU is opened.
50
51Verified on the Spark on 2026-10-23:
52
53- Native file create/read/write/seek/sync/chmod/close/unlink and errno checks.
54- Current-directory change, file creation below it and unlink through the
55 native `chdir` word.
56- Monotonic nanoseconds, realtime nanoseconds and a measured native sleep.
57- Argument copying, including empty arguments, spaces, UTF-8 bytes, and refusal
58 of short output buffers without modifying them.
59- Socket exchange between native Omega processes, including local sockets and
60 TCP loopback on a kernel-selected ephemeral port.
61- Poll timeouts, fork, accept, exec with exact arguments, exec failure, pipes,
62 descriptor duplication, process termination and child reaping.
63- Directory creation/enumeration/removal, file metadata and no-replace rename.
64- Current-directory and symbolic-link reads with explicit count conventions,
65 nonzero slice offsets, truncation checks, overlapping buffers and errno checks.
66- Socket options verified by the changed bind result on an ephemeral UDP
67 loopback port, including readonly option bytes and invalid options.
68- Forty-one negative controls for bounds, malformed packets, readonly arrays,
69 wrong types, invalid paths and use outside program mode.
70- The baseline in `original-fixtures.tsv` pins paths and observed parent statuses.
71 Its 62 cases retain identical machine code, refusal status and diagnostics.
72 This is the actual selection at `ec07d25d`; older prose incorrectly said 70.
73
74Fixtures run in a unique temporary directory under `build/seed/host/`. The
75network test connects only to its own local server. Process tests reap their
76children. No service is installed or changed. `timeout` only bounds test
77processes; timed operations inside the tests use the emitted native code.
78
79Offline gate integrity controls (temporary repositories, no services or GPU):
80
81```sh
82nice -n 19 python3 seed/host/test_gate_integrity.py
83```
84
85They exercise recursive and long secret searches, tracked generated paths,
86search errors, missing/empty/duplicate corpus obligations, common compiler
87refusals, and missing IR oracles. The secret gate checks all tracked paths
88(including build output), plus untracked paths outside root `build/` and `.git/`;
89its manifest forbids cache reuse across commits.
90
91### Packed-list hostile ingress (#671)
92
93`seed/qualification/security673/` feeds runtime packets, not compile-time
94constants, to `execprog`. `packet-corpus.om` writes one packet per mode byte;
95`pkt-consumer.om` reads stdin and passes the bytes, or only the first K bytes
96when given one decimal argument, to `execprog` unchanged. `check.sh` runs
97`packets.cases` through the OM-2 conductor: 16 rows prove each committed fixture
98in `packets/` equals the generator output, 16 rows run the modes (4 valid
99packets, including the 1024-record and the exact 65536-byte exec limits, and 12
100malformed ones: count 0, 1025 (bare and with 1025 records) and 65535, truncated,
101over-declared and 65535-byte records, a trailing byte, an empty first record,
102zero bytes inside and after the path, and a 65537-byte packet), 28 rows truncate
103the 27-byte echo packet at every length, and 5 rows run the 1024-record,
1041025-record, 65537-byte, 65536-byte and echo packets through the x86 decoder
105(`xhpack`, the consumer composed after `seed/host/execenv/x86-target.om` and run
106through binfmt qemu-x86_64: emulator evidence). Expected exits come from the
107format rules in OMEGESE section 10; every malformed packet must trap 3 (exit
108103) before any exec.
109
110`packets-mutant.cases` builds three compilers, each without one length check of
111the decoder (`hpack` in `seed/omc/omc.om`): the packet byte bound, the record
112count bound, and exact consumption. Each mutant executes the one packet that
113only its check refuses, so `check.sh` requires three exact `FAIL run exit=0
114expected=103` verdicts. Removing the record-length-versus-remaining check is
115not detected by exit status: the zero-byte and exact-consumption checks still
116trap every over-declared record, so that check only bounds how far the decoder
117reads.
118
119### Bounded networking additions (#788)
120
121The source adds `peercred` (keyword 220), `pollfds` (221), and `sendmsg` (222).
122`sockopt` now accepts only the scalar transport allowlist in OMEGESE section 10.
123The existing `socknew`, `bind`, `listen`, `accept` (`accept4`), `connect`,
124`read`/`write`, `recv`/`send`, `waitio`, and `fclose` remain the base transport API.
125No host HTTP or JSON implementation is introduced.
126
127`tests/netdata.om` exercises Unix peer PID/UID/GID at a nonzero output offset,
128two-descriptor polling and timeout, private single-iovec `sendmsg`, deliberate
129short nonblocking sends, closed-peer `EPIPE` without SIGPIPE, descriptor reuse
130after repeated close, option allowlisting, and slice/record-size refusals.
131`tests/netpeer.om` creates distinct parent/child endpoints, compares peer PIDs
132independently, and checks nonzero offsets, untouched surrounding bytes,
133negative-timeout readiness and nested expression preservation. It exposed an
134older `getppid` lowering error: syscall 110 is `timer_settime` on Linux ARM64,
135not `getppid` (173). The old fixture only rejected zero, silently accepting a
136negative error. The lowering and positive-PID assertion are corrected here.
137Run the candidate host gate without replacing the committed compiler:
138
139```sh
140nice -n 19 ionice -c3 sh -c 'seed/out/omc < seed/host/gate.om > build/seed/host/gate && chmod +x build/seed/host/gate && build/seed/host/gate /absolute/path/to/candidate-omc'
141OMC=/absolute/path/to/candidate-omc nice -n 19 ionice -c3 sh seed/host/negative.sh
142nice -n 19 ionice -c3 python3 seed/host/net-mutant.py
143nice -n 19 ionice -c3 sh seed/omc/gate18.sh
144```
145
146This is candidate host evidence, not a reseed, compiler fixpoint, release pin,
147or hardware qualification. Compiler integration owns the batch reseed.
148`net-mutant.py` is a verifier-only Python runner. It compiles each original and
149wrong-word source through the committed seed (or `OMC` override), then requires
150the real fixture to pass the original and exit 1 for the mutant. Its controls
151restore the wrong `getppid` syscall and turn an option refusal into success.
152The host gate's compiler argument (`gate.om` argv[1]) applies to every compilation,
153including nested device/mapping refusal programs and generated identity fixtures;
154early candidate-only logs from before that correction contain mixed-compiler evidence.
155The Linux interface authorities are `asm-generic/unistd.h` (`ppoll` 73,
156`getsockopt` 209, `sendmsg` 211), `asm-generic/socket.h`, and `linux/tcp.h`.
157Instruction emission uses the existing Arm ARM forms; `STR` unsigned-offset
158stores private stack records, with `imm12` scaled by eight for 64-bit cells.
159Keyword pack verification used WolframLanguageEvaluator:
160`Table[{s,FromDigits[Reverse[ToCharacterCode[s]],256]},{s,{"peercred","pollfds","sendmsg"}}]`
161returned `{{"peercred",7234314147887146352},{"pollfds",32480013390212976},{"sendmsg",29118836274783603}}`.
162
163### Typed VFIO IRQ and eventfd additions
164
165The current-main VFIO extension uses `vfioctl`228, `vfiomap`229,
166`vfiomapw`230, `eventfd`231 and `vfioirq`232. These do not collide with
167x86efi's scoped `efi`178, `qty`223, `peername`224 or `fma`227.
168The original extension used driver-pinned base
169`397e67040fb74853c6814097fe02ae4e1ebd6f66`; that historical pin is not
170rewritten. The exact acquisition, invalidation, bounded payload and masking
171contracts are in [MAPPING.md](MAPPING.md#typed-irq-and-eventfd-extension).
172These VFIO words are AArch64 program-mode only: function mode refuses them,
173and no hosted x86 VFIO implementation or arbitrary syscall is added.
174
175```sh
176taskset -c 10-14 nice -n 10 sh seed/omega-from-seed.sh
177taskset -c 10-14 nice -n 10 sh seed/host/irq.sh
178taskset -c 10-14 nice -n 10 sh seed/omc/gate18.sh
179```
180
181`irq.sh` also runs from the normal host gate. It compiles positive cases,
182ten native compiler refusals, real nonblocking eventfd read/write/poll/close
183behavior, a GCC UAPI byte-layout differential, fifteen runtime refusals, and
184wrong-word compiler mutants. A ptrace-only fixture supplies an acquired-kind
185stand-in while every real IRQ ioctl reaches an ordinary memfd and returns
186ENOTTY. It also exercises fd numbers above1024 and a full128-slot table without
187opening or closing a real VFIO resource. The C fixture and Python mutant runner
188are independent verification tools, never linked into product code.
189The QEMU tier is user-mode, VFIO-less, and cannot establish physical delivery.
190Real device interrupt behavior remains NOT_RUN pending an authorized window.
191
192WolframLanguageEvaluator query
193`{FromDigits[Reverse[ToCharacterCode["eventfd"]],256],FromDigits[Reverse[ToCharacterCode["vfioirq"]],256],BitOr[524288,2048],20+4*64}`
194returned `{28260147925448293,31932469534615158,526336,276}`:
195the keyword packs, CLOEXEC|NONBLOCK flags, and bounded IRQ record bytes.
196
197
198## Connected peer metadata
199
200`peername fd A off n` (keyword 224) queries the peer of an existing process
201descriptor. Its types, writable slice validation and negative errno behavior
202match `sockname`; success returns the full native Linux sockaddr length even
203when the supplied slice truncates it. Empty slices are permitted at array end.
204Neither word acquires or connects a socket. `accept` keeps its existing API.
205Keyword encoding was checked with the mounted WolframLanguageEvaluator:
206`FromDigits[Reverse[ToCharacterCode["peername"]],256] -> 7308604897285727600`.
207
208The implementation shares `hbuffer`'s private 32-bit socklen with `sockname`;
209checked byte-array capacities fit that representation. Linux source authority:
210[v6.12 asm-generic syscall table](https://github.com/torvalds/linux/blob/v6.12/include/uapi/asm-generic/unistd.h)
211assigns getpeername 205 and getsockname 204; under `target x86linux` the same
212word lowers to x86-64 getpeername 52 (getsockname 51) from
213[v6.17 `syscall_64.tbl`](https://github.com/torvalds/linux/blob/v6.17/arch/x86/entry/syscalls/syscall_64.tbl);
214[`move_addr_to_user`](https://github.com/torvalds/linux/blob/v6.12/net/socket.c)
215copies only the bounded prefix, permits zero capacity, and returns full length.
216The [getpeername manual](https://man7.org/linux/man-pages/man2/getpeername.2.html)
217defines EBADF, ENOTSOCK and ENOTCONN. Omega preserves raw negative syscall
218errno, rather than libc's -1/errno convention.
219
220`tests/peername.om` compares an accepted TCP peer with the independently queried
221client endpoint on loopback, checks a distinct local endpoint, offset sentinels,
222short/empty slices, closed descriptors, pipes and unconnected sockets.
223The host gate also requires bounds traps; negative.sh covers typing, readonly
224arrays and function mode. net-mutant.py replaces getpeername with getsockname
225and requires the real fixture to reject that compiler.
226
227Transport addresses are not user authentication or an original client identity
228behind a proxy. Consumers must validate length and family, retain descriptor
229lifetime control, and preserve their existing trusted-proxy boundary. This
230compiler change neither activates gateway policy nor trusts forwarding headers.
231
232## Source authority and limits
233
234Instruction forms come from the existing hand-audited instruction table in
235`seed/rung2/table.s2`, which identifies Arm manual sections. Linux interfaces
236were checked against the installed ARM64 headers: `asm/unistd.h`,
237`asm-generic/unistd.h`, `asm/fcntl.h`, `asm-generic/fcntl.h`,
238`asm-generic/stat.h`, `asm-generic/poll.h` and `linux/time.h`. The architecture
239header overrides generic constants: ARM64 `O_DIRECTORY` is 040000 octal.
240These are interface references, not imported implementation code.
241
242The additional keywords 132 through 134 are `cwd`, `readlnk` and `sockopt`.
243Installed ARM64 `asm/unistd.h` includes the generic definitions for `getcwd`
244(17), `readlinkat` (78) and `setsockopt` (208). `linux/fcntl.h` supplies
245`AT_FDCWD`; ARM64 `asm/socket.h` includes the generic `SOL_SOCKET` and
246`SO_REUSEADDR` definitions. Adding these reserved words changes the compiler
247digest. The reviewed baseline has 62 original fixtures after the old content
248filters, not the 70 previously stated here. The new fixed manifest prevents
249missing files, changed skip boundaries or common compiler refusals from silently
250shrinking that obligation. New reserved words cannot be used as ordinary identifiers.
251
252This extension supplies host facilities for the benchmark migration. It does
253not implement a JSON library, floating-point types, the full benchmark suite,
254or the sibling runtime's in-process interfaces. Existing numeric, array,
255register and loop capacities remain in force. The language has no exposed
256pointers or arbitrary-syscall escape hatch.