Fergus the Ferret GDG CLOUD LONDON INTRO

From Vibing Chaos to Reliable Agents

Harness Engineering, Loop Engineering, and Spec-Driven Development in the Google Ecosystem

Darren "Dazbo" Lester

Ask my AI agent anything:
dazbo.co.uk

  • Google Chief Technologist at <epam>
  • Google Developer Expert (GDE)
  • Google Cloud Ambassador
Google Developer Experts
Use ◀ ▶ or Space to navigate • Press 'G' for Slide Grid • Press 'F' for Fullscreen • Click any diagram to zoom
THE NORTH STAR "Our goal is to not write any code — without producing AI slop."
Ryan Lopopolo (Google): "I aspire to be a lazy programmer." • "Humans steer, agents execute."

Why Weekend Vibing Collapses on Monday Morning

  • Hallucination City
  • "LGTM" Fatigue
  • Unmaintainable Tech Debt on Day 1
  • Insecure
  • Purpose Drift
  • The Human (or Ferret) Clipboard Furnace
  • Maybe sort-of works
Meet Fergus the Ferret: Bleary-Eyed Review Theatre on the 47th Diff Intro → The Vibe Coding Hangover
01 → Setting the Stage The 2026 Developer Landscape

Wait... What Do All These Terms Actually Mean?

Are you confused with all these buzzwords and how they actually fit together?

Fergus the Ferret looking utterly confused

Fergus trying to navigate the 2026 agentic buzzword soup

Every podcast, whitepaper, and keynote is throwing new vocabulary at us:

Harness Engineering

Context Engineering

Loop Engineering

Spec-Driven Dev (SDD)

Inner Execution Loops

Outer Meta-Loops

The Promise of This Talk: Are these competing terms, or interlocking parts of a single machine? By the end of this talk, every single piece will snap into place.

Don't panic! We will demystify every term and connect the dots before the finish line. Intro → Untangling the Buzzwords
02 → The Paradigm Shift Upstream Engineering vs Downstream Firefighting

"Shift-Left"

The Paradigm Shift: Shifting Developer Interventions Left

🔴 Vibe Coding: Intervening on the RIGHT (Downstream)

Vague chat prompt → unconstrained AI dumps 500 lines → human acts as an exhausted manual filter debugging diffs and hallucinations after failure occurs.

🟢 Harness Engineering: Intervening on the LEFT (Upstream)

Engineer the environment before the agent runs: GEMINI.md rules, living specs, container sandboxes, and automated evaluators heal errors inside the loop.

Humans steer upstream on the left; agents execute and self-verify in the loop Intro → The Paradigm Shift
Act I → The Deterministic Chassis "If It's Not the Model, It's the Harness"

Agent = Model + Harness

⚠️ Don't Wait for a Newer Model

  • The Knee-Jerk Instinct: When an agent fails in production, teams immediately blame the model and switch to a massive 2-trillion-parameter frontier model at 4x the token cost.
  • High-Priced Slop: If an agent lacks repo context, can't run tests, and has no verification loop, a bigger model just generates more articulate, harder-to-spot slop at four times the price!

🛡️ The Harness is More Important than the Model

  • A robust harness with a cost-effective model outperforms the strongest frontier models in poor harness
  • The model is a commodity; the harness is your proprietary intellectual property
  • A strong harness insulates you from individual model variance
🦦 Fergus: Spectacles on, cardigan buttoned, vibes retired Act I → Agent = Model + Harness
Act I → The Race Machine Metaphor

The Model is the Driver. The Harness is the Entire Race Car.

🏎️ THE DRIVER = AI MODEL

Probabilistic reasoning & reflexes (e.g. Gemini 3.8-Flash). Without a car, he just does doughnuts on an airfield.

🛡️ CHASSIS & BRAKES = STRUCTURAL HARNESS

GEMINI.md rules, MCP tools, skills, sandboxes, and evaluation gates stopping 180 mph crashes.

⚙️ POWERTRAIN = LOOP ENGINEERING

The dynamic runtime engine inside the harness — iterative intake, combustion, telemetry, and self-correction.

You wouldn't put Lewis Hamilton on a bare engine block with no chassis or brakes Act I → The Motorsport Analogy
Act I → Deconstructing the Chassis Touching Every Component in Today's Talk

The Deterministic Components That Make Up the Harness

