From 877e3b4c76b571f6288c2f7bf86cf8e9ffada3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=99=BD=E5=8F=94?= <11794527+absfan@user.noreply.gitee.com> Date: Mon, 2 Nov 2026 19:12:12 +0800 Subject: [PATCH] fix: wait for native repair project shell and ignore known input indicators --- .../2026-11-02-issue-2-startup-recovery.md | 16 +++ src/cbb_refresh_verify/native_repair_ui.py | 14 ++- ...icdb-repair-startup-windows-sanitized.json | 26 +++++ tests/test_native_repair.py | 102 ++++++++++++++++++ 4 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/icdb-repair-startup-windows-sanitized.json diff --git a/docs/releases/2026-11-02-issue-2-startup-recovery.md b/docs/releases/2026-11-02-issue-2-startup-recovery.md index 65f13f6..59c96a2 100644 --- a/docs/releases/2026-11-02-issue-2-startup-recovery.md +++ b/docs/releases/2026-11-02-issue-2-startup-recovery.md @@ -164,3 +164,19 @@ only WMI: no owners permits release, either native owner prevents it, and arbitrary query names remain rejected. Focused validation: 172 passed. Candidate `c823a4b` must be rebuilt with this correction before frozen/native validation; field recovery remains unverified. + +Runtime fix round 3 uses the actual frozen-worker window capture. A single Afx +shell titled exactly `iCDB Project Backup` now waits, before invocation only, +for the exact project title within the existing deadline. Two owned-process +input-indicator classes (`UAC_InputIndicatorOverlayWnd`, `UAC Input Indicator`) +are ignored only with empty titles. Wrong/duplicate target windows, ambiguous +shells, named/lookalike auxiliary windows, unknown prompts, missing Output and +busy verdicts still retain the tool without unsafe commands. The native loading +line `Checking if project is in use.` is excluded from busy evidence; the actual +ownership verdict continues to control the busy gate. + +Sanitized recorded-shape replay includes real shell children, RichEdit Output +readback, startup-to-loaded transition and both input indicators before and +after load. Focused validation: 189 passed (12.40s); compile and scoped diff +checks passed. New source/frozen native validation and rebuilding the candidate +remain coordinator work; these replay results do not establish field recovery. diff --git a/src/cbb_refresh_verify/native_repair_ui.py b/src/cbb_refresh_verify/native_repair_ui.py index 1b4339d..c219b2d 100644 --- a/src/cbb_refresh_verify/native_repair_ui.py +++ b/src/cbb_refresh_verify/native_repair_ui.py @@ -34,6 +34,8 @@ def repair_completed(diagnostic_text, database_text, *, native_backup): def classify_repair_evidence(diagnostic, database, restore, output): """Classify this invocation only; an error alone does not prove native idle.""" combined = '\n'.join((diagnostic, database, restore, output)) + # This observed loading-progress line precedes the actual ownership verdict. + combined = re.sub(r'(?im)^\s*(?:\[[^\]\r\n]+\]\s*)?Checking if project is in use\.\s*$', '', combined) terminal_error = bool(re.search(r'Repair project error\s*\[[^\r\n]+\]', output, re.I)) closed_error = ('Diagnostic: FINISH' in diagnostic and 'IC: Closing project' in database) if re.search(r'project is in use|database.*(?:in use|busy)|other clients are connected', combined, re.I): @@ -225,12 +227,20 @@ def repair_worker_main(job_path): output_baseline = None output = '' while process.poll() is None and time.monotonic()= 4 and polls[2] >= .4 + assert result['status'] == expected + assert actions[:2] == [(100, win32con.WM_COMMAND), (201, win32con.BM_CLICK)] + assert ((100, win32con.WM_CLOSE) in actions) is closed + assert result['release']['safe_to_continue'] is closed + assert 'Project is not in use' in json.loads((root/'native-output.json').read_text('utf-8'))['baseline'] + + +@pytest.mark.parametrize('state,expected', [ + ('shell_stuck', 'TIMEOUT_UNRELEASED'), ('wrong_target', 'UNKNOWN_DIALOG'), + ('duplicate_shell', 'UNKNOWN_DIALOG'), ('duplicate_target', 'UNKNOWN_DIALOG'), + ('named_aux', 'UNKNOWN_DIALOG'), ('lookalike_aux', 'UNKNOWN_DIALOG'), + ('missing_output', 'TIMEOUT_UNRELEASED'), ('busy_loading', 'DATABASE_BUSY'), +]) +def test_recorded_startup_shape_retains_unconfirmed_or_unknown_state(tmp_path, monkeypatch, state, expected): + ui, root, job, actions, polls = real_shape_repair_fixture(tmp_path, monkeypatch, 'failed', state) + assert ui.repair_worker_main(job) == 1 + result = json.loads((root/'repair-result.json').read_text('utf-8')) + assert result['status'] == expected + assert actions == [] + assert result['release']['safe_to_continue'] is False + + +def test_generic_shell_after_invocation_is_not_a_startup_exception(tmp_path, monkeypatch): + import win32con + ui, root, job, actions, polls = real_shape_repair_fixture(tmp_path, monkeypatch, 'failed', 'shell_after_invoke') + assert ui.repair_worker_main(job) == 1 + result = json.loads((root/'repair-result.json').read_text('utf-8')) + assert result['status'] == 'UNKNOWN_DIALOG' + assert actions == [(100, win32con.WM_COMMAND)] + assert result['release']['safe_to_continue'] is False + + +@pytest.mark.parametrize('verdict,expected', [ + ('', 'UNCONFIRMED'), + ("Project is not in use. Full iCDB Project Backup's functionality is available.", 'UNCONFIRMED'), + ('Project is in use. Full functionality is unavailable.', 'DATABASE_BUSY'), +]) +def test_native_usage_check_progress_waits_for_actual_busy_verdict(verdict, expected): + from cbb_refresh_verify.native_repair_ui import classify_repair_evidence + output = '[2026-11-02 12:00:00] Checking if project is in use.\r\n' + output += '[2026-11-02 12:00:00] '+verdict + assert classify_repair_evidence('', '', '', output)['outcome'] == expected