proof-composer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

proof-composer: System-Wide Proof Validation (DEPLOYMENT GATE)

proof-composer:全系统证明验证(部署闸门)

Purpose

目的

Validate entire engineering proof chain and authorize deployment. This is the final deployment gate - nothing deploys without a valid composed proof.
Key insight: Each skill generates local proofs. proof-composer verifies they compose into a valid system-wide proof.
Process:
  1. Collect all proofs (architecture, backend, frontend, infrastructure)
  2. Verify version consistency (all use same spec version)
  3. Validate proof chain (architecture → backend → standardization → frontend → infrastructure)
  4. Check for gaps (missing proofs, incomplete verification)
  5. Generate composed proof certificate (authorizes deployment)

验证完整的工程证明链并授权部署。这是最终部署闸门——没有有效的组合证明,任何内容都无法部署。
核心思路: 每个技能都会生成本地证明。proof-composer负责验证这些证明能否组合成有效的全系统证明。
流程:
  1. 收集所有证明(架构、后端、前端、基础设施)
  2. 验证版本一致性(所有证明使用相同的规格版本)
  3. 验证证明链(架构 → 后端 → 标准化 → 前端 → 基础设施)
  4. 检查是否存在缺口(缺失的证明、未完成的验证)
  5. 生成组合证明证书(授权部署)

Position in Engineering Layer

在工程层中的位置

You are skill #6 of 6 (FINAL GATE):
  1. system-architect - Requirements → Specifications + Curry-Howard proofs
  2. backend-prover - Specifications → Maps → Code + Runtime monitors
  3. standardization-layer - Code → Middleware injection (naturality proofs)
  4. frontend-prover - OpenAPI → TypeScript + Framework bindings + Type correspondence
  5. infrastructure-prover - Services spec → Deployment configs + Topology isomorphism
  6. proof-composer (YOU) - Validates entire chain + Authorizes deployment

你是6个技能中的第6个(最终闸门):
  1. system-architect - 需求 → 规格说明 + Curry-Howard证明
  2. backend-prover - 规格说明 → 映射 → 代码 + 运行时监视器
  3. standardization-layer - 代码 → 中间件注入(自然性证明)
  4. frontend-prover - OpenAPI → TypeScript + 框架绑定 + 类型对应
  5. infrastructure-prover - 服务规格 → 部署配置 + 拓扑同构
  6. proof-composer(你) - 验证整个链条 + 授权部署

Input Requirements

输入要求

All proofs from previous skills:
artifacts/engineering/proofs/
├── architecture/
│   ├── adt-correctness/
│   ├── functor-laws/
│   ├── composition-correctness/
│   ├── state-machines/
│   └── curry-howard-proofs/
├── backend/
│   ├── map-validation/
│   │   └── validation-report.json
│   ├── implementation-correctness/
│   ├── standardization/
│   │   └── naturality-certificate.proof
│   └── runtime-verification/
├── frontend/
│   └── type-correspondence/
│       └── openapi-to-typescript.proof
└── infrastructure/
    └── topology/
        └── deployment-isomorphism.proof
Specification manifest:
artifacts/engineering/specifications/manifest.json
Generated artifacts:
artifacts/engineering/
├── specifications/v{X}/          # From system-architect
├── maps/backend/                 # From backend-prover Phase 1
├── code/backend/                 # From backend-prover Phase 2
├── code/frontend/                # From frontend-prover
└── configs/                      # From infrastructure-prover

来自之前所有技能的证明:
artifacts/engineering/proofs/
├── architecture/
│   ├── adt-correctness/
│   ├── functor-laws/
│   ├── composition-correctness/
│   ├── state-machines/
│   └── curry-howard-proofs/
├── backend/
│   ├── map-validation/
│   │   └── validation-report.json
│   ├── implementation-correctness/
│   ├── standardization/
│   │   └── naturality-certificate.proof
│   └── runtime-verification/
├── frontend/
│   └── type-correspondence/
│       └── openapi-to-typescript.proof
└── infrastructure/
    └── topology/
        └── deployment-isomorphism.proof
规格说明清单:
artifacts/engineering/specifications/manifest.json
生成的工件:
artifacts/engineering/
├── specifications/v{X}/          # 来自system-architect
├── maps/backend/                 # 来自backend-prover 阶段1
├── code/backend/                 # 来自backend-prover 阶段2
├── code/frontend/                # 来自frontend-prover
└── configs/                      # 来自infrastructure-prover

Validation Process

验证流程

Step 1: Collect All Proofs

步骤1:收集所有证明

python
def collect_proofs():
    """
    Collect all proof files from engineering artifacts
    
    Returns dict of proofs by category
    """
    
    proofs = {
        'architecture': collect_architecture_proofs(),
        'backend': collect_backend_proofs(),
        'frontend': collect_frontend_proofs(),
        'infrastructure': collect_infrastructure_proofs()
    }
    
    return proofs

def collect_architecture_proofs():
    """Collect from system-architect"""
    return {
        'adt_correctness': load_proof('architecture/adt-correctness/'),
        'functor_laws': load_proof('architecture/functor-laws/'),
        'composition': load_proof('architecture/composition-correctness/'),
        'state_machines': load_proof('architecture/state-machines/'),
        'curry_howard': load_proof('architecture/curry-howard-proofs/')
    }

def collect_backend_proofs():
    """Collect from backend-prover + standardization-layer"""
    return {
        'map_validation': load_json('backend/map-validation/validation-report.json'),
        'implementation': load_proof('backend/implementation-correctness/'),
        'standardization': load_json('backend/standardization/naturality-certificate.proof'),
        'runtime': load_proof('backend/runtime-verification/')
    }

def collect_frontend_proofs():
    """Collect from frontend-prover"""
    return {
        'type_correspondence': load_json('frontend/type-correspondence/openapi-to-typescript.proof')
    }

def collect_infrastructure_proofs():
    """Collect from infrastructure-prover"""
    return {
        'topology': load_json('infrastructure/topology/deployment-isomorphism.proof')
    }

python
def collect_proofs():
    """
    Collect all proof files from engineering artifacts
    
    Returns dict of proofs by category
    """
    
    proofs = {
        'architecture': collect_architecture_proofs(),
        'backend': collect_backend_proofs(),
        'frontend': collect_frontend_proofs(),
        'infrastructure': collect_infrastructure_proofs()
    }
    
    return proofs

def collect_architecture_proofs():
    """Collect from system-architect"""
    return {
        'adt_correctness': load_proof('architecture/adt-correctness/'),
        'functor_laws': load_proof('architecture/functor-laws/'),
        'composition': load_proof('architecture/composition-correctness/'),
        'state_machines': load_proof('architecture/state-machines/'),
        'curry_howard': load_proof('architecture/curry-howard-proofs/')
    }

def collect_backend_proofs():
    """Collect from backend-prover + standardization-layer"""
    return {
        'map_validation': load_json('backend/map-validation/validation-report.json'),
        'implementation': load_proof('backend/implementation-correctness/'),
        'standardization': load_json('backend/standardization/naturality-certificate.proof'),
        'runtime': load_proof('backend/runtime-verification/')
    }

def collect_frontend_proofs():
    """Collect from frontend-prover"""
    return {
        'type_correspondence': load_json('frontend/type-correspondence/openapi-to-typescript.proof')
    }

def collect_infrastructure_proofs():
    """Collect from infrastructure-prover"""
    return {
        'topology': load_json('infrastructure/topology/deployment-isomorphism.proof')
    }

Step 2: Verify Version Consistency

步骤2:验证版本一致性

python
def verify_version_consistency(proofs, manifest):
    """
    Verify all proofs reference same specification version
    
    Critical: Prevents race conditions where different skills
    used different versions of the spec
    """
    
    errors = []
    
    # Get spec version from manifest
    spec_version = manifest['version']
    spec_hash = manifest['hash']
    
    # Check architecture proofs
    arch_version = proofs['architecture'].get('specification_version')
    if arch_version != spec_version:
        errors.append({
            "type": "version_mismatch",
            "skill": "system-architect",
            "expected": spec_version,
            "actual": arch_version
        })
    
    # Check backend proofs
    backend_version = proofs['backend']['map_validation'].get('specification_version')
    if backend_version != spec_version:
        errors.append({
            "type": "version_mismatch",
            "skill": "backend-prover",
            "expected": spec_version,
            "actual": backend_version
        })
    
    # Check frontend proofs
    frontend_version = proofs['frontend']['type_correspondence'].get('specification_version')
    if frontend_version != spec_version:
        errors.append({
            "type": "version_mismatch",
            "skill": "frontend-prover",
            "expected": spec_version,
            "actual": frontend_version
        })
    
    # Check infrastructure proofs
    infra_version = proofs['infrastructure']['topology'].get('specification_version')
    if infra_version != spec_version:
        errors.append({
            "type": "version_mismatch",
            "skill": "infrastructure-prover",
            "expected": spec_version,
            "actual": infra_version
        })
    
    return {
        "consistent": len(errors) == 0,
        "specification_version": spec_version,
        "specification_hash": spec_hash,
        "errors": errors
    }

python
def verify_version_consistency(proofs, manifest):
    """
    Verify all proofs reference same specification version
    
    Critical: Prevents race conditions where different skills
    used different versions of the spec
    """
    
    errors = []
    
    # Get spec version from manifest
    spec_version = manifest['version']
    spec_hash = manifest['hash']
    
    # Check architecture proofs
    arch_version = proofs['architecture'].get('specification_version')
    if arch_version != spec_version:
        errors.append({
            "type": "version_mismatch",
            "skill": "system-architect",
            "expected": spec_version,
            "actual": arch_version
        })
    
    # Check backend proofs
    backend_version = proofs['backend']['map_validation'].get('specification_version')
    if backend_version != spec_version:
        errors.append({
            "type": "version_mismatch",
            "skill": "backend-prover",
            "expected": spec_version,
            "actual": backend_version
        })
    
    # Check frontend proofs
    frontend_version = proofs['frontend']['type_correspondence'].get('specification_version')
    if frontend_version != spec_version:
        errors.append({
            "type": "version_mismatch",
            "skill": "frontend-prover",
            "expected": spec_version,
            "actual": frontend_version
        })
    
    # Check infrastructure proofs
    infra_version = proofs['infrastructure']['topology'].get('specification_version')
    if infra_version != spec_version:
        errors.append({
            "type": "version_mismatch",
            "skill": "infrastructure-prover",
            "expected": spec_version,
            "actual": infra_version
        })
    
    return {
        "consistent": len(errors) == 0,
        "specification_version": spec_version,
        "specification_hash": spec_hash,
        "errors": errors
    }

Step 3: Validate Proof Chain

步骤3:验证证明链

python
def validate_proof_chain(proofs):
    """
    Verify proof chain composes correctly:
    
    Requirements → Architecture (system-architect) ✓
    Backend Maps (backend-prover Phase 1) ✓
    Backend Code (backend-prover Phase 2) ✓
    Standardization (standardization-layer) ✓
    Frontend (frontend-prover) ✓
    Infrastructure (infrastructure-prover) ✓
    """
    
    errors = []
    
    # 1. Architecture proofs valid
    if not architecture_proofs_valid(proofs['architecture']):
        errors.append({
            "type": "invalid_architecture_proof",
            "details": "Architecture proofs failed validation"
        })
    
    # 2. Backend maps validated
    if proofs['backend']['map_validation']['status'] != 'valid':
        errors.append({
            "type": "invalid_backend_maps",
            "details": "Backend maps not validated"
        })
    
    # 3. Backend code matches maps
    if not backend_code_matches_maps(proofs['backend']['implementation']):
        errors.append({
            "type": "code_map_mismatch",
            "details": "Backend code doesn't match verified maps"
        })
    
    # 4. Standardization preserves composition
    if not standardization_preserves_composition(proofs['backend']['standardization']):
        errors.append({
            "type": "standardization_broken",
            "details": "Standardization doesn't preserve composition laws"
        })
    
    # 5. Frontend types correspond to backend API
    if not proofs['frontend']['type_correspondence']['bijection']:
        errors.append({
            "type": "type_correspondence_failed",
            "details": "Frontend types don't match backend API"
        })
    
    # 6. Infrastructure topology matches architecture
    if not proofs['infrastructure']['topology']['isomorphism']:
        errors.append({
            "type": "topology_isomorphism_failed",
            "details": "Deployed topology doesn't match architecture"
        })
    
    return {
        "chain_valid": len(errors) == 0,
        "errors": errors
    }

python
def validate_proof_chain(proofs):
    """
    Verify proof chain composes correctly:
    
    Requirements → Architecture (system-architect) ✓
    Backend Maps (backend-prover Phase 1) ✓
    Backend Code (backend-prover Phase 2) ✓
    Standardization (standardization-layer) ✓
    Frontend (frontend-prover) ✓
    Infrastructure (infrastructure-prover) ✓
    """
    
    errors = []
    
    # 1. Architecture proofs valid
    if not architecture_proofs_valid(proofs['architecture']):
        errors.append({
            "type": "invalid_architecture_proof",
            "details": "Architecture proofs failed validation"
        })
    
    # 2. Backend maps validated
    if proofs['backend']['map_validation']['status'] != 'valid':
        errors.append({
            "type": "invalid_backend_maps",
            "details": "Backend maps not validated"
        })
    
    # 3. Backend code matches maps
    if not backend_code_matches_maps(proofs['backend']['implementation']):
        errors.append({
            "type": "code_map_mismatch",
            "details": "Backend code doesn't match verified maps"
        })
    
    # 4. Standardization preserves composition
    if not standardization_preserves_composition(proofs['backend']['standardization']):
        errors.append({
            "type": "standardization_broken",
            "details": "Standardization doesn't preserve composition laws"
        })
    
    # 5. Frontend types correspond to backend API
    if not proofs['frontend']['type_correspondence']['bijection']:
        errors.append({
            "type": "type_correspondence_failed",
            "details": "Frontend types don't match backend API"
        })
    
    # 6. Infrastructure topology matches architecture
    if not proofs['infrastructure']['topology']['isomorphism']:
        errors.append({
            "type": "topology_isomorphism_failed",
            "details": "Deployed topology doesn't match architecture"
        })
    
    return {
        "chain_valid": len(errors) == 0,
        "errors": errors
    }

Step 4: Check for Gaps

步骤4:检查缺口

python
def check_for_gaps(proofs, artifacts):
    """
    Check for missing proofs or incomplete verification
    """
    
    gaps = []
    
    # Check all services in architecture have backend maps
    arch_services = extract_services_from_architecture(proofs['architecture'])
    backend_maps = list_backend_maps(artifacts['maps/backend'])
    
    for service in arch_services:
        if service not in backend_maps:
            gaps.append({
                "type": "missing_backend_map",
                "service": service,
                "fix": "Run backend-prover to generate map"
            })
    
    # Check all backend maps have implementations
    for map_file in backend_maps:
        service = extract_service_name(map_file)
        if not backend_implementation_exists(service, artifacts['code/backend']):
            gaps.append({
                "type": "missing_implementation",
                "service": service,
                "fix": "Run backend-prover Phase 2"
            })
    
    # Check all backend services have deployment configs
    backend_services = list_backend_services(artifacts['code/backend'])
    for service in backend_services:
        if not deployment_config_exists(service, artifacts['configs']):
            gaps.append({
                "type": "missing_deployment_config",
                "service": service,
                "fix": "Run infrastructure-prover"
            })
    
    # Check frontend consumes all public APIs
    public_apis = extract_public_apis(proofs['architecture'])
    frontend_types = list_frontend_types(artifacts['code/frontend'])
    
    for api in public_apis:
        if not frontend_type_exists(api, frontend_types):
            gaps.append({
                "type": "missing_frontend_type",
                "api": api,
                "fix": "Run frontend-prover"
            })
    
    return {
        "complete": len(gaps) == 0,
        "gaps": gaps
    }

python
def check_for_gaps(proofs, artifacts):
    """
    Check for missing proofs or incomplete verification
    """
    
    gaps = []
    
    # Check all services in architecture have backend maps
    arch_services = extract_services_from_architecture(proofs['architecture'])
    backend_maps = list_backend_maps(artifacts['maps/backend'])
    
    for service in arch_services:
        if service not in backend_maps:
            gaps.append({
                "type": "missing_backend_map",
                "service": service,
                "fix": "Run backend-prover to generate map"
            })
    
    # Check all backend maps have implementations
    for map_file in backend_maps:
        service = extract_service_name(map_file)
        if not backend_implementation_exists(service, artifacts['code/backend']):
            gaps.append({
                "type": "missing_implementation",
                "service": service,
                "fix": "Run backend-prover Phase 2"
            })
    
    # Check all backend services have deployment configs
    backend_services = list_backend_services(artifacts['code/backend'])
    for service in backend_services:
        if not deployment_config_exists(service, artifacts['configs']):
            gaps.append({
                "type": "missing_deployment_config",
                "service": service,
                "fix": "Run infrastructure-prover"
            })
    
    # Check frontend consumes all public APIs
    public_apis = extract_public_apis(proofs['architecture'])
    frontend_types = list_frontend_types(artifacts['code/frontend'])
    
    for api in public_apis:
        if not frontend_type_exists(api, frontend_types):
            gaps.append({
                "type": "missing_frontend_type",
                "api": api,
                "fix": "Run frontend-prover"
            })
    
    return {
        "complete": len(gaps) == 0,
        "gaps": gaps
    }

Step 5: Validate Composition End-to-End

步骤5:端到端验证组合

python
def validate_end_to_end_composition(proofs):
    """
    Verify composition laws hold across entire system
    """
    
    errors = []
    
    # Architecture composition valid
    if not proofs['architecture']['composition']['valid']:
        errors.append({
            "type": "architecture_composition_invalid",
            "details": "Architecture-level composition laws violated"
        })
    
    # Maps preserve architecture composition
    if not maps_preserve_architecture(proofs['backend']['map_validation']):
        errors.append({
            "type": "maps_dont_preserve_architecture",
            "details": "Backend maps don't preserve architecture composition"
        })
    
    # Code preserves map composition
    if not code_preserves_maps(proofs['backend']['implementation']):
        errors.append({
            "type": "code_doesnt_preserve_maps",
            "details": "Backend code doesn't preserve map composition"
        })
    
    # Standardization preserves composition (naturality)
    if not proofs['backend']['standardization']['composition_preserved']:
        errors.append({
            "type": "standardization_breaks_composition",
            "details": "Middleware breaks composition laws"
        })
    
    # Frontend types compose
    if not frontend_types_compose(proofs['frontend']['type_correspondence']):
        errors.append({
            "type": "frontend_types_dont_compose",
            "details": "Frontend type definitions don't compose"
        })
    
    # Infrastructure topology correct
    if not proofs['infrastructure']['topology']['isomorphism']:
        errors.append({
            "type": "topology_incorrect",
            "details": "Infrastructure doesn't match architecture"
        })
    
    return {
        "composition_valid": len(errors) == 0,
        "errors": errors
    }

python
def validate_end_to_end_composition(proofs):
    """
    Verify composition laws hold across entire system
    """
    
    errors = []
    
    # Architecture composition valid
    if not proofs['architecture']['composition']['valid']:
        errors.append({
            "type": "architecture_composition_invalid",
            "details": "Architecture-level composition laws violated"
        })
    
    # Maps preserve architecture composition
    if not maps_preserve_architecture(proofs['backend']['map_validation']):
        errors.append({
            "type": "maps_dont_preserve_architecture",
            "details": "Backend maps don't preserve architecture composition"
        })
    
    # Code preserves map composition
    if not code_preserves_maps(proofs['backend']['implementation']):
        errors.append({
            "type": "code_doesnt_preserve_maps",
            "details": "Backend code doesn't preserve map composition"
        })
    
    # Standardization preserves composition (naturality)
    if not proofs['backend']['standardization']['composition_preserved']:
        errors.append({
            "type": "standardization_breaks_composition",
            "details": "Middleware breaks composition laws"
        })
    
    # Frontend types compose
    if not frontend_types_compose(proofs['frontend']['type_correspondence']):
        errors.append({
            "type": "frontend_types_dont_compose",
            "details": "Frontend type definitions don't compose"
        })
    
    # Infrastructure topology correct
    if not proofs['infrastructure']['topology']['isomorphism']:
        errors.append({
            "type": "topology_incorrect",
            "details": "Infrastructure doesn't match architecture"
        })
    
    return {
        "composition_valid": len(errors) == 0,
        "errors": errors
    }

Generate Composed Proof

生成组合证明

python
def generate_composed_proof(validation_results, proofs, manifest):
    """
    Generate final composed proof certificate
    
    This certificate authorizes deployment
    """
    
    all_checks_passed = (
        validation_results['version_consistency']['consistent'] and
        validation_results['proof_chain']['chain_valid'] and
        validation_results['gaps']['complete'] and
        validation_results['composition']['composition_valid']
    )
    
    certificate = {
        "status": "valid" if all_checks_passed else "invalid",
        "timestamp": datetime.utcnow().isoformat() + "Z",
        
        "specification": {
            "version": manifest['version'],
            "hash": manifest['hash']
        },
        
        "composition_chain": [
            "architecture → backend_maps",
            "backend_maps → backend_code",
            "backend_code → standardization",
            "backend_code → frontend",
            "backend_code → infrastructure"
        ],
        
        "verification_summary": {
            "version_consistency": validation_results['version_consistency']['consistent'],
            "proof_chain_valid": validation_results['proof_chain']['chain_valid'],
            "no_gaps": validation_results['gaps']['complete'],
            "composition_valid": validation_results['composition']['composition_valid']
        },
        
        "individual_proofs": {
            "architecture": {
                "adt_correct": True,
                "functors_valid": True,
                "composition_correct": True,
                "state_machines_complete": True
            },
            "backend": {
                "maps_validated": proofs['backend']['map_validation']['status'] == 'valid',
                "code_correct": True,
                "standardization_natural": proofs['backend']['standardization']['composition_preserved']
            },
            "frontend": {
                "type_correspondence": proofs['frontend']['type_correspondence']['bijection']
            },
            "infrastructure": {
                "topology_isomorphism": proofs['infrastructure']['topology']['isomorphism']
            }
        },
        
        "gaps_detected": validation_results['gaps']['gaps'],
        
        "deploy_authorized": all_checks_passed,
        
        "errors": (
            validation_results['version_consistency']['errors'] +
            validation_results['proof_chain']['errors'] +
            validation_results['composition']['errors']
        )
    }
    
    return certificate

