using ClaudeDo.Data.Models;

namespace ClaudeDo.Data.Filtering;

/// <summary>
/// Shared predicates that capture planning-hierarchy semantics. Any new rule
/// involving parents, children, or planning phases belongs here.
/// </summary>
public static class PlanningRules
{
    public static bool IsPlanningParent(TaskEntity t) =>
        t.PlanningPhase != PlanningPhase.None;

    public static bool HasMatchingChild(
        TaskEntity parent,
        IReadOnlyList<TaskEntity> all,
        Func<TaskEntity, bool> childPredicate)
    {
        for (var i = 0; i < all.Count; i++)
        {
            var c = all[i];
            if (c.ParentTaskId == parent.Id && childPredicate(c))
                return true;
        }
        return false;
    }
}
