Files
gstack/test/judge-panel-median.test.ts
T
Garry Tanandcapy-ai[bot] 781f928ccf test: remove the AI scorer that grades skill prose for clarity (freeze repair, GST-1371) (#4009)
* test: remove the skill-prose clarity LLM judges (GST-1371)

Removes the 21 eval cases where an LLM scored a skill's instruction text for
clarity, completeness and actionability, with their registrations, input
builders, response cache, calibration corpora, the cookie-workflow manual-review
approval and scripts/judge-controls.ts. The three remaining skill-llm-eval
judges keep their prompts, thresholds and samples; the file's supervision wall
shrinks to fit them. Outcome judges are untouched.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test: pin the retired judge-control script and cookie manual-review record as deleted (GST-1371)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test: register the manual-review fixture as free (GST-1371)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test: keep the orphaned clarity-judge calibration corpora for a follow-up deletion (GST-1371)

Deleting the four corpus directories alone puts the diff over the /ship review
ceiling; they serve no configuration now and go in a follow-up.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* docs(todos): file the clarity-judge removal follow-ups (GST-1371)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test: keep skill-bundle section paths POSIX so references dedupe on Windows (GST-1371)

windows-scoped-shard (run 41918796523) failed 'cross-skill references retain
complete bytes once': path.join gave the section entry a backslash path, so a
reference to the same section was not recognized as already bundled.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
2026-11-04 22:19:08 +00:00

62 lines
4.1 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import replay from './fixtures/judge-panel-replay-2026-10-05.json';
import { judgePanelMajority, judgePanelMean, judgePanelMedian, JUDGE_PANEL_SAMPLES } from './helpers/llm-judge';
import { EVAL_POLICY } from './helpers/periodic-exclude-data';
const gate = (scores: number[], threshold = 4) => judgePanelMedian(scores.map(score => ({ score })), ['score']).score >= threshold;
describe('judge gate: per-dimension median of exactly three samples (EVAL_POLICY v3)', () => {
test('a dimension passes when at least 2 of 3 samples meet the unchanged threshold', () => {
expect(EVAL_POLICY.judge.samples).toBe(JUDGE_PANEL_SAMPLES);
expect(gate([4, 4, 3])).toBe(true);
expect(gate([4, 3, 3])).toBe(false);
expect(gate([5, 5, 3])).toBe(true);
expect(gate([5, 3, 3])).toBe(false);
expect(gate([3, 4, 4])).toBe(true);
});
test('anything but exactly three valid samples fails closed', () => {
expect(() => gate([4, 4])).toThrow('exactly 3 samples');
expect(() => gate([4, 4, 4, 4])).toThrow('exactly 3 samples');
expect(() => judgePanelMedian([{ score: 4 }, { score: '4' }, { score: 4 }] as any, ['score'])).toThrow('sample 2 has non-numeric score');
expect(() => judgePanelMedian([{ score: 4 }, null, { score: 4 }] as any, ['score'])).toThrow('sample 2');
expect(() => judgePanelMedian([{ score: 4 }, { score: Number.NaN }, { score: 4 }], ['score'])).toThrow('non-numeric');
});
test('each dimension is gated on its own: one failing dimension fails the panel', () => {
const samples = [{ clarity: 5, actionability: 3 }, { clarity: 5, actionability: 3 }, { clarity: 5, actionability: 4 }];
const median = judgePanelMedian(samples, ['clarity', 'actionability']);
expect(median).toEqual({ clarity: 5, actionability: 3 });
expect(median.clarity >= 4 && median.actionability >= 4).toBe(false);
});
});
type Sample = Record<string, number | boolean>;
const SCORE = ['clarity', 'completeness', 'actionability'] as const;
function verdict(name: string, samples: Sample[], aggregate: typeof judgePanelMean): boolean {
const meets = (keys: readonly string[], floors: Record<string, number>) => {
const scores = aggregate(samples as Record<string, unknown>[], keys);
return keys.every(key => scores[key]! >= floors[key]!);
};
if (name === 'Setup block') return meets(['clarity', 'actionability'], { clarity: 3, actionability: 3 });
if (name === 'Browse SKILL.md') return meets(SCORE, { clarity: 3, completeness: 4, actionability: 4 });
if (name === 'QA anti-refusal') return judgePanelMajority(samples as Record<string, unknown>[], 'would_browse') && meets(['confidence'], { confidence: 4 });
if (name === 'Cross-skill consistency') return judgePanelMajority(samples as Record<string, unknown>[], 'consistent') && meets(['score'], { score: 4 });
if (name === 'Voice directive') {
const keys = ['directness', 'concreteness', 'avoids_corporate', 'avoids_ai_vocabulary', 'connects_user_outcomes'];
return meets(keys, Object.fromEntries(keys.map(key => [key, 4])));
}
return meets(SCORE, { clarity: 3, completeness: 3, actionability: 4 });
}
test('replayed panels from jobs 112032744416 and 112049856586 (replayed evidence, not a CI pass)', () => {
const rows = replay.panels.map(panel => ({ job: panel.job, case: panel.case,
mean: verdict(panel.case, panel.samples as Sample[], judgePanelMean), median: verdict(panel.case, panel.samples as Sample[], judgePanelMedian) }));
expect(rows).toHaveLength(42);
expect(rows.filter(row => !row.mean).map(row => `${row.job} ${row.case}`)).toEqual([
'112032744416 QA workflow', '112032744416 plan-eng-review/SKILL.md sections', '112049856586 design-consultation/SKILL.md research']);
expect(rows.filter(row => !row.median).map(row => `${row.job} ${row.case}`)).toEqual(['112032744416 plan-eng-review/SKILL.md sections']);
// Exactly these two panels change verdict: each had 2 of 3 samples at every threshold.
expect(rows.filter(row => row.median && !row.mean).map(row => row.case)).toEqual(['QA workflow', 'design-consultation/SKILL.md research']);
});