namespace AgentSmith.Domain.Entities;

/// <summary>
/// Execution plan generated by the agent provider.
/// p0128a: extended additively with the schema fields (Scope, OpenQuestions,
/// TestImpact, ConsumerImpact, Status). Existing constructor is unchanged so
/// legacy lax-parsed plans keep working; the strict path populates all fields.
/// </summary>
public sealed class Plan
{
    public string Summary { get; }
    public IReadOnlyList<PlanStep> Steps { get; }
    public IReadOnlyList<PlanDecision> Decisions { get; }
    public string RawResponse { get; }

    public PlanScope Scope { get; init; } = PlanScope.Empty;
    public IReadOnlyList<PlanOpenQuestion> OpenQuestions { get; init; } = Array.Empty<PlanOpenQuestion>();
    public string? TestImpact { get; init; }
    public string? ConsumerImpact { get; init; }
    public PlanStatus Status { get; init; } = PlanStatus.Complete;

    public Plan(string summary, IReadOnlyList<PlanStep> steps, string rawResponse,
                IReadOnlyList<PlanDecision>? decisions = null)
    {
        Summary = summary;
        Steps = steps;
        Decisions = decisions ?? Array.Empty<PlanDecision>();
        RawResponse = rawResponse;
    }
}
