frigg 0.3.1

Local-first MCP server for code understanding.
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
735
736
737
738
739
740
741
742
use super::*;

#[test]
fn hybrid_ranking_cli_entrypoint_queries_prefer_cli_test_witnesses_over_runtime_noise()
-> FriggResult<()> {
    let root = temp_workspace_root("hybrid-rust-cli-test-witnesses");
    prepare_workspace(
        &root,
        &[
            (
                "crates/ruff/src/commands/analyze_graph.rs",
                "pub fn analyze_graph() { let _ = \"ruff analyze\"; }\n",
            ),
            (
                "crates/ruff_linter/src/checkers/ast/analyze/expression.rs",
                "pub fn analyze_expression() { let _ = \"ruff analyze\"; }\n",
            ),
            (
                "crates/ruff_linter/src/checkers/ast/analyze/module.rs",
                "pub fn analyze_module() { let _ = \"ruff analyze\"; }\n",
            ),
            (
                "crates/ruff_linter/src/checkers/ast/analyze/suite.rs",
                "pub fn analyze_suite() { let _ = \"ruff analyze\"; }\n",
            ),
            (
                "crates/ruff_linter/src/lib.rs",
                "pub fn lib_runtime() { let _ = \"ruff analyze\"; }\n",
            ),
            (
                "crates/ruff_linter/resources/test/fixtures/isort/pyproject.toml",
                "[tool.ruff]\nline-length = 88\n",
            ),
            (
                "crates/ruff/tests/integration_test.rs",
                "mod integration_test {}\n",
            ),
            (
                ".github/workflows/ci.yaml",
                "ruff analyze cli entrypoint workflow\n",
            ),
            (
                "crates/ruff/tests/cli/analyze_graph.rs",
                "mod cli_analyze_graph {}\n",
            ),
            ("crates/ruff/tests/cli/main.rs", "mod cli_main {}\n"),
            ("crates/ruff/tests/cli/format.rs", "mod cli_format {}\n"),
            ("crates/ruff/tests/cli/lint.rs", "mod cli_lint {}\n"),
            ("crates/ruff/tests/config.rs", "mod config_test {}\n"),
        ],
    )?;

    let searcher = TextSearcher::new(FriggConfig::from_workspace_roots(vec![root.clone()])?);
    let output = searcher.search_hybrid_with_filters_using_executor(
        SearchHybridQuery {
            query: "ruff analyze ruff cli entrypoint".to_owned(),
            limit: 5,
            weights: HybridChannelWeights::default(),
            semantic: Some(false),
        },
        SearchFilters::default(),
        &SemanticRuntimeCredentials::default(),
        &PanicSemanticQueryEmbeddingExecutor,
    )?;

    let ranked_paths = output
        .matches
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();
    assert!(
        ranked_paths
            .iter()
            .take(4)
            .any(|path| *path == "crates/ruff/tests/cli/analyze_graph.rs"),
        "CLI analyze_graph test witness should land near the top for the saved query: {ranked_paths:?}"
    );
    assert!(
        ranked_paths
            .iter()
            .take(5)
            .any(|path| *path == "crates/ruff/tests/cli/main.rs"),
        "secondary CLI test witness should remain visible near the top: {ranked_paths:?}"
    );

    cleanup_workspace(&root);
    Ok(())
}

