refactor(agent): remove vestigial turn_lock (serve loop is single-driver)
This commit is contained in:
parent
66f5b8720d
commit
efaf56c2d5
2 changed files with 3 additions and 21 deletions
|
|
@ -8,7 +8,6 @@ use std::path::{Path, PathBuf};
|
|||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use hive_ag3nt::web_ui::TurnLock;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::{Parser, Subcommand};
|
||||
|
|
@ -429,7 +428,6 @@ async fn serve_main<S: Surface>(socket: &Path, poll_ms: u64) -> Result<()> {
|
|||
}
|
||||
}
|
||||
let files = turn::TurnFiles::prepare(socket, &label).await?;
|
||||
let turn_lock: TurnLock = Arc::new(tokio::sync::Mutex::new(()));
|
||||
// Plugin install failures come back as a Vec<String> — route each
|
||||
// through `<parent>` via the `send_to_parent` failure-notify path.
|
||||
// The broker resolves `<parent>` per `topology::parent_of`;
|
||||
|
|
@ -477,7 +475,6 @@ async fn serve_main<S: Surface>(socket: &Path, poll_ms: u64) -> Result<()> {
|
|||
bus,
|
||||
stats,
|
||||
&files,
|
||||
turn_lock,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
@ -499,7 +496,6 @@ async fn serve_loop<S: Surface>(
|
|||
bus: Bus,
|
||||
stats: Option<TurnStats>,
|
||||
files: &turn::TurnFiles,
|
||||
turn_lock: TurnLock,
|
||||
) -> Result<()> {
|
||||
tracing::info!(socket = %socket.display(), "harness serve");
|
||||
S::requeue_inflight(socket).await;
|
||||
|
|
@ -520,10 +516,7 @@ async fn serve_loop<S: Surface>(
|
|||
// Idle: no message this poll. Service a queued operator
|
||||
// `/compact` here so it runs even when no turn is driving
|
||||
// (the in-flight case is handled at the end of drive_turn).
|
||||
let compacted = {
|
||||
let _guard = turn_lock.lock().await;
|
||||
turn::run_pending_compact(files, &bus, &session).await
|
||||
};
|
||||
let compacted = turn::run_pending_compact(files, &bus, &session).await;
|
||||
if !compacted {
|
||||
tokio::time::sleep(interval).await;
|
||||
}
|
||||
|
|
@ -547,7 +540,6 @@ async fn serve_loop<S: Surface>(
|
|||
&bus,
|
||||
stats.as_ref(),
|
||||
files,
|
||||
&turn_lock,
|
||||
&session,
|
||||
graceful_stop_message(),
|
||||
)
|
||||
|
|
@ -558,7 +550,7 @@ async fn serve_loop<S: Surface>(
|
|||
},
|
||||
};
|
||||
let ctrl =
|
||||
handle_turn::<S>(socket, &bus, stats.as_ref(), files, &turn_lock, &session, next).await;
|
||||
handle_turn::<S>(socket, &bus, stats.as_ref(), files, &session, next).await;
|
||||
if ctrl.auth_failed {
|
||||
*login_state.lock().unwrap() = LoginState::NeedsLogin;
|
||||
login::wait_for_login(
|
||||
|
|
@ -586,7 +578,6 @@ async fn handle_turn<S: Surface>(
|
|||
bus: &Bus,
|
||||
stats: Option<&TurnStats>,
|
||||
files: &turn::TurnFiles,
|
||||
turn_lock: &TurnLock,
|
||||
session: &turn::AgentSession,
|
||||
first: hive_sh4re::DeliveredMessage,
|
||||
) -> TurnControl {
|
||||
|
|
@ -607,10 +598,7 @@ async fn handle_turn<S: Surface>(
|
|||
let started_instant = std::time::Instant::now();
|
||||
let model_at_start = bus.model();
|
||||
let prompt = serve_common::format_wake_prompt(msg_id, &from, &body, unread, redelivered);
|
||||
let outcome = {
|
||||
let _guard = turn_lock.lock().await;
|
||||
turn::drive_turn(&prompt, files, bus, session).await
|
||||
};
|
||||
let outcome = turn::drive_turn(&prompt, files, bus, session).await;
|
||||
turn::emit_turn_end(bus, &outcome);
|
||||
bus.set_state(TurnState::Idle);
|
||||
if matches!(
|
||||
|
|
|
|||
|
|
@ -44,12 +44,6 @@ const SOCKET_FETCH_TIMEOUT: std::time::Duration = std::time::Duration::from_secs
|
|||
/// render.
|
||||
pub type LoginStateCell = Arc<Mutex<LoginState>>;
|
||||
|
||||
/// Shared turn lock. The serve loop acquires this (as an async mutex) for the
|
||||
/// duration of every `drive_turn` call. The `/api/compact` handler tries
|
||||
/// `try_lock()` and rejects immediately if a turn is in flight, preventing
|
||||
/// concurrent access to the claude session.
|
||||
pub type TurnLock = Arc<tokio::sync::Mutex<()>>;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct AppState {
|
||||
label: String,
|
||||
|
|
|
|||
Loading…
Reference in a new issue