queue: one owner of the hold; a trip belongs to the run whose end tripped it and its question holds that run's claims

Cut claimable's Mind-wide stop on any follow-up question and queue's inline
blocked loop. queue::on_hold is the one reader of what an in-force question
holds (a question raised in a run holds that run's claims, anything else holds
itself); queue, inbox::derive and the open_and_launch gate read it.
Breaker::Trip names the newest ended counted run; the breaker question is
raised in that run; the boundary is the newest of a question raised in the item
and a run claiming it that a question is raised in, so an answer or withdrawal
gives every claim of the run a fresh count. The trip and the held-brief wait
are written to the heartbeat trace.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-01 02:09:49 +01:00
commit 1b19180555
5 changed files with 217 additions and 70 deletions

View file

@ -18,7 +18,7 @@ use eureka_pipeline::PipelineKind;
use huginn_mind::{PipelineFacts, PipelineStatusSummary};
use crate::persona;
use crate::queue::{MindPort, any_of, headers, in_force, of_kind};
use crate::queue::{MindPort, any_of, headers, in_force, of_kind, on_hold};
/// The owner a follow-up names when it is a brief for her Self.
pub const OWNER: &str = "self-run";
@ -65,9 +65,19 @@ fn open_briefs(mind: &dyn MindPort) -> Result<Vec<Brief>> {
Ok(briefs)
}
/// Her briefs in force that the session has not been told.
/// Her briefs in force that the session has not been told and no open question
/// holds: a held brief is neither claimed nor told until its question is
/// answered or withdrawn.
pub fn derive(mind: &dyn MindPort, told: &HashSet<String>) -> Result<Vec<Brief>> {
Ok(open_briefs(mind)?.into_iter().filter(|brief| !told.contains(&brief.id)).collect())
Ok(derive_counting_held(mind, told)?.0)
}
/// `derive`, and how many of her briefs in force an open question holds.
pub fn derive_counting_held(mind: &dyn MindPort, told: &HashSet<String>) -> Result<(Vec<Brief>, usize)> {
let holds = on_hold(mind)?;
let (held, free): (Vec<Brief>, Vec<Brief>) =
open_briefs(mind)?.into_iter().partition(|brief| holds.iter().any(|item| item.kind == PipelineKind::FollowUp && item.id.0 == brief.id));
Ok((free.into_iter().filter(|brief| !told.contains(&brief.id)).collect(), held.len()))
}
/// Her briefs in force that a closed run claimed, with that run's id: a list for