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_nameType:
strName of the changed attribute.
old_valueType:
Any | NonePrevious value of the attribute. For inserts this is usually None.
new_valueType:
Any | NoneSubmitted 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
idType:
strIdentifier of the validation rule, for example newer_than_existing.
levelType:
SeveritySeverity emitted when this validation produces a finding.
operationsType:
list[ChangeOperation]List of ChangeOperations on which the AttributeValidation is executed. Defaults to insert, update and delete
context_valueType:
strOptional context value name that is needed for validation, for example provider_oid or dataowner_oid.
parametersType:
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_nameType:
strCanonical table or class identifier affected by the change.
object_idType:
strObject identifier of the changed row.
operationType:
ChangeOperationType of row-level operation: insert, update or delete.
old_valuesType:
dict[str, Any]Attribute values before the change. For inserts this is usually empty.
new_valuesType:
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
classificationType:
ChangeClassificationReview classification assigned to the change.
permittedType:
boolWhether the change is permitted by rights evaluation.
severityType:
Severity | NoneHighest severity associated with this classified change, if findings are attached.
permission_findingsType:
tuple[ValidationFinding, ...]Permission or rights findings associated with this change.
validation_findingsType:
tuple[ValidationFinding, ...]Validation findings associated with this change.
classified_atType:
datetimeUTC 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_idType:
strCanonical identifier of the configured class.
mandatory_attributesType:
frozenset[str]Class-specific canonical attributes that require a value. These attributes extend the default mandatory attributes.
attribute_validationsType:
Mapping[str, tuple[AttributeValidation, ...]]Class-specific attribute validation rules keyed by canonical attribute identifier.
object_validationsType:
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:
change (Change)
metadata (ChangeClassificationMetadata)
Fields
changeType:
ChangeThe row-level canonical change.
metadataType:
ChangeClassificationMetadataClassification 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:
created_objects (list[ClassifiedChange])
altered_objects (list[ClassifiedChange])
deleted_objects (list[ClassifiedChange])
unpermitted_changes (list[ClassifiedChange])
metadata (dict[str, str])
- 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_objectsType:
list[ClassifiedChange]Permitted insert changes.
altered_objectsType:
list[ClassifiedChange]Permitted update changes.
deleted_objectsType:
list[ClassifiedChange]Permitted delete changes.
unpermitted_changesType:
list[ClassifiedChange]Changes rejected by rights evaluation or validation.
metadataType:
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
idType:
strIdentifier of the object-level validation implementation, for example ‘is_unique’.
levelType:
SeveritySeverity emitted when the validation produces a finding.
operationsType:
tuple[ChangeOperation, ...]Change operations for which this object validation is executed. Defaults to inserts and updates.
parametersType:
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:
ruleset (frozenset[StateTransitionRule])
allow_transitive (bool)
Fields
rulesetType:
frozenset[StateTransitionRule]Allowed state transition rules for the attribute.
allow_transitiveType:
boolWhether 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_idType:
strCanonical class identifier being validated.
identityType:
CanonicalObjectIdentity | NoneCanonical identity of the object being validated. This may be None for an inserted object whose complete canonical identity has not yet been derived.
attribute_nameType:
str | NoneCanonical attribute identifier being validated.
old_valueType:
AnyExisting attribute value before the change.
new_valueType:
AnyNew attribute value after the change.
context_valuesType:
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_attributes (frozenset[str])
attribute_validations (Mapping[str, tuple[AttributeValidation, ...]])
object_validations (Mapping[str, tuple[ObjectValidation, ...]])
classes (Mapping[str, ClassValidationDefinition])
- 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_attributesType:
frozenset[str]Canonical attributes considered mandatory by default.
attribute_validationsType:
Mapping[str, tuple[AttributeValidation, ...]]Default attribute validation rules keyed by canonical attribute identifier.
object_validationsType:
Mapping[str, tuple[ObjectValidation, ...]]Default object validation groups keyed by configuration identifier.
classesType:
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
severityType:
SeveritySeverity level assigned to the finding.
messageType:
strHuman-readable description of the validation issue.
codeType:
strStable machine-readable validation identifier.
attribute_nameType:
str | NoneAffected canonical attribute identifier if the finding applies to a specific attribute.