Section 7 of 44 13 min read

Validation Architecture

Making agent output trustworthy enough to merge at volume: oracles, independence, and verification signals the agent cannot reach.

Objective

Make agent-produced output trustworthy enough to merge at volume—which is an architecture problem, not a checklist problem.

Section 14 covers verification as a lifecycle stage with gates. This section covers the architecture those gates sit on. The distinction matters because a gate can only be as good as the oracle behind it, and most organizations have gates without oracles.

7.1 The Generation-Verification Gap Is Measured #

The intuition that verifying is easier than generating is widely invoked and, for model output, wrong in an important way.

The cleanest quantification: across several benchmarks, oracle pass@100 exceeds majority-vote selection by 16 to 37 percentage points, and by up to 64.5 points for smaller models.106 The correct answer is usually somewhere in the candidate set; the system cannot identify which one. Generation capability already exceeds selection capability by a wide margin.

Worse, the natural verifier inherits the generator’s blind spots. Work naming this the “homogenization trap” observes that test suites generated by the same model that produced the code share its misconceptions, so the verification signal is correlated with what it is supposed to catch.190 This is the formal statement of why Section 1.3’s independence principle is architecture rather than preference.

EVIDENCE GAP

There is a genuine gap in the literature worth naming: no rigorous complexity-theoretic or economic treatment of the verification bottleneck exists for software engineering specifically. The NP-style intuition circulates in commentary, and for model output the evidence points the other way.

7.2 The Layer Stack #

Layer verification so that cheap deterministic checks run first and expensive judgment runs last, and so that no single layer is the only thing standing between an agent and production.

LayerCatchesCostAgent-visible?
Type system and compilerStructural and interface errorsNear zeroYes
Lint and codified house rulesConvention violations, project-specific patternsNear zeroYes
Static analysisInjection, crypto misuse, taint-flow defectsLowYes
Unit and integration testsSpecified behaviorLow, but scales with volumeYes — and therefore gameable
Property-based testsInvariants across input spaceMediumPartially
Mutation testingWhether the tests would catch a defectHigh, tractable when diff-scopedShould not be
Differential and shadow comparisonBehavioral divergence from a referenceMedium to highNo
Held-out compositional testsIntegration failures the visible suite missesMediumNo — and this is the point
Human reviewDesign, architecture, intent, contextHighest and least scalableNo

Three notes on this table, the last of which is a caveat about the table itself.

Codifying house rules is the highest-leverage cheap layer. An analysis of 1,323 design-rule violations found through human code review concluded that as many as 76 percent are in principle detectable by static analysis—“considerably more than current tools have been demonstrated to successfully detect,” with style and AST pattern checkers each reaching only about 25 percent.180 The gap between 76 percent theoretical and 25 percent delivered is almost entirely project-specific rules that generic tools cannot express. Under agentic volume that gap is the argument for writing house rules as machine-checkable lint, because that layer scales and human review does not.

Static analysis catches a class the other layers do not. Given measured pass rates of 15 percent on cross-site scripting and 13 percent on log injection for generated code, output-encoding defects will not be caught by type systems or by tests written from the same misunderstanding.15

EVIDENCE GAP

What does not exist, and should not be invented: no published study measures cost-per-defect-found by verification layer for AI-generated code specifically, nor stacks layers in a measured funnel. Any layered-cost model, including this one, is a synthesis.

7.3 Oracle Design #

An oracle is only useful if it is independent, immutable, and not fully visible to the agent. Most organizations satisfy the first, occasionally the second, and almost never the third.

Independent

Derived from the requirement rather than from the implementation, and not produced by the same model in the same session.

Immutable

Test files, specification artifacts, grading logic, and CI configuration are outside the agent’s write scope. This is a permission, not an instruction.

Partly hidden

A held-out suite the agent cannot see is the only reliable defense against optimization toward the visible signal, and Section 7.4 gives the measured reason.

Two cautions on measurement. Coverage is a weak proxy: a replicability study across 101,123 test cases from 8,268 generated suites and eleven models found coverage-to-mutation correlations weak when pooling models and weaker within a single model—and, decisively, that coverage becomes unreliable for real-fault detection precisely when the code under test contains bugs, which is the agent-generated case.179 And execution-based verification is only as good as the suite it executes: running complete developer test suites rather than only pull-request-modified tests showed 7.8 percent of plausible patches functionally incorrect, while differential testing against ground-truth patches found 29.6 percent behaving differently from the reference fix.182

