coding-agent-search 0.5.1

Unified TUI search over local coding agent histories
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
//! 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:
//!
//! 1. enumerates every kind currently emitted by `src/lib.rs`
//!    (audited at landing time via `grep -oE 'kind: "[a-z_-]+"'`),
//! 2. 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),
//! 3. 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.

use serde::{Deserialize, Serialize};

/// 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.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ErrorKind {
    AmbiguousSource,
    ArchiveAnalyticsRebuild,
    ArchiveCount,
    ArchiveDailyStatsRebuild,
    ArchiveFtsRebuild,
    ArchivePurge,
    ArchiveTokenDailyStatsRebuild,
    Config,
    CursorDecode,
    CursorParse,
    Daemon,
    DbError,
    DbOpen,
    DbQuery,
    Doctor,
    Download,
    EmbedderUnavailable,
    EmptyFile,
    EmptySession,
    EncodeJson,
    ExportFailed,
    /// Snake-case wire literal (legacy): `failed_seed_bundle_file`.
    /// Kept exact until the cross-cutting kebab-case migration ships.
    FailedSeedBundleFile,
    FileCreate,
    FileNotFound,
    FileOpen,
    FileRead,
    FileWrite,
    Health,
    IdempotencyMismatch,
    Index,
    IndexBusy,
    IndexMissing,
    IndexedSessionRequired,
    InvalidAgent,
    InvalidFilename,
    InvalidLine,
    Io,
    IoError,
    LexicalRebuild,
    /// Snake-case wire literal (legacy): `lexical_generation`.
    LexicalGeneration,
    /// Snake-case wire literal (legacy): `lexical_shard`.
    LexicalShard,
    LineNotFound,
    LineOutOfRange,
    Local,
    Mapping,
    MissingDb,
    MissingIndex,
    Model,
    NotFound,
    OpenIndex,
    OpencodeParse,
    OpencodeSqliteParse,
    OutputNotWritable,
    PackEmptyQuery,
    PackInvalidField,
    PackInvalidLimit,
    PackNoEvidence,
    PackUnsupportedFormat,
    Pages,
    ParseError,
    PasswordReadError,
    PasswordRequired,
    RebuildError,
    RepairError,
    ResumeEmptyCommand,
    ResumeExecFailed,
    /// Snake-case wire literal (legacy): `retained_publish_backup`.
    RetainedPublishBackup,
    Search,
    SemanticBackfill,
    SemanticManifest,
    SemanticUnavailable,
    SerializeMessage,
    SessionFileUnreadable,
    SessionIdNotFound,
    SessionNotFound,
    SessionParse,
    SessionsFrom,
    Setup,
    Source,
    Ssh,
    Storage,
    StorageFingerprint,
    Timeout,
    Tui,
    TuiHeadlessOnce,
    TuiResetState,
    Unknown,
    UnknownAgent,
    UpdateCheck,
    Usage,
    WriteFailed,
}

