apr-cli 0.64.0

CLI tool for APR model inspection, debugging, and operations
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
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
use super::*;
use std::fs;

// =========================================================================
// TuneMethod tests
// =========================================================================

#[test]
fn test_tune_method_parse() {
    assert!(matches!(
        "lora".parse::<TuneMethod>().expect("parse::<TuneMethod>"),
        TuneMethod::LoRA
    ));
    assert!(matches!(
        "qlora".parse::<TuneMethod>().expect("parse::<TuneMethod>"),
        TuneMethod::QLoRA
    ));
    assert!(matches!(
        "auto".parse::<TuneMethod>().expect("parse::<TuneMethod>"),
        TuneMethod::Auto
    ));
    assert!(matches!(
        "full".parse::<TuneMethod>().expect("parse::<TuneMethod>"),
        TuneMethod::Full
    ));
}

#[test]
fn test_tune_method_parse_case_insensitive() {
    assert!(matches!(
        "LORA".parse::<TuneMethod>().expect("parse::<TuneMethod>"),
        TuneMethod::LoRA
    ));
    assert!(matches!(
        "LoRa".parse::<TuneMethod>().expect("parse::<TuneMethod>"),
        TuneMethod::LoRA
    ));
    assert!(matches!(
        "QLORA".parse::<TuneMethod>().expect("parse::<TuneMethod>"),
        TuneMethod::QLoRA
    ));
}

#[test]
fn test_tune_method_parse_invalid() {
    let result: Result<TuneMethod, _> = "invalid".parse();
    assert!(result.is_err());
    assert!(result.unwrap_err().contains("Unknown method"));
}

#[test]
fn test_tune_method_default() {
    let method = TuneMethod::default();
    assert!(matches!(method, TuneMethod::Auto));
}

#[test]
fn test_tune_method_debug() {
    assert_eq!(format!("{:?}", TuneMethod::Auto), "Auto");
    assert_eq!(format!("{:?}", TuneMethod::Full), "Full");
    assert_eq!(format!("{:?}", TuneMethod::LoRA), "LoRA");
    assert_eq!(format!("{:?}", TuneMethod::QLoRA), "QLoRA");
}

#[test]
fn test_tune_method_clone() {
    let method = TuneMethod::LoRA;
    let cloned = method;
    assert!(matches!(cloned, TuneMethod::LoRA));
}

#[test]
fn test_tune_method_copy() {
    let method = TuneMethod::QLoRA;
    let copied: TuneMethod = method;
    assert!(matches!(method, TuneMethod::QLoRA));
    assert!(matches!(copied, TuneMethod::QLoRA));
}

#[test]
fn test_tune_method_into_entrenar_method() {
    let auto: Method = TuneMethod::Auto.into();
    assert!(matches!(auto, Method::Auto));

    let full: Method = TuneMethod::Full.into();
    assert!(matches!(full, Method::Full));

    let lora: Method = TuneMethod::LoRA.into();
    assert!(matches!(lora, Method::LoRA));

    let qlora: Method = TuneMethod::QLoRA.into();
    assert!(matches!(qlora, Method::QLoRA));
}

// =========================================================================
// parse_model_size tests
// =========================================================================

#[test]
fn test_parse_model_size() {
    assert_eq!(parse_model_size("7B").expect("value"), 7_000_000_000);
    assert_eq!(parse_model_size("1.5B").expect("5B'"), 1_500_000_000);
    assert_eq!(parse_model_size("70B").expect("value"), 70_000_000_000);
    assert_eq!(parse_model_size("500M").expect("value"), 500_000_000);
}

#[test]
fn test_parse_model_size_case_insensitive() {
    assert_eq!(parse_model_size("7b").expect("value"), 7_000_000_000);
    assert_eq!(parse_model_size("1.5b").expect("5b'"), 1_500_000_000);
}

#[test]
fn test_parse_model_size_invalid() {
    assert!(parse_model_size("7").is_err());
    assert!(parse_model_size("7GB").is_err());
    assert!(parse_model_size("abc").is_err());
}

#[test]
fn test_parse_model_size_decimal() {
    assert_eq!(parse_model_size("0.5B").expect("5B'"), 500_000_000);
    assert_eq!(parse_model_size("2.7B").expect("7B'"), 2_700_000_000);
    assert_eq!(parse_model_size("13.5B").expect("5B'"), 13_500_000_000);
}

