reasoning: preserve evidence versus clarification distinction
This commit is contained in:
@@ -123,6 +123,49 @@ function buildEvidenceFallbackQuestion(meaning) {
|
||||
return `What evidence would confirm or rule out ${stripTrailingPunctuation(meaning)}?`;
|
||||
}
|
||||
|
||||
function extractConstraintClarificationSubject(node) {
|
||||
const label = stripTrailingPunctuation(node?.label || "");
|
||||
const description = String(node?.description || "");
|
||||
const combined = `${label} ${description}`;
|
||||
|
||||
const labelMatch = label.match(
|
||||
/^Whether\s+(.+)\s+is\s+a\s+hard constraint$/i,
|
||||
);
|
||||
if (labelMatch?.[1]) {
|
||||
return labelMatch[1].trim();
|
||||
}
|
||||
|
||||
const descriptionMatch = combined.match(
|
||||
/whether\s+(.+?)\s+is\s+a\s+hard constraint\s+or\s+a\s+preference(?:\/|-|\s)trade(?:\/|-|\s)?off/i,
|
||||
);
|
||||
if (descriptionMatch?.[1]) {
|
||||
return descriptionMatch[1].trim();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function buildUserMeaningClarificationQuestion(node) {
|
||||
const subject = extractConstraintClarificationSubject(node);
|
||||
|
||||
if (subject) {
|
||||
return `Is ${subject} a hard constraint or a preference/trade-off?`;
|
||||
}
|
||||
|
||||
return buildNeutralClarificationQuestion(extractMeaning(node));
|
||||
}
|
||||
|
||||
function isUserOwnedMeaningBoundaryUnknown(node) {
|
||||
const text = normaliseText(`${node?.label || ""} ${node?.description || ""}`);
|
||||
return (
|
||||
text.includes("hard constraint") &&
|
||||
(text.includes("preference trade off") ||
|
||||
text.includes("preference/trade-off") ||
|
||||
text.includes("preference or trade off") ||
|
||||
text.includes("preference or trade-off"))
|
||||
);
|
||||
}
|
||||
|
||||
function collectObservationNodes(graph) {
|
||||
return (graph?.nodes || []).filter(
|
||||
(node) => node.kind === "observation" && node.status === "supported",
|
||||
@@ -1726,6 +1769,34 @@ export function formulateQuestion({ node, graph, context = {} }) {
|
||||
const rejectedQuestionFamilies = rejectedQuestionFamiliesForPattern(
|
||||
reasoningPatternSelection.pattern,
|
||||
);
|
||||
|
||||
if (isUserOwnedMeaningBoundaryUnknown(node)) {
|
||||
const question = sanitizeQuestionText(
|
||||
buildUserMeaningClarificationQuestion(node),
|
||||
);
|
||||
const questionComplexity = assessQuestionComplexity({
|
||||
question,
|
||||
selectedUnknown: node,
|
||||
graph,
|
||||
});
|
||||
|
||||
return {
|
||||
question,
|
||||
reason:
|
||||
"Formulated as a user-clarification question because this unresolved distinction depends on the user's own meaning rather than external evidence.",
|
||||
strategy: null,
|
||||
investigationStrategy: null,
|
||||
reasoningPattern: reasoningPatternSelection.pattern,
|
||||
reasoningPatternReason: reasoningPatternSelection.reason,
|
||||
questionFamily: "prioritisation",
|
||||
allowedQuestionFamilies,
|
||||
rejectedQuestionFamilies,
|
||||
selectedQuestionTemplate: "user_meaning_clarification",
|
||||
questionComplexity,
|
||||
plainLanguageNormalisations: [],
|
||||
};
|
||||
}
|
||||
|
||||
const foundationalDirectQuestion = buildFoundationalDirectQuestion(node);
|
||||
if (
|
||||
foundationalDirectQuestion &&
|
||||
@@ -1794,7 +1865,7 @@ export function formulateQuestion({ node, graph, context = {} }) {
|
||||
)
|
||||
) {
|
||||
question = sanitizeQuestionText(
|
||||
investigationStrategy &&
|
||||
(investigationStrategy &&
|
||||
isClaimLikeUnknown(
|
||||
node,
|
||||
normaliseText(
|
||||
@@ -1807,7 +1878,8 @@ export function formulateQuestion({ node, graph, context = {} }) {
|
||||
.filter(Boolean)
|
||||
.join(" "),
|
||||
),
|
||||
)
|
||||
)) ||
|
||||
reasoningPatternSelection.pattern === "diagnosis"
|
||||
? buildEvidenceFallbackQuestion(fallbackMeaning)
|
||||
: buildNeutralClarificationQuestion(fallbackMeaning),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user