#[test]
fn hybrid_ranking_ci_workflow_queries_surface_hidden_workflow_witnesses() -> FriggResult<()> {
    let root = temp_workspace_root("hybrid-ci-workflow-witnesses");
    prepare_workspace(
        &root,
        &[
            (
                ".github/workflows/autofix.yml",
                "name: autofix.ci\njobs:\n  autofix:\n    steps:\n      - run: cargo codegen\n",
            ),
            (
                ".github/workflows/bench_cli.yml",
                "name: Bench CLI\njobs:\n  bench:\n    steps:\n      - run: cargo bench\n",
            ),
            (
                "crates/noise/src/github.rs",
                "pub fn github_reporter() { let _ = \"github workflow autofix\"; }\n",
            ),
            (
                "crates/noise/src/autofix.rs",
                "pub fn autofix_runtime() { let _ = \"autofix runtime\"; }\n",
            ),
        ],
    )?;

    let searcher = TextSearcher::new(FriggConfig::from_workspace_roots(vec![root.clone()])?);
    let output = searcher.search_hybrid_with_filters_using_executor(
        SearchHybridQuery {
            query: "github workflow autofix bench cli".to_owned(),
            limit: 4,
            weights: HybridChannelWeights::default(),
            semantic: Some(false),
        },
        SearchFilters::default(),
        &SemanticRuntimeCredentials::default(),
        &PanicSemanticQueryEmbeddingExecutor,
    )?;

    let ranked_paths = output
        .matches
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();
    assert!(
        ranked_paths.iter().take(4).any(|path| matches!(
            *path,
            ".github/workflows/autofix.yml" | ".github/workflows/bench_cli.yml"
        )),
        "CI workflow query should surface a hidden workflow witness in top-k: {ranked_paths:?}"
    );

    cleanup_workspace(&root);
    Ok(())
}

#[test]
fn hybrid_ranking_scripts_ops_queries_surface_script_and_justfile_witnesses() -> FriggResult<()> {
    let root = temp_workspace_root("hybrid-scripts-ops-witnesses");
    prepare_workspace(
        &root,
        &[
            ("justfile", "fmt:\n\tcargo fmt\n"),
            (
                "scripts/print-changelog.sh",
                "#!/usr/bin/env bash\necho changelog\n",
            ),
            (
                "scripts/update-manifests.mjs",
                "console.log('update manifests');\n",
            ),
            ("docs/changelog.md", "# Changelog\nupdate notes\n"),
            ("src/version.rs", "pub const VERSION: &str = \"1.0.0\";\n"),
        ],
    )?;

    let searcher = TextSearcher::new(FriggConfig::from_workspace_roots(vec![root.clone()])?);
    let output = searcher.search_hybrid_with_filters_using_executor(
        SearchHybridQuery {
            query: "scripts justfile changelog manifests".to_owned(),
            limit: 4,
            weights: HybridChannelWeights::default(),
            semantic: Some(false),
        },
        SearchFilters::default(),
        &SemanticRuntimeCredentials::default(),
        &PanicSemanticQueryEmbeddingExecutor,
    )?;

    let ranked_paths = output
        .matches
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();
    assert!(
        ranked_paths.iter().take(4).any(|path| matches!(
            *path,
            "justfile" | "scripts/print-changelog.sh" | "scripts/update-manifests.mjs"
        )),
        "scripts/ops query should surface a concrete script witness in top-k: {ranked_paths:?}"
    );

    cleanup_workspace(&root);
    Ok(())
}

