# Codegen create modify iterate **🔵 Expert · Lesson 26** THE LOOP TURNED MORE THAN ONCE - AND THE TWO BOOKS IT WRITES. Expert 12 drove the codegen verbs once. This iterates them, and in doing so hits the distinction that catches everyone: a codegen room and a research record keep DIFFERENT BOOKS, and only one is about your code. THE TURN - four verbs, only two of which change anything: research_preview(code, frame_name=) what WOULD this do validate_codegen(code, frame_name=) am I permitted execute_codegen(code, frame_name=) do it materialize_codegen(code, module_name=, frame_name=) keep it Running is not keeping. `materialize` takes a module_name because durability needs an ADDRESS, and that is a separate decision from having run the code. `research_preview` is CODEGEN-ROOMS-ONLY, and that is the tell for why room types differ at all: it TAKES CODE, so it only exists where writing code is already the room's business. A codegen room owns the full 34-command research family; a capability room owns twenty-one reads; a static room none. THE TWO BOOKS THE ROOM'S what CODE was written. One record per SUCCESSFUL TOP-LEVEL public command - every command, not just codegen ones - with a call-depth counter suppressing the tree underneath each call. THE RESEARCH what VERSIONS exist. Written by `bind` (active), `bind_inactive` (staged) and a notch (promotion), and by NOTHING else. So `execute_codegen` writing a module does not mint a version. A BIND does. Cutting a lane and running three codegen turns leaves that lane EMPTY, and this lesson asserts it. AND SINGLE RESIDENCE IS WHY YOU CANNOT JUST FILE IT ELSEWHERE. One binding-signature SHA256 lives in exactly ONE lane, network wide, permanently - there is no release verb. `bind_inactive` already declared the staged version onto `default`, so `register_spell(..., lane=...)` for that id raises the REDISCOVERY signal naming the holding lane. That raise is a signal, not a failure: identical content rebinds to the same SHA, and this is the system saying "you built this before, here". The way to file it under a name is a different SET - a set is its own residence partition, so a version resident in one is simply unknown to another. ## Before you run Use the [Expert guide](../../expert/index.md) 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 ```bash python UX_and_AIX_experiences/04_expert/26_codegen_create_modify_iterate.py ``` ```powershell py -3.14t UX_and_AIX_experiences/04_expert/26_codegen_create_modify_iterate.py ``` {download}`Download this collection <../../downloads/expert-examples.zip>` · [Source on GitHub](https://github.com/Synaptic724/melder/blob/a30a754d0bb61db0b142936010cdb82cffecec6f/UX_and_AIX_experiences/04_expert/26_codegen_create_modify_iterate.py) ## Public surface CodegenCommandSystem.research_preview / validate_codegen / execute_codegen / materialize_codegen / research_create_lane / research_walk, MutationResearch.research_set / create_research_set, ResearchSet.register_spell / create_lane / walk, Conduit.bind_inactive ## Code ```{literalinclude} ../../downloads/04_expert/26_codegen_create_modify_iterate.py :language: python :linenos: ``` ## 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 expert examples](index.md) · [Level guide](../../expert/index.md) ## Related guides - [Build a working system from generated code](../../expert/codegen.md) - [Preview, stage, and governed change](../../expert/governed-change.md) ## API contracts - [Conduit](../../reference/api/resolution/conduit.md) - [MutationResearch](../../reference/api/research/mutationresearch.md) - [ResearchSet](../../reference/api/research/researchset.md)