pathfinder-mcp 0.22.0

Pathfinder — The Headless IDE MCP Server for AI Coding Agents
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
use super::*;
use pathfinder_common::config::PathfinderConfig;
use pathfinder_common::sandbox::Sandbox;
use pathfinder_common::types::WorkspaceRoot;
use pathfinder_search::MockScout;
use pathfinder_treesitter::mock::MockSurgeon;
use std::sync::Arc;
use tempfile::tempdir;

// ── GAP-004: version_hash in text output ───────────────────────────────

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_read_symbol_scope_includes_version_hash_in_text() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);

    // Create a test file
    let file_path = ws.path().join("test.rs");
    let content = "fn test() {}\n";
    tokio::fs::write(&file_path, content).await.unwrap();

    let mock_surgeon = MockSurgeon::new();
    let expected_scope = pathfinder_common::types::SymbolScope {
        content: content.to_owned(),
        start_line: 1,
        end_line: 1,
        name_column: 0,
        language: "rust".to_owned(),
    };
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .push(Ok(expected_scope));

    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(mock_surgeon),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_path: Some("test.rs::test".to_owned()),
        ..Default::default()
    };

    let result = server.read_symbol_scope_impl(params).await;
    assert!(result.is_ok(), "read_symbol_scope should succeed");
    let call_result = result.unwrap();

    // Verify the text content is the symbol source
    if let Some(content) = call_result.content.first() {
        if let rmcp::model::RawContent::Text(text_content) = &content.raw {
            assert!(
                !text_content.text.is_empty(),
                "text output should be non-empty"
            );
        } else {
            panic!("Expected text content");
        }
    } else {
        panic!("Expected content");
    }
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_inspect_impl_routing() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);

    let file_path = ws.path().join("test.rs");
    let content = "fn test() {}\n";
    tokio::fs::write(&file_path, content).await.unwrap();

    let mock_surgeon = MockSurgeon::new();
    let expected_scope = pathfinder_common::types::SymbolScope {
        content: content.to_owned(),
        start_line: 1,
        end_line: 1,
        name_column: 0,
        language: "rust".to_owned(),
    };
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .push(Ok(expected_scope.clone()));
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .push(Ok(expected_scope.clone()));
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .push(Ok(expected_scope));

    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(mock_surgeon),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    // 1. inspect_impl with include_dependencies = false (delegates to read_symbol_scope_impl)
    let params_no_deps = InspectParams {
        semantic_path: Some("test.rs::test".to_owned()),
        include_dependencies: false,
        ..Default::default()
    };
    let res = server.inspect_impl(params_no_deps).await;
    assert!(res.is_ok());

    // 2. inspect_impl with include_dependencies = true (delegates to read_with_deep_context_impl)
    // This will degrade / fail because lsp is no-op, but we can verify it routes correctly
    let params_with_deps = InspectParams {
        semantic_path: Some("test.rs::test".to_owned()),
        include_dependencies: true,
        ..Default::default()
    };
    let res = server.inspect_impl(params_with_deps).await;
    // Because deep_context uses read_symbol_scope / LSP, it should fail or return degraded
    assert!(res.is_ok());
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_read_symbol_scope_require_symbol_target_fails() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);
    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(MockSurgeon::new()),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_path: Some("test.rs".to_owned()), // Missing symbol part
        ..Default::default()
    };
    let result = server.read_symbol_scope_impl(params).await;
    assert!(result.is_err());
    let err = result.unwrap_err();
    assert_eq!(err.code, rmcp::model::ErrorCode::INVALID_PARAMS);
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_read_symbol_scope_sandbox_check_fails() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);
    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(MockSurgeon::new()),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_path: Some("/etc/passwd::test".to_owned()), // Outside sandbox
        ..Default::default()
    };
    let result = server.read_symbol_scope_impl(params).await;
    assert!(result.is_err());
    let err = result.unwrap_err();
    assert_eq!(err.code, rmcp::model::ErrorCode(-32001)); // Access denied
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_read_symbol_scope_file_not_found() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);
    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(MockSurgeon::new()),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_path: Some("nonexistent.rs::test".to_owned()),
        ..Default::default()
    };
    let result = server.read_symbol_scope_impl(params).await;
    assert!(result.is_err());
    let err = result.unwrap_err();
    assert_eq!(err.code, rmcp::model::ErrorCode::INVALID_PARAMS); // File not found maps to invalid params
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_read_symbol_scope_surgeon_error() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);

    let file_path = ws.path().join("test.rs");
    let content = "fn test() {}\n";
    tokio::fs::write(&file_path, content).await.unwrap();

    let mock_surgeon = MockSurgeon::new();
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .push(Err(
            pathfinder_treesitter::error::SurgeonError::SymbolNotFound {
                path: "test".to_owned(),
                did_you_mean: vec![],
            },
        ));

    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(mock_surgeon),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_path: Some("test.rs::test".to_owned()),
        ..Default::default()
    };
    let result = server.read_symbol_scope_impl(params).await;
    assert!(result.is_err());
    let err = result.unwrap_err();
    assert_eq!(err.code, rmcp::model::ErrorCode::INVALID_PARAMS); // SymbolNotFound maps to invalid params
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_inspect_impl_invalid_max_dependencies() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);

    let file_path = ws.path().join("test.rs");
    let content = "fn test() {}\n";
    tokio::fs::write(&file_path, content).await.unwrap();

    let mock_surgeon = MockSurgeon::new();
    let expected_scope = pathfinder_common::types::SymbolScope {
        content: content.to_owned(),
        start_line: 1,
        end_line: 1,
        name_column: 0,
        language: "rust".to_owned(),
    };
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .push(Ok(expected_scope.clone()));
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .push(Ok(expected_scope));

    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(mock_surgeon),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    // Case 1: max_dependencies == 0
    let params = InspectParams {
        semantic_path: Some("test.rs::test".to_owned()),
        include_dependencies: true,
        max_dependencies: 0,
        ..Default::default()
    };
    let res = server.inspect_impl(params).await;
    assert!(res.is_err());
    assert_eq!(
        res.unwrap_err().code,
        rmcp::model::ErrorCode::INVALID_PARAMS
    );

    // Case 2: max_dependencies > 500
    let params = InspectParams {
        semantic_path: Some("test.rs::test".to_owned()),
        include_dependencies: true,
        max_dependencies: 501,
        ..Default::default()
    };
    let res = server.inspect_impl(params).await;
    assert!(res.is_err());
    assert_eq!(
        res.unwrap_err().code,
        rmcp::model::ErrorCode::INVALID_PARAMS
    );
}

