diff --git a/docs/4-implementation/swarm/ssh-ca.md b/docs/4-implementation/swarm/ssh-ca.md index ac9ee30c5..6a2e51400 100644 --- a/docs/4-implementation/swarm/ssh-ca.md +++ b/docs/4-implementation/swarm/ssh-ca.md @@ -35,7 +35,7 @@ The role signs for every agent: The entity name is the agent's name: `swarm-controller` names the entity of each agent's cert login after the agent -(`swarm-controller/src/agent_entity.rs`). A request for any other principal, +(`swarm-controller/src/secrets/agent_entity.rs`). A request for any other principal, a glob, host certificates, other key types or another extension is a refusal from the store. diff --git a/nix/host-modules/hive-archive-backup.nix b/nix/host-modules/hive-archive-backup.nix index 191508b05..a9c0b5393 100644 --- a/nix/host-modules/hive-archive-backup.nix +++ b/nix/host-modules/hive-archive-backup.nix @@ -9,7 +9,7 @@ # # Each agent backs up under the credentials swarm-controller wrote for it at # `swarm/hives//archive/` -# (../../swarm-controller/src/archive_access.rs), read with the hive's own +# (../../swarm-controller/src/secrets/archive_access.rs), read with the hive's own # store identity: the agent's login to the archive, and its restic password, # which restic reads through `RESTIC_PASSWORD_COMMAND` and nothing writes to # disk. An agent the controller has not granted this hive is skipped. The diff --git a/nix/host-modules/swarm-archive.nix b/nix/host-modules/swarm-archive.nix index 0149bcdef..765495830 100644 --- a/nix/host-modules/swarm-archive.nix +++ b/nix/host-modules/swarm-archive.nix @@ -7,7 +7,7 @@ # the index, so a compromised hive cannot erase history. Dropping history is # the prune unit's job, on this host, by retention. # - `--private-repos`: a login reaches `//` only. There is one -# login per agent, created by swarm-controller (../../swarm-controller/src/archive_access.rs) +# login per agent, created by swarm-controller (../../swarm-controller/src/secrets/archive_access.rs) # when it places the agent, replaced when it moves and removed when it is # destroyed. An agent's hive can write that agent's repository and no other. # diff --git a/nix/host-modules/swarm-bao-agent-pki.nix b/nix/host-modules/swarm-bao-agent-pki.nix index 4cd2fa626..c9e393d35 100644 --- a/nix/host-modules/swarm-bao-agent-pki.nix +++ b/nix/host-modules/swarm-bao-agent-pki.nix @@ -57,7 +57,7 @@ let # What the role pins. `{{identity.entity.name}}` is the name of the entity the # agent's cert login lands on, which swarm-controller sets to the agent's name - # (`swarm-controller/src/agent_entity.rs`); with `allowed_users_template` the + # (`swarm-controller/src/secrets/agent_entity.rs`); with `allowed_users_template` the # engine checks every requested principal against it, and with # `default_user_template` an unrequested one defaults to it, so a certificate # names its holder's own agent and no other. `allowed_user_key_lengths` limits diff --git a/nix/host-modules/swarm-controller.nix b/nix/host-modules/swarm-controller.nix index 9a937ff70..908193c5d 100644 --- a/nix/host-modules/swarm-controller.nix +++ b/nix/host-modules/swarm-controller.nix @@ -1092,7 +1092,7 @@ in SWARM_CONTROLLER_GRAFANA_URL = "https://${swarmCfg.grafana.domain}"; # The names squid allows every authenticated agent by default. The # allow-list route refuses them as entries - # (swarm-controller/src/egress_allow.rs). A hive that overrides + # (swarm-controller/src/secrets/egress_allow.rs). A hive that overrides # `deploy.hive-controller.squid.baseAllowedDomains` is not reflected # here; its hive-c0re skips the entries its own list covers. SWARM_CONTROLLER_SQUID_BASE_DOMAINS = lib.concatStringsSep " " ( diff --git a/swarm-controller/src/main.rs b/swarm-controller/src/main.rs index 9844f49c6..04acca737 100644 --- a/swarm-controller/src/main.rs +++ b/swarm-controller/src/main.rs @@ -29,16 +29,11 @@ mod agent_commands; mod agent_config_repo; mod agent_control; mod agent_custom; -mod agent_cutoff; -mod agent_entity; mod agent_icon; -mod agent_identity; mod agent_input; mod agent_limits; mod agent_login; mod agent_permissions; -mod agent_renewal; -mod agent_role_ttl; mod agent_ssh; mod agent_state_stream; mod agent_status; @@ -46,19 +41,12 @@ mod agent_todos; mod agents_md; mod agents_md_initial; mod archetypes; -mod archive_access; mod attic_copy; mod auth; -mod backend_egress; -mod backend_env; -mod backend_secrets; mod bash_task; mod builder; mod cache_miss; -mod claude_login; mod config_drift; -mod egress_allow; -mod egress_deny; mod git_forge; mod inference; mod jobq; @@ -69,12 +57,11 @@ mod meta_flake; mod observability; mod observability_grant; mod pause_hold; -mod proxy_credential; mod queue_identity; -mod read_policy; mod review; mod routes; mod schedules; +mod secrets; mod ssh_connections; mod startup; mod status; @@ -86,7 +73,7 @@ mod term_stream; mod test_nats; mod wanted; -// The accounts, forge, observability and review modules keep their crate-root paths (`crate::matrix_account::…`). +// The accounts, forge, secrets, observability and review modules keep their crate-root paths (`crate::matrix_account::…`). use accounts::{ forge_account, github_account, gitlab_account, link_egress, linked_accounts, matrix_account, }; @@ -97,6 +84,11 @@ use jobq::{Late, WorkerDeps, spawn_jobq_worker}; use observability::{alerts, held_deploys, otel_http_client, vcs_metrics}; use review::{notify_flows, notify_router_api, request_reviewer, review_classifier}; use routes::AppState; +use secrets::{ + agent_cutoff, agent_entity, agent_identity, agent_renewal, agent_role_ttl, archive_access, + backend_egress, backend_env, backend_secrets, claude_login, egress_allow, egress_deny, + proxy_credential, read_policy, +}; use startup::{ agent_icon_reader, agent_status_reader, agents_md_reader, build_app, configured_matrix_homeserver, connect_status_reader, load_hives, load_links, load_swarm_name, diff --git a/swarm-controller/src/agent_cutoff.rs b/swarm-controller/src/secrets/agent_cutoff.rs similarity index 100% rename from swarm-controller/src/agent_cutoff.rs rename to swarm-controller/src/secrets/agent_cutoff.rs diff --git a/swarm-controller/src/agent_entity.rs b/swarm-controller/src/secrets/agent_entity.rs similarity index 100% rename from swarm-controller/src/agent_entity.rs rename to swarm-controller/src/secrets/agent_entity.rs diff --git a/swarm-controller/src/agent_identity.rs b/swarm-controller/src/secrets/agent_identity.rs similarity index 100% rename from swarm-controller/src/agent_identity.rs rename to swarm-controller/src/secrets/agent_identity.rs diff --git a/swarm-controller/src/agent_renewal.rs b/swarm-controller/src/secrets/agent_renewal.rs similarity index 100% rename from swarm-controller/src/agent_renewal.rs rename to swarm-controller/src/secrets/agent_renewal.rs diff --git a/swarm-controller/src/agent_role_ttl.rs b/swarm-controller/src/secrets/agent_role_ttl.rs similarity index 100% rename from swarm-controller/src/agent_role_ttl.rs rename to swarm-controller/src/secrets/agent_role_ttl.rs diff --git a/swarm-controller/src/archive_access.rs b/swarm-controller/src/secrets/archive_access.rs similarity index 100% rename from swarm-controller/src/archive_access.rs rename to swarm-controller/src/secrets/archive_access.rs diff --git a/swarm-controller/src/backend_egress.rs b/swarm-controller/src/secrets/backend_egress.rs similarity index 100% rename from swarm-controller/src/backend_egress.rs rename to swarm-controller/src/secrets/backend_egress.rs diff --git a/swarm-controller/src/backend_env.rs b/swarm-controller/src/secrets/backend_env.rs similarity index 98% rename from swarm-controller/src/backend_env.rs rename to swarm-controller/src/secrets/backend_env.rs index 244befdac..de414148b 100644 --- a/swarm-controller/src/backend_env.rs +++ b/swarm-controller/src/secrets/backend_env.rs @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; use swarm_secret_client::backend_env::{self, BackendEnv}; use utoipa::ToSchema; -use super::linked_accounts::AccountStore; +use crate::linked_accounts::AccountStore; use crate::routes::agents::swarm_hive; use crate::routes::{AppState, error_problem}; @@ -194,8 +194,8 @@ pub(crate) mod tests { use serde_json::json; use swarm_secret_client::backend_env::BackendEnv; - use super::super::linked_accounts::{AccountStore, Accounts, tests::FakeStore}; use super::{MAX_BYTES, PutBackendEnvRequest, validated}; + use crate::linked_accounts::{AccountStore, Accounts, tests::FakeStore}; const SECRET: &str = "sk-live-0123"; @@ -226,7 +226,7 @@ pub(crate) mod tests { forge: std::sync::Arc::default(), create_gate: std::sync::Arc::default(), accounts: Accounts::Fake(Arc::clone(store)), - try_outs: super::super::review_classifier::TryOuts::default(), + try_outs: crate::review_classifier::TryOuts::default(), reviews: std::sync::Arc::default(), runs: crate::review_classifier::runs::Runs::Live(None), builds: crate::builder::runs::Builds::Live(None), diff --git a/swarm-controller/src/backend_secrets.rs b/swarm-controller/src/secrets/backend_secrets.rs similarity index 98% rename from swarm-controller/src/backend_secrets.rs rename to swarm-controller/src/secrets/backend_secrets.rs index 3b9d2927a..f1ae8fa93 100644 --- a/swarm-controller/src/backend_secrets.rs +++ b/swarm-controller/src/secrets/backend_secrets.rs @@ -17,8 +17,8 @@ use serde::{Deserialize, Serialize}; use swarm_secret_client::backend_secrets::{self, BackendSecrets}; use utoipa::ToSchema; -use super::linked_accounts::AccountStore; use crate::backend_env::validated; +use crate::linked_accounts::AccountStore; use crate::routes::agents::swarm_hive; use crate::routes::{AppState, error_problem}; @@ -132,8 +132,8 @@ mod tests { use swarm_secret_client::backend_secrets::BackendSecrets; use super::super::backend_env::tests::state; - use super::super::linked_accounts::{AccountStore, tests::FakeStore}; use super::PutBackendSecretsRequest; + use crate::linked_accounts::{AccountStore, tests::FakeStore}; const SECRET: &str = "sk-ant-live-0123"; diff --git a/swarm-controller/src/claude_login.rs b/swarm-controller/src/secrets/claude_login.rs similarity index 100% rename from swarm-controller/src/claude_login.rs rename to swarm-controller/src/secrets/claude_login.rs diff --git a/swarm-controller/src/egress_allow.rs b/swarm-controller/src/secrets/egress_allow.rs similarity index 100% rename from swarm-controller/src/egress_allow.rs rename to swarm-controller/src/secrets/egress_allow.rs diff --git a/swarm-controller/src/egress_deny.rs b/swarm-controller/src/secrets/egress_deny.rs similarity index 100% rename from swarm-controller/src/egress_deny.rs rename to swarm-controller/src/secrets/egress_deny.rs diff --git a/swarm-controller/src/secrets/mod.rs b/swarm-controller/src/secrets/mod.rs new file mode 100644 index 000000000..d033d83c1 --- /dev/null +++ b/swarm-controller/src/secrets/mod.rs @@ -0,0 +1,18 @@ +//! The secrets concern: agent identities and their renewal and cutoff, the +//! credentials the controller hands out (archive, proxy, backend) and the +//! egress and read policies written to the store. + +pub(crate) mod agent_cutoff; +pub(crate) mod agent_entity; +pub(crate) mod agent_identity; +pub(crate) mod agent_renewal; +pub(crate) mod agent_role_ttl; +pub(crate) mod archive_access; +pub(crate) mod backend_egress; +pub(crate) mod backend_env; +pub(crate) mod backend_secrets; +pub(crate) mod claude_login; +pub(crate) mod egress_allow; +pub(crate) mod egress_deny; +pub(crate) mod proxy_credential; +pub(crate) mod read_policy; diff --git a/swarm-controller/src/proxy_credential.rs b/swarm-controller/src/secrets/proxy_credential.rs similarity index 100% rename from swarm-controller/src/proxy_credential.rs rename to swarm-controller/src/secrets/proxy_credential.rs diff --git a/swarm-controller/src/read_policy.rs b/swarm-controller/src/secrets/read_policy.rs similarity index 100% rename from swarm-controller/src/read_policy.rs rename to swarm-controller/src/secrets/read_policy.rs