@o-lang/semantic-doc-search 1.0.39 → 1.0.40

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/resolver.js +13 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o-lang/semantic-doc-search",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "description": "O-lang Semantic Document Search Resolver with hybrid search, embeddings, rerank, and streaming.",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
package/src/resolver.js CHANGED
@@ -104,8 +104,9 @@ async function resolver(action, context = {}) {
104
104
  const documents = loadDocumentsFromContext(context);
105
105
  console.log("🔄 Starting ingestion for", documents.length, "documents");
106
106
 
107
- // Ingestion guard cache
108
- const cache = loadCache();
107
+ // ONLY USE CACHE FOR PERSISTENT BACKENDS
108
+ const useCache = !!context.POSTGRES_URL || !!context.REDIS_URL;
109
+ const cache = useCache ? loadCache() : {};
109
110
 
110
111
  // --- Document ingestion ---
111
112
  if (documents.length > 0) {
@@ -142,7 +143,8 @@ async function resolver(action, context = {}) {
142
143
  }
143
144
 
144
145
  const hash = hashText(text);
145
- if (cache[hash]) {
146
+ // ONLY CHECK CACHE FOR PERSISTENT BACKENDS
147
+ if (useCache && cache[hash]) {
146
148
  console.log(`⏭️ Skipping already ingested chunk ${doc.id}:${i}`);
147
149
  continue;
148
150
  }
@@ -183,7 +185,10 @@ async function resolver(action, context = {}) {
183
185
  content: text,
184
186
  source: doc.source,
185
187
  });
186
- cache[hash] = true;
188
+ // ONLY UPDATE CACHE FOR PERSISTENT BACKENDS
189
+ if (useCache) {
190
+ cache[hash] = true;
191
+ }
187
192
  console.log(`✅ Upserted ${doc.id}:${i}`);
188
193
  } catch (err) {
189
194
  console.warn(`⚠️ Upsert failed for ${doc.id}:${i}:`, err.message);
@@ -191,7 +196,10 @@ async function resolver(action, context = {}) {
191
196
  }
192
197
  }
193
198
  }
194
- saveCache(cache);
199
+ // ✅ ONLY SAVE CACHE FOR PERSISTENT BACKENDS
200
+ if (useCache) {
201
+ saveCache(cache);
202
+ }
195
203
  }
196
204
 
197
205
  // --- QUERY EMBEDDING ---