feat(runtime): implement migration failure recovery — Task 14#19
Merged
simonovic86 merged 1 commit intomainfrom Mar 5, 2026
Merged
feat(runtime): implement migration failure recovery — Task 14#19simonovic86 merged 1 commit intomainfrom
simonovic86 merged 1 commit intomainfrom
Conversation
Add robust migration retry with exponential backoff, fallback to alternative peers, and lease-aware recovery for the FS-2 ambiguous transfer case. Preserves single-instance invariant (EI-1) throughout. Components: - Peer registry with health tracking and candidate selection - Retry policy with error classification (retriable/fatal/ambiguous) - MigrateAgentWithRetry orchestrating retry loop with peer fallback - Lease transitions: RevertHandoff and Recover state machine methods - Lease recovery in tick loop for RECOVERY_REQUIRED auto-recovery - DivergenceMigrate escalation wired to retry-capable migration - Configuration: --migration-retries, --migration-retry-delay flags - Roadmap updated: Tasks 11–14 marked complete Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements robust agent migration with retry, fallback, and lease-aware recovery to handle failures gracefully while preserving the single-instance invariant (EI-1).
Key Components
Migration Retry & Fallback
internal/migration/retry.go: Error classification (retriable, fatal, ambiguous) and exponential backoff calculationMigrateAgentWithRetry: Orchestrates retry loop across multiple candidate peers with fallbackPeer Registry
internal/registry/registry.go: Peer discovery with health tracking, caching prices/capabilities, and candidate filtering by price/capability/healthSelectCandidates: Ordered peer selection for migration fallbackLease State Transitions
RevertHandoff(): HANDOFF_INITIATED → ACTIVE_OWNER when migration fails before transferRecover(): RECOVERY_REQUIRED → ACTIVE_OWNER with fresh epoch (major+1) after detecting unresponsive ownerConfiguration & CLI
--migration-retries: Max retry attempts per target (default: 3)--migration-retry-delay: Initial backoff delay (default: 1s)internal/config/config.go: MigrationMaxRetries, MigrationRetryDelay fields with validationMain Loop Refactoring
handleTick(): Encapsulates lease check, agent tick, and divergence verificationapplyCLIOverrides(): Consolidated CLI flag handlingSupporting Changes
internal/pricing/service.go:ScanPeerPrices()for bulk peer price queries during migration decisionsinternal/p2p/node.go:ConnectedPeers()for discovering migration candidatesSafety Properties
Testing