#[test]
fn test_parse_model_size_millions() {
    assert_eq!(parse_model_size("125M").expect("value"), 125_000_000);
    assert_eq!(parse_model_size("350M").expect("value"), 350_000_000);
    assert_eq!(parse_model_size("1000M").expect("value"), 1_000_000_000);
}

#[test]
fn test_parse_model_size_large() {
    assert_eq!(parse_model_size("180B").expect("value"), 180_000_000_000);
    assert_eq!(parse_model_size("405B").expect("value"), 405_000_000_000);
}

#[test]
fn test_parse_model_size_invalid_number() {
    let result = parse_model_size("abcB");
    assert!(result.is_err());
    match result {
        Err(CliError::ValidationFailed(msg)) => {
            assert!(msg.contains("Invalid number"));
        }
        other => panic!("Expected ValidationFailed, got {:?}", other),
    }
}

// =========================================================================
// format_params tests
// =========================================================================

#[test]
fn test_format_params() {
    assert_eq!(format_params(7_000_000_000), "7.0B");
    assert_eq!(format_params(1_500_000_000), "1.5B");
    assert_eq!(format_params(500_000_000), "500.0M");
}

#[test]
fn test_format_params_small() {
    assert_eq!(format_params(100_000), "100000");
    assert_eq!(format_params(999_999), "999999");
}

#[test]
fn test_format_params_millions() {
    assert_eq!(format_params(1_000_000), "1.0M");
    assert_eq!(format_params(125_000_000), "125.0M");
    assert_eq!(format_params(999_999_999), "1000.0M");
}

#[test]
fn test_format_params_billions() {
    assert_eq!(format_params(1_000_000_000), "1.0B");
    assert_eq!(format_params(70_000_000_000), "70.0B");
    assert_eq!(format_params(405_000_000_000), "405.0B");
}

// =========================================================================
// read_params_from_file — falsifiers for #2570
//
// These replace two tests that ASSERTED THE DEFECT. `test_estimate_params_from_file`
// wrote a megabyte of zeros to `test_model.gguf` and demanded the answer be
// exactly 2,000,000 parameters; `test_estimate_params_from_file_not_found` was
// the only case that could ever fail, and it only checked that a MISSING file
// errored. A file of a million zero bytes is not a model, and a green suite that
// requires it to be reported as a 2M-parameter one is how `apr tune` came to
// print "Model parameters: 982,800,128" for a model `apr inspect` reads as
// 630,167,424 out of the same bytes.
// =========================================================================

/// A GGUF whose true parameter count is deliberately nowhere near either of the
/// old size heuristics: 2048 F32 params in a file of ~8.3 KB.
fn tiny_gguf_bytes() -> Vec<u8> {
    use aprender::format::gguf::{export_tensors_to_gguf, GgmlType, GgufTensor, GgufValue};

    let data: Vec<u8> = (0..2048u32)
        .flat_map(|i| (i as f32 + 1.0).to_le_bytes())
        .collect();
    let tensor = GgufTensor {
        name: "test.weight".to_string(),
        shape: vec![64, 32],
        dtype: GgmlType::F32,
        data,
    };
    let metadata = vec![(
        "general.architecture".to_string(),
        GgufValue::String("test".to_string()),
    )];
    let mut bytes = Vec::new();
    export_tensors_to_gguf(&mut bytes, &[tensor], &metadata).expect("export GGUF");
    bytes
}

#[test]
fn read_params_from_file_reads_the_shapes_not_the_file_size() {
    let dir = std::env::temp_dir().join("apr_tune_2570_real");
    let _ = fs::create_dir_all(&dir);
    let path = dir.join("model.gguf");
    let bytes = tiny_gguf_bytes();
    let file_len = bytes.len() as u64;
    fs::write(&path, &bytes).expect("write fixture");

    let params = read_params_from_file(&path).expect("a valid GGUF must yield its param count");

    // 64 x 32 tensor shape, read out of the header.
    assert_eq!(params, 2048, "must sum the declared tensor shapes");
    // The two constants the old estimator used. Naming them here is the point:
    // if someone reintroduces a size heuristic, this fails and says which one.
    assert_ne!(
        params,
        file_len * 2,
        "must not be the .gguf heuristic (file_len {file_len} x 2)"
    );
    assert_ne!(
        params,
        file_len / 2,
        "must not be the fp16 heuristic (file_len {file_len} / 2)"
    );

    let _ = fs::remove_dir_all(&dir);
}

