omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / evidence / device-window / DRA-441 / execenv-proposal.md
| 1 | # Proposal: an `execenv` whose environment packet is sized from its input |
| 2 | |
| 3 | Status: PROPOSED (omega-mv compiler extension). Not implemented. |
| 4 | |
| 5 | ## Why |
| 6 | |
| 7 | `tools/run-device-window.om` must start `spark-window`, `git` and the probe |
| 8 | programs with the caller's environment and a `PATH` search. omega-mv |
| 9 | `execenv A off n B off m` (docs/one_layer/OMEGESE.md, keyword id 233) takes the |
| 10 | environment as packet B with a count of 1..64 records and at most 4096 bytes. |
| 11 | The environment on spark-b87b had 78 entries and 4796 bytes on 2026-11-16, so |
| 12 | the driver cannot use `execenv` and runs every child as |
| 13 | `/usr/bin/env -i -- <NAME=VALUE ...> CMD ...` through `execprog`. |
| 14 | |
| 15 | That makes `/usr/bin/env` a host dependency of the build-free run path: |
| 16 | GNU coreutils 9.4 on spark-b87b, sha256 |
| 17 | `d38fa7db8452a564868961fd5e9a0aa787095676b0fd6e497b766ac40ec65c8b`. It does two |
| 18 | things for us: it sets the child's environment from its arguments and it finds |
| 19 | `CMD` on `PATH`. |
| 20 | |
| 21 | The 64-record and 4096-byte limits are fixed sizes, not machine boundaries: the |
| 22 | kernel's own boundary is the argument-plus-environment space (a quarter of the |
| 23 | stack limit, never below 32 pages) and 131072 bytes per string |
| 24 | (`MAX_ARG_STRLEN`). The execprog packet has the same shape of limit (65536 |
| 25 | bytes, 1024 records, u16 record lengths). |
| 26 | |
| 27 | ## Change |
| 28 | |
| 29 | 1. `execenv`: size the environment packet from its input. Keep the packet |
| 30 | form (u16 count, u16-length records) but accept any count and total that fit |
| 31 | the packet's own fields, check each record (non-empty, no zero byte, one `=` |
| 32 | after a non-empty name), and refuse with the documented negative errno |
| 33 | `-E2BIG` only when the kernel does. |
| 34 | 2. `execprog`/`execenv`: add a PATH search form (`execpath`), following POSIX |
| 35 | `execvp` (search the `PATH` of packet B, skip entries that fail with |
| 36 | `ENOENT`/`ENOTDIR`/`EACCES`, return the last other error). |
| 37 | 3. Records longer than 65535 bytes need a wider length field: a second packet |
| 38 | version with u32 lengths, so that an environment entry up to |
| 39 | `MAX_ARG_STRLEN` passes (the driver refuses such an entry today, exit 3). |
| 40 | 4. Gate: `seed/host/execenv/` cases for 65, 200 and 2000 records, a 64 KiB |
| 41 | total, a 131071-byte record, an empty name, a missing `=`, a PATH search hit, |
| 42 | miss and `EACCES`, plus an alarm test that reports the largest environment |
| 43 | seen in the gate run (no cap; the no-hard-caps rule). |
| 44 | |
| 45 | When this lands, `tools/run-device-window.om` drops `/usr/bin/env` and builds |
| 46 | packet B from `envread` directly. |