Issue #2766: The checker checks a dependency type’s rule at a pub field write (consumer side of #714)

Open and answer this issue on GitHub.

blocked, solver · opened 2026-11-22 · updated 2026-11-23 · 4 comments

Part of #714 (ADR-369 D2, ADR-269 D18-D19). Filed by the driver from the Found: of the run of issue-714. The mechanism was decided by the supervisor on 2026-11-22; see the comment below.

What is missing

Since 667df1fd1, a pub struct’s written rule is published in the ledger (TypeContract.rules). On the consumer side nothing checks it yet:

Decision

The checker emits the obligation. It already knows the base’s type through field_owners (check_facts.nika, prover_calls.nika, prover_state.nika). type_rules.rs is neither extended nor re-run, per CLAUDE.md, “Written in Nikaia only”.

To build

Done when

All four tests are green, and type_rules.rs gained no lines.

Comments

keywan-ghadami, 2026-11-22

Supervisor decision (2026-11-22): the checker emits the obligation.

The obligation for a write to a foreign (dependency) type’s pub field comes from the checker, which already knows the base’s type through field_owners (check_facts.nika, prover_calls.nika). It is written in Nikaia. crates/nikaia/src/type_rules.rs is neither extended nor run a second time. CLAUDE.md, “Written in Nikaia only”: a new feature adds no Rust, and a second pass over the Rust would be new Rust.

This also unblocks the consumer literal check and the open type’s entry fact that 5b7643ab dropped. That fact is sound once every write is checked.


Generated by Claude Code

keywan-ghadami, 2026-11-23

Brief queued: issue-2766


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

Issue #2766

Your work order is issue #2766, 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/2766/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-2766.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-2766, Result: partial: items 1 and 2 built with three of the four tests; item 3 (restore the entry fact of an open type, type_rules.nika tr_declared_rules open) and its test “a function that relies on the entry fact proves” left, see Needs

Tokens: input 226, cache read 9158742, cache write 225433, output 66471 Cost: 5.16 USD, time 0 min 39 s, turns 113

Report

Result: partial: items 1 and 2 built with three of the four tests; item 3 (restore the entry fact of an open type, type_rules.nika tr_declared_rules open) and its test “a function that relies on the entry fact proves” left, see Needs Files: crates/nikaia-std/src/compiler/prover_walk.nika crates/nikaia-std/src/compiler/lowered/prover_walk.rs crates/nikaia-std/src/compiler/lowered.rs tests/compiler/tests/a_write_that_keeps_a_dependency_types_rule_passes.nika tests/compiler/tests/a_write_that_keeps_a_dependency_types_rule_passes.stdout tests/compiler/tests/a_write_that_breaks_a_dependency_types_rule_is_refused.nika tests/compiler/tests/a_write_that_breaks_a_dependency_types_rule_is_refused.stdout tests/compiler/tests/a_literal_that_breaks_a_dependency_types_rule_is_refused.nika tests/compiler/tests/a_literal_that_breaks_a_dependency_types_rule_is_refused.stdout Commit: The prover checks a dependency type’s published rule at a pub field write and at a literal (ADR-369 D2) Body: prover_walk.nika: prover_field_write (Stmt::Assign on x.f, owner from the checker’s field_owners) and prover_rule_literal (StructLit in prover_calls_in) ask each rule another package’s ledger publishes for the type, through prover_rule_kept: the rule read back with condition, the written field the new value (x.f op= v as x.f op v), the other fields self.g read through the base’s path, asked with precondition_call as a std precondition: proved, carried back to the function’s entry, NK1207 “This write/literal breaks T’s rule …”, or a claim held at run time, which NK1300 refuses. A type of this program is left to its own rule’s rewrite; type_rules.rs is untouched (0 lines). Part of #2766. Part: #2766 Tests: the three new programs pass (nikaia test --project tests/compiler --filter dependency_types_rule); on the unfixed compiler ($NIKAIA_OLD) all three printed exit 0, so the two refusal tests failed there; filters rule 39, precondition 28, literal 78 passed Gate: green Deviation: the NK1207 wording is “This write breaks level::Level’s rule 0 <= v && v <= 10 every time it is reached.” (NK1207 as the local rule’s, worded for the write; the local one prints the substituted claim) Found: under unproved-claims = "warn" an unproved rule at a consumer’s write or literal is a warning with no run-time check behind it: the claim’s terms are rarely readable (a mut value’s field paths are never prover names: fn g(mut p: P) { if p.n > 0 { assert(p.n > 0) } } NK1300 “p is not a whole number the prover reads”, while fn f(p: P) proves), and no emitter path writes the rule’s text as a check after a field write; the local type’s check is the Rust rewrite of type_rules.rs, which the decision on #2766 forbids extending; no decision yet Needs: supervisor decision: restoring the entry fact (item 3) is sound only when every way a consumer changes an open type’s field is held to the rule; this run checks writes (x.f = v, x.f op= v) and literals, not a mutating method on a pub field (r.slots.pop() under assert(slots.len() <= cap), the 5b7643ab probe), a mut argument f(mut r.n), a with copy, nor (under unproved-claims = "warn") any unproved write at run time; which of these is checked, and how the warn-mode run-time check is emitted without type_rules.rs, is not decided Changelog: A write to a pub field of a dependency’s type, and a literal of one, is held to the rule the type publishes (ADR-369 D2): shown false is NK1207, not proved NK1300, a write a guard or the caller’s argument proves passes Issue: meets I1-I13; item 3 needs the soundness preconditions above stated in the issue (it names only writes and literals) Owner: none Comment: none Friction: none Disk freed: none; nikaia-project-tests 1.8G, disk 11G free, no new entry over 100 MB Reviewed: 771c69bd9e0d42f536adc15b43213e84abddca72966cd456d1479ddb7798e688 Pushed: local e98b76b0459b5fe794f593f3c1429ca2725d626f Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDwk9ubq9teP7QCErff

