Introducing a new way to review your PRs.

Read the announcement

bruin-data / bruin

Build data pipelines with SQL and Python, ingest data from different sources, add quality checks, and build end-to-end flows.

View on GitHub

21 documents · Updated Nov 20, 2026

docs / quality-policy-linting

Quality policies and linting

Bruin validation checks that pipeline definitions and data contracts are safe to run. The bruin validate workflow combines built-in rules, repository policies, and optional query checks, then reports findings that either block validation or warn about risk. It is the quality layer for data governance and supports the dependency and metadata links described by data lineage and the semantic layer.

Validation model

Validation works on built pipeline models. It discovers the requested pipelines, assembles the available rules, and records each finding against a pipeline or an asset.

The linter uses three scopes:

LevelScopePurpose
PipelineOne complete pipelineCheck names, schedules, graph shape, notifications, variables, and pipeline settings.
AssetOne asset in a pipelineCheck metadata, files, materialization, sensors, columns, and asset quality declarations.
Cross-pipelineAll pipelines in the validation setCheck URI links and duplicate identities across pipeline boundaries.

Cross-pipeline checks run before individual pipeline checks. Single-asset validation stays narrow, but it can load the wider repository when the asset has a URI dependency.

References: pkg/…/level.go• L3-9 pkg/…/lint.go• L160-288 pkg/…/lint.go• L417-459 pkg/…/lint.go• L478-523

Rule severity

Each rule has a severity. Critical findings make validation fail. Warning findings describe a risk but do not fail an otherwise valid command. A failure to load a policy or build a rule is a command error, not a warning.

References: pkg/…/rules.go• L75-80 pkg/…/lint.go• L338-363 cmd/lint.go• L357-431

Rule speed

Rules also have a speed class. Fast rules inspect the pipeline model and local files. Slow rules render SQL, inspect query links, or ask a data platform to validate a query.

The --fast option keeps only fast rules. It gives quick local feedback, but it omits query checks and other slow rules. Policy rules remain active in this mode.

References: pkg/…/list.go• L31-363 pkg/…/list.go• L366-430 cmd/lint.go• L203-221

Policy definitions

Repository policy adds shared quality requirements without changing the default rule set. Bruin looks for policy.yaml or policy.yml at the Git repository root and applies it to pipelines validated from that repository.

Custom rules

A custom rule is a named Boolean expression with a description. An asset rule can use the asset, its pipeline, and pipeline variables. A pipeline rule can use the pipeline and its variables. The default target is an asset, while a rule can target the whole pipeline.

Rule names must use letters, numbers, and dashes. They must be unique and cannot replace a built-in policy rule.

References: pkg/…/policy.go• L32-40 pkg/…/policy.go• L75-121 pkg/…/policy.go• L144-169 integration-tests/policy.yml• L1-13

Rulesets and selectors

A ruleset groups rule names under one policy name. It can combine built-in policy rules with custom expressions. A selector limits the ruleset to matching pipelines or assets.

Selectors match pipeline names, asset names, executable or pipeline paths, and asset tags with regular expressions. All conditions in one selector must match. A ruleset without a selector applies to every matching target. Rules named by a ruleset become critical findings.

References: pkg/…/policy.go• L124-141 pkg/…/policy.go• L173-201 pkg/…/policy.go• L268-350 integration-tests/policy.yml• L15-69

Policy loading

Policy loading is repository-scoped. Validation continues without policy rules when the path is outside a Git repository or the repository has no policy file. An invalid YAML file, unknown rule, invalid expression, or invalid selector stops rule creation and validation.

The policy is loaded for each pipeline. One policy change can therefore affect every pipeline in that repository, while selectors decide which targets receive each requirement.

References: pkg/…/policy.go• L353-405 pkg/…/lint.go• L478-523

Built-in validation rules

Built-in rules protect the pipeline contract before execution. They check the pipeline graph, asset files, metadata, execution settings, relationships, and platform-specific limits. They also validate the semantic catalog when the repository uses one.

The main rule groups are:

