ADR-010: Bootstrap Deployment Architecture
Statusโ
Accepted
Dateโ
2025-01-23
Contextโ
The MCP ADR Analysis Server needs a comprehensive deployment automation system that can:
- Detect deployment platforms automatically (Kubernetes, OpenShift, Docker, etc.)
- Generate deployment scripts from validated patterns and ADRs
- Track infrastructure resources for proper cleanup
- Validate deployments against architectural decisions
- Provide reproducible workflows for CI/CD integration
Previously, deployment was manual and error-prone. We needed an intelligent system that integrates three key components:
- Validated Patterns Framework - Community-maintained deployment templates
- SystemCard Resource Tracking - Automated resource lifecycle management
- Bootstrap Validation Loop - Iterative deployment with learning
Decisionโ
We will implement a unified bootstrap deployment architecture that integrates Validated Patterns, SystemCard, and Bootstrap Validation Loop into a single developer-facing tool.
Architecture Overviewโ
Component Integration Flowโ
Deployment Workflow Detailโ
Resource Cleanup Architectureโ
Implementation Detailsโ
1. Validated Patterns Frameworkโ
Location: src/utils/validated-pattern-definitions.ts and patterns/infrastructure/*.yaml
Purpose: Provides community-maintained, tested deployment patterns
Structure:
version: '1.0'
id: 'kubernetes-v1'
name: 'Kubernetes'
authoritativeSources:
- type: 'documentation'
url: 'https://kubernetes.io/docs/'
requiredForDeployment: true
deploymentPhases:
- order: 1
name: 'Prerequisites Validation'
commands:
- command: 'kubectl cluster-info'
expectedExitCode: 0
validationChecks:
- id: 'cluster-connection'
command: 'kubectl cluster-info'
severity: 'critical'
Benefits:
- Official documentation links (LLMs should query before deployment)
- Proven deployment workflows
- Platform-specific validation checks
- Troubleshooting guidance
2. SystemCard Resource Trackingโ
Location: src/utils/system-card-manager.ts
Purpose: Track all infrastructure resources for proper cleanup
Key Features:
- Automatic resource detection during deployment
- Generates cleanup phases with proper ordering
- Integrates with CI/CD workflows
- Prevents orphaned resources
SystemCard Structure:
{
systemId: 'kubernetes-bootstrap-1234567890',
platform: {
type: 'kubernetes',
version: '1.28',
detectionConfidence: 0.95
},
resources: [
{
id: 'deployment-myapp',
type: 'deployment',
platform: 'kubernetes',
metadata: {
namespace: 'default',
name: 'myapp'
},
dependencies: ['service-myapp']
}
],
cleanupPhases: [
{
phase: 1,
description: 'Delete application deployments',
commands: ['kubectl delete deployment myapp']
}
]
}
3. Bootstrap Validation Loopโ
Location: src/tools/bootstrap-validation-loop-tool.ts
Purpose: Orchestrate the entire deployment workflow
Key Phases:
Phase 0: Environment Validationโ
- Detect platform type
- Verify connectivity (oc status, kubectl cluster-info, docker ps)
- Confirm target environment with user
Phase 1-5: Iterative Deploymentโ
- Generate bootstrap scripts from validated patterns
- Execute deployment
- Validate against ADR requirements
- Auto-fix failures (if enabled)
- Retry until success or max iterations
Generated Files:
project/
โโโ docs/adrs/
โ โโโ bootstrap-deployment-{timestamp}.md # Deployment ADR
โโโ bootstrap.sh # Deployment script
โโโ validate_bootstrap.sh # Validation script
โโโ cleanup.sh # Cleanup script (from SystemCard)
โโโ .system-card.json # Resource tracking state
4. GitHub Workflows Integrationโ
Publish Workflow (.github/workflows/publish.yml)โ
- name: Test MCP server functionality
run: ./scripts/test-mcp-server.sh
- name: Build project
run: npm run build
- name: Publish to NPM
run: npm publish
Key Scripts Called:
scripts/test-mcp-server.sh- Validates MCP protocol implementationscripts/test-infrastructure.sh- Tests infrastructure deploymentnpm run build- Compiles TypeScript โ JavaScript
Build Workflow (.github/workflows/build.yml)โ
- Type checking
- Linting
- Unit tests
- Integration tests
Test Workflow (.github/workflows/test.yml)โ
- Comprehensive test suite
- Coverage reporting
- Performance benchmarks
5. Tool Entry Point for Developersโ
Tool Call:
bootstrap_validation_loop({
projectPath: '/path/to/project',
adrDirectory: 'docs/adrs',
targetEnvironment: 'production',
maxIterations: 5,
autoFix: true,
updateAdrsWithLearnings: true,
});
Returns:
{
success: true,
iterations: 2,
finalResult: { /* execution details */ },
adrUpdates: [ /* proposed ADR updates */ ],
deploymentPlan: { /* detected platform and steps */ },
bootstrapAdrPath: "docs/adrs/bootstrap-deployment-1234.md",
contextDocumentPath: "docs/context/bootstrap-1234.json",
requiresHumanApproval: true
}
Deployment Script Examplesโ
Generated bootstrap.sh (from Kubernetes Pattern)โ
#!/bin/bash
# Bootstrap script generated from Kubernetes v1.0
# Pattern source: Official Kubernetes Documentation
# Generated: 2025-01-23T10:00:00.000Z
set -e # Exit on error
echo "========================================"
echo "Bootstrap Deployment - kubernetes"
echo "Pattern: Kubernetes"
echo "========================================"
# Phase 1: Prerequisites Validation
echo "Starting Phase 1: Prerequisites Validation"
echo " โ Verify kubectl is installed"
kubectl version --client
echo " โ Verify cluster connectivity"
kubectl cluster-info
echo "โ Phase 1 complete"
# Phase 2: Namespace Setup
echo "Starting Phase 2: Namespace Setup"
echo " โ Create namespace"
kubectl create namespace myapp
echo "โ Phase 2 complete"
# Phase 3: Deploy Application Resources
echo "Starting Phase 3: Deploy Application Resources"
echo " โ Apply deployment manifest"
kubectl apply -f deployment.yaml
echo "โ Phase 3 complete"
echo "========================================"
echo "โ
Bootstrap deployment complete!"
echo "========================================"
Generated validate_bootstrap.shโ
#!/bin/bash
# Validation script generated from Kubernetes
# Generated: 2025-01-23T10:00:00.000Z
FAILED_CHECKS=0
# Cluster Connection (critical)
echo "Checking: Cluster Connection"
if kubectl cluster-info; then
echo " โ
PASSED: Cluster Connection"
else
echo " โ FAILED: Cluster Connection"
echo " Cannot connect to Kubernetes cluster"
echo " Remediation steps:"
echo " - Verify kubeconfig is set: echo $KUBECONFIG"
echo " - Check cluster status with cloud provider"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
fi
# Deployment Ready (critical)
echo "Checking: Deployment Ready"
if kubectl get pods -l app=myapp --no-headers | grep -v Running && exit 1 || exit 0; then
echo " โ
PASSED: Deployment Ready"
else
echo " โ FAILED: Deployment Ready"
FAILED_CHECKS=$((FAILED_CHECKS + 1))
fi
if [ $FAILED_CHECKS -eq 0 ]; then
echo "โ
All validation checks passed!"
exit 0
else
echo "โ $FAILED_CHECKS validation check(s) failed"
exit 1
fi
Generated cleanup.sh (from SystemCard)โ
#!/bin/bash
# Cleanup script generated by SystemCard
# Resources tracked during deployment
set -e
echo "๐งน Starting deployment cleanup..."
# Phase 1: Delete application deployments
echo "Phase 1: Delete application deployments"
kubectl delete deployment myapp --ignore-not-found
kubectl delete service myapp --ignore-not-found
echo "โ Phase 1 complete"
# Phase 2: Delete namespace
echo "Phase 2: Delete namespace"
kubectl delete namespace myapp --ignore-not-found
echo "โ Phase 2 complete"
echo "โ
Cleanup complete!"
CI/CD Integrationโ
Teardown and Restart Workflowโ
# CI/CD workflow for deployment testing
./cleanup.sh # Teardown existing deployment
./validate_bootstrap.sh # Verify cleanup
./bootstrap.sh # Deploy fresh instance
./validate_bootstrap.sh # Verify deployment
Automated Testingโ
# .github/workflows/test-deployment.yml
- name: Bootstrap Deployment Test
run: |
# Run bootstrap validation loop
npm test -- bootstrap-validation-loop.test.ts
# Verify cleanup works
./cleanup.sh
# Verify resources are removed
kubectl get all -n myapp || echo "Namespace cleaned up"
File Structureโ
mcp-adr-analysis-server/
โโโ src/
โ โโโ tools/
โ โ โโโ bootstrap-validation-loop-tool.ts # Main orchestrator
โ โโโ utils/
โ โโโ validated-pattern-definitions.ts # Pattern definitions
โ โโโ platform-detector.ts # Platform detection
โ โโโ system-card-manager.ts # Resource tracking
โ โโโ dag-executor.ts # DAG execution
โ โโโ pattern-to-dag-converter.ts # Pattern โ DAG
โโโ patterns/
โ โโโ infrastructure/
โ โโโ kubernetes.yaml # K8s pattern
โ โโโ openshift.yaml # OpenShift pattern
โ โโโ docker.yaml # Docker pattern
โ โโโ firebase.yaml # Firebase pattern
โโโ docs/
โ โโโ adrs/
โ โ โโโ adr-010-bootstrap-deployment-architecture.md # This ADR
โ โโโ how-to-guides/
โ โโโ bootstrap-architecture-docs.md # User guide
โโโ scripts/
โ โโโ test-mcp-server.sh # MCP validation
โ โโโ test-infrastructure.sh # Infrastructure tests
โโโ .github/
โโโ workflows/
โโโ publish.yml # NPM publishing
โโโ build.yml # Build verification
โโโ test.yml # Test execution
Consequencesโ
Positiveโ
โ Single Tool Call: Developers call one tool, get complete deployment automation
โ Platform Agnostic: Works with Kubernetes, OpenShift, Docker, Firebase, etc.
โ Resource Safety: SystemCard prevents orphaned resources and provides cleanup
โ Best Practices: Validated patterns include official documentation and proven workflows
โ CI/CD Ready: Generated scripts integrate seamlessly with GitHub Actions
โ Learning System: Bootstrap loop learns from failures and improves scripts
โ ADR Generation: Automatically documents deployment decisions
โ Reproducible: Same tool call produces consistent results
Negativeโ
โ ๏ธ Complexity: Three integrated components can be difficult to debug
โ ๏ธ Pattern Maintenance: YAML patterns need community contributions and updates
โ ๏ธ AI Fallback: Without validated pattern, AI-generated workflows are less tested
โ ๏ธ Storage Overhead: SystemCard and context documents add file system usage
Mitigation Strategiesโ
- Comprehensive Testing: >80% test coverage including integration tests
- Clear Documentation: This ADR + user guide + tool context documents
- GitHub Issues: Auto-create issues for missing patterns
- Graceful Degradation: AI fallback when validated pattern unavailable
- Context Documents: Save tool state for debugging and reproducibility
Related ADRsโ
- ADR-001: MCP Protocol Implementation
- ADR-002: AI Integration Strategy
- ADR-012: Validated Patterns Framework
- ADR-014: CE-MCP Architecture (aligns with CE-MCP execution model)
Referencesโ
- Bootstrap Validation Loop:
src/tools/bootstrap-validation-loop-tool.ts:2120-2531 - SystemCard Manager:
src/utils/system-card-manager.ts - Validated Patterns:
patterns/infrastructure/*.yaml - Kubernetes Pattern:
patterns/infrastructure/kubernetes.yaml:1-407 - Platform Detection:
src/utils/platform-detector.ts - DAG Executor:
src/utils/dag-executor.ts - User Guide:
docs/how-to-guides/bootstrap-architecture-docs.md
Implementation Notesโ
For Maintainersโ
When extending this system:
- Add New Patterns: Create YAML files in
patterns/infrastructure/ - Update SystemCard: Add resource types to tracking logic
- Enhance Detection: Add platform indicators to
platform-detector.ts - Test Integration: Add tests in
tests/tools/bootstrap-validation-loop.test.ts
For Contributorsโ
To add a validated pattern:
- Use
patterns/infrastructure/kubernetes.yamlas template - Include authoritative documentation sources
- Define deployment phases with commands
- Add validation checks with remediation steps
- Submit PR with pattern YAML and tests
For Usersโ
See the End User Bootstrap ADR Template for what gets generated in your project.
Last Updated: 2025-12-15 Author: Tosin Akinosho Status: Accepted and Implemented
Implementation Status Update (2025-12-15)โ
โ Fully Implemented Componentsโ
-
Validated Patterns Framework - Complete integration
- Pattern definitions:
src/utils/validated-pattern-definitions.ts - YAML patterns:
patterns/infrastructure/*.yaml(5 patterns) - Pattern resources: Multiple resource files for pattern access
- Pattern definitions:
-
Platform Detection - Fully operational
src/utils/platform-detector.ts- Complete detection system- Supports Kubernetes, OpenShift, Docker, Firebase, AWS, Node.js, Python, MCP
-
Bootstrap Validation Loop - Production ready
src/tools/bootstrap-validation-loop-tool.ts- Main orchestratorsrc/tools/adr-bootstrap-validation-tool.ts- ADR generation- Integrated with validated patterns and SystemCard
-
SystemCard Resource Tracking - Implemented
- Resource tracking during deployment
- Cleanup script generation
- CI/CD integration support
๐ก Partial Implementationโ
-
Kubernetes Support - Core functionality exists but some advanced features pending
- Basic Kubernetes deployment: โ Complete
- Advanced K8s features (HPA, Network Policies): โ ๏ธ Planned
-
Memory Integration - Basic tracking exists, advanced querying planned
- Pattern application tracking: โ Complete
- Pattern querying via memory: โ ๏ธ Planned enhancement
๐ Implementation Metricsโ
- Overall Completion: ~90%
- Core Functionality: 100% operational
- Production Readiness: โ Ready for use
- Test Coverage: Comprehensive test suite exists
- Documentation: Complete user guides and ADRs
๐ Recent Updatesโ
- Validated patterns framework fully integrated (ADR-012)
- Platform detection system operational
- Bootstrap validation loop production-ready
- SystemCard resource tracking implemented