Lutra/crates/engine/src/lib.rs
danny f1976c7d67 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>
2026-10-14 20:24:44 +02:00

26 lines
744 B
Rust

//! Engine of Lutra (layer L4).
//!
//! Owns the command registry, the workspace state, the panic guard around every
//! entry point and the crash-recovery journal. Every user-visible action is a
//! [`Command`]; menus, the palette, shortcuts, the CLI, the control channel and
//! MCP all reach it through [`Engine::execute`].
mod buffers;
pub mod cmd;
mod command;
mod engine;
mod error;
mod event;
pub mod guard;
mod registry;
mod state;
pub mod theme;
pub mod workspace;
pub use buffers::{BufferId, LineEndingName, OpenBuffer};
pub use command::{Command, CommandInfo, CommandSpec, Effect, Outcome};
pub use engine::Engine;
pub use error::{EngineError, ErrorPayload};
pub use event::Event;
pub use registry::Registry;
pub use state::State;