fix(page-data): enforce full workspace bind delivery and repair tooling

Prevent false-positive Finish Guard passes and sync-created fake bindings by assessing publication, policy, dataset, injection, and insert smoke before H5 delivery.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-12 15:30:52 +08:00
parent f437a37660
commit 73b308af0a
12 changed files with 819 additions and 33 deletions
+39 -3
View File
@@ -32,8 +32,9 @@ import { resolveBillingTokenState } from './billing-token-state.mjs';
import {
buildPageDataCollectFailureText,
buildPageDataDeliveryArtifactsFromBindResult,
ensurePageDataDeliveryReady,
maybeAutoBindPageDataHtmlPages,
resolvePageDataCollectOutcome,
resolvePageDataCollectOutcomeAsync,
rewritePageDataDeliveryLinks,
} from './mindspace-page-data-finish-guard.mjs';
@@ -1056,28 +1057,40 @@ async function enforcePageDataCollectDelivery({
requestStartedAt = 0,
notifyFailure,
}) {
let outcome = resolvePageDataCollectOutcome({
let outcome = await resolvePageDataCollectOutcomeAsync({
reply,
intent,
publishDir: workingDir,
requestStartedAt,
pool: pageDataFinishGuard?.pool ?? null,
userId,
findPageByRelativePath: null,
});
let autoBind = null;
if (outcome.action === 'skip') return outcome;
if (pageDataFinishGuard?.pool) {
const { createPageService } = await import('./mindspace-pages.mjs');
const pageService = createPageService(pageDataFinishGuard.pool, {
h5Root: pageDataFinishGuard.h5Root,
storageRoot: pageDataFinishGuard.storageRoot,
});
autoBind = await maybeAutoBindPageDataHtmlPages({
pool: pageDataFinishGuard.pool,
userId,
publishDir: workingDir,
h5Root: pageDataFinishGuard.h5Root,
storageRoot: pageDataFinishGuard.storageRoot,
findPageByRelativePath: pageService.findPageByRelativePath.bind(pageService),
});
outcome = resolvePageDataCollectOutcome({
outcome = await resolvePageDataCollectOutcomeAsync({
reply,
intent,
publishDir: workingDir,
requestStartedAt,
pool: pageDataFinishGuard.pool,
userId,
findPageByRelativePath: pageService.findPageByRelativePath.bind(pageService),
});
}
@@ -1095,6 +1108,29 @@ async function enforcePageDataCollectDelivery({
const deliveryArtifacts = buildPageDataDeliveryArtifactsFromBindResult(autoBind, workingDir, {
publicBaseUrl,
});
if (deliveryArtifacts.length > 0 && pageDataFinishGuard?.pool) {
const { createPageService } = await import('./mindspace-pages.mjs');
const pageService = createPageService(pageDataFinishGuard.pool, {
h5Root: pageDataFinishGuard.h5Root,
storageRoot: pageDataFinishGuard.storageRoot,
});
const deliveryCheck = await ensurePageDataDeliveryReady({
publishDir: workingDir,
userId,
pool: pageDataFinishGuard.pool,
h5Root: pageDataFinishGuard.h5Root,
storageRoot: pageDataFinishGuard.storageRoot,
apiBase: publicBaseUrl,
artifacts: deliveryArtifacts,
});
if (!deliveryCheck.ok) {
const text = buildPageDataCollectFailureText();
if (typeof notifyFailure === 'function') {
await notifyFailure(text);
}
throw markWechatUserNotified(new Error(text));
}
}
if (deliveryArtifacts.length > 0 && reply && typeof reply.text === 'string') {
reply.text = rewritePageDataDeliveryLinks(reply.text, deliveryArtifacts);
}