aprender-orchestrate 0.29.0

Sovereign AI orchestration: autonomous agents, ML serving, code analysis, and transpilation pipelines
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
//! Bug Hunter Configuration
//!
//! Handles loading and parsing of `.pmat/bug-hunter.toml` configuration files.

use serde::{Deserialize, Serialize};
use std::path::Path;

/// Bug Hunter configuration loaded from `.pmat/bug-hunter.toml`.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct BugHunterConfig {
    /// Allowlist entries for intentional patterns
    #[serde(default)]
    pub allow: Vec<AllowEntry>,

    /// Custom pattern definitions
    #[serde(default)]
    pub patterns: Vec<CustomPattern>,

    /// Trend tracking settings
    #[serde(default)]
    pub trend: TrendConfig,
}

/// An allowlist entry marking a pattern as intentional.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AllowEntry {
    /// File glob pattern (e.g., "src/optim/*.rs")
    pub file: String,

    /// Pattern to allow (e.g., "unimplemented")
    pub pattern: String,

    /// Reason for allowing (documentation)
    #[serde(default)]
    pub reason: String,

    /// Optional: only allow in specific line ranges
    #[serde(default)]
    pub lines: Option<LineRange>,
}

/// Line range for scoped allowlist entries.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LineRange {
    pub start: usize,
    pub end: usize,
}

/// A custom pattern definition.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CustomPattern {
    /// The pattern to match (regex or literal)
    pub pattern: String,

    /// Category for the finding
    #[serde(default = "default_category")]
    pub category: String,

    /// Severity level
    #[serde(default = "default_severity")]
    pub severity: String,

    /// Suspiciousness score (0.0-1.0)
    #[serde(default = "default_suspiciousness")]
    pub suspiciousness: f64,

    /// Optional description
    #[serde(default)]
    pub description: String,

    /// File glob to limit scope (optional)
    #[serde(default)]
    pub file_glob: Option<String>,

    /// Language filter (optional: "rust", "python", "typescript", "go")
    #[serde(default)]
    pub language: Option<String>,
}

fn default_category() -> String {
    "Custom".to_string()
}

fn default_severity() -> String {
    "Medium".to_string()
}

fn default_suspiciousness() -> f64 {
    0.5
}

/// Trend tracking configuration.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TrendConfig {
    /// Enable automatic trend snapshots
    #[serde(default)]
    pub enabled: bool,

    /// Snapshot interval in days
    #[serde(default = "default_interval")]
    pub interval_days: u32,

    /// Maximum snapshots to retain
    #[serde(default = "default_max_snapshots")]
    pub max_snapshots: usize,
}

fn default_interval() -> u32 {
    7
}

fn default_max_snapshots() -> usize {
    52
}

impl Default for TrendConfig {
    fn default() -> Self {
        Self {
            enabled: false,
            interval_days: default_interval(),
            max_snapshots: default_max_snapshots(),
        }
    }
}

impl BugHunterConfig {
    /// Load configuration from a project path.
    ///
    /// Looks for `.pmat/bug-hunter.toml` in the project root.
    pub fn load(project_path: &Path) -> Self {
        let config_path = project_path.join(".pmat").join("bug-hunter.toml");
        if config_path.exists() {
            match std::fs::read_to_string(&config_path) {
                Ok(content) => match toml::from_str(&content) {
                    Ok(config) => return config,
                    Err(e) => {
                        eprintln!("Warning: Failed to parse {}: {}", config_path.display(), e);
                    }
                },
                Err(e) => {
                    eprintln!("Warning: Failed to read {}: {}", config_path.display(), e);
                }
            }
        }
        Self::default()
    }

    /// Check if a finding should be allowed (skipped).
    pub fn is_allowed(&self, file_path: &Path, pattern: &str, line: usize) -> bool {
        let file_str = file_path.to_string_lossy();

        for entry in &self.allow {
            // Check pattern match
            if !entry.pattern.eq_ignore_ascii_case(pattern) && entry.pattern != "*" {
                continue;
            }

            // Check file glob
            if !glob_match(&entry.file, &file_str) {
                continue;
            }

            // Check line range if specified
            if let Some(ref range) = entry.lines {
                if line < range.start || line > range.end {
                    continue;
                }
            }

            return true;
        }

        false
    }
}

