merge(main): resolve PR19 review conflicts and run intervention regressions in CI
Core regression / Python core, intervention UI and release configuration (push) Failing after 2m42s
Core regression / JavaScript syntax (push) Successful in 6s
Core regression / Python core, intervention UI and release configuration (pull_request) Canceled after 1m17s
Core regression / JavaScript syntax (pull_request) Canceled after 0s

This commit is contained in:
阿白叔 committed 2026-11-09 11:35:29 +08:00
commit f8f07d30d2
127 files changed
+9390 -386

No files matched your search

+1
View File
@@ -78,6 +78,7 @@ def test_native_only_credential_store_is_checked_without_profile_patch(tmp_path,
assert availability.check_availability(tmp_path)['source'] == 'native'
@pytest.mark.skipif(sys.platform != 'win32', reason='Windows DPAPI credential protection')
def test_dpapi_host_configuration_is_available_without_writes(tmp_path):
from dx_productivity.dsh.provider_config import save_provider
directory = tmp_path / 'dsh'
+93
View File
@@ -71,3 +71,96 @@ def test_cleanup_rejected_admission_does_not_release_resources(tmp_path):
assert not service.calls
assert result['cleanup_attempts'] == 0
assert result['status'] != 'resolved'
def test_rejected_admission_does_not_mutate_or_spend_budget(tmp_path):
@contextmanager
def scope(_action):
raise ValueError('execution_lane_changed')
yield
service = Service()
runner = make_runner(tmp_path, service)
runner.action_scope = scope
result = runner.run('t', 'worker_error', 'failure', execution_authorized=True)
assert service.calls == []
assert result['attempts'] == 0
assert not list(tmp_path.glob('dsh/retry-budget/*.json'))
def test_model_wait_changed_context_cannot_retry(tmp_path):
service = Service()
def model(*_args):
service.progress.saved_items += 1
return analyze()
result = make_runner(tmp_path, service, model).run('t', 'worker_error', 'failure', execution_authorized=True)
assert not service.calls
assert result['attempts'] == 0
assert not list(tmp_path.glob('dsh/retry-budget/*.json'))
def test_retry_scope_released_before_reflection_and_publication(tmp_path):
active, phases = [], []
@contextmanager
def scope(action):
active.append(action)
try:
yield
finally:
active.pop()
service = Service(fixed=False)
execute = service.execute_quick_run_queue
def scoped_execute(*args, **kwargs):
assert active == ['retry_failed']
return execute(*args, **kwargs)
service.execute_quick_run_queue = scoped_execute
def model(*args):
assert not active
phases.append(args[-1])
return analyze()
def publish(*_args):
assert not active
return {'status': 'unavailable'}
runner = make_runner(tmp_path, service, model, publish)
runner.action_scope = scope
runner.run('t', 'worker_error', 'failure', execution_authorized=True)
assert phases == ['diagnose', 'reflect']
assert service.calls == ['prepare', 'execute']
assert not active
def test_cancellation_during_model_wait_retains_evidence_without_publication(tmp_path):
from threading import Event
cancelled = Event()
def model(*_args):
cancelled.set()
return analyze()
service, published = Service(), []
runner = make_runner(tmp_path, service, model, lambda *_args: published.append(True))
result = runner.run('t', 'worker_error', 'failure', execution_authorized=True, cancel_event=cancelled)
assert not service.calls and not published
assert result['status'] == 'cancelled'
assert (tmp_path / 'dsh/incidents' / result['incident_id'] / 'incident.json').is_file()
def test_shared_retry_reservation_denial_never_uses_legacy_budget(tmp_path):
service = Service()
service.reserve_problem_retry = lambda *args, **kwargs: ()
result = make_runner(tmp_path, service).run('t', 'worker_error', 'failure', execution_authorized=True)
assert not service.calls
assert result['attempts'] == 0
assert result['gates']['retry_budget_available'] is False
assert not list(tmp_path.glob('dsh/retry-budget/*.json'))
def test_shared_reservation_limits_preparation_to_reserved_operation_keys(tmp_path):
service, reserved, prepared_keys = Service(), ('uid-operation',), []
service.reserve_problem_retry = lambda *args, **kwargs: reserved
prepare = service.prepare_failed_quick_run
def prepare_reserved(task_id, *, operation_keys=None):
prepared_keys.append(operation_keys)
prepare(task_id)
service.prepare_failed_quick_run = prepare_reserved
result = make_runner(tmp_path, service).run('t', 'worker_error', 'failure', execution_authorized=True)
assert prepared_keys == [reserved]
assert result['status'] == 'resolved'
assert not list(tmp_path.glob('dsh/retry-budget/*.json'))
+2
View File
@@ -1,4 +1,5 @@
import json
import sys
import pytest
from dx_productivity.dsh.native_runtime import launch_environment, write_context
from dx_productivity.dsh.snapshot import TaskSnapshot
@@ -48,6 +49,7 @@ def test_invalid_native_credential_reference_does_not_expand_environment_allowli
assert 'FIXTURE_UNRELATED_API_KEY' not in env
@pytest.mark.skipif(sys.platform != 'win32', reason='Windows file sharing lock')
def test_context_publication_survives_a_real_windows_reader_lock(tmp_path):
import ctypes
from ctypes import wintypes
+60
View File
@@ -81,6 +81,66 @@ def test_failed_queue_receipt_does_not_claim_success(project_service):
assert journal.finish('a' * 32, result)['status'] == 'failed'
def test_inspect_accepts_frozen_workspace_checkpoint(project_service):
service, _, data, ids, hashes = project_service
journal = RunJournal(data)
journal.begin('b' * 32, ids, hashes)
path = data / 'workspace-queues' / ('b' * 32 + '.json')
path.parent.mkdir(parents=True)
path.write_text(json.dumps({'version': 1, 'task_ids': ids, 'plan_hashes': hashes,
'phase': 'primary', 'entries': {key: {'state': 'pending', 'message': '',
'released': False, 'problems_done': False, 'checkpoint_id': str(index) * 32}
for index, key in enumerate(ids, 1)}}))
result = journal.inspect(service, 'b' * 32)
assert result['queue_available'] and result['resume_ready']
assert result['remaining_task_ids'] == ids
@pytest.mark.parametrize('isolated', [True, False])
def test_released_isolated_project_does_not_block_resume_of_other_projects(project_service, isolated):
from dx_productivity.dsh.run_journal import resume_preflight
service, _, data, ids, hashes = project_service
journal = RunJournal(data)
journal.begin('d' * 32, ids, hashes)
evidence(service, ids[0], state='batch_saved_unverified' if isolated else 'batch_failed')
entries = {key: {'state': ('blocked' if isolated else 'failed') if index == 0 else 'pending', 'message': 'problem' if index == 0 else '',
'released': index == 0, 'problems_done': False, 'checkpoint_id': str(index + 1) * 32}
for index, key in enumerate(ids)}
entries[ids[0]]['supervisor_batch_id'] = 'e' * 32
path = data / 'workspace-queues' / ('d' * 32 + '.json')
path.parent.mkdir(parents=True)
path.write_text(json.dumps({'version': 1, 'task_ids': ids, 'plan_hashes': hashes,
'phase': 'primary' if isolated else 'problems', 'entries': entries}))
result = journal.inspect(service, 'd' * 32)
assert result['queue_available'] and result['resume_ready'], result['blockers']
assert result['remaining_task_ids'] == (ids[1:] if isolated else ids)
assert result['isolated_task_ids'] == ([ids[0]] if isolated else [])
assert result['tasks'][0]['interrupted'] == isolated
report = resume_preflight(service, result)
assert report['ready']
assert report['tasks'][0]['isolated'] == isolated
def test_unpaused_blocked_project_is_not_a_completed_run(project_service):
_, _, data, ids, hashes = project_service
journal = RunJournal(data)
journal.begin('b' * 32, ids, hashes)
result = TaskQueueResult('b' * 32, (TaskQueueEntry(ids[0], 'blocked'),), False)
assert journal.finish('b' * 32, result)['status'] == 'blocked'
def test_confirmed_run_reports_isolated_blocked_project_as_issue(project_service, monkeypatch):
from threading import Event
from dx_productivity.dsh.execution_runs import execute_confirmed_run
from dx_productivity.dsh.task_lifecycle import preflight
service, _, data, ids, _ = project_service
monkeypatch.setattr('dx_productivity.dsh.execution_runs.execute_task_queue', lambda *_args, **_kwargs:
TaskQueueResult('c' * 32, tuple(TaskQueueEntry(task_id, 'blocked' if index == 0 else 'completed')
for index, task_id in enumerate(ids)), False))
result = execute_confirmed_run(service, data, ids, preflight(service, ids), Event(), 'c' * 32)
assert result['status'] == 'blocked'
def test_native_confirmed_resume_marks_running_and_retains_last_receipt(project_service):
_, _, data, ids, hashes = project_service
journal = RunJournal(data)