feat(pool,trace): 账号封禁原因细分与请求追踪 attempted_only 过滤

- 将账号封禁原因从笼统的"账号异常"细分为封禁/停用/需要验证三类,
  前后端关键词组同步拆分,号池管理页面展示对应分类标签
- trace API 新增 attempted_only 参数,支持仅返回实际尝试过的候选,
  前端时间线组件默认启用过滤,排除 available/unused/skipped 记录
This commit is contained in:
fawney19
2026-03-05 17:32:21 +08:00
parent a7697032a4
commit 694167f78f
8 changed files with 226 additions and 52 deletions

View File

@@ -29,7 +29,7 @@ def test_resolve_from_antigravity_forbidden_metadata() -> None:
assert state.reason == "403"
def test_resolve_from_structured_oauth_reason() -> None:
def test_resolve_from_structured_oauth_reason_verification() -> None:
state = resolve_pool_account_state(
provider_type="codex",
upstream_metadata=None,
@@ -41,15 +41,38 @@ def test_resolve_from_structured_oauth_reason() -> None:
assert state.reason == "Google requires verification"
def test_resolve_from_keyword_oauth_reason() -> None:
def test_resolve_from_structured_oauth_reason_suspended() -> None:
state = resolve_pool_account_state(
provider_type="codex",
upstream_metadata=None,
oauth_invalid_reason="[ACCOUNT_BLOCK] account suspended by admin",
)
assert state.blocked is True
assert state.code == "account_suspended"
assert state.label == "账号封禁"
assert state.reason == "account suspended by admin"
def test_resolve_from_keyword_oauth_reason_disabled() -> None:
state = resolve_pool_account_state(
provider_type=None,
upstream_metadata={},
oauth_invalid_reason="organization has been disabled by admin",
)
assert state.blocked is True
assert state.code == "account_blocked"
assert state.label == "账号异常"
assert state.code == "account_disabled"
assert state.label == "账号停用"
def test_resolve_from_keyword_oauth_reason_verification() -> None:
state = resolve_pool_account_state(
provider_type=None,
upstream_metadata={},
oauth_invalid_reason="validation_required: please verify your identity",
)
assert state.blocked is True
assert state.code == "account_verification"
assert state.label == "需要验证"
def test_resolve_healthy_state() -> None:
@@ -72,21 +95,23 @@ def test_bare_forbidden_not_treated_as_account_block() -> None:
assert state.blocked is False
def test_kiro_oauth_reason_text_detected_as_block() -> None:
def test_kiro_oauth_reason_text_detected_as_suspended() -> None:
state = resolve_pool_account_state(
provider_type="kiro",
upstream_metadata={},
oauth_invalid_reason="账户已封禁: Terms of Service violation",
)
assert state.blocked is True
assert state.code == "account_blocked"
assert state.code == "account_suspended"
assert state.label == "账号封禁"
def test_antigravity_oauth_reason_text_detected_as_block() -> None:
def test_antigravity_oauth_reason_text_detected_as_disabled() -> None:
state = resolve_pool_account_state(
provider_type="antigravity",
upstream_metadata={},
oauth_invalid_reason="账户访问被禁止: 403 Forbidden",
)
assert state.blocked is True
assert state.code == "account_blocked"
assert state.code == "account_disabled"
assert state.label == "账号停用"