Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bench/accuracy/build_bird_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path

logger = logging.getLogger(__name__)
DESCRIPTION_MARKER = "\n\nOfficial column/value descriptions (2024 Dev release):\n"


def build_documents(directory, baseline):
Expand Down Expand Up @@ -35,7 +36,7 @@ def build_documents(directory, baseline):
for row in rows if row["original_column_name"]
]
return {
db: schema + "\n\nOfficial column/value descriptions (2024 Dev release):\n"
db: schema + DESCRIPTION_MARKER
+ json.dumps(tables[db], ensure_ascii=False, indent=2)
for db, schema in baseline.items()
}
Expand Down
38 changes: 35 additions & 3 deletions bench/accuracy/codex_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import time
from pathlib import Path

from bench.accuracy.build_bird_descriptions import DESCRIPTION_MARKER
from bench.accuracy.evaluate import load_schema_documents, query_rows, validate_inputs
from bench.oracle_view.codex_demo import READ_TOOLS, mcp_settings
from bench.spider2.evaluate import (
Expand All @@ -30,6 +31,25 @@
logger = logging.getLogger(__name__)


def seed_column_cache(path, document):
"""Expose already-pinned input metadata through the existing schema cache."""
from lang2sql.adapters.storage.sqlite_store import SqliteStore
from lang2sql.tools.enrich_schema import _kv_key

columns = json.loads(document.split(DESCRIPTION_MARKER, 1)[1])
store = SqliteStore(str(path))
count = 0
try:
for table, rows in columns.items():
for row in rows:
store.kv_set("benchmark", _kv_key(table, row["original_column_name"]),
json.dumps(row, ensure_ascii=False))
count += 1
finally:
store.close()
logger.info("Seeded official column cache path=%s columns=%d", path, count)


def executed_sql(answer, events, *, db=None, sql_timeout=30, max_rows=100000):
"""Only MCP-executed final answers qualify; no shell or final-tool fallback."""
sql = final_sql(answer)
Expand Down Expand Up @@ -171,6 +191,12 @@ async def run(args):
if manifest["suite"] == "spider2":
validate_manifest(manifest, args.root, args.db_dir)
docs = load_schema_documents(args.schema_docs, manifest["suite"])
cache_columns = getattr(args, "cache_official_columns", False)
if cache_columns and (
manifest["suite"] != "bird"
or docs != load_schema_documents(repo / "bench/accuracy/bird-schema-with-values.json", "bird")
):
raise ValueError("Official column caching requires the pinned BIRD schema-with-values input")
selected = set(manifest["development_ids"]) if args.split == "development" else None
manifest["cases"] = [
c for c in manifest["cases"] if selected is None or c["instance_id"] in selected
Expand Down Expand Up @@ -234,6 +260,7 @@ async def run(args):
]
},
"schema_document_sha256": digest(args.schema_docs),
"cache_official_columns": cache_columns,
"case_selection": {
"split": args.split,
"input_cases": input_case_count,
Expand Down Expand Up @@ -287,9 +314,13 @@ async def case_run(case):
work.mkdir()
answer_path = directory / "events" / (ident + ".answer.txt")
events_path = directory / "events" / (ident + ".jsonl")
settings = mcp_settings(
["--org-id", "benchmark", "--user-id", ident], extra_env=("PYTHONPATH",)
)
server_args = ["--org-id", "benchmark", "--user-id", ident]
if cache_columns:
cache_path = (work / "metadata.sqlite").resolve()
await asyncio.to_thread(seed_column_cache, cache_path, docs[case["db"]])
record["initial_metadata_store_sha256"] = digest(cache_path)
server_args += ["--store", str(cache_path)]
settings = mcp_settings(server_args, extra_env=("PYTHONPATH",))
settings.update(
{
"model_reasoning_effort": args.reasoning_effort,
Expand Down Expand Up @@ -445,6 +476,7 @@ def main():
parser.add_argument("--expected-cases", type=int,
help="Require this final selected count before any model call; includes split and failure/pass filtering")
parser.add_argument("--review-source", type=Path, help="Prior run directory; pass only prior model answer/tool observations, never scores")
parser.add_argument("--cache-official-columns", action="store_true", help="Expose the pinned BIRD schema-with-values descriptions through each case's isolated MCP schema cache; prompt remains unchanged")
parser.add_argument("--failures-from", type=Path, help="Run only score=0 cases from this completed run; grades select cases but never enter model prompts")
parser.add_argument("--exclude-passed-from", type=Path, action="append", default=[],
help="With --failures-from only: skip previously passed cases from each validated completed run; repeatable, never a full-accuracy selection")
Expand Down
11 changes: 11 additions & 0 deletions bench/accuracy/mcp-review-results/tool-schema-cache/analysis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"correct": 0,
"total": 3,
"decision": "Keep optional condition off by default; no unchanged retry or performance-improvement claim.",
"evidence": "All three initial prompts are byte-identical to baseline. Production src trees are identical. All final cache entries match pinned descriptions exactly. All three traces contain explore_schema results with the source column descriptions.",
"finding": "Metadata delivery alone did not resolve these column choice/filter/grain errors. This does not establish whether the model made full use of every description.",
"limits": [
"One stochastic attempt per selected failure; not full accuracy.",
"No policy weakening, question-specific SQL or gold information supplied."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
card_type,card_count
Creature,71
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
japanese_name,english_card_type,ruling_total
ボロスのギルド門,Land — Gate,18
太陽打ちの槌,Artifact — Equipment,15
ボロスの魔除け,Instant,14
ボロスの駐屯地,Land,12
光り輝く炎,Sorcery,12
手練れの戦術,Instant,12
照らす光,Instant,12
浄化の光線,Instant,10
炎まといの報復者,Creature — Angel,10
ボロスの反攻者,Creature — Minotaur Wizard,9
ウォジェクの護衛,Creature — Human Soldier,8
前線の衛生兵,Creature — Human Cleric,8
ボロスの精鋭,Creature — Human Soldier,6
恐慌の扇動,Sorcery,6
戦導者オレリア,Legendary Creature — Angel,6
果敢なスカイジェク,Creature — Human Knight,6
正義の模範、オレリア,Legendary Creature — Angel,6
爆弾部隊,Creature — Human Soldier,6
聖なる鋳造所,Land — Mountain Plains,6
軍の要塞、サンホーム,Land,6
軍勢の忠節者,Creature — Goblin Soldier,6
ボロスの布陣者,Creature — Minotaur Soldier,5
真火の隊長,Creature — Human Knight,5
ボロスの大天使、ラジア,Legendary Creature — Angel,4
ボロスの魔鍵,Artifact,4
戦場操作,Instant,4
稲妻のらせん,Instant,4
軍勢の光,Creature — Angel,4
軍勢の切先、タージク,Legendary Creature — Human Soldier,4
軍勢の戦親分,Creature — Goblin Soldier,4
ウォジェクの矛槍兵,Creature — Human Soldier,3
オルドルーンの古参兵,Creature — Minotaur Soldier,3
オレリアの憤怒,Instant,3
サンホームのギルド魔道士,Creature — Human Wizard,3
サンホームの重鎮,Creature — Human Soldier,3
ボロスの挑戦者,Creature — Human Soldier,3
ボロスの猛犬,Creature — Dog,3
刃の教官,Creature — Human Soldier,3
戦心の歩兵,Creature — Elemental Soldier,3
栄光の好機,Instant,3
槌落とし,Creature — Giant Soldier,3
火拳の打撃者,Creature — Human Soldier,3
炎の血族の盲信者,Creature — Elemental Berserker,3
炎まといの天使,Creature — Angel,3
突発的な兵長,Creature — Minotaur Soldier,3
航行隊の猛士,Creature — Human Soldier,3
軍勢の刃、タージク,Legendary Creature — Human Soldier,3
ウォジェクの古参兵、アグルス・コス,Legendary Creature — Human Soldier,2
ラジアの浄化,Sorcery,2
反応 // 反正,Instant,2
反応 // 反正,Sorcery,2
完全 // 間隙,Instant,2
戦いの烈光,Enchantment,2
正義の矢,Instant,2
猛火の猛士,Creature — Minotaur Soldier,2
薙ぎ払いの巨人,Creature — Giant Soldier,2
軍団の戦略,Enchantment,2
軍部の栄光,Instant,2
轟音のクラリオン,Sorcery,2
速太刀の擁護者,Creature — Human Soldier,2
そびえ立つ雷拳,Creature — Giant Soldier,1
ボロスの怒りの盾,Instant,1
戦導者のらせん,Instant,1
焼尽の瞑想,Enchantment,1
緊急徴兵,Instant,1
軍勢のギルド魔道士,Creature — Human Wizard,1
軍勢の集結,Enchantment,1
鋳造所の勇者,Creature — Elemental Soldier,1
Hide // Seek,Instant,0
ウォジェクの号笛,Instant,0
ウォジェクの燃えさし魔道士,Creature — Human Wizard,0
ウォジェクの薬剤師,Creature — Human Cleric,0
オルドルーンの猛士,Creature — Minotaur Soldier,0
ゴブリンの旗持ち,Creature — Goblin Soldier,0
サンホームの処罰者,Creature — Giant Soldier,0
パルヘリオンの巡視兵,Creature — Human Knight,0
ボロスのギルド魔道士,Creature — Human Wizard,0
ボロスのロケット,Artifact,0
ボロスの印鑑,Artifact,0
ボロスの導き石,Artifact,0
ボロスの補充兵,Creature — Goblin Soldier,0
ボロスの速太刀,Creature — Human Soldier,0
ヴィーアシーノの初太刀,Creature — Viashino Soldier,0
初々しい補充兵,Creature — Human Soldier,0
正義の再興,Instant,0
火花の強兵,Creature — Elemental Soldier,0
痕跡消し,Instant,0
盲信のうねり,Instant,0
真火の聖騎士,Creature — Human Knight,0
破壊的一撃,Instant,0
空騎士の軍団兵,Creature — Human Knight,0
裁きの一撃,Instant,0
要塞のサイクロプス,Creature — Cyclops Soldier,0
金切り声のグリフィン,Creature — Griffin,0
雷楽のラッパ吹き,Creature — Human Soldier,0
駐屯地の兵長,Creature — Viashino Soldier,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DisplayName,edit_comment_count
mbq,2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```sql
WITH type_counts AS (
SELECT c.types AS card_type, COUNT(*) AS card_count
FROM cards AS c
WHERE c.watermark = 'boros'
AND c.uuid IN (
SELECT fd.uuid
FROM foreign_data AS fd
WHERE fd.language <> 'English'
AND fd.language <> ''
)
GROUP BY c.types
)
SELECT card_type, card_count
FROM type_counts
WHERE card_count = (SELECT MAX(card_count) FROM type_counts)
ORDER BY card_type
LIMIT 1000
```

Large diffs are not rendered by default.

Loading