mut self method throws keeps its rule as a fact: the rule is checked before each call that may failOpen and answer this issue on GitHub.
blocked, solver · opened 2026-11-21 · updated 2026-11-23 · 3 comments
Part of #714
A struct whose method changes self and throws keeps no rule as a fact today (98a8e39a, ADR-369 D3): a failing call left the method with the rule broken, and the caller could catch the error and go on. Such a type could keep its facts if the rule were checked at each call inside the method that may fail, so the rule holds at every throw as ADR-369 D2 requires. That needs the pass to know which calls fail. Governing decision: ADR-369 D2 (the rule holds at each return and each throw of a method that changes the value) and D3.
mut self method that throws, and the type keeps its rule as a fact at entry (the entry fact 98a8e39a drops comes back). Test in tests/compiler/tests/: a mut self method that breaks the rule, then calls a throwing function, and a caller that catches the error and indexes with the rule’s bound: the check fires with the rule’s message before the call; with the rule restored before the call, the index is proved.A type with a mut self method that throws keeps its written rule as a fact at its methods’ entries, and a test shows the rule checked before a call that may fail and the caller’s index proved; the commit carries this issue’s Fixes line.
Split from #714 by Claude Code
Brief queued: issue-2518
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #2518, 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/2518/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-2518.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-2518, Result: blocked
Tokens: input 36, cache read 760704, cache write 45941, output 8869 Cost: 0.74 USD, time 1 min 51 s, turns 18
Result: blocked
Files: none
Commit: none
Body: nothing built or committed. The rule pass runs right after parsing (crates/nikaia/src/parser/mod.rs:875 type_rules::expand -> crates/nikaia-std/src/compiler/type_rules.nika tr_expand). A call in Nikaia carries no mark when it can fail; whether it fails comes from the whole-program throws inference (contracts/throws.rs, check_may_fail.nika, prover_walk.nika prover_throws), and that runs after this pass. So the pass cannot tell which calls to put the rule’s assert before.
Pushed: none
Tests: none run (nothing changed)
Gate: green
Deviation: none
Found: the rule pass cannot see which calls fail (traced: tr_expand in crates/nikaia-std/src/compiler/type_rules.nika runs on the parsed tree, before name resolution and throws inference; tr_fails_changed reads only the method’s can_throw flag). Building #2518 needs one of these, and no ADR or issue picks one, no decision yet: (a) put the assert before every call in a mut self throwing method, marked, and let the checker, prover and emitter drop it where prover_throws says the call cannot fail (crosses type_rules, check, prover and emit); (b) put the rule asserts in after throws inference, a new step in the pipeline after checking; (c) put the assert before every call that is not a known non-throwing call in the same file. (c) fires on correct programs, e.g. let x = self.slots.pop() ?? 0 then self.slots.push(x) under assert(slots.len() == 4) would stop before push, which ADR-369 D2 allows (“may be broken for a while”). Probe today: struct Ring { slots: Vec[i64], assert(slots.len() == 4; message: "four slots") } with fn swap_last(mut self, n: i64) throws { let x = self.slots.pop() ?? 0; let y = fail(n); self.slots.push(x + y) }: since 98a8e39a, self.slots[3] in another method of Ring gets no entry fact. That is by design until the decision.
Needs: supervisor decision: how the ADR-369 rule pass learns which calls may fail in a mut self method that throws, from (a) a marked assert that later passes drop, (b) inserting the asserts after throws inference, or another way. Also whether checking before a failing call narrows ADR-369 D2’s “may be broken for a while” (an ADR-369 amendment)
Changelog: none
Issue: broke I7: “That needs the pass to know which calls fail” names the gap but gives no way to close it, and the pass runs before throws inference, so the To build cannot be built without a design decision; broke I4: no probe, the test’s program is only described
Owner: none
Comment: none
Friction: none
Disk freed: none; target/nikaia-project-tests 1.8G, / 11G free of 252G
Attribution:
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01UVxJDwk9ubq9teP7QCErff
type_rules.rs that 98a8e39a changed is now only an adapter; the code moved to type_rules.nika. Then I had to confirm that the pass runs at parse time, before throws inference. That took about 10 turns.parser/mod.rs:875, before checking) and where the compiler decides that a call fails (prover_throws, check_may_fail.nika, contracts/throws.rs).throw "text" drew NK1161, and the method’s exit claim covered up the index I meant to show. I ran no build or tests, which was right for a blocked run.docs/issues.md, so check those numbers.
broke I7: it names the gap (“needs the pass to know which calls fail”) but neither traces nor suggests how the pass could know it.broke I4: no probe; the test program is only described.rules-gap: no rule asks an issue that tightens an ADR decision (here D2’s “may be broken for a while”) to say whether the ADR needs an amendment.knowledge: Core | The ADR-369 rule pass runs on the parsed tree before name resolution and throws inference, so it knows only a function's own throws flag.Fact: Probes | A probe's throw needs an error value, not text: throw “x” is NK1161.
Fact: Probes | probe.nika –file takes only a path below the working directory, so copy a scratchpad file to target/ first.Fact: Ledger and bounds proofs | A type's rule is written out by crates/nikaia-std/src/compiler/type_rules.nika (tr_expand, tr_rewrite_body, tr_fails_changed), called from parser/mod.rs:875; the Rust type_rules.rs is only the adapter (seen 2026-11-23 at 8c6d2bc37).
Fact: Ledger and bounds proofs | Whether an expression can fail is known only to prover_walk.nika prover_throws and the checker's ledger, not before checking (2026-11-23, 8c6d2bc37).Generated by Claude Code
Driver: not queued, this issue waits for #2788, which is still open (#1819). Set ready again when it is closed.
Generated by Claude Code