Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(doctor): raw_provenance exempts only raw_trace_exempt: true (#8039)
garrytancbd0dd86b0a7
diff --git a/src/commands/doctor/checks/core-health.ts b/src/commands/doctor/checks/core-health.tsindex 06722dd68c..bf77603f76 100644--- a/src/commands/doctor/checks/core-health.ts+++ b/src/commands/doctor/checks/core-health.ts@@ -549,7 +549,8 @@ export async function rawProvenanceCheck(engine: BrainEngine): Promise<Check> {const where = `p.deleted_at IS NULLAND (COALESCE(p.frontmatter->>'dream_generated', '') = 'true' OR p.type = 'synthesis')- AND NOT (COALESCE(p.frontmatter, '{}'::jsonb) ?| ARRAY['raw_trace', 'raw_source', 'source_uri', 'raw_trace_exempt'])+ AND NOT (COALESCE(p.frontmatter, '{}'::jsonb) ?| ARRAY['raw_trace', 'raw_source', 'source_uri'])+ AND COALESCE(p.frontmatter->>'raw_trace_exempt', '') <> 'true'AND NOT (p.type = 'atom'AND COALESCE(p.frontmatter->>'extracted_by', '') LIKE 'extract\\_atoms%'AND COALESCE(p.frontmatter, '{}'::jsonb) ?| ARRAY['source_slug', 'source_path'])diff --git a/test/doctor-raw-provenance.test.ts b/test/doctor-raw-provenance.test.tsindex 32b5ec3e88..3458337c3b 100644--- a/test/doctor-raw-provenance.test.ts+++ b/test/doctor-raw-provenance.test.ts@@ -97,6 +97,21 @@ describe('rawProvenanceCheck (#1978, warn-only v1)', () => {expect((await rawProvenanceCheck(engine as unknown as BrainEngine)).status).toBe('ok');});+ test('an explicitly false exemption does not exempt (#8039)', async () => {+ await engine.putPage('synthesis/false-exemption', {+ type: 'synthesis', title: 'False exemption', compiled_truth: 'body', timeline: '',+ frontmatter: { raw_trace_exempt: false },+ });+ const result = await rawProvenanceCheck(engine as unknown as BrainEngine);+ expect(result.status).toBe('warn');+ expect(result.message).toContain('synthesis/false-exemption');+ await engine.executeRaw(+ `UPDATE pages SET frontmatter = frontmatter || '{"raw_trace_exempt": true, "raw_trace_exempt_reason": "reviewed"}'::jsonb+ WHERE slug = 'synthesis/false-exemption'`,+ );+ expect((await rawProvenanceCheck(engine as unknown as BrainEngine)).status).toBe('ok');+ });+test('query failure degrades to warn, never throws', async () => {const broken = { executeRaw: async () => { throw new Error('boom'); } } as unknown as BrainEngine;const result = await rawProvenanceCheck(broken);