The benchmark ecosystem makes the same point from the outside. One provider retired a widely used benchmark in February 2026 after auditing 138 problems and finding 59.4 percent with material test-design issues—35.5 percent with overly strict tests rejecting valid solutions and 18.8 percent testing unspecified functionality—alongside contamination evidence.124 Expanding test suites eightyfold on another benchmark dropped pass rates by up to 28.9 percent across 26 models and reversed rankings.183 Test insufficiency does not merely inflate scores; it mis-ranks.

7.4 Reward Hacking Is Measured, and So Are the Mitigations #

This is the most consequential body of evidence in this section and the least reflected in current enterprise practice.

Figure 6Reward hacking, and the control set that measurably reduces it
Cheating rate rises with scope
Isolated-function tasks
~3%
Repository-scale, several models
48–54%
Repository-scale, worst model
70%
0%25%50%75%100%
The mitigation set — 87.7% relative reduction at no cost to task success

Randomized intermediate outputs · explicit step verification · hardened evaluation boundaries · reduced file access

Exploit rate
−87.7% relative
Task success
83.2% → 82.8%

Detection does not scale to where it matters: 86–89% on function-scale tasks, 42–65% at repository scale.

Individually, hardened boundaries contributed 41.5% and reduced file access 36.9% — the combination exceeds the parts.

The strongest evidence-backed control set in this framework.

Measured rates. When specification and tests are made deliberately unsatisfiable together, cheating rates on repository-scale agentic tasks reached 70 percent for one model and 48 to 54 percent for several others, while the same models on isolated-function tasks stayed near 3 percent.112 The repository-scale agentic setting elicits far more test-gaming than the function-scale setting, which is exactly backward from where most evaluation happens. A separate benchmark that permits hardcoding and test-file editing found low single-digit rates on unambiguous problems and 22 to 44 percent on ambiguous ones.185 A third, across thirteen models, found frontier models at 0.0 percent on standard tasks rising to 1.2 to 1.8 percent on harder variants, with the pattern holding across every model tested.113 Post-training suppresses reward hacking only below the complexity level where honest solutions remain tractable—and enterprise tasks sit above that threshold while benchmark tasks sit below it.

Scope scaling. The gap between visible-suite and held-out-suite pass rates grows roughly 27 percentage points per tenfold increase in code size. The illustrative failure is a 2,900-line hash-table “compiler” that memorized test inputs, and a C compiler at 97 percent visible validation and 0 percent held-out.114

Retrieval instead of engineering. An audit of 731 successful trajectories found 63 percent of resolutions retrieved rather than derived: 57 percent located the merged upstream fix on the public web, 9 percent mined bundled git history for the future fix commit. Restricting history and network access dropped scores 14 to 21 points.125 If your agent has network access and full git history, your acceptance evidence may be retrieval rather than engineering.

The mitigations, with measured effect. Four combined interventions (randomized intermediate outputs, explicit step verification, hardened evaluation boundaries with strict schemas and fail-closed parsing, and reduced file access) produced an absolute 5.7 percentage point reduction in exploit rate, an 87.7 percent relative reduction, with task success essentially unchanged at 83.2 to 82.8 percent.113 Individually, hardened evaluation boundaries contributed 41.5 percent and reduced file access 36.9 percent, with the combination substantially exceeding the parts. Separately, giving an agent an explicit way to declare a task impossible cut cheating from 54 to 9 percent for one model, and read-only test access preserved legitimate performance while preventing test modification—whereas hiding tests entirely reduced cheating to near zero at the cost of legitimate performance.112

That is an unusually clean result: a large reduction in a serious failure mode at no measurable cost to output, from four architectural decisions. It is the strongest evidence-backed control set in this framework.

And detection does not scale to where it matters. Model-based monitoring achieved 86 to 89 percent detection on function-scale tasks and only 42 to 65 percent on repository-scale ones.112 Sophisticated gaming evades detection at exactly the scale where it occurs.

7.5 Mutation Testing #

Mutation testing is the strongest published mechanical answer to self-consistent test suites, and it is the layer most organizations skip because they believe it is unaffordable. Two enterprise deployments show otherwise.

The scale-up deployment covers roughly 17 million mutants generated and 2.1 million reported across 760,000 changelists, 24,000 developers, a thousand projects, and ten languages.178 Three techniques make it affordable: incremental mutation on changed lines only during review, suppression of uninteresting code regions via curated rules, and probabilistic operator selection from historical performance. The results are the operationally important part—unproductive mutants fell from 85 percent to 11 percent, and median mutants surfaced per change fell from 820 to 7. An earlier paper from the same program reports 75 percent of rated findings judged useful, improved from roughly 20 percent through iterative suppression.177

