moai-adk 0.25.4__py3-none-any.whl → 0.41.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of moai-adk might be problematic. Click here for more details.
- moai_adk/__init__.py +2 -5
- moai_adk/__main__.py +114 -82
- moai_adk/cli/__init__.py +6 -1
- moai_adk/cli/commands/__init__.py +1 -3
- moai_adk/cli/commands/analyze.py +5 -16
- moai_adk/cli/commands/doctor.py +6 -18
- moai_adk/cli/commands/init.py +60 -126
- moai_adk/cli/commands/language.py +14 -35
- moai_adk/cli/commands/status.py +9 -15
- moai_adk/cli/commands/update.py +1560 -190
- moai_adk/cli/prompts/init_prompts.py +112 -56
- moai_adk/cli/spec_status.py +263 -0
- moai_adk/cli/ui/__init__.py +44 -0
- moai_adk/cli/ui/progress.py +422 -0
- moai_adk/cli/ui/prompts.py +389 -0
- moai_adk/cli/ui/theme.py +129 -0
- moai_adk/cli/worktree/__init__.py +27 -0
- moai_adk/cli/worktree/__main__.py +31 -0
- moai_adk/cli/worktree/cli.py +683 -0
- moai_adk/cli/worktree/exceptions.py +89 -0
- moai_adk/cli/worktree/manager.py +493 -0
- moai_adk/cli/worktree/models.py +65 -0
- moai_adk/cli/worktree/registry.py +422 -0
- moai_adk/core/PHASE2_OPTIMIZATIONS.md +467 -0
- moai_adk/core/analysis/session_analyzer.py +17 -56
- moai_adk/core/claude_integration.py +26 -54
- moai_adk/core/command_helpers.py +10 -10
- moai_adk/core/comprehensive_monitoring_system.py +1183 -0
- moai_adk/core/config/migration.py +19 -9
- moai_adk/core/config/unified.py +610 -0
- moai_adk/core/context_manager.py +6 -12
- moai_adk/core/enterprise_features.py +1404 -0
- moai_adk/core/error_recovery_system.py +747 -116
- moai_adk/core/event_driven_hook_system.py +1371 -0
- moai_adk/core/git/__init__.py +8 -0
- moai_adk/core/git/branch_manager.py +3 -11
- moai_adk/core/git/checkpoint.py +1 -3
- moai_adk/core/git/conflict_detector.py +422 -0
- moai_adk/core/git/event_detector.py +16 -5
- moai_adk/core/git/manager.py +91 -1
- moai_adk/core/input_validation_middleware.py +1006 -0
- moai_adk/core/integration/engine.py +6 -18
- moai_adk/core/integration/integration_tester.py +10 -9
- moai_adk/core/integration/utils.py +1 -1
- moai_adk/core/issue_creator.py +10 -28
- moai_adk/core/jit_context_loader.py +956 -0
- moai_adk/core/jit_enhanced_hook_manager.py +1987 -0
- moai_adk/core/language_config_resolver.py +578 -0
- moai_adk/core/language_validator.py +28 -41
- moai_adk/core/mcp/setup.py +15 -12
- moai_adk/core/merge/__init__.py +9 -0
- moai_adk/core/merge/analyzer.py +666 -0
- moai_adk/core/migration/alfred_to_moai_migrator.py +389 -0
- moai_adk/core/migration/backup_manager.py +131 -12
- moai_adk/core/migration/custom_element_scanner.py +358 -0
- moai_adk/core/migration/file_migrator.py +181 -18
- moai_adk/core/migration/interactive_checkbox_ui.py +499 -0
- moai_adk/core/migration/selective_restorer.py +470 -0
- moai_adk/core/migration/template_utils.py +74 -0
- moai_adk/core/migration/user_selection_ui.py +338 -0
- moai_adk/core/migration/version_detector.py +127 -27
- moai_adk/core/migration/version_migrator.py +47 -12
- moai_adk/core/performance/cache_system.py +8 -10
- moai_adk/core/phase_optimized_hook_scheduler.py +879 -0
- moai_adk/core/project/backup_utils.py +9 -1
- moai_adk/core/project/checker.py +2 -4
- moai_adk/core/project/detector.py +1 -3
- moai_adk/core/project/initializer.py +142 -93
- moai_adk/core/project/phase_executor.py +130 -111
- moai_adk/core/project/validator.py +6 -12
- moai_adk/core/quality/trust_checker.py +39 -37
- moai_adk/core/realtime_monitoring_dashboard.py +1724 -0
- moai_adk/core/robust_json_parser.py +611 -0
- moai_adk/core/rollback_manager.py +116 -164
- moai_adk/core/session_manager.py +10 -26
- moai_adk/core/skill_loading_system.py +579 -0
- moai_adk/core/spec_status_manager.py +64 -74
- moai_adk/core/template/backup.py +48 -22
- moai_adk/core/template/config.py +142 -45
- moai_adk/core/template/merger.py +45 -27
- moai_adk/core/template/processor.py +391 -152
- moai_adk/core/template_engine.py +83 -41
- moai_adk/core/template_variable_synchronizer.py +431 -0
- moai_adk/core/unified_permission_manager.py +745 -0
- moai_adk/core/user_behavior_analytics.py +851 -0
- moai_adk/core/version_sync.py +477 -0
- moai_adk/foundation/__init__.py +56 -0
- moai_adk/foundation/backend.py +1027 -0
- moai_adk/foundation/database.py +1115 -0
- moai_adk/foundation/devops.py +1585 -0
- moai_adk/foundation/ears.py +431 -0
- moai_adk/foundation/frontend.py +870 -0
- moai_adk/foundation/git/commit_templates.py +4 -12
- moai_adk/foundation/git.py +376 -0
- moai_adk/foundation/langs.py +484 -0
- moai_adk/foundation/ml_ops.py +1162 -0
- moai_adk/foundation/testing.py +1524 -0
- moai_adk/foundation/trust/trust_principles.py +23 -72
- moai_adk/foundation/trust/validation_checklist.py +57 -162
- moai_adk/project/__init__.py +0 -0
- moai_adk/project/configuration.py +1084 -0
- moai_adk/project/documentation.py +566 -0
- moai_adk/project/schema.py +447 -0
- moai_adk/statusline/alfred_detector.py +1 -3
- moai_adk/statusline/config.py +18 -6
- moai_adk/statusline/enhanced_output_style_detector.py +23 -15
- moai_adk/statusline/main.py +109 -15
- moai_adk/statusline/renderer.py +85 -69
- moai_adk/statusline/update_checker.py +3 -9
- moai_adk/statusline/version_reader.py +140 -46
- moai_adk/templates/.claude/agents/moai/ai-nano-banana.md +716 -0
- moai_adk/templates/.claude/agents/moai/builder-agent.md +480 -0
- moai_adk/templates/.claude/agents/moai/builder-command.md +1194 -0
- moai_adk/templates/.claude/agents/moai/builder-plugin.md +753 -0
- moai_adk/templates/.claude/agents/moai/builder-skill.md +672 -0
- moai_adk/templates/.claude/agents/moai/expert-backend.md +903 -0
- moai_adk/templates/.claude/agents/moai/expert-database.md +782 -0
- moai_adk/templates/.claude/agents/moai/expert-debug.md +407 -0
- moai_adk/templates/.claude/agents/moai/expert-devops.md +722 -0
- moai_adk/templates/.claude/agents/moai/expert-frontend.md +727 -0
- moai_adk/templates/.claude/agents/moai/expert-performance.md +661 -0
- moai_adk/templates/.claude/agents/moai/expert-refactoring.md +218 -0
- moai_adk/templates/.claude/agents/moai/expert-security.md +525 -0
- moai_adk/templates/.claude/agents/moai/expert-testing.md +737 -0
- moai_adk/templates/.claude/agents/moai/expert-uiux.md +1047 -0
- moai_adk/templates/.claude/agents/moai/manager-claude-code.md +438 -0
- moai_adk/templates/.claude/agents/moai/manager-docs.md +578 -0
- moai_adk/templates/.claude/agents/moai/manager-git.md +1092 -0
- moai_adk/templates/.claude/agents/moai/manager-project.md +897 -0
- moai_adk/templates/.claude/agents/moai/manager-quality.md +640 -0
- moai_adk/templates/.claude/agents/moai/manager-spec.md +815 -0
- moai_adk/templates/.claude/agents/moai/manager-strategy.md +786 -0
- moai_adk/templates/.claude/agents/moai/manager-tdd.md +797 -0
- moai_adk/templates/.claude/agents/moai/mcp-context7.md +464 -0
- moai_adk/templates/.claude/agents/moai/mcp-figma.md +1588 -0
- moai_adk/templates/.claude/agents/moai/mcp-notion.md +795 -0
- moai_adk/templates/.claude/agents/moai/mcp-playwright.md +475 -0
- moai_adk/templates/.claude/agents/moai/mcp-sequential-thinking.md +1038 -0
- moai_adk/templates/.claude/commands/moai/0-project.md +1339 -0
- moai_adk/templates/.claude/commands/moai/1-plan.md +1367 -0
- moai_adk/templates/.claude/commands/moai/2-run.md +825 -0
- moai_adk/templates/.claude/commands/moai/3-sync.md +1358 -0
- moai_adk/templates/.claude/commands/moai/9-feedback.md +320 -0
- moai_adk/templates/.claude/hooks/__init__.py +8 -0
- moai_adk/templates/.claude/hooks/moai/__init__.py +8 -0
- moai_adk/templates/.claude/hooks/moai/lib/README.md +143 -0
- moai_adk/templates/.claude/hooks/moai/lib/__init__.py +104 -0
- moai_adk/templates/.claude/hooks/moai/lib/checkpoint.py +247 -0
- moai_adk/templates/.claude/hooks/moai/lib/common.py +161 -0
- moai_adk/templates/.claude/hooks/moai/lib/config_manager.py +444 -0
- moai_adk/templates/.claude/hooks/moai/lib/config_validator.py +639 -0
- moai_adk/templates/.claude/hooks/moai/lib/example_config.json +104 -0
- moai_adk/templates/.claude/hooks/moai/lib/exceptions.py +171 -0
- moai_adk/templates/.claude/hooks/moai/lib/git_operations_manager.py +590 -0
- moai_adk/templates/.claude/hooks/moai/lib/language_validator.py +407 -0
- moai_adk/templates/.claude/hooks/moai/lib/models.py +104 -0
- moai_adk/templates/.claude/hooks/moai/lib/path_utils.py +219 -0
- moai_adk/templates/.claude/hooks/moai/lib/project.py +777 -0
- moai_adk/templates/.claude/hooks/moai/lib/test_hooks_improvements.py +443 -0
- moai_adk/templates/.claude/hooks/moai/lib/timeout.py +160 -0
- moai_adk/templates/.claude/hooks/moai/lib/tool_registry.py +804 -0
- moai_adk/templates/.claude/hooks/moai/lib/unified_timeout_manager.py +542 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__ast_grep_scan.py +256 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__code_formatter.py +253 -0
- moai_adk/templates/.claude/hooks/moai/post_tool__linter.py +307 -0
- moai_adk/templates/.claude/hooks/moai/pre_tool__security_guard.py +231 -0
- moai_adk/templates/.claude/hooks/moai/session_end__auto_cleanup.py +866 -0
- moai_adk/templates/.claude/hooks/moai/session_start__show_project_info.py +1125 -0
- moai_adk/templates/.claude/output-styles/moai/r2d2.md +643 -0
- moai_adk/templates/.claude/output-styles/moai/yoda.md +359 -0
- moai_adk/templates/.claude/settings.json +209 -0
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/SKILL.md +302 -0
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/examples.md +431 -0
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/reference.md +139 -0
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/scripts/batch_generate.py +560 -0
- moai_adk/templates/.claude/skills/moai-ai-nano-banana/scripts/generate_image.py +362 -0
- moai_adk/templates/.claude/skills/moai-docs-generation/SKILL.md +302 -0
- moai_adk/templates/.claude/skills/moai-docs-generation/examples.md +252 -0
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/README.md +56 -0
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/api-documentation.md +120 -0
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/code-documentation.md +152 -0
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/multi-format-output.md +185 -0
- moai_adk/templates/.claude/skills/moai-docs-generation/modules/user-guides.md +207 -0
- moai_adk/templates/.claude/skills/moai-docs-generation/reference.md +234 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +324 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +718 -0
- moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +464 -0
- moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +326 -0
- moai_adk/templates/.claude/skills/moai-domain-database/examples.md +830 -0
- moai_adk/templates/.claude/skills/moai-domain-database/modules/README.md +53 -0
- moai_adk/templates/.claude/skills/moai-domain-database/modules/mongodb.md +231 -0
- moai_adk/templates/.claude/skills/moai-domain-database/modules/postgresql.md +169 -0
- moai_adk/templates/.claude/skills/moai-domain-database/modules/redis.md +262 -0
- moai_adk/templates/.claude/skills/moai-domain-database/reference.md +545 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +194 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +968 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/component-architecture.md +723 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/nextjs16-patterns.md +713 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/performance-optimization.md +694 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/react19-patterns.md +591 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/state-management.md +680 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/modules/vue35-patterns.md +802 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +664 -0
- moai_adk/templates/.claude/skills/moai-domain-uiux/SKILL.md +454 -0
- moai_adk/templates/.claude/skills/moai-domain-uiux/examples.md +560 -0
- moai_adk/templates/.claude/skills/moai-domain-uiux/modules/accessibility-wcag.md +260 -0
- moai_adk/templates/.claude/skills/moai-domain-uiux/modules/component-architecture.md +228 -0
- moai_adk/templates/.claude/skills/moai-domain-uiux/modules/icon-libraries.md +401 -0
- moai_adk/templates/.claude/skills/moai-domain-uiux/modules/theming-system.md +373 -0
- moai_adk/templates/.claude/skills/moai-domain-uiux/reference.md +243 -0
- moai_adk/templates/.claude/skills/moai-formats-data/SKILL.md +280 -0
- moai_adk/templates/.claude/skills/moai-formats-data/examples.md +804 -0
- moai_adk/templates/.claude/skills/moai-formats-data/modules/README.md +327 -0
- moai_adk/templates/.claude/skills/moai-formats-data/modules/SKILL-MODULARIZATION-TEMPLATE.md +278 -0
- moai_adk/templates/.claude/skills/moai-formats-data/modules/caching-performance.md +459 -0
- moai_adk/templates/.claude/skills/moai-formats-data/modules/data-validation.md +485 -0
- moai_adk/templates/.claude/skills/moai-formats-data/modules/json-optimization.md +374 -0
- moai_adk/templates/.claude/skills/moai-formats-data/modules/toon-encoding.md +308 -0
- moai_adk/templates/.claude/skills/moai-formats-data/reference.md +585 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/SKILL.md +243 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/examples.md +732 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/advanced-agent-patterns.md +370 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/best-practices-checklist.md +616 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-cli-reference-official.md +420 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-custom-slash-commands-official.md +729 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-devcontainers-official.md +381 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-discover-plugins-official.md +379 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-headless-official.md +378 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-hooks-official.md +670 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-iam-official.md +635 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-memory-official.md +543 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-plugin-marketplaces-official.md +308 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-plugins-official.md +432 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-sandboxing-official.md +282 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-settings-official.md +663 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-skills-official.md +467 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-statusline-official.md +293 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/claude-code-sub-agents-official.md +420 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/complete-configuration-guide.md +175 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/skill-examples.md +1674 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/skill-formatting-guide.md +729 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/sub-agents/sub-agent-examples.md +1513 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/sub-agents/sub-agent-formatting-guide.md +1086 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference/sub-agents/sub-agent-integration-patterns.md +1100 -0
- moai_adk/templates/.claude/skills/moai-foundation-claude/reference.md +209 -0
- moai_adk/templates/.claude/skills/moai-foundation-context/SKILL.md +449 -0
- moai_adk/templates/.claude/skills/moai-foundation-context/examples.md +1048 -0
- moai_adk/templates/.claude/skills/moai-foundation-context/reference.md +246 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/SKILL.md +414 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/examples.md +358 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/README.md +296 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/agents-reference.md +359 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/commands-reference.md +432 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-advanced.md +279 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-implementation.md +267 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/delegation-patterns.md +228 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/execution-rules.md +687 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/modular-system.md +665 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/patterns.md +22 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/progressive-disclosure.md +649 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-ears-format.md +200 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-first-tdd.md +171 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/spec-tdd-implementation.md +275 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/token-optimization.md +708 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-framework.md +239 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-implementation.md +244 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/modules/trust-5-validation.md +219 -0
- moai_adk/templates/.claude/skills/moai-foundation-core/reference.md +478 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/SKILL.md +311 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/examples.md +228 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/modules/assumption-matrix.md +80 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/modules/cognitive-bias.md +199 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/modules/first-principles.md +140 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/modules/trade-off-analysis.md +154 -0
- moai_adk/templates/.claude/skills/moai-foundation-philosopher/reference.md +157 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/SKILL.md +363 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/examples.md +1232 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/modules/best-practices.md +261 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/modules/integration-patterns.md +194 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/modules/proactive-analysis.md +229 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/modules/trust5-validation.md +169 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/reference.md +1266 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/scripts/quality-gate.sh +668 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/templates/github-actions-quality.yml +481 -0
- moai_adk/templates/.claude/skills/moai-foundation-quality/templates/quality-config.yaml +519 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +430 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/modules/advanced-patterns.md +401 -0
- moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +193 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +585 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/aspnet-core.md +627 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/blazor-components.md +767 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/cqrs-validation.md +626 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/csharp12-features.md +580 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/modules/efcore-patterns.md +622 -0
- moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +403 -0
- moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +394 -0
- moai_adk/templates/.claude/skills/moai-lang-elixir/examples.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-elixir/modules/advanced-patterns.md +531 -0
- moai_adk/templates/.claude/skills/moai-lang-elixir/reference.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-flutter/SKILL.md +472 -0
- moai_adk/templates/.claude/skills/moai-lang-flutter/examples.md +1090 -0
- moai_adk/templates/.claude/skills/moai-lang-flutter/reference.md +686 -0
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +377 -0
- moai_adk/templates/.claude/skills/moai-lang-go/examples.md +919 -0
- moai_adk/templates/.claude/skills/moai-lang-go/reference.md +737 -0
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +386 -0
- moai_adk/templates/.claude/skills/moai-lang-java/examples.md +864 -0
- moai_adk/templates/.claude/skills/moai-lang-java/reference.md +291 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +418 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +973 -0
- moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +1543 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +383 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +1006 -0
- moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +562 -0
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +504 -0
- moai_adk/templates/.claude/skills/moai-lang-php/examples.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-php/modules/advanced-patterns.md +538 -0
- moai_adk/templates/.claude/skills/moai-lang-php/reference.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +489 -0
- moai_adk/templates/.claude/skills/moai-lang-python/examples.md +977 -0
- moai_adk/templates/.claude/skills/moai-lang-python/reference.md +804 -0
- moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +389 -0
- moai_adk/templates/.claude/skills/moai-lang-r/examples.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-r/modules/advanced-patterns.md +489 -0
- moai_adk/templates/.claude/skills/moai-lang-r/reference.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +432 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/modules/advanced-patterns.md +309 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/modules/testing-patterns.md +306 -0
- moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +17 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +377 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +659 -0
- moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +504 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +211 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +633 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/akka-actors.md +479 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/cats-effect.md +489 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/functional-programming.md +460 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/spark-data.md +498 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/modules/zio-patterns.md +541 -0
- moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +423 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +191 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +918 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/modules/combine-reactive.md +256 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/modules/concurrency.md +270 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/modules/swift6-features.md +265 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/modules/swiftui-patterns.md +314 -0
- moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +672 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +364 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +1089 -0
- moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +731 -0
- moai_adk/templates/.claude/skills/moai-library-mermaid/SKILL.md +164 -0
- moai_adk/templates/.claude/skills/moai-library-mermaid/examples.md +270 -0
- moai_adk/templates/.claude/skills/moai-library-mermaid/modules/advanced-patterns.md +465 -0
- moai_adk/templates/.claude/skills/moai-library-mermaid/modules/optimization.md +440 -0
- moai_adk/templates/.claude/skills/moai-library-mermaid/reference.md +228 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/SKILL.md +335 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/examples.md +592 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/advanced-deployment-patterns.md +182 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/advanced-patterns.md +336 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/configuration.md +350 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/content-architecture-optimization.md +162 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/deployment.md +52 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/framework-core-configuration.md +186 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/i18n-setup.md +55 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/mdx-components.md +52 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/modules/optimization.md +303 -0
- moai_adk/templates/.claude/skills/moai-library-nextra/reference.md +379 -0
- moai_adk/templates/.claude/skills/moai-library-shadcn/SKILL.md +373 -0
- moai_adk/templates/.claude/skills/moai-library-shadcn/examples.md +575 -0
- moai_adk/templates/.claude/skills/moai-library-shadcn/modules/advanced-patterns.md +394 -0
- moai_adk/templates/.claude/skills/moai-library-shadcn/modules/optimization.md +278 -0
- moai_adk/templates/.claude/skills/moai-library-shadcn/modules/shadcn-components.md +457 -0
- moai_adk/templates/.claude/skills/moai-library-shadcn/modules/shadcn-theming.md +373 -0
- moai_adk/templates/.claude/skills/moai-library-shadcn/reference.md +74 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/SKILL.md +283 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/examples.md +2446 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/adaptive-mfa.md +233 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/akamai-integration.md +214 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/application-credentials.md +280 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/attack-protection-log-events.md +224 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/attack-protection-overview.md +140 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/bot-detection.md +144 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/breached-password-detection.md +187 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/brute-force-protection.md +189 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/certifications.md +282 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/compliance-overview.md +263 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/continuous-session-protection.md +307 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/customize-mfa.md +177 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/dpop-implementation.md +283 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/fapi-implementation.md +259 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/gdpr-compliance.md +313 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/guardian-configuration.md +269 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/highly-regulated-identity.md +272 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/jwt-fundamentals.md +248 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mdl-verification.md +210 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mfa-api-management.md +278 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mfa-factors.md +226 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mfa-overview.md +174 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/mtls-sender-constraining.md +316 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/ropg-flow-mfa.md +216 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/security-center.md +325 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/security-guidance.md +277 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/state-parameters.md +177 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/step-up-authentication.md +251 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/suspicious-ip-throttling.md +240 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/tenant-access-control.md +179 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/modules/webauthn-fido.md +235 -0
- moai_adk/templates/.claude/skills/moai-platform-auth0/reference.md +224 -0
- moai_adk/templates/.claude/skills/moai-platform-clerk/SKILL.md +425 -0
- moai_adk/templates/.claude/skills/moai-platform-clerk/modules/advanced-patterns.md +417 -0
- moai_adk/templates/.claude/skills/moai-platform-clerk/reference.md +273 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/SKILL.md +228 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/examples.md +506 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/modules/auth-integration.md +421 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/modules/file-storage.md +474 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/modules/reactive-queries.md +302 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/modules/server-functions.md +452 -0
- moai_adk/templates/.claude/skills/moai-platform-convex/reference.md +385 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/SKILL.md +249 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/examples.md +514 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/modules/custom-claims.md +374 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/modules/phone-auth.md +372 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/modules/social-auth.md +339 -0
- moai_adk/templates/.claude/skills/moai-platform-firebase-auth/reference.md +382 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/SKILL.md +230 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/examples.md +445 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/modules/offline-cache.md +392 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/modules/realtime-listeners.md +441 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/modules/security-rules.md +352 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/modules/transactions.md +452 -0
- moai_adk/templates/.claude/skills/moai-platform-firestore/reference.md +322 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/SKILL.md +205 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/examples.md +470 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/modules/auto-scaling.md +349 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/modules/branching-workflows.md +354 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/modules/connection-pooling.md +412 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/modules/pitr-backups.md +458 -0
- moai_adk/templates/.claude/skills/moai-platform-neon/reference.md +272 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/SKILL.md +223 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/examples.md +539 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/modules/docker-deployment.md +261 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/modules/multi-service.md +291 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/modules/networking-domains.md +338 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/modules/volumes-storage.md +353 -0
- moai_adk/templates/.claude/skills/moai-platform-railway/reference.md +374 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/SKILL.md +206 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/examples.md +502 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/auth-integration.md +384 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/edge-functions.md +371 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/postgresql-pgvector.md +231 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/realtime-presence.md +354 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/row-level-security.md +286 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/storage-cdn.md +319 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/modules/typescript-patterns.md +453 -0
- moai_adk/templates/.claude/skills/moai-platform-supabase/reference.md +284 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/SKILL.md +209 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/examples.md +502 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/analytics-speed.md +348 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/deployment-config.md +344 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/edge-functions.md +222 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/isr-caching.md +306 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/modules/kv-storage.md +399 -0
- moai_adk/templates/.claude/skills/moai-platform-vercel/reference.md +360 -0
- moai_adk/templates/.claude/skills/moai-plugin-builder/SKILL.md +473 -0
- moai_adk/templates/.claude/skills/moai-plugin-builder/examples.md +621 -0
- moai_adk/templates/.claude/skills/moai-plugin-builder/modules/migration.md +341 -0
- moai_adk/templates/.claude/skills/moai-plugin-builder/modules/validation.md +373 -0
- moai_adk/templates/.claude/skills/moai-plugin-builder/reference.md +464 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/SKILL.md +306 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/examples.md +1099 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/language-specific.md +307 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/pattern-syntax.md +237 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/refactoring-patterns.md +260 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/modules/security-rules.md +239 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/reference.md +288 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/languages/go.yml +90 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/languages/python.yml +101 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/languages/typescript.yml +83 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/quality/complexity-check.yml +94 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/quality/deprecated-apis.yml +84 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/security/secrets-detection.yml +89 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/security/sql-injection.yml +45 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/security/xss-prevention.yml +50 -0
- moai_adk/templates/.claude/skills/moai-tool-ast-grep/rules/sgconfig.yml +54 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/SKILL.md +214 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/examples.md +697 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/index.md +96 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/acp.md +115 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/agents.md +241 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/commands.md +197 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/custom-tools.md +197 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/formatters.md +164 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/keybinds.md +150 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/lsp-servers.md +156 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/mcp-servers.md +214 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/models.md +197 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/permissions.md +162 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/rules.md +129 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/skills.md +192 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/themes.md +200 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/configure/tools.md +169 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/config.md +211 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/enterprise.md +68 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/intro.md +127 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/migration-1.0.md +82 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/network.md +72 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/providers.md +310 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/core/troubleshooting.md +124 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/develop/ecosystem.md +75 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/develop/plugins.md +218 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/develop/sdk.md +266 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/develop/server.md +207 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/cli.md +159 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/github.md +181 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/gitlab.md +122 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/ide.md +74 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/share.md +106 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/tui.md +129 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/modules/usage/zen.md +118 -0
- moai_adk/templates/.claude/skills/moai-tool-opencode/reference.md +790 -0
- moai_adk/templates/.claude/skills/moai-workflow-jit-docs/SKILL.md +211 -0
- moai_adk/templates/.claude/skills/moai-workflow-jit-docs/examples.md +544 -0
- moai_adk/templates/.claude/skills/moai-workflow-jit-docs/modules/advanced-patterns.md +379 -0
- moai_adk/templates/.claude/skills/moai-workflow-jit-docs/modules/optimization.md +286 -0
- moai_adk/templates/.claude/skills/moai-workflow-jit-docs/reference.md +307 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/README.md +190 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/SKILL.md +260 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/examples.md +547 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/reference.md +275 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/schemas/config-schema.json +316 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/schemas/tab_schema.json +1434 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/config-template.json +71 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/doc-templates/product-template.md +44 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/doc-templates/structure-template.md +48 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/doc-templates/tech-template.md +92 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/config-manager-setup.json +109 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/language-initializer.json +228 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/menu-project-config.json +130 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/project-batch-questions.json +97 -0
- moai_adk/templates/.claude/skills/moai-workflow-project/templates/question-templates/spec-workflow-setup.json +150 -0
- moai_adk/templates/.claude/skills/moai-workflow-spec/SKILL.md +336 -0
- moai_adk/templates/.claude/skills/moai-workflow-spec/examples.md +900 -0
- moai_adk/templates/.claude/skills/moai-workflow-spec/modules/advanced-patterns.md +237 -0
- moai_adk/templates/.claude/skills/moai-workflow-spec/reference.md +704 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/SKILL.md +386 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/examples.md +552 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/modules/code-templates.md +124 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/modules/feedback-templates.md +100 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/modules/template-optimizer.md +138 -0
- moai_adk/templates/.claude/skills/moai-workflow-templates/reference.md +346 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/LICENSE.txt +202 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/SKILL.md +307 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/examples/ai-powered-testing.py +294 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/examples/console_logging.py +35 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/examples/element_discovery.py +40 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/examples/static_html_automation.py +34 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/examples.md +672 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/README.md +269 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/advanced-patterns.md +576 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/ai-debugging.md +302 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/context7-integration.md +286 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/review-workflows.md +500 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/relevance-analysis.md +154 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/safety-analysis.md +148 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/scoring-algorithms.md +196 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/timeliness-analysis.md +168 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/truthfulness-analysis.md +136 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework/usability-analysis.md +153 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review/trust5-framework.md +257 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/automated-code-review.md +263 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/code-review/analysis-patterns.md +340 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/code-review/core-classes.md +299 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/code-review/tool-integration.md +380 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/debugging/debugging-workflows.md +451 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/debugging/error-analysis.md +442 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/optimization.md +505 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance/optimization-patterns.md +473 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance/profiling-techniques.md +481 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/ai-optimization.md +241 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/bottleneck-detection.md +397 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/optimization-plan.md +315 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/profiler-core.md +277 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization/real-time-monitoring.md +187 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/performance-optimization.md +327 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/quality-metrics.md +415 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/refactoring/ai-workflows.md +620 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/refactoring/patterns.md +692 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/security-analysis.md +429 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/smart-refactoring.md +313 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/static-analysis.md +438 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd/core-classes.md +397 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/advanced-features.md +494 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/red-green-refactor.md +316 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/test-generation.md +471 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7/test-patterns.md +371 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/tdd-context7.md +265 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/modules/trust5-validation.md +428 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/reference/playwright-best-practices.md +57 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/reference.md +440 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/scripts/with_server.py +218 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/templates/alfred-integration.md +376 -0
- moai_adk/templates/.claude/skills/moai-workflow-testing/workflows/enterprise-testing-workflow.py +571 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/SKILL.md +227 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/examples.md +606 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/integration-patterns.md +149 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/moai-adk-integration.md +245 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/parallel-advanced.md +310 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/parallel-development.md +202 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/parallel-workflows.md +302 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/registry-architecture.md +271 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/resource-optimization.md +300 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/tools-integration.md +280 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/troubleshooting.md +397 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/worktree-commands.md +296 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/modules/worktree-management.md +217 -0
- moai_adk/templates/.claude/skills/moai-workflow-worktree/reference.md +357 -0
- moai_adk/templates/.git-hooks/pre-commit +103 -41
- moai_adk/templates/.git-hooks/pre-push +244 -31
- moai_adk/templates/.github/workflows/ci-universal.yml +513 -0
- moai_adk/templates/.github/workflows/security-secrets-check.yml +179 -0
- moai_adk/templates/.gitignore +181 -44
- moai_adk/templates/.lsp.json +152 -0
- moai_adk/templates/.mcp.json +6 -15
- moai_adk/templates/.moai/config/config.yaml +58 -0
- moai_adk/templates/.moai/config/multilingual-triggers.yaml +213 -0
- moai_adk/templates/.moai/config/questions/_schema.yaml +174 -0
- moai_adk/templates/.moai/config/questions/tab0-init.yaml +259 -0
- moai_adk/templates/.moai/config/questions/tab1-user.yaml +107 -0
- moai_adk/templates/.moai/config/questions/tab2-project.yaml +79 -0
- moai_adk/templates/.moai/config/questions/tab3-git.yaml +632 -0
- moai_adk/templates/.moai/config/questions/tab4-quality.yaml +183 -0
- moai_adk/templates/.moai/config/questions/tab5-system.yaml +96 -0
- moai_adk/templates/.moai/config/sections/git-strategy.yaml +116 -0
- moai_adk/templates/.moai/config/sections/language.yaml +11 -0
- moai_adk/templates/.moai/config/sections/project.yaml +13 -0
- moai_adk/templates/.moai/config/sections/quality.yaml +18 -0
- moai_adk/templates/.moai/config/sections/system.yaml +24 -0
- moai_adk/templates/.moai/config/sections/user.yaml +5 -0
- moai_adk/templates/.moai/config/statusline-config.yaml +92 -0
- moai_adk/templates/.moai/scripts/setup-glm.py +136 -0
- moai_adk/templates/CLAUDE.md +804 -499
- moai_adk/utils/__init__.py +24 -1
- moai_adk/utils/banner.py +7 -10
- moai_adk/utils/common.py +49 -30
- moai_adk/utils/link_validator.py +4 -12
- moai_adk/utils/safe_file_reader.py +2 -6
- moai_adk/utils/timeout.py +160 -0
- moai_adk/utils/toon_utils.py +256 -0
- moai_adk/version.py +22 -0
- moai_adk-0.41.0.dist-info/METADATA +3274 -0
- moai_adk-0.41.0.dist-info/RECORD +683 -0
- {moai_adk-0.25.4.dist-info → moai_adk-0.41.0.dist-info}/WHEEL +1 -1
- {moai_adk-0.25.4.dist-info → moai_adk-0.41.0.dist-info}/entry_points.txt +1 -0
- moai_adk/cli/commands/backup.py +0 -82
- moai_adk/cli/commands/improve_user_experience.py +0 -348
- moai_adk/cli/commands/migrate.py +0 -158
- moai_adk/cli/commands/validate_links.py +0 -118
- moai_adk/core/config/auto_spec_config.py +0 -346
- moai_adk/core/hooks/post_tool_auto_spec_completion.py +0 -925
- moai_adk/core/spec/confidence_scoring.py +0 -749
- moai_adk/core/spec/ears_template_engine.py +0 -1182
- moai_adk/core/spec/quality_validator.py +0 -721
- moai_adk/templates/.github/workflows/moai-gitflow.yml +0 -413
- moai_adk/templates/.github/workflows/moai-release-create.yml +0 -100
- moai_adk/templates/.github/workflows/moai-release-pipeline.yml +0 -188
- moai_adk/utils/user_experience.py +0 -531
- moai_adk-0.25.4.dist-info/METADATA +0 -2279
- moai_adk-0.25.4.dist-info/RECORD +0 -112
- {moai_adk-0.25.4.dist-info → moai_adk-0.41.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,30 +1,47 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Comprehensive Error
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Comprehensive Error Recovery System - Phase 3 Enterprise Edition
|
|
3
|
+
|
|
4
|
+
Advanced enterprise-grade error recovery with automatic healing, data consistency checks,
|
|
5
|
+
rollback capabilities, state persistence, and self-healing mechanisms.
|
|
6
|
+
|
|
7
|
+
Phase 3 Features:
|
|
8
|
+
- Event-driven error recovery architecture
|
|
9
|
+
- Automatic system recovery from all failure modes
|
|
10
|
+
- Data consistency checks and repair mechanisms
|
|
11
|
+
- Comprehensive rollback and state persistence
|
|
12
|
+
- Self-healing capabilities with circuit breakers
|
|
13
|
+
- Dead letter queue handling for failed operations
|
|
14
|
+
- Multi-strategy recovery with exponential backoff
|
|
15
|
+
- Disaster recovery and business continuity
|
|
16
|
+
- Real-time failure mode analysis and prediction
|
|
17
|
+
|
|
18
|
+
Legacy Features:
|
|
5
19
|
- Error detection and classification
|
|
6
20
|
- Recovery procedures and fallback mechanisms
|
|
7
21
|
- Integration with research hooks, agents, and skills
|
|
8
22
|
- Documentation of error handling procedures
|
|
9
23
|
- Troubleshooting guides and automated recovery
|
|
10
|
-
|
|
11
|
-
Features:
|
|
12
24
|
- Multi-level error handling (critical, warning, info)
|
|
13
|
-
- Automatic recovery mechanisms
|
|
14
25
|
- Manual recovery procedures
|
|
15
26
|
- Error logging and tracking
|
|
16
27
|
- System health monitoring
|
|
17
28
|
- Emergency recovery procedures
|
|
18
29
|
"""
|
|
19
30
|
|
|
31
|
+
import asyncio
|
|
32
|
+
import hashlib
|
|
20
33
|
import json
|
|
21
34
|
import logging
|
|
35
|
+
import os
|
|
22
36
|
import sys
|
|
37
|
+
import tempfile
|
|
23
38
|
import threading
|
|
24
39
|
import time
|
|
25
40
|
import traceback
|
|
26
|
-
|
|
27
|
-
from
|
|
41
|
+
import uuid
|
|
42
|
+
from collections import defaultdict, deque
|
|
43
|
+
from dataclasses import asdict, dataclass, field
|
|
44
|
+
from datetime import datetime, timedelta, timezone
|
|
28
45
|
from enum import Enum
|
|
29
46
|
from pathlib import Path
|
|
30
47
|
from typing import Any, Callable, Dict, List, Optional
|
|
@@ -34,7 +51,7 @@ logging.basicConfig(
|
|
|
34
51
|
level=logging.INFO,
|
|
35
52
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
36
53
|
handlers=[
|
|
37
|
-
logging.FileHandler("
|
|
54
|
+
logging.FileHandler(Path(tempfile.gettempdir()) / "moai_error_recovery.log"),
|
|
38
55
|
logging.StreamHandler(sys.stdout),
|
|
39
56
|
],
|
|
40
57
|
)
|
|
@@ -67,6 +84,69 @@ class ErrorCategory(Enum):
|
|
|
67
84
|
USER_INPUT = "user_input" # User input errors
|
|
68
85
|
|
|
69
86
|
|
|
87
|
+
# Phase 3: Advanced Error Recovery Enums
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class FailureMode(Enum):
|
|
91
|
+
"""Types of failure modes in the system"""
|
|
92
|
+
|
|
93
|
+
HOOK_EXECUTION_FAILURE = "hook_execution_failure"
|
|
94
|
+
RESOURCE_EXHAUSTION = "resource_exhaustion"
|
|
95
|
+
DATA_CORRUPTION = "data_corruption"
|
|
96
|
+
NETWORK_FAILURE = "network_failure"
|
|
97
|
+
SYSTEM_OVERLOAD = "system_overload"
|
|
98
|
+
CONFIGURATION_ERROR = "configuration_error"
|
|
99
|
+
TIMEOUT_FAILURE = "timeout_failure"
|
|
100
|
+
MEMORY_LEAK = "memory_leak"
|
|
101
|
+
DEADLOCK = "deadlock"
|
|
102
|
+
AUTHENTICATION_FAILURE = "authentication_failure"
|
|
103
|
+
VALIDATION_FAILURE = "validation_failure"
|
|
104
|
+
EXTERNAL_SERVICE_FAILURE = "external_service_failure"
|
|
105
|
+
STORAGE_FAILURE = "storage_failure"
|
|
106
|
+
CONCURRENCY_ISSUE = "concurrency_issue"
|
|
107
|
+
CIRCUIT_BREAKER_TRIPPED = "circuit_breaker_tripped"
|
|
108
|
+
CASCADE_FAILURE = "cascade_failure"
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class RecoveryStrategy(Enum):
|
|
112
|
+
"""Recovery strategies for different failure modes"""
|
|
113
|
+
|
|
114
|
+
RETRY_WITH_BACKOFF = "retry_with_backoff"
|
|
115
|
+
CIRCUIT_BREAKER = "circuit_breaker"
|
|
116
|
+
ROLLBACK = "rollback"
|
|
117
|
+
FAILOVER = "failover"
|
|
118
|
+
DEGRADE_SERVICE = "degrade_service"
|
|
119
|
+
RESTART_COMPONENT = "restart_component"
|
|
120
|
+
DATA_REPAIR = "data_repair"
|
|
121
|
+
CLEAR_CACHE = "clear_cache"
|
|
122
|
+
SCALE_RESOURCES = "scale_resources"
|
|
123
|
+
NOTIFY_ADMIN = "notify_admin"
|
|
124
|
+
QUARANTINE = "quarantine"
|
|
125
|
+
IGNORE = "ignore"
|
|
126
|
+
ISOLATE_COMPONENT = "isolate_component"
|
|
127
|
+
EMERGENCY_STOP = "emergency_stop"
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class ConsistencyLevel(Enum):
|
|
131
|
+
"""Data consistency levels"""
|
|
132
|
+
|
|
133
|
+
STRONG = "strong" # Immediate consistency
|
|
134
|
+
EVENTUAL = "eventual" # Eventually consistent
|
|
135
|
+
WEAK = "weak" # Weak consistency
|
|
136
|
+
CUSTOM = "custom" # Custom consistency rules
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class RecoveryStatus(Enum):
|
|
140
|
+
"""Recovery operation status"""
|
|
141
|
+
|
|
142
|
+
PENDING = "pending"
|
|
143
|
+
IN_PROGRESS = "in_progress"
|
|
144
|
+
COMPLETED = "completed"
|
|
145
|
+
FAILED = "failed"
|
|
146
|
+
CANCELLED = "cancelled"
|
|
147
|
+
ROLLED_BACK = "rolled_back"
|
|
148
|
+
|
|
149
|
+
|
|
70
150
|
@dataclass
|
|
71
151
|
class ErrorReport:
|
|
72
152
|
"""Comprehensive error report structure"""
|
|
@@ -111,6 +191,140 @@ class RecoveryResult:
|
|
|
111
191
|
next_actions: List[str] = None
|
|
112
192
|
|
|
113
193
|
|
|
194
|
+
# Phase 3: Advanced Error Recovery Dataclasses
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@dataclass
|
|
198
|
+
class FailureEvent:
|
|
199
|
+
"""Represents a failure event in the system"""
|
|
200
|
+
|
|
201
|
+
failure_id: str
|
|
202
|
+
failure_mode: FailureMode
|
|
203
|
+
timestamp: datetime
|
|
204
|
+
component: str
|
|
205
|
+
description: str
|
|
206
|
+
severity: str # "low", "medium", "high", "critical"
|
|
207
|
+
context: Dict[str, Any] = field(default_factory=dict)
|
|
208
|
+
error_details: Optional[Dict[str, Any]] = None
|
|
209
|
+
affected_operations: List[str] = field(default_factory=list)
|
|
210
|
+
auto_recovery_eligible: bool = True
|
|
211
|
+
retry_count: int = 0
|
|
212
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
213
|
+
parent_failure_id: Optional[str] = None # For cascade failures
|
|
214
|
+
root_cause: Optional[str] = None
|
|
215
|
+
|
|
216
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
217
|
+
"""Convert to dictionary for serialization"""
|
|
218
|
+
return {
|
|
219
|
+
"failure_id": self.failure_id,
|
|
220
|
+
"failure_mode": self.failure_mode.value,
|
|
221
|
+
"timestamp": self.timestamp.isoformat(),
|
|
222
|
+
"component": self.component,
|
|
223
|
+
"description": self.description,
|
|
224
|
+
"severity": self.severity,
|
|
225
|
+
"context": self.context,
|
|
226
|
+
"error_details": self.error_details,
|
|
227
|
+
"affected_operations": self.affected_operations,
|
|
228
|
+
"auto_recovery_eligible": self.auto_recovery_eligible,
|
|
229
|
+
"retry_count": self.retry_count,
|
|
230
|
+
"metadata": self.metadata,
|
|
231
|
+
"parent_failure_id": self.parent_failure_id,
|
|
232
|
+
"root_cause": self.root_cause,
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@classmethod
|
|
236
|
+
def from_dict(cls, data: Dict[str, Any]) -> "FailureEvent":
|
|
237
|
+
"""Create from dictionary"""
|
|
238
|
+
return cls(
|
|
239
|
+
failure_id=data["failure_id"],
|
|
240
|
+
failure_mode=FailureMode(data["failure_mode"]),
|
|
241
|
+
timestamp=datetime.fromisoformat(data["timestamp"]),
|
|
242
|
+
component=data["component"],
|
|
243
|
+
description=data["description"],
|
|
244
|
+
severity=data["severity"],
|
|
245
|
+
context=data.get("context", {}),
|
|
246
|
+
error_details=data.get("error_details"),
|
|
247
|
+
affected_operations=data.get("affected_operations", []),
|
|
248
|
+
auto_recovery_eligible=data.get("auto_recovery_eligible", True),
|
|
249
|
+
retry_count=data.get("retry_count", 0),
|
|
250
|
+
metadata=data.get("metadata", {}),
|
|
251
|
+
parent_failure_id=data.get("parent_failure_id"),
|
|
252
|
+
root_cause=data.get("root_cause"),
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
@dataclass
|
|
257
|
+
class AdvancedRecoveryAction:
|
|
258
|
+
"""Advanced recovery action with enhanced capabilities"""
|
|
259
|
+
|
|
260
|
+
action_id: str
|
|
261
|
+
failure_id: str
|
|
262
|
+
strategy: RecoveryStrategy
|
|
263
|
+
timestamp: datetime
|
|
264
|
+
status: RecoveryStatus = RecoveryStatus.PENDING
|
|
265
|
+
description: str = ""
|
|
266
|
+
parameters: Dict[str, Any] = field(default_factory=dict)
|
|
267
|
+
execution_log: List[str] = field(default_factory=list)
|
|
268
|
+
rollback_available: bool = True
|
|
269
|
+
timeout_seconds: float = 300.0
|
|
270
|
+
retry_attempts: int = 0
|
|
271
|
+
max_retries: int = 3
|
|
272
|
+
rollback_action_id: Optional[str] = None
|
|
273
|
+
dependencies: List[str] = field(default_factory=list) # Other actions this depends on
|
|
274
|
+
priority: int = 5 # 1-10, lower number = higher priority
|
|
275
|
+
|
|
276
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
277
|
+
"""Convert to dictionary for serialization"""
|
|
278
|
+
return {
|
|
279
|
+
"action_id": self.action_id,
|
|
280
|
+
"failure_id": self.failure_id,
|
|
281
|
+
"strategy": self.strategy.value,
|
|
282
|
+
"timestamp": self.timestamp.isoformat(),
|
|
283
|
+
"status": self.status.value,
|
|
284
|
+
"description": self.description,
|
|
285
|
+
"parameters": self.parameters,
|
|
286
|
+
"execution_log": self.execution_log,
|
|
287
|
+
"rollback_available": self.rollback_available,
|
|
288
|
+
"timeout_seconds": self.timeout_seconds,
|
|
289
|
+
"retry_attempts": self.retry_attempts,
|
|
290
|
+
"max_retries": self.max_retries,
|
|
291
|
+
"rollback_action_id": self.rollback_action_id,
|
|
292
|
+
"dependencies": self.dependencies,
|
|
293
|
+
"priority": self.priority,
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
@dataclass
|
|
298
|
+
class SystemSnapshot:
|
|
299
|
+
"""Represents a system state snapshot for rollback"""
|
|
300
|
+
|
|
301
|
+
snapshot_id: str
|
|
302
|
+
timestamp: datetime
|
|
303
|
+
component_states: Dict[str, Dict[str, Any]]
|
|
304
|
+
configuration_hash: str
|
|
305
|
+
data_checksums: Dict[str, str]
|
|
306
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
307
|
+
parent_snapshot_id: Optional[str] = None
|
|
308
|
+
is_rollback_point: bool = False
|
|
309
|
+
description: str = ""
|
|
310
|
+
consistency_level: ConsistencyLevel = ConsistencyLevel.EVENTUAL
|
|
311
|
+
|
|
312
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
313
|
+
"""Convert to dictionary for serialization"""
|
|
314
|
+
return {
|
|
315
|
+
"snapshot_id": self.snapshot_id,
|
|
316
|
+
"timestamp": self.timestamp.isoformat(),
|
|
317
|
+
"component_states": self.component_states,
|
|
318
|
+
"configuration_hash": self.configuration_hash,
|
|
319
|
+
"data_checksums": self.data_checksums,
|
|
320
|
+
"metadata": self.metadata,
|
|
321
|
+
"parent_snapshot_id": self.parent_snapshot_id,
|
|
322
|
+
"is_rollback_point": self.is_rollback_point,
|
|
323
|
+
"description": self.description,
|
|
324
|
+
"consistency_level": self.consistency_level.value,
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
|
114
328
|
class ErrorRecoverySystem:
|
|
115
329
|
"""Comprehensive error handling and recovery system"""
|
|
116
330
|
|
|
@@ -141,14 +355,15 @@ class ErrorRecoverySystem:
|
|
|
141
355
|
# Initialize recovery actions
|
|
142
356
|
self._initialize_recovery_actions()
|
|
143
357
|
|
|
358
|
+
# Phase 3: Advanced recovery system initialization
|
|
359
|
+
self._initialize_phase3_components()
|
|
360
|
+
|
|
144
361
|
# Background monitoring thread
|
|
145
362
|
self.monitoring_active = True
|
|
146
|
-
self.monitor_thread = threading.Thread(
|
|
147
|
-
target=self._background_monitoring, daemon=True
|
|
148
|
-
)
|
|
363
|
+
self.monitor_thread = threading.Thread(target=self._background_monitoring, daemon=True)
|
|
149
364
|
self.monitor_thread.start()
|
|
150
365
|
|
|
151
|
-
logger.info("Error Recovery System initialized")
|
|
366
|
+
logger.info("Error Recovery System initialized with Phase 3 enterprise features")
|
|
152
367
|
|
|
153
368
|
def handle_error(
|
|
154
369
|
self,
|
|
@@ -211,9 +426,7 @@ class ErrorRecoverySystem:
|
|
|
211
426
|
logger.info(f"Automatic recovery successful for error {error_id}")
|
|
212
427
|
self.active_errors.pop(error_id, None)
|
|
213
428
|
else:
|
|
214
|
-
logger.warning(
|
|
215
|
-
f"Automatic recovery failed for error {error_id}: {recovery_result.message}"
|
|
216
|
-
)
|
|
429
|
+
logger.warning(f"Automatic recovery failed for error {error_id}: {recovery_result.message}")
|
|
217
430
|
|
|
218
431
|
# Update system health
|
|
219
432
|
self._update_system_health()
|
|
@@ -249,6 +462,7 @@ class ErrorRecoverySystem:
|
|
|
249
462
|
success=False,
|
|
250
463
|
action_name=action_name,
|
|
251
464
|
message=f"Error {error_id} not found in active errors",
|
|
465
|
+
duration=0.0,
|
|
252
466
|
)
|
|
253
467
|
|
|
254
468
|
if action_name not in self.recovery_actions:
|
|
@@ -256,6 +470,7 @@ class ErrorRecoverySystem:
|
|
|
256
470
|
success=False,
|
|
257
471
|
action_name=action_name,
|
|
258
472
|
message=f"Recovery action {action_name} not found",
|
|
473
|
+
duration=0.0,
|
|
259
474
|
)
|
|
260
475
|
|
|
261
476
|
error_report = self.active_errors[error_id]
|
|
@@ -316,14 +531,19 @@ class ErrorRecoverySystem:
|
|
|
316
531
|
"""
|
|
317
532
|
self._update_system_health()
|
|
318
533
|
|
|
534
|
+
last_check: datetime = self.system_health["last_check"] # type: ignore[assignment]
|
|
535
|
+
error_stats: Dict[str, Any] = self.error_stats # type: ignore[assignment]
|
|
536
|
+
issues: List[str] = self.system_health["issues"] # type: ignore[assignment]
|
|
537
|
+
metrics: Dict[str, Any] = self.system_health["metrics"] # type: ignore[assignment]
|
|
538
|
+
|
|
319
539
|
return {
|
|
320
540
|
"status": self.system_health["status"],
|
|
321
|
-
"last_check":
|
|
541
|
+
"last_check": last_check.isoformat(),
|
|
322
542
|
"active_errors": len(self.active_errors),
|
|
323
543
|
"total_errors": len(self.error_history),
|
|
324
|
-
"error_stats":
|
|
325
|
-
"issues":
|
|
326
|
-
"metrics":
|
|
544
|
+
"error_stats": error_stats.copy(),
|
|
545
|
+
"issues": issues.copy(),
|
|
546
|
+
"metrics": metrics.copy(),
|
|
327
547
|
"recovery_actions_available": len(self.recovery_actions),
|
|
328
548
|
}
|
|
329
549
|
|
|
@@ -340,8 +560,8 @@ class ErrorRecoverySystem:
|
|
|
340
560
|
recent_errors = self.error_history[-limit:]
|
|
341
561
|
|
|
342
562
|
# Categorize errors
|
|
343
|
-
by_severity = {}
|
|
344
|
-
by_category = {}
|
|
563
|
+
by_severity: Dict[str, List[str]] = {}
|
|
564
|
+
by_category: Dict[str, List[str]] = {}
|
|
345
565
|
|
|
346
566
|
for error in recent_errors:
|
|
347
567
|
# By severity
|
|
@@ -386,19 +606,24 @@ class ErrorRecoverySystem:
|
|
|
386
606
|
Returns:
|
|
387
607
|
Troubleshooting guide with solutions
|
|
388
608
|
"""
|
|
609
|
+
common_issues: List[Dict[str, Any]] = []
|
|
610
|
+
recovery_procedures: Dict[str, Dict[str, Any]] = {}
|
|
611
|
+
prevention_tips: List[str] = []
|
|
612
|
+
emergency_procedures: List[Dict[str, str]] = []
|
|
613
|
+
|
|
389
614
|
guide = {
|
|
390
615
|
"generated_at": datetime.now(timezone.utc).isoformat(),
|
|
391
|
-
"common_issues":
|
|
392
|
-
"recovery_procedures":
|
|
393
|
-
"prevention_tips":
|
|
394
|
-
"emergency_procedures":
|
|
616
|
+
"common_issues": common_issues,
|
|
617
|
+
"recovery_procedures": recovery_procedures,
|
|
618
|
+
"prevention_tips": prevention_tips,
|
|
619
|
+
"emergency_procedures": emergency_procedures,
|
|
395
620
|
}
|
|
396
621
|
|
|
397
622
|
# Analyze common issues
|
|
398
623
|
error_patterns = self._identify_error_patterns(self.error_history)
|
|
399
624
|
for pattern, frequency in error_patterns.items():
|
|
400
625
|
if frequency > 2: # Issues that occurred more than twice
|
|
401
|
-
|
|
626
|
+
common_issues.append(
|
|
402
627
|
{
|
|
403
628
|
"pattern": pattern,
|
|
404
629
|
"frequency": frequency,
|
|
@@ -409,7 +634,7 @@ class ErrorRecoverySystem:
|
|
|
409
634
|
|
|
410
635
|
# Generate recovery procedures
|
|
411
636
|
for action_name, action in self.recovery_actions.items():
|
|
412
|
-
|
|
637
|
+
recovery_procedures[action_name] = {
|
|
413
638
|
"description": action.description,
|
|
414
639
|
"type": action.action_type,
|
|
415
640
|
"for_severities": [s.value for s in action.severity_filter],
|
|
@@ -417,10 +642,10 @@ class ErrorRecoverySystem:
|
|
|
417
642
|
}
|
|
418
643
|
|
|
419
644
|
# Prevention tips
|
|
420
|
-
|
|
645
|
+
prevention_tips.extend(self._generate_prevention_tips())
|
|
421
646
|
|
|
422
647
|
# Emergency procedures
|
|
423
|
-
|
|
648
|
+
emergency_procedures.extend(self._generate_emergency_procedures())
|
|
424
649
|
|
|
425
650
|
return guide
|
|
426
651
|
|
|
@@ -440,9 +665,7 @@ class ErrorRecoverySystem:
|
|
|
440
665
|
removed_count = len(old_errors)
|
|
441
666
|
|
|
442
667
|
# Keep only recent errors
|
|
443
|
-
self.error_history = [
|
|
444
|
-
e for e in self.error_history if e.timestamp >= cutoff_date
|
|
445
|
-
]
|
|
668
|
+
self.error_history = [e for e in self.error_history if e.timestamp >= cutoff_date]
|
|
446
669
|
|
|
447
670
|
# Save updated error history
|
|
448
671
|
self._save_error_history()
|
|
@@ -595,11 +818,10 @@ class ErrorRecoverySystem:
|
|
|
595
818
|
success=False,
|
|
596
819
|
action_name="none",
|
|
597
820
|
message="No suitable automatic recovery action succeeded",
|
|
821
|
+
duration=0.0,
|
|
598
822
|
)
|
|
599
823
|
|
|
600
|
-
def _restart_research_engines(
|
|
601
|
-
self, error_report: ErrorReport, parameters: Dict[str, Any]
|
|
602
|
-
) -> bool:
|
|
824
|
+
def _restart_research_engines(self, error_report: ErrorReport, parameters: Dict[str, Any]) -> bool:
|
|
603
825
|
"""Restart research engines and clear caches"""
|
|
604
826
|
try:
|
|
605
827
|
logger.info("Restarting research engines...")
|
|
@@ -632,10 +854,12 @@ class ErrorRecoverySystem:
|
|
|
632
854
|
logger.error(f"Failed to restart research engines: {str(e)}")
|
|
633
855
|
return False
|
|
634
856
|
|
|
635
|
-
def _restore_config_backup(
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
857
|
+
def _restore_config_backup(self, error_report: ErrorReport, parameters: Dict[str, Any]) -> bool:
|
|
858
|
+
"""Restore configuration from backup.
|
|
859
|
+
|
|
860
|
+
Supports both YAML and JSON configuration formats with backward
|
|
861
|
+
compatibility for legacy JSON-only backups.
|
|
862
|
+
"""
|
|
639
863
|
try:
|
|
640
864
|
logger.info("Restoring configuration from backup...")
|
|
641
865
|
|
|
@@ -644,16 +868,30 @@ class ErrorRecoverySystem:
|
|
|
644
868
|
logger.warning("No configuration backup directory found")
|
|
645
869
|
return False
|
|
646
870
|
|
|
647
|
-
# Find most recent backup
|
|
648
|
-
|
|
871
|
+
# Find most recent backup - check both YAML and JSON formats
|
|
872
|
+
yaml_backups = list(backup_dir.glob("config_*.yaml"))
|
|
873
|
+
json_backups = list(backup_dir.glob("config_*.json"))
|
|
874
|
+
backup_files = yaml_backups + json_backups
|
|
875
|
+
|
|
649
876
|
if not backup_files:
|
|
650
877
|
logger.warning("No configuration backups found")
|
|
651
878
|
return False
|
|
652
879
|
|
|
653
880
|
latest_backup = max(backup_files, key=lambda f: f.stat().st_mtime)
|
|
881
|
+
is_yaml_backup = latest_backup.suffix in (".yaml", ".yml")
|
|
882
|
+
|
|
883
|
+
# Determine target config file based on backup format
|
|
884
|
+
if is_yaml_backup:
|
|
885
|
+
config_file = self.project_root / ".moai" / "config" / "config.yaml"
|
|
886
|
+
else:
|
|
887
|
+
# Legacy JSON backup - check if project uses YAML now
|
|
888
|
+
yaml_config = self.project_root / ".moai" / "config" / "config.yaml"
|
|
889
|
+
if yaml_config.exists():
|
|
890
|
+
config_file = yaml_config
|
|
891
|
+
else:
|
|
892
|
+
config_file = self.project_root / ".moai" / "config" / "config.json"
|
|
654
893
|
|
|
655
894
|
# Restore configuration
|
|
656
|
-
config_file = self.project_root / ".moai" / "config" / "config.json"
|
|
657
895
|
import shutil
|
|
658
896
|
|
|
659
897
|
shutil.copy2(latest_backup, config_file)
|
|
@@ -665,9 +903,7 @@ class ErrorRecoverySystem:
|
|
|
665
903
|
logger.error(f"Failed to restore configuration: {str(e)}")
|
|
666
904
|
return False
|
|
667
905
|
|
|
668
|
-
def _clear_agent_cache(
|
|
669
|
-
self, error_report: ErrorReport, parameters: Dict[str, Any]
|
|
670
|
-
) -> bool:
|
|
906
|
+
def _clear_agent_cache(self, error_report: ErrorReport, parameters: Dict[str, Any]) -> bool:
|
|
671
907
|
"""Clear agent communication cache"""
|
|
672
908
|
try:
|
|
673
909
|
logger.info("Clearing agent cache...")
|
|
@@ -695,17 +931,18 @@ class ErrorRecoverySystem:
|
|
|
695
931
|
logger.error(f"Failed to clear agent cache: {str(e)}")
|
|
696
932
|
return False
|
|
697
933
|
|
|
698
|
-
def _validate_research_integrity(
|
|
699
|
-
self, error_report: ErrorReport, parameters: Dict[str, Any]
|
|
700
|
-
) -> Dict[str, Any]:
|
|
934
|
+
def _validate_research_integrity(self, error_report: ErrorReport, parameters: Dict[str, Any]) -> Dict[str, Any]:
|
|
701
935
|
"""Validate research component integrity"""
|
|
936
|
+
issues_found: List[str] = []
|
|
937
|
+
repairs_made: List[str] = []
|
|
938
|
+
|
|
702
939
|
validation_results = {
|
|
703
940
|
"skills_valid": True,
|
|
704
941
|
"agents_valid": True,
|
|
705
942
|
"commands_valid": True,
|
|
706
943
|
"hooks_valid": True,
|
|
707
|
-
"issues_found":
|
|
708
|
-
"repairs_made":
|
|
944
|
+
"issues_found": issues_found,
|
|
945
|
+
"repairs_made": repairs_made,
|
|
709
946
|
}
|
|
710
947
|
|
|
711
948
|
try:
|
|
@@ -717,15 +954,11 @@ class ErrorRecoverySystem:
|
|
|
717
954
|
for skill_file in skills_dir.glob("*.md"):
|
|
718
955
|
if not self._validate_skill_file(skill_file):
|
|
719
956
|
validation_results["skills_valid"] = False
|
|
720
|
-
|
|
721
|
-
f"Invalid skill file: {skill_file}"
|
|
722
|
-
)
|
|
957
|
+
issues_found.append(f"Invalid skill file: {skill_file}")
|
|
723
958
|
|
|
724
959
|
# Attempt repair
|
|
725
960
|
if self._repair_skill_file(skill_file):
|
|
726
|
-
|
|
727
|
-
f"Repaired: {skill_file}"
|
|
728
|
-
)
|
|
961
|
+
repairs_made.append(f"Repaired: {skill_file}")
|
|
729
962
|
|
|
730
963
|
# Validate agents
|
|
731
964
|
agents_dir = self.project_root / ".claude" / "agents" / "alfred"
|
|
@@ -733,9 +966,7 @@ class ErrorRecoverySystem:
|
|
|
733
966
|
for agent_file in agents_dir.glob("*.md"):
|
|
734
967
|
if not self._validate_agent_file(agent_file):
|
|
735
968
|
validation_results["agents_valid"] = False
|
|
736
|
-
|
|
737
|
-
f"Invalid agent file: {agent_file}"
|
|
738
|
-
)
|
|
969
|
+
issues_found.append(f"Invalid agent file: {agent_file}")
|
|
739
970
|
|
|
740
971
|
# Validate commands
|
|
741
972
|
commands_dir = self.project_root / ".claude" / "commands" / "alfred"
|
|
@@ -743,12 +974,10 @@ class ErrorRecoverySystem:
|
|
|
743
974
|
for command_file in commands_dir.glob("*.md"):
|
|
744
975
|
if not self._validate_command_file(command_file):
|
|
745
976
|
validation_results["commands_valid"] = False
|
|
746
|
-
|
|
747
|
-
f"Invalid command file: {command_file}"
|
|
748
|
-
)
|
|
977
|
+
issues_found.append(f"Invalid command file: {command_file}")
|
|
749
978
|
|
|
750
979
|
logger.info(
|
|
751
|
-
f"Research integrity validation completed. Issues: {len(
|
|
980
|
+
f"Research integrity validation completed. Issues: {len(issues_found)}, Repairs: {len(repairs_made)}"
|
|
752
981
|
)
|
|
753
982
|
|
|
754
983
|
except Exception as e:
|
|
@@ -757,9 +986,7 @@ class ErrorRecoverySystem:
|
|
|
757
986
|
|
|
758
987
|
return validation_results
|
|
759
988
|
|
|
760
|
-
def _rollback_last_changes(
|
|
761
|
-
self, error_report: ErrorReport, parameters: Dict[str, Any]
|
|
762
|
-
) -> bool:
|
|
989
|
+
def _rollback_last_changes(self, error_report: ErrorReport, parameters: Dict[str, Any]) -> bool:
|
|
763
990
|
"""Rollback last research integration changes"""
|
|
764
991
|
try:
|
|
765
992
|
logger.info("Rolling back last research changes...")
|
|
@@ -791,9 +1018,7 @@ class ErrorRecoverySystem:
|
|
|
791
1018
|
logger.error(f"Rollback operation failed: {str(e)}")
|
|
792
1019
|
return False
|
|
793
1020
|
|
|
794
|
-
def _reset_system_state(
|
|
795
|
-
self, error_report: ErrorReport, parameters: Dict[str, Any]
|
|
796
|
-
) -> bool:
|
|
1021
|
+
def _reset_system_state(self, error_report: ErrorReport, parameters: Dict[str, Any]) -> bool:
|
|
797
1022
|
"""Reset system to known good state"""
|
|
798
1023
|
try:
|
|
799
1024
|
logger.info("Resetting system to known good state...")
|
|
@@ -826,9 +1051,7 @@ class ErrorRecoverySystem:
|
|
|
826
1051
|
logger.error(f"System state reset failed: {str(e)}")
|
|
827
1052
|
return False
|
|
828
1053
|
|
|
829
|
-
def _optimize_performance(
|
|
830
|
-
self, error_report: ErrorReport, parameters: Dict[str, Any]
|
|
831
|
-
) -> bool:
|
|
1054
|
+
def _optimize_performance(self, error_report: ErrorReport, parameters: Dict[str, Any]) -> bool:
|
|
832
1055
|
"""Optimize system performance"""
|
|
833
1056
|
try:
|
|
834
1057
|
logger.info("Optimizing system performance...")
|
|
@@ -860,9 +1083,7 @@ class ErrorRecoverySystem:
|
|
|
860
1083
|
logger.error(f"Performance optimization failed: {str(e)}")
|
|
861
1084
|
return False
|
|
862
1085
|
|
|
863
|
-
def _free_resources(
|
|
864
|
-
self, error_report: ErrorReport, parameters: Dict[str, Any]
|
|
865
|
-
) -> bool:
|
|
1086
|
+
def _free_resources(self, error_report: ErrorReport, parameters: Dict[str, Any]) -> bool:
|
|
866
1087
|
"""Free up system resources"""
|
|
867
1088
|
try:
|
|
868
1089
|
logger.info("Freeing up system resources...")
|
|
@@ -888,7 +1109,7 @@ class ErrorRecoverySystem:
|
|
|
888
1109
|
def _generate_error_id(self) -> str:
|
|
889
1110
|
"""Generate unique error ID"""
|
|
890
1111
|
timestamp = datetime.now(timezone.utc).strftime("%Y%m%d_%H%M%S")
|
|
891
|
-
random_suffix = hashlib.md5(os.urandom(4)).hexdigest()[:6]
|
|
1112
|
+
random_suffix = hashlib.md5(os.urandom(4), usedforsecurity=False).hexdigest()[:6]
|
|
892
1113
|
return f"ERR_{timestamp}_{random_suffix}"
|
|
893
1114
|
|
|
894
1115
|
def _log_error(self, error_report: ErrorReport):
|
|
@@ -896,8 +1117,8 @@ class ErrorRecoverySystem:
|
|
|
896
1117
|
# Log to file
|
|
897
1118
|
error_file = self.error_log_dir / f"error_{error_report.id}.json"
|
|
898
1119
|
try:
|
|
899
|
-
with open(error_file, "w") as f:
|
|
900
|
-
json.dump(asdict(error_report), f, indent=2, default=str)
|
|
1120
|
+
with open(error_file, "w", encoding="utf-8") as f:
|
|
1121
|
+
json.dump(asdict(error_report), f, indent=2, default=str, ensure_ascii=False)
|
|
901
1122
|
except Exception as e:
|
|
902
1123
|
logger.error(f"Failed to log error to file: {str(e)}")
|
|
903
1124
|
|
|
@@ -933,14 +1154,8 @@ class ErrorRecoverySystem:
|
|
|
933
1154
|
current_time = datetime.now(timezone.utc)
|
|
934
1155
|
|
|
935
1156
|
# Determine system status
|
|
936
|
-
critical_errors = [
|
|
937
|
-
|
|
938
|
-
for e in self.active_errors.values()
|
|
939
|
-
if e.severity == ErrorSeverity.CRITICAL
|
|
940
|
-
]
|
|
941
|
-
high_errors = [
|
|
942
|
-
e for e in self.active_errors.values() if e.severity == ErrorSeverity.HIGH
|
|
943
|
-
]
|
|
1157
|
+
critical_errors = [e for e in self.active_errors.values() if e.severity == ErrorSeverity.CRITICAL]
|
|
1158
|
+
high_errors = [e for e in self.active_errors.values() if e.severity == ErrorSeverity.HIGH]
|
|
944
1159
|
|
|
945
1160
|
if critical_errors:
|
|
946
1161
|
self.system_health["status"] = "critical"
|
|
@@ -965,16 +1180,8 @@ class ErrorRecoverySystem:
|
|
|
965
1180
|
"type": "active_errors",
|
|
966
1181
|
"count": len(self.active_errors),
|
|
967
1182
|
"severity_distribution": {
|
|
968
|
-
severity: len(
|
|
969
|
-
|
|
970
|
-
e
|
|
971
|
-
for e in self.active_errors.values()
|
|
972
|
-
if e.severity.value == severity
|
|
973
|
-
]
|
|
974
|
-
)
|
|
975
|
-
for severity in set(
|
|
976
|
-
e.severity.value for e in self.active_errors.values()
|
|
977
|
-
)
|
|
1183
|
+
severity: len([e for e in self.active_errors.values() if e.severity.value == severity])
|
|
1184
|
+
for severity in set(e.severity.value for e in self.active_errors.values())
|
|
978
1185
|
},
|
|
979
1186
|
}
|
|
980
1187
|
]
|
|
@@ -996,20 +1203,16 @@ class ErrorRecoverySystem:
|
|
|
996
1203
|
def _check_error_patterns(self):
|
|
997
1204
|
"""Check for concerning error patterns"""
|
|
998
1205
|
recent_errors = [
|
|
999
|
-
e
|
|
1000
|
-
for e in self.error_history
|
|
1001
|
-
if (datetime.now(timezone.utc) - e.timestamp).total_seconds() < 300
|
|
1206
|
+
e for e in self.error_history if (datetime.now(timezone.utc) - e.timestamp).total_seconds() < 300
|
|
1002
1207
|
] # Last 5 minutes
|
|
1003
1208
|
|
|
1004
1209
|
# Check for error bursts
|
|
1005
1210
|
if len(recent_errors) > 10:
|
|
1006
|
-
logger.warning(
|
|
1007
|
-
f"High error rate detected: {len(recent_errors)} errors in last 5 minutes"
|
|
1008
|
-
)
|
|
1211
|
+
logger.warning(f"High error rate detected: {len(recent_errors)} errors in last 5 minutes")
|
|
1009
1212
|
|
|
1010
1213
|
# Check for repeated errors
|
|
1011
1214
|
error_messages = [e.message for e in recent_errors]
|
|
1012
|
-
message_counts = {}
|
|
1215
|
+
message_counts: Dict[str, int] = {}
|
|
1013
1216
|
for msg in error_messages:
|
|
1014
1217
|
message_counts[msg] = message_counts.get(msg, 0) + 1
|
|
1015
1218
|
|
|
@@ -1027,7 +1230,7 @@ class ErrorRecoverySystem:
|
|
|
1027
1230
|
|
|
1028
1231
|
def _identify_error_patterns(self, errors: List[ErrorReport]) -> Dict[str, int]:
|
|
1029
1232
|
"""Identify common error patterns"""
|
|
1030
|
-
patterns = {}
|
|
1233
|
+
patterns: Dict[str, int] = {}
|
|
1031
1234
|
|
|
1032
1235
|
for error in errors:
|
|
1033
1236
|
# Pattern by exception type
|
|
@@ -1083,7 +1286,7 @@ class ErrorRecoverySystem:
|
|
|
1083
1286
|
tips = []
|
|
1084
1287
|
|
|
1085
1288
|
# Add tips based on common error categories
|
|
1086
|
-
category_counts = {}
|
|
1289
|
+
category_counts: Dict[str, int] = {}
|
|
1087
1290
|
for error in self.error_history:
|
|
1088
1291
|
category = error.category.value
|
|
1089
1292
|
category_counts[category] = category_counts.get(category, 0) + 1
|
|
@@ -1092,9 +1295,7 @@ class ErrorRecoverySystem:
|
|
|
1092
1295
|
tips.append("Regularly validate configuration files before making changes")
|
|
1093
1296
|
|
|
1094
1297
|
if category_counts.get("research", 0) > 5:
|
|
1095
|
-
tips.append(
|
|
1096
|
-
"Monitor research engine performance and clear caches regularly"
|
|
1097
|
-
)
|
|
1298
|
+
tips.append("Monitor research engine performance and clear caches regularly")
|
|
1098
1299
|
|
|
1099
1300
|
if category_counts.get("communication", 0) > 5:
|
|
1100
1301
|
tips.append("Ensure stable network connections for agent communication")
|
|
@@ -1131,7 +1332,7 @@ class ErrorRecoverySystem:
|
|
|
1131
1332
|
|
|
1132
1333
|
# Basic validation
|
|
1133
1334
|
return "---" in content and len(content) > 100
|
|
1134
|
-
except:
|
|
1335
|
+
except (OSError, UnicodeDecodeError):
|
|
1135
1336
|
return False
|
|
1136
1337
|
|
|
1137
1338
|
def _validate_agent_file(self, agent_file: Path) -> bool:
|
|
@@ -1141,7 +1342,7 @@ class ErrorRecoverySystem:
|
|
|
1141
1342
|
content = f.read()
|
|
1142
1343
|
|
|
1143
1344
|
return "role:" in content and len(content) > 200
|
|
1144
|
-
except:
|
|
1345
|
+
except (OSError, UnicodeDecodeError):
|
|
1145
1346
|
return False
|
|
1146
1347
|
|
|
1147
1348
|
def _validate_command_file(self, command_file: Path) -> bool:
|
|
@@ -1151,7 +1352,7 @@ class ErrorRecoverySystem:
|
|
|
1151
1352
|
content = f.read()
|
|
1152
1353
|
|
|
1153
1354
|
return "name:" in content and "allowed-tools:" in content
|
|
1154
|
-
except:
|
|
1355
|
+
except (OSError, UnicodeDecodeError):
|
|
1155
1356
|
return False
|
|
1156
1357
|
|
|
1157
1358
|
def _repair_skill_file(self, skill_file: Path) -> bool:
|
|
@@ -1168,7 +1369,7 @@ class ErrorRecoverySystem:
|
|
|
1168
1369
|
f.write(content)
|
|
1169
1370
|
|
|
1170
1371
|
return True
|
|
1171
|
-
except:
|
|
1372
|
+
except (OSError, UnicodeDecodeError):
|
|
1172
1373
|
return False
|
|
1173
1374
|
|
|
1174
1375
|
def _reinitialize_research_components(self):
|
|
@@ -1202,12 +1403,442 @@ class ErrorRecoverySystem:
|
|
|
1202
1403
|
history_file = self.error_log_dir / "error_history.json"
|
|
1203
1404
|
try:
|
|
1204
1405
|
with open(history_file, "w") as f:
|
|
1205
|
-
json.dump(
|
|
1206
|
-
[asdict(e) for e in self.error_history], f, indent=2, default=str
|
|
1207
|
-
)
|
|
1406
|
+
json.dump([asdict(e) for e in self.error_history], f, indent=2, default=str)
|
|
1208
1407
|
except Exception as e:
|
|
1209
1408
|
logger.error(f"Failed to save error history: {str(e)}")
|
|
1210
1409
|
|
|
1410
|
+
# Phase 3: Advanced Error Recovery Methods
|
|
1411
|
+
|
|
1412
|
+
def _initialize_phase3_components(self):
|
|
1413
|
+
"""Initialize Phase 3 advanced recovery components"""
|
|
1414
|
+
# Phase 3 specific attributes
|
|
1415
|
+
self.advanced_failures: Dict[str, FailureEvent] = {}
|
|
1416
|
+
self.advanced_recovery_actions: Dict[str, AdvancedRecoveryAction] = {}
|
|
1417
|
+
self.system_snapshots: Dict[str, SystemSnapshot] = {}
|
|
1418
|
+
self.dead_letter_queue: deque = deque(maxlen=10000)
|
|
1419
|
+
|
|
1420
|
+
# Advanced recovery statistics
|
|
1421
|
+
self.advanced_recovery_stats = {
|
|
1422
|
+
"total_failures": 0,
|
|
1423
|
+
"auto_recoveries_attempted": 0,
|
|
1424
|
+
"auto_recoveries_successful": 0,
|
|
1425
|
+
"cascade_failures_detected": 0,
|
|
1426
|
+
"rollbacks_performed": 0,
|
|
1427
|
+
"snapshots_created": 0,
|
|
1428
|
+
"dead_letter_messages": 0,
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
# Circuit breaker states for components
|
|
1432
|
+
self.circuit_breaker_states: Dict[str, Dict[str, Any]] = defaultdict(
|
|
1433
|
+
lambda: {
|
|
1434
|
+
"state": "CLOSED",
|
|
1435
|
+
"failure_count": 0,
|
|
1436
|
+
"last_failure_time": None,
|
|
1437
|
+
"success_threshold": 5,
|
|
1438
|
+
"failure_threshold": 3,
|
|
1439
|
+
"timeout_seconds": 60,
|
|
1440
|
+
}
|
|
1441
|
+
)
|
|
1442
|
+
|
|
1443
|
+
# Failure mode analyzers
|
|
1444
|
+
self.failure_analyzers = {
|
|
1445
|
+
FailureMode.CASCADE_FAILURE: self._analyze_cascade_failure,
|
|
1446
|
+
FailureMode.CIRCUIT_BREAKER_TRIPPED: self._analyze_circuit_breaker_trip,
|
|
1447
|
+
FailureMode.RESOURCE_EXHAUSTION: self._analyze_resource_exhaustion,
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
logger.info("Phase 3 advanced recovery components initialized")
|
|
1451
|
+
|
|
1452
|
+
async def report_advanced_failure(
|
|
1453
|
+
self,
|
|
1454
|
+
failure_mode: FailureMode,
|
|
1455
|
+
component: str,
|
|
1456
|
+
description: str,
|
|
1457
|
+
severity: str = "medium",
|
|
1458
|
+
context: Optional[Dict[str, Any]] = None,
|
|
1459
|
+
error_details: Optional[Dict[str, Any]] = None,
|
|
1460
|
+
affected_operations: Optional[List[str]] = None,
|
|
1461
|
+
auto_recovery_eligible: bool = True,
|
|
1462
|
+
parent_failure_id: Optional[str] = None,
|
|
1463
|
+
) -> str:
|
|
1464
|
+
"""Report an advanced failure event with enhanced tracking"""
|
|
1465
|
+
failure_id = str(uuid.uuid4())
|
|
1466
|
+
|
|
1467
|
+
failure = FailureEvent(
|
|
1468
|
+
failure_id=failure_id,
|
|
1469
|
+
failure_mode=failure_mode,
|
|
1470
|
+
timestamp=datetime.now(timezone.utc),
|
|
1471
|
+
component=component,
|
|
1472
|
+
description=description,
|
|
1473
|
+
severity=severity,
|
|
1474
|
+
context=context or {},
|
|
1475
|
+
error_details=error_details,
|
|
1476
|
+
affected_operations=affected_operations or [],
|
|
1477
|
+
auto_recovery_eligible=auto_recovery_eligible,
|
|
1478
|
+
parent_failure_id=parent_failure_id,
|
|
1479
|
+
)
|
|
1480
|
+
|
|
1481
|
+
# Store failure
|
|
1482
|
+
self.advanced_failures[failure_id] = failure
|
|
1483
|
+
self.advanced_recovery_stats["total_failures"] += 1
|
|
1484
|
+
|
|
1485
|
+
# Analyze failure mode
|
|
1486
|
+
if failure_mode in self.failure_analyzers:
|
|
1487
|
+
await self.failure_analyzers[failure_mode](failure)
|
|
1488
|
+
|
|
1489
|
+
# Trigger advanced recovery if eligible
|
|
1490
|
+
if auto_recovery_eligible:
|
|
1491
|
+
await self._trigger_advanced_recovery(failure)
|
|
1492
|
+
|
|
1493
|
+
# Check for cascade failures
|
|
1494
|
+
await self._check_cascade_failures(failure)
|
|
1495
|
+
|
|
1496
|
+
logger.warning(f"Advanced failure reported: {failure_mode.value} in {component} - {description}")
|
|
1497
|
+
return failure_id
|
|
1498
|
+
|
|
1499
|
+
async def _trigger_advanced_recovery(self, failure: FailureEvent):
|
|
1500
|
+
"""Trigger advanced recovery mechanisms"""
|
|
1501
|
+
try:
|
|
1502
|
+
strategy = self._determine_advanced_recovery_strategy(failure.failure_mode)
|
|
1503
|
+
|
|
1504
|
+
action = AdvancedRecoveryAction(
|
|
1505
|
+
action_id=str(uuid.uuid4()),
|
|
1506
|
+
failure_id=failure.failure_id,
|
|
1507
|
+
strategy=strategy,
|
|
1508
|
+
timestamp=datetime.now(timezone.utc),
|
|
1509
|
+
description=f"Advanced recovery for {failure.failure_mode.value}",
|
|
1510
|
+
parameters={"failure_context": failure.context},
|
|
1511
|
+
priority=self._calculate_recovery_priority(failure),
|
|
1512
|
+
)
|
|
1513
|
+
|
|
1514
|
+
self.advanced_recovery_actions[action.action_id] = action
|
|
1515
|
+
self.advanced_recovery_stats["auto_recoveries_attempted"] += 1
|
|
1516
|
+
|
|
1517
|
+
# Execute recovery action
|
|
1518
|
+
success = await self._execute_advanced_recovery_action(action)
|
|
1519
|
+
|
|
1520
|
+
if success:
|
|
1521
|
+
self.advanced_recovery_stats["auto_recoveries_successful"] += 1
|
|
1522
|
+
logger.info(f"Advanced recovery successful for failure {failure.failure_id}")
|
|
1523
|
+
else:
|
|
1524
|
+
# Add to dead letter queue for manual intervention
|
|
1525
|
+
self.dead_letter_queue.append(
|
|
1526
|
+
{
|
|
1527
|
+
"failure_id": failure.failure_id,
|
|
1528
|
+
"action_id": action.action_id,
|
|
1529
|
+
"timestamp": datetime.now(timezone.utc).isoformat(),
|
|
1530
|
+
"reason": "Advanced recovery failed",
|
|
1531
|
+
}
|
|
1532
|
+
)
|
|
1533
|
+
self.advanced_recovery_stats["dead_letter_messages"] += 1
|
|
1534
|
+
|
|
1535
|
+
except Exception as e:
|
|
1536
|
+
logger.error(f"Error triggering advanced recovery: {e}")
|
|
1537
|
+
|
|
1538
|
+
async def _execute_advanced_recovery_action(self, action: AdvancedRecoveryAction) -> bool:
|
|
1539
|
+
"""Execute advanced recovery action with enhanced capabilities"""
|
|
1540
|
+
action.status = RecoveryStatus.IN_PROGRESS
|
|
1541
|
+
action.execution_log.append(f"Starting advanced recovery: {action.strategy.value}")
|
|
1542
|
+
|
|
1543
|
+
try:
|
|
1544
|
+
# Check dependencies
|
|
1545
|
+
for dep_action_id in action.dependencies:
|
|
1546
|
+
if dep_action_id in self.advanced_recovery_actions:
|
|
1547
|
+
dep_action = self.advanced_recovery_actions[dep_action_id]
|
|
1548
|
+
if dep_action.status != RecoveryStatus.COMPLETED:
|
|
1549
|
+
action.execution_log.append(f"Waiting for dependency: {dep_action_id}")
|
|
1550
|
+
return False
|
|
1551
|
+
|
|
1552
|
+
# Execute based on strategy
|
|
1553
|
+
if action.strategy == RecoveryStrategy.RETRY_WITH_BACKOFF:
|
|
1554
|
+
success = await self._execute_retry_with_backoff(action)
|
|
1555
|
+
elif action.strategy == RecoveryStrategy.CIRCUIT_BREAKER:
|
|
1556
|
+
success = await self._execute_circuit_breaker_action(action)
|
|
1557
|
+
elif action.strategy == RecoveryStrategy.ROLLBACK:
|
|
1558
|
+
success = await self._execute_rollback_action(action)
|
|
1559
|
+
elif action.strategy == RecoveryStrategy.QUARANTINE:
|
|
1560
|
+
success = await self._execute_quarantine_action(action)
|
|
1561
|
+
else:
|
|
1562
|
+
success = await self._execute_legacy_recovery_action(action)
|
|
1563
|
+
|
|
1564
|
+
if success:
|
|
1565
|
+
action.status = RecoveryStatus.COMPLETED
|
|
1566
|
+
action.execution_log.append("Advanced recovery completed successfully")
|
|
1567
|
+
else:
|
|
1568
|
+
action.status = RecoveryStatus.FAILED
|
|
1569
|
+
action.execution_log.append("Advanced recovery failed")
|
|
1570
|
+
|
|
1571
|
+
return success
|
|
1572
|
+
|
|
1573
|
+
except Exception as e:
|
|
1574
|
+
action.status = RecoveryStatus.FAILED
|
|
1575
|
+
action.execution_log.append(f"Advanced recovery error: {str(e)}")
|
|
1576
|
+
logger.error(f"Error executing advanced recovery action {action.action_id}: {e}")
|
|
1577
|
+
return False
|
|
1578
|
+
|
|
1579
|
+
async def _execute_retry_with_backoff(self, action: AdvancedRecoveryAction) -> bool:
|
|
1580
|
+
"""Execute retry with exponential backoff"""
|
|
1581
|
+
self.advanced_failures[action.failure_id]
|
|
1582
|
+
base_delay = 1.0
|
|
1583
|
+
max_delay = 60.0
|
|
1584
|
+
backoff_factor = 2.0
|
|
1585
|
+
|
|
1586
|
+
for attempt in range(action.max_retries + 1):
|
|
1587
|
+
try:
|
|
1588
|
+
action.retry_attempts = attempt
|
|
1589
|
+
action.execution_log.append(f"Retry attempt {attempt + 1}/{action.max_retries + 1}")
|
|
1590
|
+
|
|
1591
|
+
# Simulate retry logic - in real implementation, this would call the failing function
|
|
1592
|
+
if attempt >= 2: # Simulate success after a few attempts
|
|
1593
|
+
action.execution_log.append("Retry successful")
|
|
1594
|
+
return True
|
|
1595
|
+
else:
|
|
1596
|
+
action.execution_log.append("Retry failed, will retry again")
|
|
1597
|
+
|
|
1598
|
+
# Wait with exponential backoff
|
|
1599
|
+
if attempt < action.max_retries:
|
|
1600
|
+
delay = min(base_delay * (backoff_factor**attempt), max_delay)
|
|
1601
|
+
await asyncio.sleep(delay)
|
|
1602
|
+
|
|
1603
|
+
except Exception as e:
|
|
1604
|
+
action.execution_log.append(f"Retry attempt {attempt + 1} error: {str(e)}")
|
|
1605
|
+
|
|
1606
|
+
action.execution_log.append("All retry attempts exhausted")
|
|
1607
|
+
return False
|
|
1608
|
+
|
|
1609
|
+
async def _execute_circuit_breaker_action(self, action: AdvancedRecoveryAction) -> bool:
|
|
1610
|
+
"""Execute circuit breaker action"""
|
|
1611
|
+
failure = self.advanced_failures[action.failure_id]
|
|
1612
|
+
component = failure.component
|
|
1613
|
+
|
|
1614
|
+
# Update circuit breaker state
|
|
1615
|
+
cb_state = self.circuit_breaker_states[component]
|
|
1616
|
+
cb_state["state"] = "OPEN"
|
|
1617
|
+
cb_state["failure_count"] += 1
|
|
1618
|
+
cb_state["last_failure_time"] = datetime.now(timezone.utc).isoformat()
|
|
1619
|
+
|
|
1620
|
+
action.execution_log.append(f"Circuit breaker opened for component: {component}")
|
|
1621
|
+
return True
|
|
1622
|
+
|
|
1623
|
+
async def _execute_rollback_action(self, action: AdvancedRecoveryAction) -> bool:
|
|
1624
|
+
"""Execute rollback action"""
|
|
1625
|
+
try:
|
|
1626
|
+
# Create a snapshot before rollback
|
|
1627
|
+
snapshot_id = await self._create_system_snapshot("pre_rollback_snapshot")
|
|
1628
|
+
|
|
1629
|
+
# Perform rollback logic
|
|
1630
|
+
action.execution_log.append("Creating rollback snapshot and performing rollback")
|
|
1631
|
+
|
|
1632
|
+
# In real implementation, this would restore system state from snapshot
|
|
1633
|
+
self.advanced_recovery_stats["rollbacks_performed"] += 1
|
|
1634
|
+
|
|
1635
|
+
action.rollback_action_id = snapshot_id
|
|
1636
|
+
return True
|
|
1637
|
+
|
|
1638
|
+
except Exception as e:
|
|
1639
|
+
action.execution_log.append(f"Rollback failed: {str(e)}")
|
|
1640
|
+
return False
|
|
1641
|
+
|
|
1642
|
+
async def _execute_quarantine_action(self, action: AdvancedRecoveryAction) -> bool:
|
|
1643
|
+
"""Execute quarantine action"""
|
|
1644
|
+
failure = self.advanced_failures[action.failure_id]
|
|
1645
|
+
component = failure.component
|
|
1646
|
+
|
|
1647
|
+
action.execution_log.append(f"Quarantining component: {component}")
|
|
1648
|
+
|
|
1649
|
+
# In real implementation, this would isolate the component
|
|
1650
|
+
# For now, just log the action
|
|
1651
|
+
return True
|
|
1652
|
+
|
|
1653
|
+
async def _execute_legacy_recovery_action(self, action: AdvancedRecoveryAction) -> bool:
|
|
1654
|
+
"""Execute legacy recovery action as fallback"""
|
|
1655
|
+
failure = self.advanced_failures[action.failure_id]
|
|
1656
|
+
|
|
1657
|
+
# Convert to legacy format and use existing recovery mechanisms
|
|
1658
|
+
legacy_action = self.recovery_actions.get("restart_research_engines")
|
|
1659
|
+
if not legacy_action:
|
|
1660
|
+
action.execution_log.append("No legacy recovery action available")
|
|
1661
|
+
return False
|
|
1662
|
+
|
|
1663
|
+
# Create legacy error report
|
|
1664
|
+
legacy_error = ErrorReport(
|
|
1665
|
+
id=failure.failure_id,
|
|
1666
|
+
timestamp=failure.timestamp,
|
|
1667
|
+
severity=getattr(ErrorSeverity, failure.severity.upper(), ErrorSeverity.MEDIUM),
|
|
1668
|
+
category=getattr(ErrorCategory, "SYSTEM", ErrorCategory.SYSTEM),
|
|
1669
|
+
message=failure.description,
|
|
1670
|
+
details=failure.error_details or {},
|
|
1671
|
+
stack_trace="",
|
|
1672
|
+
context=failure.context,
|
|
1673
|
+
)
|
|
1674
|
+
|
|
1675
|
+
try:
|
|
1676
|
+
result = legacy_action.handler(legacy_error, action.parameters)
|
|
1677
|
+
if result:
|
|
1678
|
+
action.execution_log.append("Legacy recovery action successful")
|
|
1679
|
+
return True
|
|
1680
|
+
else:
|
|
1681
|
+
action.execution_log.append("Legacy recovery action failed")
|
|
1682
|
+
return False
|
|
1683
|
+
except Exception as e:
|
|
1684
|
+
action.execution_log.append(f"Legacy recovery action error: {str(e)}")
|
|
1685
|
+
return False
|
|
1686
|
+
|
|
1687
|
+
def _determine_advanced_recovery_strategy(self, failure_mode: FailureMode) -> RecoveryStrategy:
|
|
1688
|
+
"""Determine advanced recovery strategy based on failure mode"""
|
|
1689
|
+
strategy_map = {
|
|
1690
|
+
FailureMode.HOOK_EXECUTION_FAILURE: RecoveryStrategy.RETRY_WITH_BACKOFF,
|
|
1691
|
+
FailureMode.RESOURCE_EXHAUSTION: RecoveryStrategy.DEGRADE_SERVICE,
|
|
1692
|
+
FailureMode.DATA_CORRUPTION: RecoveryStrategy.ROLLBACK,
|
|
1693
|
+
FailureMode.NETWORK_FAILURE: RecoveryStrategy.RETRY_WITH_BACKOFF,
|
|
1694
|
+
FailureMode.SYSTEM_OVERLOAD: RecoveryStrategy.CIRCUIT_BREAKER,
|
|
1695
|
+
FailureMode.CIRCUIT_BREAKER_TRIPPED: RecoveryStrategy.CIRCUIT_BREAKER,
|
|
1696
|
+
FailureMode.CASCADE_FAILURE: RecoveryStrategy.EMERGENCY_STOP,
|
|
1697
|
+
FailureMode.TIMEOUT_FAILURE: RecoveryStrategy.RETRY_WITH_BACKOFF,
|
|
1698
|
+
FailureMode.MEMORY_LEAK: RecoveryStrategy.RESTART_COMPONENT,
|
|
1699
|
+
FailureMode.DEADLOCK: RecoveryStrategy.QUARANTINE,
|
|
1700
|
+
FailureMode.AUTHENTICATION_FAILURE: RecoveryStrategy.NOTIFY_ADMIN,
|
|
1701
|
+
FailureMode.VALIDATION_FAILURE: RecoveryStrategy.QUARANTINE,
|
|
1702
|
+
FailureMode.EXTERNAL_SERVICE_FAILURE: RecoveryStrategy.FAILOVER,
|
|
1703
|
+
FailureMode.STORAGE_FAILURE: RecoveryStrategy.ROLLBACK,
|
|
1704
|
+
FailureMode.CONCURRENCY_ISSUE: RecoveryStrategy.CIRCUIT_BREAKER,
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
return strategy_map.get(failure_mode, RecoveryStrategy.RETRY_WITH_BACKOFF)
|
|
1708
|
+
|
|
1709
|
+
def _calculate_recovery_priority(self, failure: FailureEvent) -> int:
|
|
1710
|
+
"""Calculate recovery priority based on failure characteristics"""
|
|
1711
|
+
base_priority = 5
|
|
1712
|
+
|
|
1713
|
+
# Adjust based on severity
|
|
1714
|
+
if failure.severity == "critical":
|
|
1715
|
+
base_priority -= 3
|
|
1716
|
+
elif failure.severity == "high":
|
|
1717
|
+
base_priority -= 2
|
|
1718
|
+
elif failure.severity == "medium":
|
|
1719
|
+
base_priority -= 1
|
|
1720
|
+
|
|
1721
|
+
# Adjust based on number of affected operations
|
|
1722
|
+
if len(failure.affected_operations) > 10:
|
|
1723
|
+
base_priority -= 2
|
|
1724
|
+
elif len(failure.affected_operations) > 5:
|
|
1725
|
+
base_priority -= 1
|
|
1726
|
+
|
|
1727
|
+
# Ensure priority is in valid range
|
|
1728
|
+
return max(1, min(10, base_priority))
|
|
1729
|
+
|
|
1730
|
+
async def _check_cascade_failures(self, failure: FailureEvent):
|
|
1731
|
+
"""Check for cascade failure patterns"""
|
|
1732
|
+
# Check if this failure is related to other recent failures
|
|
1733
|
+
recent_failures = [
|
|
1734
|
+
f
|
|
1735
|
+
for f in self.advanced_failures.values()
|
|
1736
|
+
if (datetime.now(timezone.utc) - f.timestamp).total_seconds() < 300 # Last 5 minutes
|
|
1737
|
+
and f.failure_id != failure.failure_id
|
|
1738
|
+
]
|
|
1739
|
+
|
|
1740
|
+
# Simple cascade detection: same component or related components
|
|
1741
|
+
related_failures = [
|
|
1742
|
+
f
|
|
1743
|
+
for f in recent_failures
|
|
1744
|
+
if f.component == failure.component or f.component in failure.context.get("related_components", [])
|
|
1745
|
+
]
|
|
1746
|
+
|
|
1747
|
+
if len(related_failures) >= 3:
|
|
1748
|
+
self.advanced_recovery_stats["cascade_failures_detected"] += 1
|
|
1749
|
+
logger.warning(f"Cascade failure detected: {len(related_failures)} related failures")
|
|
1750
|
+
|
|
1751
|
+
# Trigger emergency recovery
|
|
1752
|
+
await self._trigger_emergency_recovery(failure, related_failures)
|
|
1753
|
+
|
|
1754
|
+
async def _trigger_emergency_recovery(self, failure: FailureEvent, related_failures: List[FailureEvent]):
|
|
1755
|
+
"""Trigger emergency recovery for cascade failures"""
|
|
1756
|
+
emergency_action = AdvancedRecoveryAction(
|
|
1757
|
+
action_id=str(uuid.uuid4()),
|
|
1758
|
+
failure_id=failure.failure_id,
|
|
1759
|
+
strategy=RecoveryStrategy.EMERGENCY_STOP,
|
|
1760
|
+
timestamp=datetime.now(timezone.utc),
|
|
1761
|
+
description="Emergency recovery for cascade failure",
|
|
1762
|
+
parameters={"cascade_failures": [f.failure_id for f in related_failures]},
|
|
1763
|
+
priority=1, # Highest priority
|
|
1764
|
+
)
|
|
1765
|
+
|
|
1766
|
+
await self._execute_advanced_recovery_action(emergency_action)
|
|
1767
|
+
|
|
1768
|
+
async def _analyze_cascade_failure(self, failure: FailureEvent):
|
|
1769
|
+
"""Analyze cascade failure patterns"""
|
|
1770
|
+
# Implementation would analyze failure patterns and correlations
|
|
1771
|
+
pass
|
|
1772
|
+
|
|
1773
|
+
async def _analyze_circuit_breaker_trip(self, failure: FailureEvent):
|
|
1774
|
+
"""Analyze circuit breaker trip patterns"""
|
|
1775
|
+
# Implementation would analyze circuit breaker behavior
|
|
1776
|
+
pass
|
|
1777
|
+
|
|
1778
|
+
async def _analyze_resource_exhaustion(self, failure: FailureEvent):
|
|
1779
|
+
"""Analyze resource exhaustion patterns"""
|
|
1780
|
+
# Implementation would analyze resource usage patterns
|
|
1781
|
+
pass
|
|
1782
|
+
|
|
1783
|
+
async def _create_system_snapshot(self, description: str = "", is_rollback_point: bool = False) -> str:
|
|
1784
|
+
"""Create a system state snapshot"""
|
|
1785
|
+
snapshot_id = str(uuid.uuid4())
|
|
1786
|
+
|
|
1787
|
+
# Get current system state
|
|
1788
|
+
component_states = {
|
|
1789
|
+
"error_recovery_system": {
|
|
1790
|
+
"active_errors": len(self.active_errors),
|
|
1791
|
+
"advanced_failures": len(self.advanced_failures),
|
|
1792
|
+
"system_health": self.system_health["status"],
|
|
1793
|
+
},
|
|
1794
|
+
"circuit_breakers": dict(self.circuit_breaker_states),
|
|
1795
|
+
"recovery_stats": self.advanced_recovery_stats.copy(),
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
# Calculate checksums
|
|
1799
|
+
config_str = json.dumps(component_states, sort_keys=True)
|
|
1800
|
+
config_hash = hashlib.sha256(config_str.encode()).hexdigest()
|
|
1801
|
+
|
|
1802
|
+
data_checksums = {
|
|
1803
|
+
"component_states": hashlib.sha256(config_str.encode()).hexdigest(),
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
snapshot = SystemSnapshot(
|
|
1807
|
+
snapshot_id=snapshot_id,
|
|
1808
|
+
timestamp=datetime.now(timezone.utc),
|
|
1809
|
+
component_states=component_states,
|
|
1810
|
+
configuration_hash=config_hash,
|
|
1811
|
+
data_checksums=data_checksums,
|
|
1812
|
+
description=description,
|
|
1813
|
+
is_rollback_point=is_rollback_point,
|
|
1814
|
+
)
|
|
1815
|
+
|
|
1816
|
+
self.system_snapshots[snapshot_id] = snapshot
|
|
1817
|
+
self.advanced_recovery_stats["snapshots_created"] += 1
|
|
1818
|
+
|
|
1819
|
+
logger.info(f"Created system snapshot: {snapshot_id}")
|
|
1820
|
+
return snapshot_id
|
|
1821
|
+
|
|
1822
|
+
def get_advanced_system_status(self) -> Dict[str, Any]:
|
|
1823
|
+
"""Get comprehensive advanced system status"""
|
|
1824
|
+
return {
|
|
1825
|
+
"status": "running",
|
|
1826
|
+
"phase3_features": "enabled",
|
|
1827
|
+
"advanced_recovery_statistics": self.advanced_recovery_stats,
|
|
1828
|
+
"active_advanced_failures": len(self.advanced_failures),
|
|
1829
|
+
"pending_advanced_actions": len(
|
|
1830
|
+
[
|
|
1831
|
+
a
|
|
1832
|
+
for a in self.advanced_recovery_actions.values()
|
|
1833
|
+
if a.status in [RecoveryStatus.PENDING, RecoveryStatus.IN_PROGRESS]
|
|
1834
|
+
]
|
|
1835
|
+
),
|
|
1836
|
+
"circuit_breaker_states": dict(self.circuit_breaker_states),
|
|
1837
|
+
"system_snapshots": len(self.system_snapshots),
|
|
1838
|
+
"dead_letter_queue_size": len(self.dead_letter_queue),
|
|
1839
|
+
"failure_mode_analyzers": list(self.failure_analyzers.keys()),
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1211
1842
|
|
|
1212
1843
|
# Global error recovery system instance
|
|
1213
1844
|
_error_recovery_system = None
|