M1.3: engine workspace, file and buffer commands, event stream

State holds the open project (VFS project, watcher, watched directories)
and versioned buffers. New commands: project.open/close/children,
file.open/save/saveAll, buffer.get/edit/close. buffer.edit takes UTF-16
change sets based on a version and fails with the new stale_version code;
closing dirty buffers or projects without force fails with
unsaved_changes. Commands queue events (projectOpened, treeChanged,
bufferChanged, dirtyChanged, fileChangedOnDisk, ...) that the engine
returns in Outcome.events; Engine::pump_vfs maps changes on disk to
events and reloads clean buffers. project.children watches listed
directories, capped at 256 native / 32 polling, least recently listed
dropped first.

Control channel: events.subscribe streams {"event": ...} lines, with
bounded per-subscriber queues (lutra_control::Subscribers) and method docs
in methods.rs. testkit's EngineBackend and the desktop Host implement the
new Backend::subscribe. Verified with 14 engine integration tests, a TCP
events test and the running app over the control channel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-14 20:24:44 +02:00
parent a63ab4ac45
commit f1976c7d67
30 changed files with 2235 additions and 46 deletions

View file

@ -3,12 +3,14 @@
//! Serves JSON lines on `127.0.0.1:PORT` so that scripts and agents can run
//! engine commands and inspect the user interface. The protocol is described
//! in docs/architecture.md › Control channel; [`protocol`] parses and answers
//! single lines, [`server`] owns the sockets. Hosts plug in through
//! [`Backend`].
//! single lines, [`server`] owns the sockets, [`methods`] lists the
//! methods. Hosts plug in through [`Backend`] and publish engine events to
//! subscribed connections through [`Subscribers`].
mod backend;
pub mod methods;
pub mod protocol;
pub mod server;
pub use backend::Backend;
pub use backend::{Backend, EVENT_QUEUE, EventSink, Subscribers};
pub use server::{ServerHandle, start};