Models / Validation

AttributeChange

class teksi_hooks.models.validation.AttributeChange(attribute_name, old_value, new_value)[source]

Represents the change of a single attribute within a row-level change.

The row-level context, such as table name, object id and operation type, remains on Change. This object only describes the changed attribute itself.

Parameters:
  • attribute_name (str)

  • old_value (Any | None)

  • new_value (Any | None)

Fields

attribute_name

Type: str

Name of the changed attribute.

old_value

Type: Any | None

Previous value of the attribute. For inserts this is usually None.

new_value

Type: Any | None

Submitted or resulting value of the attribute. For deletes this is usually None.

AttributeValidation

class teksi_hooks.models.validation.AttributeValidation(id, level, operations=<factory>, context_value=None, parameters=<factory>)[source]

Describes a validation rule attached to an attribute.

This is intentionally lightweight. The id identifies the validation implementation, while level controls the emitted severity.

Parameters:
  • id (str)

  • level (Severity)

  • operations (list[ChangeOperation])

  • context_value (str)

  • parameters (Mapping[str, Any])

Fields

id

Type: str

Identifier of the validation rule, for example newer_than_existing.

level

Type: Severity

Severity emitted when this validation produces a finding.

operations

Type: list[ChangeOperation]

List of ChangeOperations on which the AttributeValidation is executed. Defaults to insert, update and delete

context_value

Type: str

Optional context value name that is needed for validation, for example provider_oid or dataowner_oid.

parameters

Type: Mapping[str, Any]

Validation-specific configuration values interpreted by the selected validation implementation. Generic validation orchestration must not assign semantics to these entries.

Change

class teksi_hooks.models.validation.Change(table_name, object_id, operation, old_values, new_values)[source]

Represents a row-level change.

A change describes one inserted, updated or deleted object. Attribute-level changes can be derived from old_values and new_values via changed_attributes.

Parameters:
  • table_name (str)

  • object_id (str)

  • operation (ChangeOperation)

  • old_values (dict[str, Any])

  • new_values (dict[str, Any])

property changed_attributes: frozenset

Return attribute-level changes derived from old and new row values. Attributes whose old and new values are equal are omitted.

Fields

table_name

Type: str

Canonical table or class identifier affected by the change.

object_id

Type: str

Object identifier of the changed row.

operation

Type: ChangeOperation

Type of row-level operation: insert, update or delete.

old_values

Type: dict[str, Any]

Attribute values before the change. For inserts this is usually empty.

new_values

Type: dict[str, Any]

Attribute values after the change. For deletes this is usually empty.

ChangeClassificationMetadata

class teksi_hooks.models.validation.ChangeClassificationMetadata(classification, permitted=True, severity=None, permission_findings=<factory>, validation_findings=<factory>, classified_at=<factory>)[source]

Metadata explaining how and why a change was classified.

Parameters:
  • classification (ChangeClassification)

  • permitted (bool)

  • severity (Severity | None)

  • permission_findings (tuple[ValidationFinding, ...])

  • validation_findings (tuple[ValidationFinding, ...])

  • classified_at (datetime)

property findings: tuple[ValidationFinding, ...]

Combined findings for compatibility and simple consumers.

Fields

classification

Type: ChangeClassification

Review classification assigned to the change.

permitted

Type: bool

Whether the change is permitted by rights evaluation.

severity

Type: Severity | None

Highest severity associated with this classified change, if findings are attached.

permission_findings

Type: tuple[ValidationFinding, ...]

Permission or rights findings associated with this change.

validation_findings

Type: tuple[ValidationFinding, ...]

Validation findings associated with this change.

classified_at

Type: datetime

UTC timestamp at which the change was classified.

ClassValidationDefinition

class teksi_hooks.models.validation.ClassValidationDefinition(class_id, mandatory_attributes=<factory>, attribute_validations=<factory>, object_validations=<factory>)[source]

Validation configuration declared for one canonical class.

Class-specific mandatory attributes extend the defaults. Attribute and object validation entries with the same key replace their corresponding default entries.

Parameters:
  • class_id (str)

  • mandatory_attributes (frozenset[str])

  • attribute_validations (Mapping[str, tuple[AttributeValidation, ...]])

  • object_validations (Mapping[str, tuple[ObjectValidation, ...]])

Fields

class_id

Type: str

Canonical identifier of the configured class.

mandatory_attributes

Type: frozenset[str]

Class-specific canonical attributes that require a value. These attributes extend the default mandatory attributes.

attribute_validations

Type: Mapping[str, tuple[AttributeValidation, ...]]

Class-specific attribute validation rules keyed by canonical attribute identifier.

object_validations

Type: Mapping[str, tuple[ObjectValidation, ...]]

Class-specific object validation groups keyed by configuration identifier.

ClassifiedChange

class teksi_hooks.models.validation.ClassifiedChange(change, metadata)[source]

A change together with its review classification metadata.

Parameters:

Fields

change

Type: Change

The row-level canonical change.

metadata

Type: ChangeClassificationMetadata

Classification metadata for the change.

ClassifiedChanges

class teksi_hooks.models.validation.ClassifiedChanges(created_objects=<factory>, altered_objects=<factory>, deleted_objects=<factory>, unpermitted_changes=<factory>, metadata=<factory>)[source]

