diff --git a/docs/plugin-platform/review-2026-10.md b/docs/plugin-platform/review-2026-10.md new file mode 100644 index 000000000..9d2a40ad8 --- /dev/null +++ b/docs/plugin-platform/review-2026-10.md @@ -0,0 +1,67 @@ +# Plugin platform implementation review + +Baseline: main `0256e7471d66bbbca077c361ef379d7b11ce8465` (2026-10-26). + +## Existing capabilities and gaps + +| Area | Implemented source | Remaining boundary | +| --- | --- | --- | +| Contract, SDK, package CLI | `packages/plugin-contract/schema`, `packages/plugin-sdk`, `packages/plugin-cli` | Internal API `0.1.0-internal`; no public API stability promise | +| Runtime | `electron/plugins/browserPluginRuntime.cjs`, `utilityPluginRuntime.cjs`, `hostBootstrap.cjs` | Entire host remains development opt-in; advanced utility is ambient Node authority, not a fine-grained sandbox | +| Permissions | `permissionEngine.cjs`, `hostRpcRegistry.cjs`, `secureCapabilities.cjs` | Broker checks at privileged boundary; unsigned principal bound to package digest; verified publisher/distribution not implemented | +| UI contributions | `contributionService.cjs`, `components/plugins`, `SettingsPluginsTab.tsx` | Commands, menus, keybindings, settings and views exist; current Settings page is contributed settings, not a package manager/marketplace | +| Terminal | `terminalProviderService.cjs`, `terminalDataPipelineService.cjs` | Completion/link/visual providers and lifecycle; interceptors require privileged utility placement; not arbitrary terminal object access | +| Connection, authentication, importer | `extensionProviderService.cjs`, `application/state/pluginExtensionBridge.ts` | Existing operation-bound provider integration; not general vault/SFTP/clipboard CRUD | +| Sync | `pluginSyncSidecarService.cjs`, `application/pluginSyncSidecarBridge.ts` | Opt-in non-secret settings and account/CRDT sidecars; ordinary KV is local, package code/permissions/secrets are not cloud authority | +| Compatibility | `plugin-cli/src/compatibility.ts`, `packageStore.cjs`, `runtimeSupervisor.cjs` | Install/start checks existed; startup reconciliation and lazy re-enable checks missing | +| Local package | `packageStore.cjs`, CLI `pack`, first-party `examples/plugins/hello-netcatty` | Immutable snapshot, hash/integrity validation and safe extraction exist; no ordinary import management UI | +| Distribution | No public catalog implementation | Version/hash/pinned README, review workflow, manual update UI still needed | + +Historical merged steps: #2276 contract/SDK; #2303 runtime; #2315 permission/security; +#2324 UI contributions; #2338 terminal providers; #2402 privileged terminal pipeline; +#2413 connection/auth/importers; #2713 sync; #2748 and #2752 sync follow-up fixes. +The repository AGENTS.md runtime section describes an earlier phase and must not +be mistaken for a complete current capability inventory. No repository `.agents/skills` +directory was present at this baseline. + +## Small implementation slices + +1. Reconcile host/API/features compatibility before contribution enumeration; + disable incompatible plugins and retain package/data, record the reason; + block lazy re-enable. Do not auto-enable after a host downgrade. +2. Reuse the existing Settings Plugins tab and management IPC for installed + packages, manifest-derived permissions, version/hash and lifecycle actions; + local import starts disabled for review. Keep native permission mediation. +3. Add a lightweight first-party catalog and pinned safe README detail renderer, + shared package verification, digest-bound manual update flow and author docs. + Do not introduce remote accounts, reviews, payments or a new repository. +4. Reproduce the actual Electron flow with synthetic data and the first-party + sample; transfer source/build instructions if GUI is unavailable here. + +## Decisions and explicit release gates + +User approved public source plus a clear license for catalog entries, and manual +confirmation of plugin updates. Private local packages remain separate. + +Recommended public v1 eligibility: browser runtime only. Utility Node, native +companions and raw terminal interceptors retain the development preview path. +This excludes advanced provider implementations requiring Node/native binaries; +ordinary browser contributions, broker-backed networking and providers remain +possible. This policy needs product confirmation; no existing advanced path is +removed by this review. + +Keep `NETCATTY_PLUGIN_DEV=1` until distribution trust, permission UI, compatibility +migration and native acceptance are reviewed. Passing tests is not proof of +security isolation. Do not describe utility processes as broker-constrained. + +A future KV sync feature needs an explicit manifest opt-in schema, size limits, +namespace and schema-version migrations, deterministic conflict/deletion rules, +account switching semantics and secret exclusion. It is deliberately not silently +enabled in this iteration. Reuse existing settings sidecars for small preferences. + +Catalog entries should bind ID, repository, license, author, version, commit, +artifact SHA-256 and URL, platform/engine ranges, permissions and README revision. +A hash mismatch must fail rather than fall back to latest. README must not execute +HTML or automatically fetch remote media. Directory PR checks are a bounded +review process, not a security certification or a guarantee that maintainers will +repair third-party plugins. diff --git a/electron/plugins/packageStore.cjs b/electron/plugins/packageStore.cjs index 230f35271..7c23031cb 100644 --- a/electron/plugins/packageStore.cjs +++ b/electron/plugins/packageStore.cjs @@ -151,6 +151,35 @@ class PackageStore { .filter((value) => typeof value === "string" && value !== this.paths.database) .map((directory) => mkdir(directory, { recursive: true, mode: 0o700 }))); await this.recover(); + // Reconcile every installed manifest before lazy contributions are exposed. + // An application/API upgrade must not leave incompatible providers enabled. + for (const plugin of this.database.listPlugins()) { + if (!plugin.enabled) continue; + await this.assertCompatible(plugin).catch((error) => { + if (error.code !== "PLUGIN_INCOMPATIBLE") throw error; + }); + } + } + + async assertCompatible(plugin) { + const pluginCli = await loadPluginCli(); + const result = pluginCli.checkPluginCompatibility(plugin.manifest, { + netcattyVersion: this.netcattyVersion, + apiVersion: this.apiVersion, + features: this.supportedFeatures, + }); + if (result.compatible) return result; + const error = new Error(`Plugin is incompatible: ${result.errors.join("; ")}`); + error.code = "PLUGIN_INCOMPATIBLE"; + const current = this.database.getActivePlugin(plugin.id); + if (current?.activeVersion === plugin.activeVersion) { + this.database.setEnabled(plugin.id, false); + this.database.setRuntimeState(plugin.id, "error", { + pluginVersion: plugin.activeVersion, + error: error.message, + }); + } + throw error; } async install(archivePath, options = {}) { diff --git a/electron/plugins/packageStore.test.cjs b/electron/plugins/packageStore.test.cjs index 53750ddce..88f5470a1 100644 --- a/electron/plugins/packageStore.test.cjs +++ b/electron/plugins/packageStore.test.cjs @@ -370,3 +370,43 @@ test("failed package validation removes every extracted staging file", async (co assert.deepEqual(await fs.promises.readdir(fixture.paths.staging), []); assert.deepEqual(fixture.database.listPlugins(), []); }); + +test("host upgrade disables incompatible lazy plugins before contributions and retains data", async (context) => { + const fixture = createStore(context); + await fixture.store.initialize(); + const archive = await createPackage(fixture.root, { + manifest: { engines: { netcatty: "<1.0.0", api: ">=0.1.0-internal <0.2.0" } }, + }); + const installed = await fixture.store.install(archive.archive, { enable: true }); + fixture.database.setValue(installed.id, "synthetic", { retained: true }); + fixture.store.netcattyVersion = "1.0.0"; + await fixture.store.initialize(); + const disabled = fixture.database.getActivePlugin(installed.id); + assert.equal(disabled.enabled, false); + assert.match(disabled.runtime.lastError, /incompatible.*Netcatty/); + assert.equal(disabled.activeVersion, installed.activeVersion); + assert.deepEqual(fixture.database.getValue(installed.id, "synthetic"), { retained: true }); + assert.equal(fs.existsSync(fixture.store.resolvePackageRoot(disabled)), true); + await assert.rejects(fixture.store.assertCompatible(disabled), { code: "PLUGIN_INCOMPATIBLE" }); + fixture.store.netcattyVersion = "0.0.0"; + await fixture.store.initialize(); + assert.equal(fixture.database.getActivePlugin(installed.id).enabled, false, + "returning to a compatible host must not silently re-enable code"); +}); + +for (const target of [ + { apiVersion: "0.2.0" }, + { supportedFeatures: [] }, +]) { + test(`startup checks API and required feature compatibility: ${JSON.stringify(target)}`, async (context) => { + const fixture = createStore(context, { supportedFeatures: ["example.feature"] }); + await fixture.store.initialize(); + const archive = await createPackage(fixture.root, { + manifest: { features: { required: ["example.feature"] } }, + }); + const installed = await fixture.store.install(archive.archive, { enable: true }); + Object.assign(fixture.store, target); + await fixture.store.initialize(); + assert.equal(fixture.database.getActivePlugin(installed.id).enabled, false); + }); +} diff --git a/electron/plugins/pluginManager.cjs b/electron/plugins/pluginManager.cjs index 38fccfb2f..4dd2d884f 100644 --- a/electron/plugins/pluginManager.cjs +++ b/electron/plugins/pluginManager.cjs @@ -107,6 +107,7 @@ class PluginManager { await this.#ready(); if (enabled) { const plugin = this.database.getActivePlugin(pluginId); + if (plugin) await this.packageStore.assertCompatible?.(plugin); if (plugin?.runtime?.quarantinedAt != null) { this.database.clearQuarantine(pluginId, plugin.activeVersion); } diff --git a/electron/plugins/pluginManager.test.cjs b/electron/plugins/pluginManager.test.cjs index 1172c8a89..7c7e19ffa 100644 --- a/electron/plugins/pluginManager.test.cjs +++ b/electron/plugins/pluginManager.test.cjs @@ -488,3 +488,26 @@ test("shutdown cancels an in-flight runtime mutation before waiting for its queu "database:close", ]); }); + +test("explicit enable checks compatibility before clearing quarantine or exposing lazy contributions", async () => { + const calls = []; + const plugin = { id: "com.example.incompatible", enabled: false, runtime: { quarantinedAt: 1 } }; + const manager = new PluginManager({ + database: { + getActivePlugin: () => plugin, + clearQuarantine: () => calls.push("clear"), + setEnabled: () => calls.push("enable"), + }, + packageStore: { + async initialize() {}, + async assertCompatible() { throw new Error("Plugin is incompatible"); }, + }, + runtimeSupervisor: {}, + contributionService: { + async initialize() {}, + onPluginEnabled: () => calls.push("contribute"), + }, + }); + await assert.rejects(manager.setEnabled(plugin.id, true), /incompatible/); + assert.deepEqual(calls, []); +});