feat(#2302): thread &Ident through agent path builders
This commit is contained in:
parent
1286029947
commit
bf644cc126
23 changed files with 168 additions and 85 deletions
|
|
@ -66,7 +66,12 @@ pub(super) fn gc_orphans(coord: &Coordinator, approvals: Vec<Approval>) -> Vec<A
|
|||
) {
|
||||
return true;
|
||||
}
|
||||
if Coordinator::agent_proposed_dir(&a.agent).exists() {
|
||||
let Ok(agent) = hive_host_sock::Ident::parse(&a.agent) else {
|
||||
let _ = coord.approvals.mark_failed(a.id, "invalid agent name");
|
||||
tracing::warn!(id = a.id, agent = %a.agent, "auto-failed approval with invalid agent name");
|
||||
return false;
|
||||
};
|
||||
if Coordinator::agent_proposed_dir(&agent).exists() {
|
||||
true
|
||||
} else {
|
||||
let note = "agent state dir missing";
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ pub(super) async fn get_extra_forges(Query(q): Query<ExtraForgesQuery>) -> Respo
|
|||
let Ok(agent) = Ident::parse(agent) else {
|
||||
return error_response(&format!("extra-forges: invalid agent {agent:?}"));
|
||||
};
|
||||
let dir = Coordinator::agent_notes_dir(agent.as_str());
|
||||
let dir = Coordinator::agent_notes_dir(&agent);
|
||||
let mut forges = Vec::new();
|
||||
match std::fs::read_dir(&dir) {
|
||||
Ok(entries) => {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ pub(super) async fn get_matrix_accounts(Query(q): Query<MatrixAccountsQuery>) ->
|
|||
return error_response(&format!("matrix-accounts: invalid agent name {agent:?}"));
|
||||
};
|
||||
|
||||
let dir = Coordinator::agent_notes_dir(agent.as_str());
|
||||
let dir = Coordinator::agent_notes_dir(&agent);
|
||||
let (snapshot, as_of_unix) = read_accounts_snapshot(&dir);
|
||||
let mut accounts = Vec::new();
|
||||
match std::fs::read_dir(&dir) {
|
||||
|
|
@ -313,7 +313,7 @@ pub(super) async fn get_github_account(Query(q): Query<GithubAccountQuery>) -> R
|
|||
let Ok(agent) = Ident::parse(agent) else {
|
||||
return error_response(&format!("github-account: invalid agent {agent:?}"));
|
||||
};
|
||||
let present = Coordinator::agent_notes_dir(agent.as_str())
|
||||
let present = Coordinator::agent_notes_dir(&agent)
|
||||
.join("github-token")
|
||||
.exists();
|
||||
axum::Json(GithubAccountStatus { present }).into_response()
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@ pub(super) async fn get_stale_permissions(
|
|||
let kept: std::collections::HashSet<String> =
|
||||
crate::coordinator::Coordinator::kept_state_names()
|
||||
.into_iter()
|
||||
.map(hive_host_sock::Ident::into_string)
|
||||
.collect();
|
||||
// Known = live roster ∪ kept-state names.
|
||||
let known: std::collections::HashSet<&String> = live.iter().chain(kept.iter()).collect();
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ pub(super) fn build_tombstone_views(
|
|||
.unwrap_or(0);
|
||||
let has_creds = claude_has_session(&Coordinator::agent_claude_dir(&name));
|
||||
TombstoneView {
|
||||
name,
|
||||
name: name.into_string(),
|
||||
state_bytes,
|
||||
last_seen,
|
||||
has_creds,
|
||||
|
|
@ -136,7 +136,7 @@ pub(super) async fn post_purge_tombstone(
|
|||
}
|
||||
let mut errors = Vec::new();
|
||||
for dir in [
|
||||
crate::paths::agent_state_dir(name.as_str()),
|
||||
crate::paths::agent_state_dir(&name),
|
||||
crate::paths::applied_dir(name.as_str()),
|
||||
] {
|
||||
if dir.exists()
|
||||
|
|
|
|||
Loading…
Reference in a new issue