refactor(client): split schema-drift validator into schema_validation.py#139
Merged
Conversation
Move the opt-in schema-drift validator out of the transport client into a new sibling module. Behavior-preserving: OutboxClient.validate_schema keeps its signature and delegates in one line; every moved symbol is verbatim. - client.py: 796 -> 471 LOC; no longer imports alembic - schema_validation.py: the validator + free validate_schema(engine, table, ...) - isolates the optional alembic dependency in the module that needs it - architecture/schema.md truth-home pointer promoted to the new module - tests repoint the five validator imports; no test body changed Full suite green (599 passed, coverage 100%), just lint + ty clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Behavior-preserving move of the opt-in schema-drift validator out of the transport client (
client.py) into a new sibling moduleschema_validation.py. No public-API change, no behavior change — every moved symbol is verbatim and the pre-existing 100%-coverage suite is the spec.Comes out of an architecture-deepening review: the validator was ~285 LOC of module-level functions merely co-located with the transport hot-path, sharing nothing with it but
self._table/self._engine. Splitting it deepens the transport client (its file halves) and concentrates the schema-drift concern — and its optionalalembicdependency — in one module.Changes
schema_validation.py(new, 381 LOC) — the 9 validator functions + 7 constants + the alembic guard block, fronted by one free functionvalidate_schema(engine, table, *, dlq_table=None, check_autovacuum=False).client.py: 796 → 471 LOC —OutboxClient.validate_schemakeeps its signature/docstring and delegates in one line; the transport client no longer importsalembic.ping,_row_to_message, and the DLQ CTE stay put.tests/test_unit.py— five validator symbols repointed to the new module (+ onepatch()target). No test body changed.architecture/schema.md— truth-home pointer promotedclient.py→schema_validation.py(same PR, per the promotion rule).planning/changes/2026-07-16.04-split-schema-validator.md— Lightweight change record.Verification
just test— 599 passed, Postgres 17, coverage 100.00% (integration ran)just lint— ruff clean,ty: All checks passedjust check-planning—planning: OK🤖 Generated with Claude Code