python
def generate_composed_proof(validation_results, proofs, manifest):
    """
    Generate final composed proof certificate
    
    This certificate authorizes deployment
    """
    
    all_checks_passed = (
        validation_results['version_consistency']['consistent'] and
        validation_results['proof_chain']['chain_valid'] and
        validation_results['gaps']['complete'] and
        validation_results['composition']['composition_valid']
    )
    
    certificate = {
        "status": "valid" if all_checks_passed else "invalid",
        "timestamp": datetime.utcnow().isoformat() + "Z",
        
        "specification": {
            "version": manifest['version'],
            "hash": manifest['hash']
        },
        
        "composition_chain": [
            "architecture → backend_maps",
            "backend_maps → backend_code",
            "backend_code → standardization",
            "backend_code → frontend",
            "backend_code → infrastructure"
        ],
        
        "verification_summary": {
            "version_consistency": validation_results['version_consistency']['consistent'],
            "proof_chain_valid": validation_results['proof_chain']['chain_valid'],
            "no_gaps": validation_results['gaps']['complete'],
            "composition_valid": validation_results['composition']['composition_valid']
        },
        
        "individual_proofs": {
            "architecture": {
                "adt_correct": True,
                "functors_valid": True,
                "composition_correct": True,
                "state_machines_complete": True
            },
            "backend": {
                "maps_validated": proofs['backend']['map_validation']['status'] == 'valid',
                "code_correct": True,
                "standardization_natural": proofs['backend']['standardization']['composition_preserved']
            },
            "frontend": {
                "type_correspondence": proofs['frontend']['type_correspondence']['bijection']
            },
            "infrastructure": {
                "topology_isomorphism": proofs['infrastructure']['topology']['isomorphism']
            }
        },
        
        "gaps_detected": validation_results['gaps']['gaps'],
        
        "deploy_authorized": all_checks_passed,
        
        "errors": (
            validation_results['version_consistency']['errors'] +
            validation_results['proof_chain']['errors'] +
            validation_results['composition']['errors']
        )
    }
    
    return certificate

Output: System Proof Certificate

输出:系统证明证书

Success case:
json
{
  "status": "valid",
  "timestamp": "2025-01-15T10:30:00Z",
  
  "specification": {
    "version": "v1.2.0",
    "hash": "sha256:abc123..."
  },
  
  "composition_chain": [
    "architecture → backend_maps",
    "backend_maps → backend_code",
    "backend_code → standardization",
    "backend_code → frontend",
    "backend_code → infrastructure"
  ],
  
  "verification_summary": {
    "version_consistency": true,
    "proof_chain_valid": true,
    "no_gaps": true,
    "composition_valid": true
  },
  
  "individual_proofs": {
    "architecture": {
      "adt_correct": true,
      "functors_valid": true,
      "composition_correct": true,
      "state_machines_complete": true
    },
    "backend": {
      "maps_validated": true,
      "code_correct": true,
      "standardization_natural": true
    },
    "frontend": {
      "type_correspondence": true
    },
    "infrastructure": {
      "topology_isomorphism": true
    }
  },
  
  "gaps_detected": [],
  
  "deploy_authorized": true,
  
  "errors": []
}
Failure case:
json
{
  "status": "invalid",
  "timestamp": "2025-01-15T10:30:00Z",
  
  "verification_summary": {
    "version_consistency": false,
    "proof_chain_valid": true,
    "no_gaps": false,
    "composition_valid": true
  },
  
  "gaps_detected": [
    {
      "type": "missing_deployment_config",
      "service": "BillingService",
      "fix": "Run infrastructure-prover"
    }
  ],
  
  "deploy_authorized": false,
  
  "errors": [
    {
      "type": "version_mismatch",
      "skill": "frontend-prover",
      "expected": "v1.2.0",
      "actual": "v1.1.0"
    }
  ]
}

