mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-09 10:53:34 +08:00
feat: add ecc2 global rebalance controls
This commit is contained in:
@@ -90,6 +90,18 @@ enum Commands {
|
||||
#[arg(long, default_value_t = 10)]
|
||||
lead_limit: usize,
|
||||
},
|
||||
/// Rebalance unread handoffs across lead teams with backed-up delegates
|
||||
RebalanceAll {
|
||||
/// Agent type for routed delegates
|
||||
#[arg(short, long, default_value = "claude")]
|
||||
agent: String,
|
||||
/// Create a dedicated worktree if new delegates must be spawned
|
||||
#[arg(short, long, default_value_t = true)]
|
||||
worktree: bool,
|
||||
/// Maximum lead sessions to sweep in one pass
|
||||
#[arg(long, default_value_t = 10)]
|
||||
lead_limit: usize,
|
||||
},
|
||||
/// Rebalance unread handoffs off backed-up delegates onto clearer team capacity
|
||||
RebalanceTeam {
|
||||
/// Lead session ID or alias
|
||||
@@ -337,6 +349,38 @@ async fn main() -> Result<()> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(Commands::RebalanceAll {
|
||||
agent,
|
||||
worktree: use_worktree,
|
||||
lead_limit,
|
||||
}) => {
|
||||
let outcomes = session::manager::rebalance_all_teams(
|
||||
&db,
|
||||
&cfg,
|
||||
&agent,
|
||||
use_worktree,
|
||||
lead_limit,
|
||||
)
|
||||
.await?;
|
||||
if outcomes.is_empty() {
|
||||
println!("No delegate backlog needed global rebalancing");
|
||||
} else {
|
||||
let total_rerouted: usize =
|
||||
outcomes.iter().map(|outcome| outcome.rerouted.len()).sum();
|
||||
println!(
|
||||
"Rebalanced {} task handoff(s) across {} lead session(s)",
|
||||
total_rerouted,
|
||||
outcomes.len()
|
||||
);
|
||||
for outcome in outcomes {
|
||||
println!(
|
||||
"- {} | rerouted {}",
|
||||
short_session(&outcome.lead_session_id),
|
||||
outcome.rerouted.len()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(Commands::RebalanceTeam {
|
||||
session_id,
|
||||
agent,
|
||||
@@ -747,6 +791,31 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_parses_rebalance_all_command() {
|
||||
let cli = Cli::try_parse_from([
|
||||
"ecc",
|
||||
"rebalance-all",
|
||||
"--agent",
|
||||
"claude",
|
||||
"--lead-limit",
|
||||
"6",
|
||||
])
|
||||
.expect("rebalance-all should parse");
|
||||
|
||||
match cli.command {
|
||||
Some(Commands::RebalanceAll {
|
||||
agent,
|
||||
lead_limit,
|
||||
..
|
||||
}) => {
|
||||
assert_eq!(agent, "claude");
|
||||
assert_eq!(lead_limit, 6);
|
||||
}
|
||||
_ => panic!("expected rebalance-all subcommand"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_parses_rebalance_team_command() {
|
||||
let cli = Cli::try_parse_from([
|
||||
|
||||
Reference in New Issue
Block a user