架构重构(候选 1-6): - storage/repository.py 按域拆分为包(target/scenario/run/campaign/result) - storage/db.py 按域拆分为包(eval/campaign/file/model_config/intelligent_eval) - intelligent_eval/lifecycle.py 按状态机阶段拆分为包 - services/runs.py 编排逻辑下沉 - Campaigns.tsx 拆分为 campaigns/ 子组件 测试补全(候选 7): 前端(+125 用例,107→232): - utils/ 纯函数:date/campaignTime/ruleLabels/fileTree/fileFormat/colors - stores/tabStore 状态管理 - 核心组件:FormDrawer/PageWrapper/ChatBubble/GeneratedMessages/SectionHeader/StatCard/TurnList - 业务组件:CaseBlock/CaseDetail/RuleOverview/WindowTimeline/RunList/TabBar/CampaignRunTimeline - 文件管理:FileCategoryTree/FileTable - hooks:sessionReducer/useFiles/useRunSession 后端(+38 用例,916→954): - targets API CRUD + 404 路径 - WebSocket 连接管理器 - proxy 头部重写(CSP/X-Frame-Options) - target 仓储 update 方法 - app 健康检查 + SPA 404 - scenarios 模板端点 + 404 - files API 边缘分支(404 场景 + 500 兜底) - files service update_category - 智能评估状态机迁移测试 门禁状态: - 前端:tsc 干净 + 232 passed - 后端:954 passed + ruff 全绿
114 lines
3.3 KiB
Python
114 lines
3.3 KiB
Python
"""Intelligent eval lifecycle (状态机 + 领域操作).
|
||
|
||
状态机:
|
||
draft → planning → pending_approval → executing → completed
|
||
→ cancelled
|
||
→ failed
|
||
pending_approval 可打回 → planning(附反馈)
|
||
executing 可取消 → cancelled
|
||
completed / cancelled / failed 可删除 → deleted(逻辑删除)
|
||
|
||
非法转换抛 IntelligentEvalTransitionError,路由层映射为 409。
|
||
|
||
按阶段分包:
|
||
- ``_core`` — 转换表、领域异常与 CAS 写解析(唯一真相)
|
||
- ``plan_management`` — 创建/计划/审批/取消/删除与读取
|
||
- ``session_execution`` — 虚拟用户会话、轮次与会话过期
|
||
- ``report_submission`` — executing → completed
|
||
- ``watchdog`` — ADR-0011 平台兜底闸门
|
||
|
||
本 ``__init__`` 保持旧的扁平公开面,所有既有 import 不受影响。
|
||
"""
|
||
|
||
from agenteval.channels.factory import ChannelFactory
|
||
from agenteval.intelligent_eval.lifecycle._core import (
|
||
IntelligentEvalChannelError,
|
||
IntelligentEvalNotFoundError,
|
||
IntelligentEvalTransitionError,
|
||
)
|
||
from agenteval.intelligent_eval.lifecycle.plan_management import (
|
||
approve,
|
||
cancel,
|
||
create_eval,
|
||
delete_eval,
|
||
eval_status_counts,
|
||
get_eval,
|
||
list_evals,
|
||
list_evals_page,
|
||
reject,
|
||
submit_plan,
|
||
)
|
||
from agenteval.intelligent_eval.lifecycle.report_submission import submit_report
|
||
from agenteval.intelligent_eval.lifecycle.session_execution import (
|
||
SESSION_IDLE_EXPIRE_MINUTES,
|
||
close_session,
|
||
conduct_turn,
|
||
expire_stale_running_sessions,
|
||
list_messages,
|
||
list_sessions,
|
||
open_session,
|
||
)
|
||
from agenteval.intelligent_eval.lifecycle.watchdog import (
|
||
ANALYST_NUDGE_DELAY_MINUTES,
|
||
ANALYST_NUDGE_MAX,
|
||
EXECUTING_OVERRUN_GRACE_HOURS,
|
||
PLANNING_MAX_ATTEMPTS,
|
||
PLANNING_TIMEOUT_MINUTES,
|
||
TRIGGER_COOLDOWN_MINUTES,
|
||
TRIGGER_FAILURE_MAX,
|
||
enforce_executing_ceiling,
|
||
enforce_planning_gates,
|
||
enforce_trigger_failure_gates,
|
||
eval_ids_with_pending_worker_tasks,
|
||
evals_needing_analyst_nudge,
|
||
fail_eval,
|
||
record_analyst_nudge,
|
||
record_planner_triggers,
|
||
record_trigger_failures,
|
||
record_worker_triggers,
|
||
worker_trigger_candidates,
|
||
)
|
||
|
||
__all__ = [
|
||
"ANALYST_NUDGE_DELAY_MINUTES",
|
||
"ANALYST_NUDGE_MAX",
|
||
"ChannelFactory",
|
||
"EXECUTING_OVERRUN_GRACE_HOURS",
|
||
"PLANNING_MAX_ATTEMPTS",
|
||
"PLANNING_TIMEOUT_MINUTES",
|
||
"SESSION_IDLE_EXPIRE_MINUTES",
|
||
"TRIGGER_COOLDOWN_MINUTES",
|
||
"TRIGGER_FAILURE_MAX",
|
||
"IntelligentEvalChannelError",
|
||
"IntelligentEvalNotFoundError",
|
||
"IntelligentEvalTransitionError",
|
||
"approve",
|
||
"cancel",
|
||
"close_session",
|
||
"conduct_turn",
|
||
"create_eval",
|
||
"delete_eval",
|
||
"enforce_executing_ceiling",
|
||
"enforce_planning_gates",
|
||
"enforce_trigger_failure_gates",
|
||
"eval_ids_with_pending_worker_tasks",
|
||
"eval_status_counts",
|
||
"evals_needing_analyst_nudge",
|
||
"expire_stale_running_sessions",
|
||
"fail_eval",
|
||
"get_eval",
|
||
"list_evals",
|
||
"list_evals_page",
|
||
"list_messages",
|
||
"list_sessions",
|
||
"open_session",
|
||
"record_analyst_nudge",
|
||
"record_planner_triggers",
|
||
"record_trigger_failures",
|
||
"record_worker_triggers",
|
||
"reject",
|
||
"submit_plan",
|
||
"submit_report",
|
||
"worker_trigger_candidates",
|
||
]
|