Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(bench): parity harness drops a notices array that held only the disclosure

garrytan99007a0ec6ca
diff --git a/scripts/bench/contract-parity.ts b/scripts/bench/contract-parity.ts
index 99a17b4bc1..4b8ac9b529 100644
--- a/scripts/bench/contract-parity.ts
+++ b/scripts/bench/contract-parity.ts
@@ -402,7 +402,8 @@ export function normalizeResponse(result: { content: Array<{ text: string }>; _m
const notices = meta.gbrain_notices as unknown[];
const keep = notices.filter(n => !DISCLOSURE.test(JSON.stringify(n)));
for (const n of notices) if (!keep.includes(n)) disclosures.push(JSON.stringify(n));
- meta = { ...meta, gbrain_notices: keep };
+ const { gbrain_notices: _all, ...rest } = meta;
+ meta = keep.length || notices.length === 0 ? { ...rest, gbrain_notices: keep } : rest;
}
return { blocks, meta, disclosures, is_error: result.isError === true };
}
diff --git a/test/contract-parity-harness.test.ts b/test/contract-parity-harness.test.ts
index 7ea8df6e31..0d519ca73b 100644
--- a/test/contract-parity-harness.test.ts
+++ b/test/contract-parity-harness.test.ts
@@ -98,3 +98,13 @@ describe('contract-parity rounding flips', () => {
expect(diff({ score: 0.6998 }, { score: 0.6996 })[0]?.note).not.toBe(ROUNDING_FLIP);
});
});
+
+describe('contract-parity disclosure in _meta', () => {
+ test('a notices array that held only the disclosure is removed, as if it never existed', () => {
+ const r = normalizeResponse({ content: [{ text: '[]' }], _meta: { gbrain_notices: [{ code: 'behavior_changes', text: 'Behavior change ...' }] } }, new Map());
+ expect(r.meta).toEqual({});
+ expect(r.disclosures).toHaveLength(1);
+ const kept = normalizeResponse({ content: [{ text: '[]' }], _meta: { gbrain_notices: [{ code: 'other' }] } }, new Map());
+ expect(kept.meta).toEqual({ gbrain_notices: [{ code: 'other' }] });
+ });
+});