Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(docs): disambiguate the plugin session scope ADR

new-Beginner81ee7ba0c730
diff --git a/docs/adr/0200-plugin-owned-session-api.md b/docs/adr/0200-plugin-owned-session-api.md
index b74ecbb4d..d0618f32b 100644
--- a/docs/adr/0200-plugin-owned-session-api.md
+++ b/docs/adr/0200-plugin-owned-session-api.md
@@ -3,7 +3,7 @@
- Status: Accepted
- Date: 2026-09-09
- Decision: D367
-- Amended: 2026-10-20 (ADR 0339 adds the `session.*.all` grants and the
+- Amended: 2026-10-20 (ADR 0340 adds the `session.*.all` grants and the
message-level writes; the ownership boundary below still governs `.own`)
## Context
@@ -60,10 +60,10 @@ trash-to-purge lifecycle, migration-compatible schema creation, and rate
limits. Full UI E2E execution remains deferred per repository policy; scenarios
E2E-214 and E2E-215 are recorded in the E2E plan.
-## Amendment (ADR 0339)
+## Amendment (ADR 0340)
The ownership premise above — "a plugin can only query or mutate its own rows" —
-is no longer the only boundary the host can express. ADR 0339 adds
+is no longer the only boundary the host can express. ADR 0340 adds
`session.read.all`, `session.update.all`, and `session.delete.all`, which carry
the same verbs over every live session, and it adds message-level writes
(`appendMessage`, `replaceMessages`, `deleteMessage`, `truncateFrom`) that this
@@ -85,5 +85,5 @@ What changes for this ADR:
`trash`, and `purge` statements now follow the scope Electron sends instead
of hard-coding it.
-See [ADR 0339](0339-plugin-session-all-scope.md) for the decision, the risk
+See [ADR 0340](0340-plugin-session-all-scope.md) for the decision, the risk
argument, and the alternatives.
diff --git a/docs/adr/0323-plugin-owned-session-titles.md b/docs/adr/0323-plugin-owned-session-titles.md
index b332e8c5b..8d579bebb 100644
--- a/docs/adr/0323-plugin-owned-session-titles.md
+++ b/docs/adr/0323-plugin-owned-session-titles.md
@@ -4,7 +4,7 @@
- Date: 2026-10-08
- Supersedes: ADR 0186
- Amended: 2026-10-08 (D654 restores the deterministic first-prompt fallback)
-- Amended: 2026-10-20 (ADR 0339 adds `session.read.all`, so the rejected
+- Amended: 2026-10-20 (ADR 0340 adds `session.read.all`, so the rejected
"give the plugin a broader session read" alternative below no longer fails
for the reason recorded here)
@@ -73,7 +73,7 @@ model-composed title moves to the plugin.
spend model tokens and mutate titles when the optional plugin is absent.
- Give the plugin `session.read` or `session.read.own`: rejected because those
permissions either expose a general transcript projection or only imported
- sessions and do not match the required boundary. *(Corrected by ADR 0339: the
+ sessions and do not match the required boundary. *(Corrected by ADR 0340: the
reason this alternative failed was that no grant described "read the user's
own session". `session.read.all` now does, so a title plugin that wants more
than the first turn can say so at install and ask for that grant instead.
diff --git a/docs/adr/0339-plugin-session-all-scope.md b/docs/adr/0340-plugin-session-all-scope.md
similarity index 99%
rename from docs/adr/0339-plugin-session-all-scope.md
rename to docs/adr/0340-plugin-session-all-scope.md
index ca78aa488..30eaa6291 100644
--- a/docs/adr/0339-plugin-session-all-scope.md
+++ b/docs/adr/0340-plugin-session-all-scope.md
@@ -1,4 +1,4 @@
-# ADR 0339: Let a granted plugin reach every session, not only its imports
+# ADR 0340: Let a granted plugin reach every session, not only its imports
- Status: Accepted
- Date: 2026-10-20
diff --git a/docs/adr/README.md b/docs/adr/README.md
index aeda72433..da722ddfa 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -399,4 +399,4 @@ Each ADR includes:
| 0339 | [Chat file references open absolute files outside the managed roots](0339-chat-file-refs-open-absolute-files-outside-managed-roots.md) | Accepted (amends ADR 0262 §4) |
| model-reasoning-effort-override | [Model reasoning effort override](model-reasoning-effort-override.md) | Proposed |
-| 0339 | [Let a granted plugin reach every session, not only its imports](0339-plugin-session-all-scope.md) | Accepted (D680; amends ADR 0200 and ADR 0323) |
+| 0340 | [Let a granted plugin reach every session, not only its imports](0340-plugin-session-all-scope.md) | Accepted (D680; amends ADR 0200 and ADR 0323) |
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index dc04b4a62..9708b78f4 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -19339,7 +19339,7 @@ host-created files. The full app's file-preview viewer is covered separately.
as `own`. Every audited line names the scope that authorised it.
- **Specs linked**: `07-plugins/03-plugin-api.md` §plugin-owned and host-wide
sessions; `07-plugins/13-plugin-permissions-matrix.md` §2;
- `07-plugins/04-plugin-security.md` §5; ADR 0339, ADR 0200 (amendment).
+ `07-plugins/04-plugin-security.md` §5; ADR 0340, ADR 0200 (amendment).
- **Acceptance**: A plugin that declares the `.all` grants can read and rewrite
the user's own conversations, the user sees the result in the open transcript,
and a plugin that declares only `.own` keeps exactly the ADR 0200 reach.
diff --git a/docs/spec/07-plugins/03-plugin-api.md b/docs/spec/07-plugins/03-plugin-api.md
index e5b259268..b04cdd64d 100644
--- a/docs/spec/07-plugins/03-plugin-api.md
+++ b/docs/spec/07-plugins/03-plugin-api.md
@@ -747,7 +747,7 @@ Plugins address sessions through two grants that share one set of verbs:
- `session.read.own` / `session.update.own` / `session.delete.own` — the
ADR 0200 boundary: only sessions whose origin belongs to the calling plugin.
- `session.read.all` / `session.update.all` / `session.delete.all` — every live
- session, including the conversations the user created in this app (ADR 0339).
+ session, including the conversations the user created in this app (ADR 0340).
`.all` is a separate grant, never a widening of `.own`, so an existing install
keeps exactly the reach it was reviewed for. A manifest may declare both, and
diff --git a/docs/spec/07-plugins/13-plugin-permissions-matrix.md b/docs/spec/07-plugins/13-plugin-permissions-matrix.md
index 6f921b3fb..1237fca3f 100644
--- a/docs/spec/07-plugins/13-plugin-permissions-matrix.md
+++ b/docs/spec/07-plugins/13-plugin-permissions-matrix.md
@@ -53,7 +53,7 @@ Provide a permission–capability–risk–default-policy reference table for re
| `session.read.own` | medium | `pi.session.list`, `pi.session.get`, `pi.session.listMessages` | Confirm at install | Reads only sessions imported by the calling plugin; no cross-plugin access |
| `session.update.own` | medium | `pi.session.rename` | Confirm at install | Renames only the calling plugin's active imported sessions |
| `session.delete.own` | high | `pi.session.delete` | Confirm at install | Trash/purge only the calling plugin's imported sessions; rate-limited |
-| `session.read.all` | high | `pi.session.list`, `pi.session.get`, `pi.session.listMessages` | Confirm at install | Reads **any** live session, including the conversations the user created in this app: title, project, model binding, and full message history with tool payloads. `.all` is a separate grant from `session.read.own` and wins when both are declared; the audit line records which scope authorised the call (ADR 0339) |
+| `session.read.all` | high | `pi.session.list`, `pi.session.get`, `pi.session.listMessages` | Confirm at install | Reads **any** live session, including the conversations the user created in this app: title, project, model binding, and full message history with tool payloads. `.all` is a separate grant from `session.read.own` and wins when both are declared; the audit line records which scope authorised the call (ADR 0340) |
| `session.update.all` | high | `pi.session.rename`, `pi.session.appendMessage`, `pi.session.replaceMessages` | Confirm at install | Renames any session and rewrites its transcript: append, replace, or delete-single-message. Rewrites are refused while a turn is running (`TURN_RUNNING`) and rate-limited. A rename claims the manual title source, so `session.autoTitle` cannot overwrite it afterwards |
| `session.delete.all` | high | `pi.session.delete`, `pi.session.deleteMessage`, `pi.session.truncateFrom` | Confirm at install | Trash/purge any session and cut or delete its messages. Keeps the session-delete rate limit; message rewrites share a 60/min message-write budget |
| `usage.read` | medium | `pi.usage.listTurns` | Confirm at install | Read-only listing of completed-turn facts (per-turn token counters and identifiers, keyset-paginated); no message body and no write path |
@@ -135,7 +135,7 @@ plugin, so it carries three bounds the other modes do not:
both, and `.all` wins. Message-level writes (`pi.session.appendMessage`,
`replaceMessages`, `deleteMessage`, `truncateFrom`) exist only under `.all`,
because rewriting a transcript is never an imported-session operation
- (ADR 0339). `session.autoTitle` stays the narrow title path and does not
+ (ADR 0340). `session.autoTitle` stays the narrow title path and does not
imply any session read grant
## 3A. Plan operating-state rule
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index bf3b96286..a2bc81056 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -428,7 +428,7 @@ Gold source: local Codex electron captures; latest row wins where rows conflict.
| D236 | One desktop instance per data directory | **Electron main takes `app.requestSingleInstanceLock()` during module evaluation — after `app.setName`, because the lock lives under the name-derived `userData` path, and before the logger, the persistence outbox, or any other data-directory access. A launch that does not take the lock calls `app.quit()` and boots nothing: the readiness and `before-quit` handlers both return early, so it creates no window, tray, child process, or log line inside the running instance's data directory. The lock holder answers `second-instance` by restoring and focusing its main window through the same path as the tray's Show action, which recreates a window that was closed or hidden into the tray. The lock is requested only when `PI_DESKTOP_DATA_DIR` is unset, so E2E harnesses, the capture rig, and deliberate side-by-side profiles keep the current start-anytime behavior. No IPC channel, host protocol, or storage schema changes.** | A second launch booted a complete second app: another host-core over the single-writer `pi.sqlite` (D002), another outbox and log tree in the same directory, another tray, launcher-chord registration, and updater, leaving two shells divergent over one database. Relaunching the app is a request to see the one already running, and scoping the lock to the installation keeps isolated-data-directory runs launchable (ADR 0094). |
| D367 | Host-owned plugin session import and ownership API | **`pi.session` gains `import`, `importBatch`, `list`, `get`, `listMessages`, `rename`, and `delete`; `contributes.sessionSources` is required for every source; host-core generates ids and scopes every operation to `(pluginId, source, externalId)` ownership; imports never activate project/provider/model bindings. Schema v14 adds `session_import_origins` and `sessions.deleted_at`; protocol v11 is unchanged. Trash keeps the transcript for owner-only purge.** | External-history plugins need durable import/read/update/delete, and the in-flight `session.getLlmContext` and core `session.import` boundaries are not safe plugin ownership boundaries (ADR 0200, E2E-214 / E2E-215) |
| D368 | Explicit plugin project ids and host-owned session refresh | **Permission-gated `pi.project.create({ path })` creates or reuses a project and returns its host-generated id without activating the workspace; import items may bind an existing `projectId`, omitted ids stay unbound, and historical origin paths never become tool roots. Electron main emits `pi-desktop/session/event/changed` after successful plugin imports, renames, and deletes; the renderer reuses `refreshSessions()`, skipped imports emit nothing, and closed project tabs are not reopened.** | Exposing `workspace.set` to plugins would change the user's active workspace, and plugin writes need a host-owned renderer refresh path (ADR 0201, E2E-216) |
-| D680 | Plugin session scope: `.all` grants and message-level writes | **`pi.session` gains `session.read.all`, `session.update.all`, and `session.delete.all`, which carry `list`/`get`/`listMessages`, `rename`, and `delete` over every live session instead of only the calling plugin's imports. `.all` is a separate grant, never a widening of `.own`, and it wins when a manifest declares both. Electron main resolves the scope from the grants and sends `scope` to host-core, which enforces exactly that and treats an absent value as `own`; `list` becomes a `LEFT JOIN` on the origin sidecar, `get`/messages report the real `originKind`, `source`, `externalId`, model binding, and `origin` instead of the import projection, and the `trash`/`purge` statements follow the scope instead of an embedded `EXISTS`. Message-level writes arrive as `appendMessage`/`replaceMessages` (`session.update.all`) and `deleteMessage`/`truncateFrom` (`session.delete.all`), delegating to the existing host-core transcript operations, refusing a rewrite with `TURN_RUNNING` while a turn owns the session, and sharing a 60/min budget. `rename` now claims the manual title source. Every session call audits the authorising scope; `sessionsChanged` names the changed session.** | The ADR 0200 ownership filter made a legitimate "read the user's own conversation" capability inexpressible, so ADR 0323 had to invent a narrower title permission and ADR 0333's shipped suggestion flow cannot read the session it runs on; widening `.own` instead would silently expand grants users reviewed as "only the sessions this plugin imported" (ADR 0339) |
+| D680 | Plugin session scope: `.all` grants and message-level writes | **`pi.session` gains `session.read.all`, `session.update.all`, and `session.delete.all`, which carry `list`/`get`/`listMessages`, `rename`, and `delete` over every live session instead of only the calling plugin's imports. `.all` is a separate grant, never a widening of `.own`, and it wins when a manifest declares both. Electron main resolves the scope from the grants and sends `scope` to host-core, which enforces exactly that and treats an absent value as `own`; `list` becomes a `LEFT JOIN` on the origin sidecar, `get`/messages report the real `originKind`, `source`, `externalId`, model binding, and `origin` instead of the import projection, and the `trash`/`purge` statements follow the scope instead of an embedded `EXISTS`. Message-level writes arrive as `appendMessage`/`replaceMessages` (`session.update.all`) and `deleteMessage`/`truncateFrom` (`session.delete.all`), delegating to the existing host-core transcript operations, refusing a rewrite with `TURN_RUNNING` while a turn owns the session, and sharing a 60/min budget. `rename` now claims the manual title source. Every session call audits the authorising scope; `sessionsChanged` names the changed session.** | The ADR 0200 ownership filter made a legitimate "read the user's own conversation" capability inexpressible, so ADR 0323 had to invent a narrower title permission and ADR 0333's shipped suggestion flow cannot read the session it runs on; widening `.own` instead would silently expand grants users reviewed as "only the sessions this plugin imported" (ADR 0340) |
| D370 | Local MCP control plane for desktop operations | *(amended by D372)* **An opt-in Streamable HTTP MCP server inside Electron Main binds to `127.0.0.1`, authenticates with a persistent random bearer token, validates supplied Origins against loopback hostnames, writes a mode-restricted connection manifest, and delegates to the same registered IPC handlers the renderer uses. Named tools cover the project/session/Agent flow; `pi_desktop_invoke` reaches a risk-tagged operation catalog; dangerous operations require `confirm: true`; successful external mutations reuse the renderer session-change event. Local-only and fail-soft at startup.** | An external Agent needs to drive the running desktop without a second permission or persistence implementation and without touching the deferred remote Gateway / WebUI boundary (ADR 0203, E2E-220) |
| D372 | Tightened local MCP control-plane boundary | **Amend D370 / ADR 0203: the first-version catalog is the project/session/Agent/workspace flow plus reviewed reads; secret-shaped arguments are stripped; `session/configure` is dangerous; listen addresses are asserted loopback; protocol versions are negotiated rather than echoed; results including `structuredContent` are bounded; renderer session refresh is mutation-only.** | The first catalog still exposed native pickers, secret-write provider/OAuth/MCP paths, and unconfirmed `session/configure`, and treated session reads as renderer mutations (E2E-220) |
| D377 | Plugin desktop control requires native user consent | **A `dangerous` desktop operation invoked through `pi.desktop.invoke` needs the plugin's `confirm: true` and then the user's answer to a host-owned native dialog that shows only the catalog operation id, description, and a bounded argument preview; dismissal, Deny, and a host without a dialog service fail with `PERMISSION_DENIED`. `read`/`write` operations and the MCP contract (D372) are unchanged.** | The controller's `confirm` flag is set by the caller, so a plugin (or a model behind it) could delete sessions or switch a session to `auto` with no human in the loop, and any plugin-drawn confirmation card can be relabeled by a prompt-injected transcript (ADR 0208, E2E-236) |
@@ -8152,7 +8152,7 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
## 2026-10-20 — Plugin session scope: `.all` grants and message-level writes (D680)
-- D680 / ADR 0339 opens `pi.session` beyond the ADR 0200 import boundary. Three
+- D680 / ADR 0340 opens `pi.session` beyond the ADR 0200 import boundary. Three
new permissions — `session.read.all`, `session.update.all`,
`session.delete.all` — carry the existing verbs over every live session,
including the conversations the user created in this app.
@@ -8186,6 +8186,6 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
60/minute budget.
- Covered by the `plugin_sessions` and `plugin_session` host-core tests,
`apps/desktop/test/plugin-session-access.test.mjs`, and
- `apps/desktop/test/plugin-session-api.test.mjs`. See ADR 0339, ADR 0200's
+ `apps/desktop/test/plugin-session-api.test.mjs`. See ADR 0340, ADR 0200's
amendment, ADR 0323's corrected alternative, `03-plugin-api.md` §plugin-owned
and host-wide sessions, `13-plugin-permissions-matrix.md` §2, and E2E-268.
diff --git a/docs/zh-CN/adr/index.md b/docs/zh-CN/adr/index.md
index 819244994..a7dea24e3 100644
--- a/docs/zh-CN/adr/index.md
+++ b/docs/zh-CN/adr/index.md
@@ -316,7 +316,7 @@ ADR 记录那些不应被静默改变的架构选择。中文入口与英文索
| 0311 | [在 Host 受理时重新核验 Live Work 工作空间身份](/adr/0311-live-work-workspace-admission-guard) | 已实现候选 |
| 0312 | [会话级 Todo 清单](/adr/0312-session-scoped-todo-checklist) | 已接受实施 |
| registry-header-variable-spelling | [Remote header variables accept the registry's `{name}` spelling](/adr/registry-header-variable-spelling) | Proposed |
-| 0339 | [插件可访问任意会话(新增 .all 权限)](/adr/0339-plugin-session-all-scope) | 已接受(修订 ADR 0200、ADR 0323;D680) |
+| 0340 | [插件可访问任意会话(新增 .all 权限)](/adr/0340-plugin-session-all-scope) | 已接受(修订 ADR 0200、ADR 0323;D680) |
## 什么时候看 ADR
diff --git a/docs/zh-CN/spec/07-plugins/03-plugin-api.md b/docs/zh-CN/spec/07-plugins/03-plugin-api.md
index 3f1896174..30fb78ba7 100644
--- a/docs/zh-CN/spec/07-plugins/03-plugin-api.md
+++ b/docs/zh-CN/spec/07-plugins/03-plugin-api.md
@@ -721,7 +721,7 @@ Projects 页面也会据此刷新持久项目索引;插件不需要、也不
5 次批量导入和 20 次删除。写入前会移除工具 `__pi*` 与 `piDesktop.*` 对象键。
P2/P3(会话创建、消息变更、任意重新绑定、provider/model 绑定、批量删除、标签)不属于本次接口。
-自 ADR 0339 起,同一组动词还有 `.all` 授权:`session.read.all`、
+自 ADR 0340 起,同一组动词还有 `.all` 授权:`session.read.all`、
`session.update.all`、`session.delete.all`。它们覆盖**所有活动会话**,包括用户
在本应用中自己创建的对话。`.all` 是与 `.own` 并列的独立授权,不会放宽 `.own`;
清单同时声明两者时 `.all` 生效。作用域由 Electron main 依据授权解析后传给
diff --git a/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md b/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md
index 753d77956..ec378bcb0 100644
--- a/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md
+++ b/docs/zh-CN/spec/07-plugins/13-plugin-permissions-matrix.md
@@ -56,7 +56,7 @@
| `session.read.own` | 中等 | `pi.session.list`、`pi.session.get`、`pi.session.listMessages` | 安装时确认 | 只能读取本插件导入的会话;不能跨插件访问 |
| `session.update.own` | 中等 | `pi.session.rename` | 安装时确认 | 只能重命名本插件拥有的活动导入会话 |
| `session.delete.own` | 高 | `pi.session.delete` | 安装时确认 | 只能回收或清除本插件导入的会话;有频率限制 |
-| `session.read.all` | 高 | `pi.session.list`、`pi.session.get`、`pi.session.listMessages` | 安装时确认 | 可读取**任意**活动会话,包括用户在本应用中自己创建的对话:标题、项目、模型绑定,以及含工具负载的完整消息记录。`.all` 是与 `session.read.own` 并列的独立授权,两者都声明时 `.all` 生效;审计行会记录本次调用依据的作用域(ADR 0339) |
+| `session.read.all` | 高 | `pi.session.list`、`pi.session.get`、`pi.session.listMessages` | 安装时确认 | 可读取**任意**活动会话,包括用户在本应用中自己创建的对话:标题、项目、模型绑定,以及含工具负载的完整消息记录。`.all` 是与 `session.read.own` 并列的独立授权,两者都声明时 `.all` 生效;审计行会记录本次调用依据的作用域(ADR 0340) |
| `session.update.all` | 高 | `pi.session.rename`、`pi.session.appendMessage`、`pi.session.replaceMessages` | 安装时确认 | 可重命名任意会话并改写其记录:追加、替换或删除单条消息。回合运行期间拒绝改写(`TURN_RUNNING`),并有频率限制。重命名会占用「手动标题」来源,`session.autoTitle` 之后无法覆盖 |
| `session.delete.all` | 高 | `pi.session.delete`、`pi.session.deleteMessage`、`pi.session.truncateFrom` | 安装时确认 | 可回收或清除任意会话,并截断或删除其消息。保留会话删除频率限制;消息改写共用每分钟 60 次的预算 |
| `usage.read` | 中等 | `pi.usage.listTurns` | 安装时确认 | 已完成 turn 事实行的只读列举(每回合 token 计数与标识符,keyset 分页);不含消息正文,无写路径 |
diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.md
index 9eb6219f1..d8e7378d0 100644
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@ -428,7 +428,7 @@
| D236 | 每个数据目录只允许一个桌面实例 | **Electron 主进程在模块求值期间调用 `app.requestSingleInstanceLock()` —— 在 `app.setName` 之后(锁位于由应用名派生的 `userData` 路径下),且在 logger、持久化 outbox 或任何其他数据目录访问之前。没有拿到锁的启动直接调用 `app.quit()` 且不引导任何东西:readiness 与 `before-quit` 处理器都提前返回,因此它不会在运行中实例的数据目录内创建窗口、托盘、子进程或日志行。持有锁的实例通过与托盘“显示”操作相同的路径响应 `second-instance`,恢复并聚焦主窗口,若窗口已关闭或隐藏到托盘则重新创建。只有在未设置 `PI_DESKTOP_DATA_DIR` 时才请求该锁,因此 E2E 测试装置、截图装置和有意并行的 profile 保持原有的随时启动行为。IPC 通道、宿主协议和存储架构均未变化。** | 第二次启动会引导出一个完整的第二份应用:在单写者 `pi.sqlite`(D002)上再开一个 host-core,在同一目录下再建一份 outbox 和日志树,再加一个托盘、一次启动器快捷键注册和一个更新器,导致两个 shell 在同一个数据库上出现分歧。再次启动应用是想看到已经在运行的那一个,把锁的作用域限定在安装本身也让使用独立数据目录的运行仍可启动(ADR 0094)。 |
| D367 | 宿主拥有的插件会话导入与归属 API | **`pi.session` 增加 `import`、`importBatch`、`list`、`get`、`listMessages`、`rename`、`delete`;每个来源必须声明 `contributes.sessionSources`;host-core 生成 id,并把所有操作限定在 `(pluginId, source, externalId)` 归属内;导入永不激活项目/provider/模型绑定。Schema v14 增加 `session_import_origins` 与 `sessions.deleted_at`;协议 v11 不变。回收站保留转录,仅属主可清除。** | 外部历史插件需要持久的导入/读取/更新/删除,而进行中的 `session.getLlmContext` 与核心 `session.import` 边界不是安全的插件归属边界(ADR 0200,E2E-214 / E2E-215) |
| D368 | 显式插件项目 id 与宿主拥有的会话刷新 | **受权限门控的 `pi.project.create({ path })` 创建或复用项目并返回宿主生成的 id,不激活工作区;导入项可绑定已有 `projectId`,省略则保持未绑定,历史来源路径永不成为工具根。Electron main 在插件导入、重命名、删除成功后发出 `pi-desktop/session/event/changed`;渲染器复用 `refreshSessions()`,跳过的导入不发事件,已关闭的项目标签不会重新打开。** | 向插件暴露 `workspace.set` 会改变用户的活动工作区,且插件写入需要宿主拥有的渲染器刷新路径(ADR 0201,E2E-216) |
-| D680 | 插件会话作用域:`.all` 权限与消息级写入 | **`pi.session` 增加 `session.read.all`、`session.update.all`、`session.delete.all`,让 `list`/`get`/`listMessages`、`rename`、`delete` 覆盖所有活动会话,而不再只限于本插件导入的会话。`.all` 是与 `.own` 并列的独立授权,不会放宽 `.own`;两者都声明时 `.all` 生效。Electron main 按授权解析作用域并把 `scope` 发给 host-core,host-core 只执行收到的那个值,缺省视为 `own`;`list` 改为对来源边表做 `LEFT JOIN`,`get` 与消息返回真实的 `originKind`、`source`、`externalId`、模型绑定与 `origin`,而不是导入投影,`trash`/`purge` 语句按作用域而不是内嵌 `EXISTS` 执行。消息级写入首次开放:`appendMessage`/`replaceMessages`(`session.update.all`)与 `deleteMessage`/`truncateFrom`(`session.delete.all`),复用既有 host-core 记录操作,回合运行期间以 `TURN_RUNNING` 拒绝改写,并共用每分钟 60 次预算。`rename` 改为占用手动标题来源。每次会话调用都会审计其授权作用域;`sessionsChanged` 会带上变更的会话 id。** | ADR 0200 的归属过滤让「读取用户自己的会话」这一合法能力无法表达,ADR 0323 因此不得不另造一个更窄的标题权限,ADR 0333 已交付的建议流程也读不到它所在的会话;直接放宽 `.own` 则会在用户不知情的情况下放大其审核过的「仅本插件导入的会话」授权(ADR 0339) |
+| D680 | 插件会话作用域:`.all` 权限与消息级写入 | **`pi.session` 增加 `session.read.all`、`session.update.all`、`session.delete.all`,让 `list`/`get`/`listMessages`、`rename`、`delete` 覆盖所有活动会话,而不再只限于本插件导入的会话。`.all` 是与 `.own` 并列的独立授权,不会放宽 `.own`;两者都声明时 `.all` 生效。Electron main 按授权解析作用域并把 `scope` 发给 host-core,host-core 只执行收到的那个值,缺省视为 `own`;`list` 改为对来源边表做 `LEFT JOIN`,`get` 与消息返回真实的 `originKind`、`source`、`externalId`、模型绑定与 `origin`,而不是导入投影,`trash`/`purge` 语句按作用域而不是内嵌 `EXISTS` 执行。消息级写入首次开放:`appendMessage`/`replaceMessages`(`session.update.all`)与 `deleteMessage`/`truncateFrom`(`session.delete.all`),复用既有 host-core 记录操作,回合运行期间以 `TURN_RUNNING` 拒绝改写,并共用每分钟 60 次预算。`rename` 改为占用手动标题来源。每次会话调用都会审计其授权作用域;`sessionsChanged` 会带上变更的会话 id。** | ADR 0200 的归属过滤让「读取用户自己的会话」这一合法能力无法表达,ADR 0323 因此不得不另造一个更窄的标题权限,ADR 0333 已交付的建议流程也读不到它所在的会话;直接放宽 `.own` 则会在用户不知情的情况下放大其审核过的「仅本插件导入的会话」授权(ADR 0340) |
| D370 | 桌面操作的本地 MCP 控制平面 | *(由 D372 修订)* **Electron Main 内可选启用的 Streamable HTTP MCP 服务器绑定 `127.0.0.1`,用持久随机 bearer token 认证,按回环主机名校验 Origin,写入受模式限制的连接清单,并委托给渲染器使用的同一组已注册 IPC 处理器。命名工具覆盖项目/会话/Agent 流程;`pi_desktop_invoke` 可达带风险标记的操作目录;危险操作需要 `confirm: true`;成功的外部变更复用渲染器会话变更事件。仅本地且启动时失败软着陆。** | 外部 Agent 需要驱动运行中的桌面,又不能有第二套权限或持久化实现,也不能触碰推迟的远程 Gateway / WebUI 边界(ADR 0203,E2E-220) |
| D372 | 收紧本地 MCP 控制平面边界 | **修订 D370 / ADR 0203:首版目录为项目/会话/Agent/工作区流程加已审阅的读取;剥离秘密形态的参数;`session/configure` 视为危险;监听地址断言为回环;协议版本协商而非回显;包含 `structuredContent` 的结果有界;渲染器会话刷新仅限变更操作。** | 首版目录仍暴露原生选择器、写秘密的 provider/OAuth/MCP 路径与未确认的 `session/configure`,并把会话读取当作渲染器变更(E2E-220) |
| D377 | 插件桌面控制需要原生用户同意 | **通过 `pi.desktop.invoke` 调用的 `dangerous` 桌面操作,需要插件给出 `confirm: true`,然后由用户在宿主拥有的原生对话框中作答;该对话框只显示目录中的操作 id、描述和有界的参数预览;关闭对话框、拒绝,以及没有对话框服务的宿主都以 `PERMISSION_DENIED` 失败。`read`/`write` 操作与 MCP 契约(D372)不变。** | 控制器的 `confirm` 标志由调用方设置,因此插件(或其背后的模型)可以在没有人参与的情况下删除会话或把会话切到 `auto`,而任何由插件绘制的确认卡片都可能被提示注入的成绩单改换标签(ADR 0208,E2E-236) |
@@ -5692,7 +5692,7 @@ Markdown 源码,不是 `text/html` 负载;对禁用行内 HTML 的外部编
## 2026-10-20 —— 插件会话作用域:`.all` 权限与消息级写入(D680)
-- D680 / ADR 0339 把 `pi.session` 从 ADR 0200 的导入归属边界扩开。三个新权限
+- D680 / ADR 0340 把 `pi.session` 从 ADR 0200 的导入归属边界扩开。三个新权限
`session.read.all`、`session.update.all`、`session.delete.all` 让既有动词覆盖
所有活动会话,包括用户在本应用中自己创建的对话。
- `.all` 是新增而非放宽:已安装插件保留其用户审核过的可达范围;清单可同时声明
@@ -5717,6 +5717,6 @@ Markdown 源码,不是 `text/html` 负载;对禁用行内 HTML 的外部编
schema 与持久化格式。删除限流仍为每分钟 20 次;四个消息写入共用每分钟 60 次。
- 覆盖:host-core 的 `plugin_sessions` 与 `plugin_session` 测试、
`apps/desktop/test/plugin-session-access.test.mjs`、
- `apps/desktop/test/plugin-session-api.test.mjs`。见 ADR 0339、ADR 0200 修订、
+ `apps/desktop/test/plugin-session-api.test.mjs`。见 ADR 0340、ADR 0200 修订、
ADR 0323 更正后的备选方案、`03-plugin-api.md` §插件拥有与全量会话、
`13-plugin-permissions-matrix.md` 第 2 节与 E2E-268。