interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / docs / btwave / CONTRACT.md

145 lines · 11086 bytes Raw Blame History Source

btwave: Balanced-Ternary Harmonic Waveguide and Give-Before-Take Compute Engine (Contract P0)

native/btwave/ is a 100% pure seeded OM-2 (om2) compute, transport, admission, and verification stack compiled directly to static Linux AArch64 machine code by the 3-stage seeded Omega compiler (omc). It contains zero C, C++, Rust, Python, or shell implementation or harness code.

Scope and Lineage

ItemPin / Value
Source modulesnative/btwave/trit.om, native/btwave/ledger.om, native/btwave/wave_ipc.om, native/btwave/main.om
Pure OM-2 gate runnernative/btwave/gate.om (concatenated after native/btwave/trit.om)
Root bootstrap seedomega-mv seed/rung0/seed0.hex sha256 baaf081fe6055a768485c5d25d7435681ce00b04cfa80b26c48169f78944e14d
Seeded compiler sourceomega-mv 713c9c079c2d97b58a2832495ddc7a374d462758 seed/omc/omc.om sha256 c86159627820cf5741be0a2a4c05df0efb78f5c91a652b986fec5d745baa62ed
Pinned omc binary3-stage fixpoint seed/out/omc sha256 f4fa7951816bbd09c5eaaae6692852a70c3c305164b365027c5b683dec7d63e9
Product source streamcat trit.om ledger.om wave_ipc.om main.om sha256 29de9fda42b04b1bf51b459a0bc4612fdcfa7f93d192d0f6ad3bdd9454191689
Product ELF binarysha256 583209bf9bcf8dda9a3a976e2e45e4d19ac6cdd28a0b2dbe7e1147deb9d975a2 (79,472 B MEASURED, 3x deterministic)
Wolfram trace digestb0c6399a7ae894148e8e1678a272add68385bdf67d6221044ded82216fb73575 (evidence/BTWAVE-P0/expected-trace.out)

Non-Binary Balanced-Ternary Algebra (native/btwave/trit.om)

  1. SWAR 32-Trit Packed Representation (Trit32):
    • Packs 32 balanced trits in {-1, 0, +1} into one ulong (64 bits, 2.0 bits/trit MODELED): upper 32 bits hold positive carrier mask pos32, lower 32 bits hold negative carrier mask neg32.
    • Declared as abstract Trit32 ulong ops rotr rotl. Constructor Trit32mk enforces the postcondition ((w >> 32) & (w & 0xffffffff)) == 0; any overlapping (1, 1) carrier pair immediately triggers OM-2 contract trap 10 (process exit 110 MEASURED).
    • 1-op negation (t32neg): rotr a 32 swaps pos32 and neg32 across all 32 lanes in a single AArch64 ROR instruction (1 op MODELED, zero carries, zero sign-extension bias).
    • Zero-multiply wave product (t32mul): computes all 32 balanced-ternary lane products in parallel via bitwise AND/OR/ROR (0 hardware integer multiplies MODELED).
    • Branchless inner product (t32dot): evaluates pop32(pos32) - pop32(neg32) in [-32, +32] using shift-mask SWAR popcount (0 branches, 0 multiplies MODELED).
  2. Multi-Scale Balanced-Ternary Codec (M = 6) and 16/16 Hypercube Witness (M = 3):

    • bt6enc / bt6dec map the symmetric integer lattice [-364, +364] bijectively onto 3^6 = 729 states (729/729 exact round-trips MODELED and MEASURED).
    • Dark Consensus (bt6enc(0) = 0): zero maps to pos32 = 0, neg32 = 0 (0 active carriers out of 32 MODELED and MEASURED), eliminating quiescent binary DC bias.
    • Hypercube reconstruction (hc3enc / hc3dec): embeds all 16 corners of {0, 1}^4 into M = 3 balanced trits (3^3 = 27 > 16 states MODELED), achieving 16/16 exact corner reconstruction (MEASURED and proved in Lean 4) whereas any 4 central binary hyperplanes in R^3 realize at most 14 < 16 strict sign orthants (MODELED, proved in nl1_four_central_hyperplanes_r3_at_most_14).
  3. Sylvester Walsh-Hadamard H16 Wave Spreading (h16enc / h16dec):

    • Encodes 5-bit symbol sym in 0..31 (4-bit Hadamard row index + 1-bit polarity) across 16 orthogonal ternary carriers with minimum Hamming distance d_H = 8 trits (MODELED, proved in Lean 4 and verified exhaustively in Wolfram).
    • Corrects 100% of 0, 1, 2, 3-carrier sign flips or erasures (32/32, 512/512, 360/360, and 1120/1120 MEASURED) and fail-closed returns -1 on >= 4-carrier midpoint ties (70/70 MEASURED).

