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
@@ -1,13 +1,21 @@
|
||||
from entity_archetypes.registry import (
|
||||
ENTITY_ARCHETYPES,
|
||||
INITIATIVE_ARCHETYPES,
|
||||
PROJECT_ARCHETYPES,
|
||||
archetype_label,
|
||||
list_archetypes,
|
||||
mirror_project_archetype_key,
|
||||
resolve_default_method_key,
|
||||
validate_archetype_key,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ENTITY_ARCHETYPES",
|
||||
"INITIATIVE_ARCHETYPES",
|
||||
"PROJECT_ARCHETYPES",
|
||||
"archetype_label",
|
||||
"list_archetypes",
|
||||
"mirror_project_archetype_key",
|
||||
"resolve_default_method_key",
|
||||
"validate_archetype_key",
|
||||
]
|
||||
@@ -1,4 +1,4 @@
|
||||
"""System-Archetypen (AP1.10a/10b) — In-Memory-Seed + DB-Registry."""
|
||||
"""System-Archetypen (AP1.10 + AP2.0) — Seeds, Bindings, Spiegel Project."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -8,39 +8,136 @@ from psycopg2.extras import RealDictCursor
|
||||
|
||||
from db import get_connection
|
||||
|
||||
INITIATIVE_ARCHETYPES: tuple[dict[str, Any], ...] = (
|
||||
{
|
||||
"key": "initiative.generic",
|
||||
"entity_type": "initiative",
|
||||
"label": "Allgemeines Vorhaben",
|
||||
"description": "Standard-Vorhaben ohne spezielle Vorlage.",
|
||||
"is_system": True,
|
||||
},
|
||||
{
|
||||
"key": "initiative.program",
|
||||
"entity_type": "initiative",
|
||||
"label": "Programm / Mega-Vorhaben",
|
||||
"description": "Mehrere Stränge, Zielzustand und Vision zentral.",
|
||||
"is_system": True,
|
||||
},
|
||||
{
|
||||
"key": "initiative.product",
|
||||
"entity_type": "initiative",
|
||||
"label": "Produkt / Release",
|
||||
"description": "Produkt- oder Release-orientiertes Vorhaben.",
|
||||
"is_system": True,
|
||||
},
|
||||
# initiative suffix → default method (shared by initiative + project mirror)
|
||||
_METHOD_BY_SUFFIX: dict[str, str] = {
|
||||
"generic": "generic_operating",
|
||||
"maturity_journey": "maturity_progression",
|
||||
"linear_project": "sequential_dependency",
|
||||
"recurring_program": "recurring_control",
|
||||
"support_queue": "queue_pull",
|
||||
"program": "program_delivery",
|
||||
"product": "continuous_product",
|
||||
"dispute_case": "dispute_procedure",
|
||||
"content_project": "chapter_based_progression",
|
||||
}
|
||||
|
||||
_INITIATIVE_SPEC_META: tuple[tuple[str, str, str], ...] = (
|
||||
("generic", "Allgemeines Vorhaben", "Fallback ohne spezielle Steuerungsvorlage."),
|
||||
(
|
||||
"maturity_journey",
|
||||
"Reifegrad-Entwicklung",
|
||||
"Mehrstufige Entwicklung, Routinen, Graph-Voraussetzungen.",
|
||||
),
|
||||
(
|
||||
"linear_project",
|
||||
"Lineares Vorhaben",
|
||||
"Einmalprojekte mit Pfaden, Gates und Graph.",
|
||||
),
|
||||
(
|
||||
"recurring_program",
|
||||
"Dauerprogramm / Rhythmus",
|
||||
"Haushalt, Rhythmen, Abweichungs-Steuerung.",
|
||||
),
|
||||
(
|
||||
"support_queue",
|
||||
"Inbox / Queue",
|
||||
"Ad-hoc-Eingang, triage, thematische Zuordnung.",
|
||||
),
|
||||
(
|
||||
"program",
|
||||
"Programm (begrenzt)",
|
||||
"Phasen, Release-Programm mit Abschluss.",
|
||||
),
|
||||
(
|
||||
"product",
|
||||
"Produkt (kontinuierlich)",
|
||||
"Dauerbetrieb, Wartung, Issues, Weiterentwicklung.",
|
||||
),
|
||||
(
|
||||
"dispute_case",
|
||||
"Verfahren / Konflikt",
|
||||
"Reaktive Steuerung, Fristen, Entscheidungen.",
|
||||
),
|
||||
(
|
||||
"content_project",
|
||||
"Inhalt / Kapitel",
|
||||
"Bücher, Konzepte, Kapitelstruktur.",
|
||||
),
|
||||
)
|
||||
|
||||
_ARCHETYPE_INDEX = {
|
||||
(item["entity_type"], item["key"]): item for item in INITIATIVE_ARCHETYPES
|
||||
|
||||
def _build_specs() -> tuple[dict[str, Any], ...]:
|
||||
specs: list[dict[str, Any]] = []
|
||||
for suffix, label, description in _INITIATIVE_SPEC_META:
|
||||
method = _METHOD_BY_SUFFIX[suffix]
|
||||
specs.append(
|
||||
{
|
||||
"key": f"initiative.{suffix}",
|
||||
"entity_type": "initiative",
|
||||
"label": label,
|
||||
"description": description,
|
||||
"is_system": True,
|
||||
"default_method_key": method,
|
||||
"default_method_profile_key": None,
|
||||
}
|
||||
)
|
||||
specs.append(
|
||||
{
|
||||
"key": f"project.{suffix}",
|
||||
"entity_type": "project",
|
||||
"label": label,
|
||||
"description": f"Project-Spiegel: {description}",
|
||||
"is_system": True,
|
||||
"default_method_key": method,
|
||||
"default_method_profile_key": None,
|
||||
}
|
||||
)
|
||||
return tuple(specs)
|
||||
|
||||
|
||||
ENTITY_ARCHETYPES: tuple[dict[str, Any], ...] = _build_specs()
|
||||
|
||||
INITIATIVE_ARCHETYPES: tuple[dict[str, Any], ...] = tuple(
|
||||
item for item in ENTITY_ARCHETYPES if item["entity_type"] == "initiative"
|
||||
)
|
||||
|
||||
PROJECT_ARCHETYPES: tuple[dict[str, Any], ...] = tuple(
|
||||
item for item in ENTITY_ARCHETYPES if item["entity_type"] == "project"
|
||||
)
|
||||
|
||||
_ARCHETYPE_INDEX: dict[tuple[str, str], dict[str, Any]] = {
|
||||
(item["entity_type"], item["key"]): item for item in ENTITY_ARCHETYPES
|
||||
}
|
||||
|
||||
_KEY_INDEX: dict[str, dict[str, Any]] = {item["key"]: item for item in ENTITY_ARCHETYPES}
|
||||
|
||||
|
||||
def _list_archetypes_from_memory(*, entity_type: Optional[str] = None) -> list[dict[str, Any]]:
|
||||
if entity_type is None:
|
||||
return [dict(item) for item in INITIATIVE_ARCHETYPES]
|
||||
return [dict(item) for item in INITIATIVE_ARCHETYPES if item["entity_type"] == entity_type]
|
||||
items = ENTITY_ARCHETYPES
|
||||
if entity_type is not None:
|
||||
items = tuple(i for i in items if i["entity_type"] == entity_type)
|
||||
return [_public_archetype(item) for item in items]
|
||||
|
||||
|
||||
def _public_archetype(item: dict[str, Any]) -> dict[str, Any]:
|
||||
return {
|
||||
"key": item["key"],
|
||||
"entity_type": item["entity_type"],
|
||||
"label": item["label"],
|
||||
"description": item["description"],
|
||||
"is_system": item["is_system"],
|
||||
"default_method_key": item["default_method_key"],
|
||||
"default_method_profile_key": item.get("default_method_profile_key"),
|
||||
}
|
||||
|
||||
|
||||
def _enrich_row(row: dict[str, Any]) -> dict[str, Any]:
|
||||
base = dict(row)
|
||||
spec = _KEY_INDEX.get(base.get("key", ""))
|
||||
if spec:
|
||||
base.setdefault("default_method_key", spec["default_method_key"])
|
||||
base.setdefault("default_method_profile_key", spec.get("default_method_profile_key"))
|
||||
return base
|
||||
|
||||
|
||||
def list_archetypes(*, entity_type: Optional[str] = None) -> list[dict[str, Any]]:
|
||||
@@ -67,7 +164,7 @@ def list_archetypes(*, entity_type: Optional[str] = None) -> list[dict[str, Any]
|
||||
)
|
||||
rows = cur.fetchall()
|
||||
if rows:
|
||||
return [dict(row) for row in rows]
|
||||
return [_enrich_row(dict(row)) for row in rows]
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
@@ -83,3 +180,19 @@ def validate_archetype_key(*, entity_type: str, archetype_key: str) -> None:
|
||||
def archetype_label(*, entity_type: str, archetype_key: str) -> Optional[str]:
|
||||
item = _ARCHETYPE_INDEX.get((entity_type, archetype_key))
|
||||
return item["label"] if item else None
|
||||
|
||||
|
||||
def resolve_default_method_key(archetype_key: str) -> str:
|
||||
spec = _KEY_INDEX.get(archetype_key)
|
||||
if not spec:
|
||||
return "generic_operating"
|
||||
return spec.get("default_method_key", "generic_operating")
|
||||
|
||||
|
||||
def mirror_project_archetype_key(initiative_archetype_key: str) -> str:
|
||||
if initiative_archetype_key.startswith("initiative."):
|
||||
suffix = initiative_archetype_key[len("initiative.") :]
|
||||
candidate = f"project.{suffix}"
|
||||
if ( "project", candidate) in _ARCHETYPE_INDEX:
|
||||
return candidate
|
||||
return "project.generic"
|
||||
Reference in new issue
Block a user