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 / apps / omega-strand-hub / README.md

98 lines · 8059 bytes Raw Blame History Rendered
1# Omega Helix Strand Exchange & Clip Studio (`om-strand-hub`)
2
3Pure seeded-Omega (`om2`) zero-JS HTTP server implementing the **Interplane Open-Source Helix Strand Exchange** and **Strand Clip Editor (`spclip`)**. Compiles with `seed/out/omc` into a single static AArch64 Linux ELF (~202 KiB, zero libc, zero C, zero Python, zero CUDA, zero telemetry).
4
5## Architecture & Security Boundaries
6
7- **Zero JavaScript / Strict CSP:** Standard HTML `<form method="POST">` + dedicated external stylesheet (`/strands/hub.css`), zero `<script>` tags, zero inline styles — compatible with `interplane.io`'s `script-src 'none'; style-src 'self'` CSP.
8- **Open-Source Default, Extensible Schema:** Upload UI defaults to `Apache-2.0` (`MIT`, `CC-BY-4.0`, `CC0-1.0`, `BSD-3-Clause`, `AGPL-3.0-only` selectable) while persisting extensible named metadata columns (`license`, `terms`, `provenance`, `parent_trunk`, `author`, `filename`, `description`, `downloads`, `uploaded_ns`) in versioned `omega.strand_hub.v1` / `omega.spclip_hub.v1` ledgers.
9- **Bounded Upload Containment:** Requires explicit numeric `Content-Length`, refuses `Transfer-Encoding: chunked` request smuggling (`400`), enforces configurable upload ceiling (default `32 MiB`, overridable via `argv[3]`, immediate `413` before writing disk), handles `Expect: 100-continue` cleanly, and streams payloads in O(1) 64 KiB chunks.
10- **Fail-Closed `OLLMSP01` Cryptographic Verification:** Before storing any blob or catalog entry, every upload is verified byte-for-byte against the exact `train/omega-llm/native/spec.om` `OLLMSP01` format:
11 1. Strict filename validation (`[A-Za-z0-9._-]`, no `..`, `/`, `\`, leading `.`, or control bytes; storage paths are strictly content-addressed `<data_dir>/blobs/<sha256>.sp`).
12 2. Exact 48-byte little-endian header: magic `"OLLMSP01"` (`3544421225449933903`), `1 <= base_L < spec_L <= 1024`, non-zero / non-empty-basis Merkle `base_hash`, overflow-safe `n_spec_params >= 1`, exact byte length `48 + 8 * n_spec_params`.
13 3. Merkle parent lineage check: optional 16-hex `parent_trunk` must match binary `base_hash`; optional 64-hex `parent_trunk` matching an existing hub strand enforces `child.base_L == parent.spec_L`.
14 4. Single-pass streaming payload verification: recomputes FNV-1a 64 over payload bytes `[48 .. pack_len)` and requires exact match with `pack_hash` (`ollm rc=61` equivalent), checks every IEEE-754 `f64` weight is finite (rejects `NaN`/`Inf`), computes full-file FIPS 180-4 SHA-256 (and verifies optional `expected_sha256` pin), and refuses duplicates (`409 Conflict`).
15 5. Atomic persistence via `fdsync`/`fsync` + `renames` (never leaves partial files or stale staging files on refusal).
16- **Strand Clip Editor (`/strands/clip`) & Deterministic `.spclip` Manifests (`OMSPCLIP01`):**
17 - Lets users pick `2..4` compatible verified strands sharing the same `base_hash` trunk, edit signed/positive milli-weights (`w1..w4`), fusion mode (`MODE=0` Signed PoE / Anti-DNA vs `MODE=1` Entropy Gate), temperature `tau` (`0..5000`), branch order, `splice_layer`, and optional fine-tune metadata (`ft_seed`, `ft_steps`, `ft_lr_micro`).
18 - Fail-closed rejects incompatible parent trunks, zero weights, negative weights in `MODE=1`, all-negative weights in `MODE=0`, `<2` or `>4` strands, invalid modes/tau/splice layers, and any 1-byte tamper of `.spclip` `body_sha256`.
19 - Emits deterministic, SHA-256-verified `.spclip` manifests (`<data_dir>/clips/<clip_sha256>.spclip`), copy-ready `ollm spclip` + frozen-core fine-tune CLI commands, and 1-click links to publish fine-tuned child `OLLMSP01` strands linked back to their parent hashes.
20
21## HTTP Routes & Agent API
22
23| Method | Route | Purpose |
24| --- | --- | --- |
25| `GET`/`HEAD` | `/strands/` (or `/strands`) | Landing intro, 3-step visual flow, filterable catalog (`?trunk=<hex>&license=<lic>`), upload form |
26| `GET`/`HEAD` | `/strands/hub.css` | Dedicated zero-JS stylesheet (`text/css`, `max-age=300`) |
27| `GET`/`HEAD` | `/strands/health` | Liveness check (`200 ok\n`) |
28| `GET`/`HEAD` | `/strands/strand/<sha256>` | Full cryptographic verification receipt, runnable `spapp`/`spchainsamp`/`spclip` commands |
29| `GET`/`HEAD` | `/strands/pack/<sha256>.sp` | Verified `.sp` binary download (strict 64-hex guard, persisted download counter on `GET`) |
30| `POST` | `/strands/upload` | Fail-closed upload (`multipart/form-data` browser/curl form OR raw `application/octet-stream` + `X-Strand-*` headers) |
31| `GET`/`HEAD` | `/strands/index.tsv` | Deterministic agent catalog (`text/tab-separated-values`, supports `?trunk=` / `?license=`) |
32| `GET`/`HEAD` | `/strands/index.json` | Deterministic RFC-8259 JSON catalog (`omega.strand_hub.v1`, supports `?trunk=` / `?license=`) |
33| `GET`/`HEAD` | `/strands/clip` | Zero-JS Strand Clip Editor (`?trunk=`, `?s1=`, `?s2=`) |
34| `POST` | `/strands/clip` | Compose & persist (`action=save`, `201`) or directly download (`action=download`, `200`) verified `.spclip` |
35| `GET`/`HEAD` | `/strands/clip/<clip_sha256>.spclip` | Download stored deterministic `.spclip` manifest |
36| `POST` | `/strands/clip/verify` | Standalone fail-closed `.spclip` manifest verifier (JSON receipt `200` / `400`) |
37| `GET`/`HEAD` | `/strands/clips/index.tsv` | Deterministic `.spclip` catalog (TSV, supports `?trunk=`) |
38| `GET`/`HEAD` | `/strands/clips/index.json` | Deterministic `.spclip` catalog (JSON, `omega.spclip_hub.v1`, includes `strands[]` & `?trunk=`) |
39
40## Build & Run (AArch64 Linux / DGX Spark)
41
42```sh
43seed/out/omc < apps/omega-strand-hub/main.om > om-strand-hub.tmp
44chmod +x om-strand-hub.tmp && mv -f om-strand-hub.tmp om-strand-hub
45./om-strand-hub /var/lib/omega-strand-hub 18491 33554432
46```
47
48Arguments (all optional):
491. `data_dir` (default `./strand-hub-data`)
502. `port` on `127.0.0.1` (default `18491`)
513. `max_upload_bytes` (default `33554432` = 32 MiB)
52
53## Pure-Omega Verification Gate (`gate.om`)
54
55Compiles and executes 52 live loopback end-to-end checks (positive uploads, trunk filtering, bit-exact downloads, restart persistence, XSS/JSON escaping, Clip Editor + Anti-DNA PoE + 3-strand compaction, child-strand `spclip:` lineage linking, real 14.17 MB GB10-trained `OLLMSP01` packs, plus adversarial negative controls for magic/truncation/trailing-byte/FNV-tamper/NaN-weight/Merkle-lineage/SHA256-mismatch/path-traversal/oversized/request-smuggling/incompatible-trunks/pairwise-parent-trunk-conflict/invalid-weights/forged-and-tampered-`.spclip`/Trap-4 DoS long headers, URIs, filenames, weights, and 68+ distinct trunks):
56
57```sh
58seed/out/omc < apps/omega-strand-hub/main.om > /tmp/om-strand-hub
59seed/out/omc < apps/omega-strand-hub/gate.om > /tmp/strand-hub-gate
60chmod +x /tmp/om-strand-hub /tmp/strand-hub-gate
61/tmp/strand-hub-gate /tmp/om-strand-hub /tmp/strand-hub-scratch 18499 \
62 [optional_real_pack1.sp] [optional_real_pack2.sp]
63```
64
65Expected output: `STRAND_HUB_GATE pass=52 fail=0` (49 without optional real `.sp` pack arguments), exit `0`.
66
67## Suggested Nginx Route Wiring (`/etc/nginx/sites-enabled/interplane.io`)
68
69Place alongside the `/omega/compile/` proxy block (operator-applied; not auto-modified by this package):
70
71```nginx
72 # Helix Strand Exchange & Clip Studio (pure seeded-Omega om-strand-hub on 127.0.0.1:18491).
73 location = /strands {
74 return 301 /strands/;
75 }
76 location ^~ /strands/ {
77 limit_except GET HEAD POST { deny all; }
78 limit_req zone=forge_post burst=10 nodelay;
79 limit_req_status 429;
80 client_max_body_size 34m;
81 proxy_http_version 1.1;
82 proxy_connect_timeout 5s;
83 proxy_send_timeout 60s;
84 proxy_read_timeout 60s;
85 proxy_redirect off;
86 proxy_set_header Host $host;
87 proxy_set_header Connection close;
88 proxy_pass http://127.0.0.1:18491;
89 }
90```
91
92Recommended loopback daemon launch on DGX Spark (atomic ELF replacement + `setsid -f`):
93
94```sh
95setsid -f /home/drakestapleton/.local/bin/om-strand-hub \
96 /home/drakestapleton/.local/share/omega-strand-hub 18491 33554432 \
97 >/tmp/om-strand-hub.log 2>&1 </dev/null
98```