Designing Anti-Contamination Benchmarks for Software Engineering LLM Evaluation

    This article explains how to design software engineering benchmarks for LLMs that resist contamination and produce trustworthy scores. It covers where evaluation distortion comes from, the common leakage paths that let models retrieve answers instead of solving problems, why the verifier determines the score ceiling through false positives and false negatives, and how a three-layer verification design plus verifier calibration keeps judgments sound. It also shows why short, single-line tasks compress model differences, which task characteristics create real separation, and how to run a closed-loop workflow: original task authoring, environment freezing, dual-track tests, judge calibration, leak-resistant operations, and complete reporting. Readers get a concrete protocol skeleton for per-task grading, guidance on the limits of leaderboard comparisons, and a way to apply the same principles to internal, desensitized task sets.

    Where Evaluation Distortion Comes From

    Once large language models enter real development workflows, teams no longer care much about whether single-line completion looks decent. What matters is whether a model can read constraints in an unfamiliar repository, locate a defect, make the change, and pass regression. If a public leaderboard reports only a single pass rate, readers easily mistake “can solve the exercise” for “can deliver.” When the task source, runtime environment, and grading procedure contain systematic bias, the ranking will reliably reward the wrong capabilities: memorizing public patches, guessing test weaknesses, or piling up superficially correct results on tasks that are too short.

    A more credible evaluation answers three questions: does the model work on tasks it has not seen; is the judgment truly equivalent to the requirement being satisfied; and are models of different capability levels actually separated rather than squeezed into a narrow score band. The sections below follow those three threads.

    Benchmark Contamination and Information Leakage

    Contamination is not only “the prompt appeared in the training corpus.” For software tasks, the reference answer often sits right in version history, issue discussions, patch files, and failure logs. If the evaluation environment hands the model the full commit history, notes on already-merged fixes, or the expected outputs of hidden tests, the model does not need to understand the problem — it only needs to retrieve a neighboring commit and reproduce the answer. That records retrieval and memory as engineering ability.

    Common leakage paths include:

    • Tasks rewritten directly from recent public defects, where the prompt, the error message, and the fix correspond almost one to one.
    • Containers or workspaces that retain history which can be rolled back to the fixing commit.
    • Documentation, changelogs, or example tests that hint at a single intended fix.
    • Grading scripts and the reference implementation placed in the same directory, or exposed through environment variables.
    • After repeated public runs, prompts and trajectories entering later training data and retrieval indexes, creating secondary contamination.

    The core of contamination resistance is not renaming things but cutting off the answer channel. Tasks should be constructed from scratch as much as possible: requirements, injected defects, and acceptance conditions are controlled by the evaluation authors and cannot be retrieved verbatim from existing commits in a public repository. The runtime should provide only the source snapshot and dependencies needed to solve the task, with no history pointing at the reference answer. Prompts should describe behavior rather than paste a reference patch. Published instances should be rotated or retired so that “leaderboard-chasing trajectories” do not become new corpus material.

    Isolation can be expressed through directories and permissions rather than relying on the model to “voluntarily not look”:

    1. workspace/
    2. repo/ # task starting snapshot only
    3. hidden_tests/ # not readable by the model process
    4. grader/ # runs under a separate account, returns pass or fail only

    The grading side should return aggregate results only. If debugging requires logs, they must be redacted and confirmed to contain no reference implementation.

    Why the Verifier Decides the Score Before the Model Does

    The ceiling on pass rate is set by the error rate of the grading program. False positives mark a wrong patch as passing; false negatives mark a correct patch as failing. The former encourages exploiting loopholes, the latter penalizes legitimate equivalent implementations. When both error types are high, score gaps no longer represent capability differences — they only represent who adapts better to a flawed judge.

    “Correct” for a software task is usually a set of observable behaviors, not a unique piece of code text. A verifier should separate at least three layers:

    1. Build and static checks: whether the project installs, compiles, or passes basic static rules in the specified environment. Failures should distinguish environment faults from patch faults.
    2. Public behavior tests: the inputs, outputs, interface contracts, and error handling promised in the prompt.
    3. Hidden regression: coverage of boundaries, concurrency, permissions, and preservation of existing functionality. The hidden set must not be readable by the model, nor fully derivable from the public examples.

    Comparing text similarity alone systematically penalizes refactors and equivalent implementations, while letting through patches that are “green but semantically wrong.” A sounder approach is executable specifications: given a precondition and inputs, check the postcondition. For requirements that allow multiple implementations, assertions should be written against external behavior, not against a specific line of a private function.

    The verifier itself must also be verified. Calibrate it with known-correct patches, known-incorrect patches, and patches that are “almost correct but violate one constraint,” estimating the tendency toward false negatives and false positives separately. The calibration set must be isolated from the scored task set. Environment nondeterminism (clocks, network, random seeds, dependency version drift) should be pinned; checks that cannot be pinned should not be treated as hard gates. Timeouts, resource exhaustion, and infrastructure failures should be reported separately and not counted as model failures, otherwise the ranking is dominated by runtime noise.

    When reporting, alongside the primary metric, include statements relevant to judgment confidence: whether disputed samples received human review on each task, the distribution of failure types, and the direction of verifier error on the calibration set. Without these, a single pass rate is not comparable.

    Insufficient Complexity Hides the Gap

    If most tasks are a local one-line change with few test cases and short context, both strong and mid-tier models approach the ceiling and scores bunch together. That does not mean the models are equally capable; the ruler is too short. Real maintenance work usually spans multiple modules: reading call chains, preserving compatibility, handling failure paths, and delivering without breaking existing behavior.

    Tasks that create separation tend to have these characteristics:

    • Context spanning multiple files, with the key constraint not on the line that raised the error.
    • Requirements containing negative conditions, such as not changing the external protocol or not expanding permissions.
    • Correctness that depends on regression, not just one added happy path.
    • Multiple exploration steps allowed, but scoring based only on the deliverable, with no credit for the length of the reasoning process.
    • Diverse failure modes, including partial correctness, overfitting to tests, and breaking unrelated functionality.

    Diversity matters just as much. A single language, a single framework, or a single defect type biases the leaderboard toward models that have seen that ecosystem. Language, repository size, defect type (logic, concurrency, configuration, interface evolution), and domain should be deliberately spread out, with the distribution published rather than only the total score. When the distribution is imbalanced, report per-category results so that one easy category does not inflate the overall number.

    The primary metric should be the pass rate of a single independent attempt: for a given task, take one final patch and check whether it passes all specified checks. Sampling multiple times and keeping the best mixes in a search budget; without declaring the number of attempts and the cost, results cannot be compared. Cost, time limits, and available tools should also be written into the protocol, otherwise “better at calling external retrieval” disguises itself as “better at changing code.”

    An Executable Design Workflow

    Benchmark construction can be organized as a closed loop instead of collecting tasks first and adding rules later.

    Task selection and originality. Abstract problem types from real maintenance scenarios, then reimplement them in a controlled repository. Do not reuse issues that can still be matched against public history. Record for each task: the starting state, the permitted modification scope, the prohibited behaviors, and the acceptance behaviors. Confirm licensing and redistribution scope before release so the evaluation itself does not violate a repository’s license.

    Environment freezing. Pin dependency versions, system packages, time zone, and randomness sources. Builds must be reproducible. The model’s visible scope is separated by permissions, with hidden tests and grading logic not in the same readable tree.

    Dual-track tests. Public tests help the model understand the requirement; hidden tests prevent fitting only the examples. Both must cover regression. For outputs that are easy to hardcode, add equivalent inputs to reduce answer memorization.

    Judge calibration. Pre-run with correct, incorrect, and opportunistic patches. Disagreements go into a human review queue. Review conclusions are written back into the assertions rather than applied as ad hoc score adjustments. Infrastructure failures are rerun, not rejudged.

    Leak-resistant operations. Control how widely prompts are published, and periodically retire tasks that have spread broadly. Do not publish trajectories containing reference answers without processing. If examples must be released, they must not come from the scored set.

    Reporting. Include at least: number of tasks, distribution of languages and repository sizes, the single-attempt protocol, time and tool constraints, per-category pass rates, verifier calibration conclusions, and the proportion of environment failures excluded. Avoid dumping a single total score.

    A schematic per-task judgment can be written as:

    1. Input: starting snapshot S, patch P, public spec T_pub, hidden spec T_hid
    2. 1. Apply P in an isolated environment to obtain S'
    3. 2. If the build fails, record a build failure
    4. 3. Run T_pub and T_hid
    5. 4. Record a pass only if the build succeeded and all assertions passed
    6. 5. Mark timeouts and environment errors separately; do not fold them into capability failures

    This is not the interface of any particular platform, only a protocol skeleton. In practice, write the assertions as repeatable, executable checks.

    Limits When Reading a Leaderboard

    Even with a complete process, a benchmark remains a sample. It measures code change and acceptance within the protocol, not requirement clarification, code review preferences, or long-term operations. When the number of tasks is limited, a gap of two points or less usually falls within noise and should not be over-interpreted. Open-weight and closed systems cannot be compared directly if tool permissions, context length, or retry counts differ.

    A more useful practice for engineering teams is to build an internal task set with the same anti-contamination principles: draw from the organization’s own desensitized historical defects that will not re-enter training, freeze the environment, hide regression tests, calibrate the judge, and then read pass rates broken down by business area. Public leaderboards serve only as an external reference and do not replace internal acceptance.

    Summary

    Credible software engineering evaluation depends less on a longer leaderboard and more on fewer leaks, steadier judgment, and tasks that are difficult and diverse enough. Zero contamination requires that answers be unsearchable; the verifier must first be calibrated with known-correct and known-incorrect samples, and environment failures must be separated from capability failures; complexity and distribution determine whether scores still discriminate. Design, operate, and report according to the protocol above, and the pass rate comes closer to real delivery capability rather than the degree of adaptation to a question bank and to gaps in the judge.