Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test: ship Step 7 coverage for outside_content_fences scope, error path and contact pages
garrytan49eb4da5f7c8
diff --git a/test/doctor-outside-content-fences.test.ts b/test/doctor-outside-content-fences.test.tsindex 08ffa87a3e..fee2eb5659 100644--- a/test/doctor-outside-content-fences.test.ts+++ b/test/doctor-outside-content-fences.test.ts@@ -77,4 +77,33 @@ describe('outside_content_fences doctor check', () => {const [row] = await engine.executeRaw<{ compiled_truth: string }>("SELECT compiled_truth FROM pages WHERE slug = 'emails/2026/01/planted-thread'");expect(row!.compiled_truth).toContain(CLAIM);}, 60_000);++ // Value: protects=only live fact rows on live pages of unarchived sources are reported, never expired facts, deleted pages and archived sources;+ // fails_when=the expired_at, deleted_at or archived filter is dropped; why_new=the tests above only+ // plant facts rows on live pages; seam=none; no_claim=takes and links-fence rows (import does not index them here).+ test('reports only live fact rows: skips expired facts, deleted pages and archived sources', async () => {+ await source('scope-google', { kind: 'google', g_account: '[email protected]' });+ await source('scope-archived', { kind: 'google', g_account: '[email protected]' });+ await page('scope-google', 'emails/2026/02/live-thread', 'email', FENCE);+ await page('scope-google', 'emails/2026/02/expired-thread', 'email', FENCE);+ await page('scope-google', 'emails/2026/02/deleted-thread', 'email', FENCE);+ await page('scope-archived', 'emails/2026/02/archived-thread', 'email', FENCE);+ for (const id of ['scope-google', 'scope-archived']) await runExtractFacts(engine, { sourceId: id });+ await engine.executeRaw("UPDATE facts SET expired_at = now() WHERE source_id = 'scope-google' AND source_markdown_slug = 'emails/2026/02/expired-thread'");+ await engine.executeRaw("UPDATE pages SET deleted_at = now() WHERE slug = 'emails/2026/02/deleted-thread'");+ await engine.executeRaw("UPDATE sources SET archived = true WHERE id = 'scope-archived'");+ const checks = await outsideContentFencesEntry.run({ engine } as unknown as DoctorContext) as Check[];+ const items = (checks[0]!.details as { items: Array<{ source_id: string; slug: string}> }).items.filter(i => i.source_id.startsWith('scope-'));+ expect(items.map(i => `${i.source_id}:${i.slug}`)).toEqual(['scope-google:emails/2026/02/live-thread']);+ }, 60_000);++ // Value: protects=the check reports an error check instead of throwing when the query fails;+ // fails_when=the try/catch around the query is removed; why_new=no test drives the error path;+ // seam=none; no_claim=real database failures (an engine stub throws).+ test('a failing query yields an error check, not an exception', async () => {+ const checks = await outsideContentFencesEntry.run({ engine: { executeRaw: async () => { throw new Error('boom'); } } } as unknown as DoctorContext) as Check[];+ expect(checks).toHaveLength(1);+ expect(checks[0]!.name).toBe('outside_content_fences');+ expect(checks[0]!.status).not.toBe('ok');+ });});diff --git a/test/outside-content-fence-injection.test.ts b/test/outside-content-fence-injection.test.tsindex b99db94c83..9c281d7fde 100644--- a/test/outside-content-fence-injection.test.ts+++ b/test/outside-content-fence-injection.test.ts@@ -32,6 +32,7 @@ import { extractTimelineFromContent } from '../src/core/timeline-extract.ts';import { parseInlineCitationTimelineEntries } from '../src/core/timeline-citations.ts';import { parseMarkdown } from '../src/core/markdown.ts';import { renderItemPage, renderRepoCard } from '../src/core/github-source.ts';+import { renderPersonPage } from '../src/core/google/google-render.ts';import { redactSession, renderSessionParts } from '../src/core/transcripts/render.ts';const SOURCE = 'gsrc';@@ -234,6 +235,24 @@ describe('GBRA-221: every outside-content renderer uses the shared neutralizer',expectInertPage(renderRepoCard('acme-example/app', { description: HOSTILE, default_branch: 'main', archived: false, private: true } as never, null));});+ // Value: protects=a contact's name, organization and title cannot plant a fence or timeline row on the person page;+ // fails_when=a renderPersonPage field drops its neutralizeOutsideText call; why_new=existing person-page tests only+ // cover phone-only layout; seam=none; no_claim=the Google Contacts API shape (a ContactData literal stands in).+ test('Google Contacts person pages: name, organization and title cannot carry a fence', () => {+ const contact = (over: Record<string, unknown>) => ({ resourceName: 'people/c1', displayName: 'Bob Example', emails: ['[email protected]'], phones: [],+ organization: null, title: null, groups: [], deleted: false, ...over }) as never;+ for (const over of [{ displayName: HOSTILE }, { organization: HOSTILE }, { organization: 'Acme Example', title: HOSTILE }]) {+ const page = renderPersonPage(contact(over));+ expect(page).not.toBeNull();+ const body = page!.markdown.split('\n---\n').slice(1).join('\n---\n');+ expect(parseFactsFence(body).facts).toEqual([]);+ expect(parseTakesFence(body).takes).toEqual([]);+ expect(parseLinksFence(body).rows).toEqual([]);+ expect(extractTimelineFromContent(body, 'people/bob-example')).toEqual([]);+ expect(body).not.toMatch(/gbrain\s*:/i);+ }+ });+test('chat transcripts: every fence kind and the timeline sentinel, not only facts and takes', () => {const session = { meta: { harness: 'chatgpt' as const, sessionId: 'gbra221-session', startedAt: '2026-01-01T09:00:00.000Z' },messages: [{ role: 'user' as const, timestamp: '2026-01-01T09:00:01.000Z', text: HOSTILE }] };