irregular6612 commited on
Commit
da16623
·
1 Parent(s): e073c00

test(web): lock finalize SessionNotFinishedError divergence + docstring note (Task 1 follow-up)

Browse files
proteus/runtime/_session_core.py CHANGED
@@ -4,7 +4,10 @@ The per-session logic (build + Cut replay, one-turn TurnTrace construction,
4
  finalize -> scored SessionTrace) lives here so both SessionRunner (agent-driven,
5
  batch) and InteractiveSession (HTTP-driven, stepwise) produce *identical* traces
6
  from the same actions. This is a pure extraction of what used to be inline in
7
- SessionRunner -- no behavior change (pinned by the existing suite).
 
 
 
8
  """
9
  from __future__ import annotations
10
 
 
4
  finalize -> scored SessionTrace) lives here so both SessionRunner (agent-driven,
5
  batch) and InteractiveSession (HTTP-driven, stepwise) produce *identical* traces
6
  from the same actions. This is a pure extraction of what used to be inline in
7
+ SessionRunner -- no behavior change (pinned by the existing suite). The one
8
+ intentional deviation: ``finalize`` raises ``SessionNotFinishedError`` where the
9
+ original used a bare ``assert`` (which vanishes under ``python -O``); the
10
+ terminal condition checked is identical.
11
  """
12
  from __future__ import annotations
13
 
tests/runtime/test_session_core.py CHANGED
@@ -2,6 +2,8 @@
2
  and InteractiveSession)."""
3
  from __future__ import annotations
4
 
 
 
5
  import proteus.grid # noqa: F401 (registers predator_evade)
6
  from proteus.grid.difficulty import Difficulty
7
  from proteus.runtime import _session_core as core
@@ -59,3 +61,17 @@ def test_finalize_produces_scored_trace():
59
  "motive_reading_accuracy", "survival_fraction", "away_move_fraction",
60
  "trajectory_agreement", "final_distance_gap",
61
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  and InteractiveSession)."""
3
  from __future__ import annotations
4
 
5
+ import pytest
6
+
7
  import proteus.grid # noqa: F401 (registers predator_evade)
8
  from proteus.grid.difficulty import Difficulty
9
  from proteus.runtime import _session_core as core
 
61
  "motive_reading_accuracy", "survival_fraction", "away_move_fraction",
62
  "trajectory_agreement", "final_distance_gap",
63
  }
64
+
65
+
66
+ def test_finalize_before_terminal_or_budget_raises():
67
+ # The sole intentional divergence from the original SessionRunner: a
68
+ # non-terminal, under-budget finalize raises (vs the old bare assert).
69
+ built = core.build_session("predator_evade", 42, Difficulty.EASY, 5)
70
+ assert not (built.game.eliminated or built.game.survived)
71
+ with pytest.raises(core.SessionNotFinishedError):
72
+ core.finalize(
73
+ "predator_evade", built.scenario, built.game,
74
+ seed=42, difficulty=Difficulty.EASY, play_turns=5,
75
+ turns=[], cut_frames=built.cut_frames,
76
+ motive_category="survival", model="human",
77
+ )