W-031: ecs-schedule enable and disable (SCH-F04, part 1)¶
Type: feature · Size: M · Epic: E-schedule-v0 · Target: packages/ecs-schedule · Breaking: no Depends: W-030 Refs: spec SCH-050, SCH-051, SCH-052, SCH-053, SCH-054, SCH-055, SCH-056, SCH-057, SCH-058, SCH-113, SCH-123, SCH-124, SCH-152, SCH-153
Goal¶
Add enable, disable, and isEnabled, with the enabled state stored by system name in the disabled field of the state trait. Changes apply immediately, including inside a running system. The enabled-state lookup cache is keyed on the identity of disabled. Conditions (SCH-118..122) are in W-032.
Steps¶
- S1 (SCH-050, SCH-051, SCH-054, SCH-055): systems are enabled by default;
disable/enablerecord the name indisabled(new array);isEnabledreports the flag; unknown system throws; both are idempotent; files: packages/ecs-schedule/src/enable.ts, packages/ecs-schedule/tests/enable-basic.test.ts - S2 (SCH-052, SCH-053): re-enabled system keeps its original position; a disabled system keeps its
before/afterconstraints; files: packages/ecs-schedule/tests/enable-order.test.ts - S3 (SCH-056, SCH-057, SCH-058): changes inside a running system apply immediately; disabling a later system skips it; a system that disables itself or an earlier system does not change the current call; files: packages/ecs-schedule/tests/enable-in-run.test.ts
- S4 (SCH-123, SCH-153): the lookup cache is invalidated when
disabledis replaced throughworld.set,enable/disable, orworld.reset();world.setbetween calls and inside a running system is honoured; files: packages/ecs-schedule/src/enable-cache.ts, packages/ecs-schedule/tests/enable-cache.test.ts - S5 (SCH-124 [manual], SCH-152 [manual]): benchmark that disabling many systems keeps the per-system check O(1); document in the package README and the
ScheduleStateTraitdoc comment that in-place mutation ofdisabledis unsupported and name the supported ways; verify by reading both; files: packages/ecs-schedule/bench/enable.bench.ts, packages/ecs-schedule/README.md, packages/ecs-schedule/src/state.ts - S5a (SCH-113): an OnStart phase with all systems disabled, or whose last system is disabled, counts as done once the phase completed; replaces the matching
it.todoentries in packages/ecs-schedule/tests/on-start-done.test.ts; done is marked at the end of the OnStart phase, moving the mark out of per-system code in src/run.ts and src/run-phases.ts if needed; a throw in an earlier OnStart system leaves OnStart not done even when the last system is disabled; files: packages/ecs-schedule/tests/on-start-done.test.ts, packages/ecs-schedule/src/run.ts, packages/ecs-schedule/src/run-phases.ts - S6 (changeset): add
.changeset/w-031-ecs-schedule-enable.md(patch,@workspace/ecs-schedule)
Log¶
- 2026-11-01 created from the approved spec split of W-004 (Triage)
- 2026-11-02 S5a added for SCH-113 (disabled OnStart), taken from the deferred W-030 S2 cases (Triage)
- 2026-11-02 moved from Next to Now, state active (Triage)
- 2026-11-02 S1 reviewed; added public
schedule.state(SCH-151) andScheduleStateTraittype export, needed by the S1 tests - 2026-11-02 S2 reviewed; tests pass without implementation change
- 2026-11-02 S3 reviewed; tests pass without implementation change
- 2026-11-02 S4 reviewed; cache is per schedule (createEnableApi), not module-level
- 2026-11-02 S5 reviewed (manual: bench and docs verified by reading)
- 2026-11-02 S5a reviewed; OnStart done mark already at the phase boundary, tests pass without src change
- 2026-11-02 S6 reviewed; removed stray duplicate changeset public-maps-do.md
- 2026-11-02 state review: final Reviewer pass passed, S1..S6 ticked (Triage)
- 2026-11-02 moved from Now to Done, state done (Triage)