Skip to content

Fix: Expose ActorType on MutationContext for external policy inspection - #98

Merged
rian-be merged 1 commit into
mainfrom
develop
Jul 28, 2026
Merged

Fix: Expose ActorType on MutationContext for external policy inspection#98
rian-be merged 1 commit into
mainfrom
develop

Conversation

@rian-be

@rian-be rian-be commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Problem Statement

MutationContext.ActorType is currently internal, making it impossible for external consumers (policies, governance components) to inspect whether a mutation was initiated by a User, Service, or System. This forces consumers to rely on fragile conventions like checking string prefixes:

var isSystemActor = transaction.InitiatedBy.StartsWith("system:", StringComparison.OrdinalIgnoreCase);

Solution Overview

1. Expose ActorType enum as public

The enum is used by MutationContext and needs to be visible to consumers for type inspection.

2. Change MutationContext.ActorType visibility

// Before
internal ActorType ActorType { get; init; } = ActorType.Unknown;

// After
public ActorType ActorType { get; internal init; } = ActorType.Unknown;

Consumers can read the value, but only the framework can assign it.

3. Keep System() factory signature unchanged

MutationContext.System() does not set ActorId — the system actor is identified by its type, not an ID. User() and Service() continue to set ActorId as before.


Design Decisions

Why exclude convenience booleans (`IsSystemActor`, etc.)?

MutationContext is a data holder, not a policy engine. Adding booleans blurs responsibility and creates maintenance debt — if new actor types match the same semantics (e.g. Administrator should behave like User), the booleans become misleading. Policies should write context.ActorType is ActorType.System explicitly.

Why not add `systemId` parameter to `System()`?

ActorId has shared semantics — it identifies "who did it" regardless of actor type. System actors are identified by ActorType == ActorType.System, not by an ID. If a specific system component needs attribution, consumers can pass it via Metadata.


Files Changed

ActorType.cs

  • Visibility changed from internal enum to public enum

MutationContext.cs

  • ActorType property changed from internal to public with internal init

Migration

Note

No breaking changes. Existing code that uses MutationContext factory methods (System, User, Service) is unaffected. All existing callers continue to work without modification.

closes #84

@github-actions github-actions Bot added the abstractions Public abstractions and contracts label Jul 28, 2026
@rian-be rian-be changed the title Expose ActorType on MutationContext for external policy inspection Fix: Expose ActorType on MutationContext for external policy inspection Jul 28, 2026
@rian-be
rian-be merged commit 4c1be17 into main Jul 28, 2026
33 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

abstractions Public abstractions and contracts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Expose mutation actor type to policy consumers

1 participant