mobile menu icon

Simple Deterministic Tools and LLM-Generated Counter-Examples to Test Our Architecture Tests

Published by Manuel Rivero on 27/11/2026

AI, Agentic-AI, Architecture Tests, Testing, AI Guardrails, Mutation Testing


Introduction.

In a previous post we presented the idea of using LLM-generated counter-examples to test architecture tests.

We used the power of LLMs to generate counter-examples for architectural rules , which we then stored, and to vibe-code a deterministic architectural mutation testing script that allowed us to reuse the stored counter-examples every time a rule was added or changed.

Creating this script was an application of the Offload Deterministic pattern that allowed us to save time and tokens, and, even more importantly, separate the non-deterministic process of generating architectural mutants from the deterministic process of replaying them.

This idea of using LLM-generated counter-examples to test architecture tests has proven very useful to us in our current project because we’ve been gradually extending our architectural guardrails beyond the minimal initial set of rules[1].

Tools for deterministic architectural mutation testing.

Why we are not using archmutant

When we first presented this idea in a previous post, we illustrated it with an internal vibe-coded tool, archmutant.

archmutant was useful for illustrating the idea of using counter-examples to test architectural rules, but we’re not using it in our current project because the kind of HTML report it generated was optimized for humans rather than for agents.

What we are using now.

We developed two architectural mutation testing scripts with the help of agents that behave similarly to archmutant, except that they generate text reports in the console that are easier for agents to consume. We are using one for the frontend and another one for the backend[2].

Execution flow of our deterministic architectural mutation testing scripts
Execution flow of our deterministic architectural mutation testing scripts (click to enlarge).

Let’s go through what the script does in a bit more detail:

  1. Loads the counter-examples that we previously generated with an LLM from a configuration file. Each counter-example contains code that is meant to violate a particular architectural rule.

  2. Discovers the architectural rules from our existing architecture tests.

  3. Validates the counter-examples, checking, among other things, that the architectural rules they are meant to violate actually exist.

  4. For each counter-example:
    • Temporarily introduces the counter-example into our codebase (this is how we create a mutant).
    • Runs the architecture tests.
    • Checks whether the test for the architectural rule that the counter-example was meant to violate fails. If it does, we’ve killed the mutant; otherwise, the mutant survives.
    • Removes the counter-example from our codebase before testing the next one.
  5. Generates a mutation report showing which mutaexcept thatnts were killed, which ones survived, and which architectural rules don’t have counter-examples yet.

  6. Fails if there are any surviving mutants.

Notice that, for a mutant to be killed, it’s not enough that the architecture tests fail. We want the test for the particular rule that the counter-example was meant to violate to fail. Other architecture tests may fail as well (this happens with some of our backend counter-examples).

There are a couple of limitations of the current versions of the scripts that are worth mentioning:

What we’re doing here is using the idea of mutation testing to get feedback about the effectiveness of our architecture tests, not about whether our codebase complies with our architectural rules. That’s why we only run these scripts when we change our architecture tests, either because we’re adding new architectural rules or because we’re changing existing ones.

We also developed an architecture-rules skill, which combines the generation of counter-examples, the writing of architecture tests and these deterministic architectural mutation testing scripts to help us safely add new architectural rules or change existing ones. We’re still refining the skill (you can see it in action in this lab). We’ll describe it and share it in a future post.

Conclusions.

We’re writing architecture tests as guardrails for our coding agents more frequently than ever. It’s a kind of “arms race” between the agents and us. We need ways to make sure that our architecture tests work and continue to work as we evolve them, and we think that LLM-generated counter-examples and deterministic architectural mutation testing can help with that.

In this post, we showed you how we’re applying this idea with very simple internal tools developed with agents. In a future post, we’ll share with you the skill we’re using to automate the workflow of safely evolving our architectural rules.

Acknowledgements.

Thanks to Antonio de la Torre for giving me feedback on several drafts of this post.

Thanks also to Anna Shvets for her great photo.

References.

Notes.

[1] Our previous post Tailoring Our Architectural Guardrails to a New Project was devoted to describing that evolution. The fact is that just a couple of days later, the rules described in that post were already outdated, since we had to introduce new rules in a kind of “arms race” with the agents 😅.

[2] Both scripts are practically the same. We haven’t bothered to generalise them into a single script that works with different languages because they work fine, and we didn’t want to spend more time on them at the expense of our client’s project.

Volver a posts