fix: complete issue17 cleanup and bounded native verification

This commit is contained in:
阿白叔 committed 2026-11-18 19:13:49 +08:00
1 parent 14cacb1d1c
commit 07eab61695
12 files changed
+642 -26

No files matched your search

@@ -0,0 +1,191 @@
{
"issue": 17,
"date": "2026-11-18",
"branch": "codex/issue17-batch-cleanup",
"baseline": "14cacb1d1cc9f4be6665fb5ce9434333599d0898",
"scope": "Source GUI and real Mentor, constructed isolated fault; not original field acceptance or frozen ZIP",
"tests": {
"tests": 2455,
"failures": 0,
"errors": 0,
"skipped": 0
},
"test_seconds": 891.372,
"cases": [
{
"1GPHY_8212": "FAIL",
"2GPHY_ZX5201": "PASS"
},
{
"1GPHY_RTL8211F": "PASS"
}
],
"same_ui_process": 65016,
"exact_process_identities_checked": 19,
"exclusive_files_checked": 8,
"automatic_followups": 1,
"original_source": {
"status": "PASS",
"source": "G:\\CbbIssue15FinalAccept-20261117\\run-final-01\\library",
"checked_at": "2026-11-18T11:06:18.160306+00:00",
"files": 28348,
"missing": [],
"added": [],
"changed": [],
"excluded": "top-level .mentor_lib.cbb-upload.* coordinator files, matching pre-test manifest"
},
"source_under_test_sha256": {
"src/cbb_refresh_verify/application.py": "aa02778f4ea4665a9d94926ae86fca32f7dadb535d1460b13fdbb064113eaf33",
"src/cbb_refresh_verify/backup_recovery.py": "eb5813b442de668650fff1ee800d3fba1409af233e374ea37b6ced688cc630e9",
"src/cbb_refresh_verify/batch_status.py": "55a4007cf54491ca8e045a5bf86aa4353ac8437cca5a76cd79304962e3d3fa0a",
"src/cbb_refresh_verify/close_failed_block.vbs": "e5f0d9678e07a239e96e634b90cdc761de52fc136311fae31484fa38d6fd9781",
"src/cbb_refresh_verify/com_runtime.py": "f0f3802d16c791a8bf9dfef44a94917072bfbe8fb3a927d76be8ef0341c7ed35",
"src/cbb_refresh_verify/content_check.py": "8239c17b6e2452917ed573a7deb3e4c8583eaef91bf3630eff5f424d2e398aa9",
"src/cbb_refresh_verify/defaults.py": "a1c03192f4a61ad0924b24bb635705b1ee4811d35483a02864200f95edbbebe3",
"src/cbb_refresh_verify/desktop_worker.py": "81d58513369046300f81cec20a43c3e681e38e46e8131427b354f9dff0e5241a",
"src/cbb_refresh_verify/diagnostic_open.py": "1a12a4a75d8303b3eb85fd0e50923f1e9e7d8cd619e24d6119c1fd286e4985e0",
"src/cbb_refresh_verify/dialog_agent.py": "5acb6e5cf1350a7ca20a6fe480668435fac785835874f266881973010db6504b",
"src/cbb_refresh_verify/dialog_models.py": "f68cee01d927b48364276d3c1f79e63ce8af231878db0b907d292780cfbafb56",
"src/cbb_refresh_verify/dialog_probe.py": "d6ecd359d9e5dbc9376c0a5b123c881670fc01d60dd3290a5f6468a2f599462f",
"src/cbb_refresh_verify/dialog_rules.py": "5531ea7b34cf2094629e7a750cb32a678701c5353a97616bcf7a89b903e386a1",
"src/cbb_refresh_verify/dialog_supervisor.py": "b0eb0aa92a18498843b51b6d8697bd0abfe8b014e1c545e32ddcc8baf7ff7274",
"src/cbb_refresh_verify/failed_session.py": "2b8a6321e1f4ff9b697d0e01ca85a8dd6e3672d3b32a9a6e4816cf495572e1a5",
"src/cbb_refresh_verify/file_probe.py": "849b1a36e4ee1fc6074cee5db5a2d5a4c806fb6e3a309df96e9cd387a66bba28",
"src/cbb_refresh_verify/icdb_maintenance.py": "e81d253d8b4d3e7c1000c45335a392c72b110748675c2c3324ebe524a7252e98",
"src/cbb_refresh_verify/icdb_ownership.py": "b1e25e5eddce70292c0ea2f67c2a3533273e64746b36d500b501b096470f7a5d",
"src/cbb_refresh_verify/icdb_recovery.py": "2d5ef548335ac0ca277241326ee51f5a015d327a646a7c7aa60f67165c1bfca1",
"src/cbb_refresh_verify/integration.py": "f188856af69ba25e265988c51db7a6d4263326440d972ca78378b733b891c1ed",
"src/cbb_refresh_verify/library_lock.py": "1b98c20f6127ad9b29cbf4f082289b093ec89475313e016dcb88202308cf9587",
"src/cbb_refresh_verify/library_manager_verify.py": "71e16a8581ad44b646be78b480f9812d596a6d162b3eec03d078bf4ea4503195",
"src/cbb_refresh_verify/library_reader.py": "7831b502aa1f637426ab2e22f11cb6666e69200b7615925050a5af7472a84b2b",
"src/cbb_refresh_verify/maintenance_entry.py": "ddd0480ad8b04fd99462befbe6683bace526bf5085afb1ee3de918f30e796683",
"src/cbb_refresh_verify/management.py": "b9d297ae673afea09b64bac154a7181da1e01f4c5c0cf5355dddcaeec807f8cf",
"src/cbb_refresh_verify/management_transaction.py": "53ed1564d42492465c90117eeeeee25aa93324b5ddca702d0827ec786c75b1a1",
"src/cbb_refresh_verify/mentor_adapter.py": "b9485603e42fc098ba93fd90b5adce7b0b89085ede6390019d3be9332795eb18",
"src/cbb_refresh_verify/mentor_paths.py": "ba48c0003b3eacc88906497b2e43b299ca4536a9f7dae44bbacf6a6ec694c116",
"src/cbb_refresh_verify/models.py": "94d9d28c61ff7642ae59ac9af91a698bffd15c86a995295576fbbb2143faf789",
"src/cbb_refresh_verify/native_add_failures.py": "192202732423dc624c5548c75e80bb20973e5087c21d4798c9637f25b6de7e94",
"src/cbb_refresh_verify/native_backup.py": "152235f69aefe1bd1338fdd0ed2dec8afb7355de63399f746b02e31047be7909",
"src/cbb_refresh_verify/native_engineering_identity.py": "8c0fc144707d68a9b85f6da50ef950f1f6e7fee248acbf34d19b707d51212be0",
"src/cbb_refresh_verify/native_export_guard.py": "3f6af07737ee670584e6fa9d004c040cf318c3d568e8fa82f84eb70d351b3d6a",
"src/cbb_refresh_verify/native_management.py": "38503011be1c0d4755dd72a4d283d7704937aa576e9f8f9fc3382fc9f4b0be4e",
"src/cbb_refresh_verify/native_occupancy.py": "7d686079d12217382adace6361cd343d977b91075e3b157cf410ca92d07ffc49",
"src/cbb_refresh_verify/native_repair.py": "a720758b8195fd399c81673c13a1d38e69917c9c053e28967ff4e75f40118950",
"src/cbb_refresh_verify/native_repair_ui.py": "9bfb413193d9a917f5ac71d5826e6682b3d0e40d822a5f8366a28f71ca542690",
"src/cbb_refresh_verify/network_path.py": "6b5b159502d42a46bf4ee26d5698fd2c6498b359088e2138eae46e9065b13c6f",
"src/cbb_refresh_verify/operation_lifecycle.py": "d2d654f0e2f7171f60c2d7ad2b4d7cfc3fa3bc9d8a72b64d395a4891b5579007",
"src/cbb_refresh_verify/operation_queue.py": "2a826f8234666867a6dbbacc572a1a8e196864bc3745c8d55dc9e261d6806858",
"src/cbb_refresh_verify/owner_probe.py": "8dcfd60246cb2979db34d02e0a2d605c334b6f7e2666f22daa2f50c0408bc903",
"src/cbb_refresh_verify/pcb_bridge.py": "2f6c2b09642100468814500569dbfc6695fc2a46b9a3b8333daa8e1530cdeef5",
"src/cbb_refresh_verify/pcb_open_consent.py": "ba4d8da5ce3f7ed924621eb37b925371f14d074acaf9814adfb0f77fc6bb73e1",
"src/cbb_refresh_verify/pcb_restore_prompt.py": "a488ab48845173f463042c17ad1e719fe37a4bcf98a660f06453eef171b0e7bb",
"src/cbb_refresh_verify/post_repair_consent.py": "3b1eaff1db58fd311a9dbc5fdcd850911b04cc5afd4e747f70a62b721b8fafa4",
"src/cbb_refresh_verify/post_verify_diagnostics.py": "2442de485bc0d6a34c4b2d9b10bc5f323ea38f9ff66674119a50f5c6043bac63",
"src/cbb_refresh_verify/reimport_recovery.py": "ef148549751fa47518f5f2ca8f32ba25794ec5f22e0de545476ea33f89a3f0bf",
"src/cbb_refresh_verify/residual_sessions.py": "fcf75f47f650a81c2794519bc211640214b6d888bcfb43dd7fbbf146a8a3012e",
"src/cbb_refresh_verify/runtime_logging.py": "44ac25430a89c5ffc9e48e88c227e88052f4c815365e8556f67918f3edaba39e",
"src/cbb_refresh_verify/runtime_timing.py": "c4ed4057b5000e0b86ccc7dd1fe2004d6e0dae29f397fec77b01ad41a81c6367",
"src/cbb_refresh_verify/save_verified_block.vbs": "862fc40f4cf59c73ff0efa3dee1de3fff92df019e43cce46d4fa337378087143",
"src/cbb_refresh_verify/scoped_manifest.py": "f141cfedc901ddadb9be837bc0cbb69c57614d44ab9c347d63bbfa15d4be4a8b",
"src/cbb_refresh_verify/session_record.py": "0273758c6c28557b45230258762756cf05eac5ea2f8f08a8cb7deae2857694fa",
"src/cbb_refresh_verify/status_bridge.py": "05d627d02934a14f5de409472c291d37565a95b836f9c130111aae80612e9196",
"src/cbb_refresh_verify/verify_diagnostics.py": "041b77d7d49e4c86338ed5e5741d0d27a2c42bc358f4da54b3efe64af847e9b8",
"src/cbb_refresh_verify/verify_probe.py": "3ed743df49d195c74f5045985ab23491d103ee2c42c07b558c1e037176402ed2",
"src/cbb_refresh_verify/verify_runner.py": "16a622fb23a903a921e6d949a05f7aaabadac776647efef618004871645d2dc1",
"src/cbb_refresh_verify/write_admission.py": "c5f879bd5cb70a5dedfc64349c8758bf370daa4240491addd2aecd344f3a935c",
"src/cbb_refresh_verify/__init__.py": "673ad8f884cd8a8f4c4097b348be1b77999ec018bdc6c70ab26b8cc383669878",
"src/cbb_refresh_verify/__main__.py": "dc4be034a0e43d4b659a9300137c29a6a6b7a32b7eaef02b6dff9a88c41305c0",
"src/cbb_refresh_verify/assets/cbb_refresh_verify.ico": "62d4472ebaa94f9b39aebae06459685d3322041d0e1a7ada9f368cfd816ba1d6",
"src/cbb_refresh_verify/assets/cbb_refresh_verify.png": "840f657fd7c622d9afd78625a64ed8ad04c90a895dd3c9fd37eebae543cdebe8",
"src/cbb_refresh_verify/assets/cbb_refresh_verify.svg": "cbba5b3f339cbeb5eb43012709237359442ef67c69fc5b6679a8ee4c0a1b7328",
"src/cbb_refresh_verify/assets/dialog_rules.v1.json": "3911080fc799a819662e225a7ad73e883abd8dcc9936cc30ec1b2d6d51a03c6e",
"src/cbb_refresh_verify/ui/backup_notice.py": "1a3fa5ac18a267907faf95f36d61b9f08bcbb939eef4d480dd06af1391a81599",
"src/cbb_refresh_verify/ui/backup_recovery_dialog.py": "c262ec52f870497a18b6034ab98b18498f0e7b703c131cf0d739a17e776deea3",
"src/cbb_refresh_verify/ui/icdb_check_task.py": "955a0f9e2e351e744335c7ff3eab5ad17558a4e364bf13d1e90592e18b118510",
"src/cbb_refresh_verify/ui/main_window.py": "1bb57fa6f35ac570d8810ffa4970c2cb90a6517bc6df70ef2f1a4f0c606cb64c",
"src/cbb_refresh_verify/ui/management_dialog.py": "9e94eda31765ef84b524a9be2d2c81e5aeca85d416c9b64c135d375af88d5250",
"src/cbb_refresh_verify/ui/pcb_open_dialog.py": "1b9689d555d221567263b6b587250b51a11bef276c35d64393e1b3d13803c625",
"src/cbb_refresh_verify/ui/pcb_restore_dialog.py": "11479db5520310af37824e083cb678d69d4cfd12f70dcd29ccb906b929e3d9bd",
"src/cbb_refresh_verify/ui/residual_release_dialog.py": "c2ebc63dd67186dff8ab2300a04ec173219314c2ad01cc70621630f30295a9cc",
"src/cbb_refresh_verify/ui/timed_prompt.py": "bafd5027d396e50458e4bd81e4596be51ebf87353f688e31943a97d71d2d5121",
"src/cbb_refresh_verify/ui/workers.py": "4cc9360a4820ded27a7d5ef709fc9f04b1d4804cb1e7a614f6c357ed547da888",
"src/cbb_refresh_verify/ui/write_owner_dialog.py": "65dc3c8287f4ac5dc767797c13e192f6bd916f9051570a33a2b18f4f8334c3b3",
"src/cbb_refresh_verify/ui/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"receipts_root": "G:\\CbbIssueLatest-20261118",
"receipt_sha256": {
"issue17-original.zip": {
"bytes": 124556,
"sha256": "fc4b1fa9be56bd1b90e9c88de69b46a9b82f43cece7e807a13581a7627cf05ee"
},
"analysis.md": {
"bytes": 11671,
"sha256": "e0b533ca60ae54b66280edb0b7f868de4a5f155b58ee0da776e52199bddad9f9"
},
"review.md": {
"bytes": 15515,
"sha256": "63caecf5d2e49ee9219eef8d6ab4fea408db3179e820f8552fd64a420390c374"
},
"checks/issue17-full.log": {
"bytes": 2972,
"sha256": "d725001d7b575b60855acef3f8b29b8fd04ea0d108c154d723f8a09608885eb9"
},
"checks/issue17-full.xml": {
"bytes": 358156,
"sha256": "30eb52534613ad1bda0ca2d7a1b7ba355c707060671239f4f9b3fd3a7f734fee"
},
"checks/followup-final.log": {
"bytes": 219,
"sha256": "643e5d25f5ff619c08e211a92d362b32443a3c57b4e9dcab90826c57983c293a"
},
"native/final-source-under-test.json": {
"bytes": 9102,
"sha256": "4ad209d78e01295572f3113e4c9e6f9cb1bbc0a39daded16f7314ef9d52ae2d8"
},
"native/source-copy.json": {
"bytes": 6331491,
"sha256": "f24830cce023a987a450756488425b229a36f9c0a967cee7ddebfa724f571f83"
},
"native/original-source-postcheck.json": {
"bytes": 321,
"sha256": "1cbb127c04eb74387124f2a9fc81d0c4c4017ebc7a36cb5fa1c706726e57904f"
},
"native/native-closure-proof.json": {
"bytes": 4742,
"sha256": "a434f152fdd4554a79b35945c2a8bcaa5d8faf0d38b8557d42ac29e7de30dc83"
},
"native/fault-receipt.json": {
"bytes": 576,
"sha256": "d65146f3e88271646ce2fe363c8d45e1cd70e8255544634ed1eff7ec75059902"
},
"native/actual-first-result.json": {
"bytes": 2622,
"sha256": "4c35bacbb66180f315313b6ef85c3fc564e4909c30d082d30724b31f86e70896"
},
"native/actual-retry-result.json": {
"bytes": 2496,
"sha256": "a63b6023b9176aaa00ffc2e0f5b7db68d6d36c868dca5c6cc66e665b41a1a381"
},
"native/actual-final-result.json": {
"bytes": 2631,
"sha256": "bb35ae4d15fd8f83dab7c035f6891557167331cdb57b466cbb4652992f30fccb"
},
"native/actual-retry-final-result.json": {
"bytes": 2501,
"sha256": "2a8a2e42ce507a5f1e4e23eb610b75ea31133386836dfad737e1e5706ff1dc45"
},
"native/invalid/actual-ui-results.json": {
"bytes": 6124,
"sha256": "1c66d007dcaede8d3a6238ebe14d3444089dc8b4d8e911d5b29bd0aac10b7cda"
},
"native/run-source-01/data/evidence/verify-d182cd8344bf/commit-followup.json": {
"bytes": 452,
"sha256": "097ac62e8c142c8472eb822e5d041f4612b84212e6af492acef705b6283aac07"
}
},
"forced_native_terminations": 0,
"deleted_native_lock_files": 0,
"merged": false,
"released": false,
"issue_closed": false
}
@@ -0,0 +1,45 @@
# 工单 #17 修复与实际验证记录
日期:2026-11-18。分支:`codex/issue17-batch-cleanup`;基线:`14cacb1d1cc9f4be6665fb5ce9434333599d0898`。本记录对应源码 GUI;已发布的 `v0.2.4-beta.4` ZIP 不包含这些未发布修复。
## 问题与修改
工单附件中的批次实际为 6 PASS、1 数据库加载 FAIL、11 READY 跳过,以及 346 项因同库未释放状态被跳过。附件中的数据库加载失败不能直接证明 ICDB 格式损坏。
- 精确识别 EE7.9.5 数据库加载失败后的“是否查看日志”窗口,选择否;监督器已经处理该窗口时,收尾可读取本轮精确证据,正常关闭本任务的空 PCB。未知窗口、已有文档和身份不符仍保留保护。
- 后续同库项前重新核对失败会话;确认释放后清除该失败项的全部库路径别名,继续队列。原失败不改为 PASS。没有确认释放时仍不允许下一个同库写入。
- 成功退出不再误报保留会话。保存日志分别记录工程、文档和 IsSaved;仅短暂 IsSaved 状态允许有界重试,身份不匹配或 COM 错误仍失败。
- 全库状态任务预算从 10 秒调为有界 120 秒;UNKNOWN 显示为“待读取”,不计作工程异常,不进入生产校验。执行前重新读取状态,只有 PENDING 才开始校验;READY 仍跳过。备份恢复等独立操作不共用这个校验门槛。
- 原生已 COMMITTED/CLOSED/EXITED/RELEASED、未中断,但权威仍为 NOT_GREEN,且类别精确为 `MENTOR_VERIFY_NOT_COMMITTED` 时,普通校验允许最多一次补充原生校验。它会再次打开并写入工程,不是只读重查;不适用于打开失败、保存/关闭/释放未确认、诊断或 Repair。两轮证据关联,首轮失败保留,累计总耗时;取消后不再启动补充调用。
## 实际验证方法
证据目录:`G:/CbbIssueLatest-20261118/native`。
从既有隔离库 `G:/CbbIssue15FinalAccept-20261117/run-final-01/library` 冷复制 28,348 个文件,每个文件核对 SHA-256、大小和修改时间,30 个工程引用重绑定到新副本。原复制清单明确排除旧运行顶层 `.mentor_lib.cbb-upload.*` 协调记录。所有原生写入仅针对新副本。
在副本 `1GPHY_8212/Work/database/icdb.dat` 中构造等长头部损坏,原始头部另存。此用例是 **构造损坏,不是现场原始故障复现**。健康项由原生同名更新准备为 PENDING。实际应用运行在隔离桌面,通过真实 GUI 控件提交批次;未替换校验后端,没有前台抢鼠标、强杀原生进程或删除原生锁文件。
源码身份记录为 `final-source-under-test.json`,包含 76 个源码文件/资源的 SHA-256;收尾核对确认与实测源码一致。
## 实测结果
| 用例 | 真实结果与证据 |
| --- | --- |
| 初次试验,修改补充校验逻辑之前 | `actual-first-result.json` 明确保留 FAIL/FAIL:故障项已安全释放,健康项完成保存关闭但权威 PENDING,验收未通过。随后显式重跑健康项达到 READY;这次手动重跑仅用于分析,不算自动链路通过。 |
| 最终源码,故障项 → 健康项 | `actual-final-result.json`:8212 为 FAIL、safe=true(80.390 秒);随后 ZX5201 为 PASS/GREEN、safe=true(88.453 秒)。恰好两行,无 SKIPPED,无后续暂停。执行中修改筛选、清空勾选、切换管理/校验页面,已提交目标仍完整执行。 |
| 同一应用下一批,自动补充校验 | `actual-retry-final-result.json`:RTL 首轮 PENDING/raw=0(91.829 秒),自动补充一次达到 READY/raw=1(74.656 秒);最终一行 PASS,总原生耗时 166.485 秒。`verify-d182cd8344bf/commit-followup.json` 关联首轮失败与 `verify-fde77746a92e`,限制额外调用次数为 1。 |
| 释放与再次使用 | `native-closure-proof.json`:同一 UI PID 65016 中完成两批;核对 19 个进程身份退出及 8 个文件独占打开,无本轮原生进程残留。一个旧 PID 已被晚创建的系统服务复用,通过 WMI 创建时间证明原身份退出,未触碰该系统服务。损坏头部未被偷偷修复。UI 随后正常关闭,退出码 0。 |
| 输入与空闲按钮 | 空 LMC、错误后缀、缺失文件分别显示 INPUT_EMPTY/SUFFIX/MISSING,禁用写入;真实状态读取完成后空闲取消按钮禁用。证据:`invalid/actual-ui-results.json`。 |
夹具准备曾因其他任务的原生会话拒绝一次 Add,原生同名更新留下的缺失条目通过正常 Add 恢复,记录在 `pending-2GPHY_ZX5201.json` / `restored-preparation.json`;不能将这次准备失败混作通过。另一次移动 Cert 的试验没有改变权威 READY,已完整恢复,未用作 PENDING 输入。其他任务的进程均未关闭。
## 自动化验证与边界
`original-source-postcheck.json`:原始隔离输入 28,348 个文件的 SHA-256、大小、修改时间和文件集合全部一致,缺失/新增/变化均为 0;排除项严格沿用复制前的顶层协调记录规则。
全量测试:`python -X utf8 G:/CbbIssueLatest-20261118/run_checks.py issue17-full -q`,**2,455 passed,0 failed/error/skipped**,893.79 秒,实际退出码 0。`python -X utf8 -m compileall -q src tests` 与差异格式检查通过。新增回归均保留 RED/GREEN 记录,覆盖精确窗口、监督器先处理、未知窗口、库路径别名、状态重新准入、独立恢复、32 位 VBS、最多一次补充调用、取消时协调句柄释放及双轮计时。
同目录 `2026-11-18-issue17-cleanup-validation.json` 保存源码指纹、测试统计、关键验收计数和外部原始证据 SHA-256,供复核对应关系。独立代码复核未留下待修问题,并独立核对实际自动链路与全部 76 个源码指纹。
本轮原生样本为一个构造故障接一个健康项,以及同一应用下一批一个健康项的自动补充校验。没有完成现场原始故障一致副本、一个故障接五个健康项的完整矩阵、冻结新包或 Windows 10/11 全环境验收;不能据此宣布现场 ICDB 问题已解决或全部真实占用均可忽略。本轮不关闭工单、不合并、不发行。
@@ -0,0 +1,18 @@
# 工单 #17:失败项收尾与后续任务准入
按用户“开始修复,并实际验证收尾闭环”的授权实施。沿用 2026-11-18 工单附件分析;不改 ICDB 自动 Repair、READY 跳过策略和原生 Verify 路线。
1. 以工单精确数据库加载失败问题补回归:直接遇到“是否查看日志”、监督器先行点否、空 PCB 关闭、未知弹窗保留。
2. 修复成功 worker 误报保留会话;保存后分别记录工程路径、文档名、IsSaved,短暂状态有界重试,不放宽身份/Close/READY 条件。
3. 目录完整状态查询采用足够且有界的任务预算;UNKNOWN 独立显示,不进入生产批量校验;目录结束后刷新取消按钮状态。
4. 批次在后续同库项前复核先前未释放项,释放成功后清除其全部路径别名,原失败不改为 PASS。真实未释放仍不可强行写入;不同库继续独立。
5. 实测使用既有隔离验证库的全量一致副本,记录来源、完整复制哈希及工程引用重绑定。健康项先通过原生同名更新成为 PENDING;只在本次副本制造打开故障。通过实际应用按钮运行故障批次、再次运行批次,检查真实原生启动、Save/Close、READY、精确 PID 退出、协调句柄和会话记录,不以模拟或原本 READY 的跳过代替通过。
6. 全量测试和编译检查,记录源码身份、实际步骤及未通过边界。保留工单打开,不自动合并或发行。
工单附件将“任何收尾失败都继续写下一块”与“基础设施错误十次熔断”并列。本次优先消除可自动完成的失败收尾及过期阻塞,不以强杀未知写入或伪造 RELEASED 达成队列继续。
实测补充:首次原生同名导入后,健康控制项完成 Save/Close/退出、三次权威 PENDING/raw=0,未生成 Cert;同一应用显式再次校验触发原生“保存复用块”确认并达到 READY/raw=1。保留首轮失败,不把它重记为通过。
据此新增有界提交补完:仅普通校验得到 MENTOR_VERIFY_NOT_COMMITTED,且 COMMITTED/CLOSED/EXITED/RELEASED、未中断、权威 NOT_GREEN 时,记录检查点后最多再执行一次完整原生校验。它会再次打开工程并执行原生写入,**不是只读状态重查**。不适用于数据库打开失败、未知保存/关闭/释放、诊断、自动 Repair 或 Repair 确认流程。第二次仍不为 READY 就保留失败,不循环。两轮证据关联、累计耗时,首轮证据不覆盖;取消后不进入第二轮,补完前取消也必须释放已完成首轮的协调句柄。自动链路仍需实际按钮验收,显式重跑成功本身不算通过。
最终源码按钮验收已记录:故障项 FAIL 安全释放后下一项 PASS;同一应用下一批首轮 PENDING 后自动一次补完为 READY。未强杀、删除原生锁或手动释放。进程/独占文件核对通过;完整边界与证据见 `docs/releases/2026-11-18-issue17-cleanup-validation.md`,保留现场原始故障与冻结包验收缺口。
+38 -1
View File
@@ -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
+1 -1
View File
@@ -911,7 +911,7 @@ def execute_job(job, emit):
pass
if helper is not None and helper.poll() is None:
emit(stage='save_helper_retained', helper_pid=helper.pid)
elif helper is not None:
elif helper is not None and not completed:
# A failed/truncated Save result never authorizes discard-close.
emit(stage='save_result_retained', detail='保存或关闭结果不完整,保留原生会话供核对')
elif diagnostic_close_attempted:
+20 -8
View File
@@ -1,6 +1,6 @@
Option Explicit
Dim app, doc, pi, licensing, token, expected, attempt, stable, measuredStart, operationOK, remaining
Dim nativeError, nativeDescription
Dim nativeError, nativeDescription, actualProject, actualDocument, expectedDocument, savedState
WaitForStartGate
CheckCancellation
expected = WScript.Arguments(0)
@@ -79,13 +79,25 @@ If Not stable Then
WScript.Quit 7
End If
WScript.Echo "POST_SAVE_SYNCHRONIZED"
On Error Resume Next
operationOK = doc.IsSaved() And LCase(pi.ProjectFile) = LCase(expected)
If WScript.Arguments.Count > 1 Then operationOK = operationOK And LCase(doc.Name) = LCase(WScript.Arguments(1))
nativeError = Err.Number
nativeDescription = Err.Description
Err.Clear
On Error GoTo 0
expectedDocument = ""
If WScript.Arguments.Count > 1 Then expectedDocument = WScript.Arguments(1)
For attempt = 1 To 10
On Error Resume Next
savedState = doc.IsSaved()
actualProject = pi.ProjectFile
actualDocument = ""
If expectedDocument <> "" Then actualDocument = doc.Name
nativeError = Err.Number
nativeDescription = Err.Description
Err.Clear
On Error GoTo 0
WScript.Echo "POST_SAVE_IDENTITY|project=" & actualProject & "|expected=" & expected & "|document=" & actualDocument & "|expected_document=" & expectedDocument
WScript.Echo "POST_SAVE_STATE|saved=" & CStr(savedState) & "|attempt=" & CStr(attempt) & "|error=" & CStr(nativeError)
operationOK = savedState And LCase(actualProject) = LCase(expected) And LCase(actualDocument) = LCase(expectedDocument)
If operationOK Or nativeError <> 0 Then Exit For
If LCase(actualProject) <> LCase(expected) Or LCase(actualDocument) <> LCase(expectedDocument) Then Exit For
WScript.Sleep 200
Next
If nativeError <> 0 Or Not operationOK Then
WScript.Echo "POST_SAVE_FAILED|" & CStr(nativeError) & "|identity_or_saved_state_unconfirmed|" & nativeDescription
WScript.Quit 8
+21 -10
View File
@@ -407,6 +407,7 @@ class MainWindow(QWidget):
elif not any(other.lease is job.lease for other in self._jobs.values()):
self._close_path_lease(job.lease)
if self._job_current(job): self._finished()
else: self._update()
def _release_library_lease(self):
lease, self.library_lease = self.library_lease, None
@@ -509,8 +510,8 @@ class MainWindow(QWidget):
'请选择一个当前可见的非 READY CBB。' if native_target is None else '')
self.native_repair_button.setToolTip(reason or '打开原生工具;请在其中手动选择 Repair。')
ready = ready and not self._native_backup_same_library()
self.batch_button.setEnabled(ready and bool(self._eligible_names()))
self.selected_batch_button.setEnabled(ready and bool(self._eligible_names(checked_only=True)))
self.batch_button.setEnabled(ready and bool(self._eligible_names(require_status=True)))
self.selected_batch_button.setEnabled(ready and bool(self._eligible_names(checked_only=True, require_status=True)))
self.icdb_repair_button.setEnabled(ready and not self._icdb_active() and bool(self._maintenance_names()))
self.icdb_stop_button.setEnabled(self._icdb_active() and not self.icdb_task.stop.is_set())
self.backup_restore_button.setEnabled(ready and bool(
@@ -547,8 +548,11 @@ class MainWindow(QWidget):
self.timeout_spin, self.advanced_toggle, self.advanced_panel):
widget.setEnabled(not self._closing)
counts = self.visible_counts()
unknown = sum(r.status == 'UNKNOWN' for r in self.visible_records())
pending = sum(r.status == 'PENDING' for r in self.visible_records())
self.counts_label.setText(f'可见 {counts["visible"]} / {len(self._records_by_name)} · '
f'READY {counts["ready"]} · 异常/待确认 {counts["error"]}')
f'READY {counts["ready"]} · 待验证 {pending} · 待读取 {unknown} · '
f'异常 {counts["error"]}')
directory, native, missing = self._read_counts
if directory is not None:
self.counts_label.setText(self.counts_label.text() +
@@ -956,12 +960,13 @@ class MainWindow(QWidget):
def visible_counts(self):
records = self.visible_records()
return {'visible': len(records), 'ready': sum(r.status == 'READY' for r in records),
'error': sum(r.status not in {'READY', 'PENDING'} or r.name in self.skipped_names
'error': sum(r.status not in {'READY', 'PENDING', 'UNKNOWN'} or r.name in self.skipped_names
for r in records)}
def _eligible_names(self, *, checked_only=False):
def _eligible_names(self, *, checked_only=False, require_status=False):
records = self.selected_records() if checked_only else self.visible_records()
return [r.name for r in records if r.status != 'READY' and r.name not in self.skipped_names]
return [r.name for r in records if r.status != 'READY' and r.name not in self.skipped_names
and (not require_status or self.catalog_reader is None or r.status == 'PENDING')]
def _maintenance_names(self):
records = self.selected_records() or self.visible_records()
@@ -1435,7 +1440,9 @@ class MainWindow(QWidget):
result = LibraryReadResult(tuple(records), directory_count=len(directories), native_count=len(native),
missing_project_count=sum(name in native for name in reasons), catalog_verified=True)
return result, reasons, lease, library, False
worker = ServiceWorker(lambda:self.native_queue.run(reconcile, context=context))
# Full-library status and preflight follow native catalog IO; ten seconds
# is not enough even on a local 364-entry library. Keep one bounded task.
worker = ServiceWorker(lambda:self.native_queue.run(reconcile, context=context, timeout_seconds=120))
self._lifecycle_workers.add(worker)
def completed(payload):
if self._job_current(read_job): deliver(payload)
@@ -1480,10 +1487,10 @@ class MainWindow(QWidget):
return [record.name for record in self.selected_records()]
def verify_selected(self):
self._confirm_verify(self._eligible_names(checked_only=True))
self._confirm_verify(self._eligible_names(checked_only=True, require_status=True))
def verify_all(self):
self._confirm_verify(self._eligible_names())
self._confirm_verify(self._eligible_names(require_status=True))
def _confirm_verify(self, names):
from .backup_notice import MANUAL_BACKUP_NOTICE
@@ -1709,7 +1716,7 @@ class MainWindow(QWidget):
if self._native_backup_same_library():
self.status_label.setText('请先关闭该库的版本与备份窗口。')
return
eligible = set(self._maintenance_names() if maintenance else self._eligible_names())
eligible = set(self._eligible_names(require_status=True))
names = [name for name in names if name in eligible]
if not names:
self.status_label.setText('当前可见选择中没有可校验的非 READY CBB。')
@@ -1757,6 +1764,10 @@ class MainWindow(QWidget):
if statuses.get(req.block_name) == 'NOT_REGISTERED':
from cbb_refresh_verify.verify_runner import VerifyResult
return VerifyResult('SKIPPED', stderr='仅发现目录,原生目录未登记此 CBB。')
if statuses.get(req.block_name) != 'PENDING':
from cbb_refresh_verify.verify_runner import VerifyResult
return VerifyResult('SKIPPED', error_category='STATUS_UNCONFIRMED',
error_stage='admission', stderr='STATUS_UNCONFIRMED: 当前状态未确认,未启动校验;请重新读取。')
if maintenance:
self._emit_job(job, 'event', {'block': req.block_name, 'stage': 'icdb_check_start'})
return verify(req)
+53 -2
View File
@@ -670,6 +670,46 @@ def _run_verify_task(request, *, progress=None, flag_reader=None, process_runner
request, progress=progress, flag_reader=flag_reader,
process_runner=process_runner, port_check=port_check,
dialog_supervisor_factory=dialog_supervisor_factory, version_prompt=version_prompt, stop=stop)
facts = result.write_outcome or {}
if (not request.diagnostic_only and not request.auto_repair and request.post_repair_proof is None
and result.status == 'FAIL' and result.safe_to_continue and result.evidence_path
and result.library_flag == 'NOT_GREEN' and result.error_stage == 'library_flag'
and result.error_category == 'MENTOR_VERIFY_NOT_COMMITTED'
and all(facts.get(key) == value for key, value in (
('save_state','COMMITTED'), ('close_state','CLOSED'), ('helper_state','EXITED'),
('resource_state','RELEASED'), ('interrupted',False)))
and not (stop is not None and stop.is_set())):
# A new reusable design can save its Work data on the first open,
# then publish Cert on the next native Save. Never retry an open/write failure.
followup_path = result.evidence_path.with_name('commit-followup.json')
followup = dict(kind='NATIVE_COMMIT_FOLLOWUP', status='STARTED',
library=str(request.lmc_file), block=request.block_name, max_additional_runs=1,
original_evidence=str(result.evidence_path))
initial_seconds = result.timings_seconds.get('total', 0.0)
release_confirmed = True # Completed first run stays releasable until the next native attempt.
try:
followup_path.write_text(json.dumps(followup, ensure_ascii=False, indent=2), encoding='utf-8')
except OSError as error:
_notify_progress(progress, {'stage':'commit_followup_unavailable', 'block':request.block_name,
'detail':str(error)})
else:
check_active()
_notify_progress(progress, {'stage':'commit_followup', 'block':request.block_name,
'detail':'原生已保存关闭并释放,但 READY 尚未提交;补充一次原生校验。'})
check_active()
release_confirmed = False
result = _run_verify_serialized(request, progress=progress, flag_reader=flag_reader,
process_runner=process_runner, port_check=port_check,
dialog_supervisor_factory=dialog_supervisor_factory, version_prompt=version_prompt, stop=stop)
followup.update(status='READY' if result.status == 'PASS' and result.library_flag == 'GREEN'
and result.safe_to_continue else 'UNCONFIRMED', final_evidence=str(result.evidence_path or ''))
_write_optional_evidence(followup_path, followup)
second_seconds = result.timings_seconds.get('total', 0.0)
result = replace(result, recovery_attempts=(*result.recovery_attempts, followup),
timings_seconds={**result.timings_seconds, 'initial_verify':initial_seconds,
'commit_followup':second_seconds, 'total':initial_seconds+second_seconds})
if result.evidence_path:
_write_optional_evidence(result.evidence_path, {'block_name':request.block_name, **asdict(result)})
if (request.auto_repair and result.status not in {'TIMEOUT', 'BLOCKED'}
and result.error_category == 'ICDB_REPAIR_REQUIRED'
and result.evidence_path):
@@ -1476,10 +1516,21 @@ def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=Non
stop=stop, context=context) # noqa: E731
results = []
queue_stop = False
retained_libraries = set()
retained_libraries = {}
for request in requests:
from .operation_queue import request_library_keys
library_keys = request_library_keys(request, context)
for index in {retained_libraries[key][1] for key in library_keys.intersection(retained_libraries)}:
previous = next(value[0] for value in retained_libraries.values() if value[1] == index)
if queue_stop or stop is not None and stop.is_set():
break
if not results[index].evidence_path:
continue
from .operation_lifecycle import recheck_failed_release
refreshed = recheck_failed_release(previous.lmc_file, previous.block_name, results[index], stop=stop)
if refreshed.safe_to_continue:
results[index] = refreshed
retained_libraries = {k:v for k,v in retained_libraries.items() if v[1] != index}
if (queue_stop or stop is not None and stop.is_set()
or context is not None and context.stop.is_set()):
result = VerifyResult('SKIPPED', stderr='队列已停止,未操作此 CBB')
@@ -1503,7 +1554,7 @@ def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=Non
results.append(result)
# Never start another writer after an unconfirmed native shutdown.
if not result.safe_to_continue:
retained_libraries.update(library_keys)
retained_libraries.update({key:(request, len(results)-1) for key in library_keys})
queue_stop = queue_stop or result.status in {'QUEUE_STOP', 'CANCELLED'}
if queue_stop and stop is not None:
stop.set()
+1 -1
View File
@@ -172,7 +172,7 @@ def test_catalog_union_keeps_registration_source_and_counts(qtbot, tmp_path, mon
load(window,qtbot)
qtbot.waitUntil(entered.is_set)
assert '未知' in window.counts_label.text()
assert window.batch_button.isEnabled()
assert not window.batch_button.isEnabled()
release.set()
qtbot.waitUntil(lambda:'NativeOnly' in window._records_by_name)
assert window._records_by_name['Orphan'].catalog_source == 'directory_only'
+229
View File
@@ -0,0 +1,229 @@
"""Field #17: data failures finish their own cleanup before the next writer."""
import json
import time
from dataclasses import replace
from pathlib import Path
from types import SimpleNamespace
import pytest
from cbb_refresh_verify import failed_session, verify_runner
from cbb_refresh_verify.models import CbbRecord, LibraryReadResult
def test_database_load_question_declines_log_view_then_closes_empty_target(tmp_path, monkeypatch):
import win32con
from test_failed_startup import read_write_fixture
job, records, messages, names, _ = read_write_fixture(tmp_path, monkeypatch)
names[203] = ('Problem encountered while opening one of the database files. '
'See PCBLogFile.txt for details. Loading of the job has failed.\r\r'
'Do you wish to view the log file now?')
result = failed_session.close_failed_startup(job, 12, timeout_seconds=0)
assert result['status'] == 'CLOSED', result
assert messages == [(202, win32con.BM_CLICK), (100, win32con.WM_CLOSE)]
assert not records
@pytest.mark.parametrize('text', [
'Problem encountered while opening one of the database files. Delete database?',
'Loading of the job has failed. Do you wish to repair it?',
])
def test_unknown_database_question_is_preserved(tmp_path, monkeypatch, text):
from test_failed_startup import read_write_fixture
job, records, messages, names, _ = read_write_fixture(tmp_path, monkeypatch)
names[203] = text
result = failed_session.close_failed_startup(job, 12, timeout_seconds=0)
assert result['status'] == 'RETAINED' and records and not messages
def test_supervisor_acknowledged_failed_open_can_close_empty_shell_with_address(tmp_path, monkeypatch):
import win32con
from cbb_refresh_verify.dialog_models import WindowSnapshot, ControlSnapshot, DialogPhase
from test_failed_startup import startup_fixture
job, records, messages = startup_fixture(tmp_path, monkeypatch)
address = tmp_path/'database/cdbsvr/sAddress.adr'
address.parent.mkdir(parents=True)
address.write_text('original address')
popup = WindowSnapshot(200,12,'ExpeditionPCB.exe','pcb','#32770','Expedition PCB',
DialogPhase.PCB_STARTING, (
ControlSnapshot(201,6,'Button','Yes'), ControlSnapshot(202,7,'Button','No'),
ControlSnapshot(203,65535,'Static',
'Problem encountered while opening one of the database files. '
'See PCBLogFile.txt for details. Loading of the job has failed.\r\r'
'Do you wish to view the log file now?')))
(tmp_path/'dialogs.jsonl').write_text(json.dumps(dict(popup.to_record(),
action='acknowledge_fatal', error_code='MENTOR_DATABASE_LOAD_FAILED', accepted_control=[7]))+'\n')
result = failed_session.close_failed_startup(job, 12, timeout_seconds=0)
assert result['status'] == 'CLOSED', result
assert messages == [(100,win32con.WM_CLOSE)]
assert not records and address.read_text() == 'original address'
@pytest.mark.parametrize('aliased', [False, True])
def test_late_release_is_rechecked_before_later_same_library_item(tmp_path, monkeypatch, aliased):
library = tmp_path/'lib.lmc'
calls, checks = [], []
failed = verify_runner.VerifyResult('FAIL', stderr='bad database', safe_to_continue=False,
evidence_path=tmp_path/'result.json', error_category='MENTOR_DATABASE_LOAD_FAILED')
def verify(request):
calls.append(request.block_name)
return failed if request.block_name == 'Bad' else verify_runner.VerifyResult('PASS')
def recheck(library, block, result, **kwargs):
checks.append(block)
return result if len(checks) == 1 else replace(result, safe_to_continue=True)
monkeypatch.setattr('cbb_refresh_verify.operation_lifecycle.recheck_failed_release', recheck)
if aliased:
monkeypatch.setattr('cbb_refresh_verify.operation_queue.request_library_keys',
lambda *args:{'display-path','mapped-path'})
results = verify_runner.run_batch([verify_runner.VerifyRequest(library, n, tmp_path)
for n in ('Bad','Good')], verifier=verify)
assert calls == ['Bad','Good']
assert [r.status for r in results] == ['FAIL','PASS']
assert results[0].safe_to_continue
def test_slow_catalog_status_is_delivered_and_unknown_cannot_start_bulk(qtbot, tmp_path, monkeypatch):
from test_issue15_ui_integration import window_for
from cbb_refresh_verify.management import Catalog, CatalogEntry
from threading import Event
entered, release = Event(), Event()
def statuses(names, library):
entered.set()
assert release.wait(15)
return {name:'READY' for name in names}
window = window_for(qtbot, tmp_path, monkeypatch,
reader=lambda _: LibraryReadResult((CbbRecord('A','LP'),), directory_count=1),
catalog_reader=lambda p,e:Catalog(p,1,(CatalogEntry('A','Logical-Physical'),)),
status_refresher=statuses)
window.lmc_edit.setText('a.lmc')
window.load_library()
qtbot.waitUntil(entered.is_set)
try:
assert not window.batch_button.isEnabled()
assert window.backup_restore_button.isEnabled()
assert '待读取 1' in window.counts_label.text()
# Actual prior metadata cutoff; native IO is simulated, task/Qt delivery is real.
qtbot.wait(10300)
release.set()
qtbot.waitUntil(lambda:window.ready_names == {'A'}, timeout=3000)
assert '原生 1' in window.counts_label.text()
finally:
release.set()
window.pool.waitForDone(5000)
def test_successful_worker_does_not_report_retained_save(tmp_path, monkeypatch):
from test_verify_worker_stability import exercise_worker
job, events, execute = exercise_worker(tmp_path, monkeypatch)
assert execute()['status'] == 'PASS'
assert not [e for e in events if e.get('stage') == 'save_result_retained']
@pytest.mark.parametrize('fresh', ['UNKNOWN', 'UNAVAILABLE', None])
def test_execution_rechecks_status_without_starting_unknown_target(qtbot, tmp_path, monkeypatch, fresh):
from test_issue15_ui_integration import window_for
from cbb_refresh_verify.management import Catalog, CatalogEntry
calls, reads = [], []
def statuses(names, library):
reads.append(tuple(names))
return {'A':'PENDING'} if len(reads) == 1 else ({} if fresh is None else {'A':fresh})
window = window_for(qtbot,tmp_path,monkeypatch,
reader=lambda _:LibraryReadResult((CbbRecord('A','LP'),), directory_count=1),
catalog_reader=lambda p,e:Catalog(p,1,(CatalogEntry('A','Logical-Physical'),)),
status_refresher=statuses,
verifier=lambda request:(calls.append(request.block_name) or verify_runner.VerifyResult('PASS')))
window.lmc_edit.setText('a.lmc'); window.load_library()
qtbot.waitUntil(lambda:window._read_counts[1] == 1)
window._run(['A'])
qtbot.waitUntil(lambda:not window.busy)
assert calls == []
reports=list((tmp_path/'reports').glob('batch-*.log'))
assert reports and 'STATUS_UNCONFIRMED' in reports[0].read_text(encoding='utf-8')
@pytest.mark.parametrize('second_ready', [True,False])
def test_saved_closed_pending_commit_gets_only_one_followup(tmp_path, monkeypatch, second_ready):
root=tmp_path/'first';root.mkdir()
evidence=root/'result.json';evidence.write_text('{"status":"FAIL"}')
second=tmp_path/'second';second.mkdir()
second_evidence=second/'result.json';second_evidence.write_text('{}')
pending=verify_runner.VerifyResult('FAIL',safe_to_continue=True,evidence_path=evidence,
library_flag='NOT_GREEN',error_category='MENTOR_VERIFY_NOT_COMMITTED',error_stage='library_flag',
bridge_attempts=({'status':'PENDING','source':'IsVerifiedReuseBlock','raw_status':0},),
timings_seconds={'total':2.0},
write_outcome=dict(save_state='COMMITTED',close_state='CLOSED',helper_state='EXITED',
resource_state='RELEASED',interrupted=False))
calls=[]
def serialized(request,**kwargs):
calls.append(request.block_name)
if len(calls)==1:return pending
return (verify_runner.VerifyResult('PASS',library_flag='GREEN',evidence_path=second_evidence,timings_seconds={'total':3.0})
if second_ready else replace(pending,evidence_path=second_evidence,timings_seconds={'total':3.0}))
monkeypatch.setattr(verify_runner,'_run_verify_serialized',serialized)
result=verify_runner._run_verify_task(verify_runner.VerifyRequest(tmp_path/'missing.lmc','Block',tmp_path))
assert calls == ['Block','Block']
assert result.status == ('PASS' if second_ready else 'FAIL')
assert result.timings_seconds['total']==5.0
assert json.loads(evidence.read_text()) == {'status':'FAIL'}
link=json.loads((root/'commit-followup.json').read_text())
assert link['status']==('READY' if second_ready else 'UNCONFIRMED')
@pytest.mark.parametrize('obstacle', ['unsafe','save_unknown','close_unknown','native_retained',
'helper_running','interrupted','database_failure','unknown_status','diagnostic','auto_repair','cancelled'])
def test_incomplete_or_failed_native_operation_never_gets_commit_followup(tmp_path,monkeypatch,obstacle):
from threading import Event
evidence=tmp_path/'result.json';evidence.write_text('{}')
facts=dict(save_state='COMMITTED',close_state='CLOSED',helper_state='EXITED',resource_state='RELEASED',interrupted=False)
if obstacle=='save_unknown':facts['save_state']='UNKNOWN'
if obstacle=='close_unknown':facts['close_state']='UNKNOWN'
if obstacle=='native_retained':facts['resource_state']='RETAINED'
if obstacle=='helper_running':facts['helper_state']='RUNNING'
if obstacle=='interrupted':facts['interrupted']=True
pending=verify_runner.VerifyResult('FAIL',safe_to_continue=obstacle!='unsafe',evidence_path=evidence,
library_flag='NOT_GREEN' if obstacle!='unknown_status' else 'UNKNOWN',
error_category='MENTOR_DATABASE_LOAD_FAILED' if obstacle=='database_failure' else 'MENTOR_VERIFY_NOT_COMMITTED',
error_stage='library_flag',bridge_attempts=({'status':'PENDING','source':'IsVerifiedReuseBlock','raw_status':0},),
write_outcome=facts)
stop=Event();calls=[]
def serialized(*args,**kwargs):
calls.append(1)
if obstacle=='cancelled':stop.set()
return pending
monkeypatch.setattr(verify_runner,'_run_verify_serialized',serialized)
verify_runner._run_verify_task(verify_runner.VerifyRequest(tmp_path/'missing.lmc','Block',tmp_path,
diagnostic_only=obstacle=='diagnostic',auto_repair=obstacle=='auto_repair'),stop=stop)
assert calls == [1]
assert not (tmp_path/'commit-followup.json').exists()
def test_cancel_after_followup_checkpoint_releases_completed_first_lease(tmp_path,monkeypatch):
from cbb_refresh_verify.operation_queue import BatchTaskContext, QueueCancelled
from cbb_refresh_verify import library_lock
import win32con, win32file
library=tmp_path/'lib.lmc';library.write_bytes(b'isolated fixture')
evidence=tmp_path/'result.json';evidence.write_text('{}')
pending=verify_runner.VerifyResult('FAIL',safe_to_continue=True,evidence_path=evidence,
library_flag='NOT_GREEN',error_category='MENTOR_VERIFY_NOT_COMMITTED',error_stage='library_flag',
write_outcome=dict(save_state='COMMITTED',close_state='CLOSED',helper_state='EXITED',resource_state='RELEASED',interrupted=False))
monkeypatch.setattr(library_lock,'recheck_previous_release',lambda *a,**k:None)
monkeypatch.setattr(verify_runner,'_run_verify_serialized',lambda *a,**k:pending)
context=BatchTaskContext(str(library))
original=Path.write_text
def write(path,*a,**k):
result=original(path,*a,**k)
if path.name=='commit-followup.json':context.cancel()
return result
monkeypatch.setattr(Path,'write_text',write)
try:
with pytest.raises(QueueCancelled):
context.run(lambda:verify_runner._run_verify_task(
verify_runner.VerifyRequest(library,'Block',tmp_path),stop=context.stop))
lock=library_lock.LibraryLock(library)
handle=win32file.CreateFile(str(lock.path),win32con.GENERIC_READ,0,None,win32con.OPEN_EXISTING,0,None)
handle.Close()
finally:
context.close(timeout_seconds=0)
with library_lock._guard:
owner=library_lock._owners.pop(library_lock.LibraryLock(library).key,None)
if owner:owner['handle'].Close()
+23 -1
View File
@@ -88,7 +88,7 @@ End Class
def run_helper(tmp_path, *, save_body='Save = True', close_body='Close = True',
is_saved='True', gated=False, cancelled=False):
is_saved='True', gated=False, cancelled=False, transform=None):
source = Path('src/cbb_refresh_verify/save_verified_block.vbs').read_text('utf-8')
classes = '''
Class FakePi
@@ -145,6 +145,8 @@ End Class
source = source.replace('Option Explicit', 'Option Explicit\nDim closedDoc\n' + classes)
source = source.replace('GetObject(, "MGCPCB.Application")', 'New FakeApp')
source = source.replace('CreateObject("MGCPCBAutomationLicensing.Application")', 'New FakeLic')
if transform is not None:
source = transform(source)
harness = tmp_path/'facts.vbs'
harness.write_text(source, encoding='ascii')
cancel = tmp_path/'cancel.signal'
@@ -201,3 +203,23 @@ def test_unopened_gate_cancellation_exits_before_com(tmp_path):
assert 'TEST_SAVE_CALLED' not in result.stdout
assert 'VALIDATE_START' not in result.stdout
assert result.returncode == 9
def test_post_save_identity_failure_names_actual_and_expected_values(tmp_path):
result = run_helper(tmp_path, transform=lambda source:source.replace(
'ProjectFile = WScript.Arguments(0)',
'If afterSave Then\nProjectFile = "other.prj"\nElse\nProjectFile = WScript.Arguments(0)\nEnd If')
.replace('Dim closedDoc', 'Dim closedDoc, afterSave')
.replace('Save = True', 'afterSave = True\nSave = True'))
assert result.returncode == 8, result.stdout + result.stderr
assert 'POST_SAVE_IDENTITY|project=other.prj|expected=expected.prj|document=CBB.pcb|expected_document=CBB.pcb' in result.stdout
assert 'CLOSE_START' not in result.stdout
def test_post_save_transient_unsaved_state_retries_before_closing(tmp_path):
def transform(source):
return source.replace('Dim closedDoc', 'Dim closedDoc, savedCalls').replace(
'IsSaved = True', 'savedCalls = savedCalls + 1\nIsSaved = (savedCalls <> 2)')
result = run_helper(tmp_path, transform=transform)
assert result.returncode == 0, result.stdout + result.stderr
assert 'CLOSE_OK' in result.stdout
+2 -2
View File
@@ -47,7 +47,7 @@ def names(records):
def test_search_and_filters_use_cached_catalog_and_count_visible_states(qtbot, tmp_path, monkeypatch):
window = load_window(qtbot, tmp_path, monkeypatch)
window.reader = lambda _: pytest.fail('filter reread Mentor')
assert window.visible_counts() == {'visible': 5, 'ready': 2, 'error': 3}
assert window.visible_counts() == {'visible': 5, 'ready': 2, 'error': 2}
expected = {
'ready': ['Alpha', 'Missing'], 'non_ready': ['Beta', 'Gamma', 'Delta'],
'pending': ['Beta'], 'errors': ['Gamma', 'Delta'], 'missing': ['Missing'],
@@ -58,7 +58,7 @@ def test_search_and_filters_use_cached_catalog_and_count_visible_states(qtbot, t
window.status_filter.setCurrentIndex(window.status_filter.findData('all'))
window.search_edit.setText(' ANALOG ')
assert names(window.visible_records()) == ['Gamma', 'Delta']
assert window.visible_counts() == {'visible': 2, 'ready': 0, 'error': 2}
assert window.visible_counts() == {'visible': 2, 'ready': 0, 'error': 1}
window.search_edit.setText('aLpH')
assert names(window.visible_records()) == ['Alpha']
assert '1' in window.counts_label.text()