Pipeline specification and asset modeling
The pipeline specification is the declarative contract that turns pipeline YAML and asset files into a checked model for execution. It defines shared settings, asset identity, metadata, variables, variants, dependencies, selectors, write rules, hooks, and run preparation without executing asset code.
Specification model
The model has two levels. A Pipeline holds shared settings and a collection of Asset objects. An asset is one executable unit with its code or query plus the metadata needed to place it in the dependency graph and run it against the right data system.
The model keeps source paths for the definition and executable content. This lets later tools report useful file locations while using one shape for SQL, Python, R, and YAML-defined assets. The builder also groups assets by type and connects named internal dependencies.
Pipeline settings
Pipeline YAML describes shared identity and operating limits for a workload. It can set the name, schedule, start date, owners, tags, domains, connections, notifications, retries, concurrency, catch-up behavior, and shared asset defaults. Catch-up values accept the older boolean form and the named active or all modes. The default block is a shared asset profile. It fills missing asset values without replacing explicit asset values.
The profile can include metadata, dependencies, columns, quality checks, hooks, materialization, target settings, routing, and refresh rules. This keeps common policy in one place while allowing an asset to override the parts that differ.
References: pkg/…/pipeline.go• L2315-2366 pkg/…/pipeline.go• L2375-2405 pkg/…/pipeline.go• L2446-2480 pkg/…/pipeline.go• L3444-3562
Asset identity and metadata
An asset describes what should run and how the system should understand its result. Its identity includes a name, URI, type, source files, enabled state, and executable content. Its metadata covers ownership, description, tags, domains, arbitrary metadata, connection and secret references, parameters, retry limits, timeout, and routing.
An asset can describe its output shape through columns. Column metadata supports names, source columns, types, keys, null rules, masks, defaults, foreign keys, ownership, domains, and quality checks. These fields support validation, lineage, catalog views, and materialization without changing the executable body.
Target settings extend the shared model when a data system needs extra write rules. Connection choice is part of the model: an explicit asset connection wins. Otherwise the asset type or ingestion destination maps to a connection platform and its standard connection name. Some asset types support alternate platforms, so the builder checks those platforms before using the standard name.
References: pkg/…/pipeline.go• L662-711 pkg/…/pipeline.go• L905-930 pkg/…/pipeline.go• L968-1103 pkg/…/pipeline.go• L2713-2758 pkg/…/pipeline.go• L3444-3562
Dependency declarations
The depends field declares relationships that define the workload graph and external evaluation inputs. A short string names another asset and means a full internal dependency. A mapping can name an asset or an external URI and can include selected columns and an evaluation mode: full, symbolic, last, first, or any.
The builder resolves internal names after it loads all assets. It records upstream and downstream links for scheduling and selectors. External URI references remain metadata and do not become internal graph edges. Some asset types can also add a required dependency from a parameter. Inference assets use input_asset for this purpose, and the builder rejects a missing target or a self-reference.
References: pkg/…/yaml.go• L46-223 pkg/…/pipeline.go• L3175-3202 pkg/…/pipeline.go• L3231-3254
Definition parsing
The parser reads a pipeline YAML file and asset definitions below the configured asset directories. An asset can keep metadata in a standalone asset.yml or task.yml file, or embed YAML in a comment block at the start of a SQL, Python, or R file. The executable content stays attached to the asset.
The load path connects source definitions to the model before execution.
flowchart LR
A[pipeline YAML] --> B[Pipeline settings]
C[standalone asset YAML] --> D[Asset metadata]
E[embedded asset YAML] --> D
F[SQL Python or R file] --> G[Executable content]
D --> H[Asset model]
G --> H
B --> I[Builder]
H --> I
I --> J[Defaults and inferred links]
J --> K[Checked pipeline model]
The builder discovers supported asset files, parses each definition, assigns a name from the path when needed, applies shared defaults, and links dependencies. A caller can build an unmaterialized pipeline template for inspection, one fully loaded model for a selected variant, or one model for each declared variant.
References: pkg/…/pipeline.go• L2273-2297 pkg/…/pipeline.go• L3058-3228 pkg/…/pipeline.go• L3299-3343 pkg/…/pipeline.go• L3355-3399
YAML forms
Standalone definitions use YAML fields directly. Comment-based definitions use an @bruin block or a smaller line-comment form. The parser keeps the code after an embedded block as executable content and reports malformed YAML as a parse error. It also preserves source line alignment when it reports indentation faults.
The YAML contract normalizes common shapes. Dependencies accept a scalar, one mapping, or a list. Dependency modes are case-insensitive. Unknown or non-string modes safely become full. Quality check values keep their scalar or list type. The parser ignores unsupported quality-check names instead of adding them to the asset model.
The parser accepts both refresh_restricted and the full_refresh_restricted alias. It stores them as one asset restriction so refresh handling has one model field.
References: pkg/…/comment.go• L42-63 pkg/…/comment.go• L65-142 pkg/…/yaml.go• L46-223 pkg/…/yaml.go• L585-685
Configuration loading
The environment configuration supplies named connections and selects the active environment used by the pipeline. It can load from a file or from BRUIN_CONFIG_FILE_CONTENT, expand available ${NAME} references before YAML decoding, and create a default environment when no file exists.
Relative credential and local data paths are resolved from the configuration file directory. Anchored paths remain unchanged, including Unix-rooted paths and Windows drive paths. The selected environment indexes connections by name so pipeline connection resolution can check whether every task has a usable connection.
The connection catalog covers database, warehouse, file, cloud, API, and ingestion systems. Database-like connections may opt into cloud query routing, and connection metadata can carry an asset concurrency limit. These values affect where work runs and how much work a connection can accept; they do not change asset identity.
References: pkg/…/manager.go• L197-229 pkg/…/manager.go• L306-323 pkg/…/manager.go• L361-380 pkg/…/manager.go• L446-588 pkg/…/connections.go• L17-50
Model normalization
Parsing creates the common model. Normalization then fills predictable values and connects the model to its execution context. A missing concurrency becomes one. A missing asset name comes from its path. Pipeline defaults fill only missing asset fields, while explicit asset values remain in control.
The builder applies mutators during construction. These prepare shared defaults, retry settings, connection secrets, glossary data, names, and inferred relationships. Persistence keeps meaningful explicit asset overrides, including false and zero target values, instead of treating them as inherited defaults. Target-specific defaults follow the same rule. For example, a table format default applies only to asset types that support that format.
For a variant build, the builder applies variable overrides before asset construction and renders templated structural fields after it creates the asset graph. New string fields that may contain Jinja must join that rendering contract or they can remain unresolved in the materialized model.
References: pkg/…/pipeline.go• L2408-2444 pkg/…/pipeline.go• L2964-2986 pkg/…/pipeline.go• L3110-3228 pkg/…/pipeline.go• L3444-3562
Variables and variants
Variables make one pipeline specification reusable across environments or workloads. Each variable declares a value shape and a default value. A variant is a named set of overrides that selects one configuration of the same pipeline.
Variable values
Variables use JSON Schema-style types such as string, integer, number, boolean, array, and object. The defaults form the base rendering context. Variant overrides can change declared variables but cannot add unknown keys.
Schema diagnostics check variable definitions and defaults without changing the public variable data. They use a bundled Draft 7 meta-schema and block external schema loading. References in a variable schema are reported as unsupported for warning validation instead of being fetched or followed.
SQL and YAML asset fields can refer to variables with Jinja expressions such as {{ var.client }}. Python assets receive variable values through the runtime contract instead of build-time substitution in their source body.
References: pkg/…/variables.go• L14-124 pkg/…/variables_schema.go• L11-57 pkg/…/draft-07.json• L1-50 pkg/…/variant.go• L118-126
Variant selection
A variant name uses only letters, numbers, underscores, or hyphens. Its overrides must name declared variables and use the declared basic type. Selecting a variant merges its overrides into the pipeline variables before asset construction, so defaults and mutators see the selected values.
The builder renders structural fields after it loads and links assets. This keeps materialized names and dependency lookups consistent. A caller can build one named variant or use CreatePipelinesFromPath to fan out all variants into separate materialized pipeline models. A normal single-pipeline build must name the variant when variants exist. A caller that only needs the pipeline template can request the unmaterialized form.
References: pkg/…/variant.go• L13-61 pkg/…/variant.go• L128-193 pkg/…/pipeline.go• L3038-3055 pkg/…/pipeline.go• L3105-3120 pkg/…/pipeline.go• L3299-3343
Template materialization
Variant materialization resolves structural fields that must be stable before execution. This includes pipeline and asset names, enabled state, schedules, dates, dependencies, tags, metadata, connections, routing, target settings, secrets, columns, and materialization fields.
The asset body is not rendered in this step. Parameters and query-bearing fields such as hooks, custom checks, and incremental predicates keep runtime templates for values that exist only during a run. The builder renders the structure after graph links exist, then rebuilds its name index so selectors and downstream lookups use the rendered identities.
The visitor covers target-specific structural strings. A coverage check protects this boundary when new exported string fields are added. A selected variant also requires a renderer at builder creation time.
References: pkg/…/variant.go• L152-179 pkg/…/variant.go• L209-275 pkg/…/variant.go• L362-643 pkg/…/pipeline.go• L3212-3225 pkg/…/variant_test.go• L203-324 pkg/…/variant_test.go• L411-536
Asset selection
Selectors turn a human filter into a set of assets from the built pipeline graph. They support direct identity matching and graph expansion, so a run can target one asset, a group, or the context around a group.
Selector matches
The selector core matches an asset name by default or uses an explicit method. Supported methods include tag, path, file, and fqn. Scalar matches support shell-style wildcards. Path matches also recognize a directory and its descendants.
Space creates a union. A comma creates an intersection within one union term. Results keep the pipeline's asset order rather than map order.
References: pkg/…/selector.go• L30-52 pkg/…/selector.go• L238-337
Graph expansion
The + operators expand through internal dependency links. A prefix selects upstream assets. A suffix selects downstream assets. A number limits the depth. The @ form selects connected context around a match. It cannot combine with the + operators.
flowchart LR
U[upstream assets] --> A[selected asset]
A --> D[downstream assets]
S[selector match] --> A
P[upstream expansion] --> U
Q[downstream expansion] --> D
R[connected context] --> U
R --> D
The resolver ignores external URI relationships during graph expansion. It returns an error when the selector is empty or matches no assets.
References: pkg/…/selector.go• L55-86 pkg/…/selector.go• L523-573
Hooks and materialization
Hooks and materialization describe how an asset's main query becomes the statements sent to a data system. Materialization chooses the output form and write strategy. Hooks add work before or after that strategy.
Hook behavior
An asset can define pre and post hooks. Pipeline defaults can provide hooks for SQL assets and can limit inheritance to named asset types. An asset's own pre or post list replaces the matching default list rather than combining with it.
At run preparation time, empty hook entries are skipped and missing statement terminators are added. The final statement order is pre-hooks, materialized work, and post-hooks. Some dialects move declaration statements to the top when required. Cleanup statements from list-based materializers remain separate for early-stop handling.
References: pkg/…/pipeline.go• L1459-1471 pkg/…/hooks.go• L19-39 pkg/…/materializer.go• L85-178 pkg/…/pipeline.go• L3516-3521
Materialization strategies
Materialization has a type such as view or table and a strategy such as create-and-replace, append, merge, time interval, DDL, SCD2, or Data Vault loading. Partitioning, clustering, incremental keys, predicates, and time granularity provide the details needed by a strategy.
Target-specific settings extend this contract for systems that need extra table rules. The materializer maps the declared type and strategy to a target-specific statement builder. Full refresh normally changes table work to create-and-replace. DDL and supported Data Vault strategies keep their explicit rules. Table formats such as Iceberg are accepted only for supported asset types.
Full refresh can come from the run-level flag or parameters.full_refresh. The run-level flag cannot be disabled by an asset value. refresh_restricted can block the effective refresh for that asset.
References: pkg/…/pipeline.go• L615-711 pkg/…/pipeline.go• L1422-1450 pkg/…/materializer.go• L18-82 pkg/…/yaml.go• L234-243 pkg/…/yaml.go• L585-595
Validation boundary
Validation protects the specification at several points. YAML parsing checks shape and value conversion. Pipeline unmarshalling checks variant references and assigns safe defaults. The broader validation workflow adds rules for variables, limits, dependencies, and asset policy.
Structural checks
Variant validation rejects invalid names, unknown variable references, and basic type mismatches. Variable linting reports variables without defaults. Schema diagnostics report invalid variable schemas or defaults without changing the schemas used by live jobs. Strict asset YAML validation catches unknown fields in embedded or standalone definitions.
Inference assets also require a valid input_asset relationship when the parameter is present. The builder rejects a missing target or a self-reference and adds a valid target to the graph when it is not already declared.
These checks establish that the configuration can be represented and that key cross-field contracts exist. They do not prove that a query will succeed against a live system.
References: pkg/…/comment.go• L493-525 pkg/…/pipeline.go• L2408-2444 pkg/…/pipeline.go• L3231-3254 pkg/…/variables.go• L16-24 pkg/…/variant.go• L34-102 pkg/…/variables_schema.go• L27-57
Execution readiness
The final model has selected variables, normalized metadata, executable content, grouped asset types, and internal graph links. It also carries execution limits such as concurrency and the optional maximum active-step limit, plus the connection names and routing choices needed by downstream execution.
For variant pipelines, the builder returns materialized models with stable identity fields and graph links. This boundary keeps specification work separate from query execution. The runtime can focus on scheduling and running assets because this layer has already resolved which assets exist, how they relate, which connection each asset needs, and which declared write and policy rules apply. See Execution runtime and Pipeline orchestration.
References: pkg/…/pipeline.go• L2375-2405 pkg/…/pipeline.go• L3058-3228 pkg/…/pipeline.go• L3299-3343
Change checklist
When these files or sections are changed, remember to consider these:
- A new templated structural field must be included in variant rendering so materialized pipelines do not retain unresolved values.
- A selected variant must continue to receive a renderer, while template inspection and automatic variant fan-out must remain available through their separate builder paths.
- A new asset type must have connection mapping and SQL classification when it relies on automatic connections or default SQL hooks.
- A new asset type with alternate connection platforms must update both the platform mapping and the explicit-default lookup order.
- A new dependency shape must preserve YAML parsing, internal graph linking, and the distinction between assets and external URIs.
- Changes to dependency evaluation modes must preserve their YAML and JSON round trips, especially for external URI dependencies.
- A new materialization strategy or table format must have a target mapping, supported asset types, and explicit full-refresh behavior.
- Changes to defaults must preserve the asset-overrides-defaults rule, target-specific support limits, and the replacement rule for explicit hook lists.
- Changes to variables must keep variant overrides aligned with declared names and basic types. Every variable used by the specification still needs a default.
- Changes to variable schema diagnostics must keep validation local and must not enable external
$refloading. - Changes to inference parameters must preserve the implicit dependency contract and must not create self-links.
- Changes to refresh restriction names must preserve both
refresh_restrictedandfull_refresh_restrictedinput forms. - Changes to refresh restrictions must preserve the difference between a requested refresh and an effective refresh.
- Changes to catch-up input forms must preserve the mapping from legacy booleans and named modes to the normalized pipeline state.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A pipeline with variants is built without a selected variant | The normal single-pipeline build stops | Select a variant or build all variants |
| A selected variant has no renderer in the builder | Variant materialization stops before it returns a model | Supply a VariantRendererFactory when constructing the builder |
| A variant names an undeclared variable or uses the wrong basic type | Pipeline unmarshalling fails before asset construction | Validate overrides against the variable declarations |
| A variable has no default | Variant rendering lacks a base value | Add a default for every declared variable |
A variable schema uses $ref or an external reference | Schema diagnostics skip schema and value validation for that variable | Keep warning-time schemas self-contained and use supported Draft 7 forms |
An inference asset names a missing or itself as input_asset | Model construction fails | Point to a different loaded asset |
| A dependency names an unloaded asset | No internal graph edge is created | Align dependency names with loaded assets or use a URI |
A selector matches no assets or combines @ with + | Selection stops with an error | Check the selector and use one graph operator form |
| An asset type has no connection mapping or no available supported connection | Connection resolution fails before execution | Add the mapping and define the named or default connection |
| An asset uses an unsupported table format or a materialization pair with no target mapping | Statement generation fails before execution | Use a supported asset type and strategy pair |
| A full refresh is requested for a refresh-restricted asset | The asset keeps its declared write strategy | Treat the restriction as a safety boundary |
| An embedded or standalone definition contains an unknown field | Strict validation rejects the asset | Use fields in the asset specification |
| A new Jinja-capable string field is not included in structural rendering | A materialized variant carries an unresolved value | Add the field to the variant rendering visitor |
Key files
| File | Why to read it |
|---|---|
| pkg/…/pipeline.go | Defines the pipeline and asset model, builder boundary, variant materialization, defaults, connection choice, graph links, refresh rules, and execution inputs. |
| pkg/…/yaml.go | Defines YAML shapes for assets, dependencies, columns, checks, hooks, materialization, target settings, and conversion into assets. |
| pkg/…/comment.go | Defines metadata parsing from embedded and line comments and strict validation of standalone or embedded asset YAML. |
| pkg/…/variables.go | Defines variable defaults, value views, schema views, merge behavior, and warning diagnostics. |
| pkg/…/variables_schema.go | Defines the bundled Draft 7 schema boundary and the block on external schema loading. |
| pkg/…/draft-07.json | Supplies the local Draft 7 meta-schema used to check variable schemas. |
| pkg/…/variant.go | Defines variant validation and structural field materialization. |
| pkg/…/selector.go | Defines selector matching, set operations, and graph expansion. |
| pkg/…/hooks.go | Defines the relation between hooks, the main query, and statement order. |
| pkg/…/materializer.go | Defines materialization, hook wrapping, cleanup propagation, and full-refresh safeguards. |
| pkg/…/pipeline_test.go | Shows builder, dependency, connection, refresh, persistence, and default behavior contracts. |
| pkg/…/variant_test.go | Shows variant validation, materialization boundaries, runtime template preservation, and visitor coverage. |
| pkg/…/variables_safety_test.go | Shows that variable diagnostics do not fetch external schemas and do not mutate caller data. |
| pkg/…/variables_schema_test.go | Shows the embedded meta-schema and compiler boundary for variable schemas. |
| pkg/…/yaml_test.go | Shows accepted YAML forms, refresh aliases, hook shapes, and dependency mode round trips. |
| pkg/…/manager.go | Defines environment loading, connection lookup, environment selection, environment-variable expansion, and path normalization used by pipeline connection resolution. |
| pkg/…/connections.go | Defines connection metadata and connection capabilities such as cloud routing. |