W-065: ecs-relations cascade traversal (REL-F05)¶
Type: feature · Size: S · Epic: E-relations-v0 · Target: packages/ecs-relations · Breaking: no Depends: W-060 Refs: spec REL-080..REL-089 (group REL-F05; KL3, KL6, KL7)
Goal¶
Implement cascade(world, query, rel) in packages/ecs-relations: an eager snapshot of the entities that match query, ordered by depth under rel (longest path), then by entity id. Non-matching entities still count for depth. Headless only.
Steps¶
- S1 (REL-080, REL-081, REL-082, REL-083, REL-086): compute depth with memoization and the longest-path rule over all entities, then return the matching entities once each, sorted by
[depth, entity.id()]; non-matching intermediates count for depth; files: packages/ecs-relations/src/cascade.ts, packages/ecs-relations/src/index.ts, packages/ecs-relations/tests/cascade.test.ts - S2 (REL-084, REL-085, REL-087, REL-088, REL-089; changeset): cycles ignore back edges on the current path and still return each match once; the result is a snapshot; no match gives
[]and an unused relation does not throw; no world change and no cache; entities withIsExcludedare not returned but count for depth; files: packages/ecs-relations/tests/cascade-edge.test.ts, packages/ecs-relations/src/cascade.ts, .changeset/w-065-ecs-relations-cascade.md (patch,@workspace/ecs-relations)
Log¶
- 2026-11-01 created (Triage), split from the approved spec W-008
- 2026-11-01 placed in Later (Depends W-060 not done; ready once the scaffold is done)
- 2026-11-02 moved to Next (Triage): W-060 done, size S, target and Goal filled
- 2026-11-02 moved down in Next behind the demo-critical items (Triage)