fix: bound post-repair readwrite consent to proven local startup

This commit is contained in:
阿白叔 committed 2026-11-03 09:36:33 +08:00
1 parent 5a758ee3b6
commit aa6684b588
8 files changed
+500 -1

No files matched your search

+18
View File
@@ -64,6 +64,7 @@ class VerifyRequest:
mapped_remote_root: str = ''
auto_repair: bool = True
maintenance: bool = False
post_repair_proof: object | None = field(default=None, repr=False, compare=False)
@dataclass(frozen=True)
@@ -808,11 +809,19 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
'desktop': 'CbbVerify_' + uuid4().hex[:12],
'cancel_signal': str(root/'cancel-worker.signal'),
'start_gate': str(root/'start-worker.signal')}
consent = None
if request.post_repair_proof is not None:
from .post_repair_consent import PostRepairProof, ConsentController
if not isinstance(request.post_repair_proof, PostRepairProof):
return finish(VerifyResult('BLOCKED', stderr='POST_REPAIR_PROOF_REQUIRED', safe_to_continue=False))
job['post_repair_consent'] = request.post_repair_proof.for_job(job)
consent = ConsentController(request.post_repair_proof, job)
job_path = root/'request.json'
job_path.write_text(json.dumps(job, ensure_ascii=False), encoding='utf-8')
events = root/'events.jsonl'
offset = 0
target_pid = None
launcher_pid = None
lm_pid = None
verify_invoked = False
invoke_returned = False
@@ -875,6 +884,7 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
break
timing.record(event)
if event.get('pcb_pid'): target_pid = event['pcb_pid']
if event.get('launcher_pid'): launcher_pid = event['launcher_pid']
if event.get('lm_pid'): lm_pid = event['lm_pid']
stage = event.get('stage')
if stage == 'verify_invoke': verify_invoked = True
@@ -926,6 +936,14 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
dialog_result = dialog_supervisor.poll()
else:
dialog_result = dialog_supervisor.poll()
if (consent is not None and dialog_agent is not None
and dialog_result.error_code == 'DATABASE_RECOVERY_REQUIRED'
and dialog_result.snapshot is not None):
consent_snapshot = dialog_result.snapshot
if consent_snapshot.hwnd in {int(h) for h in process.desktop.EnumDesktopWindows()}:
dialog_result = consent.handle(consent_snapshot, dialog_result.observed_snapshots,
target_pid=target_pid, launcher_pid=launcher_pid, worker_pid=process.pid,
companion_pids=tuple(process.companion_pids), perform=dialog_supervisor.backend.perform)
# Normal progress stays in memory. Only actions/errors and the
# last failure snapshots are persisted, not every elapsed tick.
latest_snapshots = dialog_result.observed_snapshots