claudette 0.7.0

Local-first AI personal secretary for Ollama. Telegram bot, voice, persistent scheduler, Gmail and Calendar. Single-binary Rust.
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
//! Subprocess wrappers for running code validation: syntax checks and unit
//! tests. Sync `try_wait` poll loop for timeouts plus pytest output parsing.
//!
//! All functions are blocking and fire real subprocesses — they're intended to
//! run from within a synchronous tool-dispatch context (inside `run_write_file`
//! or the `/validate` slash command), NOT from async code. The 30-second default
//! timeout prevents runaway test processes from stalling the REPL.
//!
//! Only Python is supported for the Sprint 3 MVP. Adding Rust (`cargo check` /
//! `cargo test --no-run`) or JavaScript (`node --check`) is a future extension
//! point — each gets its own `run_<lang>_*` pair + output parser.

use std::io::Read;
use std::path::Path;
use std::process::{Command, Stdio};
use std::time::{Duration, Instant};

/// Default timeout for validation subprocesses. Long enough for a realistic
/// test suite on a ~200-line file; short enough not to stall the REPL if a
/// test has an infinite loop.
const DEFAULT_TIMEOUT_SECS: u64 = 30;

/// Raw result from a subprocess invocation.
/// with the addition of `exit_code` for finer diagnostics.
#[derive(Debug, Clone)]
pub struct CommandResult {
    pub success: bool,
    pub stdout: String,
    pub stderr: String,
    pub timed_out: bool,
    pub exit_code: Option<i32>,
}

/// Parsed result from running `python -m unittest`.
#[derive(Debug, Clone)]
pub struct TestResult {
    /// True if the process exited 0 and no FAIL/ERROR lines were found.
    pub all_passed: bool,
    pub passed: u32,
    pub failed: u32,
    pub errors: u32,
    /// Combined stdout+stderr when something failed — handed to the coder
    /// model as context for the fix prompt. Empty on success.
    pub error_output: String,
}

// ────────────────────────────────────────────────────────────────────────────
// Subprocess execution
// ────────────────────────────────────────────────────────────────────────────

/// Spawn `program` with `args`, capturing stdout/stderr. Polls
/// `child.try_wait()` every 100 ms and kills the process if the timeout
/// is exceeded. Returns a `CommandResult` in all cases — never panics.
///
/// `cwd` overrides the subprocess working directory — needed by
/// `run_python_unittest` which must `cd` into the file's parent so
/// Python can import it by module name.
///
/// **Pipe draining:** stdout and stderr are read concurrently on dedicated
/// reader threads. Reading lazily (only after `try_wait` returns `Some`)
/// deadlocks any child that writes more than the OS pipe buffer (~64 KB)
/// because the child blocks on the write while the parent spins on
/// `try_wait` and the timeout eats the whole 30 s budget.
pub fn run_command_with_timeout(
    program: &str,
    args: &[&str],
    timeout_secs: u64,
    cwd: Option<&Path>,
) -> CommandResult {
    let mut cmd = Command::new(program);
    cmd.args(args).stdout(Stdio::piped()).stderr(Stdio::piped());
    if let Some(dir) = cwd {
        cmd.current_dir(dir);
    }
    let mut child = match cmd.spawn() {
        Ok(c) => c,
        Err(e) => {
            return CommandResult {
                success: false,
                stdout: String::new(),
                stderr: format!("failed to spawn `{program}`: {e}"),
                timed_out: false,
                exit_code: None,
            };
        }
    };

    // Drain pipes on background threads so the child can't block writing.
    let stdout_reader = spawn_pipe_reader(child.stdout.take());
    let stderr_reader = spawn_pipe_reader(child.stderr.take());

    let start = Instant::now();
    let timeout = Duration::from_secs(timeout_secs);
    loop {
        match child.try_wait() {
            Ok(Some(status)) => {
                return CommandResult {
                    success: status.success(),
                    stdout: join_reader(stdout_reader),
                    stderr: join_reader(stderr_reader),
                    timed_out: false,
                    exit_code: status.code(),
                };
            }
            Ok(None) => {
                if start.elapsed() > timeout {
                    let _ = child.kill();
                    let _ = child.wait();
                    // Reader threads exit cleanly once the kill closes the
                    // pipe ends; join so any partial output is still
                    // returned with the timeout message appended.
                    let stdout = join_reader(stdout_reader);
                    let mut stderr = join_reader(stderr_reader);
                    if !stderr.is_empty() && !stderr.ends_with('\n') {
                        stderr.push('\n');
                    }
                    use std::fmt::Write as _;
                    let _ = write!(stderr, "timed out after {timeout_secs}s");
                    return CommandResult {
                        success: false,
                        stdout,
                        stderr,
                        timed_out: true,
                        exit_code: None,
                    };
                }
                std::thread::sleep(Duration::from_millis(100));
            }
            Err(e) => {
                return CommandResult {
                    success: false,
                    stdout: join_reader(stdout_reader),
                    stderr: format!(
                        "{}\ntry_wait error: {e}",
                        join_reader(stderr_reader).trim_end()
                    ),
                    timed_out: false,
                    exit_code: None,
                };
            }
        }
    }
}

