Open and answer this issue on GitHub.
ready, solver · opened 2026-11-23 · updated 2026-11-23 · 2 comments
Split out of “bounds walk: a method’s found facts through self” (#1667) when its third run was accepted (2026-11-23).
When a function returns a struct, the bounds walk keeps no fact about the lengths of the struct’s list fields. A read of that field in the caller therefore stays checked, although the callee plainly builds it non-empty or with a known length.
Sites on develop (nikaia check --bounds packages/logic/src/main.nika):
packages/logic/src/sv_sat.nika 668: learned.lits[0], where learned = self.analyze(..). analyze always pushes the asserting literal first.packages/logic/src/sv_simplex.nika 2834-2836: split_l.lits[..] / split_c.lits[..].violated() in sv_simplex (687-700 before sv_simplex moved to packages/logic) have the same shape. Map them again on today’s lines.result.f.len() >= 1, result.f.len() == n), derived in the callee like the found facts of a free function’s result (ADR-306) and carried to the caller’s binding.tests/compiler/tests/: a function returns S { xs: [a] } or pushes once before returning, and the caller’s s.xs[0] is proved; a function that may return S { xs: [] } stays checked.The probe test passes under both settings, and the sites above print proved in check --bounds packages/logic/src/main.nika, or the report names each site that still does not and why.
Brief queued: issue-2782
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #2782, 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/2782/comments -F body=@file,
ending with the Claude Code footer), rule I13.
develop in the main checkout; other agents’ uncommitted files are not yours: never touch or stage them.target/fast/nikaia run scripts/commit.nika -- REPORT (it adds exactly the report’s Files:); the driver pushes.cargo build --profile fast -p nikaia, lower-std and its fixpoint when a tools/*.nika changed, cargo fmt, cargo clippy --all-targets -- -D warnings, nikaia run scripts/pre-push.nika, the tests the issue names and the ones your change touches.CHANGELOG.md, badges and NK codes are the supervisor’s. New tests in Nikaia only: a Rust test file an older issue names is built as a tests/compiler/tests/ program, no Deviation: and no Issue: point (I9, #1671).Body:. Found: is only for what lies outside the area, cannot be fixed this run or needs a decision; the driver files it as an issue.std or the toolchain lacks stops the work, unless an ADR or Part I-III refuses it (name it): Result: blocked, Found: the gap with a probe, Needs: supervisor decision.NIKAIA_CACHE_LIMIT=2G; at the end delete your own clone’s target/ and target/release/nikaia-scratch.suspected, or does not mark (docs/issues.md I7), is a hypothesis: run the check that settles it (nikaia run scripts/where.nika -- NAME, the probe with a trace, callgrind for a cost) before you build on it (owner, 2026-11-16). Shown false: say so in Issue: as wrong I7: <what the check showed> (the driver comments it on the issue) and follow the real cause.Result: partial with what you ruled out, the probe, and the suspected file and function./home/user/Nikaia/docs/briefs/solver/issue-2782.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.
Result:, Gate: (green or red <check>), Deviation:, Found: and the other fields with nothing to say hold the bare word: done, none. Anything after it reads as content.Result: done only when the issue’s Done when holds; partial with the items left otherwise.Deviation: only for an item of the issue built otherwise than written, or not built. Found: only for a defect outside your area, or one this run cannot fix: one defect per Found: line, with its probe and the output it gives, only the shapes that fail today, and the suspected file and function or cause unknown (#1695); a by-design behaviour is none (#1677). A correct program your own change refuses (a fail-closed check’s false refusal) is no Deviation: but one Found: line per shape, with its probe (#1680). Everything else goes into Body:; how you verified goes into Tests:.Issue: by docs/issues.md, How a run judges its issue: complete, or broke I<n>: ..., rules-gap: ..., wrong I<n>: ..., joined with ;; a point your own commit built gets (built) after its kind (rules-gap (built): ...), and the driver does not file it. complete is the bare word: prose after it (complete; the earlier runs ...) is filed as an improvement issue (#1931); history or a note for your own issue goes into Body: or Comment: #N <text>.done <sha>, report <path> (or BLOCKED: ... / PUSH REJECTED ...).Generated by Claude Code
Run: issue-2782, Result: partial
Tokens: input 202, cache read 7138256, cache write 152847, output 45401 Cost: 3.75 USD, time 23 min 22 s, turns 101
Result: partial
Files: crates/nikaia-std/src/compiler/bounds_walk.nika crates/nikaia-std/src/compiler/lowered.rs crates/nikaia-std/src/compiler/lowered/bounds_walk.rs crates/nikaia-std/src/compiler/lowered/check_core_call_on.rs crates/nikaia-std/src/runtime/lowered.rs crates/nikaia-std/src/runtime/lowered/abort_lines.rs examples/inventory/nikaia.proofs examples/n-body/nikaia.proofs packages/logic/nikaia.proofs packages/yaml/nikaia.proofs tests/build-time/nikaia.proofs tests/compiler/nikaia.proofs tests/language/nikaia.proofs tests/page-examples/nikaia.proofs tests/compiler/tests/a_list_not_empty_is_derived.bounds tests/compiler/tests/a_list_not_empty_is_derived.nika tests/compiler/tests/prove_the_values_a_call_returns_bound_a_read.bounds tests/compiler/tests/a_struct_result_keeps_the_least_length_of_its_list_fields.nika tests/compiler/tests/a_struct_result_keeps_the_least_length_of_its_list_fields.stdout tests/compiler/tests/a_struct_result_keeps_the_least_length_of_its_list_fields.bounds
Commit: bounds walk: a struct result keeps the least length of its list fields
Body: BoundsReturns gains floors (least length of each list field of a returned struct, asked >= 2 then >= 1, proved at every return, a struct literal’s field read through its value’s path, ADR-306 D23/D35); bounding_measured states len(name.f) >= floor at the caller’s let, also through ?? (nullable struct results); new proofs: a_list_not_empty_is_derived 24, prove_the_values_a_call_returns_bound_a_read 49, check_core_call_on opens[index], abort_lines table[1]; ledgers refreshed: the new floor questions add 9375 entries to packages/logic/nikaia.proofs (82667 to 91413 lines; HEAD’s ledger was current under the HEAD binary, so all are this change’s), 15 yaml, 94 page-examples
Part: #2782
Tests: new a_struct_result_keeps_the_least_length_of_its_list_fields passes –both-settings, FAILED on the unfixed compiler ($NIKAIA_OLD, 0 of 6 proved); all 193 tests/compiler .bounds compared old vs new by check –bounds, only the 2 above changed (sound, reblessed, both-settings ok); ledgers –check all current; pre-push green; clippy nikaia-std clean
Gate: green
Deviation: none
Found: a callee in another file of the package gives its struct result no list-field length (sv_simplex 2834-2837 split_l.lits/split_c.lits, callee SvBook.split in sv_proof.nika); traced: found returns are computed per file, bounds_returns in bounds_proven.nika:135 runs over one file’s program, other files reach a body only through beside frames (ADR-391 D1); probe package pk, nikaia.toml [package] name = "pk" version = "0.1.0", src/book.nika pub struct S { pub xs: Vec[i64] } pub struct Book { pub atoms: Vec[i64] } impl Book { pub fn split(mut self, a: i64) -> S? { if a < 0 { return null } self.atoms.push(a) return S { xs: [a, a] } } }, src/main.nika fn first(mut b: Book) -> i64? { let s = b.split(3) ?? return null return s.xs[1] } fn main() throws { let mut b = Book { atoms: [] } println(first(b) ?? 0) }; nikaia check --bounds src/main.nika (HEAD + this change) prints 3 s.xs[1] checked: no fact bounds what it reads, the same two files merged into one print proved (test a_struct_result_keeps_the_least_length_of_its_list_fields line 57); no decision yet whether found returns reach across files
Found: a list grown by a for loop loses len >= 1 at the return of a found-returns callee, for a struct field and a returned list alike (sv_sat 668 learned.lits[0], analyze builds lits = [0] and pushes in loops); probe loop2.nika: pub struct S { pub xs: Vec[i64] } pub fn l1(a: i64) -> S { let mut xs: Vec[i64] = [0] for k in 0..<a { xs.push(k) } return S { xs: xs } } pub fn l3(a: i64) -> Vec[i64] { let mut xs: Vec[i64] = [0] for k in 0..<a { xs.push(k) } return xs } pub fn r1(a: i64) -> i64 { let s = l1(a) return s.xs[0] } pub fn r3(a: i64) -> i64 { let s = l3(a) return s[0] } fn main() throws { println(r1(2) + r3(1)) }; nikaia check --bounds loop2.nika prints s.xs[0] checked and s[0] checked, should be proved since a push never shortens a list (Part I: push appends), and the same loop then xs[0] inside one function prints proved; without the loop (xs.push(a)) the caller’s read is proved; cause unknown, suspected: the main walk of bounds_rounds_settled / bounding_pass in bounds_walk.nika forgets the length at a loop’s exit (check: –bounds-trace on the return line of l1)
Needs: none
Changelog: Bounds: a struct a call returns keeps the least length of its list fields - s.xs[0] after return S { xs: [a] } or one push needs no check (#2782).
Issue: ok
Owner: none
Friction: none
Disk freed: 0; target/nikaia-project-tests 1.8G, / 11G free, no new entry over 100 MB
Reviewed: 8f18e088913d9fdac841df9d2d78e45525e8f337d1a7ff8107f00a2cdb25cfaa
Pushed: local 3389b4ddf0682d7b4159237d919c6906f92c4949
Attribution:
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01UVxJDwk9ubq9teP7QCErff
len >= 1 after a loop that pushes. I then spent more turns on the loop shape and did not fix it.bounding_measured fit together (ADR-306 D23/D25/D34/D35), that found returns are per file, and how a package’s files see each other (no use). I also had to work out probe syntax (ref mut refused, NK1158; mut b: Book works).check --bounds over all 193 .bounds tests, which found 2 changed tests. Also the --both-settings runs, ledgers --check and --refresh, pre-push and clippy.--bounds-trace and check that each callee is in the same file as its caller. That would have shown the cross-file sites as out of reach before I built anything.broke I7: it named no cause for sv_simplex 2834–2837 and did not say that the callee SvBook.split is in another file, where found returns cannot reach.rules-gap: no rule asks an issue to name the shape of each target site (a list grown in a loop, as in sv_sat 668’s analyze).knowledge: Ledger and bounds proofs | a change to the bounds walk that asks new questions leaves the committed ledgers stale; run ledgers.nika --refresh before committing.Fact: Core | an unquoted heredoc expands the backticks in a report's probe snippets, so write the report with a quoted heredoc ('EOF') or the Write tool.Fact: Ledger and bounds proofs | found returns (ADR-306 D23) are computed per file in bounds_proven.nika:135, so a callee in another file of the package gives its caller no result facts.Fact: Ledger and bounds proofs | measure a bounds change with check --bounds old vs new over tests/compiler/tests/*.nika that have a .bounds file; on 2026-11-23 at 3389b4dd only 2 of 193 changed, both new correct proofs.Fact: Ledger and bounds proofs | struct-field floors (3389b4dd, 2026-11-23) grew packages/logic/nikaia.proofs from 82667 to 91413 lines (+9375 questions: 3761 proved, 4138 refuted, 1476 unknown).Fact: Ledger and bounds proofs | as of 3389b4dd (2026-11-23), sv_sat 668 is still checked (the length is lost after a for loop that pushes, cause unknown) and sv_simplex 2834–2837 are still checked (callee in another file).Generated by Claude Code