#[ignore = "workstream-c escalation target"]
#[test]
fn hybrid_ranking_entrypoint_queries_surface_build_workflow_configs() -> FriggResult<()> {
    let root = temp_workspace_root("hybrid-rust-entrypoint-build-workflows");
    prepare_workspace(
        &root,
        &[
            (
                "src-tauri/src/main.rs",
                "fn main() {\n\
                     let config = AppConfig::load();\n\
                     run_pipeline(&config);\n\
                     }\n",
            ),
            (
                "src-tauri/src/lib.rs",
                "pub fn run() {\n\
                     let config = AppConfig::load();\n\
                     run_pipeline(&config);\n\
                     }\n",
            ),
            (
                "src-tauri/src/proxy/config.rs",
                "pub struct ProxyConfig;\n\
                     impl ProxyConfig { pub fn load() -> Self { Self } }\n",
            ),
            (
                "src-tauri/src/modules/config.rs",
                "pub struct ModuleConfig;\n\
                     impl ModuleConfig { pub fn load() -> Self { Self } }\n",
            ),
            (
                "src-tauri/src/models/config.rs",
                "pub struct AppConfig;\n\
                     impl AppConfig { pub fn load() -> Self { Self } }\n",
            ),
            (
                "src-tauri/src/proxy/proxy_pool.rs",
                "pub struct ProxyPool;\n\
                     impl ProxyPool { pub fn runner() -> Self { Self } }\n",
            ),
            (
                "src-tauri/src/commands/security.rs",
                "pub fn security_command_runner() {}\n",
            ),
            ("src-tauri/build.rs", "fn main() { tauri_build::build() }\n"),
            (
                ".github/workflows/deploy-pages.yml",
                "name: Deploy static content to Pages\n\
                     jobs:\n\
                       deploy:\n\
                         steps:\n\
                           - name: Deploy to GitHub Pages\n",
            ),
            (
                ".github/workflows/release.yml",
                "name: Release\n\
                     jobs:\n\
                       build-tauri:\n\
                         steps:\n\
                           - name: Build the app\n",
            ),
        ],
    )?;

    let searcher = TextSearcher::new(FriggConfig::from_workspace_roots(vec![root.clone()])?);
    let output = searcher.search_hybrid_with_filters_using_executor_with_trace(
        SearchHybridQuery {
            query: "entry point bootstrap build flow command runner main config".to_owned(),
            limit: 8,
            weights: HybridChannelWeights::default(),
            semantic: Some(false),
        },
        SearchFilters::default(),
        &SemanticRuntimeCredentials::default(),
        &PanicSemanticQueryEmbeddingExecutor,
    )?;

    let ranked_paths = output
        .matches
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();
    let witness_paths = output
        .channel_results
        .iter()
        .find(|result| result.channel == crate::domain::EvidenceChannel::PathSurfaceWitness)
        .map(|result| {
            result
                .hits
                .iter()
                .map(|hit| hit.document.path.as_str())
                .collect::<Vec<_>>()
        })
        .unwrap_or_default();
    let anchor_paths = output
        .ranked_anchors
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();
    let grouped_paths = output
        .coverage_grouped_pool
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();
    assert!(
        ranked_paths
            .iter()
            .take(8)
            .any(|path| *path == "src-tauri/src/main.rs"),
        "entrypoint runtime witness should remain visible near the top: {ranked_paths:?}"
    );
    assert!(
        ranked_paths.iter().take(8).any(|path| {
            matches!(
                *path,
                ".github/workflows/deploy-pages.yml" | ".github/workflows/release.yml"
            )
        }),
        "entrypoint/build-flow queries should surface at least one GitHub workflow config witness in top-k: ranked={ranked_paths:?} witness={witness_paths:?} anchors={anchor_paths:?} grouped={grouped_paths:?} trace={:?}",
        output.post_selection_trace
    );

    cleanup_workspace(&root);
    Ok(())
}

#[test]
fn hybrid_ranking_entrypoint_build_flow_queries_keep_runtime_entrypoints_visible_under_workflow_crowding()
-> FriggResult<()> {
    let root = temp_workspace_root("hybrid-rust-entrypoint-vs-workflow-crowding");
    prepare_workspace(
        &root,
        &[
            (
                "crates/ruff/src/main.rs",
                "fn main() { let _ = \"entry point bootstrap build flow command runner main\"; }\n",
            ),
            (
                "crates/ruff_dev/src/main.rs",
                "fn main() { let _ = \"entry point bootstrap build flow command runner main\"; }\n",
            ),
            (
                "crates/ruff_python_formatter/src/main.rs",
                "fn main() { let _ = \"entry point bootstrap build flow command runner main\"; }\n",
            ),
            (
                "crates/ty/src/main.rs",
                "fn main() { let _ = \"entry point bootstrap build flow command runner main\"; }\n",
            ),
            (
                "crates/ty_completion_bench/src/main.rs",
                "fn main() { let _ = \"entry point bootstrap build flow command runner main\"; }\n",
            ),
            (
                ".github/workflows/build-binaries.yml",
                "name: Build binaries\njobs:\n  build:\n    steps:\n      - run: cargo build --release --bin ruff\n",
            ),
            (
                ".github/workflows/build-docker.yml",
                "name: Build docker\njobs:\n  build:\n    steps:\n      - run: docker build .\n",
            ),
            (
                ".github/workflows/build-wasm.yml",
                "name: Build wasm\njobs:\n  build:\n    steps:\n      - run: cargo build --target wasm32-unknown-unknown\n",
            ),
            (
                ".github/workflows/publish-playground.yml",
                "name: Publish playground\njobs:\n  publish:\n    steps:\n      - run: cargo run --bin playground\n",
            ),
            (
                ".github/workflows/publish-ty-playground.yml",
                "name: Publish ty playground\njobs:\n  publish:\n    steps:\n      - run: cargo run --bin ty-playground\n",
            ),
            (
                ".github/workflows/release.yml",
                "name: Release\njobs:\n  release:\n    steps:\n      - run: cargo build --release\n",
            ),
            (
                ".github/workflows/publish-docs.yml",
                "name: Publish docs\njobs:\n  publish:\n    steps:\n      - run: cargo doc --no-deps\n",
            ),
            (
                ".github/workflows/publish-mirror.yml",
                "name: Publish mirror\njobs:\n  publish:\n    steps:\n      - run: echo mirror\n",
            ),
            (
                ".github/workflows/publish-pypi.yml",
                "name: Publish pypi\njobs:\n  publish:\n    steps:\n      - run: maturin publish\n",
            ),
            (
                ".github/workflows/publish-versions.yml",
                "name: Publish versions\njobs:\n  publish:\n    steps:\n      - run: cargo metadata --format-version 1\n",
            ),
            (
                ".github/workflows/publish-wasm.yml",
                "name: Publish wasm\njobs:\n  publish:\n    steps:\n      - run: wasm-pack build\n",
            ),
        ],
    )?;

    let searcher = TextSearcher::new(FriggConfig::from_workspace_roots(vec![root.clone()])?);
    let output = searcher.search_hybrid_with_filters_using_executor(
        SearchHybridQuery {
            query: "entry point bootstrap build flow command runner main".to_owned(),
            limit: 11,
            weights: HybridChannelWeights::default(),
            semantic: Some(false),
        },
        SearchFilters::default(),
        &SemanticRuntimeCredentials::default(),
        &PanicSemanticQueryEmbeddingExecutor,
    )?;

    let ranked_paths = output
        .matches
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();

    assert!(
        ranked_paths.iter().take(11).any(|path| {
            matches!(
                *path,
                "crates/ruff/src/main.rs"
                    | "crates/ruff_dev/src/main.rs"
                    | "crates/ruff_python_formatter/src/main.rs"
                    | "crates/ty/src/main.rs"
                    | "crates/ty_completion_bench/src/main.rs"
            )
        }),
        "a runtime entrypoint witness should remain visible under workflow crowding: {ranked_paths:?}"
    );
    assert!(
        ranked_paths
            .iter()
            .take(11)
            .any(|path| path.starts_with(".github/workflows/")),
        "workflow witnesses should remain visible for entrypoint build-flow queries: {ranked_paths:?}"
    );

    cleanup_workspace(&root);
    Ok(())
}

#[test]
fn hybrid_ranking_entrypoint_build_flow_queries_recover_bat_build_config_witnesses()
-> FriggResult<()> {
    let root = temp_workspace_root("hybrid-rust-bat-build-config-witnesses");
    prepare_workspace(
        &root,
        &[
            (
                "Cargo.toml",
                "[package]\nname = \"bat\"\nversion = \"0.1.0\"\nedition = \"2021\"\n",
            ),
            ("rustfmt.toml", "edition = \"2021\"\n"),
            (
                ".github/workflows/CICD.yml",
                "name: CICD\njobs:\n  build:\n    steps:\n      - run: cargo build --locked\n",
            ),
            (
                ".github/workflows/require-changelog-for-PRs.yml",
                "name: Require changelog\njobs:\n  check:\n    steps:\n      - run: ./tests/scripts/license-checks.sh\n",
            ),
            (
                "src/lib.rs",
                "pub fn run() { let _ = \"entry point bootstrap build flow command runner main\"; }\n",
            ),
            (
                "src/bin/bat/main.rs",
                "fn main() { let _ = \"entry point bootstrap build flow command runner main\"; }\n",
            ),
            ("src/bin/bat/app.rs", "pub fn build_app() {}\n"),
            ("src/bin/bat/assets.rs", "pub fn build_assets() {}\n"),
            ("src/bin/bat/clap_app.rs", "pub fn clap_app() {}\n"),
            (
                "src/bin/bat/completions.rs",
                "pub fn generate_completions() {}\n",
            ),
            ("src/bin/bat/config.rs", "pub fn load_bat_config() {}\n"),
            ("src/config.rs", "pub struct RuntimeConfig;\n"),
            ("tests/scripts/license-checks.sh", "#!/bin/sh\necho check\n"),
            (
                "tests/examples/system_config/bat/config",
                "--theme=\"TwoDark\"\n",
            ),
            (
                "tests/syntax-tests/highlighted/Elixir/command.ex",
                "defmodule Command do\nend\n",
            ),
            (
                "tests/syntax-tests/highlighted/Go/main.go",
                "package main\nfunc main() {}\n",
            ),
            (
                "tests/syntax-tests/source/Elixir/command.ex",
                "defmodule Command do\nend\n",
            ),
            (
                "tests/syntax-tests/source/Go/main.go",
                "package main\nfunc main() {}\n",
            ),
        ],
    )?;

    let searcher = TextSearcher::new(FriggConfig::from_workspace_roots(vec![root.clone()])?);
    let output = searcher.search_hybrid_with_filters_using_executor(
            SearchHybridQuery {
                query: "entry point bootstrap build flow command runner main config cargo github workflow cicd require changelog".to_owned(),
                limit: 11,
                weights: HybridChannelWeights::default(),
                semantic: Some(false),
            },
            SearchFilters::default(),
            &SemanticRuntimeCredentials::default(),
            &PanicSemanticQueryEmbeddingExecutor,
        )?;

    let ranked_paths = output
        .matches
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();

    assert!(
        ranked_paths.iter().take(11).any(|path| {
            matches!(
                *path,
                "Cargo.toml"
                    | ".github/workflows/CICD.yml"
                    | ".github/workflows/require-changelog-for-PRs.yml"
            )
        }),
        "build-config entrypoint queries should recover a Cargo/workflow witness in top-k: {ranked_paths:?}"
    );

    cleanup_workspace(&root);
    Ok(())
}

