Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/memory/retrieval/fast_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,50 @@ async fn local_branch_intersects_entities_and_applies_scope_before_limit() {
assert_eq!(response.hits[0].node_id, "allowed");
assert_eq!(response.hits[0].score, 2.0);
}

#[tokio::test]
async fn dense_fallback_filters_by_mem_src_collection_id() {
let (_temp, config) = test_config();
insert_tree_row(
&config,
&source_tree(
"note-tree",
"mem_src:src_vault_hob_local:path/to/note.md",
Some("note"),
1,
),
);
insert_summary(
&config,
&summary_node("note", "note-tree", 1, None, &[], "note", fixed_ts()),
);

let allowed = HashSet::from(["src_vault_hob_local".to_string()]);
let response = fast_retrieve(
&config,
"note",
&[],
&InertEmbedder,
Some(&allowed),
FastRetrieveOptions::default(),
)
.await
.unwrap();
assert_eq!(response.total, 1);
assert_eq!(response.hits[0].node_id, "note");

// A scope naming a different collection filters the hit out.
let denied = HashSet::from(["other_collection".to_string()]);
let response = fast_retrieve(
&config,
"note",
&[],
&InertEmbedder,
Some(&denied),
FastRetrieveOptions::default(),
)
.await
.unwrap();
assert_eq!(response.total, 0);
assert!(response.hits.is_empty());
}