feat: release 2.4.0 with original cases and automatic human review

This commit is contained in:
chenmingxuan committed 2026-10-28 17:25:08 +08:00
1 parent baf069854b
commit 4dc2057d43
66 files changed
+1390 -206

No files matched your search

@@ -99,6 +99,34 @@ def test_usage_flash_runner_counts_as_operator_and_has_no_tuning(tmp_path):
assert usage["run_tuning"] is None
def test_usage_uses_its_recorded_model_and_supports_legacy_endpoint_keys(tmp_path):
db_path = tmp_path / "sessions.db"
repo = SessionRepository(db_path)
_insert_session(db_path, "models", {"profile": "flash"})
_insert_usage(db_path, "models", "new", 1.0, {**_usage(100, 10), "model": "terra"})
_insert_usage(
db_path,
"models",
"legacy",
2.0,
{**_usage(200, 20), "source": "openai:terra:https://example.test:high"},
)
_insert_usage(
db_path, "models", "lens", 3.0, {**_usage(300, 30), "source": "lens:step_capsule:terra"}
)
_insert_usage(db_path, "models", "unknown", 4.0, {**_usage(300, 30), "source": "other"})
_insert_usage(
db_path,
"models",
"fallback",
5.0,
{**_usage(300, 30), "source": "lens:step_capsule:fallback"},
)
models = {item["model"]: item for item in repo.get_session_usage("models")["by_node_model"]}
assert models["terra"]["llm_calls"] == 3
assert models["unknown"]["llm_calls"] == 2
def test_usage_for_unknown_or_empty_session_is_zeroed(tmp_path):
db_path = tmp_path / "sessions.db"
repo = SessionRepository(db_path)
@@ -112,6 +140,26 @@ def test_usage_for_unknown_or_empty_session_is_zeroed(tmp_path):
assert usage["run_tuning"] is None
def test_legacy_usage_preserves_model_colons_and_keeps_models_separate(tmp_path):
db_path = tmp_path / "sessions.db"
repo = SessionRepository(db_path)
_insert_session(db_path, "models", {"profile": "flash"})
sources = {
"team/model:stable": "openai:team/model:stable:https://example.test:8443/v1:high",
"team/model:preview": "openai:team/model:preview:http://[::1]:8080/v1:high",
"unknown": "openai:team/model:preview:unparseable:high",
}
for index, source in enumerate(sources.values()):
_insert_usage(
db_path, "models", str(index), float(index), {**_usage(100, 10), "source": source}
)
groups = {item["model"]: item for item in repo.get_session_usage("models")["by_node_model"]}
assert groups.keys() == sources.keys()
assert all(item["llm_calls"] == 1 for item in groups.values())
assert all(item["prompt_tokens"] == 100 for item in groups.values())
def test_usage_route_is_registered():
from apps.admin_console.routers import sessions