Repository navigation
feat(storage): implement Spanner DDL migrations for components and snapshots - #484
Merged
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces Spanner schema changes and migrations to support a new components system, adding the Components, ComponentDependencies, and ExperimentComponentSnapshots tables, as well as the ExperimentConsistencyInfo view. The review feedback highlights critical performance and optimization improvements: first, a secondary index should be added to ComponentDependencies(DependencyComponentId) to avoid full table scans on parent table updates/deletes (and dropped in the down migration); second, the LEFT JOINs in the ExperimentConsistencyInfo view should be simplified to INNER JOINs since the foreign key constraints guarantee matching rows.
VLukiantsev
force-pushed
the
feat/components-spanner-migrations-b548436412
branch
from
August 19, 2026 21:52
2e72d93 to
03e2e1c
Compare
VLukiantsev
changed the base branch from
main
to
fix/ui-server-test-regression-and-rdeps
August 19, 2026 21:53
VLukiantsev
marked this pull request as ready for review
August 19, 2026 22:05
Base automatically changed from
fix/ui-server-test-regression-and-rdeps
to
main
August 20, 2026 06:56
…apshots Implement Cloud Spanner schema migrations and baseline DDL for the XMC Components system catalog and experiment snapshots (Option C Hybrid SOT). Key Additions: - Components table: Stores registered 1P/3P components, generation, and active state. Uses a stored generated column ActiveName and a unique null-filtered index Idx_Components_ActiveName to enforce active name uniqueness while retaining soft-deleted rows. - ComponentDependencies table: Interleaved under Components with cascade deletion and foreign key constraint to track inter-component dependencies. - ExperimentComponentSnapshots table: Interleaved under Experiments with cascade deletion to lock component configuration versions to specific experiment runs. - ExperimentConsistencyInfo view: Evaluates runtime consistency between live component generations and experiment snapshots. - Up and down migration scripts for clean schema upgrade and rollback. Fixes bug 548436412 TAG=agy CONV=946866f9-38d1-497a-ac2d-0eda5d3e6080
…y view join Add secondary index Idx_ComponentDependencies_Dependency on ComponentDependencies(DependencyComponentId) to optimize foreign key scans on Components table updates and deletions. Update down migration to drop this index. Simplify ExperimentConsistencyInfo view joins from LEFT JOIN to INNER JOIN since foreign key constraints enforce referential integrity. Comment link: #484 (comment) Comment link: #484 (comment) Comment link: #484 (comment) Comment link: #484 (comment) Comment link: #484 (comment) TAG=agy CONV=946866f9-38d1-497a-ac2d-0eda5d3e6080
VLukiantsev
force-pushed
the
feat/components-spanner-migrations-b548436412
branch
from
August 20, 2026 06:56
03e2e1c to
a160165
Compare
AntonTyb
approved these changes
Aug 20, 2026
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.
Summary
Implements Cloud Spanner schema migrations and updated baseline DDL for the XMC Components system catalog and experiment snapshots (Option C Hybrid SOT model).
Motivation & Context
As specified in the AI Components Design Doc and POC PR #456, XMC Components require persistent storage for registered custom components (1P/3P), dependency tracking, immutable per-experiment snapshot locking, and real-time experiment consistency evaluation.
Key Changes
010_components_system.up.sql/010_components_system.down.sql):Components: Primary keyComponentId INT64. IncludesActiveNamegenerated column (IF(State != 5, Name, NULL)) with unique null-filtered indexIdx_Components_ActiveNameto guarantee active name uniqueness while retaining soft-deleted records. Check constraintCK_Components_Statevalidates state enums (1..5).ComponentDependencies: Interleaved in parentComponentson delete cascade, with foreign key referenceFK_Dependencyand secondary indexIdx_ComponentDependencies_DependencyonDependencyComponentIdto optimize foreign key scans on parent deletes.ExperimentComponentSnapshots: Interleaved in parentExperimentson delete cascade, with secondary indexIdx_Snapshots_Componentand foreign key referenceFK_Snapshots_Component.ExperimentConsistencyInfo: Security invoker view evaluating drift between live componentObservedGenerationand experiment snapshots for active experiments usingINNER JOINs.ess-schema.sql): Appended table, index, and view definitions matching migration 010.Verification & Testing
bazel test //internal/storage/spanner/migrations:migrations_test --nocache_test_results(Passed - verifiedTestSchemaSynchronizationandTestMigrationUpDownConsistencyagainst Spanner Emulator)bazel test -- //... -//cmd/ui/...(All 110 backend test targets passed)gofmt,golangci-lint,addlicense, Ruff) executed and passed cleanly.Related Issues / Bugs
Fixes bug 548436412
TAG=agy
CONV=946866f9-38d1-497a-ac2d-0eda5d3e6080