Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
refactor(search): one shared facts-arm cosine floor (#6590)
time-attackdf918472ad48
diff --git a/src/core/search/fact-relevance.ts b/src/core/search/fact-relevance.tsindex 38498e8541..78c3a1d61d 100644--- a/src/core/search/fact-relevance.ts+++ b/src/core/search/fact-relevance.ts@@ -55,9 +55,17 @@ export const TERM_STUFFING_RATIO = 3;/** The two preregistered admission rules; dev picks one (`recall.question_admission`). */export const QUESTION_ADMISSION_RULES = ['reserve', 'facts_arm'] as const;export type QuestionAdmissionRule = (typeof QUESTION_ADMISSION_RULES)[number];-const RESERVE_COSINE_MIN = 0.5;+/**+ * Absolute cosine floors: a fact passes on similarity alone at or above them.+ * They are a property of the embedding model's cosine scale and no model has+ * a measured floor yet (#6590): on a high-baseline embedder an unrelated+ * question clears them, so an empty facts list stops meaning "nothing+ * matched". Doctor `fact_admission_floors` says so for the configured model.+ */+export const RESERVE_COSINE_MIN = 0.5;const RESERVE_TERM_SHARE_MIN = 0.34;-const FACTS_ARM_COSINE_MIN = 0.6;+/** The facts-arm floor; `query`'s facts arm (facts-arm.ts) and the `facts_arm` admission rule share it. */+export const FACTS_ARM_COSINE_MIN = 0.6;export interface FactPoolScope {sourceId?: string; sourceIds?: string[]; remote: boolean;diff --git a/src/core/search/facts-arm.ts b/src/core/search/facts-arm.tsindex 955d31e376..1b6ba694b2 100644--- a/src/core/search/facts-arm.ts+++ b/src/core/search/facts-arm.ts@@ -20,7 +20,7 @@import type { BrainEngine } from '../engine.ts';import type { PageReadScope, SearchResult } from '../types.ts';import { resolveExcludePrivatePages } from './private-visibility.ts';-import { admitted, collectFactCandidates, queryTerms, scoreFactCandidates, type FactCandidate as PoolCandidate, type FactPoolScope } from './fact-relevance.ts';+import { admitted, collectFactCandidates, FACTS_ARM_COSINE_MIN, queryTerms, scoreFactCandidates, type FactCandidate as PoolCandidate, type FactPoolScope } from './fact-relevance.ts';import { pageReadFilter } from './read-policy-sql.ts';import { enforceTokenBudget, resultTokens } from './token-budget.ts';import { factDateHeader } from './evidence-date.ts';@@ -32,7 +32,7 @@ export const QUERY_FACTS_ARM_KEY = 'search.query_facts_arm';/** Fact rows added per query at most. */export const MAX_FACT_ROWS = 3;/** Cosine similarity a fact needs against the query embedding to count as a match on its own. */-export const FACT_COSINE_MIN = 0.6;+export const FACT_COSINE_MIN = FACTS_ARM_COSINE_MIN;/** Share of the query's content terms a fact's text and entity must hold to match by keyword. */const TERM_SHARE_MIN = 0.5;