refactor(#1865): consolidate agent + manager socket servers into one
The per-agent and manager sockets ran two parallel dispatchers with duplicated lifecycle handlers (agent-side topology-gated, manager-side ungated) plus a manager-only handler set. Collapse to one parameterized server in socket_server.rs: - one serve() + dispatch(req, agent, privileged, coord); start() binds the per-agent sockets (privileged=false), start_manager() binds the manager socket (privileged=true). - each lifecycle/config handler (start/restart/kill/update/init_config/ apply_commit) merges its dual: the topology guard (require_child / require_new_child) runs only on the !privileged path; init_config records the requester as parent only when !privileged. restart keeps the orthogonal, capability-gated + audited infra-container branch. - the agent-state queries (loose-ends / reminder count + rollup) branch on privileged: privileged keeps any-target + the "*" hive-wide sweep (query_agent_state-gated), non-privileged keeps the topology/cap gate. - the privileged-only verbs (schedules / meta-inputs / get_logs) plus the submit/schedule/watchdog helpers move into socket_server; they are reached via dispatch_privileged_only(), which rejects the whole group on a non-privileged socket. - delete manager_server.rs; repoint refs; merge the test modules. No behavior change: the topology guard still applies on every non-privileged lifecycle call, the privileged socket still acts on any agent, and privileged-only verbs are still rejected on agent sockets.
This commit is contained in:
parent
a053d33184
commit
f5f06a5f14
11 changed files with 1034 additions and 1118 deletions
|
|
@ -76,7 +76,7 @@ pub(super) async fn post_kill(
|
|||
// host-side approval queue without the manager up, and
|
||||
// operator-driven meta-input updates work from the dashboard
|
||||
// either way. The MCP-surface self-kill guard in
|
||||
// `manager_server.rs::ManagerRequest::Kill` stays in place: a
|
||||
// `socket_server.rs::ManagerRequest::Kill` stays in place: a
|
||||
// manager calling Kill on its own container is self-suicide
|
||||
// mid-call, not a legitimate operator action.
|
||||
state.coord.rebuild_queue.enqueue(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ pub(super) async fn api_schedules(State(state): State<AppState>) -> Response {
|
|||
Ok(rows) => {
|
||||
let mut wire: Vec<hive_sh4re::WireSchedule> = rows
|
||||
.into_iter()
|
||||
.map(crate::manager_server::schedule_to_wire_public)
|
||||
.map(crate::socket_server::schedule_to_wire_public)
|
||||
.collect();
|
||||
// Drop ghost targets (agents that no longer exist) so the
|
||||
// table never shows dead columns. Uses the reliable async
|
||||
|
|
@ -33,7 +33,7 @@ pub(super) async fn api_schedules(State(state): State<AppState>) -> Response {
|
|||
.into_iter()
|
||||
.map(|c| c.name)
|
||||
.collect();
|
||||
crate::manager_server::filter_ghost_schedule_targets(&mut wire, &live);
|
||||
crate::socket_server::filter_ghost_schedule_targets(&mut wire, &live);
|
||||
axum::Json(wire).into_response()
|
||||
}
|
||||
Err(e) => error_response(&format!("scheduled_prompts list: {e:#}")),
|
||||
|
|
@ -214,7 +214,7 @@ pub(super) async fn patch_schedule(
|
|||
}
|
||||
match state.coord.scheduled_prompts.get(id) {
|
||||
Ok(Some(s)) => {
|
||||
let wire = crate::manager_server::schedule_to_wire_public(s);
|
||||
let wire = crate::socket_server::schedule_to_wire_public(s);
|
||||
state.coord.emit_schedules_snapshot();
|
||||
axum::Json(wire).into_response()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue