feat(confidence-engine): strengthen initial reconstruction contract
This commit is contained in:
@@ -25,8 +25,9 @@ describe("v0.3 prompt", () => {
|
||||
expect(PROMPT_VERSIONS).toContain("v0.3");
|
||||
});
|
||||
|
||||
it("DEFAULT_PROMPT_VERSION is v0.3 on this branch", () => {
|
||||
expect(DEFAULT_PROMPT_VERSION).toBe("v0.3");
|
||||
it("DEFAULT_PROMPT_VERSION was v0.3 on earlier branches (now v0.4)", () => {
|
||||
// This test documents that the old default was v0.3; the new default is v0.4
|
||||
expect(["v0.3", "v0.4"]).toContain(DEFAULT_PROMPT_VERSION);
|
||||
});
|
||||
|
||||
it("v0.2 remains available in PROMPT_VERSIONS", () => {
|
||||
@@ -675,7 +676,8 @@ describe("target scenario fixture validation", () => {
|
||||
|
||||
describe("diagnostics prompt version", () => {
|
||||
it("DEFAULT_PROMPT_VERSION is exported correctly", () => {
|
||||
expect(DEFAULT_PROMPT_VERSION).toBe("v0.3");
|
||||
// The current default is v0.4 (was v0.3)
|
||||
expect(["v0.3", "v0.4"]).toContain(DEFAULT_PROMPT_VERSION);
|
||||
});
|
||||
|
||||
it("PROMPT_VERSIONS includes both v0.2 and v0.3", () => {
|
||||
@@ -794,6 +796,99 @@ describe("Finding disposition toggle — state machine", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────
|
||||
// v0.4 prompt loading and contract tests
|
||||
// ──────────────────────────────────────────────
|
||||
|
||||
describe("v0.4 prompt", () => {
|
||||
it("DEFAULT_PROMPT_VERSION is v0.4 on this branch", () => {
|
||||
expect(DEFAULT_PROMPT_VERSION).toBe("v0.4");
|
||||
});
|
||||
|
||||
it("v0.4 is in PROMPT_VERSIONS", () => {
|
||||
expect(PROMPT_VERSIONS).toContain("v0.4");
|
||||
});
|
||||
|
||||
it("v0.4 prompt file loads from disk", async () => {
|
||||
const content = await fs.readFile(
|
||||
join(PROMPTS_DIR, "reconstruct-v0.4.md"),
|
||||
"utf-8",
|
||||
);
|
||||
expect(typeof content).toBe("string");
|
||||
expect(content.length).toBeGreaterThan(500);
|
||||
});
|
||||
|
||||
it("buildPrompt returns v0.4 prompt with scenario substituted", async () => {
|
||||
const result = await buildPrompt("Test v0.4 scenario", "v0.4");
|
||||
expect(result.version).toBe("v0.4");
|
||||
expect(result.prompt).toContain("Test v0.4 scenario");
|
||||
});
|
||||
|
||||
it("explicit v0.3 still resolves to unchanged v0.3 prompt", async () => {
|
||||
const result = await buildPrompt("V0.3 test text", "v0.3");
|
||||
expect(result.version).toBe("v0.3");
|
||||
expect(result.prompt).toContain("V0.3 test text");
|
||||
});
|
||||
|
||||
it("v0.4 contains the existing required JSON/output contract", async () => {
|
||||
const result = await buildPrompt("test", "v0.4");
|
||||
// All four top-level keys must be referenced in output format section
|
||||
expect(result.prompt).toContain("inputClassification");
|
||||
expect(result.prompt).toContain("reconstruction");
|
||||
expect(result.prompt).toContain("evidence");
|
||||
expect(result.prompt).toContain("nextQuestion");
|
||||
expect(result.prompt).toContain("plausibleInterpretations");
|
||||
expect(result.prompt).toContain("importantUnknowns");
|
||||
// Must reference evidenceType values
|
||||
expect(result.prompt).toContain("direct_observation");
|
||||
expect(result.prompt).toContain("reported_statement");
|
||||
});
|
||||
|
||||
it("v0.4 contains the provenance stop contract", async () => {
|
||||
const result = await buildPrompt("test", "v0.4");
|
||||
// Must contain explicit stop boundary language
|
||||
expect(result.prompt.toLowerCase()).toMatch(/stop/i);
|
||||
expect(result.prompt).toMatch(/explicit.*stop|do not recursively/i);
|
||||
// Must restrict decomposition to supplied meaning only
|
||||
expect(result.prompt).toMatch(/directly supported by meaning supplied/);
|
||||
});
|
||||
|
||||
it("v0.4 contains the supplied-relationship preservation contract", async () => {
|
||||
const result = await buildPrompt("test", "v0.4");
|
||||
// Must contain relationship preservation section
|
||||
expect(result.prompt.toLowerCase()).toMatch(/preserve.*supplied.*relationship|preserved.*relationship/);
|
||||
// Must mention dependency preservation specifically
|
||||
expect(result.prompt).toMatch(/dependenc/i);
|
||||
});
|
||||
|
||||
it("v0.4 explicitly separates decomposition provenance from plausible interpretation", async () => {
|
||||
const result = await buildPrompt("test", "v0.4");
|
||||
// Must reference both concepts distinctly
|
||||
expect(result.prompt).toMatch(/interpretation.*never.*smuggled|decomposition.*interpretation|plausible.*interpretations.*separate/i);
|
||||
});
|
||||
|
||||
it("v0.4 still contains normalisation guidance", async () => {
|
||||
const result = await buildPrompt("test", "v0.4");
|
||||
expect(result.prompt).toMatch(/normali[sz]e/i);
|
||||
expect(result.prompt.toLowerCase()).toContain("rate");
|
||||
expect(result.prompt.toLowerCase()).toMatch(/denominator|exposure/);
|
||||
});
|
||||
|
||||
it("v0.4 still contains exactly-one-next-question discipline", async () => {
|
||||
const result = await buildPrompt("test", "v0.4");
|
||||
expect(result.prompt).toMatch(/exactly.*one.*question|Do NOT combine/i);
|
||||
});
|
||||
|
||||
it("default buildPrompt (no version arg) resolves to v0.4", async () => {
|
||||
const result = await buildPrompt("Default version test");
|
||||
expect(result.version).toBe(DEFAULT_PROMPT_VERSION);
|
||||
expect(DEFAULT_PROMPT_VERSION).toBe("v0.4");
|
||||
// Should not contain v0.3 schema-specific differences array (it does have it)
|
||||
// but the prompt should be from the v0.4 file which has the stop boundary text
|
||||
expect(result.prompt.toLowerCase()).toMatch(/stop|explicit.*stop/);
|
||||
});
|
||||
});
|
||||
|
||||
// ── Disposition prop chain verification ────────────────────────
|
||||
|
||||
describe("Disposition prop chain — ScenarioForm → ReasoningWorkspace → FocusedQuestionBody", () => {
|
||||
|
||||
Reference in New Issue
Block a user