Skip to content

feat: add syft-migration package foundation#9431

Merged
koenvanderveen merged 7 commits into
devfrom
koen/syft-migration-package
Jul 1, 2026
Merged

feat: add syft-migration package foundation#9431
koenvanderveen merged 7 commits into
devfrom
koen/syft-migration-package

Conversation

@koenvanderveen

Copy link
Copy Markdown
Collaborator

Foundational first ticket of the migrations epic (Asana 1216142685366749). Adds a new syft-migration workspace 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 carrying canonical_name (stable logical name, e.g. job) + version (e.g. 2); concrete subclasses auto-register via __pydantic_init_subclass__ (with a registry= class kwarg for test isolation).
  • PackageProtocolSchema — protocol surface of one release of one package (protocol_name, package_name, package_version, one version per object); JSON save/load for 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_schema enforces the schema↔object sync invariant (raises on conflicting class).
  • MigrationServicemigrate, migrate_to_schema, downgrade_for_package_version (peer-version downgrade), load.
  • Wired into the uv workspace ([tool.uv.sources] + test group) and added a test-unit-migration Justfile 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.

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
@koenvanderveen koenvanderveen enabled auto-merge July 1, 2026 12:45
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
@koenvanderveen koenvanderveen merged commit b6a55b0 into dev Jul 1, 2026
19 checks passed
@koenvanderveen koenvanderveen deleted the koen/syft-migration-package branch July 1, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants