On this page

Nexus enablement๏ƒ

๐ŸŸ  Advanced ยท Lesson 08

TURNING THE NEXUS ON - and discovering that it does NOT climb the same ladder Aether does. Lesson 07 taught Aether's rule: freeze, then activate, then bring the subsystem up, in that order, or it refuses. Nexus reaches the same destination by a different route, and knowing which subsystem you are talking to is the whole lesson.

THE NEXUS PATH nexus = md.Nexus() # process-wide, no args config = nexus.create_configuration() nexus.activate(config) # installs AND finalizes nexus.is_activated -> True

THREE ASYMMETRIES WITH AETHER, ALL REAL, NONE ACCIDENTAL:

  1. THE FACTORY PRE-DEFAULTS. Aether's create_configuration() hands back a bare config and you call with_defaults() yourself. Nexus's create_configuration() applies the default property set before returning. Same verb shape, different starting state.

  2. ACTIVATE FINALIZES FOR YOU. Aether refuses a merely-frozen config and makes you call configuration.activate() first - two bits, your responsibility. Nexus.activate() finalizes the installed configuration on its way through. You do not pre-seal it, and trying to reason about it with Aether's rule in your head will mislead you.

  3. NEITHER FACTORY INSTALLS. This one they agree on, and it is worth stating because it is the part people assume: create_* is a FACTORY. It builds and hands over. Nothing is wired anywhere until you pass it to activate().

TWO BITS AGAIN, DIFFERENT NAMES nexus.is_configured - a configuration is installed nexus.is_activated - the subsystem is up Same shape as frozen/activated in lesson 07. Configuration presence and subsystem liveness are always separate questions in melder.

Before you run๏ƒ

Use the Advanced 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/03_advanced/08_nexus_enablement.py
py -3.14t UX_and_AIX_experiences/03_advanced/08_nexus_enablement.py

Download this collection ยท Source on GitHub

Public surface๏ƒ

md.Nexus, md.NexusConfiguration, create_configuration, activate, deactivate (frame mode passed as the string "single")

Code๏ƒ

  1"""
  2TIER: advanced (08)
  3GOAL: TURNING THE NEXUS ON - and discovering that it does NOT climb the
  4      same ladder Aether does. Lesson 07 taught Aether's rule: freeze,
  5      then activate, then bring the subsystem up, in that order, or it
  6      refuses. Nexus reaches the same destination by a different route,
  7      and knowing which subsystem you are talking to is the whole lesson.
  8
  9      THE NEXUS PATH
 10        nexus  = md.Nexus()                        # process-wide, no args
 11        config = nexus.create_configuration()
 12        nexus.activate(config)                       # installs AND finalizes
 13        nexus.is_activated -> True
 14
 15      THREE ASYMMETRIES WITH AETHER, ALL REAL, NONE ACCIDENTAL:
 16
 17      1. THE FACTORY PRE-DEFAULTS.
 18         Aether's create_configuration() hands back a bare config and you
 19         call with_defaults() yourself. Nexus's create_configuration()
 20         applies the default property set before returning. Same verb
 21         shape, different starting state.
 22
 23      2. ACTIVATE FINALIZES FOR YOU.
 24         Aether refuses a merely-frozen config and makes you call
 25         configuration.activate() first - two bits, your responsibility.
 26         Nexus.activate() finalizes the installed configuration on its way
 27         through. You do not pre-seal it, and trying to reason about it
 28         with Aether's rule in your head will mislead you.
 29
 30      3. NEITHER FACTORY INSTALLS.
 31         This one they agree on, and it is worth stating because it is the
 32         part people assume: create_* is a FACTORY. It builds and hands
 33         over. Nothing is wired anywhere until you pass it to activate().
 34
 35      TWO BITS AGAIN, DIFFERENT NAMES
 36        nexus.is_configured  - a configuration is installed
 37        nexus.is_activated     - the subsystem is up
 38      Same shape as frozen/activated in lesson 07. Configuration presence
 39      and subsystem liveness are always separate questions in melder.
 40SURFACE EXERCISED: md.Nexus, md.NexusConfiguration,
 41                   create_configuration, activate, deactivate
 42                   (frame mode passed as the string "single")
 43VERIFY: rides the owner's 3.14t run; asserts are the contract.
 44"""
 45import melder as md
 46
 47
 48def main() -> None:
 49    nexus = md.Nexus()
 50    print("nexus id:", nexus.id)
 51
 52    # Both bits start down. A constructed Nexus is inert.
 53    print("start - configured:", nexus.is_configured,
 54          "activated:", nexus.is_activated)
 55
 56    # THE FACTORY. New instance every call, defaults already applied, and
 57    # nothing installed onto Nexus by the act of creating it.
 58    config = nexus.create_configuration()
 59    assert isinstance(config, md.NexusConfiguration)
 60    second = nexus.create_configuration()
 61    assert second is not config, "the factory hands back a NEW config each call"
 62    print("factory: fresh pre-defaulted config, not installed")
 63
 64    # Still inert - proof that create_* did not wire anything.
 65    assert nexus.is_activated is False
 66    print("after create - activated:", nexus.is_activated)
 67
 68    # Frame mode is one of three. Pass the NAME - the setter is typed
 69    # Union[NexusFrameMode, str] and normalizes for you, so a typo is a
 70    # ValueError at the door rather than a silent default.
 71    config.with_nexus_frame_mode("single")
 72    print("frame mode set: single")
 73    print("available modes:", [mode.name for mode in md.NexusFrameMode])
 74
 75    # ACTIVATE. Installs the config and finalizes it on the way through -
 76    # note that we never called finalize() or freeze() ourselves.
 77    assert config.frozen is False, "we did not seal it; activate will"
 78    nexus.activate(config)
 79    assert nexus.is_configured is True
 80    assert nexus.is_activated is True
 81    assert config.frozen is True, "activate finalized the config for us"
 82    print("after activate - configured:", nexus.is_configured,
 83          "activated:", nexus.is_activated, "config frozen:", config.frozen)
 84
 85    # THE CONTRAST WORTH REMEMBERING. Aether would have refused this exact
 86    # sequence: it requires configuration.activate() before the subsystem
 87    # comes up, and says so in its own contract. Nexus does the sealing
 88    # itself. Two subsystems, two ladders, one codebase.
 89    print("aether: you seal and activate, THEN aether comes up")
 90    print("nexus:  you hand it over, activate seals it for you")
 91
 92    # deactivate() puts the subsystem back down. The configuration stays
 93    # installed - liveness went away, configuration did not.
 94    nexus.deactivate()
 95    assert nexus.is_activated is False
 96    assert nexus.is_configured is True
 97    print("after deactivate - configured:", nexus.is_configured,
 98          "activated:", nexus.is_activated)
 99
100    print()
101    print("create_* builds and hands over; it never installs")
102    print("configured and activated are separate questions, always")
103
104
105if __name__ == "__main__":
106    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 advanced examples ยท Level guide

API contracts๏ƒ