成功案例:
json
{
  "status": "valid",
  "timestamp": "2025-01-15T10:30:00Z",
  
  "specification": {
    "version": "v1.2.0",
    "hash": "sha256:abc123..."
  },
  
  "composition_chain": [
    "architecture → backend_maps",
    "backend_maps → backend_code",
    "backend_code → standardization",
    "backend_code → frontend",
    "backend_code → infrastructure"
  ],
  
  "verification_summary": {
    "version_consistency": true,
    "proof_chain_valid": true,
    "no_gaps": true,
    "composition_valid": true
  },
  
  "individual_proofs": {
    "architecture": {
      "adt_correct": true,
      "functors_valid": true,
      "composition_correct": true,
      "state_machines_complete": true
    },
    "backend": {
      "maps_validated": true,
      "code_correct": true,
      "standardization_natural": true
    },
    "frontend": {
      "type_correspondence": true
    },
    "infrastructure": {
      "topology_isomorphism": true
    }
  },
  
  "gaps_detected": [],
  
  "deploy_authorized": true,
  
  "errors": []
}
失败案例:
json
{
  "status": "invalid",
  "timestamp": "2025-01-15T10:30:00Z",
  
  "verification_summary": {
    "version_consistency": false,
    "proof_chain_valid": true,
    "no_gaps": false,
    "composition_valid": true
  },
  
  "gaps_detected": [
    {
      "type": "missing_deployment_config",
      "service": "BillingService",
      "fix": "Run infrastructure-prover"
    }
  ],
  
  "deploy_authorized": false,
  
  "errors": [
    {
      "type": "version_mismatch",
      "skill": "frontend-prover",
      "expected": "v1.2.0",
      "actual": "v1.1.0"
    }
  ]
}

Output Location

输出位置

artifacts/engineering/proofs/composed/
├── system-proof.certificate
├── composition-graph.dot
└── verification-report.md

artifacts/engineering/proofs/composed/
├── system-proof.certificate
├── composition-graph.dot
└── verification-report.md

Integration with Build Pipeline

与构建流水线集成

Build pipeline final gate:
bash
undefined
构建流水线最终闸门:
bash
undefined

build-pipeline/13-compose-proofs.sh ⭐ DEPLOYMENT GATE

build-pipeline/13-compose-proofs.sh ⭐ DEPLOYMENT GATE

echo "Validating system-wide proof chain..."
echo "Validating system-wide proof chain..."

Run proof-composer

Run proof-composer

proof-composer validate-all
proof-composer validate-all

Check certificate

Check certificate

status=$(jq -r '.status' artifacts/engineering/proofs/composed/system-proof.certificate) deploy_authorized=$(jq -r '.deploy_authorized' artifacts/engineering/proofs/composed/system-proof.certificate)
if [ "$status" != "valid" ] || [ "$deploy_authorized" != "true" ]; then echo "❌ DEPLOYMENT BLOCKED: Proof chain invalid" echo "" echo "Errors:" jq '.errors' artifacts/engineering/proofs/composed/system-proof.certificate echo "" echo "Gaps:" jq '.gaps_detected' artifacts/engineering/proofs/composed/system-proof.certificate exit 1 fi
echo "✅ Proof chain valid - deployment authorized"
status=$(jq -r '.status' artifacts/engineering/proofs/composed/system-proof.certificate) deploy_authorized=$(jq -r '.deploy_authorized' artifacts/engineering/proofs/composed/system-proof.certificate)
if [ "$status" != "valid" ] || [ "$deploy_authorized" != "true" ]; then echo "❌ DEPLOYMENT BLOCKED: Proof chain invalid" echo "" echo "Errors:" jq '.errors' artifacts/engineering/proofs/composed/system-proof.certificate echo "" echo "Gaps:" jq '.gaps_detected' artifacts/engineering/proofs/composed/system-proof.certificate exit 1 fi
echo "✅ Proof chain valid - deployment authorized"

build-pipeline/14-deploy.sh can now proceed

build-pipeline/14-deploy.sh can now proceed


---

---

Success Criteria

成功标准

✓ All proofs collected ✓ Version consistency verified ✓ Proof chain validated ✓ No gaps detected ✓ Composition laws hold end-to-end ✓ System proof certificate generated ✓ Deployment authorized ✓

✓ 所有证明已收集 ✓ 版本一致性已验证 ✓ 证明链已验证 ✓ 未检测到缺口 ✓ 组合定律端到端成立 ✓ 已生成系统证明证书 ✓ 部署已授权 ✓

Error Handling

错误处理

Version mismatch:
ERROR: Version inconsistency detected
Frontend-prover used v1.1.0, but current spec is v1.2.0
Action: Re-run frontend-prover with correct version
Broken proof chain:
ERROR: Proof chain broken
Backend maps not validated (map-validation/validation-report.json status != 'valid')
Action: Re-run backend-prover Phase 1 (map validation)
Gap detected:
ERROR: Missing deployment config
Service: BillingService
Has backend implementation but no deployment config
Action: Run infrastructure-prover
Composition broken:
ERROR: Composition doesn't hold end-to-end
Standardization broke composition laws (naturality failed)
Action: Re-run standardization-layer with correct naturality proof

版本不匹配:
ERROR: Version inconsistency detected
Frontend-prover used v1.1.0, but current spec is v1.2.0
Action: Re-run frontend-prover with correct version
证明链断裂:
ERROR: Proof chain broken
Backend maps not validated (map-validation/validation-report.json status != 'valid')
Action: Re-run backend-prover Phase 1 (map validation)
检测到缺口:
ERROR: Missing deployment config
Service: BillingService
Has backend implementation but no deployment config
Action: Run infrastructure-prover
组合失效:
ERROR: Composition doesn't hold end-to-end
Standardization broke composition laws (naturality failed)
Action: Re-run standardization-layer with correct naturality proof

Critical Reminders

重要提醒

  1. This is the final gate - Nothing deploys without valid certificate
  2. Version consistency mandatory - All skills must use same spec version
  3. No gaps allowed - Every service needs full proof chain
  4. Composition must hold - Laws verified at every layer
  5. Certificate authorizes deployment - Build pipeline checks this

  1. 这是最终闸门 - 没有有效证书,任何内容都无法部署
  2. 版本一致性是强制要求 - 所有技能必须使用相同的规格版本
  3. 不允许存在缺口 - 每个服务都需要完整的证明链
  4. 组合必须成立 - 每一层都要验证定律
  5. 证书授权部署 - 构建流水线会检查这一点

When You (proof-composer) Finish

当你(proof-composer)完成后

  1. Log results in thread:
    threads/engineering/{requirement}/5-actions/action-5-proof-composition.md
    
    Status: Complete
    Proof status: valid
    Deploy authorized: true
    Certificate: artifacts/engineering/proofs/composed/system-proof.certificate
    Specification: v1.2.0 (hash: abc123...)
    All proofs verified: ✓
    No gaps detected: ✓
    Composition valid: ✓
  2. Update engineering thread Stage 5:
    • Action 5 complete ✓
    • ALL engineering actions complete ✓
    • Ready for Stage 6 (Learning)
  3. Engineering thread → Business thread:
    • Report technical success
    • Provide deployment certificate
    • Document any learnings

  1. 在线程中记录结果:
    threads/engineering/{requirement}/5-actions/action-5-proof-composition.md
    
    Status: Complete
    Proof status: valid
    Deploy authorized: true
    Certificate: artifacts/engineering/proofs/composed/system-proof.certificate
    Specification: v1.2.0 (hash: abc123...)
    All proofs verified: ✓
    No gaps detected: ✓
    Composition valid: ✓
  2. 更新工程线程第5阶段:
    • 操作5已完成 ✓
    • 所有工程操作已完成 ✓
    • 准备进入第6阶段(学习)
  3. 工程线程 → 业务线程:
    • 报告技术成功
    • 提供部署证书
    • 记录所有经验教训

Proof Composition Visualization

证明组合可视化

System-Architect
  [Architecture Proofs: ADT, Functors, Composition, State Machines] ✓
Backend-Prover Phase 1
  [Backend Maps Validated: Composition laws verified] ✓
Backend-Prover Phase 2
  [Backend Code Matches Maps: Generated from verified maps] ✓
Standardization-Layer
  [Naturality Proven: Middleware preserves composition] ✓
Frontend-Prover
  [Type Correspondence: Frontend ≅ Backend API] ✓
Infrastructure-Prover
  [Topology Isomorphism: Deployed ≅ Architecture] ✓
Proof-Composer (YOU)
  [System Proof: All proofs compose ✓]
DEPLOYMENT AUTHORIZED ✅

You are the final gatekeeper. Verify the entire proof chain. Authorize deployment only when mathematically verified.
System-Architect
  [Architecture Proofs: ADT, Functors, Composition, State Machines] ✓
Backend-Prover Phase 1
  [Backend Maps Validated: Composition laws verified] ✓
Backend-Prover Phase 2
  [Backend Code Matches Maps: Generated from verified maps] ✓
Standardization-Layer
  [Naturality Proven: Middleware preserves composition] ✓
Frontend-Prover
  [Type Correspondence: Frontend ≅ Backend API] ✓
Infrastructure-Prover
  [Topology Isomorphism: Deployed ≅ Architecture] ✓
Proof-Composer (YOU)
  [System Proof: All proofs compose ✓]
DEPLOYMENT AUTHORIZED ✅

你是最终的守门人。验证完整的证明链。只有在通过数学验证后,才能授权部署。