Skip to content

Commit 6ab8750

Browse files
committed
Docs: Reframe governance roadmap around execution hardening
1 parent 962f10c commit 6ab8750

2 files changed

Lines changed: 112 additions & 69 deletions

File tree

Docs/ExecutionModel.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This document describes the execution model that `ModularityKit.Mutator` is moving toward as governance features become first-class runtime capabilities.
44

5-
It complements the roadmap by explaining the lifecycle of a mutation once the engine supports pending execution, approvals, versioning, and compensation.
5+
It complements the roadmap by explaining the lifecycle of a mutation now that governance already has request lifecycle, approval workflow, and version-resolution primitives, but still needs a fully closed governed execution loop.
66

77
## Current Model
88

@@ -18,7 +18,7 @@ Today, the engine is centered around direct mutation execution:
1818
This model is strong for immediate execution flows, but it is intentionally narrow:
1919

2020
- blocked mutations are terminal outcomes
21-
- approval requirements are modeled but not yet lifecycle-driven
21+
- direct mutation execution is still the dominant runtime path
2222
- concurrency is not yet part of a first-class execution contract
2323
- compensation and re-execution are not yet modeled as governed transitions
2424

@@ -32,11 +32,12 @@ The target shape is:
3232
2. Evaluate policies and requirements
3333
3. Enter pending state when execution is deferred
3434
4. Resolve requirements through approvals or external checks
35-
5. Re-validate against the current state version
36-
6. Execute or reject
35+
5. Resolve against the current state version
36+
6. Execute through a governed execution manager
3737
7. Emit side effects
3838
8. Audit and persist history
39-
9. Optionally compensate or reverse
39+
9. Record executed or terminal governance decision
40+
10. Optionally compensate or reverse
4041

4142
This is the key conceptual shift in the project:
4243

@@ -69,7 +70,7 @@ Possible pending reasons:
6970
- `PendingDependency`
7071
- `PendingQuota`
7172

72-
Pending state should be treated as a first-class runtime state, not just a flag in `MutationResult`.
73+
Pending state is already a first-class governance state. The remaining work is to ensure every pending path has a clear re-entry route into governed execution.
7374

7475
### Resolution
7576

@@ -83,6 +84,8 @@ Possible outcomes:
8384
- expired
8485
- superseded by a newer request or state version
8586

87+
Resolution is already modeled in the governance runtime. The remaining gap is making it part of one mandatory execution path rather than a helper that callers compose manually.
88+
8689
### Versioned Execution
8790

8891
Approval and deferred execution require explicit version handling.
@@ -95,6 +98,23 @@ When a request is approved against a later state than the one originally evaluat
9598

9699
This behavior must be explicit and consistent across all pending mutation types.
97100

101+
The main hardening point is no longer whether version resolution exists, but whether approved requests always pass through it before execution and whether revalidation has its own explicit runtime semantics.
102+
103+
### Governed Execution Manager
104+
105+
Once approvals and version resolution exist, the runtime needs one orchestrator that closes the loop.
106+
107+
Expected responsibilities:
108+
109+
- load an approved request
110+
- perform mandatory version resolution
111+
- choose execute / reject / re-approve / revalidate paths
112+
- invoke the core mutation engine when execution is still valid
113+
- record resulting state version and execution outcome
114+
- persist terminal governance decisions such as `Executed`
115+
116+
Without this step, governance remains a set of useful runtime pieces rather than one coherent execution contract.
117+
98118
### Compensation
99119

100120
Once the engine supports governed execution over time, compensation becomes part of the execution model rather than a simple utility.
@@ -123,18 +143,20 @@ Without an explicit execution model, these features risk being implemented as is
123143

124144
## Design Pressure Points
125145

126-
These are the architectural questions that should stay visible as implementation starts:
146+
These are the architectural questions that should stay visible as implementation continues:
127147

128148
- Is the primary unit of governance a mutation or a mutation request?
129149
- What state version contract is required for deferred execution?
130150
- When does a pending mutation become stale?
131151
- Can approvals survive state drift, or must they be renewed?
152+
- What is the exact contract of revalidation before execution?
132153
- Are side effects emitted on request creation, on execution, or both?
133154
- How are compensation flows represented in audit and history?
155+
- Where does core mutation execution concurrency end and governance request concurrency begin?
134156