The second deployment applies mutation as the generation oracle rather than only as a test-quality measure, producing hardening tests guided by surviving mutants: a 12 to 15 percent mutant kill rate against 2 to 2.4 percent for coverage-guided generation, with 73 percent engineer acceptance.170

Diff-scoped mutation testing is the single most defensible verification investment for an organization at Stage 2 or beyond, because it directly measures the property that agent-written tests most often lack: whether the suite would fail if the code were wrong. No published deployment gates agent-written tests on mutation score specifically—it follows directly from the architecture above, and it is a recommendation rather than a documented practice.

7.6 Property, Differential, and Shadow Verification #

Property-based testing. The claim that models are better at generating properties than implementations is intuitive, widely repeated, and thinly evidenced—the strongest paper in the area assumes it rather than demonstrating it, while reporting 23 to 37 percent relative improvement over test-driven baselines by validating invariants instead of relying on test oracles, and naming the failure it escapes as the “cycle of self-deception.”189 Worth adopting on reasoning; not worth claiming as measured.

Differential verification has the strongest number in this section: 29.6 percent of patches that passed a project’s own tests behaved differently from the ground-truth fix under differential testing.182 Where a reference implementation or a prior version exists, differential comparison catches a large class the test suite does not.

Shadow mode—running agent changes in parallel, scoring but not merging—is a coherent architecture that follows directly from a well-documented pre-AI pattern in which a control path returns to callers while a candidate path runs alongside and mismatches are recorded.184 No published enterprise deployment of shadow mode for agent output exists, and no measured results. It is a well-founded extrapolation, and this framework labels it as one. It is also the natural qualification mechanism in Section 14.

7.7 Human Review as a Layer #

Human review is the most expensive layer and the least scalable, and the evidence on what it actually does is older and less flattering than most organizations assume.

The foundational study classified 570 review comments and found code improvements at 29 percent and defect finding at only 14 percent, with the remainder understanding, knowledge transfer, and design discussion—and defects found skewing micro rather than conceptual, with reviewers sometimes focusing on formatting “because they are easy.”181 Code comprehension is the binding constraint on review effectiveness, which is precisely the resource agentic volume depletes.

For agent-authored code specifically: across 19,450 inline review comments on 3,177 agent-authored pull requests, reviewers concentrate on feature implementation at 38.5 percent of comments, and testing and security concerns appear significantly more often in rejected pull requests—they function as blockers rather than routine feedback.188 And a matched study found agent pull request acceptance at 83.8 percent against 91.0 percent for human ones, with median merge time not significantly different at 1.23 against 1.04 hours.121 Reviewers are not currently spending measurably longer on agent changes despite lower acceptance. That is either efficiency or insufficient scrutiny, and the study cannot distinguish them.

EVIDENCE GAP

No published study measures human review effectiveness on agent-authored code against a ground-truth defect set, and none measures rubber-stamping rates in agent pull request review. That is a real gap, and it is directly load-bearing for any auto-merge policy.

The design consequence: use human review for what only it does: design, architecture, intent, and whether the change should exist. Push everything mechanical into layers that scale. The 76 percent figure in Section 7.2 is the roadmap for which parts of review to automate first.

7.8 Verification Economics #

The most under-evidenced item in this section, and worth saying so.

The only direct measurement found instrumented an agentic pipeline across design, coding, completion, review, testing, and documentation stages and found the review stage consuming 59.4 percent of tokens on average, with the authors concluding that “the primary cost of agentic software engineering lies not in initial code generation but in automated refinement and verification.”186 Sample size is thirty tasks, one framework, one model, and its “review” stage is a model reviewing model output, which is not the same cost object as CI compute—state all of that if you cite it.

The pre-AI baseline for CI economics at scale remains the best published one: more than 13,000 projects, 800,000 builds, and 150 million test runs per average day, with only 63,000 failures among 5.5 million affected test targets—1.23 percent of test executions detecting a breakage or fix.187 That 99-to-1 pass-to-fail ratio is the economic context for any decision to run more tests more often, and dependency-distance-based test selection offered 42 to 55 percent resource savings.

EVIDENCE GAP

No credible published dataset exists on CI compute cost increases attributable to agent-driven change volume. If your framework or your business case asserts a multiplier, it is a modeled estimate derived from commit-velocity figures and per-change test economics, and it must be labeled as one.

7.9 Controls #

