Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

GBRA-200: segmented think and evidence parity expect the degraded stamp

garrytan7b5064078343
diff --git a/test/helpers/evidence-delivery-fixture.ts b/test/helpers/evidence-delivery-fixture.ts
index fcae34f52e..45f0cedf94 100644
--- a/test/helpers/evidence-delivery-fixture.ts
+++ b/test/helpers/evidence-delivery-fixture.ts
@@ -13,6 +13,7 @@ import { prepareMarkdownChunks } from '../../src/core/markdown-chunks.ts';
import { installFixtureChunks } from './page-projection.ts';
import { withEnv } from './with-env.ts';
import { leanRow } from '../../src/core/search/lean-rows.ts';
+import { degradedStampFor, degradedStampLine } from '../../src/core/degraded-stamp.ts';
export const OFF_PATH_PAGES: Array<{ slug: string; body: string; timeline?: string; frontmatter?: Record<string, unknown> }> = [
{
@@ -123,7 +124,9 @@ function withFactsOrder(payload: Record<string, unknown>): Record<string, unknow
* The cost wave changes remote output on purpose: C1 projects remote
* search/query rows to lean rows (and reports `rows: "lean"` in the retrieval
* meta), and C2 serializes MCP content[0] as compact JSON. Recall's question
- * ranking adds `facts_order` to every recall response. The frozen pre-feature
+ * ranking adds `facts_order` to every recall response. GBRA-200 appends the
+ * degraded stamp (a last text block and `_meta.degraded`) to an MCP reply whose
+ * frozen meta names a recall-affecting stage. The frozen pre-feature
* bytes stay as captured; this applies exactly those declared transforms to
* them, so every other byte of the capture is still compared.
*/
@@ -146,6 +149,11 @@ export function withCostWave(key: string, frozen: string): string {
const lean = base === 'mcp-search' || base === 'mcp-query';
res.content[0].text = JSON.stringify(lean ? (body as Record<string, unknown>[]).map(r => leanRow(r)) : base === 'mcp-recall' ? withFactsOrder(body) : body);
if (lean && res._meta?.retrieval) res._meta.retrieval = leanRetrieval(res._meta.retrieval);
+ const stamp = degradedStampFor(base.slice('mcp-'.length), body, res._meta ?? {}, []);
+ if (stamp) {
+ res.content.push({ type: 'text', text: degradedStampLine(stamp) });
+ res._meta = { ...res._meta, degraded: stamp as unknown as Record<string, unknown> };
+ }
return JSON.stringify(res);
}
diff --git a/test/large-pages/segmented-think-compile-leads.serial.test.ts b/test/large-pages/segmented-think-compile-leads.serial.test.ts
index fb79e45652..555c454d92 100644
--- a/test/large-pages/segmented-think-compile-leads.serial.test.ts
+++ b/test/large-pages/segmented-think-compile-leads.serial.test.ts
@@ -36,6 +36,7 @@ const SLUG = 'people/think-lead-example';
const INLINE = 'people/think-lead-inline-example';
const OPENING = 'Think Lead Example runs research at acme-example and writes about widgets.';
/** Leads do not apply the fence overlay's holds, inline or segmented (segmented-leads.test.ts), so a held row is not counted. */
+const KEYLESS_NO_MATCH_WARNINGS = ['GATHER_DEGRADED:embed_unavailable', 'GATHER_DEGRADED:keyword_zero'];
const leaked = (text: string) => privateTokensIn(text).filter(token => token !== PRIVATE.held);
/**
* Lead parity as segmented-leads.test.ts states it: the same opening text. The two bounded prefixes are cut at
@@ -79,7 +80,8 @@ for (const kind of testBackends()) {
const leads: Record<string, string> = {};
for (const slug of [SLUG, INLINE]) {
const gathered = await runGather(engine, { question: 'qqnomatchquestion', anchor: slug });
- expect(gathered.warnings).toEqual([]);
+ // Keyless and no keyword match: the gather's page search reports its degraded stages (GBRA-200).
+ expect(gathered.warnings).toEqual(KEYLESS_NO_MATCH_WARNINGS);
leads[slug] = gathered.pages.find(p => p.slug === slug)!.chunk_text;
}
expect(leads[SLUG]).toContain(OPENING);
@@ -89,7 +91,7 @@ for (const kind of testBackends()) {
test('the temporal-window floor keeps the segmented page with the inline lead', async () => {
const gathered = await runGather(engine, { question: 'qqnomatchquestion', window: parseTemporalWindow('2026-07-17', '2026-07-18')! });
- expect(gathered.warnings).toEqual([]);
+ expect(gathered.warnings).toEqual(KEYLESS_NO_MATCH_WARNINGS);
const lead = (slug: string) => gathered.pages.find(p => p.slug === slug)?.chunk_text;
expect(lead(SLUG)).toContain(OPENING);
expect(leaked(lead(SLUG)!)).toEqual([]);