mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-06 00:05:30 +00:00
Root cause: selection failure diagnostics collapsed every persisted model cooldown into a single model_rate_limited counter, so the operator could not tell an upstream 404 model_not_found, a real upstream 429, a plan-gated or temp-unschedulable cooldown, or legacy data apart. The decision log also had no request_id to join the failure with the request. Change: - read the persisted cooldown reason from the account model_rate_limits snapshot through a diagnostics-only helper; selection behavior is unchanged - keep only existing reason values (bounded allowlist), classify structured rule reasons, and bucket empty/unknown reasons as "other" - add per-reason counts to selectionFailureStats and openAISelectionFilterStats - append model_rate_limited_reasons=<reason:count,...> after the legacy summary while keeping the aggregate model_rate_limited=<n> token intact for the no_account_error regex and the existing 429 upgrade - include request_id in the SelectAccountDetailed log line Tests: - breakdown across upstream_404_model_not_found, image 429 cooldown, empty/other, scheduling-threshold JSON and temp-unschedulable JSON - OpenAI load-aware no-account error carries the model cooldown breakdown - legacy summary is byte-identical without a breakdown - handler regex still upgrades the aggregate count to 429 - go build ./... and go test ./internal/service/ pass