Repository navigation
memory-core: native context-service search seam (retire dist-patch) - #3
Merged
pavel-satalkin merged 1 commit intoSep 8, 2026
Conversation
Add MemoryIndexManager.__fredContextServiceSearch and a short-circuit at the top of search() that routes memory-corpus searches to the external context-service HTTP API. Ports docker/patches/patch-memory-context-service.py into fork source. Additive and backward-compatible; the seam returns undefined (falls through to native) on any error, non-memory source filter, missing fetch, or non-2xx response, and never throws. Includes a hermetic vitest suite covering hit mapping, source filtering, and fall-through/no-throw behavior.
pavel-satalkin
approved these changes
Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Port the context-service search seam natively into fork source, replacing the runtime dist-patch
docker/patches/patch-memory-context-service.py(indoctorina-fred-bot). This is a step toward a zero-dist-patch production image.Why
On this deployment the native OpenClaw memory search is dead:
none(sqlite-vec disabled / degraded), andno such module: fts5).So
MemoryIndexManager.search()returns no memory-corpus hits. A separate context-service (Postgres full-text now, vector later) is live athttp://context-service:8090and holds the ingested memory corpus (MEMORY.md+memory/*.md). It exposesPOST /getContext {query, k, mode}->{hits:[{text, source, line, score, ...}]}.Until now that routing was injected at image build time by a dist-patch. This PR moves it into fork source.
Change
extensions/memory-core/src/memory/manager.ts:MemoryIndexManager.__fredContextServiceSearch(query, opts)placed immediately beforesearch().search()(right afteropts?.onDebug?.({ backend: "builtin" })): try the seam; if it returns an array, return it; otherwise fall through to the unchanged native body.Seam behavior (matches the dist-patch semantics exactly, now typed against
MemorySearchResult[]):undefinedif globalfetchis not a function;undefinedifopts.sourcesis a non-empty array that does not include"memory"(sessions-only / other filters fall through to native);process.env.FRED_CONTEXT_SERVICE_URL || "http://context-service:8090"(trailing slashes stripped);k = opts.maxResults > 0 ? opts.maxResults : 8;POST ${base}/getContextwith{query, k, mode: "hybrid"},content-type: application/json,AbortSignal.timeout(800);undefinedon no response / non-2xx;MemorySearchResult(id,source: "memory",path,startLine,endLine,score,textScore,snippet,text) with safe defaults, then slices to the limit;undefined-> never throws.Compatibility
fetch, non-memory source filter, or non-2xx response the seam returnsundefinedand execution falls through to the existing native body, so behavior is never worse than today.__fredContextServiceSearch; once this method exists in the built dist the patch is a no-op.Tests
New hermetic vitest suite
extensions/memory-core/src/memory/manager.context-service-seam.test.ts(mocks globalfetch, no network) covering:MemorySearchResult[], request shape verified, andsearch()returns the seam result (native path bypassed);undefined(fetch not called);undefined(never throws);fetch->undefined;FRED_CONTEXT_SERVICE_URL+ trailing-slash strip.Verified locally:
pnpm tsgo:extensions(source typecheck): passpnpm tsgo:extensions:test(test typecheck): passvitest run(memory extension config), seam suite: 10/10 passoxlinton both changed files: 0 errorsFollow-up (separate
doctorina-fred-botPR, not in this PR)