AP2.0: Archetyp-Katalog, Method-Stubs und sichtbare Steuerung in Kontrolle.
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Failing after 2m2s
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 3s
Test Suite / compose-smoke (push) Has been skipped
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Failing after 2m2s
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 3s
Test Suite / compose-smoke (push) Has been skipped
PO-Dokumente (ADP v0.2, MVP v0.3) und Minimal Complete Slice: Registry-Methoden, Initiative/Project-Spiegel, Default-Methode bei Anlage, Lagebild mit Archetyp und Guidance. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
21d948634e
commit
3bd983297b
30 files changed
+2093
-52
No files matched your search
@@ -124,6 +124,7 @@ def create_initiative(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=row["id"],
|
||||
user_id=user_id,
|
||||
archetype_key=archetype_key,
|
||||
)
|
||||
return row
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from psycopg2.extras import RealDictCursor
|
||||
|
||||
from db import get_connection
|
||||
from services.audit import log_audit
|
||||
from entity_archetypes import mirror_project_archetype_key, validate_archetype_key
|
||||
from services.initiatives import get_initiative
|
||||
|
||||
ProjectStatus = Literal["active", "paused", "completed", "archived"]
|
||||
@@ -21,7 +22,7 @@ MAX_PROJECT_DEPTH = 5
|
||||
|
||||
_PROJECT_COLUMNS = """
|
||||
id, tenant_id, initiative_id, parent_project_id, container_kind,
|
||||
title, description, status,
|
||||
archetype_key, title, description, status,
|
||||
roadmap_item_id, sort_order, target_date, created_at, updated_at
|
||||
"""
|
||||
|
||||
@@ -227,6 +228,7 @@ def create_project(
|
||||
roadmap_item_id: Optional[str] = None,
|
||||
sort_order: int = 0,
|
||||
target_date: Optional[date] = None,
|
||||
archetype_key: Optional[str] = None,
|
||||
user_id: Optional[str] = None,
|
||||
) -> dict[str, Any]:
|
||||
title = title.strip()
|
||||
@@ -234,9 +236,15 @@ def create_project(
|
||||
raise ValueError("Titel ist erforderlich")
|
||||
_validate_status(status)
|
||||
_validate_container_kind(container_kind)
|
||||
if not get_initiative(tenant_id=tenant_id, initiative_id=initiative_id):
|
||||
initiative = get_initiative(tenant_id=tenant_id, initiative_id=initiative_id)
|
||||
if not initiative:
|
||||
raise ValueError("Initiative nicht gefunden")
|
||||
|
||||
resolved_archetype = archetype_key or mirror_project_archetype_key(
|
||||
initiative["archetype_key"]
|
||||
)
|
||||
validate_archetype_key(entity_type="project", archetype_key=resolved_archetype)
|
||||
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor(cursor_factory=RealDictCursor) as cur:
|
||||
@@ -257,10 +265,10 @@ def create_project(
|
||||
f"""
|
||||
INSERT INTO projects (
|
||||
tenant_id, initiative_id, parent_project_id, container_kind,
|
||||
title, description, status,
|
||||
archetype_key, title, description, status,
|
||||
roadmap_item_id, sort_order, target_date
|
||||
)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
RETURNING {_PROJECT_COLUMNS}
|
||||
""",
|
||||
(
|
||||
@@ -268,6 +276,7 @@ def create_project(
|
||||
initiative_id,
|
||||
parent_project_id,
|
||||
container_kind,
|
||||
resolved_archetype,
|
||||
title,
|
||||
description,
|
||||
status,
|
||||
|
||||
@@ -100,6 +100,8 @@ def ensure_steering_context(
|
||||
initiative_id: str,
|
||||
initial_state: Optional[str] = None,
|
||||
user_id: Optional[str] = None,
|
||||
method_key: Optional[str] = None,
|
||||
lifecycle_metadata: Optional[dict[str, Any]] = None,
|
||||
) -> dict[str, Any]:
|
||||
existing = get_steering_context(tenant_id=tenant_id, initiative_id=initiative_id)
|
||||
if existing:
|
||||
@@ -113,6 +115,16 @@ def ensure_steering_context(
|
||||
)
|
||||
validate_lifecycle_state(state)
|
||||
|
||||
resolved_method = method_key or DEFAULT_METHOD_KEY
|
||||
from steering.methods.registry import get_method
|
||||
|
||||
method = get_method(resolved_method)
|
||||
if not method:
|
||||
resolved_method = DEFAULT_METHOD_KEY
|
||||
method = get_method(resolved_method)
|
||||
method_version = method.version if method else DEFAULT_METHOD_VERSION
|
||||
metadata = lifecycle_metadata or {}
|
||||
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor(cursor_factory=RealDictCursor) as cur:
|
||||
@@ -129,10 +141,10 @@ def ensure_steering_context(
|
||||
(
|
||||
tenant_id,
|
||||
initiative_id,
|
||||
DEFAULT_METHOD_KEY,
|
||||
DEFAULT_METHOD_VERSION,
|
||||
resolved_method,
|
||||
method_version,
|
||||
state,
|
||||
Json({}),
|
||||
Json(metadata),
|
||||
),
|
||||
)
|
||||
row = _serialize_row(dict(cur.fetchone()))
|
||||
@@ -144,7 +156,11 @@ def ensure_steering_context(
|
||||
"steering_context.created",
|
||||
user_id=user_id,
|
||||
tenant_id=tenant_id,
|
||||
details={"initiative_id": initiative_id, "lifecycle_state": state},
|
||||
details={
|
||||
"initiative_id": initiative_id,
|
||||
"lifecycle_state": state,
|
||||
"method_key": resolved_method,
|
||||
},
|
||||
)
|
||||
return row
|
||||
|
||||
@@ -250,10 +266,25 @@ def create_context_for_new_initiative(
|
||||
tenant_id: str,
|
||||
initiative_id: str,
|
||||
user_id: Optional[str] = None,
|
||||
archetype_key: str = "initiative.generic",
|
||||
method_profile_key: Optional[str] = None,
|
||||
) -> dict[str, Any]:
|
||||
from entity_archetypes.registry import resolve_default_method_key
|
||||
from method_profiles.registry import resolve_method_for_profile
|
||||
|
||||
method_key = resolve_default_method_key(archetype_key)
|
||||
lifecycle_metadata: dict[str, Any] = {}
|
||||
if method_profile_key:
|
||||
profile_method = resolve_method_for_profile(method_profile_key)
|
||||
if profile_method:
|
||||
method_key = profile_method
|
||||
lifecycle_metadata["method_profile_key"] = method_profile_key
|
||||
|
||||
return ensure_steering_context(
|
||||
tenant_id=tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
initial_state="intake",
|
||||
user_id=user_id,
|
||||
method_key=method_key,
|
||||
lifecycle_metadata=lifecycle_metadata or None,
|
||||
)
|
||||
Reference in new issue
Block a user