//! Pure QA lifecycle helpers for `service::qa`.
//!
//! These functions classify work items and make routing decisions without
//! performing any I/O. The spike-vs-story distinction determines whether a
//! QA approval goes through the merge pipeline or bypasses it.

use crate::agents::lifecycle::item_type_from_id;

/// Return `true` if `story_id` identifies a spike (e.g. `"42_spike_foo"`).
///
/// Spikes bypass the normal merge pipeline: when approved from QA they are
/// merged directly to master and moved straight to done.
pub fn is_spike(story_id: &str) -> bool {
    item_type_from_id(story_id) == "spike"
}

// ── Tests ─────────────────────────────────────────────────────────────────────

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn is_spike_returns_true_for_spike_id() {
        assert!(is_spike("42_spike_my_research"));
    }

    #[test]
    fn is_spike_returns_false_for_story_id() {
        assert!(!is_spike("42_story_my_feature"));
    }

    #[test]
    fn is_spike_returns_false_for_bug_id() {
        assert!(!is_spike("42_bug_login_crash"));
    }

    #[test]
    fn is_spike_returns_false_for_refactor_id() {
        assert!(!is_spike("42_refactor_cleanup"));
    }
}