// ── PATCH-005 backward-compat: single semantic_path returns ReadSymbolScopeMetadata ───

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_inspect_single_unchanged() {
    // Verify that single-path mode (no `semantic_paths`) still returns the old
    // `ReadSymbolScopeMetadata` format rather than the new `BatchInspectResult`.
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);

    let file_path = ws.path().join("test.rs");
    tokio::fs::write(&file_path, "fn test() {}\n")
        .await
        .unwrap();

    let mock_surgeon = MockSurgeon::new();
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .push(Ok(pathfinder_common::types::SymbolScope {
            content: "fn test() {}".to_owned(),
            start_line: 1,
            end_line: 1,
            name_column: 0,
            language: "rust".to_owned(),
        }));

    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(mock_surgeon),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_path: Some("test.rs::test".to_owned()),
        // semantic_paths is absent — must stay in single-path mode
        ..Default::default()
    };

    let result = server.inspect_impl(params).await.expect("should succeed");
    // Response must be the legacy ReadSymbolScopeMetadata shape, NOT BatchInspectResult
    let meta: crate::server::types::ReadSymbolScopeMetadata = serde_json::from_value(
        result
            .structured_content
            .expect("structured_content present"),
    )
    .expect("single-path mode must return ReadSymbolScopeMetadata, not BatchInspectResult");
    assert_eq!(meta.content, "fn test() {}");
    assert_eq!(meta.start_line, 1);
}

