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
|
|
@ -241,7 +241,7 @@ impl Policy {
|
|||
subscribe: Some(Self::reader_subscribe(client_id)),
|
||||
// The answer to a hive's permissions import. NATS lets it
|
||||
// answer only a message it received, once.
|
||||
responses: Some(swarm_queue_client::agent_permissions::IMPORT_REPLY_DEADLINE),
|
||||
responses: Some(swarm_wire::agent_permissions::IMPORT_REPLY_DEADLINE),
|
||||
});
|
||||
}
|
||||
if self.review_classifiers.iter().any(|c| c == client_id) {
|
||||
|
|
@ -324,15 +324,15 @@ impl Policy {
|
|||
/// to swarm-ui, every hive's permissions import, and its own reply inbox.
|
||||
///
|
||||
/// The three families are the publishers' (`hive-agent`'s `swarm_term`
|
||||
/// and `swarm_agent_state`, `swarm_queue_client::subagent_term`), spelled
|
||||
/// and `swarm_agent_state`, `swarm_wire::subagent_term`), spelled
|
||||
/// by the same `swarm_queue_client` helpers. Operator input, deploys and
|
||||
/// knowledge are absent: the reader publishes those.
|
||||
fn reader_subscribe(client_id: &str) -> Vec<String> {
|
||||
vec![
|
||||
swarm_queue_client::term_subject_wildcard(),
|
||||
swarm_queue_client::subagent_term::subject_wildcard(),
|
||||
swarm_wire::term_subject_wildcard(),
|
||||
swarm_wire::subagent_term::subject_wildcard(),
|
||||
swarm_queue_client::agent_state_subject_wildcard(),
|
||||
swarm_queue_client::agent_permissions::import_subject_wildcard(),
|
||||
swarm_wire::agent_permissions::import_subject_wildcard(),
|
||||
Self::inbox(client_id),
|
||||
]
|
||||
}
|
||||
|
|
@ -577,11 +577,11 @@ impl Policy {
|
|||
swarm_wire::agent_limits::STREAM
|
||||
));
|
||||
// The permissions the swarm grants those agents
|
||||
// (`swarm_queue_client::agent_permissions`), read the same way and
|
||||
// (`swarm_wire::agent_permissions`), read the same way and
|
||||
// every key for the same reason.
|
||||
subjects.push(format!(
|
||||
"$JS.API.DIRECT.GET.{}.>",
|
||||
swarm_queue_client::agent_permissions::STREAM
|
||||
swarm_wire::agent_permissions::STREAM
|
||||
));
|
||||
// The archetype an agent was created from
|
||||
// (`swarm_queue_client::agent_archetype`), read the same way and every
|
||||
|
|
@ -593,7 +593,7 @@ impl Policy {
|
|||
// The one-shot import of the grants this hive's meta repo held, sent
|
||||
// as a request on this hive's own subject: the controller takes the
|
||||
// hive from the subject, so one hive cannot import for another.
|
||||
subjects.push(swarm_queue_client::agent_permissions::import_subject(hive));
|
||||
subjects.push(swarm_wire::agent_permissions::import_subject(hive));
|
||||
subjects.extend(
|
||||
self.extra_hive_subjects
|
||||
.iter()
|
||||
|
|
@ -701,11 +701,11 @@ impl Policy {
|
|||
// which this client already subscribes to and reads by
|
||||
// `MSG.GET` above. No bare `CONSUMER.CREATE.<stream>`, whose
|
||||
// filter is unchecked.
|
||||
swarm_queue_client::agent_term::consumer_create_grant(),
|
||||
swarm_wire::agent_term::consumer_create_grant(),
|
||||
// The same for one subagent's rows in `term-sub-<agent>`: the
|
||||
// filter is `$SWARM.term.<agent>.sub.<subagent>`, two tokens
|
||||
// deeper than the grant above reaches.
|
||||
swarm_queue_client::subagent_term::consumer_create_grant(),
|
||||
swarm_wire::subagent_term::consumer_create_grant(),
|
||||
"$KV.*.>".to_owned(),
|
||||
]);
|
||||
// The per-agent status bucket, read-side only. Same five subjects as
|
||||
|
|
@ -925,7 +925,7 @@ mod tests {
|
|||
/// no other, and writes none.
|
||||
#[test]
|
||||
fn a_hive_reads_every_agents_permissions_and_an_agent_only_its_own() {
|
||||
use swarm_queue_client::agent_permissions::{STREAM, key_subject};
|
||||
use swarm_wire::agent_permissions::{STREAM, key_subject};
|
||||
|
||||
let direct_get_subject = |agent: &str| {
|
||||
format!("$JS.API.DIRECT.GET.KV_agent-permissions.$KV.agent-permissions.{agent}")
|
||||
|
|
@ -962,7 +962,7 @@ mod tests {
|
|||
/// hive's and may answer, and no other role may send one.
|
||||
#[test]
|
||||
fn a_hive_imports_only_under_its_own_name_and_the_reader_answers() {
|
||||
use swarm_queue_client::agent_permissions::{
|
||||
use swarm_wire::agent_permissions::{
|
||||
IMPORT_REPLY_DEADLINE, import_subject, import_subject_wildcard,
|
||||
};
|
||||
|
||||
|
|
@ -1408,7 +1408,7 @@ mod tests {
|
|||
let inbox = client_inbox_prefix("swarm-controller");
|
||||
for allowed in [
|
||||
"$SWARM.term.atlas".to_owned(),
|
||||
swarm_queue_client::subagent_term::subject("atlas", "scout"),
|
||||
swarm_wire::subagent_term::subject("atlas", "scout"),
|
||||
"$SWARM.agent-state.atlas".to_owned(),
|
||||
reply(&inbox),
|
||||
multiplexer(&inbox),
|
||||
|
|
@ -1443,8 +1443,8 @@ mod tests {
|
|||
.permissions("swarm-controller")
|
||||
.expect("the reader");
|
||||
for built in [
|
||||
swarm_queue_client::term_subject("atlas"),
|
||||
swarm_queue_client::subagent_term::subject("atlas", "scout"),
|
||||
swarm_wire::term_subject("atlas"),
|
||||
swarm_wire::subagent_term::subject("atlas", "scout"),
|
||||
swarm_queue_client::agent_state_subject("atlas"),
|
||||
] {
|
||||
assert!(
|
||||
|
|
@ -1778,8 +1778,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn the_controller_may_replay_terminal_rows_and_no_other_subject() {
|
||||
use swarm_queue_client::agent_term::stream_name;
|
||||
use swarm_queue_client::{subagent_term, term_subject};
|
||||
use swarm_wire::agent_term::stream_name;
|
||||
use swarm_wire::{subagent_term, term_subject};
|
||||
|
||||
let p = policy()
|
||||
.permissions("swarm-controller")
|
||||
|
|
@ -1983,7 +1983,7 @@ mod tests {
|
|||
/// the controller's to create, which its own grant covers.
|
||||
#[test]
|
||||
fn an_agents_subagent_grant_is_publish_on_its_own_family_only() {
|
||||
use swarm_queue_client::subagent_term::{stream_name, stream_subjects, subject};
|
||||
use swarm_wire::subagent_term::{stream_name, stream_subjects, subject};
|
||||
|
||||
let p = policy()
|
||||
.with_agent_token_subjects(vec!["$SWARM.term.{agent}.sub.>".to_owned()])
|
||||
|
|
|
|||
Loading…
Reference in a new issue