Skip to main content

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:

  1. Detect deployment platforms automatically (Kubernetes, OpenShift, Docker, etc.)
  2. Generate deployment scripts from validated patterns and ADRs
  3. Track infrastructure resources for proper cleanup
  4. Validate deployments against architectural decisions
  5. 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 implementation
  • scripts/test-infrastructure.sh - Tests infrastructure deployment
  • npm 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โ€‹

  1. Comprehensive Testing: >80% test coverage including integration tests
  2. Clear Documentation: This ADR + user guide + tool context documents
  3. GitHub Issues: Auto-create issues for missing patterns
  4. Graceful Degradation: AI fallback when validated pattern unavailable
  5. Context Documents: Save tool state for debugging and reproducibility

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:

  1. Add New Patterns: Create YAML files in patterns/infrastructure/
  2. Update SystemCard: Add resource types to tracking logic
  3. Enhance Detection: Add platform indicators to platform-detector.ts
  4. Test Integration: Add tests in tests/tools/bootstrap-validation-loop.test.ts

For Contributorsโ€‹

To add a validated pattern:

  1. Use patterns/infrastructure/kubernetes.yaml as template
  2. Include authoritative documentation sources
  3. Define deployment phases with commands
  4. Add validation checks with remediation steps
  5. 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โ€‹

  1. 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
  2. Platform Detection - Fully operational

    • src/utils/platform-detector.ts - Complete detection system
    • Supports Kubernetes, OpenShift, Docker, Firebase, AWS, Node.js, Python, MCP
  3. Bootstrap Validation Loop - Production ready

    • src/tools/bootstrap-validation-loop-tool.ts - Main orchestrator
    • src/tools/adr-bootstrap-validation-tool.ts - ADR generation
    • Integrated with validated patterns and SystemCard
  4. SystemCard Resource Tracking - Implemented

    • Resource tracking during deployment
    • Cleanup script generation
    • CI/CD integration support

๐ŸŸก Partial Implementationโ€‹

  1. Kubernetes Support - Core functionality exists but some advanced features pending

    • Basic Kubernetes deployment: โœ… Complete
    • Advanced K8s features (HPA, Network Policies): โš ๏ธ Planned
  2. 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