fix(mcp): apply_patch preserves schema-defaulted ids in multi-op batches

SceneBridge.applyPatch now threads the Zod-parsed node through to the
apply phase instead of the raw input. Previously, when a caller sent a
create patch without an `id` field, the schema's objectId default ran
during dry-run parsing but only in `res.data`; the apply phase pushed
the unparsed `p.node` (no id) to the store, so subsequent tools that
walked `level.children` crashed on undefined entries (e.g.
duplicate_level -> cloneLevelSubtree -> extractIdPrefix(undefined)).

Also adds test-reports/ artefacts from live end-to-end testing:
- t1-stdio: 21/21 tools pass via stdio (~106ms)
- t2-http: connect/single-session behaviour (HTTP transport quirk
  documented)
- t3-scenario: 2-bedroom apartment built end-to-end — 12/12 steps
  after this fix (24 final nodes, validate=true, apartment.json
  exported)
- t4-errors: 24/24 invalid-input cases rejected with proper MCP errors
- t5-resources-prompts: 4/4 resources, 3/3 prompts, dev server
  /api/health 200 OK

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Adrian Perez
2026-04-18 18:21:00 +02:00
co-authored by Claude Opus 4.7
parent a6f1c4140f
commit b37e88cb83
19 changed files with 5884 additions and 4 deletions
@@ -0,0 +1,18 @@
[t3] attempting HTTP transport at http://localhost:3917/mcp
[t3] HTTP transport connected
[t3] using transport: http — shared HTTP server
[t3] OK step 1 discover (4ms): building=building_bfqg91ai9ijps9ej, level=level_wyuoxj87czq3v0re (of 1 buildings, 1 levels)
[t3] using buildingId=building_bfqg91ai9ijps9ej levelId=level_wyuoxj87czq3v0re
[t3] OK step 2 perimeter walls (2ms): created 4 perimeter walls (result.createdIds=["wall_y87bsrljd2245n51","wall_sja6jpda73tlhxwb","wall_aegff27krjwgmkmi","wall_dcymglyle9ff09ti"])
[t3] OK step 3 interior partitions (1ms): created 7 interior walls
[t3] OK step 4 set zones (3ms): created 4 zones: bedroom-1, bedroom-2, bathroom, living-kitchen
[t3] OK step 5 cut openings (6ms): 3 doors, 3 windows
[t3] post-step-5 total node count: 24
[t3] OK step 6 validate scene (1ms): valid=true, errors=0
[t3] OK step 7 measure furthest zones (3ms): furthest: zone_3fyksm10tb0dhn1e <-> zone_u95l1bt35jci3gvu = 7.000m
[t3] OK step 8 export json (1ms): exported 15392 bytes -> apartment.json
[t3] OK step 9 undo 3 steps (2ms): undone=3, nodes 24 -> 21 (delta=3)
[t3] OK step 10 redo 3 steps (2ms): redone=3, nodes 21 -> 24
[t3] OK step 11 duplicate level + validate (2ms): newLevelId=level_cxvltlqvgqcasiep, cloned=22, valid=true, errors=0
[t3] OK step 12 delete duplicated level (3ms): deleted 22 nodes; nodes 46 -> 24
[t3] done