SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.08877 · 2024

Aligning the Objective of LLM-based Program Repair

arXiv · PDF · Open in the Atlas

Code that ran

6 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 4 failures of our instrument; 2 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2404.08877.json · badge: /api/ran/2404.08877.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
cuhk-shenzhen-se/d4c canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
class_read Ran
ran; our contract draft was wrong, not the code
cuhk-shenzhen-se/d4c/validator/junit.py
code served (permissive licence) · get_code("726693ef3058e01b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
import os

# Create a temporary Java file for testing
temp_dir = tempfile.mkdtemp()
java_file_path = os.path.join(temp_dir, "TestClass.java")

# Write a valid Java file content
java_content = """public class TestClass {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}
"""

with open(java_file_path, 'w', encoding='utf-8') as f:
    f.write(java_content)

ARGS = {
    "java_file_path": java_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_code Ran
ran; our contract draft was wrong, not the code
cuhk-shenzhen-se/d4c/utils/patch_apply.py
code served (permissive licence) · get_code("d11e7e729a9dd4ea")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

def extract_code(s: str) -> str:
    pattern = '```.*?\\n(.*?)```'
    codeblocks = re.findall(pattern, s, flags=re.DOTALL)
    if len(codeblocks) == 0:
        return 'Match failed'
    return codeblocks

# Setup code to construct valid arguments
test_string = """
Here is some text with code blocks.


print("hello world")


Some more text here.

javascript
console.log("test");


End of document.
"""

ARGS = {
    "s": test_string
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_method_start_end_index Ran
ran, honoured the contract we drafted
cuhk-shenzhen-se/d4c/validator/junit.py
code served (permissive licence) · get_code("bdb99ba11608ca46")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
import os

# Create a temporary Java file for testing
temp_dir = tempfile.mkdtemp()
java_file_path = os.path.join(temp_dir, "TestClass.java")

java_content = """public class TestClass {
    public void testMethod(String param1,
                          int param2) {
        System.out.println("Hello");
        System.out.println("World");
    }
}
"""

with open(java_file_path, 'w', encoding='utf-8') as f:
    f.write(java_content)

function_head = "public void testMethod(String param1,"
method_length = 3

ARGS = {
    "java_file_path": java_file_path,
    "function_head": function_head,
    "method_length": method_length
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_hunk_range Ran
ran, honoured the contract we drafted
cuhk-shenzhen-se/d4c/utils/patch_apply.py
code served (permissive licence) · get_code("f8a6515652b1c7f9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Setup code for find_hunk_range

# The function takes two string parameters: code and chunk
# It searches for chunk as a contiguous sequence of lines within code
# and returns the character position range where the match occurs

# Create example code with multiple lines
code = """def hello():
    print("hello")
    x = 1
    y = 2
    return x + y"""

# Create a chunk that matches a contiguous sequence in the code
chunk = """    x = 1
    y = 2"""

ARGS = {
    "code": code,
    "chunk": chunk
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_element_by_time Ran
ran; our contract draft was wrong, not the code
cuhk-shenzhen-se/d4c/validator/leetcode.py
code served (permissive licence) · get_code("bc7b7ee8ab7c2f4e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from datetime import datetime

# Construct a list of tuples where each element has at least 2 items
# The function accesses list[index][0] and list[index][1]
list_arg = [
    (torch.randn(2, 4), np.array([1, 2, 3])),
    (torch.randn(2, 4), np.array([4, 5, 6])),
    (torch.randn(2, 4), np.array([7, 8, 9])),
    (torch.randn(2, 4), np.array([10, 11, 12])),
]

ARGS = {
    "list": list_arg
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
test Ran
ran; our contract draft was wrong, not the code
cuhk-shenzhen-se/d4c/generator/defects4j.py
code served (permissive licence) · get_code("0d40e3e890f68f73")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from unittest.mock import Mock, patch, MagicMock
import tempfile
import os

# Mock the helper functions that are called in test()
def extract_method_start_end_index(class_path, function_head, original_method_len):
    """Mock implementation returning a valid index tuple"""
    return (0, 100)

def replace_file(class_path, class_replace_index, fixed_method):
    """Mock implementation"""
    pass

def restore_file(class_path, bug_id):
    """Mock implementation"""
    pass

def run_JUnit(bug_id):
    """Mock implementation returning reward and submission result"""
    return (True, "All tests passed")

# Patch the functions globally so they're available when test() calls them
import sys
current_module = sys.modules[__name__]
current_module.extract_method_start_end_index = extract_method_start_end_index
current_module.replace_file = replace_file
current_module.restore_file = restore_file
current_module.run_JUnit = run_JUnit

# Create a temporary class file for testing
temp_dir = tempfile.mkdtemp()
test_class_path = os.path.join(temp_dir, "TestClass.java")
with open(test_class_path, 'w') as f:
    f.write("""
public class TestClass {
    public void testMethod() {
        System.out.println("test");
    }
}
""")

ARGS = {
    "bug_id": "BUG_001",
    "class_path": test_class_path,
    "original_method": """public void testMethod() {
        System.out.println("original");
    }""",
    "fixed_method": """public void testMethod() {
        System.out.println("fixed");
    }"""
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
apply_diff_to_program Not yet run
unverified (harvested, no recorded run)
cuhk-shenzhen-se/d4c/utils/patch_apply.py
code served (permissive licence) · get_code("d12b307c18e9b0f2")
How it ran

no invocation recorded.

run_JUnit Not yet run
unverified (harvested, no recorded run)
cuhk-shenzhen-se/d4c/validator/junit.py
code served (permissive licence) · get_code("7e5a166cef0372dd")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large language models (LLMs) have achieved decent results on automated program repair (APR). However, the next token prediction training objective of decoder-only LLMs (e.g., GPT-4) is misaligned with the masked span prediction objective of current infilling-style methods, which impedes LLMs from fully leveraging pre-trained knowledge for program repair. In addition, while some LLMs can locate and repair bugs in certain functions using the related artifacts (e.g., test cases), existing methods still depend on statement-level fault localization methods to provide a list of buggy hunks for repair. This restriction hinders LLMs from exploring potential patches beyond the given locations. In this paper, we investigate a new approach to adapt LLMs to program repair. Our core insight is that LLM's APR capability can be greatly improved by simply aligning the output to their training objective and allowing them to refine the whole program without first identifying faulty statements. Based on this insight, we designed D4C, a straightforward prompting framework for APR. D4C can repair 180 bugs correctly in Defects4J, with each patch being sampled only 10 times. This surpasses the SOTA APR methods with perfect fault localization by 10% and reduces the patch sampling number by 90%. Our findings reveal that (1) objective alignment is crucial for fully exploiting LLM's pre-trained capability, and (2) replacing the traditional localize-buggy-hunks-then-repair workflow with direct debugging is more effective for LLM-based APR methods. Thus, we believe this paper introduces a new mindset for harnessing LLMs in APR.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2404.08877")
get_code_for_paper("2404.08877")
have("2404.08877")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2404.08877.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2404.08877.svg)](https://syntology.ai/paper/2404.08877)

Connect an agent — have() is free.