diff --git a/.crumb b/.crumb index 29c9d186..46ffdf43 100644 --- a/.crumb +++ b/.crumb @@ -28,13 +28,13 @@ }, { "digest": "35d5555ff4f23d370106e874ec0d5f9aa4f7d87e37c9589d1dbbcd5bd533640d", - "last_commit": "432c9447", + "last_commit": "0e66a235", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, { - "digest": "773512413893fb607ea2e93c237b7ec15c3c55d8c656e8224a42b92b6bf0a6e5", - "last_commit": "a14aa34c", + "digest": "8aee5a5d23e1e563cc8f84cd5406e485920be85528207b3cb22ad5db758de72a", + "last_commit": "0e66a235", "name": "native", "purpose": "Directory native. Purpose not yet described by a human." }, @@ -51,15 +51,15 @@ "purpose": "First-party host artifact preparation tools" } ], - "children_root": "sha256:a3a646af619fe37df90fe0a2f31bb24001a00dc3b3df2586c0b3ee62d63e5fb9", - "compiled_at": "2026-11-06T15:04:49Z", + "children_root": "sha256:2ad776efa76731a2cf9ea6d32dd05372dc785c507ce99411091ec0551abc230c", + "compiled_at": "2026-11-06T16:39:58Z", "compiler": "crumb-compile/1", - "digest": "sha256:c39e5b525ec642c343546c7150304feba2adb0dc4f6138b060d4f68106dce3b3", - "evidence_files": 1474, - "evidence_root": "sha256:c9bebaaf662519bc6f3e7d03368e629ad54c8af2005adc6984363ed5b004a6e9", - "files": 5355, - "generated_at_commit": "a14aa34c9249188cc771a2a565494b5ce61ad432", - "source_tree": "sha256:2992687a070375993f346cda9f9eb9577ab8e6f4dd588056e36858fa08e6b837" + "digest": "sha256:b2e06f4239b9dbb4f5faef58d321b884592d223867031b90864613ff7a46069f", + "evidence_files": 1485, + "evidence_root": "sha256:a358cb07984f1840a5dc21c97b931875018dab92ca38b55f5e05abecb9471330", + "files": 5369, + "generated_at_commit": "0e66a235430a8379c34bbd563490dd7f548494b5", + "source_tree": "sha256:8309e83ea4d3e24ac2188ccd7863e52e02a2f7b1bf35cd20c835e81cb8524438" }, "owner_lane": "", "provenance": { diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/.crumb b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/.crumb new file mode 100644 index 00000000..bfd24c57 --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/.crumb @@ -0,0 +1,19 @@ +{ + "extensions": { + "generated": { + "children": [], + "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "compiled_at": "2026-11-06T16:39:58Z", + "compiler": "crumb-compile/1", + "digest": "sha256:fbccf3756602bd4c285b385f6cbc79749b6ef2d38258a522034c07f8be6177e7", + "evidence_files": 11, + "evidence_root": "sha256:5974dabb42ab93cf72816d35abdeae5aa15a76f23f0ee028b94b2d91f7857e2e", + "files": 11, + "generated_at_commit": "0e66a235430a8379c34bbd563490dd7f548494b5", + "source_tree": "sha256:e249e9f66ee910067d779e951e1e3f828988076a40fa15021957c9c0265d843a" + } + }, + "name": "macbook-20261106", + "purpose": "Observed Mac and Spark firmware inference, HTTP, refusal and lifecycle evidence", + "schema_version": "1.0.0" +} diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/SHA256SUMS b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/SHA256SUMS new file mode 100644 index 00000000..ecd1184b --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/SHA256SUMS @@ -0,0 +1,3 @@ +359a1ccbdb99e245ba12155cf601012ca0cf0b80fc16592b99225cbdf406d6de model.img +be33b905f949d6dab036d3452a248d8fef6bc97695d9de0ca7d173221d136060 BOOTX64.EFI +ad23261d43116abc3747d59a7837fbf578c9586a8993f4eeba064cd07eccb083 OVMF_CODE_4M.fd diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/cancel-proof.json b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/cancel-proof.json new file mode 100644 index 00000000..4c247c22 --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/cancel-proof.json @@ -0,0 +1,5 @@ +{ + "cancel_after_first_text": true, + "owned_vm_stopped": true, + "model_disk_preserved": true +} \ No newline at end of file diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/http-proof.json b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/http-proof.json new file mode 100644 index 00000000..1865c642 --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/http-proof.json @@ -0,0 +1,8 @@ +{ + "model": "Omega-Astra-Aienux", + "text": " The kitten", + "done": true, + "first_text_seconds": 11.56651566689834, + "total_seconds": 23.93433362490032, + "expected": " The kitten" +} \ No newline at end of file diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/idle-pause.json b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/idle-pause.json new file mode 100644 index 00000000..1d59e2f4 --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/idle-pause.json @@ -0,0 +1,4 @@ +{ + "after_http_request": "paused", + "monitor_reports_paused": true +} diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/negative.json b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/negative.json new file mode 100644 index 00000000..da52c8bc --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/negative.json @@ -0,0 +1,4 @@ +{ + "truncated_checkpoint_refused": true, + "ready_absent": true +} \ No newline at end of file diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/pins.json b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/pins.json new file mode 100644 index 00000000..33608e7e --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/pins.json @@ -0,0 +1,16 @@ +{ + "aienux_base": "0e66a235430a8379c34bbd563490dd7f548494b5", + "train_base": "77cffb6d6698f59b0644552bcbfe0b639da94abe", + "compiler_sha256": "3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194", + "firmware_image_sha256": "be33b905f949d6dab036d3452a248d8fef6bc97695d9de0ca7d173221d136060", + "reproducible_build_image_equal": true, + "adapter_source_sha256": "f263a21ca06b2749ddfdd8adeff13a801eb53af452de78f85ef29c7ca23f1fc3", + "checkpoint_sha256": "131f7e3f26f5494a9882d8107096d4209651978a5bf35eccb3f953203d1f07d6", + "firmware_guest": "UEFI-hosted Omega; no Linux; no NIC", + "host": "MacBook Air Apple M2 8GB", + "native_arm64_firmware": "NOT_IMPLEMENTED", + "standalone_kernel_inference": "NOT_IMPLEMENTED", + "full_repository_gate": "NOT_RUN; focused build and runtime checks only", + "train_source_commit": "70d048c0e1e36150d0ad2998fef992c129914551", + "train_cli_sha256": "640ba87ceeadc3e342d6e523c321eb15938dec761a52907d2971822bf7fcae8c" +} diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/refusals.json b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/refusals.json new file mode 100644 index 00000000..8d83e5c3 --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/refusals.json @@ -0,0 +1,27 @@ +[ + { + "expect": "LMERR 2 3", + "actual": "LMERR 2 3", + "pass": true + }, + { + "expect": "LMERR 3 5", + "actual": "LMERR 3 5", + "pass": true + }, + { + "expect": "LMERR 4 6", + "actual": "LMERR 4 6", + "pass": true + }, + { + "expect": "LMERR 5 4", + "actual": "LMERR 5 4", + "pass": true + }, + { + "expect": "LMERR 0 2", + "actual": "LMERR 0 2", + "pass": true + } +] \ No newline at end of file diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/sample.json b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/sample.json new file mode 100644 index 00000000..1b6b9277 --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/sample.json @@ -0,0 +1,6 @@ +{ + "text": " The kitten was sad and scared. The", + "seconds": 110.0442773749819, + "done": true, + "environment": "MacBook M2 QEMU TCG, no Linux guest" +} \ No newline at end of file diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/sample.log b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/sample.log new file mode 100644 index 00000000..3b0de5b1 --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/sample.log @@ -0,0 +1,10 @@ +LMSTART 1 +LMDATA 1 20546865 +LMDATA 1 206b697474656e +LMDATA 1 20776173 +LMDATA 1 20736164 +LMDATA 1 20616e64 +LMDATA 1 20736361726564 +LMDATA 1 2e +LMDATA 1 20546865 +LMDONE 1 diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/spark-reference.json b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/spark-reference.json new file mode 100644 index 00000000..7d7e4382 --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/spark-reference.json @@ -0,0 +1,6 @@ +{ + "text": " The kitten was sad and scared. The", + "seconds": 278.26584470598027, + "done": true, + "environment": "Spark QEMU TCG, no Linux guest" +} \ No newline at end of file diff --git a/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/truncated-boot.log b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/truncated-boot.log new file mode 100644 index 00000000..d3bac6cd --- /dev/null +++ b/evidence/OMEGA-LOCAL-MODEL/macbook-20261106/truncated-boot.log @@ -0,0 +1,16 @@ +[=3h[=3h[=3hBdsDxe: loading Boot0001 "UEFI QEMU QEMU USB HARDDRIVE 1-0000:00:02.0-1" from PciRoot(0x0)/Pci(0x2,0x0)/USB(0x0,0x0) +BdsDxe: starting Boot0001 "UEFI QEMU QEMU USB HARDDRIVE 1-0000:00:02.0-1" from PciRoot(0x0)/Pci(0x2,0x0)/USB(0x0,0x0) +AIENUX OMEGA LOCAL MODEL: firmware hosted, no Linux +BdsDxe: loading Boot0002 "EFI Internal Shell" from Fv(7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1)/FvFile(7C04A583-9E3E-4F1C-AD65-E05268D0B4D1) +BdsDxe: starting Boot0002 "EFI Internal Shell" from Fv(7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1)/FvFile(7C04A583-9E3E-4F1C-AD65-E05268D0B4D1) +UEFI Interactive Shell v2.2 +EDK II +UEFI v2.70 (Ubuntu distribution of EDK II, 0x00010000) +Mapping table + FS0: Alias(s):HD1a0:;BLK1: + PciRoot(0x0)/Pci(0x2,0x0)/USB(0x0,0x0) + BLK0: Alias(s): + PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x2,0xFFFF,0x0) +Press ESC in 5 seconds to skip startup.nsh or any other key to continue.Press ESC in 4 seconds to skip startup.nsh or any other key to continue.Press ESC in 3 seconds to skip startup.nsh or any other key to continue.Press ESC in 2 seconds to skip startup.nsh or any other key to continue.Press ESC in 1 seconds to skip startup.nsh or any other key to continue. +AIENUX OMEGA LOCAL MODEL: firmware hosted, no Linux +LMEXIT 0xA diff --git a/native/.crumb b/native/.crumb index 7b208ec2..fc22783c 100644 --- a/native/.crumb +++ b/native/.crumb @@ -80,7 +80,7 @@ }, { "digest": "af273c64a35fb82517e60ba5feea763c5ee416443ae7f9a48bc3a20b29ddc481", - "last_commit": "432c9447", + "last_commit": "0e66a235", "name": "kernel", "purpose": "Directory native/kernel. Purpose not yet described by a human." }, @@ -97,8 +97,8 @@ "purpose": "Directory native/net. Purpose not yet described by a human." }, { - "digest": "6a2dad3c256c6f916442b3256f3eabc05da9ea6a82114256aec43f53e75fc2cd", - "last_commit": "a14aa34c", + "digest": "6a09034ab1e2f93046a0539318cca86bcc9c6f3cbff9aee7a9206c0da089bd03", + "last_commit": "0e66a235", "name": "omega", "purpose": "Seeded Omega native modules" }, @@ -115,15 +115,15 @@ "purpose": "Directory native/store. Purpose not yet described by a human." } ], - "children_root": "sha256:2fcf34c940bbdc6d6d426e1610847be64c3d9b5ceae3d455c51af26c0c89f3e3", - "compiled_at": "2026-11-06T15:04:49Z", + "children_root": "sha256:cca6805332eba6715c346d71d338ee2ecebf7b8eae1dee5c8189933b14570150", + "compiled_at": "2026-11-06T16:38:45Z", "compiler": "crumb-compile/1", - "digest": "sha256:773512413893fb607ea2e93c237b7ec15c3c55d8c656e8224a42b92b6bf0a6e5", + "digest": "sha256:8aee5a5d23e1e563cc8f84cd5406e485920be85528207b3cb22ad5db758de72a", "evidence_files": 24, "evidence_root": "sha256:ecc7ccf2e924c221a5bac1d91e23b13d8f3c8d78c2a893a882ed7ca5e88d855d", - "files": 1020, - "generated_at_commit": "a14aa34c9249188cc771a2a565494b5ce61ad432", - "source_tree": "sha256:2db6157faff537ba9160bc50742fdebe5d3185beb36d0647a8ec7fc1ef03127e" + "files": 1023, + "generated_at_commit": "0e66a235430a8379c34bbd563490dd7f548494b5", + "source_tree": "sha256:c942fca7241021933af16f30cd83994553eec7ee25bbfd8b3f1345ec6a84e07a" }, "owner_lane": "", "provenance": { diff --git a/native/omega/.crumb b/native/omega/.crumb index 3977b05d..65ff082a 100644 --- a/native/omega/.crumb +++ b/native/omega/.crumb @@ -10,14 +10,14 @@ } ], "children_root": "sha256:fcc350d101f87cb9e531f243a85d6664b62bbe63cf4b8c71b61bcb4d63d3e9b0", - "compiled_at": "2026-11-06T15:04:49Z", + "compiled_at": "2026-11-06T16:38:45Z", "compiler": "crumb-compile/1", - "digest": "sha256:6a2dad3c256c6f916442b3256f3eabc05da9ea6a82114256aec43f53e75fc2cd", + "digest": "sha256:6a09034ab1e2f93046a0539318cca86bcc9c6f3cbff9aee7a9206c0da089bd03", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 127, - "generated_at_commit": "a14aa34c9249188cc771a2a565494b5ce61ad432", - "source_tree": "sha256:34c55e6b1ef7deab8e3df5b9fbf27b39809cfeba18a85708cf7fe42a13139c59" + "files": 130, + "generated_at_commit": "0e66a235430a8379c34bbd563490dd7f548494b5", + "source_tree": "sha256:ee79cde67ee115200d813715f72a543474687293787107fd5cc764aaf35ccc2a" } }, "name": "omega", diff --git a/native/omega/allen/LOCAL-MODEL.md b/native/omega/allen/LOCAL-MODEL.md new file mode 100644 index 00000000..facacf0e --- /dev/null +++ b/native/omega/allen/LOCAL-MODEL.md @@ -0,0 +1,89 @@ +# Local Omega model experiment + +This opt-in application links Allen's existing conversation lifecycle to the +Omega LLM CPU implementation from `aien-dev/aien-train`. The checkpoint, +tokenizer, attention, sampling and arithmetic run inside the firmware guest. +The guest contains no Linux runtime and makes no network inference requests. +It does not replace the default Allen firmware or change the frozen C kernel. + +This is a **firmware-hosted application under x86-64 emulation**. UEFI Boot +Services remain active. It is not the standalone Aienux kernel, an ARM64 +firmware port, native Apple Silicon execution, or hardware qualification. + +Observed November 6, 2026 on an M2 MacBook Air: the Astra checkpoint produced +` The kitten was sad and scared. The` for eight greedy tokens, matching the +Linux reference byte for byte. Generation took 110.04 seconds under QEMU TCG; +this is a single sample, not a performance benchmark. The browser adapter's +two-token request streamed ` The kitten`, with first text at 11.57 seconds. +Receipts are in +[the Mac evidence directory](../../../evidence/OMEGA-LOCAL-MODEL/macbook-20261106/). +The same firmware image passed invalid-frame and truncated-checkpoint refusal +checks on the Spark-hosted emulator. It is still an experiment, not a useful +speed replacement for the native ARM64 Linux inference path. + +## Harness acceptance + +The compiler is pinned by digest; build failures and mismatched pins must +refuse. A successful build alone does not pass acceptance. Boot the image, +require `LMREADY`, submit a fixed prompt, require `LMDONE`, and compare the +decoded generated bytes with the same checkpoint, seed and sampling settings +on the reference runner. Invalid frames must return `LMERR` without starting +inference; a following valid frame must still work. Corrupt or missing model +files must never produce `LMREADY`. + +All model and firmware adapter implementation is Omega. QEMU and its firmware +provide the emulated machine. Test orchestration is outside the guest. The +separate experimental Mac llama UI adapter is host C++ and must not be described +as pure Omega or evidence of a native macOS Omega runtime. + +## Build and boot + +On Linux ARM64, provide the x86efi compiler pinned to +`3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194`. +The training source needs `osampleloaded` in `native/omegallm/cli.om`. + +```sh +OMEGA_COMPILER=/path/to/omc sh native/omega/allen/build-local-model.sh \ + /path/to/aien-train /fresh/output/BOOTX64.EFI +``` + +Install the image as `EFI/BOOT/BOOTX64.EFI` on a FAT disk. Put the checkpoint +at `ASTRA.CK` and tokenizer at `BPE.BIN` in its root. Attach the disk read-only +to QEMU with at least 2 GiB of guest RAM and one emulated CPU. No virtual NIC +is required. Serial console input/output carries the protocol below. + +The selected inference-only checkpoint is the November 4 Astra weight edit, +SHA-256 `131f7e3f26f5494a9882d8107096d4209651978a5bf35eccb3f953203d1f07d6`. +The tokenizer SHA-256 is +`73a29baf97619a746a21232c403bf08af71a76e48b3b2cde6d64dab766083882`. +Check these externally before installing the disk. The model loader also +validates checkpoint shape, length and its format checksum. That checksum +detects corruption; it is not cryptographic authentication. + +## Console protocol + +After `LMREADY`, send `LM1 ID TOKENS TEMPMILLI SEED HEX_PROMPT` followed by CR. +ID and seed are unsigned 32-bit decimals; ID is nonzero. Tokens are 1 through +128, temperature is 0 through 2000 (0 means greedy). The prompt is 1 through +159 printable ASCII bytes, encoded as lowercase hexadecimal. + +Responses are `LMSTART ID`, zero or more `LMDATA ID HEX_BYTES`, then +`LMDONE ID`. `LMERR ID CODE` refuses a request. The model is exclusive to one +request until completion. Firmware history holds only a printable preview; +it is not silently inserted into the next prompt. A host supplies any desired +conversation context explicitly. + +The Mac launcher is **Aienux Omega.command**. Its separate llama UI endpoint is +`http://127.0.0.1:8099`, model **Omega-Astra-Aienux**. The host adapter pauses +the VM after completed requests and resumes it for the next request so firmware +polling does not occupy a CPU core while idle. Cancelling a generation stops +this private VM; reopening the launcher reloads the read-only model. The host +adapter and launcher are supplied by the aien-train UI experiment, not by a +Linux process in the firmware guest. + +## Capability limit + +This is the existing 15.8-million-parameter TinyStories model. The experiment +does not train a new model or establish improved math. It has failed the local +arithmetic and extraction probes documented by aien-train. Running it under +Aienux does not make it a replacement for a general small instruction model. diff --git a/native/omega/allen/build-local-model.sh b/native/omega/allen/build-local-model.sh new file mode 100644 index 00000000..e7851fec --- /dev/null +++ b/native/omega/allen/build-local-model.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Opt-in firmware build. Does not change the default Allen firmware. +# Usage: OMEGA_COMPILER=/pinned/omc sh build-local-model.sh AIEN_TRAIN OUT.EFI +set -eu +[ "$#" = 2 ] || { echo 'usage: build-local-model.sh AIEN_TRAIN OUT.EFI' >&2; exit 64; } +here=$(CDPATH= cd -- "$(dirname "$0")" && pwd) +train=$1/native/omegallm +out=$2 +compiler=${OMEGA_COMPILER:?set OMEGA_COMPILER to the pinned x86efi compiler} +pin=3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194 +[ "$(sha256sum "$compiler" | cut -d' ' -f1)" = "$pin" ] || { echo 'compiler pin mismatch' >&2; exit 65; } +[ ! -e "$out" ] || { echo 'fresh output required' >&2; exit 73; } +mkdir -p "$(dirname "$out")" +unit=$out.om +{ + printf '%s\n' 'target x86efi' + cat "$here/base.om" "$here/runtime.om" + for f in math data epool model adam ckpt bpe cli; do cat "$train/$f.om"; done + # Only the platform entry point and output hook are replaced. Model math is unmodified. + sed -e 's/^fn main to int$/fn ollm_file_main to int/' \ + -e 's/^fn oflush to void$/fn ollm_file_flush to void/' "$train/eio.om" + cat "$train/nogpu.om" "$here/local-model.om" +} > "$unit" +dup=$(grep -E '^(fn|global|const|text|struct) ' "$unit" | awk '{print $2}' | sort | uniq -d) +[ -z "$dup" ] || { echo "duplicate declarations: $dup" >&2; exit 65; } +rc=0 +"$compiler" < "$unit" > "$out.tmp" 2> "$out.err" || rc=$? +if [ "$rc" != 0 ]; then + cat "$out.err" >&2 + rm -f "$out.tmp" + exit "$rc" +fi +[ "$(head -c 2 "$out.tmp")" = MZ ] || { echo 'not an EFI image' >&2; rm -f "$out.tmp"; exit 65; } +mv "$out.tmp" "$out" +sha256sum "$compiler" "$unit" "$out" diff --git a/native/omega/allen/local-model.om b/native/omega/allen/local-model.om new file mode 100644 index 00000000..bd31fbc3 --- /dev/null +++ b/native/omega/allen/local-model.om @@ -0,0 +1,278 @@ +note SPDX-License-Identifier: AGPL-3.0-only +note Opt-in local-model application for Aienux's Omega firmware environment. +note Links the existing Allen base/runtime and aien-train's unchanged model/checkpoint/tokenizer. +note Firmware Boot Services stay active. This is not a standalone-kernel or bare-metal M2 claim. +note No network, Linux syscalls, shell, external inference provider or checkpoint writes. +note Serial console protocol: LM1 ID TOKENS TEMPMILLI SEED HEX_PROMPT CR. +note ID/SEED u32; TOKENS 1..128; TEMPMILLI 0..2000; prompt 1..159 printable ASCII bytes. +note Output: LMREADY; LMSTART ID; LMDATA ID HEX_BYTES; LMDONE ID; LMERR ID CODE. +note A request uses Allen's start/answer conversation lifecycle. Its history stores a bounded +note printable preview; raw generated bytes are sent unchanged in the LMDATA frames. +text Lmck "\\ASTRA.CK" +text Lmbpe "\\BPE.BIN" +text Lmboot "AIENUX OMEGA LOCAL MODEL: firmware hosted, no Linux" +text Lmready "LMREADY" +text Lmstart "LMSTART " +text Lmdata "LMDATA " +text Lmdone "LMDONE " +text Lmerror "LMERR " +global Lmstate ulong 8 +note state: input length, overflow, request ID, tokens, temperature, seed, preview length, reserved. +global Lmline uchar 512 +global Lmkey uchar 8 +global Lmprev uchar 160 + +fn lmput which ulong to void +if eq which 0 +for i ulong len Lmboot +emitb get Lmboot i +end +end +if eq which 1 +for i ulong len Lmready +emitb get Lmready i +end +end +if eq which 2 +for i ulong len Lmstart +emitb get Lmstart i +end +end +if eq which 3 +for i ulong len Lmdata +emitb get Lmdata i +end +end +if eq which 4 +for i ulong len Lmdone +emitb get Lmdone i +end +end +if eq which 5 +for i ulong len Lmerror +emitb get Lmerror i +end +end +end + +fn lmsend to void +emitb 10 +if ne get Err 0 0 +exit 71 +end +r = efi 13 0 Outb 0 get Outlen 0 +if ne r get Outlen 0 +exit 70 +end +end + +fn lmfail code ulong to void +outreset +lmput 5 +emitn get Lmstate 2 +emitb 32 +emitn code +lmsend +end + +fn lmhex c uchar to ulong +if and ge c 48 le c 57 +ret sub ulong c 48 +end +if and ge c 97 le c 102 +ret add sub ulong c 97 10 +end +ret 256 +end + +note Platform output hook: flush every complete decoded token, with no terminal escape injection. +fn oflush to void +n = get oon 0 +if eq n 0 +ret +end +outreset +lmput 3 +emitn get Lmstate 2 +emitb 32 +for i ulong n +c = get oout i +emitb get Digits ulong shr c 4 +emitb get Digits ulong and c 15 +p = get Lmstate 6 +if lt p 159 +shown = c +if or lt shown 32 gt shown 126 +shown = 32 +end +put Lmprev p shown +put Lmstate 6 add p 1 +end +end +lmsend +put oon 0 0 +end + +fn lmrequest to void +put Lmstate 2 0 +if ne get Lmstate 1 0 +lmfail 1 +ret +end +n = get Lmstate 0 +for i ulong n +put In i get Lmline i +end +put Inlen 0 n +put P 0 0 +put P 2 0 +expect 76 +expect 77 +expect 49 +expect 32 +number +put Lmstate 2 get P 1 +expect 32 +number +put Lmstate 3 get P 1 +expect 32 +number +put Lmstate 4 get P 1 +expect 32 +number +put Lmstate 5 get P 1 +expect 32 +if ne get P 2 0 +lmfail 2 +ret +end +if eq get Lmstate 2 0 +lmfail 3 +ret +end +if eq get Lmstate 3 0 +lmfail 3 +ret +end +if gt get Lmstate 3 128 +lmfail 3 +ret +end +if gt get Lmstate 4 2000 +lmfail 3 +ret +end +pos = get P 0 +size = sub n pos +if or or eq size 0 gt size 318 ne rem size 2 0 +lmfail 4 +ret +end +count = div size 2 +for i ulong count +a = lmhex get Lmline add pos mul i 2 +b = lmhex get Lmline add add pos mul i 2 1 +if or eq a 256 eq b 256 +lmfail 5 +ret +end +c = uchar add mul a 16 b +if or lt c 32 gt c 126 +lmfail 6 +ret +end +put ojob add 1024 i c +put In i c +end +put Inlen 0 count +if not start 1 oms +lmfail 7 +ret +end +put otl 6 count +put Lmstate 6 0 +outreset +lmput 2 +emitn get Lmstate 2 +lmsend +osampleloaded get Lmstate 5 get Lmstate 3 get Lmstate 4 +count = get Lmstate 6 +if eq count 0 +cancel +else +for i ulong count +put In i get Lmprev i +end +put Inlen 0 count +if not answer get R 0 oms +cancel +lmfail 8 +ret +end +end +outreset +lmput 4 +emitn get Lmstate 2 +lmsend +end + +fn main to int +outreset +lmput 0 +lmsend +put otc 0 8 +put otb 2 0 +put otl 2 len Lmck +for i ulong len Lmck +put ojob i get Lmck i +end +put otb 7 32 +put otl 7 len Lmbpe +for i ulong len Lmbpe +put ojob add 32 i get Lmbpe i +end +put otb 6 1024 +pl = oargp 2 +sz = efi 12 oefa 0 0 oarg 0 pl +if oeerr sz +outreset +lmput 5 +emitn 0 +emitb 32 +emitn sz +lmsend +ret 70 +end +oeclose +ockload 2 +obload 7 get og 0 +outreset +lmput 1 +lmsend +for session ulong 1000000 +for beat ulong 1000000 +st = efi 1 0 Lmkey 0 4 +if ne st 0 +st = efi 2 1000 Lmkey 0 0 +else +ch = or ulong get Lmkey 2 shl ulong get Lmkey 3 8 +if eq ch 13 +lmrequest +put Lmstate 0 0 +put Lmstate 1 0 +else +if and ge ch 32 le ch 126 +n = get Lmstate 0 +if lt n len Lmline +put Lmline n uchar ch +put Lmstate 0 add n 1 +else +put Lmstate 1 1 +end +end +end +end +end +end +ret 0 +end