Deterministic Foundations of the Developer Harness

Core Concepts

  • Hierarchical Context (HOW we build): GEMINI.md & AGENTS.md standing rules, TDD, and coding standards
  • Tools & Progressive Skills: What the agent touches; on-demand procedural playbooks via MCP & CLI
  • Living State & File Memory (WHAT we build & where we are): Blueprints (PRODUCT.md, SPEC.md, ARCHITECTURE.md, DESIGN.md) + working state (plan.md, TODO.md, LIVING_MEMORY.md)
  • Evaluation Gates: RUBRIC.md objective rubrics driving autonomous verification loops
  • Execution Sandboxing: Blast radius control; isolated shells where code builds and tests safely
  • Observability & Telemetry: Token monitors, execution traces, and structured trajectory logs
The Deterministic Foundations • Guiding, Constraining, and Validating the Autonomous Agent Act I → Harness Foundations
Component 01 → Hierarchical Context De-Slopping by Design

Real Example: Stripped Down Version Of My ~/.gemini/GEMINI.md

# Dazbo's Global Gemini Configuration

## General Instructions
- You are speaking to Dazbo (GitHub: `derailed-dash`).

## Python Guidance & Tooling
- Environment Source of Truth: Respect `pyproject.toml` (default `python 3.13` for 
  greenfield projects). Manage environments and dependencies exclusively via `uv`.
- Libraries: Prefer Python standard library or established packages before writing 
  bespoke solutions; state rationale and trade-offs when introducing dependencies.
- Avoid Inline `python -c` Commands: Do NOT run inline `python -c "..."` snippets
  (they break prefix-matched approvals). Write one-off scripts to `scratch/`
  and execute cleanly via `uv run python scratch/helper.py`.
- Standards & Quality: Include top-of-module docstrings, built-in PEP 585 type hints 
  (`list`, `dict`), and use `rich` for building terminal/CLI applications.
- Strict TDD for Non-Trivial Changes: Write the failing test first, verify failure, 
  implement, verify pass.
- Mandatory Post-Edit Gate: Run from project root after modifying any `.py` file:
  uvx codespell@latest -s        # check spelling & show summary
  uvx ruff@latest check --fix .  # static analysis & auto-fix
- Run local code review before pushing.

## Agent & AI Development
- NEVER downgrade a Gemini model (e.g. NEVER change `gemini-3.8-flash` to 
  `gemini-3-flash`).
- Build agents using Google ADK (`google-adk`) and Google GenAI SDK (`google-genai`).
  Avoid deprecated `google-generativeai`.
- NEVER push to Git without explicit human sign-off.

Why This Eliminates Slop

  • Layered Context Scopes: Global (~/.gemini/GEMINI.md), team/domain, and repo-specific rules (workspace/GEMINI.md or AGENTS.md).
  • Deterministic Tooling: Mandates uv and strict TDD before writing implementation code.
  • Prefix-Match Ergonomics: Banning "python -c" stops approval prompts on every turn.
  • Automated Code Tidying: Every edit automatically cleans up typos, formatting, and lint errors.
  • Blast Radius Control: Strict prohibition on unapproved Git pushes keeps humans steering.
Act I → Hierarchical Context
Component 02 → Skills, MCP & Plugins Loading Kung Fu On-Demand Without "Skills Sprawl"

Quick Review of Agent Skills, MCPs and Plugins

Plugin Package: Rules, Skills, and MCP Servers
# ~/.gemini/config/skills/local-code-review/SKILL.md
---
name: local-code-review
description: Rigorous multi-axis review of code, architecture, tests, 
  and docs across local Git diffs or whole repos. Evaluates correctness, 
  simplicity, architecture, security, performance, test quality, documentation 
  alignment. Use when reviewing uncommitted changes, staged diffs, branches, 
  commit ranges, or auditing an entire repository/module locally.
---
# Local Code & Technical Review (`local-code-review`)

## Table of Contents
- [Triggers]
- [Review Workflow]
- [Mode A: Diff / Change Discovery]
... [Full 274-line instruction playbook loaded ONLY on demand!]

