V45, checked clauses: 100, zero hops, safe and familiar wiring
The three “max” variants (V41-max, V39-max, V38-max) showed that a LiveView app can reach 100 on a rule-by-rule walk of the ALA Checklist, by three routes. (V41-max dropped to 98 when a later walk counted its panels’ I/O, and got back to 100 once the page wired it.) They differ in what it costs: V41-max keeps a message hop per cross-feature effect, V39-max asks a reader to learn fourteen binding kinds and a protocol, and V38-max’s wiring is plain clauses whose coverage is checked only when the tests run.
V45 is a design for the corner none of them occupies alone. It has four goals: 100 on the walk, zero hops, no more code than the others, and wiring that is safe and familiar. Familiar comes first, and a little familiarity can go if safety needs it.
What the max variants taught first
Building V38-max out to the full storefront and portal requirements settled two things before any design work.
- Wiring isn’t what makes a codebase big. V38-max, V39-max and V41-max are 4,827, 4,772 and 4,955 lines. Their page and view code is about the same, and their wiring runtimes differ by tens of lines. What keeps a codebase small is reusing features, domain rules and generic components, which all three do.
- Clause wiring holds at size. V38-max’s two pages have 44
wire/3clauses between them, one per feature port, and they still read as a list, about as long as V39-max’s map for the same wiring.
So V45 keeps V38-max whole: features as {state, outputs} values held in the page’s assigns, every click handled inside the page process, and one private clause per port. It changes only the three places where safety or familiarity was weak.
Named instances, so no clause reads assigns
V38-max’s weakest line was a capture like &AddLine.run(s.assigns.add_line, &1). It names the instance it calls, but a wrong assign key is a nil that surfaces as a crash somewhere else, and no test of the wiring catches it. V45 keeps the page’s store-work instances, the ones that do I/O, in one map built at mount:
instances: %{
add_line: %AddLine{carts: Carts, products: Products, cart_id: cart_id},
charge: %Charge{gateway: gateway, metadata: &CheckoutMetadata.for_cart/1},
settle: %SettleOrder{orders: Orders, carts: Carts, products: Products, announce: &Broadcast.stock_changed/2, cart_id: cart_id}
}
A clause names the one it wants, and the runner looks it up:
defp wire(s, :wishlist, {:taken, product}),
do:
s
|> Steps.feed(:cart, &Cart.receive/2, {:add_line, &AddLine.run/2}, product, &wire/3)
|> put_flash(:info, "Added to cart")
defp wire(s, :checkout, {:ready_to_pay, payment}),
do: Steps.async(s, :payment, {:charge, &Charge.call/2}, payment)
defp wire(s, :checkout, {:done, reference}),
do: s |> Steps.call({:settle, &SettleOrder.run/2}, reference) |> push_navigate(to: ~p"/cart/success")
A missing name raises no configured instance :charge in @instances at the line that asked. The instances are still configuration set once at the composition, as Spray’s §3.9 asks, and the clause still says exactly what it calls.
A one-line coverage test
With no catch-all clause, an unwired output crashes the page instead of vanishing, but only when that output is produced. V38-max closed the gap with a test that parsed each page’s source. V45 moves that into the paradigm layer as Wiring.gaps/1, which finds a page’s source from its own compile info and compares its clause heads with every port its features declare:
test "the cart page wires every declared port, and nothing else" do
assert Wiring.gaps(GoodDealWeb.CartLive.Show) == %{unwired: [], unknown: []}
end
A page lists its features once (@features %{cart: Cart, undo: Undo, ...}), and each feature declares ports/0. The linter’s :ports check, scored under --strict, adds the other half in CI: it fails when a feature’s declaration drifts from the outputs its code builds.
An optional compile-time check
use GoodDealWeb.Paradigms.Wiring on a page makes the same comparison while the page compiles. It records each wire/3 head as it’s defined and fails the build on a gap:
** (CompileError) wire/3 wiring gaps in GoodDealWeb.CartLive.Show: %{unknown: [], unwired: [ui: :tab]}
It’s off by default. The coverage test and the linter already give the same safety one step later, and the check costs a macro with definition hooks that most Phoenix developers have never written. That’s the one place V45 could trade familiarity for safety, and it leaves the choice to the team: one line turns it on.
What it scores
| V38-max | V45 | |
|---|---|---|
| Full checklist, by hand | 100 | 100 |
ala_lint default / --strict / --super-strict | 100 / 100 / 99 | 100 / 100 / 99 |
| Share of application functions holding logic | 0% | 0% |
| Message hops per cross-feature effect | 0 | 0 |
| Tests (shared acceptance tests included) | 116 | 116 |
Lines in lib/ | 4,827 | 4,942 |
| Wiring runtime | 56 lines | 88 (Steps) + 77 (Wiring) |
| Clauses that read assigns | 3 | 0 |
| Familiarity | 4 of 5 | 4 of 5 |
The walk records the same judgement calls as the other max variants, made the same way. The one-line domain rules count as concepts. Configured instances aren’t shared data. The shared cart aggregate is read through its functions. The report-only numbers stay unscored, including 22% of functions in the application layer, because each wire is a function clause. The judgement V38-max needed for captures reading assigns is gone. The linter’s remaining reports are informational: the shared aggregate, wide public surfaces on the cart modules, and the product pages’ form component relaying through the page, as in every variant.
The 115 extra lines are the two paradigm additions. In return the wiring check sits in the paradigm layer, every page gets it with one line, and a misnamed instance fails where it’s named.
Rescored 2026-10-02: 99
Two of Spray’s statements are now read strictly, and every published variant was rescored.
- 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. Abstraction layers replace hierarchical containment” (§2.2). His provision for page-specific UI is layout and bindings built from domain UI abstractions: “Using one in a specific application only requires a label and a binding to an action” (§7.14). V45 still has the
FormComponentthatphx.gen.livegenerated for the product pages, with its own state and save handler (R11, −1). - Spray’s features are compositions. “Each feature creates instances of domain abstractions, configures the instances with feature specific details, and connects them together as needed to express the feature or user story” (§2.2). V45’s
Featuresmodules are coded state and rules with ports, which he would call stateful domain abstractions. The edges don’t change, but the name misleads a reader who knows his vocabulary (R8 “should”, −0.5).
100 becomes 98.5, which rounds to 99. 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. 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-03: 97
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). 98.5 becomes 96.5, which rounds to 97. Lint under --strict is 99, meeting 8 of 10 rules: the linter now scores the shared aggregate from --strict up.
Where it sits among the full variants
| V41-max | V39-max | V38-max | V45 | |
|---|---|---|---|---|
| Wiring written as | route table between components | data map, 14 binding kinds | wire/3 clauses | wire/3 clauses |
| Hops | 1 | 0 | 0 | 0 |
| Wiring checked | test sends each announcement | test over map keys | test parsing source | one-line test, linter, optional compile check |
| Instances named in wiring | attributes on components | struct literals in the map | captures reading assigns | {name, fun} looked up by the runner |
| Familiarity | 4 | 3 | 4 | 4 |
One scoring question was open when V45 was built, and it’s now settled: wiring written as function clauses in one module meets R8. Revised V41 had lost a point for wiring with plain handle_info clauses between components, while V38-max and V45 wire with clauses and lost nothing. The point is restored (V41 is now 90). So the most familiar shape, LiveComponent panels wired by plain clauses on the page (familiarity 5), can reach the same score as V41-max without a route table, keeping its one message hop.
The code is in ala_variants_elixir/v45-checked-clauses.