Files
memind/scripts/verify-mindspace-page-sync-guards.mjs
john 264c213fbe fix(mindspace): use lightweight page sync for background list refresh
Background page list sync was calling syncAndDeliver over the remote adapter,
which could exceed the 60s timeout for heavy users and block Portal. Route list
sync through pageSyncService only via listSync while keeping full delivery on
Finish and agent-run paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 08:53:58 +08:00

80 lines
2.1 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
const root = path.resolve(new URL('..', import.meta.url).pathname);
function read(relativePath) {
return fs.readFileSync(path.join(root, relativePath), 'utf8');
}
function assertIncludes(label, source, snippet) {
if (!source.includes(snippet)) {
throw new Error(`${label} is missing required guard snippet:\n${snippet}`);
}
}
const serverSource = read('server.mjs');
const pagesSource = read('mindspace-pages.mjs');
const contractSource = read('mindspace-server-adapter-contract.mjs');
assertIncludes(
'server.mjs syncUserGeneratedPages',
serverSource,
'mindSpacePageSync.syncUserGeneratedPages(userId',
);
assertIncludes(
'server.mjs list page sync bypasses full delivery',
serverSource,
'listSync = false',
);
const pageCoreRoutesSource = read('server/portal-mindspace-page-core-routes.mjs');
assertIncludes(
'portal page list background sync',
pageCoreRoutesSource,
'syncUserGeneratedPages(userId, { listSync: true })',
);
if (serverSource.includes("mindSpaceServerRuntime.adapterKind === 'remote'")) {
throw new Error(
'server.mjs must not skip page sync in remote mode; use pageSyncService RPC instead',
);
}
assertIncludes(
'mindspace-server-adapter-contract.mjs',
contractSource,
"pageSyncService: Object.freeze(['syncUserGeneratedPages'])",
);
assertIncludes(
'mindspace-pages.mjs',
pagesSource,
'readPageContentWithWorkspaceFallback',
);
assertIncludes(
'mindspace-pages.mjs workspace fallback',
pagesSource,
"snapshot.relative_path ?? null",
);
const publicSiteBasesSource = read('src/utils/public-site-bases.mjs');
const publicUrlSource = read('src/utils/publicUrl.ts');
const buildRuntimeSource = read('scripts/build-portal-runtime.mjs');
assertIncludes(
'public-site-bases.mjs loopback guard',
publicSiteBasesSource,
'isLoopbackPublicBase',
);
assertIncludes(
'publicUrl.ts uses public-site-bases',
publicUrlSource,
"from './public-site-bases.mjs'",
);
assertIncludes(
'build-portal-runtime.mjs production plaza default',
buildRuntimeSource,
'https://plaza.tkmind.cn',
);
console.log('mindspace page sync + thumbnail regression guards ok');