fix(skills): wrap generate-mdl SKILL.md's relationships.yml example under the required key (#2676)

This commit is contained in:
Amir Fathi
2026-08-25 20:19:06 -06:00
committed by GitHub
parent 5cf36cd7aa
commit a8e8d04013
2 changed files with 48 additions and 6 deletions
@@ -213,12 +213,13 @@ From foreign key constraints discovered in Phase 2:
```yaml
# relationships.yml
- name: orders_customers
models:
- orders
- customers
join_type: many_to_one
condition: "orders.customer_id = customers.customer_id"
relationships:
- name: orders_customers
models:
- orders
- customers
join_type: many_to_one
condition: "orders.customer_id = customers.customer_id"
```
Join type mapping:
+41
View File
@@ -2369,6 +2369,47 @@ def test_validate_project_reports_relationships_bare_root(tmp_path: Path) -> Non
)
def _extract_fenced_yaml(markdown: str, heading: str) -> str:
"""Pull the first ```yaml fenced block under a markdown heading."""
after_heading = markdown[markdown.index(heading) :]
start = after_heading.index("```yaml") + len("```yaml")
end = after_heading.index("```", start)
return after_heading[start:end]
def test_generate_mdl_skill_step3_example_round_trips(tmp_path: Path) -> None:
"""The generate-mdl skill's own Step 2/Step 3 examples, fed to the real
loader/validator, must produce a clean project. Regression for #2672: Step 3
used to ship a bare top-level list, which load_relationships silently drops
and validate_project rejects."""
from wren.skills_delivery import get_skill # noqa: PLC0415
skill = get_skill("generate-mdl")
models_yaml = _extract_fenced_yaml(skill, "### Step 2 — Write model files")
relationships_yaml = _extract_fenced_yaml(skill, "### Step 3 — Write relationships")
_make_v2_project(tmp_path)
(tmp_path / "models" / "orders").mkdir(parents=True)
(tmp_path / "models" / "orders" / "metadata.yml").write_text(
models_yaml, encoding="utf-8"
)
(tmp_path / "models" / "customers").mkdir(parents=True)
(tmp_path / "models" / "customers" / "metadata.yml").write_text(
"name: customers\n"
"table_reference:\n table: customers\n"
"primary_key: customer_id\n"
"columns:\n - name: customer_id\n type: INTEGER\n",
encoding="utf-8",
)
(tmp_path / "relationships.yml").write_text(relationships_yaml, encoding="utf-8")
rels = load_relationships(tmp_path)
assert len(rels) == 1
assert rels[0]["name"] == "orders_customers"
assert validate_project(tmp_path) == []
def test_validate_project_relationship_indices_match_file(tmp_path: Path) -> None:
"""Junk at [0] must not renumber a later unnamed relationship's warnings."""
(tmp_path / "wren_project.yml").write_text("schema_version: 1\n", encoding="utf-8")