fix: resume orphan cleanup after a startup prompt

This commit is contained in:
阿白叔 committed 2026-11-25 14:44:06 +08:00
1 parent 33a41b25fb
commit 4e7efe4f41
2 files changed
+33 -13

No files matched your search

+14 -3
View File
@@ -179,7 +179,7 @@ def test_cancelled_prewrite_can_dismiss_exact_late_load_failure(qtbot, tmp_path,
assert (root/'result.json').read_bytes() == original
@pytest.mark.parametrize('obstacle', [None, 'tip', 'cancelled_tip', 'previously_dismissed_tip',
@pytest.mark.parametrize('obstacle', [None, 'tip', 'slow_tip', 'cancelled_tip', 'previously_dismissed_tip',
'read_write', 'unknown_prompt', 'save',
'uncertain_phase', 'live_supervisor', 'live_worker',
'wrong_pcb', 'possible_write', 'loaded', 'unproved_loaded'])
@@ -249,7 +249,7 @@ def test_restarted_verify_closes_exact_prewrite_orphan(tmp_path, monkeypatch, ob
monkeypatch.setattr(residual_sessions, '_recorded_process_exited',
lambda identity: obstacle != 'live_supervisor' and identity == supervisor)
if obstacle in ('tip', 'cancelled_tip', 'previously_dismissed_tip', 'read_write', 'unknown_prompt'):
if obstacle in ('tip', 'slow_tip', 'cancelled_tip', 'previously_dismissed_tip', 'read_write', 'unknown_prompt'):
frame = windows[0]
frame['enabled'] = False
windows.append(dict(hwnd=200, title='Tip of the Day' if obstacle.endswith('tip') else 'Expedition PCB',
@@ -261,7 +261,7 @@ def test_restarted_verify_closes_exact_prewrite_orphan(tmp_path, monkeypatch, ob
state['posts'].append((hwnd, pid, message))
if hwnd == 201:
windows.pop()
frame['enabled'] = True
frame['enabled'] = obstacle != 'slow_tip'
else:
state['native_alive'] = False
@@ -276,8 +276,19 @@ def test_restarted_verify_closes_exact_prewrite_orphan(tmp_path, monkeypatch, ob
monkeypatch.setattr(failed_session, '_tip_target', lambda _: SimpleNamespace(handle=201))
monkeypatch.setattr(failed_session, '_cancel_target', lambda _: ('read_write_access',
SimpleNamespace(handle=201)) if obstacle == 'read_write' else None)
if obstacle == 'slow_tip':
ticks = iter([0., 6., 7., 8., 9.])
monkeypatch.setattr(residual_sessions, 'time', SimpleNamespace(monotonic=lambda: next(ticks)))
recovered = residual_sessions.finish_owned_idle_session(path)
if obstacle == 'slow_tip':
assert recovered and state['posts'] == [(201, 12, 245)]
journal = session_record.read_session_record(path, evidence_root=root)
assert journal['owned_startup_prompt'] == 200 and 'owned_idle_cleanup' not in journal
frame['enabled'] = True
assert residual_sessions.finish_owned_idle_session(path)
assert state['posts'] == [(201, 12, 245), (100, 12, 16)]
return
assert recovered is (obstacle in (None, 'tip', 'cancelled_tip', 'read_write', 'loaded'))
expected_posts = [(201, 12, 245)] if obstacle in ('tip', 'cancelled_tip', 'read_write') else []
if recovered: