Le secrétaire de Fernand

Step 6: Fitness functions keep the architecture

Step 6: Fitness functions keep the architecture

The sixth step of the harness I put around my coding agents: fitness functions, tests that check a property of the architecture on every change and fail the build.

1 min read

My skills described the architecture and the agent followed them most of the time. Most of the time is not enough to hold for months. What holds: a fitness function, a test that checks a property of the architecture on every change and fails the build.

Böckeler's grid

Two dimensions. A guide acts before the agent, a sensor after. Each is inferential, judged by a model, or computational, decided by a program. Inferential guides are what the agent reads, AGENTS.md, a skill, a plan, sharper written in the literature's words; computational guides are deterministic tools, a codemod, a generator, a command that acts in the agent's place, code mode, where the agent writes a program instead of a string of actions, a language server. Inferential sensors are a review by a model or a person; computational sensors are the type checker, the linter, tests and fitness functions. Each practice moves a judgement toward computation, and the computational sensor is the optimum.

Inferentiala model judges, your attention follows
Computationala program decides, without your attention
Guidesbefore the agent acts
  1. 4 · literature in skills
  2. 5 · skills
toward computation
a codemod · a generator · a command (CLI) · code mode · a language server
Sensorsafter the agent acts
a review by a model or a person
toward computation
the optimum
  1. 1 · type checker
  2. 2 · linter
  3. 3 · dead code
  4. 6 · fitness functionstoday

In Birgitta Böckeler's grid of guides and sensors, a fitness function moves the architecture rule from an inferential guide, the skill, to a computational sensor, the test. The skill keeps the why. The series' map: Guides and Sensors: Mapping Your Attention to Free It

How to write one

In Java, ArchUnit does it: ArchUnit In TypeScript a plain test that reads the imports does the job.

Mine: each folder of the domain imports no infrastructure, no file system port, no telemetry. A test walks the folder and fails on the first such import. A phase that breaks it doesn't commit.

The term comes from Building Evolutionary Architectures, by Neal Ford, Rebecca Parsons and Patrick Kua, with Pramod Sadalage for the second edition: Building Evolutionary Architectures

If you want an example, here are my architecture tests: lbdremy/phax/tests/unit/architecturalGuards.test.ts

Next in this series: Step 7: A plan in phases

A thought after reading?

If you would like to discuss about this article, you can write to me here. I share because I care and I want to learn. Please teach me with care.

Send me an emailremy@lesecretairedefernand.co