huskies: merge 1100 bug Multiple LLM agents can run concurrently on the same story (coder + mergemaster + others) — enforce one-agent-per-story invariant
This commit is contained in:
@@ -161,6 +161,42 @@ pub fn pipeline_stage(agent_name: &str) -> PipelineStage {
|
||||
}
|
||||
}
|
||||
|
||||
/// Map a pipeline [`Stage`] to the canonical [`PipelineStage`] for LLM agent spawning.
|
||||
///
|
||||
/// Returns `None` for stages where no LLM agent should be active (terminal states,
|
||||
/// blocked, frozen, or unclassified merge failures requiring human intervention).
|
||||
/// Returns `Some(stage)` naming the single LLM-agent type that may run on this story.
|
||||
/// Used by `validate_agent_stage` and `reconcile_canonical_agents` to enforce the
|
||||
/// one-agent-per-story invariant (story 1100).
|
||||
pub fn canonical_pipeline_stage(s: &crate::pipeline_state::Stage) -> Option<PipelineStage> {
|
||||
use crate::pipeline_state::{MergeFailureKind, Stage};
|
||||
match s {
|
||||
Stage::Coding { .. } => Some(PipelineStage::Coder),
|
||||
Stage::Qa => Some(PipelineStage::Qa),
|
||||
Stage::Merge { .. } => Some(PipelineStage::Mergemaster),
|
||||
Stage::MergeFailure {
|
||||
kind: MergeFailureKind::ConflictDetected(_),
|
||||
..
|
||||
} => Some(PipelineStage::Mergemaster),
|
||||
Stage::MergeFailure {
|
||||
kind: MergeFailureKind::GatesFailed(_),
|
||||
..
|
||||
} => Some(PipelineStage::Coder),
|
||||
Stage::MergeFailureFinal { .. } => Some(PipelineStage::Mergemaster),
|
||||
Stage::Upcoming
|
||||
| Stage::Backlog
|
||||
| Stage::MergeFailure { .. }
|
||||
| Stage::Done { .. }
|
||||
| Stage::Blocked { .. }
|
||||
| Stage::Archived { .. }
|
||||
| Stage::Frozen { .. }
|
||||
| Stage::ReviewHold { .. }
|
||||
| Stage::Abandoned { .. }
|
||||
| Stage::Superseded { .. }
|
||||
| Stage::Rejected { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Determine the pipeline stage for a configured agent.
|
||||
///
|
||||
/// Prefers the explicit `stage` config field (added in Bug 150) over the
|
||||
|
||||
Reference in New Issue
Block a user