Rule groupQuality concern
Names and dependenciesValid identities, existing dependencies, platform-supported asset-name shapes, and an acyclic graph.
Files and asset typesRequired executable files, supported types, asset directories, seed files, and sensor fields.
Metadata and columnsDescriptions, owners, tags, columns, types, foreign keys, glossary links, and duplicate declarations.
Execution settingsSchedules, dates, timeouts, concurrency, retries, notifications, variables, and materialization.
Hooks and ingestionSupported hook targets, ingestion settings, and platform-specific asset settings.
Semantic catalogValid semantic model definitions and model relationships used by the semantic layer.
Cross-pipeline linksEmpty, missing, or duplicate URI identities.
Query relationshipsTables used by SQL but absent from declared dependencies.

Most built-in rules are critical. Warning rules cover guidance or possible risk, such as unknown fields, regular YAML files in an asset directory, deprecated settings, and some relationship checks.

References: pkg/…/list.go• L31-364 pkg/…/rules.go• L82-136 pkg/…/rules.go• L1491-1701 pkg/…/rules.go• L2502-2563 pkg/…/semantic.go• L27-45

Platform-aware names and sensors

Database asset names and table-sensor targets must use a qualified-name shape supported by the target platform. The asset-name-component-count rule applies this contract to database assets and leaves non-database assets such as Python and Ingestr outside its scope. This check catches missing, empty, or extra name parts before a warehouse query or sensor run uses the identity.

Table sensors also require a table parameter. Query sensors for BigQuery and Snowflake require a non-empty query parameter. Sensor timeouts must use the supported single-unit duration form.

References: pkg/…/list.go• L39-45 pkg/…/list.go• L133-169 pkg/…/rules.go• L1970-2160 pkg/…/rules_test.go• L27-79 pkg/…/rules_test.go• L6097-6225

Ingestion contracts

Ingestr validation keeps source, destination, capture mode, and materialization settings within the supported contract. It requires the source connection and source table. It also requires either an explicit destination or a destination connection that resolves in the selected environment. It checks destination-specific incremental strategies and prevents incompatible materialization settings from reaching runtime.

When the destination is not explicit, linting infers it from the asset connection or destination_connection. If that connection is missing from the environment or is not a supported Ingestr destination, validation reports that unresolved destination instead of allowing later checks to fail without context.

CDC assets require merge behavior. Log-based CDC can use a wildcard source table, while SQL Server Change Tracking must name one table. The old cdc_mode setting produces a warning; streaming now uses stream: true. Version values must use a major marker or a full major-minor-patch form.

Chunked CDC snapshots are treated as a CDC-only ingestion mode. Linting checks their option types and positive limits, then requires merge behavior and rejects incompatible snapshot, incremental, and materialization settings. Parallel execution is required when WAL changes are staged at the destination; the default serial mode keeps pending changes in the source WAL.

On queryable destinations, the asset name is the warehouse identity. A different destination_table would split ingestion from quality checks and lineage, so validation blocks that mismatch. Non-queryable destinations can still use an override.

References: pkg/…/rules.go• L267-450 pkg/…/rules.go• L453-470 pkg/…/cdc_chunked.go• L13-126 pkg/…/rules_cdc_chunked_test.go• L11-54 pkg/…/rules_test.go• L2452-3524

Materialization contracts

Materialization rules keep table and view settings aligned with the selected asset type and strategy. They require strategy-specific keys and columns for merge, SCD2, time-interval, and Data Vault assets. They also reject platform options that the selected asset or view cannot use.

SCD2 strategies require a primary key. The time-based strategy also requires an incremental key. SCD2 history columns are reserved for the strategy. Data Vault strategies require the key, business, time, source, and hash-difference columns that define their table contract.

Ingestr materialization has a separate contract. It supports table materialization only, rejects incremental predicates, limits incremental keys to supported strategies, and reports conflicting settings when both asset parameters and materialization fields define different values.

Inference assets use their own asset contract during validation, while Python and Ingestr assets do not enter the regular SQL materialization checks. This keeps each asset type aligned with the fields its runtime supports.

BigQuery table options are checked through the same validation boundary used by materialization. This keeps validation and execution aligned for partition and table settings.

References: pkg/…/rules.go• L480-581 pkg/…/rules.go• L1533-1770 pkg/…/rules.go• L1772-1968 pkg/…/rules_test.go• L1284-1921 pkg/…/rules_test.go• L1923-2122

