Repository navigation
fix: prevent cyclic scene hierarchies - #980
Open
Vansh0Sharma wants to merge 1 commit into
Open
Vansh0Sharma wants to merge 1 commit into
Vansh0Sharma wants to merge 1 commit into
Conversation
Contributor
|
I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…). Please try again, rephrase, or reach out if it keeps failing. Error id: 235eccc9-a8c2-434e-9271-1e6a05796267 |
ovurrsl
reviewed
Oct 6, 2026
ovurrsl
left a comment
There was a problem hiding this comment.
Architectural Review: PR #980 (fix: prevent cyclic scene hierarchies)
Layer & Package Boundary Analysis
packages/core(lib/hierarchy.ts,store/actions/node-actions.ts): Pure domain logic and graph algorithms with zero dependencies on Three.js, R3F, viewer, or editor packages. Complies fully with Invariant E-001.packages/mcp(bridge/scene-bridge.ts): ConsumesfindHierarchyCyclesfrom@pascal-app/corecleanly to report diagnostics invalidateScene().- Composition & Registry: Respects the registry-driven model; hierarchy constraints remain orthogonal to node kind definitions.
Findings
Blockers: 0
None. The implementation cleanly adheres to all package boundaries and store invariants.
Suggestions: 1
packages/core/src/store/actions/node-actions.ts:
During multi-node batch operations (applyNodeChangesActionImplandcreateNodesActionImpl),nextNodesis updated incrementally as each node is processed. The step-by-step invocation ofwouldCreateHierarchyCycle(newNode.id, effectiveParentId, nextNodes)guarantees that both direct self-references and intra-batch multi-node loops are caught before commit.
Suggestion: Consider adding a unit test specifically asserting that a 2-node circular swap within a singleapplyNodeChangesbatch call is cleanly rejected with the exact error message.
Nits: 0
None. Code is concise, types are strict (NodeMap pick on parentId), and time complexity (
Verification Summary
-
Algorithmic Soundness: The dual approach — fast
$O(D)$ ancestor walk for live mutations (wouldCreateHierarchyCycle) paired with linear$O(N)$ cycle detection for scene imports (findHierarchyCycles) — provides optimal performance without regression risks to high-frequency transform updates. -
Regression Coverage:
reparent.test.tsandapply-patch-identity.test.tstest suites provide clean regression locks.
Verdict: Ready to merge (Fully complies with Pascal architectural guidelines).
This branch has not been deployed
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?
Fixes #975
Prevents 'parentId' updates from creating cyclic scene hierarchies.
How to test