docs: update for executor loop, task events, pending-tasks projection
Reflect recent changes across all docs: - README: add executor loop (fire-and-forget), task events lifecycle, pending-tasks projection, update architecture diagram, add pulse-hermes package, add RFC #58 reference - CONTRIBUTING: add task-events.ts, defs.ts, projection-engine.ts, pending-tasks-projection.ts to code structure, update architecture diagram to three-layer decoupled model, add design principles 6-7, add ui/ directory, add migrate.ts, add RFC #58 reference - DESIGN: update packages table with all current packages
This commit is contained in:
@@ -23,12 +23,13 @@ Rule = (prev, curr, inner) => Promise<[Effect[], tickMs]>
|
||||
## 架构
|
||||
|
||||
```
|
||||
Percept 层(vitals.db) Understand + Execute 层(events.db)
|
||||
Watchers → 写 vitals → 唤醒判定 rebuildSnapshot → Rule Chain → Executors
|
||||
└── wakeTick() ──────────────→ 提前唤醒 tick
|
||||
Percept 层(vitals.db) Understand 层(events.db) Execute 层
|
||||
Watchers → 写 vitals → 唤醒判定 rebuildSnapshot → Rule Chain executorLoop
|
||||
└── wakeTick() ──────────────→ 提前唤醒 → write effect events ───→ scan & execute
|
||||
→ effect-acked/failed
|
||||
```
|
||||
|
||||
**双层驱动**:Watchers 每 5s 感知写 vitals,关键事件提前唤醒 tick。Tick 层重建 snapshot,Rules 认知产生 effects,Executors 执行。
|
||||
**三层解耦**:Watchers 每 5s 感知写 vitals,关键事件提前唤醒 tick。Tick 层重建 snapshot,Rules 认知产生 effects 写入 events.db。独立的 executorLoop 后台扫描 effect events 并异步执行(fire-and-forget)。
|
||||
|
||||
**洋葱 Rule 模型**:每个 Rule 接收 `inner`(剩余 rule chain),可以放行、bypass(跳过内层)、修饰结果、变换 snapshot。保命 rules 硬编码在最外层,agent 的业务 rules 在内层。
|
||||
|
||||
@@ -46,10 +47,11 @@ Percept 层(vitals.db) Understand + Execute 层(events.db)
|
||||
|
||||
| 包 | 说明 | npm |
|
||||
|---|---|---|
|
||||
| `@uncaged/pulse` | 核心引擎 + 保命层 + watchers | [](https://www.npmjs.com/package/@uncaged/pulse) |
|
||||
| `@uncaged/pulse` | 核心引擎 + 保命层 + watchers + task projections + executor loop | [](https://www.npmjs.com/package/@uncaged/pulse) |
|
||||
| `@uncaged/pulse-openclaw` | OpenClaw 适配器(Gateway/LLM watchers + rules + executors) | [](https://www.npmjs.com/package/@uncaged/pulse-openclaw) |
|
||||
| `@uncaged/pulse-cursor` | Cursor Agent CLI executor 适配器 | [](https://www.npmjs.com/package/@uncaged/pulse-cursor) |
|
||||
| `@uncaged/upulse` | CLI:daemon 管理、staging/promote/rollback | [](https://www.npmjs.com/package/@uncaged/upulse) |
|
||||
| `@uncaged/pulse-hermes` | Hermes Agent 适配器 | [](https://www.npmjs.com/package/@uncaged/pulse-hermes) |
|
||||
| `@uncaged/upulse` | CLI:daemon 管理、staging/promote/rollback、WebUI | [](https://www.npmjs.com/package/@uncaged/upulse) |
|
||||
|
||||
## 快速开始
|
||||
|
||||
@@ -115,11 +117,44 @@ interface WatcherDef {
|
||||
|
||||
Watcher 持续采集写 vitals,唤醒判定看最近 1 分钟窗口(~12 条),关键事件 `wakeTick()` 提前唤醒 tick。
|
||||
|
||||
### 异步 Executor Loop
|
||||
|
||||
tick 循环与 effect 执行彻底解耦。tick 产生 effects 写入 events.db,独立的 `executorLoop` 后台扫描 pending effect events 并异步执行:
|
||||
|
||||
```
|
||||
Tick Loop (sense·think) Executor Loop (act)
|
||||
rebuildSnapshot → Rules scan effect events
|
||||
→ write effect events ─────→ → effect-executing
|
||||
→ sleep(tickMs) → execute(effect)
|
||||
→ effect-acked / effect-failed
|
||||
```
|
||||
|
||||
- **Fire-and-forget**:tick 不等待 effect 执行完成
|
||||
- **去重**:inflight set + effect-acked/effect-failed 事件防止重复执行
|
||||
- **可配置**:`executorScanIntervalMs`(默认 1000ms)
|
||||
|
||||
### Task Events & Projections
|
||||
|
||||
Pulse 内置任务生命周期管理。任务通过事件驱动状态机流转:
|
||||
|
||||
```
|
||||
task-created → task-assigned → task-executing → task-acked → task-closed
|
||||
→ task-given-up
|
||||
```
|
||||
|
||||
| 类型 | 说明 |
|
||||
|---|---|
|
||||
| `TaskState` | 任务完整状态(id、project、title、prompt、priority、status、agent、result) |
|
||||
| `PendingTasksData` | 待处理任务汇总(pendingCount、tasks、byProject) |
|
||||
| `AgentCapabilityStats` | 每个 agent 的能力统计(assigned/closed/givenUp/consecutiveFailures/avgDurationMs) |
|
||||
|
||||
`rebuildSnapshot` 自动注入:当 `senseKeys` 包含 `'pending-tasks'` 时,snapshot 中自动包含 `pending-tasks` 和 `agent-capability-stats` 两个 projection,供 Rules 做任务分配决策。
|
||||
|
||||
### 存储
|
||||
|
||||
| 库 | 内容 | 策略 |
|
||||
|---|---|---|
|
||||
| `events.db` | promote/rollback/effect/error/collect | 永不压缩 |
|
||||
| `events.db` | promote/rollback/effect/effect-acked/effect-failed/error/collect/task-* | 永不压缩 |
|
||||
| `vitals.db` | 系统资源/进程/网络/LLM 健康 | 可 gc |
|
||||
| `objects/` | CAS(内容寻址,不可变) | 自动去重 |
|
||||
|
||||
@@ -170,6 +205,7 @@ Watcher 持续采集写 vitals,唤醒判定看最近 1 分钟窗口(~12 条
|
||||
- [RFC #22: 多实例管理](https://github.com/oc-xiaoju/pulse/issues/22)
|
||||
- [RFC #23: Autonomic Layer + Rule Middleware Refactor](https://github.com/oc-xiaoju/pulse/issues/23)
|
||||
- [Design #27: P0 保命层完整设计](https://github.com/oc-xiaoju/pulse/issues/27)
|
||||
- [RFC #58: Definition Layer + Projection Engine + Rule Projections](https://github.com/oc-xiaoju/pulse/issues/58)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
Reference in New Issue
Block a user