Luxe 0.1.3: your sessions on your phone, joinable sessions, and nested AGENTS.md
- luxe remote puts the sessions on your computer in reach of your own phone or tablet over Tailscale: write, steer, answer prompts, send photos, browse files, diffs and GitHub, with a paired device and your own Tailscale login. - luxe join lets another program on the same machine join a running session over the RPC protocol. - An AGENTS.md in a subfolder reaches the model the first time it works there. - Long sessions stay fast: no stall before each model call, lighter memory, cheaper drawing. - A session is open in one Luxe at a time, web_search shares results across its phrasings, and a grep glob starting with ! excludes. The CHANGELOG has the full list.
This commit is contained in:
76
crates/luxe-core/tests/engine/baseline_retention.rs
Normal file
76
crates/luxe-core/tests/engine/baseline_retention.rs
Normal file
@@ -0,0 +1,76 @@
|
||||
//! Baseline retention — a finished turn clears out the turn baselines nothing reads any more.
|
||||
|
||||
use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use luxe_core::engine::{Action, Engine, EngineConfig};
|
||||
use luxe_core::event::Event;
|
||||
use luxe_core::guided_review::TURN_BASELINE_CACHE_RELATIVE_DIR;
|
||||
use luxe_core::session::SessionStore;
|
||||
|
||||
use crate::fixtures::*;
|
||||
|
||||
fn committed_project(root: &std::path::Path) {
|
||||
std::fs::write(root.join("test.txt"), "Hello, World!").unwrap();
|
||||
for arguments in [
|
||||
["init"].as_slice(),
|
||||
["config", "user.email", "tests@example.invalid"].as_slice(),
|
||||
["config", "user.name", "Luxe Tests"].as_slice(),
|
||||
["add", "test.txt"].as_slice(),
|
||||
["commit", "-m", "initial fixture"].as_slice(),
|
||||
] {
|
||||
let status = Command::new("git").args(arguments).current_dir(root).status().unwrap();
|
||||
assert!(status.success(), "git {arguments:?} failed");
|
||||
}
|
||||
}
|
||||
|
||||
/// An hours-old baseline no record names, as a long session leaves behind.
|
||||
fn stale_baseline(root: &std::path::Path) -> std::path::PathBuf {
|
||||
let stale = root.join(TURN_BASELINE_CACHE_RELATIVE_DIR).join("f".repeat(64));
|
||||
std::fs::create_dir_all(stale.join("files")).unwrap();
|
||||
let hours_ago = SystemTime::now() - Duration::from_secs(2 * 60 * 60);
|
||||
std::fs::File::open(&stale).unwrap().set_modified(hours_ago).unwrap();
|
||||
stale
|
||||
}
|
||||
|
||||
/// Waits out the post-turn capture, which runs once the turn has ended and is done when it says
|
||||
/// the turn can be reviewed.
|
||||
async fn last_turn_available(events: &mut tokio::sync::mpsc::Receiver<Event>) {
|
||||
let wait = async {
|
||||
while let Some(event) = events.recv().await {
|
||||
if matches!(event, Event::LastTurnAvailable { .. }) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
panic!("the engine stopped before the turn could be reviewed");
|
||||
};
|
||||
tokio::time::timeout(EVENT_WAIT, wait).await.expect("the post-turn capture finishes");
|
||||
}
|
||||
|
||||
/// The break this catches: a turn that saves its record without pruning, so every turn leaves two
|
||||
/// full copies of the workspace behind for good.
|
||||
#[tokio::test]
|
||||
async fn a_finished_turn_prunes_old_baselines_and_keeps_its_own() {
|
||||
let project = tempfile::tempdir().unwrap();
|
||||
committed_project(project.path());
|
||||
let stale = stale_baseline(project.path());
|
||||
let mut store = project_store(project.path());
|
||||
let session_id = store.create(&project.path().display().to_string()).unwrap();
|
||||
let config = EngineConfig {
|
||||
guided_review_project_root: Some(project.path().to_path_buf()),
|
||||
..base_config(store, session_id, Arc::new(MockProvider::new()))
|
||||
};
|
||||
let (actions, mut events) = Engine::spawn(config);
|
||||
let message = Action::SubmitUserMessage {
|
||||
content: "Read test.txt".to_string(),
|
||||
images: vec![],
|
||||
remediation: None,
|
||||
};
|
||||
actions.send(message).await.unwrap();
|
||||
last_turn_available(&mut events).await;
|
||||
|
||||
assert!(!stale.exists(), "the hours-old baseline survived the turn");
|
||||
let cache = project.path().join(TURN_BASELINE_CACHE_RELATIVE_DIR);
|
||||
assert_eq!(std::fs::read_dir(cache).unwrap().count(), 2, "the turn's own pair should stay");
|
||||
}
|
||||
@@ -212,13 +212,24 @@ pub(crate) fn review_engine_config(
|
||||
project_root: &std::path::Path,
|
||||
session_id: SessionId,
|
||||
) -> EngineConfig {
|
||||
let store = JsonlSessionStore::new(project_root.to_path_buf());
|
||||
EngineConfig {
|
||||
guided_review_project_root: Some(project_root.to_path_buf()),
|
||||
..base_config(store, session_id, Arc::new(GuideManifestProvider::default()))
|
||||
..base_config(
|
||||
project_store(project_root),
|
||||
session_id,
|
||||
Arc::new(GuideManifestProvider::default()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The session store a project keeps under `.luxe`, as Luxe does, where Guided Review never looks.
|
||||
///
|
||||
/// Anywhere else in the project, the sessions are untracked files a review reads, and on Windows
|
||||
/// an open session's claim locks its `.lock` file against that read, so the review never loads.
|
||||
pub(crate) fn project_store(project_root: &std::path::Path) -> JsonlSessionStore {
|
||||
JsonlSessionStore::new(project_root.join(".luxe").join("sessions"))
|
||||
}
|
||||
|
||||
/// The first event `wanted` picks out of `events`, within the wait.
|
||||
pub(crate) async fn first<T>(
|
||||
events: &mut tokio::sync::mpsc::Receiver<Event>,
|
||||
|
||||
@@ -6,11 +6,15 @@
|
||||
|
||||
#![allow(clippy::unwrap_used)]
|
||||
|
||||
// Backdating a directory's modified time takes opening it, which only unix allows
|
||||
#[cfg(unix)]
|
||||
mod baseline_retention;
|
||||
mod carryover;
|
||||
mod compaction;
|
||||
mod fixtures;
|
||||
mod interruption;
|
||||
mod models;
|
||||
mod nested_instructions;
|
||||
mod remediation;
|
||||
mod review_restore;
|
||||
mod turns;
|
||||
|
||||
254
crates/luxe-core/tests/engine/nested_instructions.rs
Normal file
254
crates/luxe-core/tests/engine/nested_instructions.rs
Normal file
@@ -0,0 +1,254 @@
|
||||
//! Nested instructions — a folder's `AGENTS.md` joins the conversation when work reaches it, as an
|
||||
//! append the cached prefix survives.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::stream::{self, BoxStream};
|
||||
use luxe_core::engine::{Action, Engine};
|
||||
use luxe_core::event::Event;
|
||||
use luxe_core::message::ContentBlock;
|
||||
use luxe_core::provider::{CompletionRequest, Provider, ProviderError, ProviderEvent, StopReason};
|
||||
use luxe_core::session::{JsonlSessionStore, SessionStore};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use super::fixtures::*;
|
||||
|
||||
/// Calls one reply makes: `(tool, arguments)` each.
|
||||
type Reply = Vec<(&'static str, serde_json::Value)>;
|
||||
|
||||
/// Answers each request with the next scripted reply, and ends the turn once the script runs out.
|
||||
struct ScriptedCalls {
|
||||
replies: std::sync::Mutex<std::collections::VecDeque<Reply>>,
|
||||
requests: Arc<RwLock<Vec<CompletionRequest>>>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Provider for ScriptedCalls {
|
||||
fn name(&self) -> &str {
|
||||
"scripted-calls"
|
||||
}
|
||||
|
||||
async fn stream(
|
||||
&self,
|
||||
request: CompletionRequest,
|
||||
_cancel: tokio::sync::watch::Receiver<bool>,
|
||||
) -> Result<BoxStream<'static, ProviderEvent>, ProviderError> {
|
||||
let turn = self.requests.read().await.len();
|
||||
self.requests.write().await.push(request);
|
||||
let reply = self.replies.lock().unwrap().pop_front().unwrap_or_default();
|
||||
Ok(Box::pin(stream::iter(reply_events(turn, reply))))
|
||||
}
|
||||
}
|
||||
|
||||
/// The stream for `reply`: its calls, or a plain answer when it has none.
|
||||
fn reply_events(turn: usize, reply: Reply) -> Vec<ProviderEvent> {
|
||||
if reply.is_empty() {
|
||||
return vec![
|
||||
ProviderEvent::TextDelta { index: 0, delta: "done".to_string() },
|
||||
ProviderEvent::Done { reason: StopReason::EndTurn },
|
||||
];
|
||||
}
|
||||
let mut events = vec![ProviderEvent::Start];
|
||||
for (index, (name, args)) in reply.into_iter().enumerate() {
|
||||
let id = format!("call_{turn}_{index}");
|
||||
events.push(ProviderEvent::ToolCallStart { index, id, name: name.to_string() });
|
||||
events.push(ProviderEvent::ToolCallDelta { index, json_delta: args.to_string() });
|
||||
events.push(ProviderEvent::ToolCallEnd { index });
|
||||
}
|
||||
events.push(ProviderEvent::Done { reason: StopReason::ToolCall });
|
||||
events
|
||||
}
|
||||
|
||||
/// A checkout with root rules, `web/` rules and a file in `web/src`.
|
||||
fn project() -> tempfile::TempDir {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
std::fs::create_dir_all(dir.path().join(".git")).unwrap();
|
||||
std::fs::create_dir_all(dir.path().join("web/src")).unwrap();
|
||||
std::fs::write(dir.path().join("AGENTS.md"), "- ROOT-RULE\n").unwrap();
|
||||
std::fs::write(dir.path().join("web/AGENTS.md"), "- WEB-RULE\n").unwrap();
|
||||
std::fs::write(dir.path().join("web/src/app.ts"), "export {}\n").unwrap();
|
||||
dir
|
||||
}
|
||||
|
||||
/// Runs one turn launched at `project` with `script`, and returns every request and event.
|
||||
async fn run(
|
||||
project: &std::path::Path,
|
||||
script: Vec<Reply>,
|
||||
) -> (Vec<CompletionRequest>, Vec<Event>) {
|
||||
run_then(project, script, Vec::new()).await
|
||||
}
|
||||
|
||||
/// [`run`], then sends each of `after` and waits for the turn it starts to end.
|
||||
async fn run_then(
|
||||
project: &std::path::Path,
|
||||
script: Vec<Reply>,
|
||||
after: Vec<Action>,
|
||||
) -> (Vec<CompletionRequest>, Vec<Event>) {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let (tx, mut rx, requests) = spawn(&tmp, project, script);
|
||||
let content = "go".to_string();
|
||||
tx.send(Action::SubmitUserMessage { content, images: vec![], remediation: None })
|
||||
.await
|
||||
.unwrap();
|
||||
let mut events = events_until_turn_end(&mut rx).await;
|
||||
for action in after {
|
||||
tx.send(action).await.unwrap();
|
||||
events.extend(events_until_turn_end(&mut rx).await);
|
||||
}
|
||||
tx.send(Action::Close).await.ok();
|
||||
let requests = requests.read().await.clone();
|
||||
(requests, events)
|
||||
}
|
||||
|
||||
/// An engine launched at `project` that answers with `script`, recording what it's sent.
|
||||
fn spawn(
|
||||
tmp: &tempfile::TempDir,
|
||||
project: &std::path::Path,
|
||||
script: Vec<Reply>,
|
||||
) -> (
|
||||
tokio::sync::mpsc::Sender<Action>,
|
||||
tokio::sync::mpsc::Receiver<Event>,
|
||||
Arc<RwLock<Vec<CompletionRequest>>>,
|
||||
) {
|
||||
let mut store = JsonlSessionStore::new(tmp.path().join("sessions"));
|
||||
let sid = store.create("/tmp/test").unwrap();
|
||||
let requests = Arc::new(RwLock::new(Vec::new()));
|
||||
let replies = std::sync::Mutex::new(script.into());
|
||||
let provider = Arc::new(ScriptedCalls { replies, requests: requests.clone() });
|
||||
let mut config = base_config(store, sid, provider);
|
||||
config.tool_registry.register(WitnessReadTool::new());
|
||||
config.invoked_from = Some(project.to_path_buf());
|
||||
let (tx, rx) = Engine::spawn(config);
|
||||
(tx, rx, requests)
|
||||
}
|
||||
|
||||
/// A `read` of `relative` under `project`, by absolute path.
|
||||
fn read(project: &std::path::Path, relative: &str) -> (&'static str, serde_json::Value) {
|
||||
("read", serde_json::json!({ "path": project.join(relative).display().to_string() }))
|
||||
}
|
||||
|
||||
/// How many tool results in `request` carry `needle`.
|
||||
fn results_carrying(request: &CompletionRequest, needle: &str) -> usize {
|
||||
let outputs = request.messages.iter().flat_map(|message| &message.content);
|
||||
outputs
|
||||
.filter(|block| match block {
|
||||
ContentBlock::ToolResult { content, .. } => content.iter().any(|output| {
|
||||
matches!(output, luxe_core::message::ToolOutput::Text(text) if text.contains(needle))
|
||||
}),
|
||||
_ => false,
|
||||
})
|
||||
.count()
|
||||
}
|
||||
|
||||
/// A folder's rules reach the model once, on the result of the call that reached the folder, while
|
||||
/// every request keeps the same system prompt and extends the last request's messages exactly.
|
||||
///
|
||||
/// The break this catches: the nested file going into the system prompt, or being sent again on
|
||||
/// every call into its folder. Either rewrites what the provider cached and re-bills the
|
||||
/// conversation at the write rate.
|
||||
#[tokio::test]
|
||||
async fn a_nested_file_joins_once_and_every_request_extends_the_last() {
|
||||
let project = project();
|
||||
let p = project.path();
|
||||
let both = serde_json::json!({ "paths": [
|
||||
p.join("web/src/app.ts").display().to_string(),
|
||||
p.join("web/other.ts").display().to_string(),
|
||||
] });
|
||||
let script = vec![
|
||||
vec![read(p, "web/src/app.ts")],
|
||||
vec![("read", both)],
|
||||
vec![read(p, "web/src/app.ts")],
|
||||
];
|
||||
let (requests, events) = run(p, script).await;
|
||||
|
||||
assert_eq!(requests.len(), 4, "three calls, then the answer");
|
||||
let system = requests[0].system.clone().unwrap_or_default();
|
||||
assert!(system.contains("ROOT-RULE") && !system.contains("WEB-RULE"), "{system}");
|
||||
for (n, request) in requests.iter().enumerate() {
|
||||
assert_eq!(request.system.as_deref().unwrap_or_default(), system, "request {n}");
|
||||
}
|
||||
assert_eq!(results_carrying(&requests[0], "WEB-RULE"), 0, "not before the folder is reached");
|
||||
assert_eq!(results_carrying(&requests[3], "WEB-RULE"), 1, "once, however often it's reached");
|
||||
assert_eq!(results_carrying(&requests[3], "[instructions: web/AGENTS.md]"), 1);
|
||||
for n in 1..requests.len() {
|
||||
let before = serde_json::to_value(&requests[n - 1].messages).unwrap();
|
||||
let after =
|
||||
serde_json::to_value(&requests[n].messages[..requests[n - 1].messages.len()]).unwrap();
|
||||
assert_eq!(before, after, "request {n} rewrote the messages request {} sent", n - 1);
|
||||
}
|
||||
let told = events
|
||||
.iter()
|
||||
.any(|event| matches!(event, Event::Notice(text) if text == "Following web/AGENTS.md"));
|
||||
assert!(told, "the person is told which file joined");
|
||||
}
|
||||
|
||||
/// Two calls into the same folder in one reply carry its rules once, on the first.
|
||||
///
|
||||
/// The break this catches: checking only the committed conversation, so every call of a parallel
|
||||
/// batch got its own copy before any of them committed.
|
||||
#[tokio::test]
|
||||
async fn one_batch_carries_a_folder_s_rules_once() {
|
||||
let project = project();
|
||||
let p = project.path();
|
||||
let script = vec![vec![read(p, "web/src/app.ts"), read(p, "web/other.ts")]];
|
||||
let (requests, _) = run(p, script).await;
|
||||
let last = requests.last().unwrap();
|
||||
assert_eq!(results_carrying(last, "WEB-RULE"), 1);
|
||||
let first =
|
||||
last.messages.iter().flat_map(|message| &message.content).find_map(|block| match block {
|
||||
ContentBlock::ToolResult { call_id, content, .. } if call_id == "call_0_0" => {
|
||||
Some(content)
|
||||
}
|
||||
_ => None,
|
||||
});
|
||||
let carried = format!("{:?}", first.unwrap());
|
||||
assert!(carried.contains("WEB-RULE"), "on the first call: {carried}");
|
||||
}
|
||||
|
||||
/// A call that failed doesn't carry the rules; the next one into the folder that works does.
|
||||
///
|
||||
/// The break this catches: attaching to any call that named the folder, so the rules rode on an
|
||||
/// error the model may skim past, and were then counted as delivered.
|
||||
#[tokio::test]
|
||||
async fn a_failed_call_leaves_the_rules_for_the_next_one() {
|
||||
let project = project();
|
||||
let p = project.path();
|
||||
let missing =
|
||||
("missing", serde_json::json!({ "path": p.join("web/x.ts").display().to_string() }));
|
||||
let script = vec![vec![missing], vec![read(p, "web/x.ts")]];
|
||||
let (requests, _) = run(p, script).await;
|
||||
assert_eq!(results_carrying(&requests[1], "WEB-RULE"), 0, "not on the failure");
|
||||
assert_eq!(results_carrying(&requests[2], "WEB-RULE"), 1, "on the next call that worked");
|
||||
}
|
||||
|
||||
/// After an edit branches away from the result that carried a folder's rules, the next call into
|
||||
/// the folder carries them again.
|
||||
///
|
||||
/// The break this catches: remembering what was sent instead of reading it off the conversation,
|
||||
/// so a rewind took the rules away and nothing ever brought them back.
|
||||
#[tokio::test]
|
||||
async fn a_rewind_that_drops_the_rules_lets_them_go_again() {
|
||||
let project = project();
|
||||
let p = project.path();
|
||||
let script = vec![vec![read(p, "web/x.ts")], vec![], vec![read(p, "web/x.ts")]];
|
||||
let edit = Action::EditResend { content: "go again".to_string() };
|
||||
let (requests, _) = run_then(p, script, vec![edit]).await;
|
||||
let retried = requests.last().unwrap();
|
||||
assert_eq!(results_carrying(&requests[1], "WEB-RULE"), 1, "the first branch had them");
|
||||
assert_eq!(results_carrying(retried, WITNESS_OUTPUT), 1, "the edit's branch dropped it");
|
||||
assert_eq!(results_carrying(retried, "WEB-RULE"), 1, "and its own call carries them");
|
||||
}
|
||||
|
||||
/// A folder on the launch chain is the system prompt's, and a call into it adds nothing.
|
||||
///
|
||||
/// The break this catches: sending the launch folder's own file again as a nested one, so the
|
||||
/// same rules rode twice.
|
||||
#[tokio::test]
|
||||
async fn the_launch_folder_s_rules_are_not_sent_again() {
|
||||
let project = project();
|
||||
let p = project.path();
|
||||
let (requests, _) = run(&p.join("web"), vec![vec![read(p, "web/src/app.ts")]]).await;
|
||||
let system = requests[0].system.clone().unwrap_or_default();
|
||||
assert!(system.contains("WEB-RULE"), "launched in web/, the prompt has it: {system}");
|
||||
assert_eq!(results_carrying(&requests[1], "[instructions: "), 0);
|
||||
}
|
||||
@@ -302,9 +302,8 @@ async fn fix_two_comments(
|
||||
.success());
|
||||
}
|
||||
std::fs::write(project_root.join("tracked.rs"), "fn changed() {}\n").unwrap();
|
||||
let session_id = JsonlSessionStore::new(project_root.to_path_buf())
|
||||
.create(&project_root.display().to_string())
|
||||
.unwrap();
|
||||
let session_id =
|
||||
project_store(project_root).create(&project_root.display().to_string()).unwrap();
|
||||
let provider = Arc::new(ScriptedFixes {
|
||||
replies: std::sync::Mutex::new(replies.iter().copied().collect()),
|
||||
..Default::default()
|
||||
|
||||
@@ -10,7 +10,7 @@ use luxe_core::guided_review::{
|
||||
LastTurnRecord, LastTurnRecordStore, LocalGit, ReviewFeedbackMode, ReviewLoadRequestId,
|
||||
ReviewTarget, SubmissionId, SubmittedFinding, UntrackedSourcePolicy,
|
||||
};
|
||||
use luxe_core::session::{JsonlSessionStore, SessionStore};
|
||||
use luxe_core::session::SessionStore;
|
||||
|
||||
use crate::fixtures::*;
|
||||
|
||||
@@ -45,7 +45,7 @@ async fn a_last_turn_review_loads_the_turn_that_ran_and_refreshes_in_place() {
|
||||
std::fs::write(tmp_dir.join("PLAN.md"), "review plan evidence").unwrap();
|
||||
|
||||
// Setup session store.
|
||||
let mut store = JsonlSessionStore::new(tmp_dir.to_path_buf());
|
||||
let mut store = project_store(tmp_dir);
|
||||
let session_id = store.create(&tmp_dir.display().to_string()).unwrap();
|
||||
|
||||
let config = EngineConfig {
|
||||
@@ -220,7 +220,7 @@ async fn p32_guided_review_refresh_persists_a_fresh_artifact_after_worktree_muta
|
||||
}
|
||||
std::fs::write(project_root.join("tracked.rs"), "fn changed() {}\n").unwrap();
|
||||
|
||||
let mut store = JsonlSessionStore::new(project_root.to_path_buf());
|
||||
let mut store = project_store(project_root);
|
||||
let session_id = store.create(&project_root.display().to_string()).unwrap();
|
||||
let provider = Arc::new(GuideManifestProvider::default());
|
||||
let config = EngineConfig {
|
||||
@@ -410,11 +410,7 @@ async fn p32_guided_review_refresh_persists_a_fresh_artifact_after_worktree_muta
|
||||
|
||||
let resumed_config = EngineConfig {
|
||||
guided_review_project_root: Some(project_root.to_path_buf()),
|
||||
..base_config(
|
||||
JsonlSessionStore::new(project_root.to_path_buf()),
|
||||
session_id,
|
||||
Arc::new(MockProvider::new()),
|
||||
)
|
||||
..base_config(project_store(project_root), session_id, Arc::new(MockProvider::new()))
|
||||
};
|
||||
let (_resumed_actions, mut resumed_events) = Engine::spawn(resumed_config);
|
||||
let restored = tokio::time::timeout(EVENT_WAIT, async {
|
||||
@@ -462,7 +458,7 @@ async fn guided_review_last_turn_loads_a_retained_baseline_after_restart() {
|
||||
.success());
|
||||
}
|
||||
|
||||
let mut store = JsonlSessionStore::new(project_root.to_path_buf());
|
||||
let mut store = project_store(project_root);
|
||||
let session_id = store.create(&project_root.display().to_string()).unwrap();
|
||||
let turn_id = AgentTurnId::new();
|
||||
let git = LocalGit::new(project_root);
|
||||
|
||||
@@ -8,7 +8,7 @@ use luxe_core::engine::{Action, Engine};
|
||||
use luxe_core::event::Event;
|
||||
use luxe_core::guided_review::{FindingAnchor, FindingSeverity, ReviewLoadRequestId, ReviewTarget};
|
||||
use luxe_core::provider::{CompletionRequest, Provider, ProviderError, ProviderEvent, StopReason};
|
||||
use luxe_core::session::{JsonlSessionStore, SessionStore};
|
||||
use luxe_core::session::SessionStore;
|
||||
|
||||
use crate::fixtures::*;
|
||||
|
||||
@@ -39,9 +39,8 @@ async fn the_engine_owns_a_review_from_comment_to_report_and_through_a_restart()
|
||||
.success());
|
||||
}
|
||||
std::fs::write(project_root.join("tracked.rs"), "fn changed() {}\n").unwrap();
|
||||
let session_id = JsonlSessionStore::new(project_root.to_path_buf())
|
||||
.create(&project_root.display().to_string())
|
||||
.unwrap();
|
||||
let session_id =
|
||||
project_store(project_root).create(&project_root.display().to_string()).unwrap();
|
||||
|
||||
let (actions, mut events) =
|
||||
Engine::spawn(review_engine_config(project_root, session_id.clone()));
|
||||
@@ -163,9 +162,8 @@ async fn a_comment_saved_just_before_close_is_on_disk_when_the_engine_stops() {
|
||||
.success());
|
||||
}
|
||||
std::fs::write(project_root.join("tracked.rs"), "fn changed() {}\n").unwrap();
|
||||
let session_id = JsonlSessionStore::new(project_root.to_path_buf())
|
||||
.create(&project_root.display().to_string())
|
||||
.unwrap();
|
||||
let session_id =
|
||||
project_store(project_root).create(&project_root.display().to_string()).unwrap();
|
||||
|
||||
let (actions, mut events, task) =
|
||||
Engine::spawn_task(review_engine_config(project_root, session_id));
|
||||
@@ -264,9 +262,8 @@ async fn closing_does_not_wait_for_a_guide_being_written() {
|
||||
.success());
|
||||
}
|
||||
std::fs::write(project_root.join("tracked.rs"), "fn changed() {}\n").unwrap();
|
||||
let session_id = JsonlSessionStore::new(project_root.to_path_buf())
|
||||
.create(&project_root.display().to_string())
|
||||
.unwrap();
|
||||
let session_id =
|
||||
project_store(project_root).create(&project_root.display().to_string()).unwrap();
|
||||
let mut config = review_engine_config(project_root, session_id);
|
||||
config.provider = Arc::new(UntilCancelled);
|
||||
config.model = luxe_core::provider::ModelInfo {
|
||||
|
||||
@@ -168,6 +168,61 @@ async fn a_tool_call_announces_itself_while_the_model_is_still_writing_it() {
|
||||
action_tx.send(Action::Close).await.unwrap();
|
||||
}
|
||||
|
||||
/// What the reader sends is announced like any other committed message, before the reply.
|
||||
///
|
||||
/// The break this catches: announcing only messages Luxe composed, so a client joined to the
|
||||
/// session (the phone app, `luxe join`) shows answers to questions it never saw, and its snapshot
|
||||
/// for a later joiner leaves them out too.
|
||||
#[tokio::test]
|
||||
async fn a_sent_message_is_announced_to_every_client() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let mut store = JsonlSessionStore::new(tmp.path().to_path_buf());
|
||||
let session_id = store.create(&tmp.path().display().to_string()).unwrap();
|
||||
let config = base_config(store, session_id, Arc::new(MockProvider::new()));
|
||||
let (action_tx, mut event_rx) = Engine::spawn(config);
|
||||
let content = "Read test.txt".to_string();
|
||||
action_tx
|
||||
.send(Action::SubmitUserMessage { content, images: vec![], remediation: None })
|
||||
.await
|
||||
.unwrap();
|
||||
let events = events_until_turn_end(&mut event_rx).await;
|
||||
let first = first_committed(&events).expect("something was committed");
|
||||
assert_eq!(first.role, luxe_core::message::Role::User);
|
||||
assert_eq!(first.content, [luxe_core::message::ContentBlock::Text("Read test.txt".into())]);
|
||||
}
|
||||
|
||||
/// A turn says it started, once, before anything else of it, the user's message included.
|
||||
///
|
||||
/// The break this catches: no start signal at all, so a client that didn't send the message (the
|
||||
/// phone, the TUI beside it) has to guess from the first token; or one sent after the message
|
||||
/// commits, which leaves that client showing a saved message with no turn running.
|
||||
#[tokio::test]
|
||||
async fn a_turn_says_it_started_before_anything_else_of_it() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let mut store = JsonlSessionStore::new(tmp.path().to_path_buf());
|
||||
let session_id = store.create(&tmp.path().display().to_string()).unwrap();
|
||||
let config = base_config(store, session_id, Arc::new(MockProvider::new()));
|
||||
let (action_tx, mut event_rx) = Engine::spawn(config);
|
||||
let content = "Read test.txt".to_string();
|
||||
action_tx
|
||||
.send(Action::SubmitUserMessage { content, images: vec![], remediation: None })
|
||||
.await
|
||||
.unwrap();
|
||||
let events = events_until_turn_end(&mut event_rx).await;
|
||||
let started = |event: &Event| matches!(event, Event::TurnStarted);
|
||||
let committed = |event: &Event| matches!(event, Event::MessageCommitted { .. });
|
||||
assert_eq!(events.iter().filter(|event| started(event)).count(), 1);
|
||||
let start = events.iter().position(started).expect("turn_started");
|
||||
assert!(start < events.iter().position(committed).expect("a commit"), "{events:?}");
|
||||
}
|
||||
|
||||
fn first_committed(events: &[Event]) -> Option<&luxe_core::message::Message> {
|
||||
events.iter().find_map(|event| match event {
|
||||
Event::MessageCommitted { message, .. } => Some(message),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
/// A tool call the model makes runs the tool, and what it returned is in the next request.
|
||||
///
|
||||
/// Three claims, asserted apart so a failure says which link broke: dispatch ran the registered
|
||||
|
||||
Reference in New Issue
Block a user