// ── PATCH-005 batch with include_dependencies=true ─────────────────────────

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_inspect_batch_with_dependencies() {
    // Verify batch inspect works when include_dependencies=true.
    // With NoOpLawyer, LSP is unavailable so dependencies are empty and
    // the result is degraded — but the BatchInspectResult structure is intact.
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);

    let file1 = ws.path().join("file1.rs");
    tokio::fs::write(&file1, "fn foo() {}\n").await.unwrap();
    let file2 = ws.path().join("file2.rs");
    tokio::fs::write(&file2, "fn bar() {}\n").await.unwrap();

    let mock_surgeon = MockSurgeon::new();
    // read_with_deep_context_impl calls read_symbol_scope TWICE per path:
    //   1. via read_symbol_scope_enriched (initial scope)
    //   2. via attempt_grep_fallback (NoOpLawyer → LSP unavailable → grep path)
    // Two paths → 4 total results queued.
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .extend([
            Ok(pathfinder_common::types::SymbolScope {
                content: "fn foo() {}".to_owned(),
                start_line: 1,
                end_line: 1,
                name_column: 0,
                language: "rust".to_owned(),
            }),
            Ok(pathfinder_common::types::SymbolScope {
                content: "fn foo() {}".to_owned(), // 2nd call for grep fallback
                start_line: 1,
                end_line: 1,
                name_column: 0,
                language: "rust".to_owned(),
            }),
            Ok(pathfinder_common::types::SymbolScope {
                content: "fn bar() {}".to_owned(),
                start_line: 1,
                end_line: 1,
                name_column: 0,
                language: "rust".to_owned(),
            }),
            Ok(pathfinder_common::types::SymbolScope {
                content: "fn bar() {}".to_owned(), // 2nd call for grep fallback
                start_line: 1,
                end_line: 1,
                name_column: 0,
                language: "rust".to_owned(),
            }),
        ]);

    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(mock_surgeon),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_paths: Some(vec!["file1.rs::foo".to_owned(), "file2.rs::bar".to_owned()]),
        include_dependencies: true,
        ..Default::default()
    };

    let result = server.inspect_impl(params).await.expect("should succeed");
    let val: crate::server::types::BatchInspectResult = serde_json::from_value(
        result
            .structured_content
            .expect("structured_content present"),
    )
    .expect("batch mode returns BatchInspectResult");

    assert_eq!(val.results.len(), 2);
    // Both entries must have dependencies field present (empty because NoOpLawyer)
    for entry in &val.results {
        assert_eq!(entry.status, "ok");
        assert!(
            entry.dependencies.is_some(),
            "include_dependencies=true must populate dependencies field"
        );
    }
    assert_eq!(val.succeeded, 2);
    assert_eq!(val.failed, 0);
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_inspect_batch_multiple_symbols() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);

    // Create test files
    let file1 = ws.path().join("file1.rs");
    tokio::fs::write(&file1, "fn foo() {}\n").await.unwrap();
    let file2 = ws.path().join("file2.rs");
    tokio::fs::write(&file2, "fn bar() {}\n").await.unwrap();

    let mock_surgeon = MockSurgeon::new();
    // Preload mock results: two scopes
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .extend([
            Ok(pathfinder_common::types::SymbolScope {
                content: "fn foo() {}".to_owned(),
                start_line: 1,
                end_line: 1,
                name_column: 0,
                language: "rust".to_owned(),
            }),
            Ok(pathfinder_common::types::SymbolScope {
                content: "fn bar() {}".to_owned(),
                start_line: 1,
                end_line: 1,
                name_column: 0,
                language: "rust".to_owned(),
            }),
        ]);

    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(mock_surgeon),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_paths: Some(vec!["file1.rs::foo".to_owned(), "file2.rs::bar".to_owned()]),
        ..Default::default()
    };

    let result = server.inspect_impl(params).await.expect("should succeed");
    let val: crate::server::types::BatchInspectResult = serde_json::from_value(
        result
            .structured_content
            .expect("missing structured_content"),
    )
    .expect("valid metadata");

    assert_eq!(val.succeeded, 2);
    assert_eq!(val.failed, 0);
    assert_eq!(val.results.len(), 2);
    assert_eq!(val.results[0].semantic_path, "file1.rs::foo");
    assert_eq!(val.results[0].status, "ok");
    assert_eq!(val.results[0].source, Some("fn foo() {}".to_owned()));
    assert_eq!(val.results[1].semantic_path, "file2.rs::bar");
    assert_eq!(val.results[1].status, "ok");
    assert_eq!(val.results[1].source, Some("fn bar() {}".to_owned()));
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_inspect_batch_partial_failure() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);

    let file1 = ws.path().join("file1.rs");
    tokio::fs::write(&file1, "fn foo() {}\n").await.unwrap();

    let mock_surgeon = MockSurgeon::new();
    mock_surgeon
        .read_symbol_scope_results
        .lock()
        .unwrap()
        .extend([Ok(pathfinder_common::types::SymbolScope {
            content: "fn foo() {}".to_owned(),
            start_line: 1,
            end_line: 1,
            name_column: 0,
            language: "rust".to_owned(),
        })]);

    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(mock_surgeon),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_paths: Some(vec![
            "file1.rs::foo".to_owned(),
            "nonexistent.rs::bar".to_owned(),
        ]),
        ..Default::default()
    };

    let result = server.inspect_impl(params).await.expect("should succeed");
    let val: crate::server::types::BatchInspectResult = serde_json::from_value(
        result
            .structured_content
            .expect("missing structured_content"),
    )
    .expect("valid metadata");

    assert_eq!(val.succeeded, 1);
    assert_eq!(val.failed, 1);
    assert_eq!(val.results.len(), 2);
    assert_eq!(val.results[0].status, "ok");
    assert_eq!(val.results[1].status, "error");
    assert!(val.results[1].error.is_some());
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_inspect_batch_max_10_limit() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);
    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(MockSurgeon::new()),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    // 11 paths
    let paths = (1..=11).map(|i| format!("file{i}.rs::foo")).collect();
    let params = InspectParams {
        semantic_paths: Some(paths),
        ..Default::default()
    };

    let result = server.inspect_impl(params).await;
    assert!(result.is_err());
    assert_eq!(
        result.unwrap_err().code,
        rmcp::model::ErrorCode::INVALID_PARAMS
    );
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_inspect_batch_mutual_exclusion_both_params_errors() {
    // Providing both semantic_path AND semantic_paths simultaneously must return INVALID_PARAMS.
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);
    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(MockSurgeon::new()),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_path: Some("file.rs::foo".to_owned()),
        semantic_paths: Some(vec!["file.rs::bar".to_owned()]),
        ..Default::default()
    };

    let result = server.inspect_impl(params).await;
    assert!(result.is_err());
    let err = result.unwrap_err();
    assert_eq!(
        err.code,
        rmcp::model::ErrorCode::INVALID_PARAMS,
        "both semantic_path and semantic_paths must return INVALID_PARAMS, got: {:?}",
        err.message
    );
}

#[tokio::test]
#[allow(clippy::unwrap_used)]
async fn test_inspect_batch_empty_returns_error() {
    let ws_dir = tempdir().unwrap();
    let ws = WorkspaceRoot::new(ws_dir.path()).unwrap();
    let config = PathfinderConfig::default();
    let sandbox = Sandbox::new(ws.path(), &config.sandbox);
    let server = crate::server::PathfinderServer::with_all_engines(
        ws,
        config,
        sandbox,
        Arc::new(MockScout::default()),
        Arc::new(MockSurgeon::new()),
        Arc::new(pathfinder_lsp::NoOpLawyer),
    );

    let params = InspectParams {
        semantic_paths: Some(vec![]),
        ..Default::default()
    };

    let result = server.inspect_impl(params).await;
    assert!(result.is_err());
    assert_eq!(
        result.unwrap_err().code,
        rmcp::model::ErrorCode::INVALID_PARAMS
    );
}