Watch
0
0
Fork
You've already forked hyperhive
0

gate each deploy on a swarm build of the agent from internal/meta

This commit is contained in:
atlas 2026-10-26 16:40:06 +01:00
commit 5e64048e53

View file

@ -243,8 +243,9 @@ impl Policy {
}
}
/// What the builder may do: hear build, archetype evaluation and meta-flake
/// lock requests and answer each on its reply subject, for as long as a build may take.
/// What the builder may do: hear build, archetype evaluation, meta-flake
/// lock and meta build requests and answer each on its reply subject, for
/// as long as a build may take.
/// Its publish list is its own inbox, for
/// [`Self::review_classifier_permissions`]' reason.
fn builder_permissions(client_id: &str) -> Permissions {
@ -254,6 +255,7 @@ impl Policy {
swarm_wire::builder::SUBJECT.to_owned(),
swarm_wire::builder::ARCHETYPES_SUBJECT.to_owned(),
swarm_wire::builder::LOCK_SUBJECT.to_owned(),
swarm_wire::builder::META_SUBJECT.to_owned(),
Self::inbox(client_id),
]),
responses: Some(swarm_wire::builder::REPLY_DEADLINE),
@ -710,6 +712,8 @@ impl Policy {
swarm_wire::builder::ARCHETYPES_SUBJECT.to_owned(),
// A swarm meta-flake lock, sent as a request the same way.
swarm_wire::builder::LOCK_SUBJECT.to_owned(),
// An agent build from the meta flake, sent as a request the same way.
swarm_wire::builder::META_SUBJECT.to_owned(),
// An operator's claude login step, sent as a request the same way.
swarm_wire::claude_login::SUBJECT.to_owned(),
// The notification router's deliveries log and a dry run of a flows
@ -1637,7 +1641,9 @@ mod tests {
#[test]
fn the_builder_hears_its_subject_and_inbox_only_and_answers_by_reply() {
use swarm_queue_client::client_inbox_prefix;
use swarm_wire::builder::{ARCHETYPES_SUBJECT, LOCK_SUBJECT, REPLY_DEADLINE, SUBJECT};
use swarm_wire::builder::{
ARCHETYPES_SUBJECT, LOCK_SUBJECT, META_SUBJECT, REPLY_DEADLINE, SUBJECT,
};
let p = policy()
.with_builders(vec![BUILDER.to_owned()])
@ -1647,6 +1653,7 @@ mod tests {
assert!(may_subscribe(&p, SUBJECT));
assert!(may_subscribe(&p, ARCHETYPES_SUBJECT));
assert!(may_subscribe(&p, LOCK_SUBJECT));
assert!(may_subscribe(&p, META_SUBJECT));
assert!(may_subscribe(&p, &reply(&inbox)));
for refused in [
">".to_owned(),
@ -1667,11 +1674,11 @@ mod tests {
#[test]
fn only_the_reader_may_send_a_build() {
use swarm_wire::builder::{ARCHETYPES_SUBJECT, LOCK_SUBJECT, SUBJECT};
use swarm_wire::builder::{ARCHETYPES_SUBJECT, LOCK_SUBJECT, META_SUBJECT, SUBJECT};
let p = with_classifier().with_builders(vec![BUILDER.to_owned()]);
let reader = p.permissions("swarm-controller").expect("the reader");
for subject in [SUBJECT, ARCHETYPES_SUBJECT, LOCK_SUBJECT] {
for subject in [SUBJECT, ARCHETYPES_SUBJECT, LOCK_SUBJECT, META_SUBJECT] {
assert!(reader.publish.iter().any(|g| covers(g, subject)));
for (who, grant) in [
("a hive", p.permissions("hive-alpha").expect("a hive")),
@ -1690,6 +1697,28 @@ mod tests {
}
}
/// The controller writes the closure bucket; the builder, which evaluates
/// unreviewed PR configs, cannot.
#[test]
fn only_the_controller_may_write_the_closure_bucket() {
use swarm_wire::agent_closures::key_subject;
let p = with_classifier().with_builders(vec![BUILDER.to_owned()]);
let key = key_subject("atlas");
let controller = p.permissions("swarm-controller").expect("the reader");
assert!(controller.publish.iter().any(|g| covers(g, &key)));
for (who, grant) in [
("a hive", p.permissions("hive-alpha").expect("a hive")),
("the builder", p.permissions(BUILDER).expect("admitted")),
] {
assert!(
!grant.publish.iter().any(|g| covers(g, &key)),
"{who} may write {key}: {:?}",
grant.publish
);
}
}
const CLAUDE_LOGIN: &str = "swarm-claude-login";
#[test]