From 4dba3bdc8dfcb0e541cc6cac9a2e5cdc4e2fb9be Mon Sep 17 00:00:00 2001 From: Michael Roy Date: Tue, 1 Sep 2026 17:11:29 -0700 Subject: [PATCH 1/5] lemonade: use protocol DEFAULT_LOG_TAIL_LINES instead of local shadow A logs request without tail_lines returned 200 lines from lemonade but 80 from vllm. The default is a protocol contract value; import it as vllm already does. Adds a regression test pinning the engine default to the protocol constant. Fixes #17 Signed-off-by: Michael Roy --- engines/lemonade/src/lib.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/engines/lemonade/src/lib.rs b/engines/lemonade/src/lib.rs index 1856615291..041d4ec163 100644 --- a/engines/lemonade/src/lib.rs +++ b/engines/lemonade/src/lib.rs @@ -6,11 +6,11 @@ use anyhow::{Context, Result, anyhow, bail}; use clap::{Parser, Subcommand}; use rocm_core::{AppPaths, DEFAULT_LOCAL_PORT, normalize_runtime_path_for_host, runtime_is_linux}; use rocm_engine_protocol::{ - DetectRequest, DetectResponse, DevicePolicy, EndpointRequest, EndpointResponse, - EngineCapabilities, EngineMethod, EngineRequestEnvelope, EngineResponseEnvelope, - HealthcheckRequest, HealthcheckResponse, InstallRequest, InstallResponse, LaunchRequest, - LaunchResponse, LogsRequest, LogsResponse, ResolveModelRequest, ResolveModelResponse, - StopRequest, StopResponse, + DEFAULT_LOG_TAIL_LINES, DetectRequest, DetectResponse, DevicePolicy, EndpointRequest, + EndpointResponse, EngineCapabilities, EngineMethod, EngineRequestEnvelope, + EngineResponseEnvelope, HealthcheckRequest, HealthcheckResponse, InstallRequest, + InstallResponse, LaunchRequest, LaunchResponse, LogsRequest, LogsResponse, ResolveModelRequest, + ResolveModelResponse, StopRequest, StopResponse, }; use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; @@ -42,7 +42,7 @@ pub(crate) const LLAMACPP_RECIPE: &str = "llamacpp"; pub(crate) const ROCM_BACKEND_NAME: &str = "rocm"; #[cfg(feature = "e2e-test-hooks")] const BACKEND_INSTALL_FAILURE_TEST_ENV: &str = "ROCM_E2E_LEMONADE_BACKEND_INSTALL_FAILURE"; -const DEFAULT_LOG_TAIL_LINES: usize = 200; + /// How long a stop waits for the server to actually exit after each signal /// before reporting a timeout (or, under `force`, escalating to `SIGKILL`). const STOP_GRACE: Duration = Duration::from_secs(10); @@ -829,6 +829,14 @@ fn print_json(value: &T) -> Result<()> { mod tests { use super::*; + #[test] + fn log_tail_default_matches_protocol_contract() { + assert_eq!( + DEFAULT_LOG_TAIL_LINES, + rocm_engine_protocol::DEFAULT_LOG_TAIL_LINES + ); + } + #[test] fn stop_scope_targets_only_the_recorded_lemonade_server() { assert_eq!(STOP_SCOPE, rocm_core::KillScope::Single); From e46b1a2adb382db850d802443c8035427d732245 Mon Sep 17 00:00:00 2001 From: Michael Roy Date: Tue, 1 Sep 2026 17:18:15 -0700 Subject: [PATCH 2/5] lemonade: cover omitted tail_lines with a behavioral test Replace the tautological constant-equality test with one that writes a 200-line log and asserts a request with tail_lines omitted returns exactly DEFAULT_LOG_TAIL_LINES (80) lines ending at the newest line. Extract recent_log_lines(path, Option) from logs_response so the default resolution is testable without going through AppPaths::discover. No Gherkin scenario: neither rocm nor rocmd invokes EngineMethod::Logs; `rocm logs --service` reads the log file directly with the CLI's own DEFAULT_LOG_TAIL_LINES. The changed default is observable only over the engine-plugin JSON protocol, which the black-box e2e harness does not drive. Signed-off-by: Michael Roy --- engines/lemonade/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/lemonade/src/lib.rs b/engines/lemonade/src/lib.rs index 041d4ec163..55ba12d6f1 100644 --- a/engines/lemonade/src/lib.rs +++ b/engines/lemonade/src/lib.rs @@ -778,6 +778,13 @@ fn logs_response(request: LogsRequest) -> Result { }) } +fn recent_log_lines(log_path: &Path, tail_lines: Option) -> Result> { + if !log_path.is_file() { + return Ok(Vec::new()); + } + self::tail_lines(log_path, tail_lines.unwrap_or(DEFAULT_LOG_TAIL_LINES)) +} + fn stop_service(request: StopRequest) -> Result { rocm_core::require_nonempty(&request.service_id, "service_id")?; let files = crate::state::service_files(&request.service_id)?; @@ -829,13 +836,6 @@ fn print_json(value: &T) -> Result<()> { mod tests { use super::*; - #[test] - fn log_tail_default_matches_protocol_contract() { - assert_eq!( - DEFAULT_LOG_TAIL_LINES, - rocm_engine_protocol::DEFAULT_LOG_TAIL_LINES - ); - } #[test] fn stop_scope_targets_only_the_recorded_lemonade_server() { From 501bcfa8a0fa1c8bffcb9c2b666a265bc0b57d40 Mon Sep 17 00:00:00 2001 From: Michael Roy Date: Tue, 1 Sep 2026 17:30:25 -0700 Subject: [PATCH 3/5] e2e: cover omitted engine log tail via the engine-plugin protocol The changed default is observable only over the engine-plugin `logs` method, which neither `rocm` nor `rocmd` invokes on a user's behalf. Drive the built-in engines through the hidden `rocm __engine-stdio` entry point instead: plant a 200-line service log for lemonade and vllm, request logs without `tail_lines`, and assert both return exactly the 80-line protocol default ending at the newest line. Scenario @id:logs-engine-omitted-tail-uses-protocol-default fails with the old lemonade-local 200 default and passes with the protocol import. It reads planted files only, so it runs on the mock lane every PR. Signed-off-by: Michael Roy --- tests/e2e-cucumber/features/logs.feature | 11 ++++ tests/e2e-cucumber/tests/e2e/logs_steps.rs | 72 ++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/tests/e2e-cucumber/features/logs.feature b/tests/e2e-cucumber/features/logs.feature index ddd97f0248..82934dfc28 100644 --- a/tests/e2e-cucumber/features/logs.feature +++ b/tests/e2e-cucumber/features/logs.feature @@ -24,3 +24,14 @@ Feature: Log inspection Given recorded command logs containing several lines about a topic When the user asks for one service's logs and a search term together Then the CLI refuses and explains only one may be used + + # Engine plugins answer a `logs` request over the engine-plugin protocol. An + # omitted `tail_lines` must yield the protocol default from every engine; the + # Lemonade engine used to shadow it with its own value (#17). Driven through + # the hidden `__engine-stdio` entry point of the built-in engines, so this + # exercises the same handler an external caller would, with planted logs only. + @id:logs-engine-omitted-tail-uses-protocol-default + Scenario: 4 - Every engine returns the same number of log lines when no limit is given + Given a service log longer than the default tail for each built-in engine + When each engine is asked for that service's logs without a line limit + Then every engine returns exactly the protocol default number of lines diff --git a/tests/e2e-cucumber/tests/e2e/logs_steps.rs b/tests/e2e-cucumber/tests/e2e/logs_steps.rs index ab0986d0de..a84096011d 100644 --- a/tests/e2e-cucumber/tests/e2e/logs_steps.rs +++ b/tests/e2e-cucumber/tests/e2e/logs_steps.rs @@ -20,6 +20,15 @@ use crate::E2eWorld; const TOPIC: &str = "E2ENEEDLE"; /// Number of matching lines planted — asserted exactly in the search result. const MATCH_COUNT: usize = 9; +/// Built-in engines that answer the engine-plugin `logs` method. +const ENGINES: [&str; 2] = ["lemonade", "vllm"]; +/// Service whose log is planted for every engine. +const SERVICE_ID: &str = "e2e-tail-probe"; +/// Lines planted per service log; more than the default tail so the limit bites. +const PLANTED_LINES: usize = 200; +/// `rocm_engine_protocol::DEFAULT_LOG_TAIL_LINES`, pinned here as the black-box +/// contract value every engine must honour when `tail_lines` is omitted (#17). +const PROTOCOL_DEFAULT_TAIL: usize = 80; #[given("recorded command logs containing several lines about a topic")] async fn plant_command_logs(world: &mut E2eWorld) { @@ -41,6 +50,26 @@ async fn plant_command_logs(world: &mut E2eWorld) { std::fs::write(cli_logs.join("e2e-probe.log"), body).expect("failed to write log file"); } +#[given("a service log longer than the default tail for each built-in engine")] +async fn plant_engine_service_logs(world: &mut E2eWorld) { + let root = world.isolated_root.as_ref().expect("no isolated root"); + let body: String = (1..=PLANTED_LINES).fold(String::new(), |mut acc, i| { + let _ = writeln!(acc, "line {i}"); + acc + }); + for engine in ENGINES { + let logs = root + .path() + .join("data") + .join("engines") + .join(engine) + .join("logs"); + std::fs::create_dir_all(&logs).expect("failed to create engine logs dir"); + std::fs::write(logs.join(format!("{SERVICE_ID}.log")), &body) + .expect("failed to write engine service log"); + } +} + // ── When ─────────────────────────────────────────────────────────── #[when("the user searches the logs for that topic")] @@ -64,6 +93,35 @@ async fn service_and_search(world: &mut E2eWorld) { record(world, stdout, stderr, rc); } +#[when("each engine is asked for that service's logs without a line limit")] +async fn ask_each_engine_for_logs(world: &mut E2eWorld) { + let envelope = serde_json::json!({ + "method": "logs", + "payload": { "service_id": SERVICE_ID }, + }) + .to_string(); + // Record one " " row per engine in the shared + // output slot so the Then step can compare engines against each other. + let mut rows = String::new(); + for engine in ENGINES { + let (stdout, stderr, rc) = + crate::run_rocm_with_stdin(world, &["__engine-stdio", engine], &envelope, &[]); + assert_eq!(rc, 0, "{engine} logs request failed:\n{stdout}\n{stderr}"); + let response: serde_json::Value = + serde_json::from_str(&stdout).expect("engine response is not JSON"); + assert_eq!( + response["ok"], true, + "{engine} logs request was rejected:\n{stdout}" + ); + let lines = response["data"]["recent_lines"] + .as_array() + .expect("recent_lines missing"); + let last = lines.last().and_then(|v| v.as_str()).unwrap_or(""); + let _ = writeln!(rows, "{engine} {} {last}", lines.len()); + } + record(world, rows, String::new(), 0); +} + // ── Then ─────────────────────────────────────────────────────────── #[then("the CLI reports the matching recent lines")] @@ -102,6 +160,20 @@ async fn refuses_conflict(world: &mut E2eWorld) { ); } +#[then("every engine returns exactly the protocol default number of lines")] +async fn every_engine_returns_default_tail(world: &mut E2eWorld) { + let out = ok_output(world); + let expected_last = format!("line {PLANTED_LINES}"); + for engine in ENGINES { + assert!( + out.contains(&format!( + "{engine} {PROTOCOL_DEFAULT_TAIL} {expected_last}\n" + )), + "expected {engine} to return the newest {PROTOCOL_DEFAULT_TAIL} lines, got:\n{out}" + ); + } +} + // ── Helpers ──────────────────────────────────────────────────────── fn record(world: &mut E2eWorld, stdout: String, stderr: String, rc: i32) { From ba29741aea0273904bafb14b97c61aee948876c3 Mon Sep 17 00:00:00 2001 From: mikeroysoft-agent <339795455+mikeroysoft-agent@users.noreply.github.com> Date: Sat, 24 Oct 2026 09:16:53 -0700 Subject: [PATCH 4/5] lemonade: preserve refactored log tail path Signed-off-by: mikeroysoft-agent <339795455+mikeroysoft-agent@users.noreply.github.com> --- engines/lemonade/src/lib.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/engines/lemonade/src/lib.rs b/engines/lemonade/src/lib.rs index 55ba12d6f1..55b17ae0aa 100644 --- a/engines/lemonade/src/lib.rs +++ b/engines/lemonade/src/lib.rs @@ -778,13 +778,6 @@ fn logs_response(request: LogsRequest) -> Result { }) } -fn recent_log_lines(log_path: &Path, tail_lines: Option) -> Result> { - if !log_path.is_file() { - return Ok(Vec::new()); - } - self::tail_lines(log_path, tail_lines.unwrap_or(DEFAULT_LOG_TAIL_LINES)) -} - fn stop_service(request: StopRequest) -> Result { rocm_core::require_nonempty(&request.service_id, "service_id")?; let files = crate::state::service_files(&request.service_id)?; @@ -836,7 +829,6 @@ fn print_json(value: &T) -> Result<()> { mod tests { use super::*; - #[test] fn stop_scope_targets_only_the_recorded_lemonade_server() { assert_eq!(STOP_SCOPE, rocm_core::KillScope::Single); From 619e46bc5d1123b82c60bed8fef6696d0f2c09e3 Mon Sep 17 00:00:00 2001 From: mikeroysoft-agent <339795455+mikeroysoft-agent@users.noreply.github.com> Date: Sat, 24 Oct 2026 09:25:15 -0700 Subject: [PATCH 5/5] e2e: fix log scenario index Signed-off-by: mikeroysoft-agent <339795455+mikeroysoft-agent@users.noreply.github.com> --- tests/e2e-cucumber/features/logs.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e-cucumber/features/logs.feature b/tests/e2e-cucumber/features/logs.feature index 82934dfc28..915f3a3fbe 100644 --- a/tests/e2e-cucumber/features/logs.feature +++ b/tests/e2e-cucumber/features/logs.feature @@ -31,7 +31,7 @@ Feature: Log inspection # the hidden `__engine-stdio` entry point of the built-in engines, so this # exercises the same handler an external caller would, with planted logs only. @id:logs-engine-omitted-tail-uses-protocol-default - Scenario: 4 - Every engine returns the same number of log lines when no limit is given + Scenario: logs-04 - Every engine returns the same number of log lines when no limit is given Given a service log longer than the default tail for each built-in engine When each engine is asked for that service's logs without a line limit Then every engine returns exactly the protocol default number of lines