AP1.4e: Methodenprofile am Gate-Graph.
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 2m18s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped

generic_operating ohne harte Blockade, Reifegrad-Methoden mit Erfuellungsgrad; Attention gate_graph_blocked fuer gate-orientierte Methoden.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-11 08:06:42 +02:00
1 parent 4f8725e234
commit 1fa61b2dac
14 files changed
+426 -36

No files matched your search

+16 -3
View File
@@ -1,5 +1,18 @@
"""Roadmap graph read models (AP1.4d)."""
"""Roadmap graph read models (AP1.4d/4e)."""
from steering.graph.roadmap_engine import compute_initiative_graph_state
from steering.graph.profiles import GraphMethodProfile, get_graph_profile
from steering.graph.roadmap_engine import (
apply_graph_method_profile,
compute_initiative_graph_state,
compute_initiative_graph_state_with_profile,
load_initiative_graph_state,
)
__all__ = ["compute_initiative_graph_state"]
__all__ = [
"GraphMethodProfile",
"get_graph_profile",
"apply_graph_method_profile",
"compute_initiative_graph_state",
"compute_initiative_graph_state_with_profile",
"load_initiative_graph_state",
]
+51
View File
@@ -0,0 +1,51 @@
"""Method graph profiles — AP1.4e."""
from __future__ import annotations
from dataclasses import dataclass
DEFAULT_METHOD_KEY = "generic_operating"
@dataclass(frozen=True)
class GraphMethodProfile:
"""Steuert Graph-Read-Models pro steering_context.method_key."""
enforce_gate_blocking: bool
emphasize_fulfillment: bool
_STRICT = GraphMethodProfile(enforce_gate_blocking=True, emphasize_fulfillment=False)
_FULFILLMENT = GraphMethodProfile(enforce_gate_blocking=False, emphasize_fulfillment=True)
_LIGHT = GraphMethodProfile(enforce_gate_blocking=False, emphasize_fulfillment=False)
METHOD_GRAPH_PROFILES: dict[str, GraphMethodProfile] = {
"generic_operating": _LIGHT,
"queue_pull": _LIGHT,
"dispute_procedure": _LIGHT,
"continuous_product": _FULFILLMENT,
"maturity_progression": _FULFILLMENT,
"chapter_based_progression": _FULFILLMENT,
"product_milestone_driven": _STRICT,
"program_delivery": _STRICT,
"sequential_dependency": _STRICT,
"agile_iteration": _STRICT,
"recurring_control": _FULFILLMENT,
}
def get_graph_profile(method_key: str | None) -> GraphMethodProfile:
if not method_key:
return METHOD_GRAPH_PROFILES[DEFAULT_METHOD_KEY]
return METHOD_GRAPH_PROFILES.get(method_key, _STRICT)
def enforce_gate_blocking_for_method(method_key: str | None) -> bool:
return get_graph_profile(method_key).enforce_gate_blocking
def graph_profile_as_dict(profile: GraphMethodProfile) -> dict[str, bool]:
return {
"enforce_gate_blocking": profile.enforce_gate_blocking,
"emphasize_fulfillment": profile.emphasize_fulfillment,
}
+75 -3
View File
@@ -1,9 +1,16 @@
"""Roadmap gate graph read models — Plan-Zielzustand, kein Workflow (AP1.4d)."""
"""Roadmap graph read models — AP1.4d/4e."""
from __future__ import annotations
from typing import Any, Optional
from steering.graph.profiles import (
DEFAULT_METHOD_KEY,
GraphMethodProfile,
get_graph_profile,
graph_profile_as_dict,
)
TERMINAL_STATUSES = frozenset({"reached", "moved", "discarded"})
ACTIVE_STATUSES = frozenset({"planned", "active", "at_risk"})
BLOCKING_STATUSES = frozenset({"planned", "active", "at_risk"})
@@ -114,6 +121,7 @@ def compute_initiative_graph_state(
ratio = _fulfillment_ratio(criteria_progress.get(item_id))
item_states[item_id] = {
"status": status,
"blocked": blocked,
"ready": ready,
"blocked_by": blocked_by,
@@ -131,12 +139,72 @@ def compute_initiative_graph_state(
}
def _initiative_fulfillment_ratio(item_states: dict[str, dict[str, Any]]) -> Optional[float]:
ratios = [
st["fulfillment_ratio"]
for st in item_states.values()
if st.get("fulfillment_ratio") is not None
]
if not ratios:
return None
return round(sum(ratios) / len(ratios), 4)
def apply_graph_method_profile(
state: dict[str, Any], profile: GraphMethodProfile
) -> dict[str, Any]:
"""Passt blocked/ready an Methodenprofil an (AP1.4e)."""
if profile.enforce_gate_blocking:
state["graph_profile"] = graph_profile_as_dict(profile)
state["initiative_fulfillment_ratio"] = _initiative_fulfillment_ratio(state["items"])
return state
item_states = state["items"]
blocked_items: list[str] = []
ready_items: list[str] = []
for item_id, item_state in item_states.items():
would_block = item_state["blocked"]
item_state["would_block"] = would_block
item_state["blocked"] = False
status = item_state.get("status", "planned")
item_state["ready"] = status in ACTIVE_STATUSES
if item_state["ready"]:
ready_items.append(item_id)
state["items"] = item_states
state["blocked_items"] = blocked_items
state["ready_items"] = ready_items
state["graph_profile"] = graph_profile_as_dict(profile)
state["initiative_fulfillment_ratio"] = _initiative_fulfillment_ratio(item_states)
return state
def compute_initiative_graph_state_with_profile(
*,
items: list[dict[str, Any]],
dependencies: list[dict[str, Any]],
criteria_progress: Optional[dict[str, dict[str, int]]] = None,
method_key: Optional[str] = None,
) -> dict[str, Any]:
base = compute_initiative_graph_state(
items=items,
dependencies=dependencies,
criteria_progress=criteria_progress,
)
profile = get_graph_profile(method_key)
result = apply_graph_method_profile(base, profile)
result["method_key"] = method_key or DEFAULT_METHOD_KEY
return result
def load_initiative_graph_state(
*, tenant_id: str, initiative_id: str
) -> dict[str, Any]:
"""Lädt Items, Kanten und Kriterien-Fortschritt und berechnet Graph-State."""
"""Lädt Items, Kanten, Kriterien und Methodenprofil."""
from services import roadmap as roadmap_service
from services import roadmap_criteria as criteria_service
from services.steering_context import get_steering_context
items = roadmap_service.list_roadmap_items_for_initiative(
tenant_id=tenant_id, initiative_id=initiative_id
@@ -147,8 +215,12 @@ def load_initiative_graph_state(
criteria_progress = criteria_service.criteria_progress_for_initiative(
tenant_id=tenant_id, initiative_id=initiative_id
)
return compute_initiative_graph_state(
steering = get_steering_context(tenant_id=tenant_id, initiative_id=initiative_id)
method_key = (steering or {}).get("method_key") or DEFAULT_METHOD_KEY
return compute_initiative_graph_state_with_profile(
items=items,
dependencies=dependencies,
criteria_progress=criteria_progress,
method_key=method_key,
)