# Late binding with SpellContract **Intermediate.** Wire whole subsystems together without either side importing the other. **Excerpt.** Define the `ConfigContract` Protocol, register its provider in `platform_book`, and bind the consumer in `services_book` first. `config_id` and `service_id` below are the IDs returned by those registrations. Run the complete [late-binding lesson](https://github.com/Synaptic724/melder/blob/prod/UX_and_AIX_experiences/02_intermediate/36_late_binding_with_spellcontract.py) for the definitions and full sequence. A `SpellContract` is a **hole you leave on purpose**. The class declares the *shape* it needs; the provider arrives later, across a link: ```python class ReportService: def __init__( self, config: ConfigContract = md.SpellContract( spellframe=ConfigContract, binding_name="platform", ), ) -> None: self.config = config # ← filled from another conduit entirely ``` Name your conduits after the resolution ideas your app already has — `platform`, `services`, `workflows` — and the conduit names *become* your factory layer. No abstract factories, no service locator, no imports between subsystems. **The order of operations is the law.** Per dependency edge, in this exact order: ```python platform = platform_book.conjure(dynamic=True, name="platform") # 1. provider services = services_book.conjure(dynamic=True, name="services") # 2. consumer platform.link(services) # 3. link — AFTER both exist services.add_spell_to_contract( # 4. consumer pulls spell_id=config_id, conduit=platform, permissions="create", ) service = services.meld(spell_id=service_id) # 5. meld completes the binding ``` Expected outcome: `service.config` is the contracted provider object. The saved lesson's equivalent store example prints `region-ok`; these excerpts do not print. Assemble the chain edge by edge, in dependency order. `services` can then feed `workflows` with the identical five steps one level up — the finished product of one category becomes the dependency of the next. ## Runnable examples - [Late binding with SpellContract: runnable example](../examples/intermediate/36-late-binding-with-spellcontract.md) — Intermediate 36 - [Conduit categories as factories](../examples/intermediate/26-conduit-categories-as-factories.md) — Intermediate 26 [All intermediate examples](../examples/intermediate/index.md) · [Level contents](index.md) · [Full contents](../contents.md) [Canonical page source](https://github.com/Synaptic724/melder/blob/0895ce795453cd87e35d70665957b4e89aad3317/README.md)