fix: renew release progress at completed proof boundaries

This commit is contained in:
阿白叔 committed 2026-11-17 05:30:51 +08:00
1 parent e0bb2438e8
commit de81bbf293
3 files changed
+122

No files matched your search

+7
View File
@@ -498,6 +498,7 @@ def owned_snapshot(path):
@contextmanager
def _prove_library_released(library, block_name=None, *, block_names=(), allow_unknown_checkpoint=False, stop=None):
"""Hold all native database read handles during explicit lease release."""
from .operation_queue import note_metadata_progress
from .owner_probe import query_owners
from .native_management import _retained_workers
from .native_export_guard import assert_retained_exports_idle, prove_export_copies_released
@@ -546,6 +547,7 @@ def _prove_library_released(library, block_name=None, *, block_names=(), allow_u
owners.append(item)
if owners:
raise LibraryBusy(f'原生进程仍存在,不能解除协调阻止:{owners}')
note_metadata_progress()
return owners
check_owners()
from .file_probe import hold_release_files
@@ -558,6 +560,7 @@ def _prove_library_released(library, block_name=None, *, block_names=(), allow_u
blocked = LibraryBusy(str(error))
blocked.winerror = getattr(error, 'winerror', None)
raise blocked from error
note_metadata_progress()
if files['addresses']:
# Native inspection needs the database; reacquire proof handles
# and compare the exact address/project binding before commit.
@@ -578,6 +581,7 @@ def _prove_library_released(library, block_name=None, *, block_names=(), allow_u
'exclusive_files', 'addresses', 'signatures', 'inspection_targets')):
raise LibraryBusy('原生检查期间资源范围或地址身份变化。')
files = current
note_metadata_progress()
export_proof = (prove_export_copies_released(library, allow_unknown_checkpoint=True)
if allow_unknown_checkpoint else prove_export_copies_released(library))
export_copies = stack.enter_context(export_proof)
@@ -600,6 +604,7 @@ def release_retained_library(library, evidence_dir, *, block_name=None, block_na
not the correctness of a partially changed library or its recovery state.
"""
import win32con, win32file
from .operation_queue import note_metadata_progress
library = Path(library).resolve(strict=True)
from .session_record import (retained_session_snapshot, acknowledge_library_release,
reconciled_retained_sessions)
@@ -689,6 +694,7 @@ def release_retained_library(library, evidence_dir, *, block_name=None, block_na
'operation_ids': [item['operation_id'] for item in reconciled_sessions]}
pending = {**record, 'status': 'RELEASE_PENDING', 'lease_state': 'PENDING'}
(root/'release.json').write_text(json.dumps(pending, ensure_ascii=False, indent=2), encoding='utf-8')
note_metadata_progress()
for index, checkpoint in enumerate(checkpoints):
if checkpoint.exists():
data = checkpoint.read_bytes()
@@ -696,6 +702,7 @@ def release_retained_library(library, evidence_dir, *, block_name=None, block_na
archived.write_bytes(data)
if archived.read_bytes() != data:
raise OSError('阻止记录归档校验失败,保持库锁。')
note_metadata_progress()
if stop is not None and stop.is_set():
raise InterruptedError('已停止释放检查')
checkpoint.unlink() # Checkpoint JSON only; never .lock.