use super::ChildResult;
use crate::prompt::notice::notice;
use crate::prompt::{Error, compactor, inbox};
use crate::template::GitRunner;
use std::path::Path;
pub(super) fn qualifies(cr: &ChildResult) -> bool {
cr.epitaph == inbox::Epitaph::FinalResponse.as_str()
}
pub(super) fn land(
worktree: &Path,
agent_id: &str,
cr: &ChildResult,
git: &dyn GitRunner,
) -> Result<(), Error> {
match compactor::land(worktree, agent_id, &cr.child_id, git)? {
compactor::LandOutcome::Conflicted(paths) => notice!(
"compaction landing [{}] declined — git could not replay {} \
(marked refs/litany/conflicted/{}, ARCH §2.6); the branch continues uncompacted",
cr.child_id,
paths.join(", "),
cr.child_id,
),
compactor::LandOutcome::Superseded => notice!(
"compaction landing [{}] superseded — a compaction landed since \
its fork point (ARCH §2.6); the branch continues",
cr.child_id,
),
compactor::LandOutcome::Landed | compactor::LandOutcome::NoOp => {}
}
std::fs::remove_file(&cr.path).map_err(Error::Io)
}