You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[0.5.0] Content-addressed artifacts as compile-time constants of production roots #115
Finding: not delivered. The decoding already happens once, at link; what is missing is that the decoded value is data in the lowered program and the Rust crate. Today it is rebuilt on every call. Nothing below is built until the maintainer's go.
What the tree does today (measured)
Elaboration (SPEC §17.12 rule 2, model.rs:2627-2638). An artifact declaration decodes its content-addressed bytes once, at link, into a term, and elaborates to an ordinary nullary definition W : T := <decoded term> plus W.bytes and the kernel-checked W.decoded. The registry row declaration.artifact is runtime ("A constant of its decoded value", language/production-1.2.toml:1007), realized as ["function"] (calculus/realization.rs:272).
Lowering.W lowers to a zero-parameter calculus function whose body is a chain of build nodes (the calculus has scalar literals only: §17.14, Programs). Every call of a root that reads W evaluates that chain: a call site is call W and the denotation charges the whole body each time.
Rust. The committed rendering is a function that rebuilds the list on every call, e.g. examples/models/expected/verify/preserve/crate/R0.rust-std.rs:558 (pub fn f14() -> List<List<i64>> { List::cons(List::cons(2i64, List::cons(... ) called at :473, and :554 (f13, a ten-element List::cons chain). A bytes artifact would likewise be Bytes::lit(..), an Rc::from copy per call (:83).
Counts from the tree.
8 artifact{ declarations in committed positive sources: examples/models/src/Recognizer.lex.tex (6) and Triage.lex.tex (2); 14 more in negative fixtures under tests/negative/model-* (not roots).
In the committed lowered programs (program/R*.json, all roots of all examples), nullary functions with a build chain of at least two nodes occur only in examples/models/expected/verify/preserve/program/: R0: 4, R1: 4, R2: 2 (10 in all; 274 build nodes in each of R0 and R1 and 20 in R2). R3..R8 have none.
I did not count bootstrap/, stdlib/, compiler/ or examples/reasoning separately: no artifact{ appears in their sources.
MNIST evidence. The issue cites a crate that rebuilds ten parameter tensors per call. That repository is outside this session's scope, so I have not read it; the same shape is what the models example's R0/R1 show above.
Design choice I need from the maintainer (the plan depends on it)
The calculus has no compound literal and no constant form, so "decoded value as data" requires a calculus extension. Two shapes:
(a) A data literal (list, pair, option, ADT value of literals) in the calculus's literal position. Static rule: every literal has its type; denotation: the value it spells; Rust: each closed literal is hoisted to a once-initialised thread-local (List is Rc-based and not Sync, so not a static), and a use is an Rc clone.
(b) A program-level constants table (name, type, data value) and a constant expression.
I recommend (a): it reuses the one place literals are already typed, checked and canonicalised, and an artifact read is then an ordinary nullary call or inline literal. (b) adds a declaration kind to schema, load, canonical form and every consumer. Also to settle: the cost of reading a constant. Today it is the body's step count per call; the Rust invariant (TC-07/RB-06) only requires counted work ≤ denotation steps, so charging the literal's node weight once per read in the denotation and a clone in the rendering keeps it sound. I propose charging by weight (as primitives are), not a flat step.
Registry rows, scenarios, named tests (R3; IDs are the next free in each family)
ID
Statement (sketch)
Suite
Test
TC-08
The calculus has a closed data literal with a type rule, a canonical form, a kernel-checked denotation and a stated cost; the realization table covers it.
calculus
conformance_tc_08
RB-15
The Rust backend renders a closed data literal once per thread and a read as a clone; counted work never exceeds the denotation's.
rust-backend
conformance_rb_15
SP-21
An artifact read lowers to the decoded value as data with no per-call construction; certificates A, B and E cover it on every committed root.
preservation
conformance_sp_21
MD-14
A production root reading an artifact has its decoded value as data in the lowered program, equal to W's decoding of W.bytes; planted per-call decoding is detected.
models
conformance_md_14
Each also needs its SPEC.md §31 row (bijective, validate-spec-links) and a @<ID> @build scenario in features/suites/. All at level build.
Machine primitives and certificates
No new primitive: a literal is not a prim. RustSemantics gains the meaning of the hoisted constant (a read returns the literal's value, charging one tick per read).
Corr: under (a), I expect one new case (a data literal in the lowered program relates to its source value), because today only scalar literals are covered. I have not measured the library cost: the repair-round method of the [v0.4] #27 stage 6: complete the closed Rust AST so the runtime is generated from the calculus #91 stage-4 session needs the constructor to exist first, so it belongs to the first build PR. Not established.
Certificates A, B and E must cover the data literal on every committed root (the three models programs R0..R2 above are the roots that change; all other roots' programs are expected byte-identical).
Identities that move
schemas/target-program.schema.json, calculus/ canonical form, the compiler/ project's TargetSyntax/TargetSemantics/TargetOracle and RustSyntax/RustSemantics, their shipped copies, the calculus fixtures, and the committed Rust packages.
compiler_semantics appears in 589 committed files (records, bundles, schemas), so if the calculus is part of that identity (§21 says it is) every one of those moves. This is an identity-moving landing, so it is yours to sequence one at a time; I regenerate nothing on my own. I have not confirmed the exact count of files whose bytes change.
Rust backend and RustSemantics (RB-15), rustc differential.
Lowering and Corr, certificates A/B/E, library cost measured (SP-21).
The models example's regenerated records and the acceptance root (MD-14), after you sequence the identity move.
Not established
Whether (a) or (b); the cost rule above is a proposal.
The Corr library cost, and the exact set of files that change.
Whether the acceptance root should live in examples/models or in the corpus of [0.5.0] A general performance corpus #124 (which does not exist yet); the models example already has the shape.
I have not run any gate on this branch yet; the measurements are from committed records, not a fresh build.
Maintainer's decisions; the plan is agreed with these.
(a), a closed data literal in the calculus's literal position. It reuses the one place literals are typed, checked and canonicalised, and an artifact read becomes an ordinary nullary call or inline literal; (b) adds a declaration kind that every consumer must learn for the same value. The literal is closed (lists, pairs, options and ADT values of scalar literals, nothing else), so the denotation stays total and the canonical form stays a comparison of bytes.
Cost by weight, once per read. The denotation charges the literal's node weight per read, as a primitive is charged; the rendering is one clone per read of a once-initialised thread-local; TC-07/RB-06 stay "counted work never exceeds the denotation's steps", which this keeps sound. State the weight rule in §17.14 beside the primitives' weights.
The acceptance root lives in examples/models, which already has the shape (R0..R2); [0.5.0] A general performance corpus #124's corpus cites it when it exists (C1: evidence, not the definition of done).
This is an identity-moving landing on release/v0.5; records are mine to regenerate in sequence, as you say. Go ahead: PR 1 (the R3 skeleton) then PR 2 (the data literal, TC-08), each a draft against release/v0.5, gates on the unregenerated tree where they can run.
Correction to the plan, found reading the code for PR 2 (release/v0.5 at 17f7e46)
I wrote that the calculus "has no compound literal". That was wrong; I read §17.14's prose, not the code.Expr::Value { ty, value } already takes a compound Value (list, pair, option, result, ADT value), and check.rs:173-184 types it, interp.rs:616 evaluates it, term.rs:139 emits it, and rust/lower.rs:1416 renders it. So decision 1 ((a), a closed data literal) is already the shape of the syntax, the static rules, the canonical form and the term emission. What is missing is smaller and different:
Cost.TargetSemantics.lex.tex:5260 charges every literal one step (Outcome.value literal 1), and interp.rs:445 mirrors it, whatever its size. Decision 2 (node weight once per read) is therefore a change to the kernel-checked denotation, not an addition. The weight function already exists (TargetSemantics.lex.tex:650, interp.rs:59).
Rendering.lower.rs:1416 expands a list literal into a Cons chain evaluated at each read, which is the per-call rebuild measured in the plan. Hoisting is RB-18.
Lowering. The artifact lowering emits build chains instead of a Value literal (SP-24). That is where the 10 rebuilt constants in examples/models R0..R2 come from.
Consequence for PR 2 (TC-08). It is now the weight rule, not a new literal form: Expr.value charges weight literal in the Lean denotation, the reference interpreter and §17.14's Cost list. A scalar literal still costs 1, so only literals heavier than one node change. Measured on the committed fixtures: 14 of 122 contain such a literal (strings, byte strings, and the compound values in literals/function-shapes): binding-and-shapes, byte-compare, byte-order, byte-slices, bytes-and-text, decimal-overflow-wide, decimal-overflow, decimal, equality, function-shapes, literals, ordering, split-and-join, string-escapes. Their step counts, the generated TargetFixtures statements and compiler/lexlean.lock move; I leave those unregenerated for you to sequence, as you said.
I am rewording the TC-08 row to say this. No other decision changes.
Correction noted and accepted: the compound literal is already Expr::Value, so TC-08 is the weight rule in the kernel-checked denotation, the reference interpreter and §17.14's cost list, with scalar literals still at 1. The 14 fixtures, the generated TargetFixtures statements and compiler/lexlean.lock are identity-bound records; I regenerate them at the landing, as with every identity-moving PR. Go on with PR 3 (RB-18, the hoisted constant and the clone per read) stacked on #230, and PR 4 (SP-24) after it, running on the unregenerated tree the gates that can run there (conformance_tc_08 on the fixtures it builds itself, the rustc differential, clippy, fmt, validate-model) and saying on each PR which cases wait for the regeneration.
Certificate A.conv_value (Core.lex.tex:1039) is stated for any v : Value, not for scalars only. Its caller prove.rs used it for Nat/Integer/String/Bytes and had no case for a source cons/nil met with a literal: the first run printed LLI9001 phase preservation: the lowering of a cons is not a build of two. The fix is a branch in the aligner, not the library: a source Nil/Cons lowered to an Expr::Value is proved by conv_value at the literal's type and value (value_term already emits Value.list).
Certificate B. The value rule of Corr (side conditions Decided) already accepts the Rust construct chain a list literal renders to; the aligner's Term::Value arm needed no change.
Repair rounds: 0. I changed the lowering (production/lower.rs: an artifact definition whose lowered body is a closed Nil/Cons of literals becomes one Expr::Value; recognised through the declaration kind, Source::is_artifact), the prove.rs branch above, and nothing under language/.
Measured end to end on a copy of examples/models (language 1.2, unchanged sources), lexlean verify with the built binary on this branch: verified 9 modules; attestation 2fd00b83…, 6 m 45 s. In the verified preserve/ records:
programs R0, R1, R2 have 4, 4 and 2 nullary functions with a list-literal body and 0 build-chain constants (before: 10 chains; R3..R8 have none, as before);
the crates R0, R1, R2 hold 4, 4 and 2 thread_local! constants (RB-18);
the audit lists the same axiom sets as before for the library constants (Conv, ConvA, … [propext, Classical.choice, Quot.sound]). I did not diff the whole audit against the committed examples/models/expected/verify/preserve/audit.txt.
Caveats.
This run used the unregenerated shipped calculus modules (TC-08's weight is not in them), so it shows the certificates do not depend on a literal's step charge; it is not a statement about the regenerated tree.
Only artifact definitions fold; an ordinary definition with a literal list keeps its build chain, so no other root's program moves. I measured that on models' R3..R8, not on the other examples (production, reasoning, bootstrap, stdlib): those roots contain no artifact{, and the fold is keyed on the declaration, but I have not re-lowered them.
Not run: certificate E's statement for the new programs beyond what verify runs, and the committed-record comparison.
Next: the SP-24 and MD-14 cases (R3 first), then the PR.
Activity
afflom commentedon Oct 20, 2026
#115: plan (measured on release/v0.5 at 17f7e46)
Finding: not delivered. The decoding already happens once, at link; what is missing is that the decoded value is data in the lowered program and the Rust crate. Today it is rebuilt on every call. Nothing below is built until the maintainer's go.
What the tree does today (measured)
model.rs:2627-2638). Anartifactdeclaration decodes its content-addressed bytes once, at link, into a term, and elaborates to an ordinary nullary definitionW : T := <decoded term>plusW.bytesand the kernel-checkedW.decoded. The registry rowdeclaration.artifactisruntime("A constant of its decoded value",language/production-1.2.toml:1007), realized as["function"](calculus/realization.rs:272).Wlowers to a zero-parameter calculus function whose body is a chain ofbuildnodes (the calculus has scalar literals only: §17.14, Programs). Every call of a root that readsWevaluates that chain: a call site iscall Wand the denotation charges the whole body each time.examples/models/expected/verify/preserve/crate/R0.rust-std.rs:558(pub fn f14() -> List<List<i64>> { List::cons(List::cons(2i64, List::cons(...) called at:473, and:554(f13, a ten-elementList::conschain). Abytesartifact would likewise beBytes::lit(..), anRc::fromcopy per call (:83).artifact{declarations in committed positive sources:examples/models/src/Recognizer.lex.tex(6) andTriage.lex.tex(2); 14 more in negative fixtures undertests/negative/model-*(not roots).program/R*.json, all roots of all examples), nullary functions with abuildchain of at least two nodes occur only inexamples/models/expected/verify/preserve/program/: R0: 4, R1: 4, R2: 2 (10 in all; 274buildnodes in each of R0 and R1 and 20 in R2). R3..R8 have none.bootstrap/,stdlib/,compiler/orexamples/reasoningseparately: noartifact{appears in their sources.modelsexample's R0/R1 show above.Design choice I need from the maintainer (the plan depends on it)
The calculus has no compound literal and no constant form, so "decoded value as data" requires a calculus extension. Two shapes:
ListisRc-based and notSync, so not astatic), and a use is anRcclone.constantstable (name, type, data value) and aconstantexpression.I recommend (a): it reuses the one place literals are already typed, checked and canonicalised, and an artifact read is then an ordinary nullary call or inline literal. (b) adds a declaration kind to schema,
load, canonical form and every consumer. Also to settle: the cost of reading a constant. Today it is the body's step count per call; the Rust invariant (TC-07/RB-06) only requires counted work ≤ denotation steps, so charging the literal's node weight once per read in the denotation and a clone in the rendering keeps it sound. I propose charging by weight (as primitives are), not a flat step.Registry rows, scenarios, named tests (R3; IDs are the next free in each family)
conformance_tc_08conformance_rb_15conformance_sp_21W's decoding ofW.bytes; planted per-call decoding is detected.conformance_md_14Each also needs its SPEC.md §31 row (bijective,
validate-spec-links) and a@<ID> @buildscenario infeatures/suites/. All at levelbuild.Machine primitives and certificates
prim.RustSemanticsgains the meaning of the hoisted constant (a read returns the literal's value, charging one tick per read).Corr: under (a), I expect one new case (a data literal in the lowered program relates to its source value), because today only scalar literals are covered. I have not measured the library cost: the repair-round method of the [v0.4] #27 stage 6: complete the closed Rust AST so the runtime is generated from the calculus #91 stage-4 session needs the constructor to exist first, so it belongs to the first build PR. Not established.modelsprograms R0..R2 above are the roots that change; all other roots' programs are expected byte-identical).Identities that move
schemas/target-program.schema.json,calculus/canonical form, thecompiler/project'sTargetSyntax/TargetSemantics/TargetOracleandRustSyntax/RustSemantics, their shipped copies, the calculus fixtures, and the committed Rust packages.compiler_semanticsappears in 589 committed files (records, bundles, schemas), so if the calculus is part of that identity (§21 says it is) every one of those moves. This is an identity-moving landing, so it is yours to sequence one at a time; I regenerate nothing on my own. I have not confirmed the exact count of files whose bytes change.Plants (VERIFICATION.md falsifiability table, §27.9)
buildchain in the body) failsconformance_sp_21/conformance_md_14.W's decoding and certificate A.conformance_rb_15.Order of stacked draft PRs (each a draft, against
release/v0.5)load, canonical form,compiler/semantics, fixtures (TC-08).RustSemantics(RB-15), rustc differential.Corr, certificates A/B/E, library cost measured (SP-21).modelsexample's regenerated records and the acceptance root (MD-14), after you sequence the identity move.Not established
Corrlibrary cost, and the exact set of files that change.examples/modelsor in the corpus of [0.5.0] A general performance corpus #124 (which does not exist yet); themodelsexample already has the shape.Generated by Claude Code
afflom commentedon Oct 20, 2026
Maintainer's decisions; the plan is agreed with these.
TC-07/RB-06stay "counted work never exceeds the denotation's steps", which this keeps sound. State the weight rule in §17.14 beside the primitives' weights.SP-21,SP-22,SP-23,RB-15,RB-16andRB-17are taken by [v0.4] #27 stage 6: complete the closed Rust AST so the runtime is generated from the calculus #91 stage 4 onrelease/v0.4(its drafts #91 stage 4, PR 0: register rows SP-21 and RB-15 (R3 skeleton) #223, #91 stage 4, PR 1: the machine grows, and the Rust AST mirrors the machine callee and the overflow value (SP-21, RB-15) #224, #91 stage 4, PR 2a: the machine's natural and integer arithmetic, Some or None on overflow (SP-23) #227). TakeTC-08,RB-18,SP-24andMD-14; the register count is assigned at landing, so do not renumber on your own.examples/models, which already has the shape (R0..R2); [0.5.0] A general performance corpus #124's corpus cites it when it exists (C1: evidence, not the definition of done).Corrlibrary cost is measured in PR 4 by the repair rounds, with the static walk first, as [v0.4] #27 stage 6: complete the closed Rust AST so the runtime is generated from the calculus #91 does; post the count on this issue before writing the certificate case.This is an identity-moving landing on
release/v0.5; records are mine to regenerate in sequence, as you say. Go ahead: PR 1 (the R3 skeleton) then PR 2 (the data literal,TC-08), each a draft againstrelease/v0.5, gates on the unregenerated tree where they can run.Generated by Claude Code
R3 skeleton for #115: take RB-18 and SP-24 (RB-15..17 and SP-21..23 are
afflom commentedon Oct 20, 2026
Correction to the plan, found reading the code for PR 2 (release/v0.5 at 17f7e46)
I wrote that the calculus "has no compound literal". That was wrong; I read §17.14's prose, not the code.
Expr::Value { ty, value }already takes a compoundValue(list, pair, option, result, ADT value), andcheck.rs:173-184types it,interp.rs:616evaluates it,term.rs:139emits it, andrust/lower.rs:1416renders it. So decision 1 ((a), a closed data literal) is already the shape of the syntax, the static rules, the canonical form and the term emission. What is missing is smaller and different:TargetSemantics.lex.tex:5260charges every literal one step (Outcome.value literal 1), andinterp.rs:445mirrors it, whatever its size. Decision 2 (node weight once per read) is therefore a change to the kernel-checked denotation, not an addition. The weight function already exists (TargetSemantics.lex.tex:650,interp.rs:59).lower.rs:1416expands a list literal into aConschain evaluated at each read, which is the per-call rebuild measured in the plan. Hoisting is RB-18.buildchains instead of aValueliteral (SP-24). That is where the 10 rebuilt constants inexamples/modelsR0..R2 come from.Consequence for PR 2 (TC-08). It is now the weight rule, not a new literal form:
Expr.valuechargesweight literalin the Lean denotation, the reference interpreter and §17.14's Cost list. A scalar literal still costs 1, so only literals heavier than one node change. Measured on the committed fixtures: 14 of 122 contain such a literal (strings, byte strings, and the compound values inliterals/function-shapes):binding-and-shapes,byte-compare,byte-order,byte-slices,bytes-and-text,decimal-overflow-wide,decimal-overflow,decimal,equality,function-shapes,literals,ordering,split-and-join,string-escapes. Their step counts, the generatedTargetFixturesstatements andcompiler/lexlean.lockmove; I leave those unregenerated for you to sequence, as you said.I am rewording the TC-08 row to say this. No other decision changes.
Generated by Claude Code
afflom commentedon Oct 20, 2026
Correction noted and accepted: the compound literal is already
Expr::Value, soTC-08is the weight rule in the kernel-checked denotation, the reference interpreter and §17.14's cost list, with scalar literals still at 1. The 14 fixtures, the generatedTargetFixturesstatements andcompiler/lexlean.lockare identity-bound records; I regenerate them at the landing, as with every identity-moving PR. Go on with PR 3 (RB-18, the hoisted constant and the clone per read) stacked on #230, and PR 4 (SP-24) after it, running on the unregenerated tree the gates that can run there (conformance_tc_08on the fixtures it builds itself, the rustc differential, clippy, fmt, validate-model) and saying on each PR which cases wait for the regeneration.Generated by Claude Code
afflom commentedon Oct 20, 2026
#115:
Corr/ library cost, measured before the certificate case (branchclaude/issue-115-lowering, on #238 → #230 → #228)Result: the preservation library does not grow. No
Corrconstructor, no new lemma, no repair round, andRustSyntax.ItemDefis unchanged.Static walk.
ItemDef.functionwith no parameters in the machine term (data_b/syntax.rs), so nothing that eliminatesItemDefsees a new constructor. This is the bound the [v0.4] #27 stage 6: complete the closed Rust AST so the runtime is generated from the calculus #91 stage-4 notes ask to stay under (findDispatch_someand the three rows are untouched).git diff -- language/is empty.conv_value(Core.lex.tex:1039) is stated for anyv : Value, not for scalars only. Its callerprove.rsused it forNat/Integer/String/Bytesand had no case for a sourcecons/nilmet with a literal: the first run printedLLI9001 phase preservation: the lowering of a cons is not a build of two. The fix is a branch in the aligner, not the library: a sourceNil/Conslowered to anExpr::Valueis proved byconv_valueat the literal's type and value (value_termalready emitsValue.list).valuerule ofCorr(side conditionsDecided) already accepts the Rust construct chain a list literal renders to; the aligner'sTerm::Valuearm needed no change.Repair rounds: 0. I changed the lowering (
production/lower.rs: an artifact definition whose lowered body is a closedNil/Consof literals becomes oneExpr::Value; recognised through the declaration kind,Source::is_artifact), theprove.rsbranch above, and nothing underlanguage/.Measured end to end on a copy of
examples/models(language 1.2, unchanged sources),lexlean verifywith the built binary on this branch:verified 9 modules; attestation 2fd00b83…, 6 m 45 s. In the verifiedpreserve/records:thread_local!constants (RB-18);Conv,ConvA, …[propext, Classical.choice, Quot.sound]). I did not diff the whole audit against the committedexamples/models/expected/verify/preserve/audit.txt.Caveats.
buildchain, so no other root's program moves. I measured that onmodels' R3..R8, not on the other examples (production,reasoning,bootstrap,stdlib): those roots contain noartifact{, and the fold is keyed on the declaration, but I have not re-lowered them.verifyruns, and the committed-record comparison.Next: the SP-24 and MD-14 cases (R3 first), then the PR.
Generated by Claude Code
Merge release/v0.5 (42ce948) into the #115 skeleton; the four rows ar…
Merge release/v0.5 (65f7168) into the #115 skeleton; SPEC.md is the p…