dbt-native Python CLI for running Anarchitects Governance checks against dbt projects.
Project description
anarchitecture-dbt-governance
Build it like an Nx product. Use it like a dbt tool.
anarchitecture-dbt-governance is a dbt-native Python CLI for running
Anarchitects Governance checks against an existing dbt project. It manages dbt
artifact lifecycle, resolves the pinned Node runtime, invokes
@anarchitects/governance-runtime-dbt over a process/JSON boundary, and
renders human, JSON, and markdown output for local and CI use.
It gives dbt users a Python CLI while preserving the governance package architecture:
dbt-governance
-> host-side dbt lifecycle, config, runtime setup, and rendering
-> process/JSON boundary
-> @anarchitects/governance-runtime-dbt
-> @anarchitects/governance-adapter-dbt
-> @anarchitects/governance-extension-dbt
-> @anarchitects/governance-core
Purpose
The host owns:
- dbt-native CLI UX
governance.ymlloading, validation, andinit- dbt project and artifact path hints
- optional
dbt parse - pinned Node runtime setup and diagnostics
- process invocation of
dbt-governance-runtime - human, JSON, and markdown output
- report writing
- final CLI and CI exit codes
The host does not own:
- governance semantics
- dbt artifact loading or validation
- dbt artifact normalization
- dbt-specific rules, scoring, signals, or recommendations
- TypeScript runtime composition
Package Identity
- Nx project:
governance-host-dbt - Python distribution:
anarchitecture-dbt-governance - Python module:
anarchitecture_dbt_governance - CLI command:
dbt-governance - Runtime package:
@anarchitects/governance-runtime-dbt - Pinned runtime version:
0.1.0 - Runtime executable:
dbt-governance-runtime - Runtime version source:
runtime_manifest.json - Pinned Node range:
>=20 <25 - Contract version:
1.0.0
Architecture And Boundaries
Ownership
governance-host-dbt
- CLI UX
- config loading and precedence
- dbt project and artifact path hints
- optional
dbt parse - pinned runtime setup and
doctor - process/JSON invocation
- human, JSON, and markdown rendering
- report file output
- CI exit code mapping
governance-runtime-dbt
- TypeScript composition boundary
- JSON in / JSON out runtime execution
- composition of Core, adapter, and extension
governance-adapter-dbt
- authoritative dbt project detection at the adapter boundary
- artifact loading
- artifact validation
- artifact normalization
- dbt metadata preservation
governance-extension-dbt
- dbt-specific interpretation
- dbt-specific diagnostics
- dbt-specific signals, metrics, and recommendations
governance-core
- canonical governance contracts
- deterministic governance assessment behavior
Host Boundary Rules
The host must not:
- import
@anarchitects/governance-core - import
@anarchitects/governance-adapter-dbt - import
@anarchitects/governance-extension-dbt - import
@anarchitects/governance-runtime-dbtTypeScript source - load or parse dbt artifacts semantically
- validate dbt artifact structure semantically
- normalize dbt artifacts
- implement dbt-specific governance rules, metrics, diagnostics, recommendations, or scoring
Authoritative architectural guidance lives in ADR 0003 and the Governance Boundary Contributor Guide.
Install And Local Development
Run the host through the existing Nx and @nxlv/python targets:
yarn nx run governance-host-dbt:lint
yarn nx run governance-host-dbt:test
yarn nx run governance-host-dbt:e2e
yarn nx run governance-host-dbt:build
Exercise the CLI from the package directory with uv:
cd packages/governance/host-dbt
uv run python -m anarchitecture_dbt_governance.cli --help
uv run dbt-governance --help
Using dbt-governance In An Existing dbt Project
This package is installed as a Python CLI. It is not installed through
packages.yml or dbt deps.
Install it with one of these approaches:
pipx install anarchitecture-dbt-governance
uv tool install anarchitecture-dbt-governance
pip install anarchitecture-dbt-governance
Run it from the root of the dbt project, or pass --project-dir:
cd my-dbt-project
dbt-governance init
dbt-governance setup
dbt parse
dbt-governance check
If you want the host to generate manifest.json when it is missing:
dbt-governance check --parse
CLI Commands
dbt-governance init
Creates a starter governance.yml.
Options:
--project-dir--config--force
Behavior:
- writes a starter config file
- refuses to overwrite an existing config by default
- overwrites only when
--forceis set
dbt-governance setup
Verifies the host runtime requirements and installs or verifies the pinned runtime package in the controlled cache.
Options:
--config
dbt-governance doctor
Reports host, config, Node, package-manager, runtime-manifest, and installed runtime status.
Options:
--config
dbt-governance check
Runs the host lifecycle, invokes the runtime, renders a result, and returns a final process exit code.
Options:
--project-dir--profiles-dir--target--target-path--config--use-existing-artifacts--parse--json--report-path
dbt-governance report
Runs the same host lifecycle as check, then renders the preserved runtime
result in a selected report format.
Options:
--project-dir--profiles-dir--target--target-path--config--use-existing-artifacts--parse--format json--format markdown--report-path
governance.yml
File Name And Precedence
- default file name:
governance.yml dbt-governance initcreates itdbt-governance init --forceoverwrites an existing file- precedence is:
CLI flags >
governance.yml> host defaults
Section Boundaries
profile: canonical governance profile routingadapter: dbt adapter path hints and adapter-owned optionsextension: dbt extension-owned optionsruntime: runtime cache and report defaultshost: host artifact lifecycle, output mode, and CI behavior
Minimal Example
profile:
path: governance.profile.yml
document:
name: dbt
adapter:
paths:
projectDir: .
manifestPath: target/manifest.json
catalogPath: target/catalog.json
runResultsPath: target/run_results.json
sourcesPath: target/sources.json
options:
validationMode: strict
extension:
options:
signals: {}
metrics: {}
runtime:
cacheDir: .anarchitecture/dbt-governance/runtime
reportPath: target/governance-report.json
host:
artifactMode: use-existing-or-parse
output: human
ci:
failOnBlockingViolations: true
Supported Artifact Modes
require-existinguse-existing-onlyuse-existing-or-parse
Artifact mode behavior:
require-existing: require a resolvedmanifest.json; do not fall back todbt parseunless the user explicitly passes--parseuse-existing-only: prefer existing artifacts and never invokedbt parseuse-existing-or-parse: use existing artifacts when present, otherwise rundbt parse
Supported Output Modes
humanjson
Output mode behavior:
human: render human-readable CLI summariesjson: emit machine-readable JSON forcheckby default
failOnBlockingViolations
host.ci.failOnBlockingViolations controls how successful checks with blocking
violations map to the final exit code.
true: blocking violations return exit code1false: blocking violations are still rendered and written to reports, but the check returns exit code0
Artifact Lifecycle
The host owns operational artifact lifecycle decisions only.
- existing
target/manifest.jsonis preferred --use-existing-artifactsnever invokesdbt parse--parseinvokesdbt parseonly whenmanifest.jsonis missingcatalog.json,run_results.json, andsources.jsonare optional path hints- the host checks artifact availability and readability only
- the adapter and runtime perform authoritative loading, validation, and normalization after handoff
Runtime Setup
setup and doctor operate on the pinned runtime defined by
runtime_manifest.json.
The host:
- verifies Node.js
- verifies a supported package manager
- uses the pinned runtime package and version from the manifest
- pins
@anarchitects/governance-runtime-dbt@0.1.0 - requires contract version
1.0.0 - requires Node.js
>=20 <25 - installs into a controlled cache
- never installs globally
- never installs
latest - does not mutate the dbt project
package.json - does not mutate the repository
package.json
Default cache layout:
~/.cache/anarchitecture/dbt-governance/runtimes/@anarchitects/governance-runtime-dbt/<version>/
doctor reports:
- host version
- config path and load status
- runtime manifest values
- Node.js availability and compatibility
- package-manager availability
- runtime cache path
- installed runtime package name and version
- runtime executable availability
- overall runtime compatibility status
Runtime Handoff
The host invokes the runtime over a stable process boundary.
- the host writes JSON to
dbt-governance-runtimeoverstdin - the runtime writes JSON to
stdout stderris preserved as diagnostic context- non-zero runtime process exits preserve structured
stdoutJSON when it is valid - invalid runtime JSON remains a host invocation failure
- the host never imports runtime TypeScript internals
Output And Reports
check
- default output is human-readable summary output
--jsonemits machine-readable JSON only onstdout--report-pathwrites the JSON report envelope to disk
report
--format jsonemits the JSON report envelope--format markdownemits a markdown report--report-pathwrites the selected report format to disk
Exit Codes
0: successful check with no blocking violations, or blocking violations allowed byhost.ci.failOnBlockingViolations=false1: successful check with blocking violations whenhost.ci.failOnBlockingViolations=true2: host, dbt, or runtime setup or invocation failure3: unsupported or incompatible runtime or contract
E2E Test Strategy
The host e2e suite validates dbt-native host lifecycle and the process/JSON boundary using fake executables. It does not constitute a full real-runtime integration test.
Current e2e coverage:
- uses fake
dbt,node,npm, anddbt-governance-runtimeexecutables - validates host lifecycle, rendering, report writing, and exit codes
- validates the process/JSON boundary hermetically
- uses no warehouse
- uses no secrets
- uses no dbt Cloud
- uses no network for the main e2e suite
Fixture notes live in tests/fixtures/e2e/README.md.
Troubleshooting
Common host diagnostics include:
- missing
dbt_project.yml - missing
manifest.json dbtexecutable not founddbt parsefailed- missing Node.js
- unsupported Node.js version
- missing package manager
- runtime package missing from the controlled cache
- runtime package name or version mismatch
- runtime executable missing
- invalid runtime JSON output
- incompatible runtime metadata
- invalid
governance.yml
Related Docs
- dbt Governance Host
- ADR 0003
- Governance Boundary Contributor Guide
- Target Canonical Governance Model
Preview Release Checklist
Runtime prerequisite:
@anarchitects/governance-runtime-dbt@0.1.0must be published before releasing the Python host, becausedbt-governance setupinstalls the pinned runtime version.
Validation:
yarn nx run governance-host-dbt:lint
yarn nx run governance-host-dbt:test
yarn nx run governance-host-dbt:e2e
yarn nx run governance-host-dbt:build
Publish:
yarn nx run governance-host-dbt:nx-release-publish
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anarchitecture_dbt_governance-0.0.2.tar.gz.
File metadata
- Download URL: anarchitecture_dbt_governance-0.0.2.tar.gz
- Upload date:
- Size: 27.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d25bec7ae0b10da2a99a1c3bfe56e013c261dbd7a3a51fc270ae2d5d73edff2d
|
|
| MD5 |
1aa0be82bb440001849597bece2c0956
|
|
| BLAKE2b-256 |
06b32bf22e39b0d6465ec036ed0332aedf0d5e5c9175020c11193b8b3b95c1ee
|
File details
Details for the file anarchitecture_dbt_governance-0.0.2-py3-none-any.whl.
File metadata
- Download URL: anarchitecture_dbt_governance-0.0.2-py3-none-any.whl
- Upload date:
- Size: 34.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04544bd7597e188ddf19b4f92e861b17bb85b957d152921269a05b6af013e2fc
|
|
| MD5 |
4c8b49717f728d35923edab1776a493f
|
|
| BLAKE2b-256 |
fcd2802294b092c57a9e97fe973d9de4a3f2470bae9982d72c4de94c20e30b4d
|