Skip to content

fix(serve): variant scope uses binding embedded in the variant file (REQ-106)#335

Merged
avrabe merged 1 commit into
mainfrom
fix/req-106-serve-variant-binding
May 29, 2026
Merged

fix(serve): variant scope uses binding embedded in the variant file (REQ-106)#335
avrabe merged 1 commit into
mainfrom
fix/req-106-serve-variant-binding

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented May 28, 2026

Summary

User-reported (Ford variant corpus): the rivet serve dashboard reported bound_artifact_count: 0 for every variant, while the CLI variant solve --binding <variant-file> reported the correct counts (16 / 13 / 17).

Root cause: ProjectVariants::discover only loaded a separate project-level binding (artifacts/bindings.yaml). When the bindings: section is embedded in the variant file itself (the variant IS its own binding model), no separate file exists → self.binding = Nonecollect_bound_ids returned an empty set for every variant.

Fix: during discovery, also parse each variant file as a FeatureBinding; if it carries a non-empty bindings: section, store it keyed by variant name. resolve() and validation_status() select the binding via binding_for(name) — the variant's own embedded binding takes precedence, falling back to the project-level bindings.yaml. Mirrors the CLI's --binding <variant-file> self-reference.

Tests

  • resolve_uses_binding_embedded_in_variant_file — embedded binding, no separate bindings.yaml, asserts non-zero bound count via both resolve() and validation_status() (the /variants overview path).
  • project_binding_still_used_when_no_embedded — regression guard for the project-level path.

Test plan

  • cargo test -p rivet-cli --bins variant — 8 pass (2 new)
  • CI

Fixes: REQ-106

🤖 Generated with Claude Code

…REQ-106)

User-reported (Ford variant corpus): the serve dashboard reported
bound_artifact_count: 0 for every variant, while the CLI
`variant solve --binding <variant-file>` reported the correct counts.

Root cause: ProjectVariants::discover only loaded a *separate*
project-level binding (artifacts/bindings.yaml). When the `bindings:`
section is embedded in the variant file itself (the variant IS its own
binding model), no separate file exists, so `self.binding` was None and
collect_bound_ids returned an empty set for every variant.

Fix: during discovery, also parse each variant file as a FeatureBinding;
if it carries a non-empty `bindings:` section, store it keyed by variant
name. `resolve()` and `validation_status()` now select the binding via
`binding_for(name)` — the variant's own embedded binding takes
precedence, falling back to the project-level bindings.yaml. This
mirrors the CLI's `--binding <variant-file>` self-reference.

Tests: resolve_uses_binding_embedded_in_variant_file (embedded binding,
NO separate bindings.yaml, asserts non-zero bound count via both
resolve() and validation_status()); project_binding_still_used_when_no_embedded
(regression guard for the project-level path).

Fixes: REQ-106
Refs: REQ-083, REQ-007
Verifies: REQ-106

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

📐 Rivet artifact delta

No artifact changes in this PR. Code-only changes (renderer, CLI wiring, tests) don't touch the artifact graph.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rivet Criterion Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: fb7da50 Previous: 0d5c308 Ratio
traceability_matrix/1000 58180 ns/iter (± 547) 45419 ns/iter (± 360) 1.28

This comment was automatically generated by workflow using github-action-benchmark.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@avrabe avrabe merged commit 431d48e into main May 29, 2026
21 of 40 checks passed
@avrabe avrabe deleted the fix/req-106-serve-variant-binding branch May 29, 2026 04:48
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