AI Coding Reliability: Why an Evidence Loop Comes First

    This article explains why faster AI code generation does not automatically improve development efficiency, and how an "evidence loop" addresses the core bottleneck: human review bandwidth. It covers shifting review from raw code to verifiable evidence, using an independent grader, prioritizing end-to-end, property-based, and conformance tests, externalizing error memory through rules and hooks, and avoiding flaky or slow test suites with a layered testing strategy. It also outlines how cloud infrastructure can support the resulting AI-output, automated-verification, evidence-archiving, and merge-decision pipeline.

    When AI Becomes the Primary Developer: A Trust Crisis Gives Rise to the “Evidence Loop”

    As intelligent coding tools take on a larger share of the work, many engineering teams have noticed a striking pattern: development tasks that once required senior engineers can now be generated by AI in minutes, producing large volumes of code. Yet the increase in code generation speed has not translated directly into higher development efficiency, and the reason is straightforward — the cost of generating code has dropped, but the cost of verifying that the code is correct has not dropped at the same rate.

    Take the internal practice of one technical team as an example. Roughly ninety percent of the code in its core development team is now written and reviewed by intelligent coding tools. Three years ago, that ratio would have been almost unimaginable, but it is gradually becoming an industry norm today. What supports this ratio is not a sudden leap in AI capability, but the maturity of an entire engineering governance system. The team calls this system the “evidence loop”: every piece of AI-produced code must come with reproducible evidence showing that it has passed real tests, met explicit rules, and introduced no new defects.

    Why Can One Person Only “Watch” One or Two AIs?

    Teams that adopted AI-assisted programming early on commonly went through a bottleneck period. Developers would often open two or three AI sessions at the same time, each handling a different module, but they would quickly find themselves overwhelmed. The reason was that there was no automated verification in place, so all code could only be checked line by line by human eyes. Human attention bandwidth is limited, and when facing the dozens of lines of code that AI generates per second, manual review speed simply could not keep up, allowing errors to slip quietly into the main branch.

    This created the first physical wall for scaling AI programming: the developer’s review bandwidth.

    Breaking the Bottleneck: From “Humans Watching Code” to “Humans Watching Evidence”

    The core idea of the evidence loop is to shift the object of review from “the code itself” to “the evidence the code submits.” Specifically, when a development task is completed, the AI must deliver not only code but also the following three types of evidence:

    • Test pass records: automated test results for the code, including pass/fail status, execution time, and the paths covered.
    • Rule compliance declaration: which project standards the output followed, and whether any exceptions were triggered.
    • Impact scope list: which files were modified and which downstream modules might be affected.

    When all three types of evidence are present, developers no longer need to read the code line by line. Instead, they review whether the evidence is sufficient and whether the tests genuinely cover the critical paths. The unit of review changes from “a line of code” to “a complete task package,” improving review efficiency by an order of magnitude. In this team’s experience, one person can direct dozens or even hundreds of AI sessions working in parallel — provided, of course, that every session produces automatically verifiable evidence.

    The “Scoring Criteria” of the Evidence Loop: Make the Grader Check Against the Standard

    For an evidence loop to hold, there must be a scoring mechanism that is independent of the code generator. If the AI that writes the code is also responsible for “grading” it, it can easily produce a test that “looks like it passes but is actually ineffective,” or use carefully constructed mocks to hide real problems.

    The approach this team takes is to introduce an independent grading tool: developers define structured expected outputs in the test framework, such as which fields a certain configuration file must contain, which status codes a certain API must return, or what the output schema of a certain data processing flow looks like. Then an evaluator that is unrelated to the code generation strictly validates the AI’s output against these criteria.

    Internal test data shows that introducing an independent grader improved the task success rate by about 10 percentage points on structured file generation tasks. More notably, the higher the task difficulty, the more pronounced the improvement — because errors in simple tasks are easier for humans to spot, while hidden errors in complex tasks can only be exposed through strict external validation.

    Three Types of Tests Most Worth Investing In

    Under the evidence loop framework, not all test types are worth investing the same amount of resources in. Based on return on investment, this team selected three types of tests that are most worth building first.

    1. End-to-End Tests: The Gate AI Finds Hardest to Bypass

    If resources are limited and only one type of test can be built, end-to-end tests should be the first choice. The reason is that they are the verification method hardest to bypass through shortcuts.

    End-to-end tests simulate the complete operation path of a real user. For example, a user adds an item to the shopping cart, goes to the checkout page, selects a payment method, clicks submit, and finally reaches the payment success page. The whole process does not rely on mocks or human judgment; the system either runs through or it does not, with no middle ground.

    The difference is clearer when compared with unit tests. When a unit test times out, the error message is often just “30-second timeout,” making it impossible to tell where it got stuck. An end-to-end test, on failure, directly takes a screenshot, records the complete execution trace, and points out the current page state. If the checkout button is disabled, the test report shows that state directly, and developers can immediately tell whether the inventory check failed, the coupon expired, or the risk-control API returned an error.

    To make end-to-end tests truly effective, this team gave the AI permission to operate a real environment:

    • Use a browser extension to simulate user operations on web pages;
    • Use a mobile emulator to validate app interactions;
    • Use desktop control to test client software;
    • Bring up backend services locally for interface-level integration debugging.

    So that the AI “knows which path to take,” the team also maintains a feature map. This map lists the key operation paths, shortcuts, and expected behavior of real users, and serves directly as the AI’s construction guide and scoring criteria. Every time the AI modifies code, the system automatically runs the end-to-end tests according to the feature map and feeds the results back to the AI.

    2. Property-Based Tests: Catching Edge Cases Both Humans and AI Miss

    The second type most worth investing in is property-based testing. When human developers write tests, they usually cover the boundary cases they can think of. But the problem is that both humans and AI have cognitive blind spots. The value of property-based testing lies precisely in filling those blind spots.

    The approach is this: the developer first writes down a rule that must never be broken, then uses a random generation tool to automatically generate thousands upon thousands of input sets and tries with full force to break the program. Common rules include:

    • Data must be fully restored after serialization and then deserialization;
    • An account balance must never become negative after any sequence of operations;
    • Running the same migration logic once and running it twice must produce exactly the same result;
    • Optimized new code and unoptimized old code must produce exactly the same output for the same input.

    These rules are inherently adversarial — random boundary conditions carry no subjective bias, do not consider that “users probably won’t operate this way,” and only focus on “whether the system could crash under some input.” Property-based testing is especially effective in refactoring scenarios where the original specifications have become detached from production reality. AI can easily introduce behavioral drift when refactoring code, and property-based tests can catch that drift immediately.

    The random generation tool this team uses has multiple common implementations in the industry, with corresponding open-source libraries in different language ecosystems. When choosing one, the main considerations are whether it supports custom random strategies and whether it supports automatic shrinking of failing cases — that is, compressing a complex failing input into a minimal reproduction case.

    3. The Third Type Beyond End-to-End and Property-Based Tests: Conformance / Anti-Regression Tests

    Beyond the first two types, the third worth investing in is conformance testing. This type of test does not care whether the functional logic is correct; it only cares whether the code conforms to the project’s established constraints. For example, it may prohibit printing user privacy fields in logs, prohibit introducing synchronous blocking calls in core paths, or prohibit committing functions that exceed a certain cyclomatic complexity.

    These tests are often lightweight and fast to run, but their value lies in establishing a baseline against regression. When AI modifies code in batches, it can easily introduce these violations inadvertently. Once conformance tests are integrated into the continuous integration pipeline, they can automatically intercept such issues.

    Let AI Keep Stepping into the Same Pit? Use Feedback Interception to End Recurring Errors

    Even with a well-built test system, AI will still repeat mistakes. A typical scenario is that the AI writes a user’s phone number in plaintext into a log during one task; although the tests catch the problem, the logic the AI uses when fixing it may introduce another similar issue.

    This team’s solution is to build a feedback interception mechanism, whose core idea is: once an error is confirmed, turn it into a reusable line of defense. There are two specific approaches:

    The first is to write explicit constraints into the project rules file. For example, this team’s rules file contains a rule that all fields involving user information must be processed by a masking function before they can enter the logs. This rule is loaded into the AI’s context before every task begins, preventing similar problems at the source.

    The second is to add hooks. A hook can be understood as a validation script that is automatically triggered at key points. For example, before code is committed, all newly added log statements are automatically scanned to check whether they contain sensitive field patterns. The advantage of hooks is that they exist independently of the AI’s “memory” and will not be forgotten as the context window slides.

    Combined, these two approaches form an externalization of error memory: the AI does not need to “remember” what mistakes it has made; the system remembers for it and automatically applies those lessons in every task.

    Two of the Most Common “Ways to Die” and How to Avoid Them

    To make the above system truly work, two high-frequency failure modes must be avoided.

    Failure Mode 1: Flaky Tests Teach AI to “Game the Pass” Rather Than “Fix the Code”

    If the tests themselves are nondeterministic — for example, occasionally timing out, depending on external network state, or being affected by the concurrent environment — the AI will quickly “learn” a bad strategy: repeatedly retrying until the test happens to pass, rather than actually fixing the defect in the code.

    This situation is especially dangerous in AI programming, because the AI’s optimization goal is to “make the tests pass.” If the tests are unreliable, the AI’s optimal strategy becomes “gaming” rather than “fixing.”

    The way to avoid this is to ensure the determinism of tests:

    • Isolate external dependencies, using a local database or mock services;
    • Fix random seeds so that randomized tests are reproducible;
    • Set reasonable thresholds for timeouts, and distinguish between “genuinely stuck” and “high machine load.”

    Failure Mode 2: Tests Too Slow, Sharply Reducing AI’s Batch Troubleshooting Frequency

    End-to-end tests offer higher coverage, but their execution time is usually longer. If a suite of end-to-end tests takes half an hour, the loop of the AI running them after every change and then waiting for results becomes extremely inefficient. The developer’s attention is interrupted, and the AI’s batch troubleshooting capability is severely weakened.

    This team’s solution is a layered testing strategy:

    • Fast layer (unit tests, static checks): completed in seconds, serving as the first feedback after each AI change;
    • Medium layer (integration tests, conformance tests): completed in minutes, run in batches at fixed intervals;
    • Slow layer (end-to-end tests): ten minutes to hours, serving as the final acceptance criterion.

    The AI iterates quickly in the fast layer, and only after all fast tests pass are the medium and slow layers triggered for validation. This ensures both feedback speed and depth of coverage.

    Engineering Practice from Baidu AI Cloud’s Perspective

    For teams that want to implement an AI coding governance system, the underlying engineering infrastructure is equally critical. Baidu AI Cloud provides a combination of cloud services covering the entire development lifecycle, which can serve as the technical foundation for an AI programming evidence loop.

    At the level of code hosting and collaboration, a cloud code repository with branch protection rules can ensure that AI-produced code must pass automated validation before it can be merged. At the level of continuous integration and continuous delivery, cloud pipeline services support multi-stage builds, parallel testing, and result aggregation, naturally fitting a layered testing strategy. At the level of logging and monitoring, a unified logging service can collect test execution traces, error stacks, and performance metrics, providing developers with traceable troubleshooting evidence. At the level of artifact management, container image repositories and artifact repositories can ensure that the output of each build is traceable and rollback-able.

    More importantly, these cloud services can be orchestrated through standard APIs and message queues to form a complete pipeline of “AI output → automated validation → evidence archiving → merge decision.” Developers only need to focus on defining rules and designing scoring criteria, while the underlying infrastructure is managed by the cloud platform.

    Summary: The Reliability of AI Programming Depends on the Maturity of the Governance System

    Back to the original question: is AI-written code reliable? The answer is — reliable, but on the premise that you have built an engineering system that constrains it, verifies it, and corrects it.

    From the evidence loop to the independent grader, from end-to-end tests to property-based tests, from feedback interception to a layered strategy, every link is solving the same fundamental problem: how to turn AI output from “looks right” into “proven right.” The cost of building this system is not low, but once it is in place, the developer’s role shifts from “line-by-line reviewer of code” to “definer of quality standards and auditor of evidence.” That shift is the key to AI programming truly unleashing its scale effects.