148 lines
3.0 KiB
Python
148 lines
3.0 KiB
Python
"""AI PMO World Model 类型契约。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, NotRequired, Optional, TypedDict
|
|
|
|
|
|
class ProjectSnapshot(TypedDict):
|
|
id: int
|
|
name: str
|
|
title: str
|
|
description: str
|
|
status: str
|
|
owner_id: Optional[int]
|
|
|
|
|
|
class ProjectDomainSnapshot(TypedDict):
|
|
id: int
|
|
name: str
|
|
slug: str
|
|
description: str
|
|
owner_id: Optional[int]
|
|
|
|
|
|
class PortfolioSummary(TypedDict):
|
|
active_project_count: int
|
|
focus_project_id: Optional[int]
|
|
|
|
|
|
class BudgetSummary(TypedDict):
|
|
budget_id: Optional[int]
|
|
usage_ratio: float
|
|
hard_limit_enabled: bool
|
|
budget_type: NotRequired[str]
|
|
period: NotRequired[str]
|
|
budget_amount_usd: NotRequired[float]
|
|
current_usage_usd: NotRequired[float]
|
|
|
|
|
|
class CapacityItem(TypedDict):
|
|
user_id: int
|
|
current_assigned_hours: float
|
|
max_available_hours_per_week: float
|
|
workload_ratio: float
|
|
|
|
|
|
class SkillGraphItem(TypedDict):
|
|
user_id: int
|
|
skill_tag_id: int
|
|
proficiency_level: str
|
|
quality_score: float
|
|
efficiency_score: float
|
|
|
|
|
|
class CharterItem(TypedDict):
|
|
id: int
|
|
title: str
|
|
status: str
|
|
content: dict[str, Any]
|
|
|
|
|
|
class BlockedTask(TypedDict):
|
|
id: int
|
|
title: str
|
|
|
|
|
|
class TaskSummary(TypedDict):
|
|
total: int
|
|
by_status: dict[str, int]
|
|
overdue_count: int
|
|
uncovered_skill_tag_ids: list[int]
|
|
blocked_tasks: list[BlockedTask]
|
|
required_skill_tag_ids: NotRequired[list[int]]
|
|
|
|
|
|
class RiskSummary(TypedDict):
|
|
open_risk_count: int
|
|
|
|
|
|
class DependencySummary(TypedDict):
|
|
pressure: str
|
|
blocked_tasks: list[BlockedTask]
|
|
overdue_count: int
|
|
charter_ready: bool
|
|
|
|
|
|
class RecentSignalItem(TypedDict):
|
|
id: int
|
|
title: str
|
|
status: str
|
|
signal_type: str
|
|
|
|
|
|
class ActiveProjectSnapshot(TypedDict):
|
|
id: int
|
|
name: str
|
|
title: str
|
|
description: str
|
|
status: str
|
|
owner_id: Optional[int]
|
|
|
|
|
|
class DecisionContextSnapshot(TypedDict):
|
|
captured_at: str
|
|
project_id: Optional[int]
|
|
budget: BudgetSummary
|
|
capacity: list[CapacityItem]
|
|
skill_graph_size: int
|
|
dependency_pressure: Optional[str]
|
|
|
|
|
|
class WorldModel(TypedDict):
|
|
sender: str
|
|
resolved_project_id: Optional[int]
|
|
project: Optional[ProjectSnapshot]
|
|
project_domain: Optional[ProjectDomainSnapshot]
|
|
portfolio: PortfolioSummary
|
|
budget: BudgetSummary
|
|
capacity: list[CapacityItem]
|
|
member_count: int
|
|
skill_graph: list[SkillGraphItem]
|
|
charter: list[CharterItem]
|
|
task_summary: TaskSummary
|
|
risk_summary: RiskSummary
|
|
dependencies: DependencySummary
|
|
recent_signals: list[RecentSignalItem]
|
|
decision_context_snapshot: DecisionContextSnapshot
|
|
active_projects: NotRequired[list[ActiveProjectSnapshot]]
|
|
|
|
|
|
__all__ = [
|
|
"ProjectSnapshot",
|
|
"ProjectDomainSnapshot",
|
|
"PortfolioSummary",
|
|
"BudgetSummary",
|
|
"CapacityItem",
|
|
"SkillGraphItem",
|
|
"CharterItem",
|
|
"BlockedTask",
|
|
"TaskSummary",
|
|
"RiskSummary",
|
|
"DependencySummary",
|
|
"RecentSignalItem",
|
|
"ActiveProjectSnapshot",
|
|
"DecisionContextSnapshot",
|
|
"WorldModel",
|
|
]
|