Skip to content

fix(mcp): templates use string IDs for SiteNode.children#326

Merged
wass08 merged 1 commit into
pascalorg:mainfrom
jelharou:fix/mcp-templates-site-children-string-ids
May 21, 2026
Merged

fix(mcp): templates use string IDs for SiteNode.children#326
wass08 merged 1 commit into
pascalorg:mainfrom
jelharou:fix/mcp-templates-site-children-string-ids

Conversation

@jelharou
Copy link
Copy Markdown
Contributor

@jelharou jelharou commented May 21, 2026

What does this PR do?

Follow-up to #325. PR #320 changed SiteNode.children from embedded BuildingNode | ItemNode objects to flat string[] IDs. #325 updated the runtime call sites (rehydrate-site-children.ts, generate-variants.ts, nodes/site/renderer.tsx) but missed the three scene templates in packages/mcp/src/templates/, which still mutated the site node's children array to embed full building objects after building the flat dict.

This caused AnyNode.safeParse to fail for site_empty, site_2br, and site_garden when running bun test --cwd packages/mcp (part of .github/workflows/mcp-ci.yml):

✗ scene templates > empty-studio template nodes all pass AnyNode.safeParse
✗ scene templates > two-bedroom template nodes all pass AnyNode.safeParse
✗ scene templates > garden-house template nodes all pass AnyNode.safeParse

error: ... failed AnyNode.safeParse at children.0: Invalid input: expected string, received object

Each template already initialises site.children with the correct string id (e.g. ['building_empty']); the obsolete mutation blocks just need to be removed.

How to test

  1. bun test --cwd packages/mcp — confirm all 281 tests pass (previously 3 failing).
  2. Open the editor, load any of the three templates (empty-studio, two-bedroom, garden-house) — confirm the scene loads and the site/building/level hierarchy renders correctly.

Screenshots / screen recording

N/A — non-visual fix (schema alignment in template data).

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

PR pascalorg#320 changed SiteNode.children from embedded BuildingNode/ItemNode
objects to flat string[] IDs. PR pascalorg#325 updated the runtime call sites
but missed the three scene templates, which still mutated the site
node's children array to embed full building objects after building
the flat dict. This caused AnyNode.safeParse to fail for site_empty,
site_2br, and site_garden in bun test --cwd packages/mcp.

Remove the obsolete mutation blocks; each template already initialises
site.children with the correct string id (e.g. ['building_empty']).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
wass08 added a commit that referenced this pull request May 21, 2026
SiteNode.children is z.array(z.string()) (node ids), but the three scene
templates overwrote their inline string-id children with embedded
BuildingNode objects — leftover from the pre-PR-#325 schema where
children was a union of node objects. Against the current schema that
breaks AnyNode.safeParse in templates.test.ts.

Drop the stale post-build mutations; each site already declares the
correct string-id children inline. (Same fix as the in-flight PR #326;
carried here so this branch's CI is green when merged with current main.)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wass08 wass08 merged commit 8505d6c into pascalorg:main May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants