"""Shared registration helper for AP2.0 method stubs — AP2.3e / AP2.4.""" from __future__ import annotations from typing import Literal from steering.graph.profiles import ( FULFILLMENT, GraphMethodProfile, LIGHT, STRICT, ) from steering.lifecycle.states import STANDARD_LIFECYCLE_STEPS from steering.methods.registry import MethodDefinition, get_method, register_method _PRODUCT_LIKE_STEPS = ( "intake", "method_selection", "structure_setup", "planning", "action_selection", "assignment", "waiting", "result_intake", "validation", "review", "adaptation", "closure", ) _LIGHT_STEPS = ( "intake", "structure_setup", "action_selection", "assignment", "waiting", "review", "adaptation", "closure", ) SLICES_OM_STANDARD = frozenset( { "backlog", "actions", "roadmap", "projects", "blockers", "evidence", "decisions", "reviews", "steering_methods", } ) SLICES_PRODUCT = SLICES_OM_STANDARD | frozenset({"work_cycles"}) SLICES_QUEUE = frozenset({"backlog", "actions", "blockers", "steering_methods"}) SLICES_MATURITY = frozenset( { "actions", "roadmap", "blockers", "evidence", "decisions", "reviews", "recurring", "steering_methods", } ) SLICES_RECURRING = frozenset( {"actions", "roadmap", "recurring", "blockers", "steering_methods"} ) SLICES_PROGRAM = SLICES_OM_STANDARD | frozenset({"work_cycles"}) SLICES_GENERIC = SLICES_OM_STANDARD SLICES_AGILE = SLICES_PRODUCT ELEM_NEXT = frozenset({"next_action_primary"}) def register_stub_method( *, key: str, label: str, description: str, next_action_strategy_key: str = "default", lifecycle_steps: tuple[str, ...] | None = None, data_slices: frozenset[str] | None = None, compatible_archetype_keys: frozenset[str] | Literal["*"] = "*", steering_elements: frozenset[str] | None = None, ui_features: frozenset[str] | None = None, graph_profile: GraphMethodProfile = LIGHT, method_role: Literal["primary", "modifier"] = "primary", composes_with: frozenset[str] | None = None, ) -> None: if get_method(key): return register_method( MethodDefinition( key=key, version="0.1.0", label=label, description=description, default_lifecycle_steps=lifecycle_steps or STANDARD_LIFECYCLE_STEPS, next_action_strategy_key=next_action_strategy_key, data_slices=data_slices or SLICES_GENERIC, compatible_archetype_keys=compatible_archetype_keys, steering_elements=steering_elements or ELEM_NEXT, ui_features=ui_features or frozenset(), graph_profile=graph_profile, method_role=method_role, composes_with=composes_with or frozenset(), ) ) def register_product_like_method( *, key: str, label: str, description: str, next_action_strategy_key: str, data_slices: frozenset[str] | None = None, compatible_archetype_keys: frozenset[str] | Literal["*"] | None = None, steering_elements: frozenset[str] | None = None, ui_features: frozenset[str] | None = None, graph_profile: GraphMethodProfile = STRICT, ) -> None: register_stub_method( key=key, label=label, description=description, next_action_strategy_key=next_action_strategy_key, lifecycle_steps=_PRODUCT_LIKE_STEPS, data_slices=data_slices or SLICES_PRODUCT, compatible_archetype_keys=compatible_archetype_keys if compatible_archetype_keys is not None else frozenset({"initiative.product"}), steering_elements=steering_elements or (ELEM_NEXT | frozenset({"gate_fulfillment", "work_cycle_scope"})), ui_features=ui_features or frozenset(), graph_profile=graph_profile, )