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 / tests / one_layer / generalization / families / FAMSIG_V1.md
| 1 | # GEN family signature and split contract (v1, frozen 2026-10-15) |
| 2 | |
| 3 | Issue: aien-spark/omega#476 (GEN-1), program aien-spark/omega#475. This contract is frozen BEFORE the |
| 4 | custodian authors any held-out task. Its only implementation is `tools/gen/protocol/famsig_lib.h` |
| 5 | (tools `famsig` and `gencheck`). A change to the signature or token definition needs a new version (`FAMSIG_V2.md`, signature prefix |
| 6 | `gs2:`). Additive amendments made before any held-out task exists (the token, the coarse form, rules R6 and R7, `famsig compare`) are dated in place. After the custodian seals, nothing changes. `docs/one_layer/GEN_PROTOCOL_V1.md` pins this file by sha256. |
| 7 | |
| 8 | ## 1. What a family is |
| 9 | |
| 10 | A **family** is a composition template: which primitives a task's SPECIFICATION combines, and how they |
| 11 | nest. It is declared by the task author from the task's prompt (what the task asks for), never computed |
| 12 | from a reference solution. Identifiers, constants, types, edge cases and trap rules do not enter the |
| 13 | signature: renaming a function or changing a constant never makes a new family. |
| 14 | |
| 15 | ## 2. Primitives and the nesting shape |
| 16 | |
| 17 | Six primitives. Declare each from the prompt: |
| 18 | |
| 19 | | primitive | kind | declare it when the specification asks for | |
| 20 | |---|---|---| |
| 21 | | `arith` | leaf | one arithmetic, bitwise, shift, comparison or conversion step stated as a single operation ("add x to the total", "is n even") | |
| 22 | | `nested` | leaf | one formula combining at least three operands with at least two operations, computed as a single value ("3*x*x + 2*x + 1"); declared instead of `arith` for such a formula | |
| 23 | | `array` | leaf | a fixed-length sequence (length 1..64) of values written or read by index (inputs packed into an array, a table, a buffer); one `array` per distinct use | |
| 24 | | `branch(X)` | container | a choice between behaviours on a condition; X is what the chosen arm(s) do | |
| 25 | | `loop(X)` | container | a step repeated a bounded number of times (count from a parameter or constant, or until a condition with a stated bound); X is the repeated body | |
| 26 | | `call(X)` | container | a helper computation the prompt names (its own parameters and result) that the solution must define and use; X is the helper's own body. The functional check cannot see helper use; the family describes the specification | |
| 27 | |
| 28 | `seq(A,B,...)` writes steps one after another. It is grouping only: not a primitive, never counted. |
| 29 | |
| 30 | Grammar (ASCII, no spaces, 1..512 bytes, at most 8 levels of nesting, at most 64 nodes): |
| 31 | |
| 32 | ``` |
| 33 | node := leaf | container "(" list ")" | "seq(" node "," list ")" |
| 34 | list := node ("," node)* |
| 35 | leaf := "arith" | "array" | "nested" |
| 36 | container := "branch" | "call" | "loop" |
| 37 | ``` |
| 38 | |
| 39 | A container needs at least one child, a leaf takes none, a `seq` needs at least two children. |
| 40 | |
| 41 | ## 3. Signature |
| 42 | |
| 43 | Canonical form: (1) a `seq` directly inside a container or inside another `seq` is replaced by its |
| 44 | children (`loop(seq(a,b))` = `loop(a,b)`, `seq(a,seq(b,c))` = `seq(a,b,c)`); (2) every child list is |
| 45 | sorted by byte order (C locale `strcmp`) of the children's canonical strings, duplicates kept. Sibling |
| 46 | order therefore never matters; nesting does (`loop(branch(arith))` and `branch(loop(arith))` differ). |
| 47 | |
| 48 | **Signature** = `gs1:` + canonical form, e.g. `seq(loop(branch(arith),array),array)` has signature |
| 49 | `gs1:seq(array,loop(array,branch(arith)))`. `famsig canon <shape>` prints it. |
| 50 | |
| 51 | **Family token** (for fields that allow only `[a-z0-9_-]`, such as the record `family` field of |
| 52 | `tools/gen/retrieval/CONTRACT.md` and its `--exclude-family`): `gs1-` + the first 16 lowercase hex digits of |
| 53 | sha256 of the signature bytes (`gs1:` included, no newline). `famsig token <shape>` prints it. A record or |
| 54 | task carries the token of the family of the task it was written for. (Added 2026-10-15, before any |
| 55 | consumer used v1: additive, no rule changed.) |
| 56 | |
| 57 | **Composition edges** of a shape: `P>C` for every container P and every child C of P after flattening, |
| 58 | where C is the child's head primitive (`famsig edges <shape>`). **Coarse edges**: the same with a child |
| 59 | `nested` read as `arith`, duplicates removed. Coarse edges gate through R7 (section 4). |
| 60 | |
| 61 | **Coarse form** (rule R6; added 2026-10-15 at review of PR #486, before any held-out task existed): (1) |
| 62 | `nested` is read as `arith`; (2) `seq` is flattened as in the canonical form; (3) every child list is |
| 63 | sorted and duplicate siblings are collapsed to one, and a `seq` left with one child is that child; (4) a |
| 64 | top-level `seq` whose children are exactly one container plus only leaves is replaced by that container. |
| 65 | **Coarse signature** = `gc1:` + coarse form; `famsig coarse <shape>` prints it. Examples: |
| 66 | `loop(branch(nested))`, `loop(branch(arith,arith))` and `seq(arith,loop(branch(arith)))` all have |
| 67 | `gc1:loop(branch(arith))`; `loop(branch(arith),arith)` has `gc1:loop(arith,branch(arith))` (a leaf added |
| 68 | inside a container is a different coarse family; R7 decides whether it adds an edge the corpus lacks). |
| 69 | |
| 70 | ## 4. Metadata lines and the disjointness rule |
| 71 | |
| 72 | One line per task, fields separated by exactly one space: |
| 73 | |
| 74 | ``` |
| 75 | <task_id> <split> <arith> <branch> <loop> <array> <call> <nested> <shape> |
| 76 | ``` |
| 77 | |
| 78 | - `task_id`: `[a-z0-9_-]{1,40}`; `split`: `corpus` | `dev` | `heldout`; the six counts: decimal 0..64, |
| 79 | no leading zeros, in exactly this order; `shape`: section 2. |
| 80 | - **R1** every line parses; each declared count equals that primitive's number of occurrences in the |
| 81 | shape (the multiset is declared and cross-checked, so a typo in either is refused). |
| 82 | - **R2** task ids are unique across every split. |
| 83 | - **R3** exemplar (corpus), dev and held-out families are pairwise disjoint: one signature never |
| 84 | appears in two splits. |
| 85 | - **R4** every primitive used by a held-out task is used by at least one corpus task. |
| 86 | - **R5** every held-out shape uses at least two distinct primitives (a held-out family is a combination). |
| 87 | - **R6** coarse signatures (section 3) are pairwise disjoint across corpus, dev and held-out: two tasks |
| 88 | of different splits with different signatures never share a coarse signature (equal signatures are R3). |
| 89 | This refuses a held-out family that is a corpus or dev family with a duplicated sibling, a `nested` |
| 90 | for an `arith`, or a top-level `seq` wrapper around it plus leaves. |
| 91 | - **R7** every held-out shape has at least one coarse composition edge (section 3) that no corpus shape |
| 92 | has (`novel_edges >= 1`). Wrapping a corpus shape in `seq(...)` or relabelling a leaf adds no edge, so |
| 93 | it fails R7. |
| 94 | (R6 and R7 added 2026-10-15 at review of PR #486, before any held-out task existed.) |
| 95 | - **R8** no top-level step of a dev or held-out shape is a corpus family in coarse form: after the |
| 96 | top-level `seq` is flattened, every step that is a container (`branch`, `loop`, `call`) has a coarse |
| 97 | form (section 3) that differs from the coarse signature of every corpus task. Leaf steps are not |
| 98 | compared (R4 requires leaves to be reused); a shape whose whole coarse signature equals a corpus one is |
| 99 | R3/R6. `seq(loop(branch(arith)),loop(array))` next to a corpus `loop(branch(arith))` fails R8. |
| 100 | (R8 added 2026-10-16 at review of PR #486, before any held-out task existed; dev/META passes it against |
| 101 | the GEN-3 corpus META.) |
| 102 | |
| 103 | Known limit: R6, R7 and R8 are syntactic. A corpus family nested below the top level and given a leaf |
| 104 | sibling, such as `loop(branch(arith),arith)` next to a corpus `loop(branch(arith))`, passes R6 (different |
| 105 | coarse form) and R8 (not a top-level step), and passes R7 only if no corpus shape has the edge |
| 106 | `loop>arith`. What the shape cannot show (the same algorithm declared under a different shape) is the job |
| 107 | of the reviewer's blind re-declaration and the near-duplicate check (GEN_PROTOCOL_V1 section 2). |
| 108 | |
| 109 | `famsig rule <file>...` applies R1..R8 over every task of every file given, prints per split |
| 110 | `split <s> tasks=<n> families=<m>`, then one `family <split> <signature> tasks=<k>` line per family |
| 111 | (held-out families only with `--show-heldout`, adding `novel_edges=<e>`: coarse edges no corpus shape |
| 112 | has), and ends `RULE PASS` (exit 0) or `FAIL R<k> ...` lines and `RULE FAIL` (exit 1). A failure that |
| 113 | involves a held-out task hides the held-out signature unless `--show-heldout` is given. Counts (60 |
| 114 | held-out tasks, at least 6 held-out families, 10 dev tasks) are checked by `gencheck` against |
| 115 | `protocol.json`, not by `famsig`. |
| 116 | |
| 117 | `famsig compare <SPLIT> <REDECLARED>` (blind re-declaration, GEN_PROTOCOL_V1 section 2): both files are in |
| 118 | the `gen-split 1` format of section 6 (any salt; the reviewer draws its own); it prints only `tasks=<n> mismatches=<k>`, where a mismatch |
| 119 | is a task whose signature differs between the two files, and exits 1 when k > 0 or the two files do not |
| 120 | name exactly the same task ids. It never prints a signature. |
| 121 | |
| 122 | ## 5. Where metadata lives |
| 123 | |
| 124 | | split | file | visibility | |
| 125 | |---|---|---| |
| 126 | | dev | `tests/one_layer/generalization/dev/META` | public, in the repo | |
| 127 | | corpus | `tests/one_layer/generalization/corpus/META` (Agent D, GEN-3) | public, in the repo | |
| 128 | | heldout | `SPLIT` in the custodian's sealed directory (owner `gencust`, mode 0700) | sealed | |
| 129 | |
| 130 | Public files (`gen-meta 1`): first line exactly `gen-meta 1`; then metadata lines; `#` comment lines |
| 131 | and blank lines are allowed; a `heldout` line is refused. Bytes: `\n` and 0x20..0x7E only, final `\n`. |
| 132 | |
| 133 | Held-out metadata NEVER goes inside `tasks.tar` (whose member rules, HARNESS_INTERFACE_V2.md section 3, |
| 134 | refuse any extra file) and is never published before the run. |
| 135 | |
| 136 | ## 6. The sealed split file (`SPLIT`, written by the custodian) |
| 137 | |
| 138 | ``` |
| 139 | gen-split 1 |
| 140 | salt <64 lowercase hex: 32 random bytes the custodian draws once> |
| 141 | <metadata line, split heldout> (one per held-out task) |
| 142 | ``` |
| 143 | |
| 144 | Rules: line 1 exactly `gen-split 1`; line 2 the salt; then only `heldout` lines, task ids strictly |
| 145 | ascending in byte order; no comments, no blank lines; `\n` and 0x20..0x7E only; final `\n`. The task ids |
| 146 | are exactly the case directories of the sealed `tasks.tar`. |
| 147 | |
| 148 | - `split_sha256` = sha256 of the SPLIT file's bytes (commits every task's family membership). |
| 149 | - **FAMLIST** = the bytes `gen-famlist 1\n`, `salt <salt>\n`, then every distinct held-out signature |
| 150 | sorted by byte order, one per line with `\n`. `famlist_sha256` = sha256 of FAMLIST. The salt makes |
| 151 | both digests unguessable by enumerating the (small) space of shapes. |
| 152 | - `famsig split SPLIT` checks the format and prints `split_sha256=`, `famlist_sha256=`, `tasks=`, |
| 153 | `families=` (nothing else); `famsig famlist SPLIT` prints FAMLIST. |
| 154 | |
| 155 | Before sealing, the custodian runs (as `gencust`) `famsig rule dev/META corpus/META SPLIT` (R1..R8) and seals |
| 156 | only on `RULE PASS`. It must use the corpus META at the commit the run pins. |
| 157 | |
| 158 | ## 7. The public commitment (`HELDOUT.pub`, published by the custodian before any held-out generation) |
| 159 | |
| 160 | ``` |
| 161 | gen-heldout-pub 1 |
| 162 | tasks_sha256 <64 hex: sha256 of tasks.tar, as in TASKS.sha256> |
| 163 | split_sha256 <64 hex> |
| 164 | famlist_sha256 <64 hex> |
| 165 | tasks <n> |
| 166 | families <m> |
| 167 | task <task_id> (one per task, strictly ascending, n lines) |
| 168 | ``` |
| 169 | |
| 170 | Exactly these lines in this order, single spaces, final `\n`. Nothing about any family is published |
| 171 | except `families <m>` and the two salted digests. After the run (or for the independent review, after |
| 172 | the seal), anyone holding SPLIT verifies with `gencheck split` that SPLIT matches HELDOUT.pub |
| 173 | (digests, ids, counts) and that R1..R8 pass against the pinned dev and corpus META. |
| 174 | |
| 175 | ## 8. Reserved dev families (v1): signature and token |
| 176 | |
| 177 | The 10 dev fixtures `devgen01..devgen10` hold these four signatures; no corpus or held-out task may use |
| 178 | them (R3): |
| 179 | |
| 180 | ``` |
| 181 | gs1:branch(loop(arith),nested) gs1-e05d1c5dffd08b06 |
| 182 | gs1:loop(call(nested)) gs1-bd9c105e5ae45397 |
| 183 | gs1:loop(loop(branch(arith))) gs1-f63e09ec03a454ee |
| 184 | gs1:seq(array,loop(array,branch(arith))) gs1-30938c5c7504ef0e |
| 185 | ``` |
| 186 | |
| 187 | Their coarse signatures (R6: no corpus or held-out task may have these either): |
| 188 | |
| 189 | ``` |
| 190 | gc1:branch(arith,loop(arith)) |
| 191 | gc1:loop(call(arith)) |
| 192 | gc1:loop(loop(branch(arith))) |
| 193 | gc1:loop(array,branch(arith)) |
| 194 | ``` |