SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.16755 · 2024

CHESS: Contextual Harnessing for Efficient SQL Synthesis

arXiv · PDF · Open in the Atlas

Code that ran

6 of 6 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; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 0 no recorded run), measured 2026-11-23; 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/2405.16755.json · badge: /api/ran/2405.16755.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
shayantalaei/chess canonical (classifier label)
classifier basis: census
6 ran · 0 no recorded run
FunctionStatusWhere it lives
create_smaller_db Ran
ran; our contract draft was wrong, not the code
shayantalaei/chess/src/database_utils/execution.py
code served (permissive licence) · get_code("ad3387002d9f4290")
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 sqlite3
import os
import tempfile

# Create a temporary directory for our test database
temp_dir = tempfile.mkdtemp()

# Create an original test database with some sample data
original_db_path = os.path.join(temp_dir, 'test.db')
conn = sqlite3.connect(original_db_path)
cursor = conn.cursor()

# Create a sample table with multiple columns
cursor.execute('''
    CREATE TABLE users (
        id INTEGER PRIMARY KEY,
        name TEXT,
        email TEXT,
        age INTEGER
    )
''')

# Insert sample data (more than max_rows to test limiting)
for i in range(150):
    cursor.execute(
        'INSERT INTO users (name, email, age) VALUES (?, ?, ?)',
        (f'user_{i}', f'user_{i}@example.com', 20 + (i % 50))
    )

# Create another table to test multiple table handling
cursor.execute('''
    CREATE TABLE products (
        id INTEGER PRIMARY KEY,
        name TEXT,
        price REAL
    )
''')

for i in range(50):
    cursor.execute(
        'INSERT INTO products (name, price) VALUES (?, ?)',
        (f'product_{i}', 9.99 + i)
    )

conn.commit()
conn.close()

# Define ARGS
ARGS = {
    'original_db_path': original_db_path,
    'max_rows': 100000
}
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
execute_sql Ran
ran; our contract draft was wrong, not the code
shayantalaei/chess/src/database_utils/execution.py
code served (permissive licence) · get_code("23a00a780614c4eb")
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 2, 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 sqlite3
import tempfile
import os

# Create a temporary SQLite database with some test data
temp_db = tempfile.NamedTemporaryFile(delete=False, suffix='.db')
db_path = temp_db.name
temp_db.close()

# Initialize the database with a simple table
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute('CREATE TABLE test_table (id INTEGER PRIMARY KEY, name TEXT, value INTEGER)')
cursor.execute('INSERT INTO test_table (name, value) VALUES (?, ?)', ('Alice', 100))
cursor.execute('INSERT INTO test_table (name, value) VALUES (?, ?)', ('Bob', 200))
cursor.execute('INSERT INTO test_table (name, value) VALUES (?, ?)', ('Charlie', 300))
cursor.execute('INSERT INTO test_table (name, value) VALUES (?, ?)', ('David', 400))
cursor.execute('INSERT INTO test_table (name, value) VALUES (?, ?)', ('Eve', 500))
conn.commit()
conn.close()

# Define arguments for execute_sql
ARGS = {
    'db_path': db_path,
    'sql': 'SELECT * FROM test_table',
    'fetch': 'all',
    'timeout': 60
}
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 2, 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
get_primary_keys Ran
ran; our contract draft was wrong, not the code
shayantalaei/chess/src/database_utils/schema.py
code served (permissive licence) · get_code("fe37954301139f99")
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.

from dataclasses import dataclass, field
from typing import Dict, List, Any, Optional, Tuple

@dataclass
class ColumnInfo:
    """
    Represents metadata for a single column in a database table.
    
    Attributes:
        original_column_name (str): The original name of the column.
        column_name (str): The standardized name of the column.
        column_description (str): A description of the column.
        data_format (str): The format of the data in the column.
        value_description (str): A description of the values in the column.
        type (str): The data type of the column.
        examples (List[str]): Example values from the column.
        primary_key (bool): Whether the column is a primary key.
        foreign_keys (List[Tuple[str, str]]): Foreign keys referencing other tables and columns.
        referenced_by (List[Tuple[str, str]]): Columns in other tables that reference this column.
    """
    original_column_name: str = ''
    column_name: str = ''
    column_description: str = ''
    data_format: str = ''
    value_description: str = ''
    type: str = ''
    examples: List[str] = field(default_factory=list)
    primary_key: bool = False
    foreign_keys: List[Tuple[str, str]] = field(default_factory=list)
    referenced_by: List[Tuple[str, str]] = field(default_factory=list)
    unique_values: List[str] = field(default_factory=list)
    value_statics: str = ''

@dataclass
class TableSchema:
    """
    Represents the schema of a single table in a database.
    
    Attributes:
        columns (Dict[str, ColumnInfo]): A dictionary mapping column names to their metadata.
    """
    columns: Dict[str, ColumnInfo] = field(default_factory=dict)

def get_primary_keys(table_schema: TableSchema) -> List[str]:
    """
    Retrieves the primary key columns from a table schema.
    
    Args:
        table_schema (TableSchema): The table schema to analyze.
    
    Returns:
        List[str]: A list of primary key column names.
    """
    return [name for name, info in table_schema.columns.items() if info.primary_key]


# Setup code to construct valid arguments

# Create ColumnInfo objects for testing
col1 = ColumnInfo(
    original_column_name='user_id',
    column_name='user_id',
    column_description='Unique user identifier',
    data_format='integer',
    value_description='User ID number',
    type='INT',
    examples=['1', '2', '3'],
    primary_key=True,
    foreign_keys=[],
    referenced_by=[('orders', 'user_id')],
    unique_values=['1', '2', '3'],
    value_statics='unique'
)

col2 = ColumnInfo(
    original_column_name='user_name',
    column_name='user_name',
    column_description='Name of the user',
    data_format='string',
    value_description='User full name',
    type='VARCHAR(255)',
    examples=['Alice', 'Bob', 'Charlie'],
    primary_key=False,
    foreign_keys=[],
    referenced_by=[],
    unique_values=['Alice', 'Bob', 'Charlie'],
    value_statics='non-unique'
)

col3 = ColumnInfo(
    original_column_name='email',
    column_name='email',
    column_description='User email address',
    data_format='string',
    value_description='Email',
    type='VARCHAR(255)',
    examples=['alice@example.com', 'bob@example.com'],
    primary_key=True,
    foreign_keys=[],
    referenced_by=[],
    unique_values=['alice@example.com', 'bob@example.com'],
    value_statics='unique'
)

# Create TableSchema with multiple columns
table_schema = TableSchema(
    columns={
        'user_id': col1,
        'user_name': col2,
        'email': col3
    }
)

ARGS = {
    'table_schema': table_schema
}
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
ordered_concurrent_function_calls Ran
ran; our contract draft was wrong, not the code
shayantalaei/chess/src/threading_utils.py
code served (permissive licence) · get_code("11021b013fcea6fd")
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 queue
import torch
import torch.nn as nn

torch.manual_seed(0)

def dummy_function_1(x, y):
    """A simple function that adds two numbers"""
    return x + y

def dummy_function_2(a, b, c):
    """A simple function that multiplies three numbers"""
    return a * b * c

def dummy_function_3(tensor_input):
    """A function that processes a tensor"""
    return tensor_input.sum().item()

def dummy_function_4(name, value):
    """A function that concatenates strings"""
    return f"{name}_{value}"

ARGS = {
    'call_list': [
        {
            'function': dummy_function_1,
            'kwargs': {'x': 10, 'y': 20}
        },
        {
            'function': dummy_function_2,
            'kwargs': {'a': 2, 'b': 3, 'c': 4}
        },
        {
            'function': dummy_function_3,
            'kwargs': {'tensor_input': torch.tensor([[1.0, 2.0], [3.0, 4.0]])}
        },
        {
            'function': dummy_function_4,
            'kwargs': {'name': 'test', 'value': 'result'}
        }
    ]
}
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 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
receive_data_in_chunks Ran
ran; our contract draft was wrong, not the code
shayantalaei/chess/src/runner/database_manager.py
code served (permissive licence) · get_code("deb7dcb22098a379")
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 socket
import pickle
import threading

