What residuality theory is, and why it matters when agents write the code

Residuality theory stresses a naive architecture with invented changes in the business and keeps what survives. Coding agents build the happy path fast and cannot see what is not in the prompt, which makes stressors and residues more valuable than before.

Published
Reading time
8 min

A coding agent can take a well-described request and turn it into working code in minutes. The harder part shows up later. In a preprint published in November 2026, two researchers at Amazon gave ten coding agents chains of 20 consecutive requests taken from 140 open-source projects. Taken one at a time, the agents completed 95% of the requests on average. Chained together, they completed 51% (Cuadron and Gupta, 2026). Their explanation is simple: an agent declares a request done once its own tests pass, and every later request is built on whatever it missed.

That paper is about verification, and I will not stretch it further than it goes. It does show a pattern that matters for architecture. An agent is good at the request in front of it and much weaker at what accumulates over time, and architecture lives exactly in that second place.

Among the approaches to how architecture evolves, the one closest to my own thinking is Barry O’Reilly’s residuality theory. I have mentioned it only in passing, in walking the organization again and in why architecture has to remember why. This one is an introduction: what the theory says, and why I think it becomes more relevant when agents write the code.

We design for a world we cannot predict

The way I see it, we design an architecture for today. We take the requirements the business has given us and produce the best architecture we can at that moment. Then time passes. The business brings new requirements, and some of them are interesting enough to change the architecture significantly.

Barry gives this problem a name. Business systems, meaning the people, markets and regulations around the software, are non-ergodic: their future is not already contained in their past, so past behaviour does not let you predict it. He calls the assumption that the future of a business will look like its past one of the most common mistakes an architect can make (Residues, p. 7). Requirements are caught by the same problem. In his words, a requirement is “a snapshot of a specific stakeholder’s model of a system at a specific moment in time” (Residues, p. 33).

So what is an architect supposed to do with a future nobody can predict? Barry’s answer is to stop predicting and start stressing.

Naive architecture, stressors and residues

The method starts with a naive architecture: a design that solves the problem as it has been stated. Barry does not mind how you produce it. Any method will do, which is also why applying the theory does not require you to abandon your current way of working (Residues, p. 18).

Then you stress it. A stressor is anything outside your current understanding of the system (Residues, p. 37): a new regulation, the loss of your biggest customer, a new sales model. It needs only a coherent story of how the wider business would move into a different state. Consensus, likelihood and an assigned probability are all optional (Residues, p. 33). That is what sets it apart from an entry in a risk register.

For each stressor you ask one question: would the naive architecture survive in the business this stressor creates? Whatever is left of the architecture after the hit is the residue. You change that residue so that it would survive, and you record it as a short description of the changes the naive architecture needs, which keeps the exercise light (Residues, p. 19). You repeat this with many stressors and many stakeholders, and then integrate the residues into one architecture.

Why would invented stressors lead to a better design? Because of attractors. A business can be hit by an almost unlimited number of events, but the interactions between its elements constrain it to “a very small number of potential states” (Linders, InfoQ, 2025). Many different stressors push the business into the same few states. Each time you make the architecture survive one of those states, it also survives all the other stressors that lead there, including the ones nobody thought of (Residues, p. 22). This is why the stressors do not even have to be likely.

An example from the book

Barry’s own example is a stressor that destroys your datacentre. The business says it will not happen, a short outage would not hurt much, and a second datacentre is too expensive. The architect designs the residue anyway: components that know a second set of components may be running elsewhere, and sessions that can be moved between them. Then a second stressor arrives, the budget, and the business decides to stay in one datacentre. That is a perfectly valid decision. The architecture is now ready to move to several datacentres later at lower cost and risk, and it copes better with growth and foreign expansion too (Residues, pp. 47-48). A residue in the design does not have to be fully implemented.

Testing the result

The part I find most interesting is the test. Once the architecture is done, you write a new list of stressors that were not used during design and count how many of them the naive architecture and the residual architecture survive. The difference, divided by the number of stressors, gives a residual index between -1 and 1. Above zero, the design work moved the architecture in the right direction. When the index stops growing across iterations, further design work stops paying off (Residues, p. 44). Barry compares it to the training and test sets used in machine learning, and he sums up the theory in one line: architectures “should be trained, not designed” (Linders, InfoQ, 2025).

