feat(steering): Kernel v0.4 Agent-Slots, Tech Debt und Review-Attention
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Failing after 4m15s
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
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Failing after 4m15s
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
K-Ext-4/P8 deklarative Agent-Slots; P7 tech_debt Read Model und Vokabular; Review-Attention in den Kernel verlagert. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b747200f3a
commit
a5154cbd3b
31 files changed
+954
-98
No files matched your search
@@ -0,0 +1 @@
|
||||
"""Agent slot providers — K-Ext-4 / P8."""
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Agent slots for architecture guardrail reviews at active gates."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from steering.eval_context import SteeringEvalContext
|
||||
|
||||
|
||||
def resolve_guardrail_review_slots(
|
||||
ctx: SteeringEvalContext,
|
||||
read_models: dict[str, Any],
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Emit guardrail slot when active gate has planning debt or open review actions."""
|
||||
horizon = ctx.horizon
|
||||
if horizon.kind != "gate" or not horizon.gate_roadmap_item_id:
|
||||
return []
|
||||
|
||||
gate_id = str(horizon.gate_roadmap_item_id)
|
||||
guardrail_pack = ctx.agent_slot_config.get("guardrail_pack") or "default_v0"
|
||||
|
||||
has_planned_guardrail = any(
|
||||
review.get("status") == "planned"
|
||||
and str(review.get("milestone_id") or "") == gate_id
|
||||
for review in ctx.reviews
|
||||
)
|
||||
if has_planned_guardrail:
|
||||
return []
|
||||
|
||||
planning_debt = read_models.get("planning_debt") or []
|
||||
gate_debt = any(str(d.get("roadmap_item_id") or "") == gate_id for d in planning_debt)
|
||||
open_review_actions = any(
|
||||
action.get("action_kind") == "review"
|
||||
and str(action.get("roadmap_item_id") or "") == gate_id
|
||||
and action.get("status") in ("open", "ready", "in_progress", "review_required")
|
||||
for action in ctx.actions
|
||||
)
|
||||
if not gate_debt and not open_review_actions:
|
||||
return []
|
||||
|
||||
return [
|
||||
{
|
||||
"slot_key": "review.guardrail",
|
||||
"scope_type": "roadmap_item",
|
||||
"scope_id": gate_id,
|
||||
"title": horizon.gate_title or "Guardrail-Review",
|
||||
"summary": "Architektur-Guardrail für aktives Gate prüfen",
|
||||
"actor_role_hint": "architecture_reviewer",
|
||||
"payload_keys": ["checklist_id", "guardrail_pack"],
|
||||
"guardrail_pack": guardrail_pack,
|
||||
"priority": "normal",
|
||||
"roadmap_item_id": gate_id,
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,48 @@
|
||||
"""Agent slots for due recurring elements."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any
|
||||
|
||||
from steering.eval_context import SteeringEvalContext
|
||||
|
||||
|
||||
def _parse_due(value: Any) -> datetime | None:
|
||||
if not value:
|
||||
return None
|
||||
if isinstance(value, datetime):
|
||||
return value if value.tzinfo else value.replace(tzinfo=timezone.utc)
|
||||
try:
|
||||
text = str(value).replace("Z", "+00:00")
|
||||
parsed = datetime.fromisoformat(text)
|
||||
return parsed if parsed.tzinfo else parsed.replace(tzinfo=timezone.utc)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
|
||||
def resolve_recurring_due_slots(ctx: SteeringEvalContext) -> list[dict[str, Any]]:
|
||||
now = datetime.now(timezone.utc)
|
||||
slots: list[dict[str, Any]] = []
|
||||
|
||||
for element in ctx.recurring_elements:
|
||||
if element.get("status") != "active":
|
||||
continue
|
||||
due = _parse_due(element.get("next_due_at"))
|
||||
if due is None or due > now:
|
||||
continue
|
||||
slots.append(
|
||||
{
|
||||
"slot_key": "recurring.due",
|
||||
"scope_type": "recurring_element",
|
||||
"scope_id": str(element["id"]),
|
||||
"title": element.get("title") or "Rhythmus",
|
||||
"summary": "Wiederkehrendes Element ist fällig",
|
||||
"actor_role_hint": "operator",
|
||||
"payload_keys": ["recurring_id", "interval_days"],
|
||||
"priority": "normal",
|
||||
"recurring_element_id": str(element["id"]),
|
||||
}
|
||||
)
|
||||
|
||||
return slots
|
||||
@@ -0,0 +1,107 @@
|
||||
"""Agent slot provider registry — K-Ext-4."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Callable
|
||||
|
||||
from steering.eval_context import SteeringEvalContext
|
||||
|
||||
AgentSlotResolve = Callable[[SteeringEvalContext, dict[str, Any], dict[str, Any]], list[dict]]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class AgentSlotProvider:
|
||||
slot_key: str
|
||||
requires_elements: frozenset[str]
|
||||
requires_data_slices: frozenset[str]
|
||||
resolve: AgentSlotResolve
|
||||
requires_any_element: frozenset[str] = field(default_factory=frozenset)
|
||||
excludes_elements: frozenset[str] = field(default_factory=frozenset)
|
||||
|
||||
|
||||
_PROVIDERS: list[AgentSlotProvider] = []
|
||||
|
||||
|
||||
def register_agent_slot(provider: AgentSlotProvider) -> None:
|
||||
_PROVIDERS.append(provider)
|
||||
|
||||
|
||||
def _slot_enabled(ctx: SteeringEvalContext, slot_key: str) -> bool:
|
||||
config = ctx.agent_slot_config
|
||||
enabled = config.get("enabled_slots")
|
||||
if enabled is None:
|
||||
return True
|
||||
return slot_key in enabled
|
||||
|
||||
|
||||
def compute_agent_slots(
|
||||
ctx: SteeringEvalContext,
|
||||
*,
|
||||
read_models: dict[str, Any],
|
||||
proposals: dict[str, Any],
|
||||
) -> list[dict[str, Any]]:
|
||||
elements = ctx.steering_elements
|
||||
slices = frozenset(ctx.data_slices)
|
||||
slots: list[dict[str, Any]] = []
|
||||
|
||||
for provider in _PROVIDERS:
|
||||
if not _slot_enabled(ctx, provider.slot_key):
|
||||
continue
|
||||
if provider.requires_elements and not provider.requires_elements <= elements:
|
||||
continue
|
||||
if provider.excludes_elements and provider.excludes_elements & elements:
|
||||
continue
|
||||
if provider.requires_any_element and not (
|
||||
provider.requires_any_element & elements
|
||||
):
|
||||
continue
|
||||
if provider.requires_data_slices and not provider.requires_data_slices <= slices:
|
||||
continue
|
||||
slots.extend(provider.resolve(ctx, read_models, proposals))
|
||||
|
||||
for slot in slots:
|
||||
slot.setdefault("data_source", "steering_kernel")
|
||||
slot.setdefault("initiative_id", ctx.initiative_id)
|
||||
slot.setdefault("context_refs", ["steering_snapshot", "operating_context"])
|
||||
|
||||
slots.sort(
|
||||
key=lambda s: {"high": 0, "normal": 1, "low": 2}.get(s.get("priority", "normal"), 9)
|
||||
)
|
||||
return slots
|
||||
|
||||
|
||||
def _register_builtin_agent_slots() -> None:
|
||||
from steering.agent_slots.guardrail_review import resolve_guardrail_review_slots
|
||||
from steering.agent_slots.recurring_due import resolve_recurring_due_slots
|
||||
from steering.agent_slots.review_due import resolve_review_due_slots
|
||||
|
||||
register_agent_slot(
|
||||
AgentSlotProvider(
|
||||
slot_key="review.due",
|
||||
requires_elements=frozenset(),
|
||||
requires_data_slices=frozenset({"reviews"}),
|
||||
resolve=lambda ctx, read_models, proposals: resolve_review_due_slots(ctx),
|
||||
)
|
||||
)
|
||||
register_agent_slot(
|
||||
AgentSlotProvider(
|
||||
slot_key="recurring.due",
|
||||
requires_elements=frozenset({"recurring_rhythm"}),
|
||||
requires_data_slices=frozenset({"recurring"}),
|
||||
resolve=lambda ctx, read_models, proposals: resolve_recurring_due_slots(ctx),
|
||||
)
|
||||
)
|
||||
register_agent_slot(
|
||||
AgentSlotProvider(
|
||||
slot_key="review.guardrail",
|
||||
requires_elements=frozenset({"gate_fulfillment"}),
|
||||
requires_data_slices=frozenset({"reviews", "roadmap"}),
|
||||
resolve=lambda ctx, read_models, proposals: resolve_guardrail_review_slots(
|
||||
ctx, read_models
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
_register_builtin_agent_slots()
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Agent slots for due planned reviews."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any
|
||||
|
||||
from steering.eval_context import SteeringEvalContext
|
||||
|
||||
|
||||
def _parse_due(value: Any) -> datetime | None:
|
||||
if not value:
|
||||
return None
|
||||
if isinstance(value, datetime):
|
||||
return value if value.tzinfo else value.replace(tzinfo=timezone.utc)
|
||||
try:
|
||||
text = str(value).replace("Z", "+00:00")
|
||||
parsed = datetime.fromisoformat(text)
|
||||
return parsed if parsed.tzinfo else parsed.replace(tzinfo=timezone.utc)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
|
||||
def resolve_review_due_slots(ctx: SteeringEvalContext) -> list[dict[str, Any]]:
|
||||
now = datetime.now(timezone.utc)
|
||||
slots: list[dict[str, Any]] = []
|
||||
|
||||
for review in ctx.reviews:
|
||||
if review.get("status") != "planned":
|
||||
continue
|
||||
due = _parse_due(review.get("due_at"))
|
||||
if due is None or due > now:
|
||||
continue
|
||||
slots.append(
|
||||
{
|
||||
"slot_key": "review.due",
|
||||
"scope_type": "review",
|
||||
"scope_id": str(review["id"]),
|
||||
"title": review.get("title") or "Review",
|
||||
"summary": "Geplantes Review ist fällig",
|
||||
"actor_role_hint": "reviewer",
|
||||
"payload_keys": ["review_id", "checklist_id"],
|
||||
"priority": "high" if due < now else "normal",
|
||||
"review_id": str(review["id"]),
|
||||
"action_id": (
|
||||
str(review["action_id"]) if review.get("action_id") else None
|
||||
),
|
||||
"milestone_id": (
|
||||
str(review["milestone_id"]) if review.get("milestone_id") else None
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
return slots
|
||||
Reference in new issue
Block a user