AP1.4d: Graph Engine mit blocked/ready Read Models.
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 2m17s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 13s

Migration 020 fuer Kantenarten und Parallelgruppe; steering/graph berechnet Fortschritt; UI zeigt Bereit/Blockiert in Liste und Graph.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-11 07:59:18 +02:00
1 parent bd64340ca1
commit 4f8725e234
15 files changed
+488 -84

No files matched your search

+33 -30
View File
@@ -18,14 +18,14 @@ RoadmapItemStatus = Literal[
"planned", "active", "at_risk", "reached", "moved", "discarded"
]
SequencingMode = Literal["sequential", "parallel", "optional"]
DependencyType = Literal["requires", "blocks", "related"]
DependencyType = Literal["requires", "blocks", "related", "parallel_group", "optional_branch"]
ROADMAP_ITEM_TYPES = frozenset({"milestone", "review_gate", "maturity_stage"})
ROADMAP_ITEM_STATUSES = frozenset(
{"planned", "active", "at_risk", "reached", "moved", "discarded"}
)
SEQUENCING_MODES = frozenset({"sequential", "parallel", "optional"})
DEPENDENCY_TYPES = frozenset({"requires", "blocks", "related"})
DEPENDENCY_TYPES = frozenset({"requires", "blocks", "related", "parallel_group", "optional_branch"})
TERMINAL_STATUSES = frozenset({"reached", "moved", "discarded"})
@@ -457,6 +457,18 @@ def delete_roadmap_item(
return deleted
def _serialize_dependency(row: dict[str, Any]) -> dict[str, Any]:
dep = dict(row)
for key in ("id", "tenant_id", "from_item_id", "to_item_id"):
if dep.get(key):
dep[key] = str(dep[key])
if dep.get("created_at"):
dep["created_at"] = dep["created_at"].isoformat()
if dep.get("group_key") is None:
dep.pop("group_key", None)
return dep
def list_dependencies(*, tenant_id: str, item_id: str) -> list[dict[str, Any]]:
item = get_roadmap_item(tenant_id=tenant_id, item_id=item_id)
if not item:
@@ -467,22 +479,15 @@ def list_dependencies(*, tenant_id: str, item_id: str) -> list[dict[str, Any]]:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute(
"""
SELECT id, tenant_id, from_item_id, to_item_id, dependency_type, created_at
SELECT id, tenant_id, from_item_id, to_item_id, dependency_type,
group_key, created_at
FROM roadmap_item_dependencies
WHERE tenant_id = %s AND (from_item_id = %s OR to_item_id = %s)
ORDER BY created_at ASC
""",
(tenant_id, item_id, item_id),
)
items = []
for row in cur.fetchall():
dep = dict(row)
for key in ("id", "tenant_id", "from_item_id", "to_item_id"):
dep[key] = str(dep[key])
if dep.get("created_at"):
dep["created_at"] = dep["created_at"].isoformat()
items.append(dep)
return items
return [_serialize_dependency(dict(row)) for row in cur.fetchall()]
finally:
conn.close()
@@ -499,7 +504,7 @@ def list_dependencies_for_initiative(
cur.execute(
"""
SELECT d.id, d.tenant_id, d.from_item_id, d.to_item_id,
d.dependency_type, d.created_at
d.dependency_type, d.group_key, d.created_at
FROM roadmap_item_dependencies d
INNER JOIN roadmap_items fi
ON fi.id = d.from_item_id AND fi.tenant_id = d.tenant_id
@@ -510,15 +515,7 @@ def list_dependencies_for_initiative(
""",
(tenant_id, initiative_id),
)
items = []
for row in cur.fetchall():
dep = dict(row)
for key in ("id", "tenant_id", "from_item_id", "to_item_id"):
dep[key] = str(dep[key])
if dep.get("created_at"):
dep["created_at"] = dep["created_at"].isoformat()
items.append(dep)
return items
return [_serialize_dependency(dict(row)) for row in cur.fetchall()]
finally:
conn.close()
@@ -529,6 +526,7 @@ def add_dependency(
from_item_id: str,
to_item_id: str,
dependency_type: DependencyType = "requires",
group_key: Optional[str] = None,
user_id: Optional[str] = None,
) -> dict[str, Any]:
_validate_dependency_type(dependency_type)
@@ -542,6 +540,12 @@ def add_dependency(
if from_item["initiative_id"] != to_item["initiative_id"]:
raise ValueError("Abhängigkeiten nur innerhalb eines Vorhabens")
normalized_group_key: Optional[str] = None
if group_key is not None:
normalized_group_key = group_key.strip() or None
if dependency_type == "parallel_group" and not normalized_group_key:
raise ValueError("group_key ist für parallel_group erforderlich")
conn = get_connection()
try:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
@@ -559,17 +563,15 @@ def add_dependency(
cur.execute(
"""
INSERT INTO roadmap_item_dependencies (
tenant_id, from_item_id, to_item_id, dependency_type
tenant_id, from_item_id, to_item_id, dependency_type, group_key
)
VALUES (%s, %s, %s, %s)
RETURNING id, tenant_id, from_item_id, to_item_id, dependency_type, created_at
VALUES (%s, %s, %s, %s, %s)
RETURNING id, tenant_id, from_item_id, to_item_id, dependency_type,
group_key, created_at
""",
(tenant_id, from_item_id, to_item_id, dependency_type),
(tenant_id, from_item_id, to_item_id, dependency_type, normalized_group_key),
)
row = dict(cur.fetchone())
for key in ("id", "tenant_id", "from_item_id", "to_item_id"):
row[key] = str(row[key])
row["created_at"] = row["created_at"].isoformat()
row = _serialize_dependency(dict(cur.fetchone()))
conn.commit()
finally:
conn.close()
@@ -582,6 +584,7 @@ def add_dependency(
"from_item_id": from_item_id,
"to_item_id": to_item_id,
"dependency_type": dependency_type,
"group_key": normalized_group_key,
},
)
return row