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

103 lines · 7664 bytes Raw Blame History Rendered
1# trit: wake signal per bot (T-002)
2
3```
4trit DIR BOT... one line "<bot> <1|2> <token>" per bot that has work
5trit DIR --ack BOT TOKEN prints the receipt "<bot> 0", then the next wake if any
6```
7Reads `DIR/inbox/<bot>.md` and the emergency lane `DIR/inbox/<bot>.emergency.md`. Only prints;
8delivery stays outside (SendToAgent). Trit meaning follows TURNS.md (Drake 12:24): 1 = task,
92 = stop, 0 = read/done receipt (only from `--ack`), silence = nothing to do.
10
11Legacy exit status: 0 printed at least one line, 1 silent (no bot has work), 2 usage, 3 ack refused, 4 invalid codebook, 5 bad key,
1270+ internal/I-O.
13
14- A line is content when it starts `YYYY-MM-DDT`; headers are not content. `fyi` lines never wake.
15- Format: 6 fields = `ts|from|to|tag|text|ref`, otherwise `ts|from|tag|text|ref`, after removing a
16 last field that starts `ocb2:` or leftover `ocb1:` (the tools/codebook signature). A signed line
17 must be the 6-field form.
18- Signature (binding format, tools/codebook): last `|` field `ocb2:<cbsha>:<counter>:<digits>:<mac>`,
19 mac = HMAC-SHA256(key, `ocb2|cbsha|counter|lane|ts|from|to|tag|text|ref|digits`). Lane is `n` or `e`
20 from the file being read, not from the line. `to` must equal the bot being read. An `ocb1:` line is
21 legacy and is capped at trit 1. trit is built from the same `tools/codebook/codebook.om` bytes
22 (OM-2 has no imports; build.sh concatenates it) and `fn verified` calls its `verx`. Key and codebook:
23 `DIR/codebook/key` (mode `& 077` must be 0; the path must not contain a `boards/` segment),
24 `DIR/codebook/codebook.tsv`; without both nothing verifies. Counters: `DIR/inbox/<bot>.<sender>.ctr`
25 (`<counter> <ts>`, per receiving bot), lock `DIR/inbox/<bot>.ctr.lock`.
26- **2 only from a verified 3xx**: a line is 2 only when it verifies (codebook id, known codes, MAC,
27 counter above the stored one and above any earlier verified line from that sender in this pass,
28 and ts ≥ the last accepted ts)
29 and one of its codes is a single 3xx group. Everything else that is not `fyi` is 1: STOP text, a
30 `stop` tag, unsigned, tampered, wrong-key, stale and replayed lines. There is no `--trust-unsigned`.
31- Stop text (still parsed, wakes at 1): the tag is `stop`, or the text is `STOP` / starts `STOP ` / `STOP:`.
32- Reading never writes counters. `--ack` takes the lock (flock LOCK_EX), verifies every line up to the
33 token and advances the counters (`.tmp`, fsync, renameat2, fsync of the directory), unlocks, then
34 moves the cursor the same way. A crash between the two leaves those lines unread but stale (1).
35- Emergency lane: a verified 3xx is 2 and is reported before the normal lane (ack it to see normal
36 work). Other admitted lines there are 1 and are reported only when the normal lane is quiet.
37 Admission: sender (field 2) is `drake` or a slug with `DIR/inbox/<slug>.md`, and the timestamp parses.
38 Quota: at most 3 MAC-verified lines per sender within 60 minutes, counted once per (sender,
39 counter) over the whole file; unsigned and forged lines and replayed copies use no quota. Unread
40 rejected lines are counted on stderr: `rejected <bot> <n>`.
41- Token: `L<offset>:<sha256 of bytes 0..offset>`, L = `n` or `e`, offset = end of the last complete line
42 the trit was computed on. `--ack` moves that cursor to exactly the token; it refuses (exit 3, cursor
43 untouched) a malformed token, an offset not at a line end inside the file, behind the cursor, or a
44 prefix that no longer hashes to the token. There is no plain `--ack BOT`.
45- Cursor: `DIR/inbox/<bot>[.emergency].md.cur` = `<offset> <sha256 of the whole prefix>`; any in-place
46 rewrite before the offset, a truncation, or a malformed cursor makes the whole file unread. Written
47 to `.tmp`, fsynced, then `renames` (renameat2) over the cursor, then the directory is fsynced.
48
49Build and test from the repo root: `sh tools/trit/build.sh && sh tools/trit/test.sh`.
50Proof: `lean tools/trit/proof/TritSignal.lean`. Namespace `TritBin` mirrors trit.om function by
51function; `sh tools/trit/proof/difftest.sh` (python3 + lean) runs it with `#eval` against the binary
52on generated fixture dirs and requires identical stdout, stderr and exit status. The fixtures include codebook-signed lines
53(valid, tampered, wrong key/id, replayed, stale counter files) and unsigned STOP lines.
54`sh tools/trit/mutate.sh` runs its listed mutants against both (OMC defaults to the absolute `seed/out/omc`). The unmutated tree must pass
55first. A mutant counts as killed only when `test.sh` itself reports failed assertions (`TOTAL ... fail>=1`, exit 1); a compile error,
56an unapplied mutation, a crashed runner or a missing prerequisite is never a kill. The differential models read mode only, so it must
57kill the read-mode mutants and is recorded, not required, for the `--ack`/fsync mutants. Exit 0 = all killed; 1 survivor;
582 prerequisite missing; 3 mutant unapplied or invalid; 4 harness error; 5 baseline failed. `sh tools/trit/test-mutate.sh` is the
59regression for that driver. Gate: `tests/gates/run.sh trinary` (manifest `tests/gates/omega-trinary.gate`).
60
61## Current daily flow
62
63The receipt-era interface above remains available for historical callers. For the
64current Trinary Doctrine use:
65
66```
67trit DIR --inspect BOT... unread work as 1 plus its exact token; silence when quiet
68trit DIR --consume BOT TOKEN consume that token durably; no stdout and no next wake
69```
70
71`--inspect` preserves the existing inbox, verification and cursor rules. It emits
72only inspection requests, including for signed stop records. The current shared
73HMAC key proves key possession, not a particular sender, and the verifier's
74counter ordering does not prove wall-clock freshness. No stop request from this
75interface is an authorized process action. Inspect the record and establish fresh
76sender identity and existing runtime authorization separately before acting.
77These commands do not stop any process. Bad tokens still fail without advancing
78the cursor; consumption never hides a later unread task.
79
80Task details stay once in the existing durable record. Reading sends nothing.
81An explicit request for help is notification `0` only after its task record exists;
82no value produced by the legacy `--ack` interface may be forwarded as help. No
83codebook row is reassigned here. Neither native help signalling nor the proposed
84combined-digit codes or ambient liveness mechanism are implemented by these commands. Harnesses that need a startup prompt
85receive the record reference; this is not an enforced one-trit transport and no
86usage savings are claimed.
87
88`python3 tools/trit/test-daily.py` is an external verification oracle. It signs
89fixtures independently with Python's HMAC and checks exact output, exits, tokens,
90silent consumption, legacy behavior and invalid requests. It is not a runtime
91dependency. Existing Lean/differential proofs cover the legacy interface only;
92the new entry points are host-tested, not claimed source-proved.
93
94Mutation work directories must be fresh. A supplied existing `W` is refused and
95left intact; gate runs keep separate output directories so earlier failures survive.
96
97`python3 tools/trit/mutate-daily.py` checks the daily oracle against a passing
98baseline and deliberate stop promotion, receipt leakage, next-wake leakage and
99bypassed consumption. Invalid compilation or an incomplete test run fails the
100instrument; it never counts as a killed mutant. The host gate preserves all
101fixtures, mutant sources, binaries, raw exits and logs under its fresh output
102directory, and emits tool versions and log hashes. Wrong-recipient stop records
103remain inspection work for the reader to reject, never runtime authority.