gabriel / musehub public
feat BREAKING phase-5 dev
AI Agent gabriel · 126 days ago · May 12, 2026 · Diff

feat(phase-5): harden schema integrity checks and deploy gate

- Extract _build_alias_map and _inspect_schema as public module-level functions in schema_check.py so tests can drive them directly - Add JSONB vs JSON type drift detection (high-value: different index semantics) - Add VARCHAR length mismatch detection (catches truncation risk) - Add index existence check (ORM-declared indexes must exist in DB) - Add FK existence check (ORM-declared FKs must exist in DB) - Add musehub/db/schema_gate.py: filtered hard-fail deploy script using the same benign-diff filter as the S2 parity test - Replace warning-only alembic check in deploy/deploy.sh with hard-fail call to schema_gate (python -m musehub.db.schema_gate) - Expand test_schema_check.py: 21 tests covering all new checks; replace duplicated _run_inspect_logic with direct _inspect_schema import

sha256:b24102527e02ce4b195ae50208648286a7c517fc4a89b5dc2b3a38477591cd5d sha
+33 ~14 −6 symbols
sha256:944100eb7e993bcb143dcaa8950a018b3bb74ec8728b43582b67a78f85a1f86a snapshot
+33
symbols added
~14
symbols modified
−6
symbols removed
0
dead code introduced
Semantic Changes 53 symbols
~ musehub/db/schema_gate.py .py 4 symbols added
+ _is_benign_diff function function _is_benign_diff L22–45
+ annotations import import annotations L17–17
+ sys import import sys L19–19
+ main function function main L48–80
~ musehub/db/schema_check.py .py 2 symbols added, 1 symbol modified
+ _build_alias_map function function _build_alias_map L37–49
+ _inspect_schema function function _inspect_schema L52–168
~ tests/test_schema_check.py .py 27 symbols added, 6 symbols removed, 13 symbols modified
TestFailureDetection class class TestFailureDetection L163–216
test_alias_column_error_includes_orm_key method method test_alias_column_error_includes_orm_key L197–211
test_missing_column_detected method method test_missing_column_detected L169–181
test_missing_table_detected method method test_missing_table_detected L164–167
test_nullable_mismatch_detected method method test_nullable_mismatch_detected L183–195
_run_inspect_logic function function _run_inspect_logic L117–160
+ TestFkCheck class class TestFkCheck L372–402
+ test_missing_fk_detected method method test_missing_fk_detected L377–402
+ test_present_fk_passes method method test_present_fk_passes L373–375
+ TestIndexCheck class class TestIndexCheck L327–364
+ test_missing_index_detected method method test_missing_index_detected L332–364
+ test_present_index_passes method method test_present_index_passes L328–330
+ TestJsonbTypeCheck class class TestJsonbTypeCheck L238–274
+ test_json_instead_of_jsonb_detected method method test_json_instead_of_jsonb_detected L244–274
+ test_jsonb_in_db_passes method method test_jsonb_in_db_passes L239–242
+ test_fully_correct_schema_produces_no_mismatches method method test_fully_correct_schema_produces_no_mismatches L164–166
+ TestTableAndColumnChecks class class TestTableAndColumnChecks L174–230
+ test_alias_column_error_includes_orm_key method method test_alias_column_error_includes_orm_key L210–225
+ test_missing_column_detected method method test_missing_column_detected L180–193
+ test_missing_table_detected method method test_missing_table_detected L175–178
+ test_nullable_mismatch_detected method method test_nullable_mismatch_detected L195–208
+ TestVarcharLengthCheck class class TestVarcharLengthCheck L282–319
+ test_length_mismatch_detected method method test_length_mismatch_detected L287–319
+ test_matching_length_passes method method test_matching_length_passes L283–285
+ _Widget class class _Widget L57–65
+ _alias_map function function _alias_map L123–124
+ _good_inspector function function _good_inspector L89–120
+ ForeignKey import import ForeignKey L23–23
+ Index import import Index L23–23
+ JSONB import import JSONB L24–24
+ JSONValue import import JSONValue L27–27
+ _build_alias_map import import _build_alias_map L30–30
+ _inspect_schema import import _inspect_schema L30–30
~ String
~ Table
← Older Oldest on dev
All commits
Newer → Latest on dev

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:b24102527e02ce4b195ae50208648286a7c517fc4a89b5dc2b3a38477591cd5d --body "your comment"