Skip to content

figures: generate the native quantities from the model, and restate native literals by domain - #182

Open
afflom wants to merge 38 commits into
mainfrom
claude/project-thread-22no4o
Open

afflom wants to merge 38 commits into
mainfrom
claude/project-thread-22no4o

Conversation

@afflom

@afflom afflom commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Requested by Alex · project thread

What

The native crates now read the model's quantities from Rust modules generated from the model, instead of restating them. Two mechanisms in crates/figures do this.

figures native (just figures-native) generates crates/uorc/src/model/{framing,frame,neuromorphic,ncm,archive,x86}.rs. The sources are src/Uorc/Search/FramingOrder.lex.tex, src/Uorc/Wire/Frame.lex.tex, src/Uorc/Neuromorphic.lex.tex and client/src/Uorc/Codec/{NcmEncode,Archive,X86}.lex.tex. Each generated module contains:

  • every parameterless Nat, with the model's own body over the other quantities;
  • for each numeral extent, the characteristic quantities domains.py derives: its last value, its half, and the half's last value;
  • views for each integer type the native code works in (usize is held to 32 bits for wasm32), with base-two logarithms (bits::);
  • the constant tables, read as big-endian cells.

figures check rejects a generated module that is not the generation of its source. The modules are private to the crate and skipped by rustfmt. The figures obligation in factory/graph.json now declares the two new model sources as inputs.

figures derive [--dry] [--lines] <generated> <files…> is the native counterpart of client/gen/domains.py. The native code declares once which items hold which domain, using doc tags:

  • Domain: <d> on a field, const, static, struct or fn (for its result);
  • Domain: <param>: <d> for a function parameter;
  • Domain: len: <d> for an array length;
  • Domain: body: <d> for every literal in a fn;
  • Domain: log2 <d> for a shift-count constant.

The pass infers every expression's domains to a fixpoint, through locals, fields, tuples, closures and conversions. It restates each literal that is a characteristic quantity of a domain in scope as that quantity. A scale stands only where it multiplies or shifts, and 1 << k is placed whole. A byte width read by T::from_le_bytes becomes size_of::<T>(), and an array equal to a model table's cells becomes that table's view. The compiler (cargo check diagnostics) decides each rewritten site's integer view, so values and types do not change and native output stays byte-identical. The pass reports each literal it cannot place, with the domains in scope.

Measured

Before (#180) After
Register (model/figures.toml) 4,593 4,323

Files rewritten: ncm.rs, ncm/staged.rs, ncm/streams.rs, archive.rs, ulz.rs, uorc-wasm/src/lib.rs.

Left (native)

  • The legacy ulz layout: these values sit inline in the LzDecode bodies and are not named quantities yet.
  • Hash salts and multipliers: these wait on the Uorc.Wire.Coder identities.
  • SIMD lane and batch geometry in staged.rs: these should derive from the declared host's vector width.
  • Portfolio, chunk and table-sizing coordinates: these belong to the ratchet's coordinate stage.
  • Composites such as 6144 and 21846, the wasm ABI status codes, and the archive graph opcodes.

Checks run locally

  • just figures: 4,323 sites, none beyond the register; the generated modules are current.
  • cargo test -p figures passes.
  • rustfmt passes on every changed file.
  • cargo check passes for uorc (all targets) and uorc-wasm (wasm32).
  • The factory test passes.
  • CI runs the acceptance legs.

Depends on

Merge this after #180. It reads #180's derived names, such as stretchHalfLast.


🤖 Generated with Claude Code

https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh

The NCM decoder and encoder models read and write their globals at byte
offsets of one state table. The offsets were written out at every access
(2,086 sites of the register). They are now derived: each global's address
is the address of the global before it plus that global's width, and the
width is the one figure of its place. The register falls from 8,252 to
6,166 sites; the IR and its lowering are otherwise unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
Uorc.Performance::parametricRelease names the first release whose
implementation must be parametric (0.7.0). From that workspace version on,
the figures check rejects the tree while the register lists any site, so the
version bump that tags the release cannot land until the distance of
implementationFigures is 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
uorc::coordinates names the coder's figures the engine decides (the three
plasticity figures first): the coder reads each as set for a measurement or
at its standard value. frontier's CodecPoint carries the coordinates a point
sets (in its κ only when any is set, so earlier claims keep theirs), and a
run sets them for its compressions and decodes.

