Skip to content

feat(core): add before/after dependency ordering to SystemRegistry#419

Merged
Exoridus merged 2 commits into
mainfrom
feat/systemregistry-before-after
Jul 26, 2026
Merged

feat(core): add before/after dependency ordering to SystemRegistry#419
Exoridus merged 2 commits into
mainfrom
feat/systemregistry-before-after

Conversation

@Exoridus

Copy link
Copy Markdown
Owner

Summary

  • SystemRegistrationOptions gains before?/after?: readonly System[], additive to the existing numeric order (not a replacement — order/registration sequence still break ties among registrations the dependency graph doesn't relate).
  • Per-phase-list (_fixedList/_updateList/_drawList) sort is now a topological sort (Kahn's algorithm) instead of a plain comparator sort, falling back to byte-identical order/sequence behavior when no registration in a given list declares before/after.
  • Constraints are scoped per phase: a before/after reference 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.
  • A cycle throws a clear Error naming the systems involved (via constructor.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.
  • No named SystemSet/label concept — before/after reference concrete System objects directly. The only existing precedent for coordinated ordering in the codebase (SystemOrder enum + 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

  • New test/core/system-registry.test.ts: baseline order/sequence regression, before pulls ahead regardless of order, after pushes behind regardless of order, tie-break among multiple constrained systems (registration order wins), phase-mismatch silent no-op, cycle throws naming both systems
  • TDD: watched all new-behavior tests fail for the right reason before implementing, then pass
  • test/core/scene-systems.test.ts + test/core/application-extension-systems.test.ts unmodified, still green
  • Full test/core/ directory (63 files, 930 tests) green — no regressions
  • pnpm typecheck + pnpm typecheck:type-tests clean (covers the public System/SystemRegistry type contract)
  • eslint clean
  • pnpm verify:quick (full local pre-push gate) green

Exoridus 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
Exoridus enabled auto-merge (squash) July 26, 2026 14:26
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 7.85kB (0.03%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
exo-esm-esm 875.53kB 875 bytes (0.1%) ⬆️
exo-esm-modules-esm 3.97MB 4.06kB (0.1%) ⬆️
exo-iife-min-Exo-iife 883.28kB 875 bytes (0.1%) ⬆️
exo-full-iife-Exo-iife 2.81MB 2.04kB (0.07%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: exo-full-iife-Exo-iife

Assets Changed:

Asset Name Size Change Total Size Change (%)
exo.full.iife.js 2.04kB 2.81MB 0.07%
view changes for bundle: exo-esm-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
exo.esm.js 875 bytes 875.53kB 0.1%

Files in exo.esm.js:

  • ./src/core/SystemRegistry.ts → Total Size: 11.79kB
view changes for bundle: exo-esm-modules-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
core/SystemRegistry.js 3.16kB 11.93kB 36.03% ⚠️
core/SystemRegistry.d.ts 905 bytes 5.2kB 21.09% ⚠️

Files in core/SystemRegistry.js:

  • ./src/core/SystemRegistry.ts → Total Size: 11.79kB
view changes for bundle: exo-iife-min-Exo-iife

Assets Changed:

Asset Name Size Change Total Size Change (%)
exo.iife.min.js 875 bytes 883.28kB 0.1%

Files in exo.iife.min.js:

  • ./src/core/SystemRegistry.ts → Total Size: 11.79kB

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.65217% with 2 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/core/SystemRegistry.ts 95.65% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Exoridus
Exoridus merged commit bef47f3 into main Jul 26, 2026
17 of 18 checks passed
@Exoridus
Exoridus deleted the feat/systemregistry-before-after branch July 26, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant