Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.
JavaScript 3d3d-assets3d-modelingagent-skillsagent-toolsai-agentsasset-pipelinecligame-assetsglbgltfmcpmcp-servermodel-context-protocolprocedural-generationprocedural-modelingtext-to-3dthreejstypescript
feat(site): append committed Holodeck examples to frozen selections (#265)
Matthew Kissinger3c6fc390eae3
diff --git a/packs/holodeck/README.md b/packs/holodeck/README.mdindex d1bdca37..61dba7d2 100644--- a/packs/holodeck/README.md+++ b/packs/holodeck/README.md@@ -66,6 +66,39 @@ A store is a workspace's `assets/kiln` directory. `KILN_PACKAGE_DIR` is an instaand staging verifies they keep the canonical binary. Staging writes are immutable: changedbytes need a new release ID in `holodeck-spec.mjs`. Nothing here uploads anything.+### Add a new committed example++For a new scene, keep the published selection as the baseline instead of reselecting+older worlds. First add its real pack metadata, exact asset count and per-asset+presentation to `holodeck-spec.mjs`, choose a new `HOLODECK_RELEASE`, and add its+scene URL to `src/data/holodeck-worlds.json`. Do this only after the example and its+final assets exist. A selection does not approve an asset or publish its gallery page.++From `site/`, append the committed example with its saved Kiln store:++```sh+node scripts/select-holodeck.mjs --append-example winter-mountainside-cabin \+ --holodeck HOLODECK_REPO --ref EXAMPLE_COMMIT \+ --selection PREVIOUS_SELECTION_JSON --store winter-mountainside-cabin=STORE \+ --out ../packs/holodeck/selection.json+```++The input selection can be the current `selection.json` when the output replaces it;+the command reads and validates everything before writing. Keep a copy of that+baseline if preparing more than one candidate. The append mode reads the example+and GLBs from the requested Git commit, verifies each new saved source/manifests/GLB+and material-closure seal, and preserves earlier packs and source identities.+Shared assets must have the exact revision and canonical bytes already selected.+Their existing source need not be present locally just to append a scene. A changed+shared revision is refused: use a separately reviewed full selection update for it.+Winter assets receive `winter-` gallery slugs; existing Cove modules keep their+shared `cove-` slugs. The new pack cannot replace a previously selected pack.++Continue with staging, real rig posters and the publication checks above. The staging+command still requires every store named by the full selection, including the older+packs; append only avoids reselecting their scene inputs. Preserve the existing+revision approval records, and record any new asset review separately and honestly.+## PublishAfter release approval, upload the listed objects to the asset host, then build and deploydiff --git a/site/scripts/holodeck-spec.mjs b/site/scripts/holodeck-spec.mjsindex 2115bc14..8a60d9d2 100644--- a/site/scripts/holodeck-spec.mjs+++ b/site/scripts/holodeck-spec.mjs@@ -261,5 +261,6 @@ export function holodeckSlug(pack, worldAssetId) {const cove = Object.hasOwn(coveModules, worldAssetId);if (pack === 'holodeck-cove' && !cove) throw new Error(`Unknown Cove module ${worldAssetId}`);if (cove) return `cove-${worldAssetId}`;+ if (pack === 'holodeck-winter-mountainside-cabin') return `winter-${worldAssetId}`;return pack === 'holodeck-crescent-cove' ? `crescent-${worldAssetId}` : worldAssetId;}diff --git a/site/scripts/select-holodeck-example.test.ts b/site/scripts/select-holodeck-example.test.tsnew file mode 100644index 00000000..3b22fa06--- /dev/null+++ b/site/scripts/select-holodeck-example.test.ts@@ -0,0 +1,117 @@+import { afterEach, expect, test } from 'bun:test';+import { execFileSync } from 'node:child_process';+import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { appendHolodeckExample } from './select-holodeck.mjs';+import { hashBytes } from './mirror-core.mjs';+import { holodeckSlug } from './holodeck-spec.mjs';++const roots: string[] = [];+afterEach(async () => { await Promise.all(roots.splice(0).map(root => rm(root, { recursive: true, force: true }))); });+const seal = (bytes: Buffer) => ({ bytes: bytes.length, sha256: hashBytes(bytes) });++async function fixture() {+ const root = await mkdtemp(join(tmpdir(), 'holodeck-selection-test-')); roots.push(root);+ const holodeck = join(root, 'holodeck'), store = join(root, 'store');+ const example = 'winter-mountainside-cabin', packId = `holodeck-${example}`;+ const exampleDir = join(holodeck, 'examples', example);+ await mkdir(join(exampleDir, 'world'), { recursive: true });+ await mkdir(join(exampleDir, 'assets/imports'), { recursive: true });+ const git = (...args: string[]) => execFileSync('git', ['-C', holodeck, ...args], { encoding: 'utf8' }).trim();+ git('init', '--quiet');+ const shared = Buffer.from('fixture shared canonical GLB'), cabin = Buffer.from('fixture new canonical GLB');+ const source = Buffer.from('// synthetic test source'), material = Buffer.from('{"fixture":true}');+ const sharedId = 'a_' + '1'.repeat(32), sharedRevision = 'r_' + '1'.repeat(32);+ const assetId = 'a_' + '2'.repeat(32), revisionId = 'r_' + '2'.repeat(32);+ const files = { 'asset.glb': seal(cabin), 'source.kiln.js': seal(source) };+ const manifest = Buffer.from(JSON.stringify({ assetId, revisionId, editable: true, files, build: { dependencies: [{ kind: 'kiln.material.v2' }] } }));+ const revisionDir = join(store, assetId, 'revisions', revisionId);+ await mkdir(revisionDir, { recursive: true });+ await Promise.all(Object.entries({ 'manifest.json': manifest, 'asset.glb': cabin, 'source.kiln.js': source, 'materials.kiln.json': material }).map(([name, bytes]) => writeFile(join(revisionDir, name), bytes)));+ const assets = [+ { id: 'structure', file: 'assets/imports/shared.glb', provenance: { collection: 'project', assetId: sharedId, revisionId: sharedRevision } },+ { id: 'cabin-shell', file: 'assets/imports/cabin.glb', provenance: { collection: 'project', assetId, revisionId } },+ ];+ await writeFile(join(exampleDir, 'world/world.json'), JSON.stringify({ revision: 0, scene: { assets } }));+ await writeFile(join(exampleDir, 'example.json'), JSON.stringify({ id: example, sourceRevision: 17 }));+ await writeFile(join(exampleDir, assets[0].file), shared);+ await writeFile(join(exampleDir, assets[1].file), cabin);+ git('add', '.'); git('-c', 'user.name=Fixture', '-c', '[email protected]', 'commit', '--quiet', '-m', 'Fixture example');+ const ref = git('rev-parse', 'HEAD');+ const selection = {+ schemaVersion: 1, release: 'holodeck-old', licence: 'CC0-1.0', versions: 'final-only',+ packs: { 'holodeck-cove': { scene: 'cove', source: { commit: 'old-pinned-commit' }, assets: ['cove-structure'] } },+ assets: { 'cove-structure': { store: 'unavailable-old-store', collection: 'project', assetId: sharedId, revisionId: sharedRevision, canonical: seal(shared), manifest: seal(Buffer.from('old-manifest')), source: seal(Buffer.from('old-source')), preview: null, placements: [{ pack: 'holodeck-cove', id: 'structure' }] } },+ };+ const options = {+ selection, holodeck, ref, example, stores: { winter: store }, release: 'holodeck-new',+ packs: [{ id: packId, scene: example, expectedAssets: 2 }],+ presentations: { 'cove-structure': { name: 'Shared' }, 'winter-cabin-shell': { name: 'Cabin' } },+ };+ return { options, selection, git, exampleDir, revisionDir, material, manifest, packId };+}++test('append reads the committed example, preserves prior packs and sources, and seals new editable material dependencies', async () => {+ const f = await fixture(), before = structuredClone(f.selection);+ // The working file is deliberately changed: selection must read the requested commit.+ await writeFile(join(f.exampleDir, 'world/world.json'), '{}');+ const result = await appendHolodeckExample(f.options);+ expect(f.selection).toEqual(before);+ expect(result.release).toBe('holodeck-new');+ expect(result.packs['holodeck-cove']).toEqual(before.packs['holodeck-cove']);+ expect(result.assets['cove-structure']).toEqual({ ...before.assets['cove-structure'], placements: [...before.assets['cove-structure'].placements, { pack: f.packId, id: 'structure' }] });+ expect(result.packs[f.packId]).toMatchObject({ scene: f.options.example, source: { kind: 'holodeck-example', commit: f.options.ref, sourceRevision: 17 }, assets: ['cove-structure', 'winter-cabin-shell'] });+ expect(result.assets['winter-cabin-shell']).toMatchObject({ store: 'winter', collection: 'project', manifest: seal(f.manifest), materials: seal(f.material), placements: [{ pack: f.packId, id: 'cabin-shell' }] });+ expect(await appendHolodeckExample(f.options)).toEqual(result);+});++test('append requires a new release, a configured pack, and an exact inventory', async () => {+ const { options } = await fixture();+ await expect(appendHolodeckExample({ ...options, release: options.selection.release })).rejects.toThrow('new release');+ await expect(appendHolodeckExample({ ...options, packs: [] })).rejects.toThrow('configured pack');+ await expect(appendHolodeckExample({ ...options, packs: [{ ...options.packs[0], expectedAssets: 3 }] })).rejects.toThrow('expected 3');+ await expect(appendHolodeckExample({ ...options, presentations: {} })).rejects.toThrow('gallery presentation');+});++test('append refuses replacement of existing packs and conflicting shared identities', async () => {+ const { options, selection, packId } = await fixture();+ await expect(appendHolodeckExample({ ...options, selection: { ...selection, packs: { ...selection.packs, [packId]: {} } } })).rejects.toThrow('already selected');+ const changed = structuredClone(selection); changed.assets['cove-structure'].revisionId = 'r_' + '9'.repeat(32);+ await expect(appendHolodeckExample({ ...options, selection: changed })).rejects.toThrow('shared revision');+ const changedHash = structuredClone(selection); changedHash.assets['cove-structure'].canonical.sha256 = '0'.repeat(64);+ await expect(appendHolodeckExample({ ...options, selection: changedHash })).rejects.toThrow('canonical');+});++test('append rejects a changed shared revision even when the example renames the asset', async () => {+ const { options, selection } = await fixture();+ const previousPack = 'holodeck-earlier-cabin';+ const previous = {+ ...selection,+ packs: { ...selection.packs, [previousPack]: { scene: 'earlier-cabin', source: { commit: 'old-pinned-commit' }, assets: ['earlier-cabin-shell'] } },+ assets: {+ ...selection.assets,+ 'earlier-cabin-shell': {+ ...selection.assets['cove-structure'],+ assetId: 'a_' + '2'.repeat(32), revisionId: 'r_' + '3'.repeat(32),+ placements: [{ pack: previousPack, id: 'old-cabin-shell' }],+ },+ },+ };+ const before = structuredClone(previous);+ await expect(appendHolodeckExample({ ...options, selection: previous })).rejects.toThrow('shared revision');+ expect(previous).toEqual(before);+});++test('append rejects changed saved source before producing any selection', async () => {+ const { options, revisionDir } = await fixture();+ await writeFile(join(revisionDir, 'source.kiln.js'), '// modified');+ await expect(appendHolodeckExample(options)).rejects.toThrow();+ expect(JSON.parse(await readFile(join(revisionDir, 'manifest.json'), 'utf8')).assetId).toBe('a_' + '2'.repeat(32));+});++test('winter gallery slugs share only the established Cove modules', () => {+ expect(holodeckSlug('holodeck-winter-mountainside-cabin', 'structure')).toBe('cove-structure');+ expect(holodeckSlug('holodeck-winter-mountainside-cabin', 'cabin-shell')).toBe('winter-cabin-shell');+ expect(holodeckSlug('holodeck-crescent-cove', 'shelter')).toBe('crescent-shelter');+});diff --git a/site/scripts/select-holodeck.mjs b/site/scripts/select-holodeck.mjsindex 15777f91..2819a982 100644--- a/site/scripts/select-holodeck.mjs+++ b/site/scripts/select-holodeck.mjs@@ -133,16 +133,75 @@ export async function selectHolodeck({ courtyard, holodeck, ref, crescentRef, streturn { schemaVersion: 1, release: HOLODECK_RELEASE, licence: 'CC0-1.0', versions: 'final-only', packs: ordered, assets };}+/**+ * Append one committed example to a frozen selection without reopening or reselecting older scenes.+ * Existing shared assets must be the exact selected revision; changing them requires the full selection workflow.+ * Only new assets need a local saved-revision store. This freezes inputs, never records visual approval or stages files.+ */+export async function appendHolodeckExample({ selection, holodeck, ref, example, stores, release = HOLODECK_RELEASE, packs = HOLODECK_PACKS, presentations = HOLODECK_ASSETS }) {+ if (!selection || selection.schemaVersion !== 1 || selection.licence !== 'CC0-1.0' || selection.versions !== 'final-only' || !selection.packs || !selection.assets) throw new Error('A frozen Holodeck selection is required');+ if (!/^holodeck-[a-z0-9-]+$/.test(release ?? '') || release === selection.release) throw new Error('Appending a pack requires a new release ID');+ if (!holodeck || !ref || !/^[a-z][a-z0-9-]{0,63}$/.test(example ?? '') || !stores || !Object.keys(stores).length) throw new Error('An explicit Holodeck repository, ref, example and stores are required');+ const spec = packs.find(pack => pack.scene === example && pack.id === `holodeck-${example}`);+ if (!spec || !Number.isSafeInteger(spec.expectedAssets) || spec.expectedAssets < 1) throw new Error(`No configured pack with an exact asset count for ${example}`);+ if (Object.hasOwn(selection.packs, spec.id)) throw new Error(`${spec.id} is already selected; append never replaces a pack`);+ const git = (...args) => execFileSync('git', ['-C', holodeck, ...args], { maxBuffer: 256 * 1024 * 1024 });+ const commit = git('rev-parse', '--verify', '--end-of-options', `${ref}^{commit}`).toString('utf8').trim();+ const path = `examples/${example}`, show = file => git('show', `${commit}:${path}/${file}`);+ const worldBytes = show('world/world.json'), world = json(worldBytes), manifest = json(show('example.json'));+ if (manifest.id !== example || !Number.isSafeInteger(manifest.sourceRevision) || manifest.sourceRevision < 0) throw new Error(`${example}: invalid example identity or source revision`);+ const list = world.scene?.assets;+ if (!Array.isArray(list) || list.length !== spec.expectedAssets) throw new Error(`${spec.id}: expected ${spec.expectedAssets} placed assets, found ${list?.length ?? 'none'}`);+ const result = structuredClone(selection), slugs = [], identities = new Map(), revisions = new Map();+ for (const [slug, record] of Object.entries(result.assets)) {+ const assetIdentity = `${record.collection}/${record.assetId}`;+ if (revisions.has(assetIdentity) && revisions.get(assetIdentity) !== record.revisionId) throw new Error(`${assetIdentity} has multiple selected revisions`);+ revisions.set(assetIdentity, record.revisionId);+ const identity = `${record.collection}/${record.assetId}/${record.revisionId}`;+ if (identities.has(identity)) throw new Error(`${identity} has two slugs in the frozen selection`);+ identities.set(identity, slug);+ }+ for (const asset of list) {+ const { collection, assetId, revisionId } = asset.provenance ?? {};+ if (collection !== 'project' || !/^a_[a-f0-9]{32}$/.test(assetId ?? '') || !/^r_[a-f0-9]{32}$/.test(revisionId ?? '')) throw new Error(`${spec.id}/${asset.id}: invalid provenance`);+ if (!/^assets\/imports\/[a-zA-Z0-9_-]+\.glb$/.test(asset.file ?? '')) throw new Error(`${spec.id}/${asset.id}: unsafe example GLB path`);+ const slug = holodeckSlug(spec.id, asset.id);+ if (!Object.hasOwn(presentations, slug)) throw new Error(`No gallery presentation for ${slug}`);+ if (slugs.includes(slug)) throw new Error(`${spec.id}: duplicate slug ${slug}`);+ const assetIdentity = `${collection}/${assetId}`, identity = `${assetIdentity}/${revisionId}`, existing = result.assets[slug];+ if (revisions.has(assetIdentity) && revisions.get(assetIdentity) !== revisionId) throw new Error(`${assetIdentity}: shared revision differs; append cannot replace an existing selection`);+ if (existing && (existing.collection !== collection || existing.assetId !== assetId || existing.revisionId !== revisionId)) throw new Error(`${slug}: shared revision differs; append cannot replace an existing selection`);+ if (identities.has(identity) && identities.get(identity) !== slug) throw new Error(`${identity} has two slugs`);+ const record = existing ?? await revisionRecord(stores, assetId, revisionId);+ verifyBytes(show(asset.file), record.canonical, `${spec.id}/${asset.id} canonical GLB`);+ record.placements = [...(record.placements ?? []), { pack: spec.id, id: asset.id }];+ result.assets[slug] = record;+ identities.set(identity, slug);+ revisions.set(assetIdentity, revisionId);+ slugs.push(slug);+ }+ result.release = release;+ result.packs[spec.id] = {+ scene: spec.scene,+ source: { kind: 'holodeck-example', ref, commit, path, sourceRevision: manifest.sourceRevision, worldSha256: hashBytes(worldBytes) },+ assets: slugs,+ };+ return result;+}+if (process.argv[1] && pathToFileURL(resolve(process.argv[1])).href === import.meta.url) {const args = process.argv.slice(2), options = { stores: {} };for (let i = 0; i < args.length; i += 2) {const [flag, value] = [args[i], args[i + 1]];if (!value || value.startsWith('--')) throw new Error(`Missing value for ${flag}`);if (flag === '--store') { const [name, dir] = value.split(/=(.*)/s); options.stores[name] = await realpath(dir); }- else if (['--courtyard', '--holodeck', '--ref', '--crescent-ref', '--out'].includes(flag)) options[flag.slice(2).replace(/-([a-z])/g, (_, c) => c.toUpperCase())] = value;+ else if (['--courtyard', '--holodeck', '--ref', '--crescent-ref', '--out', '--append-example', '--selection'].includes(flag)) options[flag.slice(2).replace(/-([a-z])/g, (_, c) => c.toUpperCase())] = value;else throw new Error(`Unknown option ${flag}`);}- const selection = await selectHolodeck(options);+ if (options.selection && !options.appendExample) throw new Error('--selection requires --append-example');+ const selection = options.appendExample+ ? await appendHolodeckExample({ ...options, example: options.appendExample, selection: json(await readFile(resolve(options.selection ?? resolve(import.meta.dirname, '../../packs/holodeck/selection.json')))) })+ : await selectHolodeck(options);const out = resolve(options.out ?? resolve(import.meta.dirname, '../../packs/holodeck/selection.json'));await writeFile(out, JSON.stringify(selection, null, 2) + '\n');console.log(JSON.stringify({ out, packs: Object.fromEntries(Object.entries(selection.packs).map(([id, pack]) => [id, pack.assets.length])), uniqueRevisions: Object.keys(selection.assets).length }, null, 2));diff --git a/src/__tests__/mcp-cancellation.test.ts b/src/__tests__/mcp-cancellation.test.tsindex c4492b18..b951a428 100644--- a/src/__tests__/mcp-cancellation.test.ts+++ b/src/__tests__/mcp-cancellation.test.ts@@ -36,7 +36,10 @@ childProcess.spawn = (...args) => {};syncBuiltinESMExports();-const local = createLocalToolContext({}, { KILN_EVALUATOR_TIMEOUT_MS: '1200' });+let evaluationDeadlineMs = 1200;+const local = createLocalToolContext({+ evaluationControls: () => ({ deadlineMs: evaluationDeadlineMs })+}, { KILN_EVALUATOR_TIMEOUT_MS: '1200' });const evaluator = local.evaluatorPort;let completed;const outcome = new Promise(resolve => { completed = resolve; });@@ -64,6 +67,9 @@ try {assert.deepEqual(await closed, { code: null, signal: 'SIGKILL' });assert.throws(() => process.kill(pid, 0), { code: 'ESRCH' });+ // A cold valid request took 1.64 s on Linux. Keep the cancellation deadline+ // unchanged, then allow startup/export headroom for recovery on the same port.+ evaluationDeadlineMs = 8000;const valid = await client.callTool({name: 'kiln_render',arguments: {