|
| 1 | +import { describe, expect, test } from "bun:test"; |
| 2 | +import { |
| 3 | + claudeRow, |
| 4 | + defaultRow, |
| 5 | + FAMILY_IDS, |
| 6 | + FAMILY_ROWS, |
| 7 | + gptRow, |
| 8 | + grokRow, |
| 9 | + grokToolBudgetResidual, |
| 10 | + museRow, |
| 11 | + type PromptVarianceFamily, |
| 12 | +} from "./rows.js"; |
| 13 | + |
| 14 | +const CEREMONY_LINES = [ |
| 15 | + "Never run git add, git commit, git stash, or any other state-changing git command unless the user asks.", |
| 16 | + "Do not narrate a plan before acting on a small task; act, then report.", |
| 17 | + "Verify with the test command once at the end, not after every edit.", |
| 18 | +]; |
| 19 | + |
| 20 | +describe("prompt-variance family rows", () => { |
| 21 | + test("ships exactly the default/muse/grok/claude/gpt families", () => { |
| 22 | + expect([...FAMILY_IDS]).toEqual([ |
| 23 | + "default", |
| 24 | + "muse", |
| 25 | + "grok", |
| 26 | + "claude", |
| 27 | + "gpt", |
| 28 | + ]); |
| 29 | + }); |
| 30 | + |
| 31 | + test("has no glm row until its eval lands (CL-8265)", () => { |
| 32 | + for (const id of FAMILY_IDS) { |
| 33 | + expect(id).not.toBe("glm"); |
| 34 | + } |
| 35 | + }); |
| 36 | + |
| 37 | + test("every row carries the id/residual shape — residuals-only, no deny fields", () => { |
| 38 | + for (const row of [defaultRow, museRow, grokRow, claudeRow, gptRow]) { |
| 39 | + expect(typeof row.id).toBe("string"); |
| 40 | + expect(typeof row.residual).toBe("string"); |
| 41 | + expect("advertisedToolDeny" in row).toBe(false); |
| 42 | + expect("sectionOmit" in row).toBe(false); |
| 43 | + expect("overrides" in row).toBe(false); |
| 44 | + } |
| 45 | + }); |
| 46 | + |
| 47 | + test("row ids match their family and FAMILY_ROWS covers all five", () => { |
| 48 | + const ids: PromptVarianceFamily[] = [ |
| 49 | + defaultRow.id, |
| 50 | + museRow.id, |
| 51 | + grokRow.id, |
| 52 | + claudeRow.id, |
| 53 | + gptRow.id, |
| 54 | + ]; |
| 55 | + expect(ids).toEqual(["default", "muse", "grok", "claude", "gpt"]); |
| 56 | + expect(Object.keys(FAMILY_ROWS).sort()).toEqual([ |
| 57 | + "claude", |
| 58 | + "default", |
| 59 | + "gpt", |
| 60 | + "grok", |
| 61 | + "muse", |
| 62 | + ]); |
| 63 | + }); |
| 64 | + |
| 65 | + test("muse row is the shipped CL-7869 tool-discipline text", () => { |
| 66 | + expect(museRow.residual).toContain("Tool discipline:"); |
| 67 | + expect(museRow.residual).toContain("Batch independent tool calls"); |
| 68 | + expect(museRow.residual).toContain("Never re-read a file"); |
| 69 | + expect(museRow.residual).toContain("Do not narrate; act."); |
| 70 | + }); |
| 71 | + |
| 72 | + test("grok row is the single finish-bias + ceremony block (CL-8296)", () => { |
| 73 | + expect(grokRow.residual).toContain("Finish bias (xAI / Grok worker):"); |
| 74 | + expect(grokRow.residual).toContain("prefer the structured report"); |
| 75 | + expect(grokRow.residual).toContain("re-open paths you already read"); |
| 76 | + expect(grokRow.residual).toContain("done-definition is met"); |
| 77 | + expect(grokRow.residual).toContain("never run_shell"); |
| 78 | + }); |
| 79 | + |
| 80 | + test("each ceremony line appears exactly once in the grok row (P2 invariant)", () => { |
| 81 | + for (const line of CEREMONY_LINES) { |
| 82 | + const occurrences = grokRow.residual.split(line).length - 1; |
| 83 | + expect(occurrences).toBe(1); |
| 84 | + } |
| 85 | + }); |
| 86 | + |
| 87 | + test("grok tool-budget residual is ceremony-free and budget text appears once (P1 invariant)", () => { |
| 88 | + expect(grokToolBudgetResidual).toContain("Tool budget:"); |
| 89 | + for (const line of CEREMONY_LINES) { |
| 90 | + expect(grokToolBudgetResidual).not.toContain(line); |
| 91 | + } |
| 92 | + const budgetOccurrences = |
| 93 | + grokToolBudgetResidual.split("Tool budget:").length - 1; |
| 94 | + expect(budgetOccurrences).toBe(1); |
| 95 | + }); |
| 96 | + |
| 97 | + test("default row carries no residual", () => { |
| 98 | + expect(defaultRow.residual).toBe(""); |
| 99 | + }); |
| 100 | + |
| 101 | + test("claude row is the single XML task_guidance block (CL-8309)", () => { |
| 102 | + expect(claudeRow.residual).toContain("<task_guidance>"); |
| 103 | + expect(claudeRow.residual).toContain("</task_guidance>"); |
| 104 | + expect(claudeRow.residual).toContain("Follow the dispatch brief exactly"); |
| 105 | + expect(claudeRow.residual).toContain("Batch independent tool calls"); |
| 106 | + }); |
| 107 | + |
| 108 | + test("gpt row is the narrate-before-tools nudge (CL-8310)", () => { |
| 109 | + expect(gptRow.residual).toContain("Narrate before tools (GPT worker):"); |
| 110 | + expect(gptRow.residual).toContain( |
| 111 | + "one short line saying what you are doing", |
| 112 | + ); |
| 113 | + expect(gptRow.residual).toContain("done-definition is met"); |
| 114 | + }); |
| 115 | +}); |
0 commit comments