Skip to content

Commit ec02a7e

Browse files
committed
test(agent): red test for single merged grok residual with ceremony lines
1 parent 2c38c6f commit ec02a7e

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

‎src/agent/grok-residual.test.ts‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { describe, expect, it } from "bun:test";
2+
import { promptResidual } from "./model-family-policy.js";
3+
import {
4+
buildGrokLeafAntiThrashNote,
5+
buildSubAgentSystemPrompt,
6+
} from "./prompts.js";
7+
8+
// The three Grok ceremony lines (CL-7768 Design, merged by CL-8296): no git,
9+
// no pre-plan, verify once.
10+
const CEREMONY_LINES = [
11+
"- Never run git add, git commit, git stash, or any other state-changing git command unless the user asks.",
12+
"- Do not narrate a plan before acting on a small task; act, then report.",
13+
"- Verify with the test command once at the end, not after every edit.",
14+
] as const;
15+
16+
function countOccurrences(haystack: string, needle: string): number {
17+
return haystack.split(needle).length - 1;
18+
}
19+
20+
describe("grok ceremony merge (CL-8296)", () => {
21+
it("exposes a single grok residual with each ceremony line exactly once", () => {
22+
const residual = promptResidual("grok");
23+
expect(residual).toContain("Finish bias (xAI / Grok worker):");
24+
for (const line of CEREMONY_LINES) {
25+
expect(countOccurrences(residual, line)).toBe(1);
26+
}
27+
});
28+
29+
it("keeps the don't re-read line exactly once — no duplicate", () => {
30+
const residual = promptResidual("grok");
31+
expect(countOccurrences(residual, "re-open paths you already read")).toBe(
32+
1,
33+
);
34+
});
35+
36+
it("is grok-only: every other family resolves to an empty residual", () => {
37+
expect(promptResidual("default")).toBe("");
38+
expect(promptResidual("kimi")).toBe("");
39+
expect(promptResidual("muse")).toBe("");
40+
});
41+
42+
it("buildGrokLeafAntiThrashNote is the same single residual (one source of truth)", () => {
43+
expect(buildGrokLeafAntiThrashNote()).toBe(promptResidual("grok"));
44+
});
45+
46+
it("the assembled grok worker prompt carries the merged residual exactly once", () => {
47+
const prompt = buildSubAgentSystemPrompt(undefined, undefined, undefined, {
48+
orchestrator: false,
49+
grokAntiThrash: true,
50+
});
51+
expect(
52+
countOccurrences(prompt, "Finish bias (xAI / Grok worker):"),
53+
).toBe(1);
54+
for (const line of CEREMONY_LINES) {
55+
expect(countOccurrences(prompt, line)).toBe(1);
56+
}
57+
});
58+
});

0 commit comments

Comments
 (0)