@traqr/memory 0.2.32 → 0.2.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/classification-enforcement.integration.test.d.ts +7 -5
- package/dist/lib/classification-enforcement.integration.test.js +26 -48
- package/dist/lib/classification-enforcement.integration.test.js.map +1 -1
- package/dist/lib/retrieval.d.ts +24 -66
- package/dist/lib/retrieval.js +38 -315
- package/dist/lib/retrieval.js.map +1 -1
- package/dist/lib/retrieval.test.d.ts +8 -6
- package/dist/lib/retrieval.test.js +13 -67
- package/dist/lib/retrieval.test.js.map +1 -1
- package/dist/lib/stdout-hygiene.test.d.ts +32 -0
- package/dist/lib/stdout-hygiene.test.js +110 -0
- package/dist/lib/stdout-hygiene.test.js.map +1 -0
- package/dist/routes/search.js +4 -3
- package/dist/routes/search.js.map +1 -1
- package/dist/vectordb/postgres.d.ts +1 -23
- package/dist/vectordb/postgres.js +0 -78
- package/dist/vectordb/postgres.js.map +1 -1
- package/dist/vectordb/supabase.d.ts +1 -23
- package/dist/vectordb/supabase.js +0 -101
- package/dist/vectordb/supabase.js.map +1 -1
- package/dist/vectordb/types.d.ts +0 -47
- package/dist/vectordb/types.js.map +1 -1
- package/package.json +2 -2
- package/setup.sql +6 -178
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { createMemoryServer } from './server.js';
|
|
|
8
8
|
export { getVectorDB, resetVectorDB, setVectorDB } from './vectordb/index.js';
|
|
9
9
|
export { checkDbHealth } from './lib/health.js';
|
|
10
10
|
export type { DbHealthResult } from './lib/health.js';
|
|
11
|
-
export type { VectorDBProvider, Memory, MemoryInput, MemorySearchResult, MemoryUpdate, MemoryExport, MemoryDomain, SearchOptions, MemoryCategory, MemorySourceType, MemoryDurability, MemoryType, MemoryClassification, MemoryAccessLevel, MemoryRetentionPolicy,
|
|
11
|
+
export type { VectorDBProvider, Memory, MemoryInput, MemorySearchResult, MemoryUpdate, MemoryExport, MemoryDomain, SearchOptions, MemoryCategory, MemorySourceType, MemoryDurability, MemoryType, MemoryClassification, MemoryAccessLevel, MemoryRetentionPolicy, BrowseResult, ProviderConfig, } from './vectordb/types.js';
|
|
12
12
|
export { BOOTSTRAP_CONFIDENCE, DECAY_CONFIG, ACCESS_LEVEL_MAX_CLASSIFICATION, CLASSIFICATION_RANK } from './vectordb/types.js';
|
|
13
13
|
export { deriveAll, deriveDomain, deriveCategory, deriveTopic, deriveSummary, deriveTags, deriveMemoryType, deriveForgetAfter, extractEntityCandidates, } from './lib/auto-derive.js';
|
|
14
14
|
export type { DeriveResult, EntityCandidate } from './lib/auto-derive.js';
|
|
@@ -22,8 +22,8 @@ export type { MemoryHistoryResult, MemoryRelationship } from './lib/lifecycle.js
|
|
|
22
22
|
export { processEntitiesForMemory } from './lib/entity-pipeline.js';
|
|
23
23
|
export type { EntityExtractionResult } from './lib/entity-pipeline.js';
|
|
24
24
|
export type { StoreWithDedupResult, TriageResult, TriageZone, TriageAction, TriageOptions, RoundTripResult, DetailedStats, SystemHealth, } from './lib/memory.js';
|
|
25
|
-
export { searchMemoriesV2, reciprocalRankFusion,
|
|
26
|
-
export type { SearchV2Options, SearchStrategy, FusedItem, StrategyResult,
|
|
25
|
+
export { searchMemoriesV2, reciprocalRankFusion, } from './lib/retrieval.js';
|
|
26
|
+
export type { SearchV2Options, SearchStrategy, FusedItem, StrategyResult, } from './lib/retrieval.js';
|
|
27
27
|
export { generateEmbedding, generateEmbeddingsBatch, cosineSimilarity, formatEmbeddingForPgVector, parseEmbeddingFromPgVector, needsReembedding, checkEmbeddingHealth, EMBEDDING_CONFIG, getEmbeddingProvider, getEmbeddingConfig, resetEmbeddingProvider, } from './lib/embeddings.js';
|
|
28
28
|
export type { EmbeddingResult, EmbeddingHealthStatus, EmbeddingProvider } from './lib/embeddings.js';
|
|
29
29
|
export { CATEGORY_EMOJI, CATEGORY_EMOJI_SLACK, CATEGORY_EMOJI_TEXT, SOURCE_TYPE_EMOJI, getCategoryEmoji, } from './lib/formatting.js';
|
package/dist/index.js
CHANGED
|
@@ -26,8 +26,8 @@ export { storeMemory, searchMemories, getMemory, citeMemory, updateMemory, delet
|
|
|
26
26
|
export { getVersionChain, getMemoryHistory, getMemoryRelationships, } from './lib/lifecycle.js';
|
|
27
27
|
// Entity extraction pipeline
|
|
28
28
|
export { processEntitiesForMemory } from './lib/entity-pipeline.js';
|
|
29
|
-
//
|
|
30
|
-
export { searchMemoriesV2, reciprocalRankFusion,
|
|
29
|
+
// Retrieval (v2 — semantic-only since TD-906 Slice C)
|
|
30
|
+
export { searchMemoriesV2, reciprocalRankFusion, } from './lib/retrieval.js';
|
|
31
31
|
// Embeddings
|
|
32
32
|
export { generateEmbedding, generateEmbeddingsBatch, cosineSimilarity, formatEmbeddingForPgVector, parseEmbeddingFromPgVector, needsReembedding, checkEmbeddingHealth, EMBEDDING_CONFIG, getEmbeddingProvider, getEmbeddingConfig, resetEmbeddingProvider, } from './lib/embeddings.js';
|
|
33
33
|
// Formatting
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,SAAS;AACT,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,iBAAiB;AACjB,gFAAgF;AAChF,+EAA+E;AAC/E,wEAAwE;AACxE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAE7E,qEAAqE;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,SAAS;AACT,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,iBA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B,gBAAgB,EAChB,0BAA0B,EAC1B,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAG5B,aAAa;AACb,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAE5B,uBAAuB;AACvB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAG7I,kBAAkB;AAClB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAE1E,mBAAmB;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAGzD,qBAAqB;AACrB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAC3B,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,6BAA6B,CAAA"}
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
* it to 'restricted' (= show-all). The helper was never even reached.
|
|
15
15
|
*
|
|
16
16
|
* This file is the live-path regression guard TD-810 acceptance item 4 asked
|
|
17
|
-
* for.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* for. (TD-906 Slice C removed the bm25/temporal/graph legs + their getById
|
|
18
|
+
* hydration entirely — deletion is the strongest fix for a classification-blind
|
|
19
|
+
* path. Section 1 now drives the one surviving strategy.) Sections:
|
|
20
|
+
* 1. INTEGRATION — drive searchMemoriesV2 through a fake VectorDBProvider
|
|
21
|
+
* whose semantic pool contains over-tier rows, assert the step-6.5
|
|
22
|
+
* post-filter returns ZERO over-tier rows at the exploration ceiling
|
|
23
|
+
* (the fail-safe backstop behind the DB-level filter). Catches commit-1.
|
|
22
24
|
* 2. CONTRACT — capture the positional args PostgresVectorProvider.search()
|
|
23
25
|
* passes to query() via a fake pool, assert p_max_classification rides in
|
|
24
26
|
* arg 9 (single-project) / arg 12 (cross-project). Catches commit-2 — no DB.
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
* it to 'restricted' (= show-all). The helper was never even reached.
|
|
15
15
|
*
|
|
16
16
|
* This file is the live-path regression guard TD-810 acceptance item 4 asked
|
|
17
|
-
* for.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* for. (TD-906 Slice C removed the bm25/temporal/graph legs + their getById
|
|
18
|
+
* hydration entirely — deletion is the strongest fix for a classification-blind
|
|
19
|
+
* path. Section 1 now drives the one surviving strategy.) Sections:
|
|
20
|
+
* 1. INTEGRATION — drive searchMemoriesV2 through a fake VectorDBProvider
|
|
21
|
+
* whose semantic pool contains over-tier rows, assert the step-6.5
|
|
22
|
+
* post-filter returns ZERO over-tier rows at the exploration ceiling
|
|
23
|
+
* (the fail-safe backstop behind the DB-level filter). Catches commit-1.
|
|
22
24
|
* 2. CONTRACT — capture the positional args PostgresVectorProvider.search()
|
|
23
25
|
* passes to query() via a fake pool, assert p_max_classification rides in
|
|
24
26
|
* arg 9 (single-project) / arg 12 (cross-project). Catches commit-2 — no DB.
|
|
@@ -79,50 +81,32 @@ function searchRow(id, classification) {
|
|
|
79
81
|
// 1. INTEGRATION — searchMemoriesV2 live path drops over-tier rows (commit-1).
|
|
80
82
|
// ===========================================================================
|
|
81
83
|
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
// At exploration the ceiling is 'internal', so only public+internal survive.
|
|
84
|
+
// TD-906 Slice C: semantic is the ONLY strategy (the bm25/temporal/graph legs
|
|
85
|
+
// and the classification-blind getById hydration of their hits are deleted).
|
|
86
|
+
// The fake provider emits over-tier rows in the semantic pool itself; the real
|
|
87
|
+
// RPC already DB-filters on p_max_classification (Section 2 pins that), so this
|
|
88
|
+
// asserts the step-6.5 post-filter as the fail-safe BACKSTOP at the result
|
|
89
|
+
// boundary. At exploration the ceiling is 'internal' → only public+internal
|
|
90
|
+
// survive.
|
|
90
91
|
console.log('\n--- searchMemoriesV2 live-path classification enforcement (TD-885 / TD-810 commit-1) ---');
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
const byId = {
|
|
94
|
-
'bm25-pub': mem('bm25-pub', 'public'),
|
|
95
|
-
'bm25-restr': mem('bm25-restr', 'restricted'),
|
|
96
|
-
'graph-conf': mem('graph-conf', 'confidential'),
|
|
97
|
-
};
|
|
98
|
-
const getByIdCalls = [];
|
|
92
|
+
// Fixture rows for Section 1b's provider stub (getById is defined there for
|
|
93
|
+
// interface completeness; nothing on the live path calls it anymore).
|
|
94
|
+
const byId = {};
|
|
99
95
|
// FIDELITY NOTE (TD-885): this fake emits over-tier rows ONLY from the retrieval
|
|
100
|
-
// paths searchMemoriesV2 dispatches today — search (semantic)
|
|
101
|
-
// graphSearch, and the getById hydration of bm25/graph-only hits. The "0 over-tier
|
|
96
|
+
// paths searchMemoriesV2 dispatches today — search (semantic). The "0 over-tier
|
|
102
97
|
// rows across every path" assertion is only as complete as this fixture. If a new
|
|
103
98
|
// retrieval strategy is added to searchMemoriesV2, emit an over-tier row for it
|
|
104
99
|
// here too (see the matching note at retrieval.ts step 3) — else this guard passes
|
|
105
100
|
// blind to the new path.
|
|
106
101
|
const fakeProvider = {
|
|
107
102
|
async search() {
|
|
108
|
-
return [searchRow('sem-int', 'internal'), searchRow('sem-conf', 'confidential')];
|
|
109
|
-
},
|
|
110
|
-
async bm25Search() {
|
|
111
103
|
return [
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
searchRow('sem-int', 'internal'),
|
|
105
|
+
searchRow('sem-pub', 'public'),
|
|
106
|
+
searchRow('sem-conf', 'confidential'),
|
|
107
|
+
searchRow('sem-restr', 'restricted'),
|
|
114
108
|
];
|
|
115
109
|
},
|
|
116
|
-
async graphSearch() {
|
|
117
|
-
return [{ id: 'graph-conf', content: 'content-graph-conf', graphScore: 1, edgeType: 'related', depth: 1 }];
|
|
118
|
-
},
|
|
119
|
-
async temporalSearch() {
|
|
120
|
-
return [];
|
|
121
|
-
},
|
|
122
|
-
async getById(id) {
|
|
123
|
-
getByIdCalls.push(id);
|
|
124
|
-
return byId[id] ?? null;
|
|
125
|
-
},
|
|
126
110
|
async bumpReturned() {
|
|
127
111
|
/* no-op */
|
|
128
112
|
},
|
|
@@ -136,8 +120,6 @@ const fakeProvider = {
|
|
|
136
120
|
try {
|
|
137
121
|
results = await searchMemoriesV2('classification regression probe', {
|
|
138
122
|
accessLevel: 'exploration',
|
|
139
|
-
strategies: ['semantic', 'bm25', 'graph'], // force all 3 (skip detectStrategies)
|
|
140
|
-
entityIds: ['seed-1'], // non-empty → graph seeds present + skips findEntitiesInQuery (no network)
|
|
141
123
|
limit: 10,
|
|
142
124
|
});
|
|
143
125
|
}
|
|
@@ -147,14 +129,10 @@ const fakeProvider = {
|
|
|
147
129
|
const ids = results.map((r) => r.id);
|
|
148
130
|
const overTier = results.filter((r) => r.classification === 'confidential' || r.classification === 'restricted');
|
|
149
131
|
assert('live path returns ZERO over-tier rows at exploration (the leak both fixes closed)', overTier.length === 0);
|
|
150
|
-
assert('in-tier internal row
|
|
151
|
-
assert('in-tier public row
|
|
152
|
-
assert('confidential
|
|
153
|
-
assert('restricted
|
|
154
|
-
assert('confidential graph row dropped', !ids.includes('graph-conf'));
|
|
155
|
-
// Prove the blind getById hydration path (commit-1's leak surface) was ACTUALLY
|
|
156
|
-
// exercised — otherwise the test could pass without touching the bug class.
|
|
157
|
-
assert('getById hydration ran for bm25/graph-only hits (commit-1 leak path exercised)', getByIdCalls.length >= 2);
|
|
132
|
+
assert('in-tier internal row survives', ids.includes('sem-int'));
|
|
133
|
+
assert('in-tier public row survives', ids.includes('sem-pub'));
|
|
134
|
+
assert('confidential row dropped at step 6.5 (backstop behind the DB filter)', !ids.includes('sem-conf'));
|
|
135
|
+
assert('restricted row dropped at step 6.5 (backstop behind the DB filter)', !ids.includes('sem-restr'));
|
|
158
136
|
assert('exactly the two in-tier rows survive', results.length === 2);
|
|
159
137
|
}
|
|
160
138
|
// ===========================================================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classification-enforcement.integration.test.js","sourceRoot":"","sources":["../../src/lib/classification-enforcement.integration.test.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"classification-enforcement.integration.test.js","sourceRoot":"","sources":["../../src/lib/classification-enforcement.integration.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,8EAA8E;AAC9E,gFAAgF;AAChF,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,MAAM,CAAA;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAQpG,IAAI,MAAM,GAAG,CAAC,CAAA;AACd,IAAI,MAAM,GAAG,CAAC,CAAA;AAEd,SAAS,MAAM,CAAC,KAAa,EAAE,SAAkB;IAC/C,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,EAAE,CAAC,CAAA;QAC/B,MAAM,EAAE,CAAA;IACV,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,EAAE,CAAC,CAAA;QAC/B,MAAM,EAAE,CAAA;IACV,CAAC;AACH,CAAC;AAED,8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Q,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;YAC1C,MAAM,CAAC,uFAAuF,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAA;QAChI,CAAC;IACH,CAAC;YAAS,CAAC;QACT,iBAAiB,EAAE,CAAA;IACrB,CAAC;AACH,CAAC;AAED,8EAA8E;AAE9E,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;AAClC,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,YAAY,MAAM,SAAS,CAAC,CAAA;AAC1D,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;IACf,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAA;IAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAA;AACzE,CAAC"}
|
package/dist/lib/retrieval.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Retrieval — semantic search + classification ceiling + exact-ID recall.
|
|
3
3
|
*
|
|
4
|
-
* SearchOrchestrator for Memory Engine v2.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* SearchOrchestrator for Memory Engine v2. Semantic is the ONLY strategy:
|
|
5
|
+
* the bm25/temporal/graph fusion legs (TD-158/159/160) were dead in prod for
|
|
6
|
+
* months (42P01 — see TD-894) and were torn down in TD-906 Slice C. The one
|
|
7
|
+
* proven BM25 upside — exact-ID/acronym recall — was reclaimed semantically
|
|
8
|
+
* in TD-906 Slice B (step 6.7 below). RRF scoring is retained as the ranking
|
|
9
|
+
* contract (rank-monotonic over the single strategy).
|
|
7
10
|
*/
|
|
8
|
-
import type {
|
|
9
|
-
export type SearchStrategy = 'semantic'
|
|
11
|
+
import type { MemorySearchResult, SearchOptions, MemoryClassification, MemoryAccessLevel } from '../vectordb/types.js';
|
|
12
|
+
export type SearchStrategy = 'semantic';
|
|
10
13
|
export interface StrategyResult {
|
|
11
14
|
strategy: string;
|
|
12
15
|
items: {
|
|
@@ -20,17 +23,7 @@ export interface FusedItem {
|
|
|
20
23
|
normalizedScore: number;
|
|
21
24
|
strategies: string[];
|
|
22
25
|
}
|
|
23
|
-
export interface DetectedStrategies {
|
|
24
|
-
strategies: SearchStrategy[];
|
|
25
|
-
temporalRange?: {
|
|
26
|
-
start: Date;
|
|
27
|
-
end: Date;
|
|
28
|
-
};
|
|
29
|
-
graphSeedIds?: string[];
|
|
30
|
-
}
|
|
31
26
|
export interface SearchV2Options extends SearchOptions {
|
|
32
|
-
entityIds?: string[];
|
|
33
|
-
strategies?: SearchStrategy[];
|
|
34
27
|
rrfK?: number;
|
|
35
28
|
}
|
|
36
29
|
/**
|
|
@@ -47,12 +40,13 @@ export declare function reciprocalRankFusion(strategyResults: StrategyResult[],
|
|
|
47
40
|
/**
|
|
48
41
|
* Drop any result whose classification exceeds the ceiling for the caller.
|
|
49
42
|
*
|
|
50
|
-
* TD-810:
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
43
|
+
* TD-810 origin: the (since torn-down, TD-906 Slice C) bm25/temporal/graph
|
|
44
|
+
* legs and their getById hydration were classification-BLIND, so this
|
|
45
|
+
* post-filter closed that leak at the result boundary. It is RETAINED as the
|
|
46
|
+
* defense-in-depth backstop on the live path: the semantic RPC already
|
|
47
|
+
* DB-filters on p_max_classification, but step 6.5 re-enforces the ceiling at
|
|
48
|
+
* the boundary and step 6.7 (exact-ID augmentation) depends on it to never
|
|
49
|
+
* widen the caller's tier (integration-test Sections 1 + 1b pin both).
|
|
56
50
|
*
|
|
57
51
|
* FAIL-SAFE: when neither maxClassification nor accessLevel is provided there is
|
|
58
52
|
* no ceiling, so the input is returned UNCHANGED (byte-identical to pre-TD-810).
|
|
@@ -132,50 +126,14 @@ export declare function appendExactIdMatches<T extends {
|
|
|
132
126
|
id: string;
|
|
133
127
|
}>(head: readonly T[], matches: readonly T[], topN: number): T[];
|
|
134
128
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* TD-894 Path B (Sean-approved, Granola "Ultracode response 2" 2026-06-22:
|
|
138
|
-
* "Let's do infrastructure… let's do Path B. I trust your guidance… there's a
|
|
139
|
-
* ton of bloat in here"): the auto-detected default is now SEMANTIC-ONLY.
|
|
140
|
-
*
|
|
141
|
-
* Why: `bm25_search`/`temporal_search`/`graph_search` all carry `search_path=''`
|
|
142
|
-
* with unqualified table refs → every live call throws 42P01 (swallowed to []),
|
|
143
|
-
* so BM25/temporal/graph fusion has been a production no-op for months while
|
|
144
|
-
* still paying per-search dead RPC round-trips. The recall A/B on a *repaired*
|
|
145
|
-
* BM25 also showed equal-weight RRF evicting Sean's curated steering memories on
|
|
146
|
-
* conceptual queries (q08), so re-enabling as-is would regress recall. Per Path B
|
|
147
|
-
* we stop invoking the dead legs by default and reclaim the 21 MB of GIN indexes
|
|
148
|
-
* (migration 021); TD-587 (the never-ran hybrid) is superseded.
|
|
149
|
-
*
|
|
150
|
-
* The bm25/temporal/graph legs in searchMemoriesV2 remain reachable via an
|
|
151
|
-
* explicit `options.strategies` override (preserves the TD-810/885 classification
|
|
152
|
-
* regression test + any deliberate caller); they are simply no longer auto-on.
|
|
153
|
-
* `entityIds`/`temporalRange` are still returned so an override caller can drive
|
|
154
|
-
* graph/temporal, but they no longer flip a strategy on by themselves.
|
|
155
|
-
*/
|
|
156
|
-
export declare function detectStrategies(query: string, entityIds?: string[]): DetectedStrategies;
|
|
157
|
-
/**
|
|
158
|
-
* Parse temporal references in a query to a date range.
|
|
159
|
-
* Falls back to 30-day lookback for ambiguous patterns.
|
|
160
|
-
*/
|
|
161
|
-
export declare function parseTemporalRange(query: string): {
|
|
162
|
-
start: Date;
|
|
163
|
-
end: Date;
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* Find known entities mentioned in a search query.
|
|
167
|
-
* Tokenizes the query, filters stopwords, looks up against memory_entities.
|
|
168
|
-
* Returns entity IDs for graph search activation.
|
|
169
|
-
*/
|
|
170
|
-
export declare function findEntitiesInQuery(query: string, provider: VectorDBProvider): Promise<string[]>;
|
|
171
|
-
/**
|
|
172
|
-
* Multi-strategy search with RRF fusion.
|
|
129
|
+
* Semantic search with RRF-shaped scoring.
|
|
173
130
|
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* Returns MemorySearchResult[] for backward
|
|
131
|
+
* SEMANTIC-ONLY: TD-894 Path B stopped auto-invoking the dead bm25/temporal/
|
|
132
|
+
* graph legs (42P01 in prod for months; re-enabling regressed curated-memory
|
|
133
|
+
* recall); TD-906 Slice C then removed the legs, their `options.strategies`
|
|
134
|
+
* override, and the getById hydration of non-semantic hits entirely. The one
|
|
135
|
+
* proven BM25 upside — exact-ID/acronym recall — lives on semantically at
|
|
136
|
+
* step 6.7 (TD-906 Slice B). Returns MemorySearchResult[] for backward
|
|
137
|
+
* compatibility.
|
|
180
138
|
*/
|
|
181
139
|
export declare function searchMemoriesV2(query: string, options?: SearchV2Options): Promise<MemorySearchResult[]>;
|