MATIH Platform is in active MVP development. Documentation reflects current implementation status.
8. Platform Services
Environment Promotion

Environment Promotion

The Environment Promotion system manages the controlled movement of configurations between environments. The EnvironmentPromotionController at /api/v1/config/promotions orchestrates the dev-to-staging-to-production pipeline with validation, approval gates, and rollback capabilities.


Promotion Pipeline

dev -> staging -> production
  \       \          |
   \       \         v
    \       +-> rollback
     +------> rollback

Create a Promotion

Endpoint: POST /api/v1/config/promotions

curl -X POST http://localhost:8888/api/v1/config/promotions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "X-Tenant-ID: 550e8400-e29b-41d4-a716-446655440000" \
  -H "X-User-ID: 550e8400-e29b-41d4-a716-446655440001" \
  -H "X-User-Email: dev@acme.com" \
  -d '{
    "sourceEnvironment": "staging",
    "targetEnvironment": "production",
    "promotionType": "SELECTIVE",
    "configIds": ["770e8400-..."],
    "flagIds": ["880e8400-..."],
    "keyPatterns": ["query.*"],
    "notes": "Promoting query timeout changes verified in staging"
  }'

Promotion Types

TypeDescription
FULLPromote all configurations from source to target
SELECTIVEPromote specific configs and flags by ID
PATTERNPromote configs matching key patterns

Promotion Lifecycle

Validate: POST /api/v1/config/promotions/{promotionId}/validate

Approve: POST /api/v1/config/promotions/{promotionId}/approve

Execute: POST /api/v1/config/promotions/{promotionId}/execute

Schedule: POST /api/v1/config/promotions/{promotionId}/schedule

Rollback: POST /api/v1/config/promotions/{promotionId}/rollback

Cancel: DELETE /api/v1/config/promotions/{promotionId}


Environment Diff

Compare configurations between two environments to see what would change.

Endpoint: GET /api/v1/config/promotions/diff

curl "http://localhost:8888/api/v1/config/promotions/diff?source=staging&target=production" \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "X-Tenant-ID: 550e8400-e29b-41d4-a716-446655440000"

Response:

{
  "sourceEnvironment": "staging",
  "targetEnvironment": "production",
  "added": [
    { "key": "ai.new-model", "value": "gpt-4-turbo" }
  ],
  "modified": [
    {
      "key": "query.timeout",
      "sourceValue": "180s",
      "targetValue": "120s"
    }
  ],
  "removed": [],
  "unchanged": 35
}