On this page

Transfer of ownership๏ƒ

๐ŸŸก Intermediate ยท Lesson 23

Ownership is transferable (dynamic mode) - a spell's stewardship moves to another conduit with an auditable preflight summary. Creations can move too; contracts unshare; lineage revalidates.

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/23_transfer_of_ownership.py
py -3.14t UX_and_AIX_experiences/02_intermediate/23_transfer_of_ownership.py

Download this collection ยท Source on GitHub

Public surface๏ƒ

transfer_spell_ownership

Code๏ƒ

 1"""
 2TIER: intermediate (23)
 3GOAL: Ownership is transferable (dynamic mode) - a spell's stewardship
 4      moves to another conduit with an auditable preflight summary.
 5      Creations can move too; contracts unshare; lineage revalidates.
 6SURFACE EXERCISED: transfer_spell_ownership
 7"""
 8import sys
 9from pathlib import Path
10
11sys.path.insert(0, str(Path(__file__).parent))  # local helper (see _dynamic_world)
12from _dynamic_world import dynamic_spellbook
13
14import melder as md
15
16
17class MigratingService:
18    pass
19
20
21def main() -> None:
22    source_book = dynamic_spellbook()
23    spell_id = source_book.bind(spell=MigratingService, existence="unique")
24    source = source_book.conjure(dynamic=True, name="old-home")
25    target = dynamic_spellbook().conjure(dynamic=True, name="new-home")
26    source.link(target)
27
28    report = source.transfer_spell_ownership(
29        spell=spell_id, target_conduit=target, move_creations=True,
30    )
31
32    # THE PREFLIGHT SUMMARY IS THE POINT. Ownership moving is not a silent
33    # side effect - it hands back an auditable report of what it did.
34    assert isinstance(report, dict) and report, report
35    print("transfer report keys:", sorted(report))
36
37    # THE NEW HOME CAN MELD IT.
38    moved = target.meld(spell=MigratingService)
39    assert isinstance(moved, MigratingService)
40    print("new home melds it:", type(moved).__name__)
41
42    # AND THE OLD HOME CANNOT. This is the assertion that makes it a
43    # TRANSFER rather than a share - if the source could still meld it,
44    # ownership would have been copied, not moved.
45    try:
46        source.meld(spell=MigratingService)
47        raise AssertionError(
48            "the source still melds it - that is sharing, not transfer"
49        )
50    except Exception as gone:
51        print("old home refused -", type(gone).__name__, ":",
52              str(gone)[:70])
53        print("  stewardship MOVED. A copy would have left both able to")
54        print("  meld, and then `ownership` would mean nothing")
55
56
57if __name__ == "__main__":
58    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