On this page
Frame posture object๏
๐ Advanced ยท Lesson 06
THE POSTURE OBJECT ITSELF. Lesson 05 mapped the 14 knobs; this one picks the object up and handles it. The headline: this config is CONSTRUCTOR-FIRST, not fluent-first - alone among melder's configs.
Four values are REQUIRED keyword-only arguments at construction: origin_spellbook_id / system_state / ai_native_enabled / rift_enabled There is no bare AethericFrameConfiguration(). You cannot start empty and fill it in. The world's identity and mode are declared up front, and the with_* chain REFINES that declaration - it never originates it.
That is the mechanical difference between this config and SpellbookConfiguration, which you build empty and populate.
Three laws this lesson proves: 1. with_* MUTATES THIS OBJECT and returns self. It is fluent in SHAPE, not in semantics - there is no copy, ever. The frame's settlement law requires the RETAINED object to be the bound one. 2. validate() RAISES; it does not return False. The bool return is a convention, not a verdict channel. ai_native_enabled requires system_state dynamic, and violating it is an exception. 3. finalize() freezes and returns THE SAME INSTANCE - the fluent terminator. After it, every with_* refuses.
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/06_frame_posture_object.py
py -3.14t UX_and_AIX_experiences/03_advanced/06_frame_posture_object.py
Public surface๏
md.AethericFrameConfiguration (system_state passed as the string "automatic" / "dynamic")
Code๏
1"""
2TIER: advanced (06)
3GOAL: THE POSTURE OBJECT ITSELF. Lesson 05 mapped the 14 knobs; this one
4 picks the object up and handles it. The headline: this config is
5 CONSTRUCTOR-FIRST, not fluent-first - alone among melder's configs.
6
7 Four values are REQUIRED keyword-only arguments at construction:
8 origin_spellbook_id / system_state / ai_native_enabled / rift_enabled
9 There is no bare AethericFrameConfiguration(). You cannot start empty
10 and fill it in. The world's identity and mode are declared up front,
11 and the with_* chain REFINES that declaration - it never originates it.
12
13 That is the mechanical difference between this config and
14 SpellbookConfiguration, which you build empty and populate.
15
16 Three laws this lesson proves:
17 1. with_* MUTATES THIS OBJECT and returns self. It is fluent in
18 SHAPE, not in semantics - there is no copy, ever. The frame's
19 settlement law requires the RETAINED object to be the bound one.
20 2. validate() RAISES; it does not return False. The bool return is
21 a convention, not a verdict channel. ai_native_enabled requires
22 system_state dynamic, and violating it is an exception.
23 3. finalize() freezes and returns THE SAME INSTANCE - the fluent
24 terminator. After it, every with_* refuses.
25SURFACE EXERCISED: md.AethericFrameConfiguration (system_state passed as
26 the string "automatic" / "dynamic")
27VERIFY: rides the owner's 3.14t run; asserts are the contract.
28
29RESOLVED FINDING (init surface): this type is exported from the public root
30and still CANNOT BE INSTALLED from it. Spellbook.__init__ accepts
31(aetheric_frame, configuration, logger) - `configuration` is a
32SpellbookConfiguration, not this. Every path that reaches the live frame
33posture is private (_initialize_aetheric_frame_configuration,
34_bind_aetheric_frame_configuration_to_aether).
35
36That used to mean the posture was unauthorable: the one public door,
37Spellbook.configure_aether_frame(...), carried TWO of the 14 knobs, and the
38other 12 - rift_enabled and ai_native among them - could not be set from the
39public root at all. Since rift_enabled defaults False and gates EVERY Rift
40attachment, the public package could not configure a frame to host one.
41
42THE DOOR WAS WIDENED, NOT THE OBJECT EXPOSED (2026-08-03). All 14 knobs are
43now parameters of configure_aether_frame; the collaborator stays private.
44That is deliberate and it is the same rule that keeps Scan, SpellOverrider
45and the crystal loaders off the root: when a facade covers a collaborator,
46the facade is the surface, and the fix for a missing capability is to widen
47the door rather than hand out the object behind it.
48
49So this object stays READ-SHAPED BY DESIGN: construct one to understand the
50law book, as this lesson does. To AUTHOR a world's posture, use lesson 03's
51door - it now reaches everything.
52"""
53import melder as md
54
55
56def main() -> None:
57 # 1. CONSTRUCTOR-FIRST. All four are keyword-only and REQUIRED.
58 # `origin_spellbook_id=None` is legitimate: an unattached posture has
59 # no owning book yet. It gets attributed at freeze time by the frame.
60 posture = md.AethericFrameConfiguration(
61 origin_spellbook_id=None,
62 system_state="automatic",
63 ai_native_enabled=False,
64 rift_enabled=False,
65 )
66 # The property hands back a SystemState member, not the string you
67 # passed - normalization happens at the door. `.name` is the string
68 # form; `.value` is an int, because SystemState is built on auto()
69 # (see lesson 16 for why that trips people).
70 print("constructed:", posture.system_state)
71 assert isinstance(posture.system_state, md.SystemState)
72 assert posture.system_state.name == "automatic"
73 assert posture.ai_native_enabled is False
74 assert posture.rift_enabled is False
75
76 # 2. with_* MUTATES AND RETURNS SELF. Not a copy. Prove it by identity,
77 # because "fluent" in most libraries means "returns a new one" and
78 # here it does not - and the difference is load-bearing.
79 same = posture.with_system_caching_enabled(False)
80 assert same is posture, "with_* must return THIS object, not a clone"
81 assert posture.system_caching_enabled is False
82 print("with_* returned the same instance:", same is posture)
83
84 # 3. validate() RAISES. It does not hand back a False for you to ignore.
85 # ai_native_enabled without dynamic is the semantic rule it enforces.
86 posture.with_ai_native(True)
87 try:
88 posture.validate()
89 raise AssertionError("expected ValueError: ai_native needs dynamic")
90 except ValueError as error:
91 print("validate refused:", error)
92
93 # Satisfy the rule the honest way - move the world to dynamic.
94 posture.with_system_state("dynamic")
95 assert posture.validate() is True
96 print("validate passed once the state matched the capability")
97
98 # 4. PRESETS are methods that set several knobs at once, and they follow
99 # the same mutate-and-return-self law.
100 preset = md.AethericFrameConfiguration(
101 origin_spellbook_id=None,
102 system_state="automatic",
103 ai_native_enabled=False,
104 rift_enabled=False,
105 )
106 assert preset.dynamic_defaults() is preset
107 assert preset.system_state.name == "dynamic"
108 print("dynamic_defaults() set the mode and returned self")
109
110 # 5. finalize() - the fluent terminator. Freezes, returns THIS instance.
111 # A cloning finalize would be actively harmful here: the settlement
112 # law requires the RETAINED posture object to be the one that binds.
113 finalized = posture.finalize()
114 assert finalized is posture, "finalize must not clone the posture"
115 print("finalize returned the same instance:", finalized is posture)
116
117 # 6. THE FREEZE LAW. One world, one law book, decided before first use.
118 try:
119 posture.with_system_state("automatic")
120 raise AssertionError("expected RuntimeError on a frozen posture")
121 except RuntimeError as error:
122 print("frozen posture refused the edit:", error)
123
124 # The values survive the freeze - it seals, it does not clear.
125 assert posture.system_state.name == "dynamic"
126 assert posture.ai_native_enabled is True
127
128 print()
129 print("constructor-first: 4 required values, declared not discovered")
130 print("with_* refines the declaration and always returns THIS object")
131 print("validate raises; finalize seals; the sealed object is the bound one")
132
133
134if __name__ == "__main__":
135 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.