From 42898d33d226ae1315a5e19dee8d34bde61ef7ad 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, 9 Nov 2026 10:48:20 +0800 Subject: [PATCH] chore: pin reviewed Python line endings and record stack validation --- .gitattributes | 3 + ...2026-11-09-latest-pr-stack-validation.json | 85 +++++ .../2026-11-09-latest-pr-stack-validation.md | 24 ++ .../2026-11-09-other-pr-latest-reviews.md | 26 +- src/cbb_refresh_verify/application.py | 340 +++++++++--------- 5 files changed, 295 insertions(+), 183 deletions(-) create mode 100644 docs/releases/2026-11-09-latest-pr-stack-validation.json create mode 100644 docs/releases/2026-11-09-latest-pr-stack-validation.md diff --git a/.gitattributes b/.gitattributes index 0c6ee5f..dd1aa0e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,6 @@ # Keep the verified Windows source and binary assets byte-for-byte. # Do not normalize the r4 baseline's line endings during add/checkout. * -text +# Normalize only these two reviewed Python files at the chain tip. +src/cbb_refresh_verify/application.py text eol=lf +src/cbb_refresh_verify/ui/main_window.py text eol=lf diff --git a/docs/releases/2026-11-09-latest-pr-stack-validation.json b/docs/releases/2026-11-09-latest-pr-stack-validation.json new file mode 100644 index 0000000..28360c4 --- /dev/null +++ b/docs/releases/2026-11-09-latest-pr-stack-validation.json @@ -0,0 +1,85 @@ +{ + "date": "2026-11-09", + "scope": "Latest comments #309/#310/#313 only; older deep-review backlog excluded by user", + "integration_head_before_validation_commit": "b1c36e3ca6d6680d0b656a725a1db871d5ffabbd", + "branch_heads": { + "codex/review-native-backend": "b7baa24b5ed87256fb846236b08c75ff02887e9c", + "codex/review-ui-integration": "e73f9c6edcb36a18fdd8a17b565cc1fb7c97f26b", + "codex/review-residual-release": "651b539d0ef491b3fd410031b9f981d71272aac9", + "codex/runtime-lifecycle-safety": "b1c36e3ca6d6680d0b656a725a1db871d5ffabbd" + }, + "environment": { + "python": "3.12.10", + "windows": "10.0.26200" + }, + "full_suite": { + "tests": 1742, + "failures": 0, + "errors": 0, + "skipped": 0, + "duration_seconds": 293.056, + "xml": "F:\\Sync Tool Skyworth\\Work Maps\\cbb-refresh-verify-795\\diagnostics\\2026-11-09-latest-stack-full-1742.xml", + "source_xml": "F:\\Sync Tool Skyworth\\Work Maps\\cbb-refresh-verify-795\\diagnostics\\cbb-refresh-verify-795-review-stack-fixes-full.xml", + "xml_sha256": "e00376d01fa26dd8e62d065d700f8cc200000665a6958536d109336119f8a0c0" + }, + "focused_suites": { + "cbb-refresh-verify-795-backend-fixes": { + "tests": 94, + "failures": 0, + "errors": 0, + "skipped": 0, + "duration_seconds": 41.802, + "xml": "F:\\Sync Tool Skyworth\\Work Maps\\cbb-refresh-verify-795\\diagnostics\\2026-11-09-cbb-refresh-verify-795-backend-fixes-latest-focused-94.xml", + "source_xml": "F:\\Sync Tool Skyworth\\Work Maps\\cbb-refresh-verify-795\\diagnostics\\cbb-refresh-verify-795-backend-fixes-fixes-focused.xml", + "xml_sha256": "d8580bcc766c7ad6d3ce1d9de7d44b496afaaa8c3489cf01245f1d8a7d15500c" + }, + "cbb-refresh-verify-795-ui-fixes": { + "tests": 43, + "failures": 0, + "errors": 0, + "skipped": 0, + "duration_seconds": 5.554, + "xml": "F:\\Sync Tool Skyworth\\Work Maps\\cbb-refresh-verify-795\\diagnostics\\2026-11-09-cbb-refresh-verify-795-ui-fixes-latest-focused-43.xml", + "source_xml": "F:\\Sync Tool Skyworth\\Work Maps\\cbb-refresh-verify-795\\diagnostics\\cbb-refresh-verify-795-ui-fixes-fixes-focused.xml", + "xml_sha256": "0ed470d756f0b387ca9fbf4f4891bd60abfc3faf535e67c06d6640557d627753" + }, + "cbb-refresh-verify-795-review-stack": { + "tests": 136, + "failures": 0, + "errors": 0, + "skipped": 0, + "duration_seconds": 16.117, + "xml": "F:\\Sync Tool Skyworth\\Work Maps\\cbb-refresh-verify-795\\diagnostics\\2026-11-09-cbb-refresh-verify-795-review-stack-latest-focused-136.xml", + "source_xml": "F:\\Sync Tool Skyworth\\Work Maps\\cbb-refresh-verify-795\\diagnostics\\cbb-refresh-verify-795-review-stack-fixes-focused.xml", + "xml_sha256": "2087bfa02a0251deee535acda7454c0967b1f11aa5c7125296efc78c141fec59" + } + }, + "compileall": "passed", + "diff_check": "passed", + "independent_review": "No important introduced findings before or after integration", + "controlled_private_desktop_fixture": "passed", + "tested_files_sha256": { + ".gitattributes": "a68c9f317ed6e4131c72269b98403c7a3f9c08d5d03e710425301bd50273e791", + "src/cbb_refresh_verify/application.py": "b76ff891d77f0a7dba8feeb1f5ae5745ee83dee2fa46c585c187dbf9bb1c39d2", + "src/cbb_refresh_verify/library_lock.py": "8b3286d36ad686f65ec7e30eded9c4d0f8a629ca214b39812dfba496292da976", + "src/cbb_refresh_verify/residual_sessions.py": "b5d38a06cb2902c3612edb75b1ef83596524f02b6cf7890f6541f210d3e380ce", + "tests/test_residual_sessions.py": "f34c77a11d2a2b08c5670a9809474afd84b212016a27b104249e5fddb4675f1f", + "tests/test_review313_residual_isolation.py": "4052ca51c35787a8df9b63e79febd38b666da98c09976fffb34f4361381d8b4d", + "tests/test_review_foreign_release_evidence.py": "cbf2af02418f6bd3ec720a7a7658cf97f06d1a6e12009fdff2a99f465711591e" + }, + "icon_sha256": { + "ico": "62d4472ebaa94f9b39aebae06459685d3322041d0e1a7ada9f368cfd816ba1d6", + "png": "840f657fd7c622d9afd78625a64ed8ad04c90a895dd3c9fd37eebae543cdebe8", + "svg": "cbba5b3f339cbeb5eb43012709237359442ef67c69fc5b6679a8ee4c0a1b7328" + }, + "automatic_icdb_repair": false, + "candidate_rebuilt": false, + "not_verified": [ + "Real Mentor operations", + "Frozen execution of this revision", + "Windows 10", + "Shared/network/cross-machine release" + ], + "merged": false, + "issue_closed": false +} diff --git a/docs/releases/2026-11-09-latest-pr-stack-validation.md b/docs/releases/2026-11-09-latest-pr-stack-validation.md new file mode 100644 index 0000000..b269482 --- /dev/null +++ b/docs/releases/2026-11-09-latest-pr-stack-validation.md @@ -0,0 +1,24 @@ +# Latest PR review follow-up: 2026-11-09 + +The user selected the November 9 latest re-review comments, excluding the older November 6 deep-review backlog. + +| PR/comment | Result | Source/validation | +| --- | --- | --- | +| #10 / #309 | Proof names foreign CBB checkpoints and distinguishes requested block from effective BLOCK/LIBRARY scope. | `b7baa24`; 94 backend/lease regressions passed. See `2026-11-09-pr10-review309.md`. | +| #11 / #310 | No new blocking finding; backend synchronized in `e73f9c6`. Existing pause semantics retained. | 43 UI/background/queue regressions passed on the UI branch. | +| #12 / #313 | Incomplete window reads isolated by PID; bounded repeated evidence; native Cancel retains preview scope. | `651b539`; 116 relevant regressions passed, including a real controlled private desktop/window. See `2026-11-09-pr12-review313.md`. | +| #13 integration | Both sides of the residual preview conflict retained: runtime write protection and per-PID read/scope metadata. | Integration merge `b1c36e3`; 136 focused integrated regressions passed. Full result and file hashes in the accompanying JSON. | + +## Line endings + +At the chain tip only, `application.py` is normalized from CRLF to LF. Replacing its LF bytes with CRLF reproduces its prior bytes exactly, and `git diff --ignore-space-at-eol` is empty for this file. `main_window.py` already uses LF. Two specific `.gitattributes` rules pin these files to LF; the global `* -text` rule and every other source file's line-ending policy remain unchanged. No repository-wide normalization or EditorConfig layer is added. + +## Independent review + +The reviewer found no important introduced P1/P2 in the backend/residual changes. Its focused check passed 45 tests with the private-desktop fixture excluded; the coordinator separately ran that actual fixture successfully. A second inspection of the integration confirmed that PR13's active-write, retained-session acknowledgment and durable release records coexist with the new evidence and window-read boundaries. No tests or native operations ran during that integration inspection. + +## Reproduction + +Use the existing `diagnostics/run_review_fixes.py` wrapper from the original workspace against each linked worktree; it isolates the test mutex and sets the intended source path/Qt offscreen. The final full run, compileall and git diff --check results are in `2026-11-09-latest-pr-stack-validation.json`, including evidence hashes and source/test file hashes. + +Current ICO/PNG/SVG hashes match the previously corrected blue check/circular-arrow assets. No candidate executable or ZIP was rebuilt: the previous iconfix package does not contain these fixes. These are source/PR validations, not real Mentor/Windows 10/shared-network/cross-machine acceptance. ICDB automatic Repair remains OFF. PR #3 remains a historical umbrella already covered by #10–#13. The PRs stay Draft; no merge to main, formal release or issue closure is performed. diff --git a/docs/superpowers/plans/2026-11-09-other-pr-latest-reviews.md b/docs/superpowers/plans/2026-11-09-other-pr-latest-reviews.md index 0ac61ac..ccd167c 100644 --- a/docs/superpowers/plans/2026-11-09-other-pr-latest-reviews.md +++ b/docs/superpowers/plans/2026-11-09-other-pr-latest-reviews.md @@ -4,22 +4,22 @@ Scope: user selected only the 2026-11-09 comments #309/#310/#313. Earlier deep-r ## PR #10 -- [ ] Reproduce BlockA releasing historical BlockB checkpoints and retained owners without naming BlockB in proof. -- [ ] Record requested block, actual proof scope, checkpoint identities and foreign names in existing release proof. Preserve original checkpoint bytes and data_recovery_confirmed=False; no new blocking gate. -- [ ] Run backend/lease regressions, compile/diff checks, commit on codex/review-native-backend. +- [x] Reproduce BlockA releasing historical BlockB checkpoints and retained owners without naming BlockB in proof. +- [x] Record requested block, actual proof scope, checkpoint identities and foreign names in existing release proof. Preserve original checkpoint bytes and data_recovery_confirmed=False; no new blocking gate. +- [x] Run backend/lease regressions, compile/diff checks, commit on codex/review-native-backend. ## PR #11/#12 -- [ ] Forward-merge backend into UI, then UI into residual branch; no history rewriting. -- [ ] Test one unreadable process/thread not affecting another, without fabricated modal windows; cover preview and action-time rechecks. -- [ ] Enumerate only target-process threads/windows, store incomplete-read metadata per PID. Keep unknown/active writers protected rather than adding a blind force override. -- [ ] Persist window identities and at most a 4 KiB output excerpt, preserve full preview in memory, stop duplicating activity output. -- [ ] Carry exact preview block scope into native Cancel and recheck identity/scope before clicking. -- [ ] Run residual/UI regressions, compile/diff checks, commit on residual branch. +- [x] Forward-merge backend into UI, then UI into residual branch; no history rewriting. +- [x] Test one unreadable process/thread not affecting another, without fabricated modal windows; cover preview and action-time rechecks. +- [x] Enumerate only target-process threads/windows, store incomplete-read metadata per PID. Keep unknown/active writers protected rather than adding a blind force override. +- [x] Persist window identities and at most a 4 KiB output excerpt, preserve full preview in memory, stop duplicating activity output. +- [x] Carry exact preview block scope into native Cancel and recheck identity/scope before clicking. +- [x] Run residual/UI regressions, compile/diff checks, commit on residual branch. ## Chain tip -- [ ] Merge residual fixes into PR #13, preserving ca39fb3 and icon. -- [ ] Address #11's line-ending note once at the tip: application.py to LF; pin it and main_window.py in EditorConfig. Preserve all other file endings and the global * -text rule. -- [ ] Independent review, integrated full suite, compile/diff checks, validation records and fast-forward pushes to existing PR branches. -- [ ] Update PR descriptions with precise results and no new package/native acceptance. Leave #3 as historical umbrella, without merging or closing it. +- [x] Merge residual fixes into PR #13, preserving ca39fb3 and icon. +- [x] Address #11's line-ending note once at the tip: application.py to LF; pin it and main_window.py with targeted .gitattributes exceptions. Preserve all other file endings and the global * -text rule; EditorConfig is unnecessary. +- [x] Independent review, integrated full suite, compile/diff checks, validation records and fast-forward pushes to existing PR branches. +- [x] Update PR descriptions with precise results and no new package/native acceptance. Leave #3 as historical umbrella, without merging or closing it. diff --git a/src/cbb_refresh_verify/application.py b/src/cbb_refresh_verify/application.py index bd753ff..b4f162b 100644 --- a/src/cbb_refresh_verify/application.py +++ b/src/cbb_refresh_verify/application.py @@ -1,170 +1,170 @@ -from __future__ import annotations -import argparse, os, sys -from contextlib import contextmanager -from pathlib import Path -from typing import Sequence -from .runtime_logging import configure - - -@contextmanager -def batch_stop_signals(stop): - import signal - previous = {} - try: - for name in ('SIGINT', 'SIGTERM', 'SIGBREAK'): - signum = getattr(signal, name, None) - if signum is not None: - previous[signum] = signal.signal(signum, lambda *_: stop.set()) - yield - finally: - for signum, handler in previous.items(): - signal.signal(signum, handler) - - -def configure_qt_application(app): - """Apply a predictable light palette across machines and Qt themes.""" - from PySide6.QtGui import QColor, QPalette - - app.setStyle('Fusion') - palette = app.palette() - colors = { - QPalette.ColorRole.Window: '#f5f6f8', - QPalette.ColorRole.WindowText: '#202124', - QPalette.ColorRole.Base: '#ffffff', - QPalette.ColorRole.AlternateBase: '#eef1f5', - QPalette.ColorRole.Text: '#202124', - QPalette.ColorRole.Button: '#eef1f5', - QPalette.ColorRole.ButtonText: '#202124', - QPalette.ColorRole.Highlight: '#2f6fed', - QPalette.ColorRole.HighlightedText: '#ffffff', - QPalette.ColorRole.ToolTipBase: '#ffffff', - QPalette.ColorRole.ToolTipText: '#202124', - QPalette.ColorRole.PlaceholderText: '#6b7280', - } - for role, color in colors.items(): - palette.setColor(role, QColor(color)) - for role in (QPalette.ColorRole.WindowText, QPalette.ColorRole.Text, QPalette.ColorRole.ButtonText): - palette.setColor(QPalette.ColorGroup.Disabled, role, QColor('#858b94')) - app.setPalette(palette) - app.setStyleSheet( - 'QWidget { color: #202124; }' - 'QTableWidget, QLineEdit, QTextEdit, QSpinBox { ' - 'background: #ffffff; color: #202124; selection-color: #202124; }' - 'QHeaderView::section { background: #e9edf2; color: #202124; }' - 'QPushButton, QToolButton { color: #202124; }' - 'QPushButton:disabled, QToolButton:disabled { color: #858b94; background: #e3e6eb; }' - ) - return app - -def resolve_data_root(cli_value: Path | None) -> Path: - if cli_value is not None: return cli_value.expanduser().resolve() - if getattr(sys, "frozen", False): return Path(sys.executable).resolve().parent / "data" - local = os.environ.get("LOCALAPPDATA") - return (Path(local) / "CbbRefreshVerify" if local else Path.home() / "AppData" / "Local" / "CbbRefreshVerify").resolve() - -def main(argv: Sequence[str] | None = None) -> int: - parser = argparse.ArgumentParser(prog="CbbRefreshVerify") - parser.add_argument('--verify-worker', type=Path, help=argparse.SUPPRESS) - parser.add_argument('--repair-worker', type=Path, help=argparse.SUPPRESS) - parser.add_argument('--owner-probe', type=Path, help=argparse.SUPPRESS) - parser.add_argument('--native-backup-worker', type=Path, help=argparse.SUPPRESS) - parser.add_argument('--management-worker', type=Path, help=argparse.SUPPRESS) - parser.add_argument('--dialog-agent', type=Path, help=argparse.SUPPRESS) - parser.add_argument('--collect-failure-logs', type=Path, help=argparse.SUPPRESS) - parser.add_argument('--batch-lmc', type=Path, help=argparse.SUPPRESS) - parser.add_argument('--block', action='append', default=[], help=argparse.SUPPRESS) - parser.add_argument('--libspec', default='', help=argparse.SUPPRESS) - parser.add_argument('--dms-login-config', default='', help=argparse.SUPPRESS) - parser.add_argument('--mentor-bin', default='', help=argparse.SUPPRESS) - parser.add_argument("--smoke-test", action="store_true", help=argparse.SUPPRESS); parser.add_argument("--data-root", type=Path, help=argparse.SUPPRESS) - args = parser.parse_args(list(argv) if argv is not None else None) - if args.owner_probe: - from .owner_probe import owner_probe_main - return owner_probe_main(args.owner_probe) - if args.native_backup_worker: - from .native_backup import native_backup_worker_main - return native_backup_worker_main(args.native_backup_worker) - if args.management_worker: - from .native_management import management_worker_main - return management_worker_main(args.management_worker) - if args.repair_worker: - from .native_repair_ui import repair_worker_main - return repair_worker_main(args.repair_worker) - if args.collect_failure_logs: - from .verify_diagnostics import failure_logs_main - return failure_logs_main(args.collect_failure_logs) - if args.dialog_agent: - from .dialog_agent import dialog_agent_main - return dialog_agent_main(args.dialog_agent) - if args.verify_worker: - from .mentor_adapter import worker_main - import contextlib - with args.verify_worker.with_name('worker.log').open('a', encoding='utf-8') as log: - with contextlib.redirect_stdout(log), contextlib.redirect_stderr(log): - return worker_main(args.verify_worker) - context = configure(resolve_data_root(args.data_root)); logger = context.logger; logger.info("application_start") - try: - if args.batch_lmc: - from .verify_runner import (VerifyRequest, native_lm_verify_enabled, - run_batch, write_batch_report, failure_report_path) - from .library_reader import read_library_fast - from .batch_status import authoritative_status_map - from .network_path import LibraryPathLease, select_library_file - with LibraryPathLease.acquire(args.batch_lmc) as lease: - mentor_path = select_library_file(lease.mentor_path) - logger.info( - 'library_path_lease display=%s mentor=%s drive=%s remote=%s created=%s', - lease.display_path, mentor_path, lease.drive or '-', - lease.remote_root or '-', lease.created) - names = list(args.block) - if not names: - library = read_library_fast( - mentor_path, - status_reader=lambda path, names: authoritative_status_map( - names, path, context.root/'status-scan.jsonl'), - ) - if library.error: raise RuntimeError(library.error) - names = [record.name for record in library.records if record.status != 'READY'] - if not names: raise RuntimeError('中心库未读取到需要校验的 CBB') - requests = [VerifyRequest(mentor_path, name, context.root/'evidence', - libspec=args.libspec, dms_login_config=args.dms_login_config, - mentor_bin=args.mentor_bin, logging_context=context, - mapped_drive=lease.drive, - mapped_remote_root=lease.remote_root, - native_lm_verify=native_lm_verify_enabled()) - for name in names] - try: - from threading import Event - stop = Event() - with batch_stop_signals(stop): - results = run_batch(requests, stop=stop) - except Exception: - lease.retain_for_recovery() - raise - if any(not result.safe_to_continue for result in results): - lease.retain_for_recovery() - report = write_batch_report(requests, results, context.root/'reports') - logger.info('batch_report path=%s', report) - logger.info('failure_report path=%s', failure_report_path(report)) - code = 0 if all(result.status == 'PASS' for result in results) else 2 - logger.info('application_clean_shutdown exit_code=%s', code) - return code - from .ui.main_window import MainWindow, application_icon_path - if args.smoke_test: - os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen') - from PySide6.QtWidgets import QApplication - app = QApplication.instance() or QApplication([sys.executable]) - configure_qt_application(app) - window = MainWindow(logging_context=context); window.show() - icon_path = application_icon_path() - if icon_path.is_file(): - from PySide6.QtGui import QIcon - app.setWindowIcon(QIcon(str(icon_path))) - if args.smoke_test: - from PySide6.QtCore import QTimer - logger.info('gui_smoke_window_created title=%s', window.windowTitle()) - QTimer.singleShot(250, app.quit) - code = int(app.exec()); logger.info("application_clean_shutdown exit_code=%s", code); return code - except Exception: logger.exception("application_startup_failure"); return 1 - finally: - for handler in logger.handlers: handler.flush() +from __future__ import annotations +import argparse, os, sys +from contextlib import contextmanager +from pathlib import Path +from typing import Sequence +from .runtime_logging import configure + + +@contextmanager +def batch_stop_signals(stop): + import signal + previous = {} + try: + for name in ('SIGINT', 'SIGTERM', 'SIGBREAK'): + signum = getattr(signal, name, None) + if signum is not None: + previous[signum] = signal.signal(signum, lambda *_: stop.set()) + yield + finally: + for signum, handler in previous.items(): + signal.signal(signum, handler) + + +def configure_qt_application(app): + """Apply a predictable light palette across machines and Qt themes.""" + from PySide6.QtGui import QColor, QPalette + + app.setStyle('Fusion') + palette = app.palette() + colors = { + QPalette.ColorRole.Window: '#f5f6f8', + QPalette.ColorRole.WindowText: '#202124', + QPalette.ColorRole.Base: '#ffffff', + QPalette.ColorRole.AlternateBase: '#eef1f5', + QPalette.ColorRole.Text: '#202124', + QPalette.ColorRole.Button: '#eef1f5', + QPalette.ColorRole.ButtonText: '#202124', + QPalette.ColorRole.Highlight: '#2f6fed', + QPalette.ColorRole.HighlightedText: '#ffffff', + QPalette.ColorRole.ToolTipBase: '#ffffff', + QPalette.ColorRole.ToolTipText: '#202124', + QPalette.ColorRole.PlaceholderText: '#6b7280', + } + for role, color in colors.items(): + palette.setColor(role, QColor(color)) + for role in (QPalette.ColorRole.WindowText, QPalette.ColorRole.Text, QPalette.ColorRole.ButtonText): + palette.setColor(QPalette.ColorGroup.Disabled, role, QColor('#858b94')) + app.setPalette(palette) + app.setStyleSheet( + 'QWidget { color: #202124; }' + 'QTableWidget, QLineEdit, QTextEdit, QSpinBox { ' + 'background: #ffffff; color: #202124; selection-color: #202124; }' + 'QHeaderView::section { background: #e9edf2; color: #202124; }' + 'QPushButton, QToolButton { color: #202124; }' + 'QPushButton:disabled, QToolButton:disabled { color: #858b94; background: #e3e6eb; }' + ) + return app + +def resolve_data_root(cli_value: Path | None) -> Path: + if cli_value is not None: return cli_value.expanduser().resolve() + if getattr(sys, "frozen", False): return Path(sys.executable).resolve().parent / "data" + local = os.environ.get("LOCALAPPDATA") + return (Path(local) / "CbbRefreshVerify" if local else Path.home() / "AppData" / "Local" / "CbbRefreshVerify").resolve() + +def main(argv: Sequence[str] | None = None) -> int: + parser = argparse.ArgumentParser(prog="CbbRefreshVerify") + parser.add_argument('--verify-worker', type=Path, help=argparse.SUPPRESS) + parser.add_argument('--repair-worker', type=Path, help=argparse.SUPPRESS) + parser.add_argument('--owner-probe', type=Path, help=argparse.SUPPRESS) + parser.add_argument('--native-backup-worker', type=Path, help=argparse.SUPPRESS) + parser.add_argument('--management-worker', type=Path, help=argparse.SUPPRESS) + parser.add_argument('--dialog-agent', type=Path, help=argparse.SUPPRESS) + parser.add_argument('--collect-failure-logs', type=Path, help=argparse.SUPPRESS) + parser.add_argument('--batch-lmc', type=Path, help=argparse.SUPPRESS) + parser.add_argument('--block', action='append', default=[], help=argparse.SUPPRESS) + parser.add_argument('--libspec', default='', help=argparse.SUPPRESS) + parser.add_argument('--dms-login-config', default='', help=argparse.SUPPRESS) + parser.add_argument('--mentor-bin', default='', help=argparse.SUPPRESS) + parser.add_argument("--smoke-test", action="store_true", help=argparse.SUPPRESS); parser.add_argument("--data-root", type=Path, help=argparse.SUPPRESS) + args = parser.parse_args(list(argv) if argv is not None else None) + if args.owner_probe: + from .owner_probe import owner_probe_main + return owner_probe_main(args.owner_probe) + if args.native_backup_worker: + from .native_backup import native_backup_worker_main + return native_backup_worker_main(args.native_backup_worker) + if args.management_worker: + from .native_management import management_worker_main + return management_worker_main(args.management_worker) + if args.repair_worker: + from .native_repair_ui import repair_worker_main + return repair_worker_main(args.repair_worker) + if args.collect_failure_logs: + from .verify_diagnostics import failure_logs_main + return failure_logs_main(args.collect_failure_logs) + if args.dialog_agent: + from .dialog_agent import dialog_agent_main + return dialog_agent_main(args.dialog_agent) + if args.verify_worker: + from .mentor_adapter import worker_main + import contextlib + with args.verify_worker.with_name('worker.log').open('a', encoding='utf-8') as log: + with contextlib.redirect_stdout(log), contextlib.redirect_stderr(log): + return worker_main(args.verify_worker) + context = configure(resolve_data_root(args.data_root)); logger = context.logger; logger.info("application_start") + try: + if args.batch_lmc: + from .verify_runner import (VerifyRequest, native_lm_verify_enabled, + run_batch, write_batch_report, failure_report_path) + from .library_reader import read_library_fast + from .batch_status import authoritative_status_map + from .network_path import LibraryPathLease, select_library_file + with LibraryPathLease.acquire(args.batch_lmc) as lease: + mentor_path = select_library_file(lease.mentor_path) + logger.info( + 'library_path_lease display=%s mentor=%s drive=%s remote=%s created=%s', + lease.display_path, mentor_path, lease.drive or '-', + lease.remote_root or '-', lease.created) + names = list(args.block) + if not names: + library = read_library_fast( + mentor_path, + status_reader=lambda path, names: authoritative_status_map( + names, path, context.root/'status-scan.jsonl'), + ) + if library.error: raise RuntimeError(library.error) + names = [record.name for record in library.records if record.status != 'READY'] + if not names: raise RuntimeError('中心库未读取到需要校验的 CBB') + requests = [VerifyRequest(mentor_path, name, context.root/'evidence', + libspec=args.libspec, dms_login_config=args.dms_login_config, + mentor_bin=args.mentor_bin, logging_context=context, + mapped_drive=lease.drive, + mapped_remote_root=lease.remote_root, + native_lm_verify=native_lm_verify_enabled()) + for name in names] + try: + from threading import Event + stop = Event() + with batch_stop_signals(stop): + results = run_batch(requests, stop=stop) + except Exception: + lease.retain_for_recovery() + raise + if any(not result.safe_to_continue for result in results): + lease.retain_for_recovery() + report = write_batch_report(requests, results, context.root/'reports') + logger.info('batch_report path=%s', report) + logger.info('failure_report path=%s', failure_report_path(report)) + code = 0 if all(result.status == 'PASS' for result in results) else 2 + logger.info('application_clean_shutdown exit_code=%s', code) + return code + from .ui.main_window import MainWindow, application_icon_path + if args.smoke_test: + os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen') + from PySide6.QtWidgets import QApplication + app = QApplication.instance() or QApplication([sys.executable]) + configure_qt_application(app) + window = MainWindow(logging_context=context); window.show() + icon_path = application_icon_path() + if icon_path.is_file(): + from PySide6.QtGui import QIcon + app.setWindowIcon(QIcon(str(icon_path))) + if args.smoke_test: + from PySide6.QtCore import QTimer + logger.info('gui_smoke_window_created title=%s', window.windowTitle()) + QTimer.singleShot(250, app.quit) + code = int(app.exec()); logger.info("application_clean_shutdown exit_code=%s", code); return code + except Exception: logger.exception("application_startup_failure"); return 1 + finally: + for handler in logger.handlers: handler.flush()