< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Workflows.Sequential.PipelinePhasePolicy
Assembly: NexusLabs.Needlr.AgentFramework.Workflows
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Workflows/Sequential/PipelinePhasePolicy.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 67
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_OnEnterAsync()100%11100%
get_OnExitAsync()100%11100%
get_TokenBudget()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Workflows/Sequential/PipelinePhasePolicy.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Workflows.Sequential;
 2
 3/// <summary>
 4/// Configures runtime behavior for a <see cref="PipelinePhase"/>, including
 5/// async lifecycle hooks and an optional phase-level token budget.
 6/// </summary>
 7/// <remarks>
 8/// <para>
 9/// This is intentionally distinct from <see cref="StageExecutionPolicy"/>. Phase
 10/// policies control cross-stage concerns (budget scope, workspace reconfiguration),
 11/// while stage policies control per-stage behavior (skip, retry, validation).
 12/// </para>
 13/// <para>
 14/// <see cref="OnEnterAsync"/> fires before any stage pre-work in the phase — before
 15/// <see cref="StageExecutionPolicy.ShouldSkip"/> evaluation, before prompt construction,
 16/// before executor invocation. This guarantees that workspace/state configuration is
 17/// applied before any stage can observe it.
 18/// </para>
 19/// <para>
 20/// <see cref="OnExitAsync"/> fires after the last stage completes (or on phase failure),
 21/// in a <c>finally</c> block. It always runs regardless of success or failure, enabling
 22/// cleanup and summary logic.
 23/// </para>
 24/// </remarks>
 25/// <example>
 26/// <code>
 27/// var policy = new PipelinePhasePolicy
 28/// {
 29///     OnEnterAsync = (ctx, ct) =>
 30///     {
 31///         Console.WriteLine($"Entering phase: {ctx.PhaseName}");
 32///         return ValueTask.CompletedTask;
 33///     },
 34///     OnExitAsync = (ctx, ct) =>
 35///     {
 36///         Console.WriteLine($"Exiting phase: {ctx.PhaseName}");
 37///         return ValueTask.CompletedTask;
 38///     },
 39///     TokenBudget = 50_000,
 40/// };
 41/// </code>
 42/// </example>
 43public sealed record PipelinePhasePolicy
 44{
 45    /// <summary>
 46    /// Async callback invoked before the first stage in the phase executes.
 47    /// Fires before any stage pre-work (<see cref="StageExecutionPolicy.ShouldSkip"/>,
 48    /// prompt construction, executor invocation). Fires even if all stages in the
 49    /// phase will be skipped. Not called if the phase has zero stages and no callback is set.
 50    /// </summary>
 2451    public Func<PhaseContext, CancellationToken, ValueTask>? OnEnterAsync { get; init; }
 52
 53    /// <summary>
 54    /// Async callback invoked after the last stage in the phase completes (or on
 55    /// phase failure/cancellation). Runs in a <c>finally</c> block — always fires
 56    /// regardless of success or failure.
 57    /// </summary>
 2058    public Func<PhaseContext, CancellationToken, ValueTask>? OnExitAsync { get; init; }
 59
 60    /// <summary>
 61    /// Optional phase-level token budget. When set, the runner scopes a budget
 62    /// tracker for the entire phase. Individual stage budgets
 63    /// (<see cref="StageExecutionPolicy.TokenBudget"/>) create child scopes within
 64    /// the phase budget scope.
 65    /// </summary>
 1866    public long? TokenBudget { get; init; }
 67}