Skip to content

SEP-1755: Move FormReconstructor and FormBackfillContext into form_backfill_registry so the entry contract stops importing its own consumer - #1343

Open
peter-o-addo wants to merge 8 commits into
mainfrom
SEP-1755
Open

SEP-1755: Move FormReconstructor and FormBackfillContext into form_backfill_registry so the entry contract stops importing its own consumer#1343
peter-o-addo wants to merge 8 commits into
mainfrom
SEP-1755

Conversation

@peter-o-addo

@peter-o-addo peter-o-addo commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Move FormReconstructor and FormBackfillContext into the form-backfill registry so the contract no longer depends on its orchestrator consumer.

  • app/sep/apps/framework/form_backfill_registry.py: own and export FormReconstructor and FormBackfillContext with the rest of the contract
  • app/sep/apps/framework/form_backfill.py: drop those types and import FormBackfillContext from the registry
  • app/sep/apps/framework/form_backfill_inventory.py: replace the context type with a local _ServiceLookupCarrier protocol so inventory does not import the registry
  • app/sep/apps/{alters,archives,backup_pg,checksums,mysql_backups,mysql_backups/restore}/form_backfill.py: import FormBackfillContext from the registry
  • tests: repoint contract imports to the registry and guard that apps never import the orchestrator (and that inventory never imports the registry)

Tested

  • Import FormBackfillContext, FormBackfillEntry, and FormReconstructor from form_backfill_registry and confirm they resolve.
  • Confirm form_backfill.py no longer defines those types and nothing under app/sep/apps/ imports the orchestrator.
  • Confirm form_backfill_inventory.py names no registry types and the six resolve_service_from_meta call sites still pass ctx first.
  • Confirm the six app reconstructors import FormBackfillContext from the registry.

Checklist

  • New/modified functions have type hints and rST docstrings
  • New tests added for new features or bug fixes
  • All tests pass locally (make test)
  • Pre-commit hooks pass (make run-pre-commit)
  • Database migrations generated if models changed (make makemigrations)
  • User-facing changes documented (README, inline help, UI text)
  • Configuration changes documented with examples
  • Changelog fragment added under 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)

@github-actions github-actions Bot added python app:alters PR touches the alters app slice app:archives PR touches the archives app slice app:backup_pg PR touches the backup_pg app slice app:checksums PR touches the checksums app slice app:mysql_backups PR touches the mysql_backups app slice labels Aug 13, 2026
@peter-o-addo
peter-o-addo marked this pull request as ready for review August 13, 2026 09:07
Copilot AI lite review requested due to automatic review settings August 13, 2026 09:07
@peter-o-addo peter-o-addo added the qa in progress Someone is currently testing this PR - do not merge it label Aug 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 FormBackfillContext and FormReconstructor into form_backfill_registry and updated the orchestrator and app backfill modules to import from the registry.
  • Updated form_backfill_inventory to 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.

@peter-o-addo

Copy link
Copy Markdown
Contributor Author

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)"
ok FormBackfillContext collections.abc.Callable[['Task', 'FormBackfillContext'], dict[str, typing.Any] | None]

2 — orchestrator does not define the types; apps do not import it

rg -n "^(class FormBackfillContext|FormReconstructor =)" app/sep/apps/framework/form_backfill.py
(no matches)
rg -n "from app.sep.apps.framework.form_backfill import" app/sep/apps
(no matches)
rg -n "from app.sep.apps.framework.form_backfill_registry import" app/sep/apps tests/app/sep --glob "**/*form_backfill*"
app/sep/apps/alters/form_backfill.py:26:from app.sep.apps.framework.form_backfill_registry import FormBackfillEntry
app/sep/apps/alters/form_backfill.py:29:    from app.sep.apps.framework.form_backfill_registry import FormBackfillContext
app/sep/apps/archives/form_backfill.py:29:from app.sep.apps.framework.form_backfill_registry import FormBackfillEntry
app/sep/apps/archives/form_backfill.py:32:    from app.sep.apps.framework.form_backfill_registry import FormBackfillContext
app/sep/apps/backup_pg/form_backfill.py:29:from app.sep.apps.framework.form_backfill_registry import FormBackfillEntry
app/sep/apps/backup_pg/form_backfill.py:32:    from app.sep.apps.framework.form_backfill_registry import FormBackfillContext
app/sep/apps/checksums/form_backfill.py:26:from app.sep.apps.framework.form_backfill_registry import FormBackfillEntry
app/sep/apps/checksums/form_backfill.py:30:    from app.sep.apps.framework.form_backfill_registry import FormBackfillContext
app/sep/apps/framework/form_backfill.py:49:from app.sep.apps.framework.form_backfill_registry import (
app/sep/apps/mysql_backups/form_backfill.py:27:from app.sep.apps.framework.form_backfill_registry import FormBackfillEntry
app/sep/apps/mysql_backups/form_backfill.py:35:    from app.sep.apps.framework.form_backfill_registry import FormBackfillContext
app/sep/apps/mysql_backups/restore/form_backfill.py:27:from app.sep.apps.framework.form_backfill_registry import FormBackfillEntry
app/sep/apps/mysql_backups/restore/form_backfill.py:33:    from app.sep.apps.framework.form_backfill_registry import FormBackfillContext

3 — inventory does not import registry types; call sites still pass ctx

rg -n "form_backfill_registry|FormBackfillContext|FormReconstructor|FormBackfillEntry" app/sep/apps/framework/form_backfill_inventory.py
(no matches)
rg -n "resolve_service_from_meta\(" app/sep/apps --glob "**/form_backfill.py"
app/sep/apps/backup_pg/form_backfill.py:89:    service_id = resolve_service_from_meta(
app/sep/apps/mysql_backups/form_backfill.py:119:    service_id = resolve_service_from_meta(
app/sep/apps/alters/form_backfill.py:83:    service_id = resolve_service_from_meta(ctx, meta, ServiceTypeEnum.MYSQL)
app/sep/apps/mysql_backups/restore/form_backfill.py:70:    service_id = resolve_service_from_meta(
app/sep/apps/archives/form_backfill.py:167:    return resolve_service_from_meta(
app/sep/apps/checksums/form_backfill.py:99:    service_id = resolve_service_from_meta(ctx, meta, ServiceTypeEnum.MYSQL)

4 — no apps module imports the orchestrator; inventory does not import the registry

Covered by the rg logs in 2 (app/sep/apps: no matches) and 3 (inventory: no matches).

@peter-o-addo peter-o-addo added qa passed Tests for this PR are completed and successful. and removed qa in progress Someone is currently testing this PR - do not merge it labels Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  app/sep
  inventory.py
  app/sep/apps/alters
  form_backfill.py
  app/sep/apps/archives
  form_backfill.py
  app/sep/apps/backup_pg
  form_backfill.py
  app/sep/apps/checksums
  form_backfill.py
  app/sep/apps/framework
  form_backfill.py
  form_backfill_inventory.py
  form_backfill_registry.py
  app/sep/apps/mysql_backups
  form_backfill.py
  app/sep/apps/mysql_backups/restore
  form_backfill.py
  app/sep/sync/syncers
  pmm.py
Project Total  

This report was generated by python-coverage-comment-action

@yyyyyyyan

Copy link
Copy Markdown
Contributor

@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>

Copilot AI commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved. The conflict was in tests/app/sep/test_import_boundary.py — I kept both the updated limitation text from main and the _declared_imports docstring paragraph from this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app:alters PR touches the alters app slice app:archives PR touches the archives app slice app:backup_pg PR touches the backup_pg app slice app:checksums PR touches the checksums app slice app:mysql_backups PR touches the mysql_backups app slice python qa passed Tests for this PR are completed and successful.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants