aps-agent/docs/architecture/overview.md

67 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 架构总览(落地态)
---
## 1. 仓库分层
```
apps/web/ 表现层 React:对话 / 视口 / 项目壳 / 治理台
server/gateway/ HTTP + SSE 接入
server/agent_core/ 意图、门禁、审计、Provider、模块扫描
server/aps_domain/ 工作流编排、视图投影、沙盒、报告
server/engines/ 排产引擎(RULE / CP-SAT / HYBRID / GA)
server/knowledge/ 资产 / 检索 / 偏好
server/state/ 世界状态 + 检查点 + 种子
shared/schemas/ 跨语言 JSON Schema 契约
tests/golden/ 黄金回归
```
跨层 UI 块、视口命令和意图载荷统一携带 `interfaceVersion=1.0`。JSON Schema
是枚举与版本的基准,Python Pydantic 与 TypeScript 为运行时镜像;
`tests/golden/test_contract_sync.py` 在发版测试中阻断意图枚举或版本漂移。
公共 `/api/health` 返回同一接口版本;Web `InterfaceGate` 在认证和业务界面挂载前
执行严格相等校验,不兼容或健康检查失败时显式阻断。
---
## 2. 请求主链路
```mermaid
flowchart TB
UI[Web Shell] --> GW[Gateway]
GW --> INT[Intent 两级管线]
INT --> WF[Workflow]
WF --> H[Harness 权力判定]
H -->|P0/P1| EXE[执行器]
H -->|P2| CARD[确认卡暂存]
CARD -->|用户批准| EXE
EXE --> ENG[Engines / Knowledge / State]
EXE --> AUD[Audit 哈希链]
ENG --> VIEW[Views 投影]
VIEW --> UI
```
---
## 3. 关键不变量
1. **写主干必过 Harness**;P2 唯一确认通道。
2. **Explore 沙盒**不得写主干(`scenario.compare`)。
3. **报告数字**只允许来自冻结快照字段。
4. **可重生模块**带 `moduleId` 头声明,重生中心可扫描。
5. **文档与代码同轮**:见 [../README.md](../README.md) 铁律。
---
## 4. 技术选型(已锁定)
| 项 | 选择 |
| --- | --- |
| 后端 | Python FastAPI |
| 前端 | React 18 + Vite + TS |
| 求解 | RULE + CP-SAT + **HYBRID(RULE→CP)** + 固定种子 GA |
| LLM | DeepSeek / KIMI(OpenAI 兼容),可降级 |
| 桌面 | Electron(当前实现,`apps/desktop`;Tauri 目标态待产品/架构决策) |
细节与里程碑叙事见 `plan.md`;接口清单见 [harness.md](./harness.md)。