//! Pure story-lifecycle helpers for `service::story`.
//!
//! These functions reason about story IDs and dependencies without performing
//! any I/O. They inform routing decisions in `mod.rs` and the MCP adapter.

pub use crate::service::common::item_id::{
    extract_item_number as story_number, has_valid_id_prefix,
};

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

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

    #[test]
    fn story_number_extracts_prefix() {
        assert_eq!(story_number("42_story_foo"), Some("42"));
        assert_eq!(story_number("1_bug_bar"), Some("1"));
        assert_eq!(story_number("100_refactor_baz"), Some("100"));
    }

    #[test]
    fn story_number_returns_none_for_no_numeric_prefix() {
        assert_eq!(story_number("story_without_number"), None);
        assert_eq!(story_number("abc_story"), None);
        assert_eq!(story_number(""), None);
    }

    #[test]
    fn has_valid_id_prefix_returns_true_for_valid_ids() {
        assert!(has_valid_id_prefix("42_story_foo"));
        assert!(has_valid_id_prefix("1_bug_bar"));
    }

    #[test]
    fn has_valid_id_prefix_returns_false_for_invalid_ids() {
        assert!(!has_valid_id_prefix("story_no_number"));
        assert!(!has_valid_id_prefix(""));
    }
}