class MockSocket:
    """Mock socket that simulates receiving pickled data in chunks"""
    def __init__(self, data_to_send):
        self.data_to_send = data_to_send
        self.position = 0
        
    def recv(self, num_bytes):
        """Simulates receiving data from socket"""
        if self.position == 0:
            # First call: return the length header (4 bytes, big-endian)
            length = len(self.data_to_send)
            length_bytes = length.to_bytes(4, byteorder='big')
            self.position += 1
            return length_bytes
        else:
            # Subsequent calls: return chunks of the actual data
            chunk = self.data_to_send[self.position - 1:self.position - 1 + num_bytes]
            self.position += len(chunk)
            if not chunk:
                return b''
            return chunk

# Prepare test data
test_dict = {"key1": "value1", "key2": [1, 2, 3], "key3": 42}
pickled_data = pickle.dumps(test_dict)

# Create mock connection
mock_conn = MockSocket(pickled_data)

ARGS = {
    "conn": mock_conn,
    "chunk_size": 1024
}
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
subprocess_sql_executor Ran
ran; our contract draft was wrong, not the code
shayantalaei/chess/src/database_utils/execution.py
code served (permissive licence) · get_code("4f33589835015c45")
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 2, 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 sqlite3
import tempfile
import os

# Create a temporary SQLite database with sample data
temp_db = tempfile.NamedTemporaryFile(delete=False, suffix='.db')
db_path = temp_db.name
temp_db.close()

# Initialize the database with a simple table
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)')
cursor.execute('INSERT INTO users (name, age) VALUES (?, ?)', ('Alice', 30))
cursor.execute('INSERT INTO users (name, age) VALUES (?, ?)', ('Bob', 25))
cursor.execute('INSERT INTO users (name, age) VALUES (?, ?)', ('Charlie', 35))
conn.commit()
conn.close()

# Define valid arguments for subprocess_sql_executor
ARGS = {
    'db_path': db_path,
    'sql': 'SELECT * FROM users',
    'timeout': 60
}
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 2, 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

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 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 6 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-23.

Repositories linked to this paper

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

Abstract

Translating natural language questions into SQL queries, known as text-to-SQL, is a long-standing research problem. Effective text-to-SQL synthesis can become very challenging due to (i) the extensive size of database catalogs (descriptions of tables and their columns) and database values, (ii) reasoning over large database schemas, (iii) ensuring the functional validity of the generated queries, and (iv) navigating the ambiguities of natural language questions. We introduce CHESS, a Large Language Model (LLM) based multi-agent framework for efficient and scalable SQL synthesis, comprising four specialized agents, each targeting one of the aforementioned challenges: the Information Retriever (IR) extracts relevant data, the Schema Selector (SS) prunes large schemas, the Candidate Generator (CG) generates high-quality candidates and refines queries iteratively, and the Unit Tester (UT) validates queries through LLM-based natural language unit tests. Our framework offers configurable features that adapt to various deployment constraints, including 1) Supporting industrial-scale databases: leveraging the Schema Selector agent, CHESS efficiently narrows down very large database schemas into manageable sub-schemas, boosting system accuracy by approximately $2\%$ and reducing the number of LLM tokens by $\times 5$. 2) State-of-the-Art privacy-preserving performance: Among the methods using open-source models, CHESS achieves state-of-the-art performance, resulting in a high-performing, privacy-preserving system suitable for industrial deployment. 3) Scalablity with additional compute budget: In settings with high computational budgets, CHESS achieves $71.10\%$ accuracy on the BIRD test set, within $2\%$ of the leading proprietary method, while requiring approximately $83\%$ fewer LLM calls.

For agents

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

get_harvested_code_for_paper("2405.16755")
get_code_for_paper("2405.16755")
have("2405.16755")

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

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

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

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

Connect an agent — have() is free.