reasoning: add proposal-level answer meaning guard

- Add answerMeaning schema with supportCategory and resolutionGuidance enums
- Add pre-mutation guard that validates proposal alignment with answerMeaning
- Update prompt builder to instruct the model on answerMeaning contract
- Add tests for schema, guard logic, parsing defaults, and regression cases A-D
This commit is contained in:
2026-08-09 07:07:21 +01:00
parent 8c1036ecd0
commit 0d7ad5775c
7 changed files with 470 additions and 0 deletions
+21
View File
@@ -19,6 +19,13 @@ function makeValidProposal(overrides = {}) {
resolvedUnknownNodeIds: ["n-unknown"],
affectedNodeIds: [],
selectedQuestion: null,
answerMeaning: {
userSupportedMeaning:
"The user directly provided the updated complaint rate.",
possibleInference: null,
supportCategory: "other",
resolutionGuidance: "may_resolve",
},
...overrides,
};
}
@@ -131,6 +138,20 @@ describe("parseGraphUpdateProposal", () => {
expect(result.proposal.selectedQuestion).toBeNull();
});
it("defaults missing answerMeaning to null", () => {
const result = parseGraphUpdateProposal({
addedNodes: [],
updatedNodes: [],
addedEdges: [],
removedEdgeIds: [],
resolvedUnknownNodeIds: [],
affectedNodeIds: [],
selectedQuestion: null,
});
expect(result.success).toBe(true);
expect(result.proposal.answerMeaning).toBeNull();
});
it("parses a valid selectedQuestion", () => {
const result = parseGraphUpdateProposal(
makeValidProposal({