Some checks failed
CI / test (push) Failing after 33s
架构保养候选 3:探索生命周期的账本规则与状态机从 HTTP 层落入 exploration/lifecycle.py(open/conduct/close)与 patrol.py(巡检读模型), 违规改用类型化领域异常(NotFound/Guardrail/Channel),router 瘦回纯 HTTP 翻译(404/409/502 映射),领域层不再依赖 fastapi,可脱离 TestClient 直测(新增 12 个单元测试)。
27 lines
785 B
Python
27 lines
785 B
Python
"""Domain errors for exploratory evaluation (不依赖 fastapi).
|
||
|
||
领域违规用类型化异常表达,router 统一映射 HTTP 状态码:
|
||
NotFound → 404,Guardrail → 409(reason 即给常驻代理的反馈),
|
||
Channel → 502。
|
||
"""
|
||
|
||
|
||
class ExplorationNotFoundError(Exception):
|
||
"""探索域实体(活动 / 评测对象 / 会话)不存在。"""
|
||
|
||
|
||
class ExplorationGuardrailError(Exception):
|
||
"""平台账本规则违规(状态机 / 预算),拒绝本身即反馈。"""
|
||
|
||
def __init__(self, reason: str):
|
||
self.reason = reason
|
||
super().__init__(reason)
|
||
|
||
|
||
class ExplorationChannelError(Exception):
|
||
"""评测对象通道收发失败。"""
|
||
|
||
def __init__(self, reason: str):
|
||
self.reason = reason
|
||
super().__init__(reason)
|