//! Merge operations — rebases agent work onto master and runs post-merge validation. use serde::Serialize; mod conflicts; mod squash; pub(crate) use squash::{cleanup_merge_workspace, 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, } /// Result of a mergemaster merge operation. #[derive(Debug, Serialize, 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, 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, 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, }