How to Evaluate AI Coding: From Architecture Design to Operator Verification

    Evaluating AI-assisted programming requires more than benchmark rankings. This article explains why architecture quality and local correctness are independent dimensions, how to constrain code generation with clear design baselines and interface contracts, how to verify numerical operators through mathematical properties, analytic and manufactured solutions, and system-level tests, why backend interfaces demand a state-centric view, and how to design trustworthy code reviews and a controlled design-implement-verify-integrate-regress delivery workflow that measures total engineering cost rather than first-pass generation speed.

    1. From “Which Is Stronger” to “Which Task Requires Which Capability”

    When evaluating AI coding capabilities, it is tempting to reduce a complex problem to a ranking: which system generates code faster, which passes more tests on the first attempt, and which is better at handling large requirements.

    In real engineering, these metrics do not always point to the same conclusion.

    An implementation may pass all local tests yet break module boundaries. It may also have a clean structure and tidy interfaces but produce wrong results under extreme inputs. For backend services, the problem may appear as duplicate requests causing duplicate deductions; for scientific computing, it may appear as a discrete operator that satisfies array shape requirements but violates the conservation properties it should preserve.

    Therefore, professional evaluation should shift from “overall capability” to “whether tasks, constraints, and evidence match.” At least four levels must be distinguished:

    1. Requirement understanding: Does the system identify inputs, outputs, constraints, and failure conditions?
    2. Architecture design: Does it form stable module boundaries and dependency directions?
    3. Local implementation: Does it correctly handle algorithms, exceptions, and edge cases?
    4. System verification: Does it detect cross-module, cross-state, and cross-time problems?

    These four capabilities are related but cannot substitute for one another. Rigorous local implementation does not imply sound system design, and complete design documents do not guarantee correct mathematical computation.

    2. Architecture Quality and Local Correctness Are Two Independent Dimensions

    2.1 What Is Local Correctness

    Local correctness concerns whether a function, interface, or operator behaves as expected within given constraints, for example:

    • Whether inputs are properly validated;
    • Whether boundary conditions are covered;
    • Whether return values satisfy the contract;
    • Whether exceptions are propagated correctly;
    • Whether numerical results fall within a reasonable error range;
    • Whether out-of-bounds access or resource leaks occur.

    These checks are essential, but they are usually built on limited context. A function can fully satisfy its own interface contract yet still contribute to a system failure because of upstream misuse, downstream repeated execution, or uncontrolled shared state.

    2.2 What Is Architecture Consistency

    Architecture consistency concerns whether the system as a whole follows common rules, including responsibility division, dependency direction, state ownership, resource lifecycles, and error-handling mechanisms.

    For example, if the same kind of grid data validation is scattered across multiple operators, it may look safer in the short term, but over time the rules tend to diverge: one operator supports a new boundary type while another still rejects the input under old rules. At that point, defensive code itself becomes a maintenance risk.

    However, this does not mean all redundant validation should be removed. External input boundaries, cross-process communication boundaries, and high-risk computation entry points usually still require explicit checks. The real question is:

    Is the check placed at the correct trust boundary, and is its maintenance responsibility clear?

    Similarly, synchronous execution is not inherently outdated, and asynchronous execution is not inherently superior. Whether to adopt concurrency should be decided based on task dependencies, resource contention, throughput targets, and error-handling complexity—not by treating one coding style as a marker of sophistication.

    3. Write Down Design Constraints First, Then Let AI Coding Do the Implementation

    For medium-to-large projects, directly prompting “implement a complete system” tends to hand a large number of design decisions implicitly to the generation process. This easily produces a set of locally reasonable solutions that conflict with each other when combined.

    A more reliable approach is to first establish an engineering specification that constrains the implementation.

    3.1 Define Module Responsibilities and Dependency Directions

    Taking a scientific computing library as an example, a conceptual layering might look like:

    1. Business scenarios and computation configuration
    2. ↓
    3. Time stepping and solution workflows
    4. ↓
    5. Discrete operators and boundary handling
    6. ↓
    7. Grids, fields, and basic data structures

    This structure is not the only answer. The key is to make explicit which dependencies are allowed and which are forbidden.

    For example, low-level discrete operators should not directly read business configuration files, nor should they decide on their own where results are written. Otherwise, numerical logic becomes coupled to the runtime environment, making testing, reuse, and replacement difficult.

    3.2 Define Interface Contracts

    An actionable interface contract should include at least:

    • The shape, type, and units of input objects;
    • Who interprets and enforces boundary conditions;
    • Whether in-place modification of inputs is allowed;
    • Who owns and releases output objects;
    • How invalid inputs and computation failures are expressed;
    • Whether thread safety or reentrancy is required;
    • Constraints on precision and resource consumption.

    “Compute the divergence of the velocity field” is a feature name, not a complete contract. You also need to specify whether velocity components are stored at cell centers or cell faces, which spatial position the output corresponds to, and how different boundary conditions are handled.

    3.3 Specify Forbidden Implementation Behaviors

    Besides describing what should be done, also write down what must not be done, for example:

    • Do not duplicate the same core computation logic across multiple modules;
    • Do not silently modify input data;
    • Do not relax established error tolerances just to pass tests;
    • Do not introduce file I/O in low-level operators;
    • Do not catch exceptions and return seemingly valid default results.

    These constraints reduce the erosion of the overall design by local implementations, but they still need to be enforced through code review and testing—they cannot rely on written requirements alone.

    4. Operator Verification Cannot Stop at “The Example Runs”

    Errors in scientific computing often do not crash the program; instead, they produce results that look smooth but are actually wrong. Verification should therefore cover both numerical properties and engineering behavior.

    4.1 Basic Test Cases

    First, check common inputs, minimal-size inputs, invalid parameters, and boundary branches. This catches direct problems such as indexing errors, shape mismatches, and missing parameters.

    But basic cases only prove behavior under limited conditions; they cannot by themselves prove algorithmic correctness.

    4.2 Mathematical Property Verification

    If an operator has well-defined mathematical properties, they can be turned into test criteria.

    For example:

    • Under the applicable discrete definition, the gradient of a constant scalar field should be zero or close to zero;
    • For linear operators, verify that linearity holds within numerical error;
    • For conservative discrete methods, check the relationship between internal flux cancellation and net boundary flux;
    • For methods claiming a specific convergence order, verify how the error changes under grid refinement.

    These properties must be consistent with the grid layout, boundary conditions, and discrete definitions. Conclusions from continuous mathematics cannot be applied unconditionally to any discrete implementation.

    4.3 Analytic and Manufactured Solution Verification

    When an analytic solution exists, numerical results can be compared directly against theoretical results.

    When no convenient analytic solution exists, you can choose a sufficiently smooth target function, substitute it into the governing equations to derive the corresponding source term, and then check whether the discrete solution converges to the target function. This approach is suitable for verifying whether a discrete implementation preserves the expected convergence behavior.

    If the error approximately satisfies:

    1. E(h) ≈ C × h^p

    where h is the grid spacing and p is the convergence order, then once the asymptotic convergence regime is reached, halving the grid spacing should produce an error ratio close to 2^p.

    Practical judgment should also account for rounding error, iterative solver tolerances, and boundary discretization—do not rely on the error observed on a single grid.

    4.4 System-Level Verification

    A gradient operator and a divergence operator each passing their own tests does not guarantee that their combination is suitable for the target solution workflow.

    You still need to verify:

    • Whether the spatial positioning conventions of the operators are compatible;
    • Whether boundary handling is duplicated or omitted;
    • Whether intermediate variables are accidentally overwritten;
    • Whether the time step satisfies applicable conditions;
    • Whether non-physical drift appears during long runs.

    Local tests prove component behavior; system tests verify how components work together. Neither can be omitted.

    5. Backend Interface Development Also Requires Going Beyond the Local View

    The “correctness” of a backend interface is not just about returned fields matching the contract—it also includes whether business state changes reliably.

    Taking a task-creation interface as an example, you need to answer at least:

    • If the client submits repeatedly, will multiple identical tasks be created?
    • If the data write succeeds but the message send fails, how is recovery handled?
    • After a request times out, can the caller query the actual execution result?
    • When multiple workers process a task concurrently, are state transitions constrained?
    • Does the permission check cover the real resource, rather than only validating the request format?

    These problems cannot be solved by simply adding more conditional checks inside a function. They typically involve transaction boundaries, idempotency mechanisms, concurrency control, message delivery, and observability design.

    Therefore, when AI coding participates in interface development, it should first receive a complete description of state changes before implementing the concrete handling logic. Otherwise, the system may have a large amount of rigorous local validation while lacking a reliable business closed loop.

    6. How to Design Trustworthy Code Review and Capability Evaluation

    6.1 Observe Precision and Recall Together

    Defect review cannot be judged only by “how many problems were found.”

    Precision measures how many of the reported problems are real defects; recall measures how many of the real defects were successfully found. One review process may have few false positives but miss many issues; another may have broad coverage but require more manual triage.

    Evaluation should therefore also incorporate defect severity, fix cost, and review time, rather than counting all problems with equal weight.

    6.2 Prioritize Mutually Independent Evidence

    Having multiple execution units reread the same code does not necessarily improve reliability. If they share the same assumptions, they may miss the same class of errors simultaneously.

    A more effective approach is to split review responsibilities:

    • One checks requirements and interface contracts;
    • One checks state transitions and concurrency;
    • One checks mathematical properties and boundary conditions;
    • One checks performance and resource lifecycles;
    • Finally, consolidate and verify the findings together.

    For high-risk modules, the verification basis should be as independent from the implementation process as possible. For example, the implementer writes code based on requirements, while the reviewer designs tests based on mathematical definitions or business invariants, rather than merely restating the implementer’s explanation.

    6.3 Avoid Relying on a Single Aggregate Score

    A credible engineering evaluation should fix the task scope, context materials, available resources, time limit, and acceptance rules, and record multiple dimensions:

    Dimension Key Observations
    Functional correctness Whether requirements and edge cases are satisfied
    Design consistency Whether module boundaries and dependency rules are respected
    Defect discovery Whether real problems are identified with few misses
    Maintainability Whether the code is easy to understand, modify, and extend
    Performance Whether target load and resource constraints are met
    Delivery cost Human intervention, verification, and rework effort

    Unverified scores, test results of unknown origin, and cross-comparisons made under inconsistent conditions should not be used directly to draw engineering conclusions.

    7. Bring AI Coding into a Controlled Delivery Workflow

    In practice, a closed loop of “design—implement—verify—integrate—regress” can be adopted.

    Step 1: Clarify requirements.
    List goals, non-goals, inputs and outputs, failure conditions, and acceptance criteria. Resolve ambiguities before coding.

    Step 2: Establish a design baseline.
    Define module boundaries, public interfaces, state ownership, and key invariants. Major design changes require separate justification and must not slip in silently among implementation details.

    Step 3: Implement in small batches.
    Complete one independently reviewable capability at a time, and avoid modifying many related modules at once. The more concentrated the change, the easier it is to locate problems.

    Step 4: Verify independently.
    Run local tests first, then perform checks at the level of mathematical properties, business state, and integration. For critical defects, add regression cases that reproduce them stably.

    Step 5: Tidy up the structure.
    Check for duplicated logic, overly deep branching, implicit state, or responsibility drift. Preserve a behavioral baseline before refactoring, so that “cleaning up the code” does not introduce new functional changes.

    Step 6: Record the true cost.
    Beyond generation time, also track human review, test execution, problem diagnosis, and rework costs. The final comparison should be the total investment needed to reach the same acceptance standard—not the speed of the first code generation.

    8. Conclusion: Truly Reliable Capability Shows Up in the Engineering Closed Loop

    AI coding should not be understood as a unified capability that automatically handles architecture, algorithms, testing, and maintenance all at once. Different tasks depend on different evidence, and different stages require different constraints.

    For architecture design, the keys are clear boundaries, stable dependencies, and controllable evolution. For low-level operators, the keys are explicit mathematical definitions, sufficient verification, and explainable performance. For backend business logic, the keys are consistent state, recoverable failures, and traceable behavior.

    Therefore, the most valuable question for judging whether AI coding is mature enough is not “Can it generate a complete project in one shot?” but rather:

    Under explicit constraints, can it continuously deliver verifiable, maintainable, and evolvable results at an acceptable total cost?

    Only by bringing design responsibility, verification evidence, and delivery cost into the same workflow can AI coding evolve from a code-production tool into a genuinely reliable engineering collaboration capability.