From dd3c6dbdd9dbcfa11fefdf5bb2bdc60742544d1f Mon Sep 17 00:00:00 2001 From: Gorkem Date: Sat, 18 Jul 2026 16:27:08 +0300 Subject: [PATCH 1/2] test: unpin ollama abort regression from port 11434 The mock bound 127.0.0.1:11434 to satisfy isOllamaProvider(), which EADDRINUSEs on any host running a real Ollama and killed the whole test chain at position 3. Use an ephemeral port with an /ollama path baseURL (the detection regex's third alternative) instead. Also fixes a pre-existing false pass: the mock served /v1/embeddings but the Ollama-native route posts to /api/embeddings (v1 stripped), so the request 404ed instantly and the abort path was never exercised anywhere - the elapsed assertion had no lower bound, so a 3ms failure passed. The mock now serves the real path and the test requires the request to hang until the abort fires. (cherry picked from commit 742c6a3090e67826c2f126f5b4038f769b9721ae) --- test/cjk-recursion-regression.test.mjs | 29 +++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/test/cjk-recursion-regression.test.mjs b/test/cjk-recursion-regression.test.mjs index deba56004..9001a734d 100644 --- a/test/cjk-recursion-regression.test.mjs +++ b/test/cjk-recursion-regression.test.mjs @@ -276,7 +276,9 @@ async function testOllamaAbortWithNativeFetch() { // Author's analysis: the previous test used withServer() on a random port but hardcoded // http://127.0.0.1:11434/v1 for the Embedder — so the request always hit "connection refused" // immediately and never touched the slow handler. This test fixes that by: - // 1. Binding the mock server directly to 127.0.0.1:11434 (so isOllamaProvider() is true) + // 1. Making isOllamaProvider() true via the "/ollama" path alternative of its + // detection regex, on an ephemeral port — a fixed 11434 bind collides with + // a real Ollama install on the host (EADDRINUSE killed the whole chain) // 2. Delaying the response by 5 seconds // 3. Passing an external AbortSignal that fires after 2 seconds // 4. Asserting total time ≈ 2s (proving abort interrupted the slow request) @@ -285,14 +287,14 @@ async function testOllamaAbortWithNativeFetch() { const ABORT_AFTER_MS = 2_000; const DIMS = 1024; + // The Ollama-native route strips the /v1 suffix and posts to /api/embeddings + // (verified against the live Embedder: baseURL .../ollama/v1 → /ollama/api/embeddings). const server = http.createServer((req, res) => { - if (req.url === "/v1/embeddings" && req.method === "POST") { + if (req.url === "/ollama/api/embeddings" && req.method === "POST") { const timer = setTimeout(() => { if (res.writableEnded) return; // already aborted res.writeHead(200, { "Content-Type": "application/json" }); - res.end(JSON.stringify({ - data: [{ embedding: Array.from({ length: DIMS }, () => 0.1), index: 0 }] - })); + res.end(JSON.stringify({ embedding: Array.from({ length: DIMS }, () => 0.1) })); }, SLOW_DELAY_MS); req.on("aborted", () => clearTimeout(timer)); return; @@ -301,22 +303,23 @@ async function testOllamaAbortWithNativeFetch() { res.end("not found"); }); - // Bind directly to 127.0.0.1:11434 so isOllamaProvider() returns true - await new Promise((resolve) => server.listen(11434, "127.0.0.1", resolve)); + // Ephemeral port; the "/ollama" path segment keeps isOllamaProvider() true + await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve)); + const mockPort = server.address().port; try { const embedder = new Embedder({ provider: "openai-compatible", apiKey: "test-key", model: "mxbai-embed-large", - baseURL: "http://127.0.0.1:11434/v1", + baseURL: `http://127.0.0.1:${mockPort}/ollama/v1`, dimensions: DIMS, }); assert.equal( embedder.isOllamaProvider ? embedder.isOllamaProvider() : false, true, - "isOllamaProvider should return true for 127.0.0.1:11434" + "isOllamaProvider should return true for an /ollama path baseURL" ); const start = Date.now(); @@ -346,8 +349,14 @@ async function testOllamaAbortWithNativeFetch() { elapsed < SLOW_DELAY_MS * 0.75, `Expected abort ~${ABORT_AFTER_MS}ms, got ${elapsed}ms — abort did NOT interrupt slow request` ); + // Lower bound: an instant failure (wrong mock path → 404, connection refused) + // never reached the slow handler, so it proves nothing about abort. + assert.ok( + elapsed >= ABORT_AFTER_MS * 0.75, + `Request failed after only ${elapsed}ms — it never hung on the slow handler, so abort was not exercised` + ); - console.log(` PASSED (aborted in ${elapsed}ms < ${SLOW_DELAY_MS}ms threshold)\n`); + console.log(` PASSED (aborted in ${elapsed}ms, between ${ABORT_AFTER_MS * 0.75}ms and ${SLOW_DELAY_MS * 0.75}ms)\n`); } finally { await new Promise((resolve) => server.close(resolve)); } From 11a1854798ece333cfcea34b44b0f478e71b7192 Mon Sep 17 00:00:00 2001 From: Gorkem Date: Sat, 18 Jul 2026 22:34:03 +0300 Subject: [PATCH 2/2] chore(dist): rebuild so the freshness gate passes on current master --- dist/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index baebf86a1..778cda260 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4066,10 +4066,15 @@ const memoryLanceDBProPlugin = { const now = new Date(params.timestampMs ?? Date.now()); const dateStr = now.toISOString().split("T")[0]; const timeStr = now.toISOString().split("T")[1].split(".")[0]; + // Session key/id stay out of `text`: it is the FTS index surface, and + // the `simple` tokenizer splits a key like + // `agent:main:cron::run:` on its punctuation — so every session + // summary ends up indexed under `agent`, `main`, `cron`, `run`. A query + // mentioning any of those then BM25-matches every session summary in the + // store regardless of content. Both ids are already recorded structurally + // in metadata below, so provenance is unaffected. const memoryText = [ `Session: ${dateStr} ${timeStr} UTC`, - `Session Key: ${params.sessionKey}`, - `Session ID: ${params.sessionId}`, `Source: ${params.source}`, "", "Conversation Summary:",