reasoning: use structured semantic fidelity contract

This commit is contained in:
2026-08-11 16:45:00 +01:00
parent b6a232ff6f
commit 7d06cd3c47
7 changed files with 630 additions and 97 deletions
+23 -16
View File
@@ -104,7 +104,7 @@ describe("parseGraphUpdateProposal", () => {
expect(result.proposal.addedNodes[0].id).toBe("n-new");
});
it("accepts live-style free-text answerMeaning hints without requiring enum tokens", () => {
it("rejects supportCategory values outside the existing enum", () => {
const result = parseGraphUpdateProposal({
...makeValidProposal(),
answerMeaning: {
@@ -118,15 +118,10 @@ describe("parseGraphUpdateProposal", () => {
},
});
expect(result.success).toBe(true);
expect(result.proposal.answerMeaning).toMatchObject({
supportCategory: "conditional_preference",
resolutionGuidance:
"Identify and quantify the threshold conditions that trigger risk acceptance.",
});
expect(result.success).toBe(false);
});
it("accepts the earlier live Regression B wording variant without special aliasing", () => {
it("rejects the earlier live Regression B wording variant when it is outside the existing enum", () => {
const result = parseGraphUpdateProposal({
...makeValidProposal(),
answerMeaning: {
@@ -139,10 +134,26 @@ describe("parseGraphUpdateProposal", () => {
},
});
expect(result.success).toBe(false);
});
it("accepts valid structured answerMeaning enum values", () => {
const result = parseGraphUpdateProposal({
...makeValidProposal(),
answerMeaning: {
userSupportedMeaning:
"I'd normally avoid more risk, but for the right opportunity I might accept some.",
possibleInference:
"This may support later clarification, but the condition remains material.",
supportCategory: "conditional_tradeoff",
resolutionGuidance: "may_resolve",
},
});
expect(result.success).toBe(true);
expect(result.proposal.answerMeaning).toMatchObject({
supportCategory: "conditional_qualification",
resolutionGuidance: "may resolve once the condition is clarified",
supportCategory: "conditional_tradeoff",
resolutionGuidance: "may_resolve",
});
});
@@ -289,7 +300,7 @@ describe("parseGraphUpdateProposal", () => {
expect(result.success).toBe(false);
});
it("does not reject unsupported free-text answerMeaning labels at parse time", () => {
it("rejects unsupported answerMeaning enum labels at parse time", () => {
const result = parseGraphUpdateProposal({
...makeValidProposal(),
answerMeaning: {
@@ -300,11 +311,7 @@ describe("parseGraphUpdateProposal", () => {
},
});
expect(result.success).toBe(true);
expect(result.proposal.answerMeaning).toMatchObject({
supportCategory: "constraint_preference_mix",
resolutionGuidance: "needs more nuance",
});
expect(result.success).toBe(false);
});
it("defaults missing selectedQuestion to null", () => {