Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
ADR 0340: Let a granted plugin reach every session, not only its imports
- Status: Accepted
- Date: 2026-10-20
- Decision: D680
- Amends: ADR 0200, ADR 0323
- Related: 07-plugins/03-plugin-api · 13-plugin-permissions-matrix
Context
pi.session was built for external conversation import (ADR 0200), so every read
and write is filtered by session_import_origins.plugin_id and a plugin can only
reach sessions it imported itself. The composer-suggestion flow (ADR 0333) needs
pi.session.getLlmContext and pi.session.listMessages refuses a session no
plugin imported, which is why ADR 0323 had to invent the narrower
session.autoTitle permission instead of describing "a plugin may read a user's
session".
Decision
- Add
session.read.all,session.update.all, andsession.delete.all, which carry the same three verbs as the.ownfamily over every live session, including conversations the user created in this app. - Keep
.ownexactly as it is, since.allis an addition and never a widening; a manifest may declare both and.allwins. - Split enforcement so the ownership predicate stops being an implicit second
permission: Electron main resolves the scope from the granted permissions and
sends the literal
scope("own"|"all") to host-core, which enforces exactly what it is handed, reads an absent parameter as"own", rejects an unknown value withINVALID_PARAMS, and still holds no permission data. - Fix the queries that only worked because the boundary was narrow:
listbecomes aLEFT JOINon the origin sidecar,getreports the realoriginKind,modelId,providerId, andbound.model, messages reportorigin: "external"or"desktop", and theEXISTSpredicates inpurgeandtrashfollow the scope. - Expose message-level writes for the first time —
appendMessageandreplaceMessagesundersession.update.all,deleteMessageandtruncateFromundersession.delete.all— delegating to the existing host-core transcript operations, with a rewrite refused byTURN_RUNNINGwhile a turn owns the session andappendMessageexempt. - Keep the brakes that are not about ownership: session delete stays at 20 calls
per minute per plugin, the four message-level writes share a 60
calls-per-minute budget, and
session.autoTitlestays the narrow title path that implies no read grant.
Consequences
- A plugin can read, rename, rewrite, and delete the user's own conversations, a
genuinely high-risk grant that the matrix,
HIGH_RISK_PERMISSIONS, and the runtime-risk map all classify ashigh. renameclaims the manual title source so a latersession.autoTitlecannot overwrite a chosen title, and a session outside the caller's scope isNOT_FOUNDrather thanPERMISSION_DENIEDso an.ownplugin cannot probe for sessions it may not see.externalIdwidens tostring | nullandoriginto"external" | "desktop"for.allholders only; every session call now audits one line withscope, andsessionsChangedcarries an optionalsessionIdso the shell re-reads a rewritten active transcript.
Alternatives considered
- Widen
.owninstead of adding.all: a user who approved "only the sessions this plugin imported" never approved every conversation. - Route plugin reads through
session.read/getLlmContext: that grant is scoped to an in-flight tool invocation and returns a prompt projection. - Give the plugin direct session RPC access: it removes the pluginId provenance the audit relies on.