V41-max: feature components at 100

September 30, 2026 · ALA · V41 · LiveView · LiveComponent · checklist

This is the first of three posts on the “max” variants. Each takes an existing design and changes it, in a copy, until a hand walk of the ALA Checklist finds nothing left to deduct. The other two are V39-max and V38-max. The question behind all three: if one design can reach 100, what does it cost, and does it stay the design it was?

V41 was the obvious place to start. It had the fewest deductions of the storefront variants (92 on the full walk as first published, 90 after the rescores below), none of them structural. It’s also the shape Phoenix developers already write: each feature is a LiveComponent that holds its own state, renders itself and handles its own events, and the page places and configures the instances.

What it took

The changes were mostly small. Grouped by the rule each one answers:

One route table per page

Revised V41 wired cross-feature effects with a handle_info clause per port output, nineteen on the cart page. The first walk counted that against R8, as wiring “spread across clauses” rather than held in one place. Spray’s point is that connections “are typically cohesive, and belong in one place” (§3.3.1). V41-max replaces the clauses with a map:

@routes %{
  {:cart, :removed} => [pass: {Undo.Banner, "undo", :capture}],
  {:cart, :line} => [pass: {Wishlist.Panel, "wishlist", :toggle}],
  {:undo, :restored} => [pass: {Cart.Panel, "cart", :receive}, flash: {:info, "Item restored"}],
  {:checkout, :blocked} => [flash_by: {:error, @blocked}],
  {:checkout, :step} => [patch: @step_paths],
  {:stock, :changed} => [pass: {Cart.Panel, "cart", :set_stock}]
}

def handle_info({_name, _port, _payload} = port_output, socket),
  do: {:noreply, Instance.route(socket, @routes, port_output)}

Settled 2026-10-01: clauses in one module are already one place, so they meet R8, and V41’s −1 was dropped (V41 is now 90). The route table didn’t buy V41-max a point. What it buys is a value you can print and check by key, at the cost of one more idea to learn. V41-max would score 100 (99.5) with plain clauses too.

A route target is one of five kinds: pass to another instance’s input, assign, flash, flash by a lookup, or patch the URL. The whole Instance module, routing included, is 45 lines of paradigm code with nothing about this app in it. There is still no catch-all clause, and a test sends every port each panel announces to the page and fails if one isn’t routed.

What the walk found that earlier walks missed

Walking the other two max variants turned up four findings in code V41 shares with V39, so V41-max carried them too. The words “free over $50.00” were built inside the Cart feature. The address and PO forms’ validation messages were written in the features. The line-item builder wrote the currency "usd". The gift-wrap label repeated the fee. All four are fixed here. They also mean V41’s published 92 was generous: rescored with these and a template finding in the product pages, it’s 89, and 90 once R8 was settled for clause wiring.

Techniques, with code

Each technique below is described under its rule in the ALA Checklist and the field guide.

Every word from the page (R3). The page keeps its words in one map, merges in the ones the store shares, and hands each panel its part. Panels render @t.*, never a literal.

@texts %{cart: %{discount: "Discount", row: %{save: "Save for later", each: " each"}}, ...}
defp texts, do: update_in(@texts, [:cart], &Map.merge(&1, StoreConfig.summary_texts()))

<.live_component module={Cart.Panel} id="cart" t={@texts.cart} ... />

Form messages as configuration (R3). The checkout panel builds its feature with the messages the page passes:

Checkout.new(flow: a.flow, stock_levels: a.stock_levels, line_items: a.line_items, messages: a.messages)
|> validate_format(:postal_code, ~r/^\d{4,10}$/, message: messages.postal_code)   # in the schema

Values, not words (R3). The Cart feature projects each shipping option as money; the panel writes the sentence:

{opt.cost}<span :if={opt.free_above}> ({@t.free_over} {opt.free_above})</span>

One application module for store-wide literals (R3, R5). StoreConfig holds the rates, the low-stock level, the undo window, the currency and the shared words; CartSession holds the session keys. Both pages read them.

