AI Code Quality: Who Validates the 90% Written by Agents

    When AI agents generate most of the code, the real challenge is no longer writing speed but quality control. This article examines an agent-cluster project that built an offline cloud service simulator and abstract its quality framework: six automated review gates plus a rollback fallback. It explains the three-tier division of labor that separates coding from verification, why this model is hard to transplant directly to business code, and practical engineering recommendations for teams investing in reliable validation systems.

    Introduction: When Code Production Is No Longer the Bottleneck

    When the industry starts discussing scenarios where agents generate 90% of the code, the real focus is not “who writes faster” but “who decides whether it is correct.” A representative case is a team that used an agent cluster to build a localized cloud service simulator covering more than 200 service interfaces. It works fully offline and is open-sourced under a highly permissive license. The project team emphasized that “no line of code was hand-written, and no line-by-line human review was performed.” This sounds like a complete disruption of the traditional development process. Yet a closer look at its engineering structure reveals that what truly enables it to run autonomously is a system of explicitly defined, automatically executable “merge gates.”

    Using this kind of practice as a sample, this article abstracts a general framework for code quality assurance in the agent era: six review gates plus one rollback fallback. It further discusses the framework’s applicable boundaries and how to implement it.

    1. Three-Tier Division of Labor in the Agent Cluster: Separating Writing from Verification

    The agents in this practice are divided into three groups with clear responsibilities:

    • Group 1: Behavior baseline collection. Write “fidelity tests” based on public interface descriptions. For example, in message queue semantics, after a message is read by a consumer, it should not be fetched again by another consumer within the visibility timeout window. These tests first run and pass against a real cloud environment, effectively “recording” the real service’s behavior as an executable source of truth.
    • Group 2: Difference detection. Run the same test suite against the simulated implementation, turn inconsistencies into issues to be fixed, and log them into the database.
    • Group 3: Single-point fixes. One agent handles only one issue, preventing the scope of changes from spreading and ensuring that changes are attributable and revertible.

    Methodologically, this structure is quite traditional—test-driven development combined with code review, except that the reviewer is also a model. The key prerequisite for scaling it is having a “reference answer” on hand: the real service’s behavior can be executed and compared at any time. According to public descriptions, hundreds of agents were working in parallel at the time, processing thousands of issues per day.

    2. Six Review Gates: Automated Gatekeeping Before Merge

    Before a merge request is formally submitted, most checks have already been completed. They can be summarized as six gates:

    1. Executable verification gate. Provide agents with verification methods that actually run: execute tests, execute builds, or, for UI tasks, compare screenshots with design mockups—and require them to submit actual output rather than merely declaring “done.”
    2. Independent-context review gate. A sub-agent with a fresh context reviews the code diff. Context isolation significantly reduces “self-confirmation bias”—the model that wrote the code naturally tends to believe it is correct.
    3. Compilation and static analysis gate. A failed build is blocked immediately. This is the cheapest and most rigid gate.
    4. Convention consistency gate. Check whether code style, directory structure, dependency usage, and existing project conventions are consistent, avoiding the long-term maintenance cost of style drift.
    5. Security review gate. Look for common issues such as hard-coded credentials, unvalidated input, ambiguous permission boundaries, and untrusted dependency sources.
    6. Fidelity regression gate. Specifically confirm that the change has not caused existing behavior to regress—that fixing one issue has not broken another behavior baseline that already passed.

    If any of the six gates fails, the change is sent back for rework. In addition, there is a rollback fallback to catch accidents beyond automated judgment.

    3. Why This System Cannot Be Directly Transferred to Business Code

    The limitations are stated openly: the repository has a dedicated directory listing “what currently cannot be done,” including rate limiting, fault injection, and cross-region service differences that have not yet been simulated, as well as the lack of sandbox isolation for code execution. The more fundamental gap lies in the verification baseline:

    • No real version available for comparison. Business requirements themselves are often vague, and there is no “production ground truth” to compare against item by item.
    • Test effectiveness becomes the new bottleneck. If tests are generated by the same set of models, they may share the same misunderstanding of semantics, forming “consistently wrong” false negatives.
    • Non-functional requirements are hard to judge automatically. Metrics such as maintainability, observability, and cost efficiency are difficult to cover with a single assertion.

    Therefore, the transferable part of this system is the “gate structure,” not the “no-human conclusion.”

    4. Actionable Engineering Recommendations

    • Write specifications and acceptance criteria as executable artifacts first. The output of a requirements review should be test cases and acceptance scripts, not just documentation.
    • Enforce context-isolated review. A sample flow is shown below:
    1. Change -> Build/unit tests -> Independent sub-agent review (new context)
    2. -> Convention check -> Security check -> Behavior regression -> Merge -> Canary -> Rollback on anomaly
    • Prepare sandboxes and least privilege for agents. Runtime isolation, short-lived credentials, and restricted network egress are prerequisites for enabling automated writes.
    • Keep human “gate-definition authority.” Engineers shift their focus to writing specifications, writing tests, and setting thresholds—deciding “what counts as correct.”
    • Measure the signal-to-noise ratio of the gates themselves. Continuously track each gate’s interception rate and false-positive rate. Gates with excessive false positives will be bypassed by both agents and developers, eventually becoming meaningless.

    Conclusion

    What this kind of practice truly proves is not that engineers are replaced, but that once verification methods are reliable enough, agents can independently deliver quite complex results. The focus of quality assurance is shifting forward from “reading implementations line by line” to “designing verification and gates.” For teams, what is worth investing in first is not a model that writes code better, but a more trustworthy verification system—it determines how far automation can go.