Skip to content

feat(core): load calc evidence, hash it and check its assumption edges - #241

Draft
shunsuke-shimomura wants to merge 2 commits into
feat/207-veriq-producerfrom
feat/208-calc-load-check
Draft

shunsuke-shimomura wants to merge 2 commits into
feat/207-veriq-producerfrom
feat/208-calc-load-check

Conversation

@shunsuke-shimomura

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

Copy link
Copy Markdown
Member

Description

Updated 2026-11-10 after review. Parts of this description are out of date; the review follow-up comment says what changed and is current where the two disagree.

Closes #208 (parent: #40). Stacked on #231 (veriq producer).

Calc evidence becomes part of what a project is, not only what eval reads:

  • Manifest. [evidence] now names files per kind: tests = [...] (formerly files) and calcs = [...], either of which may be left out — the key names the design docs already use. files is rejected with serde's "unknown field files, expected tests or calcs"; the dogfood and CLI fixtures are renamed.
  • Loading (inka_core::calc_evidence). load_files reads every configured calc evidence file through the shared inka-evidence parser, anchors each defect (unreadable / malformed / unsupported version / semantic) to the file, rejects a target path delivered twice across files, and computes each target's interface hash with the frozen inka:calc-evidence:v1 layout. Project gains calc_evidence: CalcEvidenceSet; CalcEvidenceSet::from_targets builds the same set from in-memory targets for tests and other producers.
  • Graph. Edges carry a Dependency kind, Child or Assumption. Graph::build_with(blocks, &calc_evidence) (and Graph::of_project) adds an assumption edge from every calc: bind whose target the loaded evidence provides to each node that target assumes; Graph::build(blocks) is the empty-evidence case and keeps every existing caller and test unchanged. children/parents keep reading the declared structure only (assumptions / assumed_by read the new edges); topological order, cycle detection and reachability follow both kinds, so a node only an assumption reaches is not an orphan.
  • Check. inka check (via graph::check) reports, anchored on the bind's calc: property: an assumption ID no block defines (undefined assumption mass_properties_valid: the calc evidence for AOCS::?verify_detumble assumes it, but no block defines it), and a cycle through an assumption edge with the nodes in order and the assumption drawn as a dashed arrow (dependency cycle through an assumption: branch → modelled ⇢ root → branch). A calc: reference no target answers adds no edge and no error — that stays eval's missing evidence. The CLI's load_project_view builds the graph with the evidence, so export/eval/review/serve refuse an argument check would refuse.
  • LSP. Diagnostics come through the same graph::check; a broken calc evidence file anchors to that file, like a test evidence file.
  • Docs. calc-evidence.md (en/ja) spells out how assumption IDs resolve, that both edge kinds are dependencies for order, cycles and reachability while only children: is structure, the cycle rendering, and that a missing/malformed configured file is an input error.

