Repository navigation
Reconcile active SQL schema ownership with migration truth matrix guard - #2683
Open
groupthinking with Codex wants to merge 3 commits into
Open
groupthinking with Codex wants to merge 3 commits into
groupthinking with Codex wants to merge 3 commits into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 tasks
Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Contributor
🔍 PR Validation |
groupthinking
marked this pull request as ready for review
November 16, 2026 18:38
groupthinking
enabled auto-merge (squash)
November 16, 2026 18:39
Comment on lines
+54
to
+57
| def _extract_studio_columns_from_chat_store(chat_store: str) -> set[str]: | ||
| match = re.search(r"const columns = '([^']+)';", chat_store) | ||
| assert match, "Expected `const columns = '...';` in chat-store.ts" | ||
| return {value.strip() for value in match.group(1).split(",")} |
Contributor
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Production-reachable tables are incorrectly exempted from migration coverage, while the guard can miss schema, table-inventory, and security-policy drift.
6 open issues
Do not mark production-reachable tables non-production · New Verify SELECT projection supplies every required row-schema field · New Discover production tables independently of the matrix · New Validate RLS and tenant protections against migration SQL · New Compare schema against the full ordered migration chain · New Validate owner table declarations against the matrix · New
What changed in this PR
Documents SQL schema ownership and adds a source-level drift guard for UVAI’s Studio persistence and internal orchestration state, addressing part of AUDIT-007 (#2169). No runtime code or SQL migrations change.
Changes:
- Replaces the obsolete inventory with a machine-readable ownership matrix.
- Records shared runtime table classifications, tenant boundaries, row-level security, and Alembic status.
- Adds checks comparing Studio chat columns across migration SQL, the application’s query projection, and documentation.
| File | Description |
|---|---|
tests/unit/test_migration_truth_matrix.py |
Adds column-parity and required matrix-metadata checks. |
docs/MIGRATION_TRUTH.md |
Defines the ownership matrix, security notes, and guard scope. |
Review effort: Max
Comment on lines
+40
to
+46
| "non_production_domains": [ | ||
| { | ||
| "service": "internal runtime shared SQL state", | ||
| "table": "shared_sessions", | ||
| "owner_file": "src/youtube_extension/services/shared_sql_state.py", | ||
| "migration_strategy": "runtime_create_all", | ||
| "status": "allowed_non_migrated" |
Comment on lines
+55
to
+57
| match = re.search(r"const columns = '([^']+)';", chat_store) | ||
| assert match, "Expected `const columns = '...';` in chat-store.ts" | ||
| return {value.strip() for value in match.group(1).split(",")} |
Comment on lines
+67
to
+70
| production_by_table = { | ||
| entry["table"]: entry for entry in matrix["production_domains"] if "table" in entry | ||
| } | ||
| assert "studio_chats" in production_by_table |
Comment on lines
+76
to
+79
| assert studio_entry.get("rls") == "enabled+forced" | ||
| assert studio_entry.get("tenant_boundary") == "owner_subject + service_role access" | ||
|
|
||
| migration_sql = MIGRATION_PATH.read_text(encoding="utf-8") |
| assert studio_entry.get("rls") == "enabled+forced" | ||
| assert studio_entry.get("tenant_boundary") == "owner_subject + service_role access" | ||
|
|
||
| migration_sql = MIGRATION_PATH.read_text(encoding="utf-8") |
Comment on lines
+89
to
+99
| non_prod_by_table = { | ||
| entry["table"]: entry | ||
| for entry in matrix["non_production_domains"] | ||
| if "table" in entry | ||
| } | ||
| for table_name in ("shared_sessions", "shared_timeline_events", "shared_a2a_messages"): | ||
| assert table_name in non_prod_by_table | ||
| assert non_prod_by_table[table_name]["migration_strategy"] == "runtime_create_all" | ||
| assert non_prod_by_table[table_name]["owner_file"] == str( | ||
| SHARED_SQL_STATE_PATH.relative_to(REPO_ROOT).as_posix() | ||
| ) |
This branch was successfully deployed
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.


Canonical issue
Issue linking is handled by repository automation.
Outcome
This PR addresses schema-drift ambiguity by replacing legacy assumptions with a current, explicit SQL ownership matrix. It adds a guard that fails when production model columns, migration SQL, and documented mapping diverge.
Scope
docs/MIGRATION_TRUTH.mdnow contains a machine-readable active model→migration matrix, production/non-production domain classification, RLS/tenant boundary evidence, and Alembic status.tests/unit/test_migration_truth_matrix.pyenforcesstudio_chatsmapping and column parity acrosschat-store.ts, Supabase migration SQL, and documented matrix.shared_sql_statetables as runtime-managed (create_all) non-production schema surfaces.{ "production_domains": [ { "table": "studio_chats", "migration_file": "apps/web/supabase/migrations/20260912214530_create_private_studio_chat_ownership.sql", "rls": "enabled+forced" } ] }Risk
docs/MIGRATION_TRUTH.mdandtests/unit/test_migration_truth_matrix.py.Verification
List exact automated and manual checks, tied to the current head SHA.
Production evidence
Not applicable: documentation/test guard change only; no runtime behavior or production state transition.
Agent handoff
Security dependency evidence