Skip to content

feat(core): evaluate calc binds and fill the bind hash's assumption slot - #242

Draft
shunsuke-shimomura wants to merge 1 commit into
feat/208-calc-load-checkfrom
feat/209-calc-eval
Draft

shunsuke-shimomura wants to merge 1 commit into
feat/208-calc-load-checkfrom
feat/209-calc-eval

Conversation

@shunsuke-shimomura

@shunsuke-shimomura shunsuke-shimomura commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Description

Closes #209 (parent: #40). Stacked on #241 (load-time calc evidence).

Calc binds are evaluated. The closing conditions of #40 that this PR delivers: the veriq export is consumed by eval, and the bind hash's assumption slot is filled.

  • One resolver (inka_core::bind::resolve). Evaluation, the review queue and the recording command used to each look up a bind's reference themselves. They now share one function that maps a bind to the imported evidence its reference names: BindEvidence::Test(&TestEvidence) or BindEvidence::Calc { target, assumed } with the assumed ViewNodes (sorted by id), or None for the per-bind missing evidence. contract() yields what enters the hash.
  • Bind hash. LocalView::of_node takes an Option<EvidenceContract { interface, assumptions }> instead of a bare interface hash (From<InterfaceHash> keeps the test-bind case a .into()). For a calc bind the slot holds the assumed nodes' rendered descriptions; view_hash already sorted and normalized them (calc evidence: shared model, validation and builder in inka-evidence #206's frozen layout), so no vector changes. Test binds keep an empty slot.
  • Fixpoint. evaluate(view, phases, records, tests, calcs) adds, for every calc bind whose target is loaded, a dependency on each assumed node, so the bind is judged after them. A calc bind is established iff the approval holds ∧ every required leaf is true ∧ valid ∧ ¬xfail ∧ every assumed node is established.
  • Blame. Independent causes, in veto order after the approval causes: leaves_failed { leaves }, leaves_missing { leaves }, evidence_invalid, expected_failure, assumption_not_established { node }. missing_evidence gains kind (test | calc) and reads "no imported calc evidence provides …". calc_not_evaluated is removed from blame and from the review queue's blocked reasons.
  • Errors. A hand-built view whose calc target assumes an undefined node is EvalError::UnknownAssumption; a cycle through an assumption edge is EvalError::Cycle. A checked project trips neither (feat(core): load calc evidence, hash it and check its assumption edges #241 reports both at check).
  • Review / LSP. derive_queue and inka review <id> --approve resolve calc binds and bind the record to the assumption-bearing hash; a calc bind without evidence is blocked as missing calc evidence. The LSP lens passes the calc evidence through.

Test results

  • cargo test --workspace (adapter tests excluded locally for want of nextest): green. New crate/inka-core/tests/eval_calc_evidence.rs mirrors the two evaluation tables of calc-evidence.md, 16 tests: established; a false leaf; a leaf without result; valid: false with a true leaf; xfail; absent target → missing calc evidence; passing evidence without approval; an unapproved assumed fiat → assumption_not_established naming the node; an edited upstream calculation → stale; an edited assumed description → stale; a renamed assumed node → still established; a new upstream assumes entry → stale; producer order of assumptions is not content; a different target path → stale; an undefined assumed id → UnknownAssumption; assuming an ancestor → Cycle. Review queue unit tests: a calc bind with evidence is queued on the assumption-bearing hash (≠ the empty-slot hash); without evidence it is blocked as missing calc evidence.
  • CLI: the unestablished fixture grows five calc binds (false leaf, missing leaf, invalid, xfail, unestablished assumption) plus the existing absent-target one; both eval snapshots regenerated and reviewed — every cause appears once, no ancestor is blamed. New end-to-end test a_calc_bind_established_through_loaded_evidence_evaluates_clean: a project with [evidence] calcs, a passing target assuming a fiat, and approvals bound to the current hashes evaluates established 3/3.
  • Existing test-evidence behaviour and golden vectors unchanged (tests/golden untouched; eval_evidence.rs rows still pass with the extra argument).
  • cargo clippy --workspace --all-targets (pedantic), cargo fmt --check, inka fmt --check on the fixture, prek on the changed files: clean.

Impact

  • inka eval now establishes or blames calc binds. A project that already had calc: binds sees calc_not_evaluated replaced by the real causes (most commonly missing_evidence with kind: calc until a calc evidence file is configured).
  • eval --json: missing_evidence carries a new kind field; five new cause values; calc_not_evaluated is gone.
  • inka review: calc binds can be approved and declined; blocked lines for missing evidence name the kind.
  • API: evaluate and derive_queue take a &CalcEvidenceSet; LocalView::of_node takes Option<EvidenceContract>; BlockedReason::MissingEvidence and BlameReason::MissingEvidence gain kind.

Supplementary information

🤖 Generated with Claude Code

@github-actions github-actions Bot added the sys::SE システムズエンジニアリング label Nov 10, 2026
@shunsuke-shimomura shunsuke-shimomura changed the title feat(core): evaluate calc binds and fill the bind hash's assumption slot (#209) feat(core): evaluate calc binds and fill the bind hash's assumption slot Nov 10, 2026
…lot (#209)

A calc bind is now judged like a test bind, with the imported target as
its evidence: its view hash folds in the target's interface hash and the
assumed nodes' rendered descriptions (sorted bytewise, ids never), it is
established only when the approval holds, every required leaf is true,
`valid` is true, `xfail` is false and every assumed node is established,
and each failure is its own blame cause (false or missing leaves, invalid
result, expected failure, `assumed node … is not established`). The
resolution of a bind's reference against the imported evidence moves into
one shared `bind::resolve`, read by evaluation, the review queue and the
recording command, so the `calc_not_evaluated` stub is gone and a missing
reference names its kind (`no imported calc evidence provides …`).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@shunsuke-shimomura

Copy link
Copy Markdown
Member Author

Review follow-up (2026-11-10)

Rebased onto the updated #241 and force-pushed. The review asked for no change to this PR's own commit; cargo clippy and cargo test --workspace pass at this level after the rebase.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sys::SE システムズエンジニアリング

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calc evidence: evaluate calc binds and fill the bind hash's assumption slot

1 participant