Skip to content

PY-MODE1002 · shared_model_placement

Decide whether a reused model belongs at its consumers’ shared boundary.

This is a contextual rule for python. Read its implementation.

Nominate declarative top-level models with no ordinary behavior when at least the configured number of modules import them and the graph can derive a narrower shared destination. Decide to move only when the supplied class source, importing modules, and destination establish that the type is a reusable contract rather than a concept owned by its current module. Keep it when its current module owns the concept. Missing ownership or cycle evidence is uncertain. minimum_importers sets the required number of distinct importing modules.

Each candidate carries the exact class source, current path, proposed destination, field count, importing modules, model ancestry, and graph evidence. The model cites the retained claims behind its decision. A failing answer is a placement decision rather than a numeric threshold violation.

Tests, behavioral services, protocols, models with fewer importers, and models already at the derived boundary never reach contextual classification. A domain model may remain beside its owner. Any unresolved ownership or dependency cycle stays uncertain.

A generic Location record imported by unrelated adapters can move to their shared models boundary. An OrderLine imported by several order services remains with the order domain when that module owns its invariants.

  • Cites “Pydantic documentation”, models. Open reference
  • Cites “A Philosophy of Software Design”, chapters 4 and 5