Error Handling and Recovery Procedures
How errors are handled
Error Handling and Recovery Procedures
General Error Handling Principles
When Errors Occur
- Identify the error: Clearly state what went wrong
- Assess impact: Determine if the error is blocking or can be worked around
- Communicate: Inform the user about the error and options
- Offer solutions: Provide clear steps to resolve or work around the error
- Document: Log the error and resolution in
audit.md
Error Severity Levels
Critical: Workflow cannot continue
- Missing required files or artifacts
- Invalid user input that cannot be processed
- System errors preventing file operations
High: Phase cannot complete as planned
- Incomplete answers to required questions
- Contradictory user responses
- Missing dependencies from prior phases
Medium: Phase can continue with workarounds
- Optional artifacts missing
- Non-critical validation failures
- Partial completion possible
Low: Minor issues that don't block progress
- Formatting inconsistencies
- Optional information missing
- Non-blocking warnings
Phase-Specific Error Handling
Context Assessment Errors
Error: Cannot read workspace files
- Cause: Permission issues, missing directories
- Solution: Ask user to verify workspace path and permissions
- Workaround: Proceed with user-provided information only
Error: Existing aidlc-state.md is corrupted
- Cause: Manual editing, incomplete previous run
- Solution: Ask user if they want to start fresh or attempt recovery
- Recovery: Create backup, start new state file
Error: Cannot determine required phases
- Cause: Insufficient information from user
- Solution: Ask clarifying questions about intent and scope
- Workaround: Default to comprehensive execution plan
Requirements Assessment Errors
Error: User provides contradictory requirements
- Cause: Unclear understanding, changing needs
- Solution: Create follow-up questions to resolve contradictions
- Do Not Proceed: Until contradictions are resolved
Error: Requirements document cannot be converted
- Cause: Unsupported format, corrupted file
- Solution: Ask user to provide requirements in supported format
- Workaround: Work with user's verbal description
Error: Incomplete answers to verification questions
- Cause: User skipped questions, unclear what to answer
- Solution: Highlight unanswered questions, provide examples
- Do Not Proceed: Until all required questions are answered
Story Development Errors
Error: Cannot map requirements to stories
- Cause: Requirements too vague, missing functional details
- Solution: Return to Requirements Assessment for clarification
- Workaround: Create stories based on available information, mark as incomplete
Error: User provides ambiguous story planning answers
- Cause: Unclear options, complex decision
- Solution: Add follow-up questions with specific examples
- Do Not Proceed: Until ambiguities are resolved
Error: Story generation plan has uncompleted steps
- Cause: Execution interrupted, steps skipped
- Solution: Resume from first uncompleted step
- Recovery: Review completed steps, continue from checkpoint
Application Design Errors
Error: Architectural decision is unclear or contradictory
- Cause: Ambiguous answers, conflicting requirements
- Solution: Add follow-up questions to clarify decision
- Do Not Proceed: Until decision is clear and documented
Error: Cannot determine number of services/units
- Cause: Insufficient information about boundaries
- Solution: Ask specific questions about deployment, team structure, scaling
- Workaround: Default to monolith, allow change later
Design Errors
Error: Unit dependencies are circular
- Cause: Poor boundary definition, tight coupling
- Solution: Identify circular dependencies, suggest refactoring
- Recovery: Revise unit boundaries to break cycles
Error: Unit design plan has missing steps
- Cause: Plan generation incomplete, template error
- Solution: Regenerate plan with all required steps
- Recovery: Add missing steps to existing plan
Error: Cannot generate design artifacts
- Cause: Missing unit information, unclear requirements
- Solution: Return to Units Planning to clarify unit definition
- Workaround: Generate partial design, mark gaps
NFR Implementation Errors
Error: Technology stack choices are incompatible
- Cause: Conflicting requirements, platform limitations
- Solution: Highlight incompatibilities, ask user to choose
- Do Not Proceed: Until compatible choices are made
Error: Organizational constraints cannot be met
- Cause: Network restrictions, security policies
- Solution: Document constraints, ask user for workarounds
- Escalation: May require human intervention for setup
Error: NFR implementation step requires human action
- Cause: AI cannot perform certain tasks (network config, credentials)
- Solution: Clearly mark as HUMAN TASK, provide instructions
- Wait: For user confirmation before proceeding
Code Planning Errors
Error: Code generation plan is incomplete
- Cause: Missing design artifacts, unclear requirements
- Solution: Return to Design phase to complete artifacts
- Recovery: Generate plan with available information, mark gaps
Error: Unit dependencies not satisfied
- Cause: Dependent units not yet generated
- Solution: Reorder generation sequence to respect dependencies
- Workaround: Generate with stub dependencies, integrate later
Code Generation Errors
Error: Cannot generate code for a step
- Cause: Insufficient design information, unclear requirements
- Solution: Skip step, document as incomplete, continue
- Recovery: Return to step after gathering more information
Error: Generated code has syntax errors
- Cause: Template issues, language-specific problems
- Solution: Fix syntax errors, regenerate if needed
- Validation: Verify code compiles before proceeding
Error: Test generation fails
- Cause: Complex logic, missing test framework setup
- Solution: Generate basic test structure, mark for manual completion
- Workaround: Proceed without tests, add in Operations phase
Operations Errors
Error: Cannot determine build tool
- Cause: Unusual project structure, multiple build systems
- Solution: Ask user to specify build tool and commands
- Workaround: Provide generic instructions, user adapts
Error: Deployment target is unclear
- Cause: Multiple environments, complex infrastructure
- Solution: Ask user to specify deployment targets and methods
- Workaround: Provide instructions for common platforms
Recovery Procedures
Partial Phase Completion
Scenario: Phase was interrupted mid-execution
Recovery Steps:
- Load the phase plan file
- Identify last completed step (last [x] checkbox)
- Resume from next uncompleted step
- Verify all prior steps are actually complete
- Continue execution normally
Corrupted State File
Scenario: aidlc-state.md is corrupted or inconsistent
Recovery Steps:
- Create backup:
aidlc-state.md.backup - Ask user which phase they're actually on
- Regenerate state file from scratch
- Mark completed phases based on existing artifacts
- Resume from current phase
Missing Artifacts
Scenario: Required artifacts from prior phase are missing
Recovery Steps:
- Identify which artifacts are missing
- Determine if they can be regenerated
- If yes: Return to that phase, regenerate artifacts
- If no: Ask user to provide information manually
- Document the gap in
audit.md
User Wants to Restart Phase
Scenario: User is unhappy with phase results and wants to redo
Recovery Steps:
- Confirm user wants to restart (data will be lost)
- Archive existing artifacts:
{artifact}.backup - Reset phase status in
aidlc-state.md - Clear phase checkboxes in plan files
- Re-execute phase from beginning
User Wants to Skip Phase
Scenario: User wants to skip a phase that was planned
Recovery Steps:
- Confirm user understands implications
- Document skip reason in
audit.md - Mark phase as "SKIPPED" in
aidlc-state.md - Proceed to next phase
- Note: May cause issues in later phases if dependencies missing
Escalation Guidelines
When to Ask for User Help
Immediately:
- Contradictory or ambiguous user input
- Missing required information
- Technical constraints AI cannot resolve
- Decisions requiring business judgment
After Attempting Resolution:
- Repeated errors in same step
- Complex technical issues
- Unusual project structures
- Integration with external systems
When to Suggest Starting Over
Consider Fresh Start If:
- Multiple phases have errors
- State file is severely corrupted
- User requirements have changed significantly
- Architectural decision needs to be reversed
- User cannot provide missing information
- Artifacts are inconsistent across phases
Before Starting Over:
- Archive all existing work
- Document lessons learned
- Identify what to preserve
- Get user confirmation
- Create new execution plan
Session Resumption Errors
Missing Artifacts During Resumption
Error: Required artifacts from previous stages are missing
- Cause: Files deleted, moved, or never created
- Solution:
- Identify which stage created the missing artifacts
- Check if stage was marked complete in aidlc-state.md
- If marked complete but artifacts missing: Regenerate that stage
- If not marked complete: Resume from that stage
- Recovery: Return to the stage that creates missing artifacts and re-execute
Error: Artifact file exists but is empty or corrupted
- Cause: Interrupted write, manual editing, file system issues
- Solution:
- Create backup of corrupted file
- Attempt to regenerate from stage that creates it
- If cannot regenerate: Ask user for information to recreate
- Recovery: Re-execute the stage that creates the artifact
Inconsistent State During Resumption
Error: aidlc-state.md shows stage complete but artifacts don't exist
- Cause: State file updated but artifact generation failed
- Solution:
- Mark stage as incomplete in aidlc-state.md
- Re-execute the stage to generate artifacts
- Verify artifacts exist before marking complete
- Recovery: Reset stage status and re-execute
Error: Artifacts exist but aidlc-state.md shows stage incomplete
- Cause: Artifact generation succeeded but state update failed
- Solution:
- Verify artifacts are complete and valid
- Update aidlc-state.md to mark stage complete
- Proceed to next stage
- Recovery: Update state file to reflect actual completion
Error: Multiple stages marked as "current" in aidlc-state.md
- Cause: State file corruption, manual editing
- Solution:
- Review artifacts to determine actual progress
- Ask user which stage they're actually on
- Correct aidlc-state.md to show single current stage
- Recovery: Rebuild state file based on existing artifacts
Context Loading Errors
Error: Cannot load required context from previous stages
- Cause: Missing files, corrupted content, wrong file paths
- Solution:
- List which artifacts are needed for current stage
- Check which ones are missing or corrupted
- Regenerate missing artifacts or ask user for information
- Recovery: Complete prerequisite stages before resuming current stage
Error: Loaded artifacts contain contradictory information
- Cause: Manual editing, multiple people working, incomplete updates
- Solution:
- Identify contradictions and present to user
- Ask user which information is correct
- Update artifacts to resolve contradictions
- Recovery: Reconcile contradictions before proceeding
Resumption Best Practices
- Always validate state: Check aidlc-state.md matches actual artifacts
- Load incrementally: Load artifacts stage-by-stage, validate each
- Fail fast: Stop immediately if critical artifacts are missing
- Communicate clearly: Tell user exactly what's missing and why it's needed
- Offer options: Regenerate, provide manually, or start fresh
- Document recovery: Log all recovery actions in audit.md
Logging Requirements
Error Logging Format
## Error - [Phase Name]
**Timestamp**: [ISO timestamp]
**Error Type**: [Critical/High/Medium/Low]
**Description**: [What went wrong]
**Cause**: [Why it happened]
**Resolution**: [How it was resolved]
**Impact**: [Effect on workflow]
---
Recovery Logging Format
## Recovery - [Phase Name]
**Timestamp**: [ISO timestamp]
**Issue**: [What needed recovery]
**Recovery Steps**: [What was done]
**Outcome**: [Result of recovery]
**Artifacts Affected**: [List of files]
---
Prevention Best Practices
- Validate Early: Check inputs and dependencies before starting work
- Checkpoint Often: Update checkboxes immediately after completing steps
- Communicate Clearly: Explain what you're doing and why
- Ask Questions: Don't assume - clarify ambiguities immediately
- Document Everything: Log all decisions and changes in
audit.md