Abstract
When I joined Company A in early 2015, its transaction platform was caught in a frustrating paradox. Services had been sliced finer than ever and the platform exposed hundreds of APIs and extension hooks, yet shipping a new business kept getting slower. Teams were permanently understaffed, schedules stretched into months, and missed dates were routine. Every Thursday, forty or fifty branches piled into the same release train, and a change for one business dragged dozens of unrelated businesses through regression testing.
Too many if/else branches or a clunky SPI only scratched the surface of what was broken. What the platform lacked was a governance model for business change: who owns a piece of custom logic and whom it may affect, how one coherent scenario survives across thousands of services, how colliding rules compose or yield, and whether a business can evolve without riding the platform’s release train. Lattice grew out of those problems as an open-source business extension framework—restoring three boundaries (business vs. platform, business vs. business, logical flows vs. physical topology), then using business identity, Ability, Use Case, vertical-horizontal composition, and Reduce to replace scattered platform patches with bounded assembly. The closing section walks through how I turned those same principles into an executable AI architecture Skill inside Spark so boundaries hold before a single line of code is generated.
A customizable platform lives or dies by whether every change carries a clear owner, scope, composition rule, and delivery boundary. Exposing another hundred hooks buys nothing if one business’s change can still spill across the rest of the platform.
Part I · When the platform falls behind the business
01Thursday releases in 2015
During my first six months at Company A in 2015, I spent most of my time shadowing teams as they tried to land new businesses on the transaction platform. What stayed with me was a bone-deep exhaustion across the org: chronic headcount shortages, late nights, multi-month lead times, and slipping milestones. Platform and business teams worked together under a co-development model, yet every new team added to the mix drove coordination costs higher. People were working hard on a stack full of serious distributed-systems machinery, and still every business launch felt like running with sandbags strapped to your ankles.
The earlier move to distributed services had actually been a clear win. Company A started with a relatively uniform e-commerce model where listing, cart, checkout, and fulfillment fit comfortably inside one system. As volume and headcount grew, breaking that monolith into cohesive user, product, transaction, and shop services let each group own its backlog and release cadence. Both velocity and stability jumped.
Every architectural payoff, however, hits a scale limit. As the company expanded across industries and the fleet climbed into the thousands of applications and services, the very decomposition that tamed local complexity started breeding a nastier systemic complexity: a single business intent was now shredded across dozens of apps and teams.
Taking one requirement from proposal to production meant aligning multiple teams on design, coding, integration testing, and a strict deployment sequence. Worse, nobody could vouch that every affected service had been found. The happy path was obvious enough; the real landmines were years-old side entrances and exception branches tucked away in peripheral apps. Miss one, and you found out in staging—triggering design re-reviews, rework, and another slipped launch.
Applications were cleanly decoupled on the deployment diagram, while business intent had lost any place to live intact.
You can split a system into a thousand services, yet the customer still asks for one coherent outcome. The finer we slice technical boundaries, the harder we have to work to keep business intent whole.
02From open APIs to co-development
Early platform openness ran on standard APIs. Stable remote interfaces let downstream apps reuse product, order, and marketing functions—great for shared backbone logic, hopelessly rigid for the quirks of twenty different industries.
As those differences piled up, catch-all Map parameters crept into every signature. Callers stuffed extra context into key-value bags, and the platform dutifully passed along fields whose business meaning it could not comprehend. Next came Java SPI: the platform published an interface, business teams wrote implementations, and custom rules plugged directly into the core execution path. For a while, that co-development model unlocked real speed.
The bill arrived soon enough. Business realizations lived side by side with platform code inside the same repositories, with no hard isolation. A business customization could not ship on its own; it had to catch the platform’s shared release train. Every Thursday, forty or fifty branches merged into mainline at once. Each branch looked completely justified in isolation, yet merging them turned release day into a platform-wide regression gamble: Business A pushed a small tweak, and Business B’s on-call engineer spent the night holding their breath.
Staying safe depended almost entirely on individual developers being careful. When the org had a few dozen engineers, veterans and thorough code reviews could hold the line. Once headcount multiplied, “please be careful” stopped qualifying as an architecture.
03How an inventory-decrement method rots into a maze
Inventory decrement is a tiny slice of commerce logic that captures the entire decay curve. (The snippet below is purely illustrative and unrelated to any production codebase.)
Initially the platform followed one rule: decrement stock when the order is placed. Then large appliances arrived. Expensive, scarce items invited unpaid orders that locked up inventory, so the first exception went in—decrement stock only after payment:
public ReduceType getInventoryReducePolicy(OrderLine orderLine) { |
Next came digital goods, some of which carried no physical stock at all, adding an early exit at the top. Shortly afterward, large appliances launched in-store pickup: buyers received a digital pickup code that looked like a virtual item, yet the warehouse still had to decrement real inventory. Now “digital goods skip stock decrement” collided head-on with “large appliances decrement after payment,” and which if came first decided who broke.
Soon even large appliances split internally—items above a price threshold decremented after payment, cheaper ones kept the original rule. Over a few short years, one crisp default mutated into a tangled branching tree over product type, industry tag, fulfillment mode, and price.
Nobody woke up intending to sabotage this method. Every single commit answered a legitimate requirement using the cheapest local edit available at the time. A few years later, one method stretched across thousands of lines. Each newcomer hunted anxiously for a “safe-looking” line to squeeze in one more branch, praying silently that no neighboring business would break.
Watching that happen changed how I think about legacy code. Most decayed enterprise methods suffer from a missing ownership model for business change: the code cannot tell which business owns which rule, nor whether colliding rules should isolate, override, or merge—so execution order quietly makes policy decisions on behalf of the organization.
04SPI tidied the classes and hid the coupling
Facing a thousand-line branching tree, engineers naturally reach for SPI: give each strategy a filter and an execute method, loop through the list, and run the first match.
public interface InventoryReducePolicySpi { |
With four or five implementations, this feels refreshing. One monster method turns into neat, unit-testable classes. Push the platform to serious scale, though, and the exact same tangle reappears in disguise:
- Should the new requirement edit an existing implementation or register another?
- Where in the list must it sit so an earlier rule does not intercept it first?
- Does its
filteroverlap with any of the thirty implementations already registered? - If you nudge the ordering, which unrelated businesses silently shift behavior?
Worse still, real-world filter methods eventually call rule engines or remote RPCs. At that point, reading every line of source code still cannot tell you statically which implementation will fire for a given order. On large platforms I have worked on, SPI contracts climbed toward a thousand, with dozens of implementations hanging off a single interface. Global traversal plus “first match wins” herds every business into one invisible decision tree fighting for priority.
Long if/else chains disappeared from the source file, only to relocate into bean registration order and opaque filter predicates—preserving all the coupling while making it far harder to see.
- Symptom — Core methods bloat with branches; nobody can predict the blast radius of a small change.
- Surface fix — Extract branches into SPI classes selected dynamically via list order and
filter. - Secondary failure — Filters and registration order form an invisible global decision tree where businesses compete.
- Root cause — The extension layer lacks business identity, explicit scope, composition semantics, and independent delivery boundaries.

Figure 1 · An extension layer without scope. Service decomposition trimmed local complexity inside each application while losing the whole business intent; global SPIs, shared repositories, and a single release window tied those scattered changes right back together.
05Two thousand services and no business map
Another quiet mismatch sat underneath: the platform exposed hooks per application, while business teams reasoned in end-to-end scenarios.
At Company A’s scale, capabilities had already spread across more than 2,000 microservices. That figure mattered for one blunt reason: the topology had grown far beyond what any single human mind could hold, trace, or verify. When a new requirement arrived, nobody could sit down and guarantee which services it crossed, which teams needed a seat at the table, which extension points had to change, or which obscure side entrance had been forgotten.
Of course no single feature touched all 2,000 services, and microservice decomposition itself had real merits. The real drag appeared afterward: once business intent splintered across so many technical borders, impact analysis still relied on humans stitching the map back together by hand. Scoping turned into endless group chats, trace hunting, and tribal memory—and missing one peripheral entry point meant an incomplete design.
Take a rule that fits in one plain sentence: “This business does not allow shopping-cart purchases.” In an application-centric world, enforcing that single rule forced teams to patch across half a dozen places: hide the Add to Cart button on the product detail page, reject direct cart API calls that skip the UI, block forged cart-channel orders in checkout, and hunt down legacy side paths that might bypass all three.
Every service’s hook looked defensible on its own, yet the burden of proving end-to-end completeness fell squarely on the business delivery team. Engineers had to master their own industry and sift through thousands of services to discover which slice mattered, how each hook behaved, and whether any doorway stayed unguarded. Finer service boundaries clarified individual apps while making cross-system business analysis progressively heavier.
The real architectural lever was lifting the unit of extension upward—away from physical applications and technical hooks, back to businesses and scenarios—so teams see what a complete scenario accomplishes first and let that scenario wire the underlying capabilities.
Part II · Reframe the problem before writing a framework
06Six questions the platform had to answer
During our early design workshops, I asked everyone to put away class diagrams and framework pitches and simply finish one sentence: “If the platform could …, then we could ….” That single prompt dragged the room out of abstract preferences and straight back to daily friction.
What engineers asked for was remarkably grounded: package an industry’s contracting and fulfillment rules quickly; keep that package decoupled from the platform and isolated from neighboring businesses; pick and combine existing capabilities along actual business flows; let product and engineering see at a glance what the platform offers and what a business has turned on; ship without waiting for Thursday’s platform train; and keep the same logical model workable across different deployment topologies.
Distilled down, those frontline requests became six questions the framework had to answer head-on:
| Platform symptom | Question the architecture must answer |
|---|---|
| Business code mixed into platform repositories | Who owns the change, and where is its code boundary? |
| A change for Business A can alter Business B | How is the scope of a rule determined? |
| One requirement is scattered across applications | How can capabilities be organized and reused as a complete scenario? |
| Extension points are buried inside physical applications | How can the platform expose one business view independent of deployment topology? |
| Several SPI implementations match at once | How do rules compose, and who resolves a conflict? |
| Dozens of branches share one release | Can a business be developed, tested, and delivered independently? |
Every piece of Lattice grew directly out of these six questions. Annotations, interfaces, and containers are mere plumbing; lose sight of these six constraints and any framework quickly degenerates into another gilded SPI wrapper.
07Rereading Clean Architecture: controlling the direction of change
Returning to Robert C. Martin’s Clean Architecture years later, what resonated most had little to do with which package holds Entities, Use Cases, Interface Adapters, or Frameworks. What mattered was one ruthless question: which direction is change permitted to travel?
The book’s Dependency Rule states it plainly: source-code dependencies point inward. Outer rings contain volatile technical mechanisms; inner rings hold durable policies tied to business purpose. Web stacks, databases, and delivery plumbing serve business rules rather than bending them. Use cases coordinate entities toward concrete goals and cross boundaries inward.[1][2]
On a multi-industry commercial platform, keeping SQL out of domain entities only solves half the problem. Local business customization is itself a high-frequency external change. One industry’s inventory rule, one promotion’s purchase cap, or one fulfillment mode’s redemption check changes just as fast as an infrastructure choice—and must never bleed back into the shared platform core.
That realization sharpened how I apply the Dependency Rule: architectural “inside” and “outside” divide along policy reach as well as technical layer. Shared entity invariants, cross-industry scenario policies, single-vertical rules, and horizontal campaign mechanics differ dramatically in stability and blast radius. They belong behind explicit contracts rather than jostling inside a flat global list.
Clean Architecture‘s emphasis on independent development and deployment, plugin boundaries, and screaming architecture—making a system’s purpose obvious before its frameworks[1]—gave crisp vocabulary to lessons practice had already beaten into us:
- Separating business code from platform code governs change direction so volatile industry tweaks stop dragging down the shared core.
- Decoupling logical business flows from physical service topology restores coherent intent during design and impact review.
- Organizing extensions around use cases returns the codebase to business language instead of fragmented app hooks.
- Delivering plugins independently turns a conceptual line on a whiteboard into an enforceable engineering boundary.
- Executing pre-settled compositions at runtime replaces opaque ordering surprises with explicit policy.
My takeaway from the book: “Clean” has nothing to do with terse code or tall layer diagrams. A system is clean when high-level policy refuses to be pushed around by low-level plumbing or local exceptions—and when a new requirement arrives, everyone knows the exact line where its impact stops.
Part III · Inside Lattice: three separations and a two-dimensional rule grid
08Why the name Lattice
Look closely at any large commercial platform and two orthogonal forces weave across each other: isolated vertical businesses running down one axis, and reusable horizontal plays stretching across the other. Together they form a grid—a lattice. (And yes, there was a lighter inside joke too: programmers have a soft spot for plaid shirts.)
That grid gave the open-source extension framework its name, promoting business identity and capability composition into first-class primitives. The codebase lives at hiforce/lattice, with 1.0.21 on the main branch as of this essay’s latest verification.[3]
09Restoring three boundaries first
All the platform failures cataloged earlier traced back to three boundaries collapsing at once: custom business code invaded the platform core, rival businesses competed inside one global filter pool, and physical microservices shattered the view of end-to-end flows. Lattice starts by putting those three separations back in place.
| Separation | What must be kept apart | Boundary mechanism | Immediate effect |
|---|---|---|---|
| Business from platform | Stable platform capabilities and business-specific policy | Stable contracts, business plugins, separate repositories | Customization stays out of the platform core |
| Business from business | Rules and implementations owned by different businesses | Business identity, targeted loading, call-chain context | One business’s change does not enter another by default |
| Logical from physical architecture | Business flows and application or service topology | Annotation metadata, unified reporting, management view | Designers discover capabilities by scenario rather than application map |
These three separations stand or fall together. The first fixes where code lives; the second fixes which rule space a request enters at runtime; the third fixes what engineers see when scoping a feature. Drop any one and the rest sag: plugins without business identity still collide in a global pool; identity inside a shared monolith repo still chains everyone to Thursday’s release train; clean runtime isolation without a logical view still leaves impact analysis wandering blind through two thousand services.

Figure 2 · The three separations in Lattice. On the left, business customizations stay outside the platform core. In the center, identity locks execution into one isolated rule space. On the right, capabilities scattered across physical services reassemble into a logical view built for design and impact review.
10Moving business code out of the platform core
Under the old co-development model, the platform defined an SPI and business teams committed implementations straight into the platform repo. Early on that felt fast. Once dozens of teams piled in, stable infrastructure and local industry exceptions grew hopelessly intertwined—every platform upgrade had to babysit business code, and every business tweak waited on the platform’s branch freeze and regression cycle.
Lattice draws a hard perimeter: the platform repository holds only stable entities, use cases, abilities, extension contracts, and safe defaults. Concrete business rules move out into separately owned plugin packages and repositories. At runtime, registration and plugin loading bridge the two: the platform defines what may vary, and each business plugin supplies how this business behaves there. Source dependencies flow strictly inward toward stable contracts; the core never depends on a specific business.[3]
Three practical boundaries snap into alignment:
- Code boundary — Custom business logic stays inside external plugin repositories, out of platform mainline.
- Test boundary — Plugins verify their own policies and selected capabilities in isolation.
- Release boundary — Business iterations unhook from the shared platform release train and its all-hands regression windows.
Plugins alone do not magically guarantee frictionless independent releases—shared database tables, contract compatibility, runtime containers, and org habits can still bind deployments together. Severing the reverse source dependency, however, turns independent build, testing, and delivery from wishful thinking into an architecture the codebase actively supports.
11Replacing global filter guessing with business identity
A conventional SPI starts every invocation by asking, “Which implementation’s filter matches this request?” Lattice flips the question on its head: “Which business owns this request?”
That single reversal builds a completely different runtime. In traditional SPI, every implementation guesses its own applicability through a filter method, tossing all businesses into one shared candidate pool. Leave out one guard clause or match one channel too broadly, and Business A’s logic quietly fires on Business B’s checkout. Isolation rests on hoping hundreds of scattered filter predicates remain mutually exclusive forever—a bet no large platform ever wins.
Lattice enforces a strict entry invariant: the first step at any scenario boundary is establishing one unambiguous business identity. Once identity is anchored, the runtime holds an exact coordinate and loads only the plugins and realizations registered under that identity. Every other business’s code stays completely outside the candidate set. Isolation becomes a built-in property of the execution model instead of developer luck.
|
@Business declares the business; @Realization declares ownership of the customization. The annotation syntax matters far less than the shift from inferred ownership to explicit ownership: establish who I am first, then load my rules.
That unified business identity must also ride along the entire call chain. Identifying the business at the gateway and dropping it on the first downstream RPC breaks isolation at the process edge. Lattice carries the business code as foundational extension context so one request stays inside the same rule space across service calls.
12Ability: turning scattered hooks into discoverable capabilities
Business identity answers “whose rules?”; Ability answers “what extensible capability does the platform offer on this business object?”
An Ability gathers related extension points around a concrete carrier. An order line acts as the carrier, pricing is the ability, and “custom item unit price” is one extension point inside it. The ability resolves realizations for the active business and merges results under declared reduction rules, while any business without custom needs falls back cleanly to the platform default.
public interface OrderLinePriceExt extends IBusinessExt { |
With abilities in place, capabilities stop hiding in random corners of thousands of apps, uncustomized businesses inherit safe defaults automatically, and multi-implementation merging obeys the ability’s contract rather than accidental registration order.
Discipline still governs what becomes an Ability. Wrapping every internal method in an annotation achieves nothing except bloated contract surface area. Only behavior with durable business meaning—where real businesses genuinely diverge—earns promotion into an ability or extension point.
13Defining what counts as a business
“Business” gets stretched so thin inside tech companies that it often means whatever a team happens to work on, or simply a box on the org chart. To anchor a software model in reality, we need an operational definition: a business is a sustained set of activities, decisions, and rules that delivers a product or service and generates durable economic results through revenue growth or cost reduction.
Both sides of the ledger belong here. Organizations routinely split teams into profit centers—pushing markets, products, operating models, and supply chains to drive top-line revenue—and cost centers focused on shared platforms, automation, and operational efficiency. Their day-to-day levers differ, yet both answer the same commercial question: how to keep creating value while protecting healthy margin between revenue and cost.
Mapped onto a software platform, those commercial realities consistently yield two kinds of rules. One cluster anchors to a specific industry, governing how that industry prices, transacts, fulfills, and absorbs risk as a complete operating model. The other cluster is industry-agnostic, packaging a reusable commercial play or platform capability that lifts conversion, efficiency, or customer experience across many industries. One demands autonomy; the other demands reuse—answering “which industry’s P&L is this?” versus “which reusable plays has this industry turned on?”
Vertical and horizontal dimensions are simply the code-level reflection of operating ownership meeting platform reuse.
14Vertical isolation and horizontal reuse
A vertical business is typically an industry—auto finance, on-demand delivery, or movie tickets. Each owns end-to-end operating accountability for its customers, revenue, fulfillment, risk, and bottom line. Its policies therefore demand strict isolation: auto-finance qualification checks, preauthorization timeouts, and non-logistics fulfillment have no business leaking into on-demand delivery, just as delivery radius and SLA logic should never become defaults for movie tickets.
Even if two vertical industries both happen to set payment timeout to ten minutes today, each must declare that choice inside its own business space. They share the underlying “payment timeout” capability, never one another’s policy decision—otherwise when one switches to fifteen minutes next quarter, the other gets silently altered without a voice in the call. The vertical axis locks down ownership and isolation: identical numbers never justify merging two independent owners’ policies.
A horizontal business is an industry-agnostic play or platform capability (often called a platform business). Rather than owning a full industry P&L, it encapsulates a reusable mechanism that modifies one slice of a vertical baseline. Electronic vouchers govern code issuance, redemption, and refunds whether the buyer booked movie seats, theme-park passes, or car washes. Promotional campaigns reshape entry points, pricing, and sales-volume counting across industries. Cash on delivery modifies payment timing, checkout flow, and small-change rounding regardless of vertical.
Horizontal plays are defined independently of any single vertical yet adopted freely by many. Movie tickets and car-care packages both plug in electronic vouchers while picking different redemption counts; one vertical can stack vouchers, presales, and a flash campaign at the same time. The horizontal axis delivers reuse and opt-in increments layered atop a vertical baseline.
Crucially, these two axes evolve at completely different speeds: vertical industries are relatively enumerable and stable, whereas horizontal plays are open-ended, impossible to list in advance, and constantly shifting. Entering a new industry is a deliberate, infrequent strategic move—an ideal anchor for a long-lived business identity. Horizontal plays never stop multiplying: new campaign mechanics, payment rails, fulfillment modes, loyalty perks, and risk controls appear continuously and combine in unpredictable ways.
With |V| verticals and |H| independently selectable horizontal plays, modeling every “industry × play combination” as its own business type drives the combination space toward |V| × 2^|H|. Each new horizontal play potentially doubles the space. Encoding that into inheritance trees, compound business codes, or global SPI filters guarantees combinatorial explosion in both types and branches.
Lattice models in the opposite direction: use the stable, enumerable set of vertical industries as coordinate origins and durable business identities, then let each identity select N open-ended horizontal plays. Every request locks onto one vertical identity first to inherit its defaults and ownership boundary, then resolves the horizontal capabilities enabled for that identity. Launching a new horizontal play adds one optional column to the grid without touching existing verticals; toggling a vertical’s selections leaves its neighbors untouched. Stable identities carrying open-ended compositions are what let rapid commercial experimentation coexist with platform stability.
Two crisp rules follow. Any workflow spanning multiple vertical industries should coordinate separate, explicitly identified business contexts rather than forcing one request to straddle two vertical spaces. And within any vertical baseline, N can be zero or keep growing as the business innovates.
The effective rule set for any business therefore simplifies to:
Complete business rules = 1 vertical baseline + N horizontal increments (N ≥ 0)
The “1” secures single-owner accountability and defaults; the “N” supplies open-ended, composable enhancements. Rather than rigid class inheritance or a flat global SPI list, runtime executes a sparse, scoped composition—each vertical opts into only the horizontal capabilities it wants, with explicit ordering and reduction rules.

Figure 3 · The two business dimensions in Lattice. Vertical businesses protect operating ownership and isolation; horizontal capabilities drive cross-industry reuse. Every intersection marks a vertical’s deliberate adoption of a horizontal play.
15Reduce merges results; owners arbitrate conflicts
Once effective behavior equals one vertical baseline plus N horizontal increments, rule collisions become normal rather than exceptional. Multiple horizontal plays may weigh in on the same extension point alongside the vertical baseline. Locating every participating rule is only half the job; the contract must also define whether they coexist and how they produce one answer.
Some rules compose cleanly. Take maximum purchase quantity: the vertical caps orders at available stock, electronic vouchers cap a single purchase at 250 units, and a promotional campaign caps orders at 10. All three state upper bounds from distinct sources without contradicting one another. Taking the minimum satisfies every constraint simultaneously, making a MIN reducer both mathematically and commercially exact.
Other rules are mutually exclusive. A platform promotion might exclude discounted orders from organic sales counts by default, while a specific vertical—after both owners negotiate—insists its own sales-counting rule win. Two opposite Booleans cannot be averaged or unioned; the contract needs an explicit conflict priority naming whether vertical or horizontal authority prevails.
Lattice separates these two concerns cleanly: a Reduce algorithm defines how multiple outputs merge; conflict priority defines who holds final authority when they cannot. Reducers handle first non-null, collection union, minimum, or domain-specific aggregation; priority is an organizational governance decision that business owners must negotiate and declare explicitly. The framework never invents business policy behind your back—it forces the decision into the open instead of burying it inside classpath or bean registration order.
Effective business rule = Reduce(vertical baseline, horizontal increments 1…N, conflict priority)
| Dimension | Conventional SPI | Lattice |
|---|---|---|
| Ownership | Inferred indirectly through filter |
Declared through business identity |
| Candidate scope | Global implementation list | Current business and its selected capabilities |
| Multiple matches | Registration order or first match | Reduce and explicit conflict priority |
| Business reuse | Copy implementations or share hidden conditions | Compose horizontal capabilities by business |
| Impact analysis | Read every filter | Inspect the business space and composition |
16Use cases: bringing business language back into the architecture
Abilities organize point-level extension behavior, yet stakeholders rarely speak in terms of a single method on an entity. They talk in scenarios: “buyer places order,” “seller fulfills,” “buyer requests refund.” Clean Architecture places use cases around entities specifically to orchestrate data flow and drive entities toward concrete application goals.[2]
On a transaction platform, that layer changes everything. An electronic-voucher flow stretches across orders, code issuance, notifications, and redemption across multiple services. Exposing only low-level entity SPIs still forces every business team to hand-assemble the full flow. Lattice therefore packages reusable assets at the use-case layer as scenario-level SDKs aligned to business activities.
For electronic vouchers, the platform owns the full backbone—issuing, delivering, redeeming, and refunding codes—and opens only policies where industries genuinely differ:
public interface ETicketTradeSDK extends IBusinessExt { |
Movie tickets declare single redemption; a twelve-wash car-care package declares multi-redemption. Business developers answer a plain-English question—“does this voucher allow multiple redemptions?”—without hunting down which key-value attribute an order table uses or fishing for hooks across five apps.
The scenario layer translates that business policy onto lower-level entities—for instance, mapping multi-redemption into a standard order attribute at persistence time. The order entity knows how to store attributes reliably and stays completely oblivious to movie tickets, car washes, or next year’s new vertical. Dependencies point cleanly from scenario to entity, enforcing the Dependency Rule across business extensions.
Better yet, scenario assets compose cleanly. Movie tickets can install both electronic vouchers (redemption rules) and presales (deposit ratio) inside its own rule space—snapping together two independent scenario modules instead of inheriting a bloated “movie-ticket monolith.”
17Decoupling logical business flows from physical service topology
Once code ownership, runtime scope, abilities, and scenario SDKs are in place, the final piece is freeing designers from physical deployment maps. Traditional platforms publish extension catalogs per service: one SPI list inside product, another inside cart, another inside fulfillment. That layout mirrors server topology while hiding how a real transaction actually flows. Past two thousand microservices, expecting anyone to memorize physical topology before scoping a requirement guarantees blind spots.
Lattice uses @Ability and @Extension to declare capabilities, defaults, and reduction semantics, paired with @Business and @Realization for ownership. The runtime discovers this metadata automatically and reports it into a unified business management plane. What surfaces to humans is no longer “a Java interface buried in service X,” but end-to-end business flows—ordering, fulfillment, refunds, redemption—and the policies allowed to vary at each step.
Product managers and architects can now start from the logical view: trace the flow, inspect what capabilities already exist, see which horizontal plays a business has enabled, check which extension points already carry realizations, and verify which Reduce strategy governs overlaps. Existing pieces get selected and composed; genuine gaps crystallize into an explicit gap list for platform architects to evaluate. Cross-team scoping shifts from “I guess service Y might need a patch” to “step three lacks a reusable policy,” giving platform evolution a deliberate cadence.
To earn its keep, that management view has to go far beyond a flat interface registry. Each extension point needs business semantics, scenario placement, inputs and outputs, default behavior, Reduce policy, owner, version compatibility, and active adopters—plus drill-down traceability back to physical services, interfaces, and live instances. Separating logical architecture from physical topology preserves full physical traceability while ending deployment topology’s monopoly as the starting point of business design.
Annotations alone still cannot conjure a sound domain model. Blindly reporting every granular internal method merely trades a maze of two thousand services for an equally unreadable wall of interfaces. Platform architects remain responsible for carving stable semantics, structuring use cases and abilities, and stewarding contract evolution. Lattice closes the loop from code declaration to unified reporting, logical design, and runtime execution; modeling itself remains human craft.
That discipline echoes Clean Architecture‘s maxim that frameworks are details. Lattice stays in its lane—handling identity resolution, extension dispatch, plugin loading, metadata discovery, and result reduction—leaving core business policy where it belongs.

Figure 4 · Where Lattice sits in a clean architecture. Lattice lets external business plugins cross stable contracts into execution while dependencies continue pointing inward toward entities and use cases; frameworks, databases, and plugins remain outer mechanisms.
18Settling composition before runtime
Much of the fragility in conventional SPI comes from deferring structural choices until request time—walking a global list, firing arbitrary filter predicates, and letting transient data, remote calls, or bean order decide the outcome. Nobody can state the blast radius before deploying.
Lattice pushes structural decisions forward: which capabilities a business adopts, how rules overlay, and which policy wins a collision are settled during management and configuration, leaving runtime to execute the pre-resolved rule set deterministically. The official repository highlights this split between management plane and runtime plane as a foundational design choice.[3]
Dynamic order data still drives execution inside a rule; the point is separating two distinct questions. Which rules belong to this business should be static, inspectable, and auditable ahead of time; how those rules evaluate a particular order belongs to runtime. Rediscovering ownership on every single request buys nothing except risk.
Once rule compositions are visible before execution, product and engineering can finally review impact off the same blueprint—which scenarios are installed, which hooks are overridden, where multiple realizations intersect, and which Reduce rule applies. Architecture moves out of tribal memory into a shared, inspectable model.
Part IV · From a minimal loop to real scenario composition
19Minimal loop: custom pricing for Business A, default for Business B
The smallest working Lattice loop fits on half a screen. The platform exposes a “custom order-line unit price” extension inside a pricing ability; Business A declares its identity and returns 2000L; Business B adds no customization. Both orders start from a default price of 1000L:
OrderLine orderLine = new OrderLine(); |
Business A gets 2000L; Business B stays at 1000L. At two implementations this resembles a textbook Strategy pattern, yet the mechanics underneath are fundamentally different: identity locates the realization, the ability owns fallback defaults, and the contract governs reduction. Complete Quick Start and composition examples live in lattice-sample.[4]
When verifying this essay, the sample repository’s main branch still referenced Lattice 1.0.19. I bumped it locally to 1.0.21 and rebuilt both the Quick Start and Use Case modules cleanly; the console output in the next section comes straight from that 1.0.21 run—a small sanity check to keep architecture writing grounded in code that actually compiles and executes.
With two implementations, these constructs can look ceremonial. When realizations scale from two to hundreds or thousands, they supply the exact metadata legacy platforms always lacked: who owns the customization, what capability it extends, how it merges, and what happens when no override exists.
20Real composition: electronic vouchers paired with presales
Now consider a realistic commercial stack. The movie-ticket business installs electronic vouchers (declaring single redemption) alongside presales (declaring a 40% deposit). The ordering use case invokes both scenario abilities and maps persistent fields onto the order entity:
[UseCase]PreSaleTrade load custom down payment ratio: .40 |
Four clean responsibilities sit behind those five lines of output: the business plugin declares movie-ticket policy, the presale and voucher use cases package cross-industry scenarios, the order entity guards stable storage and lifecycle, and the Lattice runtime resolves and reduces realizations by identity.
Add a car-care business next quarter and it plugs straight into the exact same voucher scenario with multi-redemption enabled, setting its own presale deposit ratio independently. Movie-ticket code stays untouched, and the new vertical never queues up in a global SPI ordering contest.
21Mapping platform pain to framework mechanisms
| Original challenge | Lattice mechanism | Immediate change |
|---|---|---|
| Business and platform code intertwined | Business plugins and separate code boundaries | Customization stays outside platform core |
| Businesses influence one another | Unified business identity | Realizations are isolated by business space first |
| Extension points scattered across applications | Ability and scenario-level SDKs | Extension contracts are expressed in business terms |
| Business flows fragmented by physical topology | Annotation metadata, unified reporting, and a management view | Capabilities are discovered by scenario and missing policies become explicit |
| Horizontal capabilities are hard to reuse | Vertical businesses plus horizontal composition | Scenario assets can be selected and overlaid |
| Implementation order determines results | Reduce and conflict priority | Composition semantics become contractual |
| Runtime filters hide impact | Management decisions separated from execution | Compositions can be inspected in advance |
| One release and system-wide regression | Plugin loading and delivery boundaries | Independent business delivery becomes possible |
The right test for adopting any framework is never how clever its annotations look—it is whether every mechanism traces directly back to a recurring operational failure.
Part V · The limits of Lattice, and executable architecture in the AI era
22Lattice does not erase complexity; it gives it an address
Clean Architecture often gets misread as a promise that tidy directories keep software clean automatically; extension frameworks attract the twin myth that plugins make every customization free. After enough scars in production, I prefer stating the opposite up front: Lattice erases zero business complexity—it simply assigns each kind of complexity a clear address.
Deciding whether two verticals belong apart still takes domain modeling. Proving a horizontal capability deserves reuse takes real operational evidence. Resolving conflicting policies still requires owners to negotiate. Carve an extension point too low-level and business teams drown in plumbing all over again. A framework surfaces decisions; humans still have to make the right ones.
Five recurring misuses wreck deployments fast:
- Opening every method as an extension point. Platform internals spill out and contract counts spiral out of control.
- Using
bizCodein place of domain modeling. A business code defines scope; it never explains underlying business structure. - Treating Reduce as a conflict escape hatch. Forcing a meaningless merge algorithm hides genuine policy contradictions underground.
- Shipping the runtime without a management view. If nobody can inspect active compositions, impact analysis stays blind.
- Splitting plugin code while keeping data tightly coupled. Clean repositories cannot rescue shared tables and breaking schema changes from dragging releases back onto one train.
Before adding any extension point, I ask three blunt questions: is this a durable, nameable point of business variation? Are its owner and scope unambiguous? When two realizations collide, is there a defensible composition rule? If any answer comes back fuzzy, adding a hook only kicks the modeling debt down the road.
23Seven engineering judgments for design review
Years on, I no longer judge Clean Architecture or Lattice by folder layouts or concentric diagrams. The only honest yardstick for architecture is the total cost of change: how many unrelated teams must mobilize for one new business, how many untouched verticals require regression testing, whether a failure stays fenced inside a known scope, and how much room remains to swap mechanisms or deployment shapes later.
Distilling the book alongside a decade of platform work leaves seven judgments I actually bring into design reviews (with a reference repository organization across entities, use cases, adapters, and plugins available in lattice-clean-arch-practice-sample[5]):
Judgment one sets the objective, two through six guard the gates change must pass through, and seven keeps the framework from hijacking the business model. Left on paper, though, all seven still depend on engineers remembering them during reviews—and AI coding just accelerated the pace at which boundaries erode.
24Inside Spark: turning clean architecture into an AI coding Skill
On a 2015 transaction platform, architectural decay took a dozen engineers two or three years of adding one well-meaning if at a time. In 2026, a coding agent can generate thousands of lines across eight modules in a single afternoon. It sees the active ticket and nearby files—rarely the dependency rules, ownership lines, and painful postmortems that shaped the repo over years. Writing “please follow clean architecture” in a prompt routinely produces code that passes local tests while quietly trampling system-wide boundaries.
Inside Spark’s backend, I organized architectural governance into four concrete layers:
docs/principle/01.clean_architect_with_lattice.mdcaptures the narrative context and explains why the boundaries exist.docs/principle/02.ai-clean-architecture-lattice-guidelines.mddistills that history into checkable placement rules, Session Scope invariants, and Process / Activity / Result conventions.- Repository-level
AGENTS.mddeclares which kinds of tasks must load those guidelines first. - An architecture Skill locks reading, reviewing, designing, implementing, and auditing into a mandatory sequence around every code change.
| Layer | Purpose | Question it answers |
|---|---|---|
| Background principles | Preserve cases, reasoning, and trade-offs | Why is the system designed this way? |
| Executable rules | State allowed placements, prohibitions, and checks | What code may go where? |
| Repository triggers | Require the AI to load specific principles for specific work | When is an architecture review mandatory? |
| Architecture Skill | Fix the review sequence and required output | What must the AI do before and after coding? |
Durable architectural truth stays in the repository so Codex, Claude, and human engineers read the exact same source. The Skill acts as an execution adapter—pulling those rules in at the right moment and blocking the agent from jumping straight into code generation. Trimmed from Spark’s production setup, its core looks like this:
--- |
In day-to-day work, I never tell an AI “go implement the feature” cold. I run the Skill first so it has to put its structural model on the table. Adding Kubernetes-based Python builds to Spark Flow looks like this:
Me: Add Kubernetes-based Python builds to Spark Flow. Run the architecture Skill first and do not write code yet. Show the business identity, module boundaries, dependency direction, extension contract, and verification plan.
AI: Use the identity
build.k8s.python. Stable Context, Result, Extension, Ability, and default behavior belong inspark-console-sdk; orchestration remains inspark-pipeline; the Kubernetes-specific Python implementation belongs inspark-k8s-plugin. The plugin receives source material, build parameters, and credential references prepared by the platform, then returns image, log, and status observations. It does not read platform business tables. The scenario entry point opens one Session Scope, and Pipeline does not add a newPYTHONbranch.Me: Check that design against the dependency rules. If it passes, implement one module at a time and report the governing rule and test evidence after each layer.
AI: I will implement the leaf extension contract and safe default, then the Ability, plugin
@Realization, platform invocation, and tests. Before handoff I will check that the platform does not depend on the plugin, the SDK contains no implementation objects, and no internal helper rediscovers business identity.
The real leverage in that exchange is forcing the agent to expose its architectural assumptions while fixing them is still free. Identity, module placement, and dependency direction get corrected before thousands of lines materialize. Once coding finishes, the same Skill runs a reverse audit: did a Controller smuggle in orchestration? Did a database object slip into the SDK? Did a plugin bypass Context to query a core table? Did an inner helper open a second Session Scope? Did individual Activities commit database writes and search-index updates on their own?
For complex operations—creating, transitioning, or bulk-updating tasks—the Skill further requires one Request and one Result up front, with a Process orchestrating discrete Activities. Each Activity accumulates validation, authorization, assignment, persistence plans, and event plans into that shared Result, while all database, search-index, and event side effects fire together at the end of the Process. What comes back is a use case whose conceptual integrity remains intact rather than a pile of ad hoc glue classes.

Figure 5 · Turning architecture principles into executable AI constraints. Narrative docs hold the rationale, checkable guidelines draw the red lines, and the Skill produces a reviewable design up front and audits boundary violations afterward—anchoring identity once at the entry, sharing one Result across Activities, passing data through plugin contracts, and gathering side effects at the end of the Process.
Working this way reshaped how I view architecture documentation. For years, architecture docs were post-hoc explanations that gathered dust once code shipped. With AI writing production code, documentation doubles as a control input—carrying reasons, allowances, prohibitions, trigger conditions, and verification proof. AI will never invent clean architecture on its own, yet it opens a rare door: turning instincts that used to travel slowly by word of mouth among principal engineers into a repeatable check executed on every design and pull request.
Looked at through that lens, Lattice reaches well past runtime extension lookup. Business identity, Context, Result, Ability, and plugin contracts define a shared change protocol that both humans and coding agents can read cleanly—who may vary what, where the code lives, what crosses the border, what evidence returns, and where the blast radius stops.
25Closing: letting change stop where it belongs
Looking back at that exhausting 2015 transaction platform, it never suffered from a shortage of APIs, microservices, or extension hooks. What it lacked were four solid boundaries: between business and platform, between one business and another, between logical flows and physical service topology, and between management-time decisions and runtime execution.
Without those boundaries, more APIs breed more opaque Map bags, more SPIs grow deeper hidden decision trees, and more microservices push complexity straight onto cross-team coordination calls. Every locally sensible technique quietly forwards the bill somewhere else as scale climbs.
Lattice simply pulls those hidden bills back into the architecture—restoring three separations, then giving teams Ability, two-dimensional composition, Reduce, and Use Cases so boundaries can actually be designed, executed, and audited. Rereading Clean Architecture reinforced one quiet certainty: good architecture never promises that commercial reality will grow simple. It gives a team confidence that when the next unexpected requirement hits, everyone knows where it belongs, what it depends on, whom it touches, and exactly where it stops.
Now that AI sits alongside engineers writing code, those boundaries cannot remain private folklore inside a handful of heads. Putting them simultaneously into repository knowledge, executable Skill workflows, and handoff verification is what keeps faster code generation from dissolving structure.
To me, that is the whole meaning of “clean”: change keeps flowing, yet it never overflows its banks.
References and further reading
- Robert C. Martin. Clean Architecture: A Craftsman’s Guide to Software Structure and Design. Pearson / Addison-Wesley, 2017.
- Robert C. Martin. “The Clean Architecture Dependency Rule.” InformIT, 2017.
- HiForce. “Lattice Framework.” GitHub. At this essay’s latest update, the main-branch
pom.xmldeclared version1.0.21. - HiForce. “Lattice Sample.” GitHub. Includes Quick Start, Use Case, and multi-capability composition samples.
- HiForce. “Lattice Clean Architecture Practice Sample.” GitHub. Demonstrates project organization across entities, use cases, interface adapters, and business plugins.