Development of an AI system for analyzing assembly failures
AI-based CI/CD failure analysis automatically identifies the cause of failed builds, identifies similar historical failures, and generates fix recommendations. Reduces diagnostic time from 15–30 minutes to 2–3 minutes.
Parsing and error classification
class BuildFailureAnalyzer:
def analyze(self, build_log: str, build_metadata: BuildMetadata) -> FailureAnalysis:
# Извлечение error секций из лога
error_sections = self.extract_error_sections(build_log)
# Классификация типа ошибки
failure_type = self.classify_failure(error_sections, build_log)
# Поиск похожих исторических сбоев
similar_failures = self.search_similar(error_sections, failure_type)
# Генерация рекомендаций
fix_suggestions = self.generate_fix(
failure_type, error_sections, similar_failures, build_metadata
)
return FailureAnalysis(
failure_type=failure_type,
error_summary=self.summarize_errors(error_sections),
root_cause=fix_suggestions.root_cause,
suggested_fixes=fix_suggestions.fixes,
similar_cases=similar_failures[:3],
confidence=fix_suggestions.confidence
)
def classify_failure(self, errors: list[str], full_log: str) -> str:
patterns = {
"test_failure": r"FAILED|AssertionError|pytest.*failed",
"compilation_error": r"error:.*cannot find symbol|SyntaxError|TypeError",
"dependency_error": r"ModuleNotFoundError|Could not resolve dependency",
"docker_build_error": r"COPY failed|RUN.*returned a non-zero code",
"oom_error": r"Out of memory|Killed.*OOM|Cannot allocate memory",
"network_error": r"Connection refused|timeout|ECONNREFUSED",
}
for failure_type, pattern in patterns.items():
if re.search(pattern, full_log, re.IGNORECASE):
return failure_type
return "unknown"
LLM analysis for unknown errors
def generate_fix(self, failure_type: str, errors: list[str],
similar: list[HistoricalFailure], metadata: BuildMetadata) -> FixSuggestions:
similar_context = "\n".join([
f"Похожий случай: {f.root_cause} → исправлено: {f.fix}"
for f in similar[:3]
])
prompt = f"""Проанализируй сбой CI/CD и предложи исправление.
Тип сбоя: {failure_type}
Ошибки:
{chr(10).join(errors[:5])}
Контекст:
- Branch: {metadata.branch}
- Последний коммит: {metadata.last_commit_message}
- Изменённые файлы: {', '.join(metadata.changed_files[:10])}
Похожие исторические случаи:
{similar_context}
Определи: корневую причину, конкретные шаги для исправления, профилактические меры."""
return llm.parse(prompt, response_format=FixSuggestions)
Integration with GitHub/GitLab
def post_build_analysis_comment(repo: str, pr_number: int, analysis: FailureAnalysis):
"""Публикует анализ прямо в PR-комментарий."""
comment = f"""## CI/CD Build Failure Analysis
**Тип сбоя:** {analysis.failure_type}
**Вероятная причина:** {analysis.root_cause}
### Рекомендуемые исправления:
{chr(10).join(f'- {fix}' for fix in analysis.suggested_fixes)}
**Уверенность:** {analysis.confidence:.0%}
"""
github_client.create_comment(repo, pr_number, comment)
Historical Failures Knowledge Base
Each resolved failure is saved with tags: type, root cause, and fix method. Semantic search of the database allows finding relevant precedents for new failures. Over six months of operation, the database accumulates hundreds of precedents, increasing the accuracy of recommendations.







