Skip to content

mcp: cover exported bridge plugin-node boundaries - #44

Draft
kvnloo wants to merge 8 commits into
mainfrom
nc/pe38-1225-exported-regression
Draft

kvnloo wants to merge 8 commits into
mainfrom
nc/pe38-1225-exported-regression

Conversation

@kvnloo

@kvnloo kvnloo commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Problem

Upstream pascalorg/editor#1225 makes MCP patch creation and scene validation accept registered plugin schemas. PE37 found the missing package-export regression; PE38 covered built-in, registered and unregistered kinds. PE39 characterizes the registered vs installed-in-this-scene contract: hidden plugin nodes retain their data and MCP listing, even when registration later becomes unavailable. PE40 checks two detached scene runtimes and real MCP clients against this contract, including disposal of one runtime. PE42 pins nested plugin nodes when their parent subtree is unrooted, moved to another building, or cascade-deleted, with a saved-scene reload lacking plugin registration.

Design

  • E-001/E-018: headless MCP uses the same core scene runtime; two detached stores own independent nodes, history and disposal, while the definition registry is deliberately shared per wiki/architecture/scene-runtime.md:17. No viewer dependency added to MCP.
  • E-002/E-003: registry-based schema dispatch, persistent scene nodes and install state; unknown kinds do not become valid merely because they remain saved.
  • E-010/E-016: installation is the viewer/host gate; registering a schema does not grant plugin-specific agent-tool authority. get_scene remains a truthful view of saved nodes, including hidden ones.
  • PE42 / E-003 / E-018: installation remains document-scoped, not inherited from a building or level. A reparented, reachable plugin descendant retains its saved data; an unrooted or deleted ancestor removes the whole subtree. A later session lacking the plugin definition flags only surviving plugin nodes; E-018's shared global definition registry is not changed.
  • T-001: PE39 uses public @pascal-app/core, @pascal-app/core/schema, @pascal-app/mcp/bridge, and @pascal-app/mcp/tools/get-scene exports. PE40 imports SceneBridge and createPascalMcpServer from the published @pascal-app/mcp entrypoint and exercises two real in-memory MCP clients. No new sleeps, source-grep or test stubs.

Change

PE44 exact-main ancestry diff audit

Base: fork main 352ec93c; parent: 4333e588; child/head: 3d679d5c. Original comparison: 12 files, with the last eight inherited from the unrelated viewer perf/batching ancestor. Final comparison: 4 MCP paths, all preserved. The eight viewer restorations were atomic in one child commit, without rebase or force-push.

File (relative to repo) Scope for pascalorg#1225 Introducing commit(s) PE44 action
packages/mcp/src/bridge/scene-bridge.ts In scope: registered-node parser and validation 3e771908, 983766a8 Preserved
packages/mcp/src/bridge/scene-bridge.test.ts In scope: exported MCP bridge regressions 3e771908, 983766a8, 3a58e690 Preserved
packages/mcp/src/tools/get-scene.test.ts In scope: wire-visible install, reload semantics 0d25bbe3 Preserved
packages/mcp/src/bridge/detached-bridge.test.ts In scope: detached isolation and ancestry a8c841b0, 4333e588 Preserved
packages/viewer/src/components/viewer/glb-scene.tsx Inherited: baked GLB batching 0602f9e4 Restored main blob
packages/viewer/src/components/viewer/glb-walkthrough-controller.tsx Inherited: batching raycast layer 0602f9e4 Restored main blob
packages/viewer/src/components/viewer/lights.tsx Inherited: cached sun shadows 0602f9e4 Restored main blob
packages/viewer/src/lib/daylight/room-context.ts Inherited: lighting mask 0602f9e4 Restored main blob
packages/viewer/src/lib/daylight/rooms.ts Inherited: lit-only room loop 0602f9e4 Restored main blob
packages/viewer/src/lib/glb-merge.test.ts Inherited: GLB merge tests 0602f9e4 Removed (absent on main)
packages/viewer/src/lib/glb-merge.ts Inherited: GLB merge code 0602f9e4 Removed (absent on main)
packages/viewer/src/lib/merged-outline-node.ts Inherited: merge outline layers 0602f9e4 Restored main blob

PE44's eight restored paths were read back: six blob IDs exactly match main; the two added files are absent. The final main comparison changes only the four MCP paths. This respects E-001, E-002, E-003, E-010, E-016, E-018, and T-001 by leaving all MCP behavior and tests unchanged.

Tests

ALL UNRUN by the workers, including after PE44; no Bun, Biome, typecheck or browser execution receipt. PE44 adds 0 tests and does not edit any existing test. PE42 adds three Bun cases to the existing detached-bridge suite and uses the registry's test-only _snapshot()/_reset() with restoration. No test.todo: source inspection found no confirmed contract failure, but no case has been executed. Exact commands from the monorepo root after bun install --frozen-lockfile:

bun --cwd packages/core run build
bun --cwd packages/mcp run build
bun test packages/mcp/src/bridge/scene-bridge.test.ts packages/mcp/src/tools/get-scene.test.ts packages/mcp/src/bridge/detached-bridge.test.ts
bun x biome check packages/mcp/src/bridge/scene-bridge.test.ts packages/mcp/src/tools/get-scene.test.ts packages/mcp/src/bridge/detached-bridge.test.ts
bun run check
bun run ci

Exact PE42 focused command (UNRUN): bun test packages/mcp/src/bridge/detached-bridge.test.ts. Biome/typecheck/full CI are also UNRUN.

Worked expected outcomes, not executed:

Case Fork main 352ec93 PR head 3d679d5c
Built-in wall create Accepted Accepted
Registered plugin create with value 7 Schema rejects unknown kind Creates and validates; plugin diagnostics retain Zod value path
Registered, explicitly uninstalled fixture:get-scene-node with value 7 Registered-plugin create rejects (PE39 test red at first create) Create/validation succeed, isNodeKindEnabled=false, both JSON and get_scene preserve node and explicit installedPlugins=[]
Installed plugin node with value 11, then registry absent on reload Registered-plugin create rejects (PE39 test red at first create) Node and installed ID survive JSON reload and MCP listing; schema validation reports the now-unknown kind
Unknown kind never registered Rejects Rejects
Two detached scenes, first with plugin installed, second with explicit empty install list; first MCP client creates a value=7 plugin node No scoped MCP-plugin create support before upstream pascalorg#1225 PE40 expected: first has 2 seed nodes + 1 probe = 3, second remains 2, second client get_scene and listTools identical before/after first create and disposal; live editor unchanged; first bridge reads fail after disposal

PE42 hand-worked before/after matrix (expected, UNRUN): Baseline has 2 buildings, 2 levels, 1 registered plugin child = 5 nodes; the plugin is installed, nested under building_b/level_g, and validates.

Parent subtree change Before After saved-scene reload without plugin definition (nodeRegistry._reset())
Detach building_b from scene roots 5 nodes; installed child valid 2 retained nodes (building_other, level_other); plugin and its ancestors pruned; scene valid; installed ID persists
Reparent level_g from building_b to building_other 5 nodes; plugin under first building; valid 5 nodes; ancestry is plugin → level_g → building_other; installed ID persists; missing plugin schema makes validation invalid for the retained child
Cascade-delete building_b 5 nodes; installed child valid 2 retained nodes; ancestor, level and child removed; scene valid; installed ID persists

After each change, core export and in-memory MCP get_scene must agree on node membership and installed IDs. Missing registration is a test-only later-session simulation; it is not production hot-unregister. The values above are inferred from the source, not test results.

Rendering in PE39 is checked at the public core install-gate level, not by a newly mounted viewer. Existing viewer plugin-dispatch Bun tests exercise actual renderer suppression/activation and late registration; they have not been re-run here. The test-only nodeRegistry._reset() models a later session where code was not loaded; hot-unregister is not a supported production operation.

PE40 test: plugin scene state stays isolated across detached MCP clients and disposal added at the exact parent-to-head diff, UNRUN. PE42 tests (3): detach/unroot, reparent and cascade-delete an ancestor, then reload without plugin registration; each checks node ancestry/count, project installs, get_scene, and node-specific validation. UNRUN. It checks the public install gate (true for first, false for second), saved data, two real MCP clients, unchanged second tool listing, unchanged live editor snapshot, and second registry version after disposal. The plugin definition is intentionally shared globally under E-018; this test does not claim separate per-runtime registration tables or an authorization refusal for a registered-but-uninstalled node (PE39 explicitly preserves that behavior).

CI: no Actions runs or commit statuses reported at exact PE42 head 4333e588c90a08cae17a92a214463e7cbcfcabd6 when inspected: not run.

Upstream readiness

