Data governance and metadata
Bruin brings quality rules, data relationships, and business meaning into the pipeline model. Asset metadata describes what data means and who owns it. Quality controls check whether the pipeline and its data meet agreed requirements. Lineage shows how assets and columns relate. Semantic models give users a shared way to ask for trusted dimensions and metrics.
Governance model
Governance starts with metadata stored alongside each asset. That metadata can guide validation, describe ownership and business domains, identify keys, and record column-level meaning. The same asset relationships then support execution order, lineage views, catalog metadata, and semantic queries.
The main capabilities form one connected path:
flowchart LR
A[Asset definitions] --> M[Metadata]
A --> Q[Quality controls]
A --> L[Asset and column lineage]
M --> C[Catalog and discovery]
L --> I[Impact understanding]
S[Semantic models] --> R[Business queries]
M --> S
Quality policies focus on whether definitions and pipeline structure are acceptable. Runtime quality checks focus on the data produced by an asset. Lineage and semantic models add context so users can trace a result and use consistent business terms.
Asset metadata
Metadata scope
An asset definition is the shared contract for pipeline behavior and data meaning. It can identify the asset with a name or URI, describe its purpose, assign an owner and domain, add tags or custom metadata, define columns and types, mark keys, and attach quality checks. Column metadata can also carry ownership, domains, tags, masks, and references to upstream columns. See the asset definition schema for the full field reference.
This metadata has both human and system value. People use descriptions, ownership, and domains to find and understand data. Bruin uses dependencies and keys to order work and to connect data relationships. Metadata does not replace the asset's query or code. It gives those executable parts a clear contract.
References: docs/…/definition-schema.md• L1-13 pkg/…/pipeline.go• L842-873 pkg/…/pipeline.go• L1302-1334
Metadata inheritance
Lineage can add discovered column relationships to the metadata already declared on an asset. When several paths describe the same output column, Bruin keeps explicit descriptions and types, then fills missing context from upstream columns and combines tags, domains, and ownership where needed. Derived columns do not inherit upstream checks or key behavior as if they still applied to the source column.
This makes lineage useful for discovery without turning source rules into downstream rules. A downstream asset still needs its own checks and business decisions.
References: pkg/…/lineage.go• L200-224 pkg/…/lineage.go• L279-370 pkg/…/lineage.go• L421-474
Quality controls
Policy linting
Policy linting checks pipeline and asset definitions before execution. A policy can use built-in rules or named custom rules. A ruleset selects which rules apply and can limit them by pipeline, asset, path, or tag. The result is a set of reported issues that can stop validation and show where the contract is not met. See quality policies and linting for the detailed policy workflow.
Validation can cover all pipelines, one asset, or a selected set of assets. A selected set limits asset-level checks but does not hide the rest of the pipeline from dependency resolution. A single-asset validation also runs cross-pipeline checks when the asset has URI dependencies. When given a repository root, it uses that wider scope to resolve sibling pipelines; if the wider load fails, it keeps the asset's own pipeline as a safe fallback.
The built-in checks cover both metadata and pipeline safeguards. They check required descriptions, owners, columns, keys, tags, valid column types, naming conventions, notifications, retries, and metadata publication. They also check column relationships and type details when those metadata fields are present. Relationship metadata must name a target asset and, when that asset declares columns, a target column. A relationships check must have foreign-key metadata. Numeric type details must use valid precision, length, and scale values. Duplicate column names and duplicate tags are rejected without regard to case. A warning identifies a blocking relationship check that points to a downstream asset whose refreshed data is not yet available. A query-aware rule can also compare the columns declared in an asset with the columns found in its SQL. Ingestr update and delete strategies are accepted for reverse-ETL destinations such as Salesforce and rejected for destinations that do not support reverse ETL. CDC assets accept stream or batch mode, while use of the older cdc_mode setting produces a deprecation warning. Chunked CDC snapshot settings are checked for valid values and compatible CDC, execution, staging, and merge behavior. Queryable ingestion destinations cannot override the asset name with a different destination table because name-based checks and lineage rely on that identity. ClickHouse table settings also receive lint checks so physical keys, indexes, and projections stay valid and consistent with the table definition.
Rules are grouped by the scope and speed of the validation they perform. Fast rules can run without data access. Slower rules can inspect rendered queries or perform checks that need external context. Warning rules report risks without carrying the same stop condition as critical rules. An exclusion tag can skip asset-level checks for marked assets while the run still reports how many assets it excluded.
References: pkg/…/lint.go• L129-157 pkg/…/lint.go• L160-281 pkg/…/lint.go• L417-524 pkg/…/list.go• L19-30 pkg/…/list.go• L159-234 pkg/…/rules.go• L266-421 pkg/…/rules.go• L424-470 pkg/…/rules.go• L1079-1309 pkg/…/rules.go• L1540-1570 pkg/…/rules_cdc_chunked_test.go• L11-54 pkg/…/rules_test.go• L1284-1500 pkg/…/rules_test.go• L3388-3524 pkg/…/rules_test.go• L4188-4566 pkg/…/lint_test.go• L644-851
Runtime data checks
Runtime quality checks test data after an asset runs. They can apply to columns or to the asset as a whole. A blocking failure marks the asset as failed and prevents dependent assets from running. A non-blocking failure records the problem without stopping downstream work. Checks can also run on their own, which lets an engineer review data quality without executing the asset again. See quality checks for the check behavior.
Policy linting and runtime checks protect different boundaries. Linting asks whether the pipeline definition is fit to run. Runtime checks ask whether the produced data is fit for its consumers.
References: docs/…/overview.md• L1-5 docs/…/overview.md• L21-47 pkg/…/pipeline.go• L812-829
Lineage relationships
Asset lineage
Asset lineage describes the dependency graph around an asset. Upstream assets provide inputs. Downstream assets consume outputs. The graph can show direct relationships or the full transitive set, and it can include external URI dependencies for relationships that cross pipeline boundaries. This supports impact review before a change and helps explain why work runs in a particular order. See data lineage for the lineage workflow.
When an engineer asks for lineage, Bruin loads the asset's pipeline and returns upstream and downstream summaries. The command supports human-readable output and structured JSON, so the same relationship view can serve a person or another tool.
References: pkg/…/pipeline.go• L1681-1713 cmd/lineage.go• L14-42 cmd/lineage.go• L62-115 cmd/lineage.go• L120-187
Column lineage
Column lineage explains how an output column comes from columns in upstream assets. Bruin renders the asset query, uses upstream column metadata as input, and records the relationships found by the SQL parser. It follows the asset graph recursively, so a user can connect a final column to the source columns that shaped it. Table references match asset names without regard to case, and configured database-qualified names can resolve to the same canonical asset.
Lineage is best understood as derived evidence. It can report an unresolved upstream, a query render problem, or a parser problem instead of claiming a relationship that it cannot prove. Non-asset references remain external rather than becoming false internal dependencies.
References: pkg/…/lineage.go• L52-69 pkg/…/lineage.go• L71-99 pkg/…/lineage.go• L102-198 pkg/…/lineage.go• L200-224 pkg/…/lineage.go• L279-370 cmd/internal.go• L509-529 cmd/internal.go• L712-731
Semantic metadata
Semantic models
A semantic model is a repository-level description of business data. It names a source relation and defines reusable dimensions, metrics, segments, and joins. Dimensions describe fields for grouping and filtering. Metrics describe measures and calculations. Segments describe named filters. Joins describe safe paths to related models.
Semantic models are separate from pipeline execution definitions. They add a stable business view over existing data rather than creating another pipeline stage. Models use a versioned schema and must pass validation before they can serve queries. See semantic layer for the model and query details.
References: semantic-engine/model.go• L3-15 semantic-engine/model.go• L17-70 semantic-engine/loader.go• L15-32 semantic-engine/loader.go• L54-82 semantic-engine/…/embed.go• L12-40
Semantic catalog validation
The lint system validates the repository semantic catalog as part of both pipeline-level and single-asset validation. It reports invalid model files and checks that the catalog can form a usable semantic engine, so an invalid repository-wide model cannot be hidden by a narrow asset selection. A catalog is checked once per validation run even when several pipelines refer to it.
Query-backed semantic models can also be checked with a database dry run when a suitable SQL validator is available. Asset-scoped validation prefers the selected asset's connection, which keeps the check aligned with that asset's SQL dialect; a plain table source does not need a query dry run.
References: pkg/…/semantic.go• L27-54 pkg/…/semantic.go• L56-134 pkg/…/semantic.go• L136-201 pkg/…/list.go• L356-363 pkg/…/semantic_test.go• L17-213 pkg/…/semantic_test.go• L215-432
Semantic query relationships
The semantic engine turns a query request into SQL while preserving the meaning declared by the model. A request can select dimensions and metrics, apply filters or segments, sort results, and use time granularities. If it uses a related model, the engine builds a path through declared joins instead of allowing an arbitrary relationship.
The query path can use an asset as an anchor to obtain its pipeline context and connection. It can also use a pipeline and an explicit connection. Integration coverage shows both forms, along with joined dimensions and window metrics, through the bruin query command.
References: semantic-engine/engine.go• L250-342 semantic-engine/graph.go• L47-140 semantic-engine/graph.go• L242-339 integration-tests/integration_test.go• L805-923
Metadata publication
Catalog metadata
Metadata publication sends pipeline and asset descriptions to a supported destination catalog. It lets warehouse and catalog tools expose descriptions and related metadata where users discover and govern data. A pipeline can enable publication in its metadata_push settings, or a run can request it through the command option. Bruin selects the asset's configured connection for the publication step.
Publication is separate from lineage derivation. Lineage explains relationships in the pipeline model. Metadata publication copies descriptive metadata to an external system so that users can find that context outside the repository.
References: docs/…/definition.md• L305-323 docs/…/run.md• L317-340 pkg/…/pipeline.go• L2183-2190 pkg/…/policy_builtins.go• L487-499
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to asset or column metadata fields must be checked against policy rules, lineage output, and any catalog publication path that consumes those fields.
- Changes to relationship checks or foreign-key metadata must be checked for valid target assets and columns, and for blocking checks that point to downstream assets.
- Changes to column names or tags must be checked against case-insensitive duplicate detection and any consumers that use those names or tags as identifiers.
- Changes to precision, scale, or length metadata must be checked against the lint rules and the type contracts used by catalog or warehouse consumers.
- Changes to dependency names, URI relationships, or symbolic dependencies must be checked in both execution ordering and direct or full lineage views.
- Changes to single-asset validation scope or repository-root loading must preserve cross-pipeline URI resolution and the fallback to the asset's own pipeline when the wider scope cannot load.
- Changes to SQL rendering, declared columns, or database-qualified asset names must be checked against column lineage and the query-to-column policy rule. Keep configured database names aligned with the names used in SQL.
- Changes to CDC ingestion options or queryable destination naming must preserve the link between ingestion behavior, asset identity, quality checks, and lineage.
- Changes to chunked CDC snapshot options must preserve the link between lint validation, CDC mode, execution and WAL staging choices, and the required merge behavior.
- Changes to ClickHouse physical keys, indexes, or projections must preserve the table option rules and the relationship between the physical primary key and its sort key.
- Changes to semantic model fields, source definitions, or join rules must be checked against catalog validation, query planning, and qualified dimensions from joined models. Query-backed sources must remain valid for the SQL connection selected during dry-run validation.
- Changes to metadata publication targets must be checked against pipeline policy rules and the connection selected for the asset.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A policy file has an invalid rule, duplicate rule name, unknown target, or empty ruleset | Validation cannot build the policy rules | Validate the policy definition before relying on its findings; keep rule names and targets valid |
| A relationship check has no foreign-key metadata, or its foreign key names an unknown asset or declared column | The relationship quality check cannot describe the intended data link | Declare both targets and keep them aligned with the pipeline asset and column names |
| A blocking relationship check points to an asset that depends on the checked asset | The check runs before the referenced downstream asset is refreshed and can report stale results | Make the check non-blocking or restructure the dependency graph |
| An asset has duplicate column names or duplicate tags after case folding | Linting reports an invalid metadata contract and downstream name- or tag-based behavior can become unclear | Keep column names unique and keep tags unique within their asset or column |
| Column precision or length is not positive, scale is negative, or scale is greater than precision | Linting rejects the column type details | Use positive precision and length values, a non-negative scale, and a scale no greater than precision |
| An ingestr asset uses update or delete incremental strategy with a destination that does not support reverse ETL | Linting rejects the asset's ingestion contract | Use those strategies only with a supported reverse-ETL destination, or use a strategy supported by the destination |
A CDC asset uses the deprecated cdc_mode setting | Linting reports a deprecation warning and the asset can keep an unclear stream or batch contract | Set stream: true for streaming CDC or omit it for a bounded (batch) run |
| Chunked CDC snapshot settings use invalid values or conflict with CDC, execution, staging, or merge rules | Linting rejects the ingestion contract before execution | Use chunked snapshots only with cdc: true, valid serial or parallel settings, and merge-compatible materialization |
A queryable ingestr destination sets destination_table to a name different from the asset name | Name-based checks, lineage, and table operations can refer to a different table than ingestion writes | Set the asset name to the target table and do not override it with destination_table |
| A ClickHouse physical primary key is not a prefix of the sort key, or an index or projection lacks required identity or definition fields | Linting rejects the table definition before materialization | Keep the physical key aligned with the sort key and give each index and projection a unique name and valid definition |
| Single-asset validation cannot load the repository root that contains a sibling URI target | Cross-pipeline validation falls back to the asset's own pipeline and can report the sibling URI as unresolved | Validate from a usable repository root or repair the sibling pipeline before relying on cross-pipeline findings |
| A selected-asset or excluded-tag run omits an asset-level issue by design | The result does not represent a full asset-level validation of the pipeline | Use selection and exclusion only when the narrower validation scope is intended; dependencies remain resolved against the full pipeline |
| An asset query cannot render or its upstream table or column cannot be resolved | Asset or column lineage is incomplete and a lineage issue is reported | Keep dependency names aligned with asset names, configure database-qualified names when SQL uses them, and ensure templated SQL can render for lineage |
| A blocking runtime check fails | The asset fails and dependent assets do not run | Use blocking only for conditions that must protect downstream consumers; use non-blocking checks for observations |
| A semantic model has an invalid source, duplicate name, unknown reference, or unsafe or ambiguous join path | Catalog validation reports a critical issue and the semantic model or query cannot load or compile | Give each model one valid source and keep model names, references, and join paths valid |
| A query-backed semantic model fails the SQL dry run | Semantic validation reports the query error or invalid SQL before the model is used | Keep source queries valid for the selected asset connection and provide a connection with query validation support |
| Metadata publication is enabled without a usable destination connection | The metadata publication step fails instead of updating the catalog | Configure the destination connection for the asset and enable only supported publication targets |
Key files
| File | Why to read it |
|---|---|
| pkg/…/pipeline.go | Defines the asset, column, dependency, metadata, and metadata-publication concepts shared by the governance features. |
| pkg/…/lint.go | Shows how validation scope, asset selection, excluded tags, and cross-pipeline URI resolution shape lint results. |
| pkg/…/list.go | Shows which built-in policy checks are available and how checks are grouped by scope, severity, and speed. |
| pkg/…/semantic.go | Shows how semantic catalogs and query-backed sources participate in pipeline- and asset-level validation. |
| pkg/…/semantic_test.go | Shows the contracts for semantic catalog discovery, invalid model reporting, and SQL dry-run validation. |
| pkg/…/rules.go | Shows the validation contracts for column relationships, type details, tags, dependency-aware quality warnings, ingestion identity settings, and ClickHouse table options. |
| pkg/…/rules_cdc_chunked_test.go | Shows the lint contract for chunked CDC snapshot settings and their compatibility rules. |
| pkg/…/rules_test.go | Shows the expected contracts for ingestion settings, ClickHouse table definitions, column names, relationship metadata, type details, duplicate tags, downstream relationship warnings, and reverse-ETL incremental strategies. |
| pkg/…/lint_test.go | Shows how selected assets and cross-pipeline URI dependencies affect validation results. |
| pkg/…/policy.go | Shows how repository policies become validation rules and how selectors scope those rules. |
| pkg/…/policy_builtins.go | Shows the built-in checks for metadata, naming, pipeline safeguards, and declared SQL columns. |
| pkg/…/cdc_chunked.go | Defines the shared validity rules for chunked CDC snapshot options used by linting and execution. |
| pkg/…/lineage.go | Shows how asset and column relationships are derived from dependencies, SQL, upstream schemas, and configured database-qualified names. |
| cmd/lineage.go | Shows the user-facing lineage view and its plain-text and JSON outputs. |
| semantic-engine/model.go | Defines the business concepts available in semantic models. |
| semantic-engine/loader.go | Shows how repository semantic models are found, validated, and made available by name. |
| semantic-engine/engine.go and semantic-engine/graph.go | Explain how semantic requests use declared dimensions, metrics, filters, and join paths to produce SQL. |
| docs/…/definition.md | Documents pipeline-level metadata and the option to publish it to a catalog. |