Skip to content

W-066: ecs-relations ChildOf hierarchy (REL-F06)

Type: feature · Size: S · Epic: E-relations-v0 · Target: packages/ecs-relations · Breaking: no Depends: W-060 Refs: spec REL-100..REL-110 (group REL-F06; KL1, KL3, KL6, KL9); REL-110 is the README section

Goal

Implement ChildOf (exclusive, autoDestroy: 'orphan'), parent(world, child), and children(world, parent) in packages/ecs-relations. children is ordered by ascending entity.id(). Cycles are tolerated, not prevented.

Steps

  • S1 (REL-100, REL-101, REL-105, REL-106): define ChildOf as an exclusive relation with autoDestroy: 'orphan'; parent returns the parent or undefined; children returns a fresh array sorted by id, [] for leaves; files: packages/ecs-relations/src/child-of.ts, packages/ecs-relations/src/hierarchy.ts, packages/ecs-relations/src/index.ts, packages/ecs-relations/tests/child-of.test.ts
  • S2 (REL-102, REL-103, REL-104, REL-107, REL-108, REL-109): reparenting moves the child and keeps its other traits; destroying a parent destroys all descendants; destroying a child leaves the rest; a koota canary checks ChildOf('*') and ChildOf(p) queries; cycles do not hang parent, children, or destroy; parent and children throw naming the function for a dead entity; files: packages/ecs-relations/tests/child-of-lifecycle.test.ts, packages/ecs-relations/src/hierarchy.ts, .changeset/w-066-ecs-relations-childof.md (patch, @workspace/ecs-relations)
  • S3 (REL-110 [manual]): README section stating that ChildOf is plain koota, that cycles are the caller's responsibility, and that child order is by entity id (koota ordered() is out of scope); files: packages/ecs-relations/README.md

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 up in Next: first step of the demo-ck3 path (CK3-F01 needs it) (Triage)