rdt-model-validate
Validates all artifacts generated by rdt-model-compile against their JSON Schemas,
syntax rules, and contract specifications. This is the pipeline gate — nothing
deploys until validation passes.
| Property | Value |
|---|---|
| Binary | rdt-model-validate |
| Pipeline phase | 3 — Prepare |
| Depends on | rdt-model-compile |
| Network | None |
| Credentials | None |
| Threading | Synchronous — read-only |
| Exit codes | 0 = all checks pass, 1 = runtime error, 2 = validation errors found |
Subcommands
Section titled “Subcommands”| Subcommand | Description | Implemented |
|---|---|---|
contract | Validate data contract against JSON Schema | Stub |
schema | Ad-hoc JSON Schema validation of any file | Stub |
dbt | Validate generated dbt models | Stub |
semantic | Validate Semantic YAML | Stub |
rules | Validate rule bindings and CEL expressions | Stub |
all | Run all checks | Stub |
Validate all artifacts
Section titled “Validate all artifacts”export RDT_TARGET=devrdt-model-validate all --entity waste-trackingOutput (current stub):
[target: dev]validate all: not yet implemented (entity: waste-tracking)Validate the data contract
Section titled “Validate the data contract”export RDT_TARGET=devrdt-model-validate contract --entity waste-trackingWhen implemented, this will:
- Read
models/waste-tracking/contract.yaml - Validate against
cli/compile/src/schemas/contract.schema.json - Run
datacontract-cli linton the output (Phase 1+) - Exit
0on success,2on any validation error
Validate rules
Section titled “Validate rules”export RDT_TARGET=devrdt-model-validate rules --entity waste-trackingWhen implemented, this will:
- Load rule bindings from
models/waste-tracking/rules.yaml - Verify all referenced rule IDs exist in
rules/library/ - Compile each CEL expression to validate syntax
- Report pass/fail per binding
Global flags
Section titled “Global flags”| Flag | Short | Env | Description |
|---|---|---|---|
--target | -t | RDT_TARGET | Required. dev, test, or prod |
--entity | -e | — | Entity slug (required for all subcommands) |
--quiet | -q | — | Suppress informational output |
--config | -c | — | Path to roche-data.toml (default: ./roche-data.toml) |
Exit codes
Section titled “Exit codes”Following ADR 0008, the validator uses a fixed exit code convention:
| Code | Meaning | When |
|---|---|---|
0 | All checks passed | Every check returned passed: true |
1 | Runtime error | Config load failed, file not found, unexpected error |
2 | Validation errors | At least one check returned passed: false |
CI pipelines should treat exit code 2 as a blocking failure distinct from
infrastructure errors (code 1).
# GitHub Actions — example usage- name: Validate artifacts run: rdt-model-validate all --entity waste-tracking --target dev # Exit code 2 fails the step and blocks the PR merge gateWhat each check validates
Section titled “What each check validates”contract — data contract schema
Section titled “contract — data contract schema”Validates models/{entity}/contract.yaml against contract.schema.json.
Key enforced constraints:
governance.terms_of_use— required, non-empty (added in #84)governance.pii— required booleangovernance.sla_days— required integer ≥ 0contract.version— semver format (\d+\.\d+\.\d+)contract.gupri_uri— must start withurn:gupri:roche:contract.fields— array with at least 1 item; each field requiresname,data_type,nullable,primary_key,description
schema — ad-hoc JSON Schema
Section titled “schema — ad-hoc JSON Schema”Validates any JSON/YAML file against any JSON Schema:
rdt-model-validate schema \ --entity waste-tracking \ --file models/waste-tracking/contract.yaml \ --schema cli/compile/src/schemas/contract.schema.jsondbt — dbt model syntax
Section titled “dbt — dbt model syntax”Validates generated dbt SQL and YAML files for syntax errors before
dbt compile is invoked in the deploy step.
semantic — Snowflake Semantic YAML
Section titled “semantic — Snowflake Semantic YAML”Validates the Semantic view YAML against the Snowflake Cortex Analyst schema.
rules — DQ rule validation
Section titled “rules — DQ rule validation”Validates that rule bindings reference valid rules from the library and that CEL expressions compile successfully. Uses the CEL-based DQ system (ADR 0013).
Rule tiers: Tier 1 (atomic), Tier 2 (lookup), Tier 3 (business)
Pipeline integration
Section titled “Pipeline integration”rdt-model-pull pull → models/{entity}/model.jsonrdt-model-compile contract → models/{entity}/contract.yamlrdt-model-validate all → exits 0 (gate passes) or 2 (gate fails)# deploy steps only run when validate exits 0In GitHub Actions, the validate step is the merge gate — the deploy workflow
only triggers after validate all passes on the PR.
Error handling
Section titled “Error handling”validate X: not yet implemented
Section titled “validate X: not yet implemented”validate contract: not yet implemented (entity: waste-tracking)The subcommand is a stub. The binary exits 0 (not 2) so the pipeline
is not blocked during the stub phase.
failed to load config
Section titled “failed to load config”Error: failed to load config: failed to read roche-data.tomlNo roche-data.toml in the current directory. Either run from the repo root
or pass --config /path/to/roche-data.toml.
RDT_TARGET must be set
Section titled “RDT_TARGET must be set”Error: RDT_TARGET must be set — use dev, test, or prodPass --target dev or set export RDT_TARGET=dev.
Troubleshooting
Section titled “Troubleshooting”Validation passes locally but fails in CI
Check that the same RDT_TARGET is used in both environments. Config
overrides in [environments.dev.*] differ from [environments.prod.*].
Contract schema validation fails after adding a new field type
The data_type field in contract fields is a free-form string — schema validation
does not enforce specific XSD or Snowflake type names. If validation is failing,
check that all required field properties (name, data_type, nullable,
primary_key, description) are present and non-null.
dbt tests pass but UDF validation fails (or vice versa)
Both dbt tests and Snowflake UDFs are compiled from the same CEL expressions
in rules/library/. If they diverge, regenerate both by running:
rdt-model-policy compile --entity <name>This ensures both targets reflect the current rule library state.