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
|
||||
|
||||
@@ -118,6 +118,31 @@ fn the_frames_a_client_cannot_work_without_are_pinned() {
|
||||
r#"{"kind":"compaction_started","content":{"tokens_before":180000}}"#,
|
||||
),
|
||||
(Event::CompactionStopped, r#"{"kind":"compaction_stopped"}"#),
|
||||
(Event::TurnStarted, r#"{"kind":"turn_started"}"#),
|
||||
(
|
||||
Event::OpenReviewShown(Box::new(luxe_core::event::OpenReview {
|
||||
request_id: request_id("review-load:1"),
|
||||
review: None,
|
||||
session: None,
|
||||
reading: Vec::new(),
|
||||
})),
|
||||
r#"{"kind":"open_review_shown","content":{"request_id":"review-load:1","review":null,"session":null,"reading":[]}}"#,
|
||||
),
|
||||
(
|
||||
Event::ModelsListed {
|
||||
request_id: "models:1".into(),
|
||||
models: vec![luxe_core::event::ModelChoice {
|
||||
provider: "anthropic".into(),
|
||||
model: "claude-sonnet-5".into(),
|
||||
name: "Claude Sonnet 5".into(),
|
||||
thinking_levels: vec![
|
||||
luxe_core::provider::ThinkingLevel::Off,
|
||||
luxe_core::provider::ThinkingLevel::High,
|
||||
],
|
||||
}],
|
||||
},
|
||||
r#"{"kind":"models_listed","content":{"request_id":"models:1","models":[{"provider":"anthropic","model":"claude-sonnet-5","name":"Claude Sonnet 5","thinking_levels":["off","high"]}]}}"#,
|
||||
),
|
||||
(
|
||||
Event::PermissionRequested {
|
||||
id: request_id("perm:1"),
|
||||
@@ -143,6 +168,10 @@ fn the_frames_a_client_cannot_work_without_are_pinned() {
|
||||
},
|
||||
r#"{"kind":"question_asked","content":{"id":"ask:1","session_id":"session-1","prompt":"Which database?","options":[{"label":"postgres","description":"Relational, boring, correct","recommended":true}],"multi":false}}"#,
|
||||
),
|
||||
(
|
||||
Event::PromptClosed { id: "perm:1".into() },
|
||||
r#"{"kind":"prompt_closed","content":{"id":"perm:1"}}"#,
|
||||
),
|
||||
(
|
||||
Event::TokenDelta { block: 0, delta: "hello".into() },
|
||||
r#"{"kind":"token_delta","content":{"block":0,"delta":"hello"}}"#,
|
||||
@@ -561,7 +590,9 @@ fn every_known_event_roundtrips() {
|
||||
}],
|
||||
},
|
||||
Event::StateChanged(EngineState::default()),
|
||||
Event::TurnStarted,
|
||||
Event::TurnEnded { reason: StopReason::EndTurn },
|
||||
Event::ModelsListed { request_id: "models:1".into(), models: Vec::new() },
|
||||
Event::LastTurnAvailable { session_id: "session-1".into(), turn_id: "turn-1".into() },
|
||||
Event::CompactionStarted { tokens_before: 2_000 },
|
||||
Event::CompactionDone { tokens_before: 2_000, tokens_after: 1_000 },
|
||||
|
||||
@@ -22,7 +22,7 @@ use luxe_core::message::{ContentBlock, Message};
|
||||
use luxe_core::provider::{
|
||||
CompletionRequest, ModelInfo, Provider, ProviderError, ProviderEvent, StopReason, ToolSchema,
|
||||
};
|
||||
use luxe_core::session::{JsonlSessionStore, SessionStore};
|
||||
use luxe_core::session::{JsonlSessionStore, SessionId, SessionStore};
|
||||
use luxe_core::todo::{Todo, TodoStatus, TodoStore};
|
||||
use luxe_core::tool::{Tool, ToolContext, ToolRegistry, ToolResultData};
|
||||
use luxe_core::HookRegistry;
|
||||
@@ -479,12 +479,25 @@ impl Tool for NamedTool {
|
||||
}
|
||||
}
|
||||
|
||||
/// One provider call, as the tiering decided it: the prompt, and which tools it named.
|
||||
/// One provider call, as the tiering decided it: the prompt, which tools it named, and the tool
|
||||
/// calls its transcript carried.
|
||||
#[derive(Clone, Debug)]
|
||||
struct Sent {
|
||||
system: String,
|
||||
tools: Vec<String>,
|
||||
deferred: Vec<String>,
|
||||
calls: Vec<String>,
|
||||
}
|
||||
|
||||
/// The names of the tool calls in `messages`, in order.
|
||||
fn call_names(messages: &[Message]) -> Vec<String> {
|
||||
let blocks = messages.iter().flat_map(|message| &message.content);
|
||||
blocks
|
||||
.filter_map(|block| match block {
|
||||
ContentBlock::ToolCall { name, .. } => Some(name.clone()),
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Asks for `activate_tools {"names": ["test"]}` on its first call when `activate` is set, and
|
||||
@@ -512,6 +525,7 @@ impl Provider for ActivatingProvider {
|
||||
system: request.system.clone().unwrap_or_default(),
|
||||
tools: names(&request.tools),
|
||||
deferred: names(&request.deferred_tools),
|
||||
calls: call_names(&request.messages),
|
||||
});
|
||||
sent.len() == 1
|
||||
};
|
||||
@@ -607,33 +621,63 @@ async fn a_resumed_session_keeps_what_its_history_activated() {
|
||||
let sessions = tmp.path().join("sessions");
|
||||
let mut store = JsonlSessionStore::new(sessions.clone());
|
||||
let sid = store.create("/tmp/test").unwrap();
|
||||
let first = Arc::new(Mutex::new(Vec::new()));
|
||||
let provider = Arc::new(ActivatingProvider { sent: first.clone(), activate: true });
|
||||
let mut first_run =
|
||||
config(store, sid.clone(), tmp.path().join("todos"), provider, HookRegistry::new());
|
||||
first_run.tool_registry = tiered_tools();
|
||||
let (tx, mut rx) = Engine::spawn(first_run);
|
||||
run_turn(&tx, &mut rx, "activate").await;
|
||||
tx.send(Action::Close).await.ok();
|
||||
assert_eq!(first.lock().await.len(), 2, "the activation and its follow-up");
|
||||
let first = tiered_turn(store, &sid, tmp.path(), true).await;
|
||||
assert_eq!(first.len(), 2, "the activation and its follow-up");
|
||||
|
||||
// A new process on the same store, whose provider never activates anything itself
|
||||
let resumed = Arc::new(Mutex::new(Vec::new()));
|
||||
let provider = Arc::new(ActivatingProvider { sent: resumed.clone(), activate: false });
|
||||
let store = JsonlSessionStore::new(sessions);
|
||||
let mut second_run =
|
||||
config(store, sid.clone(), tmp.path().join("todos"), provider, HookRegistry::new());
|
||||
second_run.tool_registry = tiered_tools();
|
||||
let (tx, mut rx) = Engine::spawn(second_run);
|
||||
tx.send(Action::LoadSession(sid.to_string())).await.unwrap();
|
||||
run_turn(&tx, &mut rx, "resumed").await;
|
||||
tx.send(Action::Close).await.ok();
|
||||
|
||||
let resumed = resumed.lock().await.clone();
|
||||
let resumed = tiered_turn(JsonlSessionStore::new(sessions), &sid, tmp.path(), false).await;
|
||||
assert_eq!(resumed.len(), 1, "one call for the resumed turn: {resumed:?}");
|
||||
assert_eq!(resumed[0].tools, strings(&["activate_tools", "bash", "read", "test"]));
|
||||
}
|
||||
|
||||
/// A compacted session still carries the tool its summarized history loaded, restated after the
|
||||
/// summary.
|
||||
///
|
||||
/// The break this catches: the request builder dropping that restatement, which unloads the tool
|
||||
/// on an adapter that loads tools in place while the prompt promises it stays loaded.
|
||||
#[tokio::test]
|
||||
async fn a_compacted_session_restates_what_its_summary_replaced() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let sessions = tmp.path().join("sessions");
|
||||
let mut store = JsonlSessionStore::new(sessions.clone());
|
||||
let sid = store.create("/tmp/test").unwrap();
|
||||
tiered_turn(store, &sid, tmp.path(), true).await;
|
||||
|
||||
// A summary standing for everything before the newest entry, the activation included
|
||||
let mut store = JsonlSessionStore::new(sessions);
|
||||
let leaf = luxe_core::session::latest_leaf(&store.load(&sid).unwrap()).unwrap();
|
||||
store.compact(&sid, Some(leaf.clone()), "They loaded test.", &leaf, 0).unwrap();
|
||||
let resumed = tiered_turn(store, &sid, tmp.path(), false).await;
|
||||
|
||||
assert_eq!(resumed.len(), 1, "one call for the resumed turn: {resumed:?}");
|
||||
assert_eq!(resumed[0].calls, strings(&["activate_tools"]), "only the restatement");
|
||||
assert_eq!(resumed[0].tools, strings(&["activate_tools", "bash", "read", "test"]));
|
||||
}
|
||||
|
||||
/// One turn in a fresh engine on `store` over the tiered tools, as a new process would run it,
|
||||
/// returning every provider call.
|
||||
///
|
||||
/// With `activate`, the provider loads `test` on its first call; without, it never activates
|
||||
/// anything itself and the engine resumes `sid` first, so what is loaded came from the history.
|
||||
async fn tiered_turn(
|
||||
store: JsonlSessionStore,
|
||||
sid: &SessionId,
|
||||
dir: &std::path::Path,
|
||||
activate: bool,
|
||||
) -> Vec<Sent> {
|
||||
let sent = Arc::new(Mutex::new(Vec::new()));
|
||||
let provider = Arc::new(ActivatingProvider { sent: sent.clone(), activate });
|
||||
let mut run = config(store, sid.clone(), dir.join("todos"), provider, HookRegistry::new());
|
||||
run.tool_registry = tiered_tools();
|
||||
let (tx, mut rx) = Engine::spawn(run);
|
||||
if !activate {
|
||||
tx.send(Action::LoadSession(sid.to_string())).await.unwrap();
|
||||
}
|
||||
run_turn(&tx, &mut rx, if activate { "activate" } else { "resumed" }).await;
|
||||
tx.send(Action::Close).await.ok();
|
||||
let calls = sent.lock().await.clone();
|
||||
calls
|
||||
}
|
||||
|
||||
/// Submit one message and wait for the turn it starts to end.
|
||||
async fn run_turn(
|
||||
tx: &tokio::sync::mpsc::Sender<Action>,
|
||||
|
||||
@@ -139,12 +139,16 @@ async fn submit(
|
||||
}
|
||||
|
||||
/// Every file's contents under `dir`, concatenated.
|
||||
///
|
||||
/// Session claims are skipped: they hold nothing, and on Windows an open session's claim locks its
|
||||
/// `.lock` file against any other read.
|
||||
fn everything_under(dir: &std::path::Path) -> String {
|
||||
std::fs::read_dir(dir)
|
||||
.unwrap()
|
||||
.flatten()
|
||||
.map(|entry| match entry.path() {
|
||||
path if path.is_dir() => everything_under(&path),
|
||||
path if path.extension().is_some_and(|extension| extension == "lock") => String::new(),
|
||||
path => std::fs::read_to_string(path).unwrap(),
|
||||
})
|
||||
.collect()
|
||||
|
||||
@@ -39,6 +39,36 @@ async fn ask_once_allows_the_tool() {
|
||||
assert_eq!(runs.load(Ordering::SeqCst), 1, "approved tool must run once");
|
||||
}
|
||||
|
||||
/// Whichever front-end answers, every other one showing the prompt hears that it closed.
|
||||
///
|
||||
/// The break this catches: dropping the `PromptClosed` after the reply, which leaves a second
|
||||
/// front-end (a phone joined to the session) holding a prompt nobody is waiting on.
|
||||
#[tokio::test]
|
||||
async fn an_answered_prompt_is_announced_closed() {
|
||||
use luxe_core::Event;
|
||||
let (tx, mut rx, _) = spawn(bash_policy(PermissionAction::Ask, AskResolution::Prompt)).await;
|
||||
tx.send(Action::SubmitUserMessage { content: "go".into(), images: vec![], remediation: None })
|
||||
.await
|
||||
.unwrap();
|
||||
let (mut asked, mut closed) = (None, None);
|
||||
loop {
|
||||
let wait = tokio::time::timeout(std::time::Duration::from_secs(5), rx.recv()).await;
|
||||
match wait.expect("the turn ends").expect("the engine is running") {
|
||||
Event::PermissionRequested { id, .. } => {
|
||||
asked = Some(id.as_str().to_string());
|
||||
tx.send(Action::RespondPermission { id, reply: PermissionReply::Once })
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
Event::PromptClosed { id } => closed = Some(id),
|
||||
Event::TurnEnded { .. } => break,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
assert!(asked.is_some(), "the policy asks");
|
||||
assert_eq!(closed, asked);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn ask_always_persists_across_the_session() {
|
||||
let (tx, mut rx, runs) = spawn(bash_policy(PermissionAction::Ask, AskResolution::Prompt)).await;
|
||||
|
||||
@@ -86,6 +86,13 @@ fn git(root: &std::path::Path, arguments: &[&str]) {
|
||||
assert!(Command::new("git").args(arguments).current_dir(root).status().unwrap().success());
|
||||
}
|
||||
|
||||
/// Where the repository keeps its sessions: under `.luxe`, as Luxe does, where Guided Review never
|
||||
/// looks. Anywhere else they 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.
|
||||
fn sessions_root(root: &std::path::Path) -> std::path::PathBuf {
|
||||
root.join(".luxe").join("sessions")
|
||||
}
|
||||
|
||||
/// A repository with one committed file, changed in the working tree.
|
||||
fn changed_repository() -> tempfile::TempDir {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
@@ -131,7 +138,7 @@ async fn guide_costs(
|
||||
async fn the_guide_runs_on_the_model_the_session_switched_to() {
|
||||
let repository = changed_repository();
|
||||
let root = repository.path();
|
||||
let mut store = JsonlSessionStore::new(root.join("sessions"));
|
||||
let mut store = JsonlSessionStore::new(sessions_root(root));
|
||||
let session = store.create("/tmp/a").unwrap();
|
||||
let asked = Arc::new(Mutex::new(Vec::new()));
|
||||
let mut config = engine_config(store, session, root);
|
||||
@@ -191,7 +198,7 @@ async fn the_guide_runs_on_the_model_the_session_switched_to() {
|
||||
async fn late_guide_spend_settles_to_the_session_that_asked() {
|
||||
let repository = changed_repository();
|
||||
let root = repository.path();
|
||||
let mut store = JsonlSessionStore::new(root.join("sessions"));
|
||||
let mut store = JsonlSessionStore::new(sessions_root(root));
|
||||
let asking = store.create("/tmp/a").unwrap();
|
||||
let other = store.create("/tmp/b").unwrap();
|
||||
let asked = Arc::new(Mutex::new(Vec::new()));
|
||||
@@ -243,7 +250,7 @@ async fn late_guide_spend_settles_to_the_session_that_asked() {
|
||||
assert!(!matches!(event, Event::TurnUsage { .. }), "published to the wrong session");
|
||||
}
|
||||
let usage_in = |session: &SessionId| {
|
||||
let entries = JsonlSessionStore::new(root.join("sessions")).load(session).unwrap();
|
||||
let entries = JsonlSessionStore::new(sessions_root(root)).load(session).unwrap();
|
||||
entries
|
||||
.iter()
|
||||
.filter(|entry| {
|
||||
@@ -266,7 +273,7 @@ async fn late_guide_spend_settles_to_the_session_that_asked() {
|
||||
async fn late_guide_spend_joins_its_session_when_it_is_open_again() {
|
||||
let repository = changed_repository();
|
||||
let root = repository.path();
|
||||
let mut store = JsonlSessionStore::new(root.join("sessions"));
|
||||
let mut store = JsonlSessionStore::new(sessions_root(root));
|
||||
let asking = store.create("/tmp/a").unwrap();
|
||||
let other = store.create("/tmp/b").unwrap();
|
||||
let asked = Arc::new(Mutex::new(Vec::new()));
|
||||
@@ -332,7 +339,7 @@ async fn late_guide_spend_joins_its_session_when_it_is_open_again() {
|
||||
|
||||
let totals = totals.expect("a session total");
|
||||
assert_eq!(review_tokens(totals), Some(1_000_000), "and still counted after the turn");
|
||||
let store = JsonlSessionStore::new(root.join("sessions"));
|
||||
let store = JsonlSessionStore::new(sessions_root(root));
|
||||
let entries = store.load(&asking).unwrap();
|
||||
let leaf = luxe_core::session::latest_leaf(&entries).unwrap();
|
||||
let path = store.active_path(&asking, &leaf).unwrap();
|
||||
|
||||
@@ -209,6 +209,45 @@ async fn lifecycle_hooks_follow_the_session_the_engine_is_on() {
|
||||
assert_eq!(after.last(), Some(&HookPoint::SessionEnd), "{after:?}");
|
||||
}
|
||||
|
||||
/// The engine holds the session it's on, and won't switch to one another process holds.
|
||||
///
|
||||
/// The break this catches: loading a session without claiming it, so two Luxes append to one log
|
||||
/// and a resume shows only one of their conversations.
|
||||
#[tokio::test]
|
||||
async fn a_session_held_by_another_process_is_not_switched_to() {
|
||||
let project = tempfile::tempdir().unwrap();
|
||||
let mut store = JsonlSessionStore::new(project.path().join("sessions"));
|
||||
let mine = store.create("/tmp/a").unwrap();
|
||||
let theirs = store.create("/tmp/b").unwrap();
|
||||
let lock = |id: &SessionId| store.session_path(id).unwrap().with_extension("lock");
|
||||
let (my_lock, their_lock) = (lock(&mine), lock(&theirs));
|
||||
let other_process = std::fs::File::create(&their_lock).unwrap();
|
||||
other_process.try_lock().unwrap();
|
||||
let (actions, mut events, task) =
|
||||
Engine::spawn_task(engine_config(store, mine.clone(), project.path()));
|
||||
|
||||
actions.send(Action::LoadSession(theirs.to_string())).await.unwrap();
|
||||
let refusal = first(&mut events, "the refusal", |event| match event {
|
||||
Event::Error(message) => Some(message),
|
||||
Event::SessionLoaded { session_id, .. } if session_id == theirs.0 => {
|
||||
panic!("switched to a session another process holds")
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.await;
|
||||
assert!(refusal.contains("open in another Luxe"), "{refusal}");
|
||||
let claimed = std::fs::File::open(&my_lock).unwrap().try_lock().is_err();
|
||||
assert!(claimed, "the engine doesn't hold the session it's on");
|
||||
turn(&actions, &mut events, "still in my session").await;
|
||||
|
||||
actions.send(Action::Close).await.unwrap();
|
||||
let drained = tokio::spawn(async move { while events.recv().await.is_some() {} });
|
||||
tokio::time::timeout(WAIT, task).await.expect("the engine stops").unwrap();
|
||||
drained.abort();
|
||||
let theirs_log = std::fs::read_to_string(their_lock.with_extension("jsonl")).unwrap();
|
||||
assert!(!theirs_log.contains("still in my session"), "wrote into the held session");
|
||||
}
|
||||
|
||||
/// Reopening the session the engine is already on is not a switch: no hook hears of it.
|
||||
#[tokio::test]
|
||||
async fn reloading_the_same_session_starts_nothing_new() {
|
||||
|
||||
Reference in New Issue
Block a user