## Background 多数据源接入本身并不能带来可靠性。如果某个 provider 超时、达到 quota、返回 429/5xx、市场暂不支持或数据暂时缺失,Agent 不应该直接失败,也不能在没有记录的情况下静默切换来源。 需要在统一 financial data gateway 上建立 provider routing / resilience layer。 Related: #22 #24 ## Requirements ### Provider health and failure classification 至少区分: - timeout / network failure; - rate limited / quota exhausted; - auth/config error; - unsupported market/capability; - upstream 5xx; - empty/not-found; - malformed/stale result。 ### Routing / failover - 每种 capability 可以配置 provider preference; - 支持 timeout、bounded retry + backoff; - 支持 circuit breaker / temporary unhealthy state; - 满足明确条件时才 fail over 到备用 provider; - failover 结果必须保留实际 provider 及 fallback reason; - auth/configuration error 不应被无限 retry。 ### Cache - 根据数据类型定义 TTL,而不是全局统一缓存时间; - cache key 必须包含 instrument、provider/canonical semantics、period/adjustment 等必要维度; - stale cache 是否可降级使用必须显式定义,并向上层暴露 `stale`; - 不允许用历史 cache 冒充 live quote。 ## Acceptance Criteria - [ ] provider error 有统一、typed failure model。 - [ ] 429、timeout、5xx、unsupported capability 至少有明确处理策略。 - [ ] 至少两个 provider 可以配置 primary/fallback。 - [ ] fallback 后 provenance 中包含最终 provider 和 fallback reason。 - [ ] retry 有上限,并遵守 #17 的 run budget。 - [ ] cache TTL 能按 quote/fundamental/history 等数据类型区分。 - [ ] stale cache 被使用时 Agent/UI 可感知。 - [ ] 有 provider outage / 429 / timeout 的 integration tests。 - [ ] **必须做一次真实 provider 故障/限流或可控 fault injection,证明主 provider 失败后能正确降级且不会把 stale/备用数据伪装成原始来源。** ## Non-goals - 本 Issue 不决定两个正常 provider 返回不同数值时谁“正确”;该问题单独做 reconciliation。
Activity
louisss1016 commentedon Sep 11, 2026
/claim
github-actions commentedon Sep 11, 2026
@louisss1016 已认领该 Issue,并已自动设为 Assignee。提交 PR 时请在描述中写
Closes #25。feat(providers): 新增 Provider 韧性层:错误分型、有界重试、熔断、分类型 TTL 缓存与故障转移溯源 (hels…
fix(providers): honor provider enablement on cache hits (#274)
fix(providers): isolate calendar caches by query dimensions (#242)