fix: address M2.5 verifier findings before merge
AIMD ceiling now respects per-source max_concurrency and the pacer is assembled explicitly in the client; MIN_CALLS parses as strict int; acceptance doc corrects source-5 attempt count to 549; design and migration notes aligned with implemented 429/stall/suppression semantics and AIMD constants documented.
This commit is contained in:
@@ -119,3 +119,48 @@ class TestAdaptivePacer:
|
||||
assert pacer.admit("s1") is True
|
||||
pacer.leave("s1") # 多余 leave 不下穿 0
|
||||
assert pacer._inflight.get("s1", 0) == 0
|
||||
|
||||
|
||||
class TestPacerAssembly:
|
||||
"""独立核验 I1/M5: ceiling 尊重源级并发;取消路径在途归零。"""
|
||||
|
||||
def test_ceiling_respects_large_source_concurrency(self):
|
||||
from polygateway.client import GatewayClient
|
||||
from polygateway.config import GatewaySettings
|
||||
|
||||
env = {
|
||||
"LLM__QWEN__1__BASE_URL": "https://gw.example/v1",
|
||||
"LLM__QWEN__1__API_KEY": "sk-a",
|
||||
"LLM__QWEN__1__MODEL": "m",
|
||||
"LLM__QWEN__1__TIMEOUT_S": "60",
|
||||
"LLM__QWEN__1__MAX_CONCURRENCY": "128",
|
||||
"LLM_MAX_RETRIES": "3",
|
||||
"LLM_RETRY_BASE_DELAY": "2.0",
|
||||
"LLM_RETRY_MAX_DELAY": "30.0",
|
||||
"LLM_CIRCUIT_BREAKER_THRESHOLD": "5",
|
||||
"LLM_CIRCUIT_BREAKER_COOLDOWN": "60",
|
||||
"PGW_CACHE_BACKEND": "none",
|
||||
"PGW_TELEMETRY_BACKEND": "none",
|
||||
}
|
||||
client = GatewayClient.from_settings(GatewaySettings.from_env("LLM", env=env))
|
||||
assert client._terminal._pacer._ceiling == pytest.approx(128.0)
|
||||
|
||||
def test_min_calls_rejects_float_value(self):
|
||||
from polygateway.config import GatewaySettings
|
||||
|
||||
env = {
|
||||
"LLM__QWEN__1__BASE_URL": "https://gw.example/v1",
|
||||
"LLM__QWEN__1__API_KEY": "sk-a",
|
||||
"LLM__QWEN__1__MODEL": "m",
|
||||
"LLM__QWEN__1__TIMEOUT_S": "60",
|
||||
"LLM_MAX_RETRIES": "3",
|
||||
"LLM_RETRY_BASE_DELAY": "2.0",
|
||||
"LLM_RETRY_MAX_DELAY": "30.0",
|
||||
"LLM_CIRCUIT_BREAKER_THRESHOLD": "5",
|
||||
"LLM_CIRCUIT_BREAKER_COOLDOWN": "60",
|
||||
"LLM__BREAKER__MIN_CALLS": "10.5",
|
||||
"PGW_CACHE_BACKEND": "none",
|
||||
"PGW_TELEMETRY_BACKEND": "none",
|
||||
}
|
||||
with pytest.raises(ValueError, match="MIN_CALLS"):
|
||||
GatewaySettings.from_env("LLM", env=env)
|
||||
|
||||
Reference in New Issue
Block a user