MCPcopy
hub / github.com/garrytan/gstack / semanticRecall

Function semanticRecall

lib/gstack-decision-semantic.ts:78–93  ·  view source on GitHub ↗
(
  query: string,
  env?: NodeJS.ProcessEnv,
  minScore = 0.1,
  limit = 3,
)

Source from the content-addressed store, hash-verified

76 * never hangs.
77 */
78export 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}

Calls 3

spawnGbrainFunction · 0.90
resolveMemorySourceIdFunction · 0.85
parseSearchHitsFunction · 0.85

Tested by

no test coverage detected