Skip to content

uorc: ncm context-mixing level (--best) and the standard kernel basis (re-land #115 on main) - #116

Merged
afflom merged 17 commits into
mainfrom
claude/project-thread-84bxra
Nov 9, 2026
Merged

afflom merged 17 commits into
mainfrom
claude/project-thread-84bxra

Conversation

@afflom

@afflom afflom commented Nov 9, 2026

Copy link
Copy Markdown
Member

Requested by Alex · project thread

#115 merged at 22:39Z into its stacked base claude/project-thread-e7b16t, but #112 had already been squash-merged into main at 22:33Z. So #115's changes never reached main. This PR brings them over unchanged: the head's tree is byte-identical to claude/project-thread-e7b16t after #115 (daa639b), and main is identical to that branch before #115.

Closes #62. Closes #107.

The description, results and tests are those of #115: uorc --best comes to 369,878 B on Canterbury, against 493,080 B for xz -9e, and is smaller on every file. Linked archives name the standard kernel basis, so small files no longer carry the 2.6 KB kernel.



Generated by Claude Code

claude and others added 17 commits November 9, 2026 16:13
Throughput (#105): crates/uorc now carries native Rust ports of the
model's hot paths, byte-identical to it:
- ulz.rs: the LZ + range coder of Uorc.Codec.LzEncode/LzDecode.
- archive.rs: the archive layout, kernel prefix/suffix and the
  UORC-SHA256-CHAIN-v1 seal (sha2), mirroring Uorc.Codec.Archive.
compress writes exactly the archive the exported model writes (tested
against it). The native decoder only accepts payloads on which every
reading agrees (code < range throughout, match sources inside the
output, no overrun, payload consumed exactly) and so needs no canonical
re-encode check; anything else goes to the exported reference decoder,
and a differential test checks agreement on damaged payloads.

Streaming (#106): a uorc stream is standard self-contained archives laid
end to end, one per 8 MiB frame; a one-frame stream is the model's
archive byte for byte. compress_stream/decompress_stream keep memory
bounded by frames in flight, frames run in parallel (--threads), and the
native paths need no large stack (the 1 GiB reservation now applies only
to the exported reference code). The wasm page streams files through
frames too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
…P, export pending)

The ncm coder (client/gen/ncm_model.py, one IR compiled to LexLean, to the
UORC kernel graph and ported natively) and the standard kernel basis: the
ulz and ncm decoder libraries bound by one UORC-BASIS-V1 identity, named by
linked (scope 1) archives so small files carry no kernel. Compress gains a
level (--best tries ncm). The exported client is not regenerated yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NtwZjtFZ8oFtv7gMs
Throughput (#105): crates/uorc now carries native Rust ports of the
model's hot paths, byte-identical to it:
- ulz.rs: the LZ + range coder of Uorc.Codec.LzEncode/LzDecode.
- archive.rs: the archive layout, kernel prefix/suffix and the
  UORC-SHA256-CHAIN-v1 seal (sha2), mirroring Uorc.Codec.Archive.
compress writes exactly the archive the exported model writes (tested
against it). The native decoder only accepts payloads on which every
reading agrees (code < range throughout, match sources inside the
output, no overrun, payload consumed exactly) and so needs no canonical
re-encode check; anything else goes to the exported reference decoder,
and a differential test checks agreement on damaged payloads.

Streaming (#106): a uorc stream is standard self-contained archives laid
end to end, one per 8 MiB frame; a one-frame stream is the model's
archive byte for byte. compress_stream/decompress_stream keep memory
bounded by frames in flight, frames run in parallel (--threads), and the
native paths need no large stack (the 1 GiB reservation now applies only
to the exported reference code). The wasm page streams files through
frames too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
…ntial tests, ulz history window

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
Scalars live in a small table instead of a rebuilt record, long statement
lists are split into functions, literals go first in additions, and literal
loop counts name the state, so the preservation certificate does not unroll
the model's setup. Output is byte-identical to before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NtwZjtFZ8oFtv7gMs
A frame can name the outputs of the K preceding frames (K = 1 or 2) as
basis roots 1..K after the kernel library (root 0), so its ulz payload is
coded against that window and matches reach across frame boundaries.

- LzDecode.decodeWith / LzEncode.encodeWith: the codec against a history
  window (decode/encode are the empty-history case, byte for byte as before).
- ulz library block runWith(payload, history); window entries apply it to
  basisGet 1 (++ basisGet 2). Graph mirror gains basisGet; gen_basis --check
  decodes K=1 and K=2 window frames on the mirror.
- Archive: windowIdentity (UORC-BASIS-V1 chain over [library, window..]),
  windowArchive, ulzWindowArchive, windowDecode, fastDecodeWith,
  windowMaterialize (keeps scope 1 and the identity; inlines the library).
- Client: compress(input, window, steps, level); decompress(archive, window,
  work) passes scope conditional + basis [library, window..] to the
  reference trial for window frames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
The differential tests run the exported decoder graph; unoptimized, the uorc
unit tests took 30 min of the 60 min acceptance leg (main is over budget
too). At opt-level 1 they take 4.5 min for about 6 min more compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NkSq1MUwK7keT67Uk
ncm, a context-mixing coder extrapolated from the neuromorphic model, is
written once as an IR and compiled to LexLean, to a UORC kernel graph and
natively. The ulz and ncm decoder libraries form root 0 of a UORC-BASIS-V1
basis; archives are linked to it by identity, so small files no longer
carry a 2.6 KB kernel. Level::Best (--best) also tries ncm and keeps the
smaller archive; on Canterbury it is smaller than xz -9e on every file.

inspect names linked archives' representation (ulz or ncm).

Closes #62. Closes #107.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3NtwZjtFZ8oFtv7gMs
@afflom afflom self-assigned this Nov 9, 2026
@afflom
afflom merged commit af373ea into main Nov 9, 2026
14 checks passed
afflom pushed a commit that referenced this pull request Nov 9, 2026
- UC-BAS-01 is build evidence: archives at both levels name the
  UORC-BASIS-V1 identity, and a resealed archive naming another basis
  fails to decode. Only UC-PERF-01 (measure only) and UC-REC-01
  (external record) remain open, so open_claims.rs is gone.
- Row tests and the wasm test take compress's level argument; OPT-01
  also checks --best is never larger than the default; WIRE-01 and
  OPT-01 describe linked archives and the ncm candidate.
- bench.mjs measures the default level and --best on every corpus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Pb2pARmowTZwiuFLV
afflom added a commit that referenced this pull request Nov 10, 2026
* uorc client: LexLean-exported Rust compress/decompress, CLI, wasm, Pages site, release and bench

Uorc.Client composes Search.Engine (whole-buffer compress under a step budget)
and the ArchiveTrial decode phases (decompress). scripts/client-export.mjs
stages the closure, marks it executable, works around LexLean 0.4.0 LLV7015
with a typed let wrap, and runs the certified production build into
generated/rust. Work in progress: the exported Rust is far slower than the
Lean-native build and overflows the stack on deep recursion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Nk2H9geAZ2GKFCNvM

* Export the client with shared-box LexLean; pin it; tighten wasm stack

The client crates are re-exported with LexLean at 7da569d (rust-std keeps
datatype fields behind Rc), pinned in scripts/client-export.mjs until the
lowering is released. Compress runs 18x and decompress 5x faster than the
inline-record export, and the WebAssembly stack drops from 256 MiB to 64 MiB.
The generated crates leave the workspace members so the workspace fmt and
clippy gates do not re-lint or reformat LexLean's output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Nk2H9geAZ2GKFCNvM

* Keep the client roots non-executable in the authority graph

The authority graph links Client against a closure that is not marked
executable, so lexlean check refused Client's executable definitions
(LLT4001). The export now adds executability and the two production
annotations on its staged copy; the staged data form equals the one the
committed packages were exported from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Nk2H9geAZ2GKFCNvM

* release: check out complete history

The template trust root requires every checkout to fetch full history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Nk2H9geAZ2GKFCNvM

* deny: license the exported client crates under the repository licence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Nk2H9geAZ2GKFCNvM

* client: pin LexLean to claude/uorc-pin (shared-box lowering #441 + in-place byte update #443)

The export pin moves to the branch that carries both LexLean patches; the
re-exported client gains the std runtime's Bytes::update and is otherwise
unchanged. The pin moves to a LexLean release once both ship.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Nk2H9geAZ2GKFCNvM

* client: ulz kernel archives (LZ + range coder as a UORC program graph)

compress now writes a standard UORC program archive whose graph is the ulz
decoder kernel (45 blocks, ~3 KB on the wire) and whose payload is the ulz
encoder's output, or the raw archive when that is smaller. The program search
runs only when --steps asks for it. decompress recognises a kernel archive by
rebuilding it byte for byte, runs the certified LexLean decoder, and keeps the
result only if re-encoding reproduces the payload; every other archive takes the
reference path. The current reference client decodes kernel archives by the
graph semantics, and a test decodes one that way.

1 MB inputs: rust.rs 54,366 B (gzip -9 61,786, xz -9 46,924), elf.bin 202,696 B
(gzip 238,109, xz 183,444); compress 0.7-1.9 s, decompress 0.7-1.9 s.

The codec and the client live in client/src, outside the authority project,
because the codec's tables use the in-place byte update that only the pinned
LexLean has; client-export stages client/src over src. client/gen holds the
writing aids (regenerate with client/gen/build.sh; check_graph.py runs the
kernel graph by a Python mirror of the reference semantics).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Nk2H9geAZ2GKFCNvM

* client: raw archives decode by a rebuild check instead of the reference path

decompress recognises a raw archive by rebuilding it from its body and
comparing bytes, so a stored input decodes in milliseconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Nk2H9geAZ2GKFCNvM

* client: smaller ulz kernel graph (2988 -> 2598 bytes)

Scalars move to low store keys with per-width accessors, and the payload
is copied into the store once instead of being threaded through every
block. Archives shrink by about 390 bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Nk2H9geAZ2GKFCNvM

* Settle the open conformance rows and benchmark Silesia on release

Registry (#108):
- Bind UC-REAL-01, UC-API-01, UC-WIRE-01, UC-INT-01, UC-MACH-01,
  UC-MACH-02, UC-SYN-01 and UC-OPT-01 to the shipped client, narrowed to
  what it does, with tests in crates/uorc/tests/conformance.rs and the
  uorc-wasm exports test.
- UC-OBJ-01 and UC-BAS-01 stay open and say why in their own text.
- Retire UC-PROD-01, UC-CTL-01, UC-VIW-01, UC-STG-01, UC-EXE-01,
  UC-CHK-01 and UC-INT-06 (old Hologram/View product model), with the
  xtask tests and runtime scripts that only served them.

Benchmark (#51):
- bench.mjs takes several corpora and writes a per-corpus size, ratio
  and throughput summary to bench.{json,md,html}.
- release.yml runs it in its own release-only job on Canterbury and
  Silesia; the table goes into the release notes and the Pages site.
- UC-PERF-01 states this measure-only disposition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Pb2pARmowTZwiuFLV

* registry: canonical lexlean fmt after retiring rows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Pb2pARmowTZwiuFLV

* uorc-wasm: inspect returns a JSON array since #112

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Pb2pARmowTZwiuFLV

* Bind UC-BAS-01 to the standard basis and follow #116's level API

- UC-BAS-01 is build evidence: archives at both levels name the
  UORC-BASIS-V1 identity, and a resealed archive naming another basis
  fails to decode. Only UC-PERF-01 (measure only) and UC-REC-01
  (external record) remain open, so open_claims.rs is gone.
- Row tests and the wasm test take compress's level argument; OPT-01
  also checks --best is never larger than the default; WIRE-01 and
  OPT-01 describe linked archives and the ncm candidate.
- bench.mjs measures the default level and --best on every corpus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3Pb2pARmowTZwiuFLV

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Close the compression-ratio gap to xz -9 Conditional basis: reference the ulz kernel by identity instead of embedding it

2 participants