Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(contradictions): undated pages reach the judge as (date unknown), not the fallback date (N2-1)
garrytan7d70363e9d28
diff --git a/src/core/eval-contradictions/runner.ts b/src/core/eval-contradictions/runner.tsindex 5be212f7d1..c857ac72ad 100644--- a/src/core/eval-contradictions/runner.ts+++ b/src/core/eval-contradictions/runner.ts@@ -118,8 +118,12 @@ function searchResultToMember(r: SearchResult): PairMember {text: r.chunk_text,// Lane A1: effective_date carried through from the search projection.// null when the page has no temporal anchor (judge will see `(date unknown)`).- effective_date: r.effective_date ?? null,- effective_date_source: r.effective_date_source ?? null,+ // N2-1: a 'fallback' (or unlabeled) date is the page's recorded time, not a+ // temporal anchor — passing it on made the date filter never skip and let+ // temporal_supersede name the wrong side. Same rule as deriveTimelineAnchor.+ ...(r.effective_date && r.effective_date_source && r.effective_date_source !== 'fallback'+ ? { effective_date: r.effective_date, effective_date_source: r.effective_date_source }+ : { effective_date: null, effective_date_source: null }),};}diff --git a/test/eval-contradictions-runner.test.ts b/test/eval-contradictions-runner.test.tsindex 6a05173176..0de2d904bb 100644--- a/test/eval-contradictions-runner.test.ts+++ b/test/eval-contradictions-runner.test.ts@@ -19,6 +19,7 @@ import {} from '../src/core/eval-contradictions/runner.ts';import type { JudgeOutput } from '../src/core/eval-contradictions/judge.ts';import type { SearchResult } from '../src/core/types.ts';+import { operations, type OperationContext } from '../src/core/operations.ts';let engine: PGLiteEngine;@@ -209,6 +210,68 @@ describe('runContradictionProbe', () => {expect(out.report.per_query[0].pairs_judged).toBe(0);});+ test('N2-1: an undated page reaches the judge as (date unknown), not its recorded-time fallback', async () => {+ const putPage = operations.find((o) => o.name === 'put_page')!;+ const ctx = {+ engine, config: { engine: 'pglite' }, dryRun: false, remote: false, sourceId: 'default',+ logger: { info() {}, warn() {}, error() {}, debug() {} },+ } as unknown as OperationContext;+ const put = (slug: string, line: string) =>+ putPage.handler(ctx, { slug, content: `---\ntype: note\ntitle: ${slug}\n---\n${line}\n` });+ await put('notes/a', 'As of March 1, 2025: Acme Example headcount is 45 people.');+ await put('notes/b', 'As of September 1, 2025: Acme Example headcount is now 90 people.');+ const stored = await engine.getPage('notes/a');+ expect(stored!.effective_date_source).toBe('fallback');+ expect(stored!.effective_date).not.toBeNull();+ const seen: Array<[string | null | undefined, string | null | undefined]> = [];+ const out = await runContradictionProbe({+ engine,+ queries: ['headcount Acme Example'],+ noCache: true,+ budgetUsd: 5,+ judgeFn: async (input) => {+ seen.push([input.a.effective_date, input.b.effective_date]);+ return stubJudge({ verdict: 'no_contradiction' })(input);+ },+ });+ expect(out.report.per_query[0].result_count).toBeGreaterThanOrEqual(2);+ expect(out.report.per_query[0].pairs_skipped_by_date).toBe(1);+ expect(seen).toEqual([]);+ });++ test('N2-1: fallback dates are dropped on both chunk and take members; content dates survive', async () => {+ const idA = await seedPage('people/alice', 'Alice');+ const idB = await seedPage('meetings/2025-06-01-sync', 'Sync');+ await engine.addTakesBatch([+ { page_id: idA, row_num: 1, claim: 'Alice is the CTO', kind: 'fact', holder: 'garry', weight: 1, active: true, superseded_by: null },+ ]);+ const seen: Array<{ a: [string, string | null | undefined]; b: [string, string | null | undefined] }> = [];+ const out = await runContradictionProbe({+ engine,+ queries: ['alice role'],+ noCache: true,+ budgetUsd: 5,+ judgeFn: async (input) => {+ seen.push({ a: [input.a.slug, input.a.effective_date], b: [input.b.slug, input.b.effective_date] });+ return stubJudge({ verdict: 'temporal_supersession' })(input);+ },+ searchFn: async () => [+ { ...mkResult('people/alice', idA, 1, 'Alice is the CFO'), effective_date: '2026-09-30', effective_date_source: 'fallback' },+ { ...mkResult('meetings/2025-06-01-sync', idB, 2, 'Alice became COO'), effective_date: '2025-06-01', effective_date_source: 'filename' },+ ],+ });+ expect(seen).toEqual([+ { a: ['people/alice', null], b: ['meetings/2025-06-01-sync', '2025-06-01'] },+ { a: ['people/alice', null], b: ['people/alice', null] },+ ]);+ const members = out.report.per_query[0].contradictions.flatMap((f) => [f.a, f.b]);+ for (const m of members.filter((m) => m.slug === 'people/alice')) {+ expect(m.effective_date).toBeNull();+ }+ const cross = out.report.per_query[0].contradictions.find((f) => f.kind === 'cross_slug_chunks')!;+ expect(cross.resolution_command).toContain('date order unclear');+ });+test('judge throw counts as judge_errors, does not crash run', async () => {const idA = await seedPage('a/1', 'A');const idB = await seedPage('b/1', 'B');