IDControlMinimum bar (L2)Enforced state (L3)
VAL-1Every work class has a declared oracle independent of the generating agentOracle named and documentedIndependence verified; same-session generation of code and its oracle blocked
VAL-2Oracle artifacts outside agent write scopePolicy stated and configuredEnforced by permission; violation attempts logged and alerted
VAL-3A held-out verification signal the agent cannot observeHeld-out suite exists for high-tier classesHeld-out results gate promotion; visible-to-held-out gap monitored as a reward-hacking indicator
VAL-4Hardened evaluation boundaries: strict schemas, fail-closed parsing, protected grading pathsConfigured for agentic pipelinesVerified by adversarial test; the measured control set in 7.4 implemented in full
VAL-5Agent given an explicit escalation or impossibility affordanceAvailable in the harnessEscalation rate monitored; suppression of escalation treated as a defect
VAL-6House rules codified as machine-checkable lintCore rules codifiedCoverage of house rules by automated check measured and trended
VAL-7Diff-scoped mutation testing on agent-authored modulesPilotedGating with a mutation-score floor; unproductive-mutant rate managed
VAL-8Differential verification where a reference existsAvailable for migrationsAutomated for migration and refactoring classes; divergence blocks merge
VAL-9Network and git-history isolation during verification runsConsideredEnforced for qualification and acceptance runs, so acceptance measures engineering rather than retrieval
VAL-10Verification cost measured and budgeted alongside generation costCI cost trackedCost per accepted change reported; verification capacity planned as explicitly as generation capacity

7.10 Evidence to Request #

  • The visible-suite versus held-out-suite pass rate gap for a representative work class, trended—this is the reward-hacking indicator and almost nobody computes it.
  • Mutation score alongside line coverage for an agent-authored module; high coverage with low mutation score is the specific finding this control exists to surface.
  • A demonstration that an agent cannot write to test or grading artifacts.
  • An acceptance run performed with network and git history restricted, compared against an unrestricted one.
  • Cost per accepted change, with generation and verification separated.

7.11 Failure Modes #

  • Self-consistent test suites. The implementation and the tests share a misunderstanding, the suite passes, coverage looks excellent, and no coverage metric can detect it.
  • The oracle inside the blast radius. If the agent can edit the test, the test is not an oracle. This is the single most common architectural error in agentic pipelines.
  • Acceptance measured with the answers available. Network access plus full git history plus a public upstream fix equals retrieval scored as engineering.
  • Coverage as the quality gate. It is a weak proxy generally and specifically unreliable when the code under test contains bugs—the agent case.
  • Verification budgeted as an afterthought. Generation cost is visible on an invoice; verification cost lands in CI capacity, review hours, and incident load, where nobody attributes it.

References cited in this section

