In-process postures

Same product behaviour. Three hop graphs.

AI cost is not “how modern the syntax looks.” It is how many types an agent must confirm are equivalent before one rule can move. These three postures keep HTTP in and a database out; they disagree only on where the use case lives.

Layered

HTTP controller
  → service façade
    → mediator
      → handler
        → unit of work
          → repositories
            → factory → provider
              → database

Errors leave as thrown domain exceptions and re-enter as ProblemDetails. Request types are copied at the API edge and again in the application layer.

Modular

Minimal API route
  → feature handler
    → account module
    → ledger module
    → provider switch
      → database

Handlers aggregate modules in one assembly. Status lives on the response body. DI registers handlers and modules once at the composition root.

Operation-local

HTTP route
  → Features/Operation.cs
      request · rules · EF
      closed Outcome
      HTTP mapping
  → database

No feature DI. The route constructs the data context. Related behaviour is physically in the file the map points at.

What the agent must find to add one product rule

How Layered, Modular, and Operation-local answer the same five questions when adding a product rule.
Question Layered Modular Operation-local
Where does the command live? Handler + façade + repositories + factory Handler + modules One operation file
How do I add GET/PUT for a setting? Command, query, DTOs, contracts, interface methods Feature folder + handlers Copy the operation template for each endpoint
How do I find the files? Search the layered projects Search Features/ and Modules/ Read the feature map
Business errors Exceptions + middleware status codes Shared status on HTTP 200 Closed union local to the file
Hidden coupling High: UoW, factory, mediator, mapping Medium: DI of handlers and modules Low: options constructed at the route

Why Layered loses on both axes

Every new field or outcome fans out across Domain → Application → API. The agent cannot locally reason about a setting without also knowing the mediator request type, the service façade, and the contract types. Extra tokens are types that exist only to satisfy layers. That is hop tax.

Why Operation-local can spend more tokens than Modular

Local reasoning cuts irrelevant hops, not characters in the file you edit. Closed unions, header examples, and copy-not-share raise the token count of that file on purpose. They buy cold-start completeness. Modular is cheaper once the agent already loaded the modules. Choose the cost you actually pay: search vs density.

Across process boundaries the ranking is simpler than in-process tokens. Topology covers that layer: end-to-end ownership costs an agent far less than one RPC behind a façade, which costs far less than a chatty mesh.