Issue #1913: a per-function or per-unit ledger store that outlives one lower-std process…

Open and answer this issue on GitHub.

performance, blocked, ci · opened 2026-11-16 · updated 2026-11-19 · 9 comments

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

Found

a per-function or per-unit ledger store that outlives one lower-std process needs on-disk forms nobody has decided: crate::check::Checked (findings, CheckFacts, methods, stored_code; crates/nikaia/src/check/mod.rs:77) has no text or byte form, and the passes the issue wants woken per function (sync, throws, touch, keeps, locks, panics, tether in crates/nikaia/src/contracts/*.rs, 1743 lines, plus views::result_sources_in/places_stored_in) are Rust with whole-package infer(ledger, units, ...) entry points, so giving each one a per-function call is new Rust in Rust passes; CLAUDE.md “no new Rust” makes that a supervisor decision (move each pass into Nikaia first, or allow the Rust plumbing as #1277 did); no decision yet

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-11-16

Measured cost (the full table is on “lower-std: key each file on the interface entries it reads” (#1307)):

Proposal, not yet decided: move the remaining Rust passes of the ledger into Nikaia first, then build the store in Nikaia.


Generated by Claude Code

keywan-ghadami, 2026-11-17

Decided (owner, 2026-11-17)

Order: first move the ledger’s Rust passes into Nikaia, then build the persistent store in Nikaia. The store is a new feature, and under “no new Rust” it cannot be written into crates/nikaia/src/contracts/ (15 files). The move is part of self-hosting anyway (ADR-294, “Self-hosting” #125).

Finding that shapes the store: infer_package_parallel (crates/nikaia/src/contracts/mod.rs) also runs the checker over every unit (check::Checked). Storing the ledger rows alone saves little; an unchanged unit must skip its check as well. So the store keeps, per unit, the ledger rows and whatever later passes take from Checked (trust, the graphs).

To build

  1. Move contracts/ to crates/nikaia-std/src/compiler/*.nika, file by file, smallest first (ty, locks, panics, maps, order, sharing, keeps, send, touch, sync, throws, tether, trust, keep, then mod). Each step must give byte-identical lower-std output and an identical nikaia.ledger for the corpus. Each step is its own commit; a missing form stops the step (CLAUDE.md, Moving Rust into Nikaia).
  2. The store. Per unit: a key (the name-based key decided in “lower-std’s per-file key needs a decision on where package reads are recorded” (#1909)), the ledger rows, and the inputs that trust and the graphs need. It lives under target/ beside the lowering cache and outlives the process. A unit whose key matches is neither checked nor inferred again.
  3. Measure the same three cases as in “lower-std: key each file on the interface entries it reads” (#1307). Done when a body-only change spends no more than a tenth of today’s ledger time in the ledger phase, and heavy-sysroot-pair stays green.

Step 1 is large; the driver gets it in parts that fit a run.


Generated by Claude Code

keywan-ghadami, 2026-11-17

Brief queued: issue-1913


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

Issue #1913

Your work order is issue #1913, 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/1913/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-1913.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-17

Run: issue-1913, Result: partial: step 1 has done ty (afb5d7ca) and locks (00cabd66, report issue-1913.md.step2.report.md; its Body says 47 lines, really 55); left: step 1’s panics (its glue calls the Rust prover crate::bounds::proven in parallel through crate::proofs::in_parallel, so the Nikaia panics_infer needs a prover callback in the adapter), maps, order, sharing, keeps, send, touch, sync, throws, tether, trust, keep, mod; step 2 (the store, waits for #1909’s name-based key); step 3 (the measurement)

Tokens: input 138, cache read 5215855, cache write 122444, output 38310 Cost: 2.94 USD, time 0 min 4 s, turns 69

Report

Result: partial: step 1 has done ty (afb5d7ca) and locks (00cabd66, report issue-1913.md.step2.report.md; its Body says 47 lines, really 55); left: step 1’s panics (its glue calls the Rust prover crate::bounds::proven in parallel through crate::proofs::in_parallel, so the Nikaia panics_infer needs a prover callback in the adapter), maps, order, sharing, keeps, send, touch, sync, throws, tether, trust, keep, mod; step 2 (the store, waits for #1909’s name-based key); step 3 (the measurement) Files: crates/nikaia-std/src/compiler/check_types.nika crates/nikaia-std/src/compiler/ty.nika crates/nikaia-std/src/compiler/lowered.rs crates/nikaia-std/src/compiler/lowered/check_types.rs crates/nikaia-std/src/compiler/lowered/ty.rs crates/nikaia/src/contracts/send.rs crates/nikaia/src/contracts/ty.rs Commit: contracts/ty: the type constructors and the last-segment rule move into Nikaia Part: #1913 Body: The last logic of contracts/ty.rs moves into Nikaia: ty.nika gains a_named_ty, a_view_ty, a_seen_ty (with their ADR-278 D19 and ADR-281 D22 docs), and TyOps now only calls them, ty.nika’s parse and declared.nika’s written_ty; it goes when its Rust callers move. Rust base (one caller, a send.rs unit test) is replaced by the twin that already existed, check_types.nika’s type_last_segment, now pub for that test. The FIELD and VARIANT constants had no Rust reader and are dropped (the Nikaia checker writes $Variant itself). ty.rs: 146 to about 66 lines. The ledger’s values are the same: the constructors build the same Ty::Named, and no other lowered file changed. Tests: lower-std fixpoint (second run of the new binary changes nothing; only ty.rs, check_types.rs and lowered.rs moved); cargo test --lib contracts:: 3 passed, including send::tests::nothing_but_a_lock_or_a_count_is_refused_at_either_destination; it send:: held_across_a_pause:: sequences:: foreign_pointers:: nullable:: pausing_steps:: sequence_shapes:: fixed_size_array:: channels:: function_types:: 204 passed; clippy and fmt clean; pre-push green. No new test: a move with no change of behaviour Gate: green Deviation: none Found: none Needs: #1909 (step 2, the per-unit store, needs its name-based key) Changelog: none Issue: broke I11: step 2 says “the name-based key decided in #1909” but has no Needs #1909 line, so a run cannot tell whether the store waits for #1909 to close or only for its decision Friction: none Disk freed: none; target/nikaia-project-tests 1.6G, / 5.1G free (87% used), 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 Reviewed: 3a408d4244f18a04eb74ba8e3f0097332f9922de214e293e1ab0f5b95f443c67 Pushed: local afb5d7cae7b0ef7e32207187ae6cebe927310dbb

Debrief

  1. Most turns: waiting for the build cycle. My background wait loop had a broken [ test, so it never fired and ran until its time limit. I also spent turns finding each Rust function’s Nikaia twin (for example type_last_segment for base) before I could delete anything.
  2. Lookups the brief could have handed me:
    • Which contracts/*.rs functions have Rust callers outside contracts/ (free_calls from check/host.rs, task_facts).
    • Which of them already have a Nikaia twin.
    • That panics and the files after it call the Rust prover (crate::bounds::proven, crate::proofs::in_parallel), which still has no Nikaia form.
  3. Checks: for each step, the lower-std fixpoint by md5, the contracts:: unit tests, it filters (204 tests for ty, 70 for locks), tests/compiler --filter lock, clippy, fmt and pre-push. All were needed. The only waste was the hand-written wait loop.
  4. One change: the brief should give, for each file, its outside callers and the Rust it calls that is not in Nikaia. Then the order “smallest first” could be judged as “smallest movable first”, and I would have known before reading that panics needs a callback adapter.
  5. What the issue lacked:
    • broke I11: step 2 names #1909 but has no Needs #1909 line.
    • rules-gap: step 1 orders “byte-identical lower-std output” but gives no probe or command that checks the ledger is identical. I used “no other lowered file changed” as a stand-in.
  6. Traps the next builder will meet:
    • Fact: Core A background wait on the cycle should be one run_in_background call with timeout: 3600000, never a hand-written until grep ...; sleep loop: one wrong [ test makes it spin until its time limit.
    • Fact: slices Returning a text view as String (e.g. rsplit("::").next() ?? name) draws NK1104; reuse a cloning twin such as check_types.nika’s type_last_segment.
    • Fact: lowering A contracts/*.rs pass that needs Rust-only values (the emitter’s literal_expressions, the prover’s Proven) moves as a Nikaia *_infer taking a fn(...) sync callback, with the Rust file kept as the adapter that builds the ParsedViews.

Generated by Claude Code

keywan-ghadami, 2026-11-17

The report of the run of issue-1913 (#1913) judged this issue against docs/issues.md; the author fixes the issue by the rule it names (How a run judges its issue):


Generated by Claude Code

keywan-ghadami, 2026-11-17

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


Generated by Claude Code

keywan-ghadami, 2026-11-17

The owner decided on 2026-11-17: option A. The contract passes move into Nikaia first, and the per-function entry and the stored form of their facts are built there. No new Rust plumbing is allowed this time, unlike #1277.

The move is filed as “The contract passes (sync, throws, touch, keeps, locks, panics, tether) move into Nikaia, each with a per-function entry” (#1982).

Needs #1982

This issue stays blocked until #1982 is done. “lower-std: incremental ledger, facts per function and per unit…” (#1308) and “lower-std: key each file on the interface entries it reads…” (#1307) wait on it too.


Generated by Claude Code

keywan-ghadami, 2026-11-17

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

#1982’s run found the seven contract passes already in Nikaia with Rust adapters; what is left is the adapters’ glue (bounds proving, parallel proofs, ledger writes) and a per-function entry whose meaning for a fixpoint pass and whose test route are undecided.


Generated by Claude Code

keywan-ghadami, 2026-11-19

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

ADR-100 D7 (from #1984) decided the per-function contract entry; what is still open for #1308 is the on-disk form of the stored per-function columns and the per-unit Checked (file layout, key, where it lives under target/); once that is written down, #1913 can close


Generated by Claude Code

Back to Open Issues