claude_profile 1.0.0

Claude Code account credential management and token status
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
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
//! Unit tests for the adapter and output modules.
//!
//! Covers matrix IDs A-01..A-33 (adapter), O-01..O-19 (output), D-01..D-12 (`format_duration`).
//! All tests call library functions directly — no binary invocation.

// ── Adapter tests ─────────────────────────────────────────────────────────────

#[ cfg( feature = "enabled" ) ]
mod adapter
{
  use claude_profile::adapter::argv_to_unilang_tokens;

  fn s( vals : &[ &str ] ) -> Vec< String >
  {
    vals.iter().map( std::string::ToString::to_string ).collect()
  }

  // A-01: empty argv → help
  #[ test ]
  fn adapter_empty_argv_returns_help()
  {
    let ( tokens, needs_help ) = argv_to_unilang_tokens( &[] ).unwrap();
    assert_eq!( tokens, vec![ ".help" ] );
    assert!( needs_help );
  }

  // A-02: single command passes through
  #[ test ]
  fn adapter_single_command()
  {
    let ( tokens, needs_help ) = argv_to_unilang_tokens( &s( &[ ".account.list" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".account.list" ] );
    assert!( !needs_help );
  }

  // A-03: dot → help
  #[ test ]
  fn adapter_dot_returns_help()
  {
    let ( tokens, needs_help ) = argv_to_unilang_tokens( &s( &[ "." ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".help" ] );
    assert!( needs_help );
  }

  // A-04: --help → help
  #[ test ]
  fn adapter_double_dash_help()
  {
    let ( tokens, needs_help ) = argv_to_unilang_tokens( &s( &[ "--help" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".help" ] );
    assert!( needs_help );
  }

  // A-05: -h → help
  #[ test ]
  fn adapter_dash_h_help()
  {
    let ( tokens, needs_help ) = argv_to_unilang_tokens( &s( &[ "-h" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".help" ] );
    assert!( needs_help );
  }

  // A-06: -verbose → error
  #[ test ]
  fn adapter_rejects_unknown_flag()
  {
    let err = argv_to_unilang_tokens( &s( &[ "-verbose" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "unexpected flag" ), "got: {msg}" );
  }

  // A-07: key::value as first arg → error
  #[ test ]
  fn adapter_rejects_param_as_command()
  {
    let err = argv_to_unilang_tokens( &s( &[ "key::value" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "expected command name" ), "got: {msg}" );
  }

  // A-08: v::0 → verbosity::0
  #[ test ]
  fn adapter_verbosity_alias_0()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "v::0" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "verbosity::0" ] );
  }

  // A-09: v::1 → verbosity::1
  #[ test ]
  fn adapter_verbosity_alias_1()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "v::1" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "verbosity::1" ] );
  }

