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 / docs / physics0 / PD0_PROTOCOL_V2.md
| 1 | # PD0 protocol v2, revision 2 |
| 2 | |
| 3 | Status: implemented in the omega world binary (`src/physics0/pd0_world.c`, `pd0_wire.h`). |
| 4 | The sealed PD-0b world binary MUST implement the same two extra operations, byte for byte, |
| 5 | so the PD-0b harness (`make physics0-pd0b-run`) can take play data and truth from one binary. |
| 6 | |
| 7 | ## Transport |
| 8 | |
| 9 | The binary is started as `<world-bin> <level 0..6|null> <seed>`. It reads framed requests on |
| 10 | stdin and writes framed responses on stdout until stdin closes. A frame is a u32 little-endian |
| 11 | length followed by that many bytes. A response of length 0 (frame `00 00 00 00`) means the |
| 12 | request was refused (malformed, wrong length, unknown op, or a value the op rejects). Integers |
| 13 | are little-endian; i64 values are two's complement. All values are micro-units. |
| 14 | |
| 15 | ## Ops 0, 1, 2 (unchanged) |
| 16 | |
| 17 | | op | request | response | |
| 18 | |---|---|---| |
| 19 | | 0 describe | `[0]` | PD0DESC2 record (`PD0DESC2` magic; v1 is refused by the harness) | |
| 20 | | 1 reset | `[1][n_obs u8][n_obs x i64]` | PD0REC1 record | |
| 21 | | 2 step | `[2][channel u8 (255 = none)][value i64]` | PD0REC1 record | |
| 22 | |
| 23 | These are byte-identical to the rev 7 world. They charge budgets and extend the hash chain. |
| 24 | |
| 25 | ## Ops 5 and 6: final and audit (revision 2) |
| 26 | |
| 27 | Op 5 `final`: request `[5][32 bytes]`, length exactly 33; the 32 bytes are the SHA-256 of the learner's final submitted |
| 28 | relation bundle, as defined by the harness. Response, 1 byte: `0` accepted (first `final`), `1` refused as a duplicate |
| 29 | (the first hash is kept). A request of any other length gets a zero-length refusal and is not counted. |
| 30 | |
| 31 | Op 6 `audit`: request `[6]`. Response (57 bytes): `PD0AUDT1`, `final_done u8`, then four u32 counters |
| 32 | `score_before_final`, `shape_before_final` (reserved, always 0 since shape-before-final is not a refusal), `play_after_final`, `dup_final`, then the 32-byte final hash (zeros if none). |
| 33 | Free at all times and never counted. |
| 34 | |
| 35 | ## State machine |
| 36 | |
| 37 | - OPEN (start): ops 0, 1, 2, 4 (dimensions only), 6 served. Op 3 is refused with a zero-length answer and counted (`score_before_final`). Op 5 moves to FINAL. |
| 38 | - FINAL: ops 0, 3, 4 (full), 6 served. ops 1 and 2 are refused (zero-length) and counted (`play_after_final`). A second op 5 is refused (status 1) and counted (`dup_final`). |
| 39 | - Op 0 describe is free in both states. No refusal charges budgets or extends the hash chain. |
| 40 | - A run is VALID only if the final was accepted once, the audit echoes the same hash, and all four counters are 0. |
| 41 | |
| 42 | ## Op 3: score (noise-free truth trajectory) |
| 43 | |
| 44 | Request: `[3][n_obs u8][reset: n_obs x i64][n_steps u8][n_steps x ([channel u8 (255 = none)][value i64])]` |
| 45 | Length is exactly `3 + 8*n_obs + 9*n_steps`. `n_obs` must equal the describe record's `n_obs`; |
| 46 | `n_steps` is 0..100; a channel other than 255 must be below the describe record's `n_channels`. |
| 47 | Any violation gives a refusal (length 0). |
| 48 | |
| 49 | Response: `[status u8][n_done u8][n_done x n_obs x i64]`, length `2 + 8*n_obs*n_done`. |
| 50 | `status` is 0 (OK, `n_done == n_steps`) or 2 (OUT_OF_BOUNDS: a variable left +-10.0 units at |
| 51 | step `n_done`; `n_done` states before it are returned). Values are the noise-free state of the |
| 52 | observed variables after each step (no observation noise, hidden variable not shown). |
| 53 | |
| 54 | Semantics: stateless. Starts from the given reset vector (not range-checked: the scorer asks for |
| 55 | 1.5x the reset box) with the hidden variable at zero, applies the hidden dynamics with the |
| 56 | noise-free update, and does not touch the budgets, the episode counter, the hash chain or the |
| 57 | noise streams. Revision 2: refused until `final` has been accepted (see the state machine). |
| 58 | |
| 59 | ## Op 4: shape (dimensions before final, full after) |
| 60 | |
| 61 | Request: `[4]` (length 1). Response (`PD0SHAP1`). Revision 2 split: BEFORE `final` the response carries the dimension |
| 62 | fields only (n_vars, n_latent, n_channels, S*) with n_equations = 0, relation size = 0 and n_terms = 0 (length 22); this is |
| 63 | not a refusal and is not counted. AFTER `final` the response is full, with the true terms. The dimensions are public per |
| 64 | level; the terms are the secret and stay locked until `final`. The dimension fields must be identical before and after. |
| 65 | |
| 66 | | bytes | field | |
| 67 | |---|---| |
| 68 | | 0..8 | magic `PD0SHAP1` | |
| 69 | | 8 | n_vars (observed plus latent) | |
| 70 | | 9 | n_latent | |
| 71 | | 10 | n_channels | |
| 72 | | 11 | n_equations | |
| 73 | | 12..16 | u32 S*: the spec 6.2 size of the true law (the harness uses size_bound = S* + 2) | |
| 74 | | 16..20 | u32 size of the true relation as built | |
| 75 | | 20..22 | u16 n_terms (all equations) | |
| 76 | | 22.. | n_terms records: `[target u8][coef i64][n_vars exponents u8][n_channels exponents u8]` | |
| 77 | |
| 78 | Total length `22 + n_terms*(9 + n_vars + n_channels)`. Terms are in equation order, then term |
| 79 | order. The coefficient is the delta-form coefficient (dt folded in) in micro-units, the same |
| 80 | numbers the test-only `pd0-truth` printed. The null world returns zero terms and zero equations. |
| 81 | |
| 82 | ## Harness side |
| 83 | |
| 84 | `pd0-harness <world> - <level|null> <seed> <out-dir>` (the dash replaces the truth binary) plays with ops 0..2, then sends `final`, then uses |
| 85 | ops 4 and 3 for the relation shape and the scorer's truth episodes; the run uses ops 0..2 only |
| 86 | for play. With a real truth binary instead of `-` the older mode is unchanged. |
| 87 | |
| 88 | ## Notes for the sealed binary |
| 89 | |
| 90 | Implement exactly this (the omega world is a stand-in, nothing here is a PD-0b result): |
| 91 | |
| 92 | 1. Ops 0, 1, 2 are the rev 7 bytes, unchanged. New ops: 3 score, 4 shape, 5 final, 6 audit; same framing (u32 LE length, zero-length frame = refusal). |
| 93 | 2. State: one flag `final_done` (starts 0) and four u32 counters plus the 32-byte first final hash. Refusal rules are in the state machine above; count every refused op 3 or 4 before final, every op 1 or 2 after final (regardless of well-formedness), and every second `final`. |
| 94 | 3. `describe` may reveal only the PD0DESC2 record, in both states, always. It must not reveal terms, constants, S* or latent counts. S*, n_vars, n_latent and n_channels come only from `shape`. |
| 95 | 4. `score` and the terms of `shape` may be served only after `final`; before it `shape` answers dimensions only (n_equations, relation size and n_terms zero) and is not counted. `score` is stateless (no budget, chain or noise-stream effect). |
| 96 | 5. `final` binds the SHA-256 of the harness-defined bundle: the emitted PDLAW1 record, or if none the candidate relation bytes, or if none the empty string. The world only records it and echoes it in `audit`; it does not interpret it. |
| 97 | 6. The harness reads the dimensions (S*, n_vars, n_latent, n_channels) with `shape` BEFORE the run and takes the size bound S*+2 from them; it sends `final` once per instance, only after the learner has submitted to the ladder checker, and calls `audit` at the end. After `final` it re-reads `shape` in full and marks the instance INVALID if the dimensions changed. In PD0 mode (the omega world, binary named pd0-world and PD0B not 1) it also checks S* against the public per-level table (2, 3, 4, 8, 4, 4, 7, null 0), a self-consistency check of the omega world only. In sealed mode (any other binary, or PD0B=1) the table check is skipped and S*, n_vars, n_latent, n_channels from `shape` are recorded per instance in the PD0B_RUN receipt so the reveal can verify them against the revealed families. |
| 98 | 7. Op 4 reveals the true terms to the harness (the scorer needs them for constants). The harness never forwards them to the learner. |