AP2.2a: Archetyp-Starter-Kits und MVP Execution Plan v0.2.
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 2m40s
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 18s
Test Suite / playwright-smoke (push) Successful in 13s
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 2m40s
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 18s
Test Suite / playwright-smoke (push) Successful in 13s
Referenz-Vorhaben A1/A2/B2b/B2a per UI anlegbar mit gefuehrter Starter-Struktur; Dogfooding-Seed deprecated. Plan-Korrektur: Execution Plan v0.2 statt Seed-Spiegel als Prioritaet. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a097a82e17
commit
2b0d5dd3d9
18 files changed
+1050
-87
No files matched your search
@@ -0,0 +1,370 @@
|
||||
"""Archetyp Starter-Kits — AP2.2a (guided creation without Structure Builder)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
from entity_archetypes import resolve_default_method_key
|
||||
|
||||
# Stufe-A Archetypen mit automatischem Starter-Kit bei Anlage
|
||||
STARTER_KIT_ARCHETYPES = frozenset(
|
||||
{
|
||||
"initiative.maturity_journey",
|
||||
"initiative.linear_project",
|
||||
"initiative.product",
|
||||
"initiative.program",
|
||||
}
|
||||
)
|
||||
|
||||
_GUIDANCE: dict[str, str] = {
|
||||
"initiative.maturity_journey": (
|
||||
"Aktuelle Stufe und heutige Übung steuern deinen nächsten Schritt."
|
||||
),
|
||||
"initiative.linear_project": (
|
||||
"Nächster Schritt am kritischen Pfad — Abhängigkeiten im Plan-Graph."
|
||||
),
|
||||
"initiative.product": (
|
||||
"Eingang triagieren, dann committete Actions — optional Sprint-Zeitbox (B3)."
|
||||
),
|
||||
"initiative.program": (
|
||||
"Programm mit Abschluss — Gate-Horizont in Kontrolle."
|
||||
),
|
||||
}
|
||||
|
||||
_PROFILE_HINTS: dict[str, list[str]] = {
|
||||
"initiative.maturity_journey": ["maturity.karate_kumite"],
|
||||
"initiative.linear_project": [],
|
||||
"initiative.product": ["product.kairo_dev"],
|
||||
"initiative.program": [],
|
||||
}
|
||||
|
||||
|
||||
def _find_by_title(items: list[dict[str, Any]], title: str) -> Optional[dict[str, Any]]:
|
||||
for item in items:
|
||||
if item.get("title") == title:
|
||||
return item
|
||||
return None
|
||||
|
||||
|
||||
def supports_starter_kit(archetype_key: str) -> bool:
|
||||
return archetype_key in STARTER_KIT_ARCHETYPES
|
||||
|
||||
|
||||
def get_starter_preview(
|
||||
*,
|
||||
archetype_key: str,
|
||||
method_profile_key: Optional[str] = None,
|
||||
) -> dict[str, Any]:
|
||||
method_key = resolve_default_method_key(archetype_key)
|
||||
items: list[dict[str, Any]] = []
|
||||
|
||||
if archetype_key == "initiative.maturity_journey":
|
||||
items = [
|
||||
{"kind": "maturity_stage", "title": "Stufe 1 — Basis", "status": "active"},
|
||||
{"kind": "maturity_stage", "title": "Stufe 2 — Aufbau", "status": "planned"},
|
||||
{"kind": "maturity_stage", "title": "Stufe 3 — Ziel", "status": "planned"},
|
||||
{"kind": "project", "title": "Training"},
|
||||
{"kind": "recurring", "title": "Tägliche Übung"},
|
||||
]
|
||||
elif archetype_key == "initiative.linear_project":
|
||||
items = [
|
||||
{"kind": "milestone", "title": "G1 — Planung", "status": "active"},
|
||||
{"kind": "milestone", "title": "G2 — Vorbereitung", "status": "planned"},
|
||||
{"kind": "milestone", "title": "G3 — Umsetzung", "status": "planned"},
|
||||
{"kind": "milestone", "title": "G4 — Abschluss", "status": "planned"},
|
||||
{"kind": "project", "title": "Hauptpfad"},
|
||||
{"kind": "project", "title": "Begleitung"},
|
||||
]
|
||||
elif archetype_key == "initiative.product":
|
||||
items = [
|
||||
{"kind": "milestone", "title": "Orientierung", "status": "active"},
|
||||
{"kind": "milestone", "title": "Nächster Release-Horizont", "status": "planned"},
|
||||
{"kind": "project", "title": "Entwicklung"},
|
||||
{"kind": "project", "title": "Betrieb"},
|
||||
{"kind": "backlog_item", "title": "Idee / Issue"},
|
||||
{"kind": "hint", "title": "Optional: Sprint-Zeitbox unter Plan anlegen (B3)"},
|
||||
]
|
||||
elif archetype_key == "initiative.program":
|
||||
items = [
|
||||
{"kind": "milestone", "title": "Phase 1 — Start", "status": "active"},
|
||||
{"kind": "milestone", "title": "Phase 2 — Lieferung", "status": "planned"},
|
||||
{"kind": "milestone", "title": "Abschluss", "status": "planned"},
|
||||
]
|
||||
|
||||
return {
|
||||
"archetype_key": archetype_key,
|
||||
"method_key": method_key,
|
||||
"method_profile_key": method_profile_key,
|
||||
"supported": supports_starter_kit(archetype_key),
|
||||
"guidance": _GUIDANCE.get(archetype_key, ""),
|
||||
"method_profile_hints": _PROFILE_HINTS.get(archetype_key, []),
|
||||
"items": items,
|
||||
}
|
||||
|
||||
|
||||
def apply_starter_kit(
|
||||
*,
|
||||
tenant_id: str,
|
||||
initiative_id: str,
|
||||
archetype_key: str,
|
||||
owner_actor_id: Optional[str] = None,
|
||||
user_id: Optional[str] = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Apply idempotent starter structure for supported Stufe-A archetypes."""
|
||||
if not supports_starter_kit(archetype_key):
|
||||
return {"applied": False, "reason": "unsupported_archetype"}
|
||||
|
||||
from services.roadmap import list_roadmap_items_for_initiative
|
||||
|
||||
existing = list_roadmap_items_for_initiative(
|
||||
tenant_id=tenant_id, initiative_id=initiative_id
|
||||
)
|
||||
if existing:
|
||||
return {"applied": False, "reason": "structure_exists"}
|
||||
|
||||
created: dict[str, list[str]] = {
|
||||
"roadmap_items": [],
|
||||
"projects": [],
|
||||
"recurring": [],
|
||||
"backlog_items": [],
|
||||
}
|
||||
|
||||
if archetype_key == "initiative.maturity_journey":
|
||||
created = _apply_a1(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
user_id=user_id,
|
||||
)
|
||||
elif archetype_key == "initiative.linear_project":
|
||||
created = _apply_a2(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
user_id=user_id,
|
||||
)
|
||||
elif archetype_key == "initiative.product":
|
||||
created = _apply_b2b(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
user_id=user_id,
|
||||
)
|
||||
elif archetype_key == "initiative.program":
|
||||
created = _apply_b2a(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
from services.audit import log_audit
|
||||
|
||||
log_audit(
|
||||
"initiative.starter_kit_applied",
|
||||
user_id=user_id,
|
||||
tenant_id=tenant_id,
|
||||
details={
|
||||
"initiative_id": initiative_id,
|
||||
"archetype_key": archetype_key,
|
||||
"created": created,
|
||||
},
|
||||
)
|
||||
|
||||
return {
|
||||
"applied": True,
|
||||
"archetype_key": archetype_key,
|
||||
"guidance": _GUIDANCE.get(archetype_key, ""),
|
||||
"created": created,
|
||||
}
|
||||
|
||||
|
||||
def _apply_a1(
|
||||
*,
|
||||
tenant_id: str,
|
||||
initiative_id: str,
|
||||
user_id: Optional[str],
|
||||
) -> dict[str, list[str]]:
|
||||
from services.projects import create_project, list_projects_for_initiative
|
||||
from services.recurring import create_recurring_element, list_recurring_for_initiative
|
||||
from services.roadmap import create_roadmap_item
|
||||
|
||||
roadmap_ids: list[str] = []
|
||||
stage_defs = [
|
||||
("Stufe 1 — Basis", "active"),
|
||||
("Stufe 2 — Aufbau", "planned"),
|
||||
("Stufe 3 — Ziel", "planned"),
|
||||
]
|
||||
for index, (title, status) in enumerate(stage_defs):
|
||||
item = create_roadmap_item(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title=title,
|
||||
item_type="maturity_stage",
|
||||
status=status, # type: ignore[arg-type]
|
||||
sort_order=index * 10,
|
||||
user_id=user_id,
|
||||
)
|
||||
roadmap_ids.append(item["id"])
|
||||
|
||||
projects = list_projects_for_initiative(tenant_id=tenant_id, initiative_id=initiative_id)
|
||||
if not _find_by_title(projects, "Training"):
|
||||
create_project(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title="Training",
|
||||
description="Übungs- und Trainingsstruktur",
|
||||
sort_order=0,
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
recurring = list_recurring_for_initiative(tenant_id=tenant_id, initiative_id=initiative_id)
|
||||
if not _find_by_title(recurring, "Tägliche Übung"):
|
||||
create_recurring_element(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title="Tägliche Übung",
|
||||
description="Regelmäßige Übung für die aktuelle Reifegrad-Stufe",
|
||||
interval_days=1,
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
return {"roadmap_items": roadmap_ids, "projects": ["Training"], "recurring": ["Tägliche Übung"]}
|
||||
|
||||
|
||||
def _apply_a2(
|
||||
*,
|
||||
tenant_id: str,
|
||||
initiative_id: str,
|
||||
user_id: Optional[str],
|
||||
) -> dict[str, list[str]]:
|
||||
from services.projects import create_project, list_projects_for_initiative
|
||||
from services.roadmap import add_dependency, create_roadmap_item
|
||||
|
||||
gate_titles = [
|
||||
("G1 — Planung", "active"),
|
||||
("G2 — Vorbereitung", "planned"),
|
||||
("G3 — Umsetzung", "planned"),
|
||||
("G4 — Abschluss", "planned"),
|
||||
]
|
||||
gate_ids: list[str] = []
|
||||
for index, (title, status) in enumerate(gate_titles):
|
||||
item = create_roadmap_item(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title=title,
|
||||
item_type="milestone",
|
||||
status=status, # type: ignore[arg-type]
|
||||
sort_order=index * 10,
|
||||
user_id=user_id,
|
||||
)
|
||||
gate_ids.append(item["id"])
|
||||
|
||||
for index in range(1, len(gate_ids)):
|
||||
try:
|
||||
add_dependency(
|
||||
tenant_id=tenant_id,
|
||||
from_item_id=gate_ids[index],
|
||||
to_item_id=gate_ids[index - 1],
|
||||
dependency_type="requires",
|
||||
)
|
||||
except ValueError as exc:
|
||||
if "existiert bereits" not in str(exc):
|
||||
raise
|
||||
|
||||
projects = list_projects_for_initiative(tenant_id=tenant_id, initiative_id=initiative_id)
|
||||
for index, title in enumerate(["Hauptpfad", "Begleitung"]):
|
||||
if not _find_by_title(projects, title):
|
||||
create_project(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title=title,
|
||||
description=f"Ist-Struktur — {title}",
|
||||
sort_order=index,
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
return {
|
||||
"roadmap_items": gate_ids,
|
||||
"projects": ["Hauptpfad", "Begleitung"],
|
||||
}
|
||||
|
||||
|
||||
def _apply_b2b(
|
||||
*,
|
||||
tenant_id: str,
|
||||
initiative_id: str,
|
||||
user_id: Optional[str],
|
||||
) -> dict[str, list[str]]:
|
||||
from services.backlog import create_backlog_item, list_backlog_for_initiative
|
||||
from services.projects import create_project, list_projects_for_initiative
|
||||
from services.roadmap import create_roadmap_item
|
||||
|
||||
roadmap_ids: list[str] = []
|
||||
for index, (title, status) in enumerate(
|
||||
[("Orientierung", "active"), ("Nächster Release-Horizont", "planned")]
|
||||
):
|
||||
item = create_roadmap_item(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title=title,
|
||||
item_type="milestone",
|
||||
status=status, # type: ignore[arg-type]
|
||||
sort_order=index * 10,
|
||||
user_id=user_id,
|
||||
)
|
||||
roadmap_ids.append(item["id"])
|
||||
|
||||
projects = list_projects_for_initiative(tenant_id=tenant_id, initiative_id=initiative_id)
|
||||
for index, title in enumerate(["Entwicklung", "Betrieb"]):
|
||||
if not _find_by_title(projects, title):
|
||||
create_project(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title=title,
|
||||
description=f"Ist-Struktur — {title}",
|
||||
sort_order=index,
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
backlog = list_backlog_for_initiative(tenant_id=tenant_id, initiative_id=initiative_id)
|
||||
if not _find_by_title(backlog, "Idee / Issue"):
|
||||
create_backlog_item(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title="Idee / Issue",
|
||||
description="Product Backlog — noch nicht committet",
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
return {
|
||||
"roadmap_items": roadmap_ids,
|
||||
"projects": ["Entwicklung", "Betrieb"],
|
||||
"backlog_items": ["Idee / Issue"],
|
||||
}
|
||||
|
||||
|
||||
def _apply_b2a(
|
||||
*,
|
||||
tenant_id: str,
|
||||
initiative_id: str,
|
||||
user_id: Optional[str],
|
||||
) -> dict[str, list[str]]:
|
||||
from services.roadmap import create_roadmap_item
|
||||
|
||||
roadmap_ids: list[str] = []
|
||||
for index, (title, status) in enumerate(
|
||||
[
|
||||
("Phase 1 — Start", "active"),
|
||||
("Phase 2 — Lieferung", "planned"),
|
||||
("Abschluss", "planned"),
|
||||
]
|
||||
):
|
||||
item = create_roadmap_item(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title=title,
|
||||
item_type="milestone",
|
||||
status=status, # type: ignore[arg-type]
|
||||
sort_order=index * 10,
|
||||
user_id=user_id,
|
||||
)
|
||||
roadmap_ids.append(item["id"])
|
||||
|
||||
return {"roadmap_items": roadmap_ids}
|
||||
@@ -74,6 +74,7 @@ def create_initiative(
|
||||
priority: Priority = "normal",
|
||||
user_id: Optional[str] = None,
|
||||
method_profile_key: Optional[str] = None,
|
||||
apply_starter_kit: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
title = title.strip()
|
||||
if not title:
|
||||
@@ -138,6 +139,17 @@ def create_initiative(
|
||||
archetype_key=archetype_key,
|
||||
method_profile_key=method_profile_key,
|
||||
)
|
||||
if apply_starter_kit:
|
||||
from services.archetype_starter_kit import apply_starter_kit
|
||||
|
||||
starter = apply_starter_kit(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=row["id"],
|
||||
archetype_key=archetype_key,
|
||||
owner_actor_id=owner_actor_id,
|
||||
user_id=user_id,
|
||||
)
|
||||
row["starter_kit"] = starter
|
||||
return row
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user