/// Simple glob matching (supports * and **).
fn glob_match(pattern: &str, path: &str) -> bool {
    if pattern == "*" || pattern == "**" {
        return true;
    }

    // Convert glob to regex-like matching
    let pattern_parts: Vec<&str> = pattern.split('/').collect();
    let path_parts: Vec<&str> = path.split('/').collect();

    glob_match_parts(&pattern_parts, &path_parts)
}

fn glob_match_parts(pattern: &[&str], path: &[&str]) -> bool {
    let Some((&p, pattern_rest)) = pattern.split_first() else {
        return path.is_empty();
    };

    if p == "**" {
        return glob_match_doublestar(pattern_rest, path);
    }

    let Some((&path_first, path_rest)) = path.split_first() else {
        return false;
    };

    segment_matches(p, path_first) && glob_match_parts(pattern_rest, path_rest)
}

/// Handle ** glob pattern: matches zero or more path segments
fn glob_match_doublestar(pattern_rest: &[&str], path: &[&str]) -> bool {
    for i in 0..=path.len() {
        if glob_match_parts(pattern_rest, path.get(i..).unwrap_or(&[])) {
            return true;
        }
    }
    false
}

fn segment_matches(pattern: &str, segment: &str) -> bool {
    if pattern == "*" {
        return true;
    }

    if !pattern.contains('*') {
        return pattern == segment;
    }

    // Simple wildcard matching
    let parts: Vec<&str> = pattern.split('*').collect();
    if parts.len() == 2 {
        let (prefix, suffix) = (parts[0], parts[1]);
        return segment.starts_with(prefix) && segment.ends_with(suffix);
    }

    // Fallback to exact match for complex patterns
    pattern == segment
}

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

    #[test]
    fn test_glob_match_simple() {
        assert!(glob_match("src/*.rs", "src/main.rs"));
        assert!(glob_match("src/*.rs", "src/lib.rs"));
        assert!(!glob_match("src/*.rs", "src/foo/bar.rs"));
    }

    #[test]
    fn test_glob_match_double_star() {
        assert!(glob_match("src/**/*.rs", "src/main.rs"));
        assert!(glob_match("src/**/*.rs", "src/foo/bar.rs"));
        assert!(glob_match("src/**/*.rs", "src/foo/bar/baz.rs"));
        assert!(!glob_match("src/**/*.rs", "test/main.rs"));
    }

    #[test]
    fn test_glob_match_star() {
        assert!(glob_match("*", "anything"));
        assert!(glob_match("**", "any/path/here"));
    }

    #[test]
    fn test_is_allowed() {
        let config = BugHunterConfig {
            allow: vec![AllowEntry {
                file: "src/optim/*.rs".to_string(),
                pattern: "unimplemented".to_string(),
                reason: "Batch optimizers don't support step()".to_string(),
                lines: None,
            }],
            ..Default::default()
        };

        assert!(config.is_allowed(Path::new("src/optim/admm.rs"), "unimplemented", 100));
        assert!(!config.is_allowed(Path::new("src/main.rs"), "unimplemented", 100));
        assert!(!config.is_allowed(Path::new("src/optim/admm.rs"), "placeholder", 100));
    }

    #[test]
    fn test_is_allowed_with_line_range() {
        let config = BugHunterConfig {
            allow: vec![AllowEntry {
                file: "src/foo.rs".to_string(),
                pattern: "TODO".to_string(),
                reason: "Known issue".to_string(),
                lines: Some(LineRange { start: 10, end: 20 }),
            }],
            ..Default::default()
        };

        assert!(config.is_allowed(Path::new("src/foo.rs"), "TODO", 15));
        assert!(!config.is_allowed(Path::new("src/foo.rs"), "TODO", 5));
        assert!(!config.is_allowed(Path::new("src/foo.rs"), "TODO", 25));
    }

    #[test]
    fn test_parse_config() {
        let toml = r#"
[[allow]]
file = "src/optim/*.rs"
pattern = "unimplemented"
reason = "Batch optimizers"

[[patterns]]
pattern = "PERF-TODO"
category = "PerformanceDebt"
severity = "High"
suspiciousness = 0.8
"#;

        let config: BugHunterConfig = toml::from_str(toml).expect("toml parse failed");
        assert_eq!(config.allow.len(), 1);
        assert_eq!(config.patterns.len(), 1);
        assert_eq!(config.patterns[0].pattern, "PERF-TODO");
        assert_eq!(config.patterns[0].suspiciousness, 0.8);
    }

    // ================================================================
    // Additional coverage tests
    // ================================================================

    #[test]
    fn test_load_nonexistent_path() {
        // load() with a path that has no .pmat/bug-hunter.toml should return default
        let config = BugHunterConfig::load(Path::new("/absolutely/nonexistent/path"));
        assert!(config.allow.is_empty());
        assert!(config.patterns.is_empty());
        assert!(!config.trend.enabled);
    }

    #[test]
    fn test_load_valid_toml() {
        use std::fs;
        let tmp = std::env::temp_dir().join("batuta_test_config_load_valid");
        let pmat_dir = tmp.join(".pmat");
        let _ = fs::create_dir_all(&pmat_dir);

        let toml_content = r#"
[[allow]]
file = "src/**/*.rs"
pattern = "todo"
reason = "Known issues"

[trend]
enabled = true
interval_days = 14
max_snapshots = 100
"#;
        fs::write(pmat_dir.join("bug-hunter.toml"), toml_content).expect("fs write failed");

        let config = BugHunterConfig::load(&tmp);
        assert_eq!(config.allow.len(), 1);
        assert_eq!(config.allow[0].pattern, "todo");
        assert!(config.trend.enabled);
        assert_eq!(config.trend.interval_days, 14);
        assert_eq!(config.trend.max_snapshots, 100);

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

    #[test]
    fn test_load_invalid_toml() {
        use std::fs;
        let tmp = std::env::temp_dir().join("batuta_test_config_load_invalid");
        let pmat_dir = tmp.join(".pmat");
        let _ = fs::create_dir_all(&pmat_dir);

        // Write invalid TOML content
        fs::write(pmat_dir.join("bug-hunter.toml"), "{{invalid toml!!!").expect("fs write failed");

        // Should print warning and return default
        let config = BugHunterConfig::load(&tmp);
        assert!(config.allow.is_empty());
        assert!(config.patterns.is_empty());

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

    #[test]
    fn test_load_unreadable_file() {
        // Path exists but .pmat dir exists with a directory instead of a file
        use std::fs;
        let tmp = std::env::temp_dir().join("batuta_test_config_load_unreadable");
        let pmat_dir = tmp.join(".pmat");
        let toml_as_dir = pmat_dir.join("bug-hunter.toml");
        let _ = fs::create_dir_all(&toml_as_dir); // Create as directory, not file

        // exists() returns true for directories, but read_to_string will fail
        let config = BugHunterConfig::load(&tmp);
        assert!(config.allow.is_empty());

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

    #[test]
    fn test_default_config() {
        let config = BugHunterConfig::default();
        assert!(config.allow.is_empty());
        assert!(config.patterns.is_empty());
        assert!(!config.trend.enabled);
        assert_eq!(config.trend.interval_days, 7);
        assert_eq!(config.trend.max_snapshots, 52);
    }

    #[test]
    fn test_trend_config_default() {
        let trend = TrendConfig::default();
        assert!(!trend.enabled);
        assert_eq!(trend.interval_days, 7);
        assert_eq!(trend.max_snapshots, 52);
    }

    #[test]
    fn test_custom_pattern_defaults() {
        let toml = r#"
[[patterns]]
pattern = "FIXME"
"#;

        let config: BugHunterConfig = toml::from_str(toml).expect("toml parse failed");
        let p = &config.patterns[0];
        assert_eq!(p.pattern, "FIXME");
        assert_eq!(p.category, "Custom");
        assert_eq!(p.severity, "Medium");
        assert!((p.suspiciousness - 0.5).abs() < f64::EPSILON);
        assert_eq!(p.description, "");
        assert!(p.file_glob.is_none());
        assert!(p.language.is_none());
    }

    #[test]
    fn test_custom_pattern_full_fields() {
        let toml = r#"
[[patterns]]
pattern = "HACK"
category = "TechDebt"
severity = "Critical"
suspiciousness = 0.9
description = "Hack workaround"
file_glob = "src/**/*.rs"
language = "rust"
"#;

        let config: BugHunterConfig = toml::from_str(toml).expect("toml parse failed");
        let p = &config.patterns[0];
        assert_eq!(p.pattern, "HACK");
        assert_eq!(p.category, "TechDebt");
        assert_eq!(p.severity, "Critical");
        assert!((p.suspiciousness - 0.9).abs() < f64::EPSILON);
        assert_eq!(p.description, "Hack workaround");
        assert_eq!(p.file_glob.as_deref(), Some("src/**/*.rs"));
        assert_eq!(p.language.as_deref(), Some("rust"));
    }

    #[test]
    fn test_is_allowed_wildcard_pattern() {
        let config = BugHunterConfig {
            allow: vec![AllowEntry {
                file: "**".to_string(),
                pattern: "*".to_string(),
                reason: "Allow everything".to_string(),
                lines: None,
            }],
            ..Default::default()
        };

        // Wildcard pattern "*" should match any pattern
        assert!(config.is_allowed(Path::new("src/anything.rs"), "any_pattern", 1));
        assert!(config.is_allowed(Path::new("tests/foo.rs"), "different", 999));
    }

    #[test]
    fn test_is_allowed_case_insensitive_pattern() {
        let config = BugHunterConfig {
            allow: vec![AllowEntry {
                file: "src/*.rs".to_string(),
                pattern: "TODO".to_string(),
                reason: "Known".to_string(),
                lines: None,
            }],
            ..Default::default()
        };

        // eq_ignore_ascii_case should match
        assert!(config.is_allowed(Path::new("src/main.rs"), "todo", 1));
        assert!(config.is_allowed(Path::new("src/main.rs"), "Todo", 1));
        assert!(config.is_allowed(Path::new("src/main.rs"), "TODO", 1));
    }

    #[test]
    fn test_is_allowed_no_entries() {
        let config = BugHunterConfig::default();
        assert!(!config.is_allowed(Path::new("src/main.rs"), "TODO", 1));
    }

    #[test]
    fn test_is_allowed_multiple_entries() {
        let config = BugHunterConfig {
            allow: vec![
                AllowEntry {
                    file: "src/a.rs".to_string(),
                    pattern: "TODO".to_string(),
                    reason: "".to_string(),
                    lines: None,
                },
                AllowEntry {
                    file: "src/b.rs".to_string(),
                    pattern: "FIXME".to_string(),
                    reason: "".to_string(),
                    lines: None,
                },
            ],
            ..Default::default()
        };

        assert!(config.is_allowed(Path::new("src/a.rs"), "TODO", 1));
        assert!(!config.is_allowed(Path::new("src/a.rs"), "FIXME", 1));
        assert!(config.is_allowed(Path::new("src/b.rs"), "FIXME", 1));
        assert!(!config.is_allowed(Path::new("src/b.rs"), "TODO", 1));
    }

    #[test]
    fn test_glob_match_exact_segment() {
        // No wildcards - exact match
        assert!(glob_match("src/main.rs", "src/main.rs"));
        assert!(!glob_match("src/main.rs", "src/lib.rs"));
    }

    #[test]
    fn test_glob_match_empty_pattern() {
        // Empty pattern should match empty path
        assert!(glob_match("", ""));
        // Empty pattern should not match non-empty path
        assert!(!glob_match("", "src/main.rs"));
    }

    #[test]
    fn test_glob_match_double_star_at_end() {
        // ** at end matches anything remaining
        assert!(glob_match("src/**", "src/foo.rs"));
        assert!(glob_match("src/**", "src/foo/bar.rs"));
        assert!(glob_match("src/**", "src/foo/bar/baz.rs"));
    }

    #[test]
    fn test_glob_match_double_star_at_beginning() {
        assert!(glob_match("**/main.rs", "src/main.rs"));
        assert!(glob_match("**/main.rs", "deep/nested/main.rs"));
        assert!(glob_match("**/main.rs", "main.rs")); // zero segments before
    }

    #[test]
    fn test_glob_match_star_segment_prefix_suffix() {
        // Pattern "*.rs" matches any segment ending in .rs
        assert!(glob_match("*.rs", "main.rs"));
        assert!(glob_match("*.rs", "lib.rs"));
        assert!(!glob_match("*.rs", "main.py"));
    }

    #[test]
    fn test_glob_match_deeper_paths() {
        assert!(glob_match("a/b/c", "a/b/c"));
        assert!(!glob_match("a/b/c", "a/b/d"));
        assert!(!glob_match("a/b/c", "a/b"));
        assert!(!glob_match("a/b", "a/b/c"));
    }

    #[test]
    fn test_segment_matches_no_wildcard() {
        assert!(segment_matches("main.rs", "main.rs"));
        assert!(!segment_matches("main.rs", "lib.rs"));
    }

    #[test]
    fn test_segment_matches_star() {
        assert!(segment_matches("*", "anything"));
        assert!(segment_matches("*", ""));
    }

    #[test]
    fn test_segment_matches_prefix_suffix() {
        assert!(segment_matches("test_*.rs", "test_main.rs"));
        assert!(segment_matches("test_*.rs", "test_.rs")); // empty middle
        assert!(!segment_matches("test_*.rs", "main.rs"));
    }

    #[test]
    fn test_segment_matches_complex_pattern() {
        // Multiple wildcards fall back to exact match
        assert!(segment_matches("a*b*c", "a*b*c")); // exact match of the pattern string
        assert!(!segment_matches("a*b*c", "aXbYc")); // won't match - fallback is exact
    }

    #[test]
    fn test_glob_match_double_star_zero_segments() {
        // ** matches zero segments
        assert!(glob_match("**/src/*.rs", "src/main.rs"));
        // ** matches one segment
        assert!(glob_match("**/src/*.rs", "foo/src/main.rs"));
        // ** matches multiple segments
        assert!(glob_match("**/src/*.rs", "a/b/src/main.rs"));
    }

    #[test]
    fn test_allow_entry_line_range_boundaries() {
        let config = BugHunterConfig {
            allow: vec![AllowEntry {
                file: "src/foo.rs".to_string(),
                pattern: "TODO".to_string(),
                reason: "".to_string(),
                lines: Some(LineRange { start: 10, end: 20 }),
            }],
            ..Default::default()
        };

        // Exactly at boundaries
        assert!(config.is_allowed(Path::new("src/foo.rs"), "TODO", 10)); // start boundary
        assert!(config.is_allowed(Path::new("src/foo.rs"), "TODO", 20)); // end boundary
        assert!(!config.is_allowed(Path::new("src/foo.rs"), "TODO", 9)); // just before
        assert!(!config.is_allowed(Path::new("src/foo.rs"), "TODO", 21)); // just after
    }

    #[test]
    fn test_parse_config_with_line_range() {
        let toml = r#"
[[allow]]
file = "src/main.rs"
pattern = "HACK"
reason = "Temporary workaround"

[allow.lines]
start = 50
end = 75
"#;

        let config: BugHunterConfig = toml::from_str(toml).expect("toml parse failed");
        assert_eq!(config.allow.len(), 1);
        let entry = &config.allow[0];
        assert!(entry.lines.is_some());
        let range = entry.lines.as_ref().expect("unexpected failure");
        assert_eq!(range.start, 50);
        assert_eq!(range.end, 75);
    }

    #[test]
    fn test_parse_config_with_trend() {
        let toml = r#"
[trend]
enabled = true
interval_days = 30
max_snapshots = 24
"#;

        let config: BugHunterConfig = toml::from_str(toml).expect("toml parse failed");
        assert!(config.trend.enabled);
        assert_eq!(config.trend.interval_days, 30);
        assert_eq!(config.trend.max_snapshots, 24);
    }

    #[test]
    fn test_parse_config_empty_toml() {
        let config: BugHunterConfig = toml::from_str("").expect("toml parse failed");
        assert!(config.allow.is_empty());
        assert!(config.patterns.is_empty());
        assert!(!config.trend.enabled);
        assert_eq!(config.trend.interval_days, 7);
        assert_eq!(config.trend.max_snapshots, 52);
    }

    #[test]
    fn test_glob_match_parts_empty_pattern_empty_path() {
        // Both empty -> true
        assert!(glob_match_parts(&[], &[]));
    }

    #[test]
    fn test_glob_match_parts_pattern_longer_than_path() {
        // Pattern has segments but path is empty
        assert!(!glob_match_parts(&["src", "main.rs"], &[]));
    }

    #[test]
    fn test_glob_match_doublestar_only() {
        // Just ** matches anything
        assert!(glob_match_doublestar(&[], &[]));
        assert!(glob_match_doublestar(&[], &["a", "b", "c"]));
    }

    #[test]
    fn test_glob_match_doublestar_with_rest() {
        // ** followed by pattern
        assert!(glob_match_doublestar(&["*.rs"], &["main.rs"]));
        assert!(glob_match_doublestar(&["*.rs"], &["src", "main.rs"]));
        assert!(!glob_match_doublestar(&["*.rs"], &["main.py"]));
    }
}