Class MutationContext
Represents the execution context of a mutation. Answers the questions: WHO, WHEN, WHY, and HOW the mutation is performed.
Implements
Inherited Members
Namespace: ModularityKit.Mutator.Abstractions.Context
Assembly: ModularityKit.Mutator.dll
Syntax
public sealed record MutationContext : IEquatable<MutationContext>
Remarks
This context provides metadata for auditing, tracking, and governance of mutations within the system. It captures information about the actor (user, system, or service), the reason for the mutation, timestamps, correlation identifiers, and additional metadata.
Common usage:
- Audit trails
- Correlation and causation in distributed systems
- Simulation and validation of mutations
Properties
| Edit this page View SourceActorId
Identifier of the actor performing the mutation.
Declaration
public string? ActorId { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
ActorName
Human-readable name of the actor.
Declaration
public string? ActorName { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
CausationId
ID of the command or event that caused this mutation.
Declaration
public string? CausationId { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
CorrelationId
Correlation ID for distributed system tracking.
Declaration
public string? CorrelationId { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
Culture
Culture of the actor (e.g., "en-US").
Declaration
public string? Culture { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
Metadata
Additional contextual metadata for the mutation.
Declaration
public IReadOnlyDictionary<string, object> Metadata { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, object> |
Mode
Mode of mutation execution (commit, dry-run, etc.).
Declaration
public MutationMode Mode { get; init; }
Property Value
| Type | Description |
|---|---|
| MutationMode |
Reason
Reason for performing the mutation.
Declaration
public string? Reason { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
SessionId
User session identifier.
Declaration
public string? SessionId { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
SourceIpAddress
Source IP address (if applicable).
Declaration
public string? SourceIpAddress { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
StateId
Identifier of the state being mutated (if applicable).
Declaration
public string? StateId { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
TimeZone
Time zone of the actor.
Declaration
public TimeZoneInfo? TimeZone { get; init; }
Property Value
| Type | Description |
|---|---|
| TimeZoneInfo |
Timestamp
Timestamp when the mutation was initiated.
Declaration
public DateTimeOffset Timestamp { get; init; }
Property Value
| Type | Description |
|---|---|
| DateTimeOffset |
UserAgent
User agent string (if applicable).
Declaration
public string? UserAgent { get; init; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceService(string, string)
Creates a service-level mutation context.
Declaration
public static MutationContext Service(string serviceId, string reason)
Parameters
| Type | Name | Description |
|---|---|---|
| string | serviceId | Service ID performing the mutation. |
| string | reason | Reason for the service mutation. |
Returns
| Type | Description |
|---|---|
| MutationContext | A MutationContext representing a service actor. |
System(string, string?)
Creates a system-level mutation context.
Declaration
public static MutationContext System(string reason, string? correlationId = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | reason | Reason for the system mutation. |
| string | correlationId | Optional correlation ID. |
Returns
| Type | Description |
|---|---|
| MutationContext | A MutationContext representing a system actor. |
User(string, string?, string?)
Creates a user-level mutation context.
Declaration
public static MutationContext User(string userId, string? userName = null, string? reason = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userId | User ID performing the mutation. |
| string | userName | Optional username. |
| string | reason | Optional reason for mutation. |
Returns
| Type | Description |
|---|---|
| MutationContext | A MutationContext representing a user actor. |