refine answerMeaning support category normalisation
This commit is contained in:
@@ -1123,6 +1123,50 @@ describe("applyValidatedProposal", () => {
|
||||
expect(result.errors.join(" ")).toContain("conditional qualification");
|
||||
});
|
||||
|
||||
it("accepts equivalent conditional category labels and still applies the existing Regression B guard", () => {
|
||||
const { graph, riskUnknownId } = makeRiskClarificationFixture();
|
||||
|
||||
const result = applyValidatedProposal({
|
||||
situationGraph: graph,
|
||||
answer:
|
||||
"I'd normally avoid more risk, but for the right opportunity I might accept some.",
|
||||
previousQuestion:
|
||||
"Is avoiding additional risk a hard constraint or a preference/trade-off?",
|
||||
proposal: {
|
||||
addedNodes: [],
|
||||
updatedNodes: [
|
||||
{
|
||||
nodeId: riskUnknownId,
|
||||
previousStatus: "unknown",
|
||||
newStatus: "resolved",
|
||||
previousValue: null,
|
||||
newValue:
|
||||
"Avoiding additional risk is a preference or trade-off rather than a hard constraint.",
|
||||
reason:
|
||||
"The answer shows a preference or trade-off rather than a hard constraint.",
|
||||
},
|
||||
],
|
||||
addedEdges: [],
|
||||
removedEdgeIds: [],
|
||||
resolvedUnknownNodeIds: [riskUnknownId],
|
||||
affectedNodeIds: [],
|
||||
selectedQuestion: null,
|
||||
answerMeaning: {
|
||||
userSupportedMeaning:
|
||||
"The user would normally avoid more risk, but for the right opportunity might accept some.",
|
||||
possibleInference:
|
||||
"This may support eventual clarification, but the qualifying condition remains material.",
|
||||
supportCategory: "conditional_tradeoff",
|
||||
resolutionGuidance: "may_resolve",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.stage).toBe("proposal_compatibility");
|
||||
expect(result.errors.join(" ")).toContain("conditional qualification");
|
||||
});
|
||||
|
||||
it("Regression C: rejects unresolved uncertainty being treated as resolved", () => {
|
||||
const { graph, riskUnknownId } = makeRiskClarificationFixture();
|
||||
|
||||
|
||||
@@ -101,6 +101,33 @@ describe("parseGraphUpdateProposal", () => {
|
||||
expect(result.proposal.addedNodes[0].id).toBe("n-new");
|
||||
});
|
||||
|
||||
it("normalises equivalent answerMeaning supportCategory labels to the canonical contract", () => {
|
||||
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_qualification",
|
||||
resolutionGuidance: "may_resolve",
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.proposal.answerMeaning.supportCategory).toBe(
|
||||
"conditional_tradeoff",
|
||||
);
|
||||
expect(result.normalisationsApplied).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
path: ["answerMeaning", "supportCategory"],
|
||||
change: "Converted conditional_qualification to conditional_tradeoff",
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("unknown enum values still fail", () => {
|
||||
const result = parseGraphUpdateProposal({
|
||||
...makeValidProposal(),
|
||||
@@ -125,6 +152,27 @@ describe("parseGraphUpdateProposal", () => {
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it("still rejects unsupported answerMeaning supportCategory labels", () => {
|
||||
const result = parseGraphUpdateProposal({
|
||||
...makeValidProposal(),
|
||||
answerMeaning: {
|
||||
userSupportedMeaning: "Risk matters more to me.",
|
||||
possibleInference: null,
|
||||
supportCategory: "constraint_preference_mix",
|
||||
resolutionGuidance: "must_remain_unresolved",
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.errors).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
path: ["answerMeaning", "supportCategory"],
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("defaults missing selectedQuestion to null", () => {
|
||||
const result = parseGraphUpdateProposal({
|
||||
addedNodes: [],
|
||||
|
||||
Reference in New Issue
Block a user