A label derived from its value (R5).

put_in(texts, [:cart, :gift_wrap_label], "Gift wrap (#{Money.new(@gift_wrap_unit)})")

Sent port outputs derived from ports (R7).

@wired_here [:rows]
def sent_port_outputs, do: Keyword.keys(Cart.ports().out) -- @wired_here

Configuration once, first (R9), and facts as outputs. The page builds each rule once; features name what happened.

pricing: %{shipping: CalculateShipping.new(StoreConfig.rates()),
           stock_status: StockStatus.new(low_at: StoreConfig.low_stock_at()), ...},
line_items: BuildLineItems.new(currency: StoreConfig.currency())

{cart, [rows: {:changed, row}, changed: {:quantity, cart.cart_id, item_id, qty}]}

The aggregate read through its functions (R10). Checkout.pay/2 calls Cart.check_ready(cart, c.stock_levels.(Cart.product_ids(cart))) and Cart.id(cart), never the struct’s fields.

Generic placement components (R11). The page’s template compares nothing itself.

<.tabs current={@active_tab} event="switch_tab"><:tab name={:items} label={"Items (#{@cart_summary.item_count})"} /></.tabs>
<.pane current={@active_tab} name={:items}>...</.pane>
<.only_on current={@live_action} name={:checkout}>...</.only_on>

A rule’s display beside the rule (R11, R1), and one store call per handler. The product index shows stock with a domain component, and deletes through one store function:

<.stock_indicator stock={product.stock} rule={@stock_status} labels={@stock_labels} />
{:ok, product} = Products.delete_by_id(id)

A coverage test (R8). wiring_test.exs sends every port output each panel sends the page, plus the undo clock and both broadcast facts, to each page, and fails on any message the page doesn’t route.

What it scores

V41 (revised)V41-max
Full checklist, by hand88 (first published as 92)100 (99.5; 98 before the panels lost their I/O)
ala_lint default / --strict / --super-strict (2026-10-01 linter)95 / 95 / 90100 / 100 / 99
Tests8383
Lines in lib/4,7004,930
Familiarity5 of 54 of 5

Both lint rows use the same layer map, which puts the store-wide modules in the application layer. The half point the full walk deducts is the design’s own cost: a cross-feature effect takes one message hop, panel to page to panel. The linter’s remaining reports are informational. Configured rule instances look like shared aggregates to it, and CalculateGiftWrapCost looks like a wrapper around a multiplication; I count the first as configuration and the second as a named store rule.

Rescored 2026-10-01: 98

The first walk missed one finding, and it’s the design’s own. 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). The walk had accepted the persistence as “I/O inside an abstraction”, but that reasoning fits PlaceOrder, whose one concept is placing an order. It doesn’t fit a UI component that also writes to the store. 99.5 becomes 97.5, which rounds to 98.

A toy built on V41-max shows the fix. A generic Hosted LiveComponent holds any feature and renders nothing of its own. The page passes in UI abstractions through slots and wires changed to the store. On the toy’s scope (the cart without checkout) the walk finds nothing but the hop, the toy’s page holds no logic, and its page plus host are 369 lines against 606 for this page and its four panels. Its code is in ala_variants_elixir/toy-slot-split.

Back to 100: panels without I/O

The fix keeps everything familiar about V41-max (LiveComponent panels, one route table) and takes the I/O out of the panels:

<.live_component module={Cart.Panel} id="cart" source={&Carts.list_items/1} pricing={@pricing} ... />
{:cart, :changed} => [call: &Carts.apply_change/1],
{:wishlist, :taken} => [feed: {:add_line, &AddLine.run/2, {Cart.Panel, "cart", :receive}}, flash: {:info, "Added to cart"}],
{:checkout, :ready_to_pay} => [async: {:payment, :payment, &StartPayment.call/2}],
{:checkout, :done} => [call: {:place_order, &PlaceOrder.place/2}, redirect: true],

