feat(failover): reactive failover walker#468
Open
quangdang46 wants to merge 3 commits into
Open
Conversation
Add consolidated PR backlog from 13 reference repos (A-J, ~80 features) and supporting docs (MASTER_GOAL_PROMPT, GOAL_DRIVEN_PROMPT, CONSOLIDATED_FINDINGS).
Adds — a per-session state machine that detects provider errors in-flight, classifies them using the existing error classifier, picks the next available fallback route, and tracks cooldowns/retry counts. Composes three existing pieces: - classify_failover_error_message_structured (error classifier) - pick_next_fallback_route (route selector) - FailoverDecision (action determiner) Test coverage: 11 unit tests covering session lifecycle, cooldowns, equivalence detection, max-attempts, and integration with the existing error-classifier for rate-limit and context-length errors. Refs: docs/pr-plans/A8-failover-walker.md
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 the reactive failover walker for A8 — a per-session state machine that orchestrates automatic provider failover when errors occur mid-stream.
Architecture
Composes three existing pieces:
classify_failover_error_message_structured(failover.rs) — classifies errors intoFailoverDecision+ErrorCodepick_next_fallback_route(fallback_pick.rs) — picks next best route with 3-tier rankingReactiveFailoverWalker(failover_walker.rs) — adds the orchestration layer: per-session tracking, cooldowns, equivalence checks, internally-aborted bookkeepingNew File
crates/jcode-provider-core/src/failover_walker.rs— 536 lines, 11 testsKey types
WalkState— per-session state (original_model, current_model, fallback_index, failed_models with Instant cooldowns, attempt_count)PreparedFallback— result of fallback preparationWalkResult— full walk result (should_failover, new_model, decision, error_code, message)ReactiveFailoverWalker— main structMain methods
walk_failover()— classify error → decide → pick fallback → update state → return resultprepare_fallback()— pick next candidate with max-attempts checkfind_next_available_fallback()— walk chain respecting cooldowns + equivalencerecord_failure/record_success— cooldown managementis_internally_aborted/mark_internally_aborted— for consumer integrationTest coverage
Plan
docs/pr-plans/A8-failover-walker.md
Tracking