Skip to content

Serialize a category as its CLI slug, not a second spelling - #12

Merged
UnbreakableMJ merged 1 commit into
mainfrom
fix/category-json-spelling
Aug 7, 2026
Merged

Serialize a category as its CLI slug, not a second spelling#12
UnbreakableMJ merged 1 commit into
mainfrom
fix/category-json-spelling

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Contributor

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 PackageManagerGc was 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

Serialize is now hand-written and delegates to slug(), 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:

  • every variant in Category::ALL serializes to its slug — a new category whose name doesn't kebab-case to its slug fails here, not in someone's pipeline
  • every serialized form parses back through from_slug
  • a candidate and its group report the same string (pins this specific regression)

Verified

group     -> package-gc
candidate -> package-gc
"package-gc" fed back to --category: accepted

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

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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@UnbreakableMJ
UnbreakableMJ merged commit 7a00f57 into main Aug 7, 2026
3 checks passed
@UnbreakableMJ
UnbreakableMJ deleted the fix/category-json-spelling branch August 7, 2026 10:26
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