Collection of classified changes grouped for review/export.

This model is intentionally mutable. A workflow may enrich it incrementally with findings, review metadata or export artifacts.

Parameters:
all_changes()[source]

Return all classified changes in review order.

Return type:

tuple[ClassifiedChange, …]

add(classified_change)[source]

Add a classified change to the matching group.

Parameters:

classified_change (ClassifiedChange)

Return type:

None

Fields

created_objects

Type: list[ClassifiedChange]

Permitted insert changes.

altered_objects

Type: list[ClassifiedChange]

Permitted update changes.

deleted_objects

Type: list[ClassifiedChange]

Permitted delete changes.

unpermitted_changes

Type: list[ClassifiedChange]

Changes rejected by rights evaluation or validation.

metadata

Type: dict[str, str]

Workflow-level metadata for the classified change set. Examples: source model, import schema, provider oid, dataowner oid, job id, output folder.

ObjectValidation

class teksi_hooks.models.validation.ObjectValidation(id, level, operations=<factory>, parameters=<factory>)[source]

Describes a validation rule attached to a canonical object.

The rule identifier selects the validation implementation, while the severity controls the finding emitted by a failed validation.

Parameters:
  • id (str)

  • level (Severity)

  • operations (tuple[ChangeOperation, ...])

  • parameters (Mapping[str, Any])

Fields

id

Type: str

Identifier of the object-level validation implementation, for example ‘is_unique’.

level

Type: Severity

Severity emitted when the validation produces a finding.

operations

Type: tuple[ChangeOperation, ...]

Change operations for which this object validation is executed. Defaults to inserts and updates.

parameters

Type: Mapping[str, Any]

Validation-specific configuration values interpreted by the selected validation implementation. Generic validation orchestration must not assign semantics to these entries.

TransitionValidation

class teksi_hooks.models.validation.TransitionValidation(ruleset, allow_transitive=True)[source]

Describes transition validation for a class based on state-like attributes.

The transition graph is expressed as a set of StateTransitionRule instances. allow_transitive controls whether indirect paths through the transition graph are accepted.

Parameters:

Fields

ruleset

Type: frozenset[StateTransitionRule]

Allowed state transition rules for the attribute.

allow_transitive

Type: bool

Whether transitive transitions are allowed. If true, a transition may be accepted when a path exists through the transition graph, even if no direct edge exists.

ValidationContext

class teksi_hooks.models.validation.ValidationContext(class_id, identity=None, attribute_name=None, old_value=None, new_value=None, context_values=<factory>)[source]

Runtime context supplied to validation implementations.

Parameters:
  • class_id (str)

  • identity (CanonicalObjectIdentity | None)

  • attribute_name (str | None)

  • old_value (Any)

  • new_value (Any)

  • context_values (Mapping[str, Any])

Fields

class_id

Type: str

Canonical class identifier being validated.

identity

Type: CanonicalObjectIdentity | None

Canonical identity of the object being validated. This may be None for an inserted object whose complete canonical identity has not yet been derived.

attribute_name

Type: str | None

Canonical attribute identifier being validated.

old_value

Type: Any

Existing attribute value before the change.

new_value

Type: Any

New attribute value after the change.

context_values

Type: Mapping[str, Any]

Runtime context values available to validations, such as provider_oid and dataowner_oid.

ValidationDefinition

class teksi_hooks.models.validation.ValidationDefinition(mandatory_attributes=<factory>, attribute_validations=<factory>, object_validations=<factory>, classes=<factory>)[source]

Parsed canonical validation configuration.

Default definitions apply to every configured class unless replaced or extended by a class-specific definition.

Parameters:
mandatory_for_class(class_id)[source]

Return effective mandatory attributes for one canonical class.

Parameters:

class_id (str)

Return type:

frozenset[str]

attribute_validations_for_class(class_id)[source]

Return effective attribute validations for one canonical class.

Class-specific entries replace default entries with the same attribute identifier.

Parameters:

class_id (str)

Return type:

dict[str, tuple[AttributeValidation, …]]

object_validations_for_class(class_id)[source]

Return effective object validations for one canonical class.

Class-specific groups replace default groups with the same configuration identifier.

Parameters:

class_id (str)

Return type:

dict[str, tuple[ObjectValidation, …]]

Fields

mandatory_attributes

Type: frozenset[str]

Canonical attributes considered mandatory by default.

attribute_validations

Type: Mapping[str, tuple[AttributeValidation, ...]]

Default attribute validation rules keyed by canonical attribute identifier.

object_validations

Type: Mapping[str, tuple[ObjectValidation, ...]]

Default object validation groups keyed by configuration identifier.

classes

Type: Mapping[str, ClassValidationDefinition]

Class-specific validation definitions keyed by canonical class identifier.

ValidationFinding

class teksi_hooks.models.validation.ValidationFinding(severity, message, code, attribute_name=None)[source]

One validation finding emitted during validation.

Parameters:
  • severity (Severity)

  • message (str)

  • code (str)

  • attribute_name (str | None)

Base class: Finding

Fields

severity

Type: Severity

Severity level assigned to the finding.

message

Type: str

Human-readable description of the validation issue.

code

Type: str

Stable machine-readable validation identifier.

attribute_name

Type: str | None

Affected canonical attribute identifier if the finding applies to a specific attribute.