V41, feature components: ALA in the shape phx.gen.live already gives you
V39 puts the design in a map and V40 in a circuit. Both score well on the ALA Checklist and both ask a Phoenix developer to learn a small vocabulary before reading a page. V41 asks the other question: what is the highest checklist score reachable in a shape Phoenix developers already write, the one phx.gen.live generates, where a LiveComponent owns a piece of the page and tells its parent what happened?
A feature and its instance
The pure feature modules are V39’s, unchanged: step(state, payload) :: {state, [{port, payload}]}, no Phoenix. Each feature gains a Panel, a LiveComponent in the same feature unit. A panel is configured by attributes, loads its own rows from the store on first update/2, handles its own events with phx-target={@myself}, runs a feature step, and lands each output it shows:
def handle_event("remove_item", %{"item-id" => id}, s),
do: {:noreply, step(s, &Cart.remove(&1, %{item_id: int(id)}))}
defp wire(s, {:rows, {:removed, row}}), do: stream_delete(s, :cart_items, row)
defp wire(s, {:summary, summary} = out), do: s |> assign(summary: summary) |> Instance.send_port_output(:cart, out)
defp wire(s, {:persist, change}), do: (Carts.apply_change(change); s)
defp wire(s, out), do: Instance.send_port_output(s, :cart, out)
The last clause is the whole idea. Anything the panel does not wire itself is sent to the page that placed it, as a port output {:cart, port, payload}. Instance is eighteen lines: step/3 and send_port_output/3 (first named announce/3). There is no Binder, no circuit, no protocol.
The page routes
The page’s template places the instances and configures them, with every price, window and message text as an attribute. Its handle_info clauses pass each announcement on to the instance it concerns and say what happened:
def handle_info({:cart, :removed, item}, socket), do: {:noreply, pass(socket, Undo.Banner, "undo", capture: item)}
def handle_info({:undo, :restored, item}, socket),
do: {:noreply, socket |> pass(Cart.Panel, "cart", receive: item) |> put_flash(:info, "Item restored")}
def handle_info({:wishlist, :taken, product}, socket),
do: {:noreply, socket |> pass(Cart.Panel, "cart", add_product: product) |> put_flash(:info, "Added to cart")}
pass/4 is send_update. The cart page has two handle_event clauses (the tabs and the checkout button) and about twenty of these. Read together they are the requirements, one wire per line, though not one table the way V39’s map is.
What building it settled
The toy version of this shape held feature logic inside the components. At nine features that would have been logic trapped in LiveView, so V41 keeps the pure modules and the panels only land outputs. Two LiveView facts shaped the rest. push_patch is not allowed inside update/2, so a flow panel announces its step and the page moves the URL, which put the step-to-path table next to the calibration where the checklist wants it anyway. And send_update to an unmounted component raises, so the cart page keeps its index instances mounted, hidden, behind the checkout screen; nothing announced while paying is lost and going back is instant, at the cost of a hidden subtree.
The linter caught one real layering mistake: the panels, which are feature-layer, were importing a row component that lived in the web namespace, an upward reference. The rows moved down to the catalog domain, where generic markup that takes its event names as attributes belongs.
Hops are where V41 differs from V40 in practice. A panel’s own actions, quantity, remove, promo, shipping, the address form, pay, render synchronously. Only a cross-feature effect takes two messages, panel to page to panel, and the tests settle for those.
What the linter said
ala_lint scores V41 at 98 by default, 97 under --strict and 97 under --super-strict (re-scored 2026-09-30), with no R1 or R11 finding on either page (on that day’s linter, which didn’t read templates; see the 2026-10-01 rescore below). Since R11 learned to see for loops and nested hand-offs, V41 is the only one of the three at zero: V39 and V40 keep order placement in page helpers (95 under --super-strict), where V41 moved it into its checkout panel. Otherwise the linter separates V39, V40 and V41 by a point or two at most. What separates them is what it cannot see: V39 reads as one map, V40 pays two hops for every click, and V41 pays them only across features while being the shape a Phoenix team already knows. If I were introducing ALA to such a team, V41 is the one I would show first.
Revised: V41 with the best of the other variants (2026-09-30)
After V39, V40 and V41, I sketched a consolidated design, V44, meant to keep V41’s familiar shape and add the ideas from other variants that cost no familiarity. Most of its changes could be made to V41 in place, so I made them there rather than starting another variant:
- Domain configured once, configuration first.
CalculateShipping,ValidatePromo,CalculateGiftWrapCostandVolumeTierbecame structs the page builds once (CalculateShipping.new(@rates)) and every call passes first. The cart aggregate holds those instances instead of a config map it picked apart. That’s the checklist’s R9 “should”, from Spray’s §3.9. - Store work in domain abstractions.
PlaceOrder(create the order, take the stock, announce each new level) andAddLinereplaced the loop in the checkout panel, the order call in the portal, and a helper two panels had copied. - Stores as configuration. Panels stopped naming
Carts,ProductsandOrders; the page passes them in. - Declared ports. Every feature has
ports/0, and every panelsent_port_outputs/0. - No catch-all
handle_info. A test sends every announced port to each page and fails on a missing clause. - The checkout button is disabled by the cart’s announced
empty?, not by a comparison in the template.
ala_lint still scores V41 at 98 by default, 97 under --strict and 97 under --super-strict, with 83 tests passing (80 before). The linter already found nothing on these pages, so the gain is in what it can’t see. One detour is worth recording. My first version put the pricing instances behind a Pricing façade, and four of its functions turned out to be pure pass-throughs; --strict dropped to 96 until I removed it. Configuring once doesn’t need a wrapper around the configured things.
Re-scored 2026-10-01, after the linter learned to read templates, with a layer map that covers every module: 95 by default, 94 under --strict, 89 under --super-strict. The R11 findings (16) are the tab and step comparisons and a tab loop in the pages’ markup, plus the product pages’ template logic, the same ones the full walk counts. The new ui_io check reports the four panels that load and save through a store, the R6 finding below. R3 now counts the words held in the panels and row components, which V41-max moved to the page.
Did the changes cost anything distinctive?
Not all of them are clear wins. Taking them one at a time:
PlaceOrderandAddLine: clearly better. The same stock loop existed in V40’s page and V41’s checkout panel, and the same “write a line, then look it up” helper in two panels. Now each is one tested abstraction, and it’s Spray’s placement of I/O: the abstraction does its own, as hisDisplaywrites to the screen.- The disabled button: clearly better, and trivial.
- Declared ports: better, with upkeep. The coverage test found a mistake on its first run: the cart panel declared a port it can never announce. But
sent_port_outputs/0restates what the panel’swire/2clauses already say, and nothing checks that the two agree. - Configuring once: better, modestly. The aggregate no longer knows the shape of each rule’s configuration. In exchange, the page now names four domain modules to build the instances, and one of the linter’s R6 heuristics now calls
CalculateGiftWrapCost“a wrapper around multiplication”, which it is, with a name. - Stores as configuration: a real trade. V41’s pitch was that a panel owns its store writes: drop it into a page and it works. Now every
live_componentcall carries its stores, and because the panel callsstore.list_items(id)on a module it was handed, neither the compiler’s cross-reference nor the linter sees that edge any more. It’s more ALA (no instance names its own endpoints), and less self-contained. I kept it, but a team that values drop-in panels could fairly undo it. - No catch-all: safer in development, stricter in production. V41’s catch-all quietly absorbed
ProductSaved, a broadcast on the shared storefront topic the cart page doesn’t care about. Without it, each page has to list and ignore every fact it doesn’t use, and the day someone adds a new fact to that topic, every page subscribed to it crashes until it gets a clause. The coverage test catches that only if it’s told about the new fact. The catch-all was tolerant; its replacement is explicit. For a team that runs the test suite on every change, explicit is better. For one that doesn’t, the catch-all was the safer default.
So four of the six are clear or modest improvements, and two change V41’s character. Panels are no longer self-contained, and the page is no longer tolerant of messages it doesn’t expect. Neither costs familiarity; both cost something V41 was good at.
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), revised V41 scores 92, the highest of V39–V42. It has no page helpers and no closures, and only cross-feature effects take a hop (−0.5). Its deductions: screen labels and messages inside the feature panels, below the composition (−1); cross-feature wiring spread over handle_info clauses rather than one value, though a test now checks every announcement is routed (−1); and the findings the whole family shares, a baked low-stock threshold, the rate table written once per page, the shared cart aggregate and a few smaller items (−6). Without the revision it would be about 90.
Rescored 2026-10-01: 89. Walking the max variants turned up findings this walk missed, all in code V41 still has. The line-item builder writes the currency "usd" in the domain (R3, −1). Words sit below the composition in more places than the panels: the Cart feature builds “free over $50.00”, the address and PO schemas carry their validation messages, and the shared row components hold their labels. That makes the earlier R3 finding structural (−1 more). The label “Gift wrap ($2.99)” restates the page’s @gift_wrap_unit 299 (R5, −0.5). And the product pages’ templates decide things: a case on stock status and comparisons on live_action (R11, −0.5 beyond the tab comparison already counted). That’s −3 more: 91.5 becomes 88.5, which rounds to 89. V41-max fixes all of them.
Rescored 2026-10-02: 87. 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). V41’s feature panels aren’t deducted for it: they take their words and rules from the page, so they read as stateful domain UI abstractions. The generated FormComponent is (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). 88 becomes 86.5, which rounds to 87. Lint under --strict goes from 94 to 93.
Rescored 2026-10-02 (later): 86. Building V49 found a contract every walk had missed. Each panel names itself in its own code (Instance.send_port_output(s, :cart, out)), and the page’s clauses must match that :cart. Two modules agreeing on a literal is a silent contract (R5, −1). A panel should send under a name the page gives it, as V49’s do. 86.5 becomes 85.5, which rounds to 86.
Rescored 2026-10-03: 84. 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). 85.5 becomes 83.5, which rounds to 84. Lint under --strict is 93, meeting 4 of 10 rules: the linter now scores the shared aggregate from --strict up.
R8 settled, 2026-10-01: 90. The walk’s −1 for wiring “spread over handle_info clauses rather than one value” doesn’t stand. The checklist now says plainly that wiring written as function clauses in one module meets R8: they’re one place, which is what Spray asks for (§3.3.1), and a wiring value is a technique for inspection and safety, not a requirement. V41’s cross-feature wiring is all in its page module. With the point back, 88.5 becomes 89.5, which rounds to 90.
R6 rescored, 2026-10-01: 88. Each panel bundles four concepts in one LiveComponent: the feature’s state and logic, its display, its event decoding, and saving and loading through the store (the checkout and submit panels also take payment and place orders). Spray keeps a UI element that displays data apart from the data source it’s wired to (§5.2.2), so a UI component that persists is a composition hidden inside one module, not one abstraction (R6, structural, −2). 89.5 becomes 87.5, which rounds to 88. A slot-split toy shows the fix: a generic host for the feature, page-owned markup passed in through slots, and the store wired by the page.
The code is in ala_variants_elixir/v41-feature-components.
V41-max is V41 changed until the full walk finds nothing to deduct but the hop, at 100, with its panels’ I/O wired at the page.