fix: complete issue17 cleanup and bounded native verification
This commit is contained in:
1 parent
14cacb1d1c
commit
07eab61695
12 files changed
+642
-26
No files matched your search
@@ -44,6 +44,18 @@ def _cancel_target(snapshot):
|
||||
from .dialog_rules import pcb_version_choice
|
||||
if exact_prompt(snapshot):
|
||||
return 'read_write_access', next(c for c in snapshot.controls if c.control_id == 7)
|
||||
text = ' '.join(' '.join(c.name for c in snapshot.controls
|
||||
if c.class_name == 'Static').split())
|
||||
buttons = [c for c in snapshot.controls if c.class_name == 'Button']
|
||||
if (snapshot.window_class == '#32770' and snapshot.title == 'Expedition PCB'
|
||||
and text == ('Problem encountered while opening one of the database files. '
|
||||
'See PCBLogFile.txt for details. Loading of the job has failed. '
|
||||
'Do you wish to view the log file now?')
|
||||
and {c.control_id for c in buttons} == {6, 7}
|
||||
and len(buttons) == 2):
|
||||
no = next(c for c in buttons if c.control_id == 7)
|
||||
if no.enabled:
|
||||
return 'database_load_log', no
|
||||
if pcb_version_choice(snapshot) is not None:
|
||||
buttons = [c for c in snapshot.controls if c.class_name == 'Button']
|
||||
cancel = [c for c in buttons if c.control_id == 2 and c.name == 'Cancel' and c.enabled]
|
||||
@@ -62,6 +74,31 @@ def _tip_target(snapshot):
|
||||
return target if target is not None and target.class_name == 'Button' else None
|
||||
|
||||
|
||||
def _database_log_declined(root, pcb_pid):
|
||||
"""The supervisor can dismiss this exact failed-open question before cleanup."""
|
||||
from dataclasses import fields
|
||||
from .dialog_models import WindowSnapshot
|
||||
path = root/'dialogs.jsonl'
|
||||
try:
|
||||
if path.stat().st_size > 1024*1024:
|
||||
return False
|
||||
for line in path.read_text(encoding='utf-8').splitlines():
|
||||
record = json.loads(line)
|
||||
if (record.get('pid') != pcb_pid or record.get('phase') != 'PCB_STARTING'
|
||||
or record.get('error_code') != 'MENTOR_DATABASE_LOAD_FAILED'
|
||||
or record.get('action') != 'acknowledge_fatal'
|
||||
or record.get('accepted_control') != [7]):
|
||||
continue
|
||||
snapshot = WindowSnapshot.from_record({f.name:record[f.name]
|
||||
for f in fields(WindowSnapshot) if f.name in record})
|
||||
target = _cancel_target(snapshot)
|
||||
if target is not None and target[0] == 'database_load_log':
|
||||
return True
|
||||
except (OSError, ValueError, TypeError, KeyError):
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def cancelled_prewrite_startup(job, pcb_pid=None):
|
||||
"""Positive ordinary pre-document cancellation proof; absence of Save is insufficient."""
|
||||
from .session_record import IDENTITY_KEYS, read_session_record
|
||||
@@ -150,7 +187,7 @@ def close_failed_startup(job, pcb_pid, *, baseline_pids=(), emit=lambda **event:
|
||||
sent = False
|
||||
declined_hwnd = None
|
||||
declined_kind = None
|
||||
cancelled_open = False
|
||||
cancelled_open = _database_log_declined(root, pcb_pid)
|
||||
dismissed_tips = set()
|
||||
close_handle = None
|
||||
close_identity = None
|
||||
|
||||
Reference in new issue
Block a user