Skip to content

Enforce model required filters across query clients - #430

Merged
nicosuave merged 4 commits into
mainfrom
model-required-filters
Oct 19, 2026
Merged

nicosuave merged 4 commits into
mainfrom
model-required-filters

Conversation

@nicosuave

Copy link
Copy Markdown
Member

Add model-level required_filters and required_filters_or_groups so queries fail clearly when a participating model's required fields are neither filtered nor, where allowed, grouped. Structural field matching covers time grains, segments, Explore filters, metric dependencies, intermediate joins, and SQL aliases/scopes before Python or Rust dispatch.

Preserve the policies through YAML round trips and inheritance. CLI, HTTP, MCP, and standard semantic SQL share enforcement; raw bypasses and Yardstick SQL are rejected for policy graphs. Standalone native runtimes remain unsupported and exported definitions retain the policies.

Fixes #422.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T20:39:55.637818Z fc4affd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc4affd9d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/core/model.py
Comment on lines +54 to +56
required_filters: list[str] = Field(default_factory=list, description="Fields callers must filter")
required_filters_or_groups: list[str] = Field(
default_factory=list, description="Fields callers must filter or group by, independently for each field"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Invalidate cached SQL when required policies change

These mutable policy lists can be changed after a model is added, but such mutation does not increment SemanticGraph._version, which is the only graph state included in SemanticLayer.sql()'s rewrite-cache key. If an SQL query is cached before required_filters is assigned or appended—or after it is changed to require another field—the next identical layer.sql() call reuses the cached rewrite without invoking validate_required_filters_sql, allowing the new obligation to be bypassed. Include these policies in cache invalidation or prevent untracked mutation.

Useful? React with 👍 / 👎.

@nicosuave
nicosuave merged commit ac8f243 into main Oct 19, 2026
28 checks passed
@nicosuave
nicosuave deleted the model-required-filters branch October 19, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: model-level required filters

1 participant