rename: open_threads → loose_ends + cancel_thread → cancel_loose_end across wire / tools / web ui
This commit is contained in:
parent
b1d0a62cb9
commit
6e23d087d2
16 changed files with 152 additions and 139 deletions
|
|
@ -174,8 +174,8 @@ async fn dispatch(req: &AgentRequest, agent: &str, coord: &Arc<Coordinator>) ->
|
|||
timing,
|
||||
file_path,
|
||||
} => handle_remind(coord, agent, message, timing, file_path.as_deref()),
|
||||
AgentRequest::GetOpenThreads => match crate::open_threads::for_agent(coord, agent) {
|
||||
Ok(threads) => AgentResponse::OpenThreads { threads },
|
||||
AgentRequest::GetLooseEnds => match crate::loose_ends::for_agent(coord, agent) {
|
||||
Ok(loose_ends) => AgentResponse::LooseEnds { loose_ends },
|
||||
Err(e) => AgentResponse::Err {
|
||||
message: format!("{e:#}"),
|
||||
},
|
||||
|
|
@ -193,7 +193,7 @@ async fn dispatch(req: &AgentRequest, agent: &str, coord: &Arc<Coordinator>) ->
|
|||
role: "agent".to_owned(),
|
||||
hyperhive_rev: crate::auto_update::current_flake_rev(&coord.hyperhive_flake),
|
||||
},
|
||||
AgentRequest::CancelThread { kind, id } => crate::questions::handle_cancel_thread(
|
||||
AgentRequest::CancelLooseEnd { kind, id } => crate::questions::handle_cancel_loose_end(
|
||||
coord, agent, *kind, *id,
|
||||
)
|
||||
.map_or_else(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
//! Loose-ends aggregator. Walks the `approvals` + `operator_questions`
|
||||
//! tables once per call and assembles a `Vec<OpenThread>` for either
|
||||
//! tables once per call and assembles a `Vec<LooseEnd>` for either
|
||||
//! a single agent (`for_agent`) or the whole hive (`hive_wide`). Both
|
||||
//! `AgentRequest::GetOpenThreads` and `ManagerRequest::GetOpenThreads`
|
||||
//! `AgentRequest::GetLooseEnds` and `ManagerRequest::GetLooseEnds`
|
||||
//! land here so the routing logic + age-seconds derivation stay in
|
||||
//! one place.
|
||||
//!
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use anyhow::Result;
|
||||
use hive_sh4re::{MANAGER_AGENT, OpenThread};
|
||||
use hive_sh4re::{MANAGER_AGENT, LooseEnd};
|
||||
|
||||
use crate::coordinator::Coordinator;
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ use crate::coordinator::Coordinator;
|
|||
/// Ordered approvals → questions → reminders within the returned
|
||||
/// vector. Within each kind, source-of-truth ordering (sqlite's
|
||||
/// `pending()` queries return newest-first within their indexes).
|
||||
pub fn for_agent(coord: &Coordinator, agent: &str) -> Result<Vec<OpenThread>> {
|
||||
pub fn for_agent(coord: &Coordinator, agent: &str) -> Result<Vec<LooseEnd>> {
|
||||
let now = now_unix();
|
||||
let mut out = Vec::new();
|
||||
// Approvals are only submitted by the manager today. When that
|
||||
|
|
@ -41,7 +41,7 @@ pub fn for_agent(coord: &Coordinator, agent: &str) -> Result<Vec<OpenThread>> {
|
|||
// here on that column — for now MANAGER_AGENT == sole submitter.
|
||||
if agent == MANAGER_AGENT {
|
||||
for a in coord.approvals.pending()? {
|
||||
out.push(OpenThread::Approval {
|
||||
out.push(LooseEnd::Approval {
|
||||
id: a.id,
|
||||
agent: a.agent,
|
||||
commit_ref: a.commit_ref,
|
||||
|
|
@ -55,7 +55,7 @@ pub fn for_agent(coord: &Coordinator, agent: &str) -> Result<Vec<OpenThread>> {
|
|||
if !role_match {
|
||||
continue;
|
||||
}
|
||||
out.push(OpenThread::Question {
|
||||
out.push(LooseEnd::Question {
|
||||
id: q.id,
|
||||
asker: q.asker,
|
||||
target: q.target,
|
||||
|
|
@ -67,7 +67,7 @@ pub fn for_agent(coord: &Coordinator, agent: &str) -> Result<Vec<OpenThread>> {
|
|||
if r.agent != agent {
|
||||
continue;
|
||||
}
|
||||
out.push(OpenThread::Reminder {
|
||||
out.push(LooseEnd::Reminder {
|
||||
id: r.id,
|
||||
owner: r.agent,
|
||||
message: r.message,
|
||||
|
|
@ -82,11 +82,11 @@ pub fn for_agent(coord: &Coordinator, agent: &str) -> Result<Vec<OpenThread>> {
|
|||
/// unanswered question + EVERY pending reminder. Manager surface
|
||||
/// only; sub-agents can't see each other's threads via the agent
|
||||
/// surface (`for_agent` filters by name).
|
||||
pub fn hive_wide(coord: &Coordinator) -> Result<Vec<OpenThread>> {
|
||||
pub fn hive_wide(coord: &Coordinator) -> Result<Vec<LooseEnd>> {
|
||||
let now = now_unix();
|
||||
let mut out = Vec::new();
|
||||
for a in coord.approvals.pending()? {
|
||||
out.push(OpenThread::Approval {
|
||||
out.push(LooseEnd::Approval {
|
||||
id: a.id,
|
||||
agent: a.agent,
|
||||
commit_ref: a.commit_ref,
|
||||
|
|
@ -95,7 +95,7 @@ pub fn hive_wide(coord: &Coordinator) -> Result<Vec<OpenThread>> {
|
|||
});
|
||||
}
|
||||
for q in coord.questions.pending_all()? {
|
||||
out.push(OpenThread::Question {
|
||||
out.push(LooseEnd::Question {
|
||||
id: q.id,
|
||||
asker: q.asker,
|
||||
target: q.target,
|
||||
|
|
@ -104,7 +104,7 @@ pub fn hive_wide(coord: &Coordinator) -> Result<Vec<OpenThread>> {
|
|||
});
|
||||
}
|
||||
for r in coord.broker.list_pending_reminders()? {
|
||||
out.push(OpenThread::Reminder {
|
||||
out.push(LooseEnd::Reminder {
|
||||
id: r.id,
|
||||
owner: r.agent,
|
||||
message: r.message,
|
||||
|
|
@ -20,10 +20,10 @@ mod events_vacuum;
|
|||
mod forge;
|
||||
mod lifecycle;
|
||||
mod limits;
|
||||
mod loose_ends;
|
||||
mod manager_server;
|
||||
mod meta;
|
||||
mod migrate;
|
||||
mod open_threads;
|
||||
mod operator_questions;
|
||||
mod questions;
|
||||
mod reminder_scheduler;
|
||||
|
|
|
|||
|
|
@ -329,8 +329,8 @@ async fn dispatch(req: &ManagerRequest, coord: &Arc<Coordinator>) -> ManagerResp
|
|||
},
|
||||
}
|
||||
}
|
||||
ManagerRequest::GetOpenThreads => match crate::open_threads::hive_wide(coord) {
|
||||
Ok(threads) => ManagerResponse::OpenThreads { threads },
|
||||
ManagerRequest::GetLooseEnds => match crate::loose_ends::hive_wide(coord) {
|
||||
Ok(loose_ends) => ManagerResponse::LooseEnds { loose_ends },
|
||||
Err(e) => ManagerResponse::Err {
|
||||
message: format!("{e:#}"),
|
||||
},
|
||||
|
|
@ -348,7 +348,7 @@ async fn dispatch(req: &ManagerRequest, coord: &Arc<Coordinator>) -> ManagerResp
|
|||
role: "manager".to_owned(),
|
||||
hyperhive_rev: crate::auto_update::current_flake_rev(&coord.hyperhive_flake),
|
||||
},
|
||||
ManagerRequest::CancelThread { kind, id } => crate::questions::handle_cancel_thread(
|
||||
ManagerRequest::CancelLooseEnd { kind, id } => crate::questions::handle_cancel_loose_end(
|
||||
coord,
|
||||
MANAGER_AGENT,
|
||||
*kind,
|
||||
|
|
|
|||
|
|
@ -129,20 +129,20 @@ pub fn handle_answer(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Handle `CancelThread` from either surface. Dispatches by kind to
|
||||
/// Handle `CancelLooseEnd` from either surface. Dispatches by kind to
|
||||
/// either `OperatorQuestions::cancel` or `Broker::cancel_reminder_as`,
|
||||
/// both of which do their own auth check (canceller == owner /
|
||||
/// asker, or `operator`, or `manager`). On question cancel, fires
|
||||
/// the `QuestionAnswered` event back to the asker so the harness
|
||||
/// loop can react (mirrors the operator-cancel dashboard path).
|
||||
pub fn handle_cancel_thread(
|
||||
pub fn handle_cancel_loose_end(
|
||||
coord: &Arc<Coordinator>,
|
||||
canceller: &str,
|
||||
kind: hive_sh4re::CancelThreadKind,
|
||||
kind: hive_sh4re::CancelLooseEndKind,
|
||||
id: i64,
|
||||
) -> Result<(), String> {
|
||||
match kind {
|
||||
hive_sh4re::CancelThreadKind::Question => {
|
||||
hive_sh4re::CancelLooseEndKind::Question => {
|
||||
let (question, asker, target) = coord
|
||||
.questions
|
||||
.cancel(id, canceller)
|
||||
|
|
@ -161,7 +161,7 @@ pub fn handle_cancel_thread(
|
|||
coord.emit_question_resolved(id, &sentinel, canceller, true, target.as_deref());
|
||||
Ok(())
|
||||
}
|
||||
hive_sh4re::CancelThreadKind::Reminder => {
|
||||
hive_sh4re::CancelLooseEndKind::Reminder => {
|
||||
let owner = coord
|
||||
.broker
|
||||
.cancel_reminder_as(id, canceller)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue