Skip to content

feat(cli): spar moves enumerate — design-space exploration (Track E commit 4/8)#170

Merged
avrabe merged 1 commit intomainfrom
feat/v0.8.0-track-e-commit4-enumerate
Apr 26, 2026
Merged

feat(cli): spar moves enumerate — design-space exploration (Track E commit 4/8)#170
avrabe merged 1 commit intomainfrom
feat/v0.8.0-track-e-commit4-enumerate

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 26, 2026

Summary

Track E commit 4 of 8 for the v0.8.0 migration oracle.

Adds spar moves enumerate --component X [--target-filter PREFIX] [--format {json,text}], the second user-facing surface of the migration oracle. Builds on commit 3 (spar moves verify, #166).

  • Candidate-target set. When the component declares Spar_Migration::Allowed_Targets, those names are used. Otherwise every Processor / VirtualProcessor in the instance is a candidate. --target-filter is an optional case-insensitive substring narrower applied on top of either set.
  • Per-candidate verification. Each candidate runs the same overlay + analysis pipeline as spar moves verify: build a single-move BindingOverlay, validate it (Frozen / Allowed_Targets), run the analysis suite, and produce a structured MoveCandidate (target, ok, violations, diagnostics_count, slack_ns).
  • Slack ranking (v0.8.0 simple metric). min(deadline − response_time) in picoseconds, parsed from RTA's info-level "thread '...' on processor '...': response time X <= deadline Y" diagnostics. None when RTA produced no usable info diagnostics; negative-sentinel when RTA reports a deadline miss. The full multi-objective ranking (weight, power, EMV2 cost) lands in commits 5-6.
  • Output. JSON is the canonical machine-readable shape (consumed by the v0.9.0 MCP spar.enumerate_moves tool surface). Text is a sortable table with a total=N valid=K summary footer.
  • Exit codes. 0 if at least one admissible candidate (valid >= 1); 1 otherwise (or input-resolution error).

What's NOT in this commit

  • Full solver-driven enumeration (commits 5-6 — spar-solver integration).
  • Multi-objective ranking (weight / power / EMV2 cost) — commits 5-6.
  • MCP tool surface for spar.enumerate_moves — v0.9.0.
  • Overlay-aware analysis passes (RTA / latency / bandwidth / EMV2 / ARINC653) — orthogonal Track E lift; current behaviour matches commit 3 (analyses see the un-overlayed instance).

Files changed

  • crates/spar-cli/src/moves.rs — extends with EnumerateArgs, MoveCandidate, MoveEnumerateReport, run_enumerate, candidate-target derivation, slack parser, text + JSON renderers, and dispatch wiring (~640 LOC). Reuses VerifyArgs / Violation / build_report / resolve_component / fqn from commit 3.
  • crates/spar-cli/src/main.rs — top-level help line for the new subcommand.
  • crates/spar-cli/tests/moves_enumerate.rs — 10 new integration tests.
  • crates/spar-hir-def/src/overlay.rs + lib.rsread_allowed_targets now pub (re-exported) so enumerate can derive the candidate set without staging an overlay just to ask.
  • artifacts/requirements.yamlREQ-MIGRATION-006.
  • artifacts/verification.yamlTEST-MOVES-ENUMERATE linked to REQ-MIGRATION-{004,005,006}.

Test plan

  • cargo build --workspace clean
  • cargo test --workspace green (10 new integration tests + 4 new unit tests, additive on top of existing 800+; full workspace also passes)
  • cargo clippy --workspace --all-targets -- -D warnings clean
  • cargo fmt --all -- --check clean
  • rivet validate clean (pre-existing INFO-level field-shape notes only)
  • Frozen-component fixture: every candidate ok=false; valid=0; exit 1
  • Allowed_Targets fixture: cpu3 (not allowed) excluded from candidate list
  • RTA-fail fixture: every candidate has diagnostics_count > 0 and ok=false
  • Target-filter narrows 3-CPU model to 2 candidates by substring match
  • Text format ends with total=N valid=K
  • JSON output deserializes into the documented schema
  • Unknown component name yields non-zero exit and stderr mention
  • spar analyze output is byte-identical before / after enumerate (overlay is read-only)

🤖 Generated with Claude Code

…ommit 4/8)

Adds `spar moves enumerate --component X [--target-filter PREFIX] [--format
{json,text}]`, the second user-facing surface of the v0.8.0 migration
oracle. Lists every valid hypothetical rebinding target for a component
within Allowed_Targets (or all processors if Allowed_Targets is absent),
runs the same validation pipeline as `verify` for each, and reports
ok / violations / slack-rank.

JSON output is the canonical machine-readable shape (will be consumed
by the v0.9.0 MCP tool surface). Text output lists candidates in a
human-readable table with a `total=N valid=K` summary.

Slack ranking is the v0.8.0 simple metric: min(deadline − response_time)
across threads on the candidate target. Multi-objective ranking
(weight, power, EMV2 cost) lands in commits 5-6.

New requirement: REQ-MIGRATION-006.

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

codecov Bot commented Apr 26, 2026

Codecov Report

❌ Patch coverage is 76.48725% with 83 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/spar-cli/src/moves.rs 76.63% 82 Missing ⚠️
crates/spar-cli/src/main.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@avrabe avrabe merged commit 5a055cd into main Apr 26, 2026
16 of 17 checks passed
@avrabe avrabe deleted the feat/v0.8.0-track-e-commit4-enumerate branch April 26, 2026 20:20
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