hive-c0re: drop the spawn-time forge user-email, repo-creation and config-repo passes
sync_agent no longer runs ensure_user_email, ensure_repo_creation_disabled or ensure_config_repo. swarm-controller does all three before any deploy: CreateForgeUser sets the account email and max_repo_creation = 0 (and the agent_token backfill re-runs CreateForgeUser), CreateRepo creates and protects agent-configs/<agent>, AddRepoMember grants the agent write on it, and InitAgentConfigRepo seeds it. What goes with them: the email-aligned and repo-creation-disabled marker paths and the legacy email-marker relocate, sparse_edit_user_option, is_forbidden and its tests, and ensure_org_repo. A config repo deleted by hand is no longer recreated on the next spawn; the operator recreates the agent at swarm level. Comments in swarm-controller that described the removed hive passes now state only the current behaviour. Closes #4848
This commit is contained in:
parent
d2c6f1a967
commit
1de8a01936
6 changed files with 44 additions and 351 deletions
|
|
@ -1,7 +1,7 @@
|
|||
//! Optional Forgejo wiring — per-agent account alignment,
|
||||
//! config-repo mirroring, meta read-access grants, and each agent's
|
||||
//! read-only grant on `internal/docs` (the swarm-controller creates that
|
||||
//! repo, with the other swarm-wide orgs, teams and repos).
|
||||
//! Optional Forgejo wiring — config-repo mirroring, meta read-access
|
||||
//! grants, and each agent's read-only grant on `internal/docs` (the
|
||||
//! swarm-controller creates that repo, with the other swarm-wide orgs,
|
||||
//! teams and repos).
|
||||
//! No-op when `hive-forge` isn't running. Full design: `docs/integrations/forge.md`.
|
||||
|
||||
mod ci_runner;
|
||||
|
|
@ -13,9 +13,8 @@ mod users;
|
|||
pub use pr_comment::{config_repo, merged_pr_for_commit, post_pr_comment};
|
||||
pub use reconcile::{fetch_forge_main, reconcile_config_apply, reconcile_config_status};
|
||||
pub use repos::{
|
||||
clone_config_into_proposed, ensure_config_repo, ensure_meta_remote, ensure_repo,
|
||||
fast_forward_applied_main, fetch_config_main_into_applied, meta_read_access, push_config,
|
||||
push_meta, shared_docs_access,
|
||||
clone_config_into_proposed, ensure_meta_remote, ensure_repo, fast_forward_applied_main,
|
||||
fetch_config_main_into_applied, meta_read_access, push_config, push_meta, shared_docs_access,
|
||||
};
|
||||
pub use users::core_token;
|
||||
|
||||
|
|
@ -26,10 +25,7 @@ use anyhow::{Context, Result};
|
|||
use forgejo_api::{Auth, Forgejo};
|
||||
use url::Url;
|
||||
|
||||
use users::{
|
||||
ensure_core_avatar, ensure_core_user_and_token, ensure_repo_creation_disabled,
|
||||
ensure_user_email,
|
||||
};
|
||||
use users::{ensure_core_avatar, ensure_core_user_and_token};
|
||||
|
||||
const FORGE_CONTAINER: &str = "hive-forge";
|
||||
|
||||
|
|
@ -185,8 +181,7 @@ pub(crate) fn api(token: &str) -> Result<Forgejo> {
|
|||
Forgejo::new(Auth::Token(token), url).context("build forgejo api client")
|
||||
}
|
||||
|
||||
/// Per-agent forge sync: align the agent's forge account (email,
|
||||
/// repo-creation lockdown), mirror its config repo, grant read access
|
||||
/// Per-agent forge sync: mirror the agent's config repo, grant read access
|
||||
/// to `core/meta`, and wire the `meta` remote in its proposed repo. All operations are idempotent; failures
|
||||
/// are logged as warnings but don't abort the caller.
|
||||
///
|
||||
|
|
@ -201,27 +196,14 @@ pub(crate) fn api(token: &str) -> Result<Forgejo> {
|
|||
/// dashboard warning (see [`ensure_all`]); the rebuild path ignores it and
|
||||
/// relies on the journal `warn!` lines alone (a rebuild is its own retry).
|
||||
pub async fn sync_agent(name: &str, core_token: Option<&str>) -> bool {
|
||||
// The agent's forge user and token are swarm-controller's now
|
||||
// (`MintAgentForgeToken`); this hive no longer creates or re-mints
|
||||
// either.
|
||||
// The agent's forge account, token and `agent-configs/<name>` repo are
|
||||
// swarm-controller's; this hive creates none of them and only pushes
|
||||
// to the repo.
|
||||
let mut ok = true;
|
||||
// Align email to match the git user.email set by meta::render_flake
|
||||
// so commits link to the agent's Forgejo profile. Best-effort;
|
||||
// also patches up agents created before this fix (old @hive.local).
|
||||
ensure_user_email(name).await;
|
||||
// Block direct agent-initiated repo creation: agents create
|
||||
// repos through hive-c0re, never with their own token. Idempotent +
|
||||
// marker-guarded; also covers agents provisioned before this landed.
|
||||
ensure_repo_creation_disabled(name).await;
|
||||
// Mirror the agent's applied config repo into agent-configs.
|
||||
// ensure_config_repo is idempotent; push_config catches any
|
||||
// drift since the last run — e.g. the startup migration just
|
||||
// relocated `deployed/0`, or a deploy landed while the forge
|
||||
// was down.
|
||||
if let Err(e) = ensure_config_repo(name).await {
|
||||
tracing::warn!(%name, error = ?e, "forge: ensure_config_repo failed");
|
||||
ok = false;
|
||||
}
|
||||
// push_config catches any drift since the last run — e.g. the
|
||||
// startup migration just relocated `deployed/0`, or a deploy landed
|
||||
// while the forge was down.
|
||||
if let Err(e) = push_config(name).await {
|
||||
tracing::warn!(%name, error = ?e, "forge: push_config failed");
|
||||
ok = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue