Skip to content

Add unit tests for recovery-handler module #243

@nikolasdehor

Description

@nikolasdehor

Problem

The recovery-handler.js module (720 lines) in .aios-core/core/orchestration/ has zero test coverage. This module manages automatic error recovery for the orchestration pipeline with multiple recovery strategies.

Solution

Add comprehensive unit tests covering:

  • RecoveryStrategy and RecoveryResult enums — all values verified
  • Error classification — transient (timeout/network), state (corruption), configuration (missing config), dependency (module not found), fatal (OOM/critical), unknown
  • Strategy selection — max retries escalation, circular detection, error-type-based routing, epic criticality, autoEscalate toggle
  • handleEpicFailure — attempt tracking, Error object handling, event emission, recovery result recording
  • Strategy execution — RETRY_SAME_APPROACH, ROLLBACK_AND_RETRY, SKIP_PHASE, ESCALATE_TO_HUMAN, TRIGGER_RECOVERY_WORKFLOW (with/without orchestrator), unknown strategy, error catching
  • Escalation — report generation with epic name, suggestions, event emission
  • Suggestions — per error type (transient, state, config, dependency, unknown)
  • Attempt tracking — getAttemptCount, canRetry, resetAttempts, getAttemptHistory
  • Logging — getLogs, getEpicLogs filtering, orchestrator forwarding
  • Clear — state reset

Test Details

  • 59 tests across 13 describe blocks
  • Mocks: fs-extra
  • All tests passing

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions