< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Context.AgentExecutionContext
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Context/AgentExecutionContext.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 46
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
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_UserId()100%11100%
get_OrchestrationId()100%11100%
get_Properties()100%11100%
get_Workspace()100%11100%
NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContext.get_Properties()100%11100%
BuildProperties()83.33%66100%
.cctor()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Context/AgentExecutionContext.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Context;
 2
 3/// <summary>
 4/// Default implementation of <see cref="IAgentExecutionContext"/>. Immutable record that
 5/// carries user identity, orchestration ID, an optional workspace, and an extensible
 6/// property bag.
 7/// </summary>
 8/// <param name="UserId">The user identity for the current orchestration.</param>
 9/// <param name="OrchestrationId">Correlation ID for the current orchestration run.</param>
 10/// <param name="Workspace">Optional workspace for agent file operations. Stored in
 11/// <see cref="IAgentExecutionContext.Properties"/> under the <see cref="Workspace.IWorkspace"/>
 12/// type key so it is accessible via <see cref="AgentExecutionContextExtensions.GetWorkspace"/>.</param>
 13/// <param name="Properties">Extensible property bag for consumer-specific data.</param>
 14[DoNotAutoRegister]
 4215public sealed record AgentExecutionContext(
 816    string UserId,
 317    string OrchestrationId,
 1718    IReadOnlyDictionary<string, object>? Properties = null,
 6219    Workspace.IWorkspace? Workspace = null) : IAgentExecutionContext
 20{
 21    /// <inheritdoc />
 22    IReadOnlyDictionary<string, object> IAgentExecutionContext.Properties =>
 1723        BuildProperties();
 24
 25    private IReadOnlyDictionary<string, object> BuildProperties()
 26    {
 1727        if (Workspace is null)
 1428            return Properties ?? EmptyProperties.Instance;
 29
 30        // Merge the workspace into the property bag so GetWorkspace() works
 31        // regardless of whether the consumer uses this default implementation
 32        // or a custom one.
 333        var merged = Properties is not null
 334            ? new Dictionary<string, object>(Properties)
 335            : new Dictionary<string, object>();
 36
 337        merged[typeof(Workspace.IWorkspace).FullName!] = Workspace;
 338        return merged;
 39    }
 40
 41    private static class EmptyProperties
 42    {
 143        internal static readonly IReadOnlyDictionary<string, object> Instance =
 144            new Dictionary<string, object>();
 45    }
 46}