SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2407.12504 · 2024

Case2Code: Scalable Synthetic Data for Code Generation

arXiv · PDF · Open in the Atlas

Code that ran

9 of 13 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 1 has no contract verdict; 6 failures of our instrument; 4 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/2407.12504.json · badge: /api/ran/2407.12504.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
choosewhatulike/case2code canonical (classifier label)
classifier basis: census
9 ran · 4 no recorded run
FunctionStatusWhere it lives
execute_code_wrapped Ran
ran on a synthesized input
choosewhatulike/case2code/exec_utils.py
code served (permissive licence) · get_code("cbe1465055781766")
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 dict. 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 subprocess
import dill

def reliability_guard(maximum_memory_bytes: int=None):
    """
    This disables various destructive functions and prevents the generated code
    from interfering with the test (e.g. fork bomb, killing other processes,
    removing filesystem files, etc.)

    WARNING
    This function is NOT a security sandbox. Untrusted code, including, model-
    generated code, should not be blindly executed outside of one. See the 
    Codex paper for more information about OpenAI's code sandbox, and proceed
    with caution.
    """
    if maximum_memory_bytes is not None:
        import resource
        resource.setrlimit(resource.RLIMIT_AS, (maximum_memory_bytes, maximum_memory_bytes))
        resource.setrlimit(resource.RLIMIT_DATA, (maximum_memory_bytes, maximum_memory_bytes))
        import platform
        if not platform.uname().system == 'Darwin':
            resource.setrlimit(resource.RLIMIT_STACK, (maximum_memory_bytes, maximum_memory_bytes))
    import faulthandler
    faulthandler.disable()
    import builtins
    builtins.exit = None
    builtins.quit = None
    builtins.open = None
    builtins.help = None
    import os
    os.environ['OMP_NUM_THREADS'] = '1'
    os.kill = None
    os.makedirs = None
    os.link = None
    os.system = None
    os.putenv = None
    os.remove = None
    os.removedirs = None
    os.rmdir = None
    os.fchdir = None
    os.setuid = None
    os.fork = None
    os.forkpty = None
    os.killpg = None
    os.rename = None
    os.renames = None
    os.truncate = None
    os.replace = None
    os.unlink = None
    os.fchmod = None
    os.fchown = None
    os.chmod = None
    os.chown = None
    os.chroot = None
    os.fchdir = None
    os.lchflags = None
    os.lchmod = None
    os.lchown = None
    os.getcwd = None
    os.chdir = None
    import shutil
    shutil.rmtree = None
    shutil.move = None
    shutil.chown = None
    import subprocess
    subprocess.Popen = None
    import sys
    sys.modules['ipdb'] = None
    sys.modules['joblib'] = None
    sys.modules['resource'] = None
    sys.modules['psutil'] = None
    sys.modules['tkinter'] = None
    import sqlite3
    sqlite3.connect = None

guard_code = dill.source.getsource(reliability_guard)

def execute_code_wrapped(code_pieces: str, exec_file: str='tmp_exec.py', timeout: int=100, add_guard: bool=True):
    try:
        with open(exec_file, 'w') as fw:
            if add_guard:
                fw.write(guard_code + '\n\n')
                fw.write('reliability_guard()\n\n')
            fw.write(code_pieces)
        result = subprocess.run(['python', exec_file], capture_output=True, check=False, text=True, timeout=timeout)
        if result.returncode != 0:
            return dict(status=False, result=result.stderr.strip())
        else:
            output = result.stdout.strip()
            return dict(status=True, result=output)
    except subprocess.TimeoutExpired:
        return dict(status=False, result='Timeout detected in running subprocess')
    except Exception as e:
        return dict(status=False, result=f'Unknown error in running subprocess ({e})')

