recon + sqlglot validator + drill_down package; guard ReAct dimension picks against candidate list

This commit is contained in:
2026-06-03 07:15:02 -03:00
parent e124a8a7d9
commit 2dad62f7e7
38 changed files with 1954 additions and 596 deletions

View File

@@ -3,6 +3,11 @@
Bug captured: schema_docs.yaml had values that began with a quote character
(e.g. `gender: 'M' or 'F'.`), which YAML treats as a quoted scalar — anything
after the closing quote is a parse error.
The YAML structure is now flat — tables.<name> is a description string,
columns are keyed `table.column`, and relationships are an explicit list.
The DDL structure (column types, nullability) lives in extracted_schema.json
generated by `make recon`.
"""
from pathlib import Path
@@ -20,6 +25,9 @@ def test_schema_docs_parses(dataset):
assert docs is not None
assert "tables" in docs
assert isinstance(docs["tables"], dict) and docs["tables"]
# New shape: each table value is a description string, not a dict.
for name, val in docs["tables"].items():
assert isinstance(val, str), f"tables.{name} should be a string description, got {type(val)}"
@pytest.mark.parametrize("dataset", DATASETS)
@@ -31,16 +39,24 @@ def test_metrics_parses(dataset):
def test_financial_columns_with_quotes_survive_parse():
"""Specific regression: values that contain quoted codes (M, F, OWNER,
PRIJEM, etc.) must parse without truncation."""
"""Values containing quoted codes (M, F, OWNER, PRIJEM, ...) must parse
without truncation. Columns are flat `table.col` keys now."""
docs = yaml.safe_load(
(DATASETS_DIR / "financial" / "schema_docs.yaml").read_text()
)
cols = docs["tables"]["client"]["columns"]
assert '"M"' in cols["gender"] and '"F"' in cols["gender"]
cols = docs["columns"]
assert '"M"' in cols["client.gender"] and '"F"' in cols["client.gender"]
assert '"OWNER"' in cols["disp.type"] and '"DISPONENT"' in cols["disp.type"]
assert '"PRIJEM"' in cols["trans.type"] and '"VYDAJ"' in cols["trans.type"]
disp = docs["tables"]["disp"]["columns"]
assert '"OWNER"' in disp["type"] and '"DISPONENT"' in disp["type"]
trans = docs["tables"]["trans"]["columns"]
assert '"PRIJEM"' in trans["type"] and '"VYDAJ"' in trans["type"]
def test_financial_has_relationships():
docs = yaml.safe_load(
(DATASETS_DIR / "financial" / "schema_docs.yaml").read_text()
)
rels = docs.get("relationships") or []
assert len(rels) >= 5 # we have 8; assert ≥5 to allow some pruning
# all entries have from/to
for r in rels:
assert "from" in r and "to" in r
assert "." in r["from"] and "." in r["to"]