  // A-10: v::2 → verbosity::2
  #[ test ]
  fn adapter_verbosity_alias_2()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "v::2" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "verbosity::2" ] );
  }

  // A-11: v::3 → error (out of range)
  #[ test ]
  fn adapter_verbosity_out_of_range()
  {
    let err = argv_to_unilang_tokens( &s( &[ ".cmd", "v::3" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "out of range" ), "got: {msg}" );
  }

  // A-12: v::abc → error (not numeric)
  #[ test ]
  fn adapter_verbosity_non_numeric()
  {
    let err = argv_to_unilang_tokens( &s( &[ ".cmd", "v::abc" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "verbosity" ), "got: {msg}" );
  }

  // A-13: verbosity::1 (canonical key)
  #[ test ]
  fn adapter_verbosity_canonical_key()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "verbosity::1" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "verbosity::1" ] );
  }

  // A-14: dry::true → dry::1
  #[ test ]
  fn adapter_dry_true_normalizes()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "dry::true" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "dry::1" ] );
  }

  // A-15: dry::false → dry::0
  #[ test ]
  fn adapter_dry_false_normalizes()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "dry::false" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "dry::0" ] );
  }

  // A-16: dry::1 stays
  #[ test ]
  fn adapter_dry_1_passthrough()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "dry::1" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "dry::1" ] );
  }

  // A-17: dry::0 stays
  #[ test ]
  fn adapter_dry_0_passthrough()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "dry::0" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "dry::0" ] );
  }

  // A-18: dry::maybe → error
  #[ test ]
  fn adapter_dry_invalid_value()
  {
    let err = argv_to_unilang_tokens( &s( &[ ".cmd", "dry::maybe" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "invalid value for dry" ), "got: {msg}" );
  }

  // A-19: bareword → error (no ::)
  #[ test ]
  fn adapter_missing_separator()
  {
    let err = argv_to_unilang_tokens( &s( &[ ".cmd", "bareword" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "param::value" ), "got: {msg}" );
  }

  // A-20: --verbose after command → error
  #[ test ]
  fn adapter_rejects_flag_in_params()
  {
    let err = argv_to_unilang_tokens( &s( &[ ".cmd", "--verbose" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "unexpected flag" ), "got: {msg}" );
  }

  // A-21: duplicate → last wins
  #[ test ]
  fn adapter_duplicate_last_wins()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "k::v1", "k::v2" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "k::v2" ] );
  }

  // A-22: alias then canonical → last wins
  #[ test ]
  fn adapter_alias_then_canonical_dedup()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "v::0", "verbosity::2" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "verbosity::2" ] );
  }

  // A-23: key::val::extra → split at first ::
  #[ test ]
  fn adapter_multi_separator_split()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "key::val::extra" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "key::val::extra" ] );
  }

  // A-24: key:: → empty value allowed
  #[ test ]
  fn adapter_empty_value_allowed()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "key::" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "key::" ] );
  }

  // A-25: v::-1 → error (u8 parse)
  #[ test ]
  fn adapter_verbosity_negative()
  {
    let err = argv_to_unilang_tokens( &s( &[ ".cmd", "v::-1" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "verbosity" ), "got: {msg}" );
  }

  // A-26: v::2.5 → error
  #[ test ]
  fn adapter_verbosity_decimal()
  {
    let err = argv_to_unilang_tokens( &s( &[ ".cmd", "v::2.5" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "verbosity" ), "got: {msg}" );
  }

  // A-27: v:: → error (empty)
  #[ test ]
  fn adapter_verbosity_empty()
  {
    let err = argv_to_unilang_tokens( &s( &[ ".cmd", "v::" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "verbosity" ), "got: {msg}" );
  }

  // A-28: multiple params assembled
  #[ test ]
  fn adapter_multiple_params()
  {
    let ( tokens, _ ) = argv_to_unilang_tokens( &s( &[ ".cmd", "v::1", "format::json", "dry::1" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".cmd", "verbosity::1", "format::json", "dry::1" ] );
  }

  // A-29: `.help` as sole arg → tokens=[".help"], needs_help=true
  //
  // Step 1b pre-scan matches `.help` anywhere in argv (including as the
  // sole argument) and returns needs_help=true. Callers discard this flag
  // (`_needs_help`), so the CLI output is identical regardless of its value.
  #[ test ]
  fn adapter_help_as_command()
  {
    let ( tokens, needs_help ) = argv_to_unilang_tokens( &s( &[ ".help" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".help" ] );
    assert!( needs_help );
  }

  // A-30: v::256 → error (u8 overflow)
  #[ test ]
  fn adapter_verbosity_overflow()
  {
    let err = argv_to_unilang_tokens( &s( &[ ".cmd", "v::256" ] ) ).unwrap_err();
    let msg = format!( "{err}" );
    assert!( msg.contains( "verbosity" ), "got: {msg}" );
  }

  // A-31: `.help` in second position → routes to `.help` (N→P)
  //
  // ## Root Cause
  //
  // `claude_profile`'s adapter only checked `--help`/`-h` as argv[0].  It had
  // no pre-scan for `.help` anywhere in argv, so `clp .account.list .help`
  // was parsed as a bare token after the command name and rejected with
  // "expected param::value syntax, got: '.help'" instead of showing help.
  //
  // ## Why Not Caught
  //
  // `claude_version`'s adapter gained a `.help`-anywhere scan (Step 1b) for a
  // prior bug fix but that fix was never propagated to `claude_profile`.  No
  // test exercised `.help` in a non-first position against `clp`.
  //
  // ## Fix Applied
  //
  // Added Step 1b to `claude_profile::adapter::argv_to_unilang_tokens`: a
  // pre-scan over all argv for `".help"` or `"help"`, routing either form to
  // `".help"` before any other processing.
  //
  // ## Prevention
  //
  // A-31 and A-32 lock the new behaviour.  Any future regression (e.g. removing
  // Step 1b while refactoring the adapter) will be caught immediately.
  //
  // ## Pitfall
  //
  // Adding `--help`/`-h` handling does NOT substitute for the pre-scan.
  // `argv[0]` checks are too narrow: users type `clp .account.list .help` or
  // `clp .account.list help` — the help token is not in position 0.
  #[ test ]
  fn adapter_dot_help_in_second_position()
  {
    // A-31: `.help` after command name must route to `.help`, not error.
    let ( tokens, needs_help ) = argv_to_unilang_tokens( &s( &[ ".account.list", ".help" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".help" ] );
    assert!( needs_help );
  }

  // A-32: bare `help` in second position → routes to `.help` (N→P)
  //
  // Same root cause as A-31; bare `help` (no dot) is the form advertised in
  // the unilang help footer ("Use '<command> help'…").
  #[ test ]
  fn adapter_bare_help_in_second_position()
  {
    let ( tokens, needs_help ) = argv_to_unilang_tokens( &s( &[ ".account.list", "help" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".help" ] );
    assert!( needs_help );
  }

  // A-33: bare `help` as sole argv → routes to `.help`
  #[ test ]
  fn adapter_bare_help_as_sole_arg()
  {
    let ( tokens, needs_help ) = argv_to_unilang_tokens( &s( &[ "help" ] ) ).unwrap();
    assert_eq!( tokens, vec![ ".help" ] );
    assert!( needs_help );
  }
}

// ── Output tests ──────────────────────────────────────────────────────────────

#[ cfg( feature = "enabled" ) ]
mod output
{
  use claude_profile::output::{ OutputFormat, OutputOptions, json_escape };
  use std::collections::HashMap;
  use unilang::data::CommandDefinition;
  use unilang::semantic::VerifiedCommand;
  use unilang::types::Value;

  fn make_cmd( args : Vec< ( &str, Value ) > ) -> VerifiedCommand
  {
    let mut arguments = HashMap::new();
    for ( k, v ) in args
    {
      arguments.insert( k.to_string(), v );
    }
    let definition = CommandDefinition::former()
      .name( ".test" )
      .description( "test command" )
      .end();
    VerifiedCommand { definition, arguments }
  }

  // O-01: format="text" → Text
  #[ test ]
  fn output_format_text()
  {
    let cmd = make_cmd( vec![ ( "format", Value::String( "text".to_string() ) ) ] );
    let opts = OutputOptions::from_cmd( &cmd ).unwrap();
    assert_eq!( opts.format, OutputFormat::Text );
  }

  // O-02: format="json" → Json
  #[ test ]
  fn output_format_json()
  {
    let cmd = make_cmd( vec![ ( "format", Value::String( "json".to_string() ) ) ] );
    let opts = OutputOptions::from_cmd( &cmd ).unwrap();
    assert_eq!( opts.format, OutputFormat::Json );
  }

  // O-03: format="xml" → error
  #[ test ]
  fn output_format_xml_rejected()
  {
    let cmd = make_cmd( vec![ ( "format", Value::String( "xml".to_string() ) ) ] );
    let err = OutputOptions::from_cmd( &cmd ).unwrap_err();
    assert!( err.message.contains( "unknown format" ), "got: {}", err.message );
  }

  // O-04: no format → Text (default)
  #[ test ]
  fn output_format_default()
  {
    let cmd = make_cmd( vec![] );
    let opts = OutputOptions::from_cmd( &cmd ).unwrap();
    assert_eq!( opts.format, OutputFormat::Text );
  }

  // O-05: format="JSON" (uppercase) → error
  #[ test ]
  fn output_format_case_json_rejected()
  {
    let cmd = make_cmd( vec![ ( "format", Value::String( "JSON".to_string() ) ) ] );
    let err = OutputOptions::from_cmd( &cmd ).unwrap_err();
    assert!( err.message.contains( "unknown format" ), "got: {}", err.message );
  }

  // O-06: format="Text" (capitalized) → error
  #[ test ]
  fn output_format_case_text_rejected()
  {
    let cmd = make_cmd( vec![ ( "format", Value::String( "Text".to_string() ) ) ] );
    let err = OutputOptions::from_cmd( &cmd ).unwrap_err();
    assert!( err.message.contains( "unknown format" ), "got: {}", err.message );
  }

  // O-07: verbosity=0
  #[ test ]
  fn output_verbosity_0()
  {
    let cmd = make_cmd( vec![ ( "verbosity", Value::Integer( 0 ) ) ] );
    let opts = OutputOptions::from_cmd( &cmd ).unwrap();
    assert_eq!( opts.verbosity, 0 );
  }

  // O-08: verbosity=1
  #[ test ]
  fn output_verbosity_1()
  {
    let cmd = make_cmd( vec![ ( "verbosity", Value::Integer( 1 ) ) ] );
    let opts = OutputOptions::from_cmd( &cmd ).unwrap();
    assert_eq!( opts.verbosity, 1 );
  }

  // O-09: verbosity=2
  #[ test ]
  fn output_verbosity_2()
  {
    let cmd = make_cmd( vec![ ( "verbosity", Value::Integer( 2 ) ) ] );
    let opts = OutputOptions::from_cmd( &cmd ).unwrap();
    assert_eq!( opts.verbosity, 2 );
  }

  // O-10: no verbosity → default 1
  #[ test ]
  fn output_verbosity_default()
  {
    let cmd = make_cmd( vec![] );
    let opts = OutputOptions::from_cmd( &cmd ).unwrap();
    assert_eq!( opts.verbosity, 1 );
  }

  // O-11: json_escape plain
  #[ test ]
  fn json_escape_plain()
  {
    assert_eq!( json_escape( "hello" ), "hello" );
  }

  // O-12: json_escape quote
  #[ test ]
  fn json_escape_quote()
  {
    assert_eq!( json_escape( r#"he"lo"# ), r#"he\"lo"# );
  }

  // O-13: json_escape backslash
  #[ test ]
  fn json_escape_backslash()
  {
    assert_eq!( json_escape( "he\\lo" ), "he\\\\lo" );
  }

  // O-14: json_escape newline
  #[ test ]
  fn json_escape_newline()
  {
    assert_eq!( json_escape( "a\nb" ), "a\\nb" );
  }

  // O-15: json_escape tab
  #[ test ]
  fn json_escape_tab()
  {
    assert_eq!( json_escape( "a\tb" ), "a\\tb" );
  }

  // O-16: json_escape CR
  #[ test ]
  fn json_escape_cr()
  {
    assert_eq!( json_escape( "a\rb" ), "a\\rb" );
  }

  // O-17: json_escape empty
  #[ test ]
  fn json_escape_empty()
  {
    assert_eq!( json_escape( "" ), "" );
  }

  // O-18: json_escape mixed
  #[ test ]
  fn json_escape_mixed()
  {
    assert_eq!( json_escape( "a\"b\\c\nd" ), "a\\\"b\\\\c\\nd" );
  }

  // O-19: json_escape unicode passthrough
  #[ test ]
  fn json_escape_unicode()
  {
    assert_eq!( json_escape( "cafe\u{0301}" ), "cafe\u{0301}" );
  }
}

// ── format_duration_secs tests ────────────────────────────────────────────────

/// Unit tests for `format_duration_secs`: human-readable duration from seconds.
///
/// Corner cases covered:
/// - Zero and sub-minute values (no days/hours/mins components)
/// - Boundary at exactly 60s (first minute shows)
/// - Boundary at exactly 3600s (first hour, no minutes shown)
/// - Mixed components: hours+minutes, days+hours, days+minutes
/// - `u64::MAX` does not panic (overflow safety)
#[ cfg( feature = "enabled" ) ]
mod format_duration
{
  use claude_profile::output::format_duration_secs;

  // D-01: 0 seconds → "0m"
  #[ test ]
  fn dur_zero_seconds_shows_0m()
  {
    assert_eq!( format_duration_secs( 0 ), "0m" );
  }

  // D-02: 1 second (sub-minute) → "0m"
  #[ test ]
  fn dur_sub_minute_rounds_to_0m()
  {
    assert_eq!( format_duration_secs( 1 ), "0m" );
  }

  // D-03: 59 seconds → "0m"
  #[ test ]
  fn dur_59s_rounds_to_0m()
  {
    assert_eq!( format_duration_secs( 59 ), "0m" );
  }

  // D-04: exactly 60 seconds → "1m"
  #[ test ]
  fn dur_60s_shows_1m()
  {
    assert_eq!( format_duration_secs( 60 ), "1m" );
  }

  // D-05: 3599 seconds → "59m"
  #[ test ]
  fn dur_3599s_shows_59m()
  {
    assert_eq!( format_duration_secs( 3599 ), "59m" );
  }

  // D-06: exactly 3600 seconds (1 hour, 0 minutes) → "1h"
  // Pitfall: the condition `mins > 0 || parts.is_empty()` means minutes are
  // suppressed when hours or days already appear AND mins == 0.
  #[ test ]
  fn dur_3600s_shows_1h_no_minutes()
  {
    assert_eq!( format_duration_secs( 3600 ), "1h" );
  }

  // D-07: 3660 seconds (1h 1m) → "1h 1m"
  #[ test ]
  fn dur_3660s_shows_1h_1m()
  {
    assert_eq!( format_duration_secs( 3660 ), "1h 1m" );
  }

  // D-08: exactly 86400 seconds (1 day, 0 hours, 0 mins) → "1d"
  #[ test ]
  fn dur_86400s_shows_1d_no_hours()
  {
    assert_eq!( format_duration_secs( 86400 ), "1d" );
  }

  // D-09: 86460 seconds (1d 1m, no hours) → "1d 1m"
  #[ test ]
  fn dur_86460s_shows_1d_1m()
  {
    assert_eq!( format_duration_secs( 86460 ), "1d 1m" );
  }

  // D-10: 90000 seconds (1d 1h, 0 mins) → "1d 1h"
  #[ test ]
  fn dur_90000s_shows_1d_1h_no_minutes()
  {
    assert_eq!( format_duration_secs( 90000 ), "1d 1h" );
  }

  // D-11: 90060 seconds (1d 1h 1m) → "1d 1h 1m"
  #[ test ]
  fn dur_90060s_shows_1d_1h_1m()
  {
    assert_eq!( format_duration_secs( 90060 ), "1d 1h 1m" );
  }

  // D-12: u64::MAX — must not panic (overflow safety)
  #[ test ]
  fn dur_max_u64_does_not_panic()
  {
    let _ = format_duration_secs( u64::MAX );
  }
}