The engine's coordinate stage gallops each coordinate from its identity by
doubling while the corpus gets strictly smaller, then bisects the bracket
around the best value. Every value measured is a closed claim under its κ,
so later ticks walk the path free and measure at most hypothesisBudget new
values. A finished search is decided when every family codes smallest at the
corpus's best value, and per-input (a frame-word facet is needed) with its
distance otherwise; model/coordinates.toml records it. `uorc-engine
coordinates` runs the stage alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
… the budget did not reach has no row yet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
…allop past the standard value, key stored warmed models by the coordinates

A warmed-model image was keyed by build, kernel, profile, mask and state but
not by the coordinates the model learned at, so a measurement at a
non-standard value could read a model warmed at another value: the encoder
coded a state frame from it and the native decoder refused the payload,
sending the frame to the reference decoder. The image key now carries every
coordinate's value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
…ched them)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
The decoder's in-process cache of warmed models matched state, profile and
dimensions but not the coordinates, so after a measurement at one value a
frame coded at another decoded from the wrong model: the native decoder
refused it and the frame fell to the reference decoder. The test fails
without the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
…best; first stage over uorc-v0.3.0

plasticityGain is decided at its standard 104 (families that prefer another
value tie it). plasticityFloor is per-input with a distance of 1 byte (tiny
codes 1 byte smaller at 22). plasticityHalfLife is per-input: the corpus codes
453 B smaller at 47888 than at 4096, and the families lose 171 B against
their own bests. 71 closed claims in frontier.toml; a rerun reads them all
and measures nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
…rged tree (6,151 sites)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
Setting a coordinate changes what every coder in the process reads, so the
warmed-model test ran under the library's parallel tests and moved
stored_warm_keeps_bytes off its bytes (rest, ubuntu-24.04-arm). It now lives
in tests/coordinates.rs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
…ree is main's

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
client/gen/domains.py: a model declares each domain of its quantities once,
by its extent (stretch, slot, weight with origin and unit; every stored cell
by its width), and the tables and globals that hold it. The pass infers
every operand's domains to a fixpoint and states each literal that is a
characteristic quantity of the domains it acts with, or of where its value
goes (extent, last, half, origin, unit, byte lanes, a rescale between two
domains), as that quantity derived from the extent. The offset-form mixer
dot product's constant term is derived from the two origins
(domains.origins). Values are unchanged; the kernel graph and basis bytes
are identical; ir_check 25/25 identical.

python3 client/gen/domains.py reports the literals left, by value, with
the domains in scope: the next declarations.

NcmEncode/NcmDecode: 1,827 -> 922 fixed-figure sites; register 5,498 -> 4,593.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
Corpus 574,441 B at the standard coordinates. Half-life: best 19,912 saves
145 B over the corpus, family bests differ (per-input, distance 94 B).
Floor 24 and gain 104 stay the corpus best; each is per-input (distance 4 B
and 36 B), so they wait on a frame-word facet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
…y where used

ir.py names the format's identities: the binary radix, the squash table's
spacing (half derived) and cell width, the context hash's word and each
round's multiplier and fold (shifts derived from the folds). irlex emits
squash and hash only into modules whose IR uses them, so X86 carries
neither. X86.lex.tex regenerated (now with the derived global layout).
ir_check 25/25, x86 round-trips, kernel graph and basis bytes unchanged.

Register 4,593 -> 4,500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
…hash from named quantities

The profile word's fields are a layout chain (each unit the one before times
that field's range); the probability maps' spacing, points, top and scale
derive from the stretch and slot extents and the squash step; the rolling
context hashes share one multiplier; a quotient or remainder by 2 is the
radix. ir_check 25/25, lexlean check passes.

Register 4,500 -> 4,288.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
… wire model states it

