Files
hermes-agent/tests
teknium1 d36ac6e61a test(tui_gateway): join the rewind turn thread instead of forcing running=False
test_prompt_submit_consecutive_rewinds_with_returned_survivor_row_ids[False]
flaked in CI with `assert 3 == 2`. The in-process path starts a real turn
(dispatch thread -> prompt-turn-* worker); the test cleared sess["running"]
by hand while turn 1's worker could still be alive, an overlap production's
running gate never allows. On a slow runner that worker reached
_adopt_out_of_band_turns inside rewind 2's _persist_submit_user_row window
(row 8 written, _submit_user_row popped but not yet re-staged), read
ceiling=None, and appended rewind 2's own user row to history as a
"foreign" turn. The leaked workers also produced the post-teardown
"state.db connection ... closed while a read was still in flight" warnings.

Repro: delay turn 1 0.3s before _wait_agent_for_prompt and rewind 2's
persist 3s between the DB write and staging -> base fails 12/12, fixed
passes 12/12. Fix: _join_turn_thread() follows _run_thread from the
dispatch thread to the worker and joins it after each rewind.
2026-09-26 11:17:12 -07:00
..