/// The headline case from #2570: a zero-byte file was reported as
/// "Model parameters: 0" that "fits in 16.0 GB VRAM", exit 0.
#[test]
fn read_params_from_file_refuses_an_empty_file() {
    let dir = std::env::temp_dir().join("apr_tune_2570_empty");
    let _ = fs::create_dir_all(&dir);
    let path = dir.join("empty.apr");
    fs::write(&path, b"").expect("write fixture");

    let err = read_params_from_file(&path)
        .expect_err("an empty file must not be planned as a model that fits");
    match err {
        CliError::ValidationFailed(msg) | CliError::InvalidFormat(msg) => {
            assert!(
                msg.contains("--model <SIZE>"),
                "the refusal must point at the flag that plans WITHOUT a model file, got: {msg}"
            );
        }
        other => panic!("expected a validation failure, got {other:?}"),
    }

    let _ = fs::remove_dir_all(&dir);
}

/// A megabyte of zeros named `.gguf` — the exact fixture the deleted test
/// demanded be reported as 2,000,000 parameters.
#[test]
fn read_params_from_file_refuses_a_million_zero_bytes_named_gguf() {
    let dir = std::env::temp_dir().join("apr_tune_2570_zeros");
    let _ = fs::create_dir_all(&dir);
    let path = dir.join("test_model.gguf");
    fs::write(&path, vec![0u8; 1_000_000]).expect("write fixture");

    let err = read_params_from_file(&path)
        .expect_err("a megabyte of zeros is not a 2,000,000-parameter model");
    assert!(
        !format!("{err:?}").contains("2000000"),
        "must not report the old heuristic's answer: {err:?}"
    );

    let _ = fs::remove_dir_all(&dir);
}

/// A truncated GGUF reaches `apr tune` through the same `list_tensors` bounds
/// check added for #2569 — the two defects share one correct implementation.
#[test]
fn read_params_from_file_refuses_a_truncated_gguf() {
    let dir = std::env::temp_dir().join("apr_tune_2570_truncated");
    let _ = fs::create_dir_all(&dir);
    let path = dir.join("truncated.gguf");
    let bytes = tiny_gguf_bytes();
    // Keep the header and tensor info, drop the 8192-byte data section.
    fs::write(&path, &bytes[..bytes.len() - 8192]).expect("write fixture");

    let err = read_params_from_file(&path)
        .expect_err("apr tune must not plan a fine-tune from a truncated model");
    assert!(
        format!("{err:?}").contains("Truncated"),
        "the refusal must carry the reason, got: {err:?}"
    );

    let _ = fs::remove_dir_all(&dir);
}

/// A structurally VALID GGUF that declares zero tensors. It parses cleanly, so
/// the listing succeeds and the sum is 0 — the one path where the explicit
/// `params == 0` refusal is the only thing standing between the user and a
/// "Model parameters: 0 … fits in 16.0 GB VRAM" verdict.
#[test]
fn read_params_from_file_refuses_a_valid_gguf_with_no_tensors() {
    let dir = std::env::temp_dir().join("apr_tune_2570_no_tensors");
    let _ = fs::create_dir_all(&dir);
    let path = dir.join("empty.gguf");

    let mut bytes = b"GGUF".to_vec();
    bytes.extend_from_slice(&3u32.to_le_bytes()); // version
    bytes.extend_from_slice(&0u64.to_le_bytes()); // tensor_count = 0
    bytes.extend_from_slice(&0u64.to_le_bytes()); // metadata_kv_count = 0
    fs::write(&path, &bytes).expect("write fixture");

    // Precondition: the listing itself succeeds — this is not the #2569 path.
    let listing = aprender::format::tensors::list_tensors(
        &path,
        aprender::format::tensors::TensorListOptions::new(),
    )
    .expect("a zero-tensor GGUF is structurally valid and must list");
    assert_eq!(listing.tensor_count, 0);

    let err = read_params_from_file(&path)
        .expect_err("zero parameters is not a model to plan a fine-tune for");
    assert!(
        format!("{err:?}").contains("no tensor parameters"),
        "got: {err:?}"
    );

    let _ = fs::remove_dir_all(&dir);
}

#[test]
fn read_params_from_file_not_found() {
    let result = read_params_from_file(Path::new("/nonexistent/model.bin"));
    assert!(result.is_err());
    match result {
        Err(CliError::ValidationFailed(msg)) => {
            assert!(msg.contains("Cannot read tensor metadata"), "got: {msg}");
        }
        other => panic!("Expected ValidationFailed, got {:?}", other),
    }
}

