AP1.2 + AP1.4: Signals konsolidieren, RoadmapItem mit Gate-Verify
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Failing after 1m30s
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 46s
Test Suite / pytest-backend (push) Failing after 1m30s
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
Entfernt operating_phase aus dem Snapshot zugunsten von Lifecycle + signals. Führt methodenneutrale RoadmapItems (Migration 010), Verify-Pfad und Plan-UI ein. Milestone-API bleibt als Compat-Wrapper; Version 0.13.0-ap1.4. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a5d9eeb338
commit
09433b5d28
25 files changed
+1582
-343
No files matched your search
@@ -5,28 +5,17 @@ Baut aus flachen OM-Tabellen einen erklärbaren Graph für UI und spätere Steer
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Literal, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from psycopg2.extras import RealDictCursor
|
||||
|
||||
from db import get_connection
|
||||
from data_layer.attention import get_next_action_candidates_for_initiative
|
||||
from steering.context import get_steering_context_dto
|
||||
from steering.signals.snapshot_signals import derive_initiative_signals
|
||||
from services.initiatives import get_initiative
|
||||
from tenant_context import TenantContext
|
||||
|
||||
OperatingPhase = Literal[
|
||||
"capture",
|
||||
"triage",
|
||||
"structure",
|
||||
"commit",
|
||||
"execute",
|
||||
"verify",
|
||||
"review",
|
||||
"adapt",
|
||||
"closure",
|
||||
]
|
||||
|
||||
OPEN_BLOCKER = ("open", "in_progress")
|
||||
OPEN_ACTION = ("open", "ready", "in_progress", "blocked", "review_required")
|
||||
ACTIVE_INITIATIVE = ("active", "paused")
|
||||
@@ -40,51 +29,6 @@ def _iso(value: Any) -> Optional[str]:
|
||||
return value.isoformat() if value else None
|
||||
|
||||
|
||||
def _derive_operating_phase(
|
||||
*,
|
||||
initiative_status: str,
|
||||
open_actions: int,
|
||||
blocked_actions: int,
|
||||
review_required_actions: int,
|
||||
open_blockers: int,
|
||||
backlog_new: int,
|
||||
planned_reviews_due: int,
|
||||
) -> tuple[OperatingPhase, list[str]]:
|
||||
"""Heuristische, erklärbare Phase — kein Lifecycle-State-Machine-Ersatz."""
|
||||
signals: list[str] = []
|
||||
|
||||
if initiative_status in ("completed", "archived"):
|
||||
return "closure", ["initiative_terminal"]
|
||||
|
||||
if open_actions == 0 and backlog_new > 0:
|
||||
signals.append("backlog_awaiting_commit")
|
||||
return "triage", signals
|
||||
|
||||
if open_actions == 0 and backlog_new == 0:
|
||||
signals.append("no_open_work")
|
||||
return "structure", signals
|
||||
|
||||
if blocked_actions > 0 or open_blockers > 0:
|
||||
if blocked_actions:
|
||||
signals.append("actions_blocked")
|
||||
if open_blockers:
|
||||
signals.append("open_blockers")
|
||||
return "execute", signals
|
||||
|
||||
if review_required_actions > 0 or planned_reviews_due > 0:
|
||||
if review_required_actions:
|
||||
signals.append("actions_need_review")
|
||||
if planned_reviews_due:
|
||||
signals.append("reviews_due")
|
||||
return "review", signals
|
||||
|
||||
if open_actions > 0:
|
||||
signals.append("work_in_progress")
|
||||
return "execute", signals
|
||||
|
||||
return "adapt", signals
|
||||
|
||||
|
||||
def get_initiative_steering_snapshot(
|
||||
ctx: TenantContext, *, initiative_id: str
|
||||
) -> Optional[dict[str, Any]]:
|
||||
@@ -155,14 +99,16 @@ def get_initiative_steering_snapshot(
|
||||
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT id, title, status, target_date, created_at, updated_at
|
||||
FROM milestones
|
||||
WHERE tenant_id = %s AND initiative_id = %s
|
||||
ORDER BY updated_at DESC
|
||||
SELECT id, title, status, target_date, item_type, sequencing_mode,
|
||||
sort_order, created_at, updated_at
|
||||
FROM roadmap_items ri
|
||||
JOIN roadmaps r ON r.id = ri.roadmap_id AND r.tenant_id = ri.tenant_id
|
||||
WHERE ri.tenant_id = %s AND r.initiative_id = %s
|
||||
ORDER BY ri.sort_order ASC, ri.updated_at DESC
|
||||
""",
|
||||
(ctx.tenant_id, initiative_id),
|
||||
)
|
||||
milestones_raw = [dict(r) for r in cur.fetchall()]
|
||||
roadmap_items_raw = [dict(r) for r in cur.fetchall()]
|
||||
|
||||
cur.execute(
|
||||
"""
|
||||
@@ -270,14 +216,17 @@ def get_initiative_steering_snapshot(
|
||||
}
|
||||
)
|
||||
|
||||
milestones = []
|
||||
for m in milestones_raw:
|
||||
roadmap_items: list[dict[str, Any]] = []
|
||||
for m in roadmap_items_raw:
|
||||
mid = _sid(m["id"])
|
||||
milestones.append(
|
||||
roadmap_items.append(
|
||||
{
|
||||
"id": mid,
|
||||
"title": m["title"],
|
||||
"status": m["status"],
|
||||
"item_type": m["item_type"],
|
||||
"sequencing_mode": m["sequencing_mode"],
|
||||
"sort_order": m.get("sort_order", 0),
|
||||
"target_date": m["target_date"].isoformat() if m.get("target_date") else None,
|
||||
"reviews": reviews_by_milestone.get(mid, []),
|
||||
}
|
||||
@@ -288,7 +237,7 @@ def get_initiative_steering_snapshot(
|
||||
)
|
||||
backlog_new = sum(1 for bi in backlog if bi["status"] in ("new", "triaged", "accepted"))
|
||||
|
||||
phase, phase_signals = _derive_operating_phase(
|
||||
signals = derive_initiative_signals(
|
||||
initiative_status=initiative["status"],
|
||||
open_actions=open_actions,
|
||||
blocked_actions=blocked_actions,
|
||||
@@ -301,7 +250,7 @@ def get_initiative_steering_snapshot(
|
||||
upcoming_milestones = sorted(
|
||||
[
|
||||
m
|
||||
for m in milestones
|
||||
for m in roadmap_items
|
||||
if m["status"] in ("planned", "active", "at_risk")
|
||||
],
|
||||
key=lambda m: (m["target_date"] is None, m["target_date"] or ""),
|
||||
@@ -322,10 +271,9 @@ def get_initiative_steering_snapshot(
|
||||
"method_key": steering["method_key"],
|
||||
"method_label": steering.get("method_label"),
|
||||
"method_version": steering["method_version"],
|
||||
"operating_phase": phase,
|
||||
"operating_phase_deprecated": True,
|
||||
"phase_signals": phase_signals,
|
||||
"signals": signals,
|
||||
"upcoming_milestones": upcoming_milestones,
|
||||
"upcoming_roadmap_items": upcoming_milestones,
|
||||
"next_actions": next_actions,
|
||||
"counts": {
|
||||
"actions_open": open_actions,
|
||||
@@ -341,7 +289,8 @@ def get_initiative_steering_snapshot(
|
||||
"unlinked_reviews": len(unlinked_reviews),
|
||||
},
|
||||
"actions": actions,
|
||||
"milestones": milestones,
|
||||
"roadmap_items": roadmap_items,
|
||||
"milestones": roadmap_items,
|
||||
"initiative_level": {
|
||||
"blockers": unlinked_blockers,
|
||||
"evidence": unlinked_evidence,
|
||||
|
||||
Reference in new issue
Block a user