irregular6612 Claude Sonnet 4.6 commited on
Commit
fa9db09
·
1 Parent(s): f7209f4

test(discovery): end-to-end errand_runner session emits discovery metric

Browse files
tests/runtime/test_errand_discovery.py CHANGED
@@ -82,3 +82,36 @@ def test_interactive_accepts_interact_for_errand():
82
  s = InteractiveSession("errand_runner", seed=7, play_turns=5, use_default_memory=False)
83
  assert "interact" in s.state()["actions"]
84
  s.step("interact") # must not raise "invalid action"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  s = InteractiveSession("errand_runner", seed=7, play_turns=5, use_default_memory=False)
83
  assert "interact" in s.state()["actions"]
84
  s.step("interact") # must not raise "invalid action"
85
+
86
+
87
+ def test_full_session_runs_and_emits_discovery_metric():
88
+ """End-to-end SessionRunner with a fake provider that always reports the
89
+ correct body index; confirms discovery_turn and discovery_identified are
90
+ emitted on the resulting SessionTrace.metrics."""
91
+ from proteus.providers.fake import FakeProvider # deterministic, no network
92
+ from proteus.game.agents.vanilla import VanillaAgent
93
+ from proteus.game.runtime.session import SessionRunner
94
+
95
+ # Confirm the true_body_index for seed 7 (standalone and runner use same RNG).
96
+ scen = get_scenario("errand_runner")()
97
+ MotiveGridGame(scen, random.Random(7), Difficulty.EASY, max_steps=10)
98
+ true = scen.true_body_index # == 1 for seed 7
99
+
100
+ # FakeProvider.responses repeats last entry once exhausted, so a single
101
+ # response is sufficient for any play_turns count.
102
+ provider = FakeProvider(responses=[f"SELF: {true}\nACTION: stay"])
103
+ agent = VanillaAgent(provider)
104
+ runner = SessionRunner(
105
+ "errand_runner", agent, seed=7, play_turns=4,
106
+ use_probe=False, motive_category="errand",
107
+ )
108
+ trace = runner.run()
109
+
110
+ assert trace.scenario == "errand_runner"
111
+ assert "discovery_turn" in trace.metrics, (
112
+ f"discovery_turn missing from metrics: {trace.metrics}"
113
+ )
114
+ # Every turn reported the correct body index -> identified at turn 1.
115
+ assert trace.metrics["discovery_identified"] == 100.0, (
116
+ f"Expected 100.0 but got {trace.metrics['discovery_identified']}"
117
+ )