Files
huskies/server/src/agents/merge/mod.rs
T

60 lines
2.0 KiB
Rust
Raw Normal View History

//! Merge operations — rebases agent work onto master and runs post-merge validation.
2026-04-28 10:19:43 +00:00
use serde::{Deserialize, Serialize};
mod squash;
pub(crate) use squash::run_squash_merge;
/// Status of an async merge job.
#[derive(Debug, Clone, Serialize)]
pub enum MergeJobStatus {
Running,
Completed(MergeReport),
Failed(String),
}
/// Tracks a background merge job started by `merge_agent_work`.
#[derive(Debug, Clone, Serialize)]
pub struct MergeJob {
pub story_id: String,
pub status: MergeJobStatus,
/// Server start-time (Unix seconds) of the server instance that started
/// this job.
///
/// Used by stale-lock recovery: on a new merge attempt the system checks
/// every Running entry and removes any whose recorded start-time is older
/// than the current server's boot time. This survives `rebuild_and_restart`
/// (which re-execs and keeps the same PID).
pub server_start_time: f64,
}
/// Result of a mergemaster merge operation.
2026-04-28 10:19:43 +00:00
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MergeReport {
pub story_id: String,
pub success: bool,
pub had_conflicts: bool,
/// `true` when conflicts were detected but automatically resolved.
pub conflicts_resolved: bool,
pub conflict_details: Option<String>,
pub gates_passed: bool,
pub gate_output: String,
pub worktree_cleaned_up: bool,
pub story_archived: bool,
}
/// Result of a squash-merge operation.
pub(crate) struct SquashMergeResult {
pub(crate) success: bool,
pub(crate) had_conflicts: bool,
/// `true` when conflicts were detected but automatically resolved.
pub(crate) conflicts_resolved: bool,
pub(crate) conflict_details: Option<String>,
pub(crate) output: String,
/// Whether quality gates ran and passed. `false` when `success` is `false`
/// due to a gate failure; callers can use this to distinguish gate failures
/// from merge/commit/FF failures in the `MergeReport`.
pub(crate) gates_passed: bool,
}