Leanpub Header

Skip to main content

Governing AI Coding Agents with StrictDoc & Tracey Stack

Controlling Spec Drift with Living Intent Graphs

Governing AI Coding Agents with StrictDoc & Tracey Stack
This book is 100% completeLast updated on 2026-10-07

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

EPUB
About

About

About the Book

We are living through the AI Velocity Paradox.

Never in the history of computer science has it been so easy to produce thousands of lines of syntax in minutes. Modern coding agents—Cursor, Claude Code, OpenAI Codex, and OpenCode—can scaffold microservices, generate boilerplate, refactor functions, and synthesize suites of unit tests before an engineer has finished their coffee.

Yet, beneath this staggering burst of apparent productivity lies an insidious defect crisis: silent specification drift.

When an autonomous agent writes code without a formal, machine-readable boundary of human intent, it operates in a cognitive vacuum. It relies on vector embeddings and probabilistic pattern-matching—heuristic proximity rather than normative obligation. When asked to write tests, an agent commits the cardinal sin of software verification: circular testing. It writes unit tests that assert against its own hallucinated assumptions rather than the business invariants of the system. The tests pass, the PR is merged, and the system imperceptibly drifts away from what its architects intended.

Compiling code and passing tests is no longer proof of correctness. In an era where probabilistic models write code, we must construct deterministic fences.

This book provides the architectural blueprint to solve this crisis.

Instead of treating software specifications as dead documentation in Confluence, Jira, or static Word documents, we treat human intent as an executable, versioned graph in Git. By combining two cutting-edge open-source tools—StrictDoc (for modeling requirements as code) and Tracey 2.x (a high-performance, Tree-sitter-backed Rust verification engine)—we construct a Software Intent Graph.

Using the Model Context Protocol (MCP), we expose this intent graph directly to AI coding agents. We force agents to inspect requirements before touching code, bind their functions to explicit requirement identifiers, annotate test evidence with verifiable anchors, and submit their work to non-negotiable CI/CD merge gates.

This is not a book about fighting artificial intelligence or drowning development in bureaucracy. It is a book about governance. It teaches you how to leverage AI’s speed while maintaining the structural and architectural integrity demanded by production systems.

What You Will Learn

Across twenty comprehensive, code-backed chapters, this volume equips you with an end-to-end framework for governing AI coding assistants:

  1. Requirements-as-Code with StrictDoc (.sdoc):
    • Author machine-readable, Git-native specifications without proprietary lock-in.
    • Write unambiguous, falsifiable invariants using EARS (Easy Approach to Requirements Syntax).
    • Preserve traceability under continuous refactoring using immutable Machine Identifiers (MIDs).
    • Construct multi-document topologies, composite parent-child trees, and custom validation grammars.
  2. Mechanical Code Traceability with Tracey 2.x:
    • Understand how Tracey uses Tree-sitter AST parsing across 30+ languages (TypeScript, Rust, Python, Go, C/C++) to anchor code comments directly to syntax nodes.
    • Master the duality between StrictDoc's formal @relation(..., role=Verifies) and Tracey's concise r[impl] / r[verify] markers.
    • Differentiate between code that implements a feature and test suites that prove it.
    • Track breaking requirement changes with +N version suffixes and automated stale-reference detection.
  3. Agent Integration via Model Context Protocol (MCP):
    • Understand why traditional Vector RAG fails at architectural compliance and how deterministic intent graphs fix it.
    • Connect autonomous coding agents to Tracey’s native 11-tool MCP server over JSON-RPC.
    • Configure terminal agents (Claude Code, Codex CLI) with automated skills (tracey ai).
    • Inject real-time specification context into IDE agents (Cursor Composer, Zed, and generic LSP clients).
    • Build headless verification loops with open-source autonomous agents (OpenCode).
  4. Production Enforcement & Real-World Safety:
    • Build hard merge gates in GitHub Actions that fail builds when spec coverage drops (tracey query validate --deny warnings).
    • Enforce atomic version bumps as ACID transactions in Git pre-commit hooks (tracey pre-commit and tracey bump).
    • Learn how production safety-critical projects like Zephyr RTOS and aerospace standards (DO-178C) structure their traceability models.
    • Direct AI agents through bounded remediation workflows to close evidence gaps without hallucinating false proof.
    • Build the complete Aegis Inference Gateway capstone project—a polyglot, multi-tenant enterprise service governed entirely by living specifications.

