Freshware · Interactive Workbook
MDX Source Edition Residual Systems & Verified Compilation Learning Center & Videos
Part II · The First Residue · Chapter 02

Residuality Theory: Stressors, Attractors, and Contagion

Why Domain-Driven Design boundaries drawn around business nouns still fracture under shock — and how Barry O'Reilly's Incidence Matrix tells you where to put the walls.

Reading time: 8 min Interactive: Lab 01 · Residuality Incidence Matrix Source: src/content/chapters/02-boundaries-and-stressors.mdx

Traditional software architecture asks: What are the entities in this business today, and what features do users want next?

Barry O’Reilly’s Residuality Theory starts from the opposite premise. Real software operates inside hyperliminal systems: strictly logical, complicated deterministic modules embedded inside an unpredictable, complex environment of shifting vendor PDFs, flaky remote APIs, regional tax updates, and hurried human operators.

Drawing on theoretical biologist Stuart Kauffman’s work on Random Boolean Networks, O’Reilly notes that although a complex business environment has an astronomical number of possible configurations, stressed systems settle into a much smaller family of stable operating regimes called attractors.

From Hand-Waving to the Incidence Matrix

When Domain-Driven Design teams draw Bounded Contexts purely from nouns on a whiteboard, hidden couplings lurk beneath the surface. Everything looks modular until a single supplier changes an invoice header and suddenly breaks line arithmetic, catalog matching, ledger deduplication, and audit logging all at once.

Residuality Theory replaces architectural intuition with an Incidence Matrix: rows represent random and adversarial stressors, columns represent system modules, and each cell records whether that module breaks, forces a recompile, stays cached untouched, or holds an invariant firm.

Explore the interactive workbench below. Switch between a Naive Coupled System and Residual Bounded Contexts, or fire stressors at random to measure the exact Contagion Score and Blast Radius.

Interactive Lab 01 · Residuality Incidence Matrix

Does Your Boundary Actually Stop Contagion Under Stress?

Contagion Cells 6 / 36 Naive baseline: 32 / 36
Mean Blast Radius 17% Share of modules hit per shock
Sha256 Cached (0 Tokens) 14 Untouched contexts skipped cleanly
Tier 0 Survival 6 / 6 Shocks with accounting core intact
Inspect stressor:
Beverage supplier redesigns invoice layout

A major distributor shifts barcode positions and moves bottle-deposit fees into a nested summary box.

Stressor Scenario Document Intake
tier2
Extraction Adapter
tier2
Line Math & Totals
tier0
Catalog & Account Match
tier1
Ledger Write & Dedupe
tier2
Immutable Audit Trail
tier0
Blast
Beverage supplier redesigns invoice layout
sha256-cached
Ingestion queue isolated by content hash
recompiled
Only Tier 2 extraction adapter recompiled + gate-checked
invariant-held
Tier 0 penny-sum invariant rejects bad parses
sha256-cached
Catalog lookup untouched (zero tokens)
invariant-held
Idempotent ledger boundary never sees bad input
invariant-held
Immutable run verdict recorded
1/6
Accounting ledger API renames tax-code field (422)
sha256-cached
Ingestion unaffected
sha256-cached
Extraction untouched; canonical bill unchanged
invariant-held
Tier 0 math core isolated from wire format
sha256-cached
Policy rules untouched
recompiled
Tier 2 anti-corruption adapter recompiled + verified
invariant-held
Provenance bundle updated atomically
1/6
Accounting ledger API suffers 15-minute 503 outage
sha256-cached
Items stay queued safely
sha256-cached
Zero re-extraction needed
invariant-held
Math core untouched
sha256-cached
Policy bundle unchanged
invariant-held
Stressor classifier detects outage -> pauses with 0 thrash
invariant-held
Circuit-breaker pause logged cleanly
0/6
Operator adds bottle-deposit rule in shared playbook
sha256-cached
Ingestion unchanged
sha256-cached
OCR layout unaffected
invariant-held
Tier 0 accounting math bounds candidate rulebook
recompiled
Tier 1 rulebook compiled & verified against Golden Pins
invariant-held
Dedupe & balance gates enforced before promote
invariant-held
Version bundle promoted atomically with rollback link
1/6
New hospitality venue onboarded with local codes
sha256-cached
Shared runtime unchanged
sha256-cached
Vendor parser reused via hash
invariant-held
Same core invariants apply
recompiled
Per-location Tier 1 rulebook compiled in isolation
invariant-held
Site-scoped tenant key verified statically
invariant-held
Separate durable conversation & spec pack initialized
1/6
Regional tax regime alters credit-note rounding
sha256-cached
Ingestion untouched
sha256-cached
Extraction untouched
recompiled
Conflict halted; requires person-ratified Tier 0 update
recompiled
Tier 1 tax mapping compiled after Tier 0 decision
invariant-held
Signed credit-note guard waits for Gate 1 + Gate 2 pass
invariant-held
Decision record appended with human ratification
2/6

Contagion Analysis Unifies DDD and Freshware

Watch what happens inside the matrix when you compare the two modes:

  1. In Naive Mode (28 / 36 cells affected): Because prompts, parsing logic, math rules, and external API DTOs share unseparated state, almost every shock propagates across 4 to 6 modules. Worse, Tier 0 accounting invariants break under stress — penny equality slips during layout shifts and transient 503 outages provoke frantic prompt rewrites.
  2. In Residual Mode (6 / 36 cells affected): Placing Tier 2 Anti-Corruption Adapters at the perception edge (Extraction Adapter) and ledger edge (Ledger Write & Dedupe), insulating Tier 1 Policy Rules, and hardening Tier 0 Accounting Core cuts mean blast radius to 17%, keeps untouched modules skipped at zero token cost (sha256 cache hits), and ensures 6 / 6 shocks leave Tier 0 invariants unbroken.
Inspect Incidence Matrix & Contagion Equations

Let S be the set of simulated stressors (|S| = 6) and M be the set of system modules (|M| = 6). Each matrix cell c(s, m) belongs to {broken, recompiled, sha256-cached, invariant-held}.

  • Row Contagion: Contagion(s) = count(m in M where c(s, m) in {broken, recompiled}).
  • Blast Radius Ratio: Blast(s) = Contagion(s) / |M|.
  • Zero-Token Cache Savings: Modules marked sha256-cached prove identical build inputs and skip LLM recompilation completely.
  • Tier 0 Survival Predicate: A shock s preserves core safety iff no Tier 0 module (Line Math, Audit Trail) enters state broken.

Notice a subtle bonus of viewing software through O’Reilly’s Incidence Matrix: you never have to predict the exact future. Simulating enough diverse stressors exposes structural couplings before production traffic discovers them. Once the walls sit in the right places, we need a mechanical runtime harness that actually extracts, stores, protects, and forks those constraints as sessions unfold.

Theoretical Archive · 01 Residuality & Complexity

Go Deeper: Residuality Talks & Primary Readings

Explore full Learning Center (14 in pillar) →

Barry O'Reilly's architectural theory of hyperliminal systems, random stressor simulation, contagion analysis, and Kauffman attractors — defining what must survive external shocks.

Barry O'Reilly · Code BEAM Lite Stockholm · 2026

Keynote: Residuality Theory in Software Architecture

Barry O'Reilly · NDC London · 2024

An Introduction to Residuality Theory