운영 안정화와 화면 회귀 검증을 반영
Some checks failed
API contract / OpenAPI type drift (push) Failing after 6m2s

This commit is contained in:
Yun Chan 2026-10-20 16:33:48 +09:00
parent 6e3123091a
commit aeddaa6972
69 changed files with 3178 additions and 424 deletions

View file

@ -22,7 +22,7 @@ import sys
import time
from pathlib import Path
from types import ModuleType
from typing import Any
from typing import Any, TypedDict
from uuid import uuid4
@ -43,6 +43,10 @@ class FixtureError(RuntimeError):
pass
class PracticeReadBody(TypedDict):
competency_graph: dict[str, Any] | None
def _load_smoke_helper(filename: str, module_name: str) -> ModuleType:
path = SCRIPTS_DIR / filename
spec = importlib.util.spec_from_file_location(module_name, path)
@ -76,6 +80,14 @@ def _initial_transfer_count(
)
def _prescription_competency_graph(
practice_read: PracticeReadBody,
benchmark_graph: dict[str, Any],
) -> dict[str, Any]:
current_graph = practice_read["competency_graph"]
return benchmark_graph if current_graph is None else current_graph
async def _find_resumable_source(dsn: str) -> dict[str, str] | None:
"""Find the one scratch-only source that already passed session evaluation."""
import asyncpg
@ -228,10 +240,15 @@ def run(args: argparse.Namespace) -> dict[str, Any]:
practice_headers = {
"X-Vignette-Practice-Token": args.practice_internal_token
}
practice_read: PracticeReadBody = client.request(
"GET", "/practice/learners/me"
).body
prescription_submission = {
"submission_id": str(uuid4()),
"coaching_cards": live_case["coaching_cards"],
"competency_graph": live_case["graph"],
"competency_graph": _prescription_competency_graph(
practice_read, live_case["graph"]
),
"evidence_turn_ids": source_turn_ids,
}
prescription_path = (

View file

@ -0,0 +1,86 @@
from __future__ import annotations
import copy
import importlib.util
import sys
import unittest
from pathlib import Path
from types import ModuleType
HARNESS = Path(__file__).with_name("prepare-returned-practice-db.py")
def load_harness() -> ModuleType:
spec = importlib.util.spec_from_file_location(
"prepare_returned_practice_db", HARNESS
)
if spec is None or spec.loader is None:
raise RuntimeError("cannot load returned-practice fixture harness")
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
return module
harness = load_harness()
class PrescriptionCompetencyGraphTest(unittest.TestCase):
def test_current_graph_is_preserved_without_mutating_inputs(self) -> None:
benchmark_graph = {
"graph_version": 1,
"states": [{"competency_id": "benchmark", "score": 0.2}],
}
current_graph = {
"graph_version": 7,
"states": [
{
"competency_id": "competency.empathic_attunement",
"score": 0.84,
"evidence": {"episode_ids": ["episode-7"]},
}
],
}
practice_read = {"competency_graph": current_graph}
benchmark_before = copy.deepcopy(benchmark_graph)
read_before = copy.deepcopy(practice_read)
selected = harness._prescription_competency_graph(
practice_read, benchmark_graph
)
self.assertIs(selected, current_graph)
self.assertIs(selected["states"][0], current_graph["states"][0])
self.assertEqual(benchmark_graph, benchmark_before)
self.assertEqual(practice_read, read_before)
def test_none_graph_uses_initial_benchmark_seed(self) -> None:
benchmark_graph = {"graph_version": 1, "states": []}
selected = harness._prescription_competency_graph(
{"competency_graph": None}, benchmark_graph
)
self.assertIs(selected, benchmark_graph)
def test_invalid_graph_is_not_silently_replaced_with_seed(self) -> None:
benchmark_graph = {"graph_version": 1, "states": []}
invalid_graph = {"graph_version": "invalid", "states": "invalid"}
selected = harness._prescription_competency_graph(
{"competency_graph": invalid_graph}, benchmark_graph
)
self.assertIs(selected, invalid_graph)
self.assertIsNot(selected, benchmark_graph)
def test_missing_graph_is_not_silently_replaced_with_seed(self) -> None:
with self.assertRaises(KeyError):
harness._prescription_competency_graph(
{}, {"graph_version": 1, "states": []}
)
if __name__ == "__main__":
unittest.main()