Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/plugin-api-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ jobs:
- uses: actions/checkout@v4
with:
repository: kachofugetsu09/akashic-agent
# 5624 lacks the v3 domain-effect lookup export. Keep this exact
# Core commit until it is published; checkout failure is intentional
# release blocking, not permission to weaken the plugin oracle.
ref: 3005f838bcd96e2cbc58616aede46e4f39df4523
ref: 9da3a988a2bf62b0f550bd4f6bb98c4eeb1f56f5
path: .akashic-core
- uses: actions/checkout@v4
with:
repository: akashic-plugins/proactive_feedback
ref: 531eae4e4ac4714aad5417b8257a724007728345
path: .proactive-feedback
- uses: actions/setup-python@v5
with:
python-version: "3.13"
Expand All @@ -53,6 +55,7 @@ jobs:
- name: Run focused plugin tests
env:
AKASHIC_AGENT_ROOT: .akashic-core
AKASHIC_PROACTIVE_FEEDBACK_ROOT: .proactive-feedback
PYTHONPATH: .akashic-core
run: python -m pytest -q tests
- uses: actions/setup-node@v4
Expand All @@ -64,8 +67,12 @@ jobs:
env:
AKASHIC_AGENT_ROOT: .akashic-core
PYTHONPATH: .akashic-core
run: pyright --level error plugin.py dashboard.py db.py tests
run: >-
pyright --level error plugin.py runtime.py feedback_history.py
dashboard.py db.py tests
- name: Compile Python sources
run: python -m compileall -q plugin.py dashboard.py db.py drift tests
run: >-
python -m compileall -q plugin.py runtime.py feedback_history.py
dashboard.py db.py drift tests
- name: Check diff formatting
run: git diff --check
115 changes: 83 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,85 @@
# emotion

Akashic emotion and proactive tuning plugin.

## v3 接入

入口是 module-level `api_version = 3` 与 `apply(ctx, config)`。Emotion 通过 Core
声明以下能力:

- `PROACTIVE_COMPONENTS`:在 exact generation 中形成 VAD prompt projection;formal
运行由 `emotion.state` domain effect 提交 SQLite,candidate 不打开数据库。
- `BACKGROUND_JOBS`:`feedback-preference-context` Drift 完成后,使用 Core 的 LLM
lease 和窄 documents port 合并 `PROACTIVE_CONTEXT.md` / `proactive_pending.md`。
- `AFTER_TURN_COMMITTED`:消费 Core 已提交的 typed Turn。上游若提供
`extra.proactive_feedback`,按其稳定 identity 幂等写入;显式引用消息则按 Turn
自带标记写入 gold feedback。
- `UI_SLOTS` 与 C09 Dashboard:移动端和桌面端只读 Emotion 自有投影,不读取
`sessions.db`,不取得任意 workspace 句柄。

插件不再声明 v2 `Plugin`、EventBus listener、固定 `proactive_modules()` / `jobs()`
或旧 mobile/dashboard ABI。旧数据库不会在 import/apply 时自动迁移;切换前应先
停用旧 runtime 并使用独立迁移脚本(尚未将旧源删除)。

CI 的 Core pin 是 20062a715d2c5822228b327863b51c8d036119b3,因为旧 pin
5624a059348406c1f97993612adfec886b158158 没有 domain_effect_lookup_export。
该 commit 尚未发布到 Core 的公共默认分支前,CI checkout 失败属于明确的发布阻塞;
本插件必须继续在 integration Core exact worktree 上验证,不得删除 lookup seam 或放宽
candidate/formal oracle。

## 移动端看板

插件通过通用移动 UI 生命周期注册“主动状态”入口,说明用户反馈如何改变 Agent 的语气
与主动发送把握。移动端只列真正产生状态增量的反馈,不复制桌面端每个 proactive tick
的 effect 表;原始 VAD 指标默认折叠,需要时再查看。
Akashic 的 Emotion 状态、反馈历史和主动偏好插件。

## v3 普通能力组合

Emotion 不拥有 React,也不是 proactive 特权模块。它只组合 Core 已有原子:

```text
RUNTIME_STARTED
└─ TIMERS ──刷新──> emotion_context_current(可覆盖 current)
└────> drift.proposals.v1(普通 proposal)

CONTEXT_PREPARED(channel=wake)
└─ fresh current ──append──> extra_hints

Wake Turn 选择 proposal
├─ 普通 tool ──事务提交──> 完整 drift result + current preference + cursor
└─ AFTER_TURN_COMMITTED ──对账──> selected Turn / missing-commit revision

proactive-feedback.history.v1(可选)
└─ TIMERS ──pull page──> Emotion observation/sample + PF cursor(同一事务)
```

