Standalone · 12 min read v1.10 · Published 19 June 2026 · Updated 22 June 2026
A specification document with R1 and R2 flows through a guarded arrow into a three-tier test pyramid with checkmarks — specs drive, tests validate.

Specs Drive. Tests Validate.

The assistant message read perfectly. The Playwright journey still failed on a 403. The unit test on the progress FSM caught a false clarify increment the chat never surfaced. Three different layers, three different failures — and I would have shipped if I had only read the transcript.

I am building a full-stack application in parallel with the open-source evaluation work in this lab. Almost every line is agent-drafted. What keeps it from becoming a demo is not better prompting. It is a loop I treat as non-negotiable: write the spec first, encode acceptance in tests, let agents implement between those guardrails. Agent quality work sits on top of that — it does not replace it.

Context

Specification-driven design (SDD) here means product and engineering specs with explicit functional requirements, acceptance criteria, stable error codes, and often a testing section before implementation lands. The spec is the driver: it says what “done” means.

QA is the familiar application test pyramid: unit and component tests on business logic, API handler tests, browser E2E for user-visible flows, CI gates on coverage and lint. The tests are the validator for the spec’s acceptance blocks.

AQ (agent quality) is the extra lane when conversational agents own multi-turn state. I covered that separately in Agent Quality Engineering: Grade the Protocol, Not the Chat. AQ validates protocol over turns; QA validates that the app lets the user finish.

LaneDrives or validates?Question
SDDDrivesWhat must be true when we ship?
QAValidatesDoes the application behave that way end-to-end?
AQValidates (agents only)Does the agent obey caps, progress, and completion rules?

Specs without tests are marketing. Tests without specs are archaeology. Agents without both are fast fiction.

Specs drive, tests validate SDD drives intent; agents draft implementation; CI signs; QA and AQ validate behavior. SDD drives Requirements, acceptance, error codes What done means Agents draft Handlers, UI, tests, infrastructure Between guardrails CI signs Coverage, lint, stub E2E Before validate QA validates App, auth, journeys Always AQ validates Progress, caps, scenarios When agents

What the spec actually contains

On the application I am building, I keep specs under docs/specs/ — not as decoration, but as the artifact agents read before they touch code. UX surfaces get the same treatment: feed-and-home-ux.md maps static HTML mockup regions to numbered requirements and acceptance checkboxes for the feed-first home. A typical SDD slice looks like this:

Example shape (abbreviated):

### R1 — Eligibility

Only allow the workflow when preconditions are met (linked account, active session, required prior step completed).

**Acceptance:**
- Ineligible requests return 400 with stable error codes.
- Cross-principal access returns 404.

### R5 — Finalize

**Acceptance:**
- status becomes finalized; mutation endpoints return 400 afterward.
- Parent session and audit trail unchanged.

That is not prose for stakeholders only. It is the contract the next pull request must satisfy. When an agent proposes an implementation, I point it at the SDD section and say: make these acceptance bullets true.

Larger design docs add a Testing plan section before code: which routes get handler tests, which flows get Playwright integration, which negative cases must fail closed (unsupported upload, cross-owner access, sandbox mode must not create production records). The agent’s job is to implement; my job is to ensure the plan becomes real tests, not a checklist in a forgotten doc.

What the test pyramid looks like at scale

Order-of-magnitude numbers from the stack as it exists today — not to impress, but to show this is not “we should add tests later”:

LayerRough scaleRole
Unit / component (*.test.ts, *.test.tsx)About a hundred filesProgress FSM, RBAC, validation, UI states, wizard steps
Python unit / benchmark (test_*.py)About a hundred files, hundreds of casesAgent runtime, structured progress, scenario validators
Playwright E2E (*.spec.ts)A dozen-plus specsStub journeys in CI; integration against real auth + deployed API
Agent scenarios (YAML)About fifteen gated pathsClarify, cap, digression, parity — see AQ post

CI runs static checks, workspace unit tests, stub E2E, and coverage gates (≥95% lines/statements/functions on the packages that own behavior). Live LLM benchmarks and full integration E2E are opt-in locally or in separate workflows — same distinction as stub vs live in the evaluation lab.

Role-based APIs need exhaustive negative cases and agents will not infer them from happy paths. One handler test file alone can exercise thousands of lines of in-process routing — not because I love big files, but because “works for admin” is not the same as “403 for the wrong role.”

How the three lanes connect on one feature

Take “user completes a multi-step workflow, then the result becomes immutable” as a thread through the stack:

  1. SDD — R1 eligibility codes, R5 finalize immutability, R6 UI section distinct from the prior step’s summary.
  2. Unit — store rules, workspace helpers, 400 on writes after finalize.
  3. E2E — browser journey: open the flow, complete steps, finalize; stub variant for CI without external auth.
  4. AQ — not the primary gate for this feature (no multi-turn agent), but the conversational agent that feeds the workflow still has scenario coverage elsewhere.

