chore: snapshot in-progress question-gen work before preflight fixes

This commit is contained in:
2026-07-16 04:12:21 -04:00
parent 11a5545f57
commit a4c429b247
39 changed files with 738 additions and 283 deletions
+48 -15
View File
@@ -1,11 +1,10 @@
"""core/protocols.py 单元测试 — 验证 Protocol 可 runtime_checkable。"""
from __future__ import annotations
from pathlib import Path
from typing import Any
import pytest
from core.protocols import LLMProvider, TelemetryRecorder, VLMProvider
from core.types import LLMResponse
@@ -19,9 +18,17 @@ class _FakeLLM:
parent_call_id: str | None = None,
) -> LLMResponse:
return LLMResponse(
content="ok", thinking="", model="m", provider="p",
prompt_tokens=1, completion_tokens=1, latency_ms=1,
ttft_ms=None, max_inter_token_ms=None, cache_hit=False, call_id="c",
content="ok",
thinking="",
model="m",
provider="p",
prompt_tokens=1,
completion_tokens=1,
latency_ms=1,
ttft_ms=None,
max_inter_token_ms=None,
cache_hit=False,
call_id="c",
)
@@ -35,19 +42,39 @@ class _FakeVLM:
parent_call_id: str | None = None,
) -> LLMResponse:
return LLMResponse(
content="ok", thinking="", model="m", provider="p",
prompt_tokens=1, completion_tokens=1, latency_ms=1,
ttft_ms=None, max_inter_token_ms=None, cache_hit=False, call_id="c",
content="ok",
thinking="",
model="m",
provider="p",
prompt_tokens=1,
completion_tokens=1,
latency_ms=1,
ttft_ms=None,
max_inter_token_ms=None,
cache_hit=False,
call_id="c",
)
class _FakeTelemetry:
async def record_llm_call(
self, *, call_id: str, parent_call_id: str | None, session_id: str | None,
model_name: str, provider: str, messages: str, response: str, thinking: str,
prompt_tokens: int, completion_tokens: int, latency_ms: int,
ttft_ms: float | None, max_inter_token_ms: float | None,
cache_hit: bool, error: str | None,
self,
*,
call_id: str,
parent_call_id: str | None,
session_id: str | None,
model_name: str,
provider: str,
messages: str,
response: str,
thinking: str,
prompt_tokens: int,
completion_tokens: int,
latency_ms: int,
ttft_ms: float | None,
max_inter_token_ms: float | None,
cache_hit: bool,
error: str | None,
) -> None:
pass
@@ -55,12 +82,15 @@ class _FakeTelemetry:
def test_fake_llm_satisfies_protocol() -> None:
assert isinstance(_FakeLLM(), LLMProvider)
def test_fake_vlm_satisfies_protocol() -> None:
assert isinstance(_FakeVLM(), VLMProvider)
def test_fake_telemetry_satisfies_protocol() -> None:
assert isinstance(_FakeTelemetry(), TelemetryRecorder)
def test_plain_object_does_not_satisfy() -> None:
assert not isinstance(object(), LLMProvider)
assert not isinstance(object(), VLMProvider)
@@ -80,8 +110,11 @@ class TestPoolStrategyProtocol:
class FakeStrategy:
def build(self, questions, correctness, config):
return Pools(
diagnosis=[], validation=[], test=[],
baseline_run_id="", baseline_val_accuracy=0.0,
diagnosis=[],
validation=[],
test=[],
baseline_run_id="",
baseline_val_accuracy=0.0,
)
def build_incremental(self, new_task_types, questions, correctness, config):