Learn / Wiring

How the assembly routes Messages and builds the runtime config

From a list of wirings and bundle placements, Page.assemble produces an assembly value that derives each runtime piece in order:

  • Claimed vs. shared tags: Each claimed tag routes to its single wiring via route (which returns Option.some when handled and Option.none otherwise), and falls through to own for everything else. A shared tag—such as UrlChanged or MirrorRestored—is folded by every wiring sharing it in list order, then passed to own.
  • Startup commands: wiring.initial runs placement init steps (shallowest first), then each wiring's init step in list order. A key-value mirror's restore command is returned as a normal Foldkit command.
  • Subscriptions and resources: Subscription entries and managed resources merge by key, throwing on duplicate keys and combining all Effect service requirements into the runtime type.
  • URL handling: wiring.url runs every wiring's onUrl on the initial URL and builds the onUrlChange dispatcher for navigation messages.
  • Module contracts: wiring.module collects every placement contract (owning its Model path) and every wiring contract into one list for Module.validate.

Who owns state when using an assembly

Joining integrations in one list leaves state ownership unchanged: each package keeps the exact responsibilities it had when wired by hand.

  • Remote owns the normalized server cache slice through Data.reduce.
  • Mirror observes local fields in your Model; your update remains the owner of those fields.
  • Sync owns replication through Sync.mount, contributing only its contract to the assembly.
  • Agent dispatches Messages from your union, which update handles as usual.
  • Placements own their slice of the parent Model via wrapped child Messages.