Services / Change Classifier

ChangeClassifier

class teksi_hooks.services.change_classifier.ChangeClassifier(rights_evaluator)[source]

Classify changes into review groups and attach findings.

Classification rules:

  • INSERT + no blocking findings -> created_objects

  • UPDATE + no blocking findings -> altered_objects

  • DELETE + no blocking findings -> deleted_objects

  • rights denied -> unpermitted_changes

  • validation errors -> unpermitted_changes

  • unknown operation -> unpermitted_changes

Permission failures are represented as PermissionFinding.

Validation findings stay in validation_findings. Only blocking validation errors are stored there, because the database diff schema derives is_rejected from the presence of permission_findings or validation_findings.

Parameters:

rights_evaluator (RightsEvaluator)

classify(changes, context, validation_findings_by_change_key=None, metadata=None)[source]

Classify a sequence of changes.

Parameters

changes:

Changes to classify.

context:

Base rights evaluation context. Operation, old_values and new_values are replaced per change before rights evaluation.

validation_findings_by_change_key:

Optional validation findings keyed by (table_name, object_id, operation).

metadata:

Optional workflow-level metadata copied into the result.

Parameters:
Return type:

ClassifiedChanges

change_key(change)[source]

Return a stable key for attaching validation findings to a change.

This avoids using Change objects as dictionary keys, because Change is a workflow model and may be mutable.

Parameters:

change (Change)

Return type:

tuple[str, str, ChangeOperation]

Fields

rights_evaluator

Type: RightsEvaluator