refactor(#2441): update queue consumers + docs for agent-per-node

DagView no longer has a DAG-level agent, so consumers derive it from the
per-node agents:
- hivectl dag_progress.rs: dag_agents(d) helper (distinct node agents,
  comma-joined) in place of d.agent.
- dashboard builds.js: entryAgents(entry) helper likewise for the
  rebuild-queue card + live-log header + cancel confirms.
- docs/coordinator.md: lease prose (node-agent-keyed, global per agent),
  wire shape (NodeView.agent, no DagView.agent), and dropped the removed
  dedup section.
This commit is contained in:
atlas 2026-07-14 21:42:37 +02:00 committed by mara
commit e2b48d2014
3 changed files with 66 additions and 36 deletions

View file

@ -68,7 +68,7 @@ async fn wait_for_dags_plain(socket: &Path, ids: Vec<u64>) -> Result<()> {
// sees whether the agent came back.
if d.nodes.iter().all(|n| n.state.is_terminal()) {
if d.state == hive_sh4re::jobs::State::Failed {
failed.push(format!("{} {}", d.kind.as_str(), d.agent));
failed.push(format!("{} {}", d.kind.as_str(), dag_agents(d)));
}
} else {
all_terminal = false;
@ -138,7 +138,7 @@ async fn wait_for_dags_animated(socket: &Path, ids: Vec<u64>) -> Result<()> {
"{} {} {} · {}",
state_glyph(d.state),
d.kind.as_str(),
d.agent,
dag_agents(d),
fmt_dur(dag_elapsed(d, now)),
));
for n in &d.nodes {
@ -166,7 +166,7 @@ async fn wait_for_dags_animated(socket: &Path, ids: Vec<u64>) -> Result<()> {
}
if d.nodes.iter().all(|n| n.state.is_terminal()) {
if d.state == hive_sh4re::jobs::State::Failed {
failed.push(format!("{} {}", d.kind.as_str(), d.agent));
failed.push(format!("{} {}", d.kind.as_str(), dag_agents(d)));
}
} else {
all_terminal = false;
@ -204,6 +204,19 @@ fn finish_wait(mut failed: Vec<String>) -> Result<()> {
}
}
/// Distinct agents across a DAG's nodes, comma-joined for display — the
/// per-node replacement for the old DAG-level `agent` field. Single-agent
/// DAGs render one name; a hive-wide DAG lists each.
fn dag_agents(d: &hive_sh4re::jobs::DagView) -> String {
let mut seen: Vec<&str> = Vec::new();
for n in &d.nodes {
if !seen.contains(&n.agent.as_str()) {
seen.push(&n.agent);
}
}
seen.join(",")
}
/// Current unix time in seconds (0 on the impossible pre-epoch error).
fn now_unix() -> i64 {
std::time::SystemTime::now()
@ -290,7 +303,7 @@ fn render_dag_line(d: &hive_sh4re::jobs::DagView) -> String {
"{} {} {:<12}",
state_glyph(d.state),
d.kind.as_str(),
d.agent
dag_agents(d)
);
for (i, n) in d.nodes.iter().enumerate() {
let sep = if i == 0 { " " } else { "" };
@ -314,9 +327,10 @@ mod tests {
use super::render_dag_line;
fn node(id: u32, kind: &str, state: State, step: Option<&str>) -> NodeView {
fn node(id: u32, agent: &str, kind: &str, state: State, step: Option<&str>) -> NodeView {
NodeView {
id,
agent: agent.to_owned(),
kind: kind.to_owned(),
deps: if id == 0 { vec![] } else { vec![id - 1] },
state,
@ -332,7 +346,6 @@ mod tests {
fn render_dag_line_shows_chain_and_running_step() {
let dag = DagView {
id: 7,
agent: "alice".to_owned(),
kind: Template::Rebuild,
state: State::Running,
source: Source::Manual,
@ -345,10 +358,16 @@ mod tests {
approval_id: None,
perm_payload: None,
nodes: vec![
node(0, "prebuild", State::Done, None),
node(1, "stop_for_update", State::Done, None),
node(2, "swap", State::Running, Some("nixos-container update")),
node(3, "reconcile", State::Queued, None),
node(0, "alice", "prebuild", State::Done, None),
node(1, "alice", "stop_for_update", State::Done, None),
node(
2,
"alice",
"swap",
State::Running,
Some("nixos-container update"),
),
node(3, "alice", "reconcile", State::Queued, None),
],
};
let line = render_dag_line(&dag);
@ -363,11 +382,10 @@ mod tests {
#[test]
fn render_dag_line_surfaces_first_node_error() {
let mut failed = node(0, "prebuild", State::Failed, None);
let mut failed = node(0, "bob", "prebuild", State::Failed, None);
failed.error = Some("nix build exploded".to_owned());
let dag = DagView {
id: 8,
agent: "bob".to_owned(),
kind: Template::Rebuild,
state: State::Failed,
source: Source::Manual,