Skip to content

Commit 70b1dd5

Browse files
author
Test User
committed
fix(orchestrator,service): remove duplicate functions and stale re-export from cherry-pick
1 parent e39aeb3 commit 70b1dd5

2 files changed

Lines changed: 0 additions & 117 deletions

File tree

  • crates

crates/terraphim_orchestrator/src/lib.rs

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -416,121 +416,6 @@ fn nest_by_project<V: Clone>(
416416
out
417417
}
418418

419-
/// Build the composite restart-state key for an agent definition.
420-
///
421-
/// Legacy (project-less) agents use [`crate::dispatcher::LEGACY_PROJECT_ID`]
422-
/// so restart counts never collide across projects once projects are added.
423-
fn agent_key(def: &AgentDefinition) -> (String, String) {
424-
(
425-
def.project
426-
.clone()
427-
.unwrap_or_else(|| crate::dispatcher::LEGACY_PROJECT_ID.to_string()),
428-
def.name.clone(),
429-
)
430-
}
431-
432-
/// Build the per-project runtime map consumed by
433-
/// [`flow::executor::FlowExecutor::with_projects`].
434-
fn build_flow_project_runtimes(
435-
config: &OrchestratorConfig,
436-
) -> HashMap<String, flow::executor::ProjectRuntime> {
437-
config
438-
.projects
439-
.iter()
440-
.map(|p| {
441-
(
442-
p.id.clone(),
443-
flow::executor::ProjectRuntime {
444-
working_dir: p.working_dir.clone(),
445-
gitea_owner: p.gitea.as_ref().map(|g| g.owner.clone()),
446-
gitea_repo: p.gitea.as_ref().map(|g| g.repo.clone()),
447-
},
448-
)
449-
})
450-
.collect()
451-
}
452-
453-
/// Build a [`SpawnContext`] for an agent, resolving per-project working_dir,
454-
/// Gitea owner/repo, and the project id itself into the child process's
455-
/// environment (`ADF_PROJECT_ID`, `ADF_WORKING_DIR`, `GITEA_OWNER`,
456-
/// `GITEA_REPO`). Legacy (project-less) agents use [`SpawnContext::global()`].
457-
fn build_spawn_context_for_agent(
458-
config: &OrchestratorConfig,
459-
def: &AgentDefinition,
460-
) -> SpawnContext {
461-
let Some(pid) = def.project.as_deref() else {
462-
return SpawnContext::global();
463-
};
464-
let Some(project) = config.project_by_id(pid) else {
465-
return SpawnContext::global();
466-
};
467-
let working_dir_str = project.working_dir.to_string_lossy().into_owned();
468-
let mut ctx = SpawnContext::with_working_dir(project.working_dir.clone())
469-
.with_env("ADF_PROJECT_ID", pid)
470-
.with_env("ADF_WORKING_DIR", working_dir_str);
471-
if let Some(gitea) = project.gitea.as_ref() {
472-
ctx = ctx
473-
.with_env("GITEA_OWNER", gitea.owner.clone())
474-
.with_env("GITEA_REPO", gitea.repo.clone());
475-
}
476-
ctx
477-
}
478-
479-
/// Flatten persisted nested maps (project -> agent -> count) and any legacy
480-
/// flat entries into the in-memory composite key map. Legacy flat entries are
481-
/// mapped to [`crate::dispatcher::LEGACY_PROJECT_ID`].
482-
#[cfg(not(test))]
483-
fn flatten_restart_counts(state: &PersistedRestartState) -> HashMap<(String, String), u32> {
484-
let mut out: HashMap<(String, String), u32> = HashMap::new();
485-
for (project, per_agent) in &state.counts_by_project {
486-
for (agent, count) in per_agent {
487-
out.insert((project.clone(), agent.clone()), *count);
488-
}
489-
}
490-
for (agent, count) in &state.counts {
491-
out.entry((
492-
crate::dispatcher::LEGACY_PROJECT_ID.to_string(),
493-
agent.clone(),
494-
))
495-
.or_insert(*count);
496-
}
497-
out
498-
}
499-
500-
/// Flatten persisted nested maps for last-failure timestamps into the
501-
/// composite key format.
502-
#[cfg(not(test))]
503-
fn flatten_restart_failures(state: &PersistedRestartState) -> HashMap<(String, String), i64> {
504-
let mut out: HashMap<(String, String), i64> = HashMap::new();
505-
for (project, per_agent) in &state.last_failure_unix_secs_by_project {
506-
for (agent, ts) in per_agent {
507-
out.insert((project.clone(), agent.clone()), *ts);
508-
}
509-
}
510-
for (agent, ts) in &state.last_failure_unix_secs {
511-
out.entry((
512-
crate::dispatcher::LEGACY_PROJECT_ID.to_string(),
513-
agent.clone(),
514-
))
515-
.or_insert(*ts);
516-
}
517-
out
518-
}
519-
520-
/// Re-nest composite keyed maps into the persisted `project -> agent -> value`
521-
/// shape for serialisation.
522-
#[cfg(not(test))]
523-
fn nest_by_project<V: Clone>(
524-
flat: &HashMap<(String, String), V>,
525-
) -> HashMap<String, HashMap<String, V>> {
526-
let mut out: HashMap<String, HashMap<String, V>> = HashMap::new();
527-
for ((project, agent), value) in flat {
528-
out.entry(project.clone())
529-
.or_default()
530-
.insert(agent.clone(), value.clone());
531-
}
532-
out
533-
}
534419

535420
/// Validate agent name for safe use in file paths.
536421
/// Rejects empty names, names containing path separators or traversal sequences.

crates/terraphim_service/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ mod score;
1414
use crate::score::Query;
1515

1616
pub mod auto_route;
17-
#[allow(deprecated)]
18-
pub use auto_route::JMAP_MISSING_TOKEN_DOWNWEIGHT;
1917
pub use auto_route::{
2018
AutoRouteContext, AutoRouteReason, AutoRouteResult, JMAP_MISSING_TOKEN_PENALTY,
2119
auto_select_role,

0 commit comments

Comments
 (0)