Evaluating AI Coding for Long-Horizon Tasks: Capability Assessment and Secure Delivery Practices

    This article argues that AI coding for long-horizon tasks should be evaluated by engineering closure rather than code generation speed. It presents two complementary assessment scenarios—legacy-system modification and end-to-end new application build—and discusses explicit state tracking, secure image-asset import, permission testing beyond passing test suites, learning-game state consistency, comparable evaluation dimensions, and layered delivery gates. The goal is to turn AI coding speed into reviewable, secure, and sustainable engineering outcomes.

    1. Evaluate AI Coding by Engineering Closure, Not Code Generation Alone

    The easiest part of AI coding to observe is how quickly code is generated. The hardest part to judge is final delivery quality. A function may run without matching the existing system’s interface contracts. A page may display correctly without having the right permission boundaries behind its data access.

    Real software development includes many implicit requirements: historical data must remain compatible, asynchronous tasks must handle failures, API behavior must remain consistent, and new features must not bypass existing authentication and authorization mechanisms. The longer the task and the more modules it involves, the more likely a model is to miss constraints during execution or replace an overall correct design with a locally workable implementation.

    Evaluation should therefore focus on four areas:

    First, whether the system is understood, not merely whether relevant files can be found. The model should identify business objects, data flows, trust boundaries, and module dependencies, and determine which constraints must not be broken.

    Second, whether the task can be advanced consistently. For cross-module changes, interfaces, data structures, state transitions, and test logic should remain consistent rather than completing one module and forgetting earlier agreements.

    Third, whether a verification loop is formed. Beyond generating an implementation, the system should execute checks, explain failures, fix problems, and provide reviewable verification records.

    Fourth, whether capability boundaries are recognized. For unverified security assumptions, inaccessible runtime environments, and missing business rules, uncertainty should be stated explicitly rather than turning speculation into a delivery conclusion.

    This means the unit of evaluation for AI coding should not be a code snippet, but a complete task with constraints, a verification process, and acceptance criteria.

    2. Use Two Complementary Task Types to Build Assessment Scenarios

    A single task usually reflects only local capability. A more effective approach is to set up two scenarios at the same time: incremental modification of a legacy system and complete construction of a new application.

    Legacy system modification: focus on constraint preservation

    Choose a project that already has a frontend, server, database, and background jobs. Require the addition of user image asset import and allow page animation scenarios to reference those assets.

    This requirement may look like simple upload and display, but it involves multiple connected steps:

    The user submits a file. The server validates it and creates an asset record. The file enters storage. The business scenario saves the asset reference. A background task reads the asset and generates a result. Finally, the user accesses the output.

    Improper handling at any step can create problems. For example, the upload API may be authenticated, but if the background task reads a file only by asset ID, an authorization break can appear. Deleting an asset by removing only the database record may also leave an accessible file behind.

    This type of task is suitable for testing whether a model understands the real constraints in a legacy system, rather than merely completing a new page and API.

    New application build: focus on requirement closure

    Another task can be to build an agent knowledge learning game from scratch based on learning materials and product requirement documents.

    Evaluation cannot stop at “the homepage opens” or “questions can be clicked.” A truly complete learning application needs to cover learning objectives, knowledge organization, question adjudication, feedback explanations, progress saving, failure retry, and final completion.

    The two task types have different value. The first tests the ability to modify a system within existing constraints. The second tests the ability to translate abstract requirements into complete product behavior. Combining them helps avoid mistaking one smooth demonstration for stable engineering capability.

    3. Long-Horizon Tasks Need Reliable State, Not Just Longer Context

    Long context can hold more files and discussions, but “visible” does not mean “always used correctly.” In tasks that continue for dozens of rounds, early requirements may be buried by later errors, and temporary fixes may conflict with the original design.

    A more reliable approach is to record task state explicitly.

    First, establish a constraint checklist, including:

    • Which users can operate which resources;
    • Which data structures must remain compatible with historical records;
    • Which API behaviors cannot change;
    • Which failure cases must be handled;
    • Which results must be confirmed by a human.

    Second, establish a module impact map. For an image asset feature, map the dependencies among upload, asset management, scenario editing, task scheduling, result access, and resource cleanup to avoid missing indirect paths that use assets.

    Third, adopt small closed loops rather than modifying all modules at once. A reasonable order is: define the data model and permission rules first, then implement a minimal upload and read path, then integrate the business scenario, and finally add asynchronous tasks, exception recovery, and cleanup mechanisms.

    Each step should have an observable result. This way, even if the task is interrupted, work can resume from records rather than relying on the model to guess the project state again.

    4. Image Asset Import: Separate File Security from Permission Security

    “Secure upload” includes at least two independent problems: whether the file itself is acceptable, and whether the current principal is authorized to operate on that file. One cannot substitute for the other.

    File validation cannot rely on extensions alone

    File names and client-supplied type information should not be treated as trusted evidence. The server needs to judge based on file characteristics, actual decoding results, and the business-allowed scope.

    For images, file size, pixel dimensions, and decoding resource consumption should also be controlled to prevent inputs that are small in bytes but unusually expensive to decode from consuming excessive resources. Whether to re-encode should depend on business requirements, but re-encoding should not be understood as eliminating all risks.

    Original file names should not be used directly to construct storage paths. Storage identifiers should be generated by the system, and display names should be separated from storage locations to reduce path-handling errors and overwrite risks.

    If importing external addresses is allowed, server-side request forgery risks must also be considered, including target address ranges, redirect behavior, connection timeouts, and response body size. Compared with supporting arbitrary remote import directly, defining trusted sources first is usually easier for controlling risk.

    Asset IDs are not access credentials

    A resource identifier locates an object; it does not prove permission. Even if the ID is hard to guess, it cannot replace an authorization decision.

    A simplified authorization logic can be expressed as:

    1. Allowed to reference asset =
    2. current identity is valid
    3. AND current principal can edit the target scenario
    4. AND current principal can use the target asset
    5. AND asset state allows reference

    If the system supports shared assets, “can use” should be determined by explicit sharing relationships or organizational rules, not simply equated with “uploaded by the current user.”

    This check should be performed on the server and cover entry points such as adding a reference, modifying a reference, copying a scenario, restoring a historical version, and resubmitting a task. Filtering invisible records in an asset list cannot prevent a directly constructed request.

    Background jobs must not become an authorization bypass

    Background execution processes often have broader storage access than ordinary users, so the authorization source for tasks must be especially clear.

    When creating a task, resource ownership and usage permissions should be validated. During actual execution, product rules should also be used to confirm whether the task state, asset state, and access conditions are still valid. For assets whose sharing has been revoked or that have been deleted, the system should have a consistent handling policy rather than letting different execution paths decide separately.

    The authorization basis must come from trusted server records and must not directly trust client-submitted user IDs or organization IDs.

    Download and cleanup are also part of the security chain

    If files are distributed through short-lived access URLs, their validity period and purpose should be limited, and it should be understood that they may be forwarded while valid. For sensitive resources, whether each access requires re-authentication should depend on the risk level.

    Deletion operations also need defined semantics: after an asset is deleted, do existing tasks continue to run? Are historical outputs still retained? Are shared references invalidated? These are not implementation details, but business rules that need to be clarified before development.

    5. Why Passing Tests Can Still Leave Serious Permission Issues

    Passing tests only means that the tested assertions hold. It does not prove that the system satisfies all security requirements.

    In AI coding, a common risk is that the implementation and the tests share the same wrong assumption. For example, if the model treats “a logged-in user can use any existing asset” as a rule, and the tests it writes only verify login and asset existence, then even complete test coverage cannot find cross-user reference issues.

    Therefore, permission tests must start from resource relationships, not only from interface success paths.

    At minimum, the following cases need to be covered:

    • The resource owner performs a legitimate operation;
    • An unauthorized user in the same organization attempts access;
    • A user in a different organization attempts to read or reference the resource;
    • An unauthenticated user directly requests the resource;
    • Access after sharing permission is granted, and access again after sharing is revoked;
    • Replaying an old request after the asset is deleted;
    • A background task attempts to read an asset outside the authorization scope of the current task.

    For failure paths, the test must verify that access is actually denied, not merely that the page does not show a button.

    For high-risk features, acceptance reviewers should also review permission rules independently. Independent means reading the requirements and data relationships first and then judging whether the implementation meets them, rather than drawing conclusions only from generated test names and success logs.

    6. Learning Game Development: From Demonstrable Prototype to Completable Product

    When generating a learning application from materials, the biggest challenge is not the number of pages, but whether the knowledge structure and interaction rules are consistent.

    Define learning objectives before designing levels

    Each concept in the materials does not need to map mechanically to one question. A more reasonable approach is to organize content by capability objectives, such as identifying the components of an agent, understanding the tool-calling flow, judging when external retrieval is needed, and analyzing recovery strategies after failure.

    Questions, feedback, and completion requirements should all serve these objectives. Otherwise, the application may look rich in content while actually just splitting materials into a number of multiple-choice questions.

    Manage game flow with explicit state transitions

    The learning process should clearly define how states such as not started, in progress, incorrect awaiting retry, stage complete, and all complete transition.

    Pay particular attention to the following edge cases: does repeated answer submission cause duplicate scoring; is progress restored after page refresh; does returning to a previous level break later state; does the game truly enter the completion state after the last level ends; and is there an understandable correction path for incorrect answers.

    The clearer the state rules, the easier it is to find issues such as “the interface shows completion, but internal progress is not complete.”

    Validate knowledge correctness separately from program correctness

    Stable scoring does not mean the answers themselves are correct. Learning content needs to be checked for concept boundaries, applicability conditions, and explanation accuracy, avoiding descriptions of specific implementation habits as universal definitions.

    For scenario questions that may have multiple reasonable answers, explainable adjudication rules should be designed rather than forcing a single option. Question quality is also part of delivery quality and cannot be replaced by functional tests.

    7. Establish Comparable, Reviewable Evaluation Methods

    When evaluating different development approaches or different stages of capability, task conditions should be controlled as much as possible, including starting code, requirement descriptions, available environments, tool permissions, and acceptance rules.

    The following dimensions should be recorded separately:

    • Functional completeness: whether explicit requirements and necessary error paths are covered;
    • Modification consistency: whether data structures, APIs, and frontend/backend behavior remain coordinated;
    • Long-horizon stability: whether constraints are repeatedly forgotten or regressions introduced during task execution;
    • Verification quality: whether checks are actually executed and reviewable evidence is retained;
    • Security: whether identity, permissions, input handling, and resource access requirements are met;
    • Maintainability: whether unnecessary abstractions, duplicate logic, or broad changes appear;
    • Human repair cost: how much judgment, localization, and rework are needed to complete delivery.

    Time should also be tracked separately: first implementation time, verification and fix time, human security review time, and release preparation time. Comparing only first-generation speed misses the most expensive follow-up work.

    Without unified experimental conditions and enough samples, precise capability rankings should be avoided. A more valuable conclusion is: which tasks can already be delegated reliably, and which tasks still require strong constraints and human review.

    8. Set Layered Delivery Gates for AI Coding

    A reasonable delivery process is not “generate and then deploy,” but reducing uncertainty layer by layer.

    The first layer is basic engineering checks: confirm that the code builds, necessary tests can run, and the change scope matches expectations.

    The second layer is functional acceptance: verify normal flows, failure retry, state recovery, and the complete closed loop along user operation paths.

    The third layer is security acceptance: independently check permissions, file handling, external resource access, and sensitive information exposure.

    The fourth layer is operational readiness: confirm that logs, alerts, resource cleanup, data changes, and rollback plans are available. When database changes are involved, compatible deployment and failure recovery should also be considered.

    Different layers cannot substitute for one another. A successful build does not mean correct functionality. Correct functionality does not mean permission security. Passing a security review does not mean operational readiness is sufficient.

    9. Conclusion: Build Efficiency Gains on Verifiable Boundaries

    The practical value of AI coding in long tasks is to help developers organize context, connect multiple modules, complete repetitive implementation, and reach verification sooner. But completed code, passing tests, and meeting delivery standards are still three different milestones.

    For legacy system modification, priority should be given to whether constraints are preserved. For new application build, priority should be given to whether the process truly closes the loop. For permissions and security, independent rules, negative tests, and human review should be maintained.

    A reliable way to use these systems is not to let the model take unbounded final responsibility, but to let it continuously produce inspectable results under clear constraints. Only by combining task decomposition, authorization design, test evidence, and delivery gates can the speed advantage of AI coding become sustainable engineering value.