Skip to main content
Table of Contents

Class SessionContext

Namespace
Stratara.Contracts.Session
Assembly
Stratara.Contracts.dll

Dual-identity session context: Actor (who triggered) + the data-owner pair (TenantId, UserId). For 95% of operations Actor equals the data-owner; the distinction only diverges for PlatformAdmin cross-tenant operations, anonymous endpoints, and system/saga flows.

Convention across the codebase: unprefixed properties (TenantId, UserId) identify the data owner; Actor* properties identify the principal who triggered the write (audit / "who did this"). This matches every other IMultiTenant entity in the system.

[ExcludeFromCodeCoverage]
public sealed record SessionContext : IEquatable<SessionContext>
Inheritance
SessionContext
Implements
Inherited Members
Extension Methods

Constructors

SessionContext(string, string?, string?, Guid, Guid, Guid, Guid?, Guid?)

Dual-identity session context: Actor (who triggered) + the data-owner pair (TenantId, UserId). For 95% of operations Actor equals the data-owner; the distinction only diverges for PlatformAdmin cross-tenant operations, anonymous endpoints, and system/saga flows.

Convention across the codebase: unprefixed properties (TenantId, UserId) identify the data owner; Actor* properties identify the principal who triggered the write (audit / "who did this"). This matches every other IMultiTenant entity in the system.

public SessionContext(string CorrelationId, string? CausationId, string? ClientConnectionId, Guid ActorTenantId, Guid ActorUserId, Guid TenantId, Guid? UserId, Guid? ClientId = null)

Parameters

CorrelationId string

Stable correlation identifier (typically a v7 GUID string) — propagated across hops for log/trace correlation.

CausationId string

Causation identifier (the upstream command/event id) — propagated for causality chains.

ClientConnectionId string

Optional connection identifier (SignalR / WebSocket / call session) — used for proactive push.

ActorTenantId Guid

Tenant id of the principal who triggered the operation (audit dimension).

ActorUserId Guid

User id of the principal who triggered the operation (audit dimension).

TenantId Guid

Tenant the data belongs to (data-owner dimension; routing, encryption AAD, query filter).

UserId Guid?

Optional user the data belongs to (null for tenant-scoped aggregates).

ClientId Guid?

Optional client identifier (browser tab / phone call / SSR session) — used as Conversation/ProactiveSession stream id.

Fields

SystemActorTenantId

Sentinel for service/saga flows that have no inherited Actor. Distinguishable from Guid.Empty (which is used for anonymous endpoints).

public static readonly Guid SystemActorTenantId

Field Value

Guid

SystemActorUserId

Sentinel for service/saga flows that have no inherited Actor. Distinguishable from Guid.Empty (which is used for anonymous endpoints).

public static readonly Guid SystemActorUserId

Field Value

Guid

Properties

ActorTenantId

Tenant id of the principal who triggered the operation (audit dimension).

[JsonPropertyName("ActorTenantId")]
public Guid ActorTenantId { get; init; }

Property Value

Guid

ActorUserId

User id of the principal who triggered the operation (audit dimension).

[JsonPropertyName("ActorUserId")]
public Guid ActorUserId { get; init; }

Property Value

Guid

CausationId

Causation identifier (the upstream command/event id) — propagated for causality chains.

[JsonPropertyName("CausationId")]
public string? CausationId { get; init; }

Property Value

string

ClientConnectionId

Optional connection identifier (SignalR / WebSocket / call session) — used for proactive push.

[JsonPropertyName("ClientConnectionId")]
public string? ClientConnectionId { get; init; }

Property Value

string

ClientId

Optional client identifier (browser tab / phone call / SSR session) — used as Conversation/ProactiveSession stream id.

[JsonPropertyName("ClientId")]
public Guid? ClientId { get; init; }

Property Value

Guid?

CorrelationId

Stable correlation identifier (typically a v7 GUID string) — propagated across hops for log/trace correlation.

[JsonPropertyName("CorrelationId")]
public string CorrelationId { get; init; }

Property Value

string

TenantId

Tenant the data belongs to (data-owner dimension; routing, encryption AAD, query filter).

[JsonPropertyName("TenantId")]
public Guid TenantId { get; init; }

Property Value

Guid

UserId

Optional user the data belongs to (null for tenant-scoped aggregates).

[JsonPropertyName("UserId")]
public Guid? UserId { get; init; }

Property Value

Guid?

Methods

Empty()

Returns an empty/anonymous session-context value with freshly generated correlation + causation ids.

public static SessionContext Empty()

Returns

SessionContext