Branch Environments are schemas in the shared stage Warehouse
Beyond the fixed dev/stage/prod Environments, every Git branch / pull request gets a disposable Branch Environment implemented as its own set of schemas in the stage Warehouse, named br_<branch>__<schema> (e.g. br_add_refunds__analytics). It is created by adops run <pipeline> --branch <branch> and dropped by adops drop-branch <branch>. Schemas were chosen over a separate database or docker stack per branch because they are cheap, fast to create, and work identically on Postgres and DuckDB.
Consequences: a Branch Environment does not re-sync Sources by default. It defers to the stage Environment's synced tables and rebuilds only changed Steps and their downstream dependents; a full re-sync happens only when the branch changes a Sync Step itself.
Clarification (2026-11-20)
The original text named a single env_<branch> schema created by CI and dropped on merge/close. What shipped:
-
One schema per kind, not one per branch. A Branch gets
br_<branch>__raw_<source>(only when it re-syncs that Source),br_<branch>__analyticsandbr_<branch>__adops, beside stage's ownraw_<source>,analyticsandadops. dlt also creates<schema>_stagingcompanions; they carry the same prefix. -
The
__separator is kept by turning off dlt's dataset-name normalization for non-default schemas only, because dlt otherwise collapses__to_. dev and stage schema names are unchanged. -
The Branch name is the Git branch lower-cased with every run of non-alphanumerics replaced by
_, truncated with a hash suffix whenbr_<name>__raw_<longest source>_stagingwould exceed Postgres's 63 bytes. -
A Changed Step is one whose Step Fingerprint differs from stage's last successful run. Stage saves fingerprints only after a Step's Checks pass; a Branch run never writes stage's tables, fingerprints or schema snapshots.
-
Dropping is manual.
adops drop-branch <branch>drops every schema starting with exactlybr_<name>__(CASCADE) and the Branch's local dlt state; stage's schemas are never touched. Running it from CI on merge/close is deferred. -
dbt projects must read their raw schema through a variable, so a Branch that re-syncs a Source can point Transforms at its own copy. In
sources.yml:schema: "{{ var('adops_raw_schema_shop', 'raw_shop') }}"where
shopis the Source name. A Branch run that rebuilds a Sync fails fast when the dbt sources do not use the variable. -
Known gap:
adops accept-schemahas no--branchoption. A Branch's schema snapshots start fresh, so a Breaking Change inside a Branch is rare.
Clarification (2026-11-21)
- Dropping now runs from CI. The generated
adops-pull-request.ymlrunsadops drop-branch <branch>on the stage Server when a pull request is closed or merged (ADR-0016).adops drop-branchby hand still works. - Branch names that sanitize to the same name collide. Two branches such as
feature/new-ordersandfeature-new/ordersboth becomefeature_new_ordersand share one Branch Environment: each run overwrites the other's tables, and closing either pull request drops both. This is recorded, not fixed;docs/playbooks/promotion.mdgives the recovery steps.
Clarification (2026-11-23)
- The
--branchknown gap is closed.adops accept-schema <pipeline> <table> --branch <branch>accepts a table's current shape as that Branch Environment's baseline inbr_<name>__adops, under stage's Warehouse lock, and writes no accepted-change record. It cannot be combined with--envand is CLI only: the Assistant'saccept_schematool stays dev only. A committed accepted-change record is still applied by Branch runs as it is by stage (ADR-0015).
Clarification (2026-11-27)
- prod saves fingerprints too. stage and prod both save a Step's Step Fingerprint in their own
adops._adops_step_fingerprintsafter its Checks pass, so a deploy to either can rerun only its Changed Steps (ADR-0014 clarification of 2026-11-27). Branch Environments still compare against stage's fingerprints only and still never write them. - Each deploy also saves a Deploy State in that Environment's
adops._adops_deploy_state: a Settings Marker (a hash of that Environment's block inadops.yaml, the time zone and the alert webhook setting) and the Accepted-Change Record ids it has already run with. Fingerprint rows of Steps that no longer exist are ignored, not deleted.
Clarification (2026-11-28)
- A first Branch run rebuilds the whole Pipeline. When stage has no saved Step Fingerprints for a Pipeline (stage has never run it), every Step counts as changed: the Branch run rebuilds every Step into its own
br_<name>__schemas, loading each Sync Step from the real Source, instead of refusing. It still saves no fingerprint, and a Reverse Sync still only previews. The fail-fast for dbt sources that do not read the Branch's raw schema now applies to that first run too. - A Pipeline whose first Step is a Transform still reads stage. With no Sync Step before it in the Branch, that Transform reads stage's
raw_<source>schema, which may not exist yet before stage's first run, so such a first Branch run can fail on a missing schema.