On this page
Several worlds of record in one process๏
๐ต Expert ยท Lesson 34
KEEP TWO SEPARATE WORLDS OF RECORD IN ONE PROCESS. Every lesson so far has recorded into one nameless place. It has a name - "default" - and you can have others.
A PROFILE IS WHERE EMISSIONS LAND. Twins accumulate into the active profile, and unqualified operations resolve to it. Two profiles are two separate bodies of recorded content in one running process: a staging record and a production one, or one per tenant, or a throwaway you clear between experiments.
BUT A PROFILE IS NOT A PRIVATE LEDGER, AND THIS IS THE THING TO GET RIGHT. create_checkpoint snapshots ONE profile's window and advances THAT profile's journal mark - the content is partitioned. list_checkpoint_ids() returns "all checkpoint ids in exact ledger creation order" for the PROCESS. Switching profiles does not give you a filtered view and does not hide anyone else's seals. Same shelf, different boxes. Assume otherwise and you will write an assertion that fails - this lesson's author did exactly that.
YOU CREATE WORLDS BY NAME AND NOTHING ELSE. The facade says so outright: "users and agents create worlds by name only; PersistenceProfile objects never escape the depths." You never hold the profile object, so there is nothing to pass around, alias, or accidentally keep alive - the name IS the handle. That is worth contrasting with a surface that does NOT do this: the ACL authoring chain hands you internal builders and is marked "do not drive it directly". Here the internal object is kept buried and you are given a name. Same codebase, two answers, and the one you get tells you whether a surface is finished.
SWITCHING MOVES A POINTER. NOTHING ELSE. set_active_profile "moves the pointer only - no data is copied or migrated between profiles". Nothing is merged, nothing is duplicated, and the profile you left keeps exactly what it had. If you expected a switch to bring your checkpoints along, this is the sentence that saves you.
CLEAR AND DELETE ARE DIFFERENT VERBS ON PURPOSE clear_profile EMPTIES it and KEEPS it - still listed, still activatable. The non-destructive reset. delete_profile REMOVES it. The name stops appearing in list_profile_names(). And "default" is NEVER DELETABLE - it is the guaranteed landing place, the same shape of law as the default research lane that never archives (expert 31). Every system needs one thing that cannot be removed, or its own fallbacks have nowhere to fall.
ALL OF IT REQUIRES AN ACTIVATED CRYSTALLIZER, and the refusal is the point: "a configured-but-not-activated crystallizer raises rather than silently no-opping. Recording is opt-in and this is where that shows up." A world that quietly recorded nothing would be worse than one that refused.
Before you run๏
Use the Expert 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/04_expert/34_several_worlds_of_record_in_one_process.py
py -3.14t UX_and_AIX_experiences/04_expert/34_several_worlds_of_record_in_one_process.py
Public surface๏
Crystallizer.active_profile_name / create_profile / set_active_profile / list_profile_names / describe_profile / clear_profile / delete_profile, with create_checkpoint proving the partition is real
Code๏
1"""
2TIER: expert (34)
3GOAL: KEEP TWO SEPARATE WORLDS OF RECORD IN ONE PROCESS. Every lesson so
4 far has recorded into one nameless place. It has a name - "default"
5 - and you can have others.
6
7 A PROFILE IS WHERE EMISSIONS LAND. Twins accumulate into the active
8 profile, and unqualified operations resolve to it. Two profiles are
9 two separate bodies of recorded content in one running process: a
10 staging record and a production one, or one per tenant, or a
11 throwaway you clear between experiments.
12
13 BUT A PROFILE IS NOT A PRIVATE LEDGER, AND THIS IS THE THING TO GET
14 RIGHT. `create_checkpoint` snapshots ONE profile's window and
15 advances THAT profile's journal mark - the content is partitioned.
16 `list_checkpoint_ids()` returns "all checkpoint ids in exact ledger
17 creation order" for the PROCESS. Switching profiles does not give
18 you a filtered view and does not hide anyone else's seals.
19 Same shelf, different boxes. Assume otherwise and you will write an
20 assertion that fails - this lesson's author did exactly that.
21
22 YOU CREATE WORLDS BY NAME AND NOTHING ELSE. The facade says so
23 outright: "users and agents create worlds by name only;
24 PersistenceProfile objects never escape the depths." You never hold
25 the profile object, so there is nothing to pass around, alias, or
26 accidentally keep alive - the name IS the handle.
27 That is worth contrasting with a surface that does NOT do this: the
28 ACL authoring chain hands you internal builders and is marked
29 "do not drive it directly". Here the internal object is kept buried
30 and you are given a name. Same codebase, two answers, and the one
31 you get tells you whether a surface is finished.
32
33 SWITCHING MOVES A POINTER. NOTHING ELSE.
34 `set_active_profile` "moves the pointer only - no data is copied or
35 migrated between profiles". Nothing is merged, nothing is
36 duplicated, and the profile you left keeps exactly what it had. If
37 you expected a switch to bring your checkpoints along, this is the
38 sentence that saves you.
39
40 CLEAR AND DELETE ARE DIFFERENT VERBS ON PURPOSE
41 clear_profile EMPTIES it and KEEPS it - still listed, still
42 activatable. The non-destructive reset.
43 delete_profile REMOVES it. The name stops appearing in
44 list_profile_names().
45 And "default" is NEVER DELETABLE - it is the guaranteed landing
46 place, the same shape of law as the default research lane that never
47 archives (expert 31). Every system needs one thing that cannot be
48 removed, or its own fallbacks have nowhere to fall.
49
50 ALL OF IT REQUIRES AN ACTIVATED CRYSTALLIZER, and the refusal is the
51 point: "a configured-but-not-activated crystallizer raises rather
52 than silently no-opping. Recording is opt-in and this is where that
53 shows up." A world that quietly recorded nothing would be worse than
54 one that refused.
55SURFACE EXERCISED: Crystallizer.active_profile_name / create_profile /
56 set_active_profile / list_profile_names /
57 describe_profile / clear_profile / delete_profile,
58 with create_checkpoint proving the partition is real
59VERIFY: authored 2026-08-05; not yet run.
60"""
61import melder as md
62
63
64FRAME = "profile-world"
65
66
67class Ledger:
68 def __init__(self) -> None:
69 self.entries: list[str] = []
70
71
72def main() -> None:
73 crystallizer = md.Crystallizer()
74
75 # RECORDING IS OPT-IN, and asking a configured-but-inactive
76 # crystallizer about profiles REFUSES rather than answering emptily.
77 try:
78 crystallizer.list_profile_names()
79 raise AssertionError("expected a refusal before activation")
80 except RuntimeError as inactive:
81 print("profiles before activation ->", str(inactive)[:88])
82 print(" a world that quietly recorded nothing would be worse")
83 print(" than one that refused")
84
85 crystallizer.activate(
86 md.CrystallizerConfigurationBuilder().with_defaults().activate(),
87 )
88
89 # THE ONE YOU HAVE ALREADY BEEN USING HAS A NAME.
90 assert crystallizer.active_profile_name == "default"
91 assert "default" in crystallizer.list_profile_names()
92 print()
93 print("active profile:", crystallizer.active_profile_name)
94 print(" every earlier lesson recorded here without naming it")
95
96 # A WORLD WORTH RECORDING.
97 spellbook_configuration = (
98 md.SpellbookConfiguration(FRAME).with_defaults().finalize()
99 )
100 book = md.Spellbook(aetheric_frame=FRAME,
101 configuration=spellbook_configuration)
102 book.configure_aether_frame(
103 system_state="dynamic",
104 disposal=None,
105 disposal_method_names=None,
106 rift_enabled=True,
107 ai_native=True,
108 )
109 book.bind(spell=Ledger, existence="unique", permissions="create",
110 binding_name="profile-ledger")
111 book.conjure(name="profile-root")
112
113 on_default = crystallizer.create_checkpoint()
114 print()
115 print("sealed a checkpoint on 'default':", on_default[:14], "...")
116
117 # A SECOND WORLD OF RECORD, BY NAME. No object is handed back.
118 crystallizer.create_profile("staging")
119 assert crystallizer.active_profile_name == "staging", (
120 "create_profile activates by default"
121 )
122 assert set(crystallizer.list_profile_names()) >= {"default", "staging"}
123 print()
124 print("create_profile('staging') -> active is now:",
125 crystallizer.active_profile_name)
126 print(" it returned None. The NAME is the handle; the profile object")
127 print(" never escapes the depths, so there is nothing to alias or")
128 print(" accidentally keep alive")
129
130 # AND HERE IS THE LINE PEOPLE GET WRONG, INCLUDING THE AUTHOR OF THIS
131 # LESSON ON THE FIRST TRY. A profile decides what a checkpoint
132 # CONTAINS. It does not give you a private ledger.
133 on_staging = crystallizer.create_checkpoint()
134 everything = crystallizer.list_checkpoint_ids()
135 assert on_staging in everything
136 assert on_default in everything, (
137 "list_checkpoint_ids returns ALL ids - the ledger is process-wide"
138 )
139 print("sealed a checkpoint on 'staging':", on_staging[:14], "...")
140 print()
141 print("list_checkpoint_ids() ->", len(everything), "ids, and BOTH are")
142 print(" here. Its contract says `all checkpoint ids in exact ledger")
143 print(" creation order` - one ledger for the process. Switching")
144 print(" profiles does not hand you a private one.")
145 print(" What the profile partitions is the CONTENT: create_checkpoint")
146 print(" snapshots ONE profile's twin window and advances THAT")
147 print(" profile's journal mark. Same shelf, different boxes.")
148
149 # SWITCHING MOVES A POINTER AND NOTHING ELSE - including not moving
150 # the ledger, which is why both ids are still listed below.
151 crystallizer.set_active_profile("default")
152 assert crystallizer.active_profile_name == "default"
153 after_switch = crystallizer.list_checkpoint_ids()
154 assert set(after_switch) == set(everything), (
155 "the switch moves a pointer; it does not copy, migrate or hide"
156 )
157 print()
158 print("set_active_profile('default') -> the ledger is unchanged:",
159 set(after_switch) == set(everything))
160 print(" `moves the pointer only - no data is copied or migrated`")
161 print(" cuts both ways: nothing follows you, and nothing is taken")
162
163 # YOU CAN ALSO NAME THE PROFILE EXPLICITLY rather than switching to
164 # it - the argument is there so a caller never has to move the
165 # pointer just to seal somewhere.
166 targeted = crystallizer.create_checkpoint(profile_name="staging")
167 assert crystallizer.active_profile_name == "default", (
168 "checkpointing another profile must not move the active pointer"
169 )
170 print()
171 print("create_checkpoint(profile_name='staging') ->", targeted[:14],
172 "... and the active profile is still",
173 crystallizer.active_profile_name)
174
175 # DESCRIBE READS THE ACTIVE ONE WHEN YOU NAME NOTHING - and this is
176 # where the CONTENT partition is visible, since the ledger read is
177 # not. `describe_profile` reports per-level twin counts and the
178 # emission sequence for ONE profile.
179 active_view = crystallizer.describe_profile()
180 default_view = crystallizer.describe_profile("default")
181 staging_view = crystallizer.describe_profile("staging")
182 assert isinstance(active_view, dict)
183 assert active_view == default_view, (
184 "None must resolve to the ACTIVE profile, which is 'default' here"
185 )
186 print()
187 print("describe_profile() -> the ACTIVE one (keys:",
188 "%s)" % sorted(active_view)[:4])
189 print("describe_profile('staging') -> that one (keys:",
190 "%s)" % sorted(staging_view)[:4])
191 print(" None means ACTIVE, not `all profiles` - proven by the two")
192 print(" reads above being equal while 'default' is active")
193 print(" and THIS is where the partition shows: per-profile twin")
194 print(" counts and emission sequence, not the shared ledger")
195
196 # CLEAR EMPTIES AND KEEPS. DELETE REMOVES.
197 crystallizer.clear_profile("staging")
198 assert "staging" in crystallizer.list_profile_names(), (
199 "clear is the NON-destructive reset - the profile survives"
200 )
201 print()
202 print("clear_profile('staging') -> still listed:",
203 "staging" in crystallizer.list_profile_names())
204
205 crystallizer.delete_profile("staging")
206 assert "staging" not in crystallizer.list_profile_names()
207 print("delete_profile('staging') -> still listed:",
208 "staging" in crystallizer.list_profile_names())
209 print(" two verbs because emptying a world and removing it are")
210 print(" different intentions, and one of them is recoverable")
211
212 # AND THE DEFAULT IS NEVER DELETABLE.
213 try:
214 crystallizer.delete_profile("default")
215 raise AssertionError("expected a refusal: default is guaranteed")
216 except ValueError as refusal:
217 print()
218 print("delete_profile('default') refused -", str(refusal)[:80])
219 print(" the same shape of law as the default research lane that")
220 print(" never archives: every system needs one thing that cannot")
221 print(" be removed, or its own fallbacks have nowhere to fall")
222
223 print()
224 print("one process, several records, and you addressed them by name")
225
226
227if __name__ == "__main__":
228 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.