Skip to content

Commit 9541971

Browse files
authored
feat: Add governance and change management primitives with YAML/JSON configuration support (#16)
1 parent 99e5f9e commit 9541971

36 files changed

+6113
-4
lines changed

docs/user-guide/configuration.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,136 @@ app.Run();
608608

609609
---
610610

611+
## Governance Configuration
612+
613+
ExperimentFramework.Governance can be configured via YAML/JSON, enabling lifecycle management, approval gates, and policy-as-code guardrails without code changes.
614+
615+
### Installing Governance
616+
617+
```bash
618+
dotnet add package ExperimentFramework.Governance
619+
```
620+
621+
### Governance Schema
622+
623+
```yaml
624+
experimentFramework:
625+
governance:
626+
enableAutoVersioning: true
627+
628+
approvalGates:
629+
- type: automatic | manual | roleBased
630+
fromState: Draft | PendingApproval | Approved | etc.
631+
toState: PendingApproval | Approved | Running | etc.
632+
allowedRoles: # For roleBased only
633+
- operator
634+
- sre
635+
636+
policies:
637+
- type: trafficLimit | errorRate | timeWindow | conflictPrevention
638+
# Traffic limit properties
639+
maxTrafficPercentage: 10.0
640+
minStableTime: '00:30:00'
641+
642+
# Error rate properties
643+
maxErrorRate: 0.05
644+
645+
# Time window properties
646+
allowedStartTime: '09:00'
647+
allowedEndTime: '17:00'
648+
649+
# Conflict prevention properties
650+
conflictingExperiments:
651+
- experiment-name-1
652+
- experiment-name-2
653+
```
654+
655+
### Complete Example
656+
657+
See [governance-example.yaml](governance-example.yaml) for a complete example:
658+
659+
```yaml
660+
experimentFramework:
661+
governance:
662+
enableAutoVersioning: true
663+
664+
approvalGates:
665+
- type: automatic
666+
fromState: Draft
667+
toState: PendingApproval
668+
669+
- type: roleBased
670+
fromState: Approved
671+
toState: Running
672+
allowedRoles:
673+
- operator
674+
- sre
675+
676+
policies:
677+
- type: trafficLimit
678+
maxTrafficPercentage: 10.0
679+
minStableTime: '00:30:00'
680+
681+
- type: errorRate
682+
maxErrorRate: 0.05
683+
684+
- type: timeWindow
685+
allowedStartTime: '09:00'
686+
allowedEndTime: '17:00'
687+
688+
- type: conflictPrevention
689+
conflictingExperiments:
690+
- checkout-redesign
691+
- payment-flow-v2
692+
```
693+
694+
### Approval Gate Types
695+
696+
| Type | Description | Required Fields |
697+
|------|-------------|----------------|
698+
| `automatic` | Always approves transition | `toState` |
699+
| `manual` | Requires external approval record | `toState` |
700+
| `roleBased` | Checks actor's role | `toState`, `allowedRoles` |
701+
702+
### Policy Types
703+
704+
| Type | Description | Properties |
705+
|------|-------------|------------|
706+
| `trafficLimit` | Limits traffic % until stable | `maxTrafficPercentage`, `minStableTime` (optional) |
707+
| `errorRate` | Enforces max error rate | `maxErrorRate` |
708+
| `timeWindow` | Restricts operations to time window | `allowedStartTime`, `allowedEndTime` |
709+
| `conflictPrevention` | Prevents conflicting experiments | `conflictingExperiments` |
710+
711+
### Lifecycle States
712+
713+
Valid lifecycle states for `fromState` and `toState`:
714+
- `Draft` - Initial state
715+
- `PendingApproval` - Awaiting approval
716+
- `Approved` - Approved for activation
717+
- `Running` - Actively running
718+
- `Ramping` - Increasing traffic
719+
- `Paused` - Temporarily suspended
720+
- `RolledBack` - Reverted due to issues
721+
- `Rejected` - Not approved
722+
- `Archived` - Completed (terminal state)
723+
724+
### Integration Example
725+
726+
```csharp
727+
// appsettings.json or experiments.yaml
728+
var services = new ServiceCollection();
729+
services.AddExperimentFrameworkFromConfiguration(configuration);
730+
731+
// Governance is automatically configured from YAML
732+
var provider = services.BuildServiceProvider();
733+
var lifecycleManager = provider.GetService<ILifecycleManager>();
734+
var policyEvaluator = provider.GetService<IPolicyEvaluator>();
735+
```
736+
737+
For more details on governance features, see [Experiment Governance](governance.md).
738+
739+
---
740+
611741
## Best Practices
612742

613743
### 1. Organize by Feature
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Example: Complete governance configuration with YAML DSL
2+
3+
experimentFramework:
4+
# Governance configuration
5+
governance:
6+
# Enable automatic versioning on configuration changes
7+
enableAutoVersioning: true
8+
9+
# Define approval gates for lifecycle transitions
10+
approvalGates:
11+
# Automatic approval for Draft → PendingApproval
12+
- type: automatic
13+
fromState: Draft
14+
toState: PendingApproval
15+
16+
# Manual approval for PendingApproval → Approved
17+
- type: manual
18+
fromState: PendingApproval
19+
toState: Approved
20+
21+
# Role-based approval for Approved → Running
22+
- type: roleBased
23+
fromState: Approved
24+
toState: Running
25+
allowedRoles:
26+
- operator
27+
- sre
28+
29+
# Role-based approval for ramping (SRE only)
30+
- type: roleBased
31+
fromState: Running
32+
toState: Ramping
33+
allowedRoles:
34+
- sre
35+
36+
# Define policy guardrails
37+
policies:
38+
# Traffic limit: max 10% until 30 minutes stable
39+
- type: trafficLimit
40+
maxTrafficPercentage: 10.0
41+
minStableTime: '00:30:00'
42+
43+
# Error rate: must stay below 5%
44+
- type: errorRate
45+
maxErrorRate: 0.05
46+
47+
# Time window: only allow changes during business hours
48+
- type: timeWindow
49+
allowedStartTime: '09:00'
50+
allowedEndTime: '17:00'
51+
52+
# Conflict prevention: don't run these experiments together
53+
- type: conflictPrevention
54+
conflictingExperiments:
55+
- checkout-redesign
56+
- payment-flow-v2
57+
- shipping-calculator-update
58+
59+
# Regular experiment configuration
60+
trials:
61+
- serviceType: IPaymentProcessor
62+
selectionMode:
63+
type: featureFlag
64+
flagName: UseNewPaymentProcessor
65+
control:
66+
key: legacy
67+
implementationType: LegacyPaymentProcessor
68+
conditions:
69+
- key: "true"
70+
implementationType: NewPaymentProcessor

0 commit comments

Comments
 (0)