Debrief

  1. Most turns: reading before the first edit, across the prover. I had to find how a std precondition becomes a claim (precondition_call, std_claims/held, check_claims_unproved, the emitter’s reaches). Then I had to work out why the consumer could prove nothing: a mut value’s field paths are never prover names. After that it took two builds.
  2. Looked up: how a published rule is stored in the ledger (assert(claim; message: "…") in TypeContract.rules, keyed pkg::Type). Also where field_owners reaches the prover (ProverState.field_owners), and that open in tr_declared_rules is the one switch item 3 flips. The brief could have named all three.
  3. Checks run:
    • the old-binary probes;
    • three build cycles, the last only to fix the wording of the NK1300 text;
    • the new tests on the old and the new binary;
    • the rule, precondition and literal filters;
    • pre-push.

    Wasted: my first test run used nikaia run on a test file, which refuses it, so I reran with nikaia test --filter. The scratch copy for fmt was wasted too, because test .nika files may be formatted in place.

  4. One change: builder.md should say that a test program’s actual output is recorded with nikaia test --project tests/compiler --filter X --bless. Run with the old binary, that also gives the “failed before the fix” evidence in one step.
  5. What the issue lacked:
    • broke I7: item 3 does not say which consumer changes must be checked before the entry fact can come back. 5b7643ab’s own probe was r.slots.pop(), which is not a write or a literal. Item 3 needs those preconditions stated, or an explicit decision.
    • rules-gap: the issue does not say how the rule is checked at run time under unproved-claims = "warn" when type_rules.rs is off limits.
    • knowledge: Lowering | a mut binding's or mut parameter's field paths are never prover names, so a consumer's rule obligation over the other fields is unproved (NK1300) unless the written value alone settles it
  6. Fact: Core Test programs in tests/compiler/tests/ cannot be started with nikaia run FILE; use nikaia test --project tests/compiler --filter NAME, and --bless writes the .stdout.
    Fact: Ledger and bounds proofs A dependency type’s rule is in own.types["pkg::Type"].rules as the text assert(claim; message: "…"); the prover reads it back with the condition callback over the field names.
  7. Fact: Ledger and bounds proofs The consumer-side rule checks (prover_field_write, prover_rule_literal, prover_rule_kept) are in prover_walk.nika, commit e98b76b0, 2026-11-23. The entry-fact switch is open in type_rules.nika tr_declared_rules. A body change to prover_walk.nika needs one lower-std plus a build plus a fixpoint lower-std, under 10 minutes (2026-11-23, e98b76b0).

Generated by Claude Code

keywan-ghadami, 2026-11-23

Items 1 and 2 are built (e98b76b04): prover_field_write, prover_rule_literal and prover_rule_kept in prover_walk.nika, with 3 tests. Item 3, restoring the open type’s entry fact, waits on the write points that are still unchecked. A mutating method on a pub field, a mut argument, a with copy and the warn-mode check are now one build, “Prover: a dependency type’s rule holds after every change to a pub field, checked at run time under unproved-claims = “warn”” (#2816). That build was decided from ADR-369 D2 and Part I 4.1 (686b36041), and item 3 is the last item on its list. This issue is set to blocked until #2816 lands.


Generated by Claude Code

Back to Open Issues