Case Study

The Self-Auditing
Codebase

When architecture diagrams become bug specifications

March 25–27, 2026 Active Pattern
The Idea

What if the architecture diagram is the test?

Generate a DOT graph from code. Compare it to the design doc.
Feed the graph to AI agents as a specification.
Let them measure the code against its own architecture.

Act I · Mar 25–26

Building the Pipeline

"We want a dot file that is purposeful — to the goal of explaining a system architecture. Not a call graph. Not file names pointing to line numbers. Those aren't useful."
— User, establishing the vision

It started with the team-knowledge-base project. The user generated a deep DOT graph of the team-kb codebase, then compared it against the design document. The gap between diagram and design revealed concrete, actionable issues.

The Graph

One DOT file. 667 lines of architecture.

667
Lines of DOT
70
Nodes
99
Edges
8
Clusters

The user then built DOT generation into the team-kb CLI and ran it against amplifier-chat, producing two key files:

amplifier-chat.dot

System architecture overview — 5-tier: entry points → daemon → plugin backend → SSE streaming → frontend SPA → disk storage

event-flow-deep.dot

Deep event flow with 7 annotated bugs (BUG-01 through BUG-07) and 3 structural gaps embedded directly in the graph

The Gap

Diagram vs. Design Doc

Comparing the generated architecture graph against the original design document revealed concrete discrepancies:

01
Stub Functions

Functions declared in the design but never implemented — empty shells that silently passed through.

02
Dead Fields

Data fields declared in structures but never populated by any code path — ghosts in the schema.

03
170 Lines Duplicated

Logic duplicated between modules — copy-pasted implementations that should have been shared.

The architecture diagram didn't just describe the system. It became a contract the code was measured against.

The Breakthrough
"Less for human consumption and more for context/pointers for agents — they can provide more bang-for-the-buck (more context for fewer tokens) than other approaches."
— Brian, on the value of DOT graphs for AI agents

A 667-line DOT file encodes more structural information than thousands of lines of raw source code.

Architecture as compression.

Act II · Mar 27, 1:00 AM

DOT as
Bug-Finding Spec

4 parallel Amplifier sessions.
Each consuming a DOT file.
Each diving into the code.

1:00 AM – 3:30 AM · One continuous night session
Parallel Attack

Four sessions, four angles

S1
Architecture Audit
14 turns · amplifier-chat.dot

Fed amplifier-chat.dot. Dispatched 3 parallel agents (frontend, backend, test/git-history). Found 24 issues across 4 categories.

S2
Bug Validation
7 turns · event-flow-deep.dot

Fed event-flow-deep.dot with its annotated bugs (BUG-01 through BUG-07). Agents validated each against source code.

S3
Cross-Validator
8 turns · independent verification

Read Session 1's findings via session-analyst. Dispatched parallel agents (Security, Frontend, Backend) to independently verify every issue. Found an additional vulnerability the original session missed.

S4
Execution
52 turns · git worktrees → 4 PRs

Cross-checked with all other sessions. Designed a 4-PR fix plan organized by regression risk. Implemented all fixes using git worktrees.

The Human Router

Manually shuttling findings between sessions

"Another session found this, can you clarify if it's accurate"
"The other session gave you this feedback, can you validate?"
"I just passed back your assessment into the other session."

The user became the orchestrator — a human message bus routing findings between competing AI sessions for independent verification. Each session could challenge the others' conclusions.

The Findings

36+ verified issues, 4 categories

G1 Security — path traversal, regex mismatch, event loop blocking 6
G2 Event Pipeline — token routing, race conditions, lineage loss 9
G3 Backend Reliability — atomic writes, thread safety
G4 Frontend State — memory growth, toolMap contamination

31 confirmed unique issues. Session 4 discovered an additional bug during implementation. All stemming from two DOT files used as specifications.

Cross-Validation
24/24
Issues independently confirmed real
22
Fully confirmed
2
Partially confirmed
+1
New vulnerability found

When parallel sessions independently converge on the same findings, confidence is multiplicative.

Act III · ~3:00 AM

The Meta-Realization

"I have 4 different sessions investigating the same issue. Is there a way I can have them talk to each other? Continue the conversation until they all agree."
"HELLO! Different amplifier sessions. On my terminal. So what are the ways that they can talk to each other until they all get agreement?"

The workflow was so powerful it demanded its own infrastructure. The user designed a cross-session consensus protocol — sessions that could autonomously converge on findings, observable and interruptable.

The Pattern

The Self-Auditing Feedback Loop

Generate
Architecture
Compare to
Design
Feed to
Agents
Update
Architecture
Fix
Bugs
Find
Bugs

The architecture diagram is both the map and the test.
The codebase audits itself.

By The Numbers

One night session

4
Parallel sessions
81
Total turns
36+
Issues found
31
Confirmed unique
4
PRs squash-merged
~2.5h
Total elapsed time

From DOT generation to merged fixes, driven by architecture-as-specification and cross-session validation.

Sources

Research Methodology

Data as of: March 27, 2026

Pattern status: Active — discovered workflow, not a shipped product feature

Primary source:

Quotes:

Gaps & caveats:

Primary contributor: Single user conducted all sessions and provided the full account

Try It

Your architecture knows where the bugs are.

Generate a DOT graph. Feed it to an agent.
Let the code audit itself.

# 1. Generate the architecture amplifier dot-graph --repo ./my-project # 2. Feed it to an agent as a spec amplifier chat "Review this codebase against its architecture: @my-project.dot" # 3. Cross-validate with a second session amplifier chat "Verify these findings independently: @findings.md"
More Amplifier Stories