V35, composed inputs on a committed-codegen spine
The V36 vernacular core holds ALA by discipline and leans on a linter to catch drift. V35 makes the opposite bet twice over. First, instead of trusting a convention and checking it after the fact, it makes the ALA diagram a literal artifact in the repository, generates the wiring from it, commits the generated code, and fails the build the moment the code and the diagram disagree. Second, for the one coupling that quietly wrecks multi-feature LiveView pages, a feature reading another feature’s state, it changes the structure so the coupling cannot be written, and adds a detector so any attempt to sneak it back shows up.
The first bet was V30’s, an earlier variant this one grew from; V35 is that spine plus the second bet, plus calibration hoisted to the diagram. This post covers both, since V35 is where the spine lives now.
The diagram is a data file
Spray’s ALA says the diagram is the source of truth and the code is a faithful transcription of it. V35 takes that at its word. A page’s wiring lives in a Manifest: plain Elixir data, no macros, no use. Reading it answers the questions the diagram answers. Which features are on this page? Who reacts to what? What renders where?
defmodule ZeroCoupledWeb.CartPage.Manifest do
alias ZeroCoupled.Features.{CartItems, Undo, SavedItems, Wishlist, CheckoutFlow, PageUI}
alias ZeroCoupled.Features.CartItems.Facts, as: CartFacts
alias ZeroCoupled.Features.Undo.Facts, as: UndoFacts
# slot → feature (one field per feature on the page)
def features do
[cart: {CartItems, render: :render_data}, undo: Undo, saved: SavedItems,
wishlist: Wishlist, checkout: CheckoutFlow, ui: PageUI]
end
# a typed fact from one feature → a reaction on another, wired here and only here
def reactions do
[
{CartFacts.ItemRemoved, to: {:undo, Undo.Intents, :capture_removed}},
{UndoFacts.ItemRestored, to: {:cart, CartItems.Intents, :receive_item}},
{CartFacts.PromoRejected, to: {:ui, PageUI.Intents, :set_promo_error}}
]
end
def action_views, do: [index: IndexView, checkout: CheckoutView]
end
This is the whole cross-feature story of the page in one readable place. No feature calls another; a fact one feature emits is routed to a reaction on another here, in the manifest, which is the composition. And because the manifest is ordinary Elixir, a typo’d fact alias or a renamed feature module is a plain compile error, not a runtime surprise. V35’s manifest also carries a config: channel: the shipping rates, promo codes, volume tiers, gift-wrap price and undo window are data on the diagram, threaded into each feature’s init/1, so the features below hold no store-specific number.
The glue is generated, and committed
You do not hand-write the boilerplate that turns that manifest into a working page. You run mix zc.gen, and it writes generated.ex: the session struct with one field per slot, the fact-routing dispatch, the reaction runners. The generated file starts with a banner and is checked into the repository:
# ══════════════════════════════════════════════════════════════════════
# GENERATED FILE — do not edit.
# Source of truth: ZeroCoupledWeb.CartPage.Manifest (change it first, then run
# `mix zc.gen`). `mix zc.gen --check` fails the build on drift.
# ══════════════════════════════════════════════════════════════════════
defmodule ZeroCoupledWeb.CartPage.Session do
defstruct cart: nil, undo: nil, saved: nil, wishlist: nil, checkout: nil, ui: nil
def new(opts \\ []) do
struct!(__MODULE__,
cart: ZeroCoupled.Features.CartItems.init(opts),
undo: ZeroCoupled.Features.Undo.init(opts),
# ... one per slot, straight from the manifest
)
end
end
Committing generated code is a deliberate choice, and it is the interesting one. A macro would produce the same wiring at compile time, invisibly. V35 instead makes the wiring a file you can open, read, grep, set a breakpoint in, and diff in a pull request. Nothing about the page expands behind your back. The cost of that transparency is that the file can go stale, which is exactly what the next piece prevents.
CI fails on drift
The manifest is the source of truth only if the code cannot quietly disagree with it. So mix zc.gen --check regenerates each page in memory and fails if the committed file differs, and that check is wired into the test alias:
mix zc.gen # regenerate every page's generated.ex
mix zc.gen --check # fail if any committed file is stale (runs in CI)
Now the guarantee is real. You change the manifest and forget to regenerate: CI red. You hand-edit the generated file: CI red. The only green state is one where the committed glue is exactly what the diagram produces. The diagram is the source of truth because the build refuses to let it not be.
There is a sharper, information-theoretic way to say why the generated glue does not muddy the diagram. Treat the code a feature adds as a message and measure its content in bits: not the raw Shannon entropy of the source text, which only rewards terse syntax, but the conditional information of the new code given the codebase already present, estimated by a language model’s cross-entropy (its per-token log-loss, which is Shannon information in bits). Measured across the variant corpus, the manifest runs dense at about 4.01 bits per token (it is the decisions), a hand-written LiveView sits at 2.63, and the generated glue falls to 1.12 bits per token standalone and 0.44 once the generator is in its context: derivative, near-predictable, close to zero essential information. The floor is domain entropy, which is architecture-invariant, so every framework competes only on its gap to that floor and none beats it, and mix zc.gen --check is really a boilerplate detector: it certifies that the committed glue carries no information beyond the manifest.
That is the spine. The second bet is about what the features may read.
The sneaky dependency
A page like a cart has several features sharing one session: cart items, wishlist, checkout, saved items. Each feature owns a slot of the session. In V35 a feature declares its slot when it opts into the intents behaviour:
defmodule CheckoutFlow.Intents do
use ZeroCoupled.Feature.Intents, slot: :checkout
# ...
end
Now checkout needs to do something that depends on stock. The stock levels are not checkout’s data. They belong to another part of the system. The path of least resistance is to reach across and read them off the session:
# tempting, and wrong
def pay(session, _args) do
levels = session.inventory # reading a peer's slot
# ...
end
That one line is a peer dependency wearing a disguise. Nothing about it looks like a call between features, because it is not a call, it is a field access. But two sibling features now share the meaning of a third’s state. Rename or restructure the inventory slot and checkout breaks, silently, with no edge in any call graph to warn you. This is exactly the communication dependency ALA’s second rule forbids, and it is invisible to the usual tools precisely because it is data, not a call.
The fix: the composition supplies the input
ALA’s answer is that a join between peers belongs in the layer above them, the composition. So the value checkout needs does not get read by checkout. It gets resolved by the page composition and passed in:
# checkout reads only its own slot; the cross-slot value arrives as an argument
def pay(session, stock_levels) do
# session.checkout only; stock_levels came from above
# ...
end
The feature’s signature now tells the truth. pay needs stock levels, and it declares that need as a parameter. It no longer knows where stock lives or who owns it. The composition, which is allowed to know about every feature because wiring is its job, reads the inventory slot and threads the value down. The dependency did not disappear. It moved to the one place it is legitimate, and it became visible in a signature instead of hiding in a field access.
This is why the variant is called composed inputs. A feature’s inputs are composed for it from above, rather than fetched by it from the shared state.
The revised ALA Checklist adds two caveats. First, pay/2 never reads stock_levels itself. It carries it into Cart.check_ready/2, which carries it on to the stock check. That’s the shape Spray warns about when he compares ALA with functional programming: “the middle layer functions end up with extra parameters that don’t have anything to do with them, just so they can pass state data through to even lower functions” (§3.11.1). The checklist now records it as a “should” under R6, and ala_lint reports it as an advisory tramp finding (with V35’s own layer map it stays quiet, because Cart and the stock check share a layer). Second, the page resolving the value and passing it in is still the page handling data, by Spray’s §1.6.3 standard. V40 goes one step further: Checkout takes its stock source as configuration, so no one carries the levels at all.
Making it a check, not a hope
Moving the coupling is necessary but not sufficient, because the next developer can always reach across the session again. So V35 adds a detector. It walks each feature’s intents module, learns the feature’s own slot from the use line, and flags any session.<other_slot> access:
A feature’s
Intentsmodule must not read a peer slot off the session. It may read and write only its own slot. Anysession.<other_slot>access is a cross-slot read, two sibling features sharing the meaning of a third’s state, the dependency R2 forbids. The composition is where cross-slot joins belong, so it resolves the value and passes it in.
The detector runs two ways: as a Credo check in the editor and the build, and as a standalone measurement so I can score a whole codebase for cross-slot reads at once. That dual form matters. The Credo check keeps new code honest; the measurement told me the design worked, by showing the count of peer-slot reads drop to zero once the composed-inputs pattern was applied across the features.
Adding a feature, the V35 way
V35 ships a verified end-to-end walkthrough (building a “recently viewed” list, the last five products removed from the cart). Condensed, it shows what the discipline asks of you and, just as importantly, what the checkers hold you to so you do not have to remember it.
1. One feature file, four sibling modules of a standard shape. The pure module owns state and its projection ports (values shaped for rendering, never a raw domain struct). The Intents module declares the feature’s slot, owns its browser events, and holds its reactions.
defmodule ZeroCoupled.Features.RecentlyViewed do
defstruct products: []
def init(_opts), do: %__MODULE__{}
def record(%__MODULE__{} = rv, product),
do: %{rv | products: [product | Enum.reject(rv.products, &(&1.id == product.id))] |> Enum.take(5)}
# projection ports, the presentation reads these, never the struct
def render_data(%__MODULE__{products: p}), do: %{count: length(p)}
def row(p), do: %{id: p.id, product: %{thumbnail: p.thumbnail, name: p.name, amount: p.amount}}
end
defmodule ZeroCoupled.Features.RecentlyViewed.Intents do
use ZeroCoupled.Feature.Intents, slot: :recent
intent :clear_recent
def clear_recent(session, _args),
do: {put_slot(session, %RecentlyViewed{}), [Effects.stream_reset(Contracts.stream_name(:recent), [])]}
# a reaction: (own slot, payload) -> {own slot, effects}. It reads only :recent.
def track_removed(%RecentlyViewed{} = rv, %{item: item}),
do: {RecentlyViewed.record(rv, item.product), [Effects.stream_insert(Contracts.stream_name(:recent), RecentlyViewed.row(item.product), 0)]}
end
2. Name the contract. Event, stream, and hook names are declared in Web.Contracts, never written as literals in markup or emitters. That is R5 (no silent contracts) made structural: one source for a name both sides agree on. The revised checklist adds a caution. A names module used only by the page (its HEEx, handlers, and JS hooks) is fine. But features calling it, as track_removed/2 does above with Contracts.stream_name(:recent), means each feature still picks its own destination. R9 now counts that against the feature (an output never names where it goes), and R5 calls a names module shared by features a registry of global names. The fix is for the page to pass each feature its stream name as configuration, or to route the feature’s :item_removed fact to a stream insert in the manifest, as it already does for reactions.
3. Wire it in the manifest, not by a call. The feature reacts to cart removals, but it never calls the cart. The manifest routes the cart’s typed :item_removed fact to track_removed. Cross-feature effects travel as declared facts through the composition, so no feature ever names a peer.
4. Regenerate and render. mix zc.gen splices the slot, its events, and its reactions into the generated glue; zc.gen --check fails the build if the committed glue has drifted from the manifest. The view renders one call site, reading the projected render_data port, not the feature’s struct.
The payoff of all this ceremony is that the rules become checks, not memory. From the walkthrough’s own list of what the tools enforce:
A feature reads and writes only its own slot; it never reads
session.<peer>(the composition resolves cross-slot data and passes it in). Cross-feature effects go out as typed facts wired in the manifest, never a direct peer call. No literal event or stream names in markup. Presentation reads projected ports, never a domain struct.
Adding the feature above touched a feature file, the contracts module, the manifest, and one call site. The checkers held the rest: zc.gen --check, the contracts check, the purity Credo checks, a reaction-placement audit, and the full test suite all had to stay green before it counted.
That suite is not slow, despite being a whole Phoenix app. V35’s 162 tests run in about 0.8 seconds. Because the features are pure functions over their own state and the presentation reads projected ports, most of the suite exercises plain data transforms, not a LiveView process or a database. The purity that ALA asks for is the same purity that makes the tests cheap.
What it costs, and where it sits
V35 is not free. Compared to V36 it asks a developer to learn more: the slot model, the intents behaviour, the composed-inputs convention, and the detector that enforces it. On my familiarity scale it sits at 3, where V36 sits at 5. That is the trade. You spend some approachability to make a class of bug structurally impossible and mechanically caught, rather than merely discouraged.
On the compliance side the spend pays off. V35 ties for the top of my composite score across all variants. It carries the whole zero-coupled machinery (committed code generation, presentation purity, the flows channel) and adds the composed-inputs resolution of R2 on top, which lifts its encoding-adherence score to the highest in the set. When ala_lint runs against it with a layer map, it reports zero peer coupling and zero upward edges among the features, and the cross-slot detector reports zero peer-slot reads.
On the familiarity scale V35 sits at 3. The manifest is data and the features are plain modules, and “change the diagram, then regenerate” is a small idea; what costs the points are the slot model, the intents behaviour, the composed-inputs convention and the detector, each a real thing to learn. V30, the spine alone, sat at 4, and left calibration scattered in the features and some cross-boundary agreements as silent strings; those are the gaps the config: channel and typed contracts closed on the way to V35.
Which bet should you make
V35 and V36 are the same architecture viewed from two ends. Both drive feature coupling to zero; they differ in where the guarantee lives. V36 keeps the code vernacular and puts enforcement in a CI linter. V35 puts a small amount of machinery into the workflow (a data manifest and a codegen step) and gets a stronger promise in return: the diagram is not merely documented as the source of truth, it is mechanically incapable of being anything else. V36 does it by keeping features pure, returning typed outcomes, and wiring everything in a plain composition, then trusting a CI linter to catch drift. V35 does it by keeping the session-and-slots model that larger teams often already have, forbidding peer reads within it, and enforcing that with a detector built into the build.
If your team is starting fresh and prizes a design a new hire reads on day one, V36. If your team already thinks in terms of a shared session with per-feature slots and wants the peer-read foot-gun removed at the structural level, V35. Neither is more ALA than the other on the rule that matters. They differ in what they ask you to learn and in how much of the guarantee lives in the code versus in the tooling around it.
A later refinement, and what a strict lint taught me
Running ala_lint --strict on V35 later prompted one real change and a couple of instructive non-changes. The real one: the 608-line diagram compiler was split into three single-concept modules: ManifestResolver (reads the manifest into data), FlowsGenerator (the V33 flows channel), and PageGenerator (emits the page code, now depending downward on the other two). The generated output is byte-identical, the 162 tests stay green, and each generator now reads and tests in isolation. It barely moved the score, since module size is lightly weighted. That is the point. The win is readability, and the number is too coarse to see it.
The non-changes were as informative. Strict mode first reported fifteen “dead” functions; every one was a false positive: live HEEx components invoked as <.tabs/> from inside ~H template strings, a macro-generated defp, and functions called through &name/1 captures, none of which a naive AST call graph sees. That was a bug in the tool, now fixed, not debt in V35. So were most of the “pass-throughs”: the Ecto context functions are %Struct{} |> changeset() |> Repo transforms, not bare renames, and the tool now recognises the difference. What genuinely remains is a little top-layer branching, V33’s deliberate URL-and-sequencing thesis, which the linter now scores only under --super-strict, where “no logic at the top” is treated as an aspirational ideal rather than a gate. The distance from V35’s strict score to V36’s is not refactorable debt; it is the cost of carrying codegen machinery, which is exactly what V36 declines to carry.
The full checklist, by hand
Walked through every rule of the ALA Checklist with an explicit deduction per finding (the method from the V42 post), V35 scores 82 (81.5, rounded up). The first one-pass score was 90. Two findings are structural. Its features name their own destinations: about fifty stream and flash calls go through Contracts.stream_name/1, which is R9’s “must”, and it also makes Contracts a registry of names the features agree on (−3). Thirteen messages sit inside the features rather than at the page (−2). The checkout feature still reads the cart’s session slot in three places, the very peer read composed inputs was built to remove (−2). The page handlers branch on V33’s flow sequencing (−2). Then the manifest, generator and trace machinery (−2), the literals every storefront variant shares, the shared cart aggregate, and smaller items. The manifest itself is exactly what R8 asks for, and it costs nothing. The fix with the most leverage is V39’s: announce results on the features’ own ports and let the page name streams and texts.
Rescored 2026-10-01: 78. Later walks of the storefront variants found findings this one missed, in code V35 shares with them. The line-item builder writes the currency "usd" in the domain (R3, −1). The cart feature’s row says “Gift wrap ($2.99)” while the manifest configures the fee as 299, an agreement between two modules that nothing checks (R5, −1). And V35’s views and product pages decide things beyond the tab comparison already counted: comparisons, Money checks and a case on stock status in the markup (R11, −1.5). 81.5 becomes 78. On the 2026-10-01 linter, which reads templates and covers every module (the product pages and paradigms were outside the earlier layer map), it scores 91 by default, 90 under --strict and 77 under --super-strict.
Rescored 2026-10-02: 77. Two of Spray’s statements are now read strictly. A page-specific LiveComponent is a contained sub-component. Spray has “no analog of a sub-module or sub-component, no such thing as a sub-abstraction” (§2.2), and his provision for page-specific UI is layout and bindings built from domain UI abstractions (§7.14). V35 still has the FormComponent that phx.gen.live generated for its product pages (R11, −1). And Spray’s features are compositions: “Each feature creates instances of domain abstractions, configures the instances with feature specific details, and connects them together” (§2.2). The modules this variant calls Features are coded state and rules, which he would call stateful domain abstractions, so the name misleads a reader who knows his vocabulary (R8 “should”, −0.5). 78 becomes 76.5, which rounds to 77. Lint under --strict is 91: the new finding rounds away, and the same day’s linter stopped counting interpolated text in the bottom layer (a paradigm’s own messages) as product words, which removed two R3 findings.
Rescored 2026-10-03: 75. Spray’s §6.17.2 is now read strictly under R10. Checkout receives the whole cart (%Cart{}) to use three facts of it; the checklist already named that as missing R10, and every walk had passed it (−1). And the storefront’s cart, which carries promo, gift-wrap and shipping state, is the struct the portal’s order lines are built on: one use case’s data in a struct another use case shares, which Spray says an identity “should not be used as the carrier of” (−1). 76.5 becomes 74.5, which rounds to 75. Lint under --strict is 90, meeting 5 of 10 rules: the linter now scores the shared aggregate from --strict up.