Who This Book Is For

  • Senior Software Engineers & Tech Leads: You use Cursor, Claude Code, or Codex daily. You love the velocity, but you are alarmed by regression creep, context decay, and the erosion of your architecture.
  • Software Architects & Engineering Managers: You need to establish automated, verifiable compliance boundaries across your teams without slowing down feature delivery or relying on manual code review checklists.
  • Systems & Verification Engineers: You come from safety-critical, regulated, or mission-critical domains (automotive, aerospace, medical, fintech) and want to modernize compliance using Git-native, developer-friendly open-source stacks instead of enterprise monoliths like IBM DOORS or Polarion.
  • Open-Source & AI Engineers: You want to build autonomous coding pipelines that operate safely on local models or open runtimes (OpenCode, Ollama) with zero vendor lock-in.

Prerequisites

  • General Programming Experience: You should be an experienced developer comfortable reading and structuring production code. All primary application examples and test suites are written in Modern TypeScript (using Vitest), with companion scripts in Python and performance modules in Rust.
  • Git & Terminal Proficiency: You should be comfortable with Git workflows (branches, rebase, diffs, pre-commit hooks) and command-line execution.
  • Basic Familiarity with AI Coding Tools: You should have at least passing familiarity with prompting AI coding tools (such as Cursor, GitHub Copilot, Claude Code, or Aider).
  • No Formal Verification Background Required: You do not need prior experience in formal methods, avionics certification, or requirements engineering. All principles are explained from first principles through modern software engineering analogies.

How to Read This Book

This book is engineered as a modular field manual and reference architecture, not a linear narrative essay. While it follows an end-to-end progression from foundational specification modeling to an enterprise gateway capstone, you do not need to read it cover-to-cover from page 1 to page 600 in a single sitting.

Software engineering under autonomous coding agents introduces distinct operational challenges depending on your role and your immediate priorities. Whether you need to stop an AI agent from hallucinating test suites this afternoon, configure a Model Context Protocol (MCP) server for your team by tomorrow, or design a multi-year safety-critical traceability pipeline, this guide is structured so you can jump directly to the relevant solution.

The Predictable 5-Part Chapter Anatomy

Every single chapter in this volume follows an identical, highly predictable five-part structure. Once you understand this layout, you can navigate any chapter in seconds:

  • 1. Theoretical Foundations: The conceptual "Why". Analyzes the failure mode, the mathematical or topological invariant, and grounds the topic in software engineering analogies without code distractions.
  • 2. Basic Code Example: The minimal "Hello World". A standalone, zero-dependency implementation accompanied by a detailed line-by-line explanation and common pitfalls.
  • 3. Advanced Application Implementation: The production artifact. A substantial, enterprise-grade codebase snippet (80–200+ lines)—ranging from StrictDoc trees and Styx configs to polyglot modules and GitHub Actions workflows—broken down into an architectural analysis.
  • 4. Practical Exercises: Hands-on engineering katas, edge-case challenges, and feature requests designed to test your understanding before looking at the answers.
  • 5. Solutions and Explanations: Complete, un-truncated TypeScript and configuration solutions featuring line-by-line comments, accompanied by a distinct Instructor's Analysis that dissects why the solution satisfies the formal invariant.

Targeted Reading Paths

To maximize your return on investment, choose the path that mirrors your immediate engineering objective:

Path 1: The Software Architect & Tech Lead

Goal: Establish formal boundaries around AI velocity, understand intent graphs, and design system topologies that do not rot.

  • Start with: Chapter 1 (The AI Velocity Paradox) and Chapter 2 (Git-Native Requirements with StrictDoc).
  • Deep dive into topology: Chapter 4 (Modeling System Topologies & Parent-Child Trees) and Chapter 11 (Bridging Context Gaps: Why Vector RAG Fails).
  • Explore safety realities: Chapter 18 (Safety-Critical Lessons from Zephyr RTOS and DO-178C).
  • Synthesize the architecture: Chapter 20 (Capstone Project: Aegis Inference Gateway).

Path 2: The DevOps & Platform Engineer

Goal: Build automated, unbypassable gates that halt spec drift in pull requests and enforce repository hygiene.

  • Master the daemon & AST extraction: Chapter 6 (AST Code Inspection with Tracey) and Chapter 10 (Daemon Architecture & Unix Sockets).
  • Enforce commit atomicity: Chapter 17 (Pre-Commit Spec Hygiene & Atomic Version Bumps).
  • Implement hard CI gates: Chapter 16 (Hard Merge Gates in CI/CD with tracey query validate --deny warnings).
  • Automate background remediation: Chapter 19 (Agentic Remediation Loops).

