# Diffs are derived never stored **🔵 Expert · Lesson 04** DERIVE A DIFF, THREE WAYS, AND WATCH THE ANSWER CHANGE. Version records are full objects; "what changed" is computed on demand and never written back. "A verdict is an answer, not a fact the system remembers." A DERIVED DIFF CANNOT GO STALE, because it did not exist until you asked. That is the whole argument for storing full objects and computing comparisons - a stored diff is a second copy of the truth that can disagree with the first. THREE GRAINS SHIP, AND THEY ARE GENUINELY DIFFERENT QUESTIONS source the TEXT - a rename is enormous structural the SHAPE - a rename is invisible parts the MEMBERS - which pieces moved This lesson runs the SAME pair through all three and prints what each one concluded, because the point is not that three names exist - it is that they disagree, on purpose. TWO DEFAULTS AT TWO LAYERS, AND THIS TRIPS PEOPLE DiffEngine.diff_materials(...) defaults to "source" the codegen room's research_diff pins "structural" for a spell pair (expert 30) The engine's default is text; the room overrides it with its reasoning layer. Same family, different default, because the room knows it is answering an agent and the engine does not. THE REGISTRY IS OPEN. `register_strategy` is public surface, so "what changed" is extensible by you rather than fixed by the library - the engine is open/closed, and "adding a grain means registering a strategy, never editing this class". AND THE ENGINE NEVER REACHES INTO THE CRYSTALLIZER. It takes an injected material resolver, which is why this lesson can run the whole diff family over material it holds in its hand, with no recorded world at all. `diff()` resolves through custody; `diff_materials()` is the door for material you already have - unbound codegen output, for instance. ## 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/04_diffs_are_derived_never_stored.py ``` ```powershell py -3.14t UX_and_AIX_experiences/04_expert/04_diffs_are_derived_never_stored.py ``` {download}`Download this collection <../../downloads/expert-examples.zip>` · [Source on GitHub](https://github.com/Synaptic724/melder/blob/0895ce795453cd87e35d70665957b4e89aad3317/UX_and_AIX_experiences/04_expert/04_diffs_are_derived_never_stored.py) ## Public surface MutationResearch.create_diff_engine, DiffEngine.list_strategy_names / diff_materials, all three shipped strategies over one pair, and the KeyError an unknown grain raises ## Code ```{literalinclude} ../../downloads/04_expert/04_diffs_are_derived_never_stored.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 - [Research sets, lanes, residency, and recorded source](../../expert/research.md) ## API contracts - [MutationResearch](../../reference/api/research/mutationresearch.md) - [DiffEngine](../../reference/api/research/diffengine.md)