impl ErrorKind {
    /// Returns the wire-format string emitted in `CliError.kind`.
    /// **MUST** match the literal currently used in `src/lib.rs` for
    /// every variant — the golden test below asserts this. Adding a
    /// new variant without updating this match is a compile error
    /// (no `_ => ...` catch-all).
    pub fn kind_str(self) -> &'static str {
        match self {
            Self::AmbiguousSource => "ambiguous-source",
            Self::ArchiveAnalyticsRebuild => "archive-analytics-rebuild",
            Self::ArchiveCount => "archive-count",
            Self::ArchiveDailyStatsRebuild => "archive-daily-stats-rebuild",
            Self::ArchiveFtsRebuild => "archive-fts-rebuild",
            Self::ArchivePurge => "archive-purge",
            Self::ArchiveTokenDailyStatsRebuild => "archive-token-daily-stats-rebuild",
            Self::Config => "config",
            Self::CursorDecode => "cursor-decode",
            Self::CursorParse => "cursor-parse",
            Self::Daemon => "daemon",
            Self::DbError => "db-error",
            Self::DbOpen => "db-open",
            Self::DbQuery => "db-query",
            Self::Doctor => "doctor",
            Self::Download => "download",
            Self::EmbedderUnavailable => "embedder-unavailable",
            Self::EmptyFile => "empty-file",
            Self::EmptySession => "empty-session",
            Self::EncodeJson => "encode-json",
            Self::ExportFailed => "export-failed",
            Self::FailedSeedBundleFile => "failed_seed_bundle_file",
            Self::FileCreate => "file-create",
            Self::FileNotFound => "file-not-found",
            Self::FileOpen => "file-open",
            Self::FileRead => "file-read",
            Self::FileWrite => "file-write",
            Self::Health => "health",
            Self::IdempotencyMismatch => "idempotency-mismatch",
            Self::Index => "index",
            Self::IndexBusy => "index-busy",
            Self::IndexMissing => "index-missing",
            Self::IndexedSessionRequired => "indexed-session-required",
            Self::InvalidAgent => "invalid-agent",
            Self::InvalidFilename => "invalid-filename",
            Self::InvalidLine => "invalid-line",
            Self::Io => "io",
            Self::IoError => "io-error",
            Self::LexicalRebuild => "lexical-rebuild",
            Self::LexicalGeneration => "lexical_generation",
            Self::LexicalShard => "lexical_shard",
            Self::LineNotFound => "line-not-found",
            Self::LineOutOfRange => "line-out-of-range",
            Self::Local => "local",
            Self::Mapping => "mapping",
            Self::MissingDb => "missing-db",
            Self::MissingIndex => "missing-index",
            Self::Model => "model",
            Self::NotFound => "not-found",
            Self::OpenIndex => "open-index",
            Self::OpencodeParse => "opencode-parse",
            Self::OpencodeSqliteParse => "opencode-sqlite-parse",
            Self::OutputNotWritable => "output-not-writable",
            Self::PackEmptyQuery => "pack-empty-query",
            Self::PackInvalidField => "pack-invalid-field",
            Self::PackInvalidLimit => "pack-invalid-limit",
            Self::PackNoEvidence => "pack-no-evidence",
            Self::PackUnsupportedFormat => "pack-unsupported-format",
            Self::Pages => "pages",
            Self::ParseError => "parse-error",
            Self::PasswordReadError => "password-read-error",
            Self::PasswordRequired => "password-required",
            Self::RebuildError => "rebuild-error",
            Self::RepairError => "repair-error",
            Self::ResumeEmptyCommand => "resume-empty-command",
            Self::ResumeExecFailed => "resume-exec-failed",
            Self::RetainedPublishBackup => "retained_publish_backup",
            Self::Search => "search",
            Self::SemanticBackfill => "semantic-backfill",
            Self::SemanticManifest => "semantic-manifest",
            Self::SemanticUnavailable => "semantic-unavailable",
            Self::SerializeMessage => "serialize-message",
            Self::SessionFileUnreadable => "session-file-unreadable",
            Self::SessionIdNotFound => "session-id-not-found",
            Self::SessionNotFound => "session-not-found",
            Self::SessionParse => "session-parse",
            Self::SessionsFrom => "sessions-from",
            Self::Setup => "setup",
            Self::Source => "source",
            Self::Ssh => "ssh",
            Self::Storage => "storage",
            Self::StorageFingerprint => "storage-fingerprint",
            Self::Timeout => "timeout",
            Self::Tui => "tui",
            Self::TuiHeadlessOnce => "tui-headless-once",
            Self::TuiResetState => "tui-reset-state",
            Self::Unknown => "unknown",
            Self::UnknownAgent => "unknown-agent",
            Self::UpdateCheck => "update-check",
            Self::Usage => "usage",
            Self::WriteFailed => "write-failed",
        }
    }

    /// Reverse lookup: parse a wire-format kind string back into the
    /// typed enum. Returns `None` on unknown kinds. Used by JSON-mode
    /// deserialization paths that need to branch on `err.kind` and by
    /// the golden test that asserts every variant round-trips.
    pub fn from_kind_str(kind: &str) -> Option<Self> {
        Some(match kind {
            "ambiguous-source" => Self::AmbiguousSource,
            "archive-analytics-rebuild" => Self::ArchiveAnalyticsRebuild,
            "archive-count" => Self::ArchiveCount,
            "archive-daily-stats-rebuild" => Self::ArchiveDailyStatsRebuild,
            "archive-fts-rebuild" => Self::ArchiveFtsRebuild,
            "archive-purge" => Self::ArchivePurge,
            "archive-token-daily-stats-rebuild" => Self::ArchiveTokenDailyStatsRebuild,
            "config" => Self::Config,
            "cursor-decode" => Self::CursorDecode,
            "cursor-parse" => Self::CursorParse,
            "daemon" => Self::Daemon,
            "db-error" => Self::DbError,
            "db-open" => Self::DbOpen,
            "db-query" => Self::DbQuery,
            "doctor" => Self::Doctor,
            "download" => Self::Download,
            "embedder-unavailable" => Self::EmbedderUnavailable,
            "empty-file" => Self::EmptyFile,
            "empty-session" => Self::EmptySession,
            "encode-json" => Self::EncodeJson,
            "export-failed" => Self::ExportFailed,
            "failed_seed_bundle_file" => Self::FailedSeedBundleFile,
            "file-create" => Self::FileCreate,
            "file-not-found" => Self::FileNotFound,
            "file-open" => Self::FileOpen,
            "file-read" => Self::FileRead,
            "file-write" => Self::FileWrite,
            "health" => Self::Health,
            "idempotency-mismatch" => Self::IdempotencyMismatch,
            "index" => Self::Index,
            "index-busy" => Self::IndexBusy,
            "index-missing" => Self::IndexMissing,
            "indexed-session-required" => Self::IndexedSessionRequired,
            "invalid-agent" => Self::InvalidAgent,
            "invalid-filename" => Self::InvalidFilename,
            "invalid-line" => Self::InvalidLine,
            "io" => Self::Io,
            "io-error" => Self::IoError,
            "lexical-rebuild" => Self::LexicalRebuild,
            "lexical_generation" => Self::LexicalGeneration,
            "lexical_shard" => Self::LexicalShard,
            "line-not-found" => Self::LineNotFound,
            "line-out-of-range" => Self::LineOutOfRange,
            "local" => Self::Local,
            "mapping" => Self::Mapping,
            "missing-db" => Self::MissingDb,
            "missing-index" => Self::MissingIndex,
            "model" => Self::Model,
            "not-found" => Self::NotFound,
            "open-index" => Self::OpenIndex,
            "opencode-parse" => Self::OpencodeParse,
            "opencode-sqlite-parse" => Self::OpencodeSqliteParse,
            "output-not-writable" => Self::OutputNotWritable,
            "pack-empty-query" => Self::PackEmptyQuery,
            "pack-invalid-field" => Self::PackInvalidField,
            "pack-invalid-limit" => Self::PackInvalidLimit,
            "pack-no-evidence" => Self::PackNoEvidence,
            "pack-unsupported-format" => Self::PackUnsupportedFormat,
            "pages" => Self::Pages,
            "parse-error" => Self::ParseError,
            "password-read-error" => Self::PasswordReadError,
            "password-required" => Self::PasswordRequired,
            "rebuild-error" => Self::RebuildError,
            "repair-error" => Self::RepairError,
            "resume-empty-command" => Self::ResumeEmptyCommand,
            "resume-exec-failed" => Self::ResumeExecFailed,
            "retained_publish_backup" => Self::RetainedPublishBackup,
            "search" => Self::Search,
            "semantic-backfill" => Self::SemanticBackfill,
            "semantic-manifest" => Self::SemanticManifest,
            "semantic-unavailable" => Self::SemanticUnavailable,
            "serialize-message" => Self::SerializeMessage,
            "session-file-unreadable" => Self::SessionFileUnreadable,
            "session-id-not-found" => Self::SessionIdNotFound,
            "session-not-found" => Self::SessionNotFound,
            "session-parse" => Self::SessionParse,
            "sessions-from" => Self::SessionsFrom,
            "setup" => Self::Setup,
            "source" => Self::Source,
            "ssh" => Self::Ssh,
            "storage" => Self::Storage,
            "storage-fingerprint" => Self::StorageFingerprint,
            "timeout" => Self::Timeout,
            "tui" => Self::Tui,
            "tui-headless-once" => Self::TuiHeadlessOnce,
            "tui-reset-state" => Self::TuiResetState,
            "unknown" => Self::Unknown,
            "unknown-agent" => Self::UnknownAgent,
            "update-check" => Self::UpdateCheck,
            "usage" => Self::Usage,
            "write-failed" => Self::WriteFailed,
            _ => return None,
        })
    }

    /// Returns every variant in declaration order. Used by the
    /// golden test to assert every variant has both a `kind_str()`
    /// arm AND a `from_kind_str()` arm.
    pub fn all_variants() -> &'static [Self] {
        &[
            Self::AmbiguousSource,
            Self::ArchiveAnalyticsRebuild,
            Self::ArchiveCount,
            Self::ArchiveDailyStatsRebuild,
            Self::ArchiveFtsRebuild,
            Self::ArchivePurge,
            Self::ArchiveTokenDailyStatsRebuild,
            Self::Config,
            Self::CursorDecode,
            Self::CursorParse,
            Self::Daemon,
            Self::DbError,
            Self::DbOpen,
            Self::DbQuery,
            Self::Doctor,
            Self::Download,
            Self::EmbedderUnavailable,
            Self::EmptyFile,
            Self::EmptySession,
            Self::EncodeJson,
            Self::ExportFailed,
            Self::FailedSeedBundleFile,
            Self::FileCreate,
            Self::FileNotFound,
            Self::FileOpen,
            Self::FileRead,
            Self::FileWrite,
            Self::Health,
            Self::IdempotencyMismatch,
            Self::Index,
            Self::IndexBusy,
            Self::IndexMissing,
            Self::IndexedSessionRequired,
            Self::InvalidAgent,
            Self::InvalidFilename,
            Self::InvalidLine,
            Self::Io,
            Self::IoError,
            Self::LexicalRebuild,
            Self::LexicalGeneration,
            Self::LexicalShard,
            Self::LineNotFound,
            Self::LineOutOfRange,
            Self::Local,
            Self::Mapping,
            Self::MissingDb,
            Self::MissingIndex,
            Self::Model,
            Self::NotFound,
            Self::OpenIndex,
            Self::OpencodeParse,
            Self::OpencodeSqliteParse,
            Self::OutputNotWritable,
            Self::PackEmptyQuery,
            Self::PackInvalidField,
            Self::PackInvalidLimit,
            Self::PackNoEvidence,
            Self::PackUnsupportedFormat,
            Self::Pages,
            Self::ParseError,
            Self::PasswordReadError,
            Self::PasswordRequired,
            Self::RebuildError,
            Self::RepairError,
            Self::ResumeEmptyCommand,
            Self::ResumeExecFailed,
            Self::RetainedPublishBackup,
            Self::Search,
            Self::SemanticBackfill,
            Self::SemanticManifest,
            Self::SemanticUnavailable,
            Self::SerializeMessage,
            Self::SessionFileUnreadable,
            Self::SessionIdNotFound,
            Self::SessionNotFound,
            Self::SessionParse,
            Self::SessionsFrom,
            Self::Setup,
            Self::Source,
            Self::Ssh,
            Self::Storage,
            Self::StorageFingerprint,
            Self::Timeout,
            Self::Tui,
            Self::TuiHeadlessOnce,
            Self::TuiResetState,
            Self::Unknown,
            Self::UnknownAgent,
            Self::UpdateCheck,
            Self::Usage,
            Self::WriteFailed,
        ]
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::collections::HashSet;

    /// `coding_agent_session_search-dxnmb` golden gate: every variant
    /// in `all_variants()` must round-trip through `kind_str()` →
    /// `from_kind_str()` and yield the same variant. A new variant
    /// added without registering it in both arms fails this gate.
    #[test]
    fn every_error_kind_round_trips_through_kind_str() {
        for variant in ErrorKind::all_variants() {
            let kind = variant.kind_str();
            let parsed = ErrorKind::from_kind_str(kind).unwrap_or_else(|| {
                panic!(
                    "ErrorKind::{:?}.kind_str() = {:?} but from_kind_str returned None — \
                     missing from_kind_str arm",
                    variant, kind
                )
            });
            assert_eq!(
                parsed, *variant,
                "round-trip mismatch: {:?}.kind_str() → {:?} → {:?}",
                variant, kind, parsed
            );
        }
    }

    /// All wire strings must be unique. A regression that mapped two
    /// variants to the same kind_str() (e.g. the historical "db_error"
    /// vs "db-error" duplicate from bead al19b) trips this gate.
    #[test]
    fn every_kind_str_is_unique() {
        let mut seen: HashSet<&'static str> = HashSet::new();
        for variant in ErrorKind::all_variants() {
            let kind = variant.kind_str();
            assert!(
                seen.insert(kind),
                "duplicate kind_str detected: {:?} maps to {:?} which was already \
                 registered by an earlier variant",
                variant,
                kind
            );
        }
    }

    /// The vocabulary covers every kind currently emitted by
    /// src/lib.rs at landing time (audited via
    /// `grep -oE 'kind: \"[a-z_-]+\"' src/lib.rs | sort -u`). A
    /// regression that added a new kind to lib.rs without adding it
    /// here would be invisible until a future enum migration site
    /// hit a missing variant; pinning the count here surfaces the
    /// drift immediately at CI time.
    #[test]
    fn variant_count_matches_audited_lib_rs_kind_literals() {
        // 91 unique kinds at landing time (commit before the pack
        // landed). If lib.rs grows a new kind, bump this count AND
        // add the variant + arms above.
        const AUDITED_KIND_COUNT: usize = 91;
        assert_eq!(
            ErrorKind::all_variants().len(),
            AUDITED_KIND_COUNT,
            "ErrorKind variant count drifted from the audited lib.rs literal set; \
             re-run `grep -oE 'kind: \"[a-z_-]+\"' src/lib.rs | sort -u | wc -l` and \
             update the constant + add the missing variant"
        );
    }

    /// Pin the four legacy snake_case stragglers explicitly so a
    /// future "rename to kebab-case" cleanup slice has a single place
    /// to flip the contract. Pinning them here also surfaces an
    /// accidental flip-back from kebab-case to snake_case.
    #[test]
    fn snake_case_stragglers_preserve_legacy_wire_format() {
        assert_eq!(
            ErrorKind::FailedSeedBundleFile.kind_str(),
            "failed_seed_bundle_file"
        );
        assert_eq!(
            ErrorKind::LexicalGeneration.kind_str(),
            "lexical_generation"
        );
        assert_eq!(ErrorKind::LexicalShard.kind_str(), "lexical_shard");
        assert_eq!(
            ErrorKind::RetainedPublishBackup.kind_str(),
            "retained_publish_backup"
        );
    }

    /// Unknown kinds return None (not a default Unknown variant);
    /// callers must explicitly handle the parse failure.
    #[test]
    fn from_kind_str_returns_none_for_unknown_inputs() {
        assert_eq!(ErrorKind::from_kind_str(""), None);
        assert_eq!(ErrorKind::from_kind_str("not-a-real-kind"), None);
        // Casing matters: the wire format is exact.
        assert_eq!(ErrorKind::from_kind_str("DB-ERROR"), None);
        assert_eq!(ErrorKind::from_kind_str("Db-Error"), None);
        // Sanity: the well-known "unknown" kind IS distinct from
        // "not-a-real-kind" and parses cleanly.
        assert_eq!(
            ErrorKind::from_kind_str("unknown"),
            Some(ErrorKind::Unknown)
        );
    }

    /// Serde round-trip via JSON works (callers can use the enum as
    /// a serde-serializable field). Default rename uses CamelCase
    /// for serde, but downstream consumers that need the wire-format
    /// kebab-case string call `kind_str()` directly. This test pins
    /// that the enum is at least serializable / deserializable so
    /// callers wanting the typed form (e.g. error envelopes for
    /// telemetry sinks) can opt in.
    #[test]
    fn error_kind_is_serde_compatible() {
        let json = serde_json::to_string(&ErrorKind::DbError).expect("serialize");
        let parsed: ErrorKind = serde_json::from_str(&json).expect("deserialize");
        assert_eq!(parsed, ErrorKind::DbError);
    }
}