The scanner admitted every parameterless numeral of a Uorc.Codec module as a
format identity, so a generator could name any choice (a count limit, a
slack, a stride, a table's depth or base, a global's width) and the register
would not see it. Uorc.Wire.Coder now states the coder's identities (radix,
byte and word, the fixed-point domains' extents, the squash table, the hash
constants, the model's structure, the profile and frame words' fields, the
merged tables' ids, the v0.3 coder's profile); a coder numeral is admitted
only with that name and value. The rest are fixed figures, each counted once
at its definition.

The register is reseeded at the measured state: 4,288 -> 4,690. The 402
added sites are all named numerals of the coder modules (194 in each NCM
module, 10 Archive, 4 X86) that were figures before and went uncounted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
…ative literals by domain

`figures native` (`just figures-native`) generates crates/uorc/src/model/*.rs
from the model's sources (Uorc.Neuromorphic, Uorc.Codec.NcmEncode, Archive,
X86): every parameterless Nat with the model's own body, the characteristic
quantities of each numeral extent (last, half, the half's last), integer
views per type, base-two logarithms, and the constant tables read as cells.
`figures check` rejects a generated module that is not the generation of its
source, so the native values are always the model's.

`figures derive` is the native counterpart of client/gen/domains.py: the
native code declares once which items hold which domain (`Domain:` doc
tags), the pass infers every expression's domains to a fixpoint and restates
each literal that is a characteristic quantity of a domain in scope as that
quantity of the generated module. A scale (unit, rescale) stands only where
it multiplies or shifts. The compiler is asked for each rewritten site's
type, so values and types are unchanged and the native output is
byte-identical.

First reduction: ncm.rs, ncm/staged.rs, ncm/streams.rs.
Register 4,593 -> 4,405.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
…ix lengths read from the model

Uorc.Search.FramingOrder and Uorc.Wire.Frame join the generated modules.
archive.rs declares which signatures carry an integrity digest and which
layout functions read the fixed prefix (Domain: len:, Domain: body:); the
pass restates their 32s and 8s. Register 4,405 -> 4,355.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
…ins; a local's uses reach only a numeral value

Register 4,355 -> 4,335.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
…ts; a missing module is the compiler's to reject

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
A module whose generator has no axioms.json entries for its layout (X86, newly
regenerated with the derived layout) fell back to [Quot.sound, propext],
which the production export rejects as an inexact axiom policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MrzwoXqXQR1FdKaod
…ntities; a product method's operands stand where a scale may

Restates the context hash rounds and the rolling hash's multiplier from Uorc.Wire.Coder's identities.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
…d are their positions; a value two quantities share is left open

- uorc-wasm: an export's status is its position in Status (the page's ERRORS order).
- tree: Kind is its manifest code (Kind::code, Kind::of_code); the wasm listing reads and writes it so.
- staged: a slot's stretch is read through stretch_index.
- figures derive: a literal is placed only when exactly one quantity in scope is its value; a literal beside a count in a shift count is a count of that count's kind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
…he model's selectors; a window graph's frames are their instructions

- figures native: a one-parameter Nat definition that maps each constructor to a numeral (GraphEmit::opcode, typeCode) is emitted as a module of the constructors' codes; GraphEmit is generated as model/graph.rs.
- archive: the instructions each later frame adds are named by their opcodes, and the node count per frame is their number.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
…lity blocks as a chain, and the native decoder reads them

- client/gen/gen_dec.py: each probability block's base is the previous base plus that block's size (states, the literal coders by context bits, slot trees by length state, the reverse trees to the full distances, the align tree, the length trees); the range coder's bits, move scale and top, the header (length, zero byte, code word) and the probability cells are named once and the bodies read them. Values are unchanged.
- figures native: reads bare names and the model's pow2; LzDecode is generated as model/lz.rs.
- ulz.rs reads the layout and the coder's quantities from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
…follow pow2 (LexLean links in order)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MpxfXkET9iz3ZEfNh
…n_snake_case allowed)

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

This branch has not been deployed

No deployments
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.

2 participants