Skip to content

Commit 84d4f03

Browse files
committed
fix(retrieval): ensure store initialization before hybrid routing
1 parent 7ea8174 commit 84d4f03

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/retriever.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ export class MemoryRetriever {
561561
async retrieve(context: RetrievalContext): Promise<RetrievalResult[]> {
562562
const { query, limit, scopeFilter, category, source } = context;
563563
const safeLimit = clampInt(limit, 1, 20);
564+
// Ensure store is fully initialized before routing decision (hybrid vs vector-only).
565+
// Without this, hasFtsSupport may be false on first call if FTS index creation is still in flight.
566+
await this.store.ensureInitialized();
564567
this.lastDiagnostics = null;
565568
const diagnostics: RetrievalDiagnostics = {
566569
source,

src/store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ export class MemoryStore {
220220
return this.config.dbPath;
221221
}
222222

223-
private async ensureInitialized(): Promise<void> {
223+
/** Ensure the store is fully initialized (FTS index created, table opened, etc.). Safe to call multiple times. */
224+
public async ensureInitialized(): Promise<void> {
224225
if (this.table) {
225226
return;
226227
}

0 commit comments

Comments
 (0)