135157
## Relationship to the Roadmap
136158

137-
- `v1.1 Governance Runtime` introduces pending mutation lifecycle, approval workflow, versioned execution, and concurrency control.
159+
- `v1.1 Governance Runtime Hardening` closes the governed execution loop and hardens approval, version-resolution, and core concurrency semantics.
138160
- `v1.2 Governance Data` adds persistence, queryability, metadata handling, and typed side effects around that runtime model.
139161
- `v1.3 Integration` expands the model to async policy evaluation and external governance dependencies.
140162
- `v2.0 Governance Platform` extends the lifecycle with compensation and richer policy composition.

Docs/Roadmap.md

Lines changed: 82 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This document captures the most valuable next steps for `ModularityKit.Mutator` based on the current state of the API, runtime, and examples.
44

5-
The goal is not to add features for their own sake. The goal is to close gaps between the public model and the runtime behavior, then extend the engine into a more complete governance platform for state mutations.
5+
The goal is not to add features for their own sake. The goal is to close gaps between the public model and the runtime behavior, then complete the governed execution loop and extend the engine into a more operational governance platform for state mutations.
66

77
## Principles
88

@@ -15,102 +15,120 @@ The goal is not to add features for their own sake. The goal is to close gaps be
1515

1616
These areas already exist in the model but are only partially realized in the runtime:
1717

18-
- `PolicyRequirement` exists, but there is no approval lifecycle around it.
18+
- Governance now has request lifecycle, approval workflow, and version resolution primitives, but the end-to-end execution loop is still incomplete.
1919
- `MutationIntent.IsReversible` exists, but there is no undo or compensation mechanism.
20-
- `MutationEngineOptions.MaxConcurrentMutations` exists, but concurrency control is not enforced in runtime execution.
20+
- `MutationEngineOptions.MaxConcurrentMutations` exists, but concurrency control is not enforced in core mutation execution.
2121
- `MutationIntent.EstimatedBlastRadius`, `Tags`, and `Metadata` exist, but the engine does not yet use them for governance or query workflows.
22-
- The project has examples and benchmarks, but no dedicated test project yet.
22+
- Approved governance requests do not yet flow through a single runtime path that performs version resolution, mutation execution, audit/history persistence, and terminal executed-state recording.
2323

24-
## v1.1 Governance Runtime
24+
## v1.1 Governance Runtime Hardening
2525

26-
Focus: establish a first-class governance runtime centered around mutation requests, pending execution, and version-aware decision making.
26+
Focus: close the governed execution loop and harden the current governance runtime rather than introducing the first lifecycle concepts.
2727

28-
### 1. Pending Mutation Lifecycle
28+
### 1. Governed Execution Manager
2929

30-
Add a first-class lifecycle around deferred mutation requests.
30+
Add a first-class runtime path that executes approved governance requests end to end.
3131

3232
Scope:
3333

34-
- Introduce a `PendingMutation` or `MutationRequest` model for governed execution.
35-
- Support pending reasons beyond approval, such as external checks, scheduling, or dependencies.
36-
- Support approval expiration and explicit cancellation.
37-
- Persist approval decisions and approval history.
38-
- Define re-execution rules when a pending mutation is resolved against a newer state version.
39-
- Support listing and resolving pending mutation records.
34+
- Introduce a `GovernanceExecutionManager` or equivalent orchestration runtime for approved requests.
35+
- Always perform version resolution before executing an approved request.
36+
- Execute the underlying mutation through the core runtime once the request is still valid.
37+
- Record execution outcome, resulting state version, and terminal request decision.
38+
- Mark requests as `Executed`, rejected as stale, or sent back into a renewed approval / revalidation path.
39+
- Ensure audit and history flows capture both request-level and execution-level outcomes.
4040

4141
Why this matters:
4242

43-
- Approval workflow is only one specialization of pending execution.
44-
- A single `PendingApproval` status in `MutationResult` is not enough once the engine owns a real governance process.
43+
- Governance runtime already knows how to hold, approve, reject, expire, and version-check requests.
44+
- The biggest missing behavior is the actual transition from approved request to governed mutation execution.
4545

