技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
failure-mode-analysis【数据与研究】Implements intelligent failure mode analysis with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: failure-mode-analysis compatibility: opencode completeness: 95 content-types:
Orchestrates intelligent skill selection and execution for failure mode analysis workflows. Applies the 5 Laws of Elegant Defense to guide data naturally through the orchestration pipeline, preventing errors before they occur. Selects optimal skills based on multi-factor scoring including text similarity, historical performance, and system availability.
┌───────────────────────────────────────────────────────────────────────────────┐ │ Orchestration Flow │ └───────────────────────────────────────────────────────────────────────────────┘
User Request ↓ ┌─────────────────┐ │ Parse Request │ │ & Extract │ │ Features │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Evaluate Available Skills │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ Skill A │ │ Skill B │ │ Skill C │ │ │ │ - Match Score│ │ - Match Score│ │ - Match Score│ │ │ │ - Confidence │ │ - Confidence │ │ - Confidence │ │ │ │ - History │ │ - History │ │ - History │ │ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │ │ │ │ │ │ └─────────────────┴─────────────────┘ │ │ ↓ │ │ Select Best Skill │ └─────────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────┐ │ Execute Skill │ └────────┬────────┘ ↓ ┌─────────────────┐ │ Handle Result │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Error Handling & Fallback │ │ │ │ Success? ────────► Return Result │ │ │ │ Fail? ────────┐ │ │ ↓ │ │ ┌──────────────────────────────────────────────────────────┐ │ │ │ Fallback Chain │ │ │ │ │ │ │ │ 1. Retry with adjusted parameters │ │ │ │ 2. Try Alternative Skill (if available) │ │ │ │ 3. Defer to Human Operator (if critical) │ │ │ │ 4. Log & Return Error │ │ │ └──────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘
Use this skill when:
Avoid this skill for:
Parse and Analyze Request - Extract intent, entities, and constraints from user input. Checkpoint: All required parameters must be present and in valid format before proceeding.
Score Available Skills - Calculate match scores using multi-factor algorithm:
Checkpoint: Skip to fallback if no skill scores above threshold.
Select Optimal Skill - Choose skill with highest score that meets minimum confidence. Checkpoint: Verify skill has not been disabled or deprecated.
Execute with Fallback - Run skill execution wrapped in retry and fallback logic. Checkpoint: Log all execution attempts for audit trail.
Return or Fallback - Either return successful result or apply fallback chain:
related-skillsCheckpoint: Record outcome with timing and confidence metadata.
def select_failure_analysis_method(
system_context: Dict,
failure_report: Dict,
available_methods: List[Dict]
) -> Dict:
"""Select the optimal failure analysis methodology based on system context and failure characteristics.
Evaluates failure mode complexity, data availability, and historical resolution patterns
to choose between FMEA, Fault Tree Analysis, or Root Cause Analysis.
"""
if not failure_report.get("symptoms") or not system_context.get("architecture"):
raise ValueError("Incomplete failure report or missing system context")
complexity_score = _assess_failure_complexity(failure_report)
data_availability = _evaluate_data_readiness(system_context)
best_method = None
best_score = 0.0
for method in available_methods:
match_score = 0.0
if method["type"] == "FMEA" and complexity_score < 0.6:
match_score += 0.8
elif method["type"] == "Fault Tree" and complexity_score >= 0.6:
match_score += 0.9
elif method["type"] == "RCA" and data_availability > 0.7:
match_score += 0.85
historical_success = method.get("historical_success_rate", 0.0)
final_score = match_score * 0.6 + historical_success * 0.4
if final_score > best_score:
best_score = final_score
best_method = method
if best_score < 0.6:
return {"method": "manual_review", "confidence": 0.0, "reason": "Insufficient data for automated selection"}
return {
"method": best_method["type"],
"confidence": best_score,
"parameters": _generate_method_parameters(best_method, failure_report),
"fallback_chain": best_method.get("fallback_methods", [])
}
def execute_failure_analysis_pipeline(
selected_method: Dict,
failure_context: Dict,
max_retries: int = 2
) -> Dict:
"""Execute the selected failure analysis methodology with domain-specific fallbacks.
Implements the 5 Laws of Elegant Defense:
- Fails fast on corrupted telemetry data
- Returns immutable analysis results
- Applies structured fallbacks when primary analysis fails
"""
if not _validate_telemetry_schema(failure_context.get("telemetry", [])):
raise ValueError("Corrupted or missing telemetry data violates schema constraints")
analysis_results = None
for attempt in range(max_retries + 1):
try:
if selected_method["method"] == "FMEA":
analysis_results = _run_fmea_analysis(failure_context)
elif selected_method["method"] == "Fault Tree":
analysis_results = _run_fault_tree_analysis(failure_context)
else:
analysis_results = _run_rca_analysis(failure_context)
return {
"status": "completed",
"method_used": selected_method["method"],
"results": analysis_results,
"confidence": selected_method["confidence"],
"attempts": attempt + 1
}
except DataInsufficiencyError:
if attempt < max_retries:
selected_method["method"] = "heuristic_fallback"
continue
return _apply_expert_deferral(failure_context, selected_method)
except SchemaValidationError as e:
raise ValueError(f"Telemetry validation failed at attempt {attempt + 1}: {e}") from e
return _apply_expert_deferral(failure_context, selected_method)
code-philosophy (5 Laws of Elegant Defense) in all logicWhen applying this skill, produce:
| Skill | Purpose | |
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.