The Game Panel specification

ADR-0003: Mutable registries are sealed into immutable catalogues

Context

Several parts of the engine collect things while the panel boots and consult them afterwards: the container collects bindings and resolvers, and the configuration component collects configuration objects. Registration happens in stages and from more than one place. Some of it depends on what has already been registered: modules register their own configuration, but which modules are enabled is itself configuration, and has to be readable before modules register anything.

Once boot is over, the code that reads these collections needs them to stay as they were when it read them.

Decision

Anything registered during boot is collected by a mutable registry and sealed into an immutable catalogue, which is what the rest of the panel reads. The registry is a short-lived builder, discarded once it has been sealed. The catalogue is read-only, and immutability is enforced at the type boundary between the two rather than by convention. Where registration depends on something already registered, sealing happens in phases, each producing something the next phase can read.

Alternatives

No alternatives were weighed.

Consequences

Easier:

Harder:

Constrained:

Sources