Skip to main content

Module schema_evolution

Module schema_evolution 

Source
Expand description

Autonomous schema evolution

Automatically detects schema changes from ingested events and manages schema evolution without manual intervention. Works alongside the existing SchemaRegistry to:

  1. Infer schemas from event payloads on first ingestion of a new event type
  2. Detect drift when new events have fields not in the registered schema
  3. Auto-register backward-compatible schema versions (new optional fields)
  4. Flag breaking changes that require manual review (type changes, removed required fields)

§How it works

On each event ingestion, the SchemaEvolutionManager compares the event’s payload structure against the latest registered schema for that event type. If differences are detected:

  • New optional fields → auto-registered as a new schema version
  • Type changes or missing required fields → flagged as breaking, not auto-registered

§Limitations

  • Only analyzes top-level and one level of nested fields
  • Type inference is basic: string, number, boolean, array, object, null
  • Does not handle polymorphic types (field sometimes string, sometimes number)
  • No automatic data migration — schemas describe shape, don’t transform data

Structs§

EvolutionRecord
A record of a schema evolution event
FieldSchema
An inferred field schema
FieldTypeChange
A field type change (potential breaking change)
InferredSchema
Schema shape inferred from a payload
SchemaDiff
Diff between two schemas
SchemaEvolutionManager
Schema evolution manager — tracks inferred schemas and evolution history
SchemaEvolutionStats
Schema evolution statistics

Enums§

EvolutionAction
Schema evolution event types
InferredType
Inferred JSON type for a field

Functions§

compute_diff
Compute the diff between an existing schema and a new payload’s inferred schema
infer_schema
Infer a schema shape from a JSON payload
to_json_schema
Convert an inferred schema to a JSON Schema document