Give-Before-Take Reciprocal Ledger (native/btwave/ledger.om)

StatusMeaningGuard location
0Admitted (GIVE credits work; TAKE grants compute within credit)ldg_give / ldg_take
-1Invalid opcode (op != 1 and op != 2)ldg_step
-2Non-sequential or negative epoch (req_epoch != epoch + 1)ldg_step
-3Invalid GIVE work bounds (work == 0, work > 1000, take != 0, or bad symbol)ldg_step / ldg_give
-4H16 wave decode refusal (>= 4 carrier corruptions / midpoint tie)ldg_give
-5Incomplete active carrier power (t32pow(job_wave) != 32)ldg_give
-6Scale out of admitted range (sc == 0 or |sc| > 65536)scale_bad
-7Caller set mode 3, so the computed receipt copy differs by one byte. ldg_give does not read an external receipt. The IPC host compares the child frame to a receipt it recomputes (host_give_round); a mismatch there returns -44, not -7.ldg_give when mode == 3; IPC check is rx_rcpt_ok (returns -44)
-8Invalid TAKE grant bounds (take == 0, take > 1000, or work != 0)ldg_take
-9Parasitic TAKE before any verified GIVE (contributed == 0)ldg_take (cred_pos)
-10Reciprocity overdraft (extracted + take > contributed)ldg_take (recip_ok)
-11Caller set mode 5. host_take_round sets that mode when the first 8 bytes of the frame chain differ from ldg_chid. This is not a 32-byte compare inside ldg_take.ldg_take when mode == 5
-12Not reachable from ldg_step. The function rebuilds a mirrored tag from the epoch and checks that tag against itself. A non-mirrored WaveDup traps 10 (exit 110) in the constructor (trap-dup), which is not status -12.no return path

Duplex Cross-Core Waveguide (native/btwave/wave_ipc.om)

Pure OM-2 Gate and Mutant Harness (native/btwave/gate.om)

Build and run from the repository root on Linux AArch64 (passing a scratch copy of evidence/BTWAVE-P0 so committed receipt.tsv and ipc.stdout stay untouched; gate.om opens native/btwave/*.om relative to the working directory and fails at step 5 otherwise). The block uses a private mktemp -d directory and ends with the gate's own exit status (table below), so a scripted run fails when the gate fails:

T=$(mktemp -d)
cat native/btwave/trit.om native/btwave/gate.om | "$OMC" > "$T/gate"
chmod +x "$T/gate"
cp -r evidence/BTWAVE-P0 "$T/ev"
"$T/gate" "$OMC" "$T/ev"; rc=$?
rm -rf "$T"
(exit "$rc")
Gate exitMeaning
0BTWAVE PASS: compiler pin verified, 3x deterministic build + Wolfram trace match, cross-core IPC pass, negative controls pass, 23/23 mutants killed (including m23-ipc-peer-wrong-job, which must make btwave ipc exit 65 with empty stdout), 4/4 type swaps refused (omc error 7)
1Gate check or mutant kill failed (prints step code to stderr)
2Usage error
77BTWAVE NOT_RUN: <omc_path> SHA-256 does not match pinned seed/out/omc

Not Run or Not Claimed