feat(steering): K-Ext-2 Attention-Registry, Gate/Intake-Proposals, generische UI
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Successful in 4m13s
Test Suite / lint-backend (push) Successful in 3s
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 4m13s
Test Suite / lint-backend (push) Successful in 3s
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
Methodenuebergreifende Provider auf Kernel v0.3; verbindliche Coding Rules fuer Agenten in ADP und .cursor/rules. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
1bbc5dbfce
commit
b747200f3a
29 files changed
+1364
-182
No files matched your search
@@ -0,0 +1 @@
|
||||
"""Attention contributors — K-Ext-2."""
|
||||
@@ -0,0 +1,109 @@
|
||||
"""Attention evaluation context — shared caches for contributors."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
from steering.eval_context import SteeringEvalContext
|
||||
from steering.kernel.models import HorizonMarker, SteeringBinding
|
||||
from tenant_context import TenantContext
|
||||
|
||||
|
||||
@dataclass
|
||||
class AttentionEvalContext:
|
||||
tenant_ctx: TenantContext
|
||||
initiative_id: str
|
||||
binding: SteeringBinding
|
||||
horizon: HorizonMarker
|
||||
next_work: list[dict[str, Any]]
|
||||
read_models: dict[str, Any]
|
||||
proposals: dict[str, Any]
|
||||
eval_ctx: SteeringEvalContext | None = None
|
||||
|
||||
_actions: list[dict[str, Any]] | None = field(default=None, repr=False)
|
||||
_blockers: list[dict[str, Any]] | None = field(default=None, repr=False)
|
||||
_roadmap_items: list[dict[str, Any]] | None = field(default=None, repr=False)
|
||||
_dependencies: list[dict[str, Any]] | None = field(default=None, repr=False)
|
||||
_graph_state: dict[str, Any] | None = field(default=None, repr=False)
|
||||
_gate_scope: str | None = field(default=None, repr=False)
|
||||
|
||||
@property
|
||||
def steering_elements(self) -> frozenset[str]:
|
||||
if self.eval_ctx:
|
||||
return self.eval_ctx.steering_elements
|
||||
return frozenset()
|
||||
|
||||
@property
|
||||
def actions(self) -> list[dict[str, Any]]:
|
||||
if self._actions is None:
|
||||
if self.eval_ctx:
|
||||
self._actions = self.eval_ctx.actions
|
||||
else:
|
||||
from services import actions as action_service
|
||||
|
||||
self._actions = action_service.list_actions_for_initiative(
|
||||
tenant_id=self.tenant_ctx.tenant_id,
|
||||
initiative_id=self.initiative_id,
|
||||
)
|
||||
return self._actions
|
||||
|
||||
@property
|
||||
def blockers(self) -> list[dict[str, Any]]:
|
||||
if self._blockers is None:
|
||||
from services import blockers as blocker_service
|
||||
|
||||
self._blockers = blocker_service.list_blockers_for_initiative(
|
||||
tenant_id=self.tenant_ctx.tenant_id, initiative_id=self.initiative_id
|
||||
)
|
||||
return self._blockers
|
||||
|
||||
@property
|
||||
def roadmap_items(self) -> list[dict[str, Any]]:
|
||||
if self._roadmap_items is None:
|
||||
from services import roadmap as roadmap_service
|
||||
|
||||
self._roadmap_items = roadmap_service.list_roadmap_items_for_initiative(
|
||||
tenant_id=self.tenant_ctx.tenant_id, initiative_id=self.initiative_id
|
||||
)
|
||||
return self._roadmap_items
|
||||
|
||||
@property
|
||||
def gate_scope(self) -> str | None:
|
||||
if self._gate_scope is None:
|
||||
from steering.strategies.next_action.execution_ready import (
|
||||
gate_horizon_scope_for_method,
|
||||
)
|
||||
|
||||
self._gate_scope = gate_horizon_scope_for_method(
|
||||
self.binding.primary_method_key,
|
||||
self.tenant_ctx,
|
||||
self.initiative_id,
|
||||
)
|
||||
return self._gate_scope
|
||||
|
||||
@property
|
||||
def dependencies(self) -> list[dict[str, Any]]:
|
||||
if self._dependencies is None:
|
||||
from services.execution_plan import list_dependencies_for_initiative
|
||||
|
||||
self._dependencies = list_dependencies_for_initiative(
|
||||
tenant_id=self.tenant_ctx.tenant_id, initiative_id=self.initiative_id
|
||||
)
|
||||
return self._dependencies
|
||||
|
||||
@property
|
||||
def graph_state(self) -> dict[str, Any]:
|
||||
if self._graph_state is None:
|
||||
cached = self.read_models.get("execution_graph")
|
||||
if cached is not None:
|
||||
self._graph_state = cached
|
||||
else:
|
||||
from steering.graph.execution_engine import compute_execution_graph_state
|
||||
|
||||
self._graph_state = compute_execution_graph_state(
|
||||
actions=self.actions,
|
||||
dependencies=self.dependencies,
|
||||
scope_roadmap_item_id=self.gate_scope,
|
||||
)
|
||||
return self._graph_state
|
||||
@@ -0,0 +1 @@
|
||||
"""Attention contributors package."""
|
||||
@@ -0,0 +1,62 @@
|
||||
"""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)
|
||||
)
|
||||
@@ -0,0 +1,105 @@
|
||||
"""Gate / execution graph attention — planning_debt, execution_waiting."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from steering.attention.context import AttentionEvalContext
|
||||
from steering.attention.contributors.registry import (
|
||||
AttentionContributor,
|
||||
register_attention_contributor,
|
||||
)
|
||||
from steering.graph.execution_engine import (
|
||||
execution_waiting_to_attention_items,
|
||||
planning_debt_to_attention_items,
|
||||
)
|
||||
|
||||
_GATE_METHODS = frozenset(
|
||||
{"sequential_dependency", "program_delivery", "maturity_progression"}
|
||||
)
|
||||
|
||||
|
||||
def _planning_debt(ctx: AttentionEvalContext) -> list[dict]:
|
||||
if ctx.binding.primary_method_key not in _GATE_METHODS:
|
||||
return []
|
||||
debts = ctx.read_models.get("planning_debt")
|
||||
if debts is None:
|
||||
from steering.graph.execution_engine import compute_planning_debt
|
||||
|
||||
gate_scope = ctx.gate_scope
|
||||
scoped_roadmap = ctx.roadmap_items
|
||||
scoped_actions = ctx.actions
|
||||
if gate_scope:
|
||||
scoped_roadmap = [
|
||||
ri for ri in ctx.roadmap_items if str(ri.get("id")) == str(gate_scope)
|
||||
]
|
||||
scoped_actions = [
|
||||
a
|
||||
for a in ctx.actions
|
||||
if a.get("roadmap_item_id")
|
||||
and str(a["roadmap_item_id"]) == str(gate_scope)
|
||||
]
|
||||
debts = compute_planning_debt(
|
||||
actions=scoped_actions, roadmap_items=scoped_roadmap
|
||||
)
|
||||
return planning_debt_to_attention_items(
|
||||
initiative_id=ctx.initiative_id, debts=debts or []
|
||||
)
|
||||
|
||||
|
||||
def _execution_waiting(ctx: AttentionEvalContext) -> list[dict]:
|
||||
if "critical_path" not in ctx.steering_elements and "gate_fulfillment" not in ctx.steering_elements:
|
||||
return []
|
||||
return execution_waiting_to_attention_items(
|
||||
initiative_id=ctx.initiative_id,
|
||||
actions=ctx.actions,
|
||||
graph_state=ctx.graph_state,
|
||||
)
|
||||
|
||||
|
||||
def _horizon_no_ready_work(ctx: AttentionEvalContext) -> list[dict]:
|
||||
if ctx.next_work:
|
||||
return []
|
||||
if ctx.binding.primary_method_key not in _GATE_METHODS:
|
||||
return []
|
||||
if ctx.horizon.kind != "gate":
|
||||
return []
|
||||
|
||||
debts = ctx.read_models.get("planning_debt") or []
|
||||
has_planning = len(debts) > 0
|
||||
has_waiting = bool(ctx.graph_state.get("blocked_actions"))
|
||||
if not has_planning and not has_waiting and not ctx.graph_state.get("ready_actions"):
|
||||
return [
|
||||
{
|
||||
"kind": "initiative_without_next_action",
|
||||
"severity": "info",
|
||||
"title": ctx.horizon.gate_title or "Aktiver Horizont",
|
||||
"summary": "Keine ausführungsbereite Arbeit im aktiven Horizont",
|
||||
"scope_type": "milestone",
|
||||
"scope_id": ctx.horizon.gate_roadmap_item_id,
|
||||
"initiative_id": ctx.initiative_id,
|
||||
"reason_code": "horizon_no_ready_work",
|
||||
}
|
||||
]
|
||||
return []
|
||||
|
||||
|
||||
register_attention_contributor(
|
||||
AttentionContributor(
|
||||
key="planning_debt",
|
||||
requires_elements=frozenset({"gate_fulfillment"}),
|
||||
contribute=_planning_debt,
|
||||
)
|
||||
)
|
||||
register_attention_contributor(
|
||||
AttentionContributor(
|
||||
key="execution_waiting",
|
||||
requires_any_element=frozenset({"critical_path", "gate_fulfillment"}),
|
||||
contribute=_execution_waiting,
|
||||
)
|
||||
)
|
||||
register_attention_contributor(
|
||||
AttentionContributor(
|
||||
key="horizon_no_ready_work",
|
||||
requires_elements=frozenset({"gate_fulfillment"}),
|
||||
contribute=_horizon_no_ready_work,
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,80 @@
|
||||
"""Read-model / proposal derived attention."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from steering.attention.context import AttentionEvalContext
|
||||
from steering.attention.contributors.registry import (
|
||||
AttentionContributor,
|
||||
register_attention_contributor,
|
||||
)
|
||||
from steering.proposals.gate_next_actions import gate_next_actions_attention_items
|
||||
from steering.proposals.intake_triage import intake_triage_attention_items
|
||||
from steering.proposals.sprint_commit import sprint_commit_attention_items
|
||||
from steering.read_models.epic_rollup import epic_rollup_attention_items
|
||||
|
||||
|
||||
def _epic_rollup(ctx: AttentionEvalContext) -> list[dict]:
|
||||
rollups = ctx.read_models.get("epic_rollup")
|
||||
if not rollups:
|
||||
return []
|
||||
return epic_rollup_attention_items(
|
||||
initiative_id=ctx.initiative_id, rollups=rollups
|
||||
)
|
||||
|
||||
|
||||
def _sprint_commit(ctx: AttentionEvalContext) -> list[dict]:
|
||||
proposals = ctx.proposals.get("sprint_commit")
|
||||
if not proposals:
|
||||
return []
|
||||
return sprint_commit_attention_items(
|
||||
initiative_id=ctx.initiative_id,
|
||||
proposals=proposals,
|
||||
actions=ctx.actions,
|
||||
)
|
||||
|
||||
|
||||
def _gate_next_actions(ctx: AttentionEvalContext) -> list[dict]:
|
||||
proposals = ctx.proposals.get("gate_next_actions")
|
||||
if not proposals:
|
||||
return []
|
||||
return gate_next_actions_attention_items(
|
||||
initiative_id=ctx.initiative_id, proposals=proposals
|
||||
)
|
||||
|
||||
|
||||
def _intake_triage(ctx: AttentionEvalContext) -> list[dict]:
|
||||
proposals = ctx.proposals.get("intake_triage")
|
||||
if not proposals:
|
||||
return []
|
||||
return intake_triage_attention_items(
|
||||
initiative_id=ctx.initiative_id, proposals=proposals
|
||||
)
|
||||
|
||||
|
||||
register_attention_contributor(
|
||||
AttentionContributor(
|
||||
key="epic_rollup",
|
||||
requires_elements=frozenset({"backlog_epic_hierarchy"}),
|
||||
contribute=_epic_rollup,
|
||||
)
|
||||
)
|
||||
register_attention_contributor(
|
||||
AttentionContributor(
|
||||
key="sprint_commit",
|
||||
requires_elements=frozenset({"work_cycle_scope"}),
|
||||
contribute=_sprint_commit,
|
||||
)
|
||||
)
|
||||
register_attention_contributor(
|
||||
AttentionContributor(
|
||||
key="gate_next_actions",
|
||||
requires_elements=frozenset({"gate_fulfillment"}),
|
||||
contribute=_gate_next_actions,
|
||||
)
|
||||
)
|
||||
register_attention_contributor(
|
||||
AttentionContributor(
|
||||
key="intake_triage",
|
||||
contribute=_intake_triage,
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,59 @@
|
||||
"""Attention contributor registry — K-Ext-2."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Callable
|
||||
|
||||
from steering.attention.context import AttentionEvalContext
|
||||
|
||||
AttentionContribute = Callable[[AttentionEvalContext], list[dict]]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AttentionContributor:
|
||||
key: str
|
||||
requires_elements: frozenset[str] = field(default_factory=frozenset)
|
||||
requires_any_element: frozenset[str] = field(default_factory=frozenset)
|
||||
requires_primary_methods: frozenset[str] = field(default_factory=frozenset)
|
||||
contribute: AttentionContribute = lambda _ctx: []
|
||||
|
||||
|
||||
_CONTRIBUTORS: list[AttentionContributor] = []
|
||||
|
||||
|
||||
def register_attention_contributor(contributor: AttentionContributor) -> None:
|
||||
_CONTRIBUTORS.append(contributor)
|
||||
|
||||
|
||||
def collect_attention_items(ctx: AttentionEvalContext) -> list[dict]:
|
||||
elements = ctx.steering_elements
|
||||
primary = ctx.binding.primary_method_key
|
||||
items: list[dict] = []
|
||||
|
||||
for contributor in _CONTRIBUTORS:
|
||||
if (
|
||||
contributor.requires_elements
|
||||
and not contributor.requires_elements <= elements
|
||||
):
|
||||
continue
|
||||
if contributor.requires_any_element and not (
|
||||
contributor.requires_any_element & elements
|
||||
):
|
||||
continue
|
||||
if (
|
||||
contributor.requires_primary_methods
|
||||
and primary not in contributor.requires_primary_methods
|
||||
):
|
||||
continue
|
||||
items.extend(contributor.contribute(ctx))
|
||||
|
||||
for item in items:
|
||||
item.setdefault("data_source", "steering_kernel")
|
||||
|
||||
items.sort(
|
||||
key=lambda x: {"critical": 0, "warning": 1, "info": 2}.get(
|
||||
x.get("severity", "info"), 9
|
||||
)
|
||||
)
|
||||
return items
|
||||
Reference in new issue
Block a user