Pascal Editor
Pascal graph repair: preserve useful walls, remove stale links, infer only one parent
Read and execute the pure scene-healing helper, then distinguish conservative repair from full validation, migration and rendering.
What you will learn
- Three passes with deliberately different decisions
- Repair an unambiguous back-link, not an arbitrary owner
- Connect the helper to validation without merging their meanings
Before you start
- Basic scene-graph, JavaScript and HTTP concepts
- An owned small scene with expected dimensions and relationships
Explain the implementation boundary and reproduce the chapter’s checklist or narrow graph exercise.
Key takeaways
- A zero-length host with children is deliberately retained.
- Unique parent evidence can repair a link; ambiguity cannot.
- Pure healing is only one layer of import acceptance.
Three passes with deliberately different decisions
healSceneNodes repairs a copied node map. Its first pass removes only childless walls whose endpoint distance is at most 1e-6. A degenerate wall that still hosts a door or window is retained, because dropping it would discard a meaningful relationship. The decision is made before child-list cleanup, so it should not be described as an iterative geometry optimizer.
The second pass removes non-string child references, references to walls just dropped, duplicate IDs and links whose child explicitly belongs to another parent. Legacy site nodes may contain embedded child objects; the helper preserves those for later migration instead of flattening or deleting them here. Different corruption types therefore need different preservation policies.
Repair an unambiguous back-link, not an arbitrary owner
The third pass collects parent claims for each surviving child. It fills a null parentId only when exactly one non-self parent claims the node. Two competing claimants remain unresolved. This is conservative inference from structural evidence, not a global proof that the graph is valid, acyclic or suitable for every downstream building operation.
The helper returns repair counts and IDs alongside the resulting map. Unchanged nodes retain reference identity, while repaired nodes receive copies. We verified that the original input JSON stayed unchanged, a childless zero wall was removed, invalid and stale references were counted, a unique parent was repaired and an ambiguous parent was left alone.
Connect the helper to validation without merging their meanings
validateBuildJson consumes the healed nodes, distinguishes hard errors from warnings and validates known or registered-plugin schemas. Unknown plugin kinds can remain in the parsed graph with warnings rather than making a parent’s static child-ID schema reject them. Materials are normalized entry by entry; invalid entries are skipped with a warning. A successful structural check is not building-code compliance or a visual review.
The standalone probe executes the inspected dependency-free TypeScript using Node type stripping after verifying source hashes. It does not run the full validator, scene-store migrations or GPU. The JavaScript below independently illustrates only the unique-parent rule; its intentionally narrow scope makes the ambiguous and self-parent cases easy to reproduce without installing Pascal.
Implementation steps
- 1
Read all three repair passes in the fixed source.
- 2
Test empty walls separately from walls hosting an opening.
- 3
Compare unique, ambiguous and self-parent claims.
- 4
Review warnings and rendering after structural repair.
Copy-ready example
// Independent model of one repair rule, not the full graph healer.
function inferredParent(nodeId, claims) {
return claims.length === 1 && claims[0] !== nodeId ? claims[0] : null;
}
console.log([inferredParent("wall", ["level"]), inferredParent("wall", ["a", "b"]), inferredParent("wall", ["wall"])]);Frequently asked questions
Does healing delete every zero-length wall?
No. The inspected first pass retains a wall that still has children, including a hosted opening.
Does a repaired graph prove a safe building design?
No. Structural repair, schema validation, rendering and professional design review are different activities.
Sources
- README.mdSource checked 2026-09-08
- LICENSESource checked 2026-09-08
- packages/cli/package.jsonSource checked 2026-09-08
- packages/core/package.jsonSource checked 2026-09-08
- packages/viewer/README.mdSource checked 2026-09-08
- packages/cli/src/runtime.tsSource checked 2026-09-08
- packages/cli/src/editor-process.tsSource checked 2026-09-08
- packages/cli/src/mcp-connector.tsSource checked 2026-09-08
- packages/mcp/src/transports/http.tsSource checked 2026-09-08
- packages/mcp/src/storage/sqlite-scene-store.tsSource checked 2026-09-08
- packages/core/src/store/use-scene.tsSource checked 2026-09-08
- packages/viewer/src/components/renderers/node-renderer.tsxSource checked 2026-09-08
- packages/viewer/src/lib/renderer-capability.tsSource checked 2026-09-08
- packages/core/src/validation/validate-build-json.tsSource checked 2026-09-08
- packages/core/src/utils/heal-scene-graph.tsSource checked 2026-09-08
- packages/mcp/src/storage/slug.tsSource checked 2026-09-08