Skip to main content

Module grammar_trampoline

Module grammar_trampoline 

Source
Expand description

The sync grammar trampoline + registry wiring (plugin-host.md §4.1, PH7.7c).

This is the production counterpart to the picker/completion actor adapters — but synchronous, per the PH7.7 fork: a plugin motion/operator/text-object must resolve inline on the dispatch thread to compose with its operator (async would break operator∘motion atomicity + dot-repeat/macros). So there is no actor task; the native spec’s apply closure calls the guest export directly under a lock, bounded by a Reflex-class fuel/epoch budget (PluginBudget::grammar).

Flow (PluginHost::instantiate_grammar_plugin):

  1. instantiate the grammar-plugin component against the sync grammar linker (lib.rs: sync WASI + the grammar register import),
  2. call the guest’s register-grammar export (sync) — the guest calls the imported register-* host funcs, which record into GrammarContributions,
  3. drain the recorded contributions and build a native *Spec for each, whose apply / parse_args is a trampoline closure over the shared Arc<Mutex<GrammarGuest>> + the guest-chosen callback id,
  4. return a GrammarContributionSet the caller registers into its CommandRegistry via register_plugin_* (mode-ownership — the host builds specs, the caller owns the registry; ZERO Editor:: methods).

Graceful degradation (§8): a guest err, a fuel/epoch trap (the Reflex runaway guard), a boundary-conversion failure, or a poisoned lock all map to CommandError::Plugin — the dispatcher commits no effect, the contribution is a no-op, the reason is logged. Never a panic, never a keystroke hang.

Structs§

GrammarContributionSet
The native grammar contributions a plugin declared, each with a trampoline apply into the guest, ready for the caller to register into its CommandRegistry. The host builds the specs (owning the trampoline over the guest store) but never owns the registry — register_all takes the caller’s &mut CommandRegistry and stamps every entry SourceLayer::Plugin(plugin_id) via the register_plugin_* seam (mode-ownership; ZERO Editor:: methods).
PluginOperatorChord
CM.2: a chord a plugin declared on its operator, as recorded at drain time.
WiredOperatorChord
CM.2: a chord request, paired with the OperatorId registration produced.