# Avro Schema Evolution Audit

> Audit Apache Avro writer-reader schema compatibility offline with binary encoding/decoding across defaults, numeric promotions, unions, aliases, enums, and dire

- Skill: `ranbot-ai/avro-schema-evolution-audit` (Agent Skill)
- Install (CLI): `npx get-skill add ranbot-ai/avro-schema-evolution-audit`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ranbot-ai/avro-schema-evolution-audit/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: ranbot-ai (https://skillmd.com/u/ranbot-ai)
- Updated: 2026-12-03
- Page: https://skillmd.com/skills/ranbot-ai/avro-schema-evolution-audit

---

---
name: avro-schema-evolution-audit
description: Audit Apache Avro writer-reader schema compatibility offline with binary encoding/decoding across defaults, numeric promotions, unions, aliases, enums, and direction rules. 
category: Document Processing
source: antigravity
tags: [python, ai, agent, design, document, aws, cro]
url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/avro-schema-evolution-audit
---


# Avro Schema Evolution Audit

## Overview

Verify Apache **Avro** writer-reader schema evolution offline using real binary encoding and decoding (`fastavro.schemaless_writer` and `fastavro.schemaless_reader`) grounded in the Apache Avro `1.12.0` schema resolution specification. Tests concrete schema changes in both directions (`old writer -> new reader` and `new writer -> old reader`), asserts exact decoded payloads and `SchemaResolutionError` failures, and separates pairwise compatibility checks from transitive registry guarantees.

Distinction from existing data and event-sourcing skills:
- `snowflake-development`: covers Snowflake SQL, Snowpark, and `VARIANT` semi-structured queries rather than Avro binary schema resolution.
- `data-engineer` and `data-engineering-data-pipeline`: provide broad ETL, Kafka, and lakehouse architecture patterns without executable Avro wire-compatibility checks.
- `event-sourcing-architect` and `event-store-design`: model CQRS aggregates, projections, and snapshotting without testing Avro writer/reader binary evolution rules.

## When to Use

- Reviewing an Avro `.avsc` schema change before publishing producers or upgrading consumers.
- Testing added fields with/without defaults, removed fields, numeric widening vs. disallowed narrowing, union branch evolution, field `aliases`, and `enum` symbol evolution (`default` fallback vs. resolution error).
- Verifying backward (`old writer -> new reader`) and forward (`new writer -> old reader`) behavior locally before CI or staging rollout.
- Do **not** use this skill to connect to production Confluent/AWS Glue Schema Registries or modify live compatibility settings.

## Prerequisites

- Python 3.10+ with `fastavro` (tested with Python `3.12.10`, `fastavro==1.13.1`, and `pytest==9.1.1`).
- Synthetic or sanitized writer/reader `.avsc` JSON schemas and representative sample records covering every union branch and enum symbol under test.
- **No production schema registry access, network requests, or live brokers required.**

## How It Works

### 1. Encode and decode real Avro binary frames

1. Parse both schemas with `fastavro.parse_schema(...)` so invalid JSON or unknown types raise structured parse errors (`SchemaParseException` / `UnknownType` / `ValueError`).
2. Encode each sample record with `fastavro.schemaless_writer(buf, writer_schema, record)` and decode using `fastavro.schemaless_reader(buf, writer_schema, reader_schema)`.

### 2. Test both evolution directions and union branches

Run the local verification suite in [avro evolution harness](references/avro-evolution-harness.md):

1. **Field addition & removal:**
   - Added reader field with valid `default`: decodes old writer bytes with exact default (**backward compatible**).
   - Added required field without `default`: raises `SchemaResolutionError` on old writer data.
   - Removed field: new reader drops absent field cleanly (**backward**), while old reader without a default fails on new writer data (**forward broken**).
2. **Numeric promotions & narrowing:**
   - Avro `1.12.0` permits `int -> long/float/double`, `long -> float/double`, `float -> double`; narrowing (`long -> int`, `double -> float`, `double -> long`) must raise `SchemaResolutionError`.
3. **Unions (`[...]`):**
   - Test **every relevant union branch** independently (`null` branch passing never proves non-null branches like `long` vs. `string` resolve!).
4. **Aliases & enums:**
   - Verify `aliases` remaps renamed fields during binary resolution.
   - Verify enum symbol additions and reader enum `default` fallback (`"default": "UNKNOWN"`) vs. `SchemaResolutionError` when an unmapped symbol arrives.

### 3. Classify compatibility honestly (never overclaim transitivity)

Represent **each direction separately** as **`PASS`, `FAIL`, `NOT_TESTED`, or `INVALID_INPUT`** (`backward_status`, `forward_status`); `classification` is a truthful pairwise `"<backward>/<forward> (pairwise samples only)"` summary:

- **`PASS`**: valid schema + ≥1 tested sample in that direction + every tested sample resolved.
- **`FAIL`**: valid schema + ≥1 tested sample produced a genuine `fastavro.read.SchemaResolutionError`, no invalid inputs.
- **`NOT_TESTED`**: no samples provided in that direction. **Absent evidence is not failed compatibility; do not classify untested directions as incompatible.** Both lists empty => `NOT_TESTED`/`NOT_TESTED`; valid old + no new => backward `PASS`, forward `NOT_TESTED`.
- **`INVALID_INPUT`**: invalid schema (`SchemaParseException`/`UnknownType`/`ValueError`/`KeyError`/`TypeError`) or invalid record input (not a valid record for the writer schema; `ValidationError`/`TypeError`/`ValueError`/`KeyError`). **Invalid schema/record inputs are distinguished from genuine `SchemaResolutionError` compatibility failures** (`invalid_inputs` vs `resolution_errors`).

Explicitly note:
- **Pairwise sample-only limitation preserved:** a passing test on a single schema pair `(v1, v2)` or subset of sample records **ca

