fix(dsh): resolve follow-up UI and shared diagnosis budget review
Core regression / Python 3.12 core, intervention UI and release configuration (push) Failing after 21s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python 3.12 core, intervention UI and release configuration (pull_request) Failing after 21s
Core regression / JavaScript syntax (pull_request) Successful in 3s
Core regression / Python 3.12 core, intervention UI and release configuration (push) Failing after 21s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python 3.12 core, intervention UI and release configuration (pull_request) Failing after 21s
Core regression / JavaScript syntax (pull_request) Successful in 3s
This commit is contained in:
1 parent
775bc23dc3
commit
5ce3f827f0
11 files changed
+204
-20
No files matched your search
@@ -83,6 +83,24 @@ def test_readonly_diagnosis_does_not_prevent_window_close(slow_diagnosis, qtbot)
|
||||
assert not published
|
||||
|
||||
|
||||
@pytest.mark.parametrize('reason', ['unsaved', 'saving'])
|
||||
def test_cancelled_close_confirmation_keeps_diagnosis_running(slow_diagnosis, qtbot, monkeypatch, ui, reason):
|
||||
window, automation, _, start = slow_diagnosis
|
||||
start()
|
||||
if reason == 'unsaved':
|
||||
monkeypatch.setattr(window.plan_panel, 'has_unsaved_plans', lambda: True)
|
||||
monkeypatch.setattr(window, '_close_plan_confirmer', lambda: 'cancel')
|
||||
else:
|
||||
window._close_saving = True
|
||||
window.close()
|
||||
assert not window._closed
|
||||
assert not automation.cancel_event.is_set()
|
||||
window._close_saving = False
|
||||
automation.cancel()
|
||||
qtbot.waitUntil(lambda: automation.worker is None, timeout=5000)
|
||||
ui.settle()
|
||||
|
||||
|
||||
def test_resource_diagnosis_has_no_cad_pause_or_force_controls(slow_diagnosis, qtbot, ui):
|
||||
window, automation, published, start = slow_diagnosis
|
||||
view = start(read_only=False, cleanup=True)
|
||||
@@ -115,6 +133,50 @@ def test_model_wait_is_limited_by_remaining_total_budget(slow_diagnosis, monkeyp
|
||||
ui.settle()
|
||||
|
||||
|
||||
def test_model_budget_starts_when_harness_session_is_ready(slow_diagnosis, monkeypatch):
|
||||
_, automation, _, _ = slow_diagnosis
|
||||
complete = module.Event()
|
||||
automation.waiters['request'] = (complete, {})
|
||||
monkeypatch.setattr(module, 'monotonic', lambda: 100.0)
|
||||
automation._analysis_deadline = None
|
||||
automation._diagnosis_event({'request_id': 'request', 'status': 'started', 'session_id': 'session'})
|
||||
assert automation._analysis_deadline == 100.0 + automation._diagnosis_budget_seconds()
|
||||
|
||||
|
||||
def test_cold_session_wait_does_not_consume_shared_model_budget(slow_diagnosis, monkeypatch, ui):
|
||||
window, automation, _, _ = slow_diagnosis
|
||||
window._open_dsh()
|
||||
clock, waits = [100.0], []
|
||||
|
||||
class ControlledEvent:
|
||||
def __init__(self):
|
||||
self.set_flag = False
|
||||
|
||||
def set(self):
|
||||
self.set_flag = True
|
||||
|
||||
def wait(self, timeout):
|
||||
waits.append(timeout)
|
||||
if timeout == 300:
|
||||
clock[0] += 75 # Controlled cold session creation.
|
||||
request_id = next(iter(automation.waiters))
|
||||
automation._diagnosis_event({'request_id': request_id, 'status': 'started', 'session_id': 'session'})
|
||||
automation._diagnosis_event({'request_id': request_id, 'status': 'completed', 'reply': '{"action":"none"}'})
|
||||
return self.set_flag
|
||||
|
||||
monkeypatch.setattr(module, 'Event', ControlledEvent)
|
||||
monkeypatch.setattr(module, 'monotonic', lambda: clock[0])
|
||||
result = automation._analyze('a' * 24, {'task_id': ''}, 'evidence', 'diagnose')
|
||||
assert waits == [300, 180]
|
||||
assert '_ready' not in result
|
||||
clock[0] += 40
|
||||
with pytest.raises(TimeoutError):
|
||||
automation._analyze('a' * 24, {'task_id': ''}, 'evidence', 'reflect')
|
||||
assert waits[-1] == 140
|
||||
assert window._dsh_view.requests[-1]['model_budget_ms'] == 140000
|
||||
ui.settle()
|
||||
|
||||
|
||||
def test_native_cancel_removes_queued_request_and_sends_only_target_id():
|
||||
from dx_productivity.trial_task_center.ui.dsh_native import NativeHarnessView
|
||||
sent = []
|
||||
@@ -139,3 +201,14 @@ def test_completed_incident_removes_embedded_cancel_action(slow_diagnosis, qtbot
|
||||
assert window._dsh_view.automation['can_cancel'] is False
|
||||
assert not window.cancel_diagnosis_button.isVisible()
|
||||
ui.settle()
|
||||
|
||||
|
||||
def test_optional_automation_without_cancel_api_keeps_gates_and_close_usable(ui, monkeypatch, qtbot):
|
||||
ui.settle()
|
||||
window = ui.window
|
||||
monkeypatch.setattr(window, '_dsh_automation', SimpleNamespace(enqueue=lambda *a, **kw: True))
|
||||
window._update_gates()
|
||||
assert not window.cancel_diagnosis_button.isVisible()
|
||||
window._cancel_dsh_diagnosis()
|
||||
window.close()
|
||||
qtbot.waitUntil(lambda: window._closed)
|
||||
@@ -137,7 +137,8 @@ def test_worker_exception_handoff_keeps_original_run_control(ui,qtbot,monkeypatc
|
||||
from dx_productivity.trial_task_center.errors import TaskCenterError
|
||||
window=ui.window;task_id=window._task_id
|
||||
captured=[]
|
||||
window._dsh_automation=SimpleNamespace(enqueue=lambda *args,**kwargs:captured.append(kwargs)or True)
|
||||
window._dsh_automation=SimpleNamespace(can_cancel=False,cancel=lambda:None,
|
||||
enqueue=lambda *args,**kwargs:captured.append(kwargs)or True)
|
||||
window._dsh_authorized_tasks.add(task_id)
|
||||
window._begin_run(task_id)
|
||||
control=window._batch_stop;run_id=window._dsh_run_id
|
||||
|
||||
Reference in new issue
Block a user