Expand description
Typed CliError.kind enum (coding_agent_session_search-dxnmb).
CliError.kind is currently a &'static str field with 86 unique
values scattered as string literals across src/lib.rs. There is
no compile-time exhaustiveness check, no naming-convention guard,
and no rename-safety. A hurried maintainer can:
- typo a kind (“db_error” vs “db-error”) without compiler error,
- introduce a new kind that shadows an existing one,
- use inconsistent casing (the existing literal set already has
4 snake_case stragglers —
failed_seed_bundle_file,lexical_generation,lexical_shard,retained_publish_backup— alongside the canonical kebab-case majority).
That inconsistency caused 3 real duplicates pinned by bead al19b.
This module ships the vocabulary slice of the dxnmb fix: a single source-of-truth enum that:
- enumerates every kind currently emitted by
src/lib.rs(audited at landing time viagrep -oE 'kind: "[a-z_-]+"'), - exposes a
kind_str()accessor that returns the canonical kebab-case (or, for the four snake_case stragglers, the exact legacy literal — preserving wire compatibility with golden tests + downstream agents until those four are migrated in a separate slice), - exposes a
from_kind_str()lookup so JSON-mode consumers (and golden tests) can round-trip the kind cleanly.
The actual migration of the 223 call sites in src/lib.rs (each
CliError { kind: "...", ... } literal → CliError { kind: ErrorKind::Foo.as_str(), ... }) is the follow-up slice; it
requires write access to src/lib.rs which is currently held by
another agent’s exclusive file reservation. Landing the
vocabulary first lets that follow-up slice land as a pure
mechanical replacement gated by the golden test below.
§Variant naming
Variants use Rust’s standard CamelCase. The mapping to the
wire-format string is held by kind_str() rather than by
#[serde(rename = "...")] because the four snake_case stragglers
cannot be auto-generated from CamelCase by serde’s
rename_all = "kebab-case" (e.g. LexicalGeneration would
serialize as lexical-generation, breaking the existing
kind: "lexical_generation" wire contract). The audit golden
test pins both the kebab-case canonical kinds AND the snake_case
exemptions so a future cleanup slice that migrates the four
stragglers to kebab-case has an explicit place to flip the
contract.
Enums§
- Error
Kind - Typed counterpart to
CliError.kind. Every variant maps to the exact wire-format string emitted today; new kinds added by future CLI surfaces should be added here AND covered by the golden test at the bottom of this module.