from pathlib import Path
from .logging import setup_logging
from .exceptions import ConfigurationError

logger = setup_logging("core.utils")

def verify_project_goals(rules_path: Path) -> bool:
    """
    Verify that the project-goals.md exists and is readable.
    This acts as the immutable Source of Truth check.
    """
    if not rules_path.exists():
        logger.error(f"Missing Project Goals at: {rules_path}")
        return False
        
    try:
        content = rules_path.read_text()
        if "Source of Truth" not in content and "SOURCE OF TRUTH" not in content:
             logger.warning("Project Goals file does not contain 'Source of Truth' marker.")
        return True
    except Exception as e:
        logger.error(f"Failed to read Project Goals: {e}")
        return False
