Skip to content

fix(gateway): list dormant plugins in full after a core upgrade - #326

Merged
fylorn merged 1 commit into
mainfrom
fix/dormant-plugin-manifest
Oct 11, 2026
Merged

fylorn merged 1 commit into
mainfrom
fix/dormant-plugin-manifest

Conversation

@fylorn

@fylorn fylorn commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Problem

With no plugin enabled, Plugins::build does not compile disabled plugins (dormant_one) and shows each one with the manifest remembered in plugins/.manifests.json. That file's version() includes CARGO_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.permissions is empty, which Lite reads as "manifest unknown"). Seen on a real install: core 0.70.0, .manifests.json written 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::parse is split into fields() (every field except hooks: name, api, description, permissions, requests, match, on_error, reply, settings with order, labels and values) and finish() (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.
  • Hooks are left empty. Which functions a module exports is only known by running it, so the hook/permission pairing is not checked statically. A dormant plugin never runs, and enabling one makes the next build compile every plugin.
  • source::display_manifest (gateway) wraps it. dormant_one falls back to it when neither the compiled cache nor .manifests.json has 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, with on_error and scope as declared, as before.
  • The static manifest is display-only and never written to .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_write and the approval checks), save, install and approve run load_or_refuse, and trials awaken a dormant plugin. A new test pins this with an engine whose compiled manifest asks for more than the file declares.

.manifests.json is still invalidated on every core version

I kept this on purpose. A compiled manifest depends on tw-plugin's rules, bridge.js and the gateway's conversion, and none of them feed GUEST_WASM_SHA256, which hashes the wasm before the snapshot. 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: PluginView has no hooks, which is the only field the static read lacks.

Tests

  • tw-gateway plugin::defaults: each bundled default, both as shipped and after its on_error, scope and every setting are rewritten, reads statically to exactly what the real sandbox compiles, field by field (hooks aside).
  • tw-plugin loading: 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 same LoadError both ways. Problems only compiling can find (hook/permission mismatch, a syntax error elsewhere, module code changing the manifest) still read statically.
  • tw-gateway plugin::load:
    • A dormant plugin with an absent or stale cache lists its name, description, permissions, requests, scope, on_error and settings without compiling and without writing the cache.
    • A non-literal manifest falls back to the id. A literal that breaks a rule also falls back to the id but keeps its declared on_error and scope.
    • A changed file shows its approved copy.
    • Enabling one plugin compiles all of them, and the cache gets the compiled manifests with hooks.
  • tw-control plugin_defaults:
    • After an "upgrade" (stale or missing cache), the real bundled defaults list in full without starting the sandbox.
    • A stale, mismatched, broken or missing cache is ignored in favour of the file.
    • With only the static manifest available, enabling a plugin or changing its code from the web path is still decided on a compiled manifest.

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 twcore and ./scripts/smoke.sh (82/0). No new messages, no protocol change, no version bump.

🤖 Generated with Claude Code

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>
@fylorn
fylorn merged commit e366174 into main Oct 11, 2026
5 checks passed
@fylorn
fylorn deleted the fix/dormant-plugin-manifest branch October 11, 2026 14:58
@fylorn fylorn mentioned this pull request Oct 11, 2026
fylorn added a commit that referenced this pull request Oct 11, 2026
Disabled plugins are listed in full after a core upgrade (#326). Protocol 46 unchanged.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant