panics = true for a function whose every site check --bounds proves (yaml fold, text, scalar_text, walk)Open and answer this issue on GitHub.
blocked, bugs · opened 2026-11-17 · updated 2026-11-21 · 4 comments
Found while building “yaml: remove the needless collects and copies” (#1981).
cd packages/yaml
nikaia check --bounds src/main.nika # proves every index and operation of fn fold
grep -A3 'fn fold' nikaia.contracts # panics = true
packages/yaml/nikaia.contracts records panics = true for fold, and also for text, scalar_text and walk. The bounds report proves every site of fold.
A function with every site proved should be panics = false, so its callers do not inherit a panic they cannot have.
crates/nikaia-std/src/compiler/panics.nika: compare its site walk with the bounds report for fold. It may count a site that the bounds walk proves, or it may not read the proofs at all.
panics = false.tests/compiler/tests/: a function with an index that is proved gets panics = false; one that is not proved stays true.scripts/ledgers.nika).The yaml ledger records panics = false for fold (and for the others where every site is proved), and scripts/ledgers.nika -- --check is green.
Brief queued: issue-1995
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #1995, 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/1995/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/bugs/issue-1995.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-1995, Result: blocked
Tokens: input 62, cache read 1380196, cache write 53377, output 12061 Cost: 0.99 USD, time 2 min 45 s, turns 31
Result: blocked
Body: nothing committed; panics.nika is right: in a scratch package fn idx(xs: ref Vec[i64]) -> i64 sync { if xs.len() > 0 { return xs[0] } return 0 } gets panics = false and fn idx_bad(xs: ref Vec[i64], i: i64) -> i64 sync { return xs[i] } gets panics = true; fold’s own sites are all proved (check –bounds rows 2883-2914), but fold calls push_between (main.nika:2862), which calls t.start().forward(bytes: a) and t.between(p, q), both panics = true in crates/nikaia-std/std.contracts (text::Pos::forward line 8465, str::between line 5590); text, scalar_text and walk reach fold, so all four inherit the panic through what they call, not through a site the pass gets wrong
Pushed: none
Tests: scratch package (src/main.nika with pb_a let p = t.start().forward(bytes: a) ?? return 0, pb_b out.push_str(t), pb_c forward+between, push_between copied from yaml, idx, idx_bad), target/fast/nikaia run built at HEAD 7fe501f0f: ledger idx false, idx_bad true, pb_a true, pb_b false, pb_c true, push_between true; check --bounds packages/yaml/src/main.nika: 63/63 indexes proved, fold’s operations all proved
Gate: green
Deviation: none
Found: std’s ledger has [fn."text::Pos::forward"] panics = true, but forward(bytes: n) cannot panic: crates/nikaia-std/src/text_pos.rs forward_bytes is p.0.checked_add(..)? plus text.is_char_boundary(at), which answers false past the end, so it has no slice. Only the scalars:/graphemes: forms slice text[p.0..], and that check stays until ADR-374 D5/D8 (#743). Probe in a package with only [package] name = "p": fn pb_a(t: String, a: i64) -> i64 sync { let p = t.start().forward(bytes: a) ?? return 0 \n return 1 } gets panics = true in nikaia.contracts. It should be false for the bytes form, but the ledger has one entry for every unit form, so the fix needs a way to give the forms separate claims; no decision yet
Needs: supervisor decision: yaml’s fold can only get panics = false if push_between stops reaching str::between, whose q before p stops the program (ADR-374 D3, text_pos.rs between_backwards), and stops reaching a forward claimed to panic. That means either a yaml rewrite of push_between (yaml lane) or a std ledger change (the Found above); the panics pass needs no change
Changelog: none
Issue: wrong I7: panics.nika reads the bounds proofs correctly (a proved index gives false, an unproved one true); fold, text, scalar_text and walk panic through push_between’s library calls str::between and text::Pos::forward, which std.contracts claims can panic; broke I5: the Done-when figure (panics = false for fold) contradicts the std contract of between, which ADR-374 D3 says panics
Comment: #1995 The panics pass is correct: check --bounds proves all of fold’s own sites, and fold is panics = true only because it calls push_between, which calls str::between (panics when q comes before p, ADR-374 D3) and text::Pos::forward (claimed panics = true in std.contracts, though the bytes: form cannot panic). text, scalar_text and walk reach fold. Getting false needs either a yaml change to push_between or per-form std ledger claims for forward, plus a way to know a <= b before between.
Friction: none
Disk freed: none; target/nikaia-project-tests 560M, / 19G 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_01UVxJDutPTwP5Xj5HkGuidk
fold’s panic actually came from. It took about 8 turns to go from panics.nika, to the MethodsCalled keys, to sync.nika, to the entries in std.contracts. I first thought the methods had no entry at all. They do, but under str:: and text::Pos:: keys, not String::.crates/nikaia-std/std.contracts, with keys like str::between and text::Pos::forward;panics_methods;between panic on purpose;text_pos.rs, to see which forward forms can really panic.check --bounds on yaml, then one scratch package with six variants. That package settled the cause in a single run.cargo build, since the binary was already current. The age check listed HEAD’s own commit, and I read that as stale.MethodsCalled builders.panics/sync/throws, read the callee chain in the generated nikaia.contracts and the library entries in std.contracts.”wrong I7: it suspected panics.nika, but the panic comes through calls (push_between → str::between/text::Pos::forward). A cause marked suspected, and its settling check (the callees’ ledger rows), was never run.broke I5: the Done-when figure (panics = false for fold) contradicts the documented contract of between. No reference run backed it.knowledge: Probes | a function's ledger 'panics' joins its callees' entries, so the bounds report alone never shows that a function cannot panic.| Fact: Core | The binary-age check git log --since=@$(stat ...) can list HEAD’s own commit when the binary was built right after it; a build that ends in under a second confirms the binary is current. |
| Fact: Probes | To find why a ledger says panics = true, put each callee into its own one-line function in a scratch package and read its row; std methods are keyed str::NAME and text::Pos::NAME in std.contracts. |
| Fact: Ledger and bounds proofs | crates/nikaia-std/src/compiler/panics.nika uses the bounds proofs correctly: a proved index gives panics = false and an unproved one true (scratch run, 2026-11-21, HEAD 7fe501f0f). |
| Fact: Ledger and bounds proofs | check --bounds packages/yaml/src/main.nika: 63/63 indexes and 80/106 operations proved (2026-11-21, 7fe501f0f). |
| Fact: Ledger and bounds proofs | In std.contracts, text::Pos::forward and str::between/before/after/split_at are panics = true, so every caller of theirs inherits a panic; forward(bytes:) cannot actually panic (text_pos.rs forward_bytes). |
Generated by Claude Code
From the report of the run of issue-1995 (#1995):
The panics pass is correct: check --bounds proves all of fold’s own sites, and fold is panics = true only because it calls push_between, which calls str::between (panics when q comes before p, ADR-374 D3) and text::Pos::forward (claimed panics = true in std.contracts, though the bytes: form cannot panic). text, scalar_text and walk reach fold. Getting false needs either a yaml change to push_between or per-form std ledger claims for forward, plus a way to know a <= b before between.
Generated by Claude Code
Driver: not queued, this issue waits for #743, #2663, which is still open (#1819). Set ready again when it is closed.
Generated by Claude Code