The payment job now runs on the page, and its outcome goes back to the checkout panel like any other port output. ala_lint’s new ui_io check, which flagged all four panels, finds nothing, and the walk is back to 99.5 (the hop), which rounds to 100. A pull port is wiring, because the page decides what’s read. Passing a store module was not, because the panel defined the API it needed from a store.

Rescored 2026-10-02: 98

Two of Spray’s statements are now read strictly, and every published variant was rescored.

Its 99.5 (the hop) becomes 98. The lint score stays 100: the linter now reports the FormComponent as subcomponent under --strict, but one finding in a codebase of about 5,000 lines rounds away. Its panels aren’t deducted: they take their words and rules from the page, so they read as stateful domain UI abstractions, not contained sub-components. Both fixes, a generic record form the page configures and wires, and a layer named for what it holds, are in V46 and V47, which score 100 under these readings.

Rescored 2026-10-02 (later): 97

Building V49, which is V41-max without its route table, found two things every walk had missed.

98 becomes 97.

Rescored 2026-10-03: 95

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). 97 becomes 95. Lint under --strict is 99, meeting 8 of 10 rules: the linter now scores the shared aggregate from --strict up.

The cart page, drawn from its route table

Paradigms.Drawing.mermaid/1 draws a page from routes/0, the table the page routes by. A pass is a solid arrow to the panel whose input gets the output, and a feed names the instance it asks on the way. A task such as payment is a node its outcome comes back from. The drawing shows only what panels send the page: what each panel wires to itself (its rows to its own stream, its summary to its own assigns) isn’t in the table, so it isn’t drawn.

flowchart LR
  cart -.->|"changed"| call_apply_change["call apply_change"]
  cart -->|"line → toggle"| wishlist
  cart -.->|"promo_applied"| page_flash["page: flash"]
  cart -.->|"promo_rejected"| page_flash["page: flash"]
  cart -->|"removed → capture"| undo
  cart -->|"saved → stash"| saved
  cart -.->|"saved"| page_flash["page: flash"]
  cart -.->|"summary"| page_assign["page: assign"]
  checkout -.->|"blocked"| page_flash_by["page: flash_by"]
  checkout -.->|"done"| call_place_order["call place_order"]
  checkout -.->|"done"| page_redirect["page: redirect"]
  checkout -.->|"ready_to_pay"| payment["task payment"]
  checkout -.->|"step"| page_patch["page: patch"]
  payment -->|"failed → failed"| checkout
  payment -->|"succeeded → succeeded"| checkout
  saved -.->|"count"| page_assign["page: assign"]
  saved -->|"moved → receive"| cart
  saved -.->|"moved"| page_flash["page: flash"]
  stock -->|"changed → set_stock"| cart
  undo -->|"expire → expire"| undo
  undo -->|"expired → confirm_removal"| cart
  undo -->|"restored → receive"| cart
  undo -.->|"restored"| page_flash["page: flash"]
  wishlist -.->|"added"| page_flash["page: flash"]
  wishlist -.->|"count"| page_assign["page: assign"]
  wishlist -.->|"dropped"| page_flash["page: flash"]
  wishlist -.->|"ids"| page_assign["page: assign"]
  wishlist -->|"taken via add_line → receive"| cart
  wishlist -.->|"taken"| page_flash["page: flash"]

Did it stay V41?

Yes. A panel is still a LiveComponent that owns its feature’s state, stream, events and store writes, and the page still reads like a phx.gen.live template with instances in it. The cost is one idea a newcomer hasn’t met, the route table, which is why familiarity drops from 5 to 4. What the team gets for it is a page whose whole cross-feature design is one value they can read top to bottom and test.

How it compares with the other two

None of the three max variants is a copy of another. V41-max and V39-max share their features and domain code almost file for file, but V39-max keeps every feature’s state in the page and runs a click in zero hops. V38-max shares no code and reaches the same score with function clauses for wiring. The V39-max post has the full comparison.

The code is in ala_variants_elixir/v41-max.

← all posts