refactor(#1865): rename agent_server module to socket_server
Pure rename ahead of the agent+manager server consolidation: the per-agent socket dispatcher already hosts the shared dispatch and all lifecycle handlers, and will absorb the manager-only handlers next, so `agent_server` becomes a misnomer. No logic change — git mv plus a mechanical `agent_server` -> `socket_server` rename across refs.
This commit is contained in:
parent
b11360503a
commit
a053d33184
8 changed files with 14 additions and 14 deletions
|
|
@ -15,7 +15,7 @@
|
||||||
//!
|
//!
|
||||||
//! Same process-singleton handle pattern as `build_logs`: installed once
|
//! Same process-singleton handle pattern as `build_logs`: installed once
|
||||||
//! at `Coordinator::open`, fetched via [`global`] so the recording sites
|
//! at `Coordinator::open`, fetched via [`global`] so the recording sites
|
||||||
//! (e.g. `agent_server::handle_restart_infra`) don't have to thread an
|
//! (e.g. `socket_server::handle_restart_infra`) don't have to thread an
|
||||||
//! `Arc<AuditLog>` through every call path. Recording is best-effort: a
|
//! `Arc<AuditLog>` through every call path. Recording is best-effort: a
|
||||||
//! sqlite blip must never fail the underlying privileged action.
|
//! sqlite blip must never fail the underlying privileged action.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ fn auth_failed_sentinel(name: &str) -> bool {
|
||||||
|
|
||||||
/// Read the agent's free-text status and the Unix timestamp when it was last set
|
/// Read the agent's free-text status and the Unix timestamp when it was last set
|
||||||
/// (derived from the file's mtime). Returns `(None, None)` when the file is absent
|
/// (derived from the file's mtime). Returns `(None, None)` when the file is absent
|
||||||
/// or empty. `pub` so `agent_server` and `manager_server` can populate `AgentMeta`.
|
/// or empty. `pub` so `socket_server` and `manager_server` can populate `AgentMeta`.
|
||||||
///
|
///
|
||||||
/// NB: callers building `AgentMeta` for a *stopped* container should
|
/// NB: callers building `AgentMeta` for a *stopped* container should
|
||||||
/// clear the result — the on-disk status is a stale snapshot from
|
/// clear the result — the on-disk status is a stale snapshot from
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@ use std::sync::{Arc, Mutex};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use tokio::sync::{broadcast, watch};
|
use tokio::sync::{broadcast, watch};
|
||||||
|
|
||||||
use crate::agent_server::{self, AgentSocket};
|
|
||||||
use crate::approvals::Approvals;
|
use crate::approvals::Approvals;
|
||||||
use crate::broker::Broker;
|
use crate::broker::Broker;
|
||||||
use crate::container_view::{self, ContainerView};
|
use crate::container_view::{self, ContainerView};
|
||||||
use crate::dashboard_events::DashboardEvent;
|
use crate::dashboard_events::DashboardEvent;
|
||||||
use crate::operator_questions::OperatorQuestions;
|
use crate::operator_questions::OperatorQuestions;
|
||||||
|
use crate::socket_server::{self, AgentSocket};
|
||||||
|
|
||||||
/// Capacity of the dashboard event channel. Slow browser subscribers
|
/// Capacity of the dashboard event channel. Slow browser subscribers
|
||||||
/// (idle tab, throttled connection) drop frames past this — that's
|
/// (idle tab, throttled connection) drop frames past this — that's
|
||||||
|
|
@ -126,7 +126,7 @@ pub struct Coordinator {
|
||||||
/// `recent_crash_counts`, which prunes entries older than its window.
|
/// `recent_crash_counts`, which prunes entries older than its window.
|
||||||
recent_crashes: Mutex<HashMap<String, Vec<std::time::Instant>>>,
|
recent_crashes: Mutex<HashMap<String, Vec<std::time::Instant>>>,
|
||||||
/// Agents with a graceful stop in progress. Set by the `GracefulStop`
|
/// Agents with a graceful stop in progress. Set by the `GracefulStop`
|
||||||
/// orchestration; read by `agent_server::handle_recv`, which returns
|
/// orchestration; read by `socket_server::handle_recv`, which returns
|
||||||
/// `Response::GracefulStop` (instead of polling the broker) while an
|
/// `Response::GracefulStop` (instead of polling the broker) while an
|
||||||
/// agent is in this set — the inbound fence. Cleared when the agent
|
/// agent is in this set — the inbound fence. Cleared when the agent
|
||||||
/// reports `GracefulStopComplete` or the container is stopped.
|
/// reports `GracefulStopComplete` or the container is stopped.
|
||||||
|
|
@ -429,7 +429,7 @@ impl Coordinator {
|
||||||
crate::build_logs::install(build_logs.clone());
|
crate::build_logs::install(build_logs.clone());
|
||||||
// Audit log shares the same db dir; install its process-wide
|
// Audit log shares the same db dir; install its process-wide
|
||||||
// handle so privileged-action recording sites (e.g.
|
// handle so privileged-action recording sites (e.g.
|
||||||
// `agent_server::handle_restart_infra`) write without threading an
|
// `socket_server::handle_restart_infra`) write without threading an
|
||||||
// `Arc<AuditLog>` through the agent-request surface.
|
// `Arc<AuditLog>` through the agent-request surface.
|
||||||
let audit_log =
|
let audit_log =
|
||||||
Arc::new(crate::audit_log::AuditLog::open(build_logs_dir).context("open audit_log")?);
|
Arc::new(crate::audit_log::AuditLog::open(build_logs_dir).context("open audit_log")?);
|
||||||
|
|
@ -1068,7 +1068,7 @@ impl Coordinator {
|
||||||
// Hand the full Coordinator to the per-agent socket — it
|
// Hand the full Coordinator to the per-agent socket — it
|
||||||
// needs broker + operator_questions to handle the agent-side
|
// needs broker + operator_questions to handle the agent-side
|
||||||
// `ask` / `answer` tools, not just the broker.
|
// `ask` / `answer` tools, not just the broker.
|
||||||
let socket = agent_server::start(name, &socket_path, self.clone())?;
|
let socket = socket_server::start(name, &socket_path, self.clone())?;
|
||||||
self.agents.lock().unwrap().insert(name.to_owned(), socket);
|
self.agents.lock().unwrap().insert(name.to_owned(), socket);
|
||||||
Ok(agent_dir)
|
Ok(agent_dir)
|
||||||
}
|
}
|
||||||
|
|
@ -1136,7 +1136,7 @@ impl Coordinator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark `name` as having a graceful stop in progress. While set,
|
/// Mark `name` as having a graceful stop in progress. While set,
|
||||||
/// `agent_server::handle_recv` returns `Response::GracefulStop` for
|
/// `socket_server::handle_recv` returns `Response::GracefulStop` for
|
||||||
/// this agent instead of polling the broker (the inbound fence).
|
/// this agent instead of polling the broker (the inbound fence).
|
||||||
pub fn mark_graceful_stop(&self, name: &str) {
|
pub fn mark_graceful_stop(&self, name: &str) {
|
||||||
self.graceful_stop_pending
|
self.graceful_stop_pending
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
//! surface beyond "this is where the modules live".
|
//! surface beyond "this is where the modules live".
|
||||||
|
|
||||||
pub mod actions;
|
pub mod actions;
|
||||||
pub mod agent_server;
|
|
||||||
pub mod agent_sockets;
|
pub mod agent_sockets;
|
||||||
pub mod approvals;
|
pub mod approvals;
|
||||||
pub mod audit_log;
|
pub mod audit_log;
|
||||||
|
|
@ -52,5 +51,6 @@ pub mod reminder_scheduler;
|
||||||
pub mod scheduled_prompts;
|
pub mod scheduled_prompts;
|
||||||
pub mod scheduled_prompts_worker;
|
pub mod scheduled_prompts_worker;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
|
pub mod socket_server;
|
||||||
pub mod tool_groups;
|
pub mod tool_groups;
|
||||||
pub mod topology;
|
pub mod topology;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
//! to a state file and the path sent as the body.
|
//! to a state file and the path sent as the body.
|
||||||
//!
|
//!
|
||||||
//! Reminders get a separate auto-file escape hatch (see
|
//! Reminders get a separate auto-file escape hatch (see
|
||||||
//! `agent_server::handle_remind`) so callers don't have to think
|
//! `socket_server::handle_remind`) so callers don't have to think
|
||||||
//! about it — oversized reminder bodies get persisted to disk
|
//! about it — oversized reminder bodies get persisted to disk
|
||||||
//! transparently and the inbox sees a pointer.
|
//! transparently and the inbox sees a pointer.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ pub fn start(coord: Arc<Coordinator>) -> Result<()> {
|
||||||
let listener = UnixListener::bind(&socket)
|
let listener = UnixListener::bind(&socket)
|
||||||
.with_context(|| format!("bind manager socket {}", socket.display()))?;
|
.with_context(|| format!("bind manager socket {}", socket.display()))?;
|
||||||
// 0666 so the in-container root user (non-root) can connect;
|
// 0666 so the in-container root user (non-root) can connect;
|
||||||
// the bind source dir is manager-only on host. See agent_server.rs.
|
// the bind source dir is manager-only on host. See socket_server.rs.
|
||||||
std::fs::set_permissions(&socket, std::fs::Permissions::from_mode(0o666))
|
std::fs::set_permissions(&socket, std::fs::Permissions::from_mode(0o666))
|
||||||
.with_context(|| format!("chmod manager socket {}", socket.display()))?;
|
.with_context(|| format!("chmod manager socket {}", socket.display()))?;
|
||||||
tracing::info!(socket = %socket.display(), "manager socket listening");
|
tracing::info!(socket = %socket.display(), "manager socket listening");
|
||||||
|
|
@ -81,7 +81,7 @@ async fn dispatch(req: &ManagerRequest, coord: &Arc<Coordinator>) -> ManagerResp
|
||||||
// grant manager-level authority from the socket, not from matching the
|
// grant manager-level authority from the socket, not from matching the
|
||||||
// `MANAGER_AGENT` name. `MANAGER_AGENT` is still passed as the actor
|
// `MANAGER_AGENT` name. `MANAGER_AGENT` is still passed as the actor
|
||||||
// name for attribution/routing (notifications, ownership), not authz.
|
// name for attribution/routing (notifications, ownership), not authz.
|
||||||
if let Some(resp) = crate::agent_server::dispatch_shared(req, MANAGER_AGENT, true, coord).await
|
if let Some(resp) = crate::socket_server::dispatch_shared(req, MANAGER_AGENT, true, coord).await
|
||||||
{
|
{
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ fn inline_fallback(req_path: &str, reason: &str, message: &str) -> String {
|
||||||
/// Persist `message` to `host_path` with the symlink-escape defenses
|
/// Persist `message` to `host_path` with the symlink-escape defenses
|
||||||
/// described in the module docs. Returns `Ok(())` on success, or a
|
/// described in the module docs. Returns `Ok(())` on success, or a
|
||||||
/// human-readable reason string on any failure (caller logs +
|
/// human-readable reason string on any failure (caller logs +
|
||||||
/// inline-falls-back). `pub` because `agent_server::handle_remind`
|
/// inline-falls-back). `pub` because `socket_server::handle_remind`
|
||||||
/// reuses it for the at-remind-time auto-file path.
|
/// reuses it for the at-remind-time auto-file path.
|
||||||
pub fn write_payload(agent: &str, host_path: &Path, message: &str) -> Result<(), String> {
|
pub fn write_payload(agent: &str, host_path: &Path, message: &str) -> Result<(), String> {
|
||||||
let Some(parent) = host_path.parent() else {
|
let Some(parent) = host_path.parent() else {
|
||||||
|
|
@ -186,7 +186,7 @@ pub fn container_state_prefix(agent: &str) -> String {
|
||||||
/// validating that it lives under the agent's own state subtree, has
|
/// validating that it lives under the agent's own state subtree, has
|
||||||
/// a non-empty relative tail, and doesn't try to traverse out via
|
/// a non-empty relative tail, and doesn't try to traverse out via
|
||||||
/// `..`. Returns the host `PathBuf` on success, or a human-readable
|
/// `..`. Returns the host `PathBuf` on success, or a human-readable
|
||||||
/// reason string on rejection. `pub` so `agent_server::handle_remind`
|
/// reason string on rejection. `pub` so `socket_server::handle_remind`
|
||||||
/// can reuse it for the at-remind-time auto-file path.
|
/// can reuse it for the at-remind-time auto-file path.
|
||||||
pub fn resolve_host_path(agent: &str, req_path: &str) -> Result<PathBuf, String> {
|
pub fn resolve_host_path(agent: &str, req_path: &str) -> Result<PathBuf, String> {
|
||||||
let prefix = container_state_prefix(agent);
|
let prefix = container_state_prefix(agent);
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ pub(crate) fn recv_timeout(wait_seconds: Option<u64>) -> std::time::Duration {
|
||||||
/// semantics (e.g. `GetLooseEnds` / `CountPendingReminders` / `ReminderRollup`
|
/// semantics (e.g. `GetLooseEnds` / `CountPendingReminders` / `ReminderRollup`
|
||||||
/// where the manager can target other agents) or for manager-only variants.
|
/// where the manager can target other agents) or for manager-only variants.
|
||||||
///
|
///
|
||||||
/// Both `agent_server::dispatch` and `manager_server::dispatch` call this
|
/// Both `socket_server::dispatch` and `manager_server::dispatch` call this
|
||||||
/// first; each then handles its own remaining arms.
|
/// first; each then handles its own remaining arms.
|
||||||
pub(crate) async fn dispatch_shared(
|
pub(crate) async fn dispatch_shared(
|
||||||
req: &hive_sh4re::Request,
|
req: &hive_sh4re::Request,
|
||||||
Loading…
Reference in a new issue