AP0.8: Operating Model Extension I (Attention, Blocker, Backlog, Milestone)
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 58s
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 12s
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 58s
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 12s
Schema 007, regelbasierte Attention/NextAction im Data Layer, CRUD fuer Blocker/Backlog/Meilensteine, Workspace-Widget und Initiative-Detail-Sektionen. 25 Capabilities. Tests fuer Remote-Pytest auf Pi angepasst (conftest Session-Guard). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6dd9dd4f62
commit
fe3bc4f057
39 files changed
+4333
-22
No files matched your search
@@ -0,0 +1,103 @@
|
||||
"""BacklogItem API — AP0.8c."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal, Optional
|
||||
|
||||
from capabilities import require_capability
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
from services import backlog as backlog_service
|
||||
from tenant_context import TenantContext
|
||||
|
||||
router = APIRouter(prefix="/api/backlog", tags=["backlog"])
|
||||
|
||||
|
||||
class BacklogCreateRequest(BaseModel):
|
||||
title: str = Field(min_length=1, max_length=255)
|
||||
description: str = ""
|
||||
status: Literal["new", "triaged", "accepted", "rejected"] = "new"
|
||||
priority: Literal["low", "normal", "high"] = "normal"
|
||||
|
||||
|
||||
class BacklogUpdateRequest(BaseModel):
|
||||
title: Optional[str] = Field(default=None, min_length=1, max_length=255)
|
||||
description: Optional[str] = None
|
||||
status: Optional[Literal["new", "triaged", "accepted", "rejected"]] = None
|
||||
priority: Optional[Literal["low", "normal", "high"]] = None
|
||||
|
||||
|
||||
class BacklogConvertRequest(BaseModel):
|
||||
assigned_actor_ids: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
@router.get("/{backlog_item_id}")
|
||||
def get_backlog_item(
|
||||
backlog_item_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.backlog.read")),
|
||||
):
|
||||
item = backlog_service.get_backlog_item(
|
||||
tenant_id=ctx.tenant_id, backlog_item_id=backlog_item_id
|
||||
)
|
||||
if not item:
|
||||
raise HTTPException(status_code=404, detail="Backlog-Item nicht gefunden")
|
||||
return item
|
||||
|
||||
|
||||
@router.patch("/{backlog_item_id}")
|
||||
def update_backlog_item(
|
||||
backlog_item_id: str,
|
||||
body: BacklogUpdateRequest,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.backlog.manage")),
|
||||
):
|
||||
try:
|
||||
item = backlog_service.update_backlog_item(
|
||||
tenant_id=ctx.tenant_id,
|
||||
backlog_item_id=backlog_item_id,
|
||||
user_id=ctx.user_id,
|
||||
title=body.title,
|
||||
description=body.description,
|
||||
status=body.status,
|
||||
priority=body.priority,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
if not item:
|
||||
raise HTTPException(status_code=404, detail="Backlog-Item nicht gefunden")
|
||||
return item
|
||||
|
||||
|
||||
@router.delete("/{backlog_item_id}", status_code=204)
|
||||
def delete_backlog_item(
|
||||
backlog_item_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.backlog.manage")),
|
||||
):
|
||||
if not backlog_service.delete_backlog_item(
|
||||
tenant_id=ctx.tenant_id,
|
||||
backlog_item_id=backlog_item_id,
|
||||
user_id=ctx.user_id,
|
||||
):
|
||||
raise HTTPException(status_code=404, detail="Backlog-Item nicht gefunden")
|
||||
|
||||
|
||||
@router.post("/{backlog_item_id}/convert-to-action", status_code=201)
|
||||
def convert_backlog_to_action(
|
||||
backlog_item_id: str,
|
||||
body: BacklogConvertRequest,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.backlog.manage")),
|
||||
):
|
||||
assigned = body.assigned_actor_ids
|
||||
if not assigned and ctx.actor_id:
|
||||
assigned = [ctx.actor_id]
|
||||
try:
|
||||
return backlog_service.convert_backlog_to_action(
|
||||
tenant_id=ctx.tenant_id,
|
||||
backlog_item_id=backlog_item_id,
|
||||
user_id=ctx.user_id,
|
||||
assigned_actor_ids=assigned,
|
||||
)
|
||||
except ValueError as exc:
|
||||
detail = str(exc)
|
||||
if detail == "Backlog-Item nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=detail) from exc
|
||||
raise HTTPException(status_code=400, detail=detail) from exc
|
||||
@@ -0,0 +1,77 @@
|
||||
"""Blocker API — AP0.8b."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal, Optional
|
||||
|
||||
from capabilities import require_capability
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
from services import blockers as blocker_service
|
||||
from tenant_context import TenantContext
|
||||
|
||||
router = APIRouter(prefix="/api/blockers", tags=["blockers"])
|
||||
|
||||
|
||||
class BlockerCreateRequest(BaseModel):
|
||||
title: str = Field(min_length=1, max_length=255)
|
||||
description: str = ""
|
||||
status: Literal["open", "in_progress", "resolved", "accepted_risk", "dismissed"] = "open"
|
||||
action_id: Optional[str] = None
|
||||
set_action_blocked: bool = False
|
||||
|
||||
|
||||
class BlockerUpdateRequest(BaseModel):
|
||||
title: Optional[str] = Field(default=None, min_length=1, max_length=255)
|
||||
description: Optional[str] = None
|
||||
status: Optional[
|
||||
Literal["open", "in_progress", "resolved", "accepted_risk", "dismissed"]
|
||||
] = None
|
||||
action_id: Optional[str] = None
|
||||
clear_action_id: bool = False
|
||||
|
||||
|
||||
@router.get("/{blocker_id}")
|
||||
def get_blocker(
|
||||
blocker_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.blocker.read")),
|
||||
):
|
||||
item = blocker_service.get_blocker(tenant_id=ctx.tenant_id, blocker_id=blocker_id)
|
||||
if not item:
|
||||
raise HTTPException(status_code=404, detail="Blocker nicht gefunden")
|
||||
return item
|
||||
|
||||
|
||||
@router.patch("/{blocker_id}")
|
||||
def update_blocker(
|
||||
blocker_id: str,
|
||||
body: BlockerUpdateRequest,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.blocker.manage")),
|
||||
):
|
||||
try:
|
||||
item = blocker_service.update_blocker(
|
||||
tenant_id=ctx.tenant_id,
|
||||
blocker_id=blocker_id,
|
||||
user_id=ctx.user_id,
|
||||
title=body.title,
|
||||
description=body.description,
|
||||
status=body.status,
|
||||
action_id=body.action_id,
|
||||
clear_action_id=body.clear_action_id,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
if not item:
|
||||
raise HTTPException(status_code=404, detail="Blocker nicht gefunden")
|
||||
return item
|
||||
|
||||
|
||||
@router.delete("/{blocker_id}", status_code=204)
|
||||
def delete_blocker(
|
||||
blocker_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.blocker.manage")),
|
||||
):
|
||||
if not blocker_service.delete_blocker(
|
||||
tenant_id=ctx.tenant_id, blocker_id=blocker_id, user_id=ctx.user_id
|
||||
):
|
||||
raise HTTPException(status_code=404, detail="Blocker nicht gefunden")
|
||||
@@ -8,7 +8,10 @@ from capabilities import require_capability
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
from services import actions as action_service
|
||||
from services import backlog as backlog_service
|
||||
from services import blockers as blocker_service
|
||||
from services import initiatives as initiative_service
|
||||
from services import milestones as milestone_service
|
||||
from tenant_context import TenantContext
|
||||
|
||||
router = APIRouter(prefix="/api/initiatives", tags=["initiatives"])
|
||||
@@ -38,6 +41,28 @@ class ActionCreateRequest(BaseModel):
|
||||
assigned_actor_ids: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class BlockerCreateRequest(BaseModel):
|
||||
title: str = Field(min_length=1, max_length=255)
|
||||
description: str = ""
|
||||
status: Literal["open", "in_progress", "resolved", "accepted_risk", "dismissed"] = "open"
|
||||
action_id: Optional[str] = None
|
||||
set_action_blocked: bool = False
|
||||
|
||||
|
||||
class BacklogCreateRequest(BaseModel):
|
||||
title: str = Field(min_length=1, max_length=255)
|
||||
description: str = ""
|
||||
status: Literal["new", "triaged", "accepted", "rejected"] = "new"
|
||||
priority: Literal["low", "normal", "high"] = "normal"
|
||||
|
||||
|
||||
class MilestoneCreateRequest(BaseModel):
|
||||
title: str = Field(min_length=1, max_length=255)
|
||||
goal_description: str = ""
|
||||
status: Literal["planned", "active", "at_risk", "reached", "moved", "discarded"] = "planned"
|
||||
target_date: Optional[str] = None
|
||||
|
||||
|
||||
@router.get("")
|
||||
def list_initiatives(
|
||||
ctx: TenantContext = Depends(require_capability("kairo.initiative.read")),
|
||||
@@ -153,3 +178,127 @@ def create_initiative_action(
|
||||
if detail == "Initiative nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=detail) from exc
|
||||
raise HTTPException(status_code=400, detail=detail) from exc
|
||||
|
||||
|
||||
@router.get("/{initiative_id}/blockers")
|
||||
def list_initiative_blockers(
|
||||
initiative_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.blocker.read")),
|
||||
):
|
||||
try:
|
||||
return blocker_service.list_blockers_for_initiative(
|
||||
tenant_id=ctx.tenant_id, initiative_id=initiative_id
|
||||
)
|
||||
except ValueError as exc:
|
||||
if str(exc) == "Initiative nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@router.post("/{initiative_id}/blockers", status_code=201)
|
||||
def create_initiative_blocker(
|
||||
initiative_id: str,
|
||||
body: BlockerCreateRequest,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.blocker.manage")),
|
||||
):
|
||||
try:
|
||||
return blocker_service.create_blocker(
|
||||
tenant_id=ctx.tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title=body.title,
|
||||
description=body.description,
|
||||
status=body.status,
|
||||
action_id=body.action_id,
|
||||
reported_by_actor_id=ctx.actor_id,
|
||||
user_id=ctx.user_id,
|
||||
set_action_blocked=body.set_action_blocked,
|
||||
)
|
||||
except ValueError as exc:
|
||||
detail = str(exc)
|
||||
if detail == "Initiative nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=detail) from exc
|
||||
raise HTTPException(status_code=400, detail=detail) from exc
|
||||
|
||||
|
||||
@router.get("/{initiative_id}/backlog")
|
||||
def list_initiative_backlog(
|
||||
initiative_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.backlog.read")),
|
||||
):
|
||||
try:
|
||||
return backlog_service.list_backlog_for_initiative(
|
||||
tenant_id=ctx.tenant_id, initiative_id=initiative_id
|
||||
)
|
||||
except ValueError as exc:
|
||||
if str(exc) == "Initiative nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@router.post("/{initiative_id}/backlog", status_code=201)
|
||||
def create_initiative_backlog_item(
|
||||
initiative_id: str,
|
||||
body: BacklogCreateRequest,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.backlog.manage")),
|
||||
):
|
||||
try:
|
||||
return backlog_service.create_backlog_item(
|
||||
tenant_id=ctx.tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title=body.title,
|
||||
description=body.description,
|
||||
status=body.status,
|
||||
priority=body.priority,
|
||||
user_id=ctx.user_id,
|
||||
)
|
||||
except ValueError as exc:
|
||||
detail = str(exc)
|
||||
if detail == "Initiative nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=detail) from exc
|
||||
raise HTTPException(status_code=400, detail=detail) from exc
|
||||
|
||||
|
||||
@router.get("/{initiative_id}/milestones")
|
||||
def list_initiative_milestones(
|
||||
initiative_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.milestone.read")),
|
||||
):
|
||||
try:
|
||||
return milestone_service.list_milestones_for_initiative(
|
||||
tenant_id=ctx.tenant_id, initiative_id=initiative_id
|
||||
)
|
||||
except ValueError as exc:
|
||||
if str(exc) == "Initiative nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@router.post("/{initiative_id}/milestones", status_code=201)
|
||||
def create_initiative_milestone(
|
||||
initiative_id: str,
|
||||
body: MilestoneCreateRequest,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.milestone.manage")),
|
||||
):
|
||||
from datetime import date as date_type
|
||||
|
||||
target_date = None
|
||||
if body.target_date:
|
||||
try:
|
||||
target_date = date_type.fromisoformat(body.target_date)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail="Ungültiges target_date") from exc
|
||||
try:
|
||||
return milestone_service.create_milestone(
|
||||
tenant_id=ctx.tenant_id,
|
||||
initiative_id=initiative_id,
|
||||
title=body.title,
|
||||
goal_description=body.goal_description,
|
||||
status=body.status,
|
||||
target_date=target_date,
|
||||
user_id=ctx.user_id,
|
||||
)
|
||||
except ValueError as exc:
|
||||
detail = str(exc)
|
||||
if detail == "Initiative nicht gefunden":
|
||||
raise HTTPException(status_code=404, detail=detail) from exc
|
||||
raise HTTPException(status_code=400, detail=detail) from exc
|
||||
@@ -0,0 +1,77 @@
|
||||
"""Milestone API — AP0.8d."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
from typing import Literal, Optional
|
||||
|
||||
from capabilities import require_capability
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
from services import milestones as milestone_service
|
||||
from tenant_context import TenantContext
|
||||
|
||||
router = APIRouter(prefix="/api/milestones", tags=["milestones"])
|
||||
|
||||
|
||||
class MilestoneCreateRequest(BaseModel):
|
||||
title: str = Field(min_length=1, max_length=255)
|
||||
goal_description: str = ""
|
||||
status: Literal["planned", "active", "at_risk", "reached", "moved", "discarded"] = "planned"
|
||||
target_date: Optional[date] = None
|
||||
|
||||
|
||||
class MilestoneUpdateRequest(BaseModel):
|
||||
title: Optional[str] = Field(default=None, min_length=1, max_length=255)
|
||||
goal_description: Optional[str] = None
|
||||
status: Optional[
|
||||
Literal["planned", "active", "at_risk", "reached", "moved", "discarded"]
|
||||
] = None
|
||||
target_date: Optional[date] = None
|
||||
clear_target_date: bool = False
|
||||
|
||||
|
||||
@router.get("/{milestone_id}")
|
||||
def get_milestone(
|
||||
milestone_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.milestone.read")),
|
||||
):
|
||||
item = milestone_service.get_milestone(tenant_id=ctx.tenant_id, milestone_id=milestone_id)
|
||||
if not item:
|
||||
raise HTTPException(status_code=404, detail="Meilenstein nicht gefunden")
|
||||
return item
|
||||
|
||||
|
||||
@router.patch("/{milestone_id}")
|
||||
def update_milestone(
|
||||
milestone_id: str,
|
||||
body: MilestoneUpdateRequest,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.milestone.manage")),
|
||||
):
|
||||
try:
|
||||
item = milestone_service.update_milestone(
|
||||
tenant_id=ctx.tenant_id,
|
||||
milestone_id=milestone_id,
|
||||
user_id=ctx.user_id,
|
||||
title=body.title,
|
||||
goal_description=body.goal_description,
|
||||
status=body.status,
|
||||
target_date=body.target_date,
|
||||
clear_target_date=body.clear_target_date,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
if not item:
|
||||
raise HTTPException(status_code=404, detail="Meilenstein nicht gefunden")
|
||||
return item
|
||||
|
||||
|
||||
@router.delete("/{milestone_id}", status_code=204)
|
||||
def delete_milestone(
|
||||
milestone_id: str,
|
||||
ctx: TenantContext = Depends(require_capability("kairo.milestone.manage")),
|
||||
):
|
||||
if not milestone_service.delete_milestone(
|
||||
tenant_id=ctx.tenant_id, milestone_id=milestone_id, user_id=ctx.user_id
|
||||
):
|
||||
raise HTTPException(status_code=404, detail="Meilenstein nicht gefunden")
|
||||
@@ -7,6 +7,7 @@ from typing import Optional
|
||||
from capabilities import require_capability
|
||||
from data_layer import actions as dl_actions
|
||||
from data_layer import actors as dl_actors
|
||||
from data_layer import attention as dl_attention
|
||||
from data_layer import initiatives as dl_initiatives
|
||||
from data_layer import workspace as dl_workspace
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
@@ -61,3 +62,18 @@ def workspace_actor_workload(
|
||||
ctx: TenantContext = Depends(require_capability("kairo.workspace.read")),
|
||||
):
|
||||
return dl_actors.get_actor_workload(ctx)
|
||||
|
||||
|
||||
@router.get("/attention")
|
||||
def workspace_attention(
|
||||
ctx: TenantContext = Depends(require_capability("kairo.attention.read")),
|
||||
):
|
||||
return dl_attention.get_attention_items(ctx)
|
||||
|
||||
|
||||
@router.get("/next-actions")
|
||||
def workspace_next_actions(
|
||||
limit: Optional[int] = Query(default=10, ge=1, le=50),
|
||||
ctx: TenantContext = Depends(require_capability("kairo.attention.read")),
|
||||
):
|
||||
return dl_attention.get_next_action_candidates(ctx, limit=limit or 10)
|
||||
Reference in new issue
Block a user