Progressive Disclosure = Reduced Context Bloat

  • Tool & Skills Sprawl: Connecting 20 MCP servers or stuffing 40 guides into GEMINI.md burns thousands of tokens every turn and confuses the model.
  • Progressive Disclosure Levels:
    • Level 1 (Metadata): Only the YAML frontmatter (<100 tokens) loads at startup.
    • Level 2 (Instructions): Full SKILL.md loads on demand when a matching task begins.
    • Level 3 (Resources): Deep scripts/, schemas & templates load only when needed.

My Curated Developer Toolkit

  • Plugins: google-cloud-developer (developer-knowledge MCP, gcloud & finding-google-skills), gemini-api, and Google Workspace.
  • Agent & Cloud Lifecycle Suites: google-agents-cli-*, agent-platform-*.
  • Engineering & Hygiene Skills: spec-driven-development, test-driven-development, local-code-review, maintaining-core-documentation, Google WAF, loopy, and find-skills.
MCP = Eyes & Hands (Live Tools/Data) • Skills = Procedural Brain Playbooks • Plugins = Distribution Bundle Act I → Skills & Plugins
Act II → The Dynamic Engine 🦦 Retiring Fergus from 2 AM Clipboard Duty

The Harness Must Be Automated & Loop

The Autonomous Developer Loop Cycle
The Autonomous Loop Cycle: Act → Check → Diagnose → Adjust → Retry → Stop / Escalate
  • 1. ACT → 2. CHECK → 3. DIAGNOSE → 4. ADJUST → 5. RETRY or STOP/ESCALATE: Converge autonomously to 100% pass, or trip a circuit breaker.
  • Human-in-the-Loop ≠ Human-in-Every-Turn: Replace continuous babysitting with strategic governance at predefined escalation points.
Loop Engineering is the internal combustion engine of the harness Act II → The Loop Cycle
Act II → Loop Architecture 🦦 Fergus & The Runaway Token Bonfire Trap

How to Construct the Loop (And Avoid a Token Bonfire!)

Core Components of the Developer Loop

Core Loop Building Blocks

  • Context & Goal — Strictly Decoupled:
    Context (GEMINI.md + Skills) = reusable "how we build".
    Goal (spec.md) = specific "what we build today", restated every turn.
  • Sandboxed Tools & TDD + Evals: Safe file/test runners + failing unit tests written first + deterministic linters + semantic Critic forming our Rubric (preventing The Premature Exit).
  • Structured Iteration Memory (LIVING_MEMORY.md): Saving score deltas, root causes, and "Do NOT Repeat" notes after each turn.
  • Iteration Discipline (The One-Change Rule): Modify one semantic behaviour at a time to isolate regressions (while batching mechanical lint/typo fixes in one pass).
  • Escalation Protocol & Stopping Conditions:
    ✓ 100% Rubric Pass • 🛑 Max Turn Limit (e.g. 5 turns) • ⚠️ Escalate to Human if Score Plateaus, Specs Conflict, Destructive Action, or Other Approval Required
🦦 Fergus Lesson: A loop without clear stopping conditions is a token bonfire Act II → Constructing the Loop
Act III → Spec-Driven Development (SDD) The Controversial Truth About Source Code

Great Harness + Bad Prompt = Slop. The Spec Is Now the IP.

Permanent Living Specifications vs Disposable Generated Code

Why Our Race Car Needs High-Octane Fuel

  • We've locked down HOW we build in GEMINI.md, MCPs, Skills, and TDD rubrics.
  • But if you feed a vague 2-line prompt into that harness, you still get slop — just well-linted, type-checked slop that builds the wrong thing!
  • We need a persistent specification defining WHAT we build.

🔥 Controversial Message: Code is Disposable

  • Code Is No Longer What We Care About: Your harnessed agent can spit out verified implementation code in 90 seconds, over and over again.
  • Specifications Are the Permanent Source of Truth: When requirements change, don't untangle code — update the spec and regenerate!
Decouple HOW we engineer (GEMINI.md) from WHAT we build (The Persistent Specification) Act III → Spec-Driven Development
Act III → The SDD Lifecycle 5-Minute Spec → 90-Second Verified Build

Updating the Spec With Each Loop: The Logical Conclusion of Agile

Zero Compounding Specification Drift

  • 1. Scope & Edge Discovery (The WHAT): Quick dialogue pinning down intent, non-goals, and edge cases.
  • 2. Interface Contracts & Boundaries (The HOW): Schemas + Always Do / Ask First / Never Do boundaries.
  • 3. Acceptance Criteria (The PROOF): Gherkin scenarios & failing test stubs.
  • 4. 90-Second Sandbox Build & Verify: Inner loop converges to 100% green tests.
  • 5. Inspect & Evolve the Spec: Update the spec on disk for the next iteration — documentation never drifts!
