Watch
0
0
Fork
You've already forked hyperhive
0

agents get a per-agent repo limit in their permissions record, orgs are locked

max_repos (default 0, 0..=100) lives in the agent's agent-permissions record and is edited on its permissions panel. The controller applies each agent's own value as max_repo_creation at CreateForgeUser and to existing accounts on change, restart and every five minutes; agent accounts may not create organizations.
This commit is contained in:
atlas 2026-11-15 20:47:21 +01:00 • committed by mara
commit 1edeb5c55d

View file

@ -31,6 +31,14 @@ pub struct Permissions {
/// out keeps the stored value.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub internet_log: Option<bool>,
/// How many repositories the agent's forge account may create, 0 to 100.
/// Absent in a `GET` means the swarm never set it, which counts as 0.
/// Absent in a `PUT` keeps the stored value. An agent that may create
/// repositories can add a CI workflow to them, and CI workflows run
/// unsandboxed on the CI runner.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "schema", schema(example = 0, minimum = 0, maximum = 100))]
pub max_repos: Option<u32>,
}
#[cfg(test)]
@ -47,6 +55,7 @@ mod tests {
permissions: Some(vec![]),
unrestricted_internet: None,
internet_log: None,
max_repos: None,
},
r#"{"permissions":[]}"#,
),
@ -55,6 +64,7 @@ mod tests {
permissions: None,
unrestricted_internet: Some(false),
internet_log: None,
max_repos: None,
},
r#"{"unrestricted_internet":false}"#,
),
@ -63,6 +73,7 @@ mod tests {
permissions: None,
unrestricted_internet: Some(false),
internet_log: Some(true),
max_repos: None,
},
r#"{"unrestricted_internet":false,"internet_log":true}"#,
),
@ -71,9 +82,17 @@ mod tests {
permissions: Some(vec![Permission::Messaging, Permission::ManageRootAgent]),
unrestricted_internet: None,
internet_log: None,
max_repos: None,
},
r#"{"permissions":["messaging","manage_root_agent"]}"#,
),
(
Permissions {
max_repos: Some(3),
..Permissions::default()
},
r#"{"max_repos":3}"#,
),
] {
assert_eq!(serde_json::to_string(&value).unwrap(), wire);
assert_eq!(serde_json::from_str::<Permissions>(wire).unwrap(), value);