Cognitive units · How much world touches the call
Purity and the five levels
Purity is five engineering capabilities, not a moral virtue. Each level from sealed to acting trades predictability for reach. declare the trade on purpose.
12 min read
Cover for Purity and the five levelsTeams ask whether a cognitive unit is "pure enough" as if purity were etiquette. It is not. Purity names five capabilities you either keep or spend: evaluate in isolation, cache, re-run, know cost in advance, and replay. A sealed cognitive units has all five. Each step outward buys reach and spends predictability. The argument about whether a cognitive units should reach outside itself is usually conducted as taste, discipline versus pragmatism. Once the five capabilities are named, the argument becomes engineering: which capability are you giving up, and what are you getting for it?
Helpful context: What is a cognitive unit introduces the artifact. Judgment terrain helps decide how open the work is. What is not a cognitive unit clarifies that acting writes do not belong inside the judgment edge.
What purity buys
The first capability is evaluate in isolation. Hand a cognitive unit a hundred cases, each case consisting of arguments and nothing else. Nothing must be reconstructed. The score means what it appears to mean. The moment a cognitive unit depends on something outside its arguments, evaluation requires reproducing that something for every case, and most impure cognitive units are less well evaluated than their authors intended.
The second is cache. Same arguments, same answer. Closure becomes measurable. Cache hit rate is evidence that a class of cases has closed. The third is re-run safely. Nothing observable changes as a consequence of calling again, so sampling, retry, critic-and-revise, and cascade techniques remain available. Lose re-run and you lose the reliability toolkit, not one capability, but the mechanism that makes the others useful.
The fourth is know cost before running. One call, bounded template, measurable arguments, price is arithmetic, not observation. That is what makes cost per decision planning possible. The fifth is replay to debug. Given arguments and a recorded result, you reconstruct what happened, essential when you cannot reproduce draws from the distribution.
The cognitive unit · Ch. 7Purity is five capabilities, not a virtue.
What an impurity actually is
Every impurity moves a decision from design time to run time. When a cognitive unit is sealed, the architect chose what information it sees and how the problem decomposes, once, before cases arrive. Each reach outward hands one of those decisions to the system instead.
A reading cognitive unit decides at run time what history is relevant. A searching cognitive unit decides what it needs to know, often the hardest part of a problem. A composite cognitive unit decides at run time how to decompose via callees. An acting cognitive unit decides what to do in the world, and is no longer a cognitive unit in the architectural sense.
The trade is not discipline against convenience. You buy adaptivity with predictability. Systems whose cases share one shape can keep decisions at design time. Systems whose cases vary in shape must move some decisions to run time. Calling that a lapse of discipline is refusing to look at the problem.
The five levels
The levels are ordered by reach, not moral severity, from nothing outside arguments to observable world writes.
Level 0, Sealed. Template and arguments only. All five capabilities hold. Cost is exact. AssessMealPracticality on a single evening and candidate is the Meal Companion archetype: one judgment, bounded inputs, no tool calls.
Level 1, Composite. Calls other declared cognitive units. Still a function of arguments if every callee is sealed, loses only exact cost prediction, keeps the other four. ComposeWeek orchestrates domain cognitive units while owning one compose judgment.
Level 2, Reading. Reads injected memory, working state, endorsed knowledge, experience. Evaluation needs stubs or fixtures. Caching requires version keys on memory grants. AskTargetedQuestion needs household context to form the smallest useful question.
Level 3, Searching. Invokes read-only tools outside your system. Caching and advance cost largely lost, case shape varies at run time. This level belongs where the information needed is not knowable at design time.
Level 4, Acting. Writes observable world state: emails sent, payments posted, tickets filed. Re-run is unsafe. Acting belongs outside the cognitive unit edge in deterministic code with idempotent adapters. Logging and trace emission are fine. Alerting someone because of a log line is an effect wearing a record's clothing.
| Level | Name | Reach | Evaluate | Cache | Re-run | Cost known |
|---|---|---|---|---|---|---|
| 0 | Sealed | Arguments only | yes | yes | yes | exactly |
| 1 | Composite | Declared callees | yes | yes | yes | bounded |
| 2 | Reading | Injected memory | with stubs | if version-keyed | yes | bounded |
| 3 | Searching | Read-only tools | with fixtures | no | yes | no |
| 4 | Acting | World writes | no | no | no | no |
- 010 SealedAll five capabilities
- 021 CompositeDeclared callees
- 032 ReadingInjected memory
- 043 SearchingRead-only tools
- 054 ActingOutside cognitive unit edge
Declare the level on purpose. Accidental impurity spends predictability for nothing.
What this looks like in practice
Meal Companion cognitive units sit at different levels by design, not by accident. GenerateCandidates is typically sealed or composite, patterned generation with bounded cost. AssessMealPracticality is sealed: one evening, one candidate, arguments determine the answer. AskTargetedQuestion is reading, because it needs working-state context to know what is missing. ComposeWeek is composite, calling domain cognitive units while owning one compose judgment. None of them send email or place grocery orders. Purchase lives in deterministic code after human approval.
This matters because autonomy grants correlate with purity. Sealed cognitive units can be tried, budgeted, and composed freely. Searching and acting need tighter authority and richer evaluation, because you no longer know what will happen before run time.
Invoice exceptions show the same ladder in enterprise material: sealed tolerance comparison where policy is numeric, reading cognitive units that pull endorsed vendor history, searching where document retrieval is unavoidable, acting only in adapters after clerk approval.
Declaring level in the contract
Purity level belongs in the contract beside decides and returns, not in oral tradition. Callers and evaluators need to know which capabilities they can rely on. Accidental impurity, a sealed cognitive units that quietly calls search, spends predictability without gaining declared reach.
When case shape truly varies at run time, the architecture admits searching and pays for evaluation fixtures. When case shape is stable, the architecture keeps cognitive units sealed longer than feels fashionable. The hit rate tells you when closure is real.
Level one is cheaper than it looks
Composite cognitive units, level one, call declared callees and lose only exact cost prediction. They keep evaluate-in-isolation (with callee fixtures), cache (when callees are sealed), re-run, and replay. Teams sometimes treat composite as "impure" and avoid decomposition, running monolithic templates instead. That trades away the best of both worlds: adaptive decomposition inside a fixed compose judgment without smuggling unnamed callees.
ComposeWeek that calls GenerateCandidates and AssessMealPracticality is still one compose decision. The composite level says callers buy composition, not hidden second judgments inside one template.
Combinators spend purity deliberately
Sampling, critics, and cascades require re-run. That is why acting inside a cognitive unit edge is structurally different from searching. Searching loses cache and advance cost. Acting loses re-run entirely, and with it the combinator toolkit.
Wrappers are not impurity accidents. They are purchases of reliability at a price. The base purity level is declared first. Wrapper spend is accounted separately on costing tables.
Economics and fixture strategy
The cognitive unit book argues that purity levels make costing honest. Sealed cognitive units have arithmetic prices. Searching cognitive units need ranges, and planners should budget toward the top of the range because hard cases arrive in volume when upstream seams fail. Autonomy grants correlate with purity: try sealed cognitive units broadly, require tighter authority and richer evaluation before deploying searching profiles on consequential paths.
Fixture strategy follows from level. Sealed cognitive units need argument fixtures only. Reading cognitive units need memory stubs with version keys. Searching cognitive units need tool fixtures that simulate external responses, expensive to maintain, mandatory for honest evaluation. Budget fixture work when declaring level three. Demos were easy because nobody tested the failure path.
Sealed by default
Default new cognitive units to sealed when case shape allows. Reach outward only with declared level changes and updated evaluation fixtures. The most common purity mistake is accidental searching, a tool call added for convenience that destroys cache and cost predictability without architectural review.
GenerateCandidates may need composite decomposition internally. It does not silently become searching because someone added a web scrape "just for demos." Acting is not a fifth convenience level either. Level four belongs in deterministic adapters with idempotent design. cognitive units that send email have traded away re-run, and with it every reliability technique that makes judgment deployable at scale.
Relationship to judgment terrain and shapes
Judgment terrain asks how open and how stable work is. Purity asks how much reach a cognitive unit needs to do that work. Stable, patterned judgment on bounded inputs, like busy evening fit, stays sealed longer. Novel document interpretation may require searching from day one, with eyes open about the capabilities spent.
Terrain and purity together inform maturity moves work out: as answers stabilise, closed work moves to code. As case shape stabilises, cognitive units stay sealed. Interpreter-shaped cognitive units often stay sealed or reading. Generators may be sealed or composite. Judges are often sealed with strict grounds requirements. Searching levels appear when document retrieval is genuinely unpredictable at design time, not when a team skipped preprocessing.
Promotion and demotion
cognitive units may demote from searching to reading when preprocessing matures, canonical documents ingested, retrieval predictable. They may promote from sealed to composite when decomposition becomes valuable. Level changes are architectural events with evaluation consequences, not runtime toggles. Map each Meal Companion cognitive unit to level and shape when planning evaluation investment. Label levels on costing spreadsheets the same way you label instance types in cloud budgets.
Declare level in the contract, justify it against the five capabilities, shrink authority as reach grows, and never treat acting as a convenience. Spent predictability always buys declared reach. If you cannot name which capability you traded away, you have accidental impurity, not engineering tradeoffs.
What to do next
Review purity level when case shape, authority, or evaluation strategy changes. Ask which of the five capabilities each cognitive unit must keep for its warranty to mean anything. The level belongs in the contract and operational profile, keeping sealed cognitive units sealed unless case shape truly varies at run time. World writes and effects live outside the cognitive unit edge in deterministic code, and authority grants tighten as level rises, especially for searching and acting profiles.
Read next: Six shapes of cognitive units.