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,79 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
buildPageDataValidationRepairPrompt,
|
||||
formatPageDataValidationUserMessage,
|
||||
isPageDataSuggestionRemediable,
|
||||
listPageDataValidationSuggestionCodes,
|
||||
resolvePageDataValidationSuggestions,
|
||||
suggestionCodesFromPageDataHtmlIssues,
|
||||
} from './page-data-validation-suggestions.mjs';
|
||||
|
||||
test('first-batch Page Data suggestion codes are registered', () => {
|
||||
const codes = listPageDataValidationSuggestionCodes();
|
||||
for (const code of [
|
||||
'PAGE_DATA_DELIVERABLE_MISSING',
|
||||
'PAGE_DATA_DELIVERY_FAILED',
|
||||
'DELIVERABLE_DATA_STORAGE_FORBIDDEN',
|
||||
'COLUMNS_NOT_ALLOWED',
|
||||
'WORKFLOW_VALIDATION_GATE_UNAVAILABLE',
|
||||
'WORKFLOW_VALIDATION_GATE_REJECTED',
|
||||
'WORKFLOW_VALIDATION_GATE_INCONCLUSIVE',
|
||||
]) {
|
||||
assert.ok(codes.includes(code), `missing ${code}`);
|
||||
}
|
||||
});
|
||||
|
||||
test('resolvePageDataValidationSuggestions dedupes and ignores unknown codes', () => {
|
||||
const suggestions = resolvePageDataValidationSuggestions([
|
||||
'page_data_deliverable_missing',
|
||||
'PAGE_DATA_DELIVERABLE_MISSING',
|
||||
'not-a-real-code',
|
||||
'columns_not_allowed',
|
||||
]);
|
||||
assert.deepEqual(
|
||||
suggestions.map((item) => item.code),
|
||||
['PAGE_DATA_DELIVERABLE_MISSING', 'COLUMNS_NOT_ALLOWED'],
|
||||
);
|
||||
assert.ok(suggestions[0].actions.length >= 1);
|
||||
});
|
||||
|
||||
test('formatPageDataValidationUserMessage appends actionable Chinese suggestions', () => {
|
||||
const text = formatPageDataValidationUserMessage({
|
||||
code: 'WORKFLOW_VALIDATION_GATE_UNAVAILABLE',
|
||||
message: 'Page Data Orchestrator validation was not observed: not_selected',
|
||||
});
|
||||
assert.match(text, /Page Data Orchestrator validation was not observed/);
|
||||
assert.match(text, /建议(Page Data 审查服务不可用)/);
|
||||
assert.match(text, /PAGE_DATA_VALIDATION_GATE_ENABLED=0|仅观察/);
|
||||
});
|
||||
|
||||
test('formatPageDataValidationUserMessage keeps original message when code is unknown', () => {
|
||||
const text = formatPageDataValidationUserMessage({
|
||||
code: 'SOME_UNKNOWN_CODE',
|
||||
message: '原始错误',
|
||||
});
|
||||
assert.equal(text, '原始错误');
|
||||
});
|
||||
|
||||
test('html issues map to remediable suggestion codes for goosed repair', () => {
|
||||
assert.deepEqual(
|
||||
suggestionCodesFromPageDataHtmlIssues([
|
||||
{ relativePath: 'public/x.html', issue: 'forbidden_local_storage' },
|
||||
]),
|
||||
['FORBIDDEN_LOCAL_STORAGE'],
|
||||
);
|
||||
assert.equal(isPageDataSuggestionRemediable('DELIVERABLE_DATA_STORAGE_FORBIDDEN'), true);
|
||||
assert.equal(isPageDataSuggestionRemediable('WORKFLOW_VALIDATION_GATE_UNAVAILABLE'), false);
|
||||
});
|
||||
|
||||
test('buildPageDataValidationRepairPrompt includes Chinese suggestions for goosed', () => {
|
||||
const prompt = buildPageDataValidationRepairPrompt({
|
||||
htmlIssues: [{ relativePath: 'public/x.html', issue: 'forbidden_local_storage' }],
|
||||
unboundFiles: [{ relativePath: 'public/x.html' }],
|
||||
});
|
||||
assert.match(prompt, /系统纠正建议/);
|
||||
assert.match(prompt, /page-data-collect/);
|
||||
assert.match(prompt, /检测到 localStorage 回退|FORBIDDEN_LOCAL_STORAGE/);
|
||||
assert.match(prompt, /private_data_bind_workspace_page/);
|
||||
});
|
||||
Reference in New Issue
Block a user