Watch
0
0
Fork
You've already forked hyperhive
0

archetype flows behave like the built-ins: switch off per archetype or per agent, board cards, duplicate

The document's disabled list takes archetype:<archetype>/<flow> (off for every member) and the same with @<agent> (off for one member); a key naming nothing is ignored. GET /api/notify/flows lists the archetype flows with their members, the board draws a card for each with a switch, a checkbox per agent and duplicate, and the dry run counts their hits. The flows keep following the archetype.
This commit is contained in:
atlas 2026-11-11 19:08:19 +01:00 • committed by mara
commit 68c24643f6

View file

@ -738,4 +738,85 @@ mod tests {
]
);
}
/// An archetype edit changes what its member receives at the next read of
/// the archetype record, with no flow document stored at all.
#[tokio::test]
async fn an_archetype_edit_changes_what_a_member_receives() {
use swarm_queue_client::agent_archetype::{self, ArchetypeRef};
use swarm_queue_client::archetypes::{self, ArchetypeMeta, SourceRecord};
let nats = crate::test_nats::TestNats::start();
let client = nats.client().await;
let records = archetypes::open_or_create(&client).await.expect("records");
let choices = agent_archetype::open_or_create(&client)
.await
.expect("choices");
let choice = ArchetypeRef {
source: "hyperhive".to_owned(),
name: "triage".to_owned(),
};
choices
.put("alice", serde_json::to_vec(&choice).unwrap().into())
.await
.expect("put the choice");
let roster = std::collections::BTreeSet::from(["alice".to_owned()]);
let publish = |text: &'static str| {
let records = records.clone();
async move {
let mut flow = members_flow();
flow.id = "new".to_owned();
if let NodeKind::Todo(sink) = &mut flow.nodes[2].kind {
sink.text = text.to_owned();
}
let record = SourceRecord {
source: "hyperhive".to_owned(),
archetypes: [(
"triage".to_owned(),
ArchetypeMeta {
description: "d".to_owned(),
flows: vec![flow],
..ArchetypeMeta::default()
},
)]
.into(),
refused: std::collections::BTreeMap::default(),
};
records
.put("hyperhive", serde_json::to_vec(&record).unwrap().into())
.await
.expect("put the record");
}
};
let received = || async {
let flows = crate::archetype_flows::load(&client, &roster)
.await
.expect("a read");
let routed = super::route(
"issue_assign",
&delivery("assigned", &[]),
&Snapshot::default(),
&[],
&flows,
|_| true,
);
routed
.actions
.iter()
.map(|a| (a.agent.clone(), a.op.summary.clone()))
.collect::<Vec<_>>()
};
publish("first wording").await;
assert_eq!(
received().await,
[("alice".to_owned(), "first wording".to_owned())]
);
publish("second wording").await;
assert_eq!(
received().await,
[("alice".to_owned(), "second wording".to_owned())]
);
}
}