Skip to content

fix(codegen): per-category summary + hint when WIT requested but none emitted#242

Merged
avrabe merged 2 commits into
mainfrom
fix/v0.11.0-codegen-summary-hint
May 27, 2026
Merged

fix(codegen): per-category summary + hint when WIT requested but none emitted#242
avrabe merged 2 commits into
mainfrom
fix/v0.11.0-codegen-summary-hint

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented May 24, 2026

Summary

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.

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

Generating code for Threads::Sys. (2 components)
Generated 3 files in /tmp/threads-out/

After

Generating code for Threads::Sys. (2 components)
codegen: wrote 3 files (1 .rs, 2 workspace) (format: both) to /tmp/threads-out/
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 hint fires only when WIT was requested (--format wit or the
default --format both) and zero .wit files came out.

Smoke matrix

Case Format Expectation Result
Threads-only model both (default) hint fires, (1 .rs, 2 workspace)
Process + --format wit wit (1 .wit), no hint
Threads + --format rust rust (1 .rs, 2 workspace), no hint (user didn't ask for WIT)

Files

  • crates/spar-cli/src/main.rscmd_codegen calls two new helpers:
    summarise_codegen_output and maybe_print_empty_wit_hint. Both
    are pure functions of &[GeneratedFile] + OutputFormat, suitable
    for golden-test promotion later if the stdout shape is contracted.
  • Artifacts: REQ-CODEGEN-SUMMARY + TEST-CODEGEN-SUMMARY-HINT.

Test plan

  • Three smoke cases above all match expectations
  • cargo clippy -p spar --all-targets — clean
  • cargo fmt --check — clean
  • rivet validate — 0 broken cross-refs; totals byte-identical to baseline

🤖 Generated with Claude Code

@avrabe avrabe enabled auto-merge (squash) May 24, 2026 13:30
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 24, 2026

Rivet verification gate

20/20 passed

count
Passed 20
Failed 0
Skipped (no steps) 0

Filter: (and (= type "feature") (or (has-tag "v093") (has-tag "v0100")))

Failed artifacts

(none)

Updated automatically by tools/post_verification_comment.py. Source of truth: artifacts/verification.yaml.

@avrabe avrabe force-pushed the fix/v0.11.0-codegen-summary-hint branch from 3c24fb3 to b1858ea Compare May 26, 2026 18:42
avrabe added a commit that referenced this pull request May 26, 2026
The codegen stdout now reads
  codegen: wrote N files (… .rs, … .wit, … workspace) (format: both) to <dir>/
instead of the prior bare `Generated N files in <dir>/`. The roundtrip
test asserted on the old prefix; update it to assert on the new shape
(`codegen: wrote` + `(format:`) so the per-category summary line is
locked in.

Caught by CI before the release tag; should have been caught locally
by running `cargo test -p spar --test roundtrip` before opening #242.

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

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 92.95775% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/spar-cli/src/main.rs 92.95% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

avrabe added a commit that referenced this pull request May 26, 2026
Workspace bump from 0.10.0 → 0.11.0 across all 22 spar crates (via
[workspace.package].version), plus the VS Code extension's
package.json — the two version surfaces the release workflow's
check-versions job compares against the tag.

What v0.11.0 ships, since v0.10.0:

  trace-topology reconciliation engine (incremental rollout):
    #239  IdentityUnknown check (PR 3a — component-borne MAC + chassis-id)
    #241  GptpOutOfBudget check  (PR 3b — single-budget case)

  trace-topology fixture pipeline:
    #233  Rust gen-fixtures tool (netns + TSN, RAII teardown)
    #234  NixOS guest + QEMU harness for fixture generation
    #238  corrected nixos/nix container digest (fd7a5c67…, multi-arch index)
    #240  podman runner label so workflows schedule on the only
          rootless-podman-capable runner in the fleet (runner9)

  codegen:
    #232  --format wit emits only WIT (strict-filter; no Rust/Bazel
          workspace leakage)
    #242  per-category file-count summary + hint when WIT was
          requested but the model has no `process` subcomponents
          (in-flight at bump time; auto-merge armed)

  release flow:
    #244  standardise on the synth reference — actions/attest-build-
          provenance@v2 + sigstore cosign sign-blob (v2.4.1) over
          SHA256SUMS.txt, build-env.txt; the v0.11.0 release is the
          first one to exercise the standardised cosign + SLSA chain.

Verification after release:
  cosign verify-blob \\
    --certificate-identity-regexp \\
      'https://github.com/pulseengine/spar/.github/workflows/release.yml@.*' \\
    --certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \\
    --bundle SHA256SUMS.txt.cosign.bundle SHA256SUMS.txt
  gh attestation verify spar-v0.11.0-<triple>.tar.gz --repo pulseengine/spar

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
avrabe and others added 2 commits May 27, 2026 05:51
… 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>
The codegen stdout now reads
  codegen: wrote N files (… .rs, … .wit, … workspace) (format: both) to <dir>/
instead of the prior bare `Generated N files in <dir>/`. The roundtrip
test asserted on the old prefix; update it to assert on the new shape
(`codegen: wrote` + `(format:`) so the per-category summary line is
locked in.

Caught by CI before the release tag; should have been caught locally
by running `cargo test -p spar --test roundtrip` before opening #242.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@avrabe avrabe force-pushed the fix/v0.11.0-codegen-summary-hint branch from eda1368 to 7bbc9b8 Compare May 27, 2026 03:51
@avrabe avrabe merged commit 3969fd0 into main May 27, 2026
17 of 18 checks passed
@avrabe avrabe deleted the fix/v0.11.0-codegen-summary-hint branch May 27, 2026 07:40
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