Seed and executable files

File rules confirm that an executable exists and is a usable file. Seed rules require a path and accept local or remote seed sources. Supported formats include CSV, Parquet, JSON, JSONL, NDJSON, and Avro. CSV seeds compare declared columns with the header without regard to case. Non-CSV formats leave schema checks to runtime ingestion, while Spark seed assets remain CSV-only.

References: pkg/…/rules.go• L171-221 pkg/…/rules.go• L849-971 pkg/…/rules_test.go• L166-474 pkg/…/rules_test.go• L5765-6095

Metadata and relationship checks

Metadata rules check that column links point to real assets and columns when the target declares its schema. They also validate type details, duplicate columns and tags, and the relationship between a relationship check and its foreign-key metadata.

A blocking relationship check that points to a downstream asset receives a warning because it can run before that asset refreshes. URI identities, declared dependencies, foreign keys, and query source tables must describe the same flow for validation and lineage to agree. See data lineage for the wider relationship model.

References: pkg/…/rules.go• L1086-1277 pkg/…/rules.go• L1280-1316 pkg/…/rules.go• L2502-2563 pkg/…/rules_test.go• L3938-4228

Notification and hook checks

Notification rules check that targets are present and unique at pipeline, asset, custom-check, and column-check levels. Hook rules limit hooks to supported SQL assets and distinguish inherited default hooks from asset-level hook settings.

References: pkg/…/rules.go• L1375-1537 pkg/…/rules.go• L793-847 pkg/…/rules_test.go• L1134-1282

Query checks

Query checks validate executable SQL and declared SQL metadata at the boundary between a pipeline definition and a data platform. They use the selected environment and the asset connection when a matching platform validator is available.

SQL dry-run checks

For supported SQL assets, Bruin extracts and renders the query with pipeline values and macros. It applies materialization when needed, then asks the selected platform to validate the resulting query without running it.

The check reports extraction, rendering, missing-query, materialization, hook, and warehouse errors. If a script contains several queries and the target cannot validate that form safely, Bruin skips query validation for that script instead of treating each statement as a full asset query.

References: cmd/lint.go• L484-558 pkg/…/query.go• L80-186 pkg/…/query.go• L333-387

Semantic model checks

When a repository has a semantic catalog, validation checks both the catalog structure and the SQL generated by queryable semantic models. The catalog check runs at pipeline and asset scope, so a single-asset command does not bypass a repository-level semantic error.

The semantic query check uses a suitable SQL connection from the selected environment and dry-runs each queryable model without executing it. A selected asset's connection is preferred for asset-scoped validation, which keeps the check aligned with the asset's SQL dialect.

References: pkg/…/list.go• L357-364 cmd/lint.go• L210-215 pkg/…/semantic.go• L48-75 pkg/…/semantic.go• L79-124

Custom checks and hooks

Custom checks are runtime data-quality queries attached to an asset. Linting first requires a query, then renders and dry-runs each non-empty query when the asset has a supported connection. This proves that the platform can read the query; it does not run the data check.

SQL hooks follow the same query validation path. BigQuery validates the full materialized script so shared query scope stays valid. Other supported SQL assets validate pre- and post-hooks separately. Hooks on script assets are rejected because the runtime does not support them.

References: pkg/…/rules.go• L741-753 pkg/…/rules.go• L2124-2278 pkg/…/rules.go• L793-815

Query-to-column checks

The query-matches-columns policy compares columns found in rendered SQL with columns declared in asset metadata. It reports both missing declarations and stale declarations.

The check uses upstream schemas and column links. It depends on successful template rendering and SQL parsing. It applies to SQL assets and complements the separate used-tables warning, which checks whether query source tables appear in declared dependencies.

References: pkg/…/policy_builtins.go• L500-590 pkg/…/rules.go• L2349-2407

Dry-run limits

Dry-run validation needs referenced tables, views, and columns to exist in the selected destination. A new asset or column can therefore fail a dry-run before the destination schema is updated.

Use fast validation for local structure checks. Use a configured environment for query checks when the destination schema is ready. Treat a dry-run finding as a platform query signal rather than proof that the repository contract is wrong.

