Skip to content

refactor(ecs): systems under their module, and a name on every observer - #1037

Merged
andrewgazelka merged 1 commit into
mainfrom
ecs-idioms
Jul 28, 2026
Merged

refactor(ecs): systems under their module, and a name on every observer#1037
andrewgazelka merged 1 commit into
mainfrom
ecs-idioms

Conversation

@andrewgazelka

Copy link
Copy Markdown
Member

What

flecs resolves the string in system_named("smash::tick_cooldowns") relative to the module scope that world.module::<Self>("smash::Ability") already set. So the redundant smash:: prefix created a phantom smash node and buried every game system at smash.Ability.smash.tick_cooldowns. On the live world the explorer drew 17 phantom smash rows that correspond to nothing, plus the same defect in two hyperion effects modules.

This drops the redundant prefix so the module scope supplies the path, and names every previously anonymous observer across hyperion and smash.

  • 24 systems/observers in smash + 3 kits: smash::X prefix removed -> clean smash.Module.leaf.
  • hyperion effects/spawn and effects/particle: same hyperion:: phantom removed.
  • Terrain left untouched: it already resolved cleanly to smash.rotate_map (verified on the live REST endpoint, HTTP 200 at smash/rotate_map, 404 at MapModule/smash/rotate_map), and stripping its prefix would have moved it out of the smash tree.
  • Every .observer::<...>() in hyperion + smash is now observer_named with a meaningful leaf, so the explorer stops listing them as #NNN and the flecs borrow-panic can print the observer's name (the docs/flecs-rust-api-notes.md note asked for this; it was dead for observers with no name).

Behaviour is unchanged: only name strings and observer names moved, no logic.

Proof

events/smash/tests/system_paths.rs is the guard. It imports SmashModule and fails if any module grows a child literally named smash.

Broken on purpose (re-added a smash:: prefix to one system), the guard fires with the intended message:

thread 'no_phantom_smash_scope' panicked at events/smash/tests/system_paths.rs:37:5:
a redundant `smash::` prefix put a phantom node in the module tree: ["::smash::Ability::smash"]
test no_phantom_smash_scope ... FAILED
test systems_sit_directly_under_their_module ... FAILED

Restored, both pass:

test no_phantom_smash_scope ... ok
test systems_sit_directly_under_their_module ... ok
  • cargo clippy -p smash -p hyperion --all-targets --all-features -- -D warnings: clean.
  • cargo test -p smash: all pass.
  • cargo test -p hyperion: all pass.

flecs resolves a system_named("smash::tick_cooldowns") string relative to
the module scope that world.module::<Self>("smash::Ability") already set, so
the redundant prefix created a phantom smash node and buried every game
system at smash.Ability.smash.tick_cooldowns. The explorer drew 17 phantom
smash rows that correspond to nothing. Drop the prefix; the module scope
supplies the path. Terrain, which already resolved cleanly, is left alone.

Name every previously anonymous observer across hyperion and smash so the
explorer stops listing them as #NNN and the flecs borrow-panic can print the
observer's name.

tests/system_paths.rs guards both: it fails if any module grows a child
literally named smash.
@andrewgazelka
andrewgazelka merged commit 495fac1 into main Jul 28, 2026
9 of 11 checks passed
@andrewgazelka
andrewgazelka deleted the ecs-idioms branch July 28, 2026 11:50
@github-actions

Copy link
Copy Markdown

Benchmark Results for general

ray_intersection/aabb_size_0.1                     [  17.3 ns ...  17.2 ns ]      -0.55%
ray_intersection/aabb_size_1                       [  17.2 ns ...  17.2 ns ]      +0.03%
ray_intersection/aabb_size_10                      [  17.2 ns ...  17.2 ns ]      +0.20%
ray_intersection/ray_distance_1                    [   1.5 ns ...   1.5 ns ]      +0.15%
ray_intersection/ray_distance_5                    [   1.5 ns ...   1.5 ns ]      -0.44%
ray_intersection/ray_distance_20                   [   1.5 ns ...   1.5 ns ]      -0.15%
overlap/no_overlap                                 [  15.6 ns ...  15.6 ns ]      +0.15%
overlap/partial_overlap                            [  15.6 ns ...  15.6 ns ]      -0.14%
overlap/full_containment                           [  14.9 ns ...  14.9 ns ]      +0.17%
point_containment/inside                           [   6.0 ns ...   6.0 ns ]      +0.04%
point_containment/outside                          [   6.0 ns ...   6.1 ns ]      +0.13%
point_containment/boundary                         [   6.1 ns ...   6.1 ns ]      -0.16%

Comparing to 035a8ce

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.81132% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.06%. Comparing base (9ecba09) to head (4e1844d).
⚠️ Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
events/smash/src/input.rs 0.00% 12 Missing ⚠️
events/smash/src/adapter.rs 0.00% 2 Missing ⚠️
events/smash/src/mirror.rs 0.00% 1 Missing ⚠️
events/smash/src/terrain.rs 0.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1037      +/-   ##
==========================================
+ Coverage   53.46%   54.06%   +0.60%     
==========================================
  Files         345      347       +2     
  Lines       31870    32497     +627     
  Branches     1207     1234      +27     
==========================================
+ Hits        17039    17571     +532     
- Misses      14561    14644      +83     
- Partials      270      282      +12     
Files with missing lines Coverage Δ
crates/hyperion/src/effects/particle.rs 65.69% <100.00%> (ø)
crates/hyperion/src/effects/spawn.rs 93.75% <100.00%> (ø)
crates/hyperion/src/egress/boss_bar.rs 59.81% <100.00%> (ø)
crates/hyperion/src/egress/channel.rs 26.66% <100.00%> (ø)
crates/hyperion/src/egress/player_join/roster.rs 11.11% <100.00%> (ø)
crates/hyperion/src/ingress/mod.rs 63.23% <100.00%> (ø)
crates/hyperion/src/lib.rs 77.97% <100.00%> (ø)
crates/hyperion/src/net/protocol/join.rs 7.69% <100.00%> (ø)
crates/hyperion/src/simulation/mod.rs 76.51% <100.00%> (ø)
events/smash/src/module/ability.rs 94.15% <100.00%> (-0.33%) ⬇️
... and 17 more

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant