Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(search): pin the lean-row id and score contract in the remaining fixtures
garrytanbdcd524ea2a6
diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.jsonindex e90dc65f77..e98b918026 100644--- a/test/fixtures/goldens/exports/types.json+++ b/test/fixtures/goldens/exports/types.json@@ -6100,6 +6100,7 @@"emitResponseMeta?: ((key: string, value: unknown) => void) | undefined","engine: BrainEngine","explicitReadBinding?: ExplicitReadBinding | undefined",+ "isCallable?: ((opName: string) => boolean) | undefined","jobId?: number | undefined","localFederatedSourceIds?: string[] | undefined","localSourceImplicit?: boolean | undefined",diff --git a/test/fixtures/goldens/search-c5/notices.json b/test/fixtures/goldens/search-c5/notices.jsonindex 24f48185b9..213d60a407 100644--- a/test/fixtures/goldens/search-c5/notices.json+++ b/test/fixtures/goldens/search-c5/notices.json@@ -2,7 +2,7 @@"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\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]",+ "[{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.1459,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"matched_alias\":\"Numbat Labs\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]","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): about the entity this query names (newest first), then facts those point to, then matches for its words; 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\".",@@ -68,7 +68,7 @@},"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\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]",+ "[{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.5949,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.1459,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"matched_alias\":\"NULA\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]","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).",@@ -223,7 +223,7 @@},"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\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]",+ "[{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.5949,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.1459,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"matched_alias\":\"NULA\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]","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."@@ -339,7 +339,7 @@"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\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL2FtZW5kbWVudC1vbmUiXQ\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]",+ "[{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.5082,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.4999,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]","[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."@@ -373,7 +373,7 @@},"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\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]",+ "[{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.5949,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]","[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."@@ -407,7 +407,7 @@},"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\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]",+ "[{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.5041,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]","[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."@@ -475,7 +475,7 @@},"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\",\"effective_date_source\":\"fallback\",\"evidence\":\"keyword_exact\",\"create_safety\":\"probable\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL251bWJhdC1sYWJzLW1zYSJd\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]",+ "[{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.5949,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL251bWJhdC1sYWJzIl0\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]","[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."],@@ -511,7 +511,7 @@},"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\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcmVuZXdhbC1wbGF5Ym9vayJd\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]",+ "[{\"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\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"},{\"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.5041,\"source_id\":\"default\",\"effective_date\":\"DATE\",\"effective_date_source\":\"fallback\",\"evidence\":\"weak_semantic\",\"create_safety\":\"unknown\",\"id\":\"gbrain-page:v1:WyJkZWZhdWx0IiwiY3JtL29jZWxvdC1mcmVpZ2h0Il0\",\"trust_tier\":\"unknown\",\"origin\":\"legacy\"}]","[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."],diff --git a/test/helpers/deep-research-contract.ts b/test/helpers/deep-research-contract.tsindex 093b6528aa..bf9f5d00cb 100644--- a/test/helpers/deep-research-contract.ts+++ b/test/helpers/deep-research-contract.ts@@ -215,7 +215,7 @@ export function deepResearchContract(getEngine: () => BrainEngine): void {for (const transport of ['stdio', 'http'] as const) {test(`${transport} MCP dispatch round-trips search/fetch and rechecks changed grants`, async () => {- const opts = { sourceId: 'default', remote: true, transport, auth: { allowedSources: ['default', 'beta'] } as any };+ const opts = { sourceId: 'default', remote: true, transport, auth: { scopes: ['read'], allowedSources: ['default', 'beta'] } as any };const searched = await dispatchToolCall(getEngine(), 'search', { query: 'Zirconiumneedle' }, opts);expect(searched.isError).not.toBe(true);const hits = JSON.parse(searched.content[0].text);@@ -224,7 +224,7 @@ export function deepResearchContract(getEngine: () => BrainEngine): void {const page = JSON.parse(result.content[0].text);expect(page.id).toBe(hits[0].id);expect(page.metadata.source_id).toBe('beta');- const refused = await dispatchToolCall(getEngine(), 'fetch', { id: hits[0].id }, { ...opts, auth: { allowedSources: ['default'] } as any });+ const refused = await dispatchToolCall(getEngine(), 'fetch', { id: hits[0].id }, { ...opts, auth: { scopes: ['read'], allowedSources: ['default'] } as any });expect(refused.isError).toBe(true);expect(refused.content[0].text).not.toContain('beta');expect(refused.content[0].text).not.toContain('Zirconiumneedle');diff --git a/test/mcp-backup-nag.serial.test.ts b/test/mcp-backup-nag.serial.test.tsindex 5ef87d7531..c6a513bea8 100644--- a/test/mcp-backup-nag.serial.test.ts+++ b/test/mcp-backup-nag.serial.test.ts@@ -111,10 +111,16 @@ type CallOpts = { remote?: boolean; transport?: 'stdio' | 'http' };// Default transport is 'stdio' — the ONLY transport the notice fires on.// Trust-pin tests pass 'http' / undefined explicitly.-/** Remote callers get lean rows (C1): the fixture row minus its page_id diagnostic. */-function leanResults(): unknown[] {+/**+ * Remote callers get lean rows (C1): the fixture row minus its page_id diagnostic.+ * `fetchCallable: false` (an HTTP or unmarked caller with no read grant) also drops `id`, the fetch key.+ */+function leanResults({ fetchCallable = true } = {}): unknown[] {// The search op labels every hit with its trust tier and origin (#5575 A6); the stub rows carry neither, so unknown/unrecorded.- return nextResults.map(r => { const { page_id: _p, ...lean } = r as Record<string, unknown>; return { ...lean, trust_tier: 'unknown', origin: 'unrecorded' }; });+ return nextResults.map(r => {+ const { page_id: _p, id, ...lean } = r as Record<string, unknown>;+ return { ...lean, ...(fetchCallable && id !== undefined ? { id } : {}), trust_tier: 'unknown', origin: 'unrecorded' };+ });}async function callSearch(opts: CallOpts = {}) {@@ -200,7 +206,7 @@ describe('maybeAttachBackupNotice (stdio aggregate block)', () => {const http = await callSearch({ remote: true, transport: 'http' });expect(http.content.length).toBe(1);- expect(JSON.parse(http.content[0].text)).toEqual(leanResults());+ expect(JSON.parse(http.content[0].text)).toEqual(leanResults({ fetchCallable: false }));// The http call must not burn the once-per-process flag or arm the// hourly latch — the first stdio call still attaches the block.@@ -213,7 +219,7 @@ describe('maybeAttachBackupNotice (stdio aggregate block)', () => {saveBackupStatus(warnStatus());const out = await callSearch({ remote: true, transport: undefined });expect(out.content.length).toBe(1);- expect(JSON.parse(out.content[0].text)).toEqual(leanResults());+ expect(JSON.parse(out.content[0].text)).toEqual(leanResults({ fetchCallable: false }));});test('aggregate block never leaks local paths or source ids', async () => {diff --git a/test/mcp-result-size-ceiling.test.ts b/test/mcp-result-size-ceiling.test.tsindex 9f04c921db..2503fcd1e2 100644--- a/test/mcp-result-size-ceiling.test.ts+++ b/test/mcp-result-size-ceiling.test.ts@@ -35,9 +35,12 @@ import { withEnv } from './helpers/with-env.ts';* ceilings 2540 -> 2756): search 3129 -> 3408 (3245 measured), query* 2916 -> 3195 (3042). Master merge (19358c1d9 re-pinned master's query* ceiling to 3303 for per-row fact trust tiers): query 3195 -> 3669 (3494- * measured); search unchanged (3245).+ * measured); search unchanged (3245). GBRA-81 item 2 (lean-row score at 4+ * significant digits; the fixture is now a full-surface HTTP client with a+ * read grant, so `id` stays): search 3408 -> 3356 (3196 measured), query+ * 3669 -> 3593 (3421).*/-const CEILINGS = { search: 3408, query: 3669 };+const CEILINGS = { search: 3356, query: 3593 };/*** 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 ceilings@@ -55,6 +58,9 @@ const PAGES: Array<[string, string, string]> = [['notes/billing-faq', 'Billing FAQ', 'Billing contacts change often. Confirm the current billing contact before sending an invoice or a renewal quote.'],];+/** A full-surface HTTP client with a read grant (the registration default): `fetch` is callable, so lean rows keep `id`. */+const HTTP_CLIENT = { remote: true, transport: 'http' as const, sourceId: 'default', auth: { token: 't', clientId: 'size-client', clientName: 'size', scopes: ['read'], expiresAt: Date.now() / 1000 + 3600 } };+let engine: PGLiteEngine;beforeAll(async () => {@@ -73,7 +79,7 @@ afterAll(async () => { await engine?.disconnect(); });async function visible(name: 'search' | 'query'): Promise<{ res: ToolResult; text: string }> {const args = name === 'query' ? { query: 'Numbat Labs billing contact renewal', expand: false } : { query: 'Numbat Labs billing contact renewal' };- const res = await withEnv({ GBRAIN_BACKUP_CHECK: '0' }, () => dispatchToolCall(engine, name, args, { remote: true, transport: 'http', sourceId: 'default' }));+ const res = await withEnv({ GBRAIN_BACKUP_CHECK: '0' }, () => dispatchToolCall(engine, name, args, HTTP_CLIENT));expect(res.isError).not.toBe(true);const degraded = res.content.filter(c => isDegradedNotice(c.text));expect(degraded.length).toBe(1);@@ -109,7 +115,7 @@ describe('canonical remote result size', () => {expect(JSON.stringify(body, null, 2).length + rest).toBeGreaterThan(CEILINGS[name]);const full = await withEnv({ GBRAIN_BACKUP_CHECK: '0' }, () => dispatchToolCall(engine, name,{ query: 'Numbat Labs billing contact renewal', ...(name === 'query' ? { expand: false } : {}), fields: 'full' },- { remote: true, transport: 'http', sourceId: 'default' }));+ HTTP_CLIENT));expect(full.content.filter(c => !isDegradedNotice(c.text)).map(c => c.text).join('\n').length).toBeGreaterThan(CEILINGS[name]);});}diff --git a/test/search-c5-identical.test.ts b/test/search-c5-identical.test.tsindex 878f50fcdd..1c82037391 100644--- a/test/search-c5-identical.test.ts+++ b/test/search-c5-identical.test.ts@@ -28,7 +28,10 @@ import { aliasDeclarations } from '../src/core/ops/search.ts';import { withEnv } from './helpers/with-env.ts';const GOLDEN = join(import.meta.dir, 'fixtures/goldens/search-c5/notices.json');-const REMOTE = { remote: true, transport: 'http' as const, sourceId: 'default' };+/** The remote write path the fresh-fact probes save through. */+const WRITER = { remote: true, transport: 'http' as const, sourceId: 'default' };+/** A full-surface HTTP client with a read grant: `fetch` is callable, so lean rows keep `id`. */+const REMOTE = { ...WRITER, auth: { token: 't', clientId: 'c5-client', clientName: 'c5', scopes: ['read'], expiresAt: Date.now() / 1000 + 3600 } };const PAGES: Array<[string, string, string]> = [['crm/numbat-labs', 'CRM record: Numbat Labs', 'Account record. Account code: NULA. Segment: mid-market. Billing contact: Old Person.'],@@ -128,7 +131,7 @@ describe('a fresh fact is never hidden', () => {const before = await withEnv({ GBRAIN_BACKUP_CHECK: '0' }, () => dispatchToolCall(engine, 'search', { query: 'Numbat Labs escalation owner' }, REMOTE));expect(before.content.map(c => c.text).join('\n')).not.toContain('Saved facts');const saved = await withEnv({ GBRAIN_BACKUP_CHECK: '0' }, () => dispatchToolCall(engine, 'remember',- { fact: 'The Numbat Labs escalation owner is Alice Example.', provenance: 'test', entity: 'numbat-labs' }, { ...REMOTE, writeWaitMs: 30_000 }));+ { fact: 'The Numbat Labs escalation owner is Alice Example.', provenance: 'test', entity: 'numbat-labs' }, { ...WRITER, writeWaitMs: 30_000 }));expect(saved.isError, saved.content[0].text).not.toBe(true);const after = await withEnv({ GBRAIN_BACKUP_CHECK: '0' }, () => dispatchToolCall(engine, 'search', { query: 'Numbat Labs escalation owner' }, REMOTE));expect(after.content.map(c => c.text).join('\n')).toContain('escalation owner is Alice Example');