On this page

Structural operations and admission๏ƒ

Prerequisites: dynamic composition and room boundaries. Continue using public structural verbs such as bind, link, sever, transfer, and staged binding. Each owns its admission and bookkeeping; normal application code does not open an extra transaction around it.

Read and write paths have different jobs๏ƒ

The internal DevOps plane coordinates structural changes through scopes and claim modes. Resolution uses its own validity and creation gates. A failure at an admission or posture gate should be diagnosed at the boundary named by the error. The rewiring lesson demonstrates both a static world and a dynamic world whose posture explicitly disables linking.

A gate is more than a mutex๏ƒ

Stopping new entrants does not prove existing readers have left. The gate lesson distinguishes reversible disable/enable from terminal shutdown. It selects the raise entry policy for a single-threaded demonstration, disables admission, checks refusal, reopens the gate, and checks that the same validation call works.

For shutdown, it performs a bounded close_and_wait_rift(...) and checks the remaining active-thread count afterward. That count is a diagnostic, not a polling loop to use as a substitute for synchronization.

The concurrency guide demonstrates several rooms executing actual jobs against a shared target. Use the architecture reference for the internal coordination design behind these public operations.

The workflow in code๏ƒ

These are the core steps from the saved example. Use its complete linked script for all class definitions and setup.

 1def main() -> None:
 2    # STEPS 1 AND 2: both conduits exist before anything is wired.
 3    owner_book = md.Spellbook(aetheric_frame="rewire-world")
 4    borrower_book = md.Spellbook(aetheric_frame="rewire-world")
 5    service_id = owner_book.bind(
 6        spell=Service, existence="unique", permissions="create",
 7        binding_name="rewire-service",
 8    )
 9    borrower_book.bind(
10        spell=Consumer, existence="unique", permissions="create",
11        binding_name="rewire-consumer",
12    )
13    owner = owner_book.conjure(dynamic=True, name="owner")
14    borrower = borrower_book.conjure(dynamic=True, name="borrower")
15    print("two conduits up, nothing wired between them yet")
16
17    # The owner resolves its own spell. This works before any linking -
18    # ownership and sharing are different questions.
19    assert owner.meld("Service",
20                      binding_name="rewire-service").label == "service"
21    print("owner melds its own spell -> service")
22
23    # STEP 3: link, now that both ends exist.
24    assert owner.link(borrower) is True
25    print()
26    print("link() -> True")
27
28    # STEP 4: the CONSUMER pulls. Naming `owner` here is not a style
29    # choice - the conduit named must own the spell.
30    assert borrower.add_spell_to_contract(
31        spell_id=service_id,
32        conduit=owner,
33        permissions="create",
34    )
35    print("borrower pulled the owner's spell into its contract")
36    print("  sharing is a PULL - the named conduit must OWN the spell")
37
38    # STEP 5: meld completes the late binding across the new edge.
39    borrowed = borrower.meld("Service", binding_name="rewire-service")
40    assert borrowed.label == "service"
41    print("borrower melds it ->", borrowed.label)
42    print()
43    print("the world was rewired while running, in three ordinary calls")
44
45    # A WORLD TOLD NOT TO LINK REFUSES, AND SAYS WHY. This one IS
46    # dynamic; it has simply been braked.
47    braked_owner, braked_borrower = _pair(
48        "rewire-braked", system_state="dynamic", disable_linking=True,
49    )
50    try:
51        braked_owner.link(braked_borrower)
52        raise AssertionError("expected a refusal: linking is braked")
53    except RuntimeError as error:
54        assert "posture" in str(error)
55        print()
56        print("braked world refused link() -")
57        print("  ", error)
58
59    # AN ORDINARY STATIC WORLD REFUSES TOO - and with the SAME sentence,
60    # because the posture gate answers first and an unconfigured
61    # non-dynamic frame is already "not allowed to link" to it.
62    static_owner, static_borrower = _pair("rewire-static")
63    try:
64        static_owner.link(static_borrower)
65        raise AssertionError("expected a refusal: static cannot link")
66    except RuntimeError as error:
67        assert "posture" in str(error)
68        print()
69        print("static world refused link() -")
70        print("  ", error)
71        print("  SAME sentence as the braked world: the message names the")
72        print("  GATE that refused, not the property you had in mind")
73
74    print()
75    print("link, pull, meld - and the order is just dependency order")
76    print("nothing here opens, holds, or commits anything by hand")

Runnable examples๏ƒ

All expert examples ยท Level contents ยท Full contents

Canonical page source