/// Spawn a background thread that drains a child pipe into a `String`. The
/// thread exits when the pipe closes (child exit or kill). `None` input
/// yields a thread that returns an empty string immediately so callers
/// never have to special-case "pipe wasn't captured."
fn spawn_pipe_reader<P>(pipe: Option<P>) -> std::thread::JoinHandle<String>
where
    P: Read + Send + 'static,
{
    std::thread::spawn(move || {
        let Some(mut r) = pipe else {
            return String::new();
        };
        let mut buf = String::new();
        let _ = r.read_to_string(&mut buf);
        buf
    })
}

/// Join a pipe-reader thread and return its captured string. Treats a
/// panicked reader as an empty pipe — output capture is best-effort.
fn join_reader(handle: std::thread::JoinHandle<String>) -> String {
    handle.join().unwrap_or_default()
}

// ────────────────────────────────────────────────────────────────────────────
// Python-specific checks
// ────────────────────────────────────────────────────────────────────────────

/// Run `python -m py_compile <path>`. Returns success if the file is valid
/// Python syntax, failure with the compiler's error message otherwise.
pub fn run_python_syntax_check(path: &Path) -> CommandResult {
    let path_str = path.to_string_lossy();
    run_command_with_timeout(
        "python",
        &["-m", "py_compile", &path_str],
        DEFAULT_TIMEOUT_SECS,
        None,
    )
}

/// Run `python -m unittest <module> -v` with the working directory set to
/// the file's parent directory. Python's unittest needs to IMPORT the file
/// as a module, so we pass the stem name (e.g. `userClass`, not the full
/// path or `userClass.py`) and `cd` into the parent so the import
/// succeeds.
///
/// **Why not `python <path>`?** That works only if the file has a
/// `if __name__ == "__main__": unittest.main()` guard at the bottom. The
/// module-import approach finds all `TestCase` subclasses regardless.
pub fn run_python_unittest(path: &Path) -> TestResult {
    let parent = path.parent().unwrap_or(Path::new("."));
    let stem = path.file_stem().and_then(|s| s.to_str()).unwrap_or("");
    let result = run_command_with_timeout(
        "python",
        &["-m", "unittest", stem, "-v"],
        DEFAULT_TIMEOUT_SECS,
        Some(parent),
    );
    parse_unittest_output(&result)
}

/// Parse `python -m unittest -v` output into a `TestResult`. Counts per-test
/// status lines (`... ok`, `... FAIL`, `... ERROR`) and checks the overall
/// exit code.
///
/// Example verbose output:
/// ```text
/// test_greet (__main__.TestUser.test_greet) ... ok
/// test_get_age (__main__.TestUser.test_get_age) ... FAIL
///
/// ======================================================================
/// FAIL: test_get_age (__main__.TestUser.test_get_age)
/// ...
/// Ran 11 tests in 0.001s
///
/// FAILED (failures=1)
/// ```
pub fn parse_unittest_output(result: &CommandResult) -> TestResult {
    let combined = format!("{}\n{}", result.stdout, result.stderr);
    let mut passed: u32 = 0;
    let mut failed: u32 = 0;
    let mut errors: u32 = 0;

    for line in combined.lines() {
        let trimmed = line.trim_end();
        if trimmed.ends_with("... ok") {
            passed += 1;
        } else if trimmed.ends_with("... FAIL") {
            failed += 1;
        } else if trimmed.ends_with("... ERROR") {
            errors += 1;
        }
    }

    // Fallback: if we didn't see any per-test lines (maybe -v wasn't
    // honoured or the output format differs), use the exit code + summary
    // line. `FAILED (failures=N)` or `FAILED (errors=N)` patterns.
    if passed == 0 && failed == 0 && errors == 0 && !result.success {
        // Parse "FAILED (failures=1, errors=2)" style
        for line in combined.lines() {
            if line.starts_with("FAILED") {
                for segment in line.split(|c: char| !c.is_ascii_digit()) {
                    if let Ok(n) = segment.parse::<u32>() {
                        if n > 0 && failed == 0 {
                            failed = n;
                        }
                    }
                }
                break;
            }
        }
        if failed == 0 {
            failed = 1; // we know SOMETHING failed — exit code was non-zero
        }
    }

    let all_passed = result.success && failed == 0 && errors == 0;
    TestResult {
        all_passed,
        passed,
        failed,
        errors,
        error_output: if all_passed { String::new() } else { combined },
    }
}

/// Check whether a file's content looks like it contains Python unit tests.
/// This is a heuristic, not a parser — good enough for the "should we run
/// `python -m unittest`?" decision. False-positives are fine (we just run
/// unittest and it finds 0 tests). False-negatives are rare because every
/// real test file uses at least one of these patterns.
#[must_use]
pub fn has_python_tests(content: &str) -> bool {
    content.contains("def test_")
        || content.contains("class Test")
        || content.contains("import unittest")
        || content.contains("from unittest")
}

/// Outcome of a Python import pre-flight check. See [`check_python_imports`].
#[derive(Debug, Clone)]
pub struct ImportCheckResult {
    /// Top-level module names referenced by the file that aren't importable.
    /// Empty means either everything is importable or the check itself
    /// couldn't run (see `check_error`).
    pub missing: Vec<String>,
    /// Non-empty when the check itself failed (no `python` on PATH, AST
    /// parse error, etc.). Callers should treat this as "don't know —
    /// fall through to the existing unittest path."
    pub check_error: String,
}

/// Walk the AST of a Python file and try `__import__` on every top-level
/// module it names. Returns modules that raise `ImportError`.
///
/// Used as a pre-flight before `run_python_unittest` so Codet can surface
/// a clean "missing package X" message instead of burning a regen loop on
/// a `unittest.loader._FailedTest` — which looks like a test failure but
/// is actually an environment issue the coder cannot repair.
///
/// Skips relative imports (`from . import x`) and treats non-ImportError
/// exceptions during `__import__` as "proceed anyway" — the goal is to
/// catch the obvious "pip install missing" case, not every possible
/// import-time problem.
pub fn check_python_imports(path: &Path) -> ImportCheckResult {
    const SCRIPT: &str = "\
import sys, ast\n\
if len(sys.argv) < 2:\n\
    sys.exit(0)\n\
try:\n\
    with open(sys.argv[1], 'r', encoding='utf-8') as f:\n\
        tree = ast.parse(f.read())\n\
except Exception:\n\
    sys.exit(0)\n\
missing = []\n\
seen = set()\n\
def try_mod(mod):\n\
    if mod in seen:\n\
        return\n\
    seen.add(mod)\n\
    try:\n\
        __import__(mod)\n\
    except ImportError:\n\
        missing.append(mod)\n\
    except Exception:\n\
        pass\n\
for node in ast.walk(tree):\n\
    if isinstance(node, ast.Import):\n\
        for alias in node.names:\n\
            try_mod(alias.name.split('.')[0])\n\
    elif isinstance(node, ast.ImportFrom):\n\
        if node.level == 0 and node.module:\n\
            try_mod(node.module.split('.')[0])\n\
if missing:\n\
    print(','.join(missing))\n\
    sys.exit(1)\n\
sys.exit(0)\n";

    let path_str = path.to_string_lossy();
    let result = run_command_with_timeout(
        "python",
        &["-c", SCRIPT, &path_str],
        DEFAULT_TIMEOUT_SECS,
        None,
    );

    // Exit 0 — all imports resolve. Exit 1 with stdout — list of misses.
    // Anything else (None exit code from spawn failure, non-zero without
    // stdout, timeout) is "check failed, don't block unittest."
    if result.success {
        return ImportCheckResult {
            missing: Vec::new(),
            check_error: String::new(),
        };
    }
    if result.exit_code == Some(1) && !result.stdout.trim().is_empty() {
        let missing = result
            .stdout
            .trim()
            .split(',')
            .filter(|s| !s.is_empty())
            .map(str::to_string)
            .collect();
        return ImportCheckResult {
            missing,
            check_error: String::new(),
        };
    }
    ImportCheckResult {
        missing: Vec::new(),
        check_error: if result.timed_out {
            "import check timed out".to_string()
        } else {
            format!("import check failed: {}", result.stderr.trim())
        },
    }
}

// ────────────────────────────────────────────────────────────────────────────
// Rust validation (Sprint 10)
// ────────────────────────────────────────────────────────────────────────────

