File size: 1,618 Bytes
881f9f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from __future__ import annotations

import json
from pathlib import Path

from scripts import judge_trajectory


def test_existing_score_keys_include_prompt_version_and_legacy_rows(
    tmp_path: Path,
) -> None:
    out = tmp_path / "scenario_scores.jsonl"
    out.write_text(
        json.dumps(
            {
                "run_name": "run-a",
                "scenario_id": "SGT-001",
                "trial_index": 1,
                "judge_model": "watsonx/test",
            }
        )
        + "\n",
        encoding="utf-8",
    )

    keys = judge_trajectory._existing_score_keys(out)

    assert keys == {
        (
            "run-a",
            "SGT-001",
            1,
            "watsonx/test",
            judge_trajectory._JUDGE_PROMPT_VERSION,
        )
    }


def test_score_identity_matches_existing_row_shape(tmp_path: Path) -> None:
    run_dir = tmp_path / "raw" / "run-a"
    run_dir.mkdir(parents=True)
    trajectory = run_dir / "2026-05-03_Y_multi_01_run02.json"
    trajectory.write_text(
        json.dumps({"answer": "ok", "history": []}) + "\n",
        encoding="utf-8",
    )
    scenario = tmp_path / "multi_01.json"
    scenario.write_text(json.dumps({"id": "SGT-001", "text": "prompt"}) + "\n")
    meta = run_dir / "meta.json"
    meta.write_text(json.dumps({"run_name": "run-a"}) + "\n")

    identity = judge_trajectory._score_identity(
        trajectory,
        scenario,
        meta,
        "watsonx/test",
    )

    assert identity == (
        "run-a",
        "SGT-001",
        2,
        "watsonx/test",
        judge_trajectory._JUDGE_PROMPT_VERSION,
    )