46-
### 2. Approval Workflow for `PolicyRequirement`
46+
### 2. Approval Workflow Hardening
4747

48-
Add first-class support for approval-based policy outcomes.
48+
Harden the approval model now that first-class approval workflow exists.
4949

5050
Scope:
5151

52-
- Introduce a pending approval result state for blocked mutations that require action rather than hard denial.
53-
- Persist approval requirements to audit and history.
54-
- Add follow-up mutations such as `ApproveRequirement` and `RejectRequirement`.
55-
- Support multi-step approvals such as two-man approval and role-based approval chains.
52+
- Replace generic approval failure paths with explicit domain exceptions and outcomes where they still leak through.
53+
- Add approval groups, role-oriented approver targeting, and richer requirement assignment semantics.
54+
- Support quorum or `N-of-M` approvals rather than only linear step completion.
55+
- Add timeout / expiration policies that are specific to approval requirements, not only request-level pending expiration.
56+
- Introduce a richer rejection reason model for auditability and later query support.
5657

5758
Why this matters:
5859

59-
- The policy model already supports `RequireApproval`.
60-
- This turns the engine from allow/deny enforcement into an actual governance workflow engine.
60+
- Approval workflow is no longer hypothetical.
61+
- The next investment is making it operationally expressive rather than merely present.
6162

62-
### 3. Versioned Execution and Concurrency Control
63+
### 3. Version Resolution Semantics Hardening
6364

64-
Add explicit optimistic concurrency handling around mutation execution.
65+
Harden the stale-request and revalidation semantics that now exist in the governance runtime.
6566

6667
Scope:
6768

68-
- Introduce version-aware mutation execution based on `stateId` and expected version.
69-
- Use `ConcurrencyException` as a real runtime outcome instead of a dormant abstraction.
70-
- Add optional lock-per-state execution for high-contention scenarios.
71-
- Define how batch execution behaves when a mid-batch concurrency conflict occurs.
69+
- Clarify what `RevalidateOnLatestState` means operationally before execution starts.
70+
- Consider an explicit pending reason or status path for revalidation-driven deferral.
71+
- Add end-to-end scenarios such as:
72+
- approve stale request
73+
- require renewed approval
74+
- approve again
75+
- execute
76+
- Ensure stale handling semantics are visible through request decisions, examples, and tests.
7277

7378
Why this matters:
7479

75-
- The library claims deterministic and async-safe behavior.
76-
- Without explicit concurrency semantics, that promise is incomplete for shared state workloads.
80+
- Version resolution exists, but its branch semantics still need to be tightened before governed execution becomes a durable contract.
81+
82+
### 4. Core Runtime Concurrency
83+
84+
Close the remaining concurrency gap in the core mutation engine itself.
85+
86+
Scope:
87+
88+
- Enforce `MutationEngineOptions.MaxConcurrentMutations` in core execution rather than leaving it as a passive option.
89+
- Introduce explicit concurrency handling around direct state mutation execution.
90+
- Decide whether per-state locking, optimistic execution, or both are part of the core runtime contract.
91+
- Define how direct batch execution behaves when concurrency conflicts appear mid-flight.
92+
93+
Why this matters:
94+
95+
- Recent work hardened governance request storage concurrency.
96+
- The underlying core execution runtime still has its own unresolved concurrency contract.
7797

7898
## v1.2 Governance Data
7999

80100
Focus: make governed execution queryable, persistent, and classification-aware.
81101

82-
### 1. Persistent History and Audit Stores
102+
### 1. Governance Query Store
83103

84-
Add production-ready adapters beyond in-memory implementations.
104+
Expose operational queries over requests, approvals, and decisions.
85105

86106
Scope:
87107

88-
- Entity Framework Core store for audit and history.
89-
- PostgreSQL-oriented store or provider package.
90-
- Optional Redis-backed recent-history cache for hot paths.
108+
- Introduce an `IMutationRequestQueryStore` or equivalent query contract.
109+
- Query pending approvals by actor, group, role, or request category.
110+
- Query requests by `stateId`, request category, tags, governance metadata, and blast radius.
111+
- Query recent request decisions, approval actions, stale resolutions, and execution outcomes.
112+
- Define storage-agnostic query contracts before binding them to a specific provider.
91113

