< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Workflows.Sequential.StageExecutionPolicy
Assembly: NexusLabs.Needlr.AgentFramework.Workflows
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Workflows/Sequential/StageExecutionPolicy.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 50
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_ShouldSkip()100%11100%
get_PostValidation()100%11100%
get_MaxAttempts()100%11100%
get_TokenBudget()100%11100%
get_AfterExecution()100%11100%

File(s)

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

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Workflows.Sequential;
 2
 3/// <summary>
 4/// Configures runtime behavior for a single pipeline stage, including
 5/// conditional skipping, post-execution validation with retries, and
 6/// per-stage token budgets.
 7/// </summary>
 8/// <example>
 9/// <code>
 10/// var policy = new StageExecutionPolicy
 11/// {
 12///     ShouldSkip = ctx => ctx.StageIndex > 3,
 13///     PostValidation = result => result.ResponseText?.Contains("error") == true
 14///         ? "Response contained an error"
 15///         : null,
 16///     MaxAttempts = 3,
 17///     TokenBudget = 5000,
 18/// };
 19/// </code>
 20/// </example>
 21public sealed record StageExecutionPolicy
 22{
 23    /// <summary>
 24    /// Evaluated at runtime. When true, the stage is skipped entirely.
 25    /// </summary>
 2626    public Func<StageExecutionContext, bool>? ShouldSkip { get; init; }
 27
 28    /// <summary>
 29    /// Called after stage execution. Returns <see langword="null"/> on success,
 30    /// or an error message that triggers a retry (up to <see cref="MaxAttempts"/>).
 31    /// </summary>
 1632    public Func<StageExecutionResult, string?>? PostValidation { get; init; }
 33
 34    /// <summary>
 35    /// Maximum execution attempts for post-validation retries. Default is 1 (no retry).
 36    /// </summary>
 4537    public int MaxAttempts { get; init; } = 1;
 38
 39    /// <summary>
 40    /// Optional per-stage token budget. When set, the runner scopes a child
 41    /// budget tracker for this stage.
 42    /// </summary>
 1043    public long? TokenBudget { get; init; }
 44
 45    /// <summary>
 46    /// Called after stage execution (success or failure, not skip).
 47    /// Receives the execution result and context for workspace checks or state updates.
 48    /// </summary>
 2249    public Func<StageExecutionResult, StageExecutionContext, Task>? AfterExecution { get; init; }
 50}