kelp.models.policy_definition¶
Reference for the Policy definition model — the top-level governance rule set that maps to a path pattern and contains model and column rules.
kelp.models.policy_definition.Policy
pydantic-model
¶
Bases: BaseModel
Policy definition for a specific scope or layer.
Represents a set of governance rules that apply to tables in specified paths.
Attributes:
| Name | Type | Description |
|---|---|---|
origin_file_path |
SkipJsonSchema[str] | None
|
Path to the source YAML file defining this policy. |
name |
str
|
Policy name (e.g., "bronze_layer", "data_quality"). |
applies_to |
str | None
|
Glob pattern for models this policy applies to (e.g., "models/bronze/*").
Must start with "models/" and use forward slashes. Matched against the
|
model |
ModelPolicyRule
|
Rules applied at the model level. |
column |
ColumnPolicyRule
|
Rules applied at the column level. |
raw_config |
SkipJsonSchema[dict]
|
Original unparsed configuration. |
Show JSON schema:
{
"$defs": {
"ColumnPolicyRule": {
"description": "Policy rules for column-level governance checks.\n\nAttributes:\n require_description: Each column must have a non-empty description.\n require_tags: Specific tag keys that must be present on each column.\n require_any_tag: At least one tag must exist on each column.\n naming_pattern: Regex pattern that column names must match.\n naming_patterns_by_type: Naming patterns for specific data types.\n not_: Negate checks for this rule block (YAML key: ``not``).\n severity: Severity when this rule is violated.",
"properties": {
"require_description": {
"default": false,
"description": "Each column must have a non-empty description",
"title": "Require Description",
"type": "boolean"
},
"require_tags": {
"description": "Specific tag keys that must be present on each column",
"items": {
"type": "string"
},
"title": "Require Tags",
"type": "array"
},
"require_any_tag": {
"default": false,
"description": "At least one tag must exist on each column",
"title": "Require Any Tag",
"type": "boolean"
},
"naming_pattern": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Regex pattern that all column names must match",
"title": "Naming Pattern"
},
"naming_patterns_by_type": {
"description": "Regex patterns for column names by data type",
"items": {
"$ref": "#/$defs/NamingPattern"
},
"title": "Naming Patterns By Type",
"type": "array"
},
"not": {
"default": false,
"description": "Negate checks for this rule block",
"title": "Not",
"type": "boolean"
},
"severity": {
"$ref": "#/$defs/PolicySeverity",
"default": "warn",
"description": "Severity level when a rule is violated"
}
},
"title": "ColumnPolicyRule",
"type": "object"
},
"ModelPolicyRule": {
"description": "Policy rules for table-level governance checks.\n\nAttributes:\n require_description: Table must have a non-empty description.\n require_tags: Specific tag keys that must be present on the table.\n require_any_tag: At least one tag must exist on the table.\n require_constraints: Constraint types that must be defined (e.g. \"primary_key\").\n naming_pattern: Regex pattern that table names must match.\n has_columns: Column names that must be present in the table.\n has_table_property: Table properties that must exist (partial match, allows extra keys).\n has_quality_check: Table must have quality checks configured.\n not_: Negate checks for this rule block (YAML key: ``not``).\n severity: Severity when this rule is violated.",
"properties": {
"require_description": {
"default": false,
"description": "Table must have a non-empty description",
"title": "Require Description",
"type": "boolean"
},
"require_tags": {
"description": "Specific tag keys that must be present on the table",
"items": {
"type": "string"
},
"title": "Require Tags",
"type": "array"
},
"require_any_tag": {
"default": false,
"description": "At least one tag must exist on the table",
"title": "Require Any Tag",
"type": "boolean"
},
"require_constraints": {
"description": "Constraint types that must be defined (e.g. 'primary_key', 'foreign_key')",
"items": {
"type": "string"
},
"title": "Require Constraints",
"type": "array"
},
"naming_pattern": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Regex pattern that table names must match",
"title": "Naming Pattern"
},
"has_columns": {
"description": "Column names that must be present in the table",
"items": {
"type": "string"
},
"title": "Has Columns",
"type": "array"
},
"has_table_property": {
"additionalProperties": true,
"description": "Table properties that must exist (partial match, allows extra keys)",
"title": "Has Table Property",
"type": "object"
},
"has_quality_check": {
"default": false,
"description": "Table must have quality checks configured",
"title": "Has Quality Check",
"type": "boolean"
},
"not": {
"default": false,
"description": "Negate checks for this rule block",
"title": "Not",
"type": "boolean"
},
"severity": {
"$ref": "#/$defs/PolicySeverity",
"default": "warn",
"description": "Severity level when a rule is violated"
}
},
"title": "ModelPolicyRule",
"type": "object"
},
"NamingPattern": {
"description": "Naming convention rule for a specific data type.\n\nAttributes:\n data_type: SQL data type this pattern applies to (e.g., \"STRING\", \"BOOLEAN\").\n pattern: Regex pattern that column names must match (e.g., \"^(is_|has_).*\").",
"properties": {
"data_type": {
"description": "SQL data type (e.g. STRING, BOOLEAN, INT)",
"title": "Data Type",
"type": "string"
},
"pattern": {
"description": "Regex pattern column names must match",
"title": "Pattern",
"type": "string"
}
},
"required": [
"data_type",
"pattern"
],
"title": "NamingPattern",
"type": "object"
},
"PolicySeverity": {
"description": "Severity level for policy violations.\n\nAttributes:\n warn: Log a warning but do not fail.\n error: Raise an error and stop processing.",
"enum": [
"warn",
"error"
],
"title": "PolicySeverity",
"type": "string"
}
},
"description": "Policy definition for a specific scope or layer.\n\nRepresents a set of governance rules that apply to tables in specified paths.\n\nAttributes:\n origin_file_path: Path to the source YAML file defining this policy.\n name: Policy name (e.g., \"bronze_layer\", \"data_quality\").\n applies_to: Glob pattern for models this policy applies to (e.g., \"models/bronze/*\").\n Must start with \"models/\" and use forward slashes. Matched against the\n `origin_file_path` of models. See module docstring for examples.\n model: Rules applied at the model level.\n column: Rules applied at the column level.\n raw_config: Original unparsed configuration.",
"properties": {
"name": {
"description": "Policy name",
"title": "Name",
"type": "string"
},
"applies_to": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Glob pattern for models this applies to (e.g. 'models/bronze/*'). Must start with 'models/' and use forward slashes.",
"title": "Applies To"
},
"model": {
"$ref": "#/$defs/ModelPolicyRule",
"description": "Model-level policy rules"
},
"column": {
"$ref": "#/$defs/ColumnPolicyRule",
"description": "Column-level policy rules"
},
"meta": {
"additionalProperties": true,
"description": "Generic user-defined metadata for filtering and grouping",
"title": "Meta",
"type": "object"
}
},
"required": [
"name"
],
"title": "Policy",
"type": "object"
}
Fields:
-
origin_file_path(SkipJsonSchema[str] | None) -
name(str) -
applies_to(str | None) -
model(ModelPolicyRule) -
column(ColumnPolicyRule) -
meta(dict[str, Any]) -
raw_config(SkipJsonSchema[dict])
origin_file_path
pydantic-field
¶
Path to the source YAML file defining this policy
applies_to
pydantic-field
¶
Glob pattern for models this applies to (e.g. 'models/bronze/*'). Must start with 'models/' and use forward slashes.
raw_config
pydantic-field
¶
Original unparsed configuration preserving placeholder variables