Nothing evaluates calc evidence yet (#209): the bind hash's assumption slot stays empty and calc binds still report calc_not_evaluated.

Test results

  • cargo test --workspace (adapter tests excluded locally for want of nextest): all green, 269 core unit tests incl. 6 new graph tests (edges resolve; a missing target adds no edge; undefined assumption anchored on calc:; self-assumption and ancestor-assumption cycles with their rendering; an assumed-only node is not an orphan). New integration tests: tests/calc_evidence.rs loader (valid file exposes the target with its hash; every golden calc-evidence-v1 vector, written out as an evidence file, loads to its frozen hash; unreadable / malformed / v2 / semantic defect / duplicate across files name the file), tests/project.rs (calcs-only manifest loads; missing calc file is LoadError::CalcEvidence), tests/manifest.rs (tests+calcs, calcs-only, files rejected naming the valid keys).
  • CLI: three new fixtures with snapshot tests — undefined-assumption and assumption-cycle freeze the rendered snippets pointing at calc:, broken-calc-evidence fails check and eval before any verdict. Existing snapshots unchanged.
  • LSP: an assumption cycle is an error on the calc: range; a v2 calc evidence file anchors to that file.
  • cargo clippy --workspace --all-targets (pedantic) and cargo fmt --check clean; inka fmt --check clean on the new fixtures; prek clean on docs, fixtures and snapshots.

Impact

  • Breaking for inka.toml: [evidence] files must be renamed to tests. The error names the valid keys.
  • Projects without [evidence] calcs behave exactly as before: Graph::build is unchanged in behaviour, no new edges, no new diagnostics.
  • With calc evidence configured, check can newly fail (undefined assumption, assumption cycle) and a missing/invalid file fails every command, as for test evidence.
  • Graph::parents excludes assumption edges, so ArgumentView::roots and the exported view are unaffected by assumptions.

Supplementary information

  • Assumption IDs resolve exactly as children: references do today — by literal block ID, since namespace resolution has not landed. The veriq fixture's power::eclipse_model_valid style IDs will resolve once it does; until then an argument that imports such evidence spells its block IDs the same way.
  • Design choice made here, flagged for review: a node reached only through an assumption edge counts as reachable from the objective (no "unreachable" warning). The alternative — requiring every assumed node to also be someone's child — would force double-listing the assumption registry.

🤖 Generated with Claude Code

@github-actions github-actions Bot added sys::SE システムズエンジニアリング documentation 📓 Improvements or additions to documentation and removed sys::SE システムズエンジニアリング labels Nov 10, 2026
@shunsuke-shimomura shunsuke-shimomura changed the title feat(core): load calc evidence, hash it and check its assumption edges (#208) feat(core): load calc evidence, hash it and check its assumption edges Nov 10, 2026
@shunsuke-shimomura shunsuke-shimomura added the sys::SE システムズエンジニアリング label Nov 10, 2026
shunsuke-shimomura and others added 2 commits November 10, 2026 12:54
#208)

`inka.toml` names evidence per kind: `[evidence] tests` (formerly `files`)
and `calcs`. Calc evidence is read at project load, each target hashed
with the frozen `inka:calc-evidence:v1` layout, and every node a loaded
target assumes becomes an assumption edge of the graph from the bind that
references it. `inka check` and the LSP report an assumption naming no
block, and a cycle through an assumption edge (`branch → modelled ⇢ root`),
as errors anchored on the bind's `calc:` property. A `calc:` reference no
target answers stays evaluation's missing evidence; projects without calc
evidence behave exactly as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… they are

Three reports at project load blamed the wrong thing:

- A component holding both a cycle of `children:` alone and a way round
  through an assumption was reported as "through an assumption" and
  anchored on the `calc:` reference, whenever the search happened to meet
  that path first. The children cycle is in the argument as written and
  stands whatever the evidence says, so it is now the one named.
- `[evidence] files`, renamed to `tests`, failed as an unknown field. It
  is a hard break, but the error now says what to rename.
- A target delivered by two entries of `[evidence] calcs`, or a file
  listed twice, was reported as invalid evidence in the second file. Neither
  file is defective alone; the error now names the pair.

The design doc also claimed an assumption ID resolves like a `children:`
reference. It is matched exactly against fully-qualified IDs.
@shunsuke-shimomura

Copy link
Copy Markdown
Member Author

Review follow-up (2026-11-10)

Rebased onto the updated #231 and force-pushed. One commit was added. Where the description above and this comment disagree, this comment is current.

9ea8bcc — fix(core): name the cycle, the rename and the duplicate file for what they are

  • Cycles. A component holding both a cycle of children: alone and a way round through an assumption was reported as "through an assumption", anchored on the calc: reference, whenever the search met that path first. The children-only cycle is in the argument as written, so it is the one named now, and the choice is deterministic.
  • [evidence] files. Still a hard break, but the error is now "[evidence] files is now [evidence] tests; rename the key (calc evidence files go under [evidence] calcs)" instead of serde's unknown-field message.
  • Duplicate targets. A target delivered by two entries of [evidence] calcs, or a file listed twice, was reported as invalid evidence in the second file. The error now names the pair, and the LSP reports it as well.
  • Docs. The design document claimed an assumption ID resolves like a children: reference. It is matched exactly against fully-qualified IDs.

Decisions taken with the author

  • A node reached only through an assumption edge is not an orphan (the design choice flagged in the description): confirmed as intended.

Left as is

  • The test evidence loader still reports a duplicate against the second file. Naming the pair there too would be a separate change.

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

documentation 📓 Improvements or additions to documentation sys::SE システムズエンジニアリング

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calc evidence: load-time consumption, interface hash and assumption edges in check

1 participant