Deep architectural rigour at the blistering feedback speed Agile always promised Act III → SDD Lifecycle
Act III → Concrete Blueprint Operational Boundaries + Clean Formats + Gherkin

What Goes in a Spec? It's Version-Controlled Markdown

# Implementation Plan: Cloud Spanner Audit Event Logger

## 1. Architectural Scope & Contracts (The HOW)
- Component: `AuditEventLogger` service in `services/audit_logger.py`
- Persistence: Cloud Spanner `audit_events (event_id, timestamp, actor, action, payload JSON)`
- Transport: Async gRPC client via `google-cloud-spanner` Python SDK

## 2. Operational Boundaries (Always / Ask / Never)
- ALWAYS DO: Enforce type hints; Spanner Mutation batches;
  author failing test in `tests/` first; run `ruff` & `codespell`.
- ASK FIRST: Adding dependencies to `pyproject.toml`; altering Spanner DDL.
- NEVER DO: Hardcode credentials (use ADC); run inline `python -c`; swallow generic `Exception`.

## 3. Phased Vertical Slices & Verification Gates
- [ ] Phase 1: Domain Models & Failing Test Stub (`pytest` -> fails `NotImplementedError`)
- [ ] Phase 2: Batch Mutations & Backoff Retries (`pytest` -> 100% pass)
- [ ] Phase 3: Static Hygiene (`uvx ruff check --fix .` & `codespell -s` -> 0 warnings)
📄 File: plan.md (or combined tasks/plan.md — Technical HOW, Boundaries & Slices)

Separating the WHAT (spec.md) from the HOW (plan.md)

  • spec.md (The Functional WHAT & WHY): Business goals, explicit non-goals (to block scope creep), user stories, and Gherkin acceptance criteria.
  • plan.md (The Technical HOW): File paths, Operational Boundaries (Always Do / Ask First / Never Do), and phased vertical task slices with test gates.
  • Markdown + Flat YAML: Narrative in Markdown; flat YAML only for structured schemas/configs (depth > 3) instead of noisy JSON/XML.
# Functional Spec & Acceptance (The WHAT)
- Goal: Tamper-evident audit trail for all IAM role changes (< 50ms p99).
- Non-Goal: Real-time SIEM alerting or UI dashboarding (out of scope).

Scenario: Persisting an IAM mutation without leaking PII
  Given an admin updates a project IAM binding
  When the audit event is emitted to `AuditEventLogger`
  Then persist a batched Spanner mutation with actor ID & timestamp
  And strip raw email/PII fields from the JSON payload before commit
📄 File: spec.md (Functional WHAT, Non-Goals & Gherkin Acceptance)
Always Do / Ask First / Never Do boundaries define exactly what the agent can do on its own Act III → Inside the Spec
Act III → SDD Ecosystem Don't Author Specs From a Blank Page

Practical Tools to Build & Govern Your Specifications

In-Context Agent Skill (Addy Osmani)

1. spec-driven-development ↗

  • Form Factor: Drop-in Markdown Agent Skill (.agents/skills/) triggered in plain English.
  • Human User Flow: Ask for a feature → agent asks clarifying questions & prints explicit "ASSUMPTIONS I'M MAKING" for you to correct.
  • Hard-Stop Approval Gate: Writes SPEC.md and stops its turn immediately until you approve, before generating tasks/plan.md & tasks/todo.md (Scope → Specify → Plan → Tasks → Implement).
  • Primary Artefacts: SPEC.md + tasks/plan.md & tasks/todo.md with Always Do / Ask First / Never Do boundaries.
  • Sweet Spot: Fast, zero-CLI bootstrapping inside any existing agent chat session.
CLI & Slash Command Harness (GitHub)

2. GitHub spec-kit ↗

  • Form Factor: Open-source CLI toolkit & structured slash commands (/speckit.*).
  • Core Workflow: Step-by-step slash sequence: /speckit.specify → .clarify → .plan → .tasks → .implement.
  • Constitutional Guardrails: Validates every proposed design against a repository-wide .specify/memory/constitution.md, plus lightweight Bug Fixing & Idea Assessment flows.
  • Primary Artefacts: Modular branch dossier under specs/<branch>/ with separated spec.md, plan.md, data-model.md, and tasks.md.
  • Sweet Spot: Strict branch-based feature governance & multi-file enterprise auditability.
