fix(reasoning): honor explicit whether propositions

This commit is contained in:
2026-08-14 07:01:23 +01:00
parent 29d565372b
commit 437aadc587
2 changed files with 78 additions and 3 deletions
+4 -3
View File
@@ -118,10 +118,11 @@ function extractMeaning(node) {
};
if (
/\b(status|likelihood|probability|chance|risk|uncertainty)\b/i.test(
/^whether\s+/i.test(strippedDescription) &&
(/\b(status|likelihood|probability|chance|risk|uncertainty)\b/i.test(
String(node?.label || ""),
) &&
/^whether\s+/i.test(strippedDescription)
) ||
/^whether\s+/i.test(description))
) {
return sentenceCase(extractWhetherProposition(strippedDescription));
}
+74
View File
@@ -893,6 +893,53 @@ describe("formulateQuestion", () => {
);
});
it("60B.31 regression: bare 'Whether...' description defines proposition even with nominal label", () => {
const unknown = makeNode({
id: "unc-60b31",
label: "Enterprise customer signing decision",
description:
"Whether the prospective enterprise customer will commit this year, because resolving this uncertainty is needed to decide if launching this year provides superior net value over waiting twelve months.",
kind: "unknown",
status: "unknown",
confidence: "medium",
});
const graph = makeGraphFor(unknown, {
centralStatement:
"We need to decide whether launching this year provides superior net value over waiting twelve months.",
});
const result = formulateQuestion({ node: unknown, graph });
expect(result.question).toBe(
"What evidence would clarify whether the prospective enterprise customer will commit this year?",
);
expect(result.question).not.toContain("launching");
expect(result.question).not.toContain("superior net value");
expect(result.question).not.toContain("waiting twelve months");
expect(result.question).not.toContain("because");
});
it("bare 'Whether...' with unrelated nominal label remains proposition-specific", () => {
const unknown = makeNode({
id: "unc-bare-nominal",
label: "Supplier contract decision",
description: "Whether the supplier will renew the contract.",
kind: "unknown",
status: "unknown",
confidence: "medium",
});
const result = formulateQuestion({
node: unknown,
graph: makeGraphFor(unknown),
});
expect(result.question).toBe(
"What evidence would clarify whether the supplier will renew the contract?",
);
});
it("bare 'Whether...' remains unchanged (existing behaviour)", () => {
const unknown = makeNode({
id: "unc-bare-whether",
@@ -980,6 +1027,33 @@ describe("formulateQuestion", () => {
);
});
it("generic non-proposition decision unknown remains on its existing non-proposition path", () => {
const unknown = makeNode({
id: "unc-generic-decision",
label: "Launch decision value threshold",
description:
"Need to determine what outcome would be sufficient to justify launching this year.",
kind: "unknown",
status: "unknown",
confidence: "medium",
});
const result = formulateQuestion({
node: unknown,
graph: makeGraphFor(unknown, {
centralStatement:
"We need to decide whether launching this year provides superior net value over waiting twelve months.",
}),
});
expect(result.question).not.toContain(
"whether the prospective enterprise customer will commit this year",
);
expect(result.question).not.toContain(
"whether the supplier will renew the contract",
);
});
it("nominal label without explicit 'whether...' falls back to label-based extraction", () => {
const unknown = makeNode({
id: "unc-nominal",