This document describes the execution model that ModularityKit.Mutator is moving toward as governance features become first-class runtime capabilities.
It complements the roadmap by explaining the lifecycle of a mutation once the engine supports pending execution, approvals, versioning, and compensation.
Today, the engine is centered around direct mutation execution:
- Receive a mutation
- Evaluate policies
- Validate
- Execute or block
- Audit
- Persist history
This model is strong for immediate execution flows, but it is intentionally narrow:
- blocked mutations are terminal outcomes
- approval requirements are modeled but not yet lifecycle-driven
- concurrency is not yet part of a first-class execution contract
- compensation and re-execution are not yet modeled as governed transitions
As governance features expand, execution becomes a lifecycle rather than a single pass.
The target shape is:
- Create a mutation request
- Evaluate policies and requirements
- Enter pending state when execution is deferred
- Resolve requirements through approvals or external checks
- Re-validate against the current state version
- Execute or reject
- Emit side effects
- Audit and persist history
- Optionally compensate or reverse
This is the key conceptual shift in the project:
- from direct mutation execution
- to governed mutation request execution
Represents a request to execute a mutation under governance.
Expected responsibilities:
- carry the original mutation intent and context
- keep a stable request identifier
- track creation time, current status, and owning state
- record required approvals or checks
- retain the state version or snapshot contract used for re-evaluation
Represents a mutation request that cannot execute immediately.
Possible pending reasons:
PendingApprovalPendingExternalCheckPendingSchedulePendingDependencyPendingQuota
Pending state should be treated as a first-class runtime state, not just a flag in MutationResult.
A pending mutation must eventually transition through an explicit resolution path.
Possible outcomes:
- approved and executed
- rejected
- canceled
- expired
- superseded by a newer request or state version
Approval and deferred execution require explicit version handling.
When a request is approved against a later state than the one originally evaluated, the runtime must define one of the following behaviors:
- re-execute against the latest state after re-validation
- reject as stale
- require re-approval
This behavior must be explicit and consistent across all pending mutation types.
Once the engine supports governed execution over time, compensation becomes part of the execution model rather than a simple utility.
Compensation should describe:
- what original execution it is linked to
- whether it is automatic or operator-triggered
- whether it restores prior state or applies a forward corrective mutation
The roadmap explains priorities and release grouping.
The execution model explains semantics.
That distinction matters because several features are tightly coupled:
- pending mutation lifecycle
- approval workflow
- versioned execution
- concurrency control
- undo and compensation
Without an explicit execution model, these features risk being implemented as isolated additions instead of one coherent runtime contract.
These are the architectural questions that should stay visible as implementation starts:
- Is the primary unit of governance a mutation or a mutation request?
- What state version contract is required for deferred execution?
- When does a pending mutation become stale?
- Can approvals survive state drift, or must they be renewed?
- Are side effects emitted on request creation, on execution, or both?
- How are compensation flows represented in audit and history?
v1.1 Governance Runtimeintroduces pending mutation lifecycle, approval workflow, versioned execution, and concurrency control.v1.2 Governance Dataadds persistence, queryability, metadata handling, and typed side effects around that runtime model.v1.3 Integrationexpands the model to async policy evaluation and external governance dependencies.v2.0 Governance Platformextends the lifecycle with compensation and richer policy composition.