Improve cross_device MemFuse recall with source tags and recallContext.
Auto-enable device/location prefixes for cross_device scenarios, thread question_device into keyword and embedding paths, and boost lexical scores from source-tag tokens. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -353,6 +353,26 @@ test('extractKeywordTerms prioritizes proper nouns over generic English terms',
|
||||
assert.equal(terms.includes('soccer'), true);
|
||||
});
|
||||
|
||||
test('mergeKeywordTerms prioritizes recallContext device tokens', () => {
|
||||
const { mergeKeywordTerms } = pgvectorMemoryBackendInternals;
|
||||
const terms = mergeKeywordTerms(
|
||||
'What happened this morning?',
|
||||
{ device: 'phone_sarah', user: 'Sarah' },
|
||||
{ maxTerms: 8 },
|
||||
);
|
||||
assert.equal(terms.includes('sarah'), true);
|
||||
assert.equal(terms.includes('phone'), true);
|
||||
assert.ok(terms.indexOf('phone') < terms.indexOf('morning'));
|
||||
});
|
||||
|
||||
test('latinWordQueryCoverage boosts tagged device tokens in source prefix', () => {
|
||||
const { latinWordQueryCoverage } = pgvectorMemoryBackendInternals;
|
||||
const query = 'What did Ethan do at soccer practice?';
|
||||
const tagged = '[watch_ethan · field] Ethan fell during soccer practice';
|
||||
const untagged = 'Ethan fell during soccer practice';
|
||||
assert.ok(latinWordQueryCoverage(query, tagged) >= latinWordQueryCoverage(query, untagged));
|
||||
});
|
||||
|
||||
test('selectKeywordCandidateRows keeps priority-term gold under broad OR truncation', () => {
|
||||
const { selectKeywordCandidateRows, extractKeywordTerms } = pgvectorMemoryBackendInternals;
|
||||
const query = 'Why did David promise Ethan extra LEGO time on weekends?';
|
||||
|
||||
Reference in New Issue
Block a user