Skip to main content

semantic-view-guard

Lint and score Snowflake semantic models — native SEMANTIC VIEW DDL and Cortex Analyst YAML — for correctness and AI-readiness. Warehouse-free. Works in GitHub and GitLab CI.

svguard is a CLI + CI integration that treats your semantic layer like code: it parses your semantic views, runs lint rules (missing comments, missing synonyms, orphan relationships, tables without primary keys), and produces a transparent AI-readiness score (0–100) so a Cortex agent gets clean, well-described, joinable metadata.

It fills a gap in the ecosystem:

Tool What it governs
dbt-semguard dbt MetricFlow semantic layer YAML
dbt-sf-ai Creates Snowflake AI objects (doesn't govern them)
semantic-view-guard Snowflake SEMANTIC VIEW DDL + Cortex Analyst YAML — correctness + AI-readiness

Why

Snowflake semantic views power Cortex Analyst / Agents. Their quality (comments, synonyms, keys, relationships) directly determines how well an agent answers natural-language questions — but nothing lints them today. svguard makes that quality visible and enforceable in CI.

Install

pip install semantic-view-guard

Quick start

# From a dbt manifest (reads materialized='semantic_view' nodes)
svguard lint --manifest target/manifest.json

# Zero dbt / zero warehouse — parse raw .sql model files directly
svguard lint --sql "models/**/semantic_views/**/*.sql"

# Cortex Analyst YAML semantic models
svguard lint --analyst-yaml "semantic_models/**/*.yml"

# Mix sources, gate on score, emit JSON
svguard lint --manifest target/manifest.json \
             --analyst-yaml "semantic_models/**/*.yml" \
             --min-score 80 --reporter json --output svguard.json

Exit code is non-zero if any rule set to error fires, or any view falls below --min-score.

Example output

## semantic-view-guard

**FAILED** — 13 view(s), 4 error(s), 0 warning(s)

| Semantic view | Source | Score | Errors | Warnings | Status |
|---|---|---:|---:|---:|---|
| `sv_fact_arr`             | ddl | 100 | 0 | 0 | PASS |
| `sv_fact_avatax_txn`      | ddl | 100 | 1 | 0 | FAIL |
| `sv_hex_connections`      | ddl | 100 | 0 | 0 | PASS |

How it works

 SEMANTIC VIEW DDL  ──►  DDL parser   ─┐
 (manifest / .sql)                     ├─►  Canonical model ──► Rules engine ──► Findings + Score ──► Reporter
 Cortex Analyst YAML ─►  YAML parser  ─┘     (tables, columns,    (source-aware)      (markdown │ json │ gitlab)
                                              comments, synonyms,
                                              relationships, keys)

The DDL parser is a tolerant, hand-rolled section parser (no warehouse, no full SQL grammar): it splits a body into TABLES / RELATIONSHIPS / FACTS / DIMENSIONS / METRICS / COMMENT clauses and extracts PRIMARY KEY, WITH SYNONYMS, and COMMENT. Unparseable fragments become an SV000 parse-warning rather than a crash.

Rules

Code Category Default Checks
SV001 structural error table missing PRIMARY KEY
SV002 structural error relationship references a table not in TABLES(...)
SV003 structural error relationship join-key arity mismatch
SV004 structural error column references an undeclared table
SV010 ai-readiness warn table/column missing COMMENT
SV011 ai-readiness warn column missing WITH SYNONYMS
SV012 ai-readiness warn low synonym coverage across the view
SV013 ai-readiness warn comment too short / echoes the column name
SV014 ai-readiness warn view missing top-level COMMENT
SV020 governance off column name looks like PII
SV022 governance off DDL missing COPY GRANTS
SV000 parser warn a fragment could not be parsed

AI-readiness score

Transparent weighted coverage (configurable), shown with sub-scores:

sv_fact_avatax_txn — 100/100  (documentation 100% · synonyms 100% · structure 100% · richness 100%)
Component Default weight Measures
documentation 0.35 share of tables + columns + the view with a COMMENT
synonyms 0.30 share of tables + columns with WITH SYNONYMS
structure 0.25 PKs present, relationships resolvable, columns map to declared tables
richness 0.10 comments meeting min length and not echoing the column name

Configuration

.semantic-view-guard.yml at repo root:

rules:
  SV001: error
  SV011: warn
  SV020: "off"        # quote off/on — YAML parses them as booleans
thresholds:
  min_score: 0
  synonym_coverage: 0.8
  min_comment_length: 15
weights:
  documentation: 0.35
  synonyms: 0.30
  structure: 0.25
  richness: 0.10

Inline suppression in a model body:

-- svguard:disable SV011, SV013

CI

  • GitHub Actions: see action.yml — runs svguard and posts a sticky PR comment.
  • GitLab CI: see examples/gitlab-ci.yml — posts a sticky MR note and emits a Code Quality artifact (inline MR annotations).

Roadmap

  • v1.1 — diff mode: compare a PR against the base branch and classify semantic changes as breaking / risky / safe.
  • v2 — optional --verify-deployed (DESCRIBE SEMANTIC VIEW against a live account) and a thin dbt-package wrapper.

License

Apache-2.0.

Metadata

Release files for semantic-view-guard 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semantic-view-guard 0.1.0
File Size Uploaded Provenance Actions
semantic_view_guard-0.1.0.tar.gz 26.1 kB With provenance Details for semantic_view_guard-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for semantic-view-guard 0.1.0
File Interpreter ABI Platform Actions
semantic_view_guard-0.1.0-py3-none-any.whl Python 3 none any Details for semantic_view_guard-0.1.0-py3-none-any.whl

Total release size: 55.8 kB

Release files / semantic_view_guard-0.1.0.tar.gz

Download URL semantic_view_guard-0.1.0.tar.gz
Size 26.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ad89db55afd8fdb232f352560ad29398cf3a7174f5eac688377122b05611c6f0
BLAKE2b-256 checksum
How to use checksums
f3a3cdb96b9022ae5629b47f846f23c9876cde3d5807826cc01abdaa2ec58959
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.

Transparency log

Release files / semantic_view_guard-0.1.0-py3-none-any.whl

Download URL semantic_view_guard-0.1.0-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2a63bb4d66b1864391aa00ee370025d35f8b5fd2b8314d84ca99a5b1bf48845
BLAKE2b-256 checksum
How to use checksums
d25ce0975720dd0a0b29f2fab4eb2052d14e49f9f6ab126ed716511bae4b3d25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.

Transparency log

Security for semantic-view-guard 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for semantic_view_guard-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page