On this page
Sever link๏
๐ก Intermediate ยท Lesson 27
sever_link - the UNDO of the whole dynamic arc. Contracts ride links, so when the link dies, everything shared across it dies with it: the borrower loses resolution of every pulled spell on its very next meld. Nothing is torn down eagerly - the owner's live instances stay alive in the owner's world; what the borrower loses is the RIGHT TO RESOLVE them. Severing an already-severed pair refuses (there is no contract left to remove).
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/27_sever_link.py
py -3.14t UX_and_AIX_experiences/02_intermediate/27_sever_link.py
Public surface๏
sever_link, post-sever meld refusal
Code๏
1"""
2TIER: intermediate (27)
3GOAL: sever_link - the UNDO of the whole dynamic arc. Contracts ride
4 links, so when the link dies, everything shared across it dies
5 with it: the borrower loses resolution of every pulled spell on
6 its very next meld. Nothing is torn down eagerly - the owner's
7 live instances stay alive in the owner's world; what the borrower
8 loses is the RIGHT TO RESOLVE them. Severing an already-severed
9 pair refuses (there is no contract left to remove).
10SURFACE EXERCISED: sever_link, post-sever meld refusal
11"""
12import sys
13from pathlib import Path
14
15sys.path.insert(0, str(Path(__file__).parent)) # local helper (see _dynamic_world)
16from _dynamic_world import dynamic_spellbook
17
18import melder as md
19
20
21class SharedDirectory:
22 def lookup(self) -> str:
23 return "found"
24
25
26def main() -> None:
27 owner_book = dynamic_spellbook()
28 spell_id = owner_book.bind(spell=SharedDirectory, existence="unique")
29 owner = owner_book.conjure(dynamic=True, name="sever-owner") # settles
30 borrower = dynamic_spellbook().conjure(name="sever-borrower") # inherits
31
32 # The full sharing cycle from lesson 21...
33 owner.link(borrower)
34 borrower.add_spell_to_contract(spell_id=spell_id, conduit=owner,
35 permissions="create")
36 shared = borrower.meld(spell=SharedDirectory)
37 print("while linked, the borrower resolves:", shared.lookup())
38
39 # ...and the undo. The contract dies WITH the link.
40 owner.sever_link(borrower)
41 try:
42 borrower.meld(spell=SharedDirectory)
43 print("post-sever meld unexpectedly resolved")
44 except Exception as err:
45 print("post-sever meld refused:", type(err).__name__,
46 "(the borrower lost the right to resolve, not the owner's object)")
47
48 # The owner's world never noticed: the CREATIONS STORE still
49 # retains everything that was built. Severing revokes resolution
50 # RIGHTS - it never reaches into anyone's memory.
51 print("owner still holds the live creation:",
52 owner.has_live_creation(spell=SharedDirectory))
53 still_alive = owner.meld(spell=SharedDirectory)
54 print("owner still resolves its own spell:", still_alive is shared)
55
56 # Severing again refuses: there is no contract left to remove.
57 try:
58 owner.sever_link(borrower)
59 print("double sever unexpectedly succeeded")
60 except Exception as err:
61 print("double sever refused:", type(err).__name__)
62
63
64if __name__ == "__main__":
65 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.