References: docs/…/validate.md• L34-45 pkg/…/query.go• L151-184

Validation workflows

The bruin validate command is the main entry point for quality checks. It loads configuration and the selected environment, creates the rule set, discovers pipelines, and validates either all pipelines under a path or one asset.

The main workflows are:

WorkflowCommand shapeUse
Repository or directory validationbruin validate [path]Check every discovered pipeline under a path.
Single-asset validationbruin validate path/to/assetCheck the target asset and relevant cross-pipeline URI rules.
Fast feedbackbruin validate --fast [path]Run fast rules without slow query checks.
Machine-readable reportingbruin validate --output json [path]Send structured results to tools and CI.
Scoped validationbruin validate --exclude-paths path/to/skip [path]Skip selected paths during discovery.

The command also supports an environment, variable overrides, a variant, full-refresh mode, an exclude tag, and a config-file path. An exclude tag skips matching assets during repository validation. It is not supported for single-asset validation.

References: cmd/lint.go• L53-107 cmd/lint.go• L109-240 cmd/lint.go• L242-334 docs/…/validate.md• L6-32 docs/…/validate.md• L47-73

Environment and asset selection

The selected environment resolves connections and decides which platform query checks can run. Variable overrides, variant selection, and full-refresh mode change the materialized pipeline that the rules inspect.

When the argument names an asset, Bruin finds its containing pipeline and narrows the rule set to asset and relevant cross-pipeline rules. URI dependencies can widen lookup to the repository root. A scoped run can select assets while keeping the full pipeline model available for upstream resolution. An empty selection produces no asset-level findings.

References: cmd/lint.go• L118-197 cmd/lint.go• L229-234 cmd/lint.go• L246-334 pkg/…/lint.go• L160-288 pkg/…/lint_test.go• L809-851

Validation reporting

Plain output groups findings by pipeline and asset. Pipeline findings appear apart from asset findings. Each issue includes its rule name and may include context such as paths, dependency names, or mismatched columns.

JSON output groups issues by pipeline and asset name. Pipeline-level issues use _pipeline as the asset key. Each issue includes its description, context, and severity, which makes the format suitable for CI and other tools.

References: pkg/…/print.go• L34-96 pkg/…/lint.go• L366-415

Exit status

The command prints critical and warning counts. Any critical finding returns validation failure. Warnings return success unless another critical finding exists.

Errors while loading pipelines, reading policy, creating rules, or writing structured output use the command-error path and return a non-zero result. This is different from a rule finding, which is a normal validation result.

References: cmd/lint.go• L332-352 cmd/lint.go• L357-431 pkg/…/lint.go• L417-459

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to rule severity or speed must stay aligned with --exclude-warnings, --fast, exit status, and asset-only validation.
  • Changes to policy targets or selector keys must stay aligned with expression inputs and pipeline-versus-asset JSON grouping.
  • Changes to built-in policy names must be checked against repository policy files because custom rules cannot use those names.
  • Changes to query rendering, materialization, hooks, or connection selection must be checked against SQL dry-runs, custom-check validation, and query-matches-columns.
  • Changes to semantic catalog loading or semantic query validation must stay aligned with pipeline-scoped and asset-scoped validation, selected SQL connections, and the semantic layer.
  • Changes to URI or dependency resolution must be checked against cross-pipeline validation, asset-only lookup, selected-asset validation, and data lineage.
  • Changes to ingestion destination inference, destination names, destination-specific strategies, CDC capture modes, or source-table handling must stay aligned with runtime ingestion and warehouse identity checks.
  • Changes to chunked CDC snapshot options must stay aligned with the CDC validator, merge-only materialization, WAL staging and execution modes, and the incompatibility checks for snapshot and incremental settings.
  • Changes to platform table-name capabilities must be checked against both asset names and table-sensor targets.
  • Changes to seed format support must stay aligned with runtime ingestion. Keep CSV header checks separate from non-CSV schema handling.
  • Changes to SCD2, Data Vault, or inference asset contracts must keep required keys, reserved columns, and strategy-specific roles aligned with materialization or inference execution.

Important failure modes

TriggerConsequenceGuard
A policy has invalid YAML, an unknown rule, an invalid expression, or an invalid selectorRule creation fails and validation stopsKeep policy names, expressions, and selectors valid and reference existing rules.
A selector does not match the intended path, name, or tagThe requirement is skipped for that targetCheck selector scope with a representative pipeline and asset.
--fast is used when query checks are requiredValidation can pass without checking executable SQL or semantic model queriesRun full validation before merge or release checks.
The selected environment has no matching connectionThe related warehouse or semantic query validator is not addedSelect an environment with the required connection.
A dry-run references a table or column not yet in the destinationQuery validation reports a platform error for an intentional repository changeUpdate the destination schema first or treat the finding as a dry-run limit.
A semantic catalog is invalidPipeline or asset validation reports a semantic catalog errorKeep semantic model definitions valid and run validation after catalog changes.
A database asset name or table-sensor target has an unsupported qualified-name shapeA critical name or sensor rule blocks validationMatch each identity to the target platform's supported form.
An Ingestr asset has neither an explicit destination nor a connection that resolves to a supported destinationValidation cannot determine where the asset writesSet destination or use connection or destination_connection in the selected environment.
An Ingestr asset uses a different queryable destination_table or an unsupported destination strategyIngestion and quality checks use different identities or runtime behaviorUse the asset name as the queryable table identity and match the strategy to the destination and table.
SQL Server Change Tracking uses source_table: "*"Validation blocks a multi-table capture path that supports one table onlyName one source table or use log-based CDC for wildcard capture.
A CDC asset uses a strategy other than mergeValidation blocks a capture path that cannot apply changes safelyUse merge and keep capture settings consistent.
Chunked CDC snapshot settings are used without cdc: true, with serial destination WAL staging, or with incompatible incremental or snapshot settingsValidation blocks the ingestion contract before runtimeEnable CDC, use parallel execution for destination staging, and remove the conflicting settings.
A seed uses an unsupported format or a Spark seed is not CSVValidation blocks the seed before runtime ingestionUse a supported format and keep Spark seeds in CSV form.
An SCD2 or Data Vault asset lacks required keys or declares reserved columnsMaterialization validation blocks the table contractAdd the required roles and keys and leave generated history columns reserved.
Query columns and asset metadata drift apartquery-matches-columns reports missing or extra columnsChange SQL and declared columns as one contract.
A blocking relationship check points downstreamThe check can run before the referenced asset refreshesMake the check non-blocking or change the dependency direction.
Only warning findings remainValidation reports issues but exits successfullyReview warnings as quality work. Do not hide them unless the workflow allows it.

Key files

FileWhy to read it
cmd/lint.goDefines the bruin validate workflow, flags, environment setup, query-rule selection, asset selection, and exit behavior.
pkg/…/level.goDefines pipeline, asset, and cross-pipeline scope.
pkg/…/lint.goShows discovery, rule application, selected-asset scope, issue counts, and cross-pipeline checks.
pkg/…/list.goDefines default rules, severity, speed, semantic checks, and rule filters.
pkg/…/policy.goDefines policy files, custom expressions, rulesets, selectors, and policy loading.
pkg/…/policy_builtins.goDefines reusable metadata, pipeline, relationship, and query-to-column policies.
pkg/…/rules.goDefines structural, metadata, dependency, ingestion, sensor, materialization, seed, inference, and platform-aware checks.
pkg/…/cdc_chunked.goDefines the shared contract for chunked CDC snapshot options that linting checks before runtime.
pkg/…/rules_cdc_chunked_test.goShows the lint contract for valid and conflicting chunked CDC snapshot settings.
pkg/…/semantic.goDefines semantic catalog validation and dry-runs for queryable semantic models.
pkg/…/query.goDefines SQL extraction, rendering, materialization, hooks, and warehouse dry-runs.
pkg/…/print.goDefines plain and JSON reporting.
pkg/…/rules_test.goShows the expected contracts for names, sensors, ingestion, materialization, seeds, columns, and relationships.
docs/…/validate.mdGives user-facing command syntax, flags, dry-run limits, and examples.
integration-tests/policy.ymlShows custom rules, built-in policy rules, and selector-scoped rulesets.