SEP-1755: Move FormReconstructor and FormBackfillContext into form_backfill_registry so the entry contract stops importing its own consumer - #1343
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the “form backfill” contract so app packages can depend on the contract types (FormReconstructor, FormBackfillContext) without importing the form_backfill orchestrator module, and adds import-boundary tests to prevent that dependency from creeping back in.
Changes:
- Moved
FormBackfillContextandFormReconstructorintoform_backfill_registryand updated the orchestrator and app backfill modules to import from the registry. - Updated
form_backfill_inventoryto avoid importing the registry by using a local protocol for the minimal context shape it needs. - Added import-boundary tests that detect both import-time and
TYPE_CHECKING-only edges for the orchestrator/registry constraints.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| app/sep/apps/framework/form_backfill_registry.py | Now owns/exports FormBackfillContext + FormReconstructor alongside the registry contract. |
| app/sep/apps/framework/form_backfill.py | Drops the moved contract types and imports FormBackfillContext from the registry. |
| app/sep/apps/framework/form_backfill_inventory.py | Replaces the context dependency with a local protocol to keep inventory helpers decoupled from the registry. |
| app/sep/apps/alters/form_backfill.py | Updates TYPE_CHECKING import of FormBackfillContext to come from the registry. |
| app/sep/apps/archives/form_backfill.py | Updates TYPE_CHECKING import of FormBackfillContext to come from the registry. |
| app/sep/apps/backup_pg/form_backfill.py | Updates TYPE_CHECKING import of FormBackfillContext to come from the registry. |
| app/sep/apps/checksums/form_backfill.py | Updates TYPE_CHECKING import of FormBackfillContext to come from the registry. |
| app/sep/apps/mysql_backups/form_backfill.py | Updates TYPE_CHECKING import of FormBackfillContext to come from the registry. |
| app/sep/apps/mysql_backups/restore/form_backfill.py | Updates TYPE_CHECKING import of FormBackfillContext to come from the registry. |
| tests/app/sep/test_import_boundary.py | Adds declared-import walker and tests to enforce “apps must not import orchestrator” and “inventory must not import registry,” including under TYPE_CHECKING. |
| tests/app/sep/apps/framework/test_form_backfill.py | Repoints contract-type imports to form_backfill_registry. |
| tests/app/sep/apps/framework/test_form_backfill_inventory.py | Repoints FormBackfillContext import to form_backfill_registry. |
| tests/app/sep/apps/alters/test_form_backfill.py | Repoints FormBackfillContext import to form_backfill_registry. |
| tests/app/sep/apps/archives/test_form_backfill.py | Repoints FormBackfillContext import to form_backfill_registry. |
| tests/app/sep/apps/backup_pg/test_form_backfill.py | Repoints FormBackfillContext import to form_backfill_registry. |
| tests/app/sep/apps/checksums/test_form_backfill.py | Repoints FormBackfillContext import to form_backfill_registry. |
| tests/app/sep/apps/mysql_backups/test_form_backfill.py | Repoints FormBackfillContext import to form_backfill_registry. |
| tests/app/sep/apps/mysql_backups/restore/test_form_backfill.py | Repoints FormBackfillContext import to form_backfill_registry. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
1 — contract types import from the registry.venv/bin/python -c "from app.sep.apps.framework.form_backfill_registry import FormBackfillContext, FormBackfillEntry, FormReconstructor; print('ok', FormBackfillContext.__name__, FormReconstructor)"2 — orchestrator does not define the types; apps do not import itrg -n "^(class FormBackfillContext|FormReconstructor =)" app/sep/apps/framework/form_backfill.pyrg -n "from app.sep.apps.framework.form_backfill import" app/sep/appsrg -n "from app.sep.apps.framework.form_backfill_registry import" app/sep/apps tests/app/sep --glob "**/*form_backfill*"3 — inventory does not import registry types; call sites still pass
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@copilot resolve the merge conflicts in this pull request |
# Conflicts: # tests/app/sep/test_import_boundary.py Co-authored-by: yyyyyyyan <24644216+yyyyyyyan@users.noreply.github.com>
Merge conflicts resolved. The conflict was in |
Summary
Move
FormReconstructorandFormBackfillContextinto the form-backfill registry so the contract no longer depends on its orchestrator consumer.app/sep/apps/framework/form_backfill_registry.py: own and exportFormReconstructorandFormBackfillContextwith the rest of the contractapp/sep/apps/framework/form_backfill.py: drop those types and importFormBackfillContextfrom the registryapp/sep/apps/framework/form_backfill_inventory.py: replace the context type with a local_ServiceLookupCarrierprotocol so inventory does not import the registryapp/sep/apps/{alters,archives,backup_pg,checksums,mysql_backups,mysql_backups/restore}/form_backfill.py: importFormBackfillContextfrom the registryTested
FormBackfillContext,FormBackfillEntry, andFormReconstructorfromform_backfill_registryand confirm they resolve.form_backfill.pyno longer defines those types and nothing underapp/sep/apps/imports the orchestrator.form_backfill_inventory.pynames no registry types and the sixresolve_service_from_metacall sites still passctxfirst.FormBackfillContextfrom the registry.Checklist
make test)make run-pre-commit)make makemigrations)changelog.d/if the change is user-facing (make changelog-add), or confirmed N/A (internal-only change, or a same-release-cycle fix for an unreleased sibling ticket)