agent_permissions, agent_term and subagent_term take their wire contracts from swarm-wire
This commit is contained in:
parent
c06b1325e7
commit
839efd1642
27 changed files with 661 additions and 607 deletions
|
|
@ -232,10 +232,11 @@ pub mod agent_inference;
|
|||
/// and reading needs `agent-limits`.
|
||||
pub mod agent_limits;
|
||||
|
||||
/// The bucket swarm-controller sets each agent's permissions in — one key
|
||||
/// per agent, read by the hive that runs it, plus the one-shot import a hive
|
||||
/// sends. The names are unconditional; writing needs `kv` and the stored type
|
||||
/// and reading need `agent-permissions`.
|
||||
/// Opening and reading the bucket swarm-controller sets each agent's
|
||||
/// permissions in — one key per agent, read by the hive that runs it. The names,
|
||||
/// the stored type and the import messages are `swarm_wire::agent_permissions`;
|
||||
/// writing needs `kv` and reading needs `agent-permissions`.
|
||||
#[cfg(any(feature = "kv", feature = "agent-permissions"))]
|
||||
pub mod agent_permissions;
|
||||
|
||||
/// The bucket swarm-controller publishes each operator's name and forge-profile
|
||||
|
|
@ -348,39 +349,15 @@ pub const AGENT_CONTROL_SUBJECT_WILDCARD: &str = "$SWARM.control.*";
|
|||
/// Shared by [`agent_control_subject`] and [`AGENT_CONTROL_SUBJECT_WILDCARD`].
|
||||
const AGENT_CONTROL_SUBJECT_PREFIX: &str = "$SWARM.control";
|
||||
|
||||
/// The subject `agent` publishes its terminal rows on. One leaf per agent, so
|
||||
/// a subscriber can follow one agent without filtering the swarm's whole
|
||||
/// terminal traffic.
|
||||
///
|
||||
/// Shared by the publisher (`hive-agent`), the relay that streams it to
|
||||
/// swarm-ui (`swarm-controller`) and the queue's subscribe grant for readers
|
||||
/// (`swarm-nats-auth`), which spells [`term_subject_wildcard`] — so a rename
|
||||
/// moves all three together.
|
||||
#[must_use]
|
||||
pub fn term_subject(agent: &str) -> String {
|
||||
format!("{TERM_SUBJECT_PREFIX}.{agent}")
|
||||
}
|
||||
|
||||
/// Every [`term_subject`] at once: the reader's subscribe grant, which has no
|
||||
/// roster to enumerate agents from.
|
||||
#[must_use]
|
||||
pub fn term_subject_wildcard() -> String {
|
||||
term_subject("*")
|
||||
}
|
||||
|
||||
/// Shared by [`term_subject`] and [`subagent_term`], whose subjects sit under
|
||||
/// the same prefix.
|
||||
const TERM_SUBJECT_PREFIX: &str = "$SWARM.term";
|
||||
|
||||
/// The subject `agent` publishes its turn-state header on. Same shape and
|
||||
/// same three users as [`term_subject`].
|
||||
/// same three users as [`swarm_wire::term_subject`].
|
||||
#[must_use]
|
||||
pub fn agent_state_subject(agent: &str) -> String {
|
||||
format!("{AGENT_STATE_SUBJECT_PREFIX}.{agent}")
|
||||
}
|
||||
|
||||
/// Every [`agent_state_subject`] at once, for the same reason as
|
||||
/// [`term_subject_wildcard`].
|
||||
/// [`swarm_wire::term_subject_wildcard`].
|
||||
#[must_use]
|
||||
pub fn agent_state_subject_wildcard() -> String {
|
||||
agent_state_subject("*")
|
||||
|
|
@ -475,14 +452,16 @@ pub struct AgentInput {
|
|||
#[cfg(feature = "notices")]
|
||||
pub mod notices;
|
||||
|
||||
/// The stream that keeps an agent's own terminal rows, and the consumer a
|
||||
/// reader replays them through. Only the `JetStream` calls need the
|
||||
/// `agent-term` feature; the names are unconditional.
|
||||
/// Creating an agent's own terminal stream and the consumer a reader replays
|
||||
/// it through. The names, subjects, grants and replay start are
|
||||
/// `swarm_wire::agent_term`. Behind the `agent-term` feature.
|
||||
#[cfg(feature = "agent-term")]
|
||||
pub mod agent_term;
|
||||
|
||||
/// The subject an agent's subagents' terminal rows go to, and the per-agent
|
||||
/// stream that lists them. Only opening the stream needs the `subagent-term`
|
||||
/// feature; the names are unconditional, like [`agent_icon`]'s.
|
||||
/// Creating the per-agent stream that lists an agent's subagents. The names,
|
||||
/// subjects and grants are `swarm_wire::subagent_term`. Behind the
|
||||
/// `subagent-term` feature.
|
||||
#[cfg(feature = "subagent-term")]
|
||||
pub mod subagent_term;
|
||||
|
||||
/// Only the fields this needs; authelia returns several.
|
||||
|
|
@ -1119,12 +1098,9 @@ mod tests {
|
|||
|
||||
/// The names the publishers, the relays and the queue's grant all spell.
|
||||
#[test]
|
||||
fn term_and_agent_state_subjects_are_the_agreed_names() {
|
||||
assert_eq!(term_subject("mara"), "$SWARM.term.mara");
|
||||
assert_eq!(term_subject_wildcard(), "$SWARM.term.*");
|
||||
fn agent_state_subjects_are_the_agreed_names() {
|
||||
assert_eq!(agent_state_subject("mara"), "$SWARM.agent-state.mara");
|
||||
assert_eq!(agent_state_subject_wildcard(), "$SWARM.agent-state.*");
|
||||
assert_eq!(subagent_term::subject_wildcard(), "$SWARM.term.*.sub.*");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue