Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(search): label row dates by source and keep effective_date_source in lean rows
garrytanc06210adf046
diff --git a/docs/architecture/key-files/core-search-1.md b/docs/architecture/key-files/core-search-1.mdindex b76494ff63..b7b63b4cf1 100644--- a/docs/architecture/key-files/core-search-1.md+++ b/docs/architecture/key-files/core-search-1.md@@ -16,6 +16,8 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/core/search/date-bounds.ts` — shared public since/until normalization for text and image query paths; hybrid.ts preserves both existing exports. Exact timestamps keep their precision, date-only upper bounds use exclusive next midnight, and invalid calendar dates fail before embedding. Direct legacy afterDate/beforeDate comparisons remain strict by default.+- `src/core/search/date-labels.ts` — row-date honesty for `search` / `query`. `effectiveDateLabel(source)` maps `effective_date_source` to a document date (`date`, `published`, `filename`), an event date (`event_date`) or a fallback (`created`, `fallback`: when the page was created or imported); `dateLabelLine(rows)` is the one model-visible `[gbrain dates]` line `src/mcp/dispatch.ts` appends when rows carry dates, naming only the sources present and saying the date is never a contract's effective or validity date. Lean rows (`lean-rows.ts`) keep `effective_date_source` for it. Test: `test/search-date-labels.test.ts`.+- `src/core/search/dedup.ts` — 4-layer result dedup + compiled-truth guarantee: (1) top 3 chunks per page by score, (2) drop chunks >0.85 Jaccard-similar to already-kept chunks of the SAME page (cross-page near-dups survive — two legitimately similar pages both return), (3) no page type exceeds 60% of results — applied only when the candidate set actually contains multiple page types; a homogeneous set passes through unchanged because dropping (for example) one of three distinct LongMemEval `note` sessions cannot introduce diversity and destroys multi-session recall (pinned by the homogeneous-set case in `test/dedup.test.ts`), (4) max 2 chunks per page (default; the two-pass structural expansion in `hybrid.ts` widens it), (5) ensure at least 1 compiled_truth chunk per page — the page's best compiled_truth chunk is APPENDED (never swapped over a kept chunk, so matching evidence survives) and the final output is re-sorted by score, because slice / token budget / evidence consumers assume score order. Page identity is the composite `pageKey()` (source_id, slug) — the one canonical key helper every layer uses, so slug collisions across sources can't collapse recall.- `src/core/search/embedding-column.ts` — single source of truth for "which `content_chunks.*` column does this query rank against?" Pure functions, no engine I/O: `loadRegistry(cfg)` walks the `embedding_columns` config (DB plane, JSON map keyed by column name with `{provider, dimensions, type}` entries), seeds the OpenAI `embedding` builtin when unset, validates everything before it lands (column-name regex, type ∈ `vector | halfvec`, dims in [1, 8192], provider format) using `Object.create(null)` + `Object.hasOwn` so a key like `constructor` rejects instead of resolving to `Object.prototype.constructor`. `resolveColumn(registry, override?, cfg)` is the boundary call: returns a frozen `ResolvedColumn` descriptor (`{name, provider, dimensions, type}`) honoring per-call override → `search_embedding_column` config → `'embedding'` default; throws `UnknownEmbeddingColumnError` with the list of registered names on miss. `isCacheSafe(resolved, cfg)` compares the full embedding SPACE (provider + dimensions + name) against cfg's default so a repointed `embedding` builtin doesn't serve OpenAI-shaped cache rows. `validateResolvedColumn(descriptor)` re-validates hand-rolled descriptors that bypass the registry (internal-SDK passthrough) so the SQL-injection escape hatch through the descriptor field is closed. Consumed by `hybridSearch`, `gateway.embedQuery(text, {embeddingModel, dimensions})`, `cosineReScore`, and the `query` MCP op (per-call `embedding_column` param). Engine column routing is covered by `test/e2e/embedding-column-pglite.test.ts`, `test/e2e/embedding-column-postgres.test.ts` and `test/cosine-rescore-column.test.ts`. Write side: `resolveWriteColumnFromConfigRows({searchEmbeddingColumn, embeddingColumnsJson})` resolves upsertChunks's active write target from the raw DB-plane config rows through the same registry/validation chain (legacy `embedding` descriptor when neither row routes elsewhere; `embedding_image` falls back to the legacy text column since image vectors travel in their own INSERT column; malformed registry JSON is forgiven like loadConfigWithEngine; unregistered names throw the paste-ready error), and `vectorCastSuffix(resolved)` is the placeholder-free `'::vector' | '::halfvec(N)'` cast shared by the read fragment builder and the write path so the two casts can't drift. Pinned by `test/e2e/upsert-chunks-registry-column.test.ts`.diff --git a/docs/mcp/README.md b/docs/mcp/README.mdindex 57f2e1f2fa..d90c9f6598 100644--- a/docs/mcp/README.md+++ b/docs/mcp/README.md@@ -74,8 +74,15 @@ A lean row keeps `id` (the `fetch` key), `slug`, `title`, `type`,provenance marker that is present: `injection_suspected`, `injection_p`,`unverified`, `content_flag`, `status`, `superseded`, `superseded_by`,`message_id`, `thread_id`, `source_subject`, `modality` when not `text`,-`stale` when true, and `delivered: {"truncated": true}` when evidence-delivery cut the text.+`stale` when true, `provenance: "generated"` on a machine-written page,+and `delivered: {"truncated": true}` when evidence delivery cut the text.++`effective_date` is the page's own date and `effective_date_source` says+which kind: `date`, `published` or `filename` is a document date,+`event_date` an event date, and `created` or `fallback` only when the page+was created or imported. It is never a contract's effective or validity+date; that date is in the text. Every reply with dated rows adds one line+after the rows that says so (`[gbrain dates] ...`).```json{"query": "acme-example renewal terms"}diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex 0ba558a5a4..e7c997d0ed 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -296,6 +296,8 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }{ since: '0.60.105.0', text: 'The entity card gains `aka_sources`, `identity_siblings`, `identity_excerpt` (verbatim lines that may name the entity otherwise) and `alias_guidance`; `aka` is unchanged. search and query also search every other name of the entity a query names (up to 4, keyword-only, rows marked `matched_alias`); `gbrain config set search.alias_fanout_max 0` turns that off.' },{ since: '0.60.105.0', text: 'search now says how many pages match the query\'s keywords (`keyword_total`, up to 10000+) and adds one line after the rows saying they are a ranked top-K. `match: "keyword"` lists every keyword match with `total`, `truncated` and a ready-to-send `next`. An agent-facing `mode` is now refused (it was ignored) with a fix naming `match: "keyword"`, and an offset over 10,000 is refused.' },{ since: '0.60.105.0', text: 'search and query rank a page gbrain generated (frontmatter `dream_generated: true`, type `extract_receipt`) at half its score when the query names an entity and a primary record about it is among the results; such rows carry `provenance: "generated"`. Generated corrections are never demoted. `gbrain config set search.demote_generated false` turns the demotion off.' },+ { since: '0.60.105.0', text: 'search now says how many pages match the query\'s keywords (`keyword_total`, up to 10000+) and adds one line after the rows saying they are a ranked top-K. `match: "keyword"` lists every keyword match with `total`, `truncated` and a ready-to-send `next`. An agent-facing `mode` is now refused (it was ignored) with a fix naming `match: "keyword"`, and an offset over 10,000 is refused.' },+ { since: '0.60.105.0', text: 'Lean search and query rows now keep `effective_date_source`, and replies with dated rows add one line labeling each `effective_date` as a document, event or fallback (import) date; it is never a contract\'s effective date.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/src/core/search/date-labels.ts b/src/core/search/date-labels.tsnew file mode 100644index 0000000000..a55c8d56af--- /dev/null+++ b/src/core/search/date-labels.ts@@ -0,0 +1,41 @@+/**+ * Date honesty in search rows (Cat 40 Hard F4). A row's `effective_date` is+ * the page's own date, chosen by a precedence chain whose winner is+ * `effective_date_source` (`types.ts` EffectiveDateSource): an `event_date`+ * is when the event happened, `date` / `published` / `filename` date the+ * document, and `created` / `fallback` are only when the page was created or+ * imported. None of them is a contract's effective or validity date, which+ * lives in the text ("Effective 2026-03-01"). Agents read `effective_date`+ * as that date, so every `search` / `query` reply whose rows carry dates gets+ * one model-visible line naming what each source present means.+ */++const LABELS: ReadonlyArray<{ sources: readonly string[]; label: string }> = [+ { sources: ['date', 'published', 'filename'], label: 'document date' },+ { sources: ['event_date'], label: 'event date' },+ { sources: ['created', 'fallback'], label: 'fallback (page created/imported, not from its text)' },+];++/** The label for one `effective_date_source` value. */+export function effectiveDateLabel(source: unknown): string {+ return LABELS.find(l => l.sources.includes(String(source)))?.label ?? 'date of unrecorded origin';+}++/** One line for the rows' dates, naming only the sources present; null when no row carries a date. */+export function dateLabelLine(rows: unknown): string | null {+ if (!Array.isArray(rows)) return null;+ const present = new Set<string>();+ for (const row of rows) {+ const r = row as { effective_date?: unknown; effective_date_source?: unknown } | null;+ if (r?.effective_date == null) continue;+ present.add(typeof r.effective_date_source === 'string' ? r.effective_date_source : 'unrecorded');+ }+ if (present.size === 0) return null;+ const parts: string[] = [];+ for (const l of LABELS) {+ const hit = l.sources.filter(src => present.has(src));+ if (hit.length > 0) parts.push(`${hit.join('/')} = ${l.label}`);+ }+ if ([...present].some(src => !LABELS.some(l => l.sources.includes(src)))) parts.push(`no source = ${effectiveDateLabel(null)}`);+ return `[gbrain dates] effective_date by effective_date_source: ${parts.join('; ')}. Never a contract's effective or validity date (read the text).`;+}diff --git a/src/core/search/lean-rows.ts b/src/core/search/lean-rows.tsindex 4e55d9e2e1..db7433d59a 100644--- a/src/core/search/lean-rows.ts+++ b/src/core/search/lean-rows.ts@@ -7,13 +7,15 @@* signals) that agents do not read but pay for on every later turn. A lean* row keeps what an agent acts on:* - identity and text: id (the deep-research fetch key), slug, title, type,- * chunk_text, score, effective_date, source_id, chunk_id (assemble_evidence+ * chunk_text, score, effective_date (with effective_date_source, which+ * says what kind of date it is), source_id, chunk_id (assemble_evidence* takes {source_id, slug, chunk_id});* - the duplicate-page guard: evidence and create_safety;* - safety and provenance markers whenever present: injection_suspected,* injection_p, unverified, content_flag, status, superseded, superseded_by,* message_id, thread_id, source_subject, matched_alias (the other name the- * alias fan-out searched); modality when not text; stale+ * alias fan-out searched); `provenance` only as `generated` (a+ * machine-written page); modality when not text; stale* only when set (true, or the held-file object from #5988);* - `delivered: { truncated: true }` whenever evidence delivery truncated;* - `evidence_omitted` on a keyword-mode row whose text did not fit.@@ -26,7 +28,7 @@ import type { OperationContext } from '../ops/contract.ts';export type ResultRows = 'lean' | 'full';const KEPT_FIELDS: ReadonlySet<string> = new Set([- 'id', 'slug', 'title', 'type', 'chunk_text', 'score', 'effective_date', 'source_id', 'chunk_id',+ 'id', 'slug', 'title', 'type', 'chunk_text', 'score', 'effective_date', 'effective_date_source', 'source_id', 'chunk_id','evidence', 'create_safety','injection_suspected', 'injection_p', 'unverified', 'content_flag', 'status', 'superseded', 'superseded_by','message_id', 'thread_id', 'source_subject', 'relational', 'matched_alias',@@ -50,6 +52,7 @@ export function leanRow(row: Record<string, unknown>): Record<string, unknown> {if (KEPT_FIELDS.has(key)) out[key] = value;else if (key === 'stale' && (value === true || (typeof value === 'object' && value !== null))) out[key] = value;else if (key === 'modality' && value !== 'text') out[key] = value;+ else if (key === 'provenance' && value === 'generated') out[key] = value;else if (key === 'delivered' && (value as { truncated?: unknown }).truncated === true) out[key] = { truncated: true };}return out;diff --git a/src/mcp/dispatch.ts b/src/mcp/dispatch.tsindex 8aba94132f..6b57bdfc27 100644--- a/src/mcp/dispatch.ts+++ b/src/mcp/dispatch.ts@@ -20,6 +20,7 @@ import { hostFix, scopeDeniedError } from '../core/ops/op-fix.ts';import { mutedNoticeCodes, processNoticeLedger, __resetProcessNoticeLedgerForTests, type NoticeLedger, type NoticeAudience } from '../core/notice-ledger.ts';import { logVerbUsage } from '../core/verbs/usage-log.ts';import { searchCountLine } from '../core/search/keyword-paging.ts';+import { dateLabelLine } from '../core/search/date-labels.ts';import { localTranscriptsNotice, recallInteropNotices, wantsTranscriptHint } from '../core/interop-notices.ts';import { hiddenToolHint } from './hidden-tool-hint.ts';import { takePostUpgradeMcpNotice } from '../core/post-upgrade-notice.ts';@@ -371,7 +372,7 @@ export function summarizeMcpParams(opName: string, params: unknown): ParamSummar/*** Model-visible notices the search/query ops attach to `_meta.retrieval`: the* D8 empty-retrieval diagnosis, a reconciled type filter, other names declared in the evidence, and saved- * facts that match the query, and search's keyword count line. Each rides as its own text block after the+ * facts that match the query, search's keyword count line and the row-date label. Each rides as its own text block after the* results (content[0] stays the bare result array for thin clients).*/export function retrievalNoticeBlocks(result: unknown, retrieval: unknown): string[] {@@ -400,6 +401,9 @@ export function retrievalNoticeBlocks(result: unknown, retrieval: unknown): stri// F2: which set the rows are and which set the keyword count covers, on every search call.const countLine = searchCountLine(result, retrieval);if (countLine) blocks.push(countLine);+ // F4: what each row's effective_date is (document, event or fallback date), never contractual validity.+ const dateLine = dateLabelLine(result);+ if (dateLine) blocks.push(dateLine);if (typeof r.answer_id === 'string' && r.feedback?.rateable === true) blocks.push(rateLine(r.answer_id, typeof r.feedback.how_to_rate === 'string'));return blocks;}diff --git a/test/fixtures/goldens/search-c5/notices.json b/test/fixtures/goldens/search-c5/notices.jsonindex 589f79b014..db372b73e5 100644--- a/test/fixtures/goldens/search-c5/notices.json+++ b/test/fixtures/goldens/search-c5/notices.json@@ -2,10 +2,11 @@"with": {"search NULA billing contact": {"content": [- "[{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Account code: NULA. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"},{\"slug\":\"contracts/amendment-one\",\"title\":\"Amendment No. 1: NULA\",\"type\":\"note\",\"chunk_text\":\"Executed amendment for NULA: payment terms change to Net 30.\",\"chunk_id\":3,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\"},{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs (account code NULA). Payment terms: Net 45.\",\"chunk_id\":2,\"score\":0.14590249955654144,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"matched_alias\":\"Numbat Labs\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"}]",+ "[{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Account code: NULA. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"},{\"slug\":\"contracts/amendment-one\",\"title\":\"Amendment No. 1: NULA\",\"type\":\"note\",\"chunk_text\":\"Executed amendment for NULA: payment terms change to Net 30.\",\"chunk_id\":3,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\"},{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs (account code NULA). Payment terms: Net 45.\",\"chunk_id\":2,\"score\":0.14590249955654144,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"matched_alias\":\"Numbat Labs\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"}]","Other names in these results (documents may use either; search the one you have not tried): NULA = Numbat Labs (declared in contracts/numbat-labs-msa).","Saved facts (remember) matching this query, newest first; recall returns more:\n- The billing contact for Numbat Labs is New Person. [entity: numbat-labs; saved 2026-09-01; provenance: user update]","[gbrain search] Rows are a ranked top-K, not proof of coverage. Keyword matches: 1 page (pages matching the query's keywords, not a count of these rows). List every keyword match with match: \"keyword\".",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -67,9 +68,10 @@},"search Numbat Labs payment terms": {"content": [- "[{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs (account code NULA). Payment terms: Net 45.\",\"chunk_id\":2,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Account code: NULA. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5948760330578512,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"},{\"slug\":\"contracts/amendment-one\",\"title\":\"Amendment No. 1: NULA\",\"type\":\"note\",\"chunk_text\":\"Executed amendment for NULA: payment terms change to Net 30.\",\"chunk_id\":3,\"score\":0.14590249955654144,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"matched_alias\":\"NULA\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\"}]",+ "[{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs (account code NULA). Payment terms: Net 45.\",\"chunk_id\":2,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Account code: NULA. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5948760330578512,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"},{\"slug\":\"contracts/amendment-one\",\"title\":\"Amendment No. 1: NULA\",\"type\":\"note\",\"chunk_text\":\"Executed amendment for NULA: payment terms change to Net 30.\",\"chunk_id\":3,\"score\":0.14590249955654144,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"matched_alias\":\"NULA\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\"}]","Other names in these results (documents may use either; search the one you have not tried): NULA = Numbat Labs (declared in crm/numbat-labs).","[gbrain search] Rows are a ranked top-K, not proof of coverage. Keyword matches: 1 page (pages matching the query's keywords, not a count of these rows). List every keyword match with match: \"keyword\".",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -121,10 +123,11 @@},"search OCFR renewal": {"content": [- "[{\"slug\":\"crm/ocelot-freight\",\"title\":\"CRM record: Ocelot Freight\",\"type\":\"note\",\"chunk_text\":\"Account record for Ocelot Freight, also known as OCFR. Renewal owner: the platform team.\",\"chunk_id\":4,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\"},{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]",+ "[{\"slug\":\"crm/ocelot-freight\",\"title\":\"CRM record: Ocelot Freight\",\"type\":\"note\",\"chunk_text\":\"Account record for Ocelot Freight, also known as OCFR. Renewal owner: the platform team.\",\"chunk_id\":4,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\"},{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]","Other names in these results (documents may use either; search the one you have not tried): OCFR = Ocelot Freight (declared in crm/ocelot-freight).","Saved facts (remember) matching this query, newest first; recall returns more:\n- Ocelot Freight renewal moves to the platform team. [entity: ocelot-freight; saved 2026-09-02; provenance: user update]","[gbrain search] Rows are a ranked top-K, not proof of coverage. Keyword matches: 1 page (pages matching the query's keywords, not a count of these rows). List every keyword match with match: \"keyword\".",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -186,8 +189,9 @@},"search renewal quote": {"content": [- "[{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]",+ "[{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]","[gbrain search] Rows are a ranked top-K, not proof of coverage. Keyword matches: 1 page (pages matching the query's keywords, not a count of these rows). List every keyword match with match: \"keyword\".",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -219,8 +223,9 @@},"query Numbat Labs payment terms": {"content": [- "[{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs (account code NULA). Payment terms: Net 45.\",\"chunk_id\":2,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Account code: NULA. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5948760330578512,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"},{\"slug\":\"contracts/amendment-one\",\"title\":\"Amendment No. 1: NULA\",\"type\":\"note\",\"chunk_text\":\"Executed amendment for NULA: payment terms change to Net 30.\",\"chunk_id\":3,\"score\":0.14590249955654144,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"matched_alias\":\"NULA\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\"}]",+ "[{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs (account code NULA). Payment terms: Net 45.\",\"chunk_id\":2,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Account code: NULA. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5948760330578512,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"},{\"slug\":\"contracts/amendment-one\",\"title\":\"Amendment No. 1: NULA\",\"type\":\"note\",\"chunk_text\":\"Executed amendment for NULA: payment terms change to Net 30.\",\"chunk_id\":3,\"score\":0.14590249955654144,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"matched_alias\":\"NULA\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\"}]","Other names in these results (documents may use either; search the one you have not tried): NULA = Numbat Labs (declared in crm/numbat-labs).",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -275,8 +280,9 @@},"query OCFR renewal owner": {"content": [- "[{\"slug\":\"crm/ocelot-freight\",\"title\":\"CRM record: Ocelot Freight\",\"type\":\"note\",\"chunk_text\":\"Account record for Ocelot Freight, also known as OCFR. Renewal owner: the platform team.\",\"chunk_id\":4,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\"},{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]",+ "[{\"slug\":\"crm/ocelot-freight\",\"title\":\"CRM record: Ocelot Freight\",\"type\":\"note\",\"chunk_text\":\"Account record for Ocelot Freight, also known as OCFR. Renewal owner: the platform team.\",\"chunk_id\":4,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\"},{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]","Other names in these results (documents may use either; search the one you have not tried): OCFR = Ocelot Freight (declared in crm/ocelot-freight).",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -333,8 +339,9 @@"without": {"search NULA billing contact": {"content": [- "[{\"slug\":\"contracts/amendment-one\",\"title\":\"Amendment No. 1: NULA\",\"type\":\"note\",\"chunk_text\":\"Executed amendment for NULA: payment terms change to Net 30.\",\"chunk_id\":3,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5081967213114754,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"},{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":0.4998656275194841,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]",+ "[{\"slug\":\"contracts/amendment-one\",\"title\":\"Amendment No. 1: NULA\",\"type\":\"note\",\"chunk_text\":\"Executed amendment for NULA: payment terms change to Net 30.\",\"chunk_id\":3,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5081967213114754,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"},{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":0.4998656275194841,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]","[gbrain search] Rows are a ranked top-K, not proof of coverage. Keyword matches: 0 pages (pages matching the query's keywords, not a count of these rows). List every keyword match with match: \"keyword\".",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -366,8 +373,9 @@},"search Numbat Labs payment terms": {"content": [- "[{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs . Payment terms: Net 45.\",\"chunk_id\":2,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5948760330578512,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"}]",+ "[{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs . Payment terms: Net 45.\",\"chunk_id\":2,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5948760330578512,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"}]","[gbrain search] Rows are a ranked top-K, not proof of coverage. Keyword matches: 1 page (pages matching the query's keywords, not a count of these rows). List every keyword match with match: \"keyword\".",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -399,8 +407,9 @@},"search OCFR renewal": {"content": [- "[{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"},{\"slug\":\"crm/ocelot-freight\",\"title\":\"CRM record: Ocelot Freight\",\"type\":\"note\",\"chunk_text\":\"Account record for Ocelot Freight. Renewal owner: the platform team.\",\"chunk_id\":4,\"score\":0.5041322314049587,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\"}]",+ "[{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"},{\"slug\":\"crm/ocelot-freight\",\"title\":\"CRM record: Ocelot Freight\",\"type\":\"note\",\"chunk_text\":\"Account record for Ocelot Freight. Renewal owner: the platform team.\",\"chunk_id\":4,\"score\":0.5041322314049587,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\"}]","[gbrain search] Rows are a ranked top-K, not proof of coverage. Keyword matches: 0 pages (pages matching the query's keywords, not a count of these rows). List every keyword match with match: \"keyword\".",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -432,8 +441,9 @@},"search renewal quote": {"content": [- "[{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]",+ "[{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"}]","[gbrain search] Rows are a ranked top-K, not proof of coverage. Keyword matches: 1 page (pages matching the query's keywords, not a count of these rows). List every keyword match with match: \"keyword\".",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -465,7 +475,8 @@},"query Numbat Labs payment terms": {"content": [- "[{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs . Payment terms: Net 45.\",\"chunk_id\":2,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5948760330578512,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"}]",+ "[{\"slug\":\"contracts/numbat-labs-msa\",\"title\":\"MSA: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Master services agreement with Numbat Labs . Payment terms: Net 45.\",\"chunk_id\":2,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\"},{\"slug\":\"crm/numbat-labs\",\"title\":\"CRM record: Numbat Labs\",\"type\":\"note\",\"chunk_text\":\"Account record. Segment: mid-market. Billing contact: Old Person.\",\"chunk_id\":1,\"score\":0.5948760330578512,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\"}]",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {@@ -500,7 +511,8 @@},"query OCFR renewal owner": {"content": [- "[{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"},{\"slug\":\"crm/ocelot-freight\",\"title\":\"CRM record: Ocelot Freight\",\"type\":\"note\",\"chunk_text\":\"Account record for Ocelot Freight. Renewal owner: the platform team.\",\"chunk_id\":4,\"score\":0.5041322314049587,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\"}]",+ "[{\"slug\":\"notes/renewal-playbook\",\"title\":\"Renewal playbook\",\"type\":\"note\",\"chunk_text\":\"Confirm the billing contact, check payment terms, send the renewal quote 60 days before the term ends.\",\"chunk_id\":5,\"score\":1,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\"},{\"slug\":\"crm/ocelot-freight\",\"title\":\"CRM record: Ocelot Freight\",\"type\":\"note\",\"chunk_text\":\"Account record for Ocelot Freight. Renewal owner: the platform team.\",\"chunk_id\":4,\"score\":0.5041322314049587,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\"}]",+ "[gbrain dates] effective_date by effective_date_source: fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).","[gbrain notice degraded_recall kind=degraded]\nwhy: Recall was degraded (embed_unavailable): semantic (vector) search did not run, so matches phrased differently from the query can be missing. Treat a thin or empty result as \"not found with a degraded search\", never as \"the brain has nothing on this\".\nfix: gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024\nnext: tell_user_to_run\nuser_message: Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (<provider key>), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are."],"retrieval": {diff --git a/test/helpers/evidence-delivery-fixture.ts b/test/helpers/evidence-delivery-fixture.tsindex 19e33fa024..89ac9bfe3a 100644--- a/test/helpers/evidence-delivery-fixture.ts+++ b/test/helpers/evidence-delivery-fixture.ts@@ -64,8 +64,9 @@ export async function captureOffPath(engine: BrainEngine): Promise<Record<string{ remote: true, transport: 'stdio', sourceId: 'default' });// Agent contract v1 notices (extra prefixed blocks + _meta.gbrain_notices, e.g. degraded_recall on this// keyless corpus) are additive and pinned in test/mcp-notice-channels.test.ts; the off path compares the rest.- // Cat 40 Hard F2's keyword count line and fields are additive too (pinned in test/search-keyword-paging.test.ts).- const content = res.content.filter(c => !c.text.startsWith('[gbrain notice ') && !c.text.startsWith('[gbrain search] '));+ // Cat 40 Hard F2's keyword count line and fields and F4's row-date line are additive too+ // (pinned in test/search-keyword-paging.test.ts and test/search-date-labels.test.ts).+ const content = res.content.filter(c => !/^\[gbrain (notice |search\] |dates\] )/.test(c.text));const { gbrain_notices: _notices, ...meta } = res._meta ?? {};if (meta.retrieval) meta.retrieval = withoutCounts(meta.retrieval as Record<string, unknown>);out[`mcp-${name}`] = JSON.stringify({ ...res, content, ...(res._meta ? { _meta: meta } : {}) });diff --git a/test/mcp-result-size-ceiling.test.ts b/test/mcp-result-size-ceiling.test.tsindex 046640b58f..0901494e72 100644--- a/test/mcp-result-size-ceiling.test.ts+++ b/test/mcp-result-size-ceiling.test.ts@@ -28,8 +28,11 @@ import { withEnv } from './helpers/with-env.ts';* ceil(measured x 1.05) on the fixture below. search 2540 -> 2754 (2622* measured): Cat 40 Hard F2's keyword count line rides on every search call* (the rows are top-K; the line says how many pages match the keywords).+ * search 2754 -> 3129 (2980) and query 2540 -> 2916 (2777): Cat 40 Hard F4,+ * lean rows keep effective_date_source and a line labels each row's date by+ * its source (document, event or fallback date, never contractual validity).*/-const CEILINGS = { search: 2754, query: 2540 };+const CEILINGS = { search: 3129, query: 2916 };/*** The keyless fixture also gets the operator contract's degraded_recall* notice (F3) on every HTTP call. It is bounded on its own so the ceilingsdiff --git a/test/search-date-labels.test.ts b/test/search-date-labels.test.tsnew file mode 100644index 0000000000..606b6c3937--- /dev/null+++ b/test/search-date-labels.test.ts@@ -0,0 +1,72 @@+/**+ * Cat 40 Hard F4: date honesty in search rows. `effective_date` stays the one+ * date field; lean rows keep `effective_date_source`, and every search/query+ * reply with dated rows carries one model-visible line that labels the date+ * by its source (document, event or fallback date) and says it is never a+ * contract's effective or validity date.+ *+ * Authoring gate: (1) agents read `effective_date` as a contract's effective+ * date; the label is the model-visible contract that it is not; (2) fails if+ * lean rows drop `effective_date_source`, if a source is mislabeled (a+ * fallback import date called a document date), or if the line leaves the+ * MCP content; (3) no test covered row-date labels; (4) no seam.+ */+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import { dispatchToolCall } from '../src/mcp/dispatch.ts';+import { dateLabelLine, effectiveDateLabel } from '../src/core/search/date-labels.ts';+import { withEnv } from './helpers/with-env.ts';+import { seedPage } from './helpers/keyword-paging-fixture.ts';++const REMOTE = { remote: true, transport: 'http' as const, sourceId: 'default' };+let engine: PGLiteEngine;++beforeAll(async () => {+ engine = new PGLiteEngine();+ await engine.connect({});+ await engine.initSchema();+ await seedPage(engine, 'contracts/widget-co-amendment', 'Amendment for widget-co: the new price is effective 2026-06-01.', { frontmatter: { date: '2026-05-10' } });+ await seedPage(engine, 'meetings/widget-co-review', 'Review meeting about the widget-co amendment.', { type: 'meeting', frontmatter: { event_date: '2026-05-12' } });+ await seedPage(engine, 'notes/widget-co-undated', 'Undated note on the widget-co amendment.');+}, 120_000);++afterAll(async () => { await engine?.disconnect(); });++describe('labels by source', () => {+ test('each source maps to document, event or fallback date', () => {+ for (const s of ['date', 'published', 'filename']) expect(effectiveDateLabel(s)).toBe('document date');+ expect(effectiveDateLabel('event_date')).toBe('event date');+ for (const s of ['created', 'fallback']) expect(effectiveDateLabel(s)).toStartWith('fallback (page created/imported');+ expect(effectiveDateLabel(null)).toBe('date of unrecorded origin');+ });++ test('the line names only the sources present and never claims contractual validity', () => {+ const line = dateLabelLine([+ { effective_date: '2026-05-10', effective_date_source: 'date' },+ { effective_date: '2026-01-02', effective_date_source: 'fallback' },+ ])!;+ expect(line).toBe("[gbrain dates] effective_date by effective_date_source: date = document date; fallback = fallback (page created/imported, not from its text). Never a contract's effective or validity date (read the text).");+ expect(dateLabelLine([{ effective_date: null }, { slug: 'x' }])).toBeNull();+ expect(dateLabelLine([{ effective_date: '2026-05-10' }])).toContain('no source = date of unrecorded origin');+ });+});++describe('over MCP (model-visible content only)', () => {+ for (const name of ['search', 'query'] as const) {+ test(`${name}: lean rows keep effective_date_source and the date line labels each one`, async () => {+ const res = await withEnv({ GBRAIN_BACKUP_CHECK: '0' }, () => dispatchToolCall(engine, name,+ { query: 'widget-co amendment', ...(name === 'query' ? { expand: false } : {}) }, REMOTE));+ expect(res.isError).toBeUndefined();+ const rows = JSON.parse(res.content[0].text) as Array<{ slug: string; effective_date: string | null; effective_date_source?: string }>;+ const bySlug = new Map(rows.map(r => [r.slug, r]));+ expect(bySlug.get('contracts/widget-co-amendment')).toMatchObject({ effective_date: '2026-05-10', effective_date_source: 'date' });+ expect(bySlug.get('meetings/widget-co-review')).toMatchObject({ effective_date: '2026-05-12', effective_date_source: 'event_date' });+ const line = res.content.map(c => c.text).find(t => t.startsWith('[gbrain dates] '));+ expect(line).toBeDefined();+ expect(line).toContain('date = document date');+ expect(line).toContain('event_date = event date');+ expect(line).toContain("Never a contract's effective or validity date");+ expect(line).toContain('fallback = fallback (page created/imported');+ });+ }+});diff --git a/test/search-lean-rows.test.ts b/test/search-lean-rows.test.tsindex f2d600e0d9..aed87d03f2 100644--- a/test/search-lean-rows.test.ts+++ b/test/search-lean-rows.test.ts@@ -22,7 +22,7 @@ import { withEnv } from './helpers/with-env.ts';const REMOTE: DispatchOpts = { remote: true, transport: 'http', sourceId: 'default' };const LEAN_ALWAYS = ['id', 'slug', 'title', 'type', 'chunk_text', 'score', 'source_id', 'chunk_id', 'evidence', 'create_safety'];-const DIAGNOSTICS = ['page_id', 'chunk_index', 'chunk_source', 'keyword_hit', 'effective_date_source', 'stale'];+const DIAGNOSTICS = ['page_id', 'chunk_index', 'chunk_source', 'keyword_hit', 'stale'];let engine: PGLiteEngine;@@ -50,6 +50,8 @@ describe('lean rows for remote callers', () => {for (const key of LEAN_ALWAYS) expect(row, key).toHaveProperty(key);for (const key of DIAGNOSTICS) expect(row, key).not.toHaveProperty(key);expect(row).toHaveProperty('effective_date');+ // Cat 40 Hard F4: a dated row says what kind of date it is.+ if (row.effective_date !== null) expect(typeof row.effective_date_source).toBe('string');}expect(meta?.rows).toBe('lean');});@@ -169,6 +171,15 @@ describe('leanRow field contract', () => {expect(marked.delivered).toEqual({ truncated: true });});+ test('effective_date_source and provenance: generated survive; ordinary rows carry neither, nor matched_alias', () => {+ const dated = leanRow({ ...full, effective_date: '2026-03-01', effective_date_source: 'event_date', provenance: 'generated' });+ expect(dated.effective_date_source).toBe('event_date');+ expect(dated.provenance).toBe('generated');+ const ordinary = leanRow(full);+ for (const key of ['effective_date_source', 'provenance', 'matched_alias']) expect(ordinary).not.toHaveProperty(key);+ expect(leanRow({ ...full, provenance: 'auto-extracted' })).not.toHaveProperty('provenance');+ });+test('absent sparse fields stay absent', () => {expect(Object.keys(leanRow({ slug: 's', title: 't', type: 'note', chunk_text: 'x', score: 1, chunk_id: 1, page_id: 1 })).sort()).toEqual(['chunk_id', 'chunk_text', 'score', 'slug', 'title', 'type']);diff --git a/test/search-readiness-http.test.ts b/test/search-readiness-http.test.tsindex fb8cb91b52..f881802449 100644--- a/test/search-readiness-http.test.ts+++ b/test/search-readiness-http.test.ts@@ -195,10 +195,11 @@ describe('search projection readiness over legacy bearer HTTP MCP', () => {test('partial nonempty search exposes the same readiness metadata without changing the public result body', async () => {const response = await search(MATCH);- // Body + F2's keyword count line + F3's degraded_recall notice (recall-affecting stage present).- expect(response.content).toHaveLength(3);+ // Body + F2's keyword count line + F4's row-date line + F3's degraded_recall notice (recall-affecting stage present).+ expect(response.content).toHaveLength(4);expect(response.content[1]!.text).toStartWith('[gbrain search] Rows are a ranked top-K');- expect(response.content[2]!.text).toStartWith('[gbrain notice degraded_recall kind=degraded]');+ expect(response.content[2]!.text).toStartWith('[gbrain dates] ');+ expect(response.content[3]!.text).toStartWith('[gbrain notice degraded_recall kind=degraded]');expect(response.body).toHaveLength(1);expect(JSON.stringify(response.body)).toContain(MATCH);expectPendingMetadata(response.retrieval);