fix(regeneration): profile-aware kind selection for post-merge and proposed-change regeneration

Merged
PO
4mo ago
+224-33

Summary

Regeneration selection now widens a diff's changed kinds to include the node kind behind each changed profile, resolved from the branch's live schema. A change touching only a profile selects every generator and artifact whose query reads the profiled node kind — on both the post-merge selective regeneration and the proposed-change refresh.

What changed

  • New SchemaProfileExpander (core/regeneration/profiles.py): given a branch and a set of changed kinds, adds the profiled node kind for every changed profile kind, using the schema's profile→node relationship. A kind that names no profile passes through. The SchemaManager is a constructor dependency (resolved to registry.schema at the wiring sites), so the component no longer reaches into the global registry.
  • Wired into both selection paths through one component: injected as the merge planner's kinds_expander, which runs it in the planner's shared plan step so both the initial plan and the cascade reselection widen alike; constructed at the proposed-change flow level for the generator and artifact loops. The proposed-change generator loop, which selected on raw query_models membership, now runs through the same widened kinds.
  • reads_kind moved to predicates.py: with profile handling now living in the expander, it reduces to kind in query_models, so the name-stripping heuristic (kind.replace("Profile", "", 1)) is removed and the predicate lives beside query_changed / definition_changed as a free function over RegenerationDefinition — off the definition models, which stay plain data holders.

The widening only ever adds kinds, so the no-under-execution guarantee is preserved.

Tests

  • unit: SchemaProfileExpander against an injected in-memory schema branch that generates profiles
  • unit: gate widening selects both a generator and an artifact for a profiled kind
  • unit: the planner passes the expanded kinds to every selector
  • unit: reads_kind matches only a kind the definition's query reads
  • component: run_generators dispatches every generator reading a profiled kind on a profile-only change

Notes

  • Resolves https://opsmill.atlassian.net/browse/IFC-2907 in full — both items the ticket tracks: the fragile profile heuristic, and profile handling applied to artifacts but not generators.
  • Rebased onto pmi-20260727-refactor-selectors, which is now participant/planner based; the profile-kind widening integrates into the planner's shared plan step, and the tests moved to the participant wiring. Review feedback addressed: SchemaProfileExpander takes an injected SchemaManager (no global registry), and reads_kind moved off the definition models into predicates.py.

🤖 Generated with Claude Code