feat: harden orchestrator execution runtime

This commit is contained in:
john
2026-07-24 23:53:32 +08:00
parent 396bb78200
commit f6f2cd0933
55 changed files with 5122 additions and 194 deletions
+63
View File
@@ -6,6 +6,7 @@ import {
injectMindSpacePageDataContext,
injectPublishedPageDataContext,
parseMindSpacePublishFilePath,
resolveMindSpacePageDataContext,
} from './mindspace-public-page-context.mjs';
test('parseMindSpacePublishFilePath extracts userId and relative path', () => {
@@ -47,3 +48,65 @@ test('injectPublishedPageDataContext injects pageId from publication resolve res
assert.match(next, /meta name="mindspace-page-data-page-id" content="2b201736-03ca-4172-affd-00f2a0f700b5"/);
assert.match(next, /window\.__MINDSPACE_PAGE_DATA__=\{"pageId":"2b201736-03ca-4172-affd-00f2a0f700b5","accessMode":"public"\}/);
});
test('resolveMindSpacePageDataContext prefers the Portal policy index in split-service mode', async () => {
const pool = {
async query() {
return [[{
page_id: 'local-page',
owner_user_id: 'user-1',
access_mode: 'public',
dataset_count: 1,
scope_hash: 'scope',
updated_at: 123,
current_publish_id: 'local-publish',
}]];
},
};
let remoteCalls = 0;
const result = await resolveMindSpacePageDataContext({
pool,
pageService: {
async findPageByRelativePath() {
remoteCalls += 1;
return { id: 'remote-page', publicationAccessMode: 'password' };
},
},
userId: 'USER-1',
relativePath: 'public/storefront.html',
});
assert.deepEqual(result, {
pageId: 'local-page',
accessMode: 'public',
publicationId: 'local-publish',
});
assert.equal(remoteCalls, 0);
});
test('resolveMindSpacePageDataContext falls back to the MindSpace page service', async () => {
const result = await resolveMindSpacePageDataContext({
pool: {
async query() {
return [[]];
},
},
pageService: {
async findPageByRelativePath(userId, relativePath) {
assert.equal(userId, 'user-1');
assert.equal(relativePath, 'public/plain.html');
return {
id: 'remote-page',
publicationAccessMode: 'internal',
currentPublishId: 'remote-publish',
};
},
},
userId: 'USER-1',
relativePath: 'public/plain.html',
});
assert.deepEqual(result, {
pageId: 'remote-page',
accessMode: 'internal',
publicationId: 'remote-publish',
});
});