The Rules of LVD: Layers, Dependencies and Axioms

Most architecture rules are guidelines, argued over in code review and bent under deadline. LVD's central rule is closer to arithmetic. Every component sits on a numbered floor, and an import may point at the same floor or a lower one, never a higher one. A surprising amount of the model, including a guarantee that your dependency graph has no loops, falls out of that one comparison.

The comparison in action

Imagine a small podcast app with five components, one for each of the first five layers: an episode type in Schema, a duration formatter in Utils, a feed-fetching client in Resources, a subscribe tool in Tools and an HTTP route in the API layer. Here is how the rule judges some imports:

formatDuration (L2) -> EpisodeType     (L1)   allowed: points down
EpisodeType    (L1) -> formatDuration  (L2)   rejected: points up
SubscribeTool  (L4) -> FeedClient      (L3)   allowed: points down
FeedClient     (L3) -> SubscribeTool   (L4)   rejected: points up
SubscribeTool  (L4) -> RenewTool       (L4)   rejected: distinct Tools stay apart

The first four lines need no memorised table, just two numbers and a comparison. That is also why the rule is easy to automate: a checker only has to know which layer a file belongs to. The fifth line is the first of two deliberate exceptions.

The same-floor loophole

Strictly downward imports between layers are clean. The interesting question is imports within a layer, because the rule allows same-floor dependencies. The book permits them in every layer except one, with the proviso that they must never form a loop.

The exception is the Tools layer, covered by Axiom A5: distinct tools may not depend on each other at all. Whatever else motivates A5, it has a useful side effect for loops. Same-floor imports are the only place a cycle could possibly hide, and in Tools the axiom closes that door completely. How tools share logic without importing one another is a topic of its own, in the A5 article.

Why loops cannot form

The book proves that every LVD architecture is acyclic, and the proof is by contradiction. The intuition is easy to hold without any notation. Think of a staircase you can walk down or along but never up. Follow any chain of imports and write down the floor number at each step: the numbers never increase. A loop, however, has to finish where it started, so the number cannot have decreased either. The whole loop must therefore sit on a single floor.

On that one floor, one of two things stops it. In Tools, A5 rules out the dependency between distinct tools outright. Everywhere else, the same-layer proviso says loops are not allowed. Two practical benefits follow, which the book also states: a valid ordering of the components always exists, and so does a well-defined build order. I have left the formal steps out on purpose; they are the part worth reading on the page.

Axiom A6: a staircase with a narrower rail

The second exception concerns the top layer. The UI executes on someone else's hardware, in a browser or on a phone, so the book narrows what it may reach for on the way down. In plain terms, the UI can use Schema and Utils code, meaning shared types and pure helpers, plus the published, generated artefacts that the API, MCP, Skills and Agents layers hand out to their consumers. Anything that would drag a data-access client or a business rule into that environment is simply not importable.

The reasoning behind A6 is that sensitive code should never be reachable from a place you cannot trust. Making that a rule a tool can check, instead of a reminder for reviewers, is the point of expressing it as an axiom. The exact statement of A6 and the dependency matrix that includes it are in the book. The practical side is covered in the UI and API boundary.

The takeaway

Strip LVD down and you find a short rulebook: depend on the same layer or lower, keep tools independent of each other, and let the UI see only what has been published for it. The loop-free graph is a consequence of those rules, not an extra thing to maintain. For the guarantee in more detail, see why LVD cannot contain cycles, and for the layers themselves, the nine layers explained.

What the book covers

  • The formal definitions of a layer, its volatility coefficient and a full LVD architecture
  • The complete dependency matrix, including every cell touched by Axioms A5 and A6
  • The formal proof of Theorem 4.1 and its two corollaries about ordering and build order
  • Why the proof holds unchanged for nine layers and with both axioms in force
  • The exact statement of Axiom A6 and what counts as a published contract