ARGS = {
    'code_pieces': 'print("Hello, World!")',
    'exec_file': 'tmp_exec.py',
    'timeout': 100,
    'add_guard': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
dill — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
find_next_matching_parentheses Ran
ran, honoured the contract we drafted
choosewhatulike/case2code/prompt_code_data.py
code served (permissive licence) · get_code("f77c3ab6fcec0050")
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.

# Analyze the function to understand what it needs
# find_next_matching_parentheses takes:
# - s: a string to search through
# - start: an integer index (default 0)
# - left: a string character for opening bracket (default '(')
# - right: a string character for closing bracket (default ')')

# The function searches for matching parentheses in a string
# It returns a tuple of (start_index, end_index) or None

ARGS = {
    's': '(hello (world) foo)',
    'start': 0,
    'left': '(',
    'right': ')'
}
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_functions Ran
ran; our contract draft was wrong, not the code
choosewhatulike/case2code/ast_utils.py
code served (permissive licence) · get_code("f715b02aee57f4cc")
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 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 ast

# Create a simple Python code string to parse
code_string = """
def hello_world():
    print("Hello")

def add(a, b):
    return a + b

class MyClass:
    pass

def multiply(x, y):
    return x * y
"""

# Parse the code string into an AST
tree = ast.parse(code_string)

ARGS = {
    "tree": tree
}
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 float — 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
hinted_tuple_hook Ran
ran, honoured the contract we drafted
choosewhatulike/case2code/exec_utils.py
code served (permissive licence) · get_code("4a9ac795913154cf")
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.

import torch
import json

torch.manual_seed(0)

# Test case 1: object with '__bytes__' key
obj_bytes = {
    '__bytes__': True,
    'items': 'hello world'
}

# Test case 2: object with '__set__' key
obj_set = {
    '__set__': True,
    'items': [1, 2, 3, 4]
}

# Test case 3: object with '__tuple__' key
obj_tuple = {
    '__tuple__': True,
    'items': [5, 6, 7, 8]
}

# Test case 4: object with no special keys (passthrough)
obj_plain = {
    'data': 'some value',
    'number': 42
}

# Define ARGS mapping parameter to value
# The function takes one parameter: obj (a dictionary)
# We'll test with the '__tuple__' case as a representative example
ARGS = {
    'obj': obj_tuple
}
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 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
read_json Ran
ran; our contract draft was wrong, not the code
choosewhatulike/case2code/api_call_util.py
code served (permissive licence) · get_code("ad5f98bba0c21929")
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 dict. 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 json
import tempfile
import os

# Create a temporary JSON file
temp_dir = tempfile.mkdtemp()
json_file = os.path.join(temp_dir, "test.json")

# Write a simple JSON file
test_data = {"key": "value", "number": 42, "array": [1, 2, 3]}
with open(json_file, 'w') as f:
    json.dump(test_data, f)

# Define arguments for read_json function
ARGS = {
    "path": json_file
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
read_jsonl Ran
ran; our contract draft was wrong, not the code
choosewhatulike/case2code/api_call_util.py
code served (permissive licence) · get_code("65c57366104cbd60")
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 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 json
import tempfile
import os

# Create a temporary JSONL file for testing
temp_file = tempfile.NamedTemporaryFile(mode='w', suffix='.jsonl', delete=False)
temp_path = temp_file.name

# Write some valid JSON lines
test_data = [
    {"id": 1, "text": "hello world"},
    {"id": 2, "text": "foo bar"},
    {"id": 3, "text": "test data"}
]

for item in test_data:
    temp_file.write(json.dumps(item) + '\n')

temp_file.close()

# Define arguments for read_jsonl
ARGS = {
    'path': temp_path,
    'stream': False
}
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 float — 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
run_code_carefully Ran
ran; our contract draft was wrong, not the code
choosewhatulike/case2code/exec_utils.py
code served (permissive licence) · get_code("91900a7213500feb")
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 dict. 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 multiprocessing

# Simple test code that will be executed
test_code = """
def add(a, b):
    return a + b

result = add(2, 3)
assert result == 5
"""

ARGS = {
    "code": test_code,
    "timeout": 5.0,
    "code_id": 1
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
source_to_ast Ran
ran; our contract draft was wrong, not the code
choosewhatulike/case2code/ast_utils.py
code served (permissive licence) · get_code("9d97a25d8bf47524")
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 Module. 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 ast

# The function source_to_ast takes a single parameter: code (a string)
# It attempts to parse the code string into an AST using ast.parse()
# If parsing succeeds, it returns the AST object
# If an exception occurs that isn't a SyntaxError, it prints the error
# Otherwise it returns None

# Valid Python code strings to test with
valid_python_code = "x = 1 + 2"
invalid_syntax_code = "x = + +"
valid_function_code = "def foo(a, b):\n    return a + b"

ARGS = {
    "code": valid_python_code
}
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 Module — a Module output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Module 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
unwrap_code Ran
ran; our contract draft was wrong, not the code
choosewhatulike/case2code/data_process.py
code served (permissive licence) · get_code("1d3bfb6057c12f45")
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 torch

def unwrap_code(text: str) -> str:
    """Unwrap a code block."""
    if '```python' in text:
        sidx = text.index('```python') + 10
        if '```' in text[sidx:]:
            eidx = text.index('```', sidx)
        else:
            eidx = len(text)
        return text[sidx:eidx].strip()
    else:
        return text.strip()


# Test case 1: text with python code block
text_with_code = """Here is some code:

def hello():
    print("world")

End of code."""

ARGS = {
    "text": text_with_code
}
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 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
get_data_processor Not yet run
unverified (harvested, no recorded run)
choosewhatulike/case2code/data_process.py
code served (permissive licence) · get_code("77994d7607b4f856")
How it ran

no invocation recorded.

process_code Not yet run
unverified (harvested, no recorded run)
choosewhatulike/case2code/mp_exec_code.py
code served (permissive licence) · get_code("7e8e2b21d03cf0aa")
How it ran

no invocation recorded.

read_gen_data Not yet run
unverified (harvested, no recorded run)
choosewhatulike/case2code/api_call_util.py
code served (permissive licence) · get_code("c8f61b44d28f3ca2")
How it ran

no invocation recorded.

run_worker Not yet run
unverified (harvested, no recorded run)
choosewhatulike/case2code/mp_test_case2code_with_exe.py
code served (permissive licence) · get_code("b1f9298be41ff962")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 0 later) and 11 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.

FunctionAlso present inEarliest-datedOthers named
read_json 1 other paper
1 dated earlier
2310.10158 (2023-10)
Character-LLM: A Trainable Agent for Role-Playing
unwrap_code 1 other paper
1 dated earlier
2401.12869 (2024-01)
TroVE: Inducing Verifiable and Efficient Toolboxes for Solving Programmatic Tasks

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 shown outstanding breakthroughs in code generation. Recent work improves code LLMs by training on synthetic data generated by some powerful LLMs, which can be challenging to scale due to the dependence on a teacher model and high generation costs. In this paper, we focus on synthesizing code data at scale and propose a \textbf{Case2Code} task by exploiting the expressiveness and correctness of programs. \textbf{Case2Code} is an inductive inference task that aims to infer underlying code implementations by observing input-output examples or program behaviors, By incorporating LLMs to generate program inputs, and executing the program with these inputs to obtain the program outputs, we can synthesize diverse and high-quality \textbf{Case2Code} data at scale for training and evaluating code LLMs. Experimental results show that case-to-code induction is challenging for current representative LLMs if they are untrained. Models trained with \textbf{Case2Code} improve performance not only on distribution case-to-code induction but also on various coding-generation tasks, demonstrating the great potential of large-scale synthetic data and inductive learning.

For agents

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

get_harvested_code_for_paper("2407.12504")
get_code_for_paper("2407.12504")
have("2407.12504")

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

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

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

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

Connect an agent — have() is free.