You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ecs: a system that writes a resource should not require ordering every reader by hand #243
A system can write a resource only by naming it, and once it writes it, it conflicts with every system that reads it, so each reader needs before/after. Adding a reader fails the build until someone remembers the ordering, and the ordering is only ever "the writer first".
Case (mecs, @adobe/ecs 0.2.4)
applyHistory (undo/redo) writes resources[volumeSize]. Ten systems read volumeSize (the face pointing, the controls, a dialog, hover pick, the view's framing...). The build says:
Systems "selectFace" and "applyHistory" both access "volumeSize" and one writes it; order them with before or after.
We fixed it by giving a phase (facePointed, after: [applyHistory]) and adding after: [applyHistory] to the others.
Since #232, the same ordering also decides sync points: every after on a system whose predecessor issues commands adds a sync point (see #245). So an ordering we need only to settle a read/write conflict also changes the schedule's cost.
Requested
Either of:
A declared writer role: System.create({ resources: { writes: [volumeSize] }, first: true }), meaning every other accessor of the key runs after, without being edited.
Scheduler default: when exactly one system writes a resource and others only read, order readers after the writer, and report an error only for two writers or a cycle.
Notes
Reader/writer order for a resource that one system owns is almost always "writer first"; the explicit form is for the rare reader that must see the old value.
Addressed in #250 (Adobe-Firefly/ecs#9) by option 1, in a form declared once on the writer: before and after take a resource key. applyHistory with before: [volumeSize] runs before every other system of its composite that reads, writes, reduces, filters on or is conditioned on volumeSize. A reader that must see the old value says before: [applyHistory], which wins without a cycle. Two systems naming one resource stay unordered with each other, so two writers still conflict.
Option 2, ordering readers after a lone writer by default, is declined. A second writer added anywhere would turn a silent order into an error far from that change, and readers' tiers and sync points would change with nothing in their code saying so.
Activity
krisnye commentedon Nov 1, 2026
Addressed in #250 (Adobe-Firefly/ecs#9) by option 1, in a form declared once on the writer:
beforeandaftertake a resource key.applyHistorywithbefore: [volumeSize]runs before every other system of its composite that reads, writes, reduces, filters on or is conditioned onvolumeSize. A reader that must see the old value saysbefore: [applyHistory], which wins without a cycle. Two systems naming one resource stay unordered with each other, so two writers still conflict.Option 2, ordering readers after a lone writer by default, is declined. A second writer added anywhere would turn a silent order into an error far from that change, and readers' tiers and sync points would change with nothing in their code saying so.