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

125 lines · 8056 bytes Raw Blame History Source

seed/trace: local trace segment (omega-mv #608)

segment.om is a library unit in seeded Omega. It has no main, so concatenate it in front of a program that defines one (units concatenate; Omega has no import). Host words: fopen, read, write, fseek, fsync, fclose, unlink, link, renames (OMEGESE section 10). Linux AArch64 only.

Format version 1

All integers are little-endian.

PartBytesFields
header16AITR (65 73 84 82), version u16 = 1, record size u16 = 64, header size u32 = 16, reserved u32 = 0
record64type u16, payload length u16 (at most 52), sequence u32, payload 52 bytes (zero past the length), CRC-32 u32

Operations

FunctionBehaviour
segcreatecreates tpath with O_WRONLY, O_CREAT, O_EXCL and O_NOFOLLOW, mode 0600, and writes and fsyncs the header. An existing path is refused (10); it is never truncated
segreadycreates a missing segment. For an existing one it requires a valid header, and it never recreates the file
segappend t nappends one record with payload pay[0..n). It refuses if the file length is not header plus whole records (25: torn tail, recover first), when the segment is full (26), or when the payload is over 52 bytes (20). Each record is fsynced
segscanread-only. Sets scount (valid records before the first damage), sreason (0 clean, 1 torn tail, 2 bad length, 3 CRC mismatch, 4 sequence mismatch, 5 over capacity), stotal (file bytes) and slost (bytes after the valid prefix). A header that is short, has bad magic (11), an unsupported version (15), or bad geometry or nonzero reserved bytes (16) is refused
segrecoverreturns 0 for a clean segment. Otherwise it writes the header and valid prefix to <segment>.new (O_EXCL, fsync), hard-links the damaged file to <segment>.bad (refused with 32 if that exists, so a quarantine is never overwritten), renames the new file over the segment and returns 1. Header errors are returned, not recovered

Every open uses O_NOFOLLOW, so a symbolic link as the segment path is refused (ELOOP, serrno = -40). The caller creates directories with mode 0700 (makedir ... 448); the test does so.

Gate

sh seed/trace/gate.sh, or tests/gates/run.sh trace (manifest tests/gates/omega-trace.gate). It checks seed/out/omc against seed/out/omc.sha256, compiles segment.om plus segment-test.om, and runs the test in build/seed/trace/main. The test must exit 0 and its stdout must equal expected.txt. The 71 checks cover:

Four source mutants must each compile, exit 1 and fail their own check: crc (CRC no longer compared, so crc-reason fails), torn (torn-reason), align (torn-append-refused) and excl (create with O_TRUNC, so create-again-refused).

The expected sizes and offsets were computed in Wolfram Language: `{16+64100, 16+6499+30, 16+6499, 16+6450+8, (16+64100)-16-6450, 16+64*50, Mod[6382-16,64]} -> {6416, 6382, 6352, 3224, 3200, 3216, 30}`. The flags were checked the same way: `{BitOr[1,1024,32768], BitOr[1,32768], BitOr[1,64,128,32768], BitOr[1,64,512,32768]} -> {33793, 32769, 32961, 33345}`. The remaining values (errno 2, 17 and 40, and the result codes) are pinned by the source.

CLI (omega-mv #610)

tracecli.om is the offline, read-only inspector. Concatenate it after segment.om and tsha.om. Commands: version, verify, show, events (--type, --range), stats, export, compare, list. Nothing is written except stdout. Exit status: 0 ok, 1 a compare found a difference, 2 usage, 3 partial or inconclusive, 4 refused, 5 a stdout write failed. Energy and timing are reported unavailable: format v1 carries no typed measurements. There is no steps command: format v1 has no step index, and events is the typed record listing.

tracegen.om writes the fixtures (fx/ in an empty scratch directory; regular files are left mode 0400). Build it the same way, with tracegen.om in place of tracecli.om.

sh seed/trace/cli-gate.sh, or tests/gates/run.sh tracecli (manifest tests/gates/omega-tracecli.gate). It checks seed/out/omc against seed/out/omc.sha256, compiles both programs, regenerates the fixtures and checks fixtures.sha256 (plus the link.seg target and mode 0400), then requires each line of cli.cases to match cli-golden/ and the recorded exit status. A copy of fx/a.seg made mode 000 must be refused (refused code=10 errno=13, exit 4) by verify, show, events, stats and export. The gate refuses to run as root, because mode 000 would still be readable and the check would pass for the wrong reason.

Four source mutants must each compile and fail their own check:

An edited golden must fail the gate on a stdout mismatch.

Not in this unit

Issue #608 also lists items this unit does not provide: an index, rotation and retention, an async writer, schema migration beyond refusing other versions, export, consent and redaction. Concurrent writers are not supported either: there is no lock, and the unit assumes a single writer.

The CLI above is a separate program. It does not add an index, rotation, retention, an async writer, consent, redaction, or a query-scaling measurement.

One-shot SHA-256 digest (security673)

sha256.om is a one-shot FIPS 180-4 SHA-256 over at most 4096 input bytes. It holds 32-bit words in ulong, masks every addition, and writes 32 big-endian output bytes. sha256-test.om checks the empty, abc, 56-byte, 112-byte and 1000-byte vectors. It is separate from tsha.om (the streaming copy of om/evidence/evidence.om that tracecli.om uses).

seed/out/omc < seed/trace/sha256-gate.om > build/sha256-gate
chmod +x build/sha256-gate
./build/sha256-gate

Expected: sha256 vectors=5 fails=0, exit 0. The same gate is compiled and run by seed/qualification/security673/gate669.om. The segment writer is qualified by gate.sh above, not by gate669.