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
omega-mv / evidence / SECURITY-673 / store-write-cleanup / REVIEW.md
| 1 | # Store write descriptor cleanup: source-only candidate |
| 2 | |
| 3 | Publication base: `95529421e9a0e6d6d63ca5d8b8cdfaf443e0ef78` (#687). |
| 4 | Historical preparation base: `19948824fea22e66499af02f27feef3ce9efa5d9`. |
| 5 | Review date: 2026-10-24. Scope: authority store (#649/#670), #673 tracker. |
| 6 | |
| 7 | ## Defect and minimal correction |
| 8 | |
| 9 | After a successful open, `writerec` returned 11 (failed/short write) or 12 (failed |
| 10 | fsync), and `writegen` returned 41 or 42, without closing the descriptor. Each |
| 11 | of those four paths now makes exactly one best-effort `fclose` call before |
| 12 | returning its original error. A secondary close error must not mask the primary |
| 13 | write/fsync error. No close retry is introduced: a failed close may already have |
| 14 | released the descriptor. Existing successful-write close errors remain 13/43; |
| 15 | record rename remains unreachable after any earlier failure. |
| 16 | |
| 17 | No compiler, runtime implementation, ABI, store format, lock protocol, durability |
| 18 | claim, temporary-file removal, or historical receipt is changed. This does not |
| 19 | repair partial generation writes or guarantee cleanup if the process is killed. |
| 20 | |
| 21 | ## Deterministic source-level regression |
| 22 | |
| 23 | `store-cleanup-test.om` is handwritten Omega. `store-cleanup-source.sh` composes |
| 24 | it with the real store source after mechanically renaming only five write-side |
| 25 | The composer uses portable awk token matching, rejects unexpected write-side |
| 26 | effect argument prefixes, and buffers output until source transformation and |
| 27 | harness reading both succeed. It does not rely on GNU sed word boundaries or |
| 28 | a pipeline that could mask a source-read failure. |
| 29 | primitive call prefixes to its effect doubles. Global buffer arguments are omitted because ordinary Omega functions cannot accept |
| 30 | global arrays; buffer contents are not under test. There are no production test hooks or |
| 31 | copied writer implementations. `read` remains real but the read functions are |
| 32 | never called. The fixture opens no real files; its final success message uses |
| 33 | real stdout. This is a control-flow/error-precedence test, NOT a real syscall, |
| 34 | fd-leak, persistence, concurrency, Linux, or hardware qualification. |
| 35 | |
| 36 | Eighteen cases cover both writers and nine modes: open failure, negative write, |
| 37 | short write, fsync failure, close failure, success, write plus close failure, |
| 38 | fsync plus close failure, rename failure (the generation writer does not rename). |
| 39 | Each asserts the return code, exact ordered effect trace, and that every |
| 40 | write/sync/close receives the successfully opened fake fd 7. Traces distinguish |
| 41 | zero/one/multiple closes, skipped effects and unwanted rename. Open failure has |
| 42 | no close. Primary failures survive a simultaneous close failure. |
| 43 | |
| 44 | In a disposable Linux AArch64 checkout, after approval of the reconstructed |
| 45 | compiler and its prerequisites: |
| 46 | |
| 47 | ```sh |
| 48 | mkdir -p build |
| 49 | sh seed/authority/store-cleanup-source.sh > build/store-cleanup.om |
| 50 | cmp build/store-cleanup.om seed/authority/store-cleanup-gate.om |
| 51 | seed/out/omc < build/store-cleanup.om > build/store-cleanup |
| 52 | readelf -h build/store-cleanup |
| 53 | chmod +x build/store-cleanup |
| 54 | build/store-cleanup |
| 55 | ``` |
| 56 | |
| 57 | Run each command only after its predecessor succeeds; never run failed compiler |
| 58 | output. Expected: `store cleanup cases=18 fails=0`, exit 0. This standalone gate |
| 59 | is not wired into `gate669`; existing real store, exact-store, dispatch, |
| 60 | dispatch-order and full security gates remain separately required. |
| 61 | |
| 62 | Negative control: extract `seed/authority/store.om` from the publication base above, |
| 63 | pass that path as the script's optional first argument, then compile/run the |
| 64 | result identically. It must exit 1 without the success message: ten cases (five |
| 65 | per writer) lack their required close. A compiler error, signal or timeout is |
| 66 | INVALID, not a passing negative control. Both fixed and negative native outcomes |
| 67 | are expectations, NOT observed results. |
| 68 | |
| 69 | ## Inherited fixture corrections preserved |
| 70 | |
| 71 | The publication base already contains the #685/#686 identifier and global-array |
| 72 | argument corrections. This candidate preserves those test files and the README |
| 73 | fixture-correction notes byte-for-byte; it does not introduce or re-publish those |
| 74 | repairs. They were reviewed alongside the new cleanup fixture during preparation. |
| 75 | |
| 76 | ## Verification status |
| 77 | |
| 78 | - PASS: source diff whitespace check and shell syntax check. |
| 79 | - PASS: source-only composer negative checks: separately changed the reviewed |
| 80 | fopen/write/fsync/fclose/renames argument prefix in temporary source copies; |
| 81 | all five returned nonzero with zero stdout. Missing source also returned |
| 82 | nonzero with zero stdout. No Omega source was compiled or executed. |
| 83 | - PASS: independent source review of all three updated fixtures, scalar doubles, |
| 84 | effect traces, identifier limits, array arguments and negative-control structure. |
| 85 | This is source review, not compiler acceptance. |
| 86 | - PASS: global/text names <=8 and function names <=63 across all authority |
| 87 | gate declarations; inherited global-array call replaced with a local copy. |
| 88 | - PASS: all four existing affected gate concatenations match their component |
| 89 | sources exactly; new gate matches the source-composition script. |
| 90 | - PASS: the pre-fix control composition differs only by the four missing cleanup |
| 91 | calls. No new production helper is needed by the old-source control. |
| 92 | - PASS: pinned crumb structural compile/verify (source metadata only). |
| 93 | - NOT_RUN: Omega compilation; fixed/negative execution; real syscall fd-leak |
| 94 | regression; full security gates; independent Linux AArch64/hardware replay. |
| 95 | No bundled native seed executable ran and no toolchain was installed. |
| 96 | |
| 97 | Keep draft. Source review and metadata checks are not functional qualification. |