fix(mindspace): use UUIDs for repair replies

This commit is contained in:
john
2026-07-12 15:53:11 +08:00
parent 73b308af0a
commit f9561cd91d
4 changed files with 8 additions and 2 deletions
+3 -1
View File
@@ -235,7 +235,9 @@ export async function maybeRepairH5HtmlAfterFinish({
repairAttemptsBySession.set(key, attempts + 1);
const prompt = buildH5HtmlRepairPrompt(evaluation);
const requestId = `h5-html-repair-${crypto.randomUUID()}`;
// goosed validates request_id as a UUID, so repair metadata must not be
// encoded by prefixing the id. The message metadata below carries the type.
const requestId = crypto.randomUUID();
const userMessage = {
role: 'user',
content: [{ type: 'text', text: prompt }],
+1
View File
@@ -109,6 +109,7 @@ test('maybeRepairH5HtmlAfterFinish triggers proxy reply when enabled', async ()
});
assert.equal(result.repaired, true);
assert.equal(calls.length, 1);
assert.match(calls[0].requestId, /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
assert.match(calls[0].userMessage.content[0].text, /icon\.svg/);
} finally {
if (previous == null) delete process.env.MEMIND_H5_HTML_FINISH_GUARD;
@@ -300,6 +300,7 @@ test('integration: H5 finish guard triggers repair prompt for invalid survey htm
assert.equal(result.repaired, true);
assert.equal(result.triggered, true);
assert.equal(submitCalls.length, 1);
assert.match(submitCalls[0].requestId, /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
assert.match(submitCalls[0].userMessage.content[0].text, /localStorage/);
assert.match(submitCalls[0].userMessage.content[0].text, /private_data_bind_workspace_page/);
} finally {
+3 -1
View File
@@ -646,7 +646,9 @@ export async function maybeRepairPageDataAfterFinish({
repairAttemptsBySession.set(key, attempts + 1);
const prompt = buildPageDataCollectRepairPrompt(afterBind);
const requestId = `page-data-repair-${crypto.randomUUID()}`;
// goosed validates request_id as a UUID. Keep the repair classification in
// message metadata rather than making the request id non-conformant.
const requestId = crypto.randomUUID();
const userMessage = {
role: 'user',
content: [{ type: 'text', text: prompt }],