Files
osmaczko a58b5ffe71 feat/migrate to Rust SDK (#32)
* feat: migrate chat_module from a C++ plugin to a Rust SDK module

Reimplement chat_module as a Rust module on the logos-rust-sdk LIDL model,
replacing the hand-written C++ plugin that wrapped liblogoschat directly.

The contract rust-lib/chat_module.lidl (interface: cdylib) is now the single
source of truth: logos-module-builder runs logos-lidl-gen over it to generate
the C-ABI provider scaffold (the ChatModule trait, dispatch, the logos_module_*
exports, and the emit_* event emitters), which src/lib.rs include!s and
implements. The module pushes six typed events (message_received, message_sent,
conversation_created/updated/deleted, delivery_state_changed) over the lp_* IPC
event channel; consumers subscribe via on_<event>() instead of polling.

Delivery is consumed through the generated typed dependency client rather than
untyped string-keyed calls. init() bootstraps delivery off the Qt dispatch
thread: it runs the fallible local setup (open, load_state) and registers the
event subscriptions first, then fires start_async and chains the content-topic
subscribe in its completion callback, so the dispatch thread is never blocked and
a failed ChatClient::open can no longer orphan a started node. Readiness is
surfaced as a delivery_state_changed event reaching `online`, and publish() hands
the envelope to delivery's async send so a slow accept handshake never stalls the
UI. Persistence write failures are surfaced instead of swallowed.

The C++ plugin, its CMake test harness, and the liblogoschat mocks/stubs are
removed; metadata.json now declares codegen.rust over the crate.

* build: build the Rust staticlib via Nix and Cargo

nix build .#chat_module drives the whole build through logos-module-builder
(mkLogosModule): it generates the provider scaffold, fetches the Cargo deps from
rust-lib/Cargo.lock, compiles the staticlib, and links it into the Qt plugin via
CMakeLists.txt. No build.rs, no manual hash bookkeeping.

Two build inputs the crate needs are gitignored because the builder produces them
from a single pinned logos-rust-sdk rev (so the generator and the SDK can never
skew): rust-lib/generated/provider_gen.rs (the include!d scaffold) and the staged
SDK source the crate path-deps at ../logos-rust-sdk-src. nix run .#generate
materialises both in the working tree so a bare cargo build works in rust-lib/.

logos-delivery-module is pinned past v0.1.2 to the commit carrying the
zerokit/RLN nix build fix, so a cache-miss build does not hit the crates.io 403.

* ci: lint, build and test the Rust module

Three jobs: nix build .#chat_module is the hermetic build gate (matrix OS); a
lint job runs rustfmt and clippy (-D warnings); a cargo job runs the unit tests
(matrix OS). The lint and cargo jobs call nix run .#generate first to materialise
the generated scaffold and the SDK source, then run cargo in rust-lib/ directly.

Generated code is excluded from both rustfmt and clippy: it lives behind an
include! inside a module that opts out of warnings, so machine output never fails
the lint.

* docs: document the Rust module build and API

Rewrite README for the Rust module: the nix build entry point, the
nix run .#generate step for a bare cargo build, the LIDL contract and codegen,
the six IPC events, and init() bring-up. Refresh the e2e README's CI and
setup notes.

* chore: address review feedback

- bump logos-module-builder to the thread-safe inter-module-calls SDK; init no
  longer needs the Qt event-loop thread, so drop that caveat from the README
  and the module/inbound docs
- flatten start_delivery_bootstrap's nested callbacks into create/start/
  subscribe steps
- name the conversation in the steady-state "not found" error
- note the installation-name override is superseded once Accounts land
2026-06-25 15:21:31 +02:00
..
2026-06-25 15:21:31 +02:00