AP2.2b/c: A1-Stufenwechsel, Team-Fix, Agent-Anlage, Steuerungs-Hinweise.
AP2.0e rotiert Recurring bei maturity_stage reached. Maturity-Strategie priorisiert Routinen. Team zeigt Namen und Agent-Formular. Archetyp-Hints in Kontrolle und Stufe-A-Gruppierung bei Anlage. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2b0d5dd3d9
commit
0b57e2ec75
18 files changed
+507
-107
No files matched your search
@@ -14,6 +14,10 @@ from steering.strategies.next_action.execution_ready import (
|
||||
from steering.strategies.next_action.product_milestone_driven import (
|
||||
ProductMilestoneDrivenStrategy,
|
||||
)
|
||||
from steering.strategies.next_action.recurring_helpers import (
|
||||
active_recurring_candidates,
|
||||
recurring_due_candidates,
|
||||
)
|
||||
from steering.strategies.next_action.registry import (
|
||||
get_next_action_strategy,
|
||||
register_next_action_strategy,
|
||||
@@ -39,26 +43,37 @@ class MaturityProgressionStrategy:
|
||||
if not initiative_id:
|
||||
return _default.evaluate(ctx, limit=limit)
|
||||
|
||||
gate_scope = first_active_gate_id(ctx, initiative_id)
|
||||
ready = list_execution_ready_candidates(
|
||||
ctx,
|
||||
initiative_id,
|
||||
limit=limit,
|
||||
scope_roadmap_item_id=gate_scope,
|
||||
prefer_critical_path=True,
|
||||
)
|
||||
recurring = recurring_due_candidates(ctx, initiative_id, limit=limit)
|
||||
if not recurring:
|
||||
recurring = active_recurring_candidates(ctx, initiative_id, limit=1)
|
||||
|
||||
remaining = limit - len(ready)
|
||||
gate_items: list[dict[str, Any]] = []
|
||||
remaining = limit - len(recurring)
|
||||
gate_scope = first_active_gate_id(ctx, initiative_id)
|
||||
ready: list[dict[str, Any]] = []
|
||||
if remaining > 0:
|
||||
ready = list_execution_ready_candidates(
|
||||
ctx,
|
||||
initiative_id,
|
||||
limit=remaining,
|
||||
scope_roadmap_item_id=gate_scope,
|
||||
prefer_critical_path=True,
|
||||
)
|
||||
|
||||
merged = merge_candidates(recurring, ready, limit=limit)
|
||||
if len(merged) >= limit:
|
||||
return merged[:limit]
|
||||
|
||||
gate_items: list[dict[str, Any]] = []
|
||||
rest_limit = limit - len(merged)
|
||||
if rest_limit > 0:
|
||||
gate_items = _milestone.evaluate(
|
||||
ctx, initiative_id=initiative_id, limit=remaining
|
||||
ctx, initiative_id=initiative_id, limit=rest_limit
|
||||
)
|
||||
gate_items = [
|
||||
item for item in gate_items if item.get("kind") == "review_milestone"
|
||||
]
|
||||
|
||||
merged = merge_candidates(ready, gate_items, limit=limit)
|
||||
merged = merge_candidates(merged, gate_items, limit=limit)
|
||||
if len(merged) >= limit:
|
||||
return merged[:limit]
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from db import get_connection
|
||||
from psycopg2.extras import RealDictCursor
|
||||
from steering.strategies.next_action.recurring_helpers import recurring_due_candidates
|
||||
from steering.signals import default_rules
|
||||
from steering.strategies.next_action.default_strategy import DefaultNextActionStrategy
|
||||
from steering.strategies.next_action.execution_ready import (
|
||||
@@ -21,43 +20,6 @@ from tenant_context import TenantContext
|
||||
_default = DefaultNextActionStrategy()
|
||||
|
||||
|
||||
def _recurring_due_candidates(
|
||||
ctx: TenantContext, initiative_id: str, *, limit: int
|
||||
) -> list[dict[str, Any]]:
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor(cursor_factory=RealDictCursor) as cur:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT
|
||||
'recurring_due' AS kind,
|
||||
re.title AS title,
|
||||
'Wiederkehrendes Element fällig' AS summary,
|
||||
re.initiative_id,
|
||||
NULL::uuid AS action_id,
|
||||
NULL::uuid AS backlog_item_id,
|
||||
'recurring_due' AS reason_code,
|
||||
'Rhythmus-Element bearbeiten' AS recommended_action
|
||||
FROM recurring_elements re
|
||||
WHERE re.tenant_id = %s AND re.initiative_id = %s
|
||||
AND re.status = 'active'
|
||||
AND re.next_due_at IS NOT NULL
|
||||
AND re.next_due_at <= NOW()
|
||||
ORDER BY re.next_due_at ASC
|
||||
LIMIT %s
|
||||
""",
|
||||
(ctx.tenant_id, initiative_id, limit),
|
||||
)
|
||||
items: list[dict[str, Any]] = []
|
||||
for row in cur.fetchall():
|
||||
item = dict(row)
|
||||
item["initiative_id"] = str(item["initiative_id"])
|
||||
items.append(item)
|
||||
return items
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
class RecurringControlStrategy:
|
||||
key = "recurring_control"
|
||||
|
||||
@@ -73,7 +35,7 @@ class RecurringControlStrategy:
|
||||
if not initiative_id:
|
||||
return _default.evaluate(ctx, limit=limit)
|
||||
|
||||
recurring = _recurring_due_candidates(ctx, initiative_id, limit=limit)
|
||||
recurring = recurring_due_candidates(ctx, initiative_id, limit=limit)
|
||||
remaining = limit - len(recurring)
|
||||
ready: list[dict[str, Any]] = []
|
||||
if remaining > 0:
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
"""Shared recurring NextAction helpers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from db import get_connection
|
||||
from psycopg2.extras import RealDictCursor
|
||||
from tenant_context import TenantContext
|
||||
|
||||
|
||||
def recurring_due_candidates(
|
||||
ctx: TenantContext, initiative_id: str, *, limit: int
|
||||
) -> list[dict[str, Any]]:
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor(cursor_factory=RealDictCursor) as cur:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT
|
||||
'recurring_due' AS kind,
|
||||
re.title AS title,
|
||||
'Wiederkehrendes Element fällig' AS summary,
|
||||
re.initiative_id,
|
||||
NULL::uuid AS action_id,
|
||||
NULL::uuid AS backlog_item_id,
|
||||
'recurring_due' AS reason_code,
|
||||
'Rhythmus-Element bearbeiten' AS recommended_action
|
||||
FROM recurring_elements re
|
||||
WHERE re.tenant_id = %s AND re.initiative_id = %s
|
||||
AND re.status = 'active'
|
||||
AND re.next_due_at IS NOT NULL
|
||||
AND re.next_due_at <= NOW()
|
||||
ORDER BY re.next_due_at ASC
|
||||
LIMIT %s
|
||||
""",
|
||||
(ctx.tenant_id, initiative_id, limit),
|
||||
)
|
||||
items: list[dict[str, Any]] = []
|
||||
for row in cur.fetchall():
|
||||
item = dict(row)
|
||||
item["initiative_id"] = str(item["initiative_id"])
|
||||
items.append(item)
|
||||
return items
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def active_recurring_candidates(
|
||||
ctx: TenantContext, initiative_id: str, *, limit: int = 1
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Active recurring as 'heutige Übung' when nothing is due yet."""
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor(cursor_factory=RealDictCursor) as cur:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT
|
||||
'recurring_due' AS kind,
|
||||
re.title AS title,
|
||||
'Heutige Übung / Routine' AS summary,
|
||||
re.initiative_id,
|
||||
NULL::uuid AS action_id,
|
||||
NULL::uuid AS backlog_item_id,
|
||||
'recurring_active' AS reason_code,
|
||||
'Routine ausführen' AS recommended_action
|
||||
FROM recurring_elements re
|
||||
WHERE re.tenant_id = %s AND re.initiative_id = %s
|
||||
AND re.status = 'active'
|
||||
ORDER BY re.next_due_at ASC NULLS LAST, re.title
|
||||
LIMIT %s
|
||||
""",
|
||||
(ctx.tenant_id, initiative_id, limit),
|
||||
)
|
||||
items: list[dict[str, Any]] = []
|
||||
for row in cur.fetchall():
|
||||
item = dict(row)
|
||||
item["initiative_id"] = str(item["initiative_id"])
|
||||
items.append(item)
|
||||
return items
|
||||
finally:
|
||||
conn.close()
|
||||
Reference in new issue
Block a user