feat: integrate Google semantic search and branded desktop launcher
Core CI / core (ubuntu-latest) (push) Failing after 3m27s
Core CI / core (macos-latest) (push) Canceled after 0s
Core CI / core (windows-latest) (push) Canceled after 0s
Core CI / desktop (ubuntu-latest) (push) Successful in 5m45s
Core CI / desktop (macos-latest) (push) Canceled after 0s
Core CI / desktop (windows-latest) (push) Canceled after 0s
Core CI / core (ubuntu-latest) (push) Failing after 3m27s
Core CI / core (macos-latest) (push) Canceled after 0s
Core CI / core (windows-latest) (push) Canceled after 0s
Core CI / desktop (ubuntu-latest) (push) Successful in 5m45s
Core CI / desktop (macos-latest) (push) Canceled after 0s
Core CI / desktop (windows-latest) (push) Canceled after 0s
This commit is contained in:
1 parent
a90df15503
commit
caf6a2f82e
80 files changed
+14971
-837
No files matched your search
@@ -123,3 +123,106 @@ fn v4_migration_backfills_names_and_preserves_passage_ids() -> Result<()> {
|
||||
assert_eq!(index.passage_batch(0, 1)?[0].id, 88);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn background_statistics_preserve_results_across_reopen_and_changes() -> Result<()> {
|
||||
let root = tempfile::tempdir()?;
|
||||
let db = root.path().join("index.db");
|
||||
fs::write(root.path().join("invoice_1042.txt"), "billing evidence")?;
|
||||
let mut index = SearchIndex::open(&db)?;
|
||||
index.index_folder(root.path())?;
|
||||
assert!(index.prewarm()? > 0);
|
||||
drop(index);
|
||||
let mut index = SearchIndex::open(&db)?;
|
||||
assert_eq!(index.search("1042", 1)?[0].filename, "invoice_1042.txt");
|
||||
fs::rename(
|
||||
root.path().join("invoice_1042.txt"),
|
||||
root.path().join("new_pattern.txt"),
|
||||
)?;
|
||||
index.index_folder(root.path())?;
|
||||
// Stale statistics affect only candidate cost, never substring correctness.
|
||||
assert_eq!(index.search("pattern", 1)?[0].filename, "new_pattern.txt");
|
||||
assert!(index.search("1042", 1)?.is_empty());
|
||||
index.prewarm()?;
|
||||
assert_eq!(index.search("pattern", 1)?[0].filename, "new_pattern.txt");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn positional_candidates_preserve_repeated_identifiers_unicode_and_path_matches() -> Result<()> {
|
||||
let root = tempfile::tempdir()?;
|
||||
let nested = root.path().join("folder_0000001_rare");
|
||||
fs::create_dir(&nested)?;
|
||||
for (name, text) in [
|
||||
("ζαζα_0000001_rare.txt", "first source"),
|
||||
("ζαζα_0000101_rare.txt", "second source"),
|
||||
("backup_ζαζα_0000001_rare.txt", "backup source"),
|
||||
] {
|
||||
fs::write(root.path().join(name), text)?;
|
||||
}
|
||||
fs::write(nested.join("other.md"), "path source")?;
|
||||
let mut index = SearchIndex::open(":memory:")?;
|
||||
index.index_folder(root.path())?;
|
||||
index.prewarm()?;
|
||||
let matches = index.search("0000001_rare", 20)?;
|
||||
assert_eq!(matches.len(), 3);
|
||||
assert_eq!(matches[0].match_kind, "filename");
|
||||
assert_eq!(matches[1].match_kind, "filename");
|
||||
assert_eq!(matches[2].match_kind, "path");
|
||||
assert_eq!(
|
||||
index.search("ζαζα_0000101_rare", 1)?[0].filename,
|
||||
"ζαζα_0000101_rare.txt"
|
||||
);
|
||||
let filtered = SearchOptions {
|
||||
folder: Some(nested),
|
||||
extension: Some("md".into()),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(
|
||||
index.search_with_options("0000001_rare", 1, &filtered)?[0].filename,
|
||||
"other.md"
|
||||
);
|
||||
assert!(index.search("0000010_rare", 20)?.is_empty());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn candidate_first_content_matches_complete_filtered_ranking_and_sources() -> Result<()> {
|
||||
let root = tempfile::tempdir()?;
|
||||
fs::write(root.path().join("needle.txt"), "needle once")?;
|
||||
for number in 0..50 {
|
||||
let text = format!(
|
||||
"{} background evidence {}",
|
||||
"needle ".repeat(number % 7 + 1),
|
||||
"filler ".repeat(number % 5)
|
||||
);
|
||||
fs::write(root.path().join(format!("notes_{number:03}.md")), text)?;
|
||||
}
|
||||
let mut index = SearchIndex::open(":memory:")?;
|
||||
index.index_folder(root.path())?;
|
||||
index.prewarm()?;
|
||||
let fast = index.search("needle", 20)?;
|
||||
// This nonrestrictive filter selects the normal complete filtered lane.
|
||||
let filtered = index.search_with_options(
|
||||
"needle",
|
||||
20,
|
||||
&SearchOptions {
|
||||
min_size: Some(0),
|
||||
..Default::default()
|
||||
},
|
||||
)?;
|
||||
assert_eq!(fast.len(), 20);
|
||||
assert_eq!(filtered.len(), 20);
|
||||
for (fast, filtered) in fast.iter().zip(&filtered) {
|
||||
assert_eq!(fast.path, filtered.path);
|
||||
assert_eq!(fast.match_kind, filtered.match_kind);
|
||||
assert!((fast.score - filtered.score).abs() < 1e-12);
|
||||
assert_eq!(fast.snippet, filtered.snippet);
|
||||
assert_eq!(
|
||||
fast.source.as_ref().unwrap().number,
|
||||
filtered.source.as_ref().unwrap().number
|
||||
);
|
||||
}
|
||||
assert_eq!(fast[0].match_kind, "filename");
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user