Repository navigation
feat(compliance): grade key and relationship portability - #699
MikeNitsenko wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
_collect_structure()will raiseKeyError(orTypeErroronlen(...)) if a returned document… · NewElement.declarationis used with different tuple shapes (e.g., keys vs relationships). That makes… · New This assumesprimary_key/ eachunique_keysentry is an iterable of column names. If a… · New This test assumes the firstrelationshipfinding is the one under test. To avoid… · New
What changed in this PR
Extends the portability grader to evaluate structural declarations (keys and relationships) alongside expressions, adding a dedicated K0 fixture, tests, and CI validation to prevent structural regressions in converter round-trips.
Changes:
- Collects and grades
keyandrelationshipdeclarations (including key roles, compound grouping, and join-column pairings). - Adds K0 structural fixture and comprehensive structural grading tests (including diagnostics/scoping and CLI JSON output).
- Wires portability grader tests + K0 fixture validation into CI and updates documentation/manifest wording.
| File | Description |
|---|---|
| compliance/portability/manifest.yaml | Updates outcome descriptions and registers the new structural rung K0 and its elements. |
| compliance/portability/k0/k0_compound_keys.ossie.yaml | Adds standalone K0 fixture with compound keys and a compound relationship join. |
| compliance/portability/grader/test_structure.py | Introduces structural grading tests covering keys/relationships, ambiguity rules, diagnostics, and fixture/manifest alignment. |
| compliance/portability/grader/grade.py | Implements structural collection, structural repair pairing, and surrogate-diagnostic handling for keys. |
| compliance/portability/grader/README.md | Documents structural grading rules (naming/comparison/diagnostic requirements) and how to run tests. |
| compliance/portability/README.md | Links the K0 rung and structural grading rules into the portability ladder docs. |
| .github/workflows/validation-ci.yml | Runs portability grader tests and validates the K0 fixture in CI; expands workflow path filters to portability files. |
Review effort: Lite
|
@jbonofre could you please take a look when you get a chance? thanks! |
christianeu-db
left a comment
There was a problem hiding this comment.
Thanks @MikeNitsenko! Left two comments; the fixture version needs fixing before merge, and I'll take another look once this is rebased onto #631.
christianeu-db
left a comment
There was a problem hiding this comment.
Thanks @MikeNitsenko, both points are addressed. I'll take another look and approve once #631 lands and this is rebased onto it.
kayemkim
left a comment
There was a problem hiding this comment.
The new validation step covers k0 only, so the ladder fixtures under m*/ still never run through validate.py in CI (eight on main, thirteen once #631 is in). One glob covers them all, and on the merge with main it passes 9 of 9:
- name: Validate portability fixtures
run: uv run validation/validate.py compliance/portability/*/*.ossie.yamlmake compliance-validate globs m*/, so k0 is not in it either; the same glob there would keep the two in step.
d7aa6f2 to
9366204
Compare
9366204 to
b494f1b
Compare
kayemkim
left a comment
There was a problem hiding this comment.
Two cases from real converter returns, inline. They come from the interop run on ossie-converters#247 with this branch as the submodule. On the same returns the metric and field findings are the same as with main's grader.
| repaired = _repair_by_expression(dropped, added_elements, owners, aliases) | ||
| repaired_in = {id(a): b for a, b in repaired} | ||
| repaired_out = {id(b) for _, b in repaired} | ||
| structural_repairs = _repair_by_structure(dropped, added_elements) |
There was a problem hiding this comment.
Keys and relationships do not follow a dataset the converter renamed, though expressions do. lightdash returns M4's sales as orders, after its source table, and the relationship comes back as orders_to_customers:
relationship sales_to_customer DROPPED_SILENT
relationship orders_to_customers ADDED
The fields and the metric of that dataset grade REWRITTEN through _dataset_aliases, and the converters that only rename this relationship (cube, dbt, omni and others) get "identity not preserved". In a hand-made return a key does the same: sales.primary_key dropped, erp_sales.primary_key added. Could the returned declarations go through aliases before they are compared? With that, this case grades "identity not preserved: returned as 'orders_to_customers'" and the suite still passes.
| for part in parts: | ||
| remaining.remove(part) | ||
| pending.remove(element) | ||
| # A changed alternate key has no stable name. Match only one missing key to |
There was a problem hiding this comment.
This pairs a dropped key with a restated primary key. thoughtspot returns K0 without [area_code] and with the primary key repeated under unique_keys:
key customer_sales_area.unique_keys["area_code"] REWRITTEN review: key columns changed to ('customer', 'distr_channel', 'division', 'sales_org')
The key was dropped. honeydew repeats the primary key the same way and gets ADDED for it. Leaving out a returned unique key whose columns are the dataset's returned primary key gives DROPPED_SILENT plus ADDED here, and the suite still passes.



The portability grader can report unchanged PORTABLE findings after a converter removes keys and relationships, truncates a compound key, or changes a join's column pairing. Collect and grade these declarations alongside expressions.
Closes #693.
Changes
Expression classification is unchanged. This compares declarations, not warehouse data. No runtime dependencies or schema changes.
Integration with #631
Draft while #631 is pending, following the discussion on #693. Targets current main; K0 stays separate from M0–M6.
The combined grader and fixtures passed 54 tests in a temporary checkout after resolving the two small _collect overlaps and expanding #631's manifest kind allowlist to key and relationship. These integration edits will be applied on rebase after #631 lands. Its pending implementation is not included here.
Validation
AI assistance
Prepared with AI assistance (Codex).