fix: supports backup for governance migration - #4101
Conversation
|
Need an answer fast? Review this PR in Change Stack to ask focused questions about the PR or a changed range. Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughMigration conflict handling enhanced to preserve stranded governance relationships. When a user-created wildcard model config conflicts with provider migration, the code now creates savepoint-backed snapshots of governance budgets and rate limits into provider-keyed backup tables, logs failures non-blockingly, and rolls back on error instead of abandoning data preservation attempts. ChangesProvider Governance Migration Conflict Handling with Backup
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
b16243c to
e33c29b
Compare
Confidence Score: 1/5The PR introduces a compile-breaking syntax error that will prevent the binary from building. The The critical area is the Important Files Changed
|

Summary
Closed because all models support is being added in this release. So, there won't be any case to what this PR was fixing
When migrating provider governance to model configs, a conflict can occur if a user-created
(global, provider, '*')wildcard row already occupies the slot that the migration would otherwise create. In that case, the provider's own budget and rate-limit rows become stranded — detached from the provider FK but not folded into any model config. This PR adds a backup mechanism that snapshots those stranded rows intogovernance_provider_budgets_backupandgovernance_provider_rate_limits_backupbefore the FKs are cleared, giving support a data record from which governance can be restored on request.Changes
migrationMigrateProviderGovernanceToModelConfigs, the provider's existing budget and rate-limit rows are snapshotted into backup tables (governance_provider_budgets_backup/governance_provider_rate_limits_backup) keyed byprovider_name.CREATE TABLE IF NOT EXISTS ... WHERE 1 = 0so they only exist when a conflict actually occurs.migrations.go.Type of change
Affected areas
How to test
go test ./framework/configstore/... -run TestMigrationMigrateProviderGovernanceToModelConfigsThe three relevant test functions are:
TestMigrationMigrateProviderGovernanceToModelConfigs— verifies backup tables are absent when no conflict occurs.TestMigrationMigrateProviderGovernanceToModelConfigsConflictBackup— verifies correct snapshotting on conflict and idempotency.TestMigrationMigrateProviderGovernanceToModelConfigsBackupFailureNonBlocking— verifies a failing backup does not abort the migration.Breaking changes
Security considerations
Backup tables contain budget and rate-limit configuration data (limits, durations). No credentials or PII are stored. Tables are only created inside the existing migration transaction when a conflict is detected, and are scoped to the same database as the rest of the config store.
Checklist
docs/contributing/README.mdand followed the guidelinesSummary by CodeRabbit