< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.AgentGraphReducerAttribute
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/AgentGraphReducerAttribute.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 53
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
.ctor(...)100%11100%
get_GraphName()100%11100%
get_ReducerMethod()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/AgentGraphReducerAttribute.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework;
 2
 3/// <summary>
 4/// Declares a deterministic reducer node for fan-in convergence in a named
 5/// graph workflow. The reducer aggregates branch outputs without incurring
 6/// LLM cost — it is a pure function, not an agent.
 7/// </summary>
 8/// <remarks>
 9/// <para>
 10/// The <see cref="ReducerMethod"/> must be a <c>public static</c> method on the
 11/// decorated class that accepts <see cref="System.Collections.Generic.IReadOnlyList{T}"/>
 12/// of <see cref="string"/> and returns <see cref="string"/>.
 13/// </para>
 14/// </remarks>
 15/// <example>
 16/// <code>
 17/// [AgentGraphReducer("ResearchPipeline", ReducerMethod = nameof(MergeResults))]
 18/// public static class ResearchReducer
 19/// {
 20///     public static string MergeResults(IReadOnlyList&lt;string&gt; branchOutputs)
 21///         =&gt; string.Join("\n---\n", branchOutputs);
 22/// }
 23/// </code>
 24/// </example>
 25[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
 26public sealed class AgentGraphReducerAttribute : Attribute
 27{
 28    /// <summary>
 29    /// Initializes a new <see cref="AgentGraphReducerAttribute"/>.
 30    /// </summary>
 31    /// <param name="graphName">The name of the graph this reducer belongs to.</param>
 18432    public AgentGraphReducerAttribute(string graphName)
 33    {
 18434        ArgumentException.ThrowIfNullOrWhiteSpace(graphName);
 18435        GraphName = graphName;
 18436    }
 37
 38    /// <summary>Gets the graph name this reducer belongs to.</summary>
 18439    public string GraphName { get; }
 40
 41    /// <summary>
 42    /// Gets or sets the name of the static method on the decorated class that
 43    /// performs the reduction. The method must accept
 44    /// <see cref="System.Collections.Generic.IReadOnlyList{T}"/> of
 45    /// <see cref="string"/> and return <see cref="string"/>.
 46    /// </summary>
 47    /// <remarks>
 48    /// If not specified, defaults to <c>"Reduce"</c> by convention. The source
 49    /// generator will look for a <c>public static string Reduce(IReadOnlyList&lt;string&gt;)</c>
 50    /// method on the decorated class.
 51    /// </remarks>
 20652    public string? ReducerMethod { get; set; }
 53}