feat: add syft-migration package foundation#9431
Merged
Merged
Conversation
New workspace package with the four migration building blocks: MigratableObject (canonical_name + version, auto-registering), PackageProtocolSchema (per-release protocol surface, one version per object, JSON metadata save/load), MigrationRegistry (per-package object/migration/schema store with sync invariant and BFS path-finding), and MigrationService (upgrade/downgrade incl. peer-version downgrade). Wired into the uv workspace and added a test-unit-migration Justfile target.
- Use kwargs over positional args in migration tests for readability - Drop redundant object_classes from PackageProtocolSchema; rename objects to object_versions - Make _identity raise instead of returning None; add _has_identity guard - Store registry objects as a nested canonical_name -> version -> class dict - Split register_migration into a direct method and a migration decorator - Rename register_object to register_object_version
…o koen/syft-migration-package
Comment on lines
+161
to
+181
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install the project | ||
| run: uv sync --all-extras | ||
|
|
||
| - name: Install just | ||
| run: | | ||
| curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin | ||
|
|
||
| - name: Run migration tests | ||
| run: just test-unit-migration |
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.
Foundational first ticket of the migrations epic (Asana 1216142685366749). Adds a new
syft-migrationworkspace package with the building blocks for on-the-fly object migration across syft packages, so peers running different package versions can exchange data by upgrading/downgrading objects.What's included
MigratableObject— pydantic base carryingcanonical_name(stable logical name, e.g.job) +version(e.g.2); concrete subclasses auto-register via__pydantic_init_subclass__(with aregistry=class kwarg for test isolation).PackageProtocolSchema— protocol surface of one release of one package (protocol_name,package_name,package_version, one version per object); JSONsave/loadfor package metadata.MigrationRegistry— per-package store of all object versions, migration edges (BFS path-finding for multi-step + downgrade), and current/historical protocol schemas.register_protocol_schemaenforces the schema↔object sync invariant (raises on conflicting class).MigrationService—migrate,migrate_to_schema,downgrade_for_package_version(peer-version downgrade),load.[tool.uv.sources]+testgroup) and added atest-unit-migrationJustfile target.No production objects are touched; the classes are exercised against mock objects in tests. Retrofitting real objects, per-package metadata wiring, and concrete migrations are left to later epic tickets.
Test plan
just test-unit-migration— 15 unit tests pass (auto-registration, sync invariant/conflict raise, current/history storage, multi-step upgrade, downgrade, peer-version downgrade, metadata round-trip, load).just test-unit-fast— 406 tests, unaffected.pre-commit run --all-files— clean.