- 新增 task_report 任务级聚合指标 task_metrics - 补充创建任务幂等与失败路径/冲突测试 - 将后端测试基线提升到 20 passed - 新增 edge-agent 初始化代码、启动脚本与打包脚本 - 新增 http_health_check、check_port、check_process、grep_log 执行器 - 补充 edge-agent 基础测试并提升基线到 10 passed - 同步更新 backend README 与当前进度总结
3.8 KiB
3.8 KiB
Smart Deploy Agent Demo Backend
Setup
python -m venv .venv
.venv\\Scripts\\python -m pip install -e backend
Run
.venv\\Scripts\\python -m uvicorn app.main:app --reload --app-dir backend
Test
The lightweight API verification can run with in-memory SQLite:
set PYTHONPATH=backend
set DATABASE_URL=sqlite:///:memory:
.venv\\Scripts\\python -m pytest backend/tests -q -p no:cacheprovider
Runtime Notes
This repo currently defaults to:
- database:
sqlite:///./data/agent_demo.db - demo cache / queue: no Redis dependency
- edge defaults:
edge_id=edge-shanghai-001tool_name=http_health_check - demo operator defaults:
alice(u1001)for task executionbob(u2001)for approval
In the current sandbox, file-based SQLite may fail with disk I/O error.
For tests and local verification here, use:
set DATABASE_URL=sqlite:///:memory:
Implemented API Scope
Current backend includes:
- agent task
POST /api/agent/tasksPOST /api/agent/tasks/{task_id}/confirmPOST /api/agent/tasks/{task_id}/cancelGET /api/agent/tasks/{task_id}GET /api/agent/tasks/{task_id}/report - demo identity
POST /api/demo/identity/loginGET /api/demo/identity/meGET /api/demo/identity/users/{user_id}/permissionsPOST /api/demo/identity/token/introspect - demo approval
POST /api/demo/approval/requestsGET /api/demo/approval/requests/{approval_id}POST /api/demo/approval/requests/{approval_id}/decisionGET /api/demo/approval/requests - software-a minimal implementation
POST /api/demo/software-a/deploy-tasksGET /api/demo/software-a/deploy-tasks/{software_a_task_id}POST /api/demo/software-a/permissions/check - edge
POST /api/agent/edge/heartbeatPOST /api/agent/edge/tasks/pullPOST /api/agent/edge/tasks/reportPOST /api/agent/edge/events
Current execution flow:
- create task
- confirm task
- high-risk task enters approval flow
- check
software-aminimal implementation permission - create
software-aminimal implementation deploy task - create default edge verification step
- edge pulls and reports verification result
- task reaches
SUCCEEDED/FAILED/CANCELLED - task detail/report returns software-a status, approval trace, tool trace, verification trace and audit trace
Current execution metrics:
tool_call.duration_msis persisted fromstarted_at/finished_atverification_trace.duration_msis persisted for edge task reportstask_report.task_metricsreturns task-level aggregate durations and counts- current aggregate metrics include:
total_duration_msconfirm_wait_duration_msapproval_duration_msexecution_duration_mstool_call_duration_ms_totalverification_duration_ms_total
Current result summary capabilities:
- task detail/report returns
result_summary_detail - summary includes final status, final reason, software-a result, approval result and verification result
Demo failure semantics currently include:
- if
app_codeorversioncontainsfail, thesoftware-aminimal implementation returns a failed deploy task - approval rejection moves task to
CANCELLED - failed edge report moves task to
FAILED
Current Verification Baseline
Automated tests currently cover:
- create / confirm / get task
- high-risk approval path
- identity and software-a minimal implementation APIs
- edge heartbeat / pull / report
- edge event report
- task report trace aggregation
- cancel running task
Current baseline: 20 passed
Next Focus
Recommended next implementation steps:
- continue enriching audit details and task-level metric breakdown
- continue implementing local edge-agent executors beyond
http_health_check - add packaging/bootstrap scripts for portable edge-agent delivery
- then continue with second-batch OpenAPI