// =========================================================================
// run() error cases tests
// =========================================================================

#[test]
fn test_run_no_model_or_size() {
    let result = run(
        None, // No model path
        TuneMethod::Auto,
        None,
        16.0,
        true,
        None, // No model size
        false,
        None,
        false,
    );

    assert!(result.is_err());
    match result {
        Err(CliError::ValidationFailed(msg)) => {
            assert!(msg.contains("Either --model or model path required"));
        }
        other => panic!("Expected ValidationFailed, got {:?}", other),
    }
}

#[test]
fn test_run_with_model_size() {
    let result = run(
        None,
        TuneMethod::LoRA,
        Some(8),
        24.0,
        true,
        Some("7B"),
        false,
        None,
        false,
    );

    assert!(result.is_ok());
}

#[test]
fn test_run_with_model_size_json_output() {
    let result = run(
        None,
        TuneMethod::QLoRA,
        Some(16),
        16.0,
        true,
        Some("1.5B"),
        false,
        None,
        true, // JSON output
    );

    assert!(result.is_ok());
}

#[test]
fn test_run_plan_only() {
    let result = run(
        None,
        TuneMethod::Auto,
        None,
        8.0,
        true, // plan_only
        Some("3B"),
        false,
        None,
        false,
    );

    assert!(result.is_ok());
}

#[test]
fn test_run_with_rank() {
    let result = run(
        None,
        TuneMethod::LoRA,
        Some(4), // rank
        16.0,
        true,
        Some("7B"),
        false,
        None,
        false,
    );

    assert!(result.is_ok());
}

#[test]
fn test_run_with_model_file() {
    let temp_dir = std::env::temp_dir().join("apr_tune_run_test");
    let _ = fs::create_dir_all(&temp_dir);

    // #2570: this fixture used to be 100 KB of ZEROS named `.gguf`, and the test
    // asserted `run(..).is_ok()` on it. That is precisely the defect — planning a
    // fine-tune for a file that contains no model — so the assertion locked it in.
    // A real (tiny) GGUF is what the success path is entitled to.
    let test_file = temp_dir.join("test_model.gguf");
    fs::write(&test_file, tiny_gguf_bytes()).expect("write fixture");

    let result = run(
        Some(&test_file),
        TuneMethod::QLoRA,
        None,
        8.0,
        true,
        None,
        false,
        None,
        false,
    );

    assert!(result.is_ok(), "a real GGUF must still plan: {result:?}");

    let _ = fs::remove_dir_all(&temp_dir);
}

/// The other half of the case above: the zero-filled file that used to pass.
#[test]
fn test_run_refuses_a_file_that_is_not_a_model() {
    let temp_dir = std::env::temp_dir().join("apr_tune_run_zeros");
    let _ = fs::create_dir_all(&temp_dir);

    let test_file = temp_dir.join("test_model.gguf");
    fs::write(&test_file, vec![0u8; 100_000]).expect("write fixture");

    let result = run(
        Some(&test_file),
        TuneMethod::QLoRA,
        None,
        8.0,
        true,
        None,
        false,
        None,
        false,
    );

    assert!(
        result.is_err(),
        "100 KB of zeros is not a model; apr tune must not plan for it"
    );

    let _ = fs::remove_dir_all(&temp_dir);
}

#[test]
fn test_run_model_file_not_found() {
    let result = run(
        Some(Path::new("/nonexistent/model.gguf")),
        TuneMethod::Auto,
        None,
        16.0,
        true,
        None,
        false,
        None,
        false,
    );

    assert!(result.is_err());
}

#[test]
fn test_run_invalid_model_size() {
    let result = run(
        None,
        TuneMethod::Auto,
        None,
        16.0,
        true,
        Some("invalid"), // Invalid size format
        false,
        None,
        false,
    );

    assert!(result.is_err());
}

// =========================================================================
// classify tune tests (SPEC-TUNE-2026-001)
// =========================================================================

#[test]
fn test_classify_tune_json_output() {
    let result = run_classify_tune(
        None, 3,      // budget
        "tpe",  // strategy
        "asha", // scheduler
        true,   // scout
        None,   // no data (dry run)
        5,      // num_classes
        None,   // model_size
        None,   // from_scout
        20,     // max_epochs
        None,   // time_limit
        true,   // json output
    );
    assert!(result.is_ok(), "JSON classify tune should succeed");
}

