On this page

Give each agent an explicit room and target

Prerequisites: Nexus setup and world posture. A Rift owns one room, including its viewer, workstation, command surface, and optional codegen machinery.

Room

Main purpose

static

Inspect the permitted live surface

capability

Use the broader runtime command surface and research reads

codegen

Add source validation/execution/materialization and research authoring operations

Ask list_supported_command_methods() for the commands the actual room exposes. A method may also require an active subsystem. Availability and authority are different: activating research does not add its authoring commands to a capability room.

Attach with both sides configured

The target frame must opt into observation before conjure. Nexus policy must allow the target. Conjure publishes the world, then the Rift attaches with create_frame_link(frame_name). Codegen targets also require dynamic and AI-native posture. The target-attachment lesson exercises refusals from both sides.

For multiple worlds, configure the allowed names, permit multiple targets, and set the target count. Attach each world explicitly. A shared observer leaves the underlying worlds isolated.

Hold objects deliberately

The workstation holds named handles; the command system resolves permitted world access. A bound object retains its ordinary Python behavior. Post-bind use of an already-granted handle is a different boundary from acquiring it. See workstation ownership and the complete workbench lesson.

Room policy and code validation are application controls. They are not an operating system sandbox or a proof that arbitrary hostile Python is safely isolated.

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    # A frame that never opted in. This is the default, on purpose.
 3    closed = md.Spellbook(aetheric_frame="closed-world")
 4    closed.bind(spell=Ledger, existence="unique", binding_name="closed-world")
 5    closed.conjure(name="closed-root")
 6
 7    # ...and three that did. 'unlisted' is postured EXACTLY like
 8    # 'observable' - the only thing that will differ is the Nexus's own
 9    # policy, which is how we isolate gate A from gate B.
10    _postured_frame("observable")
11    _postured_frame("unlisted")
12    _postured_frame("workshop", dynamic=True)
13    print("four frames: one default, two rift-enabled, one AI-native")
14
15    # The Rift domain has to be live before any of this matters - and the
16    # NEXUS has to be told which worlds it may reach. The shipped
17    # allow-list is ("default",), so every frame here is foreign to it.
18    nexus = md.Nexus()
19    system_configuration = nexus.create_configuration()
20    system_configuration.with_rift_creation_enabled(True)
21    system_configuration.with_allowed_target_frame_names(
22        ["observable", "workshop", "closed-world"],
23    )
24    # Two worlds get attached below, and the budget is NEXUS-WIDE.
25    system_configuration.with_multiple_target_frames(True)
26    system_configuration.with_max_target_frame_count(4)
27    nexus.activate(system_configuration)
28    assert nexus.is_activated is True
29    print("nexus activated; allow-list names 3 of the 4 worlds")
30
31    # A capability room, then ATTACH it to the world that opted in AND is
32    # named by the observer's policy. Both parties agreed.
33    rift_configuration = nexus.create_rift_configuration()
34    rift_configuration.with_space_type("capability")
35    rift = nexus.create_rift(configuration=rift_configuration,
36                             rift_name="observer")
37    rift.mark_active()
38    rift.create_frame_link("observable")
39    print()
40    print("attached: a capability rift now targets 'observable'")
41
42    # GATE A - THE OBSERVER SAID NO. 'unlisted' is postured identically to
43    # 'observable'; the only difference is that the Nexus never named it.
44    # The frame's consent is irrelevant here, and note WHICH gate answers:
45    # policy is checked BEFORE posture is ever consulted.
46    try:
47        rift.create_frame_link("unlisted")
48        raise AssertionError("expected a refusal: not on the allow-list")
49    except ValueError as error:
50        assert "not allowed by Nexus policy" in str(error)
51        print("refused 'unlisted' -", error)
52        print("  same posture as 'observable' - the OBSERVER refused it")
53
54    # GATE B - THE WORLD SAID NO. 'closed-world' IS on the allow-list, so
55    # policy passes and the posture gate answers instead. Opposite party,
56    # opposite reason, and the message names which.
57    try:
58        rift.create_frame_link("closed-world")
59        raise AssertionError("expected a refusal: rift_enabled is False")
60    except ValueError as error:
61        assert "rift_enabled" in str(error)
62        print("refused 'closed-world' -", error)
63        print("  allow-listed, but never opted in - the WORLD refused it")
64
65    # A CODEGEN room raises the bar twice more: ai_native AND dynamic.
66    codegen_configuration = nexus.create_rift_configuration()
67    codegen_configuration.with_space_type("codegen")
68    codegen_rift = nexus.create_rift(configuration=codegen_configuration,
69                                     rift_name="maker")
70    codegen_rift.mark_active()
71
72    # 'observable' is rift-enabled but NOT ai-native, so codegen refuses it
73    # while capability accepted it. Same frame, different room, different
74    # answer - the posture is read against what the room can DO.
75    try:
76        codegen_rift.create_frame_link("observable")
77        raise AssertionError("expected a refusal: codegen needs ai_native")
78    except ValueError as error:
79        print()
80        print("codegen refused 'observable' -", error)
81
82    codegen_rift.create_frame_link("workshop")
83    print("codegen attached to 'workshop', which is dynamic AND ai-native")
84
85    # THE BUDGET IS NEXUS-WIDE, NOT PER RIFT. Two rifts, two different
86    # worlds, and they spent TWO of max_target_frame_count between them -
87    # which is why this lesson had to raise the cap from its default of 1
88    # even though no single rift targets more than one world.
89    print()
90    print("two rifts hold two target frames; the cap is shared, not")
91    print("per-rift - target frames are ref-counted across the Nexus")
92
93    print()
94    print("attachment is the authority boundary - checked once, there")
95    print("a frame is observable because IT said so, before it settled")
96    print("and reachable because the OBSERVER said so - both, or neither")

Runnable examples

All expert examples · Level contents · Full contents

Canonical page source