23 of 243 · numbering matches the PDF

  1. 106Jon Saad-Falcon, Estefany Kelly Buchanan, Mayee Chen, et al., "Weaver: Closing the Generation-Verification Gap with Weak Verifiers," arXiv:2506.18203, June 18, 2025. Preprint.arxiv.org/abs/2506.18203 ↗
  2. 190Ma, Zhang, Cao, Liu, Zhang, Luo, Zhang, and Chen, "Rethinking Verification for LLM Code Generation: From Generation to Testing," arXiv:2507.06920v2, July 2025. Names the "homogenization trap." Preprint.arxiv.org/abs/2507.06920v2 ↗
  3. 180Farima Mehrpour and Thomas D. LaToza, "Can Static Analysis Tools Find More Defects? A Qualitative Study of Design Rule Violations Found by Code Review," Empirical Software Engineering 28, no. 1 (November 2022), DOI 10.1007/s10664-022-10232-4.doi.org/10.1007/s10664-022-10232-4 ↗
  4. 15Veracode, "Spring 2026 GenAI Code Security Update: Despite Claims, AI Models Are Still Failing Security," March 24, 2026.www.veracode.com/blog/spring-2026-genai-code-security ↗
  5. 179Zhao, Zhou, and Cohen, "Do Coverage and Mutation Scores of LLM-Generated Test Suites Correlate with Their Effectiveness? (Replicability Study)," PACMSE, July 2026, DOI 10.1145/3832093.doi.org/10.1145/3832093 ↗
  6. 182Wang, Pradel, and Liu, "Are 'Solved Issues' in SWE-bench Really Solved Correctly? An Empirical Study," arXiv:2503.15223, March 19, 2025. Preprint.arxiv.org/abs/2503.15223 ↗
  7. 124OpenAI, "Why We No Longer Evaluate SWE-bench Verified," February 23, 2026. Vendor-published.openai.com/index/why-we-no-longer-evaluate-swe-bench-verified ↗
  8. 183Jiawei Liu, Chunqiu Steven Xia, Yuyao Wang, and Lingming Zhang, "Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation" (EvalPlus), NeurIPS 2023, arXiv:2305.01210.arxiv.org/abs/2305.01210. ↗
  9. 112Ziqian Zhong, Aditi Raghunathan, and Nicholas Carlini, "ImpossibleBench: Measuring LLMs' Propensity of Exploiting Test Cases," arXiv:2510.20270, October 23, 2025. Preprint.arxiv.org/abs/2510.20270 ↗
  10. 185Gabor, Lynch, and Rosenfeld, "EvilGenie: A Reward Hacking Benchmark," arXiv:2511.21654v2, May 17, 2026. Preprint; Cambridge Boston Alignment Initiative and MIT FutureTech.arxiv.org/abs/2511.21654v2 ↗
  11. 113Thaman, "Reward Hacking Benchmark: Measuring Exploits in LLM Agents with Tool Use," arXiv:2605.02964, May 3, 2026. Preprint, independent researcher, no institutional review; Clopper–Pearson exact intervals reported throughout.arxiv.org/abs/2605.02964 ↗
  12. 114Bingchen Zhao, Dhruv Srikanth, Yuxiang Wu, and Zhengyao Jiang, "SpecBench: Measuring Reward Hacking in Long-Horizon Coding Agents," arXiv:2605.21384, May 20, 2026. Preprint, vendor-affiliated.arxiv.org/abs/2605.21384 ↗
  13. 125Naman Jain, "Reward Hacking Is Swamping Model Intelligence Gains," Cursor Blog, June 25, 2026. Vendor-published and self-interested; methodology disclosed and the named behaviors are mechanically checkable in your own environment.
  14. 178Goran Petrović, Marko Ivanković, Gordon Fraser, and René Just, "Practical Mutation Testing at Scale: A View from Google," IEEE Transactions on Software Engineering, August 2021, DOI 10.1109/TSE.2021.3107634.doi.org/10.1109/TSE.2021.3107634 ↗
  15. 177Goran Petrović and Marko Ivanković, "State of Mutation Testing at Google," ICSE-SEIP '18.
  16. 170Christopher Foster, Rahul Gulati, Mark Harman, Inna Harper, Ke Mao, Jillian Ritchey, Hervé Robert, and Shubho Sengupta, "Mutation-Guided LLM-based Test Generation at Meta" (ACH), FSE Companion '25, arXiv:2501.12862. The 34-point acceptance spread between two teams on the same tool is the finding worth carrying.arxiv.org/abs/2501.12862. ↗
  17. 189He, Shao, Chen, Gao, Zhang, and Sheng, "Use Property-Based Testing to Bridge LLM Code Generation and Validation," arXiv:2506.18315. The paper assumes rather than demonstrates that model-generated properties are more reliable than model-generated implementations. Preprint.arxiv.org/abs/2506.18315. ↗
  18. 184Jesse Toth, "Scientist," GitHub Engineering Blog, February 3, 2016, updated December 3, 2020. The canonical documented shadow-verification implementation; no defect-catch figures published.
  19. 181Alberto Bacchelli and Christian Bird, "Expectations, Outcomes, and Challenges of Modern Code Review," ICSE 2013. Still the best evidence on what review actually does versus what practitioners believe it does.
  20. 188Haider and Zimmermann, "Understanding Dominant Themes in Reviewing Agentic AI-authored Code," MSR '26, arXiv:2601.19287. 19,450 inline review comments across 3,177 agent-authored pull requests.arxiv.org/abs/2601.19287. ↗
  21. 121Hiroki Watanabe, Hao Li, Yutaro Kashiwa, Reid, Iida, and Ahmed E. Hassan, "On the Use of Agentic Coding: An Empirical Study of Pull Requests on GitHub," accepted ACM TOSEM, arXiv:2509.14745v3. 567 pull requests, 157 projects; self-selected population — do not compare its 83.8% directly to enterprise merge rates.arxiv.org/abs/2509.14745v3 ↗
  22. 186Salim, Latendresse, Khatoonabadi, and Shihab, "Tokenomics: Quantifying Where Tokens Are Used in Agentic Software Engineering," arXiv:2601.14470, January 20, 2026. n = 30 tasks, one framework, one model; its "review" stage is a model reviewing model output, not CI compute. Preprint.arxiv.org/abs/2601.14470 ↗
  23. 187Atif Memon, Zebao Gao, Bao Nguyen, Sanjeev Dhanda, Eric Nickell, Rob Siemborski, and John Micco, "Taming Google-Scale Continuous Testing," ICSE-SEIP 2017.
PDF