feat(core): add before/after dependency ordering to SystemRegistry#419
Merged
Conversation
added 2 commits
July 26, 2026 16:17
Additive to the existing numeric `order` field, not a replacement. SystemRegistrationOptions gains `before`/`after` (arrays of System references); ordering within each phase list (fixed/update/draw) is now a topological sort (Kahn's algorithm) instead of a plain comparator sort, falling back to identical order/sequence-only behavior when no registration declares before/after anywhere in that list. Constraints are scoped per phase list: a before/after reference to a system outside the current phase (different phase, or never registered) is a silent no-op rather than an error, since the constraint genuinely has nothing to order there. A cycle throws a clear error naming the systems involved, surfaced lazily at the next sort of the affected phase (same dirty-flag-driven timing the registry already used). No named SystemSet/label concept - before/after reference concrete System objects directly. The codebase's only real precedent for coordinated ordering (SystemOrder enum + PhysicsWorld) is a single-system pattern with no evidence of needing group-based dependencies; adding label resolution later is a compatible extension, not a redesign, since the graph already operates on registration identity.
Exoridus
enabled auto-merge (squash)
July 26, 2026 14:26
Bundle ReportChanges will increase total bundle size by 7.85kB (0.03%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: exo-full-iife-Exo-iifeAssets Changed:
view changes for bundle: exo-esm-esmAssets Changed:
Files in
view changes for bundle: exo-esm-modules-esmAssets Changed:
Files in
view changes for bundle: exo-iife-min-Exo-iifeAssets Changed:
Files in
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
SystemRegistrationOptionsgainsbefore?/after?: readonly System[], additive to the existing numericorder(not a replacement —order/registration sequence still break ties among registrations the dependency graph doesn't relate)._fixedList/_updateList/_drawList) sort is now a topological sort (Kahn's algorithm) instead of a plain comparator sort, falling back to byte-identicalorder/sequencebehavior when no registration in a given list declaresbefore/after.before/afterreference to a system outside the current phase (different phase, or never registered) is a silent no-op there, not an error — the constraint genuinely has nothing to order in that list.Errornaming the systems involved (viaconstructor.name), surfaced lazily at the next sort of the affected phase — same dirty-flag-driven timing the registry already used, no new eager-validation path.SystemSet/label concept —before/afterreference concreteSystemobjects directly. The only existing precedent for coordinated ordering in the codebase (SystemOrderenum +PhysicsWorld) is a single-system pattern with no evidence of needing group-based dependencies; label resolution could be added later as a compatible extension (the graph already operates on registration identity), not a redesign.No public API removal or behavior change for existing
order-only callers — internal sort algorithm swap, additive options surface.Test plan
test/core/system-registry.test.ts: baseline order/sequence regression,beforepulls ahead regardless of order,afterpushes behind regardless of order, tie-break among multiple constrained systems (registration order wins), phase-mismatch silent no-op, cycle throws naming both systemstest/core/scene-systems.test.ts+test/core/application-extension-systems.test.tsunmodified, still greentest/core/directory (63 files, 930 tests) green — no regressionspnpm typecheck+pnpm typecheck:type-testsclean (covers the publicSystem/SystemRegistrytype contract)eslintcleanpnpm verify:quick(full local pre-push gate) green