( query: string, env?: NodeJS.ProcessEnv, minScore = 0.1, limit = 3, )
| 76 | * never hangs. |
| 77 | */ |
| 78 | export function semanticRecall( |
| 79 | query: string, |
| 80 | env?: NodeJS.ProcessEnv, |
| 81 | minScore = 0.1, |
| 82 | limit = 3, |
| 83 | ): SemanticHit[] | null { |
| 84 | if (!query.trim()) return null; |
| 85 | // Require the curated-memory source. If it's absent (gbrain down OR no worktree-backed |
| 86 | // source), degrade to null rather than searching UNSCOPED — an unscoped search pulls |
| 87 | // code/doc corpora that would be mislabeled as "related decisions" (Codex finding). |
| 88 | const sourceId = resolveMemorySourceId(env); |
| 89 | if (!sourceId) return null; |
| 90 | const r = spawnGbrain(["search", query, "--source", sourceId], { baseEnv: env, timeout: TIMEOUT_MS }); |
| 91 | if (r.status !== 0) return null; // gbrain down / not on PATH / errored → degrade |
| 92 | return parseSearchHits(r.stdout || "", minScore, limit); |
| 93 | } |
no test coverage detected