Handle structured Scattermind context

This commit is contained in:
OpenClaw Bot
2026-05-26 23:40:46 +02:00
parent 65832f9b56
commit adcef9a6f7
3 changed files with 58 additions and 4 deletions
+34 -1
View File
@@ -337,7 +337,40 @@ try {
assert.ok(duplicateIds.handoff.warnings.some(item => /duplicate source id preview normalized to preview-2/.test(item)));
assert.ok(Object.values(duplicateIds.buildOrder).flat().includes('preview-2'));
console.log(JSON.stringify({ ok: true, top: data.ranked[0].id, hintedTop: hinted.ranked[0].id, actionTop: actions.ranked[0].id, nestedConceptTop: nestedConcept.ranked[0].id, nonGoalTop: nonGoal.ranked[0].id, duplicateIds: duplicateIds.ranked.map(item => item.id), provenance: data.input.provenance, buildOrder: data.buildOrder }, null, 2));
const structuredContextResponse = await fetch(`${base}/api/rank-feedback`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
sourceName: 'Scattermind',
artifactId: 'concept_map_structured_context',
originalPrompt: 'Scattermind sent a structured context object instead of a flat context string.',
idea: 'Ranker should preserve structured context and not turn it into [object Object].',
mode: 'mvp',
context: {
summary: 'Bridge proof for a tired non-AI-native user.',
targetAudience: 'Tired non-AI-native solo builder',
constraints: ['No account before first value', 'Use a copyable artifact first'],
nonGoals: ['Avoid auth dashboard', 'Avoid saved workspaces'],
assumptions: ['Manual proof is acceptable for the first pass'],
},
conceptMap: {
nextActions: [
{ id: 'copyable-bridge-artifact', action: 'Copyable bridge artifact', why: 'Turn the source Concept Map into one defended build-order brief.', evidence: 'Can the user paste it and know the first move?', suggestedLane: 'do-first', rankerHints: { value: 9, effort: 2, confidence: 8, urgency: 8, risk: 2 } },
{ id: 'auth-dashboard', action: 'Auth dashboard', why: 'Accounts and saved workspaces for every idea.', evidence: 'None yet', suggestedLane: 'do-first', rankerHints: { value: 10, effort: 2, confidence: 9, urgency: 9, risk: 2 } },
],
},
}),
});
assert.equal(structuredContextResponse.status, 200);
const structuredContext = await structuredContextResponse.json();
assert.doesNotMatch(structuredContext.input.context, /\[object Object\]/);
assert.match(structuredContext.input.context, /Target audience: Tired non-AI-native solo builder/);
assert.deepEqual(structuredContext.input.decisionContext.constraints, ['No account before first value', 'Use a copyable artifact first']);
assert.deepEqual(structuredContext.handoff.decisionContext.nonGoals, ['Avoid auth dashboard', 'Avoid saved workspaces']);
assert.equal(structuredContext.ranked[0].id, 'copyable-bridge-artifact');
assert.equal(structuredContext.ranked.find(item => item.id === 'auth-dashboard').lane.source, 'source-non-goal');
console.log(JSON.stringify({ ok: true, top: data.ranked[0].id, hintedTop: hinted.ranked[0].id, actionTop: actions.ranked[0].id, nestedConceptTop: nestedConcept.ranked[0].id, nonGoalTop: nonGoal.ranked[0].id, structuredContextTop: structuredContext.ranked[0].id, duplicateIds: duplicateIds.ranked.map(item => item.id), provenance: data.input.provenance, buildOrder: data.buildOrder }, null, 2));
} finally {
server.kill('SIGTERM');
}