{"slug": "zero-repeat-regressions-how-a-375-ticket-empirical-ledger-exposes-the-missing-in", "title": "Zero Repeat Regressions: How a 375-Ticket Empirical Ledger Exposes the Missing Eval Layer in Agent Code Generation", "summary": "Randal Schwartz built a 375-ticket empirical defect ledger that logs every agent code-generation breakage, tags its failure mode, and feeds the resulting \"scar files\" back into the agent's context before it writes similar code. The system runs a four-layer verification stack — syntax, type, contract, and regression — that blocks commits on failure and appends new ledger entries, and it flagged a cross-language match in which a Dart async state race pattern was caught in newly generated Python. The repeat-regression rate reportedly fell to near zero after ticket 200 across Python, Dart, and JavaScript.", "body_md": "Agent code generation has a measurement problem. Most eval frameworks count pass rates on synthetic benchmarks or rely on majority-vote consensus across model runs. Neither approach answers the question that matters in production: does this agent repeat the same mistakes?\n\nRandal Schwartz built a 375-ticket empirical ledger to track exactly that. The system logs every breakage, categorizes the failure mode, and instruments a 4-layer verification stack to prevent the same regression from shipping twice. The result is a trust metric grounded in actual defects, not simulated tasks.\n\nBarry Boehm's research from the 1980s established an exponential defect cost curve: fixing a bug in requirements costs $1, in development costs $500, in production costs $25,000. The ratio holds across decades and languages.\n\nAgent-generated code collapses this timeline. An LLM can write 200 lines of Python in 30 seconds, skip the requirements phase entirely, and push code that fails silently in production because the agent never learned that failure mode existed.\n\nThe traditional response is more testing. The empirical ledger approach is different: capture every failure as a scar, index it by symptom and root cause, then inject that scar into the agent's context before it writes similar code again.\n\nThe stack operates at four distinct trust boundaries:\n\n| Layer | Scope | Failure Mode Detected | Instrumentation | \n|---|---|---|---|\n| **Syntax** | Parse tree validity | Malformed code, missing imports | Language-specific linter, AST walker | \n| **Type** | Static type correctness | Null derefs, type mismatches | Type checker (mypy, Dart analyzer) | \n| **Contract** | Pre/post conditions | Violated invariants, bad state transitions | Assertion injection, property-based tests | \n| **Regression** | Historical defect patterns | Repeat bugs from the 375-ticket ledger | Scar file matching, cross-language pattern detection | \n\nEach layer runs independently. A failure at any layer blocks the commit and appends a new entry to the ledger. The agent sees the failure, the fix, and the category tag in its next context window.\n\nThe most interesting failure mode came from Dart. The ledger tracked four distinct Dart bugs related to async state management and null safety. When the agent generated Python code for a flight recorder (event logging system), the regression layer flagged a pattern match: the Python code exhibited the same async state race that had broken a Dart service three months earlier.\n\nThe Dart scar file contained:\n\n```\nscar_id: dart_async_state_race_001\nsymptom: Event logger drops messages under concurrent writes\nroot_cause: Async callback modifies shared state without lock\nlanguages: [dart, python, javascript]\npattern:\n  - async function writes to shared collection\n  - no mutex or queue serialization\n  - high concurrency environment\nfix_template: |\n  Replace direct collection mutation with queue.put()\n  or asyncio.Lock() guard\n```\n\nThe Python agent had never seen this exact bug in Python. But the scar file's `languages` field triggered a cross-language match. The verification layer rejected the code, injected the Dart scar into context, and the agent rewrote the flight recorder with proper async locking.\n\nThe ledger is a Git repository of YAML files. Each ticket gets a unique ID, a timestamp, the language, the symptom, the root cause, and the fix. Tags group related failures (null safety, async, type coercion, off-by-one).\n\nWhen the agent starts a new task, the orchestrator:\n\nThe ledger grows monotonically. After 375 tickets, the system has coverage for most common failure modes in Python, Dart, and JavaScript. The regression rate (same bug appearing twice) dropped to near zero after ticket 200.\n\nSome agent frameworks run the same prompt through three models, then pick the code that two out of three agree on. This approach optimizes for consensus, not correctness.\n\nThe empirical ledger approach optimizes for defect prevention. If all three models make the same mistake (because they share the same pre-training blind spot), majority vote ships the bug. The scar file catches it.\n\nThe difference shows up in production. Majority vote reduces variance but not bias. The ledger reduces both by explicitly teaching the agent about failure modes that don't appear in public training data.\n\nThe orchestrator maintains a state machine with five phases:\n\nEach phase emits structured logs (JSON) with timing, token count, scar IDs used, and verification results. The logs feed a dashboard that tracks:\n\nThe state machine is idempotent. If the orchestrator crashes mid-task, it resumes from the last completed phase using a checkpoint file.\n\nThe system runs as three containers:\n\nThe orchestrator and verifier communicate over gRPC. The verifier never sees the LLM API key. The ledger is append-only from the orchestrator's perspective (the verifier has read-only access).\n\nFor production deployments, the verifier runs in a separate Kubernetes namespace with network policies that block outbound traffic except to the orchestrator. The LLM calls happen in the orchestrator, which has internet access but never executes untrusted code.\n\n**Scar file bloat**: After 1,000 tickets, the ledger becomes too large to fit in the context window. The mitigation is semantic search over scar embeddings, but that introduces latency and requires a vector database.\n\n**False positives**: The pattern matcher occasionally flags safe code as a regression. The current threshold is tuned for high recall (catch all real regressions) at the cost of precision (some false alarms). Each false positive requires manual review and ledger annotation.\n\n**Cross-language drift**: A scar written for Python might not apply cleanly to Rust or Go. The `languages` field helps, but the fix template often needs language-specific adjustments. The system doesn't auto-translate fixes yet.\n\n**Adversarial prompts**: If the agent's task description contains keywords that trigger irrelevant scars, the context window fills with noise. The query logic needs better semantic filtering, not just keyword matching.\n\nUse this approach when:\n\nAvoid it when:\n\nThe empirical ledger trades upfront instrumentation cost for long-term defect reduction. It works best when the agent writes similar code repeatedly, so the scar database becomes a high-value asset. For one-off tasks, the overhead isn't worth it.", "url": "https://wpnews.pro/news/zero-repeat-regressions-how-a-375-ticket-empirical-ledger-exposes-the-missing-in", "canonical_source": "https://dev.to/mech_app_ai/zero-repeat-regressions-how-a-375-ticket-empirical-ledger-exposes-the-missing-eval-layer-in-agent-2iig", "published_at": "2026-11-28 00:08:15+00:00", "updated_at": "2026-11-28 00:13:55.699347+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "large-language-models", "mlops"], "entities": ["Randal Schwartz", "Barry Boehm", "Dart", "Python", "JavaScript", "mypy"], "also_reported_by": [], "takeaway": "Indexing each production defect as a YAML scar file with symptom, root cause, affected languages and fix template — then injecting matching scars into the agent's context — caught a Dart async state race in generated Python and drove repeat regressions to near zero after 200 tickets.", "recommendation": {"advice": "Log every agent-caused defect as a tagged scar file and inject matching patterns into context before code generation; the source saw repeat regressions approach zero after 200 tickets.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/zero-repeat-regressions-how-a-375-ticket-empirical-ledger-exposes-the-missing-in", "markdown": "https://wpnews.pro/news/zero-repeat-regressions-how-a-375-ticket-empirical-ledger-exposes-the-missing-in.md", "text": "https://wpnews.pro/news/zero-repeat-regressions-how-a-375-ticket-empirical-ledger-exposes-the-missing-in.txt", "jsonld": "https://wpnews.pro/news/zero-repeat-regressions-how-a-375-ticket-empirical-ledger-exposes-the-missing-in.jsonld"}}