Skip to content

refactor(forecast,registry): move ModelFamily to shared/core to break slice cycle #268

@w7-mgfcode

Description

@w7-mgfcode

Status: deferred — needs its own PRP.

Origin: CodeRabbit #3270767554 on PR #266.

The flag

`app/features/registry/schemas.py:27` directly imports `ModelFamily` from `app.features.forecasting.schemas`, and `schemas.py:164` lazy-imports `model_family_for` from `app.features.forecasting.feature_metadata`. This violates the vertical-slice invariant (`app/features/X` may NOT import from `app/features/Y`) and is the proximate cause of the existing lazy-import cycle workaround documented in lines 20-27 of that file.

Why deferred

Per project memory `computed-field-cross-slice-cycle` and `data-platform-shared-orm-layer` (in agent memory), the existing fix (lazy in-method import + a NOTE comment naming the cycle) is the documented pattern. The proper resolution — relocating `ModelFamily` + `model_family_for` to a neutral module — is a non-trivial refactor that touches:

That belongs behind a PRP, not a hot-fix commit on a release-prep PR.

Proposed scope (when a PRP lands)

  • Create `app/shared/model_taxonomy.py` (or extend `app/shared/models.py`) with `ModelFamily` + `model_family_for(model_type) -> ModelFamily`.
  • Re-export from `app/features/forecasting/{schemas,feature_metadata}.py` to preserve the public API of those modules.
  • Update `app/features/registry/schemas.py` to import from the shared module.
  • Drop the lazy-import workaround in `app/features/forecasting/service.py` get_feature_metadata_for_* methods if the cycle is fully broken.
  • Update the ARCHITECTURE.md cross-slice pattern note to add this case as a "broken cycle" example.

Sibling case

CodeRabbit also keeps flagging `app/features/data_platform/models.py` cross-slice imports for the same reason — that one is the de-facto shared ORM layer and is tracked separately (HANDOFF.md Open Questions).

Refs: PR #266

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions