Post-migration validation (--validate) - #23
Open
Doug Guthrie (dpguthrie) wants to merge 3 commits into
Open
Conversation
New braintrust_migrate/validation.py provides the reusable validation engine: - Object parity: list source vs dest for a project-scoped resource, compare, and report the specific items missing in the destination (cheap; small N). - Event count-parity: a single cheap BTQL count() per parent (per dataset / experiment / project) compared source vs dest. We do NOT enumerate which events are missing — that requires diffing full id sets and doesn't scale; counts are reported per parent so a gap can still be localized to an object. Mirrors migration policy via per-resource specs: functions exclude bundle- backed code (intentionally skipped), and roles/groups/ai_secrets/ACLs are out of scope. validate_resource() dispatches by resource name; matching pairs by slug/name and uses the migration id_mapping when available; counts honor the same created_after/before window as the migration. This is the engine only — wiring (a --validate flag, orchestrator phase, and report/console output) is separate. Tests cover object missing-items, the function bundle exclusion, event match/mismatch, logs, and the count window. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds the --validate/--no-validate flag (MIGRATION_VALIDATE env), a validate_migration config field, the orchestrator validation phase (_validate_project) that runs after each project migrates, inclusion of the validation block in migration_report.json, and the console summary rendering. Extracts a module-level list_resources() in base.py so the validation core can list destination resources without a migrator instance. Documents the feature in README and CHANGELOG. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Skipping a bundle-backed code function is expected behavior, not a problem — demote the per-function skip log from warning to info so it doesn't surface as noise during normal migrations. 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.
Summary
Adds an optional post-migration validation phase. Pass
--validate(orMIGRATION_VALIDATE=true) and, after migrating, the tool validates the destination against the source per project:countof events per dataset/experiment and per project for logs.Results are summarized per resource in the console (mismatches listed, with a pointer to the full report) and recorded under each project's
validationblock inmigration_report.json.Design notes
--created-after/--created-beforewindow.id_mappingwhen available, falling back to slug/name.Implementation
validation.py— reusable core (validate_resource,count_events,VALIDATION_SPECS). (committed earlier on this branch)resources/base.py— extracted module-levellist_resources()so the core can list resources without a migrator instance; the existing method now delegates.config.py—validate_migrationfield +MIGRATION_VALIDATEenv parsing.cli.py—--validate/--no-validateoption + console validation summary.orchestration.py—_validate_projectphase + inclusion in the migration report.Tests
tests/unit/test_validation.py— 7 tests for the core.tests/unit/test_validation_wiring.py— orchestrator aggregation, console rendering, andfrom_envflag parsing.Not yet done
🤖 Generated with Claude Code