Issue #2827: build-time code is compiled as one program per comptime value, not one crate…

Open and answer this issue on GitHub.

blocked, bugs · opened 2026-11-23 · updated 2026-12-01 · 4 comments

Filed by the driver from the Found: of the run of issue-2804 (#2804) (owner, 2026-11-06).

Found

build-time code is compiled as one program per comptime value, not one crate per package as ADR-321 D4 says (“The package’s build-time code is one crate, compiled by rustc directly and run once”): a cold env -u CARGO_TARGET_DIR NIKAIA_CACHE_DIR=<fresh> nikaia build --locked of a git archive HEAD tests/build-time copy (crates symlinked; 60d45569c, $NIKAIA_OLD) takes 116 s and leaves 37 directories under target/nikaia/build-time/comptime/, each with its own main.rs, run binary and answer, written about 1-3 s apart; expected: one crate under that directory per build, compiled and run once; traced: comptime_bundle_run (crates/nikaia-std/src/compiler/comptime_bundle.nika) compiles and runs one program per value, called once per value through comptime_computed (comptime_tree.nika); batching the values while keeping per-comptime bounds (D11), earlier values feeding later ones and the per-value cache (#2149) is a redesign that does not fit this run

To build

Done when

The probe or check gives the expected output the first item names from its ADR or Part I-III section, and a tests/compiler/tests/ test (or the named check) that failed on the unfixed tree is green; or the probe already passes on develop and a test pins it, naming the commit that fixed it; or the issue is closed as by design, naming the function or ADR.


Generated by Claude Code

Comments

keywan-ghadami, 2026-12-01

Brief queued: issue-2827


agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —

Issue #2827

Your work order is issue #2827, inlined below with its comments. There is no brief written around it: plan your own steps from its To build list, build them in order, commit after each finished step, and end when its Done when holds (or at the limits of builder.md, reporting what is left). The facts in your prompt are Core of docs/builder-facts.md; more on a topic: nikaia run scripts/syntax.nika -- KEYWORD, a probe: nikaia run scripts/probe.nika -- SNIPPET.

Measure the issue against docs/issues.md while you work: what it lacked, what was wrong in it. That answer goes into the report’s Issue: field. A finding, a changed plan or a finished item also goes into the issue as a comment (gh api repos/Nikaia-Foundation/Nikaia/issues/2827/comments -F body=@file, ending with the Claude Code footer), rule I13.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/bugs/issue-2827.md.report.md)

Fields: Result, Files, Commit, Body (optional), Fixes, Pushed, Tests, Gate, Deviation, Found, Needs, Changelog, Issue, Owner (a question for the owner), Comment (#N <text>, what to say on another issue; the driver posts it, one line each), Friction, Disk freed, and last Attribution: with your commit trailer lines below it.


Generated by Claude Code

keywan-ghadami, 2026-12-01

Run: issue-2827, Result: blocked

Tokens: input 30, cache read 638837, cache write 42625, output 8088 Cost: 0.68 USD, time 1 min 48 s, turns 15

Report

Result: blocked Body: reproduced on HEAD 69e21888d (target/fast/nikaia, built after it): a scratch package [package] name = "ct2827" with fn sum_to(n: i64) -> i64 { let mut s = 0; for i in 0..n { s = s + i + 1764587000 }; return s }, comptime A: i64 = sum_to(10), comptime B: i64 = sum_to(20), comptime C: i64 = sum_to(30) and a fn main() throws printing them, nikaia run, leaves 3 directories under target/nikaia/build-time/comptime/, each with its own main.rs, run and answer (11:21:51-11:21:52); ADR-321 D4 expects one crate per package, compiled and run once. Traced: the checker asks for each value on its own (crates/nikaia/src/comptime_run.rs compute -> comptime_tree.nika comptime_value_computed -> comptime_computed, which builds sub_program for that value with earlier values inlined through known, then comptime_driven/cr_with_driver and host.run_comptime); comptime_bundle.nika changed since the Found only in dfb27ed41 (library naming), so the Found holds on develop Pushed: none Tests: probe above on target/fast/nikaia (HEAD 69e21888d): 3 values, 3 crates; nothing built, no test run Gate: green Deviation: none Found: none Needs: supervisor decision: ADR-321 D4 as one crate per package is a redesign across several passes that the issue gives no To build items for. Open choices: (1) the checker computes values on demand, so a batch must collect the package’s comptimes (written types, D2 rule per value) before or at the first request; (2) a value that cannot be lowered or crossed, or is forbidden, is either left out of the batch and run alone, or refuses the batch; (3) a stop (NK1152/NK1244) ends the shared run, or each value runs under its own counters reset (D11) and recovery; (4) earlier values feeding later ones (comptime_worked_out_ahead, Part II 10.2) get an order inside the crate instead of being inlined literals; (5) the per-value answer cache (#2149) stays the key, and only the misses are batched; (6) a dependency-home value (ADR-321 D13) gets a crate per home package. no decision yet Changelog: none Issue: broke I9: a redesign filed as a bug with the generic three items (reproduce, fix, test); it needs numbered items, one pass each (collect the batch, a multi-value driver in cr_with_driver, the host’s batched run and answers, the fallbacks), each settling choices (2)-(6) above; broke I8a: the cost (116 s for 37 values) has no measure of what a batch would save (rustc per crate against the shared dylib, D3) Comment: #2827 Reproduced on 69e21888d: three comptime values in a scratch package give three crates under target/nikaia/build-time/comptime/ (main.rs, run, answer each). Cause traced: comptime_run.rs compute asks for one value at a time; comptime_tree.nika comptime_computed builds and runs one program per value. A batch needs decisions on what to do with values that are forbidden or can’t be lowered, how a stop works in a shared run, how earlier values are ordered, and the crate per home package. The run stopped before building; it needs numbered To build items. Owner: none Friction: none Disk freed: scratch package target removed; target/nikaia-project-tests 2.0G, / 11G free; no new cache entries over 100 MB Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDutPTwP5Xj5HkGuidk

Debrief

  1. Most turns: judging whether this was a fix that fits one run or a redesign. That meant reading ADR-321 D3, D4 and D11, then comptime_value_computed, comptime_computed and the Rust compute that calls them, to see that the checker asks for values one at a time. The reproduction itself took one call. The whole run was about 15 calls and about $0.60.
  2. Looked up: where in comptime_run.rs the checker calls into the computation, and the text of ADR-321 D4, D5, D11 and D13. Neither the issue nor the facts gave these. The brief could have named comptime_run.rs compute as the entry point and quoted D4 and D11.
  3. Checks run: the binary’s age against HEAD, where.nika on two names, the file outline, and a three-value scratch package with its directory timestamps. None was wasted. I chose not to rerun the Found’s 116 s cold tests/build-time probe, because the small package showed the same thing in 1 s.
  4. One change: the driver should not file ready from a Found: that says the fix is “a redesign that does not fit this run”. It should file it as decision, or as a request for a planning brief. The builder’s run then becomes only a reproduction.
  5. What the issue lacked:
    • broke I9: it has only the generic reproduce/fix/test items for a redesign over several passes. There are no items, one per pass, that settle the batch’s choices (fallback for one bad value, how a stop works in a shared run, ordering, cache key, one crate per home package).
    • broke I8a: it gives no estimate of what a batch saves (a rustc compile and link per crate against the shared library) compared with 116 s for 37 values.
    • knowledge: Core | A comptime's directory under target/nikaia/build-time/comptime/ is written only on a miss in the per-value cache, so a reproduction needs function bodies changed from the last run (a constant made from date +%s works), not a fresh NIKAIA_CACHE_DIR.
  6. Fact: Core A Found: that says its own fix “does not fit this run” still arrives as a ready bug brief; check that sentence first and report blocked with the open choices, rather than starting the redesign.
  7. Topic section (new, “Build-time runs”):
    • Fact: Build-time runs Values are computed one at a time: crates/nikaia/src/comptime_run.rs compute → comptime_tree.nika comptime_value_computed (per-value cache, #2149) → comptime_computed (sub_program, comptime_driven, cr_with_driver, host.run_comptime); comptime_bundle.nika builds the shared library (ADR-321 D3).
    • Fact: Build-time runs 2026-12-01, HEAD 69e21888d: a three-comptime scratch package gave 3 crates (main.rs, run, answer each) in about 1 s in total; the measure is find target/nikaia/build-time/comptime -name main.rs | wc -l after nikaia run.
    • Fact: Build-time runs The Found’s figure (116 s, 37 crates, cold tests/build-time, commit 60d45569c) is the cost a batch would cut.

One slip of mine: the large constant in the report’s Body: snippet was typed in afterwards, not copied from the file that ran (the real file used $(date +%s)). The report says so.


Generated by Claude Code

keywan-ghadami, 2026-12-01

From the report of the run of issue-2827 (#2827):

Reproduced on 69e21888d: three comptime values in a scratch package give three crates under target/nikaia/build-time/comptime/ (main.rs, run, answer each). Cause traced: comptime_run.rs compute asks for one value at a time; comptime_tree.nika comptime_computed builds and runs one program per value. A batch needs decisions on what to do with values that are forbidden or can’t be lowered, how a stop works in a shared run, how earlier values are ordered, and the crate per home package. The run stopped before building; it needs numbered To build items.


Generated by Claude Code

keywan-ghadami, 2026-12-01

Driver: not queued, this issue waits for #3031, which is still open (#1819). Set ready again when it is closed.


Generated by Claude Code

Back to Open Issues