Skip to content

feat(wren-core): validate cubes in AnalyzedWrenMDL::analyze#2264

Merged
goldmedal merged 2 commits into
feat/wasm-cubefrom
worktree-plan-0513-174102
May 14, 2026
Merged

feat(wren-core): validate cubes in AnalyzedWrenMDL::analyze#2264
goldmedal merged 2 commits into
feat/wasm-cubefrom
worktree-plan-0513-174102

Conversation

@goldmedal
Copy link
Copy Markdown
Collaborator

@goldmedal goldmedal commented May 13, 2026

Summary

  • Reject manifests with a cube whose baseObject doesn't resolve to a known Model or View.
  • Detect circular derived-measure dependencies inside a cube via petgraph cycle detection on measure expressions.
  • Reject hierarchy levels that don't reference a defined dimension or time_dimension.
  • Hook validate_cubes into all three AnalyzedWrenMDL entry points (analyze, analyze_with_tables, analyze_with_url_tables) so every caller path is covered.

Test plan

  • RUST_MIN_STACK=8388608 cargo test --lib --tests --bins — 83 tests pass (4 new + 79 prior)
  • cargo clippy --all-targets --all-features -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • New unit tests cover: valid cube, unknown baseObject, measure cycle, bad hierarchy level
  • Verify CI passes on the wren-core path-filtered workflow

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements

    • Strengthened cube validation to detect circular or self-referential measure dependencies, ensure cubes reference existing base models/views, and verify hierarchy levels reference defined dimensions.
  • Tests

    • Added unit tests covering valid cube configurations and error cases: unknown base objects, circular measure dependencies, self-references, and invalid hierarchy references.

Review Change Stack

Reject manifests whose cubes reference an unknown baseObject, have
circular derived-measure expressions, or list a hierarchy level that
isn't a defined dimension or time_dimension. Validation runs from all
three analyze entry points so any caller path catches the error before
lineage is built.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 714c9720-8e13-41cb-bb92-d99faf584a5d

📥 Commits

Reviewing files that changed from the base of the PR and between 9fdd73d and 1a0a416.

📒 Files selected for processing (1)
  • core/wren-core/core/src/mdl/lineage.rs

Walkthrough

This PR adds cube-level validation to MDL analysis: a new validate_cubes checks each cube's base_object resolves to a Model/View, enforces acyclic measure dependencies, and verifies hierarchy levels reference defined dimensions. The validation runs in all three analysis entry points before Lineage creation.

Changes

Cube-level validation

Layer / File(s) Summary
Cube validation implementation
core/wren-core/core/src/mdl/lineage.rs
Cube type imported. New validate_cubes iterates cubes to validate base_object resolution, hierarchy level references, and invokes validate_measure_cycles which builds a measure dependency graph and errors on non-DAGs (including self-references).
Validation integration into analysis pipeline
core/wren-core/core/src/mdl/mod.rs
Calls to lineage::validate_cubes(&wren_mdl)? inserted before Lineage creation in analyze, analyze_with_tables, and analyze_with_url_tables.
Cube validation test cases
core/wren-core/core/src/mdl/lineage.rs
Test imports expanded; unit tests added for a valid cube and error cases: unknown base_object, circular measure dependency, self-referential measure, and hierarchy referencing an unknown dimension.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop through MDL fields, checking each cube's art,
Seeking bases and measures that play their part.
No looping measures nor missing dimension tune,
I twitch my nose and pass them — validation soon!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding cube validation to the AnalyzedWrenMDL::analyze flow, which aligns with the primary objective of validating cubes before lineage analysis.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-plan-0513-174102

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added rust Pull requests that update rust code core labels May 13, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/wren-core/core/src/mdl/lineage.rs`:
- Around line 355-361: The current code skips adding edges for self-referential
identifiers (ident.name.as_str() != measure.name), which lets self-loops bypass
is_dag() detection; either remove the != measure.name condition so
graph.add_edge(from, to, ()) will add self-loop edges and let is_dag() catch
them, or add an explicit validation before this loop that checks if
ident.name.as_str() == measure.name and returns/reports an error for the measure
(e.g., using the same error path the caller expects); locate the check using the
symbols measure.name, ident.name, measure_names, node_map and
graph.add_edge/is_dag() to implement the chosen fix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 18e3a73c-e967-4d10-9569-1348067261e9

📥 Commits

Reviewing files that changed from the base of the PR and between fa70ed8 and 9fdd73d.

📒 Files selected for processing (2)
  • core/wren-core/core/src/mdl/lineage.rs
  • core/wren-core/core/src/mdl/mod.rs

Comment thread core/wren-core/core/src/mdl/lineage.rs Outdated
Dropping the != measure.name guard lets is_dag see self-loops, so a
measure defined in terms of itself (e.g. revenue = revenue * 1.1) is
now rejected instead of silently passing. Adds a regression test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@goldmedal goldmedal changed the base branch from main to feat/wasm-cube May 14, 2026 01:24
@goldmedal goldmedal merged commit 9baada5 into feat/wasm-cube May 14, 2026
18 checks passed
@goldmedal goldmedal deleted the worktree-plan-0513-174102 branch May 14, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant