# Text-to-SQL eval: raw schema vs dbt semantic layer (2026-11-23) ## Update: coverage gap closed (layer c1c5270, semantic arm re-run) The first sweep (below) found that 9 of the 60 questions need columns the marts dropped. The layer now carries them (cre-semantic-layer `c51c5ef` + `c1c5270`): `fct_permits` (permit grain: permit number, developer, issue dates), `bridge_property_parcel` (sold property x APN, normalized county), `bridge_trade_permit_parcel` (the DEFINITIONS D10 parcel join), `dim_market_county` (CBSA county FIPS), and community `url` / `url_status` / latest scrape status on `dim_property`. All 9 reproduce their frozen result from the marts alone (`tests/test_semantic_coverage.py`). Only the semantic arm was re-run: the raw arm reads the same snapshot through the same harness, so its runs stand. Harness pinned at text-to-sql-eval `2956fb7` for the whole re-run (agent, arms, scorer and runner are byte-identical to the first sweep's `570c1ae`; checked with `git diff` before each invocation). Same models, effort, turn limit and repeats (Haiku 3, Sonnet 2, Opus 1 on the scored split; 1 each on the hold-out). Metered spend for the re-run: **$2.90** (estimate $2.90-4.60, caps totalling $5.50). Cumulative for everything in results/runs: $10.85. EX = execution accuracy, PBW = plausible-but-wrong. Each question counts once (the mean over its repeats), so the scored and hold-out splits combine fairly (`tools/coverage_compare.py`; full grid incl. the 9-question cut in `results/COVERAGE_COMPARE.md`). | Model | Raw EX (all 60) | Semantic EX before -> after (all 60) | Raw PBW | Semantic PBW before -> after | Raw EX (44) | Semantic EX before -> after (44) | Raw PBW (44) | Semantic PBW before -> after (44) | |---|---|---|---|---|---|---|---|---| | Haiku 5.5 | 58.9% | 55.0% -> **78.3%** | 37.8% | 27.2% -> **20.0%** | 56.8% | 68.2% -> 73.5% | 38.6% | 30.3% -> 24.2% | | Sonnet 5.5 | 67.5% | 60.0% -> **83.3%** | 31.7% | 23.3% -> **15.0%** | 67.0% | 72.7% -> 81.8% | 31.8% | 25.0% -> 15.9% | | Opus 5.5 | 65.0% | 65.0% -> **81.7%** | 33.3% | 18.3% -> **16.7%** | 59.1% | 77.3% -> 79.5% | 38.6% | 20.5% -> 18.2% | The "44" columns are the 44 scored questions the first marts already covered (the same post-hoc cut as below); raw is the same runs in both phases. The semantic arm now beats raw on overall EX for every model (+19.4, +15.8, +16.7 points) and keeps the lower PBW. What moved, per question (semantic arm): - **The 9 gap questions** went from 0% (all refused) to 96% / 100% / 89% EX. Misses: Haiku J03 once (1 of 3); Opus A10 summed units by `primary_developer_name` on the project mart, which drops co-filers, despite the column description pointing to `fct_permits`. - **Gains on covered questions came from the new permit grain**, not chance alone: A05 and T03 flipped to correct for every model, using `fct_permits` (the first report's fix #3, "a permit-grain supply fact"). J10 / L09 / T05 (hold-out, one repeat) and Sonnet M09 / M10 also flipped without touching the new columns: treat those as run-to-run noise. - **One new failure mode:** J08 went 1/1 -> 0/1 for Opus and 3/3 -> 2/3 for Haiku, both times via `fct_permits`. Having a permit grain next to the project grain lets an agent pick the wrong one. Caveats, read these before quoting the numbers: - **The hold-out split is no longer held out.** The layer change was aimed at gaps the hold-out run exposed (A09, A10, J09), and one design choice was checked against A10's gold SQL before the re-run (a single project-level developer name lost co-filers on 428 of 7,431 projects; it became `primary_developer_name` + `developer_count`, and per-developer totals go through `fct_permits`). The after-numbers on the 9 gap questions measure "the columns exist now", not generalization. Fresh questions are needed for a clean generalization number. - The 44-question columns are the cleaner comparison: no question there drove a layer change, but the new marts are visible to every question (the A05 / T03 / J08 effects above). - Repeats are small (Opus 1, Sonnet 2, Haiku 3; hold-out 1). Run-to-run spread was <= 4 points where measured. ## Original sweep (layer 33e6a69) Harness at text-to-sql-eval 570c1ae; semantic layer cre-semantic-layer 33e6a69 (catalog `layer_sha`). Golden set: 60 frozen questions (50 scored, 10 held out), snapshot as of 2026-11-22. Effort `medium`, max 15 turns, one agent loop per question. Scorer: result-set match (tools/scorer.py). Real metered spend for everything in results/runs: **$7.94** on one metered Anthropic API key (prices from the pricing docs page, 2026-11-23). ## Headline: scored split (n = 50 per run) | Model | Arm | Repeats | n | Execution accuracy (mean, min-max) | Answerable | Refusals | Plausible-but-wrong | Valid SQL | Cost / run | |---|---|---|---|---|---|---|---|---|---| | claude-haiku-5-5 | raw | 3 | 50 | 60.7% (58.0%-62.0%) | 52.0% | 100.0% | 35.3% | 100.0% | $0.12 | | claude-haiku-5-5 | semantic | 3 | 50 | 60.0% (60.0%-60.0%) | 52.8% | 92.6% | 26.7% | 99.2% | $0.06 | | claude-sonnet-5-5 | raw | 2 | 50 | 69.0% (68.0%-70.0%) | 62.2% | 100.0% | 30.0% | 98.8% | $0.78 | | claude-sonnet-5-5 | semantic | 2 | 50 | 64.0% (64.0%-64.0%) | 56.1% | 100.0% | 22.0% | 100.0% | $0.49 | | claude-opus-5-5 | raw | 1 (incl. 7-q top-up after budget halt) | 50 | 64.0% (64.0%-64.0%) | 56.1% | 100.0% | 34.0% | 100.0% | $2.29 | | claude-opus-5-5 | semantic | 1 | 50 | 68.0% (68.0%-68.0%) | 61.0% | 100.0% | 18.0% | 100.0% | $1.36 | Runs counted: 12 (tag `sweep`, split `scored`). Cumulative metered spend, all runs in results/runs: $7.944. Plausible-but-wrong (PBW) = the SQL ran and returned a wrong answer, or the agent answered a question it should have refused. The semantic arm lowers PBW for every model (Haiku 35.3 -> 26.7, Sonnet 30.0 -> 22.0, Opus 34.0 -> 18.0). Overall execution accuracy is mixed (-0.7, -5.0, +4.0 points). ## Why accuracy doesn't move: a coverage gap, not wrong metrics The semantic arm sees only the marts. Six scored questions (J02, J03, L03, L05, L07, L08) need a column the marts drop, and every semantic attempt refused them (6/6 each): trade parcel ID / APN, permit number, community website, CBSA-to-county map. The agents' refusal text names the missing field each time. That's 12% of the scored set the semantic arm can't reach, so its ceiling is 88%. On the 44 questions the layer covers (a post-hoc cut chosen from those refusals; not a pre-registered metric): | Model | Raw EX | Semantic EX | Raw PBW | Semantic PBW | Cases per arm | |---|---|---|---|---|---| | Haiku 5.5 | 56.8% | 68.2% | 38.6% | 30.3% | 132 | | Sonnet 5.5 | 67.0% | 72.7% | 31.8% | 25.0% | 88 | | Opus 5.5 | 59.1% | 77.3% | 38.6% | 20.5% | 44 | ## Held-out split (run once, after everything above was frozen; n = 10, one repeat) | Model | Arm | Repeats | n | Execution accuracy (mean, min-max) | Answerable | Refusals | Plausible-but-wrong | Valid SQL | Cost / run | |---|---|---|---|---|---|---|---|---|---| | claude-haiku-5-5 | raw | 1 | 10 | 50.0% (50.0%-50.0%) | 44.4% | 100.0% | 50.0% | 100.0% | $0.03 | | claude-haiku-5-5 | semantic | 1 | 10 | 30.0% (30.0%-30.0%) | 22.2% | 100.0% | 30.0% | 88.9% | $0.02 | | claude-sonnet-5-5 | raw | 1 | 10 | 60.0% (60.0%-60.0%) | 55.6% | 100.0% | 40.0% | 100.0% | $0.14 | | claude-sonnet-5-5 | semantic | 1 | 10 | 40.0% (40.0%-40.0%) | 33.3% | 100.0% | 30.0% | 100.0% | $0.14 | | claude-opus-5-5 | raw | 1 | 10 | 70.0% (70.0%-70.0%) | 66.7% | 100.0% | 30.0% | 100.0% | $0.51 | | claude-opus-5-5 | semantic | 1 | 10 | 50.0% (50.0%-50.0%) | 44.4% | 100.0% | 20.0% | 100.0% | $0.22 | Runs counted: 6 (tag `holdout`, split `holdout`). Cumulative metered spend, all runs in results/runs: $7.944. The semantic arm is 20 points lower on every model. Three of the 10 questions (A09, A10, J09) hit the same gap (leasing URL / listing status, permit developer, trade parcel ID) and every semantic run refused all three. On the 7 covered hold-out questions: Haiku 3/7 raw vs 3/7 semantic, Sonnet 3/7 vs 4/7, Opus 5/7 vs 5/7. Across all 60 questions, **9 (15%) need columns the marts don't carry.** n = 10 is too small for anything but that direction. ## Error analysis (tools/error_analysis.py; full table results/ERROR_ANALYSIS.md) - **Raw arm fails by skipping conventions.** Of raw wrong/empty answers, the share whose SQL omits a predicate the gold applies (from golden DEFINITIONS): Haiku 39/53 (74%), Sonnet 21/30 (70%), Opus 9/17 (53%). Most often: trade confidence filter, `superseded_by is null`, `product = 'mf'`, the $50k-$600k per-unit band, `comp_exclusion`. The marts pre-apply these, which is where the semantic arm's PBW drop comes from. - **Semantic arm fails by refusing (coverage) and by skipping the product split.** False refusals: Haiku 12.7%, Sonnet 14.0% of semantic cases (raw: 4.0%, 0.0%). M09-M11: the marts reproduce the gold number exactly once `product = 'mf'` is applied (M09 0.43370508054522927, M10 5.731428571428571, M11 5.58392), but the agents filtered on `is_market_rent_universe` alone, which covers both MF and BFR (D1 splits by product). T03: the supply mart is project-grain with a first-issued date, so "permits issued in the last 90 days" has no per-permit date. - **Hand check of the result-shape tags** (12 sampled cases): 5 of the 6 raw "wrong number" cases were missed filters on a 1x1 answer, so the result-shape tags can't separate filter from metric errors. That's why the tags are named by shape and the cause comes from the SQL check above. "Right numbers, wrong shape" was correct each time (wide pivot with a total column, long vs wide months). - No layer defect was found. Every semantic wrong answer I traced came from the agent's filter or grain choice, not a mart computing a DEFINITIONS metric differently. ## What would move the semantic number Not done here: changing the layer after seeing these questions contaminates both splits, so any fix needs fresh questions to measure it. 1. Carry the dropped attributes into the marts: trade parcel/APN and county (the empty `int_property_xref` stub is the place for the trades<->permits join), permit number and developer, community URL / listing status, CBSA-county. 2. Put `product` into the rent metric filters, or separate MF and BFR metrics, so "apartments" can't silently include BFR. 3. A permit-grain supply fact next to the project-grain one. ## Caveats - Repeats: Haiku 3, Sonnet 2, Opus 1 per arm. Run-to-run spread was <= 4 points where measured. - Opus raw hit its $2.00 cap after 43 questions; the 7 it never reached (all refusal questions, R03-R09) were run separately (`*_topup`) and merged. All 7 were correct; refusal questions are the easiest category, so this doesn't bias the comparison against raw. - The semantic arm also gets metric definitions from the dbt manifest. The raw arm gets the DEFINITIONS conventions list (section A) only, same as at freeze time. - Scorer equivalences (extra columns, market spelling, transposed single row) were added after the pilot (market spelling from the golden notes; the other two generic), each pinned by a test that shows it can't rescue a wrong number. No question or frozen result was edited. Reproduce: workflows/eval_harness.md. `tools.report --tag sweep`, `tools.report --tag holdout --split holdout`, `tools.error_analysis --tag sweep`.