Long-Horizon Refactoring and Migration Tasks as Eval Targets
Long-Horizon Refactoring and Migration Tasks as Eval Targets
Most code evals test completion. A function stub, a unit test, a short algorithm. The model fills in the blank and a verifier checks the output. That paradigm has produced useful benchmarks, and frontier models have largely saturated them. Long-horizon refactoring and migration tasks as eval targets represent a structurally different challenge: the model must reason across an entire codebase, respect cascading constraints, and produce a coherent transformation that compiles, passes tests, and preserves semantics, without a human holding its hand at each step.
This post explains how to design, author, and verify long-horizon refactoring and migration tasks, where frontier models fail on them, and what makes a task in this class a reliable eval signal rather than an expensive noise source.
Answer Capsule
Long-horizon refactoring and migration tasks are eval targets that require a model to transform a multi-file codebase across many interdependent steps while preserving correctness. They are harder to saturate than single-function tasks because failure can occur at any step in a long dependency chain. Reliable evals in this class need a programmatic verifier, a seeded failure corpus, and empirical difficulty calibration against multiple frontier models.
What Makes a Task Long-Horizon?
A task is long-horizon when correct completion requires maintaining a consistent plan across more than one decision boundary. In refactoring and migration work, this means the model must track state, intent, and constraint across files, modules, or layers that it did not write and cannot rewrite arbitrarily.
Three properties distinguish long-horizon tasks from extended single-function tasks:
Cascading dependencies. A change to one interface propagates to every caller. The model must identify all call sites, update them consistently, and not introduce a latent inconsistency that only surfaces at link time or runtime.
Semantic preservation under structural change. The refactored codebase must behave identically to the original on all specified inputs. Structural similarity to the original is not a proxy for correctness.
Non-local verifiability. No single output file can be graded in isolation. The verifier must run the full test suite, check interface contracts, and in some migration tasks, compare execution traces against a reference implementation.
Migration tasks add a fourth property: the target environment has different semantics. A Python 2 to Python 3 migration, a jQuery to vanilla JS migration, or a REST-to-gRPC API migration each requires the model to understand what the source semantics mean and re-express them correctly in the target, not just transliterate syntax.
Why Long-Horizon Refactoring Tasks Resist Saturation
Single-function benchmarks saturate because the search space is small. Given a function signature and a docstring, a frontier model can sample many plausible completions and one will usually be correct. Pass@k climbs quickly. Long-horizon tasks have an exponentially larger failure surface: a model that is 95% likely to make the right decision at each of twenty interdependent steps is only about 36% likely to produce a fully correct result end-to-end.
This is not a claim about any specific model. It is a structural property of compositional tasks. The implication for eval design is that difficulty does not decay as fast as it does for isolated tasks, and that tasks authored today against a specific codebase and migration target are likely to remain discriminative for longer, provided they are original and not derived from public repositories that models have already seen.
The contamination risk is real. A migration task built on a public GitHub repository is a poor eval target. The model may have seen the before and after states in training data. Original authored versus scraped tasks covers the contamination gap in detail; the short version is that original, expert-authored codebases with non-public migration targets are the only reliable source of headroom against frontier models. Web-derived tasks decay faster than practitioners expect, a phenomenon examined in the analysis of benchmark half-life for web-derived eval tasks.
Designing a Verifiable Long-Horizon Task
A long-horizon refactoring task is only as useful as its verifier. Expert authoring without a reliable verifier produces tasks that require expensive human review on every submission, which does not scale and introduces inter-reviewer variance.
The verifier stack for a migration task typically has three layers:
Syntactic and structural checks. Does the output parse? Does it conform to the target language or framework version? These checks are cheap and should run first to fail fast on malformed outputs.
Behavioral equivalence checks. Run the original test suite against the migrated codebase. Run a property-based test suite if one exists. For API migrations, replay a recorded request corpus and compare response schemas. Behavioral checks are the primary signal.
Expert rubric for partial credit. When a migration is 90% correct but fails on one edge case, aggregate pass/fail discards useful signal. A rubric that scores interface correctness, dependency resolution, and test coverage separately allows a reward model to learn from near-misses. The design of rubrics that function as reward signals is covered in the guide to writing tasks with exactly one defensible answer.
The programmatic verifier must be authored and tested independently of the task itself. A verifier that was written by the same expert who authored the migration target will tend to share the author's blind spots. Verifier review is a separate step, not an afterthought. The practical guide to programmatic verifiers for domain tasks covers verifier design in depth.
Illustrative Example: A Legacy API Migration Task
Illustrative example. Numbers and structure are realistic but invented for illustration.
Suppose the task is: migrate a twelve-file Python 2.7 Flask application to Python 3.11 and Flask 3.x. The application uses unicode literals, has_key() dict calls, and a deprecated flask.ext import pattern. It has 47 unit tests and 8 integration tests.
The verifier does the following:
Runs
python3 -m py_compileon all twelve files. Any syntax error fails the task immediately.Runs the 47 unit tests under Python 3.11. Each passing test contributes to a weighted score.
Runs the 8 integration tests against a local test server. These are weighted more heavily because they exercise cross-module behavior.
Checks that no
flask.extimports remain (a structural check that a model could pass by deleting the import without replacing it, so the integration tests guard against that shortcut).
A model that mechanically replaces print statements and unicode literals but misses the has_key() calls will pass the syntax check, fail 11 of the 47 unit tests, and score roughly 0.72 on the weighted rubric. That score is a more useful training signal than a binary pass/fail. Designing tasks to resist shortcut solutions of this kind is addressed in the post on designing tasks robust to shortcut solutions.
Common Failure Modes in Long-Horizon Eval Design
The following failure modes appear repeatedly when teams build this class of eval for the first time.
1. Underspecified migration target. The task description says "migrate to the new API" without specifying the target version, deprecation list, or behavioral contract. The model produces a plausible output; the verifier accepts it; the task yields no useful signal because any reasonable transformation would pass. Detection: run two structurally different model outputs through the verifier and check whether both pass. Fix: pin the target version, enumerate the deprecated patterns the model must resolve, and write at least one test that would catch a partial migration.
2. Verifier that tests the wrong thing. The verifier checks that the output compiles and the happy-path tests pass, but does not check edge-case behavior. A model that deletes the edge-case handling rather than migrating it will pass. Detection: manually inject a known regression into a correct solution and confirm the verifier catches it. Fix: include tests that specifically exercise the behavior most likely to be dropped during migration.
3. Codebase sourced from a public repository. The model has likely seen both the before and after states. Pass rates are inflated; the task is not measuring migration capability. Detection: search the repository URL and the migration commit in a web index. Fix: author original codebases or use internal codebases with permission, never public repositories with known migration histories.
4. Task too large for a single context window. A codebase that exceeds the model's effective context produces failures that are artifacts of context length, not migration capability. The task measures a different construct than intended. Detection: measure the token count of the full codebase plus instructions against the model's context limit. Fix: scope the task to fit within two-thirds of the target model's context limit, or design an agentic scaffold with explicit file retrieval steps and eval the scaffold separately.
5. No difficulty calibration against multiple models. A task that every frontier model passes on the first sample is not a useful eval target. A task that no model ever partially solves provides no gradient for a reward model. Detection: run pass@1 and pass@5 against at least two frontier models before including a task in a benchmark. Fix: calibrate empirically and target a pass@1 range of 0.15 to 0.60 across the model set, adjusting task scope until the distribution is useful. Difficulty measured today will drift as models improve; recalibrate on a defined schedule. The approach to calibrating expert quality with gold standard seed tasks applies the same principle to expert reviewers.
6. Rubric that rewards surface similarity over correctness. An LLM judge asked to score a migration output will tend to reward outputs that look like good code, not outputs that are behaviorally correct. For long-horizon tasks, LLM-as-judge is unreliable as a primary verifier; it should be used only for dimensions that cannot be checked programmatically, such as code style or comment quality. The conditions under which LLM judges fail are examined in the post on when not to use an LLM judge.
Where This Approach Breaks Down
Long-horizon refactoring evals are expensive to author and maintain. A task that requires an original twelve-file codebase, a full test suite, a three-layer verifier, and empirical difficulty calibration against multiple models takes significantly more expert time than a single-function task. That cost is justified when the eval target is a capability that matters for production use and that simpler tasks cannot measure. It is not justified for every capability dimension.
Additionally, some migration tasks have no single correct output. A REST-to-gRPC migration can be implemented in multiple valid ways that are behaviorally equivalent. Verifiers that require exact output matching will produce false negatives. Verifiers that accept any behaviorally equivalent output may accept outputs that are correct but unmaintainable or that violate the target framework's conventions. Partial credit rubrics help, but they require expert review to calibrate, and expert reviewers will disagree on edge cases. That disagreement is a signal about task ambiguity, not a failure of the review process; tasks with high inter-reviewer variance should be revised or discarded.
Frequently Asked Questions
How long should a long-horizon refactoring task be?
Scope the codebase to fit within two-thirds of the target model's effective context window. For most current frontier models, this means tasks in the range of 500 to 3,000 lines of code across 5 to 15 files. Larger tasks require an agentic scaffold, which introduces additional variables and should be evaled separately from the base migration capability.
Can synthetic codebases be used as migration task sources?
Synthetic codebases are acceptable if they are generated by a domain expert who then reviews them for realism and introduces the specific anti-patterns the task is designed to test. Fully automated synthetic generation tends to produce codebases that are structurally uniform and lack the idiosyncratic patterns that make real migration tasks hard. Expert review of synthetic source material is not optional.
What pass@k target indicates a useful eval task?
A task where pass@1 is below 0.10 across all sampled models provides little gradient for a reward model and may indicate the task is underspecified or the verifier is broken. A task where pass@1 exceeds 0.80 is likely too easy or contaminated. The useful range for discriminative evals is roughly pass@1 between 0.15 and 0.60, measured across at least two frontier models at the time of authoring. These thresholds are guidelines, not guarantees; the right range depends on the intended use of the eval.
How often do long-horizon migration evals need to be refreshed?
Difficulty drifts as models improve. A task that was discriminative at pass@1 of 0.30 twelve months ago may be at 0.70 today. Recalibrate empirically on a defined schedule, at minimum every six months for fast-moving capability areas. Tasks built on original, non-public codebases drift more slowly than tasks built on web-derived material, because the model cannot have seen the source in training data.
When should a long-horizon task use process reward rather than outcome reward?
Use process reward when the migration has a natural step decomposition and when intermediate steps can be verified independently. For example, in a multi-framework migration, each module's conversion can be verified before the full integration test runs. Process reward is harder to design but provides a denser training signal and is more robust to reward hacking than outcome-only grading. When intermediate steps cannot be verified programmatically, outcome reward with a partial credit rubric is the practical alternative.
What This Means in Practice
Long-horizon refactoring and migration tasks are among the most structurally defensible eval targets available for code capability. They resist saturation, they test a capability that matters for production software engineering, and they expose failure modes that single-function benchmarks cannot see. The investment in authoring, verifier design, and difficulty calibration is real. So is the return: tasks that remain discriminative as models improve and that provide training signal that aggregate leaderboard scores do not.
Chiron Data Labs authors original, expert-verified tasks in domains where frontier models still fail reliably. If you are building evals or RL environments that require long-horizon code tasks, get in touch with Chiron Data Labs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.
Most code evals test completion. A function stub, a unit test, a short algorithm. The model fills in the blank and a verifier checks the output. That paradigm has produced useful benchmarks, and frontier models have largely saturated them. Long-horizon refactoring and migration tasks as eval targets represent a structurally different challenge: the model must reason across an entire codebase, respect cascading constraints, and produce a coherent transformation that compiles, passes tests, and preserves semantics, without a human holding its hand at each step.
This post explains how to design, author, and verify long-horizon refactoring and migration tasks, where frontier models fail on them, and what makes a task in this class a reliable eval signal rather than an expensive noise source.
Answer Capsule
Long-horizon refactoring and migration tasks are eval targets that require a model to transform a multi-file codebase across many interdependent steps while preserving correctness. They are harder to saturate than single-function tasks because failure can occur at any step in a long dependency chain. Reliable evals in this class need a programmatic verifier, a seeded failure corpus, and empirical difficulty calibration against multiple frontier models.
What Makes a Task Long-Horizon?
A task is long-horizon when correct completion requires maintaining a consistent plan across more than one decision boundary. In refactoring and migration work, this means the model must track state, intent, and constraint across files, modules, or layers that it did not write and cannot rewrite arbitrarily.
Three properties distinguish long-horizon tasks from extended single-function tasks:
Cascading dependencies. A change to one interface propagates to every caller. The model must identify all call sites, update them consistently, and not introduce a latent inconsistency that only surfaces at link time or runtime.
Semantic preservation under structural change. The refactored codebase must behave identically to the original on all specified inputs. Structural similarity to the original is not a proxy for correctness.
Non-local verifiability. No single output file can be graded in isolation. The verifier must run the full test suite, check interface contracts, and in some migration tasks, compare execution traces against a reference implementation.
Migration tasks add a fourth property: the target environment has different semantics. A Python 2 to Python 3 migration, a jQuery to vanilla JS migration, or a REST-to-gRPC API migration each requires the model to understand what the source semantics mean and re-express them correctly in the target, not just transliterate syntax.
Why Long-Horizon Refactoring Tasks Resist Saturation
Single-function benchmarks saturate because the search space is small. Given a function signature and a docstring, a frontier model can sample many plausible completions and one will usually be correct. Pass@k climbs quickly. Long-horizon tasks have an exponentially larger failure surface: a model that is 95% likely to make the right decision at each of twenty interdependent steps is only about 36% likely to produce a fully correct result end-to-end.
This is not a claim about any specific model. It is a structural property of compositional tasks. The implication for eval design is that difficulty does not decay as fast as it does for isolated tasks, and that tasks authored today against a specific codebase and migration target are likely to remain discriminative for longer, provided they are original and not derived from public repositories that models have already seen.
The contamination risk is real. A migration task built on a public GitHub repository is a poor eval target. The model may have seen the before and after states in training data. Original authored versus scraped tasks covers the contamination gap in detail; the short version is that original, expert-authored codebases with non-public migration targets are the only reliable source of headroom against frontier models. Web-derived tasks decay faster than practitioners expect, a phenomenon examined in the analysis of benchmark half-life for web-derived eval tasks.
Designing a Verifiable Long-Horizon Task
A long-horizon refactoring task is only as useful as its verifier. Expert authoring without a reliable verifier produces tasks that require expensive human review on every submission, which does not scale and introduces inter-reviewer variance.
The verifier stack for a migration task typically has three layers:
Syntactic and structural checks. Does the output parse? Does it conform to the target language or framework version? These checks are cheap and should run first to fail fast on malformed outputs.
Behavioral equivalence checks. Run the original test suite against the migrated codebase. Run a property-based test suite if one exists. For API migrations, replay a recorded request corpus and compare response schemas. Behavioral checks are the primary signal.
Expert rubric for partial credit. When a migration is 90% correct but fails on one edge case, aggregate pass/fail discards useful signal. A rubric that scores interface correctness, dependency resolution, and test coverage separately allows a reward model to learn from near-misses. The design of rubrics that function as reward signals is covered in the guide to writing tasks with exactly one defensible answer.
The programmatic verifier must be authored and tested independently of the task itself. A verifier that was written by the same expert who authored the migration target will tend to share the author's blind spots. Verifier review is a separate step, not an afterthought. The practical guide to programmatic verifiers for domain tasks covers verifier design in depth.
Illustrative Example: A Legacy API Migration Task
Illustrative example. Numbers and structure are realistic but invented for illustration.
Suppose the task is: migrate a twelve-file Python 2.7 Flask application to Python 3.11 and Flask 3.x. The application uses unicode literals, has_key() dict calls, and a deprecated flask.ext import pattern. It has 47 unit tests and 8 integration tests.
The verifier does the following:
Runs
python3 -m py_compileon all twelve files. Any syntax error fails the task immediately.Runs the 47 unit tests under Python 3.11. Each passing test contributes to a weighted score.
Runs the 8 integration tests against a local test server. These are weighted more heavily because they exercise cross-module behavior.
Checks that no
flask.extimports remain (a structural check that a model could pass by deleting the import without replacing it, so the integration tests guard against that shortcut).
A model that mechanically replaces print statements and unicode literals but misses the has_key() calls will pass the syntax check, fail 11 of the 47 unit tests, and score roughly 0.72 on the weighted rubric. That score is a more useful training signal than a binary pass/fail. Designing tasks to resist shortcut solutions of this kind is addressed in the post on designing tasks robust to shortcut solutions.
Common Failure Modes in Long-Horizon Eval Design
The following failure modes appear repeatedly when teams build this class of eval for the first time.
1. Underspecified migration target. The task description says "migrate to the new API" without specifying the target version, deprecation list, or behavioral contract. The model produces a plausible output; the verifier accepts it; the task yields no useful signal because any reasonable transformation would pass. Detection: run two structurally different model outputs through the verifier and check whether both pass. Fix: pin the target version, enumerate the deprecated patterns the model must resolve, and write at least one test that would catch a partial migration.
2. Verifier that tests the wrong thing. The verifier checks that the output compiles and the happy-path tests pass, but does not check edge-case behavior. A model that deletes the edge-case handling rather than migrating it will pass. Detection: manually inject a known regression into a correct solution and confirm the verifier catches it. Fix: include tests that specifically exercise the behavior most likely to be dropped during migration.
3. Codebase sourced from a public repository. The model has likely seen both the before and after states. Pass rates are inflated; the task is not measuring migration capability. Detection: search the repository URL and the migration commit in a web index. Fix: author original codebases or use internal codebases with permission, never public repositories with known migration histories.
4. Task too large for a single context window. A codebase that exceeds the model's effective context produces failures that are artifacts of context length, not migration capability. The task measures a different construct than intended. Detection: measure the token count of the full codebase plus instructions against the model's context limit. Fix: scope the task to fit within two-thirds of the target model's context limit, or design an agentic scaffold with explicit file retrieval steps and eval the scaffold separately.
5. No difficulty calibration against multiple models. A task that every frontier model passes on the first sample is not a useful eval target. A task that no model ever partially solves provides no gradient for a reward model. Detection: run pass@1 and pass@5 against at least two frontier models before including a task in a benchmark. Fix: calibrate empirically and target a pass@1 range of 0.15 to 0.60 across the model set, adjusting task scope until the distribution is useful. Difficulty measured today will drift as models improve; recalibrate on a defined schedule. The approach to calibrating expert quality with gold standard seed tasks applies the same principle to expert reviewers.
6. Rubric that rewards surface similarity over correctness. An LLM judge asked to score a migration output will tend to reward outputs that look like good code, not outputs that are behaviorally correct. For long-horizon tasks, LLM-as-judge is unreliable as a primary verifier; it should be used only for dimensions that cannot be checked programmatically, such as code style or comment quality. The conditions under which LLM judges fail are examined in the post on when not to use an LLM judge.
Where This Approach Breaks Down
Long-horizon refactoring evals are expensive to author and maintain. A task that requires an original twelve-file codebase, a full test suite, a three-layer verifier, and empirical difficulty calibration against multiple models takes significantly more expert time than a single-function task. That cost is justified when the eval target is a capability that matters for production use and that simpler tasks cannot measure. It is not justified for every capability dimension.
Additionally, some migration tasks have no single correct output. A REST-to-gRPC migration can be implemented in multiple valid ways that are behaviorally equivalent. Verifiers that require exact output matching will produce false negatives. Verifiers that accept any behaviorally equivalent output may accept outputs that are correct but unmaintainable or that violate the target framework's conventions. Partial credit rubrics help, but they require expert review to calibrate, and expert reviewers will disagree on edge cases. That disagreement is a signal about task ambiguity, not a failure of the review process; tasks with high inter-reviewer variance should be revised or discarded.
Frequently Asked Questions
How long should a long-horizon refactoring task be?
Scope the codebase to fit within two-thirds of the target model's effective context window. For most current frontier models, this means tasks in the range of 500 to 3,000 lines of code across 5 to 15 files. Larger tasks require an agentic scaffold, which introduces additional variables and should be evaled separately from the base migration capability.
Can synthetic codebases be used as migration task sources?
Synthetic codebases are acceptable if they are generated by a domain expert who then reviews them for realism and introduces the specific anti-patterns the task is designed to test. Fully automated synthetic generation tends to produce codebases that are structurally uniform and lack the idiosyncratic patterns that make real migration tasks hard. Expert review of synthetic source material is not optional.
What pass@k target indicates a useful eval task?
A task where pass@1 is below 0.10 across all sampled models provides little gradient for a reward model and may indicate the task is underspecified or the verifier is broken. A task where pass@1 exceeds 0.80 is likely too easy or contaminated. The useful range for discriminative evals is roughly pass@1 between 0.15 and 0.60, measured across at least two frontier models at the time of authoring. These thresholds are guidelines, not guarantees; the right range depends on the intended use of the eval.
How often do long-horizon migration evals need to be refreshed?
Difficulty drifts as models improve. A task that was discriminative at pass@1 of 0.30 twelve months ago may be at 0.70 today. Recalibrate empirically on a defined schedule, at minimum every six months for fast-moving capability areas. Tasks built on original, non-public codebases drift more slowly than tasks built on web-derived material, because the model cannot have seen the source in training data.
When should a long-horizon task use process reward rather than outcome reward?
Use process reward when the migration has a natural step decomposition and when intermediate steps can be verified independently. For example, in a multi-framework migration, each module's conversion can be verified before the full integration test runs. Process reward is harder to design but provides a denser training signal and is more robust to reward hacking than outcome-only grading. When intermediate steps cannot be verified programmatically, outcome reward with a partial credit rubric is the practical alternative.
What This Means in Practice
Long-horizon refactoring and migration tasks are among the most structurally defensible eval targets available for code capability. They resist saturation, they test a capability that matters for production software engineering, and they expose failure modes that single-function benchmarks cannot see. The investment in authoring, verifier design, and difficulty calibration is real. So is the return: tasks that remain discriminative as models improve and that provide training signal that aggregate leaderboard scores do not.
Chiron Data Labs authors original, expert-verified tasks in domains where frontier models still fail reliably. If you are building evals or RL environments that require long-horizon code tasks, get in touch with Chiron Data Labs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.