Add Format Specification section 21 (Scenario Model 0.1) and the runtime that realizes it: the scenario director, seven trigger classes, timelines with repeats and branches, admission and concurrency control, nested ownership with bounded cleanup, and the production GC5 resource counters. Exhibit E provides a reproducible forty-minute long-scenario reference and scenario-challenge.xzbt covers the PRD 131 cases. A standalone acceptance/soak page is built by tools/build-scenario-acceptance.mjs. 252 automated checks pass. The two-hour real-duration development soak required by the GC6 schedule remains pending. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01M7dgfQ12mpM4JjSMv3inLA
88 lines
3.3 KiB
JavaScript
88 lines
3.3 KiB
JavaScript
#!/usr/bin/env node
|
|
import { createHash } from 'node:crypto';
|
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
const sourceFiles = Object.freeze([
|
|
'src/runtime/constants.js',
|
|
'src/runtime/diagnostics.js',
|
|
'src/runtime/rng.js',
|
|
'src/runtime/types.js',
|
|
'src/runtime/values.js',
|
|
'src/runtime/audio-contract.js',
|
|
'src/runtime/audio-protection.js',
|
|
'src/runtime/audio-automation.js',
|
|
'src/runtime/audio-graph.js',
|
|
'src/runtime/audio-controls.js',
|
|
'src/runtime/visual-contract.js',
|
|
'src/runtime/visual-diagnostics.js',
|
|
'src/runtime/visual-math.js',
|
|
'src/runtime/visual-geometry.js',
|
|
'src/runtime/visual-noise.js',
|
|
'src/runtime/visual-behaviors.js',
|
|
'src/runtime/visual-distributions.js',
|
|
'src/runtime/visual-fields.js',
|
|
'src/runtime/visual-systems.js',
|
|
'src/runtime/visual-validation.js',
|
|
'src/runtime/cadence-validation.js',
|
|
'src/runtime/scenario-validation.js',
|
|
'src/runtime/validator.js',
|
|
'src/runtime/persistence.js',
|
|
'src/runtime/library.js',
|
|
'src/runtime/resolution.js',
|
|
'src/runtime/visual-motion.js',
|
|
'src/runtime/visual-automation.js',
|
|
'src/runtime/visual-lifecycle.js',
|
|
'src/runtime/visual-effects.js',
|
|
'src/runtime/visual-engine.js',
|
|
'src/runtime/visual-canvas2d.js',
|
|
'src/runtime/visual-subsystem.js',
|
|
'src/runtime/actions.js',
|
|
'src/runtime/cadence.js',
|
|
'src/runtime/scenario.js',
|
|
'src/runtime/performance.js',
|
|
'src/runtime/activation.js',
|
|
'src/runtime/audio-engine.js',
|
|
'src/runtime/app.js'
|
|
]);
|
|
|
|
function normalized(path) {
|
|
return readFileSync(resolve(repositoryRoot, path), 'utf8').replace(/\r\n/g, '\n');
|
|
}
|
|
|
|
function bundleModule(source, path) {
|
|
const withoutImports = source.replace(/^import\s+[\s\S]*?\s+from\s+['"][^'"]+['"];\s*$/gm, '');
|
|
const withoutExports = withoutImports.replace(/\bexport\s+/g, '');
|
|
return `\n/* ${path} */\n${withoutExports.trim()}\n`;
|
|
}
|
|
|
|
export function bundleRuntime(includeApp = true) {
|
|
return sourceFiles.filter(path => includeApp || path !== 'src/runtime/app.js')
|
|
.map(path => bundleModule(normalized(path), path)).join('');
|
|
}
|
|
|
|
export function buildStandalone(outputPath = resolve(repositoryRoot, 'XZBT.html')) {
|
|
const template = normalized('src/XZBT.template.html');
|
|
const styles = normalized('src/styles.css').trim();
|
|
const script = `'use strict';\n(() => {\n${bundleRuntime()}\n})();`;
|
|
if (!template.includes('/*__XZBT_STYLES__*/') || !template.includes('/*__XZBT_SCRIPT__*/')) {
|
|
throw new Error('Standalone template is missing a build placeholder.');
|
|
}
|
|
const artifact = template
|
|
.replace('/*__XZBT_STYLES__*/', () => styles)
|
|
.replace('/*__XZBT_SCRIPT__*/', () => script)
|
|
.replace(/\r\n/g, '\n');
|
|
writeFileSync(outputPath, artifact, 'utf8');
|
|
return { outputPath, bytes: Buffer.byteLength(artifact), sha256: createHash('sha256').update(artifact).digest('hex') };
|
|
}
|
|
|
|
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
const outputIndex = process.argv.indexOf('--output');
|
|
const outputPath = outputIndex >= 0 ? resolve(process.argv[outputIndex + 1]) : resolve(repositoryRoot, 'XZBT.html');
|
|
const result = buildStandalone(outputPath);
|
|
console.log(`Built ${result.outputPath}`);
|
|
console.log(`SHA-256 ${result.sha256} (${result.bytes} bytes)`);
|
|
}
|