feat: integrate native diagnostics and coordinated CBB transactions

This commit is contained in:
阿白叔 committed 2026-11-05 23:18:00 +08:00
1 parent 9e230e1a46
commit da67de026f
91 files changed
+14370 -435

No files matched your search

+11 -10
View File
@@ -27,12 +27,11 @@ def test_network_timeout_cannot_remove_database_advertisement(tmp_path, monkeypa
@pytest.mark.parametrize('state', ['LIVE', 'UNREACHABLE', 'INVALID'])
def test_existing_database_owner_blocks_before_pcb_launch(tmp_path, monkeypatch, state):
def test_address_probe_result_is_not_a_substitute_for_native_verify(tmp_path, monkeypatch, state):
job, events, execute = exercise_worker(tmp_path, monkeypatch)
monkeypatch.setattr(adapter, 'prepare_icdb_address', lambda *a, **k: {'status': state})
with pytest.raises(RuntimeError, match='ICDB_SESSION_UNCONFIRMED'):
execute()
assert not any(e['stage'] == 'pcb_launch' for e in events)
assert execute()['status'] == 'PASS'
assert any(e['stage'] == 'pcb_launch' for e in events)
@pytest.mark.parametrize('text', [
@@ -114,7 +113,7 @@ def test_desktop_abort_does_not_kill_native_process_tree(monkeypatch):
assert worker.handle in terminated
def test_saved_pcb_with_retained_icdb_address_cannot_pass(tmp_path, monkeypatch):
def test_saved_pcb_with_address_records_remains_an_execution_result_for_bridge_validation(tmp_path, monkeypatch):
job, events, execute = exercise_worker(tmp_path, monkeypatch)
original = adapter.subprocess.Popen
def helper(*a, **k):
@@ -123,9 +122,8 @@ def test_saved_pcb_with_retained_icdb_address_cannot_pass(tmp_path, monkeypatch)
address.write_text('still owned', encoding='ascii')
return original(*a, **k)
monkeypatch.setattr(adapter.subprocess, 'Popen', helper)
with pytest.raises(RuntimeError, match='ICDB_RELEASE_UNCONFIRMED'):
execute()
assert not any(e['stage'] == 'complete' for e in events)
assert execute()['status'] == 'PASS'
assert any(e['stage'] == 'icdb_address_remaining' for e in events)
def test_retained_pcb_after_close_cannot_pass_or_be_killed(tmp_path, monkeypatch):
@@ -189,7 +187,8 @@ def test_supervisor_rejects_pass_when_native_release_is_unconfirmed(tmp_path, mo
def test_existing_pcb_session_blocks_before_mutating_project(tmp_path, monkeypatch):
job, events, execute = exercise_worker(tmp_path, monkeypatch)
monkeypatch.setattr(adapter, 'pcb_processes', lambda: ((20, 'ExpeditionPCB.exe', 'user design'),))
monkeypatch.setattr(adapter, 'pcb_processes', lambda:
((20, 'ExpeditionPCB.exe', f'ExpeditionPCB.exe "{job["pcb"]}"'),))
with pytest.raises(RuntimeError, match='PCB_SESSION_ACTIVE'):
execute()
assert not events
@@ -209,7 +208,9 @@ def test_real_windows_job_abort_preserves_native_like_child(tmp_path):
script.write_text(
'import subprocess, sys, time\nfrom pathlib import Path\n'
'child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(30)"])\n'
f'Path({str(pid_path)!r}).write_text(str(child.pid))\n'
f'pid_file = Path({str(pid_path)!r})\n'
'pending = pid_file.with_suffix(".pending")\n'
'pending.write_text(str(child.pid)); pending.replace(pid_file)\n'
'time.sleep(30)\n', encoding='utf-8')
worker = DesktopWorker([sys.executable, str(script)], 'CbbSafetyTest_' + uuid.uuid4().hex[:8])
child_handle = None