70 lines
2.1 KiB
Python
70 lines
2.1 KiB
Python
"""Stable, serialisable contracts for project-scoped business runs."""
|
|
|
|
from typing import Any, Literal
|
|
|
|
from pydantic import BaseModel, Field, ConfigDict
|
|
|
|
|
|
class Evidence(BaseModel):
|
|
model_config = ConfigDict(extra="allow")
|
|
id: str
|
|
project_id: str
|
|
source: str
|
|
locator: str
|
|
field: str
|
|
value: Any = None
|
|
snapshot_id: str
|
|
|
|
|
|
class CheckOutcome(BaseModel):
|
|
model_config = ConfigDict(extra="allow")
|
|
code: str = Field(min_length=1, max_length=250)
|
|
title: str
|
|
result: Literal["pass", "issue", "unknown", "not_applicable", "error"]
|
|
severity: Literal["info", "attention", "warning"] = "attention"
|
|
fields: list[str] = Field(default_factory=list)
|
|
evidence_ids: list[str] = Field(default_factory=list)
|
|
basis_ids: list[str] = Field(default_factory=list)
|
|
suggested_action: str = ""
|
|
|
|
|
|
class Finding(BaseModel):
|
|
id: str
|
|
code: str
|
|
project_id: str
|
|
title: str
|
|
result: Literal["pass", "issue", "unknown", "not_applicable", "error"]
|
|
severity: Literal["info", "attention", "warning"] = "attention"
|
|
status: Literal["待处理", "待补件", "待复核", "已解决", "不适用"] = "待处理"
|
|
evidence_ids: list[str] = Field(default_factory=list)
|
|
basis_ids: list[str] = Field(default_factory=list)
|
|
suggested_action: str = ""
|
|
first_seen_run_id: str
|
|
last_seen_run_id: str
|
|
|
|
|
|
class ProjectSnapshot(BaseModel):
|
|
model_config = ConfigDict(extra="allow")
|
|
schema_version: int = 1
|
|
id: str
|
|
project_id: str
|
|
data_domain: Literal["demo", "production"]
|
|
revision: int
|
|
created_at: str
|
|
facts: dict[str, Any]
|
|
documents: list[dict[str, Any]] = Field(default_factory=list)
|
|
|
|
|
|
class SkillResult(BaseModel):
|
|
model_config = ConfigDict(extra="allow")
|
|
schema_version: int = 1
|
|
run_id: str
|
|
step_id: str
|
|
skill: dict[str, str]
|
|
status: Literal["completed", "partial", "failed", "skipped"]
|
|
input_snapshot_id: str
|
|
outputs: dict[str, Any] = Field(default_factory=dict)
|
|
findings: list[CheckOutcome] = Field(default_factory=list)
|
|
missing_inputs: list[str] = Field(default_factory=list)
|
|
errors: list[dict[str, Any]] = Field(default_factory=list)
|