|
1 | 1 | import { describe, expect, test } from "bun:test"; |
2 | 2 | import { assemble } from "./assemble.js"; |
3 | | -import { defaultRow, grokRow, museRow } from "./rows.js"; |
4 | | - |
5 | | -// CL-8269 RED: assemble does not exist yet — every test below fails until |
6 | | -// the GREEN lands packages/prompt-variance. |
| 3 | +import { claudeRow, defaultRow, gptRow, grokRow, museRow } from "./rows.js"; |
7 | 4 |
|
8 | 5 | const SECTIONS = ["contract", "Tools (names only): read_file", "context"]; |
9 | | -const TOOLS = ["read_file", "skill_search", "use_skill", "run_shell"]; |
10 | 6 |
|
11 | 7 | describe("assemble", () => { |
12 | 8 | test("joins sections with the residual as the last section", () => { |
13 | | - const out = assemble(SECTIONS, grokRow, TOOLS); |
14 | | - expect(out.systemPrompt).toContain("contract"); |
15 | | - expect(out.systemPrompt.trimEnd().endsWith(grokRow.residual)).toBe(true); |
| 9 | + const out = assemble(SECTIONS, grokRow); |
| 10 | + expect(out).toContain("contract"); |
| 11 | + expect(out.trimEnd().endsWith(grokRow.residual)).toBe(true); |
16 | 12 | }); |
17 | 13 |
|
18 | 14 | test("a row without residual leaves the sections unchanged", () => { |
19 | | - const out = assemble(SECTIONS, defaultRow, TOOLS); |
20 | | - expect(out.systemPrompt).toBe(SECTIONS.join("\n\n")); |
| 15 | + expect(assemble(SECTIONS, defaultRow)).toBe(SECTIONS.join("\n\n")); |
21 | 16 | }); |
22 | 17 |
|
23 | 18 | test("muse residual closes the prompt like the shipped tail append", () => { |
24 | | - const out = assemble(SECTIONS, museRow, TOOLS); |
25 | | - expect(out.systemPrompt.trimEnd().endsWith(museRow.residual)).toBe(true); |
26 | | - }); |
27 | | - |
28 | | - test("filters advertisedToolDeny from the tool names, preserving order", () => { |
29 | | - const out = assemble(SECTIONS, grokRow, TOOLS); |
30 | | - expect([...out.toolNames]).toEqual(["read_file", "use_skill", "run_shell"]); |
31 | | - }); |
32 | | - |
33 | | - test("variance cannot grant tools: output is always a subset of the input", () => { |
34 | | - for (const row of [defaultRow, museRow, grokRow]) { |
35 | | - const out = assemble(SECTIONS, row, TOOLS); |
36 | | - for (const name of out.toolNames) { |
37 | | - expect(TOOLS).toContain(name); |
38 | | - } |
39 | | - expect(out.toolNames.length).toBeLessThanOrEqual(TOOLS.length); |
40 | | - } |
| 19 | + const out = assemble(SECTIONS, museRow); |
| 20 | + expect(out.trimEnd().endsWith(museRow.residual)).toBe(true); |
41 | 21 | }); |
42 | 22 |
|
43 | | - test("variance cannot grant tools: unknown mounted names pass through untouched", () => { |
44 | | - const out = assemble(SECTIONS, defaultRow, ["alpha", "beta"]); |
45 | | - expect([...out.toolNames]).toEqual(["alpha", "beta"]); |
| 23 | + test("claude and gpt residuals close the prompt the same way", () => { |
| 24 | + expect( |
| 25 | + assemble(SECTIONS, claudeRow).trimEnd().endsWith(claudeRow.residual), |
| 26 | + ).toBe(true); |
| 27 | + expect(assemble(SECTIONS, gptRow).trimEnd().endsWith(gptRow.residual)).toBe( |
| 28 | + true, |
| 29 | + ); |
46 | 30 | }); |
47 | 31 |
|
48 | | - test("refuses a row that denies use_skill", () => { |
49 | | - const bad = { ...grokRow, advertisedToolDeny: ["use_skill"] }; |
50 | | - expect(() => assemble(SECTIONS, bad, TOOLS)).toThrow(/use_skill/); |
| 32 | + test("tool mounting is out of scope: assemble returns a string, not tool names", () => { |
| 33 | + const out = assemble(SECTIONS, grokRow); |
| 34 | + expect(typeof out).toBe("string"); |
51 | 35 | }); |
52 | 36 | }); |
0 commit comments