63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
|
|
"""Core attention contributors — blockers, blocked actions."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from steering.attention.context import AttentionEvalContext
|
||
|
|
from steering.attention.contributors.registry import (
|
||
|
|
AttentionContributor,
|
||
|
|
register_attention_contributor,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def _open_blockers(ctx: AttentionEvalContext) -> list[dict]:
|
||
|
|
items: list[dict] = []
|
||
|
|
for blocker in ctx.blockers:
|
||
|
|
if blocker.get("status") not in ("open", "in_progress"):
|
||
|
|
continue
|
||
|
|
items.append(
|
||
|
|
{
|
||
|
|
"kind": "open_blocker",
|
||
|
|
"severity": "warning",
|
||
|
|
"title": blocker.get("title") or "Blocker",
|
||
|
|
"summary": "Offener Blocker im Vorhaben",
|
||
|
|
"scope_type": "blocker",
|
||
|
|
"scope_id": str(blocker["id"]),
|
||
|
|
"initiative_id": ctx.initiative_id,
|
||
|
|
"action_id": (
|
||
|
|
str(blocker["action_id"]) if blocker.get("action_id") else None
|
||
|
|
),
|
||
|
|
"blocker_id": str(blocker["id"]),
|
||
|
|
"reason_code": "path_blocked",
|
||
|
|
}
|
||
|
|
)
|
||
|
|
return items
|
||
|
|
|
||
|
|
|
||
|
|
def _blocked_actions(ctx: AttentionEvalContext) -> list[dict]:
|
||
|
|
items: list[dict] = []
|
||
|
|
for action in ctx.actions:
|
||
|
|
if action.get("status") != "blocked":
|
||
|
|
continue
|
||
|
|
items.append(
|
||
|
|
{
|
||
|
|
"kind": "blocked_action",
|
||
|
|
"severity": "critical",
|
||
|
|
"title": action.get("title") or "Arbeitspaket",
|
||
|
|
"summary": "Maßnahme ist blockiert",
|
||
|
|
"scope_type": "action",
|
||
|
|
"scope_id": str(action["id"]),
|
||
|
|
"initiative_id": ctx.initiative_id,
|
||
|
|
"action_id": str(action["id"]),
|
||
|
|
"reason_code": "path_blocked",
|
||
|
|
}
|
||
|
|
)
|
||
|
|
return items
|
||
|
|
|
||
|
|
|
||
|
|
register_attention_contributor(
|
||
|
|
AttentionContributor(key="open_blockers", contribute=_open_blockers)
|
||
|
|
)
|
||
|
|
register_attention_contributor(
|
||
|
|
AttentionContributor(key="blocked_actions", contribute=_blocked_actions)
|
||
|
|
)
|