AP1.16d + AP1.9c: Planning Debt in Attention und Cockpit-Signale.
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Successful in 2m18s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 12s
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Successful in 2m18s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 12s
Attention-Regeln planning_debt/execution_waiting; Portfolio-Kacheln zeigen Steuerungssignale. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8546c7021b
commit
b9bfa9e5bd
13 files changed
+352
-12
No files matched your search
@@ -111,6 +111,77 @@ def compute_planning_debt(
|
||||
return debts
|
||||
|
||||
|
||||
def planning_debt_to_attention_items(
|
||||
*,
|
||||
initiative_id: str,
|
||||
debts: list[dict[str, Any]],
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Map Planning Debt read model → Attention Items (AP1.16d)."""
|
||||
items: list[dict[str, Any]] = []
|
||||
for debt in debts:
|
||||
gate_id = str(debt["roadmap_item_id"])
|
||||
items.append(
|
||||
{
|
||||
"kind": "planning_debt",
|
||||
"severity": "warning",
|
||||
"title": debt.get("title") or "Zielzustand",
|
||||
"summary": debt.get("message") or "Durchführungsplan fehlt",
|
||||
"scope_type": "milestone",
|
||||
"scope_id": gate_id,
|
||||
"initiative_id": initiative_id,
|
||||
"action_id": None,
|
||||
"blocker_id": None,
|
||||
"milestone_id": gate_id,
|
||||
"reason_code": "planning_debt",
|
||||
"data_source": "execution_graph",
|
||||
}
|
||||
)
|
||||
return items
|
||||
|
||||
|
||||
def execution_waiting_to_attention_items(
|
||||
*,
|
||||
initiative_id: str,
|
||||
actions: list[dict[str, Any]],
|
||||
graph_state: dict[str, Any],
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Actions blocked by Execution-Graph (nicht Status=blocked) → Attention."""
|
||||
action_by_id = {str(action["id"]): action for action in actions}
|
||||
items: list[dict[str, Any]] = []
|
||||
for action_id in graph_state.get("blocked_actions", []):
|
||||
action = action_by_id.get(str(action_id))
|
||||
if not action:
|
||||
continue
|
||||
if action.get("status") in ("done", "discarded", "blocked"):
|
||||
continue
|
||||
meta = graph_state.get("items", {}).get(str(action_id), {})
|
||||
blocked_by = meta.get("blocked_by") or []
|
||||
summary = (
|
||||
"Wartet auf Vorgänger-Arbeitspaket"
|
||||
if len(blocked_by) == 1
|
||||
else f"Wartet auf {len(blocked_by)} Vorgänger"
|
||||
)
|
||||
items.append(
|
||||
{
|
||||
"kind": "execution_waiting",
|
||||
"severity": "info",
|
||||
"title": action.get("title") or "Arbeitspaket",
|
||||
"summary": summary,
|
||||
"scope_type": "action",
|
||||
"scope_id": str(action_id),
|
||||
"initiative_id": initiative_id,
|
||||
"action_id": str(action_id),
|
||||
"blocker_id": None,
|
||||
"milestone_id": (
|
||||
str(action["roadmap_item_id"]) if action.get("roadmap_item_id") else None
|
||||
),
|
||||
"reason_code": "execution_waiting",
|
||||
"data_source": "execution_graph",
|
||||
}
|
||||
)
|
||||
return items
|
||||
|
||||
|
||||
def compute_execution_graph_state(
|
||||
*,
|
||||
actions: list[dict[str, Any]],
|
||||
|
||||
@@ -18,6 +18,8 @@ AttentionKind = Literal[
|
||||
"stale_initiative",
|
||||
"milestone_at_risk",
|
||||
"gate_graph_blocked",
|
||||
"planning_debt",
|
||||
"execution_waiting",
|
||||
"overdue_action",
|
||||
"review_due",
|
||||
"recurring_due",
|
||||
@@ -316,6 +318,61 @@ def _graph_blocked_gates(cur, ctx: TenantContext) -> list[dict[str, Any]]:
|
||||
return items
|
||||
|
||||
|
||||
def _execution_plan_attention(cur, ctx: TenantContext) -> list[dict[str, Any]]:
|
||||
"""Planning Debt + Execution-Waiting — AP1.16d / Execution-Graph."""
|
||||
from services import actions as action_service
|
||||
from services import roadmap as roadmap_service
|
||||
from steering.graph.execution_engine import (
|
||||
compute_execution_graph_state,
|
||||
compute_planning_debt,
|
||||
execution_waiting_to_attention_items,
|
||||
planning_debt_to_attention_items,
|
||||
)
|
||||
from services.execution_plan import list_dependencies_for_initiative
|
||||
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT id FROM initiatives
|
||||
WHERE tenant_id = %s AND status IN ('active', 'paused')
|
||||
ORDER BY updated_at DESC
|
||||
LIMIT 30
|
||||
""",
|
||||
(ctx.tenant_id,),
|
||||
)
|
||||
|
||||
items: list[dict[str, Any]] = []
|
||||
for row in cur.fetchall():
|
||||
initiative_id = str(row["id"])
|
||||
actions = action_service.list_actions_for_initiative(
|
||||
tenant_id=ctx.tenant_id, initiative_id=initiative_id
|
||||
)
|
||||
roadmap_items = roadmap_service.list_roadmap_items_for_initiative(
|
||||
tenant_id=ctx.tenant_id, initiative_id=initiative_id
|
||||
)
|
||||
debts = compute_planning_debt(actions=actions, roadmap_items=roadmap_items)
|
||||
items.extend(
|
||||
planning_debt_to_attention_items(initiative_id=initiative_id, debts=debts)
|
||||
)
|
||||
|
||||
dependencies = list_dependencies_for_initiative(
|
||||
tenant_id=ctx.tenant_id, initiative_id=initiative_id
|
||||
)
|
||||
graph_state = compute_execution_graph_state(
|
||||
actions=actions, dependencies=dependencies
|
||||
)
|
||||
items.extend(
|
||||
execution_waiting_to_attention_items(
|
||||
initiative_id=initiative_id,
|
||||
actions=actions,
|
||||
graph_state=graph_state,
|
||||
)
|
||||
)
|
||||
|
||||
if len(items) >= 30:
|
||||
return items[:30]
|
||||
return items
|
||||
|
||||
|
||||
def _milestones_at_risk(cur, ctx: TenantContext) -> list[dict[str, Any]]:
|
||||
cur.execute(
|
||||
"""
|
||||
@@ -491,6 +548,7 @@ def get_attention_items(ctx: TenantContext) -> list[dict[str, Any]]:
|
||||
items.extend(_initiatives_without_next_action(cur, ctx))
|
||||
items.extend(_stale_initiatives(cur, ctx))
|
||||
items.extend(_graph_blocked_gates(cur, ctx))
|
||||
items.extend(_execution_plan_attention(cur, ctx))
|
||||
items.extend(_milestones_at_risk(cur, ctx))
|
||||
items.extend(_overdue_actions(cur, ctx))
|
||||
items.extend(_actions_review_required(cur, ctx))
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
from steering.graph.execution_engine import (
|
||||
compute_execution_graph_state,
|
||||
compute_planning_debt,
|
||||
execution_waiting_to_attention_items,
|
||||
planning_debt_to_attention_items,
|
||||
)
|
||||
|
||||
|
||||
@@ -114,3 +116,45 @@ def test_scope_filters_to_gate():
|
||||
scope_roadmap_item_id="g1",
|
||||
)
|
||||
assert set(state["items"].keys()) == {"a"}
|
||||
|
||||
|
||||
def test_planning_debt_attention_items():
|
||||
items = planning_debt_to_attention_items(
|
||||
initiative_id="init-1",
|
||||
debts=[
|
||||
{
|
||||
"roadmap_item_id": "gate-1",
|
||||
"title": "G5 Plan",
|
||||
"message": "Aktiver Zielzustand ohne Durchführungsplan",
|
||||
}
|
||||
],
|
||||
)
|
||||
assert len(items) == 1
|
||||
assert items[0]["kind"] == "planning_debt"
|
||||
assert items[0]["initiative_id"] == "init-1"
|
||||
assert items[0]["milestone_id"] == "gate-1"
|
||||
|
||||
|
||||
def test_execution_waiting_attention_items():
|
||||
actions = [
|
||||
_action("a", "open", sort_order=0),
|
||||
_action("b", "open", sort_order=1),
|
||||
]
|
||||
state = compute_execution_graph_state(
|
||||
actions=actions,
|
||||
dependencies=[
|
||||
{
|
||||
"predecessor_action_id": "a",
|
||||
"successor_action_id": "b",
|
||||
"dependency_kind": "requires",
|
||||
}
|
||||
],
|
||||
)
|
||||
items = execution_waiting_to_attention_items(
|
||||
initiative_id="init-1",
|
||||
actions=actions,
|
||||
graph_state=state,
|
||||
)
|
||||
assert len(items) == 1
|
||||
assert items[0]["kind"] == "execution_waiting"
|
||||
assert items[0]["action_id"] == "b"
|
||||
Reference in new issue
Block a user