590facb45c
- Moore machine model: Effects determined by state diff, not events - S combinator rule composition: pulse = S r3 . S r2 . S r1 $ dummy - createRule helper with accessor-based state adaptation - 7 tests passing (compose, async, adaptive tickMs, Moore property) Design: https://github.com/oc-xiaoju/ograph/issues/44
2.0 KiB
2.0 KiB
Pulse
Agent 的自主神经系统。
有状态的响应式循环——持续感知多数据源,自主执行确定性任务,只在不确定时才上报 Agent 决策。
核心模型
f(prevSnapshot, currSnapshot) → (Effect[], tickMs)
Runtime 只有十行。所有智能在规则里。
Moore 机
Pulse 不逐事件响应,只看两次采样间的状态变化。Effects 由新状态决定,不由事件驱动。副作用不满足结合律——Pulse 承认采样有损,保证每个采样点的决策在当时是对的。
S 组合子规则叠加
每条规则是一个 S 组合子。不区分确定性/不确定性规则,统一叠加:
pulse = S r3 . S r2 . S r1 $ dummy
规则签名:
type Rule<S, E> =
(prev: S, curr: S) =>
(effects: E[], tickMs: number) =>
Promise<[E[], number]> | [E[], number]
每条规则接收快照,返回修饰函数——拿到前面规则的累积结果,可以追加、删除、替换 effects,调整 tickMs,或 pass through。
Agent 关系
Agent 是意识层,Pulse 是自主神经系统。Agent 定义规则,Pulse 执行规则,遇到例外回报 Agent,Agent 调整规则。
包结构
| 包 | 内容 |
|---|---|
@uncaged/pulse |
核心引擎:runPulse() + Rule 类型,纯泛型零依赖 |
@uncaged/upulse |
CLI:daemon 管理 + test/staging/promote |
@uncaged/pulse-rules |
共享规则函数库 |
Engine 目录
每个 Agent 维护自己的 engine repo:
~/.upulse/
config.json
engine/ ← main branch(生产)
types.ts ← Snapshot + Effect 类型
rules/ ← 规则链
collectors/ ← State 获取
effectors/ ← Effect 执行
pulse.config.ts
staging/ ← git worktree(Agent 在这改)
设计文档
详见 RFC #44: Pulse — Agent 的自主神经系统
License
MIT