Skip to main content

bamboo_plugin/
registry.rs

1//! Provenance registry: `~/.bamboo/plugins/installed.json`.
2//!
3//! Records, for each installed plugin, EXACTLY what it registered (which
4//! `mcpServers` ids, which skill dir names, which prompt preset ids, which
5//! workflow filenames) so uninstall/upgrade can precisely undo only what a
6//! given plugin added — never touching a user's own hand-added entries that
7//! happen to share a config file with plugin-registered ones.
8//!
9//! This module only defines the schema + load/save/add/remove helpers. Wiring
10//! *when* to call `add`/`remove` relative to actually registering/
11//! deregistering capabilities (MCP servers, prompt presets, workflow files)
12//! is the installer's job (see [`crate::installer`] and `PLUGIN_PLAN.md`).
13
14use std::collections::HashSet;
15use std::path::{Path, PathBuf};
16
17use chrono::{DateTime, Utc};
18use serde::{Deserialize, Serialize};
19use tokio::fs;
20
21use crate::error::{PluginError, PluginResult};
22
23/// Where a plugin's installed bundle came from. Recorded verbatim so
24/// `update`/reinstall can re-fetch from the same place.
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26#[serde(tag = "type", rename_all = "snake_case")]
27pub enum PluginSource {
28    /// Installed from a local directory (copied or referenced in place — the
29    /// installer decides which; either way this records the ORIGINAL path the
30    /// user pointed at, not necessarily `plugin_dir`).
31    LocalDir { path: PathBuf },
32    /// Installed by unpacking a local `.tar.gz` archive.
33    LocalArchive { path: PathBuf },
34    /// Installed by fetching a URL. Three trust layers, all enforced by
35    /// `bamboo-server`'s `plugin_source.rs` before this record is written:
36    ///
37    /// 1. **Host allowlist** (source authorization) — was the URL's host
38    ///    fetched from an operator-trusted host (`allow_untrusted_host` opts
39    ///    out).
40    /// 2. **Signature** (publisher authenticity) — did the bundle's `.sig`
41    ///    verify against a trusted ed25519 key (`signed_by`; `allow_unsigned`
42    ///    opts out of requiring one).
43    /// 3. **Checksum** (integrity) — `sha256` is the user-verified hash of
44    ///    the downloaded BUNDLE (the `plugin.json`, or the archive containing
45    ///    it) — `Some` in the normal case, confirmed against a
46    ///    caller-supplied expected hash BEFORE anything was
47    ///    extracted/trusted.
48    ///
49    /// `sha256` is `None` either when the install explicitly opted out of
50    /// checksum verification (`allow_unverified: true`, no hash supplied), OR
51    /// when a verified signature (`signed_by: Some(_)`) already established
52    /// integrity+authenticity more strongly than a pasted checksum could —
53    /// see `plugin_source.rs`'s module docs for why a valid signature
54    /// supersedes the checksum requirement. An install refuses outright
55    /// rather than silently trusting an unpinned/unsigned download from an
56    /// untrusted host, so every `None`/`false` combination here always means
57    /// a deliberate, recorded risk acceptance, never an oversight.
58    Url {
59        url: String,
60        #[serde(default, skip_serializing_if = "Option::is_none")]
61        sha256: Option<String>,
62        /// Recorded for audit: true when this install ran with
63        /// `allow_unverified` and no `sha256`. `#[serde(default)]` so a
64        /// pre-existing `installed.json` row (written before this field
65        /// existed, back when only the per-platform binary artifact was
66        /// pinned) loads as `false` rather than failing to deserialize.
67        #[serde(default, skip_serializing_if = "is_false")]
68        allow_unverified: bool,
69        /// Recorded for audit: true when this install ran with
70        /// `allow_untrusted_host` against a host outside
71        /// `plugin_trust.trusted_hosts`. `#[serde(default)]` for backward
72        /// compat with rows written before this field existed.
73        #[serde(default, skip_serializing_if = "is_false")]
74        allow_untrusted_host: bool,
75        /// Recorded for audit: true when this install ran with
76        /// `allow_unsigned` (no valid signature from a trusted key).
77        /// `#[serde(default)]` for backward compat.
78        #[serde(default, skip_serializing_if = "is_false")]
79        allow_unsigned: bool,
80        /// The label of the `plugin_trust.trusted_keys` entry the bundle's
81        /// `.sig` verified against, or `None` if the install proceeded
82        /// unsigned (`allow_unsigned: true`). `#[serde(default)]` for
83        /// backward compat with rows written before signing existed.
84        #[serde(default, skip_serializing_if = "Option::is_none")]
85        signed_by: Option<String>,
86    },
87}
88
89/// `skip_serializing_if` helper for a `bool` field that should be omitted
90/// from the JSON when `false` (serde has no built-in equivalent of
91/// `std::ops::Not::not` that takes a reference).
92fn is_false(value: &bool) -> bool {
93    !*value
94}
95
96/// Exactly what an installed plugin registered into Bamboo's shared capability
97/// stores. Every id/name here MUST have actually been written by the
98/// installer for THIS plugin — never a superset (that would risk clobbering
99/// or removing a user's own entries on uninstall) and never a subset
100/// (uninstall would leak orphaned registrations).
101#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
102pub struct RegisteredCapabilities {
103    /// Ids registered into `config.json`'s `mcpServers` map.
104    #[serde(default, skip_serializing_if = "Vec::is_empty")]
105    pub mcp_server_ids: Vec<String>,
106    /// Directory names under `<plugin_dir>/skills/` that are valid skill
107    /// dirs (contain `SKILL.md`) and are therefore discoverable in place.
108    #[serde(default, skip_serializing_if = "Vec::is_empty")]
109    pub skill_dirs: Vec<String>,
110    /// Ids appended into `prompt-presets.json`.
111    #[serde(default, skip_serializing_if = "Vec::is_empty")]
112    pub preset_ids: Vec<String>,
113    /// Filenames copied into `bamboo_config::paths::workflows_dir()`.
114    #[serde(default, skip_serializing_if = "Vec::is_empty")]
115    pub workflow_filenames: Vec<String>,
116}
117
118impl RegisteredCapabilities {
119    pub fn is_empty(&self) -> bool {
120        self.mcp_server_ids.is_empty()
121            && self.skill_dirs.is_empty()
122            && self.preset_ids.is_empty()
123            && self.workflow_filenames.is_empty()
124    }
125
126    /// The capabilities present in `old` (a prior install's registered set)
127    /// but ABSENT from `self` (the set the new/upgraded install will register).
128    ///
129    /// These are exactly the entries an in-place upgrade must DE-register:
130    /// their ids/filenames vanish from provenance across the upgrade, so if
131    /// they are not actively removed here they leak — orphaned forever,
132    /// un-removable because no future uninstall knows they were ours. See the
133    /// upgrade sequence in [`crate::installer`] / `PLUGIN_PLAN.md`.
134    ///
135    /// Order-preserving relative to `old` (stable output for diffing/logging).
136    pub fn removed_since(&self, old: &RegisteredCapabilities) -> RegisteredCapabilities {
137        RegisteredCapabilities {
138            mcp_server_ids: subtract(&old.mcp_server_ids, &self.mcp_server_ids),
139            skill_dirs: subtract(&old.skill_dirs, &self.skill_dirs),
140            preset_ids: subtract(&old.preset_ids, &self.preset_ids),
141            workflow_filenames: subtract(&old.workflow_filenames, &self.workflow_filenames),
142        }
143    }
144}
145
146/// Elements of `from` not present in `remove`, preserving `from`'s order.
147fn subtract(from: &[String], remove: &[String]) -> Vec<String> {
148    let drop: HashSet<&str> = remove.iter().map(String::as_str).collect();
149    from.iter()
150        .filter(|value| !drop.contains(value.as_str()))
151        .cloned()
152        .collect()
153}
154
155/// Ownership classification of one declared capability id/filename against a
156/// shared store, for the REFUSE-on-conflict capability kinds (MCP servers,
157/// workflow files). Prompt presets do NOT use this — they rename on collision
158/// via bamboo-server's `ensure_unique_preset_id` instead.
159#[derive(Debug, Clone, Copy, PartialEq, Eq)]
160pub enum Ownership {
161    /// Not present in the shared store — safe to create AND record as
162    /// plugin-owned/removable.
163    New,
164    /// Present, and registered by THIS plugin's prior install — an upgrade
165    /// re-registering its own entry. Safe; stays recorded as plugin-owned.
166    OwnedReinstall,
167    /// Present and NOT owned by this plugin (a user's own entry, or another
168    /// plugin's). Must block the install — never recorded as removable.
169    ForeignConflict,
170}
171
172/// Classify one id against the shared store's current `existing` ids and the
173/// `owned_previously` ids that THIS plugin's prior install registered.
174pub fn classify_ownership(
175    id: &str,
176    existing: &HashSet<&str>,
177    owned_previously: &HashSet<&str>,
178) -> Ownership {
179    if !existing.contains(id) {
180        Ownership::New
181    } else if owned_previously.contains(id) {
182        Ownership::OwnedReinstall
183    } else {
184        Ownership::ForeignConflict
185    }
186}
187
188/// Result of reconciling a plugin's declared ids/filenames against a shared
189/// store for a REFUSE-on-conflict capability (MCP servers, workflow files).
190#[derive(Debug, Clone, Default, PartialEq, Eq)]
191pub struct ExclusiveReconciliation {
192    /// Genuinely-new plus this-plugin's-own-from-a-prior-install: register
193    /// these and record them as plugin-owned/removable in provenance.
194    pub to_register: Vec<String>,
195    /// Foreign collisions (exist, not owned by this plugin). If this is
196    /// non-empty the caller MUST refuse the install (return
197    /// [`PluginError::Conflict`]) — do not register or record any of these.
198    pub foreign_conflicts: Vec<String>,
199}
200
201/// Reconcile `declared` ids against the shared store for a REFUSE-on-conflict
202/// capability. `existing` = every id currently in the shared store;
203/// `owned_previously` = the ids THIS plugin's prior install recorded (empty
204/// for a fresh install). Pure — the caller supplies the store state (which,
205/// for MCP/workflows, only the app layer can read).
206///
207/// This is the pre-check that closes BLOCKER 1: a pre-existing collision with
208/// a non-plugin entry lands in `foreign_conflicts`, so it is NEVER registered
209/// and NEVER recorded as removable — uninstall can therefore only ever delete
210/// entries this plugin genuinely created.
211pub fn reconcile_exclusive(
212    declared: &[String],
213    existing: &[String],
214    owned_previously: &[String],
215) -> ExclusiveReconciliation {
216    let existing_set: HashSet<&str> = existing.iter().map(String::as_str).collect();
217    let owned_set: HashSet<&str> = owned_previously.iter().map(String::as_str).collect();
218
219    let mut result = ExclusiveReconciliation::default();
220    for id in declared {
221        match classify_ownership(id, &existing_set, &owned_set) {
222            Ownership::New | Ownership::OwnedReinstall => result.to_register.push(id.clone()),
223            Ownership::ForeignConflict => result.foreign_conflicts.push(id.clone()),
224        }
225    }
226    result
227}
228
229/// Lifecycle status of a provenance row — the crash-safety journal marker.
230///
231/// The installer writes a row as [`Self::Installing`] BEFORE it begins
232/// registering capabilities (MCP into `config.json`, prompts, workflow files),
233/// and flips it to [`Self::Installed`] only after the whole sequence succeeds.
234/// A row left [`Self::Installing`] therefore marks an install that was
235/// interrupted (a hard process kill mid-install): its `registered` set names
236/// what the install INTENDED to own, so on the next install/upgrade of that id
237/// the installer can (a) treat the leftover as this-plugin-owned — so the
238/// ownership pre-check doesn't false-`Conflict` on the plugin's own
239/// half-written entries — and (b) clean it up as an upgrade-over-incomplete.
240/// `uninstall` works on an `Installing` row too, so a user is never stranded
241/// having to hand-edit `config.json`.
242#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
243#[serde(rename_all = "snake_case")]
244pub enum PluginInstallStatus {
245    /// A crash-safety journal marker: capability registration has begun but
246    /// not yet completed. `registered` records the INTENDED ownership set.
247    Installing,
248    /// The steady state: registration completed and provenance is authoritative.
249    /// The [`Default`] so a pre-journal `installed.json` (no `status` field)
250    /// deserializes as a completed install (backward compat).
251    #[default]
252    Installed,
253}
254
255/// A single installed plugin's provenance record.
256#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
257pub struct InstalledPlugin {
258    pub id: String,
259    /// The manifest `version` at the time of this install/upgrade.
260    pub version: String,
261    pub source: PluginSource,
262    /// `~/.bamboo/plugins/<id>` — where the plugin's own files live.
263    pub plugin_dir: PathBuf,
264    /// Caller-supplied timestamp (NOT computed internally — see module docs
265    /// on why: keeps this crate free of a hidden `Utc::now()` call so tests
266    /// and callers stay in full control of "when").
267    pub installed_at: DateTime<Utc>,
268    /// Crash-safety journal marker (see [`PluginInstallStatus`]). Defaults to
269    /// [`PluginInstallStatus::Installed`] so an `installed.json` written before
270    /// this field existed loads as a completed install.
271    #[serde(default)]
272    pub status: PluginInstallStatus,
273    #[serde(default)]
274    pub registered: RegisteredCapabilities,
275}
276
277/// The full `installed.json` document: `{ "plugins": [ ... ] }`.
278#[derive(Debug, Clone, Default, Serialize, Deserialize)]
279pub struct InstalledPlugins {
280    #[serde(default)]
281    pub plugins: Vec<InstalledPlugin>,
282}
283
284impl InstalledPlugins {
285    /// Load from `path`. A missing file is treated as an empty registry (this
286    /// is the state before any plugin has ever been installed) rather than an
287    /// error.
288    pub async fn load(path: &Path) -> PluginResult<Self> {
289        match fs::try_exists(path).await {
290            Ok(true) => {}
291            Ok(false) => return Ok(Self::default()),
292            Err(error) => return Err(PluginError::Io(error)),
293        }
294
295        let raw = fs::read_to_string(path).await?;
296        if raw.trim().is_empty() {
297            return Ok(Self::default());
298        }
299        let store: Self = serde_json::from_str(&raw)?;
300        Ok(store)
301    }
302
303    /// Persist to `path`, creating parent directories as needed.
304    ///
305    /// Writes to a sibling `<path>.tmp` first, then `rename`s it over `path`
306    /// — `rename` is atomic on the same filesystem (and `<path>.tmp` sits
307    /// right next to `path`, guaranteeing that), so a hard kill mid-write can
308    /// only ever leave a stray, harmless `.tmp` file behind, never a
309    /// truncated/corrupt `installed.json` a later `load` would choke on.
310    pub async fn save(&self, path: &Path) -> PluginResult<()> {
311        if let Some(parent) = path.parent() {
312            fs::create_dir_all(parent).await?;
313        }
314        let serialized = serde_json::to_string_pretty(self)?;
315        let tmp_path = tmp_path_for(path);
316        fs::write(&tmp_path, serialized).await?;
317        fs::rename(&tmp_path, path).await?;
318        Ok(())
319    }
320
321    /// Look up a plugin by id.
322    pub fn get(&self, id: &str) -> Option<&InstalledPlugin> {
323        self.plugins.iter().find(|plugin| plugin.id == id)
324    }
325
326    /// Insert or replace (by id) — an upgrade re-adds the same id with a new
327    /// version/registered set, so this is an upsert rather than an append.
328    pub fn add(&mut self, plugin: InstalledPlugin) {
329        self.remove(&plugin.id);
330        self.plugins.push(plugin);
331    }
332
333    /// Remove and return the entry for `id`, if any.
334    pub fn remove(&mut self, id: &str) -> Option<InstalledPlugin> {
335        let index = self.plugins.iter().position(|plugin| plugin.id == id)?;
336        Some(self.plugins.remove(index))
337    }
338
339    /// All installed plugins, in insertion order.
340    pub fn list(&self) -> &[InstalledPlugin] {
341        &self.plugins
342    }
343}
344
345/// `<path>` with `.tmp` appended to its file name (e.g. `installed.json` ->
346/// `installed.json.tmp`) — a sibling in the SAME directory as `path`, so the
347/// `rename` in [`InstalledPlugins::save`] is guaranteed same-filesystem and
348/// therefore atomic.
349fn tmp_path_for(path: &Path) -> PathBuf {
350    let mut tmp_name = path.file_name().unwrap_or_default().to_os_string();
351    tmp_name.push(".tmp");
352    path.with_file_name(tmp_name)
353}
354
355#[cfg(test)]
356mod tests {
357    use super::*;
358
359    fn sample_plugin(id: &str) -> InstalledPlugin {
360        InstalledPlugin {
361            id: id.to_string(),
362            version: "0.1.0".to_string(),
363            source: PluginSource::LocalDir {
364                path: PathBuf::from("/tmp/source"),
365            },
366            plugin_dir: PathBuf::from(format!("/home/user/.bamboo/plugins/{id}")),
367            installed_at: DateTime::parse_from_rfc3339("2026-07-12T00:00:00Z")
368                .unwrap()
369                .with_timezone(&Utc),
370            status: PluginInstallStatus::Installed,
371            registered: RegisteredCapabilities {
372                mcp_server_ids: vec![],
373                skill_dirs: vec!["hello-world".to_string()],
374                preset_ids: vec!["hello_preset".to_string()],
375                workflow_filenames: vec![],
376            },
377        }
378    }
379
380    #[tokio::test]
381    async fn load_missing_file_returns_empty_registry() {
382        let dir = tempfile::tempdir().expect("tempdir");
383        let path = dir.path().join("plugins").join("installed.json");
384        let loaded = InstalledPlugins::load(&path).await.expect("load");
385        assert!(loaded.plugins.is_empty());
386    }
387
388    #[tokio::test]
389    async fn save_is_atomic_via_tmp_file_rename() {
390        let dir = tempfile::tempdir().expect("tempdir");
391        let path = dir.path().join("installed.json");
392        let tmp_path = tmp_path_for(&path);
393
394        let mut store = InstalledPlugins::default();
395        store.add(sample_plugin("hello-plugin"));
396        store.save(&path).await.expect("save");
397
398        assert!(path.exists(), "installed.json should exist after save");
399        assert!(
400            !tmp_path.exists(),
401            "the .tmp staging file must be renamed over the target, never left behind"
402        );
403
404        // A second save (e.g. an upgrade re-persisting the store) must go
405        // through the same write-tmp-then-rename path and leave no trace
406        // either.
407        let mut reloaded = InstalledPlugins::load(&path).await.expect("load");
408        reloaded.add(sample_plugin("other-plugin"));
409        reloaded.save(&path).await.expect("save again");
410        assert!(!tmp_path.exists());
411
412        let loaded = InstalledPlugins::load(&path).await.expect("load");
413        assert_eq!(loaded.plugins.len(), 2);
414    }
415
416    #[tokio::test]
417    async fn save_then_load_round_trips() {
418        let dir = tempfile::tempdir().expect("tempdir");
419        let path = dir.path().join("plugins").join("installed.json");
420
421        let mut store = InstalledPlugins::default();
422        store.add(sample_plugin("hello-plugin"));
423        store.add(sample_plugin("other-plugin"));
424        store.save(&path).await.expect("save");
425
426        let loaded = InstalledPlugins::load(&path).await.expect("load");
427        assert_eq!(loaded.plugins.len(), 2);
428        let hello = loaded.get("hello-plugin").expect("hello-plugin present");
429        assert_eq!(hello.version, "0.1.0");
430        assert_eq!(hello.registered.skill_dirs, vec!["hello-world".to_string()]);
431        assert_eq!(
432            hello.registered.preset_ids,
433            vec!["hello_preset".to_string()]
434        );
435        assert_eq!(
436            hello.source,
437            PluginSource::LocalDir {
438                path: PathBuf::from("/tmp/source")
439            }
440        );
441    }
442
443    #[tokio::test]
444    async fn add_upserts_by_id() {
445        let dir = tempfile::tempdir().expect("tempdir");
446        let path = dir.path().join("installed.json");
447
448        let mut store = InstalledPlugins::default();
449        store.add(sample_plugin("hello-plugin"));
450
451        let mut upgraded = sample_plugin("hello-plugin");
452        upgraded.version = "0.2.0".to_string();
453        store.add(upgraded);
454
455        assert_eq!(store.plugins.len(), 1);
456        assert_eq!(store.get("hello-plugin").unwrap().version, "0.2.0");
457
458        store.save(&path).await.expect("save");
459        let loaded = InstalledPlugins::load(&path).await.expect("load");
460        assert_eq!(loaded.plugins.len(), 1);
461        assert_eq!(loaded.get("hello-plugin").unwrap().version, "0.2.0");
462    }
463
464    #[tokio::test]
465    async fn remove_deletes_and_returns_entry() {
466        let mut store = InstalledPlugins::default();
467        store.add(sample_plugin("hello-plugin"));
468
469        let removed = store.remove("hello-plugin").expect("present before remove");
470        assert_eq!(removed.id, "hello-plugin");
471        assert!(store.get("hello-plugin").is_none());
472        assert!(store.remove("hello-plugin").is_none());
473    }
474
475    #[test]
476    fn reconcile_exclusive_fresh_install_splits_new_from_foreign() {
477        // Fresh install (no prior ownership): "a" is new, "b" collides with a
478        // user's own entry.
479        let declared = vec!["a".to_string(), "b".to_string()];
480        let existing = vec!["b".to_string(), "user-thing".to_string()];
481        let owned_previously: Vec<String> = vec![];
482
483        let reconciliation = reconcile_exclusive(&declared, &existing, &owned_previously);
484        assert_eq!(reconciliation.to_register, vec!["a".to_string()]);
485        assert_eq!(reconciliation.foreign_conflicts, vec!["b".to_string()]);
486    }
487
488    #[test]
489    fn reconcile_exclusive_upgrade_reregisters_own_but_refuses_new_foreign() {
490        // Upgrade: "a" was ours last time (owned reinstall, fine); "c" is new;
491        // "d" newly collides with a user entry that appeared since → foreign.
492        let declared = vec!["a".to_string(), "c".to_string(), "d".to_string()];
493        let existing = vec!["a".to_string(), "d".to_string()];
494        let owned_previously = vec!["a".to_string()];
495
496        let reconciliation = reconcile_exclusive(&declared, &existing, &owned_previously);
497        assert_eq!(
498            reconciliation.to_register,
499            vec!["a".to_string(), "c".to_string()]
500        );
501        assert_eq!(reconciliation.foreign_conflicts, vec!["d".to_string()]);
502    }
503
504    #[test]
505    fn classify_ownership_three_way() {
506        let existing: HashSet<&str> = ["x", "y"].into_iter().collect();
507        let owned: HashSet<&str> = ["y"].into_iter().collect();
508        assert_eq!(classify_ownership("z", &existing, &owned), Ownership::New);
509        assert_eq!(
510            classify_ownership("y", &existing, &owned),
511            Ownership::OwnedReinstall
512        );
513        assert_eq!(
514            classify_ownership("x", &existing, &owned),
515            Ownership::ForeignConflict
516        );
517    }
518
519    #[test]
520    fn removed_since_computes_dropped_capabilities_per_kind() {
521        let old = RegisteredCapabilities {
522            mcp_server_ids: vec!["srv-a".to_string(), "srv-b".to_string()],
523            skill_dirs: vec!["skill-a".to_string()],
524            preset_ids: vec!["preset-a".to_string(), "preset-b".to_string()],
525            workflow_filenames: vec!["wf-a.md".to_string()],
526        };
527        // New version drops srv-b and preset-a, keeps the rest, adds srv-c.
528        let new = RegisteredCapabilities {
529            mcp_server_ids: vec!["srv-a".to_string(), "srv-c".to_string()],
530            skill_dirs: vec!["skill-a".to_string()],
531            preset_ids: vec!["preset-b".to_string()],
532            workflow_filenames: vec!["wf-a.md".to_string()],
533        };
534
535        let removed = new.removed_since(&old);
536        assert_eq!(removed.mcp_server_ids, vec!["srv-b".to_string()]);
537        assert!(removed.skill_dirs.is_empty());
538        assert_eq!(removed.preset_ids, vec!["preset-a".to_string()]);
539        assert!(removed.workflow_filenames.is_empty());
540    }
541
542    #[tokio::test]
543    async fn load_empty_file_returns_empty_registry() {
544        let dir = tempfile::tempdir().expect("tempdir");
545        let path = dir.path().join("installed.json");
546        tokio::fs::create_dir_all(path.parent().unwrap())
547            .await
548            .unwrap();
549        tokio::fs::write(&path, "").await.unwrap();
550
551        let loaded = InstalledPlugins::load(&path).await.expect("load");
552        assert!(loaded.plugins.is_empty());
553    }
554}