Evaluating Long-Horizon Coding and Permission Safety in Large Language Models
Leaderboard scores alone are insufficient for assessing whether a large language model can handle real-world software engineering tasks. This article introduces a practical framework for evaluating long-horizon coding capabilities across three core dimensions: contextual understanding, cross-module modification, and deliverable quality. It outlines two representative evaluation scenarios, a repeatable automated assessment framework, and explains why permission safety and access control still require manual human review. The article also provides engineering practices for balancing risk, cost, and efficiency, along with a reusable evaluation checklist.
Why Leaderboard Scores Are Not Enough to Judge Coding Ability
Public leaderboards typically use standalone problems with clear boundaries. These tests can compare a model’s basic code generation level, but they do not reflect the realities of actual projects. Real projects often contain years of accumulated legacy code, implicit dependencies, incomplete documentation, and ever-changing acceptance criteria.
The question engineering teams truly care about is: can a model independently complete a task within such an environment and deliver a working result? Therefore, the evaluation focus should shift from individual problem scores to long-horizon task performance. Long-horizon tasks refer to work that requires multi-step reasoning, iterative modifications, and changes spanning multiple files and modules.
To determine whether a model is suitable for integration into a development workflow, three aspects can be examined: whether it can comprehend complex context, whether it can drive changes across multiple modules consistently, and whether the final output can pass build and test verification.
Three Core Evaluation Dimensions
1. Contextual Understanding
Contextual understanding refers to a model’s ability to correctly grasp the project structure, business conventions, and existing implementation before it begins making changes.
Specific points to observe include:
- Can it locate the entry files, configuration, and data models relevant to the requirement, rather than creating a parallel set of logic from scratch?
- Can it notice existing utility functions, error handling patterns, and naming conventions within the project, and remain consistent with them?
- Can it identify legacy-specific branches, such as fields or interfaces retained for backward compatibility?
- After reading a large number of files, can it still remember constraints discovered earlier in the process?
Deficiencies in contextual understanding often surface late. A model may implement the first module correctly, only to reinvent the wheel in the fifth module, or modify a public interface it should not have touched.
2. Cross-Module Changemaking Ability
A feature often spans the data layer, service layer, API layer, and frontend interface. Long-horizon changemaking ability refers to whether a model can maintain overall design consistency while progressively implementing changes layer by layer.
When evaluating, consider:
- When data structures change, are serialization, validation, and display logic updated synchronously?
- When new states or workflows are added, are branches such as exceptions, timeouts, retries, and cancellations covered?
- When fixing one problem, does it introduce regressions in other modules?
- After multiple rounds of modification, do the design explanations from earlier versions remain coherent with the final implementation?
An effective approach is to log the scope of each change, tracking the number of files modified, the number of modules involved, and the frequency of rework. These data points are more telling than subjective impressions.
3. Runnable and Testable Deliverable State
There is a significant gap between “being able to write code” and “being able to ship code.” The deliverable state should be measured against verifiable standards:
- Dependency installation and build commands execute successfully.
- Unit tests and integration tests pass, and the tests actually cover the newly added logic.
- Critical user flows can be fully completed in a browser or client environment.
- Configuration, environment variables, and documentation are consistent with the actual code.
Only when these four points are met can a task be considered truly complete. If a model produces only code snippets without the ability to start the service, the result should be treated as incomplete.
Two Representative Evaluation Scenarios
Scenario 1: Modifying a Legacy Project with Security Constraints
This scenario tests a model’s ability to understand an existing system and adhere to constraints. A task might involve adding a new feature to an existing content management or collaboration platform while preserving the original permission model.
Key evaluation points:
- Does the model first read the permission-related code, rather than directly modifying business interfaces?
- Do new endpoints reuse existing authentication middleware, instead of implementing a separate validation logic?
- For historical data, are migration and compatibility issues considered?
- For security-related changes, does the model proactively explain risks and raise items requiring manual confirmation?
The value of this scenario lies in exposing hidden issues beyond “functional correctness.” A piece of code may fully satisfy the stated requirements while silently bypassing existing access controls.
Scenario 2: End-to-End Build from Source Material to a Product
The second scenario requires a model to build a complete, usable application from scratch based only on a set of learning materials and a product requirement document. For example, building an interactive quiz game for learning, where players progress through questions, levels, and state feedback to complete the entire content.
Key evaluation points in this scenario:
- Can it extract knowledge points from raw materials and convert them into a reasonable level structure?
- Can it translate the rules from the product document into an executable state machine—such as level unlock conditions, scoring rules, and completion criteria?
- Can it provide clear feedback at the interface level and handle common situations like refresh, back navigation, and network disconnections?
- Can the user ultimately complete the entire journey from start to finish, rather than getting stuck on an intermediate page?
The judgment criterion should be “can the user complete the entire flow,” not “is the code line count impressive.”
Building an Automated Evaluation Framework
To make evaluations repeatable, tasks, execution, and checks can be separated. Below is a simplified structural example:
def evaluate_task(task, agent):# 1. Prepare a repository snapshot in an isolated sandbox to avoid polluting the original environmentworkspace = prepare_sandbox(task.repo_snapshot)# 2. Have the model execute according to the requirement document, with limits on steps and timerun_log = agent.run(prompt=task.prompt,workspace=workspace,max_steps=task.max_steps,timeout_seconds=task.timeout,)# 3. Layer the checks; record results at each layer to make it easier to pinpoint issuesreport = {"build": run_build(workspace),"unit_tests": run_tests(workspace),"e2e_flow": run_browser_flow(workspace, task.acceptance_script),"permission_audit": audit_access_control(workspace, task.policy),"changed_files": count_changed_files(workspace),"run_log": run_log.summary(),}return report
Several design considerations are worth noting:
- Sandbox isolation ensures every evaluation starts from the same baseline, allowing horizontal comparison of results.
- Step and time limits prevent the model from falling into endless loops while also measuring efficiency.
- Layered checks allow teams to distinguish problem types such as “build failure,” “logic error,” and “security defect.”
- The number of changed files and the run log provide evidence for subsequent review.
It is important to note that automated checks can only cover rules that are explicitly written into scripts. Whether the permission model is complete often requires manual verification on an item-by-item basis.
Why Permission Isolation Still Requires Manual Sign-Off
Passing functional tests does not mean the permission model is correct. Permission issues are often subtle: an API may behave normally under typical usage, but expose vulnerabilities only under specific identities or specific resources.
Common problems include:
- Only checking whether a user is logged in, without verifying whether the resource belongs to that user.
- Applying filters in list endpoints but missing the same check in detail endpoints.
- Implementing admin role checks on the frontend without secondary verification on the backend.
- Logging tokens, keys, or other sensitive fields.
The following example shows two versions of the same endpoint:
# Risky implementation: any logged-in user can read any documentdef get_document(user, doc_id):return db.query(Document).get(doc_id)# Improved implementation: verifies resource ownership; handles non-existence and unauthorized access uniformlydef get_document(user, doc_id):doc = db.query(Document).get(doc_id)if doc is None or doc.owner_id != user.id:raise PermissionDenied()return doc
To a normal user, both implementations appear identical, but they produce completely different results in the context of unauthorized access. These kinds of issues are difficult to discover through functional test cases alone; they require dedicated review of identity, role, and resource relationships.
Therefore, permission isolation, data access, and security-related changes should be classified as mandatory items for human sign-off. Automated tools can help locate suspicious code, but the final judgment should be made by engineers familiar with the business and security specifications.
Engineering Practices for Risk and Cost Control
Long-horizon tasks are time-consuming, and the cost of failure is high. The following practices strike a balance between efficiency and safety.
Staged Commits and Checkpoints
Break large tasks into milestones, such as data models, service interfaces, frontend implementation, and test coverage. Run builds and tests at the end of each milestone, and only move to the next stage after confirming everything works. This way, even if an error occurs mid-process, the rollback scope remains small.
Confirmation Gates for High-Risk Operations
Operations such as database migrations, data deletions, permission changes, and production deployments should require manual confirmation before execution. Once completed, these operations are expensive to undo and should not be fully delegated to automated pipelines.
Preserve Complete Change Records
Every change should have clear commit messages and change descriptions, documenting the motivation, impact scope, and verification methods. Complete records facilitate code review and provide evidence for subsequent retrospectives.
Limit Permissions and Sensitive Information
Credentials in evaluation environments should follow the principle of least privilege and be injected via environment variables or a key management service—never written into code or configuration files. Sensitive fields should be filtered before log output.
Reusable Evaluation Checklist
In practical evaluations, the following checklist can be used for item-by-item recording:
- Did the model correctly understand the existing architecture and reuse available tools and conventions?
- Were cross-module changes kept consistent, with interfaces and data structures updated in sync?
- Did builds, unit tests, and integration tests all pass?
- Can critical user flows be completed end-to-end, including error and rollback scenarios?
- Does the permission check cover all entry points, especially detail, export, and batch endpoints?
- Do sensitive fields appear in logs, responses, or frontend code?
- Does the scope of changes exceed what the task requires, or are there unnecessary refactors?
- Is the final documentation and configuration consistent with the actual implementation?
After running through the checklist, three types of conclusions can be drawn: ready to merge directly, requires revision before acceptance, or involves security issues that mandate in-depth manual review.
Conclusion
Long-horizon coding ability has become a key indicator of the practical value of coding models. Models are now capable of taking on substantial real-world work in understanding complex contexts, driving cross-module changes, and delivering runnable output. Evaluations should use real projects and complete acceptance workflows, rather than relying solely on public leaderboard scores.
At the same time, permission isolation, security constraints, and final acceptance still require human involvement. Automated tests can cover most functional paths, but they cannot fully determine whether access controls are watertight. A sensible division of labor: the model handles the majority of implementation and initial verification, while engineers take responsibility for risk assessment, critical decisions, and release approval.
