Issue #2777: bounds walk: the result rule of heap_pop does not stand in its caller pick (sv_sat.nika 809)

Open and answer this issue on GitHub.

wip, solver · opened 2026-11-22 · updated 2026-11-23 · 3 comments

Found

This was found by the builder run for “bounds walk: shift, xor and heap-index arithmetic form no goal (14 solver sites)” (#1631), report docs/briefs/solver/issue-1631.md.report.md, commit 899735f2.

packages/logic/src/sv_sat.nika:806-809, pick:

let v = self.heap_pop()
... self.value[v] ...

The walk of heap_pop holds the rules index heap … and result heap_pop …, but the walk of pick does not. The trace of line 809 lists no heap rule, not even before the call, so the index into self.value stays checked.

A reduced probe of pick plus heap_pop proves, so the cause is not found yet. Possibly related: the field SvSat.value gets no length activity value rule, but the same field renamed to vvalue does, which proves 3 more sites. The suspect is a bare name value that bounds_frame.nika (the fallback in fields_mark) records as changed beside. A two-file probe did not reproduce it.

To build

  1. Reproduce the case with check --bounds packages/logic/src/sv_sat.nika --trace 809, then reduce sv_sat.nika step by step until the rule drops out.
  2. Fix the cause in the walk (the frame’s field marking, or how a result rule is carried across the call), with a test in tests/compiler/tests/ that has a .bounds file.
  3. Check whether the value/vvalue difference has the same cause. If it does not, fix it as its own commit.

Done when

Comments

keywan-ghadami, 2026-11-23

Brief queued: issue-2777


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

Issue #2777

Your work order is issue #2777, 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/2777/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/solver/issue-2777.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-23

Run: issue-2777, ESCALATE claude exited with code 1

Tokens: input 152, cache read 4845930, cache write 152216, output 42223 Cost: 3.22 USD, time 1 min 48 s, turns 77

Report

(none)

Debrief

Nothing is committed and there is no report file yet. The run ended before I could read the last background cycle (relower, build, ledger check, logic package tests).

What I found so far, on the working tree:

Still open: the cycle 4 results, ledgers.nika --refresh if the check is stale, cargo fmt, pre-push, the two commits (walk order: bounds_proven + bounds_walk; field handed to a function: bounds_frame + bounds_rules), the report and the disk cleanup.

  1. Most turns: working out two causes in turn. First, the callers-first walk order runs pick before the heap methods whose derived preconditions its rules need. Second, after that was fixed, SvSat.value still had no candidate rule. The reason is that fields_handed falls back to a bare value when sv_simplex hands a local of unknown type to a ref-parameter function. Each check --bounds of sv_sat takes about 2 minutes, and each lower-std cycle 6–11 minutes.
  2. Looked up: where derived_order, held.clear() and BoundsBeside.changed live; which FnArg flag marks a mut parameter; that lower-std --bounds writes nothing; and that proved.nika takes only a path relative to the working directory.
  3. Checks: the old binary on the reduced test was useful, as were sv_sat --bounds/--asserts and the before/after lower-std --bounds. Wasted: one proved.nika call on a scratchpad path, and a site diff whose regex was wrong at first.
  4. One change: builder.md should say that scripts/proved.nika refuses a path outside the checkout (copy the report under target/ first), and that lower-std --bounds is read-only, so the old binary can run it safely.
  5. What the issue lacked:
    • broke I7: it did not mark the cause of 809 as traced or suspected. The walk order (callers first, so derived preconditions arrive too late for the rules) was found only by moving pick in a copy.
    • rules-gap: it did not say that the missing value rule comes from another file of the package (sv_simplex’s handed fields).
  6. Traps for the next builder:
    • Fact: Ledger and bounds proofs A rule set a body starts from is fixed before callees later in derived_order add derived preconditions, so a caller’s rules may need those preconditions first.
    • Fact: Ledger and bounds proofs fields_mark/fields_handed turn a field of a local of unknown type into a bare name in changed, which silently drops every struct’s rule over a field of that name in the whole package.
    • Fact: Core scripts/proved.nika refuses a report path outside the working directory; copy it under target/ first.
  7. For the next builder in Ledger and bounds proofs:
    • Fact: Ledger and bounds proofs Measure: target/fast/nikaia lower-std --bounds --asserts > target/x/ls.txt, then nikaia run scripts/proved.nika -- target/x/ls.txt. Measured 2026-11-23 on the working tree for #2777 over develop: 3244/4123 indexes, 1572/2435 operations, 6243 sites, about 5.5 minutes per binary.
    • Fact: Ledger and bounds proofs Key files: bounds_proven.nika (the walk order and the second walk), bounds_frame.nika (FieldsScan, BoundsBeside) and bounds_rules.nika (rules_candidates, rules_holding).

Generated by Claude Code

keywan-ghadami, 2026-11-23

Run: issue-2777, Result: done

Tokens: input 190, cache read 6075779, cache write 176546, output 51223 Cost: 3.84 USD, time 5 min 14 s, turns 96

Report

Result: done Files: crates/nikaia-std/src/compiler/bounds_proven.nika crates/nikaia-std/src/compiler/bounds_walk.nika crates/nikaia-std/src/compiler/bounds_frame.nika crates/nikaia-std/src/compiler/bounds_rules.nika crates/nikaia-std/src/compiler/lowered.rs crates/nikaia-std/src/compiler/lowered/bounds_proven.rs crates/nikaia-std/src/compiler/lowered/bounds_walk.rs crates/nikaia-std/src/compiler/lowered/bounds_frame.rs crates/nikaia-std/src/compiler/lowered/bounds_rules.rs crates/nikaia-std/src/compiler/lowered/logic/lowered.rs crates/nikaia-std/src/compiler/lowered/logic/lowered/sv_walk.rs packages/logic/nikaia.contracts packages/logic/nikaia.proofs packages/logic/rod/nikaia.contracts packages/logic/nikaia.proofs.d/1e816674e5fe9436890924c8258429922005f68177a476499096b122d96ecdfd packages/logic/nikaia.proofs.d/2f24f9606f1a7820eca8049900566097b8fa462a35ece93b10b1e3885dfe4383 packages/logic/nikaia.proofs.d/3929b1aae4c5f0730424cb6c328c7b6d76b4a000439e14682399ac536004ba14 packages/logic/nikaia.proofs.d/f999eafe7ec6aa87c35f084c44e9ea8ecaa68d65eb18d5d9cf425d4bde4180a4 tests/compiler/tests/a_caller_walked_before_its_callees_takes_the_rules_their_preconditions_hold.nika tests/compiler/tests/a_caller_walked_before_its_callees_takes_the_rules_their_preconditions_hold.bounds tests/compiler/tests/a_caller_walked_before_its_callees_takes_the_rules_their_preconditions_hold.stdout Commit: bounds walk: a body walked before its callees takes the rules their derived preconditions hold Body: Two causes. (1) Bodies are walked callers first (ADR-391 D1), so pick fixed its SvSat rules before heap_pop/heap_insert/heap_down derived the preconditions those rules need (index heap, result heap_pop): bounds_proven now records each body’s rules (BoundsProven.rules_used, by rules_key) and walks it again once at the end where derived preconditions were added since and the rules that hold now differ; what either walk proved stands. (2) fields_handed recorded a bare field into BoundsBeside.changed when it could not tell the base’s type, so sv_simplex handing had.value to the ref-parameter sv_delta_cmp dropped SvSat activity.len() == value.len(); the pair callee|field now goes into handed and counts as changed only where a package function of that name takes a mut parameter or none is declared. sv_sat 809/810 proved, pick no longer panics (ledgers refreshed), sv_walk gains proved reads. Fixes: #2777 Pushed: local 19b440f993f74cb2ba50007fcb04b46387a582e9 Tests: new test proves line 16, old binary leaves it checked (shown); sv_sat.nika 809 and 810 proved; –asserts finds SvSat activity.len() == value.len(); lower-std –bounds –asserts old vs new 6243 sites, 0 lost, 0 gained (3244/4123 indexes, 1572/2435 operations); logic package tests 54 passed; ledgers –check current after –refresh; pre-push green Gate: green Deviation: one commit for both causes, not two: commit.nika refuses a lowered/ change without lowered.rs, whose digest names the whole set; cause 2 has no tests/compiler test since it needs two files of one package (shown on sv_sat’s –asserts) Found: none Needs: none Changelog: The bounds walk walks a method again when the derived preconditions of its callees, walked after it, make more of its type’s rules hold; and a field handed to a function with no mut parameter no longer drops the rules over fields of that name (#2777) Issue: broke I7: the cause of 809 was not marked traced or suspected; it was the callers-first walk order, plus a second cause in another file (sv_simplex handing fields) for the value rule Owner: none Friction: commit.nika refuses splitting lowered/ files across commits (LOWERED_DIGEST in lowered.rs), so two causes in two bounds_*.nika files cannot be two commits; scripts/proved.nika refuses a report path outside the checkout Disk freed: target/nikaia-project-tests 1.8G kept (11G free of 252G), no new cache entry over 100 MB Reviewed: 2819a4cb47500bca97c6491a5e6a5711dc197ab2cd418fd0e0f78f0a53ba8794 Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDwk9ubq9teP7QCErff

Debrief

Issue #2777 is fixed and committed locally as 19b440f9: sv_sat.nika lines 809 and 810 are now proved, and lower-std --bounds loses no site.

  1. Most time: finding the two causes one after the other, then the build cycles. Each lower-std after a bounds_*.nika change took 6–12 minutes, and one cycle had to be redone after develop moved under the uncommitted work. My two-commit split cost a refused commit.nika run.
  2. Looked up:
    • where derived_order, held.clear() and BoundsBeside.changed are;
    • that FnArg.mutable marks a mut parameter;
    • that lower-std --bounds writes nothing;
    • that proved.nika takes only a path inside the checkout;
    • that nikaia.proofs.d/ holds long certificates and is committed with the ledger.
  3. Checks:
    • Useful: the old binary on the reduced test; sv_sat --bounds and --asserts; lower-std --bounds --asserts old against new, compared site by site (6243 sites, 0 lost, 0 gained); the logic package tests (54 passed); ledgers.nika --refresh.
    • Wasted: the step-1 dry run and commit attempt, refused for the lowered digest; one proved.nika call on a scratchpad path; the first site-diff regex, which was wrong.
  4. One change: builder.md should say that all lowered/ changes go in one commit with lowered.rs, since LOWERED_DIGEST names the whole set. “One commit per cause” only works when the causes share no lowered output.
  5. What the issue lacked:
    • broke I7: the cause of 809 was not marked traced or suspected. It was the callers-first walk order (ADR-391 D1).
    • rules-gap: the missing value rule came from another file of the package (sv_simplex hands had.value to ref-parameter functions), and nothing pointed to the files beside sv_sat.
  6. Traps for the next builder:
    • Fact: Core scripts/commit.nika refuses a staged lowered/ change without lowered.rs (its LOWERED_DIGEST), so lowered output cannot be split across commits.
    • Fact: Ledger and bounds proofs A long ledger certificate goes into nikaia.proofs.d/<hash>, which is committed with nikaia.proofs.
    • Fact: Ledger and bounds proofs When fields_handed cannot tell a local’s type, a field passed to a function by name is now recorded as callee|field in BoundsBeside.handed; only a callee with a mut parameter, or one the package doesn’t declare, drops the rules over that field name.
  7. For the next builder in Ledger and bounds proofs:
    • Fact: Ledger and bounds proofs Measure: target/fast/nikaia lower-std --bounds --asserts > target/x/ls.txt, then nikaia run scripts/proved.nika -- target/x/ls.txt. On 2026-11-23, at 19b440f9: 3244/4123 indexes, 1572/2435 operations, 6243 sites, about 5.5 minutes per run.
    • Fact: Ledger and bounds proofs bounds_proven.nika now walks a body again where derived preconditions added after it change the rules that hold (BoundsProven.rules_used, bp_rules_changed, 19b440f9).

Generated by Claude Code

Back to Open Issues