Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions crates/tinymemory-tools/src/recall/gather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ async fn with_listed_beliefs(
engine: &dyn MemoryEngine,
section: &ScopeSection,
want: usize,
keep: &dyn Fn(&Hit) -> bool,
keep: &(dyn Fn(&Hit) -> bool + Sync),
) -> tinymemory_api::Result<(Vec<Hit>, Vec<Hit>)> {
if !reads_learnings(section) {
return Ok((
Expand Down Expand Up @@ -324,7 +324,7 @@ async fn fetch(
query: &str,
limit: usize,
beliefs: usize,
keep: &dyn Fn(&Hit) -> bool,
keep: &(dyn Fn(&Hit) -> bool + Sync),
) -> tinymemory_api::Result<(Vec<Hit>, Vec<Hit>)> {
let Some(mode) = preferred_mode(engine) else {
return Ok((latest(engine, filter, limit, keep).await?, Vec::new()));
Expand All @@ -347,7 +347,7 @@ async fn latest(
engine: &dyn MemoryEngine,
filter: &MetaFilter,
limit: usize,
keep: &dyn Fn(&Hit) -> bool,
keep: &(dyn Fn(&Hit) -> bool + Sync),
) -> tinymemory_api::Result<Vec<Hit>> {
let mut all: Vec<Hit> = Vec::new();
let mut cursor: Option<String> = None;
Expand Down
16 changes: 16 additions & 0 deletions crates/tinymemory-tools/src/recall/mod_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,19 @@ async fn a_belief_the_filter_rules_out_is_left_out() {
.unwrap();
assert!(!pack.markdown.contains("pnpm"), "{}", pack.markdown);
}

/// Hosts run recall on multi-threaded runtimes (a spawned pre-turn, an
/// `async_trait` method), which need its future to be `Send`. Every
/// reference it holds across an `.await` must therefore be `Sync`,
/// including the `keep` predicate the gathering passes down.
#[test]
fn a_recall_future_can_cross_threads() {
fn send<T: Send>(_: &T) {}
let engine = ReferenceEngine::new();
let request = HolisticRecall::new(
Some("refunds".into()),
vec![ScopeSection::fetch("Docs", docs(), 5)],
);
let future = holistic_recall(&engine, &request);
send(&future);
}
Loading