Support closing-note rank fallback

This commit is contained in:
OpenClaw Bot
2026-05-27 19:38:53 +02:00
parent 90beb50459
commit 13622de5a0
3 changed files with 75 additions and 1 deletions
+43
View File
@@ -1236,6 +1236,31 @@ function optionsFromQuestionsToSitWith(items = [], sourceSection = 'concept-map.
}).filter(item => item.action && item.evidence);
}
function optionFromClosingNote(text = '', sourceSection = 'concept-map.closingNote', sourceTitle = '48-hour next move') {
const note = cleanMultiline(text, 520);
if (!note) return null;
return {
id: 'closing-note-next-move',
action: titleFromBuildOrderFragment(note),
why: 'Scattermind named this as the single best next move in the Concept Map closing note.',
evidence: /\b(evidence|signal|proof|test|validate|ask|observe|show|playtest|prototype)\b/i.test(note)
? note
: 'What smallest real-world signal would prove this 48-hour move deserves the active build slot?',
nextStep: note,
suggestedLane: 'do-first',
rankerHints: { value: 8, effort: 2, confidence: 7, urgency: 8, risk: 2 },
sourceSection,
sourceItemId: `${sourceSection}#1`,
sourceTitle,
sourceExcerpt: note,
};
}
function closingNoteFromSource(source = {}) {
const obj = objectFrom(source);
return cleanMultiline(obj.closing_note || obj.closingNote || obj.next48Hours || obj.next_48_hours || obj.startHere || obj.start_here || '', 520);
}
function optionsFromSnapshotReading(source = {}, sourceSection = 'snapshot') {
const reading = objectFrom(source);
const lenses = objectFrom(reading.lenses);
@@ -1422,6 +1447,13 @@ function optionsFromBody(body = {}) {
'Thread to hold'
);
if (actionThreadOptions.length >= 2) return normalizeCandidateGroup([{ items: actionThreadOptions, sourceSection: actionThreadSource.sourceSection || 'threadsToHold' }]);
const closingNoteSource = [
{ text: closingNoteFromSource(conceptMap), sourceSection: 'concept-map.closingNote' },
{ text: closingNoteFromSource(snapshot), sourceSection: 'snapshot.closingNote' },
{ text: closingNoteFromSource(envelope), sourceSection: 'ranker-input.closingNote' },
{ text: closingNoteFromSource(featureSet), sourceSection: 'feature-set.closingNote' },
{ text: closingNoteFromSource(body), sourceSection: 'closingNote' },
].find(entry => entry.text) || { text: '', sourceSection: '' };
const questionSource = firstArraySource([
{ items: conceptMap.questions_to_sit_with || conceptMap.questionsToSitWith || conceptMap.evidenceQuestions || conceptMap.evidence_questions || conceptMap.decisionQuestions || conceptMap.decision_questions || conceptMap.questionsToAnswer || conceptMap.questions_to_answer || conceptMap.followupQuestions || conceptMap.followup_questions || conceptMap.openQuestions || conceptMap.open_questions, sourceSection: 'concept-map.questionsToSitWith' },
{ items: snapshot.questions_to_sit_with || snapshot.questionsToSitWith || snapshot.evidenceQuestions || snapshot.evidence_questions || snapshot.decisionQuestions || snapshot.decision_questions || snapshot.questionsToAnswer || snapshot.questions_to_answer || snapshot.followupQuestions || snapshot.followup_questions || snapshot.openQuestions || snapshot.open_questions, sourceSection: 'snapshot.questionsToSitWith' },
@@ -1434,6 +1466,17 @@ function optionsFromBody(body = {}) {
questionSource.sourceSection || 'questionsToSitWith',
'Question to sit with'
);
const closingNoteOption = optionFromClosingNote(
closingNoteSource.text,
closingNoteSource.sourceSection || 'closingNote',
'Concept Map closing note'
);
if (closingNoteOption && questionOptions.length) {
return normalizeCandidateGroup([
{ items: [closingNoteOption], sourceSection: closingNoteSource.sourceSection || 'closingNote', defaultLane: 'do-first' },
{ items: questionOptions, sourceSection: questionSource.sourceSection || 'questionsToSitWith', defaultLane: 'validate-next' },
]);
}
if (questionOptions.length >= 2) return normalizeCandidateGroup([{ items: questionOptions, sourceSection: questionSource.sourceSection || 'questionsToSitWith', defaultLane: 'validate-next' }]);
const nestedSnapshotReadingOptions = optionsFromSnapshotReading(snapshot, 'snapshot');
const snapshotReadingOptions = nestedSnapshotReadingOptions.length