Harden Ranker summary guardrails

This commit is contained in:
OpenClaw Bot
2026-05-27 15:34:47 +02:00
parent 5cd5dd2fcf
commit 1a829e05af
3 changed files with 47 additions and 4 deletions
+12 -2
View File
@@ -181,7 +181,7 @@ function guardrailsFromContextText(value = '') {
for (const sentence of contextSentences(value)) {
const cleaned = cleanText(sentence, 180);
if (!cleaned) continue;
if (/^(avoid|no|do not|don't|dont|must not|never)\b/i.test(cleaned)) nonGoals.push(cleaned);
if (/^(avoid|no|do not|don't|dont|must not|never|non-goal|non goal|not yet|out of scope)\b/i.test(cleaned)) nonGoals.push(cleaned.replace(/^non[- ]goal\s*:\s*/i, ''));
else if (/\b(avoid|no auth|no account|no billing|no workspace|not a dashboard|without accounts|before proof|manual proof|solo builder|constraint)\b/i.test(cleaned)) constraints.push(cleaned);
}
return { nonGoals: uniqueList(nonGoals), constraints: uniqueList(constraints) };
@@ -636,6 +636,12 @@ function firstContextText(sources = [], aliases = []) {
return '';
}
function contextGuardrailText(value = '') {
if (!value || typeof value !== 'object' || Array.isArray(value)) return cleanMultiline(value || '', 3000);
const obj = objectFrom(value);
return cleanMultiline(obj.summary || obj.description || obj.notes || obj.brief || obj.text || '', 3000);
}
function cleanDecisionContext(input = {}) {
const featureSet = objectFrom(input.featureSet || input.feature_set);
const artifact = objectFrom(input.artifact || featureSet.artifact);
@@ -660,7 +666,11 @@ function cleanDecisionContext(input = {}) {
artifact.context,
];
const textContextGuardrails = guardrailsFromContextText([
typeof input.context === 'string' ? input.context : '',
contextGuardrailText(input.context || ''),
contextGuardrailText(featureSet.context || ''),
contextGuardrailText(artifact.context || ''),
contextGuardrailText(snapshot.context || ''),
contextGuardrailText(conceptMap.context || ''),
lensContent(riskLens),
lensContent(constraintsLens),
conceptMap.risk || conceptMap.whatNotToBuildYet || conceptMap.notYet || '',