92114
Why this matters:
93115

94-
- In-memory implementations are suitable for examples, tests, and development only.
95-
- Production integration is the next natural adoption step.
116+
- Governance data becomes operational once users can ask workflow questions, not just load a single request by id.
96117

97-
### 2. Query API for Audit and History
118+
### 2. Persistent Governance and Audit Providers
98119

99-
Expose richer retrieval primitives than state-id-only history lookup.
120+
Add production-ready persistence adapters beyond in-memory implementations.
100121

101122
Scope:
102123

103-
- Query by `actorId`, `category`, `riskLevel`, `sideEffectSeverity`, and time range.
104-
- Query by `tags`, governance metadata, and estimated blast radius.
105-
- Support recent activity queries and filtered timelines.
106-
- Add approval-oriented queries such as pending approvals and recent approval decisions.
107-
- Support risk-oriented filtering and reporting views.
108-
- Define storage-agnostic query contracts first, then implement provider-specific adapters.
124+
- Entity Framework Core provider for governance request storage and query flows.
125+
- PostgreSQL-oriented governance provider package.
126+
- Persistent audit/history provider where governance execution outcomes can be correlated with request data.
127+
- Optional Redis-backed recent-decision cache for hot operational paths if it proves necessary.
109128

110129
Why this matters:
111130

112-
- Audit and history become much more useful once users can answer operational questions, not just replay a single state stream.
113-
- Persistence without queryability is only a storage layer, not an operational feature.
131+
- Governance runtime without persistence remains development-friendly but operationally shallow.
114132

115133
### 3. Governance Metadata
116134

@@ -145,7 +163,7 @@ Why this matters:
145163

146164
Focus: connect governance runtime behaviors to external systems and asynchronous policy sources.
147165

148-
### 1. Async Policies
166+
### 1. Async Policies and External Governance Checks
149167

150168
Support policy evaluation that depends on external systems.
151169

@@ -154,7 +172,9 @@ Scope:
154172
- Introduce `EvaluateAsync(...)` policy support.
155173
- Preserve a sync path for lightweight policies.
156174
- Define ordering and timeout semantics when multiple async policies are involved.
157-
- Allow approval and governance checks to rely on external identity, ticketing, or compliance systems.
175+
- Allow approval and governance checks to rely on external identity, ticketing, quota, or compliance systems.
176+
- Support ticket-driven approval flows, external quota checks, and identity-provider backed approver resolution.
177+
- Define timeout and cancellation semantics for external governance dependencies.
158178

159179
Why this matters:
160180

@@ -212,19 +232,20 @@ The longer-term lifecycle model behind these milestones is documented in [`Docs/
212232

213233
## Recommended Build Order
214234

215-
1. Add pending mutation lifecycle support.
216-
2. Implement approval workflow support for `PolicyRequirement`.
217-
3. Add versioned execution and concurrency handling to the runtime.
218-
4. Add persistent audit/history providers.
219-
5. Add query APIs over persisted governance data.
220-
6. Persist and expose governance metadata.
221-
7. Add typed side effects once persistence and query contracts are stable.
222-
8. Add async policy support, unless external approval integrations force it earlier.
223-
9. Add undo/compensation support once approval and persistence semantics are stable.
235+
1. Add a governed execution manager that resolves and executes approved requests.
236+
2. Harden approval workflow semantics around quorum, roles, and rejection modeling.
237+
3. Tighten version-resolution semantics and revalidation paths.
238+
4. Close remaining core runtime concurrency gaps.
239+
5. Add governance query contracts for requests, approvals, and decisions.
240+
6. Add persistent governance and audit/history providers.
241+
7. Persist and expose governance metadata.
242+
8. Add typed side effects once persistence and query contracts are stable.
243+
9. Add async policy support, unless external approval integrations force it earlier.
244+
10. Add undo/compensation support once governed execution and persistence semantics are stable.
224245

225246
## Not Recommended Yet
226247

227248
These ideas may be useful later, but they are not the best next investment:
228249

229250
- Distributed execution features before concurrency semantics are explicit.
230-
- More examples before the runtime contract around approvals and concurrency is complete.
251+
- More examples before the governed execution loop is complete.

0 commit comments

Comments
 (0)