Repository navigation
feat(evidence): add the calc evidence model, validation and builder (#206) - #229
Draft
shunsuke-shimomura wants to merge 2 commits into
Draft
shunsuke-shimomura wants to merge 2 commits into
shunsuke-shimomura wants to merge 2 commits into
Conversation
shunsuke-shimomura
force-pushed
the
feat/206-calc-evidence-model
branch
from
November 10, 2026 00:56
c75d9d2 to
90e4082
Compare
…206) `inka_evidence::calc` mirrors schemas/calc-evidence-v1.schema.json: a strict parser and a builder sharing one validation pass, so the veriq adapter cannot emit a file the consumer rejects. The provenance rules both builders apply move into one shared module. The Python binding exposes `CalcEvidenceBuilder`, `Definition` and `Leaf`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The parser and the schema disagreed in three places a producer other than inka's own builder can reach: - A file of a later version was refused for the keys v1 lacks instead of for its version. The version stamp is now read before the v1 shape. - `result: null` and `provenance: null` were read as absent keys. The schema has no null there, so both are now input errors. - A path or leaf ID with whitespace was reported without saying which, and whitespace other than a plain space is invisible in the message. The offending value is now quoted with its escapes. A test pins "whitespace" to the Unicode White_Space set on both sides.
shunsuke-shimomura
force-pushed
the
feat/206-calc-evidence-model
branch
from
November 10, 2026 03:55
90e4082 to
cde6f83
Compare
Member
Author
Review follow-up (2026-11-10)Rebased onto the updated #227 and force-pushed. One commit was added.
Left as is
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #206 (parent: #40). Stacked on #227 (
calc:rename), which is stacked on #226 (the calc evidence design andschemas/calc-evidence-v1.schema.json).Adds the calc evidence model to the shared
inka-evidencecrate, following the test evidence pattern so a producer cannot emit what the consumer rejects:inka_evidence::calc— the serde mirror of the schema (Target,Definition,DefinitionKind,Leaf), a strictparse(unknown fields rejected outsideprovenance, version checked) and aCalcEvidenceBuilderwhoseadd_targetruns the samecheckasparse. The checks: target, definition and leaf paths are non-empty with no whitespace; a target declares at least one definition and is among its own definitions; definition paths and leaf IDs are unique per target; sources are non-empty; assumption IDs follow the inka ID grammar (ident(::ident)*) and are unique; target paths are unique per file; provenance entries are non-blank. Whether an assumption ID names a real node, and the interface hash, remain the consumer's job (calc evidence: load-time consumption, interface hash and assumption edges in check #208).resultkey (nevernull),xfail: falseis omitted, empty provenance is omitted.provenance.rs): the blank-entry rule and theCAPSULA_RUN_IDfill are now one implementation used by both builders;EvidenceBuilder's behaviour is unchanged.inka-evidence-py):CalcEvidenceBuilder,Definition,Leaf, re-exported frominka_evidence; invalid input raises the existingInvalidEvidenceError. Definition kinds and outcomes are read through the crate's serde vocabulary, so the accepted strings cannot drift from the wire format. README documents the API.Not included: a merge operation for calc evidence (no use case yet — a veriq project is evaluated in one run) and the wasm binding (no TypeScript producer of calc evidence).
Test results
cargo test -p inka-evidence: 49 tests pass.tests/calc_emission.rscovers the round trip, the schema conformance of emitted files (viajsonschema), everyInvalidCalcEvidencevariant at add time, the duplicate-target rejection on both sides, and a proptest asserting that builder, parser and the repository JSON Schema agree on arbitrary (often invalid) input: the first defect the builder and parser report is identical, and the schema admits a file exactly when the crate does — except for the one rule the schema cannot express (a target being among its own definitions), which is exercised and exempted explicitly.uv run pytestincrate/inka-evidence-py: 73 pass (17 new intests/test_calc_emission.py, including schema conformance of the emitted file and every rejection reachable from Python).cargo test --workspace: all pass except theinka-evidence-rustadapter tests, which needcargo-nextest(not installed locally; unrelated).cargo fmt --check,cargo clippy --workspace --all-targets,prekon changed files: clean.Impact
inka_evidence::calcand three new Python classes. The existing test evidence API and wire format are untouched; the provenance refactor is behaviour-preserving (existing tests cover it).inka-evidence-pygains a directserdedependency (already in the workspace) for the generic vocabulary helpers;Cargo.lockupdated accordingly.uv.lockis unchanged.Supplementary information
calc::parsereturns only the targets, likeparsefor tests; the consumer ininka-core(calc evidence: load-time consumption, interface hash and assumption edges in check #208) wraps each error with the file path, as it does for test evidence.🤖 Generated with Claude Code