import { spawnSync } from 'node:child_process'; import path from 'node:path'; const root = path.resolve(new URL('..', import.meta.url).pathname); const withRuntime = process.argv.includes('--with-runtime') || process.env.MINDSPACE_VERIFY_RUNTIME === '1'; function run(label, args) { const result = spawnSync(process.execPath, args, { cwd: root, stdio: 'inherit', }); if (result.status !== 0) { throw new Error(`${label} failed with exit code ${result.status ?? 'unknown'}`); } } run('MindSpace publish + chat finish unit tests', [ '--test', 'mindspace-public-finish-sync.test.mjs', 'mindspace-h5-html-finish-guard.test.mjs', 'mindspace-chat-save-service.test.mjs', 'mindspace-conversation-package-artifact-service.test.mjs', 'mindspace-workspace-publication-delivery-service.test.mjs', 'mindspace-workspace-tool-service.test.mjs', 'mindspace-mcp-scoped-token.test.mjs', 'mindspace-sandbox-mcp.test.mjs', 'capabilities.test.mjs', 'server/portal-workspace-publication-delivery.test.mjs', 'server/portal-publication-routes.test.mjs', 'server/portal-mindspace-asset-routes.test.mjs', 'server/portal-agent-job-routes.test.mjs', 'server/portal-gateway-services-bootstrap.test.mjs', 'conversation-display.test.mjs', 'chat-finish-sync.test.mjs', ]); run('chat finish sync source guards', ['scripts/verify-chat-finish-sync.mjs']); run( withRuntime ? 'MindSpace authority source and runtime guards' : 'MindSpace authority source guards', [ 'scripts/verify-mindspace-authority-boundary.mjs', ...(withRuntime ? ['--with-runtime'] : []), ], ); if (withRuntime) { run('public finish sync runtime guard', ['scripts/verify-public-finish-sync-runtime.mjs']); } console.log( withRuntime ? 'mindspace publish + chat finish regression guards ok (with runtime)' : 'mindspace publish + chat finish regression guards ok', );