#[test]
fn test_classify_tune_human_output() {
    let result = run_classify_tune(
        None, 5,        // budget
        "random", // strategy
        "none",   // scheduler
        false,    // full mode
        None,     // no data
        3,        // num_classes
        None,     // model_size
        None,     // from_scout
        10,       // max_epochs
        None,     // time_limit
        false,    // human output
    );
    assert!(result.is_ok(), "Human classify tune should succeed");
}

#[test]
fn test_classify_tune_invalid_strategy() {
    let result = run_classify_tune(
        None,
        5,
        "invalid_strategy",
        "asha",
        true,
        None,
        5,
        None,
        None,
        20,
        None,
        false,
    );
    assert!(result.is_err(), "Invalid strategy should fail");
    match result {
        Err(CliError::ValidationFailed(msg)) => {
            assert!(
                msg.contains("Unknown strategy"),
                "Error should mention unknown strategy, got: {msg}"
            );
        }
        other => panic!("Expected ValidationFailed, got {:?}", other),
    }
}

#[test]
fn test_classify_tune_budget_zero() {
    let result = run_classify_tune(
        None, 0, // budget=0
        "tpe", "asha", true, None, 5, None, None, 20, None, false,
    );
    assert!(result.is_err(), "Budget=0 should fail");
    match result {
        Err(CliError::ValidationFailed(msg)) => {
            assert!(
                msg.contains("FALSIFY-TUNE-001"),
                "Error should contain FALSIFY-TUNE-001, got: {msg}"
            );
        }
        other => panic!("Expected ValidationFailed, got {:?}", other),
    }
}

#[test]
fn test_classify_tune_missing_data() {
    let result = run_classify_tune(
        None,
        3,
        "tpe",
        "asha",
        true,
        Some(Path::new("/nonexistent/corpus.jsonl")),
        5,
        None,
        None,
        20,
        None,
        false,
    );
    assert!(result.is_err(), "Missing data file should fail");
    match result {
        Err(CliError::ValidationFailed(msg)) => {
            assert!(
                msg.contains("FALSIFY-TUNE-003"),
                "Error should contain FALSIFY-TUNE-003, got: {msg}"
            );
        }
        other => panic!("Expected ValidationFailed, got {:?}", other),
    }
}

// ── Additional falsification tests (SPEC-TUNE-2026-001 §7) ────

#[test]
fn test_classify_tune_grid_strategy_json() {
    let result = run_classify_tune(
        None, 5, "grid", "median", false, None, 3, None, None, 10, None, true, // JSON output
    );
    assert!(
        result.is_ok(),
        "Grid strategy with JSON output should succeed"
    );
}

#[test]
fn test_classify_tune_random_strategy() {
    let result = run_classify_tune(
        None, 3, "random", "none", true, None, 5, None, None, 1, None, false,
    );
    assert!(result.is_ok(), "Random strategy should succeed");
}

#[test]
fn test_classify_tune_invalid_scheduler() {
    let result = run_classify_tune(
        None,
        5,
        "tpe",
        "hyperband_v99", // invalid scheduler
        true,
        None,
        5,
        None,
        None,
        20,
        None,
        false,
    );
    assert!(result.is_err(), "Invalid scheduler should fail");
}

#[test]
fn test_classify_tune_num_classes_zero() {
    let result = run_classify_tune(
        None, 3, "tpe", "asha", true, None, 0, // num_classes=0
        None, None, 20, None, false,
    );
    assert!(result.is_err(), "num_classes=0 should fail");
    match result {
        Err(CliError::ValidationFailed(msg)) => {
            assert!(
                msg.contains("FALSIFY-TUNE-004"),
                "Error should contain FALSIFY-TUNE-004, got: {msg}"
            );
        }
        other => panic!("Expected ValidationFailed, got {:?}", other),
    }
}

#[test]
fn test_classify_tune_scout_mode_caps_epochs() {
    // Scout mode should succeed with budget=1 (minimal)
    let result = run_classify_tune(
        None, 1, "tpe", "asha", true, // scout mode
        None, 5, None, None, 100, None, true, // JSON for easy verification
    );
    assert!(result.is_ok(), "Scout mode with budget=1 should succeed");
}

#[test]
fn test_classify_tune_large_budget_json() {
    let result = run_classify_tune(
        None, 100, "tpe", "asha", false, None, 10, None, None, 20, None, true, // JSON output
    );
    // Should succeed — budget=100 with no data just shows sample configs
    assert!(result.is_ok(), "Large budget with JSON should succeed");
}