fix(codegen): per-category summary + hint when WIT requested but none emitted#242
Open
avrabe wants to merge 1 commit into
Open
fix(codegen): per-category summary + hint when WIT requested but none emitted#242avrabe wants to merge 1 commit into
avrabe wants to merge 1 commit into
Conversation
… emitted
`spar codegen` previously printed a bare `Generated N files in <dir>/`,
which silently hid the most common confusing case: a model with
threads but no `process` subcomponents run under the default
`--format both` emits Rust + Cargo.toml + BUILD.bazel and zero `.wit`
files (because WIT generation is per-process). Operators and agents
read the output as "the other files but no wit" with no clue why.
Replace the summary with a per-category breakdown and add a focused
hint when WIT was requested but none came out:
codegen: wrote 3 files (1 .rs, 2 workspace) (format: both) to gen/
hint: --format both emits one .wit interface per AADL `process`
subcomponent; this model has 0 processes — add `process`
declarations to the system implementation, or pass --format
rust for thread skeletons only.
The format label answers "did spar honour my --format?"; the
per-category count answers "what got produced?"; the hint answers
"why didn't I get what I asked for?" The dry-run path gets the same
shape (without writing files). Three smoke cases cover the matrix:
threads + default => hint; process + --format wit => no hint; threads
+ --format rust => no hint (user did not request WIT).
Helpers are pure functions of `&[GeneratedFile]` + `OutputFormat`,
suitable for promotion to golden tests if the stdout shape is later
contracted.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Rivet verification gate✅ 20/20 passed
Filter: Failed artifacts(none) Updated automatically by |
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.
Summary
spar codegenpreviously printed a bareGenerated N files in <dir>/,which silently hid the most common confusing case: a model with
threads but no
processsubcomponents run under the default--format bothemits Rust +Cargo.toml+BUILD.bazeland zero.witfiles (because WIT generation is per-process). Operators andagents read the output as "the other files but no wit" with no clue
why.
This is a no-functional-change diagnostic improvement: replace the
summary with a per-category breakdown and add a focused hint when WIT
was requested but none came out.
Before
After
The hint fires only when WIT was requested (
--format witor thedefault
--format both) and zero.witfiles came out.Smoke matrix
both(default)(1 .rs, 2 workspace)--format witwit(1 .wit), no hint--format rustrust(1 .rs, 2 workspace), no hint (user didn't ask for WIT)Files
crates/spar-cli/src/main.rs—cmd_codegencalls two new helpers:summarise_codegen_outputandmaybe_print_empty_wit_hint. Bothare pure functions of
&[GeneratedFile]+OutputFormat, suitablefor golden-test promotion later if the stdout shape is contracted.
REQ-CODEGEN-SUMMARY+TEST-CODEGEN-SUMMARY-HINT.Test plan
cargo clippy -p spar --all-targets— cleancargo fmt --check— cleanrivet validate— 0 broken cross-refs; totals byte-identical to baseline🤖 Generated with Claude Code