Evaluating LLM Long-Horizon Coding Capabilities: The Boundary Between Automation and Human Review

    Evaluating large language models (LLMs) for real-world software development requires shifting focus from single-point code generation to delivering fully functional, cross-module features. This article explores four key dimensions for assessing long-horizon coding tasks: context understanding, cross-module consistency, execution loop, and deviation control. It also highlights the critical role of human review in security validation—such as permission checks and input sanitization—and outlines a practical human-AI collaboration workflow to ensure safe and deliverable code in legacy systems.

    1. Why We Need a New Approach to Evaluating Coding Models

    Past evaluations of code generation capabilities focused on single-point tasks, such as completing a function, fixing a bug, or generating boilerplate code. These metrics diverge significantly from real-world software development. In practice, developers must locate change points within existing systems, understand constraints left by historical design, coordinate modifications across frontend, backend, data layers, and asynchronous tasks, and ultimately bring a feature to a runnable and testable state.

    Therefore, the evaluation focus should shift from “can it write code” to “can it bring the task to a deliverable state.” The scope of evaluation must also expand from individual files to the entire change process.

    2. Four Dimensions for Evaluating Long-Horizon Task Capabilities

    1. Context Understanding

    The model needs to find key modules across numerous files, understand call chains and data flows, and identify implicit conventions not explicitly written in the code. For example, a field might only be modifiable in a specific state, or scripts in a certain directory might execute automatically during deployment. Whether the model can discover these hidden rules determines if its changes will introduce regressions.

    2. Cross-Module Consistency

    After modifying an interface definition, the model must synchronize updates across callers, database migration scripts, type declarations, and test cases. Modifying only one location often leads to runtime errors. During evaluation, observe whether the model proactively searches for all reference points rather than just modifying the first file it sees.

    3. Execution Loop

    The ability to run builds, execute tests, read error logs, and fix issues accordingly is key to distinguishing “code generation” from “task completion.” Stopping at “code is written” still requires manual troubleshooting.

    4. Deviation Control

    Beyond the task scope, observe whether the model performs unrelated refactoring, alters unrelated configurations, changes dependency versions, or modifies existing directory structures and naming conventions. Less deviation means lower code review costs.

    When evaluating, record the following data for each round of tasks for horizontal comparison:

    • Time spent on initial implementation and number of reworks
    • Number of build and test rounds required to pass
    • Number of changed files, and the number of files unrelated to the task among them
    • Issues found during human acceptance testing and their severity levels

    3. Passing Tests Does Not Mean Deliverable

    Testing is a necessary condition for delivery, but not a sufficient one. Test cases cover paths envisioned by the author, while security issues like permissions, unauthorized access, and resource ownership often fall outside the test scope.

    A common scenario is that the main workflow functions normally and all tests pass, but a user can read someone else’s data simply by replacing the resource identifier in a request. Such issues fall into functional testing blind spots and require a dedicated security review.

    Permission isolation failures typically take the following forms:

    • Only verifying login status without verifying resource ownership
    • Hiding the entry point on the frontend while the backend API remains directly callable
    • Failing to normalize file paths before concatenation, leading to directory traversal risks
    • Failing to restrict the type and size of user-uploaded content, which is then directly rendered as executable content

    Below is an example code snippet for resource ownership validation, demonstrating that validation should occur on the server side and cover legitimate scenarios like shared access:

    1. def get_asset(user_id: str, asset_id: str):
    2. asset = repo.find_asset(asset_id)
    3. if asset is None:
    4. raise NotFound()
    5. # Ownership must be validated on the server side; do not rely solely on login status or frontend entry points
    6. if asset.owner_id != user_id and not has_shared_access(user_id, asset):
    7. raise Forbidden()
    8. return asset

    4. Designing Security Constraints for New Features in Legacy Systems

    When adding features to projects with extensive historical code, risks primarily arise at the boundary between old and new logic. It is recommended to constrain tasks from the following four aspects:

    1. Write Constraints into Task Specifications

    Constraints should be explicit and verifiable, rather than vague phrases like “be mindful of security.” For example: “Asset access must validate ownership,” “Uploaded files are only allowed types from a whitelist,” or “New features must not modify published migration files.” Both the model and human reviewers can use these items to judge whether the result is acceptable.

    2. Input Validation at Trust Boundaries

    All input from clients, external files, and third-party resources should be validated before entering business logic, including type, size, format, and value range. File paths require normalization, and database queries should use parameterization to avoid string concatenation.

    3. Limit Rendering Capabilities

    If user-imported assets are embedded and rendered on a page, their capabilities must be restricted. Browsers offer various mechanisms, such as setting sandbox attributes on iframes to disable scripts, or using Content Security Policy (CSP) to limit resource sources. Below is a sample response header configuration:

    1. Content-Security-Policy: default-src 'self'; img-src 'self' <trusted-resource-domain>; script-src 'none'

    HTML animation scenarios require special attention to external resource references. External addresses might trigger cross-site requests or lead to data exfiltration. A sound approach is to only allow loading resources from trusted sources and to disable unnecessary network and local storage access in the rendering environment.

    4. Least Privilege Execution

    Service accounts executing generation, rendering, and import tasks should only be granted the permissions necessary to complete the task. This way, even if a vulnerability occurs in one phase, the impact radius is contained within a smaller area.

    5. From Materials to Product: How to Measure Completeness

    When a task starts from a set of learning materials and requirement documents and directly delivers a usable product, completeness should be measured from the following aspects:

    • Requirements Decomposition: Does every feature point in the PRD have corresponding implementation and verification methods?
    • Data Model: Are entities, states, and business rules consistent, and are there any missing relationships?
    • Key Flows: Can the core paths be demonstrated end-to-end, including both successful and failed outcomes?
    • Edge Cases: Are empty data, timeouts, duplicate submissions, and concurrent modifications handled explicitly?
    • Content Accuracy: Does the knowledge in the product align with the original materials, without fabricated conclusions?

    Acceptance for such tasks should not merely check if the UI runs, but rather verify against the requirements checklist item by item and spot-check the accuracy of the knowledge content.

    The following workflow separates automated execution from human oversight, suitable for most coding tasks involving legacy systems:

    1. Before starting the task, clearly define the scope, constraints, prohibitions, and acceptance criteria.
    2. Require the executor to output a change plan first, and only proceed after a human confirms the scope.
    3. Implement in phases, running builds and tests at each stage.
    4. Conduct an independent security review on permissions, inputs, output rendering, and dependency changes.
    5. Manually validate key paths and proactively test anomaly scenarios like unauthorized access and illegal inputs.
    6. Update discovered issues into the constraint checklist for reuse in subsequent tasks.

    Task specifications can be expressed using structured files, making it easy for executors and reviewers to share the same standard:

    1. task: Add user asset import feature
    2. scope:
    3. allowed_paths: [services/asset, web/src/asset]
    4. forbidden: [published database migration files]
    5. constraints:
    6. - Asset ownership must be validated on the server side
    7. - Upload types use a whitelist, and size limit is determined by configuration
    8. - Script execution is disabled in the rendering environment
    9. acceptance:
    10. - All builds and unit tests pass
    11. - Unauthorized access requests return rejection results
    12. - Permission-related code paths have been manually reviewed

    7. Conclusion

    LLMs are now capable of completing a significant proportion of implementation and repair work in long-horizon, cross-module coding tasks, making them suitable for small-scale trials in real-world projects. Evaluation should focus on the four dimensions of context understanding, cross-module consistency, execution loop, and deviation control, using deliverable status rather than code generation volume as the measurement standard.

    Permissions, security, and final acceptance still require human responsibility. By writing constraints clearly, separating security reviews, and handing key paths over to human acceptance, teams can improve efficiency while controlling risks.