HOLD pending native checks. No fork CI success or local test execution. The unrelated viewer ancestry is now removed from the final PR diff (4 MCP files only), but historical ancestry still contains 0602f9e4 and a future merge would preserve existing main's viewer content because PE44 restores it exactly. Per-runtime definition registry isolation is not an existing E-018 contract: the global nodeRegistry is deliberately shared; only scene data, installed-plugin state and client observations are independent. The generic MCP applyPatch accepting a registered-but-uninstalled kind remains characterized but not a confirmed authorization bug. PE42 is test-only and cannot establish a passing native result without Bun/CI. Plugin-specific tool offering is host policy; do not add an install restriction without a documented requirement. No upstream comments, PRs, reviews or merges were made.

Follow-ups

  1. PE41-1225-NATIVE-CI-RECEIPT: run focused Bun and Biome plus fork CI at the exact head and preserve logs; leave Draft on failure or no run.
  2. PE44-1225-ANCESTRY-DIFF-HYGIENE (complete): eight inherited viewer paths restored/deleted to match main in one child commit; no viewer paths remain in the PR diff.
  3. PE43-1225-REGISTRY-SCOPE-POLICY: only if independent per-runtime definition tables are required, first supersede E-018 and specify a runtime-owned registry contract before proposing a larger refactor; do not confuse shared definitions with scene/MCP isolation.

What does this PR do?

Tests registry-aware MCP create/validation, per-scene installation and durable JSON/MCP scene discovery, plus independent detached scene/MCP client state and safe disposal under a deliberately shared definition registry.

How to test

Build core and MCP, run the three focused Bun files and Biome commands above. Verify the PE39 lifecycle cases against the previous bridge, and the PE40 two-runtime/client regression against the exact parent. All are UNRUN here. Run the complete native quality suite before promotion.

Screenshots / screen recording

N/A — headless MCP regression.

Checklist

  • Native Bun/CI run at exact head
  • Biome and type checks at exact head
  • Inherited viewer ancestry reconciled; only 4 MCP files remain in the PR diff
  • Fork-only Draft PR targeting kvnloo/editor:main

Implemented by ChatGPT (mobile app, GitHub connector) for Kevin's OSS factory.

wass08 and others added 8 commits November 6, 2026 09:23
…rge for baked scenes (pascalorg#1224)

* perf(viewer): cache the daylight sun shadow; light the outside from lit sources only

- The sun's 4096 shadow map re-rendered every frame, a full extra pass over
  every caster. It now renders only when its placement, frustum or settings
  change or a caster moves, appears, vanishes or swaps geometry (a cheap
  per-frame signature over a caster list refreshed with the bounds). Orbiting
  and walking reuse it.
- The outside spill and lantern loops ran over every window and exterior lamp
  for every pixel, day and night. They now loop over compact lists of the
  windows whose room has a lamp on and the exterior lamps that are on (rewritten
  on lamp and door changes), and indoor pixels skip them. Pixel-identical.

Baked GLB walkthrough, M5 Max: 22 → 50 fps (capped) on a 4.3k-draw house,
18 → 32 fps on a 72-window condo at night; daytime GPU on the condo 85 → 40 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* perf(viewer): merge a baked artifact's static meshes (the enhanced viewer's batching)

A big baked house is ~4,000 meshes, each drawn once per pass; on WebGPU every
draw costs CPU to encode, so the overview spent ~60 ms a frame just submitting.
Static meshes now merge per level, ~24 m cell, material and surface role into
one mesh under their level (level visibility, explode and solo still apply);
a moving part's meshes (a sash, a door leaf, a shutter) merge under that part
and swing with it, glass included.

The originals stay on the batched layer: never drawn or shadowed, still hit by
pointer, reticle and room rays and the walkthrough collider, still outlined.
Interactive items, loose glass, ceilings and roofs, the site, zones and plugin
kinds stay individual; batches follow monochrome by role, and the merge
rebuilds if a merged mesh is shown or hidden on its own. ?merge=0 turns it off.

M5 Max, baked GLBs: 72-window condo overview 14 → 42 fps (8.6k → 1.8k draws);
4.3k-mesh house overview 14 → 32 fps. Renders match the unmerged scene (mean
pixel difference ~1/255); the walkthrough collider is identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Cover registry-aware create, render install gate, durable scene JSON,
and the get_scene MCP wire listing under explicit uninstallation and
missing-plugin reload. Keep upstream pascalorg#1225 intact.

PE39-1225-SCENE-INSTALL-SEMANTICS
…ssion branch

Restore the six unrelated viewer files to fork main and remove the two
GLB batching files added by ancestor 0602f9e. Preserve all MCP bridge
production changes and exported-package regression tests unchanged.

PE44-1225-ANCESTRY-DIFF-HYGIENE
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.

3 participants