Skip to main content

lattice_plugin_host/
scan_host.rs

1//! OM.A1 — the scanned-excerpt-source guest world.
2//!
3//! A WASM agenda provider implements the `scanned-excerpt-source-plugin` world: it
4//! exports `extensions` / `begin` / `scan` and imports the capability-gated
5//! host seams. This module holds the `bindgen!` for that world, using the same
6//! shared-types trick as every seam before it — `with:` points `types` +
7//! `logging` at the `plugin` world's generated modules so a crossed value is
8//! the SAME Rust type the boundary round-trips.
9//!
10//! **Producer, async.** A scan runs on a spawned task, never the keystroke
11//! path, and a `scan` call suspends the guest stack rather than pinning the
12//! caller's thread.
13//!
14//! Unlike `media`, the exports sit at world level rather than inside a named
15//! interface. That is `error-parser`'s shape and it is deliberate: the design
16//! fragment (`org-mode.md` §6.2) chose it because the two seams have the same
17//! job — a stateful per-run parser fed one unit of input at a time — and
18//! giving them different shapes would be inventing a second spelling for one
19//! idea.
20
21pub(crate) mod bindings {
22    wasmtime::component::bindgen!({
23        world: "scanned-excerpt-source-plugin",
24        path: "../lattice-wit/wit",
25        // A scan call suspends the guest rather than pinning the caller's
26        // thread — and it is never on the keystroke path.
27        exports: { default: async },
28        with: {
29            // `logging` is shared: an `entry` is declared in this seam's own
30            // interface rather than in `types`, and the guest touches no
31            // filesystem so there is no `host-services` import to reuse.
32            "lattice:plugin-host/logging": crate::lattice::plugin_host::logging,
33            // OT.3, for `context-plugin`'s reason stated verbatim there: this
34            // must point at the GRAMMAR world's `tree-sitter` module, where
35            // `HostTreeSnapshot` / `HostNode` are implemented and whose
36            // resources are already on the async linker. Letting this world
37            // generate its own would mint a second, incompatible set of
38            // resource types for the same host objects — and the `scan-input`
39            // borrow the host lends would not typecheck against the one the
40            // guest receives.
41            "lattice:plugin-host/tree-sitter":
42                crate::grammar_host::bindings::lattice::plugin_host::tree_sitter,
43        },
44    });
45}