fix: separate verification and ICDB maintenance with live session leases

This commit is contained in:
阿白叔 committed 2026-11-04 19:16:08 +08:00
1 parent 2587d33c5a
commit 477a5a46e3
15 files changed
+420 -194

No files matched your search

+5 -4
View File
@@ -258,7 +258,7 @@ def test_native_log_capture_generates_only_fresh_repair_evidence(tmp_path, name)
assert log.read_text('utf-8') == ERROR
def test_contents_session_loss_stops_batch_before_any_pcb_launch(tmp_path, monkeypatch):
def test_contents_session_loss_records_each_item_without_launching_pcb_or_repair(tmp_path, monkeypatch):
from test_verify_runner import fixture, request
fixture(tmp_path)
monkeypatch.setattr(runner, 'resolve_importer', lambda *_: Path('ReuseBlockImporter.exe'))
@@ -269,11 +269,12 @@ def test_contents_session_loss_stops_batch_before_any_pcb_launch(tmp_path, monke
results = runner.run_batch([request(tmp_path, libspec='EE', dms_login_config='login')]*2,
verifier=lambda req: runner.run_verify(req, process_runner=content_check,
port_check=lambda: pytest.fail('PCB must not start')))
assert len(calls) == 1
assert len(calls) == 2
assert results[0].error_category == 'ICDB_REPAIR_REQUIRED'
assert results[0].safe_to_continue is False
assert results[0].safe_to_continue is True
assert 'Repair project' in results[0].stderr
assert results[1].status == 'SKIPPED'
assert results[1].status == 'FAIL'
assert results[1].error_category == 'ICDB_REPAIR_REQUIRED'
def test_supervisor_enriches_generic_failure_from_fresh_native_log(tmp_path, monkeypatch):
+142
View File
@@ -0,0 +1,142 @@
from pathlib import Path
import pytest
from test_maintenance_entry import case
def test_verify_defaults_to_no_repair_and_does_not_retain_a_failure_lock(tmp_path, monkeypatch):
from cbb_refresh_verify import verify_runner as runner, library_lock as locks, native_repair
library = tmp_path / 'library.lmc'; library.touch()
req = runner.VerifyRequest(library, 'CBB', tmp_path / 'evidence')
assert req.auto_repair is False
marker = locks.blocker_path(library)
marker.write_text('historical diagnostic record')
calls = []
result = runner.VerifyResult('FAIL', stderr='ICDB_REPAIR_REQUIRED: session lost',
error_category='ICDB_REPAIR_REQUIRED', safe_to_continue=True)
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k: (calls.append('verify') or result))
monkeypatch.setattr(native_repair, 'attempt_recovery', lambda *a, **k: pytest.fail('verify requested Repair'))
assert runner.run_verify(req) is result
assert runner.run_verify(req) is result
assert calls == ['verify', 'verify']
assert marker.read_text() == 'historical diagnostic record'
assert locks._key(tmp_path / '.library.cbb-upload.lock') not in locks._owners
def test_catalog_checkpoint_does_not_disable_ordinary_verify(qtbot, tmp_path, monkeypatch):
from test_ui_filters import load_window
from cbb_refresh_verify.verify_runner import VerifyResult
calls = []
window = load_window(qtbot, tmp_path, monkeypatch,
verifier=lambda req: (calls.append(req) or VerifyResult('FAIL', stderr='ICDB_REPAIR_REQUIRED: lost',
error_category='ICDB_REPAIR_REQUIRED', safe_to_continue=True)),
status_refresher=lambda names, _: {name: 'PENDING' for name in names})
window._maintenance_recovery_view = True
window._management_unsafe = True
window.search_edit.setText('Beta'); window.select_visible_button.click(); window._update()
assert window.selected_batch_button.isEnabled()
window.verify_selected(); qtbot.waitUntil(lambda: not window.busy)
assert len(calls) == 1 and not calls[0].maintenance and not calls[0].auto_repair
assert window.selected_batch_button.isEnabled()
assert 'ICDB' in window.cbb_table.item(window._row_by_name['Beta'], 3).text()
def test_maintenance_guard_does_not_scan_other_cbb_projects(case, monkeypatch):
from cbb_refresh_verify import maintenance_entry as entry
from cbb_refresh_verify import scoped_manifest as manifests
req, project, _ = case
scans = []
scan = manifests.scan_tree
monkeypatch.setattr(manifests, 'scan_tree', lambda root, **kw: (scans.append(Path(root)) or scan(root, **kw)))
with entry.maintenance_target_guard(req):
pass
assert req.lmc_file.parent not in scans
assert scans.count(project.parent) == 2
def test_repair_finishes_without_calling_verify(case, monkeypatch):
from cbb_refresh_verify import native_repair, verify_runner as runner
from test_maintenance_entry import patch_verification_after_fault
from test_native_repair import complete_native_success
req, _, address = case
def repair(target, *a, **kw):
address.unlink()
return complete_native_success(target)
monkeypatch.setattr(native_repair, 'run_native_repair', repair)
monkeypatch.setattr(native_repair, 'repair_release_state', lambda req, target, result: result['release'])
patch_verification_after_fault(monkeypatch, runner, lambda *a, **k: pytest.fail('maintenance started CBB verification'))
result = runner.run_verify(req)
assert result.status == 'REPAIRED' and result.safe_to_continue
assert result.library_flag == 'UNKNOWN'
assert result.recovery_attempts[0]['validation_passed'] is False
@pytest.mark.parametrize('stage,expected_safe', [('PCB_STARTING', True), ('back_annotation', False)])
def test_only_released_startup_failure_can_continue_from_icdb_diagnosis(tmp_path, monkeypatch, stage, expected_safe):
import json
from cbb_refresh_verify import verify_runner as runner
library = tmp_path/'library.lmc'; library.touch()
evidence = tmp_path/'evidence'; evidence.mkdir()
report = evidence/'result.json'; report.write_text('{}')
(evidence/'session-release.json').write_text(json.dumps({'library': str(library),
'block': 'CBB', 'worker_exited': True, 'safe_to_continue': True}))
failure = runner.VerifyResult('FAIL', stderr='ICDB_REPAIR_REQUIRED: lost session',
error_stage=stage, safe_to_continue=False, evidence_path=report)
monkeypatch.setattr(runner, '_run_verify', lambda *a, **k: failure)
result = runner._run_verify_serialized(runner.VerifyRequest(library, 'CBB', evidence))
assert result.status == 'FAIL' and result.error_category == 'ICDB_REPAIR_REQUIRED'
assert result.safe_to_continue is expected_safe
def test_live_writer_keeps_execution_lock_without_a_permanent_diagnostic_blocker(tmp_path, monkeypatch):
import win32con, win32file
from cbb_refresh_verify import library_lock as locks, verify_runner as runner
library = tmp_path/'lib.lmc'; library.touch()
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k:
runner.VerifyResult('TIMEOUT', safe_to_continue=False))
result = runner.run_verify(runner.VerifyRequest(library, 'CBB', tmp_path/'evidence'))
lock = locks.LibraryLock(library)
try:
assert not result.safe_to_continue and not locks.blocker_path(library).exists()
with pytest.raises(Exception):
win32file.CreateFile(str(lock.path), win32con.GENERIC_READ | win32con.GENERIC_WRITE,
0, None, win32con.OPEN_ALWAYS, 0, None)
finally:
with locks._guard:
owner = locks._owners.pop(lock.key, None)
if owner: owner['handle'].Close()
def test_healthy_native_inspection_with_old_address_does_not_lock_management(case, monkeypatch):
from cbb_refresh_verify import native_repair, verify_runner as runner, library_lock as locks
from test_native_occupancy import output
request, project, address = case
def inspect(target, *a, **kw):
assert kw['inspection_only']
return {'inspection_only': True, 'repair_requested': False, 'repair_required': False,
'status': 'NOT_IN_USE', 'native_pid': 777, 'native_exit_code': 0,
'project': str(target.project), 'database': str(target.database),
'output': output(target.project, target.database), 'release': {'native_exited': True}}
monkeypatch.setattr(native_repair, 'run_native_repair', inspect)
result = runner.run_verify(request)
assert result.status == 'CHECKED' and result.safe_to_continue and address.exists()
assert not result.stderr and '无需修复' in result.stdout
assert not locks.blocker_path(request.lmc_file).exists()
with locks.LibraryLock(request.lmc_file): pass
@pytest.mark.parametrize('operation', ['verify', 'maintenance'])
def test_retained_execution_lease_can_retry_after_its_actual_client_exits(tmp_path, operation):
from contextlib import contextmanager
from cbb_refresh_verify.library_lock import LibraryLock, LibraryBusy
library = tmp_path/'library.lmc'; library.touch()
released = [False]
with LibraryLock(library, checkpoint=False, safe_to_release=lambda: released[0]): pass
with pytest.raises(LibraryBusy):
with LibraryLock(library, checkpoint=False): pass
released[0] = True
@contextmanager
def guard(): yield {'target': 'isolated fixture'}
lock = (LibraryLock(library, checkpoint=False) if operation == 'verify' else
LibraryLock.for_maintenance(library, tmp_path/'archive', guard, safe_to_release=lambda: True))
with lock: pass
+9 -12
View File
@@ -65,28 +65,25 @@ def test_verification_refuses_uploader_exclusive_lock_before_native_work(tmp_pat
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k: pytest.fail('native work bypassed lock'))
try:
result = runner.run_verify(runner.VerifyRequest(library, 'Block', tmp_path/'out'))
assert result.status == 'BLOCKED' and not result.safe_to_continue
assert result.status == 'FAIL' and result.safe_to_continue
finally:
handle.Close()
def test_unsafe_verify_retains_lease_and_persistent_blocker(tmp_path, monkeypatch):
def test_unsafe_verify_records_failure_without_persistent_library_blocker(tmp_path, monkeypatch):
import json
import cbb_refresh_verify.verify_runner as runner
import cbb_refresh_verify.library_lock as locks
library = tmp_path/'lib.lmc'; library.touch()
evidence = tmp_path/'out'; evidence.mkdir()
(evidence/'session-release.json').write_text(json.dumps({'library': str(library),
'block': 'Block', 'worker_exited': True, 'safe_to_continue': True}))
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k:
runner.VerifyResult('FAIL', safe_to_continue=False))
runner.VerifyResult('FAIL', safe_to_continue=False, evidence_path=evidence/'result.json'))
result = runner.run_verify(runner.VerifyRequest(library, 'Block', tmp_path/'out'))
assert not result.safe_to_continue
assert locks.blocker_path(library).is_file()
with pytest.raises(locks.LibraryBusy):
with locks.LibraryLock(library): pass
# Simulate OS handle loss on process exit; persistent marker still blocks.
with locks._guard:
owner = locks._owners.pop(str((tmp_path/'.lib.cbb-upload.lock').resolve()).casefold(), None)
if owner: owner['handle'].Close()
with pytest.raises(locks.LibraryBusy):
with locks.LibraryLock(library): pass
assert not locks.blocker_path(library).exists()
with locks.LibraryLock(library): pass
def test_explicit_release_requires_fresh_proof_and_never_deletes_sidecar(tmp_path, monkeypatch):
+21 -16
View File
@@ -96,8 +96,9 @@ def test_explicit_maintenance_enters_official_repair_once_without_lostsession_fa
return runner.VerifyResult('PASS', library_flag='GREEN')
patch_verification_after_fault(monkeypatch, runner, verify)
result = runner.run_verify(request)
assert calls == ['repair', 'verify'] and result.status == 'PASS'
assert result.recovery_attempts[0]['validation_passed'] is True
assert calls == ['repair'] and result.status == 'REPAIRED'
assert result.recovery_attempts[0]['validation_passed'] is False
assert result.library_flag == 'UNKNOWN'
record = json.loads(result.evidence_path.read_text(encoding='utf-8'))
assert record['operation'] == 'explicit_project_maintenance'
assert 'session' not in record['maintenance_context']
@@ -118,7 +119,7 @@ def test_addressless_target_binds_unique_project_and_rejects_new_address(case):
def test_guard_reuses_full_tree_scan_but_still_refreshes_before_yield(case, monkeypatch):
from cbb_refresh_verify.maintenance_entry import maintenance_target_guard
import cbb_refresh_verify.scoped_manifest as manifests
request, _, _ = case
request, project, _ = case
scans = []
original = manifests.scan_tree
def scan(root, **kwargs):
@@ -126,7 +127,8 @@ def test_guard_reuses_full_tree_scan_but_still_refreshes_before_yield(case, monk
return original(root, **kwargs)
monkeypatch.setattr(manifests, 'scan_tree', scan)
with maintenance_target_guard(request): pass
assert scans.count(request.lmc_file.parent) == 2
assert request.lmc_file.parent not in scans
assert scans.count(project.parent) == 2
def test_guard_rejects_new_native_database_appearing_during_checks(case, monkeypatch):
@@ -198,12 +200,15 @@ def test_optional_pcb_project_appearance_invalidates_maintenance_proof(case):
with maintenance_target_guard(request, before): pass
def test_ordinary_verify_still_blocks_existing_address_without_repair(case, monkeypatch):
def test_ordinary_verify_calls_native_verifier_despite_existing_address(case, monkeypatch):
from cbb_refresh_verify import verify_runner as runner, native_repair
request, _, address = case
monkeypatch.setattr(native_repair, 'run_native_repair', lambda *a, **k: pytest.fail('ordinary verify must not repair'))
calls = []
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k:
(calls.append('verify') or runner.VerifyResult('FAIL', stderr='native ICDB problem')))
result = runner.run_verify(replace(request, maintenance=False))
assert result.status == 'BLOCKED' and not result.safe_to_continue
assert calls == ['verify'] and result.status == 'FAIL' and result.safe_to_continue
assert address.read_bytes() == b'old server address - preserved'
@@ -373,11 +378,11 @@ def test_independent_cbb_address_does_not_select_or_block_current_project(case):
@pytest.mark.parametrize('status,complete,expected_safe', [
('RESTORED_REVIEW_REQUIRED', True, False), ('DATABASE_BUSY', True, False),
('UNKNOWN_DIALOG', True, False), ('UNCONFIRMED', True, False),
('MISSING_HEALTHY_BACKUP', False, False), ('NATIVE_REPAIR_FAILED', False, False),
('RESTORED_REVIEW_REQUIRED', True, True), ('DATABASE_BUSY', True, True),
('UNKNOWN_DIALOG', True, True), ('UNCONFIRMED', True, True),
('MISSING_HEALTHY_BACKUP', False, True), ('NATIVE_REPAIR_FAILED', False, True),
('MISSING_HEALTHY_BACKUP', True, True), ('NATIVE_REPAIR_FAILED', True, True)])
def test_physical_release_alone_does_not_authorize_queue(case, monkeypatch, status, complete, expected_safe):
def test_failed_content_does_not_block_other_items_after_actual_release(case, monkeypatch, status, complete, expected_safe):
from cbb_refresh_verify import native_repair, verify_runner as runner, library_lock
from test_native_repair import complete_native_success
request, _, address = case
@@ -410,10 +415,10 @@ def test_successful_icdb_repair_then_version_choice_reports_partial_completion(c
error_category='PCB_VERSION_CHOICE_REQUIRED', stderr='PCB版本待选:最后用户保存/自动保存 2026/9/24 23:06',
safe_to_continue=False, evidence_path=request.evidence_dir/'verify/result.json'))
result = runner.run_verify(request)
assert result.status == 'FAIL' and not result.safe_to_continue
assert 'ICDB原生修复已完成' in result.stderr and '尚未校验通过' in result.stderr
assert result.status == 'REPAIRED' and result.safe_to_continue
assert '待单独校验' in result.stdout
assert result.recovery_attempts[0]['native_status'] == 'REPAIRED'
assert result.recovery_attempts[0]['status'] == 'PCB_VERSION_CHOICE_REQUIRED'
assert result.recovery_attempts[0]['status'] == 'REPAIRED_UNVERIFIED'
assert result.recovery_attempts[0]['validation_passed'] is False
@@ -431,6 +436,6 @@ def test_user_chosen_pcb_history_is_not_reported_as_lossless_repair(case, monkey
return runner.VerifyResult('PASS', library_flag='GREEN', evidence_path=root/'result.json')
patch_verification_after_fault(monkeypatch, runner, verify)
result = runner.run_verify(request)
assert result.status == 'PASS'
assert result.recovery_attempts[0]['status'] == 'RESTORED_REVIEW_REQUIRED'
assert result.recovery_attempts[0]['pcb_version']['choice'] == 'last_user_saved'
assert result.status == 'REPAIRED' and result.library_flag == 'UNKNOWN'
assert result.recovery_attempts[0]['status'] == 'REPAIRED_UNVERIFIED'
assert not (request.evidence_dir/'verify').exists()
+22 -22
View File
@@ -24,15 +24,18 @@ def test_only_confirmed_maintenance_sets_explicit_flag(qtbot, tmp_path, monkeypa
@pytest.mark.parametrize('marker_kind', ['valid', 'foreign', 'malformed'])
def test_blocked_library_recovery_view_is_filesystem_only_and_maintenance_only(qtbot, tmp_path, monkeypatch, marker_kind):
def test_old_checkpoint_does_not_force_maintenance_or_disable_verify(qtbot, tmp_path, monkeypatch, marker_kind):
from cbb_refresh_verify.library_lock import LibraryLock, blocker_path, _owners, _guard
from cbb_refresh_verify.ui.main_window import MainWindow
from cbb_refresh_verify.verify_runner import VerifyResult
from cbb_refresh_verify.models import LibraryReadResult, CbbRecord
import cbb_refresh_verify.ui.main_window as ui
library = tmp_path/'library/mentor.lmc'; library.parent.mkdir(); library.touch()
(library.parent/'ReusableBlocksLP/IP101GR').mkdir(parents=True)
with LibraryLock(library, safe_to_release=lambda: False) as lock: pass
with _guard: _owners.pop(lock.key)['handle'].Close()
with _guard:
owner = _owners.pop(lock.key, None)
if owner: owner['handle'].Close()
marker = blocker_path(library)
if marker_kind == 'malformed': marker.write_text('{}')
if marker_kind == 'foreign':
@@ -40,31 +43,26 @@ def test_blocked_library_recovery_view_is_filesystem_only_and_maintenance_only(q
marker.write_text(json.dumps(record))
monkeypatch.setattr(ui, 'preflight_skip_reason', lambda *a: None)
calls = []
window = MainWindow(reader=lambda *a: pytest.fail('blocked view called native reader'),
window = MainWindow(reader=lambda *a: LibraryReadResult((CbbRecord('IP101GR', 'Reusable Blocks', status='PENDING'),)),
verifier=lambda req: (calls.append(req) or VerifyResult('BLOCKED', safe_to_continue=False)),
status_refresher=lambda *a: pytest.fail('unsafe view refreshed native status'), data_root=tmp_path/'data')
status_refresher=lambda *a: {'IP101GR': 'PENDING'}, data_root=tmp_path/'data')
qtbot.addWidget(window)
window.lmc_edit.setText(str(library)); window.load_library()
qtbot.waitUntil(lambda: not window.busy)
assert window.release_library_button.isEnabled()
if marker_kind != 'valid':
assert window.loaded_path is None and not window.icdb_repair_button.isEnabled()
return
assert window.visible_records()[0].name == 'IP101GR'
assert window.visible_records()[0].status == 'UNKNOWN'
assert '未确认' in window.status_label.text()
assert 'ICDB' in window.management_capability_label.text()
assert '会话' in window.add_button.toolTip()
assert window.visible_records()[0].status == 'PENDING'
assert not window._maintenance_recovery_view
window.select_visible_button.click()
assert window.icdb_repair_button.isEnabled()
assert not any(button.isEnabled() for button in (window.batch_button, window.selected_batch_button,
window.backup_restore_button, window.add_button, window.update_button, window.remove_button))
window.verify_all(); window.verify_selected(); window.restore_backup(); window.manage_cbb('remove')
assert window.refresh_affected_records(['IP101GR']) is False
assert calls == [] and not window.busy
assert window.batch_button.isEnabled() and window.selected_batch_button.isEnabled()
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes)
window.verify_selected(); qtbot.waitUntil(lambda: not window.busy)
assert len(calls) == 1 and calls[0].maintenance is False
assert window.selected_batch_button.isEnabled()
window.repair_icdb_all(); qtbot.waitUntil(lambda: not window.busy)
assert len(calls) == 1 and calls[0].maintenance is True
assert len(calls) == 2 and calls[1].maintenance is True
assert marker.exists()
def test_maintenance_summary_exposes_first_failure_reason(qtbot, tmp_path):
@@ -92,11 +90,13 @@ def test_safe_maintenance_reloads_authoritative_catalog_after_worker_finishes(qt
library = tmp_path/'library/mentor.lmc'; library.parent.mkdir(); library.touch()
(library.parent/'ReusableBlocksLP/IP101GR').mkdir(parents=True)
with LibraryLock(library, safe_to_release=lambda: False) as lease: pass
with _guard: _owners.pop(lease.key)['handle'].Close()
with _guard:
owner = _owners.pop(lease.key, None)
if owner: owner['handle'].Close()
reads = []
def reader(path):
reads.append(path)
return LibraryReadResult((CbbRecord('IP101GR', 'Reusable Blocks', status='READY'),))
return LibraryReadResult((CbbRecord('IP101GR', 'Reusable Blocks', status='PENDING'),))
def verify(req):
assert req.maintenance
blocker_path(library).unlink() # Simulate normal cleanup at the injected boundary.
@@ -104,12 +104,12 @@ def test_safe_maintenance_reloads_authoritative_catalog_after_worker_finishes(qt
monkeypatch.setattr(ui, 'preflight_skip_reason', lambda *a: None)
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: QMessageBox.Yes)
window = MainWindow(reader=reader, verifier=verify, data_root=tmp_path/'data',
status_refresher=lambda *a: pytest.fail('recovery view must reload after worker completion'))
status_refresher=lambda *a: {'IP101GR': 'READY'})
qtbot.addWidget(window)
window.lmc_edit.setText(str(library)); window.load_library(); qtbot.waitUntil(lambda: not window.busy)
assert reads == []
assert len(reads) == 1
window.search_edit.setText('IP101')
window.repair_icdb_all()
qtbot.waitUntil(lambda: not window.busy and bool(reads))
qtbot.waitUntil(lambda: not window.busy)
assert window.visible_records()[0].status == 'READY'
assert not window._maintenance_recovery_view and window.search_edit.text() == 'IP101'
+1
View File
@@ -13,6 +13,7 @@ def export_case(tmp_path, monkeypatch):
import cbb_refresh_verify.native_engineering_identity as identity
import win32com.client
monkeypatch.setattr(win32com.client, 'GetObject', lambda *_: SimpleNamespace(ExecQuery=lambda *_: []))
monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners', lambda *_a, **_k: [])
monkeypatch.setattr(identity, '_process_snapshot', lambda: [])
monkeypatch.setattr(identity, '_retained_exports', [])
monkeypatch.setattr(locks, '_supervisor_alive', lambda _: False)
+5 -2
View File
@@ -5,6 +5,7 @@ import pytest
def target_fixture(tmp_path):
from dataclasses import replace
from test_verify_runner import fixture, request
from cbb_refresh_verify.native_repair import select_repair_target
work = fixture(tmp_path)
@@ -13,7 +14,8 @@ def target_fixture(tmp_path):
(database/'icdb.dat').write_bytes(b'original damaged database')
diagnosis = {'error_code': 'ICDB_REPAIR_REQUIRED', 'machine': 'OLD-PC',
'database_path': str(database), 'session': '2026-10-24 08.22.29-10308', 'scope': 'project'}
return request(tmp_path), diagnosis, select_repair_target(request(tmp_path), diagnosis)
req = replace(request(tmp_path), auto_repair=True)
return req, diagnosis, select_repair_target(req, diagnosis)
def complete_native_success(target):
@@ -511,7 +513,8 @@ def test_invoked_busy_native_result_never_reopens_or_continues_queue(tmp_path, m
busy = json.loads((root/'repair-result.json').read_text('utf-8'))
assert (100, win32con.WM_CLOSE) not in actions
assert busy['status'] == 'DATABASE_BUSY' and busy['release']['native_exited'] is False
req = request(tmp_path)
from dataclasses import replace
req = replace(request(tmp_path), auto_repair=True)
target = json.loads(job.read_text('utf-8'))
evidence = tmp_path/'first/result.json'
evidence.parent.mkdir()