Skip to content

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

Merge origin/main into feat/plugin-channels

vastsa94dcb7a18aaa
diff --cc crates/host-core/src/plugins/tests.rs
index ba34c61cc,3b2270a33..a780f9c6d
--- a/crates/host-core/src/plugins/tests.rs
+++ b/crates/host-core/src/plugins/tests.rs
@@@ -2049,80 -1968,26 +2049,103 @@@ fn market_cards_and_details_read_the_ca
);
}
+/// An install reports the phases it passes through, and a user who cancels
+/// stops it before anything is written.
+#[test]
+fn an_install_reports_progress_and_honours_a_cancel() {
+ #[derive(Default)]
+ struct InstallLog {
+ phases: Vec<&'static str>,
+ bytes: Vec<(u64, u64)>,
+ errors: Vec<String>,
+ }
+
+ impl InstallObserver for InstallLog {
+ fn progress(&mut self, event: InstallProgress) {
+ self.phases.push(event.phase.as_str());
+ if event.received_bytes > 0 {
+ self.bytes.push((event.received_bytes, event.total_bytes));
+ }
+ if let Some(error) = event.error {
+ self.errors.push(error);
+ }
+ }
+ }
+
+ struct CancelAfterFirstReport {
+ seen: usize,
+ }
+
+ impl InstallObserver for CancelAfterFirstReport {
+ fn progress(&mut self, _event: InstallProgress) {
+ self.seen += 1;
+ }
+
+ fn cancelled(&self) -> bool {
+ self.seen > 0
+ }
+ }
+
+ with_local_market(|| {
+ let dir = tempdir().unwrap();
+ unsafe {
+ std::env::set_var("PI_DESKTOP_DATA_DIR", dir.path());
+ }
+ let mut mgr = PluginManager::new(dir.path(), MarketChannel::Official, None);
+
+ let mut log = InstallLog::default();
+ let installed = mgr
+ .install_from_market_observed("demo.workspace-notes", None, true, false, None, &mut log)
+ .expect("the fixture package installs");
+ assert_eq!(installed.plugin.id, "demo.workspace-notes");
+ // The fixture catalog serves a local package, so resolution is skipped
+ // and the phases are the ones a download has: bytes, verify, install.
+ for phase in ["download", "verify", "install"] {
+ assert!(
+ log.phases.contains(&phase),
+ "{phase} missing from {:?}",
+ log.phases
+ );
+ }
+ assert!(
+ log.bytes
+ .iter()
+ .any(|(received, total)| *received > 0 && *total >= *received),
+ "bytes were reported against the announced size: {:?}",
+ log.bytes
+ );
+ assert!(log.errors.is_empty(), "{:?}", log.errors);
+
+ // A cancel that arrives while the bytes arrive stops the install before
+ // it is verified, written or registered.
+ let mut cancelling = CancelAfterFirstReport { seen: 0 };
+ let error = mgr
+ .install_from_market_observed("demo.hello", None, true, false, None, &mut cancelling)
+ .unwrap_err()
+ .to_string();
+ assert!(error.contains("PLUGIN_CANCELLED"), "{error}");
+ });
++
+ #[test]
+ fn plugin_ui_meta_parses_the_floating_widget_placement() {
+ let widget: PluginUiMeta = serde_json::from_value(json!({
+ "panel": "renderer/index.html",
+ "width": 200,
+ "height": 200,
+ "shape": "widget",
+ "alwaysOnTop": true,
+ "resizable": false
+ }))
+ .unwrap();
+ assert_eq!(widget.shape.as_deref(), Some("widget"));
+ assert_eq!(widget.always_on_top, Some(true));
+ assert_eq!(widget.resizable, Some(false));
+
+ // A manifest that never heard of widgets keeps deserializing untouched, and
+ // the camelCase keys stay the wire contract.
+ let panel: PluginUiMeta =
+ serde_json::from_value(json!({ "panel": "renderer/index.html" })).unwrap();
+ assert!(panel.shape.is_none());
+ assert!(panel.always_on_top.is_none());
+ assert!(panel.resizable.is_none());
}
diff --cc docs/adr/0276-official-plugin-channel-and-backup-channels.md
index 16282d4b4,000000000..96c92a237
mode 100644,000000..100644
--- a/docs/adr/0276-official-plugin-channel-and-backup-channels.md
+++ b/docs/adr/0276-official-plugin-channel-and-backup-channels.md
@@@ -1,238 -1,0 +1,238 @@@
- # ADR 0274: Official plugin channel and backup channels
++# ADR 0276: Official plugin channel and backup channels
+
+- Status: Accepted for implementation
+- Date: 2026-09-17
+- Deciders: PI-Desktop plugin and distribution maintainers
+- Related: ADR 0102, D238, E2E-024P, E2E-PLUGIN-official-channel-resolves-through-the-platform
+
+## Context
+
+The client's marketplace source was a three-value union — `official`, `mirror`,
+`custom` — mapped to hardcoded catalog URLs, and `official` was
+indistinguishable from "never set": both landed on the GitHub default. A
+package was fetched by joining the catalog's relative `url` onto
+`artifactBaseUrl` or the catalog directory, and the `verified` trust tier was
+recognized only while the catalog URL equaled one of two constants.
+
+Since ADR 0102 the plugin center at `plugins.aiuo.net` is the publishing
+authority, and it defines the client-facing download contract:
+
+```text
+GET /catalog.json the catalog the client reads
+POST /api/v1/download/resolve JSON { deviceId, pluginId, version? }
+ -> 200 { sha256, sizeBytes, downloads[] }
+ Cache-Control: no-store
+GET /download/{id}/{version} byte route for the marketplace page and
+ console; not the client's path
+```
+
+The platform's own rules, verified against production: it never hosts the bytes
+of a published package, only answers where they are; `downloads` is ordered and
+never empty on `200`; a client calls resolve once per install or update, sends a
+**stable** device identifier, never caches the answer, verifies `sha256` before
+installing, and tries the next mirror when one fails; `counted: false` is normal;
+rate limiting is per device identifier (otherwise per source address), 600
+requests per minute by default, with `429` and `Retry-After`; refusals are
+`400 PLUGIN_REQUIRED`, `403 NOT_PUBLISHED`, `403 PLUGIN_ARCHIVED`,
+`404 NOT_FOUND`, `429`, and `503 NO_DOWNLOAD_SOURCE`; and a platform-unreachable
+install falls back to the catalog's URL and is not counted. Counting identity is
+the device identifier, the platform stores counts rather than identities, and
+the optional `source` field is a statistics hint only.
+
+Measured on the same day: the catalog declares
+`artifactBaseUrl = raw.githubusercontent.com/AIUO-Net/pi-desktop-plugins/main`;
+all three mirrors answered `200` and every mirror host is already inside the
+client's download allowlist; the CNB mirror still served an older distribution
+(22 plugins, and `pi.todo-0.6.5` at 92487 bytes where the other mirror served
+92951 bytes). A version string may contain `+` (for example `0.3.0+0.2.0`), so
+the platform's byte route cannot be assumed to carry every published version.
+
+The client's source model therefore has to become "the center first, the two Git
+hosts as backups", and the install path has to follow the platform's contract.
+
+## Decision
+
+### 1. Four channels, and `official` keeps its meaning
+
+| # | Channel | Value | Catalog URL | Install path |
+| --- | --- | --- | --- | --- |
+| 1 | Official channel | `official` (default) | `https://plugins.aiuo.net/catalog.json` | Platform resolve |
+| 2 | GitHub backup | `github` (new) | `https://raw.githubusercontent.com/AIUO-Net/pi-desktop-plugins/main/catalog.json` | Static relative URL |
+| 3 | CNB backup | `mirror` (unchanged) | `https://cnb.cool/aixk/pi-desktop-plugins/-/git/raw/main/catalog.json` | Static relative URL |
+| 4 | Custom | `custom` (unchanged) | user-provided | Static relative URL |
+
+`official` keeps meaning "the project's own first-party channel" and now points
+at the center, so an unset value and an unrecognized value resolve to it and no
+persisted setting is migrated. `mirror` keeps meaning CNB; `github` is new
+because the GitHub backup no longer is the default. Display names are
+localized — Official channel / GitHub backup / CNB backup / Custom in English.
+A package URL never crosses providers: whichever channel served the catalog also
+serves the package.
+
+### 2. The official channel resolves through the platform
+
+1. Refresh the catalog, then `POST {center origin}/api/v1/download/resolve` with
+ `{ deviceId, pluginId, version }` — once per install or update. POST rather
+ than GET, because the platform documents that a device id in a query string
+ ends up in access logs.
+2. Try the returned `downloads` entries in order. Every attempt is downloaded to
+ a temporary file, checked against the returned `sha256` and the announced
+ `sizeBytes`, and extracted only when both agree. A mirror that fails —
+ network error, HTTP error, digest mismatch, size mismatch — is abandoned and
+ the next one is tried. Requests stay on the download allowlist.
+3. Only when the platform could not be reached, or when no mirror in the list
+ could serve the version, the client falls back to the catalog's own package
+ URL (`artifactBaseUrl` plus the relative `url`). That is the fallback the
+ platform defines, and that install is not counted.
+4. The answer is never cached (`Cache-Control: no-store` is the platform's
+ confirmation of this), so two installs of the same version are two calls.
+5. The resolve digest is authoritative on the resolve path; the catalog's
+ `shasum` stays authoritative on the fallback and on the backup channels.
+ `sizeBytes` is a sanity check on both.
+6. Refusals are reported, not papered over: `403 NOT_PUBLISHED` (no retry),
+ `403 PLUGIN_ARCHIVED` (hide the plugin from install and update selection),
+ `404` (the platform has no such version — including a `+`-suffixed version
+ the byte route cannot carry), `429` (wait the `Retry-After` interval, retry
+ once, then report), `503` (report the deployment problem; `NO_DOWNLOAD_SOURCE`
+ means no mirror can serve the version).
+7. Nothing switches the channel automatically. An unreachable platform is
+ reported after the fallback, and the user switches through the existing
+ selector.
+
+### 3. A stable device identifier, sent as a digest
+
+The resolve request carries a `deviceId` that host-core derives from the machine
+identity the operating system exposes — the Windows
+`HKLM\SOFTWARE\Microsoft\Cryptography\MachineGuid`, the macOS platform UUID, or
+Linux `/etc/machine-id` (falling back to `/var/lib/dbus/machine-id` and
+`/sys/class/dmi/id/product_uuid`). What leaves the machine is
+`sha256("pi-desktop.device.v1:" + <machine id>)` as 64-character lowercase hex,
+never the machine code itself: the platform only needs to compare two requests
+for equality, so it has no use for the code, and a raw hardware identifier in a
+third-party request is a privacy downgrade the counting feature does not
+require. The fixed prefix domain-separates the value from every other hash the
+app computes, so a leaked digest cannot be matched against another digest of the
+same machine.
+
+When no machine identity is readable, host-core generates one random 64-hex id
+on first use and persists it under the application data directory
+(`plugins/market/device.json`), reusing it from then on. Either way the value is
+read once per process, is stable for an installation across restarts, is never
+shown in the UI, and is not a setting. It is a counting and rate-limit key, not
+an account.
+
+### 4. The backup channels and `custom` are unchanged
+
+`github`, `mirror`, and `custom` keep the static relative-URL resolution,
+including `artifactBaseUrl` precedence, the download allowlist, redirect
+re-validation, and shasum verification, byte for byte. The persisted source
+keeps working for existing users, the cache stays keyed by `sourceUrl` so a
+switch ignores rather than deletes another channel's snapshot, and an installed
+record's `providerId` now names the channel it actually came from — already
+installed records are not rewritten.
+
+### 5. Trust tiers follow the trusted channels
+
+`verified` renders as written only from the three project channels (official,
+GitHub backup, CNB backup). `custom` still degrades to `community`, and a v1
+catalog's boolean `verified` mapping is unchanged. The predicate changes from
+"is this the official source" to "is this a trusted channel".
+
+### 6. The download allowlist does not change
+
+The allowlist stays `github.com`, `githubusercontent.com`, `cnb.cool`, and the
+host that served the current catalog. The platform's resolve answers name
+mirrors on exactly those hosts today, so no entry is added. A mirror on any
+other host is refused like any other package URL: the next mirror is tried, and
+if every entry names such a host the install fails instead of widening the list.
+Moving a mirror outside the table is therefore a client-release dependency, not
+a platform-side change.
+
+### 7. An install reports progress, and can be cancelled while it downloads
+
+An install or update is a single request, so a download that takes a minute is
+otherwise indistinguishable from a frozen window. Host-core therefore reports
+where the install is: `plugin.installProgress` carries `pluginId`, `version`,
+`phase` (`resolve`, `download`, `verify`, `install`, `enable`), the mirror in
+use (`source`) with its 1-based `attempt` / `attempts`, `receivedBytes` /
+`totalBytes` (`0` meaning the size is unknown), every mirror tried so far
+(`tried[]`, each `{ source, url, error }`), and `error` on the report that ends
+a failed install. Reports are throttled to at most one per 200 ms, plus one per
+phase change and the terminal report, so byte-level progress cannot flood the
+RPC channel or the interface.
+
+The report goes to the interface rather than only to the log. A log line helps
+an operator afterwards; the person waiting needs to see that the install moved
+on to the second mirror and how far it is. Progress is therefore
+observer-shaped, host-core emits it as a notification, and the RPC layer owns
+the throttle.
+
+`market.cancelInstall { id }` answers `{ cancelled, id }` and cancels only an
+install that is running right now, never a queued or finished one. Cancellation
+is honoured while bytes arrive, before each mirror is tried, and at the last
+safe point before the package is written, so only a download is actually
+interruptible: stopping after the package has been unpacked and the plugin's row
+is being written would leave the plugin directory and the registry in a state
+no later step can describe, which is worse than letting that step finish. A
+cancelled install fails with `PLUGIN_CANCELLED` (code 1019), and the dialog closes quietly instead of reporting an error.
+
+The dialog is for a manual install or update only; a background auto-update
+stays silent. It shows the phase, `mirror n/N · name`, a determinate bar, and a
+cancel button enabled only during `resolve` and `download`; success closes it
+about two seconds after the install finishes, failure keeps it open with the
+readable error, the mirrors that were tried with a copy action, and a retry
+action.
+
+## Consequences
+
+- The official channel gains per-mirror fallback, withdrawal and archive
+ signals, and download counting, and it acquires a dependency: an install asks
+ the platform. The documented catalog-URL fallback and the two backup channels
+ are the mitigation.
+- Per-mirror digest verification becomes the reason a divergent mirror cannot
+ break an install. The measured CNB divergence (`pi.todo-0.6.5` at 92487 bytes
+ versus 92951) is exactly the case this absorbs.
+- A first third-party service now receives an installation-level identifier.
+ Only a digest is sent, the platform stores counts rather than identities, and
+ the privacy policy and the decisions log state it.
+- `429` costs at most one `Retry-After` wait per install; a batch update makes
+ one call per plugin, not one per mirror.
+- An install is no longer opaque: the interface sees the phase, the mirror being
+ tried, and the byte count, and a user can stop a download without leaving a
+ half-installed plugin. The cost is progress notifications on the RPC channel,
+ bounded by the 200 ms throttle and the per-phase reports.
+- No `.piplug` or manifest change, no catalog v1/v2 parsing change, no
+ permission-review change, no storage schema change, no migration of persisted
+ source values, and no change to the two backup install paths.
+- Still open, deliberately: signature verification (optional as before), any
+ automatic channel switching, and the center's own byte route, which stays the
+ marketplace page and console path.
+
+## Rejected alternatives
+
+- **Keep resolving the catalog's declared base on the client only.** The catalog
+ is a static file, so it cannot say which mirrors currently serve a version, it
+ cannot refuse an archived or unpublished plugin, and it is the same list for
+ every install. The client would also keep trusting a publisher-influenced base
+ without any per-mirror signal, and the platform would lose the counting and
+ rate-limit identity its contract depends on.
+- **Send a per-request identifier.** The platform counts one download per
+ device, version, and day and rate-limits per device, so a value that changes
+ per call counts every call as a new installation and degrades the limiter to
+ the source address. The requirement is stability.
+- **Send the raw machine code, or hash it without a prefix.** The platform only
+ compares values, so shipping the code itself would hand a third party a
+ reusable hardware identifier for no functional gain, and an unprefixed digest
+ could be correlated with other digests of the same machine.
+- **Expose the identifier in Settings (show or reset it).** It answers no user
+ question, it invites treating a counting key as an account, and a reset button
+ would silently let one machine inflate the platform's counters. The fallback
+ file is documented instead.
+- **An automatic fallback between channels.** A channel switch changes which
+ catalog, versions, trust verdicts, and bytes the user sees, so doing it
+ silently would attribute an install to a source the user did not choose. The
+ only automatic fallback stays inside the official channel, to the catalog URL
+ that channel served, and it is not counted.
+- **Cache the resolve answer.** The platform marks it `no-store` because mirrors
+ and availability change; a cached answer would pin a dead mirror and could
+ serve a version the platform has since withdrawn.
diff --cc docs/adr/README.md
index 6e3396728,d20428573..6a9f73ee7
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@@ -300,4 -300,9 +300,10 @@@ Each ADR includes
| 0268 | Remove quotes, annotations, and side chats | Accepted (supersedes message-quotes-and-side-chats / response-annotations / floating-annotation-index) |
| 0272 | [Judge a public-network address on the route the request will dial](0272-connection-time-public-network-route.md) | Accepted for implementation (amends ADR 0243; issue #419 / PR #473) |
| 0273 | [Git checkout as a Create project source](0273-git-checkout-create-project-source.md) | Accepted for implementation (amends ADR 0233; ADR 0247) |
- | 0274 | [Official plugin channel and backup channels](0274-official-plugin-channel-and-backup-channels.md) | Accepted for implementation (amends ADR 0102; D438) |
+ | 0274 | [A development plugin is reviewed before it is loaded](0274-development-plugin-permission-review.md) | Accepted for implementation (amends ADR 0005) |
+ | 0275 | [A floating widget placement for plugin panels](0275-plugin-panel-floating-widget.md) | Accepted for implementation (amends ADR 0093 §4; ADR 0092 / ADR 0110) |
+ <!-- In flight on feat/chat-wide-layout: it claims 0274, which main has since taken
+ (development-plugin-permission-review). The branch owner renumbers it when it
+ lands; this row is kept verbatim rather than rewritten here. -->
+ | 0274 | [Draggable chat content width](0274-draggable-chat-content-width.md) | Accepted (D439) |
++| 0276 | [Official plugin channel and backup channels](0276-official-plugin-channel-and-backup-channels.md) | Accepted for implementation (amends ADR 0102; D442) |
diff --cc docs/spec/06-delivery/04-e2e-test-plan.md
index 247333de8,e200e5068..d4c5c29ae
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@@ -12611,72 -12802,3 +12802,72 @@@ plugin-form fixtures in an isolated tem
marked); `packages/shared/src/model-catalog.test.ts` covers the four source rules;
`crates/host-core/src/providers/catalog.rs` covers the config round trip, the
unmarked record, and the dropped unknown marker. The end-to-end settings journey
+#### E2E-PLUGIN-official-channel-resolves-through-the-platform: An official-channel install resolves through the platform and installs from the first working mirror
+
+- **Preconditions**: A clean profile on the official channel, a plugin present in `plugins.aiuo.net/catalog.json`, and a request log for the platform and both mirror hosts (a local stub may stand in for each).
+- **Steps**: 1) Open Extensions → Marketplace and confirm the source line reads Official channel and that the catalog came from `plugins.aiuo.net`. 2) Install the plugin. 3) Capture the request the platform received. 4) Inspect which mirror served the package. 5) Install a second plugin, then install the same version of the first one again.
+- **Expected**: Exactly one `POST /api/v1/download/resolve` is sent per install or update, with a JSON body carrying `deviceId`, `pluginId`, and the version when one was picked; the package comes from the first entry in `downloads` that answers, and its bytes match the returned `sha256` and `sizeBytes` before anything is extracted; a mirror that is unreachable or fails is abandoned and the next one is used without user interaction; reinstalling the same version issues a fresh resolve call rather than reusing the earlier answer, because the response is never cached; the installed plugin passes the ordinary permission review and its record names the official channel as its provider.
+- **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2, `07-plugins/15-plugin-center.md` §10
+- **Acceptance**: G (remote marketplace source)
+- **Milestone**: M6+
+- **Status**: Draft
+
+#### E2E-PLUGIN-mirror-digest-mismatch-falls-through-to-the-next-mirror: A mirror whose bytes fail the digest is rejected before extraction
+
+- **Preconditions**: An official-channel install whose `downloads` list has at least two entries, with the first mirror serving bytes that do not match the returned `sha256` (a stale distribution, or a stub that serves the CNB-era bytes for `pi.todo-0.6.5`), plus a view of the install cache and the plugin directory.
+- **Steps**: 1) Start the install. 2) Watch the first mirror's download and the digest check. 3) Inspect the install cache and the plugin directory before the install finishes. 4) Let the install continue. 5) Repeat with a stub whose first mirror fails only the announced `sizeBytes`.
+- **Expected**: The mismatching bytes are discarded without being extracted or handed to the installer, nothing lands in the plugin directory, and the rejection is reported in the install progress instead of being swallowed; the next mirror's bytes are verified against the same digest and the install completes from there; the size-mismatch case behaves identically; when every entry fails, the install ends as a reported failure rather than a partially installed plugin.
+- **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2
+- **Acceptance**: G (remote marketplace source) + Security
+- **Milestone**: M6+
+- **Status**: Draft
+
+#### E2E-PLUGIN-platform-unreachable-install-falls-back-to-the-catalog-url: An install falls back to the catalog URL when the platform cannot be reached
+
+- **Preconditions**: The official catalog is already cached from a successful refresh, and `plugins.aiuo.net` becomes unreachable for the install (a blocked stub, or a refused DNS/proxy route).
+- **Steps**: 1) Refresh the catalog while the platform is reachable, then make it unreachable. 2) Install a plugin whose catalog entry carries a relative `url`. 3) Confirm which host served the package and whether the platform received a resolve request. 4) Restore reachability and install a version the platform refuses in turn with `403 NOT_PUBLISHED`, `403 PLUGIN_ARCHIVED`, `404`, `429`, and `503`.
+- **Expected**: The install resolves the package from the catalog's own URL — `artifactBaseUrl` plus the relative `url` — and completes after the same shasum verification; no resolve request reaches the platform for that install and the fallback install is not counted; the failed resolve call is visible in the install log instead of being hidden; once the platform answers again each refusal produces its own message — not-published with no retry, archived hiding the plugin from install and update selection, not-found, one `Retry-After` wait for the rate limit, and a deployment error for `503` — and no refusal silently switches to another channel or another version.
+- **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2
+- **Acceptance**: G (remote marketplace source)
+- **Milestone**: M6+
+- **Status**: Draft
+
+#### E2E-PLUGIN-device-identifier-is-stable-and-never-the-machine-code: The device identifier is stable across launches and is not the raw machine code
+
+- **Preconditions**: A host whose machine identifier is readable (Windows `MachineGuid`, the macOS platform UUID, or `/etc/machine-id`), a second environment where it is not readable, and a request-logging stub for `POST /api/v1/download/resolve`.
+- **Steps**: 1) Trigger two installs in one session and compare the recorded `deviceId` values. 2) Restart the app and trigger a third install. 3) Compare the value with the raw machine identifier of the host. 4) Search the settings, the Marketplace surface, and the installed-plugin detail view for the value. 5) Repeat steps 1 and 2 where no machine identifier is readable, then inspect the application data directory.
+- **Expected**: Every resolve request from one installation carries the same 64-character lowercase hex value, including after a restart and after an app reinstall while the machine identifier is unchanged; the value is neither the machine code nor a prefix of it, and it equals `sha256("pi-desktop.device.v1:" + <machine identifier>)`; the identifier never appears in the UI and no setting can reveal or reset it; in the unreadable case the value is a different 64-hex string that is generated once and persisted under `plugins/market/device.json`, then repeated across restarts.
- - **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2, ADR 0274
++- **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2, ADR 0276
+- **Acceptance**: G (remote marketplace source) + Security
+- **Milestone**: M6+
+- **Status**: Draft
+
+#### E2E-PLUGIN-install-progress-shows-phases-and-mirror: An official-channel install reports its phases and the mirror it is using, then completes
+
+- **Preconditions**: A clean profile on the official channel, a plugin whose resolve answer lists at least two entries, a first mirror that fails or is slow so a second attempt is observable, and a renderer subscribed to `plugin.installProgress`.
+- **Steps**: 1) Start a manual install from the marketplace detail sheet. 2) Record the reports that arrive while it runs. 3) Hover the dialog after the install succeeds. 4) Look at the installed plugin once the install ends. 5) Install again with a large package and count the reports over a window of at least one second.
+- **Expected**: The dialog shows the phases in order — `resolve`, `download`, `verify`, `install`, `enable` — with `mirror n/N · name` and a determinate bar from `receivedBytes` / `totalBytes`; every report carries `pluginId` and `version`, only the report that names a mirror carries `source`, and `attempt` counts 1-based within `attempts` while a mirror switch increments `attempt` without changing `attempts`; byte reports arrive at most once per 200 ms, with one extra report per phase change and one terminal report; the install ends with no `error` and the plugin is installed and enabled after the ordinary permission review; the dialog closes about two seconds after success, that countdown pauses while it is hovered, and a background auto-update installs the same way without opening the dialog at all.
- - **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2, `07-plugins/15-plugin-center.md` §10, ADR 0274 §7
++- **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2, `07-plugins/15-plugin-center.md` §10, ADR 0276 §7
+- **Acceptance**: G (remote marketplace source)
+- **Milestone**: M6+
+- **Status**: Draft
+
+#### E2E-PLUGIN-cancel-during-download-installs-nothing: Cancelling during the download stops the install, leaves nothing installed, and closes the dialog without an error
+
+- **Preconditions**: An official-channel install of a package large enough or a mirror slow enough that the download phase lasts, a way to answer `market.cancelInstall`, and a view of the plugin directory, the install cache, and the Installed list.
+- **Steps**: 1) Start the install and wait for the download phase. 2) Press the cancel action in the dialog. 3) Watch the dialog and capture the RPC answer. 4) Inspect the plugin directory, the install cache, and the Installed list after the install ends. 5) Send `market.cancelInstall` again for the same id, for an install that is not running, and once after the download has finished.
+- **Expected**: The cancel call answers `{ cancelled: true, id }` for the running install, and the install fails with `PLUGIN_CANCELLED` (JSON-RPC code 1019); the dialog closes without reporting an error; nothing is installed — no plugin directory, no installed row, no enabled plugin — and no partial package survives in the cache; the second call for the same id, the call for an install that is not running, and a call after the download finished answer `{ cancelled: false, id }` and change nothing, so a cancel can never interrupt the write of the plugin directory.
- - **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2, ADR 0274 §7
++- **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2, ADR 0276 §7
+- **Acceptance**: G (remote marketplace source) + Security
+- **Milestone**: M6+
+- **Status**: Draft
+
+#### E2E-PLUGIN-failed-install-lists-tried-mirrors: A failed install keeps the dialog open and lists the mirrors it tried with a copy action
+
+- **Preconditions**: An official-channel install whose every mirror fails — for example a digest mismatch on the first and a network error on the second — with a renderer subscribed to `plugin.installProgress` and a clipboard readback.
+- **Steps**: 1) Start the install. 2) Let every mirror fail. 3) Read the terminal report and the dialog. 4) Use the copy action, then the retry action once the mirrors serve valid bytes again.
+- **Expected**: The terminal report carries `error` and a `tried[]` entry per mirror in the order they were tried, each naming its `source`, `url`, and the error that mirror answered; the dialog stays open and shows the readable error plus that list; the copy action puts the tried mirrors on the clipboard; the retry action starts a new install of the same version and completes it when the mirrors answer, without reusing the failed attempt's partial state; nothing was installed by the failed attempt.
- - **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2, ADR 0274 §7
++- **Specs linked**: `07-plugins/07-plugin-marketplace.md` §2, ADR 0276 §7
+- **Acceptance**: G (remote marketplace source)
+- **Milestone**: M6+
+- **Status**: Draft
diff --cc docs/spec/08-meta/decisions-log.md
index 74923526c,d7bf84fb5..573173397
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@@ -112,7 -112,6 +112,7 @@@ This log freezes previously open questi
| D341 | Per-provider custom HTTP headers | **Amend D339 / ADR 0176: each AI-service and OAuth row stores optional `config_json.headers`. Empty / `{}` keeps adapter defaults. A non-empty map is last-writer on that row's outbound HTTP (turns, subagents, one-shots, discovery, connection test, OAuth refresh) via a fetch wrapper plus stream-option headers. Leftover `userAgent` migrates to `headers["User-Agent"]`. Max 32 headers; key ≤ 256 bytes; value ≤ 4096 bytes; no CR/LF; reserved auth/hop-by-hop/routing keys rejected. Compact KeyValueRows Advanced UI; first OAuth login does not collect headers. `matches()` includes the map. No schema/protocol bump.** | Users needed arbitrary non-secret headers, not only User-Agent. See ADR 0178 and E2E-005G. |
| D242 | Builtin subagents inherit the parent permission mode | **Builtin subagents use the default `permission: inherit` behavior. The builtin `fixer` no longer overrides the parent session, so `auto` covers its in-root and explicit external-path calls without a second authorization card; explicit non-`inherit` scopes on eligible builtin or user definitions remain intentional overrides.** | The observed popup came from the builtin `fixer` replacing an `auto` parent with `accept-edits`; inheriting the parent fixes the UX without weakening host-core containment or external-path permission rules (ADR 0100). |
| D241 | Titled Settings navigation clusters | **Keep the eight-destination Settings directory flat and searchable, but render four non-interactive localized group headings — Personal / 个人 (Basics, AI, Shortcuts), Agent / 智能体 (Instructions, Model configuration), Workspace / 工作区 (Import, Project archive), and About / 关于 (Info). Headings use whitespace for separation and no divider lines. Empty groups disappear with filtered search. This supersedes only D238's prohibition on group headings; destination order, IDs, search ownership, and marketplace placement remain unchanged.** | The flat rows became visually dense without scan landmarks. Muted headings restore grouping while preserving one-level navigation and the existing destination ownership. |
- | D438 | Marketplace download requests carry a device identifier | **Amend D238: the official plugin channel resolves every install and update through `POST /api/v1/download/resolve` and sends a stable `deviceId` — the SHA-256 digest of a platform machine identifier, or a locally persisted random id when none is readable. The client tries the returned mirrors in order, verifies `sha256` and `sizeBytes` before extracting, never caches the answer, and falls back to the catalog's own package URL only when the platform could not be reached. The GitHub and CNB backup channels and `custom` keep the existing static relative-URL resolution. See ADR 0274 and E2E-PLUGIN-official-channel-resolves-through-the-platform.** | The platform needs one stable installation identity to count a download once and to rate-limit per device instead of per source address; the value is a digest, so no machine code leaves the machine, and no new UI surface is introduced. |
++| D442 | Marketplace download requests carry a device identifier | **Amend D238: the official plugin channel resolves every install and update through `POST /api/v1/download/resolve` and sends a stable `deviceId` — the SHA-256 digest of a platform machine identifier, or a locally persisted random id when none is readable. The client tries the returned mirrors in order, verifies `sha256` and `sizeBytes` before extracting, never caches the answer, and falls back to the catalog's own package URL only when the platform could not be reached. The GitHub and CNB backup channels and `custom` keep the existing static relative-URL resolution. See ADR 0276 and E2E-PLUGIN-official-channel-resolves-through-the-platform.** | The platform needs one stable installation identity to count a download once and to rate-limit per device instead of per source address; the value is a digest, so no machine code leaves the machine, and no new UI surface is introduced. |
## D. Codex visual parity decisions (0.3.5+)
diff --cc docs/zh-CN/adr/index.md
index 46d03604a,22ea64fa6..3366eb2ed
--- a/docs/zh-CN/adr/index.md
+++ b/docs/zh-CN/adr/index.md
@@@ -286,7 -286,6 +286,7 @@@ ADR 记录那些不应被静默改变�
| 0265 | [排队队列的优先区块与行内操作](/adr/0265-turn-queue-priority-block-and-row-actions) | 已接受待实现(修订 ADR 0213 / 0118) |
| 0267 | [插件标签跟随应用语言](/adr/0267-plugin-labels-follow-the-app-language) | 已接受(修订 ADR 0160;ADR 0182) |
| 0272 | [按请求实际会走的线路判定公网地址](/adr/0272-connection-time-public-network-route) | 已接受待实现(修订 ADR 0243;issue #419 / PR #473) |
- | 0274 | [官方插件渠道与备份渠道](/adr/0274-official-plugin-channel-and-backup-channels) | 已接受待实现(修订 ADR 0102;D438) |
++| 0276 | [官方插件渠道与备份渠道](/adr/0276-official-plugin-channel-and-backup-channels) | 已接受待实现(修订 ADR 0102;D442) |
## 什么时候看 ADR
diff --cc docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 3bce92628,8400d4cff..7f88d7c14
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@@ -7543,72 -7646,3 +7646,72 @@@ runner 会在运行时的隔离临时�
目录、继承值保持 `catalog` 标记);`packages/shared/src/model-catalog.test.ts` 覆盖
四条来源规则;`crates/host-core/src/providers/catalog.rs` 覆盖配置往返、无标记记录与
被丢弃的未知标记。端到端的设置旅程与实际启动窗口断言为草稿。
+#### E2E-PLUGIN-official-channel-resolves-through-the-platform:官方渠道的安装通过平台解析,并从第一个可用镜像安装
+
+- **先决条件**:全新配置停留在官方渠道;`plugins.aiuo.net/catalog.json` 中存在一个插件;平台与两个镜像主机各有请求日志(可用本地存根代替)。
+- **步骤**:1) 打开扩展 → 市场,确认来源行显示官方渠道,且目录来自 `plugins.aiuo.net`。 2) 安装该插件。 3) 抓取平台收到的请求。 4) 检查是哪个镜像提供了安装包。 5) 再安装第二个插件,然后重新安装第一个插件的同一版本。
+- **预期**:每次安装或更新只发出一次 `POST /api/v1/download/resolve`,JSON body 含 `deviceId`、`pluginId`,用户选定版本时含版本号;安装包来自 `downloads` 中第一个可应答的条目,且在解压之前其字节与返回的 `sha256` 和 `sizeBytes` 一致;不可达或失败的镜像被放弃并自动尝试下一个,无需用户操作;重新安装同一版本会发出新的 resolve 调用,而不是复用上一次的应答,因为响应从不缓存;插件通过常规权限审查安装,其记录标明来源为官方渠道。
+- **链接规格**:`07-plugins/07-plugin-marketplace.md` §2、`07-plugins/15-plugin-center.md` §10
+- **验收**:G(远程市场来源)
+- **里程碑**:M6+
+- **状态**:草稿
+
+#### E2E-PLUGIN-mirror-digest-mismatch-falls-through-to-the-next-mirror:字节与摘要不符的镜像在解压前被拒绝
+
+- **先决条件**:一次官方渠道安装,其 `downloads` 至少有两个条目,第一个镜像提供的字节与返回的 `sha256` 不符(旧分发内容,或提供 `pi.todo-0.6.5` 的 CNB 时代字节的存根);同时可以查看安装缓存与插件目录。
+- **步骤**:1) 启动安装。 2) 观察第一个镜像的下载与摘要校验。 3) 在安装结束前检查安装缓存与插件目录。 4) 让安装继续。 5) 换成一个只在第一个镜像上让声明的 `sizeBytes` 不符的存根重做一遍。
+- **预期**:不符的字节被丢弃,不会被解压或交给安装器,插件目录里不会留下任何内容,拒绝会显示在安装进度里而不是被吞掉;下一个镜像的字节按同一摘要校验,安装从那里完成;大小不符的情形表现完全相同;所有条目都失败时安装以明确的失败结束,而不是留下半安装的插件。
+- **链接规格**:`07-plugins/07-plugin-marketplace.md` §2
+- **验收**:G(远程市场来源)+ 安全性
+- **里程碑**:M6+
+- **状态**:草稿
+
+#### E2E-PLUGIN-platform-unreachable-install-falls-back-to-the-catalog-url:平台不可达时安装回退到目录地址
+
+- **先决条件**:官方目录已成功刷新并缓存;安装期间 `plugins.aiuo.net` 不可达(被阻断的存根,或被拒绝的 DNS/代理线路)。
+- **步骤**:1) 在平台可达时刷新目录,然后让它不可达。 2) 安装一个目录条目里带相对 `url` 的插件。 3) 确认是哪个主机提供了安装包,以及平台是否收到 resolve 请求。 4) 恢复可达后,依次安装平台分别以 `403 NOT_PUBLISHED`、`403 PLUGIN_ARCHIVED`、`404`、`429` 和 `503` 拒绝的版本。
+- **预期**:安装从目录自身的地址解析安装包——`artifactBaseUrl` 加相对 `url`——并在同样的 shasum 校验之后完成;该次安装不会向平台发出 resolve 请求,也不计入统计;resolve 失败的原因会出现在安装日志里而不是被隐藏;平台恢复应答后,各拒绝码各自给出对应的提示——尚未发布不重试、已归档会从安装与更新选择中隐藏该插件、平台没有该版本、限流按 `Retry-After` 等待一次、`503` 报部署问题——并且任何拒绝都不会静默切到别的渠道或别的版本。
+- **链接规格**:`07-plugins/07-plugin-marketplace.md` §2
+- **验收**:G(远程市场来源)
+- **里程碑**:M6+
+- **状态**:草稿
+
+#### E2E-PLUGIN-device-identifier-is-stable-and-never-the-machine-code:设备标识跨启动稳定,且不是机器码原文
+
+- **先决条件**:一个能读到机器标识的主机(Windows `MachineGuid`、macOS 平台 UUID,或 `/etc/machine-id`),一个读不到机器标识的环境,以及为 `POST /api/v1/download/resolve` 记录请求的存根。
+- **步骤**:1) 在同一会话内触发两次安装,比较记录的 `deviceId`。 2) 重启应用后再触发一次安装。 3) 把该值与主机的机器标识原文比较。 4) 在设置、市场页面与已安装插件详情中查找该值。 5) 在读不到机器标识的环境里重复步骤 1 与 2,然后检查应用数据目录。
+- **预期**:同一安装发出的每次 resolve 请求都携带同一个 64 位小写十六进制值,包括重启之后,以及机器标识未变时的应用重装之后;该值既不是机器码原文也不是它的前缀,并等于 `sha256("pi-desktop.device.v1:" + 机器标识)`;该标识从不出现在界面上,也没有任何设置可以显示或重置它;读不到机器标识时,该值是另一个 64 位十六进制字符串,只生成一次并持久化在 `plugins/market/device.json`,之后跨重启一直复用。
- - **链接规格**:`07-plugins/07-plugin-marketplace.md` §2、ADR 0274
++- **链接规格**:`07-plugins/07-plugin-marketplace.md` §2、ADR 0276
+- **验收**:G(远程市场来源)+ 安全性
+- **里程碑**:M6+
+- **状态**:草稿
+
+#### E2E-PLUGIN-install-progress-shows-phases-and-mirror:官方渠道安装显示各阶段与正在尝试的镜像并完成
+
+- **先决条件**:全新配置停留在官方渠道;一个插件的 resolve 应答至少列出两个条目;第一个镜像失败或很慢,以便观察到第二次尝试;渲染进程已订阅 `plugin.installProgress`。
+- **步骤**:1) 从市场详情面板发起一次手动安装。 2) 记录安装期间收到的报告。 3) 安装成功后把指针悬停在对话框上。 4) 安装结束后查看已安装插件。 5) 用一个较大的安装包再次安装,并统计至少一秒窗口内的报告数量。
+- **预期**:对话框按顺序显示各阶段——`resolve`、`download`、`verify`、`install`、`enable`——以及 `mirror n/N · name` 和由 `receivedBytes` / `totalBytes` 得出的确定进度条;每条报告都带 `pluginId` 与 `version`,只有指明镜像的报告才带 `source`,`attempt` 按 1 在 `attempts` 内计数,切换镜像会递增 `attempt` 而不改变 `attempts`;字节报告最多每 200 ms 一条,另有每次阶段变化一条与最终一条;安装以不带 `error` 的状态结束,插件通过常规权限审查后完成安装并启用;成功后对话框约 2 秒自动关闭,悬停时该倒计时暂停;后台自动更新以同样方式安装,但完全不打开对话框。
- - **链接规格**:`07-plugins/07-plugin-marketplace.md` §2、`07-plugins/15-plugin-center.md` §10、ADR 0274 §7
++- **链接规格**:`07-plugins/07-plugin-marketplace.md` §2、`07-plugins/15-plugin-center.md` §10、ADR 0276 §7
+- **验收**:G(远程市场来源)
+- **里程碑**:M6+
+- **状态**:草稿
+
+#### E2E-PLUGIN-cancel-during-download-installs-nothing:在下载期间取消会停止安装、不留下任何已安装内容,并让对话框静默关闭
+
+- **先决条件**:一次官方渠道安装,其安装包足够大或镜像足够慢,使下载阶段持续一段时间;能够应答 `market.cancelInstall`;同时可以查看插件目录、安装缓存与已安装列表。
+- **步骤**:1) 启动安装并等待进入下载阶段。 2) 按下对话框中的取消操作。 3) 观察对话框并抓取 RPC 应答。 4) 安装结束后检查插件目录、安装缓存与已安装列表。 5) 对同一 id、对一个并未在运行的安装,以及在下载已结束之后,分别再次发出 `market.cancelInstall`。
+- **预期**:对正在运行的安装,取消调用返回 `{ cancelled: true, id }`,安装以 `PLUGIN_CANCELLED`(JSON-RPC 码 1019)失败;对话框不报告错误就关闭;没有任何东西被安装——没有插件目录、没有已安装行、没有已启用的插件——缓存中也不残留任何不完整的安装包;对同一 id 的第二次调用、对并未在运行的安装的调用,以及下载已结束之后的调用都返回 `{ cancelled: false, id }` 且不改变任何状态,因此取消永远不会中断插件目录的写入。
- - **链接规格**:`07-plugins/07-plugin-marketplace.md` §2、ADR 0274 §7
++- **链接规格**:`07-plugins/07-plugin-marketplace.md` §2、ADR 0276 §7
+- **验收**:G(远程市场来源)+ 安全性
+- **里程碑**:M6+
+- **状态**:草稿
+
+#### E2E-PLUGIN-failed-install-lists-tried-mirrors:安装失败时对话框保持打开,并列出尝试过的镜像与复制操作
+
+- **先决条件**:一次官方渠道安装,其所有镜像都失败——例如第一个摘要不符、第二个网络错误;渲染进程已订阅 `plugin.installProgress`,且可以读回剪贴板。
+- **步骤**:1) 启动安装。 2) 让所有镜像失败。 3) 读取最终报告与对话框。 4) 使用复制操作,然后在镜像恢复正常后使用重试操作。
+- **预期**:最终报告带有 `error`,并按尝试顺序为每个镜像提供一条 `tried[]` 记录,各自标明 `source`、`url` 与该镜像给出的错误;对话框保持打开,显示可读的错误与这份列表;复制操作把尝试过的镜像放入剪贴板;重试操作会对同一版本发起一次新的安装,并在镜像正常应答后完成,且不会复用失败尝试的不完整状态;失败的尝试没有安装任何东西。
- - **链接规格**:`07-plugins/07-plugin-marketplace.md` §2、ADR 0274 §7
++- **链接规格**:`07-plugins/07-plugin-marketplace.md` §2、ADR 0276 §7
+- **验收**:G(远程市场来源)
+- **里程碑**:M6+
+- **状态**:草稿
diff --cc docs/zh-CN/spec/08-meta/decisions-log.md
index 2c9484b0c,d06e54bcc..d33547271
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@@ -115,7 -115,6 +115,7 @@@
| D242 | 内置子智能体继承父会话权限模式 | **内置子智能体默认使用 `permission: inherit`。内置 `fixer` 不再覆盖父会话,因此 `auto` 会覆盖其工作区内和明确外部路径调用,避免第二张授权卡;合格的内置或用户定义仍可显式声明非 `inherit` scope。** | 观察到的弹窗来自内置 `fixer` 将 `auto` 父会话替换为 `accept-edits`;继承父会话可以修复体验,同时不削弱 host-core 的 containment 和外部路径权限规则(ADR 0100)。 |
| D241 | 带标题的设置导航视觉分组 | **设置目录保持八个目的地、扁平且可搜索,但显示四个非交互式本地化分组标题:Personal / 个人(基础、全局 AI、快捷键)、Agent / 智能体(说明、模型配置)、Workspace / 工作区(导入、项目存档)和 About / 关于(信息)。标题之间使用留白,不绘制分割线。搜索过滤时,空分组及其标题一并消失。本决策仅覆盖 D238 对分组标题的禁止,不改变目的地顺序、ID、搜索归属或市场位置。** | 扁平行缺少扫描锚点,视觉上过于紧密。柔和标题可以恢复分组,同时保持单层导航和既有目的地归属。 |
- | D438 | 市场下载请求携带设备标识 | **修订 D238:官方插件渠道的每次安装与更新都通过 `POST /api/v1/download/resolve` 解析并携带稳定的 `deviceId` —— 平台机器标识的 SHA-256 摘要,读不到机器标识时为本地持久化的随机 ID。客户端按顺序尝试返回的镜像,解压前校验 `sha256` 与 `sizeBytes`,从不缓存响应,只在平台不可达时回退到目录自身的包地址。GitHub 与 CNB 两个备份渠道以及 `custom` 继续沿用现有的静态相对 URL 解析。见 ADR 0274 与 E2E-PLUGIN-official-channel-resolves-through-the-platform。** | 平台需要一个稳定的安装标识,才能把一次下载只计一次,并按设备而不是按来源地址限流;上报的是摘要,因此机器码不出本机,也不新增任何界面入口。 |
++| D442 | 市场下载请求携带设备标识 | **修订 D238:官方插件渠道的每次安装与更新都通过 `POST /api/v1/download/resolve` 解析并携带稳定的 `deviceId` —— 平台机器标识的 SHA-256 摘要,读不到机器标识时为本地持久化的随机 ID。客户端按顺序尝试返回的镜像,解压前校验 `sha256` 与 `sizeBytes`,从不缓存响应,只在平台不可达时回退到目录自身的包地址。GitHub 与 CNB 两个备份渠道以及 `custom` 继续沿用现有的静态相对 URL 解析。见 ADR 0276 与 E2E-PLUGIN-official-channel-resolves-through-the-platform。** | 平台需要一个稳定的安装标识,才能把一次下载只计一次,并按设备而不是按来源地址限流;上报的是摘要,因此机器码不出本机,也不新增任何界面入口。 |
## D. 法典视觉平等决策 (0.3.5+)