core: repair null parent links so stored scenes pass authority validation - #574
Merged
Conversation
…alidation Stored scenes could link site → building → level through children arrays while building/level carried parentId null: loadScene never wrote parent ids and the legacy embedded-site-child flatten kept the already-flat node's null parentId. The editor traverses children and renders these scenes, but the hosted scene authority validates parent/child symmetry and rejected every snapshot into a fatal read-only session. healSceneNodes now repairs a null parent link when exactly one parent claims the node (embedded legacy site children claim by id), loadScene writes explicit parent links, and both migrations are exported server-safe through @pascal-app/core/scene-migrations so the hosted authority can apply the same normalization before validating. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Repairs the stored-scene corruption behind the hosted "Live collaboration is unavailable for this project. Editing is paused to protect the scene." incident (Sentry MONOREPO-EDITOR-JR/JQ/GF): scenes whose
childrenarrays link site → building → level whilebuilding/levelcarryparentId: null. The editor renders these scenes by traversingchildren, but the hosted scene authority validates parent/child symmetry and rejected every snapshot, locking sessions read-only and silently discarding tool placements (ghost + SFX with no commit).healSceneNodesgains a repair pass: a node with a nullparentIdthat exactly one parent claims viachildrenpoints back at that parent. Embedded legacy site children claim byid, so the flattened flat-map node is repaired too. Ambiguous multi-claim nodes are left alone.loadScenewrites explicit parent links for the default Site → Building → Level hierarchy (it previously relied on the schema'sparentId: nulldefault — one of the two writers of the corrupt shape; the other was the legacy embedded-site-child flatten, which pass 3 now covers on load).@pascal-app/core/scene-migrationsbarrel exportshealSceneNodesalongsideremoveRetiredDrawingSheetNodes, keeping the entry server-safe so the hosted authority can apply the identical normalization before validating.How to test
bun test packages/core/src/utils/heal-scene-graph.test.ts— new cases cover the null-parent chain repair, embedded legacy site-child claims, ambiguous multi-claim nodes, and untouched dangling parents.bun test packages/core/src/store/use-scene-load-scene.test.ts— the default scene now carries symmetric parent links.bun test packages/core/src— full core suite (930 tests).building/levelatparentId: nullthroughnormalizeAuthoritySceneGraph(companion private-editor change) and confirmapiGraphSchemaaccepts it.Screenshots / screen recording
N/A — non-visual data-repair change.
Checklist
bun devbun checkto verify)mainbranchNote
Medium Risk
Changes scene graph normalization used on load and by the hosted authority; incorrect repair logic could alter hierarchy, though guards limit repairs to unambiguous single-claim cases.
Overview
Fixes stored scenes where
childrenlinks site → building → level butparentIdstays null on building/level, which blocked hosted scene authority validation and paused live collaboration.healSceneNodesadds a third pass: if a node hasparentId: nulland exactly one parent lists it inchildren(including embedded legacy site children), it setsparentIdto that parent; ambiguous multi-parent claims are unchanged.loadScenenow sets explicitparentIdon the default Site → Building → Level graph instead of relying on schema defaults, so new default scenes save with symmetric parent/child links.The
@pascal-app/core/scene-migrationsexport is pointed at a new server-safe barrel that re-exportshealSceneNodesandremoveRetiredDrawingSheetNodesfor shared client/authority normalization.Reviewed by Cursor Bugbot for commit 7c4d170. Bugbot is set up for automated code reviews on this repo. Configure here.