Repository navigation
fix: prevent cyclic scene hierarchies - #980
Vansh0Sharma wants to merge 1 commit into
Conversation
|
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
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).
Aymericr
left a comment
There was a problem hiding this comment.
Thanks @Vansh0Sharma, this looks good. The guard covers every reparent and create path in core and MCP, and validate_scene now catches existing cycles. The regression tests are solid too. The fork's CI is waiting on maintainer approval, and I'll merge once it's green. If it conflicts with main by then, please rebase.
|
Hi @Vansh0Sharma, heads up: #1027 (detached scene runtime) just merged into Could you rebase on the latest |
Port pascalorg#980 by Vansh0Sharma onto main after pascalorg#1027. Preserve core mutation atomicity and MCP invalid_parent refusals. Adapt the three 691ebb2 regressions to the current verify_scene tool. Original contribution: Vansh0Sharma (pascalorg#980).
Port the contributor's hierarchy-cycle guard to the current scene store and MCP tools, with structured invalid_parent errors and consistent cycle validation. Add regression coverage and reduce packed runtime size with whitespace-only minification while preserving the existing size budget. Independent Codex review approved head 498419a; all six CI checks passed. Original contribution by Vansh Sharma in PR #980; contributor authorship is retained in the PR history.
|
Thank you @Vansh0Sharma! Your cycle-guard fix was ported onto current |
What does this PR do?
Fixes #975
Prevents 'parentId' updates from creating cyclic scene hierarchies.
How to test