M0.7: control channel over JSON lines

lutra_control::start binds 127.0.0.1:PORT and serves app.ping,
engine.execute, engine.listCommands and ui.screenshot through the Backend
trait the host implements. Lines are capped at 16 MiB, every input gets a
well-formed response with a stable error code, and backend panics become
internal errors. Proptests cover arbitrary lines; a TCP integration test
uses the new testkit EngineBackend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-14 06:47:30 +02:00
parent 07adedadbd
commit a3f83102f1
9 changed files with 979 additions and 3 deletions

View file

@ -0,0 +1,29 @@
//! The interface the control channel needs from its host.
use std::path::Path;
use lutra_engine::{CommandInfo, EngineError};
use serde_json::Value;
/// What the control channel can ask the host to do.
///
/// The desktop app implements it on top of its engine and window; tests
/// implement it with a bare engine. Methods are called from connection
/// threads, so implementations synchronise internally.
pub trait Backend: Send + Sync + 'static {
/// Runs an engine command and applies its effects.
///
/// # Errors
/// The engine's error for the command.
fn execute(&self, command: &str, params: Value) -> Result<Value, EngineError>;
/// Lists every command with its current enabled state.
fn list_commands(&self) -> Vec<CommandInfo>;
/// Writes a PNG screenshot of the main window to `path`.
///
/// # Errors
/// A message if there is no window to capture or the file cannot be
/// written.
fn screenshot(&self, path: &Path) -> Result<(), String>;
}