Files
OmniRoute/tests/unit/fusion-judge-own-intelligence.test.ts
Chirag Singhal 6105bc1713 feat(fusion): let judge use its own knowledge and override the panel (#6804)
The judge prompt said to write an answer 'grounded in that analysis',
implicitly capping output at the panel's union. When all panel members
miss or are collectively wrong on something, the judge should apply its
own reasoning as a full participant and override consensus, while keeping
an honesty guard against fabrication. Adds a regression test.

Co-authored-by: Chirag Singhal <chirag127@users.noreply.github.com>
2026-07-10 15:06:03 -03:00

31 lines
1.3 KiB
TypeScript

// ABOUTME: buildJudgePrompt must license the judge to use its own knowledge and override
// ABOUTME: the panel — not just synthesize within it — while still embedding panel responses.
import test from "node:test";
import assert from "node:assert/strict";
import { buildJudgePrompt } from "../../open-sse/services/fusion.ts";
test("judge prompt embeds all panel answers, anonymized by source", () => {
const prompt = buildJudgePrompt([
{ text: "answer-alpha" },
{ text: "answer-beta" },
]);
assert.match(prompt, /\[Source 1\]/);
assert.match(prompt, /\[Source 2\]/);
assert.match(prompt, /answer-alpha/);
assert.match(prompt, /answer-beta/);
assert.match(prompt, /2 expert models/);
});
test("judge is licensed to use its own intelligence and override the panel", () => {
const prompt = buildJudgePrompt([{ text: "x" }]);
// Must NOT cap the judge at panel content ("grounded in that analysis" was the old ceiling).
assert.doesNotMatch(prompt, /grounded in that analysis/);
// Must explicitly grant own-reasoning + override authority.
assert.match(prompt, /OWN reasoning and knowledge/);
assert.match(prompt, /override/i);
assert.match(prompt, /not a vote-counter/i);
// Must keep the honesty guard so it doesn't fabricate.
assert.match(prompt, /not confident about/i);
});