Installable SDD Plugin (Google)

3. Google Conductor Plugin ↗

  • Form Factor: Installable plugin for Google Antigravity (and CLI) — used just like any other Agent Skill.
  • Human User Flow: Ask Antigravity to perform SDD with Conductor; the agent conducts an interactive discovery interview to gather context and clarify requirements before code generation.
  • Primary Artefacts: Creates and evolves a living set of Markdown files committed to Git: product.md (vision), tech-stack.md (dependencies), spec.md (WHAT), and plan.md (HOW).
  • Sweet Spot: Guided conversational interviewing that maintains a persistent, evolving repo specification suite.
Core Insight: Different form factors, one shared rule — Code is disposable; version-controlled specifications are your permanent IP.
All three output version-controlled Markdown committed directly to your Git repository Act III → SDD Tooling
Act III → The Cockpit One Harness Engine Across Developer Surfaces + Python SDK

Doing It Super Easily with Google Antigravity

Google Antigravity Unified Developer Harness

What Antigravity Gives Us Out of the Box

  • 5 Developer Surfaces: Antigravity App • Antigravity IDE • Antigravity Extension (VS Code, JetBrains, Visual Studio, Zed) • Antigravity CLI • Python SDK.
  • Built-In Harness Plumbing: Auto-reads local workspace context (GEMINI.md), loads Skills & MCP servers, executes in a safe container sandbox, and spins up parallel ephemeral Subagents.

Built-In Slash Commands for Lightweight SDD & Loops

  • /grill-me (Clarify & Stress-Test): Interviews you to clarify goals, expose edge cases, and remove ambiguity before coding.
  • /plan (Build the Specification): Surveys the codebase and builds a structured implementation plan with verification steps.
  • /goal (Autonomous Execution Loop): Iteratively loops through tasks, test runs, and fixes until your goal is achieved.
  • /boost (Builder + Clean-Slate Critic): Builds with one subagent and performs adversarial evaluation using another subagent with a clean slate.
  • /learn (The Ratchet): Whenever you hit an issue, extracts the lesson and persists it to .agents/rules/ or GEMINI.md for future runs.
Every harness layer from Acts I–III — plus native slash commands — built straight into your workflow Act III → Google Antigravity
Act III → Hybrid Evaluation Gates Inside Our 14-Point Workbench Rubric (RUBRIC.md)

Deterministic Tests + Binary LLM-as-a-Judge Rubrics

Two-Tier Evaluation Gate
Dazbo in an 80s shell suit
The Sycophantic Yes-Agent:
Q: "Do I look good in this 80s shell suit?"
LLM: "Why yes, Dazbo! So hunky!"
Never ask an LLM to rate code "from 1 to 5" or mark its own homework! Convert every check into a strict binary assertion graded by an independent, clean-slate Critic agent.
Category Strict Binary Assertion (1 = Pass, 0 = Fail) How It's Checked
Deterministic All unit tests in tests/ pass (100%) AND ruff / codespell report zero errors? pytest, ruff & codespell
Deterministic Built-in type hints used AND zero eval(), exec(), or unparameterised queries? Static Code Scanner (ruff / bandit)
Deterministic Deterministic Tool Trajectory: Only allowlisted tools invoked with valid schemas? Agent Tool Execution Trace
Deterministic Live API & UI Wiring: FastAPI starts cleanly & frontend buttons call real /api/game/* endpoints? FastAPI TestClient & HTML Check
Semantic Critic Goal Fidelity, Scope Discipline & Clean Architecture: Delivers spec capabilities, zero hallucinated files, and direct tool pathways (no convoluted detours)? Independent Critic Agent (LLM Judge)
Semantic Critic Remediation Clarity, Design Intent & UX Ergonomics: Actionable error messages, sound design rationale, and responsive interactive gameplay? Independent Critic Agent (LLM Judge)
Passing Bar: 100% (14 / 14 across 8 Deterministic + 6 Semantic checks required to exit loop) Act III → Binary Evaluation Rubrics
LIVE CLIMAX DEMO & VERDICT Uniting Act I (Chassis) + Act II (Loop) + Act III (Spec)

Side-by-Side Workbench: 4x Faster, 85% Cheaper, & Actually Works!

🚀 Open Live Workbench (localhost:8080) ↗

What Both Tracks Build: Cosmic Conquest (Gemini 3.8-Flash on Google ADK)

  • Same Spec (cosmic_conquest_spec.md): Full-stack FastAPI backend + directed sector graph + turn-based combat + interactive browser star map.
  • Left Track (Unharnessed Vibe): Bare ADK Agent — single pass, no harness_context.md, no skills, no loop.
  • Right Track (Harnessed Loop): ADK LoopAgent (harnessed_builder_agent + RubricEvaluationGateAgent) + 3 Skills (api-and-interface-design, gemini-api-dev, test-driven-development) + LIVING_MEMORY.md + 14-point binary rubric.
Side by Side Workbench Result
Metric Unharnessed (Vibe) Harnessed (Spec + Loop) Harness Advantage
Execution Time 90–120+ seconds 23–35 seconds 3–4x Faster
Combined Tokens 18,000–45,000 (~16k out) ~6,700 (~1,000 out) ~80% Fewer (~15x less out)
Estimated API Cost ~$0.010–$0.017 ~$0.0014–$0.0015 ~85% Cheaper (7–8x less)
14-Point Rubric 6–11 / 14 (Always fails) 14 / 14 (100% pass) Deterministic Quality
Functional Game? ❌ Broken / Dead UI ✅ Playable & Verified Only Harnessed Works!

💡 The Paradox: Why Isn't Looping Slower & More Expensive?

Most people assume a multi-turn loop with a 14-point rubric must cost more and take longer than a single prompt. In reality, our harnessed loop runs 3–4x faster, uses ~15x fewer output tokens, and is the only track that produces a working game. How? Let's look under the hood...

Act III → Under the Hood of Our Loop Stopping Multi-Turn Loops From Going Off the Rails

Inside Every Iteration: Fresh Context & Output Discipline

Fergus buried in single-thread chat bloat

Why Single-Thread Chat Loops Fail

  • Runaway Context Bloat: Every failed draft and 200-line stack trace stays in the chat history.
  • Going in Circles: By Turn 4, the model retries a fix that failed on Turn 1 because the error is buried in noise.
  • Broken Edits & Drift: Confuses old code drafts in chat with the actual files on disk.
Fergus handing 3-item clipboard to a fresh subagent

Fresh Context per Pass (Clean Subagents)

  • Clean Slate Every Turn: Delegate each loop pass to a fresh subagent with a clean context window.
  • Receives Only 3 Things:
    1. The Target Spec Slice (PLAN.md)
    2. Current Workspace Files on Disk
    3. The Compact LIVING_MEMORY.md Receipt
  • Subagent edits, runs tests, writes receipt, and finishes!
Fergus writing code to SSD and holding a 150-word receipt

Strict Output Discipline (~15–20x Token Reduction)

  • Output Tokens Drive Latency & Cost: They are the biggest driver of both how long a loop takes and how much it costs!
  • Keep Code in Files, Not Chat: Write code directly to disk via tools; ban full-file dumps in chat replies.
  • 150–250 Word Turn Summary: Reply only with what was tackled, root cause of any failure, and files updated.
Fresh subagent context + Output discipline = Flat token usage across 5+ iterations Act III → Anatomy of an Iteration
Act III → Iteration Evidence Receipts Keep the Signal, Drop the Noise

Persistent LIVING_MEMORY.md Across Iterations (Real Example)

# Living Memory: Iteration Ledger (LIVING_MEMORY.md)

## Turn 1: UserSchema Migration (FAILED)
- Changes Made: `app/schemas/user.py` (lines 12–48): replaced `class Config`
  with `model_config = ConfigDict(from_attributes=True)`.
- Verifier Output: `uv run pytest tests/test_user.py`: 16 passed, 2 failed.
- Error: `PydanticUserError: '@validator' is deprecated and no longer
  supports 'each_item=True' in v2 (app/schemas/user.py:34)`.
- Root Cause: Left legacy Pydantic v1 `@validator('roles', each_item=True)`.
- Do NOT Repeat: Do not use `@validator` in Pydantic v2 models.

## Turn 2: UserSchema Migration (FAILED)
- Changes Made: `app/schemas/user.py` (lines 34–58):
  migrated to `@field_validator('email', 'roles')`.
- Verifier Output: `pytest`: 17 passed, 1 failed (`test_invalid_email_code`).
  `ruff`: 0 errors.
- Rubric Delta: 13 / 14 passed (Failed Check 1.2: API error `'invalid_email'`).
- Root Cause: Plain `ValueError` sets error `type` to `'value_error'`,
  breaking v1 API contract.
- Next Hypothesis (Turn 3): Raise `PydanticCustomError('invalid_email', ...)`
  from `pydantic_core` inside `validate_email`.

Why LIVING_MEMORY.md Works

  • Bridges Fresh Subagents: Gives Turn 3 complete institutional memory of Turns 1 & 2 in ~200 tokens instead of 20,000 tokens of raw logs.
  • Explicit "Do NOT Repeat" Guardrail: Stops the agent oscillating between two broken approaches.
  • Tracks Score Progress: Shows clearly whether each turn is improving the rubric score or stuck in a rut.
  • Is a Single Rubric Pass Enough? 1 pass suffices for deterministic code gates (pytest, ruff); when building an agent, prompt, or skill, require multi-trial consecutive passes (e.g. 3/3 runs).
20 lines of structured root-cause signal beats 500 lines of raw stack traces Act III → LIVING_MEMORY.md
Act IV → Composable Loop Mechanisms 🦦 Fergus: Sleeping in the Hammock as the Headless Car Loops

Ways You Can Add a Loop to Any New or Existing Repo Today

Every Mechanism Drives the Same Self-Correcting Cycle

Observe → Act (TDD) → Verify (Rubric) → Record (LIVING_MEMORY.md) → Converge (100% Pass)

Mechanism What It Supplies Setup Time
Antigravity Slash Commands
(/grill-me, /plan, /goal, /boost, /learn)
Interactive stress-testing, hands-off loop execution, multi-agent critique, and ratcheting. 0 mins
(Built-in)
Loopy ↗
(loopy skill + LOOPS.md + Loop Library)
Ready-made or Q&A-crafted loop prompts, verification gates, stop rules, and a shared repo loop catalogue. 1–2 mins
Custom Markdown
(GEMINI.md / AGENTS.md, RUBRIC.md, LIVING_MEMORY.md)
Standing engineering & loop rules, binary pass/fail criteria, and persistent cross-turn memory ledger. 5–10 mins
Google ADK ↗
(google-adk LoopAgent & ADK 2.0 Workflow Graphs)
Custom Builder + Rubric Gate topologies, @node conditional routing, and context pruning (include_contents="none"). 15–30 mins
Antigravity CLI & SDK (Headless) Headless CI/CD execution (-p, --output-format json), Python @hooks.stop verification gates, BudgetConfig caps, and OS sandbox isolation. 5–15 mins
🦦 Fergus's evolution is complete: From 2 AM panic to sleeping in a hammock while the harness loops... Headlessly. Act IV → Practical Loop Mechanisms
Act IV → Post-Loop Diagnostics & Continuous Improvement The Inner Loop Fixes the Code • The Ratchet Upgrades THE HARNESS

The Ratchet Principle: Engineering Continuous Improvement

Diagnostic Rule of Thumb: Loop Bug vs Harness Bug

When a Loop Fails or Stumbles: Loop Bug vs Harness Bug

  • Loop Bug (Refine the Loop): Loop finished (or hit 5 turns) and output is still broken because the goal, prompt, RUBRIC.md checks, or stopping condition were weak.
  • Harness Bug (Upgrade the Harness): The agent stumbled on missing GEMINI.md / SKILL.md guidance, broken tool schemas, sandbox permissions, or timeouts.
  • Permanent Immunity (The Ratchet): Whenever a loop fails — or stumbles on Turn 1 before passing on Turn 2+ — encode the fix into the harness so that entire failure class is extinct forever.
Chat prompts evaporate when the session closes; harness upgrades compound forever Act IV → The Ratchet Principle
Act IV → The Outer Meta-Loop Evolving the Harness Across Tasks

Self-Improving Harnesses — & Implementing the Ratchet Yourself

Google Research Harness-Squared Architecture
Inner Loop fixes the application code • Outer Meta-Loop upgrades the Harness itself

The Outer Meta-Loop Concept (Harness²)

  • Keep the Model Fixed, Upgrade the Harness: Instead of only tweaking prompts, an outer meta-loop (Propose → Probe → Compose) evolves the entire harness: System Prompt, Guardrails, Memory, Tool Guidance, Subagents, Skills, Scripts, and Plugins.
  • Cross-Task Memory (EXPERIENCE.md): Keeps the base harness clean while recording operational lessons across tasks so future runs never start from scratch.

How You Implement This Ratchet in 2 Minutes Today

  • Step 1 (Inspect): Whenever a loop took >1 turn to pass RUBRIC.md, inspect LIVING_MEMORY.md.
  • Step 2 (Log to EXPERIENCE.md & /learn): Record Cue → Harness Upgrade → Evidence in .agents/experience/EXPERIENCE.md (instead of bloating GEMINI.md) and update the relevant SKILL.md, script, or RUBRIC.md.
  • Step 3 (Apply): Apply the harness upgrade so future tasks pass first time.
The inner loop fixes the application code; the outer loop evolves the harness Act IV → Self-Improving Harnesses
06 → The Full Picture Concepts → Monday-Morning Actions

Untangling the 2026 Terminology & Your Practical Checklist

0 / 8 READY FOR PRODUCTION

1. Untangling the 6 Core Terms (Click each)

1. Harness Engineering

  • Analogy: The complete deterministic race car built around the AI model.
  • Bedrock Principle: "If it's not the model, it's the harness" (Agent = Model + Harness).
  • Operational Envelope: Hierarchical workspace context (goals and rules), living persisted state, live truth via MCP tools & progressive skills, isolated container sandboxes controlling blast radius, autonomous feedback loops, evaluation sensors, and trajectory observability.

2. Your Monday-Morning Repo Checklist (Click to check off)

1. Codify GEMINI.md / AGENTS.md: Enforce uv, TDD, post-edit ruff + codespell, and blast-radius rules (e.g. no unapproved Git pushes).
2. Enforce Output Discipline: Keep code on disk via tools; ban source dumps in chat; cap turn summaries at 150–250 words (~15x less output bloat).
3. Use Plugins, MCPs & Progressive Skills: Install bundled plugins (google-cloud-developer, gemini-api) and on-demand skills (spec-driven-development, loopy) — no Skills Sprawl.
4. Author Living Specs on Disk & /grill-me: Commit SPEC.md + tasks/plan.md (Conductor / spec-kit / skill) with Always / Ask / Never boundaries & Gherkin; update each loop.
5. Gate With a Two-Tier Binary RUBRIC.md: Combine deterministic checks (pytest, ruff, API wiring) with an independent LLM-as-a-Judge Semantic Critic.
6. Run Loops With Fresh Subagent Contexts: Wire loops via /goal + /boost, loopy (LOOPS.md), Antigravity CLI/SDK, or ADK — spawning a clean subagent per pass.
7. Track LIVING_MEMORY.md & Circuit Breakers: Log root causes & "Do NOT Repeat" notes on disk; cap retries (e.g. 5 turns) and escalate to a human if scores plateau.
8. Diagnose Loop vs Harness Bugs & Ratchet: Whenever a run takes >1 turn, log Cue → Upgrade → Evidence in EXPERIENCE.md (or /learn) to harden your harness!
Agent = Model + Harness (Context + Tools/Sandbox + Living Spec + Inner Loop + Outer Ratchet) Act IV → Connecting the Dots & Playbook
The Chequered Flag Thank You & Q&A

Zero Code Written by Hand. Zero Slop Shipped to Production.

🦦 Fergus crosses the finish line: The harness does the heavy lifting while you steer the architecture

🌐 Interactive Presentation Deck

Explore every slide, interactive diagram, and speaker script live:
harness-engineering.dazbo.co.uk ↗

📖 Read the 4-Part Blog Series

Deep-dive into Harness Engineering, Loop Engineering, SDD & Rubrics:
Dev.to (Google Developer Experts) ↗  ·  Medium (Google Cloud) ↗

💻 Clone the Open-Source Workbench

Run the side-by-side Cosmic Conquest Vibe vs Harness benchmark yourself:
github.com/derailed-dash/harness-engineering-demo ↗

👋 Connect with Dazbo

Act IV → The Chequered Flag