/// Run `rustc --edition 2021 --crate-type lib <path>` to syntax-check a Rust
/// file without producing a binary. Uses a temp output dir so we don't litter
/// the workspace with `.rlib` files.
pub fn run_rust_syntax_check(path: &Path) -> CommandResult {
    let path_str = path.to_string_lossy();
    let tmp = std::env::temp_dir().join("claudette-rustc");
    let _ = std::fs::create_dir_all(&tmp);
    let out_dir = tmp.to_string_lossy();
    run_command_with_timeout(
        "rustc",
        &[
            "--edition",
            "2021",
            "--crate-type",
            "lib",
            "--out-dir",
            &out_dir,
            &path_str,
        ],
        DEFAULT_TIMEOUT_SECS,
        None,
    )
}

/// Check whether Rust source contains test functions.
#[must_use]
pub fn has_rust_tests(content: &str) -> bool {
    content.contains("#[test]") || content.contains("#[cfg(test)]")
}

// ────────────────────────────────────────────────────────────────────────────
// JavaScript / TypeScript validation (Sprint 10)
// ────────────────────────────────────────────────────────────────────────────

/// Run `node --check <path>` to syntax-check a JavaScript file.
pub fn run_js_syntax_check(path: &Path) -> CommandResult {
    let path_str = path.to_string_lossy();
    run_command_with_timeout("node", &["--check", &path_str], DEFAULT_TIMEOUT_SECS, None)
}

/// Run `npx tsc --noEmit --allowJs --strict <path>` to type-check a TypeScript
/// file. Falls back gracefully if `npx` is not available.
pub fn run_ts_syntax_check(path: &Path) -> CommandResult {
    let path_str = path.to_string_lossy();
    run_command_with_timeout(
        "npx",
        &["tsc", "--noEmit", "--strict", &path_str],
        DEFAULT_TIMEOUT_SECS,
        None,
    )
}

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

    fn cmd_result(success: bool, stdout: &str, stderr: &str) -> CommandResult {
        CommandResult {
            success,
            stdout: stdout.to_string(),
            stderr: stderr.to_string(),
            timed_out: false,
            exit_code: if success { Some(0) } else { Some(1) },
        }
    }

    #[test]
    fn parse_unittest_all_pass() {
        let result = cmd_result(
            true,
            "",
            "test_greet (__main__.TestUser.test_greet) ... ok\n\
             test_get_name (__main__.TestUser.test_get_name) ... ok\n\
             test_is_adult (__main__.TestUser.test_is_adult) ... ok\n\
             \n----------------------------------------------------------------------\n\
             Ran 3 tests in 0.001s\n\n\
             OK\n",
        );
        let tr = parse_unittest_output(&result);
        assert!(tr.all_passed);
        assert_eq!(tr.passed, 3);
        assert_eq!(tr.failed, 0);
        assert_eq!(tr.errors, 0);
        assert!(tr.error_output.is_empty());
    }

    #[test]
    fn parse_unittest_one_failure() {
        let result = cmd_result(
            false,
            "",
            "test_greet (__main__.TestUser.test_greet) ... ok\n\
             test_get_age (__main__.TestUser.test_get_age) ... FAIL\n\
             test_is_adult (__main__.TestUser.test_is_adult) ... ok\n\
             \n======================================================================\n\
             FAIL: test_get_age (__main__.TestUser.test_get_age)\n\
             AssertionError: 40 != 4\n\
             \n----------------------------------------------------------------------\n\
             Ran 3 tests in 0.001s\n\n\
             FAILED (failures=1)\n",
        );
        let tr = parse_unittest_output(&result);
        assert!(!tr.all_passed);
        assert_eq!(tr.passed, 2);
        assert_eq!(tr.failed, 1);
        assert_eq!(tr.errors, 0);
        assert!(tr.error_output.contains("FAIL"));
        assert!(tr.error_output.contains("40 != 4"));
    }

    #[test]
    fn parse_unittest_mixed_fail_and_error() {
        let result = cmd_result(
            false,
            "",
            "test_a ... ok\n\
             test_b ... FAIL\n\
             test_c ... ERROR\n\
             test_d ... ok\n\
             \nRan 4 tests in 0.002s\n\n\
             FAILED (failures=1, errors=1)\n",
        );
        let tr = parse_unittest_output(&result);
        assert!(!tr.all_passed);
        assert_eq!(tr.passed, 2);
        assert_eq!(tr.failed, 1);
        assert_eq!(tr.errors, 1);
    }

    #[test]
    fn parse_unittest_empty_output_nonzero_exit() {
        let result = cmd_result(false, "", "");
        let tr = parse_unittest_output(&result);
        assert!(!tr.all_passed);
        assert_eq!(
            tr.failed, 1,
            "should infer at least 1 failure from exit code"
        );
    }

    #[test]
    fn parse_unittest_success_no_verbose_lines() {
        // Some environments don't emit verbose per-test lines.
        let result = cmd_result(true, "", "Ran 5 tests in 0.001s\n\nOK\n");
        let tr = parse_unittest_output(&result);
        assert!(tr.all_passed);
        assert_eq!(tr.passed, 0, "can't count without verbose lines");
        assert_eq!(tr.failed, 0);
    }

    #[test]
    fn has_python_tests_detects_patterns() {
        assert!(has_python_tests("def test_foo(): pass"));
        assert!(has_python_tests("class TestUser(unittest.TestCase):"));
        assert!(has_python_tests("import unittest"));
        assert!(has_python_tests("from unittest import TestCase"));
    }

    #[test]
    fn has_python_tests_returns_false_for_plain_code() {
        assert!(!has_python_tests("def greet(): pass"));
        assert!(!has_python_tests("class User:\n    pass"));
        assert!(!has_python_tests("x = 42"));
    }

    // Import pre-flight.
    // These tests spawn a real `python` process, so they're only meaningful
    // when python is installed. If it isn't, `check_python_imports` returns
    // a non-empty `check_error` and the tests assert only the fallback
    // behavior (empty `missing` list, no crash).

    fn write_temp_py(tag: &str, body: &str) -> std::path::PathBuf {
        let path = std::env::temp_dir().join(format!("claudette-import-check-{tag}.py"));
        std::fs::write(&path, body).expect("write temp file");
        path
    }

    #[test]
    fn check_python_imports_allows_stdlib_only() {
        let path = write_temp_py(
            "stdlib",
            "import os\nimport sys\nfrom pathlib import Path\n",
        );
        let result = check_python_imports(&path);
        let _ = std::fs::remove_file(&path);
        if result.check_error.is_empty() {
            assert!(
                result.missing.is_empty(),
                "stdlib imports should resolve, got missing: {:?}",
                result.missing
            );
        }
    }

    #[test]
    fn check_python_imports_flags_obvious_miss() {
        let path = write_temp_py("miss", "import claudette_definitely_not_a_real_module\n");
        let result = check_python_imports(&path);
        let _ = std::fs::remove_file(&path);
        if result.check_error.is_empty() {
            assert_eq!(
                result.missing,
                vec!["claudette_definitely_not_a_real_module".to_string()],
                "expected the bogus module name, got missing={:?}",
                result.missing,
            );
        }
    }

    #[test]
    fn run_command_drains_large_output_without_timeout() {
        // Regression: previously the parent only read pipes after the child
        // exited, so any child that wrote more than the OS pipe buffer
        // (~64 KB) would block on write and we would burn the full 30 s
        // timeout. With concurrent drainers this completes in well under
        // the timeout budget.
        //
        // Python is the most portable "spew 200 KB" we have on the runners
        // that already cover the rest of this module. If python isn't
        // installed we skip — the assertion would be meaningful only when
        // the subprocess actually ran.
        let body = "import sys; sys.stdout.write('x' * 200_000); sys.stdout.flush()";
        let started = Instant::now();
        let result = run_command_with_timeout("python", &["-c", body], 10, None);
        if !result.success
            && result.exit_code.is_none()
            && result.stderr.starts_with("failed to spawn")
        {
            eprintln!("skipping: python not on PATH");
            return;
        }
        assert!(!result.timed_out, "should not time out: {result:?}");
        assert!(result.success, "child should exit 0: {result:?}");
        assert_eq!(result.stdout.len(), 200_000);
        assert!(
            started.elapsed() < Duration::from_secs(8),
            "drain should be fast, took {:?}",
            started.elapsed()
        );
    }

    #[test]
    fn check_python_imports_skips_relative_imports() {
        // `from . import foo` must not be reported as missing — those are
        // resolved by Python's package system at test time, not by
        // __import__(name).
        let path = write_temp_py("relative", "from . import sibling\nimport os\n");
        let result = check_python_imports(&path);
        let _ = std::fs::remove_file(&path);
        if result.check_error.is_empty() {
            assert!(
                result.missing.is_empty(),
                "relative imports should be skipped, got missing: {:?}",
                result.missing,
            );
        }
    }
}