The spec row is the spine. Tests are keyed to acceptance bullets, not to “we implemented something.” Traceability tables (requirement id → route → page → status) stay honest about partial vs done so agents do not claim green on placeholders.

Agents in the middle

I described the operating model in Agents Draft. I Sign.: walk the problem, loop through mechanisms, sign what ships. On the full-stack application, that loop has a concrete split:

Cursor rules in the private repo encode the same bar on every session: coverage floors, positive and negative scenarios, E2E for new behavior, no gaming gates. Agents did not choose that discipline; I did, and I made it machine-enforced so future agent sessions inherit it.

The failure mode I watch for is spec lag: an experiment harness prototypes a new FSM ahead of production, documented as tech debt until parity tests pass. That is acceptable temporarily. Test lag is not — if acceptance is written and there is no test, the agent can “satisfy” the spec in prose.

AQ is not a substitute for QA

The AQ post focuses on grading progress objects across scripted user turns. That caught bugs no E2E would prioritize — a polite digression incrementing a clarify counter, cap applied one turn early.

E2E still matters. It catches auth wiring, wrong portal routing, CORS, and “button does not submit.” AQ catches “session state lied while the UI smiled.” You need both, plus unit tests on the deterministic finalize layer because that is where agents and servers must agree.

Stacked validation ladder I actually run after large changes:

  1. Unit + coverage (fast, deterministic).
  2. Stub Playwright (CI-shaped, no live external auth).
  3. Deployed API smoke (liveness, auth, RBAC without starting the SPA).
  4. Integration E2E (full journeys, optional when env is complete).
  5. Live agent benchmark (opt-in, scored scenarios).
Validation ladder Five stacked validation steps: unit and coverage, stub Playwright, deployed API smoke, integration E2E, live agent benchmark. 1 Unit + coverage Fast, deterministic, CI gate 2 Stub Playwright CI-shaped, no live auth 3 Deployed API smoke Liveness, CORS, RBAC, no SPA 4 Integration E2E Full journeys, env optional 5 Live agent benchmark Scored scenarios, opt-in Do not skip to step 5 because the product has an LLM

Skipping straight to step 5 because the product has an LLM is how teams ship confident chat and broken portals.

Lifecycle coverage matrix (multi-role E2E)

The validation ladder says when to run stub Playwright versus deployed integration. It does not say what browser journeys must exist when two roles share one resource — book, move, cancel on the same schedulable slot, each from their own portal.

That surface is where agent-drafted E2E rots fastest. An agent adds another happy-path spec for role A. Role B still shows stale state. Or API tests catch the 409 overlap rule and nobody opens the other UI. Single-portal green is not cross-role truth.

I borrowed the AQ instinct — executable contracts with stable ids — and applied it to application E2E. Call it a lifecycle coverage matrix: one row per behavior the SDD claims, not one spec file per agent session.

Each row tracks:

Abbreviated shape from a dual-portal scheduling workflow I am building in parallel:

IDActorActionOther party sees±StubIntegration
A-BK-01Role ABook via UIRole B lists same resource id+yesyes
A-RS-02Role AMove onto occupied slot409; neither view moves−yesyes
A-CL-01Role ACancel bookingRole B agenda clears+yesyes
B-RS-01Role BReschedule to free adjacent slotRole A upcoming shows new start+yesyes
EX-01Role ABook during blocked windowSlot not offered−yesyes
CHAIN-01BothBook → A moves → B moves → B cancelsSync after each step+yesyes

Mechanics that keep it from becoming wallpaper:

AQ scenarios grade agent progress over scripted user turns. The lifecycle matrix grades shared application state over scripted cross-role turns. Same discipline: deterministic script, authoritative object under test, negative rows beside happy paths.

When an agent proposes “add E2E for reschedule,” I ask which matrix row it closes — or which row is missing from the table.

Connect to marfago-labs

The evaluation lab already enforced the same instinct at smaller scale. The Minimum Credible Loop shipped ArticleRecommender Phase 1 with a ≥95% pytest gate and Playwright E2E in CI. Posts 02–06 added benchmark validators, gold-data invariants, and public evidence for model outputs. Did the Summary Keep the Important Bits? maps the compression scorecard in plain language for readers who want the four-check overview before the ResNet story in Part 3.

The full-stack application applies that discipline to product behavior: not only “is the compression faithful?” but “can the user register, complete the workflow, and hit the right error when they should not have access?” Same walk-loop-sign model; a wider surface and more E2E journeys.

What changed in my head

“Better AI engineer” used to mean better prompts and model routing. On a multi-role product with agent-drafted code, it means better spec writer and better QA engineer, with AQ when agents own conversation state.

The evaluation lab taught me to measure compression and NER with public evidence. The application taught me that shipping requires the same rigor on specs and application tests — agents just produce more code per day, so the cost of missing a layer compounds faster.

Specs drive. Tests validate. Agents draft. I still sign.

Takeaways


← All posts