Engineering Evaluation and Safe Delivery for Long-Horizon AI Coding
This article explains how to evaluate long-horizon AI coding systems beyond "does the code run." It proposes a complementary evaluation framework combining an incremental feature task on a legacy system with a from-scratch product build, examines secure design for an image asset pipeline (authentication vs. authorization, file validation, async task permissions, render isolation), state-machine verification for a learning game, business-invariant-driven testing, reproducible evaluation records, and human oversight at high-risk decision points.
1. Evaluating AI Coding Capability Requires More Than “Does the Code Run”
When an AI coding system takes on cross-module development tasks, the evaluation criteria must change accordingly. Completing a function or fixing a local bug mainly tests code comprehension and short-range reasoning. Adding a complete feature to a system with a large existing codebase, however, requires handling architectural constraints, data models, interface contracts, asynchronous tasks, UI interactions, and test validation all at once.
The core difference is this: the former asks whether a local answer is correct, while the latter asks whether the entire chain of changes is consistent.
Therefore, judging AI coding capability means answering at least four questions:
- Does the system accurately understand the requirements, including boundary conditions that were never written down?
- Can it make cross-module changes along dependency relationships, rather than only implementing the entry-point page?
- Can it discover problems from runtime results, then fix and regression-test them?
- Can it demonstrate that the new feature has not broken existing permissions, security controls, and business rules?
The fourth question is especially easy to overlook. A program that starts, pages that respond, and a fully green test suite do not mean the system is ready to ship. Tests can only verify rules that have been expressed; they cannot automatically prove that uncovered security constraints still hold.
The focus of evaluation should shift from “how much code was generated” to “how many independently verifiable engineering outcomes were produced.”
2. What Long-Horizon Tasks Actually Test
Long-horizon AI coding is not simply letting a model work longer. It requires the system to keep goals, constraints, and state consistent across a long execution chain.
2.1 Building a Correct Structural Understanding of the System
With a legacy project, the first step is locating business entry points, data ownership, task scheduling mechanisms, and key interfaces. Without a basic dependency map, subsequent changes tend to stay superficial.
For example, adding an image import capability is not just about finding the upload component. You also need to confirm where image metadata is stored, who makes access-control decisions, how background jobs obtain the files, and whether the final rendering process can safely use those resources.
A more reliable approach is to first produce a short system brief covering:
- Which modules are involved and their responsibilities;
- The steps a request passes through from entry to final handling;
- How identity information and resource ownership propagate;
- Which modules have legacy compatibility requirements;
- Which boundaries are security-sensitive.
This brief serves as both a development plan and a baseline for later human review.
2.2 Maintaining Contract Consistency Across Modules
Errors in long tasks are often not obviously wrong code, but divergent understandings of the same concept across modules.
For example, the frontend assumes an asset belongs to the current project while the server only checks that the asset exists; a background job stores a file path but no verifiable resource ownership; after an asset is deleted, existing render jobs keep using the stale reference.
These are all contract inconsistencies. Solving them requires clearly defining resource identifiers, state transitions, error semantics, and permission conditions—and ensuring every related module follows the same rules.
2.3 Making Evidence-Based Fixes After Failure
Making changes continuously is not the same as making progress. A reliable execution process includes an explicit feedback loop:
Form a hypothesis → implement the change → run validation → analyze the failure → narrow the problem scope → fix and regress.
If the system simply keeps appending patches in response to error messages, the end result may include duplicated logic, bypassed validation, or deleted tests. Evaluation should therefore look not only at whether the final run succeeded, but also at whether the repair process sacrificed any original constraints.
3. Building a Complementary Evaluation System with Two Task Types
A single task can hardly reflect the full engineering capability of an AI coding system. A representative combination is one incremental development task on a legacy system plus one complete product built from scratch.
The former stresses constraint comprehension and compatibility; the latter stresses requirement decomposition and product closure.
It is important to be clear that these two tasks form an evaluation plan, and should not be described as completed empirical findings without execution records.
Task 1: Adding a Secure Image Asset Import Capability to a Legacy System
This task can be broken into six consecutive stages:
- Accept user uploads and identify the actual file type;
- Validate file size, pixel dimensions, and decoding results;
- Persist the file and resource metadata;
- Establish ownership relationships between the resource and the user, tenant, and project;
- Reference the asset in animation scenarios;
- Have the background execution environment read the asset and complete rendering.
The real difficulty is not making the image appear, but ensuring every stage enforces the same authorization rules.
For example, the fact that a user can see an image in the editing page does not prove the background render job is authorized to read it. Hard-to-guess resource identifiers are also no substitute for permission checks. An attacker may obtain identifiers from history records, shared content, or other legitimate entry points; the system must still verify the relationship between the requesting principal and the resource.
Task 2: Building a Knowledge Learning Game from Materials and Requirements
Building a learning game from scratch mainly tests the ability to turn requirements into a product, not the number of interfaces.
A complete learning product should at least specify:
- How learning objectives map to levels;
- What determines whether each answer is correct;
- What explanation is provided after a wrong answer;
- Whether the completion condition can actually be triggered;
- How progress is restored after refresh, exit, and re-entry;
- Whether it is possible to skip required steps and jump straight to the end state.
“Completing the game” should not mean a success message appears on screen. It should mean the state machine has reached its terminal state according to the rules, with abnormal paths handled as well.
Combining both task types avoids judging overall capability by UI completeness or code generation speed alone.
4. Security Design for the Image Asset Pipeline
4.1 Authentication and Resource Authorization Must Be Separate
Authentication answers “who is the requester”; resource authorization answers “can this requester perform the specified operation on the target.”
A logged-in user cannot necessarily read arbitrary assets; belonging to the same tenant does not imply modification rights over every project. Resource queries should carry the authorization scope with them, rather than fetching a resource by ID first and relying on the caller to add checks afterward.
Illustrative logic:
function load_readable_asset(identity, asset_id, project_id):require_authenticated(identity)require_project_permission(identity, project_id, "read")asset = find_asset(id = asset_id,tenant_id = identity.tenant_id,project_id = project_id,state = "available")if asset is missing:return resource_unavailablereturn asset
This is only a logical illustration, not a concrete product API. A real implementation must also account for sharing rules, role systems, and whether resources support cross-project references.
4.2 Untrusted Files Require Content-Level Validation
File extensions and client-declared media types cannot serve as the sole basis for trust. The server should inspect actual file signatures and use controlled decoding to verify that the file matches an allowed format.
Depending on business needs, limits should also be placed on file size, total pixel count, and processing resource consumption, to prevent small files from consuming excessive memory after decoding. Formats that may carry active content should be subject to stricter restrictions or conversion strategies, rather than being handed directly to browsers or rendering environments.
When storing files, use server-generated storage identifiers instead of concatenating user-supplied filenames into paths.
4.3 Asynchronous Tasks Do Not Automatically Inherit User Permissions
Background executors typically have broad infrastructure access, but that does not mean they are authorized to read every resource at the business layer.
A task message should not contain only an arbitrary file path; it should retain the necessary principal, tenant, project, and resource reference information. Before execution, predefined rules should verify that the task-resource association is still valid.
This also raises a product decision that must be made explicit: if a user’s permissions are revoked after a task is created, should the task continue or terminate immediately? Different businesses may adopt different policies, but the policy must be stated explicitly, not left to implementation accident.
4.4 The Rendering Environment Should Be Isolated from Core Systems
Animation scenarios may contain untrusted content, so the rendering process should not directly have access to internal networks, host files, or business secrets.
Common measures include a restricted runtime environment, least privilege, network access controls, and time and resource quotas. If the feature allows referencing remote images, server-side request forgery (SSRF) risks must also be addressed by restricting protocols, target addresses, and redirect behavior, and by blocking access to internal services.
These controls are architectural requirements; they cannot rely on input prompts or on a model’s voluntary compliance.
5. Using a State Machine to Prove a Learning Game “Can Be Completed”
The core of a learning game is not stacking pages, but whether state transitions follow the pedagogical and product rules.
Level states can be defined as a finite set—locked, available, in progress, passed—with explicit trigger conditions for each transition. For example, the next level can only move from locked to available after its prerequisite level is completed.
On that basis, verify separately:
- Whether a correct answer drives the expected state change;
- Whether a wrong answer preserves a reasonable retry path;
- Whether repeated submissions cause progress to accumulate multiple times;
- Whether refreshing the page loses or incorrectly restores state;
- Whether tampering with client parameters can bypass server-side validation;
- Whether completing all required conditions reliably leads to the end state.
Learning content also needs independent review. Assembling terminology from source materials into multiple-choice questions does not automatically constitute effective teaching. Questions should map to clear knowledge objectives, explanations should state the basis for each judgment, and the content should distinguish concept recall, scenario judgment, and practical application.
Product acceptance should therefore include at least one complete normal completion path, one recovery path containing wrong answers, and a set of abnormal paths that attempt to bypass the rules.
6. Why All Tests Passing Can Still Hide Serious Vulnerabilities
Test results are jointly limited by test scope, assertion quality, and data design.
If every test is written by the implementer based on their own understanding, the code and the tests may share the same wrong assumption. For example, if the implementer believes “any logged-in user can read assets” and tests only cover logged-in versus anonymous cases, cross-user privilege escalation will never be discovered.
A more effective approach is to design tests from business invariants.
For an asset system, start by defining rules such as:
- Resources are not accessible across tenants by default;
- Within the same tenant, different projects still follow their own authorization boundaries;
- Deleted or disabled assets must not be referenced by new tasks;
- Background execution must not become a channel for bypassing frontend permissions;
- Sharing and revoking sharing must have explicit, verifiable behavior.
Then build an access matrix covering the resource owner, members of the same project, non-project members, users of other tenants, and anonymous requesters—testing read, modify, delete, and reference operations for each.
Also verify “no side effects after denial.” A failed response is only the first layer of evidence; stricter checks include whether the denial incorrectly created a task, wrote a reference relationship, or leaked a storage address.
7. Keeping Reproducible Engineering Evaluation Records
For an evaluation to have reference value, preserve the requirements, environment, changes, and verification evidence—rather than only recording the final screenshot.
It is recommended to record at least the following:
| Evaluation dimension | Key questions | Recommended evidence |
|---|---|---|
| Requirement comprehension | Were constraints and abnormal paths missed? | Requirement checklist, clarification records |
| Architectural changes | Were existing layering and contracts followed? | Change descriptions, dependency relationships |
| Feature completeness | Does it cover the full user flow? | Operation logs, end-to-end tests |
| Security | Are isolation and authorization rules satisfied? | Access matrix, negative tests |
| Maintainability | Were duplicated logic or implicit dependencies introduced? | Code review records |
| Execution efficiency | How much effort to reach the same acceptance bar? | Time spent, human interventions, rework records |
Efficiency should not be measured by first-generation latency alone. A more meaningful comparison is the total cost of reaching the same delivery standard, including human clarification, fixes, review, and regression verification.
If different runs use different permissions, dependency versions, or test scopes, the results should not be compared directly.
8. Placing Human Control at High-Risk Decision Points
A sensible human-machine division of labor is neither requiring humans to watch every generated line, nor granting the AI system unrestricted commit and release permissions.
A more workable process:
Phase 1: Requirement and risk confirmation. Humans define business goals, security boundaries, areas that must not be modified, and acceptance criteria.
Phase 2: Plan review. The AI system produces module impact analysis, data changes, permission design, and a test plan; humans focus on checking key assumptions.
Phase 3: Incremental implementation. Each change stays reviewable and reversible. Avoid mixing database migrations, permission adjustments, and page refactors into one large, hard-to-understand change.
Phase 4: Independent verification. Beyond routine testing, use a review perspective that was not involved in the implementation to check for permission bypasses, state races, and abnormal paths.
Phase 5: Controlled delivery. Set up necessary monitoring, auditing, and rollback measures, and adopt a more cautious release strategy for high-risk changes.
Audit logs should also follow the principle of minimal necessity: record the principal, operation, resource, and result—rather than writing tokens, full file contents, or other sensitive information into logs.
Conclusion
Progress in long-horizon AI coding should be measured by the ability to continuously understand a system, coordinate cross-module changes, and close the verification loop—not merely by producing longer code in one shot.
Asset import in a legacy system exposes the complexity of authorization chains and asynchronous execution; a from-scratch learning game tests requirement decomposition, state design, and product closure. Together they show that feature completeness, security correctness, and engineering maintainability must be evaluated separately—none can substitute for another.
For development teams, what is worth building is not a shortcut of “ship when tests pass,” but a reproducible, reviewable, and accountable workflow. Let the AI system take on the repetitive labor of implementation and verification, and let humans focus on business invariants, security boundaries, and final acceptance. That is how generative capability becomes reliable engineering productivity.
