refactor(#3434): drop the agent_repo identity function
mara, PR #3438 review: 'remove the identity function. agent names are unique and all repos go into agent-configs namespace anyway'. Right -- repo==agent isn't a convention worth a name once every call site can just say so; call create_repo/add_repo_member/seed_agent_config with &agent directly.
This commit is contained in:
parent
4d526b8492
commit
6dffa74d90
2 changed files with 8 additions and 21 deletions
|
|
@ -31,19 +31,12 @@ use crate::webhook::DeliveryKind;
|
||||||
/// The forge org that owns agent repos. Same org `hive-c0re::forge`
|
/// The forge org that owns agent repos. Same org `hive-c0re::forge`
|
||||||
/// already uses for its own single-hive `CreateRepo` path — this is
|
/// already uses for its own single-hive `CreateRepo` path — this is
|
||||||
/// the same forge instance, not a separate one, so the same org.
|
/// the same forge instance, not a separate one, so the same org.
|
||||||
pub const AGENTS_ORG: &str = "agents";
|
|
||||||
|
|
||||||
/// The repo an agent's config lives in — one repo per agent inside
|
|
||||||
/// [`AGENTS_ORG`], named after the agent.
|
|
||||||
///
|
///
|
||||||
/// The identity here is the point, not an accident to be inlined: this is
|
/// There is no per-agent repo-vs-agent naming convention to maintain here:
|
||||||
/// the single home for the naming convention, so a caller holding an agent
|
/// agent names are unique and every agent's repo lives in this one org, so
|
||||||
/// name never writes the repo name itself. Callers used to pass both, which
|
/// the agent name IS the repo name at every call site (dropped the
|
||||||
/// meant every node payload carried the same string twice and any future
|
/// `agent_repo` identity function this used to go through, per review).
|
||||||
/// change to the convention would have been a search rather than an edit.
|
pub const AGENTS_ORG: &str = "agents";
|
||||||
pub fn agent_repo(agent: &str) -> &str {
|
|
||||||
agent
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The `operators` team, whitelisted for the merge gate on every repo
|
/// The `operators` team, whitelisted for the merge gate on every repo
|
||||||
/// this client protects — provisioned by `hive-c0re::forge::repos`
|
/// this client protects — provisioned by `hive-c0re::forge::repos`
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ async fn run_swarm_node(
|
||||||
SWARM_CONTROLLER_FORGE_TOKEN_FILE unset)"
|
SWARM_CONTROLLER_FORGE_TOKEN_FILE unset)"
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
),
|
),
|
||||||
Some(client) => match client.create_repo(forge::agent_repo(&agent)).await {
|
Some(client) => match client.create_repo(&agent).await {
|
||||||
Ok(full_name) => {
|
Ok(full_name) => {
|
||||||
tracing::info!(%full_name, "swarm jobq: create_repo done");
|
tracing::info!(%full_name, "swarm jobq: create_repo done");
|
||||||
Outcome::Done
|
Outcome::Done
|
||||||
|
|
@ -169,10 +169,7 @@ async fn run_swarm_node(
|
||||||
SWARM_CONTROLLER_FORGE_TOKEN_FILE unset)"
|
SWARM_CONTROLLER_FORGE_TOKEN_FILE unset)"
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
),
|
),
|
||||||
Some(client) => match client
|
Some(client) => match client.add_repo_member(&agent, &agent).await {
|
||||||
.add_repo_member(forge::agent_repo(&agent), &agent)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(()) => Outcome::Done,
|
Ok(()) => Outcome::Done,
|
||||||
Err(e) => Outcome::Failed(format!("{e:#}")),
|
Err(e) => Outcome::Failed(format!("{e:#}")),
|
||||||
},
|
},
|
||||||
|
|
@ -183,10 +180,7 @@ async fn run_swarm_node(
|
||||||
SWARM_CONTROLLER_FORGE_TOKEN_FILE unset)"
|
SWARM_CONTROLLER_FORGE_TOKEN_FILE unset)"
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
),
|
),
|
||||||
Some(client) => match client
|
Some(client) => match client.seed_agent_config(&agent, &agent).await {
|
||||||
.seed_agent_config(forge::agent_repo(&agent), &agent)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(()) => Outcome::Done,
|
Ok(()) => Outcome::Done,
|
||||||
Err(e) => Outcome::Failed(format!("{e:#}")),
|
Err(e) => Outcome::Failed(format!("{e:#}")),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue