Skip to content

ecs: a system that writes a resource should not require ordering every reader by hand #243

Closed

Description

@krisnye

Summary

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:

  1. A declared writer role: System.create({ resources: { writes: [volumeSize] }, first: true }), meaning every other accessor of the key runs after, without being edited.
  2. 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.

Activity

  1. krisnye commented on Nov 1, 2026

    @krisnye
    CollaboratorAuthor

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions