Skip to content

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.

PropertyValue
Binaryrdt-model-validate
Pipeline phase3 — Prepare
Depends onrdt-model-compile
NetworkNone
CredentialsNone
ThreadingSynchronous — read-only
Exit codes0 = all checks pass, 1 = runtime error, 2 = validation errors found
SubcommandDescriptionImplemented
contractValidate data contract against JSON SchemaStub
schemaAd-hoc JSON Schema validation of any fileStub
dbtValidate generated dbt modelsStub
semanticValidate Semantic YAMLStub
rulesValidate rule bindings and CEL expressionsStub
allRun all checksStub
Terminal window
export RDT_TARGET=dev
rdt-model-validate all --entity waste-tracking

Output (current stub):

[target: dev]
validate all: not yet implemented (entity: waste-tracking)
Terminal window
export RDT_TARGET=dev
rdt-model-validate contract --entity waste-tracking

When implemented, this will:

  1. Read models/waste-tracking/contract.yaml
  2. Validate against cli/compile/src/schemas/contract.schema.json
  3. Run datacontract-cli lint on the output (Phase 1+)
  4. Exit 0 on success, 2 on any validation error
Terminal window
export RDT_TARGET=dev
rdt-model-validate rules --entity waste-tracking

When implemented, this will:

  1. Load rule bindings from models/waste-tracking/rules.yaml
  2. Verify all referenced rule IDs exist in rules/library/
  3. Compile each CEL expression to validate syntax
  4. Report pass/fail per binding
FlagShortEnvDescription
--target-tRDT_TARGETRequired. dev, test, or prod
--entity-eEntity slug (required for all subcommands)
--quiet-qSuppress informational output
--config-cPath to roche-data.toml (default: ./roche-data.toml)

Following ADR 0008, the validator uses a fixed exit code convention:

CodeMeaningWhen
0All checks passedEvery check returned passed: true
1Runtime errorConfig load failed, file not found, unexpected error
2Validation errorsAt 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 gate

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 boolean
  • governance.sla_days — required integer ≥ 0
  • contract.version — semver format (\d+\.\d+\.\d+)
  • contract.gupri_uri — must start with urn:gupri:roche:
  • contract.fields — array with at least 1 item; each field requires name, data_type, nullable, primary_key, description

Validates any JSON/YAML file against any JSON Schema:

Terminal window
rdt-model-validate schema \
--entity waste-tracking \
--file models/waste-tracking/contract.yaml \
--schema cli/compile/src/schemas/contract.schema.json

Validates generated dbt SQL and YAML files for syntax errors before dbt compile is invoked in the deploy step.

Validates the Semantic view YAML against the Snowflake Cortex Analyst schema.

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)

rdt-model-pull pull → models/{entity}/model.json
rdt-model-compile contract → models/{entity}/contract.yaml
rdt-model-validate all → exits 0 (gate passes) or 2 (gate fails)
# deploy steps only run when validate exits 0

In GitHub Actions, the validate step is the merge gate — the deploy workflow only triggers after validate all passes on the PR.

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.

Error: failed to load config: failed to read roche-data.toml

No roche-data.toml in the current directory. Either run from the repo root or pass --config /path/to/roche-data.toml.

Error: RDT_TARGET must be set — use dev, test, or prod

Pass --target dev or set export RDT_TARGET=dev.

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:

Terminal window
rdt-model-policy compile --entity <name>

This ensures both targets reflect the current rule library state.