插件声明 `TIMERS`、`TOOL_CATALOG`、`UI_SLOTS`、`drift.proposals.v1` 和
`drift.wake.v1`。candidate 没有 `RUNTIME_STARTED`,因此不会登记 Timer、打开
Emotion DB 或产生 formal 写入。formal generation 的 current refresh 和可选 feedback
pull 各有一条职责独立的 Fiber-owned one-shot Timer 链;PF service 缺席时 pull child
保持 pending。reload 会先停止旧 child,再从 Emotion 自有 cursor 启动新 child。

当前 hint 只在 `channel=wake` 且刷新时间不超过 10 分钟时追加。它不 abort、
不 replace,也不污染 passive Turn。外部暂态 `OSError` 会记录 incident 并等待
下一 Timer;配置、schema、Content/Tool 合同错误保持 fail-loud。

## 事实 owner 与保留

| 事实 | owner | 正常语义 |
|---|---|---|
| `emotion_events` | Emotion | 真实情绪观察历史,全量追加保留 |
| `emotion_feedback_samples` | Emotion | 真实主动反馈样本,全量追加保留 |
| `emotion_drift_runs` | Emotion | 每个 proposal revision、选择和结果,全量追加保留 |
| `emotion_state` | Emotion | 当前 VAD singleton,可原位覆盖 |
| `emotion_context_current` | Emotion | 当前 VAD/presence/hint,可原位覆盖 |
| `emotion_preference_state` | Emotion | 当前偏好与已提交 cursor,可原位覆盖 |
| `pf_history_cursor` | Emotion | 已原子应用的 PF history current cursor,可原位覆盖 |
| `emotion_effects` | legacy Emotion | 冻结保留,不再新增、不删除 |
| `emotion_domain_effects` | legacy Emotion | 冻结保留,不再新增、不删除 |

空 tick 只允许刷新 current singleton,不创建 proposal/history。反馈批次先冻结进
`emotion_drift_runs`,普通 Drift 接受后由 `emotion_commit_preference_context`
在一个 SQLite transaction 中保存完整结果、替换 current preference、推进 cursor。
Turn 已提交但工具没提交时,该 revision 记为 `completed_without_commit`;下次为
同一批证据生成新 revision。重复提交相同结果幂等,identity 漂移会明确失败。

PF accepted history 由 Feedback 插件全量持有;Emotion 的 event/sample 是“这条反馈已被
Emotion 接纳、改变了什么、是否进入 Drift evidence”的独立应用账本。每页 observation、
可选 sample、VAD current 和 `pf_history_cursor` 同事务提交。普通非引用反馈在 PF accepted
前不会进入 Emotion,下一 Timer 后恰好应用一次。显式引用由 Emotion direct rule 立即
应用;PF 后续同 user message receipt 仍追加零 delta terminal 并推进 cursor/hash,但不再
增加 VAD 或重复写 Drift sample。跨插件边界会按 PF v1 完整稳定字段(包括 `session_key`)
重算 canonical JSON SHA-256;字段、类型、有限数值或 hash 漂移都会在 cursor 前 fail-loud。
旧 Emotion 已应用但没有 hash 的 `proactive_feedback:<id>` 事实保持原样;identity 相符时另
追加 `pf_history_import:<cursor>` 零 delta/零 sample terminal receipt,再同事务推进 cursor,
identity 冲突则整页回滚。

## 旧 proactive island 交接

旧版本曾参与两个 workspace 根文件,但它们是 proactive island 的共享事实,不归
Emotion 独占:

- `PROACTIVE_CONTEXT.md`:旧 Core `ProactiveDocuments` 读取并成对替换的当前主动规则。
- `proactive_pending.md`:旧 Drift skill 追加、旧 merge job 清空的共享候选队列。

本版本不声明 `workspace_files`,不读取、写入或清空这两个文件,也不保留
`PROACTIVE_COMPONENTS`、`BACKGROUND_JOBS`、`DRIFT_FINISHED` 或 private proactive
module。最终 Core island archive PR 应对旧文件做只读归档 receipt,记录完整 bytes、
SHA-256、原路径和时间后再 supersede;原文件不由 Emotion 删除。

## 验证边界

测试使用真实 Core DriftStore、Plugin Timer/Tool/UI composition 与隔离 SQLite,覆盖
candidate 零副作用、fresh wake hint、被动链零污染、proposal 重放、未提交重提、
工具幂等提交、TurnCommitted selection 时序、PF 双顺序组合、分页事务、显式引用单计数、
暂态 Timer 重臂和 reload 单 Timer。
这些是隔离 E2E fixture,不声称 hua-home formal activation 或线上 provider E2E。
Loading
Loading