On this page

Dynamic linking basics๏ƒ

๐ŸŸก Intermediate ยท Lesson 21

Dynamic mode END TO END under the settle-then-inherit law: 1) A fresh world has no mode yet. The FIRST conjure(dynamic=True) SETTLES the world dynamic - and the posture locks. 2) Every later book just attaches: a plain conjure() INHERITS the world's mode. You never repeat the flag to stay dynamic. 3) link() opens a contract between two named conduits, and add_spell_to_contract shares one spell across it.

Before you run๏ƒ

Use the Intermediate guide for prerequisite concepts. Run from a checkout with Melder installed and Python 3.14 free-threading selected. The collection download includes the level's local helper modules.

Run the saved script๏ƒ

python UX_and_AIX_experiences/02_intermediate/21_dynamic_linking_basics.py
py -3.14t UX_and_AIX_experiences/02_intermediate/21_dynamic_linking_basics.py

Download this collection ยท Source on GitHub

Public surface๏ƒ

conjure(dynamic=True) settlement, plain-conjure inheritance, link, add_spell_to_contract, meld

Code๏ƒ

 1"""
 2TIER: intermediate (21)
 3GOAL: Dynamic mode END TO END under the settle-then-inherit law:
 4      1) A fresh world has no mode yet. The FIRST conjure(dynamic=True)
 5         SETTLES the world dynamic - and the posture locks.
 6      2) Every later book just attaches: a plain conjure() INHERITS the
 7         world's mode. You never repeat the flag to stay dynamic.
 8      3) link() opens a contract between two named conduits, and
 9         add_spell_to_contract shares one spell across it.
10SURFACE EXERCISED: conjure(dynamic=True) settlement, plain-conjure
11                   inheritance, link, add_spell_to_contract, meld
12"""
13import sys
14from pathlib import Path
15
16sys.path.insert(0, str(Path(__file__).parent))  # local helper (see _dynamic_world)
17from _dynamic_world import dynamic_spellbook
18
19import melder as md
20
21
22class SharedDirectory:
23    def lookup(self) -> str:
24        return "found"
25
26
27def main() -> None:
28    owner_book = dynamic_spellbook()
29    spell_id = owner_book.bind(spell=SharedDirectory, existence="unique")
30
31    # SETTLEMENT - the first conjure on a fresh world carries the world
32    # decision: dynamic=True SETTLES the world dynamic, and it locks.
33    owner = owner_book.conjure(dynamic=True, name="owner")
34
35    # INHERITANCE - the borrower does not ask. It attaches to a world
36    # that is already dynamic; a plain conjure() inherits the mode.
37    borrower = dynamic_spellbook().conjure(name="borrower")
38
39    assert owner.link(borrower) is True
40    # Sharing is a PULL: the borrower asks, and the conduit it NAMES
41    # must OWN the spell being pulled.
42    borrower.add_spell_to_contract(spell_id=spell_id, conduit=owner,
43                                   permissions="create")
44    shared = borrower.meld(spell=SharedDirectory)
45    print("borrower melded the owner's spell:", shared.lookup())
46    print("settled once at first conjure; every later conduit inherited")
47
48
49if __name__ == "__main__":
50    main()

Check the outcome๏ƒ

The script contains its own assertions or demonstrated refusal paths. Run it to evaluate those checks against your installed version. The code above is taken directly from the saved file; no run output is invented here.

More intermediate examples ยท Level guide