On this page

Upgrade to normal๏ƒ

๐ŸŸก Intermediate ยท Lesson 28

upgrade_to_normal - a lesser conduit GROWS UP in place. Lessers are unnamed child scopes (lesson 07); in a dynamic world one can be promoted to a full named citizen: registered in the world, discoverable by name in the cloud, able to do everything a normal conduit does. The promotion KEEPS what the child already built - its creations ride through the upgrade untouched. Dynamic-only verb: in a static world the same call refuses.

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

Download this collection ยท Source on GitHub

Public surface๏ƒ

create_lesser_conduit, upgrade_to_normal, cloud name lookup after promotion

Code๏ƒ

 1"""
 2TIER: intermediate (28)
 3GOAL: upgrade_to_normal - a lesser conduit GROWS UP in place. Lessers
 4      are unnamed child scopes (lesson 07); in a dynamic world one can
 5      be promoted to a full named citizen: registered in the world,
 6      discoverable by name in the cloud, able to do everything a normal
 7      conduit does. The promotion KEEPS what the child already built -
 8      its creations ride through the upgrade untouched. Dynamic-only
 9      verb: in a static world the same call refuses.
10SURFACE EXERCISED: create_lesser_conduit, upgrade_to_normal,
11                   cloud name lookup after promotion
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 Workbench:
23    pass
24
25
26def main() -> None:
27    book = dynamic_spellbook()
28    book.bind(spell=Workbench, existence="unique_per_conduit")
29    root = book.conjure(dynamic=True, name="factory-floor")   # settles
30
31    # An unnamed child scope, working away...
32    worker = root.create_lesser_conduit()
33    bench_before = worker.meld(spell=Workbench)
34
35    # ...promoted in place. Name granted, world registration performed.
36    worker.upgrade_to_normal(name="worker")
37
38    # It KEPT its stuff: the per-conduit bench survives the promotion.
39    bench_after = worker.meld(spell=Workbench)
40    assert bench_after is bench_before
41    print("promotion kept the child's creations:", type(bench_after).__name__)
42
43    # And it is now a discoverable citizen of the world.
44    cloud = root.get_conduit_cloud()
45    assert cloud.get_conduit_by_name("worker") is worker
46    print("promoted conduit found by name:", worker.name)
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