Repository navigation
fix(gateway): list dormant plugins in full after a core upgrade - #326
Merged
Merged
Conversation
With no plugin enabled, Plugins::build does not compile disabled plugins and shows each one with the manifest remembered in plugins/.manifests.json. That cache is keyed on the core version, so every upgrade discards it, and with every plugin disabled nothing ever compiles to rebuild it. The bundled default plugins ship disabled, so after any upgrade a default install listed each plugin as a bare id: no name, description, permissions, request kinds, scope or settings (empty permissions, which the desktop app reads as "manifest unknown"). A dormant plugin with neither a compiled nor a cached manifest now gets a display-only manifest read from its approved bytes without starting the sandbox. The manifest is plain data, so tw_plugin::declared_manifest finds the literal and checks it with the same code that checks a compiled one: manifest::parse is split into fields() (every field except hooks) and finish() (hooks against permissions when hooks are known, then requests against permissions), and both paths go through them, in the same order, so they cannot drift. Hooks cannot be known without running the module, so they are left empty and the hook/permission pairing is not checked; a dormant plugin never runs, and enabling one makes the next build compile every plugin. A dormant plugin whose file changed shows its approved copy the same way, as the awake path does by compiling it. A manifest that is not plain data, or breaks a rule, still leaves only the id (with on_error and scope as declared, as before). The static manifest is never written to .manifests.json, which keeps holding compiled manifests only. Nothing security-relevant uses it: enabling a plugin, changing code, approving a changed file and trials all compile first (compiled_manifest() refuses a dormant host), and a test pins that with an engine whose compiled manifest asks for more than the file declares. .manifests.json is still invalidated on every core version. A compiled manifest depends on tw-plugin's rules, bridge.js and the gateway's conversion, none of which feed GUEST_WASM_SHA256 (it hashes the wasm before the snapshot), so dropping the core version would rely on someone remembering to bump FORMAT. With the static fallback an invalidated cache no longer changes what the list shows. Tests: the bundled defaults (as shipped and after the user edits their data) read statically to exactly what the real sandbox compiles, field by field except hooks; field-rule violations give the same LoadError both ways; dormant plugins with an absent or stale cache list name, description, permissions, requests, scope, on_error and settings (order, labels, values) without compiling and without writing the cache; a non-literal manifest falls back to the id; enabling a plugin compiles every plugin. No new messages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With no plugin enabled,
Plugins::builddoes not compile disabled plugins (dormant_one) and shows each one with the manifest remembered inplugins/.manifests.json. That file'sversion()includesCARGO_PKG_VERSION, so every core upgrade discards it, and with every plugin disabled nothing ever compiles to rebuild it.The bundled default plugins ship disabled, so this is the default state: after any upgrade the Plugins page shows each plugin as its bare id, with no name, description, permissions, request kinds, scope or settings (
PluginView.permissionsis empty, which Lite reads as "manifest unknown"). Seen on a real install: core 0.70.0,.manifests.jsonwritten by an older core on 2026-10-04, two disabled default plugins listed as bare ids.Fix
tw_plugin::declared_manifest(source)reads the manifest from the source without compiling. The manifest is plain data, so it finds the literal (literal::find) and checks it with the same code that checks a compiled manifest.manifest::parseis split intofields()(every field except hooks: name, api, description, permissions, requests, match, on_error, reply, settings with order, labels and values) andfinish()(hooks against permissions when hooks are known, then requests against permissions). Both paths go through them in the same order, so the rules cannot drift.source::display_manifest(gateway) wraps it.dormant_onefalls back to it when neither the compiled cache nor.manifests.jsonhas the manifest. A dormant plugin whose file changed shows its approved copy the same way, as the awake path does by compiling it. If the manifest is not plain data or breaks a rule, the plugin still shows only its id, withon_errorand scope as declared, as before..manifests.json, which still holds compiled manifests only. Every security-relevant call site still compiles first and does not accept it:compiled_manifest()refuses a dormant host (used by enabling,guard_raw_writeand the approval checks), save, install and approve runload_or_refuse, and trialsawakena dormant plugin. A new test pins this with an engine whose compiled manifest asks for more than the file declares..manifests.jsonis still invalidated on every core versionI kept this on purpose. A compiled manifest depends on tw-plugin's rules,
bridge.jsand the gateway's conversion, and none of them feedGUEST_WASM_SHA256, which hashes the wasm before the snapshot. Dropping the core version would rely on someone remembering to bumpFORMAT. With the static fallback, an invalidated cache no longer changes what the list shows:PluginViewhas no hooks, which is the only field the static read lacks.Tests
tw-gatewayplugin::defaults: each bundled default, both as shipped and after itson_error, scope and every setting are rewritten, reads statically to exactly what the real sandbox compiles, field by field (hooks aside).tw-pluginloading: manifests that compile read the same statically apart from hooks. Every field-rule violation, plus non-plain-data and non-UTF-8 sources, gives the sameLoadErrorboth ways. Problems only compiling can find (hook/permission mismatch, a syntax error elsewhere, module code changing the manifest) still read statically.tw-gatewayplugin::load:on_errorand settings without compiling and without writing the cache.on_errorand scope.tw-controlplugin_defaults:Local checks, all passing:
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test -p tw-plugin -p tw-gateway -p tw-control -p twcoreand./scripts/smoke.sh(82/0). No new messages, no protocol change, no version bump.🤖 Generated with Claude Code