#[test]
fn hybrid_ranking_entrypoint_queries_surface_build_workflow_configs_with_semantic_runtime()
-> FriggResult<()> {
    let root = temp_workspace_root("hybrid-rust-entrypoint-build-workflows-semantic");
    prepare_workspace(
        &root,
        &[
            (
                "src-tauri/src/main.rs",
                "fn main() {\n\
                     // entry point bootstrap build flow command runner main config\n\
                     let config = load_config();\n\
                     run_build_flow(config);\n\
                     }\n",
            ),
            (
                "src-tauri/src/proxy/config.rs",
                "pub struct ProxyConfig;\n// entry point bootstrap build flow command runner main config\n",
            ),
            (
                "src-tauri/src/lib.rs",
                "pub fn run() {\n// entry point bootstrap build flow command runner main config\n}\n",
            ),
            (
                "src-tauri/src/modules/config.rs",
                "pub struct ModuleConfig;\n// entry point bootstrap build flow command runner main config\n",
            ),
            (
                "src-tauri/src/models/config.rs",
                "pub struct ModelConfig;\n// entry point bootstrap build flow command runner main config\n",
            ),
            (
                "src-tauri/src/proxy/proxy_pool.rs",
                "pub struct ProxyPool;\n// entry point bootstrap build flow command runner main config\n",
            ),
            (
                "src-tauri/build.rs",
                "fn main() {\n tauri_build::build();\n}\n",
            ),
            (
                "src-tauri/src/commands/security.rs",
                "pub fn security_command() {\n// entry point bootstrap build flow command runner main config\n}\n",
            ),
            (
                ".github/workflows/deploy-pages.yml",
                "name: Deploy static content to Pages\n\
                     jobs:\n\
                       deploy:\n\
                         steps:\n\
                           - name: Upload artifact\n\
                             run: echo upload build artifacts\n\
                           - name: Deploy to GitHub Pages\n\
                             run: echo deploy release pages\n",
            ),
            (
                ".github/workflows/release.yml",
                "name: Release\n\
                     jobs:\n\
                       build-tauri:\n\
                         steps:\n\
                           - name: Build the app\n\
                             run: cargo build --release\n\
                           - name: Publish release artifacts\n\
                             run: echo publish release artifacts\n",
            ),
        ],
    )?;
    seed_semantic_embeddings(
        &root,
        "repo-001",
        "snapshot-001",
        &[
            semantic_record(
                "repo-001",
                "snapshot-001",
                "src-tauri/src/main.rs",
                0,
                vec![1.0, 0.0],
            ),
            semantic_record(
                "repo-001",
                "snapshot-001",
                "src-tauri/src/proxy/config.rs",
                0,
                vec![0.99, 0.0],
            ),
            semantic_record(
                "repo-001",
                "snapshot-001",
                "src-tauri/src/lib.rs",
                0,
                vec![0.98, 0.0],
            ),
            semantic_record(
                "repo-001",
                "snapshot-001",
                "src-tauri/src/modules/config.rs",
                0,
                vec![0.97, 0.0],
            ),
            semantic_record(
                "repo-001",
                "snapshot-001",
                "src-tauri/src/models/config.rs",
                0,
                vec![0.96, 0.0],
            ),
            semantic_record(
                "repo-001",
                "snapshot-001",
                "src-tauri/src/proxy/proxy_pool.rs",
                0,
                vec![0.95, 0.0],
            ),
            semantic_record(
                "repo-001",
                "snapshot-001",
                "src-tauri/build.rs",
                0,
                vec![0.94, 0.0],
            ),
            semantic_record(
                "repo-001",
                "snapshot-001",
                "src-tauri/src/commands/security.rs",
                0,
                vec![0.93, 0.0],
            ),
            semantic_record(
                "repo-001",
                "snapshot-001",
                ".github/workflows/release.yml",
                0,
                vec![0.82, 0.0],
            ),
            semantic_record(
                "repo-001",
                "snapshot-001",
                ".github/workflows/deploy-pages.yml",
                0,
                vec![0.81, 0.0],
            ),
        ],
    )?;

    let mut config = FriggConfig::from_workspace_roots(vec![root.clone()])?;
    config.semantic_runtime = semantic_runtime_enabled(false);
    config.max_search_results = 8;
    let searcher = TextSearcher::new(config);
    let output = searcher.search_hybrid_with_filters_using_executor_with_trace(
        SearchHybridQuery {
            query: "entry point bootstrap build flow command runner main config".to_owned(),
            limit: 8,
            weights: HybridChannelWeights::default(),
            semantic: Some(true),
        },
        SearchFilters::default(),
        &SemanticRuntimeCredentials {
            openai_api_key: Some("test-openai-key".to_owned()),
            gemini_api_key: None,
        },
        &MockSemanticQueryEmbeddingExecutor::success(vec![1.0, 0.0]),
    )?;

    assert_eq!(output.note.semantic_status, HybridSemanticStatus::Ok);

    let ranked_paths = output
        .matches
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();
    let witness_paths = output
        .channel_results
        .iter()
        .find(|result| result.channel == crate::domain::EvidenceChannel::PathSurfaceWitness)
        .map(|result| {
            result
                .hits
                .iter()
                .map(|hit| hit.document.path.as_str())
                .collect::<Vec<_>>()
        })
        .unwrap_or_default();
    let anchor_paths = output
        .ranked_anchors
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();
    let grouped_paths = output
        .coverage_grouped_pool
        .iter()
        .map(|entry| entry.document.path.as_str())
        .collect::<Vec<_>>();
    assert!(
        ranked_paths.iter().take(8).any(|path| {
            matches!(
                *path,
                ".github/workflows/deploy-pages.yml" | ".github/workflows/release.yml"
            )
        }),
        "entrypoint/build-flow queries should keep a workflow config witness visible even under semantic runtime pressure: ranked={ranked_paths:?} witness={witness_paths:?} anchors={anchor_paths:?} grouped={grouped_paths:?} trace={:?}",
        output.post_selection_trace
    );

    cleanup_workspace(&root);
    Ok(())
}