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 - demo software-a
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-a demopermission - create
software-a demodeploy 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
Demo failure semantics currently include:
- if
app_codeorversioncontainsfail,software-a demoreturns 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 demo APIs
- edge heartbeat / pull / report
- edge event report
- task report trace aggregation
- cancel running task
Current baseline: 14 passed
Next Focus
Recommended next implementation steps:
- compute and persist
duration_ms - refine richer result summaries and audit details
- add more idempotency and rollback tests
- then continue with local edge-agent bootstrap and second-batch OpenAPI