feat(dsh): add persistent automatic AI intervention switch
Core regression / Python core and release configuration (push) Successful in 21s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 17s
Core regression / JavaScript syntax (pull_request) Successful in 3s
Core regression / Python core and release configuration (push) Successful in 21s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 17s
Core regression / JavaScript syntax (pull_request) Successful in 3s
This commit is contained in:
1 parent
9316cf4fc4
commit
e28c6d0d6e
12 files changed
+292
-31
No files matched your search
@@ -122,3 +122,128 @@ def test_interrupted_incident_restores_as_pending_without_replay(ui, monkeypatch
|
||||
monkeypatch.setattr(type(window), '_create_dsh_view', lambda self: HarnessView(self))
|
||||
window.dsh_action.trigger()
|
||||
assert window._dsh_view.automation['status'] == 'pending_issue'
|
||||
|
||||
|
||||
def test_auto_intervention_toggle_persists_and_disabled_errors_do_not_enqueue(ui, qtbot):
|
||||
from PySide6.QtCore import QSettings
|
||||
window = ui.window
|
||||
events = []
|
||||
assert window.auto_intervention_check.isChecked()
|
||||
window._dsh_automation = SimpleNamespace(enqueue=lambda *a, **kw: events.append(a),
|
||||
set_enabled=lambda enabled: None)
|
||||
qtbot.mouseClick(window.auto_intervention_check, Qt.MouseButton.LeftButton)
|
||||
window._show_error(TaskCenterError('worker_error', 'disabled error'))
|
||||
assert not events
|
||||
settings = QSettings(str(ui.service.layout_settings_path), QSettings.Format.IniFormat)
|
||||
assert settings.value('dsh/auto_intervention', True, type=bool) is False
|
||||
ui.settle()
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
reopened = TrialTaskCenterWindow(ui.service)
|
||||
qtbot.addWidget(reopened)
|
||||
assert not reopened.auto_intervention_check.isChecked()
|
||||
qtbot.waitUntil(lambda: not reopened._task_query.busy and not reopened._resource_status.busy)
|
||||
reopened.close()
|
||||
|
||||
|
||||
def test_taskless_error_automatically_queues_diagnosis(ui):
|
||||
window = ui.window
|
||||
window._task_id = None
|
||||
window._dsh_run_id = 'previous-cad-run'
|
||||
events = []
|
||||
window._dsh_automation = SimpleNamespace(enqueue=lambda *a, **kw: events.append((a, kw)) or True)
|
||||
window._show_error(TaskCenterError('worker_error', 'taskless error'))
|
||||
assert len(events) == 1
|
||||
assert events[0][0][:2] == ('', 'worker_error')
|
||||
assert events[0][1]['execution_authorized'] is False
|
||||
assert events[0][1]['run_id'] == 'observation'
|
||||
assert window._dsh.history[-1]['snapshot']['task_id'] == ''
|
||||
|
||||
|
||||
def test_native_startup_failure_never_enqueues_itself(ui):
|
||||
events = []
|
||||
ui.window._dsh_automation = SimpleNamespace(enqueue=lambda *a, **kw: events.append(a))
|
||||
ui.window._show_error(TaskCenterError('dsh_startup', 'native unavailable'))
|
||||
assert not events
|
||||
|
||||
|
||||
def test_disabling_clears_pending_without_stopping_original_execution(ui, monkeypatch):
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from dx_productivity.trial_task_center.ui.dsh_automation import DshAutomation
|
||||
monkeypatch.setattr(QApplication, 'platformName', lambda: 'windows')
|
||||
automation = DshAutomation(ui.window)
|
||||
ui.window._dsh_automation = automation
|
||||
from dx_productivity.trial_task_center.stop_control import StopControl
|
||||
original_stop = StopControl()
|
||||
drain = automation._drain
|
||||
monkeypatch.setattr(automation, '_drain', lambda: None)
|
||||
assert automation.enqueue(ui.window._task_id, 'worker_error', 'queued', stop_event=original_stop)
|
||||
retry_permission = automation.execution_enabled
|
||||
ui.window.auto_intervention_check.setChecked(False)
|
||||
assert not automation.pending
|
||||
assert not original_stop.is_set()
|
||||
assert not retry_permission.is_set()
|
||||
drain()
|
||||
assert ui.window._dsh_view is None
|
||||
assert not automation.enqueue('', 'worker_error', 'disabled')
|
||||
ui.window.auto_intervention_check.setChecked(True)
|
||||
assert automation.execution_enabled.is_set()
|
||||
assert not retry_permission.is_set()
|
||||
|
||||
|
||||
def test_duplicate_errors_share_pending_incident_but_new_runs_do_not(ui, monkeypatch):
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from dx_productivity.trial_task_center.ui.dsh_automation import DshAutomation
|
||||
monkeypatch.setattr(QApplication, 'platformName', lambda: 'windows')
|
||||
automation = DshAutomation(ui.window)
|
||||
monkeypatch.setattr(automation, '_drain', lambda: None)
|
||||
for run in ('first', 'first', 'second'):
|
||||
assert automation.enqueue(ui.window._task_id, 'worker_error', 'error', run_id=run)
|
||||
assert len(automation.pending) == 2
|
||||
|
||||
|
||||
def test_diagnosis_completion_refresh_cannot_retrigger_persistent_read_error(ui, monkeypatch):
|
||||
from dx_productivity.trial_task_center.ui.dsh_automation import DshAutomation
|
||||
ui.settle()
|
||||
automation = DshAutomation(ui.window)
|
||||
events = []
|
||||
monkeypatch.setattr(automation, 'enqueue', lambda *a, **kw: events.append(a))
|
||||
monkeypatch.setattr(ui.window, '_dsh_automation', automation)
|
||||
def fail(*a, **kw):
|
||||
raise TaskCenterError('task_read_failed', 'persistent failure')
|
||||
monkeypatch.setattr(ui.service, 'task_context', fail)
|
||||
automation._current_identity = (ui.window._task_id, 'task_read_failed', 'observation')
|
||||
automation.seen.add(automation._current_identity)
|
||||
automation._finished()
|
||||
ui.settle()
|
||||
assert not events
|
||||
assert 'persistent failure' in ui.window.run_panel.operator_band.text()
|
||||
|
||||
|
||||
def test_taskless_incident_actions_allow_outbox_and_evidence_but_reject_other_tasks(ui, monkeypatch):
|
||||
from PySide6.QtGui import QDesktopServices
|
||||
window = ui.window
|
||||
calls = []
|
||||
monkeypatch.setattr(window, '_task_id', None)
|
||||
monkeypatch.setattr(window, '_dsh_view', SimpleNamespace(context={'revision': 'r'}, shutdown=lambda: None))
|
||||
monkeypatch.setattr(window, '_dsh_automation', SimpleNamespace(
|
||||
latest={'task_id': '', 'incident_id': 'a' * 24}, resubmit=lambda value: calls.append(value)))
|
||||
monkeypatch.setattr(QDesktopServices, 'openUrl', lambda url: calls.append(url.toLocalFile()))
|
||||
window._handle_dsh_action({'task_id': '', 'revision': 'r', 'action': 'retry_issue'})
|
||||
window._handle_dsh_action({'task_id': '', 'revision': 'r', 'action': 'open_evidence'})
|
||||
window._handle_dsh_action({'task_id': 'other', 'revision': 'r', 'action': 'retry_issue'})
|
||||
assert len(calls) == 2
|
||||
assert calls[0] == 'a' * 24
|
||||
assert calls[1].endswith('a' * 24)
|
||||
|
||||
|
||||
def test_passive_taskless_refresh_cannot_retrigger_renderer_error(ui, monkeypatch):
|
||||
ui.settle()
|
||||
events = []
|
||||
monkeypatch.setattr(ui.window, '_task_id', None)
|
||||
monkeypatch.setattr(ui.window, '_queue_dsh_incident', lambda *a: events.append(a))
|
||||
def fail(*args):
|
||||
raise TaskCenterError('render_failed', 'persistent render failure')
|
||||
monkeypatch.setattr(ui.window.project_summary, 'populate', fail)
|
||||
ui.window._load_task_data(auto_intervene=False)
|
||||
assert not events
|
||||
assert 'persistent render failure' in ui.window.run_panel.operator_band.text()
|
||||
Reference in new issue
Block a user