Path 3: The AI & Tooling Engineer

Goal: Wire coding assistants directly to living intent graphs using the Model Context Protocol (MCP).

  • Understand the context interface: Chapter 11 (Deterministic Intent vs. Probabilistic Embeddings).
  • Master the inspection toolset: Chapter 12 (The Complete Tracey MCP Tool Suite).
  • Configure terminal agents: Chapter 13 (Claude Code & Codex CLI via tracey ai).
  • Configure IDE environments: Chapter 14 (Cursor Composer, .cursor/mcp.json, and Editor LSP Clients).
  • Build headless autonomous loops: Chapter 15 (Open-Source Autonomous Agents with OpenCode).

Path 4: The Hands-On Pragmatist ("Show Me the Code")

Goal: Copy production-grade, compilable TypeScript contracts, Vitest test suites, and configuration templates directly into your project.

  • Skip Section 1 (Theory) in each chapter.
  • Read Section 2 (Basic Code Example) to verify syntax patterns (r[impl], r[verify], @relation).
  • Copy and adapt Section 3 (Advanced Application Implementation) for production use.
  • Consult Section 5 (Solutions and Explanations) whenever you need fully annotated test assertions and Zod validation schemas.


Table of contents

Chapter 1: The AI Velocity Paradox - How Fast Code Generation Causes Silent Spec Drift

Chapter 2: Git-Native Requirements - Structuring Machine-Readable Specifications with StrictDoc (.sdoc)

Chapter 3: Eliminating Ambiguity - Writing Falsifiable Invariants with EARS Syntax and Stable MIDs

Chapter 4: Modeling System Topologies - Parent-Child Trees, Relation Roles, and Multi-Document Hierarchies

Chapter 5: Living Specifications - Static Dashboards, Web Reviews, and Multi-Document Composition

Chapter 6: Beyond String Matching - Real-Time Code AST Inspection and Spec Parsing with Tracey 2.x

Chapter 7: Anchoring Code to Intent - In-Source Reference Grammars (@relation vs r[...] Syntax)

Chapter 8: Making Test Evidence Explicit - Linking Automated Suites to Requirements via r[verify]

Chapter 9: Detecting Stale References - Managing Spec Evolution with +N Suffixes and Impact Analysis

Chapter 10: Low-Latency Verification - Background Daemons (.tracey/daemon.sock), Web Dashboards, and LSP Feedback

Chapter 11: Bridging Context Gaps - Complementing Vector Search with Deterministic Intent Graphs

Chapter 12: The Agent Inspection Toolkit - Discovery, Audit, and Workspace Configuration Tools in Tracey MCP

Chapter 13: Spec-Guided Terminal Workflows - Configuring Claude Code and Codex CLI via tracey ai

Chapter 14: IDE Tooling & LSP - Live Intent Context in Cursor (.cursor/mcp.json) and Editor LSP Clients

Chapter 15: Open-Source Autonomous Agents - Wiring OpenCode to Tracey MCP for Headless Verification Loops

Chapter 16: Hard Merge Gates in CI/CD - Automated Validation of Specs and Coverage

Chapter 17: Pre-Commit Spec Hygiene - Halting Silent Drift and Enforcing Atomic Version Bumps in Git

Chapter 18: Safety-Critical Realities - Lessons from Zephyr RTOS Tracing and DO-178C Structural Templates

Chapter 19: Agentic Remediation - Directing Coding Assistants to Close Missing Evidence Gaps

Chapter 20: Capstone Project - Architecting, Implementing, and Governing an Enterprise Service with StrictDoc, Tracey, and Cursor

If printed, this ebook would span over 800 pages. The book was created with the help of AI.

Author

About the Author

Edgar Milvus

A veteran software engineer with 20 years of experience, I have dedicated my career to the art of automation. My philosophy is simple: programming should eliminate repetitive chores to unlock human creativity. This journey began early on with the development of custom code-generation tools and has evolved into a deep mastery of LLMs and their APIs. Today, I specialize in architecting AI-driven solutions that handle everything from complex coding and security tasks to advanced knowledge retrieval, transforming the way we interact with technology

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub