Issue #2862: The corpus-wide ledger tests reuse the committed proofs books and run as Nikaia tests

Open and answer this issue on GitHub.

blocked, ci · opened 2026-11-28 · updated 2026-11-29 · 10 comments

Part of the ci lane’s goal, a short CI run. Found while measuring the 80-minute suite of run 46111829022 (ci/bugs, 13a7f74c). Related: “The corpus-wide ledger tests are 4-6x slower in CI since the panics inference goes through loops” (#2474) is the cause’s real fix and stays open; this issue does not wait for it. Needs #2931

Facts: Ledger and bounds proofs, CI and caches

What happens today

The run’s critical path is two shards: x86 it-2 57 min, heavy-rest 41 min (arm64 53 / 39 min; every other job 10 min or less, from the job list of run 46111829022). In them run three Rust tests that check every .nika file of the tree in-process with Ledger::infer / Ledger::infer_package:

They assert tethers, Shared decisions and crossings, but each computes the whole ledger of each file, the panics column included, and solves every bounds question fresh: the in-process Ledger::infer reads no proofs book (nikaia.proofs), which the CLI does (crates/nikaia-std/src/compiler/proofs_book.nika, proofs_answers.nika). Cause traced by the callgrind figures in #2474: benches/lowering/source.nika alone takes 673 s per infer locally, 545 s of it in rs2nika_free_methods, through bounding_loop_invariant in bounds_walk.nika; the file is proved again in each of the three tests. benches/lowering/ has no nikaia.proofs; examples/* and packages/* projects have one.

Decision

Supervisor, 2026-11-28, on the owner’s rule that no compile-time proof is traded for speed: the corpus checks reuse the committed proofs books the way the CLI does, so an answer already proved is read and every other question is still solved. Nothing is skipped or weakened. By CLAUDE.md (New tests), the three tests move to Nikaia rather than being changed in Rust: each becomes a .nika test in tests/compiler/tests/ with its .stdout, run by nikaia test, that checks the corpus through the toolchain (with the books), per file in parallel.

To build

  1. Give benches/lowering/ (and any other corpus file the three tests read that lies in no project with a book) a committed proofs book, written by the toolchain, so its answers are reused.
  2. Move sharing::the_one_shared_in_the_repository_comes_out_atomic_undecided to a .nika test that asserts the same: exactly one undecided Shared (db in examples/fortunes.nika, atomic), and hello-http’s crossing counters atomic and decided. Per file in parallel.
  3. Move tethers::nothing_in_the_corpus_needs_a_tether and bytes::the_corpus_needs_no_tether the same way, keeping both claims of the latter (no tether, no crossing refused NK25.. in examples/ and std’s sources). Where two tests read the same files, one walk of the tree may assert both claims (as bytes.rs already does for two).
  4. Delete the three Rust tests once their .nika twins pass.
  5. What Nikaia or the toolchain lacks on the way (a flag that prints a column, reading a book from a test) is a Found: and stops the step (CLAUDE.md, A missing form stops the work).

Done when

The three claims are asserted by .nika tests in tests/compiler/tests/ that read the proofs books, the three Rust tests are gone, and the report gives each new test’s local time against the old Rust test’s (the step that deletes the last Rust test carries Fixes #N); one Found: line per finding. The supervisor checks the it-2 and heavy-rest durations on the next CI run.

Files and limits


Generated by Claude Code

Comments

keywan-ghadami, 2026-11-28

Brief queued: issue-2862


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

Issue #2862

Your work order is issue #2862, 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/2862/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/ci/issue-2862.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-11-28

Run: issue-2862, Result: blocked

Tokens: input 82, cache read 2434591, cache write 70560, output 17582 Cost: 1.45 USD, time 0 min 40 s, turns 41

Report

Result: blocked Files: none Commit: none Body: nothing committed. Probes on target/fast/nikaia at 5baec0db4 (binary not older than HEAD). The CLI has the needed flags (check --sharing, --tethers; it prints findings), reads the project’s nikaia.proofs (project::with_recorded_proofs) and checks 59 of the 79 corpus files in 36 s wall time with 4 in parallel; the gaps below stop to-build items 1-3 before any edit. Pushed: none Tests: none run (nothing changed); probes only. nikaia check --tethers --user-parallelism yes benches/lowering/source.nika gave no output and was stopped at its 60-minute background limit Gate: green Deviation: none Found: The toolchain cannot write a proofs book for a program the checker refuses, so to-build item 1 (a committed book for benches/lowering/) cannot be done: a book is written only by write_ledgers (crates/nikaia/src/project.rs) after a member lowers, and benches/lowering/source.nika has check errors of its own (CHANGELOG 0.0.x entry: “benches/lowering/source.nika … has its own check errors”). Probe: a project bk (nikaia.toml [package] name = "bk"), src/main.nika = fn pick(xs: Vec[i64], i: i64) -> i64 { if i >= 0 && i < xs.len() { return xs[i] } return 0 } + fn main() throws { println(f"{pick([1, 2, 3], 1)}") } + fn broken() -> i64 { return undefined_name }; nikaia build prints error[NK1117]: undefined_name isn't declared anywhere. and writes no nikaia.proofs. The same project without broken writes nikaia.proofs. Also, benches/lowering has no nikaia.toml, so Layout::resolve reads no book for it even if one existed. Options: book entries kept for a refused build, or fix source.nika and make benches/lowering a project; no decision yet Found: Loose corpus files that use a dependency cannot be checked or explained through the toolchain, and the Rust sharing test’s one claim lives in one of them: nikaia check --sharing --user-parallelism yes examples/fortunes.nika prints error[NK1339]: A single file outside a project has no dependencies, so there's no http to use. and no report; benches/game/json/tree.nika gives the same (json); examples/foreign-runtime/overlaps.nika gives error[NK1181]: hyper_shim::serve_once ... hyper_shim isn't declared anywhere. The in-process Rust tests parse these files alone. The same fortunes.nika copied into a scratch project with http = { path = ".../examples/http" } does print atomic db (Shared[postgres::Connection]) could not decide: ... fetch, even though NK1117 then refuses it. So a toolchain test needs each such file in a project (moving examples/fortunes.nika breaks 44 references), or a test that wraps it in a scratch project, which reads no committed book; no decision yet Found: The toolchain’s answers are not the in-process tests’ claims, so a “same claims” move needs a decision on what to assert. (a) nikaia check examples/foreign-runtime/crossing/src/main.nika and .../smuggled/src/main.nika are refused error[NK2502]: handle can't move to another thread on purpose (the file’s header: “expected to be refused”), but bytes.rs asserts that no examples/ program has an NK25.. refusal; that holds only because Ledger::infer alone does not read their contracts/. (b) hello-http’s counters come out plain under the project’s user-parallelism = "no" and word ... crosses: a kept lambda only with --user-parallelism yes, while sharing.rs asserts Count::Atomic (the ledger’s switch-independent floor, sharing::infer). (c) benches/brc/fast.nika is refused NK1300 by the CLI. Proposal: assert crossing/smuggled refused exactly NK2502, and run the sharing claim with --user-parallelism yes; no decision yet Needs: supervisor decision Changelog: none Issue: broke I7: item 1 assumes the toolchain can write a book for benches/lowering, but a book comes only from a successful nikaia build of a project; broke I5: the issue says the moved tests assert “the same”, but through the toolchain fortunes/tree/overlaps are not read and crossing/smuggled are refused, which no Rust test sees Owner: none Comment: #2474 nikaia check --tethers --user-parallelism yes benches/lowering/source.nika (target/fast, 5baec0db4) printed nothing in 60 minutes and was stopped; #2474 quotes 673 s per infer Friction: a background check of benches/lowering/source.nika used up the whole 60-minute background limit and printed nothing Disk freed: none; target/nikaia-project-tests 873M, / 5.3G free, no new cache entry over 100 MB Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDtmukJNapbMLmZMzTV

Debrief

  1. Most time: the background nikaia check of benches/lowering/source.nika. It ran into the 60-minute background limit, printed nothing and settled nothing. Next came reading project.rs, main.rs and cache.rs to learn when a proofs book is read and when one is written.
  2. Looked up: when a book is read (only in a project, via with_recorded_proofs) and when one is written (write_ledgers, only after a member lowers). Also that check already has --sharing and --tethers, and which corpus files lie in no project. That foreign-runtime/crossing and smuggled are refused on purpose, and that hello-http’s project sets user-parallelism = "no".
  3. Checks: useful were the parallel check --sharing --tethers over the 78 other files (36 s), the scratch fortunes project, and the two tiny projects showing a refused build writes no book. The hour-long lowering check was wasted.
  4. One change: the brief should say that nikaia build writes nikaia.proofs only for a project that checks, and should give one CLI line per test claim, to be probed before planning.
  5. What the issue lacked:
    • broke I7: item 1 takes for granted that the toolchain can write benches/lowering a book; no probe settled that (nothing writes one for a refused program outside a project).
    • broke I5: “asserts the same” was never run through the CLI; the toolchain refuses fortunes, tree, overlaps, crossing and smuggled.
    • knowledge: Ledger and bounds proofs in-process Ledger::infer answers at the switch-independent floor (no contracts, crossings assumed possible), while the CLI uses the project’s settings and dependencies.
  6. Fact: Core Never run a check of benches/lowering/source.nika as a probe: it prints nothing for over 60 minutes and uses up the background limit.
    Fact: Ledger and bounds proofs nikaia.proofs is written only by a successful nikaia build of a project (write_ledgers in project.rs); a refused program or a file outside a project gets none.
  7. Fact: CI and caches nikaia check --sharing --tethers --user-parallelism yes over the 78 corpus files other than benches/lowering took 36 s wall time with 4 in parallel (2026-11-28, 5baec0db4); the slowest were benches/yaml/{events,load} at about 32 s each.
    Fact: CI and caches Loose corpus files that use a dependency (examples/fortunes.nika, benches/game/json/tree.nika, examples/foreign-runtime/overlaps.nika) are refused by nikaia check at once (NK1339 / NK1181) and print no report (2026-11-28, 5baec0db4).

Generated by Claude Code

keywan-ghadami, 2026-11-28

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


Generated by Claude Code

keywan-ghadami, 2026-11-29

From the report of the run of issue-2871-r2 (#2871):

benches/lowering is now a project with a committed nikaia.proofs (benches/lowering/src/main.nika, a 21 454-token copy of packages/yaml; source.nika, 159 720 tokens, is gone), so the corpus tests walking benches/ parse a much smaller file there.


Generated by Claude Code

keywan-ghadami, 2026-11-29

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


Generated by Claude Code

keywan-ghadami, 2026-11-29

Supervisor decision, 2026-11-29: this issue runs again now; the open rest of “Loose corpus files that use a dependency cannot be checked…” (#2872) and of “The toolchain’s answers are not the in-process tests’ claims…” (#2873) does not hold it up.


Generated by Claude Code

keywan-ghadami, 2026-11-29

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


Generated by Claude Code

keywan-ghadami, 2026-11-29

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


Generated by Claude Code

keywan-ghadami, 2026-11-29

Run: issue-2862, Result: partial: item 3’s std part and item 4’s last deletion are left. bytes::the_corpus_needs_no_tether stays, because no .nika test can check std’s compiler package in time (Found below)

Tokens: input 120, cache read 4522386, cache write 118649, output 36270 Cost: 2.72 USD, time 35 min 20 s, turns 60

Report

Result: partial: item 3’s std part and item 4’s last deletion are left. bytes::the_corpus_needs_no_tether stays, because no .nika test can check std’s compiler package in time (Found below) Files: none Commit: none Body: two local commits. (1) “test: the corpus’s one undecided Shared and its tethers are the toolchain’s answers, checked per file at once”: tests/compiler/tests/corpus_shares_one_undecided_value_and_needs_no_tether runs nikaia check --sharing --tethers --user-parallelism yes on every tracked .nika under examples/ and benches/ (par_iter limit 8, each project with its settings, dependencies and committed nikaia.proofs). It asserts the one undecided Shared (db, examples/fortunes), 0 tethered positions, and the known refusals verbatim (brc/fast NK1300 x2, crossing/smuggled NK2502, fortunes NK1245 x2). The commit deletes sharing::the_one_shared_in_the_repository_comes_out_atomic_undecided and tethers::nothing_in_the_corpus_needs_a_tether. (2) “test: std’s runtime package and loose modules need no tether, as the toolchain checks them”: tests/compiler/tests/std_sources_need_no_tether runs check --tethers on std’s runtime package and loose modules: 0 tethered, 0 refused. The –tethers report of std’s compiler package shows site_split (check_declared.nika:173) <result> tethered with no NK2303; not chased Pushed: local d2aff4d96, local 1a205cceb Tests: new corpus test 11 s alone, 23 s –both-settings (old Rust sharing test: about 51 min in CI per the issue, stopped after 53 min locally by #2872’s run; tethers: same walk, not timed). New std test 3.6 s (bytes stays). Both green under –both-settings. cargo clippy -p nikaia –test it -D warnings clean, rustfmt clean, pre-push green Gate: green Deviation: item 3 is built only partly: std’s compiler package has no .nika twin, so bytes.rs’s test is not deleted (item 4) and nothing says Fixes #2862 Found: std’s compiler package cannot be checked through the toolchain within a test’s 300 s limit, so bytes::the_corpus_needs_no_tether has no Nikaia twin for it: target/fast/nikaia check --tethers crates/nikaia-std/src/compiler/ty.nika (HEAD a373031b0) took real 22m52s, user 25m23s, exit 0. The package has no nikaia.proofs, and check uses no build cache, so it proves every claim afresh. lower-std refuses every error finding of each std file it lowers, NK2303 included (crates/nikaia/src/sysroot.rs, the refusals filter before emit_std_against). Options: count lower-std’s refusal as the compiler package’s claim and delete the Rust test, or give the compiler package a committed proofs book check reads; no decision yet Needs: supervisor decision Changelog: Tests: the corpus’s one undecided Shared and its freedom from tethers, and std’s runtime and loose modules’ freedom from tethers, are checked through the toolchain with the committed proofs books, per file at once; two corpus-wide Rust tests are gone. Issue: broke I5: “std’s sources” through the toolchain includes the compiler package, whose check takes 23 min, and no probe of it was in the issue; broke I7: the claims of item 3 were described from bytes.rs’s walk, which today asserts only NK2303 over the whole tree (the NK25 part had moved to corpus_crossings_and_counters_are_the_toolchains under #2873) Owner: none Comment: #2474 nikaia check --tethers crates/nikaia-std/src/compiler/ty.nika (target/fast at a373031b0) took 22m52s real, 25m23s user on one core; std’s compiler package has no nikaia.proofs Friction: a second background check of the compiler package was killed by the out-of-memory killer after 5m49s and measured nothing Disk freed: none; target/nikaia-project-tests 1011M, / 4.2G free, no new cache entry over 100 MB Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDtmukJNapbMLmZMzTV

Debrief

  1. Most cost: checking std’s compiler package. The plain check --tethers of it took 22m52s. A second background check was killed by the out-of-memory killer after 5m49s and measured nothing. Before that, the old Rust tests did not finish locally in 53+ minutes, so I have no local time to compare against.
  2. Looked up: how check --sharing --tethers prints its report (section headers, absolute paths for dependencies, the could not decide: line, the padded tether states). Also which packages have a nikaia.proofs (std’s compiler package has none). And whether lower-std refuses every error (sysroot.rs, the refusals filter). The brief could have named all of these.
  3. Checks run:
    • Useful: the two tests under --both-settings, clippy on it, rustfmt, pre-push.
    • Wasted: the second compiler-package check (killed), and the attempts to time the old Rust tests (the issue’s CI figures were enough).
  4. One change: a brief that orders “through the toolchain” for a package should give that package’s check time, or say “no figure, measure it first with a 5-minute cap”. That would have shown in minutes that std’s compiler package cannot be a test.
  5. What the issue lacked:
    • broke I5: no probe of check on std’s compiler package, the one that settles whether item 3 fits a test.
    • wrong I7: item 3 described bytes.rs’s claim as wider than it is; today it asserts only NK2303, since the NK25 part moved under #2873.
    • knowledge: Core | std's compiler package has no nikaia.proofs, and check uses no build cache, so checking it proves everything afresh (about 23 min).
  6. Traps the next builder will meet:
    • Fact: Core | A dependency's '--- path' header from check comes out absolute; strip "<repo>/" before comparing it with git ls-files paths.
    • Fact: Core | A package's files and its dependencies show up in every check that reaches them, so a corpus test must read each section once, and the checked file's own header must not count as already seen.
    • Fact: Slices | Text cannot be sliced (NK1214); use strip_prefix(...) ?? line.
  7. For the next builder in this area:
    • Fact: CI and caches | tests/compiler/tests/corpus_shares_one_undecided_value_and_needs_no_tether.nika: 11 s alone, 23 s --both-settings (2026-11-29, d2aff4d96); it replaced the Rust sharing test (about 51 min in CI).
    • Fact: CI and caches | tests/compiler/tests/std_sources_need_no_tether.nika: 3.6 s (2026-11-29, 1a205cceb).
    • Fact: Ledger and bounds proofs | nikaia check --tethers crates/nikaia-std/src/compiler/ty.nika: 22m52s real, 25m23s user, exit 0 (2026-11-29, a373031b0, target/fast); a second, parallel run hit the out-of-memory killer.

Generated by Claude Code

keywan-ghadami, 2026-11-29

Where it stands (supervisor, 2026-11-29): a run built items 2 and 3 for examples/ and benches/. These commits are on develop and wait for the driver’s push:

Found: std’s compiler package cannot be checked through the toolchain within a test’s 300 s. nikaia check --tethers crates/nikaia-std/src/compiler/ty.nika took 22m52s and exited 0. The package has no nikaia.proofs, so every claim is proved again.

bytes::the_corpus_needs_no_tether therefore stays until the compiler package has a committed proofs book. That book comes from “lower-std keeps a proofs book for the compiler and runtime packages, and check of their files reads it” (#2931). #2931 in turn waits for “The proofs book of the compiler package is 109 MB instead of “lines, not megabytes”: a compact encoding of certificates and models” (#2939) and that issue’s decision paper (#2941).

The rest of this issue is item 3’s compiler part and item 4’s last deletion. They are built after #2931.

Needs #2931


Generated by Claude Code

Back to Open Issues