Why it matters when agents write the code

Residues does not discuss coding agents, so what follows is my reading.

First, an agent builds the naive architecture by default. Give it a requirement and it will implement that requirement, often well. Barry warns against “the dreaded happy path architecture”, a design built against the picture the team already has (Residues, p. 19). A prompt produces exactly that picture, only faster. The preprint from the beginning describes the same thing at the level of code: what limits agents left alone is the mistakes they cannot see (Cuadron and Gupta, 2026). A stressor is something the agent cannot see either, because it is not in the prompt.

Second, cheap code moves the hard part. When an agent can implement a change in an afternoon, the expensive question is which change is worth making. Barry points out that a naive architecture that fails a stressor is easy to change at this early stage (Residues, p. 19). Stressor analysis is a way to find the important changes while they are still just text.

Third, agents make the opposite mistake very easy. Barry describes an anti-pattern: building flexibility into the code with no idea what will actually change in the business, which ends in over-engineering, with dependency injection or microservices as default answers to an unknown future (Residues, p. 21). Ask an agent to make something flexible and it will happily generate layers of abstraction. With residuality, every bit of flexibility is tied to a named stressor, and anything without one is a candidate for removal.

Fourth, stressors give the guardrails something to protect. I underestimated fitness functions before AI. Partly I did not know how to write them, partly I did not understand them. Now I cannot imagine working with agents without those boundaries. A fitness function gives an objective check of an architectural characteristic as the system changes (Building Evolutionary Architectures, p. 14). A list of stressors and residues tells you which characteristics will matter when the business moves, and the second list tells you whether the architecture would survive. Both are plain text, so both can go into an agent’s context or be checked against its output.

Barry himself points in a similar direction. Asked how AI is shaping architectural design, he answered that its impact “won’t be asking an LLM what to do”, and that “we’ll use AI ideas to change how we think about and solve problems”, naming randomness, simulation, and training and testing sets (Dear Architects). In November 2026 he gave a lecture in Zurich titled “Rethinking Architecture Through Residuality and AI”. Its description, written by the organizers, calls agentic and harness engineering “an attempt to automate architecture” and says residuality is well placed to answer the questions that follow (Software Leader, 2026).

How we use it, and where I would be careful

Barry does not soften his claims. He writes that random simulation of stress is more effective than requirements engineering, risk management and pattern matching, and that these traditional ideas are harmful (Residues, p. 62). He also states that experiments have shown a statistically significant effect, and leaves the details of those results for a longer book (Residues, pp. 44 and 63). If you want to judge the evidence yourself, his papers in Procedia Computer Science are the place to start, for example his 2022 paper on random simulation and attractor networks.

In our work at Arpeggia, residuality sits on top of our own method. Our six steps for designing architecture still start with functional requirements and event storming, and they give us the best architecture we can build for today. When that architecture starts to live and the business brings requirements that could change it significantly, we take another tool: Barry’s stressors.

A first step

Take one feature an agent is about to build for you, and treat its design as your naive architecture. With two or three people from outside the development team, for example from sales, finance or operations, write down ten stressors: things that could happen to the business, each with a short story of what the business looks like afterwards. For each one, ask whether the design survives, and write the residue as a few lines describing what would have to change. Keep a second list of stressors aside for the test. Barry says you will not need any tool beyond a spreadsheet (Residues, p. 45).

If you want to go deeper, read Residues first. It is short and deliberately less academic than his papers (Residues, p. 1). Arpeggia.studio, the company I co-founded, is bringing Barry to Warsaw for his first workshop in Poland, Advanced Software Architecture with Residuality Theory, on 1 to 3 March 2027, so take the recommendation with that in mind. Details and tickets are here.

Residuality Theory: the first workshop with Barry O'Reilly in Poland, Warsaw, 1 to 3 March 2027, three days in English, Arpeggia.studio

Sources

Choosing a vendor or shaping a project team?

Tell me what you are deciding and who is involved. I will tell you honestly whether I can help.