feat(page-data): add validation suggestions, repair path, and thinking fixes
Memind CI / Test, build, and release guards (push) Failing after 3m18s
Memind CI / Test, build, and release guards (push) Failing after 3m18s
Map Page Data failure codes to Chinese remediation hints, trigger one-shot goosed repair for remediable cases, and recover poisoned thinking sessions. Route local DeepSeek through the no-think proxy via host.docker.internal so tool rounds no longer hit reasoning_content 400; document gate and case-study scenarios for event registration repair. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Case study: Page Data Tier A suggestions → goosed one-shot repair prompt.
|
||||
* Deterministic (no live agent). Prints a structured report for the event-registration story.
|
||||
*/
|
||||
import {
|
||||
buildPageDataValidationRepairPrompt,
|
||||
formatPageDataValidationUserMessage,
|
||||
isPageDataSuggestionRemediable,
|
||||
resolvePageDataValidationSuggestions,
|
||||
} from '../page-data-validation-suggestions.mjs';
|
||||
import { buildPageDataCollectRepairPrompt } from '../mindspace-page-data-finish-guard.mjs';
|
||||
|
||||
const CASES = [
|
||||
{
|
||||
id: 'missing-deliverable',
|
||||
title: '报名页未生成 public HTML',
|
||||
code: 'PAGE_DATA_DELIVERABLE_MISSING',
|
||||
message: 'Page Data 任务未生成可交付页面,不能标记成功',
|
||||
},
|
||||
{
|
||||
id: 'localstorage-forbidden',
|
||||
title: '报名表误用 localStorage',
|
||||
code: 'DELIVERABLE_DATA_STORAGE_FORBIDDEN',
|
||||
message: '页面交付违反数据存储策略:forbidden_local_storage',
|
||||
htmlIssues: [{ relativePath: 'public/event-registration-survey.html', issue: 'forbidden_local_storage' }],
|
||||
},
|
||||
{
|
||||
id: 'bind-failed',
|
||||
title: '后台页未 bind / 策略缺失',
|
||||
code: 'PAGE_DATA_DELIVERY_FAILED',
|
||||
message: '页面数据绑定或发布失败',
|
||||
unboundFiles: [{ relativePath: 'public/event-registration-admin.html' }],
|
||||
},
|
||||
{
|
||||
id: 'orchestrator-down',
|
||||
title: '审查闸门不可用(不应自动修)',
|
||||
code: 'WORKFLOW_VALIDATION_GATE_UNAVAILABLE',
|
||||
message: 'Page Data Orchestrator validation was not observed: not_selected',
|
||||
},
|
||||
];
|
||||
|
||||
function section(title) {
|
||||
console.log(`\n## ${title}`);
|
||||
}
|
||||
|
||||
const report = {
|
||||
caseStudy: 'event-registration-page-data-suggestion-repair',
|
||||
generatedAt: new Date().toISOString(),
|
||||
cases: [],
|
||||
};
|
||||
|
||||
section('Page Data 审查纠错案例(确定性)');
|
||||
console.log('场景:活动报名表单 + 口令后台列表');
|
||||
console.log('链路:失败 code → 中文建议(用户可见)→ remediable? → goosed repair prompt(每 run 最多 1 次)');
|
||||
|
||||
for (const item of CASES) {
|
||||
const suggestions = resolvePageDataValidationSuggestions([item.code]);
|
||||
const userVisible = formatPageDataValidationUserMessage({
|
||||
code: item.code,
|
||||
message: item.message,
|
||||
});
|
||||
const remediable = isPageDataSuggestionRemediable(item.code);
|
||||
const goosedPrompt = remediable
|
||||
? buildPageDataValidationRepairPrompt({
|
||||
code: item.code,
|
||||
message: item.message,
|
||||
htmlIssues: item.htmlIssues ?? [],
|
||||
unboundFiles: item.unboundFiles ?? [],
|
||||
})
|
||||
: null;
|
||||
const finishGuardPrompt = item.htmlIssues
|
||||
? buildPageDataCollectRepairPrompt({
|
||||
htmlIssues: item.htmlIssues,
|
||||
unboundFiles: item.unboundFiles ?? [],
|
||||
})
|
||||
: null;
|
||||
|
||||
report.cases.push({
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
code: item.code,
|
||||
suggestionCount: suggestions.length,
|
||||
remediable,
|
||||
userVisiblePreview: userVisible.slice(0, 240),
|
||||
goosedPromptPreview: goosedPrompt ? goosedPrompt.slice(0, 280) : null,
|
||||
autoRepairToGoosed: remediable,
|
||||
});
|
||||
|
||||
section(item.title);
|
||||
console.log(`code: ${item.code}`);
|
||||
console.log(`remediable → goosed: ${remediable ? 'YES (one-shot)' : 'NO'}`);
|
||||
console.log('--- user-visible ---');
|
||||
console.log(userVisible);
|
||||
if (goosedPrompt) {
|
||||
console.log('--- goosed repair prompt (truncated) ---');
|
||||
console.log(goosedPrompt.split('\n').slice(0, 14).join('\n'));
|
||||
console.log('...');
|
||||
}
|
||||
if (finishGuardPrompt) {
|
||||
console.log('finish-guard prompt includes suggestions:', /纠正建议|FORBIDDEN_LOCAL_STORAGE/.test(finishGuardPrompt));
|
||||
}
|
||||
}
|
||||
|
||||
section('汇总');
|
||||
console.table(
|
||||
report.cases.map((row) => ({
|
||||
id: row.id,
|
||||
code: row.code,
|
||||
suggestions: row.suggestionCount,
|
||||
auto_goosed: row.autoRepairToGoosed,
|
||||
})),
|
||||
);
|
||||
|
||||
const remediableCount = report.cases.filter((row) => row.remediable).length;
|
||||
const blockedCount = report.cases.length - remediableCount;
|
||||
console.log(`\n结论: ${remediableCount} 个案例会自动把建议发给 goosed;${blockedCount} 个(基础设施/闸门)只展示建议不自动修。`);
|
||||
console.log(JSON.stringify({ ok: true, remediableCount, blockedCount }, null, 2));
|
||||
Reference in New Issue
Block a user