helix_ir.diff

helix_ir.diff — schema diffing and change classification.

helix_ir.diff.diff(old: Schema, new: Schema) SchemaDiff[source]

Compare two schemas and return a SchemaDiff.

Classification rules: - Field removed: BREAKING (downstream consumers break) - Field added (nullable): SAFE - Field added (non-nullable): RISKY (existing data won’t have this field) - Type narrowed (e.g. string → int): BREAKING - Type widened (e.g. int32 → int64): SAFE - Type changed incompatibly: BREAKING - Nullable → non-nullable: RISKY - Non-nullable → nullable: SAFE - Semantic changed: RISKY - PII class added: RISKY - PII class removed: SAFE (becoming less sensitive)

class helix_ir.diff.SchemaDiff(old_name: str, new_name: str, changes: tuple[SchemaChange, ...])[source]

Bases: object

Result of comparing two schemas.

old_name: str
new_name: str
changes: tuple[SchemaChange, ...]
property has_breaking_changes: bool
property has_risky_changes: bool
filter(severity: str) SchemaDiff[source]

Return a new SchemaDiff containing only changes of the given severity.

filter_kind(kind: str) SchemaDiff[source]

Return a new SchemaDiff containing only changes of the given kind.

summary() dict[str, int][source]

Return a summary count of changes by severity.

class helix_ir.diff.SchemaChange(path: Path, kind: str, severity: str, old_type: HelixType | None, new_type: HelixType | None, description: str)[source]

Bases: object

A single change between two schema versions.

path: Path
kind: str
severity: str
old_type: HelixType | None
new_type: HelixType | None
description: str