File size: 2,267 Bytes
a0c29cf
426093b
a0c29cf
 
 
 
 
93cd78f
a0c29cf
 
 
 
 
 
93cd78f
a0c29cf
 
 
 
 
93cd78f
a0c29cf
 
 
 
0457b55
 
426093b
0457b55
 
 
 
 
93cd78f
0457b55
 
 
 
 
 
 
 
 
 
 
 
 
 
93cd78f
0457b55
 
 
 
 
 
 
 
 
 
 
93cd78f
0457b55
 
 
 
 
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
67
from proteus.cli import main
from proteus.game.runtime.memory import load_checkpoint


def test_memory_subcommand_writes_loadable_checkpoint(tmp_path):
    out = tmp_path / "ck.json"
    rc = main([
        "memory", "--scenario", "template", "--model", "fake:demo",
        "--difficulty", "easy", "--seed", "42", "--memory-turns", "4",
        "--out", str(out),
    ])
    assert rc == 0
    ck = load_checkpoint(out)
    assert ck.model == "demo"
    assert ck.scenario == "template"
    assert 1 <= len(ck.memory_turns) <= 4


def test_memory_subcommand_unknown_model_exits_2(tmp_path, capsys):
    rc = main([
        "memory", "--scenario", "template", "--model", "bogusprovider:x",
        "--difficulty", "easy", "--seed", "42", "--out", str(tmp_path / "c.json"),
    ])
    assert rc == 2
    assert "bogusprovider" in capsys.readouterr().err


from proteus.game.runtime import read_traces


def test_run_memory_generate_sets_memory_ref(tmp_path):
    out = tmp_path / "t.jsonl"
    rc = main([
        "run", "--scenario", "template", "--model", "fake:demo",
        "--difficulty", "easy", "--seed", "42", "--play-turns", "3",
        "--no-probe", "--memory", "generate", "--memory-turns", "4",
        "--memory-root", str(tmp_path / "mem"), "--out", str(out),
    ])
    assert rc == 0
    traces = read_traces(out)
    assert traces[0].memory_ref is not None
    # the turn-1 observation carries the memory block
    assert "MEMORY" in traces[0].turns[0].observation


def test_run_memory_latest_missing_exits_2(tmp_path, capsys):
    out = tmp_path / "t.jsonl"
    rc = main([
        "run", "--scenario", "template", "--model", "fake:demo",
        "--difficulty", "easy", "--seed", "42", "--play-turns", "3",
        "--no-probe", "--memory", "latest",
        "--memory-root", str(tmp_path / "mem"), "--out", str(out),
    ])
    assert rc == 2
    assert "memory" in capsys.readouterr().err.lower()


def test_run_memory_none_is_default(tmp_path):
    out = tmp_path / "t.jsonl"
    rc = main([
        "run", "--scenario", "template", "--model", "fake:demo",
        "--difficulty", "easy", "--seed", "42", "--play-turns", "3",
        "--no-probe", "--out", str(out),
    ])
    assert rc == 0
    assert read_traces(out)[0].memory_ref is None