Serialize a category as its CLI slug, not a second spelling - #12
Merged
Conversation
A category went out under two different names. `vacuum list --json` labelled the group `package-gc`, from `Category::slug`, while every candidate inside it said `package-manager-gc`, from a `#[serde(rename_all = "kebab-case")]` derive over the variant name. A consumer that read a candidate's category could not feed it back to `--category`, which only accepts the slug. Only `PackageManagerGc` was affected: it is the one variant whose name does not kebab-case to its slug. That is exactly what made the bug easy to miss — four of the five categories agreed, so the two spellings looked interchangeable. `Serialize` is now written out and delegates to `slug`, which makes the slug the single source of truth for the command line, candidate records, group headings, and the introspection schema alike. A derive cannot express that: it necessarily restates the mapping, and any variant renamed without a matching slug change reintroduces the divergence silently. Three tests hold it closed. Two iterate `Category::ALL` and assert that each variant serializes to its slug and parses back through `from_slug`, so a new category whose name does not kebab-case to its slug fails here rather than in a consumer. The third pins the specific regression, asserting a candidate and its group report the same string. This changes JSON output for anything matching the literal `package-manager-gc`. Nothing in the tree did, and at 0.1.0 the alternative is carrying two spellings of one identifier indefinitely. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FCJbPm4FWS99y9utbUe13z
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
A category went out under two different names:
{ "category": "package-gc", // the group, from Category::slug "candidates": [ { "category": "package-manager-gc" } // the candidate, from a serde derive ] }The group used
Category::slug; each candidate used#[serde(rename_all = "kebab-case")]over the variant name. A consumer that read a candidate's category could not feed it back to--category, which only accepts the slug.Only
PackageManagerGcwas affected — the one variant whose name doesn't kebab-case to its slug. That is precisely what made it easy to miss: four of five categories agreed, so the two spellings looked interchangeable.Fix
Serializeis now hand-written and delegates toslug(), making the slug the single source of truth across the command line, candidate records, group headings, and the introspection schema. A derive cannot express that — it necessarily restates the mapping, so any variant renamed without a matching slug change reintroduces the divergence silently.Tests
Three, and the first two are the ones that matter long-term:
Category::ALLserializes to its slug — a new category whose name doesn't kebab-case to its slug fails here, not in someone's pipelinefrom_slugVerified
Compatibility
This changes JSON output for anything matching the literal
package-manager-gc. Nothing in the tree did (checked). At 0.1.0 the alternative is carrying two spellings of one identifier indefinitely, so it is better done now than after adoption.🤖 Generated with Claude Code
https://claude.ai/code/session_01FCJbPm4FWS99y9utbUe13z