Skip to content

feat(variants): spar-variants consumer crate for rivet variant context v1 (Track B commit 1)#162

Merged
avrabe merged 1 commit intomainfrom
feat/v0.7.x-track-b-commit1-variants-consumer
Apr 26, 2026
Merged

feat(variants): spar-variants consumer crate for rivet variant context v1 (Track B commit 1)#162
avrabe merged 1 commit intomainfrom
feat/v0.7.x-track-b-commit1-variants-consumer

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 25, 2026

Summary

Speculative consumer side for the rivet ↔ spar variant binding contract v1
(docs/contracts/rivet-spar-variant-v1.md, proposed in #144).
Rivet's emitter is in flight; this crate is ready for it.

  • New crate spar-variants (sibling of spar-network) — depends only on spar-hir-def and serde/serde_json.
  • VariantContext::from_json parses the v1 blob and strictly rejects any rivet_spar_context_version != "1" (v2 readers refused per contract §"Compatibility and versioning").
  • Binding covers both file-scoped (artifact) and symbol-scoped (symbol) entries via serde(untagged).
  • HasBindingIdentity trait — minimal identity adapter HIR items will implement.
  • keep_in_variant(item, context) applies the contract's intersection semantics: an item is kept iff every matching binding has its requires satisfied; items with no matching binding are kept unconditionally as variant-independent infrastructure.

Out of scope for this commit (deferred to Track B commit 2 alongside CLI wiring):

  • --variant / --variant-context flags on spar-cli.
  • impl HasBindingIdentity for spar-hir-def types — tests use a local StubItem.
  • End-to-end test loop with the rivet emitter.

The symbol-binding matcher uses textual prefix-matching (<symbol> followed by ., ::, or end-of-string) which covers nested-in-body items per contract §"Symbol granularity"; a TODO(track-b-commit-2+) flags the inheritance corner-case that needs HIR-level "contains" plumbing rather than string-shape.

Artifacts

  • New requirement: REQ-VARIANT-001 ("Consume rivet's variant context blob (v1) and filter HIR").
  • New verification: TEST-VARIANTS-CONSUMER linked to REQ-VARIANT-001.

Test plan

  • cargo build -p spar-variants clean
  • cargo test -p spar-variants — 17 tests pass (10 spec'd + 7 incidental coverage)
  • cargo build --workspace clean
  • cargo test --workspace — all green
  • cargo clippy --workspace --all-targets -- -D warnings clean
  • cargo fmt --all -- --check clean
  • rivet validate PASS (91 advisory warnings, all pre-existing)

Contract-spec ambiguities encountered

None blocking. One soft point worth flagging for the v1 finalization pass:

  • Path normalization scope. Contract §"Binding resolution semantics" says "after normalization" without specifying it. This commit does textual normalization only: strip leading ./, fold \/. No .. resolution, no case-folding, no canonicalization against the filesystem. That's almost certainly the right v1 behaviour (project-relative paths, no I/O on the consumer side) but the spec could be tighter. Not blocking commit 1 — happy to firm up once the emitter is exercising real fixtures.

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 94.18960% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/spar-variants/src/context.rs 86.17% 17 Missing ⚠️
crates/spar-variants/src/binding.rs 97.97% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

…t v1 (Track B commit 1)

New crate spar-variants implements the consumer side of the v1 contract
(docs/contracts/rivet-spar-variant-v1.md). Reads rivet's resolved-variant
JSON blob, exposes a `keep_in_variant` predicate that applies intersection-
semantics binding rules to HIR items, and validates strict version
matching ("1" only — v2 readers refused per contract).

No CLI integration in this commit (--variant flag wiring lands when
rivet's emitter side ships and we have an end-to-end test loop). No
HasBindingIdentity impls for spar-hir-def types yet — adapter ships
with the CLI commit. Stub types are used in unit tests.

Per Track B contract v1 (#144).

New requirement: REQ-VARIANT-001.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@avrabe avrabe force-pushed the feat/v0.7.x-track-b-commit1-variants-consumer branch from 87e9906 to a2f7f9d Compare April 26, 2026 06:45
@avrabe avrabe merged commit f74c56f into main Apr 26, 2026
14 checks passed
@avrabe avrabe deleted the feat/v0.7.x-track-b-commit1-variants-consumer branch April 26, 2026 13:15
avrabe added a commit that referenced this pull request Apr 27, 2026
…ommit 6/8)

Wires spar-variants (Track B v0.7.x consumer crate, #162) into
spar moves verify and spar moves enumerate. Both commands now accept
--variant NAME (implicit; shells out to rivet) and --variant-context
PATH (explicit; reads the JSON blob directly per the v1 contract).

Variant filter is applied before overlay validation: items not in the
selected variant are dropped from the analysis surface, matching the
contract's intersection semantics. Output includes variant + feature
model hash for audit trail.

New requirement: REQ-MIGRATION-008.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avrabe added a commit that referenced this pull request Apr 27, 2026
…ommit 6/8) (#173)

* chore(release): bump to v0.7.1 + add CHANGELOG

Promotes the v0.7.x line to a tagged release. Headlines:

- Track A v0.7.0 (IRQ-aware hierarchical RTA + Lean theorems)
- Track A v0.7.1 (PIP/PCP blocking)
- Track B v0.7.x foundation (variant contract spec + spar-variants
  consumer crate)
- v0.7.x verification infrastructure: Lean + Bazel + proptest CI
  gates (#135), Kani harnesses (#136), cargo-fuzz (#138), criterion
  benchmarks (#137)

Track D Phase 1 (TSN/WCTT) and Track E commits 1-4 are also on main
at the time of this tag and ship in the resulting binaries; they
will be advertised as v0.8.0 features when Track E is fully closed.

Cargo.toml workspace version + vscode-spar/package.json bumped to
0.7.1. CHANGELOG.md created (Keep a Changelog format).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(moves): rivet variant integration in verify/enumerate (Track E commit 6/8)

Wires spar-variants (Track B v0.7.x consumer crate, #162) into
spar moves verify and spar moves enumerate. Both commands now accept
--variant NAME (implicit; shells out to rivet) and --variant-context
PATH (explicit; reads the JSON blob directly per the v1 contract).

Variant filter is applied before overlay validation: items not in the
selected variant are dropped from the analysis surface, matching the
contract's intersection semantics. Output includes variant + feature
model hash for audit trail.

New requirement: REQ-MIGRATION-008.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avrabe added a commit that referenced this pull request Apr 27, 2026
… 7/8)

Adds docs/cli/moves.md — comprehensive user-facing documentation for
`spar moves verify` and `spar moves enumerate`, covering flags, exit
codes, JSON/text output schemas, candidate-set derivation,
multi-objective ranking, rivet-variant integration, and a worked
example.

Updates COMPLIANCE.md:
- Header date + version line (v0.7.1 released / v0.8.0 in progress).
- Renames "In progress / v0.7.0" -> "v0.7.1 (released 2026-04-27)".
- Promotes Track B from "foundation only" to including spar-variants
  consumer crate (#162).
- New "v0.8.0 (in progress on main)" section with Track D Phase 1
  (6/6) + Track E (7/8 with this commit) + Track F.
- New "v0.9.0 horizon" listing Track E commit 8 (MCP), spar-insight,
  Track D Phase 2 conditional on demand.

Track E commit 7 of 8.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant