修复 #17:本任务会话收尾、共享资源释放与批次误阻塞 #18

Open
abaishu0730 wants to merge 3 commits from codex/issue17-batch-cleanup into main
pull from: codex/issue17-batch-cleanup
31 changed files with 1865 additions and 69 deletions

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,170 @@
{
"date": "2026-11-19",
"branch": "codex/issue17-batch-cleanup",
"baseline": "07eab61",
"scope": "Final source GUI and actual Mentor, isolated constructed fault; not original field ICDB or frozen EXE acceptance",
"full_tests": {
"tests": 2472,
"failures": 0,
"errors": 0,
"skipped": 0
},
"seconds": 657.842,
"actual": {
"1GPHY_8212": "FAIL",
"1GPHY_RTL8211F": "PASS"
},
"batch_seconds": 314.60899999999674,
"process_identities_checked": 8,
"exclusive_files_checked": 6,
"application_exit": 0,
"automatic_followups": 1,
"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": "32bef6547d61fe36cbb7c21f35bd45419c4cdaf10c70452ee2368269e6c75d94",
"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": "1a5d33cc75577de11bfbd06c780a46e4679089b44c42f51454e2fdbb4ac4b7ad",
"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": "c91041b6e2f7d88f3460b4cdf184df59ff5183c8bc478704e3d442e4ae0406f3",
"src/cbb_refresh_verify/operation_queue.py": "7a2f08d4bc32d1de0a3151d509d41e676fbc962aba2a9346008c71a48adf0e79",
"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": "cbdf6cce5a5104edcf1f6b9d66dc2e379d2ffc92989e9cc231c13a4d719e4d8f",
"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": "5453c1b61ad2969cb3071d7ccf0bba571bcb0d1dac8270b3c96ec0dd1c3d88ff",
"src/cbb_refresh_verify/ui/icdb_check_task.py": "70a678e632487e0e829798284ee7644af0ecb0b27212866dfb23cdb6db6e168d",
"src/cbb_refresh_verify/ui/main_window.py": "368263a7aa57a85de4c76485ff83d68e12bcfd6254a874425bcaa53049c258a1",
"src/cbb_refresh_verify/ui/management_dialog.py": "fc67d7d3a4ba07ccbff5b40f789192c85c8dafa64349446e6a7d86b5f20941d2",
"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"
},
"original_source_postcheck": {
"status": "PASS",
"source": "G:\\CbbIssue15FinalAccept-20261117\\run-final-01\\library",
"checked_at": "2026-11-19T01:53:06.022051+00:00",
"files": 28348,
"missing": [],
"added": [],
"changed": [],
"excluded": "top-level .mentor_lib.cbb-upload.* coordinator files, matching pre-test manifest"
},
"forced_native_terminations": 0,
"native_lock_deletions": 0,
"previous_failed_run_preserved": true,
"raw_evidence_sha256": {
"G:\\CbbBatchIsolationFinal-20261119\\source-under-test.json": {
"bytes": 9066,
"sha256": "47ea3e517051d06467aae4e8174d446013486d4408bfa18ad62a6cfe230211f1"
},
"G:\\CbbBatchIsolationFinal-20261119\\actual-result.json": {
"bytes": 2278,
"sha256": "4cf80df3b3a217acc752ea4113e7cd3fca72dea16927f0a7f40b3bc746cc3030"
},
"G:\\CbbBatchIsolationFinal-20261119\\closure-proof.json": {
"bytes": 5026,
"sha256": "d8cb14b49ba2efa960faba43aec1dd6c7ddff1ba7af343920ec49c141bd39d96"
},
"G:\\CbbBatchIsolationFinal-20261119\\preparation-result.json": {
"bytes": 17036,
"sha256": "a74a5f0dc508c7ae55ca111c1cb8177be35d6872ceb7a65118012586c2b10549"
},
"G:\\CbbBatchIsolationFinal-20261119\\original-source-postcheck.json": {
"bytes": 321,
"sha256": "cfcd3fb37367272f196e0cb48d6dae0cbbe67edc230743b89a92c6394c104cf3"
},
"G:\\CbbBatchIsolationFinal-20261119\\native\\run-source-01\\ui-01\\results\\1795053108621710900-4461.json": {
"bytes": 100,
"sha256": "9f0cb90cca6bc4388da6e21884e13772fd658272d89b1d4f294f0648cc828d40"
},
"G:\\CbbIssueLatest-20261118\\checks\\batch-isolation-final-full.log": {
"bytes": 2981,
"sha256": "955453a903ddb443fd103e3115c54abff9ec94039f3d5d08c6868fdf67d30cd3"
},
"G:\\CbbIssueLatest-20261118\\checks\\batch-isolation-final-full.xml": {
"bytes": 360637,
"sha256": "fa878c69b35f701f00bead1b1df137a96fd35ba14856d88b591542526030f6a7"
},
"G:\\CbbIssueLatest-20261118\\checks\\batch-isolation-full.log": {
"bytes": 13963,
"sha256": "78367028f332c4192e8458c66d25390aee1905160d6eeeb5c7f689cccdf6af5f"
},
"G:\\CbbIssueLatest-20261118\\checks\\batch-isolation-full.xml": {
"bytes": 371306,
"sha256": "57d9c2916a3c104ac4fa498439d84d815886e975d6a2bb86d1521a26fe78173d"
},
"G:\\CbbIssueLatest-20261118\\checks\\batch-isolation-regressions-green.log": {
"bytes": 302,
"sha256": "6167237d4f29af707fa8d05f546dd46fa4be72fbe70153ab3135446c037173ac"
},
"G:\\CbbIssueLatest-20261118\\checks\\cancellation-deadline-red.log": {
"bytes": 7668,
"sha256": "c1354beab3db9a3624e20678be6f3bcc5a823e5331d708f0ce4b34fb3028aa1a"
},
"G:\\CbbIssueLatest-20261118\\batch-isolation-review.md": {
"bytes": 17553,
"sha256": "81181b51d5c30309659db16340b662b2ae62d3cab3139378c74f16a811b012c9"
}
},
"merged": false,
"released": false,
"issue_closed": false
}
@@ -0,0 +1,56 @@
# 异常项跳过与阻塞范围复核
基线:`07eab61`。分支:`codex/issue17-batch-cleanup`。日期:2026-11-19。
## 结论与范围
上一轮不能宣称没有阻塞:生产任务在排队时仍可能无限等待活跃观察会话;ICDB 和管理批次仍将一次未释放结果永久缓存到后续同库项;管理的意外异常和进度接收器异常还能让整批结果丢失。
这轮修正这些分支,不改变原生保存成功条件或 ICDB 诊断判据。普通单项失败保留 FAIL,后续项继续。当前项从未启动时,记录 SKIPPED 和准入原因,不声称新建了待释放会话。确有未释放写入时,冲突项逐项跳过,独立任务继续;没有把“继续遍历”解释为绕过真实占用继续写同一个中心库。
| 条件 | 当前项与后续行为 | 识别依据 |
| --- | --- | --- |
| 前项操作失败但已释放 | 保留原失败,继续下一项 | 原生保存/关闭/退出、资源释放证明各自核对 |
| 后台已登记会话仍运行/初始化 | 当前项未启动即 SKIPPED,继续遍历,无无限排队 | `NATIVE_SESSION_PENDING`,仅活跃观察缓存;历史孤立记录不触发这个准入判定 |
| 前项原生写入仍未确认释放 | 下一项前复核原占用项,确认释放后去除全部库别名缓存;否则跳过冲突项 | `PREVIOUS_SESSION_UNRELEASED`,记录原占用 CBB,不能归为新项 ICDB 错误 |
| 库管理出现未预期异常 | 单项 RECOVERY_REQUIRED;保留未知释放事实,同库冲突项跳过,其他独立库继续 | `BATCH_ITEM_EXCEPTION`,不凭异常类型伪造安全释放 |
| 界面进度接收器失效 | 不改变业务结果和后续执行 | 复用已有容错通知函数 |
| 用户明确停止/关闭队列 | 尊重停止;保留已完成项 | 与“资源未准入”分开,取消优先 |
生产校验、ICDB 检查、库管理、备份恢复及目录读取启用“未准入即跳过/返回”的规则。显式恢复控制仍可接近其原占用会话,普通串行排队和用户主动暂停保留原有行为。只检查缓存的活跃观察状态;不在 GUI 排队谓词里访问文件、查询进程或启动 Mentor。
特别补齐界面调用链:备份恢复、自定义管理入口及主窗口错误处理不得把启动前的 `QueueUnavailable` 转成 FAIL/RECOVERY_REQUIRED 或新增保留租约;全跳过的批次不再刷新空目标集合,也不以刷新失败覆盖结果。
## 验证
证据目录:`G:/CbbBatchIsolation-20261119`;自动化日志:`G:/CbbIssueLatest-20261118/checks`。
- `batch-isolation-red`:9 个新增回归均失败,复现无限等待、缓存不复核与异常逃逸。
- `batch-isolation-edges-red`:复现取消竞争、取消时原结果丢失及进度接收器异常;其中 UI 测试最初错误地要求正常结束的 context 不可被 close/cancel,后改为核对业务结果没有 CANCELLED,未据此修改产品。
- `admission-ui-red`:3 个界面误报未释放分支均失败;修正后新增回归共 16 项通过。
- 相关回归 212 项通过;进一步界面和租约回归 33 项通过。编译检查与 `git diff --check` 通过。
- 首轮全量 `batch-isolation-full` 保留 2 failed / 2,469 passed:新增原占用提示访问字符串注入项的 `block_name` 导致 AttributeError;窗口扫描期间已取消却先超时,返回错误诊断类别。前者用既有合同用例复现,后者新增确定时钟用例复现;均先 RED 后修正。82 项相关回归通过。不是仅调大测试超时;产品扫描返回后立即复核取消,确保不再执行后续窗口动作。最终源码的全量与原生验收重新运行。
- 最终全量 `python -X utf8 G:/CbbIssueLatest-20261118/run_checks.py batch-isolation-final-full -q`:**2,472 passed,0 failure/error/skipped**,665.57 秒,实际退出码 0。相邻 JSON 保存测试统计、最终源码指纹和原始证据 SHA-256。
- 最终原始输入核对 `G:/CbbBatchIsolationFinal-20261119/original-source-postcheck.json`:28,348 个文件 SHA-256、大小、修改时间和集合完全一致;缺失、新增、修改均为 0,顶层旧协调记录的排除规则沿用复制前清单。
### 本轮新源码实际按钮验收
下述首次原生结果保留在 `G:/CbbBatchIsolation-20261119`,对应上述两处补修之前的源码。最终源码另用 `G:/CbbBatchIsolationFinal-20261119` 保存完整记录,不覆盖第一次证据。
`actual-result.json`:同一批次 `1GPHY_8212` 为 FAIL/`MENTOR_DATABASE_LOAD_FAILED`(101.859 秒),完成释放后 `1GPHY_RTL8211F` 为 PASS/GREEN(130.844 秒);权威状态 READY,四项同步、Save/IsSaved/Close 均通过。批次总计 259.875 秒,恰好两行,零 SKIPPED。运行中改变搜索条件、清空勾选、切换管理/校验页,提交时目标保持一致,任务结束后取消按钮禁用。
`closure-proof.json`:5 个精确进程身份退出,6 个关键文件独占打开,76 个源码/资源 SHA-256 与实际测试版本一致。原构造损坏头部未变,未强杀原生进程、未删除原生锁;应用随后正常关闭,退出码 0。本轮健康项首轮即 READY,没有触发旧版本已单独实测过的补充校验分支,不能把本次结果写成又一次自动补充校验验收。
**最终源码重验**(`G:/CbbBatchIsolationFinal-20261119`):8212 为 FAIL/`MENTOR_DATABASE_LOAD_FAILED`、safe=true(88.265 秒);RTL 首轮 `verify-f1c25f324bb3` 为 FAIL/NOT_GREEN、safe=true(101.937 秒),自动补充一次 `verify-f011eceff63f` 后 PASS/GREEN、权威 READY、safe=true(101.078 秒)。报告累计健康项原生耗时 203.015 秒,批次 314.609 秒,恰好 FAIL/PASS 两行、零 SKIPPED。首轮失败原样保留,`commit-followup.json` 为 READY,限制额外调用 1 次。
最终 `closure-proof.json` 核对 8 个精确进程身份退出、6 个关键文件独占打开、全部 76 个源码/资源哈希一致。故障头部未改变,没有强杀或删原生锁;最终应用也正常关闭 exit 0,`ui-01/results` 保存 finish 回执。正常关闭时的初始保守 shutdown 盘点文件不是最终释放证明,保留其原值,由独立进程/文件证明和退出回执确认收尾。
本次实际验证复用此前明确隔离的构造损坏库。新建独立 GUI 数据/证据目录;健康项通过正常原生同名更新准备为 PENDING,未修改客户库。原生准备过程为 UPLOADED、safe=true;准备阶段的 after-remove catalog 窗口观察线程曾记录 `EnumDesktopWindows` 错误码 0,主目录读取成功且已退出;该条原始日志保留,不能据此声称所有原生线程均无异常。
新源码 GUI 读取时,测试驱动 UIA 在重绘期间遇到 `CurrentIsEnabled/-2147220991`,原控制结果保留。只给只读枚举增加有限重试,恢复同一个应用,不重复回放已提交的写动作。产品后端未替换为模拟校验。
## 验收边界
不会承诺“所有写操作永远能继续”:同一原生写会话、中心库或共享数据库仍在使用时,冲突写入必须保持未执行。用户主动暂停、停止以及手动打开的原生维护窗口也不是工程损坏。准确报告这些状态比把它们标成 ICDB 故障更重要。
ICDB 问题仍需本轮原生错误内容支撑;数据库一般加载失败、共享库访问失败、无法确认状态和会话未释放不等同于 ICDB 损坏。构造头部损坏的通过结果也不等于客户原始故障已修复。本轮不发布新包、不合并、不关闭工单。
@@ -0,0 +1,210 @@
{
"date": "2026-11-19",
"baseline": "3bde847",
"branch": "codex/issue17-batch-cleanup",
"scope": "Source GUI/native, deliberately delayed owned empty PCB cleanup in isolated constructed failure; not customer-original or frozen EXE acceptance",
"tests": {
"tests": 2500,
"failures": 0,
"errors": 0,
"skipped": 0
},
"test_seconds": 459.075,
"batch": {
"1GPHY_8212": "FAIL",
"1GPHY_RTL8211F": "PASS"
},
"batch_seconds": 327.85899999999674,
"owned_idle_cleanup": "CLIENT_EXITED",
"original_business_status": "FAIL",
"original_safe_to_continue": false,
"late_resource_safe_to_continue": true,
"release_proof_scope": "BLOCK",
"process_identities_checked": 8,
"exclusive_files_checked": 7,
"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": "32bef6547d61fe36cbb7c21f35bd45419c4cdaf10c70452ee2368269e6c75d94",
"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": "2471d605bdee5eda781ea96f89bbfb598357c4cdfa5f7d99a8bc9ae882e12240",
"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": "b55b608352c68ef30ad8e70a762bb148136a05adc1c2b71a261d50039a420507",
"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": "1a5d33cc75577de11bfbd06c780a46e4679089b44c42f51454e2fdbb4ac4b7ad",
"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": "b8bebad94885e576403b099d9819027e59834bf25185b3ccabfccdc375d16055",
"src/cbb_refresh_verify/operation_queue.py": "7a2f08d4bc32d1de0a3151d509d41e676fbc962aba2a9346008c71a48adf0e79",
"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": "fa5ae0d857b8791b444d3b35366d4b311e444da61c042f77eb157ca3ab970ad1",
"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": "d0fdcd3c403ce09adc49857340c0bbef7caae31e1360a0d2d4c9e7d2d5062b16",
"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": "214f9a7313369d45f03141c0c99fbbe1038f936ba8821c17eabc4780df2caf81",
"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": "5453c1b61ad2969cb3071d7ccf0bba571bcb0d1dac8270b3c96ec0dd1c3d88ff",
"src/cbb_refresh_verify/ui/icdb_check_task.py": "70a678e632487e0e829798284ee7644af0ecb0b27212866dfb23cdb6db6e168d",
"src/cbb_refresh_verify/ui/main_window.py": "368263a7aa57a85de4c76485ff83d68e12bcfd6254a874425bcaa53049c258a1",
"src/cbb_refresh_verify/ui/management_dialog.py": "fc67d7d3a4ba07ccbff5b40f789192c85c8dafa64349446e6a7d86b5f20941d2",
"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"
},
"original_source_postcheck": {
"status": "PASS",
"source": "G:\\CbbIssue15FinalAccept-20261117\\run-final-01\\library",
"checked_at": "2026-11-19T02:50:46.654715+00:00",
"files": 28348,
"missing": [],
"added": [],
"changed": [],
"excluded": "top-level .mentor_lib.cbb-upload.* coordinator files, matching pre-test manifest"
},
"automatic_followups": 1,
"application_exit": 0,
"forced_terminations": 0,
"native_lock_deletions": 0,
"evidence_sha256": {
"G:\\CbbOwnedRelease-20261119\\source-under-test.json": {
"bytes": 9066,
"sha256": "c5f04fa2c48582cf3538d17f7e7357b9ebcbd038d36d067f30c35fe8072ef2ec"
},
"G:\\CbbOwnedRelease-20261119\\fault-injection.json": {
"bytes": 2503,
"sha256": "1fb89d1b8c2a84d80393ede444ab11b6aa80264f9ec2ab1552550458ae2f964f"
},
"G:\\CbbOwnedRelease-20261119\\actual-result.json": {
"bytes": 6261,
"sha256": "efeedd20114e13796c9001c6aaf1c936e40448e3c1e0d366b3e08703e9218820"
},
"G:\\CbbOwnedRelease-20261119\\closure-proof.json": {
"bytes": 16836,
"sha256": "d772e924022bfae174004300516eb96eb7c72aab851b568407ba6dc3c214eca6"
},
"G:\\CbbOwnedRelease-20261119\\preparation-result.json": {
"bytes": 17126,
"sha256": "288913089686d6cee5e420bc1feba8ab5ddf40d97d1254be9b200afbcf35dc31"
},
"G:\\CbbOwnedRelease-20261119\\original-source-postcheck.json": {
"bytes": 321,
"sha256": "db9851f093513fbaa52bb66863664ea52dfb126b7de81f659ef92d8b427c4d69"
},
"G:\\CbbOwnedRelease-20261119\\native\\run-source-01\\data\\evidence\\verify-b5a731c7b22a\\result.json": {
"bytes": 1356,
"sha256": "21fd5904fa62fcf71a2b9dd24aa906b5046bdb5d372e89034dc322e504b44dd5"
},
"G:\\CbbOwnedRelease-20261119\\native\\run-source-01\\data\\evidence\\verify-b5a731c7b22a\\session.json": {
"bytes": 2387,
"sha256": "3b7341f101f1b655db6521b111b81596e250f2f4528e8224a200fab435e30d28"
},
"G:\\CbbOwnedRelease-20261119\\native\\run-source-01\\data\\evidence\\verify-b5a731c7b22a\\startup-close.json": {
"bytes": 1658,
"sha256": "4342b450f365769ae0664d86e4905a960a47c228c7882896949adb6b604036d5"
},
"G:\\CbbOwnedRelease-20261119\\native\\run-source-01\\data\\evidence\\verify-b5a731c7b22a\\owned-idle-cleanup-result.json": {
"bytes": 764,
"sha256": "cb60648b4d474ac36f961d4d22acdbdccf683cd4cd4265d91704b41fc94ba47b"
},
"G:\\CbbOwnedRelease-20261119\\native\\run-source-01\\data\\evidence\\verify-b5a731c7b22a\\late-release-result.json": {
"bytes": 5657,
"sha256": "b5c7558f75187bdd4e3556863b1f61e42eb10e82bbc39d090200eb7f386c3776"
},
"G:\\CbbOwnedRelease-20261119\\native\\run-source-01\\ui-01\\results\\1795056556817677800-f459.json": {
"bytes": 100,
"sha256": "9f0cb90cca6bc4388da6e21884e13772fd658272d89b1d4f294f0648cc828d40"
},
"G:\\CbbIssueLatest-20261118\\checks\\owned-release-final-full.log": {
"bytes": 2979,
"sha256": "e195023875728737aac8252af3b60a2550fd03d882348e3b5119bfe961c5b2e1"
},
"G:\\CbbIssueLatest-20261118\\checks\\owned-release-final-full.xml": {
"bytes": 364840,
"sha256": "22868613cbbc42603ba9706a69a763408501e4737b37ad273afedd8c40024e95"
},
"G:\\CbbIssueLatest-20261118\\checks\\owned-release-full.log": {
"bytes": 8164,
"sha256": "13144d335d9810ea17d86cd5c69637d9d2ad895919471bbf218e52e1560309cb"
},
"G:\\CbbIssueLatest-20261118\\checks\\owned-release-full.xml": {
"bytes": 369719,
"sha256": "b38fb41722f538db280c17c9b660efe3f221827718b968739108f1c4b0f99751"
},
"G:\\CbbIssueLatest-20261118\\checks\\owned-release-metadata-green.log": {
"bytes": 215,
"sha256": "fb872df90264cbf29bd633aed47619c8699d3d78fa3ae54c2a99119b22c1d9f6"
},
"G:\\CbbIssueLatest-20261118\\checks\\owned-idle-red.log": {
"bytes": 40884,
"sha256": "c120c4601b49a7d78fb6bf43f6d67741bbb5997f8d121b237e5c054073018c24"
},
"G:\\CbbIssueLatest-20261118\\checks\\retained-target-red.log": {
"bytes": 14393,
"sha256": "22fc9e83e0badc075193472a3a3326ab8c5e63ba6f932b410d94bbecf7227771"
},
"G:\\CbbIssueLatest-20261118\\checks\\owned-cleanup-binding-red.log": {
"bytes": 6208,
"sha256": "f3916183b5de3c755ee0de0dc5d2979378fa1dbecae865b8d25cb9499eaab89d"
},
"G:\\CbbIssueLatest-20261118\\checks\\owned-cleanup-binding-green.log": {
"bytes": 296,
"sha256": "46d2ef54e220d7757628be683706ac5e3582909ab179dd75b961ed4f5541d2fb"
},
"G:\\CbbIssueLatest-20261118\\owned-release-review.md": {
"bytes": 13350,
"sha256": "7cf8e8d5652af4382397e6507a280dfaacb41a10ad4f06d395d9aebb55fc3006"
}
},
"merged": false,
"released": false,
"issue_closed": false
}
@@ -0,0 +1,52 @@
# 本任务会话主动收尾与共享资源释放验证
基线:`3bde847`;分支:`codex/issue17-batch-cleanup`。日期:2026-11-19。
## 已确认的问题
1. `recheck_failed_release` 发现登记进程 ACTIVE 时直接返回;后台观察只接续已取消的启动,没有接续终态失败后本任务留下的空闲客户端。
2. 普通校验的 `LibraryLock(checkpoint=False)` 没有携带 `block_name`,保留租约成为无工程身份的整库范围。已实际复现:目标 Bad 的释放,被无关 Other 工程的 `sAddress.adr` 扩大阻塞。
3. 文件占用探测返回 Win32 32/33 时没有文件路径,无法从记录中准确判断是工程还是共享数据库占用。
## 当前收尾顺序
失败仍保持失败。先观察本次精确会话;只对已登记且工作进程/助手已退出的安全空客户端执行一次正常关闭,再独立证明工程和共享资源释放,之后才允许同库后续项继续。
自动正常关闭的条件为:请求、会话、操作、库、私有桌面和结果匹配;Verify 结果还必须匹配 CBB 名称及自身证据路径;进程创建身份、镜像、用户和 Windows 会话一致;所有 worker/helper 原身份已退出;没有其他原生写入任务。仅接续明确数据库启动失败且未进入 Save 的空 PCB、保存/关闭均有明确返回的空 PCB,或本任务只读目录调用留下的空 Library Manager。
有文档(包括隐藏文档)、未知窗口、进度、保存结果未知、身份变化、记录损坏、正在运行的工作进程或其他任务时不自动关闭。服务器不作为自动关闭目标。关闭前持久化一次性意图,并再次核对窗口、请求、结果和 worker-state;状态变化即不发送 Close。正常关闭等待最多 3 秒,不循环发送、不强杀、不删除原生锁。
`CLIENT_EXITED` 只描述客户端退出,明确保留 `resource_release_confirmed=false`。随后仍需独立释放证明覆盖目标工程、LMC 与 SymbolLibs 共享数据库。Verify 租约现在携带目标 CBB,复核不再无故扫描全部其他工程。共享库或其他程序仍占用时保留未释放状态;实际 Win32 32/33 记录为 IN_USE,保存准确的 `blocked_resources` 路径,超时/权限/无法确认等仍为 UNCONFIRMED。历史业务结果文件不被修改。
冷启动发现旧会话时仍按只读观察处理;用户的明确释放操作保持原有入口。新主动收尾接在正在执行的批次复核及非只读后台收尾观察中。
## 回归证据
自动化日志位于 `G:/CbbIssueLatest-20261118/checks`。
- `owned-idle-red`:18 条新增测试先失败,复现被动观察不能正常收尾的缺口。
- `retained-target-red`:真正文件探测复现无关 Other 地址扩大释放范围;补上租约 block_name 后通过。
- `owned-release-observer`:真实 Win32 share=0 句柄占住共享 icdb,客户端正常关闭但资源仍未释放;同时发现错误缺少路径,随后补齐。
- `owned-cleanup-parser-red`、`owned-cleanup-binding-red`:错误 JSON 类型、错置结果和意图持久化后状态改变均先复现,再修正为拒绝动作。
- 早期相关回归 162 项通过;随后资源回归 51 项通过;最终相关回归 84 项通过。编译与差异格式检查通过。
- 首轮全量 `owned-release-full` 保留 2 failed / 2,498 passed:恢复交接测试的 300ms 时限在实际文件复制到达其指定停顿点前触发,失败断言为 `entered.is_set()`,不是晚安装或跨库准入失效。仅调整该用例的局部时钟:准备期间冻结,到指定边界后推进以触发真实交接,再恢复实时时钟验证租约与后续操作。文件复制、库锁、TaskHandoff 与“不晚安装/不晚校验”断言均保留,未放宽产品超时;40 项相关用例通过。最终全量另记,不覆盖失败日志。
- 最终 `python -X utf8 G:/CbbIssueLatest-20261118/run_checks.py owned-release-final-full -q`:**2,500 passed,0 failed/error/skipped**,461.69 秒,实际退出码 0。相邻 JSON 保存测试统计、源码指纹和证据 SHA-256;独立复核无遗留代码问题。
- `G:/CbbOwnedRelease-20261119/original-source-postcheck.json`:原始隔离输入 28,348 个文件的 SHA-256、大小、修改时间及集合一致,新增、缺失、修改均为 0;排除项仍是复制前清单明确排除的旧顶层协调文件。
## 实际应用按钮验收
独立证据目录:`G:/CbbOwnedRelease-20261119`。复用此前明确隔离的库和构造损坏头部;健康项通过原生同名更新准备为 PENDING,未替换校验后端。76 个源码与资源 SHA-256 在运行前冻结、运行后逐一核对。
为了实际触发旧收尾失败,验证驱动只对本轮已登记、身份核实的私有桌面空 PCB 窗口临时设置不可用。原生数据库加载错误仍被正常识别;等待原始 `startup-close.json` 返回 RETAINED 后,立即恢复窗口可用。恢复不发送 Close、不结束进程;后续 Close 由产品自身完成。这是刻意制造的收尾延迟,不是客户现场原始故障复现。
`fault-injection.json`:PCB PID 65168,桌面 `CbbVerify_0058861f6eea`,干预仅两次 EnableWindow(false),66.469 秒后恢复;原收尾记录 PCB/启动器未退出、safe=false。
`verify-b5a731c7b22a/session.json` 保存一次 `owned_idle_cleanup`;`owned-idle-cleanup-result.json` 为 CLIENT_EXITED。原 `result.json` 仍是 FAIL/`MENTOR_DATABASE_LOAD_FAILED`、safe=false;独立 `late-release-result.json` 保存业务 FAIL、资源 safe=true 及 fresh RELEASE_CONFIRMED,范围为该 CBB 加共享数据库,明确包含 `SymbolLibs/__ReusableBlocksSymb/icdb.dat`。
后续 RTL 实际继续执行:首轮 `verify-5d4a9fe55bb4` 完成保存关闭、权威 PENDING;自动一次 `verify-8a460f0dd044` 后 PASS/GREEN、权威 READY。两轮累计 188.453 秒;批次共 327.859 秒,恰好 FAIL/PASS 两行,零 SKIPPED。运行期间切换筛选、清空勾选、切换页签,提交目标不变。
`closure-proof.json`:8 个登记进程身份退出、7 个关键文件独占打开、76 个源码指纹一致;保留原始失败与收尾失败,实际未强杀、未删原生锁。应用随后正常关闭 exit 0,控制回执位于 `native/run-source-01/ui-01/results`。只读 Library Manager 空壳自动收尾有回归覆盖,本轮未另外制造其真实残留。
## 边界
客户原始故障一致副本、冻结 EXE 和所有安装环境未在本轮验收。真实共享写入或未知保存状态仍不能强行解除;这个保护不会被“继续下一项”的要求替代。本轮不合并、不发行、不关闭工单。
@@ -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`,保留现场原始故障与冻结包验收缺口。
@@ -463,6 +463,7 @@ def check_target_window(job, pcb_pid, *, emit, error_reader, launcher_process=No
if not session.pcb_alive():
raise RuntimeError('DIAGNOSTIC_OPEN_UNCONFIRMED: target PCB exited before loaded evidence')
windows = scan(deadline)
_cancel(job)
if any(window['pid'] != int(pcb_pid) for window in windows):
raise RuntimeError('DIAGNOSTIC_PID_MISMATCH')
frame = _target_frame(windows, Path(job['pcb']).stem, require_ready=False)
+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
+8 -2
View File
@@ -41,6 +41,7 @@ def hold_release_files(library, roots=None, *, timeout_seconds=10, stop=None):
if record.get('token') != token or record.get('status') != 'HELD' or process.poll() is not None:
error = OSError('FILE_PROBE_UNCONFIRMED: '+str(record.get('error', '探测身份或句柄失效')))
error.winerror = record.get('winerror')
error.blocked_resources = record.get('blocked_resources', [])
raise error
# Duplicate the already-open handles before acknowledging the probe.
# Its exit can never create a gap in the parent's commit protection.
@@ -108,6 +109,7 @@ def file_probe_main(job):
job = Path(job)
request = json.loads(job.read_text('utf-8'))
result = {'token': request['token'], 'status': 'UNCONFIRMED'}
opening = None
try:
def checked_path(value):
path = Path(value).absolute()
@@ -127,15 +129,18 @@ def file_probe_main(job):
with ExitStack() as stack:
handles = []
for path in snapshot['exclusive_files']:
opening = path
handle = win32file.CreateFile(path, win32con.GENERIC_READ, 0, None,
win32con.OPEN_EXISTING, win32con.FILE_ATTRIBUTE_NORMAL, None)
stack.callback(handle.Close)
handles.append(int(handle))
for path in snapshot['binding_files']:
opening = path
handle = win32file.CreateFile(path, win32con.GENERIC_READ, win32con.FILE_SHARE_READ,
None, win32con.OPEN_EXISTING, win32con.FILE_ATTRIBUTE_NORMAL, None)
stack.callback(handle.Close)
handles.append(int(handle))
opening = None
if _snapshot(library, roots) != snapshot:
raise ValueError('占用检查期间资源集合变化')
pending = job.with_name('result.pending')
@@ -145,7 +150,8 @@ def file_probe_main(job):
return 0
except Exception as error:
pending = job.with_name('result.pending')
pending.write_text(json.dumps({**result, 'error': str(error),
'winerror': getattr(error, 'winerror', None)}), 'utf-8')
blocked = [opening] if opening and getattr(error, 'winerror', None) in (32,33) else []
pending.write_text(json.dumps({**result, 'error': (opening+': ' if opening else '')+str(error),
'winerror': getattr(error, 'winerror', None), 'blocked_resources': blocked}), 'utf-8')
pending.replace(job.with_name('result.json'))
return 1
+2
View File
@@ -559,6 +559,7 @@ def _prove_library_released(library, block_name=None, *, block_names=(), allow_u
except OSError as error:
blocked = LibraryBusy(str(error))
blocked.winerror = getattr(error, 'winerror', None)
blocked.blocked_resources = getattr(error, 'blocked_resources', [])
raise blocked from error
note_metadata_progress()
if files['addresses']:
@@ -576,6 +577,7 @@ def _prove_library_released(library, block_name=None, *, block_names=(), allow_u
except OSError as error:
blocked = LibraryBusy(str(error))
blocked.winerror = getattr(error, 'winerror', None)
blocked.blocked_resources = getattr(error, 'blocked_resources', [])
raise blocked from error
if any(current[key] != files[key] for key in (
'exclusive_files', 'addresses', 'signatures', 'inspection_targets')):
+28 -9
View File
@@ -171,7 +171,7 @@ def _may_have_mutated(record):
def run_management(request, *, adapter=None, verifier=None, idle_check=None, progress=None, stop=None, version_prompt=None,
write_admission=None):
from .verify_runner import VerifyRequest, run_verify
from .verify_runner import VerifyRequest, run_verify, _notify_progress
from .backup_recovery import _idle_check
from contextlib import ExitStack
from .operation_queue import check_active, native_channel, task_stop, remember_result
@@ -216,7 +216,7 @@ def run_management(request, *, adapter=None, verifier=None, idle_check=None, pro
_write_json(report, {**asdict(request), 'stage': stage, 'status': 'RUNNING',
'safe_to_continue': False, 'history': history, 'backup_policy': 'manual'})
if progress:
progress({'stage': stage, 'block': request.name, 'operation': request.operation, **details})
_notify_progress(progress, {'stage': stage, 'block': request.name, 'operation': request.operation, **details})
def finish(status, detail='', safe=True):
nonlocal change_report
remember_result(ManagementResult(request.operation, request.library, request.name, request.partition,
@@ -465,7 +465,8 @@ def run_management(request, *, adapter=None, verifier=None, idle_check=None, pro
def run_management_batch(requests, *, stop=None, progress=None, item_executor=None, context=None, **kwargs):
from threading import Event
from .write_admission import WriteAdmission
from .operation_queue import QueueCancelled, TaskHandoff, request_library_keys, remember_result, current_context
from .verify_runner import _notify_progress
from .operation_queue import QueueCancelled, QueueUnavailable, TaskHandoff, request_library_keys, remember_result, current_context
context = context or current_context()
if context is not None:
stop = stop if stop is not None else context.stop
@@ -474,19 +475,30 @@ def run_management_batch(requests, *, stop=None, progress=None, item_executor=No
stop = Event()
kwargs.setdefault('write_admission',WriteAdmission(prompt=kwargs.get('version_prompt'),stop=stop))
results = []
retained_libraries = set()
retained_libraries = {}
cancelled = False
for request in requests:
keys = request_library_keys(request, context)
stopped = (cancelled or stop.is_set() or context is not None
and (context.stop.is_set() or context.stop_after_current.is_set()))
if not stopped:
for index in {retained_libraries[key][1] for key in keys.intersection(retained_libraries)}:
previous = next(value[0] for value in retained_libraries.values() if value[1] == index)
from .operation_lifecycle import recheck_failed_release
refreshed = recheck_failed_release(previous.library, previous.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 stopped or keys.intersection(retained_libraries):
previous = (retained_libraries[next(iter(keys.intersection(retained_libraries)))][0]
if not stopped else None)
result = ManagementResult(request.operation, request.library, request.name, request.partition,
request.source, request.auto_verify, 'complete', 'SKIPPED', True,
'队列已停止,未操作此 CBB' if stopped else '同库原生会话尚未释放,未启动新的写入')
request.source, request.auto_verify, 'admission', 'SKIPPED', True,
'队列已停止,未操作此 CBB' if stopped else
f'PREVIOUS_SESSION_UNRELEASED: 前项 {previous.name} 的同库会话尚未释放,当前项未启动。')
results.append(result)
if progress:
progress({'stage': result.status, 'block': result.name, 'detail': result.detail})
_notify_progress(progress, {'stage': result.status, 'block': result.name, 'detail': result.detail})
continue
def action():
result = run_management(request, progress=progress, stop=stop, **kwargs)
@@ -497,6 +509,9 @@ def run_management_batch(requests, *, stop=None, progress=None, item_executor=No
return result
try:
result = item_executor(request, action) if item_executor is not None else action()
except QueueUnavailable as error:
result = ManagementResult(request.operation, request.library, request.name, request.partition,
request.source, request.auto_verify, 'admission', 'SKIPPED', True, str(error))
except QueueCancelled as error:
known = error.result if isinstance(error, TaskHandoff) else None
if isinstance(known, ManagementResult):
@@ -510,12 +525,16 @@ def run_management_batch(requests, *, stop=None, progress=None, item_executor=No
request.source, request.auto_verify, 'complete',
'TIMEOUT' if isinstance(error, TaskHandoff) and not error.cancelled else 'CANCELLED',
not isinstance(error, TaskHandoff), str(error))
except Exception as error:
result = ManagementResult(request.operation, request.library, request.name, request.partition,
request.source, request.auto_verify, 'exception', 'RECOVERY_REQUIRED', False,
'BATCH_ITEM_EXCEPTION: '+str(error))
results.append(result)
if progress:
progress({'stage': result.status, 'block': result.name, 'detail': result.detail,
_notify_progress(progress, {'stage': result.status, 'block': result.name, 'detail': result.detail,
'evidence_path': str(result.evidence_path or '')})
if not result.safe_to_continue:
retained_libraries.update(keys)
retained_libraries.update({key:(request, len(results)-1) for key in keys})
if result.status == 'CANCELLED':
cancelled = True
return results
+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:
+19 -5
View File
@@ -6,13 +6,13 @@ def recheck_failed_release(library, block, result, *, stop=None, timeout_seconds
"""Refresh resource facts after a late exit; keep the original business failure."""
if result.safe_to_continue or not result.evidence_path:
return result
from .operation_queue import BatchTaskContext, TaskHandoff, current_context, task_stop
from .operation_queue import BatchTaskContext, QueueCancelled, current_context, task_stop
if current_context() is None:
context = BatchTaskContext(library=str(library), targets=(block,))
try:
return context.run(lambda: recheck_failed_release(library, block, result, stop=stop),
stop=stop, timeout_seconds=timeout_seconds)
except TaskHandoff:
except QueueCancelled:
return result
stop = task_stop(stop)
from pathlib import Path
@@ -28,7 +28,10 @@ def recheck_failed_release(library, block, result, *, stop=None, timeout_seconds
if record.get('block') != block or Path(record.get('library', '')).resolve() != Path(library).resolve():
return result
if inspect_session_record(session, evidence_root=evidence.parent).get('status') == 'ACTIVE':
return result
from .residual_sessions import finish_owned_idle_session
finish_owned_idle_session(session, stop=stop)
if inspect_session_record(session, evidence_root=evidence.parent).get('status') == 'ACTIVE':
return result
else:
record = json.loads(evidence.read_text('utf-8'))
if (record.get('name') != block or record.get('operation') not in ('add', 'update', 'remove')
@@ -42,7 +45,10 @@ def recheck_failed_release(library, block, result, *, stop=None, timeout_seconds
if Path(owned.get('library', '')).resolve() != Path(library).resolve():
return result
if inspect_session_record(candidate, evidence_root=evidence.parent).get('status') == 'ACTIVE':
return result
from .residual_sessions import finish_owned_idle_session
finish_owned_idle_session(candidate, stop=stop)
if inspect_session_record(candidate, evidence_root=evidence.parent).get('status') == 'ACTIVE':
return result
bound.append(candidate)
if not bound:
return result # A generic timeout without a bound owner is not an exit fact.
@@ -60,7 +66,15 @@ def recheck_failed_release(library, block, result, *, stop=None, timeout_seconds
business_status=result.status, safe_to_continue=True, release_proof=proof),
ensure_ascii=False, default=str, indent=2), 'utf-8')
return replace(result, safe_to_continue=True, release_proof=proof)
except Exception:
except Exception as error:
try:
evidence.with_name('late-release-attempt.json').write_text(json.dumps(dict(
business_status=result.status, safe_to_continue=False,
status='IN_USE' if getattr(error,'winerror',None) in (32,33) else 'UNCONFIRMED',
library=str(library), block=block, detail=str(error),
blocked_resources=getattr(error,'blocked_resources',[])),ensure_ascii=False,indent=2),'utf-8')
except OSError:
pass
return result
+18 -2
View File
@@ -11,6 +11,14 @@ class QueueCancelled(RuntimeError):
pass
class QueueUnavailable(RuntimeError):
"""Admission failed before action dispatch; this task created no native session."""
def __init__(self, library):
self.library = str(library)
super().__init__('NATIVE_SESSION_PENDING: '+self.library+
' 的已登记会话仍在运行或初始化,当前项未启动。')
class TaskHandoff(QueueCancelled):
"""The call is still observable; this is never a release receipt."""
def __init__(self, context, *, cancelled=False, result=None):
@@ -409,14 +417,19 @@ class NativeQueue:
for context in contexts)
def run(self, action, *, stop=None, waiting=None, ready=lambda: True, wait_state=None,
context=None, timeout_seconds=10):
context=None, timeout_seconds=10, skip_unavailable=False):
def available_now():
if not ready():
return False
if context is None:
return True # Explicit recovery controls must still reach their retained clients.
from .session_record import _live_library_available
return all(_live_library_available(path) for path in (context.library, *context.aliases))
for path in (context.library, *context.aliases):
if not _live_library_available(path):
if skip_unavailable:
raise QueueUnavailable(path)
return False
return True
ticket = [object(), False]
acquired, notified = False, False
previous_state = None
@@ -428,6 +441,9 @@ class NativeQueue:
self.pending.append(ticket)
try:
while not acquired:
if (self.closed or stop is not None and stop.is_set()
or context is not None and (context.stop.is_set() or context.stop_after_current.is_set())):
raise QueueCancelled('已取消排队,未启动原生操作。')
available = available_now() # Cached predicates only, outside the queue lock.
with self.condition:
if (self.closed or stop is not None and stop.is_set()
+112
View File
@@ -818,6 +818,118 @@ def resume_cancelled_startup(path, *, stop=None):
return False
def finish_owned_idle_session(path, *, stop=None):
"""One normal close for a registered, settled, empty client; never a server."""
from contextlib import ExitStack
import stat
import pywintypes, win32con, win32event
from .session_record import _session, active_write_records, write_session_record
from .operation_queue import check_active, native_phase
path = Path(path)
mutex = win32event.CreateMutex(None, False, r'Local\CbbRefreshVerify795')
acquired = False
try:
acquired = win32event.WaitForSingleObject(mutex, 0) in (win32con.WAIT_OBJECT_0, win32con.WAIT_ABANDONED)
if not acquired or stop is not None and stop.is_set(): return False
session, state, identities = _session(path, path.parent)
if 'owned_idle_cleanup' in session: return False
def read(name):
item = path.with_name(name)
if item.lstat().st_file_attributes & stat.FILE_ATTRIBUTE_REPARSE_POINT:
raise ValueError('OWNED_CLEANUP_REPARSE_POINT')
with item.open('rb') as stream: data = stream.read(1024*1024+1)
if len(data) > 1024*1024: raise ValueError('OWNED_CLEANUP_RECORD_TOO_LARGE')
return json.loads(data)
job, result = read('request.json'), read('result.json')
if not isinstance(job, dict) or not isinstance(result, dict): return False
if (any(job.get(k) != session.get(k) for k in ('operation_id','operation','library','desktop','block'))
or Path(job.get('session_record_path','')).resolve() != path.resolve()
or result.get('safe_to_continue') is not False): return False
operation, desktop = job['operation'], job['desktop']
if operation == 'verify':
facts = result.get('write_outcome') or {}
failed_open = (result.get('error_stage') == 'PCB_STARTING'
and result.get('error_category') in ('MENTOR_DATABASE_LOAD_FAILED','ICDB_REPAIR_REQUIRED')
and not path.with_name('save.log').exists())
saved_closed = (isinstance(facts, dict) and facts.get('interrupted') is False
and all(facts.get(k) == v for k,v in (
('save_state','COMMITTED'),('close_state','CLOSED'),('helper_state','EXITED'))))
if (not desktop.startswith('CbbVerify_') or job.get('interactive_input') is not False
or result.get('status') not in ('FAIL','BLOCKED','TIMEOUT','CANCELLED')
or result.get('block_name') != job['block']
or Path(result.get('evidence_path','')).resolve() != path.with_name('result.json').resolve()
or Path(job.get('root','')).resolve() != path.parent.resolve()
or job.get('lmc_file') != job['library'] or not (failed_open or saved_closed)): return False
client_name = 'expeditionpcb.exe'
elif operation == 'catalog' and job.get('worker_role') == 'catalog_readonly' and desktop.startswith('CbbManagement_'):
client_name = 'librarymanager.exe'
else:
return False
workers = [p for p in identities if p.get('role') in ('worker','helper')]
clients = [p for p in identities if p.get('role') == 'native' and Path(p['image']).name.casefold() == client_name]
if not workers or len(clients) != 1: return False
if any(r.get('operation_id') != session['operation_id'] for r in active_write_records(session['library'])):
return False
with ExitStack() as held:
for worker in workers:
try:
handle = held.enter_context(_process_handle(worker['pid']))
if (win32event.WaitForSingleObject(handle, 0) != win32con.WAIT_OBJECT_0
and _handle_identity(handle) == {k:worker[k] for k in ('created_handle','image')}):
return False
except pywintypes.error as error:
if error.winerror != 87: raise
client = clients[0]
handle = held.enter_context(_process_handle(client['pid']))
def same_client():
owner = _force_ownership(handle, client['pid'])
return (win32event.WaitForSingleObject(handle, 0) == win32con.WAIT_TIMEOUT
and owner.get('force_user_confirmed') is True
and _handle_identity(handle) == {k:client[k] for k in ('created_handle','image')}
and all(owner.get(k) == client[k] for k in ('owner_sid','session_id')))
def empty_target():
snapshot = _process_windows({client['pid']}, include_hidden_documents=True)
windows = snapshot.get(client['pid'], [])
if (any(w.get('desktop') != desktop or w.get('documents')
or any(c['class'].casefold().startswith('afx:') and c.get('visible') is False
for c in w.get('children',[])) for w in windows)):
return None
return close_target(client_name, windows, incomplete=_window_error(snapshot,client['pid']))[0]
if not same_client(): return False
target = empty_target()
if target is None or stop is not None and stop.is_set(): return False
check_active()
current, _, _ = _session(path, path.parent)
if current != session: return False
claim = dict(operation_id=session['operation_id'],pid=client['pid'],identity=client,
status='REQUESTED',hwnd=target['hwnd'],desktop=desktop)
write_session_record(path, {**session,'owned_idle_cleanup':claim})
# Re-read after durable I/O; never act on a window that gained a document.
latest, latest_state, latest_identities = _session(path, path.parent)
if (latest_state != state or latest_identities != identities
or latest.get('owned_idle_cleanup') != claim
or any(latest.get(k) != v for k,v in session.items() if k != 'recorded_at')
or not same_client() or empty_target() != target or read('request.json') != job
or read('result.json') != result or stop is not None and stop.is_set()): return False
with native_phase(read_only=True):
_post_window_message(target,target['hwnd'],client['pid'],win32con.WM_CLOSE)
deadline = time.monotonic()+3
while time.monotonic() < deadline:
if win32event.WaitForSingleObject(handle,100) == win32con.WAIT_OBJECT_0: break
if stop is not None and stop.is_set(): break
exited = win32event.WaitForSingleObject(handle,0) == win32con.WAIT_OBJECT_0
write_session_record(path.with_name('owned-idle-cleanup-result.json'),dict(
operation_id=session['operation_id'],library=session['library'],
status='CLIENT_EXITED' if exited else 'WAITING',claim=claim,
resource_release_confirmed=False))
return True # Client exit is still not independent resource release proof.
except (OSError,pywintypes.error,ValueError,KeyError,TypeError,RuntimeError):
return False
finally:
if acquired: win32event.ReleaseMutex(mutex)
mutex.Close()
def _request_close(row, *, stop=None):
import win32con, win32event
with _process_handle(row['pid']) as handle:
+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
+2 -2
View File
@@ -409,8 +409,8 @@ def observe_retained_session(path, *, evidence_root, stop=None, progress=None, p
pass
if result['status'] == 'ACTIVE' and not observation_only and not stop.is_set():
try:
from .residual_sessions import resume_cancelled_startup
if resume_cancelled_startup(path, stop=stop):
from .residual_sessions import resume_cancelled_startup, finish_owned_idle_session
if resume_cancelled_startup(path, stop=stop) or finish_owned_idle_session(path, stop=stop):
# Cleanup is not release proof. Re-read all held identities
# and independently prove the resource release as usual.
result = _reconcile(Path(path), Path(evidence_root), handles, stack)
@@ -113,13 +113,17 @@ class BackupRecoveryDialog(QDialog):
options = {'version_prompt': lambda choice:self._emit(context, 'choice',choice),'stop':context.stop} if self.recoverer is None else {}
action = lambda: recoverer(request, source, progress=lambda event:self._emit(context, 'progress',event), **options)
if self.native_queue is None: return context.run(action)
from ..operation_queue import QueueCancelled
from ..operation_queue import QueueCancelled, QueueUnavailable
def restore():
self._emit(context, 'progress',{'stage': 'queue_acquired'})
return action()
try:
return self.native_queue.run(restore, stop=context.stop, context=context, waiting=lambda: self._emit(context, 'progress',
return self.native_queue.run(restore, stop=context.stop, context=context, skip_unavailable=True, waiting=lambda: self._emit(context, 'progress',
{'stage': 'waiting_native_slot', 'detail': '已排队,等待当前检查结束'}))
except QueueUnavailable as error:
from ..verify_runner import VerifyResult
return VerifyResult('SKIPPED', stderr=str(error), error_category='NATIVE_SESSION_PENDING',
error_stage='admission')
except QueueCancelled as error:
from ..operation_queue import TaskHandoff
from ..verify_runner import VerifyResult, _handoff_verify_result
+21 -7
View File
@@ -1,7 +1,7 @@
"""A check batch owns its snapshot and yields the native queue after each CBB."""
from PySide6.QtCore import QObject, QThreadPool, Signal
from .workers import ServiceWorker
from ..operation_queue import QueueCancelled, BatchTaskContext
from ..operation_queue import QueueCancelled, QueueUnavailable, BatchTaskContext, request_library_keys
from ..verify_runner import VerifyResult, run_verify, write_batch_report
from ..icdb_maintenance import write_maintenance_report
@@ -30,7 +30,7 @@ class IcdbCheckTask(QObject):
self.running = False
self.report = None
self.report_error = ''
self.retained_libraries = set()
self.retained_libraries = {}
self.pool = QThreadPool(self); self.pool.setMaxThreadCount(1)
def _emit_event(self, event):
@@ -66,9 +66,6 @@ class IcdbCheckTask(QObject):
if self.stop.is_set():
self.results.extend(VerifyResult('SKIPPED', stderr='队列已停止,未操作此 CBB')
for _ in self.requests[len(self.results):])
while len(self.results) < len(self.requests) and str(
self.requests[len(self.results)].lmc_file).casefold() in self.retained_libraries:
self.results.append(VerifyResult('SKIPPED', stderr='同库原生会话尚未释放,未启动新的检查'))
if len(self.results) == len(self.requests):
self._report(); return
if self.paused: return
@@ -76,6 +73,19 @@ class IcdbCheckTask(QObject):
def check():
from ..session_record import library_available, library_wait_reason
try:
keys = request_library_keys(request, self.context)
for index in {self.retained_libraries[key] for key in keys.intersection(self.retained_libraries)}:
previous = self.requests[index]
from ..operation_lifecycle import recheck_failed_release
refreshed = recheck_failed_release(previous.lmc_file, previous.block_name,
self.results[index], stop=self.stop)
if refreshed.safe_to_continue:
self.results[index] = refreshed
self.retained_libraries = {k:v for k,v in self.retained_libraries.items() if v != index}
if keys.intersection(self.retained_libraries):
index = self.retained_libraries[next(iter(keys.intersection(self.retained_libraries)))]
return VerifyResult('SKIPPED', error_category='PREVIOUS_SESSION_UNRELEASED',
error_stage='admission', stderr=f'前项 {self.requests[index].block_name} 的同库会话尚未释放,当前项未启动。')
def execute():
if self.status_reader is not None:
statuses = self.status_reader((request.block_name,), request.lmc_file)
@@ -92,12 +102,15 @@ class IcdbCheckTask(QObject):
from ..operation_lifecycle import recheck_failed_release
result = recheck_failed_release(request.lmc_file, request.block_name, result)
return result
return self.queue.run(execute, stop=self.stop, context=self.context,
return self.queue.run(execute, stop=self.stop, context=self.context, skip_unavailable=True,
wait_state=lambda: (self.paused, library_wait_reason(request.lmc_file)),
ready=lambda: not self.paused,
waiting=lambda: self._emit_event({'stage': 'waiting_native_slot', 'block': request.block_name,
'library': str(request.lmc_file), 'retained': not library_available(request.lmc_file),
'detail': library_wait_reason(request.lmc_file) or '已排队,等待当前原生操作结束'}))
except QueueUnavailable as error:
return VerifyResult('SKIPPED', stderr=str(error), error_category='NATIVE_SESSION_PENDING',
error_stage='admission')
except QueueCancelled as error:
from ..operation_queue import TaskHandoff
from ..verify_runner import _handoff_verify_result
@@ -116,7 +129,8 @@ class IcdbCheckTask(QObject):
request = self.requests[len(self.results)]
name = request.block_name
if not result.safe_to_continue:
self.retained_libraries.add(str(request.lmc_file).casefold())
self.retained_libraries.update({key:len(self.results)
for key in request_library_keys(request, self.context)})
self.results.append(result)
if result.status in ('CANCELLED', 'QUEUE_STOP'): self.stop.set()
self.item_done.emit(name, result)
+27 -16
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()
@@ -1054,7 +1059,7 @@ class MainWindow(QWidget):
event['detail'] = label+'中…'
emit(event)
return action()
return lambda: self.native_queue.run(execute, stop=stop, context=job.context if job else None,
return lambda: self.native_queue.run(execute, stop=stop, context=job.context if job else None, skip_unavailable=True,
wait_state=lambda: library_wait_reason(library),
waiting=lambda: emit({'stage': 'waiting_native_slot',
'library': str(library), 'retained': not library_available(library),
@@ -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, skip_unavailable=True))
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)
@@ -1778,12 +1789,12 @@ class MainWindow(QWidget):
safe = all(result.safe_to_continue for result in results)
self._emit_job(job, 'batch_ready', (results, report))
refresh = None
if safe and not job.context.stop.is_set():
from cbb_refresh_verify.operation_queue import QueueCancelled
if safe and affected and not job.context.stop.is_set():
from cbb_refresh_verify.operation_queue import QueueCancelled, QueueUnavailable
try:
refresh = self._queued_action(lambda: self._read_affected_records(affected, library=library, lease=job.lease),
label='批次已结束,状态刷新', library=library, job=job)()
except QueueCancelled:
except (QueueCancelled, QueueUnavailable):
pass # Cancelling the refresh must not erase completed item results.
return results, report, affected, refresh
self._start(action, self._batch_refreshed, queued=False, job=job, bounded=False)
@@ -2147,8 +2158,8 @@ class MainWindow(QWidget):
'已请求取消;检查将停止,原生写入只等待安全结束,不强制终止。'); self._update()
def _failed(self, error):
from cbb_refresh_verify.operation_queue import QueueCancelled
if self.library_lease is not None and not isinstance(error, QueueCancelled):
from cbb_refresh_verify.operation_queue import QueueCancelled, QueueUnavailable
if self.library_lease is not None and not isinstance(error, (QueueCancelled, QueueUnavailable)):
self._retain_path_lease(self.library_lease, hold_busy=True)
self._display_error(error)
@@ -193,12 +193,12 @@ class ManagementDialog(QDialog):
action = lambda: self.runner(requests, adapter=self.adapter, stop=context.stop,
progress=lambda event:self._emit(context, 'progress',event),**choices)
if self.native_queue is None: return context.run(action)
from ..operation_queue import QueueCancelled
from ..operation_queue import QueueCancelled, QueueUnavailable
from ..session_record import library_available, library_wait_reason
try:
if self.runner is run_management_batch:
def item(request, action):
return self.native_queue.run(action, stop=context.stop, context=context,
return self.native_queue.run(action, stop=context.stop, context=context, skip_unavailable=True,
wait_state=lambda: library_wait_reason(request.library),
waiting=lambda: self._emit(context, 'progress',{'stage': 'waiting_native_slot',
'retained': not library_available(request.library),
@@ -206,11 +206,15 @@ class ManagementDialog(QDialog):
return self.runner(requests, adapter=self.adapter, stop=context.stop,
progress=lambda event:self._emit(context, 'progress',event), item_executor=item,
version_prompt=lambda choice:self._emit(context, 'choice',choice), context=context)
return self.native_queue.run(action, stop=context.stop, context=context, waiting=lambda: self._emit(context, 'progress',
return self.native_queue.run(action, stop=context.stop, context=context, skip_unavailable=True, waiting=lambda: self._emit(context, 'progress',
{'stage': 'waiting_native_slot',
'retained': not library_available(self.template.library),
'detail': library_wait_reason(self.template.library) or '已排队,等待当前检查结束'}),
wait_state=lambda: library_wait_reason(self.template.library))
except QueueUnavailable as error:
from ..management import ManagementResult
return [ManagementResult(r.operation, r.library, r.name, r.partition, r.source, r.auto_verify,
'admission', 'SKIPPED', True, str(error)) for r in requests]
except QueueCancelled as error:
from ..operation_queue import TaskHandoff
from ..management import ManagementResult
+62 -7
View File
@@ -657,7 +657,7 @@ def _run_verify_task(request, *, progress=None, flag_reader=None, process_runner
Path(request.evidence_dir)/'previous-release', block_name=request.block_name,
progress=progress, stop=stop)
check_active()
library_lock = LibraryLock(request.lmc_file, checkpoint=False,
library_lock = LibraryLock(request.lmc_file, checkpoint=False, block_name=request.block_name,
safe_to_release=clients_released)
library_lock.__enter__()
check_active()
@@ -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):
@@ -1465,7 +1505,7 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=None, item_executor=None,
context=None):
"""Run serially and stop when database/session safety is unconfirmed."""
"""Run serially; isolate failures and skip writes to resources still retained."""
if max_workers != 1:
raise ValueError('Only serial Verify is supported for the shared Library Manager session')
if context is not None:
@@ -1476,15 +1516,28 @@ 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')
elif library_keys.intersection(retained_libraries):
result = VerifyResult('SKIPPED', stderr='同库原生会话尚未释放,未启动新的写入')
previous, index = retained_libraries[next(iter(library_keys.intersection(retained_libraries)))]
result = VerifyResult('SKIPPED', error_category='PREVIOUS_SESSION_UNRELEASED',
error_stage='admission', stderr=f'前项 {getattr(previous, "block_name", previous)} 的同库会话尚未释放,当前项未启动。')
else:
try:
def execute():
@@ -1495,15 +1548,17 @@ def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=Non
return result
result = item_executor(request, execute) if item_executor is not None else execute()
except Exception as error:
from .operation_queue import QueueCancelled, TaskHandoff
from .operation_queue import QueueCancelled, QueueUnavailable, TaskHandoff
# An unexpected exception cannot establish database safety.
result = (_handoff_verify_result(error) if isinstance(error, TaskHandoff) else
result = (VerifyResult('SKIPPED', stderr=str(error), error_category='NATIVE_SESSION_PENDING',
error_stage='admission') if isinstance(error, QueueUnavailable) else
_handoff_verify_result(error) if isinstance(error, TaskHandoff) else
VerifyResult('CANCELLED' if isinstance(error, QueueCancelled) else 'FAIL',
stderr=str(error), safe_to_continue=isinstance(error, QueueCancelled)))
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()
+248
View File
@@ -0,0 +1,248 @@
"""An item failure must not strand a batch or masquerade as ICDB damage."""
from dataclasses import replace
from threading import Event
import pytest
from cbb_refresh_verify import management, operation_lifecycle, session_record
from cbb_refresh_verify.operation_queue import BatchTaskContext, NativeQueue
from cbb_refresh_verify.verify_runner import VerifyRequest, VerifyResult, run_batch
def test_bulk_admission_skips_live_observer_without_starting_or_cancelling(tmp_path, monkeypatch):
from test_live_observer_queue import observed
library, _ = observed(tmp_path, monkeypatch)
queue = NativeQueue()
context = BatchTaskContext(str(library))
calls = []
with pytest.raises(RuntimeError, match='NATIVE_SESSION_PENDING'):
queue.run(lambda: calls.append('unexpected'), context=context, skip_unavailable=True)
assert not calls and not queue.pending and not queue.active
assert not context.stop.is_set()
assert queue.run(lambda: 'other library', context=BatchTaskContext(str(tmp_path/'other.lmc')),
skip_unavailable=True) == 'other library'
assert not session_record.library_available(library, live_only=True)
@pytest.mark.parametrize('kind', ['verify', 'management'])
def test_pre_admission_busy_is_one_skip_not_a_retained_or_cancelled_batch(tmp_path, monkeypatch, kind):
from test_live_observer_queue import observed
library, state = observed(tmp_path, monkeypatch)
queue = NativeQueue()
calls = []
def item(req, action):
path = req.lmc_file if kind == 'verify' else req.library
context = BatchTaskContext(str(path))
try:
return queue.run(action, context=context, skip_unavailable=True)
finally:
# The original observer finishes between submitted targets.
state['status'] = 'RELEASED'
if kind == 'verify':
def execute(req):
calls.append(req.block_name)
return VerifyResult('PASS')
results = run_batch([VerifyRequest(library, name, tmp_path) for name in ('Busy', 'Good')],
verifier=execute, item_executor=item)
else:
def execute(req, **kwargs):
calls.append(req.name)
return management.ManagementResult(req.operation, req.library, req.name, req.partition,
req.source, req.auto_verify, 'complete', 'REMOVED', True)
monkeypatch.setattr(management, 'run_management', execute)
results = management.run_management_batch([
management.ManagementRequest('remove', library, name) for name in ('Busy', 'Good')],
item_executor=item)
assert [r.status for r in results] == ['SKIPPED', 'PASS' if kind == 'verify' else 'REMOVED']
assert all(r.safe_to_continue for r in results)
assert calls == ['Good']
assert 'NATIVE_SESSION_PENDING' in (results[0].stderr if kind == 'verify' else results[0].detail)
@pytest.mark.parametrize('released', [True, False])
def test_management_rechecks_original_owner_and_preserves_failure(tmp_path, monkeypatch, released):
library = tmp_path/'lib.lmc'
requests = [management.ManagementRequest('remove', library, name) for name in ('Bad', 'Next')]
failed = management.ManagementResult('remove', library, 'Bad', 'Logical-Physical', None,
True, 'complete', 'RECOVERY_REQUIRED', False, 'original failure', tmp_path/'result.json')
checks, calls = [], []
def recheck(lib, block, result, **kwargs):
assert lib == library and block == 'Bad' and result.name == 'Bad'
checks.append(block)
return replace(result, safe_to_continue=True) if released and len(checks) > 1 else result
def execute(req, **kwargs):
calls.append(req.name)
return failed if req.name == 'Bad' else replace(failed, name=req.name, status='REMOVED', safe_to_continue=True)
monkeypatch.setattr(operation_lifecycle, 'recheck_failed_release', recheck)
monkeypatch.setattr(management, 'run_management', execute)
results = management.run_management_batch(requests)
assert checks == ['Bad', 'Bad']
assert calls == (['Bad', 'Next'] if released else ['Bad'])
assert results[0].status == 'RECOVERY_REQUIRED' and results[0].detail == 'original failure'
assert results[0].safe_to_continue is released
if not released:
assert 'Bad' in results[1].detail and results[1].stage == 'admission'
def test_management_unexpected_item_exception_keeps_independent_targets(tmp_path, monkeypatch):
libraries = [tmp_path/'same.lmc', tmp_path/'same.lmc', tmp_path/'other.lmc']
requests = [management.ManagementRequest('remove', library, name)
for library, name in zip(libraries, ('Crash', 'Same', 'Other'))]
calls = []
def execute(req, **kwargs):
calls.append(req.name)
if req.name == 'Crash':
raise OSError('unexpected evidence disk failure')
return management.ManagementResult(req.operation, req.library, req.name, req.partition,
None, True, 'complete', 'REMOVED', True)
monkeypatch.setattr(management, 'run_management', execute)
results = management.run_management_batch(requests)
assert [r.status for r in results] == ['RECOVERY_REQUIRED', 'SKIPPED', 'REMOVED']
assert not results[0].safe_to_continue
assert 'BATCH_ITEM_EXCEPTION' in results[0].detail
assert calls == ['Crash', 'Other']
@pytest.mark.parametrize('released', [True, False])
def test_icdb_rechecks_failed_owner_before_next_target(qtbot, tmp_path, monkeypatch, released):
from cbb_refresh_verify.ui.icdb_check_task import IcdbCheckTask
library = tmp_path/'lib.lmc'
checks, calls = [], []
failed = VerifyResult('FAIL', stderr='original database load error', safe_to_continue=False,
evidence_path=tmp_path/'result.json', error_category='MENTOR_DATABASE_LOAD_FAILED')
def execute(req):
calls.append(req.block_name)
return failed if req.block_name == 'Bad' else VerifyResult('CHECKED')
def recheck(lib, block, result, **kwargs):
assert lib == library and block == 'Bad' and result is failed
checks.append(block)
return replace(result, safe_to_continue=True) if released and len(checks) > 1 else result
monkeypatch.setattr(operation_lifecycle, 'recheck_failed_release', recheck)
task = IcdbCheckTask([VerifyRequest(library, name, tmp_path) for name in ('Bad', 'Next')],
NativeQueue(), tmp_path/'reports', verifier=execute)
task.start()
qtbot.waitUntil(lambda: not task.active, timeout=5000)
assert checks == ['Bad', 'Bad']
assert calls == (['Bad', 'Next'] if released else ['Bad'])
assert task.results[0].status == 'FAIL' and task.results[0].safe_to_continue is released
if not released:
assert 'Bad' in task.results[1].stderr
assert task.results[1].error_category == 'PREVIOUS_SESSION_UNRELEASED'
def test_icdb_live_observer_finishes_batch_without_cancel_button(qtbot, tmp_path, monkeypatch):
from test_live_observer_queue import observed
from cbb_refresh_verify.ui.icdb_check_task import IcdbCheckTask
library, _ = observed(tmp_path, monkeypatch)
calls = []
task = IcdbCheckTask([VerifyRequest(library, name, tmp_path) for name in ('A', 'B')],
NativeQueue(), tmp_path/'reports',
verifier=lambda req: calls.append(req.block_name) or VerifyResult('CHECKED'))
task.start()
try:
qtbot.waitUntil(lambda: not task.active, timeout=1500)
assert [r.status for r in task.results] == ['SKIPPED', 'SKIPPED']
assert all(r.safe_to_continue and r.error_category == 'NATIVE_SESSION_PENDING' for r in task.results)
assert not calls and not task.stop.is_set()
finally:
task.cancel()
qtbot.waitUntil(lambda: not task.active, timeout=3000)
def test_cancel_has_priority_over_busy_admission(tmp_path, monkeypatch):
from test_live_observer_queue import observed
from cbb_refresh_verify.operation_queue import QueueCancelled
library, _ = observed(tmp_path, monkeypatch)
context = BatchTaskContext(str(library))
context.cancel()
with pytest.raises(QueueCancelled):
NativeQueue().run(lambda: pytest.fail('cancelled action dispatched'),
context=context, skip_unavailable=True)
def test_cancel_during_release_recheck_preserves_original_result(tmp_path):
stop = Event()
stop.set()
failed = VerifyResult('FAIL', safe_to_continue=False, evidence_path=tmp_path/'result.json')
result = operation_lifecycle.recheck_failed_release(tmp_path/'lib.lmc', 'Bad', failed, stop=stop)
assert result is failed
def test_broken_management_progress_sink_does_not_abort_completed_items(tmp_path, monkeypatch):
requests = [management.ManagementRequest('remove', tmp_path/'lib.lmc', name) for name in ('A', 'B')]
def execute(req, **kwargs):
return management.ManagementResult(req.operation, req.library, req.name, req.partition,
None, True, 'complete', 'REMOVED', True)
def disconnected(event):
raise RuntimeError('UI receiver deleted')
monkeypatch.setattr(management, 'run_management', execute)
results = management.run_management_batch(requests, progress=disconnected)
assert [r.status for r in results] == ['REMOVED', 'REMOVED']
def test_verify_ui_busy_admission_reports_each_skip_and_remains_usable(qtbot, tmp_path, monkeypatch):
from test_ui_filters import load_window
window = load_window(qtbot, tmp_path, monkeypatch,
verifier=lambda req: pytest.fail('live observer must prevent native launch'))
library = window.mentor_lmc_path or window.loaded_path
# Preserve the real admission/Qt paths; only emulate the cached native observer.
from types import SimpleNamespace
monkeypatch.setattr(session_record, '_retained_libraries', {'owned':{session_record._library_key(library)}})
monkeypatch.setattr(session_record, '_retained_results', {'owned':{'status':'ACTIVE'}})
monkeypatch.setattr(session_record, '_observers', {'owned':(SimpleNamespace(is_alive=lambda:True),None)})
window._run(['Beta', 'Gamma'])
try:
qtbot.waitUntil(lambda: not window.busy, timeout=2500)
assert window.search_edit.isEnabled()
reports = list((tmp_path/'reports').glob('batch-*.log'))
assert reports
text = reports[0].read_text(encoding='utf-8')
assert text.count('NATIVE_SESSION_PENDING') >= 2
assert 'CANCELLED' not in text and 'PREVIOUS_SESSION_UNRELEASED' not in text
assert window.status_label.text().startswith('已结束:')
finally:
window.stop.set()
window.native_queue.wake()
qtbot.waitUntil(lambda: not window.busy, timeout=3000)
@pytest.mark.parametrize('kind', ['backup', 'management'])
def test_dialog_busy_before_dispatch_never_claims_own_unreleased_session(qtbot, tmp_path, monkeypatch, kind):
from test_live_observer_queue import observed
from cbb_refresh_verify.ui import timed_prompt
from PySide6.QtWidgets import QMessageBox
library, _ = observed(tmp_path, monkeypatch)
monkeypatch.setattr(timed_prompt, 'question', lambda *a, **kw: QMessageBox.Yes)
results = []
if kind == 'backup':
from cbb_refresh_verify.ui.backup_recovery_dialog import BackupRecoveryDialog
dialog = BackupRecoveryDialog(('A',), lambda name: VerifyRequest(library, name, tmp_path),
recoverer=lambda *a, **kw: pytest.fail('blocked recovery dispatched'))
source=tmp_path/'A.prj'; source.touch()
dialog.source_edit.setText(str(source))
dialog.completed.connect(lambda name,result: results.append(result))
button=dialog.restore_button
else:
from cbb_refresh_verify.ui.management_dialog import ManagementDialog
dialog = ManagementDialog([management.ManagementRequest('remove',library,'A')],
runner=lambda *a,**kw: pytest.fail('blocked management dispatched'))
dialog.completed.connect(results.extend)
button=dialog.execute_button
qtbot.addWidget(dialog)
dialog.native_queue=NativeQueue()
button.click()
qtbot.waitUntil(lambda: not dialog.busy, timeout=2500)
assert len(results)==1 and results[0].status=='SKIPPED' and results[0].safe_to_continue
def test_pre_admission_error_does_not_retain_a_path_lease(qtbot, tmp_path, monkeypatch):
from test_ui_filters import load_window
from cbb_refresh_verify.operation_queue import QueueUnavailable
window=load_window(qtbot,tmp_path,monkeypatch)
from types import SimpleNamespace
window.library_lease=SimpleNamespace()
retained=[]
monkeypatch.setattr(window,'_retain_path_lease',lambda *a,**kw: retained.append(a))
window._failed(QueueUnavailable('lib.lmc'))
window.library_lease=None
assert not retained
+20
View File
@@ -122,6 +122,26 @@ def test_persistent_loading_progress_keeps_deadline_and_never_closes(diagnostic,
assert Session.instances[-1].posted == []
def test_cancel_from_window_scan_wins_expired_open_deadline(diagnostic, job, monkeypatch):
job['diagnostic_log_baseline'] = diagnostic.snapshot_diagnostic_logs(job)
write_logs(job)
signal = Path(job['root']).parent/'cancel-after-scan'
job['cancel_signal'] = str(signal)
clock = [0.0]
monkeypatch.setattr(diagnostic.time, 'monotonic', lambda: clock[0])
monkeypatch.setattr(diagnostic, '_NativeSession', Session)
target = frame(job)
target['children'].append({'hwnd':13,'class':'msctls_progress32','text':'','visible':True})
def windows(pid):
signal.touch()
clock[0] = 10.0
return [target]
monkeypatch.setattr(diagnostic, '_windows', windows)
with pytest.raises(RuntimeError, match='VERIFY_CANCELLED'):
diagnostic.check_target_window(job, 42, emit=lambda **event: None, error_reader=lambda: None)
assert Session.instances[-1].posted == []
def test_diagnostic_waits_for_startup_forward_no_before_close(diagnostic, job, monkeypatch):
job['diagnostic_log_baseline'] = diagnostic.snapshot_diagnostic_logs(job)
write_logs(job); job['timeout'] = 1
+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()
+219
View File
@@ -0,0 +1,219 @@
"""Finish a proved owned idle client, then prove resources independently."""
from contextlib import nullcontext
from dataclasses import replace
import json
from pathlib import Path
from threading import Event
import pytest
from cbb_refresh_verify import residual_sessions as residual, session_record as sessions
from cbb_refresh_verify import operation_lifecycle as lifecycle
from cbb_refresh_verify.verify_runner import VerifyResult
def owned_fixture(tmp_path, monkeypatch, kind='startup'):
import win32con, win32event
library=tmp_path/'library/lib.lmc';library.parent.mkdir();library.touch()
root=tmp_path/'evidence';root.mkdir()
operation='catalog' if kind=='catalog' else 'verify'
desktop=('CbbManagement_' if kind=='catalog' else 'CbbVerify_')+'owned'
job=dict(operation_id='owned',operation=operation,library=str(library),lmc_file=str(library),
block='Bad',root=str(root),desktop=desktop,interactive_input=False,
project=str(library.parent/'ReusableBlocksLP/Bad/Work/Bad.prj'),
pcb=str(library.parent/'ReusableBlocksLP/Bad/Work/PCB/Bad.pcb'),
session_record_path=str(root/'session.json'))
if kind=='catalog':job['worker_role']='catalog_readonly'
worker=dict(role='worker',pid=11,created_handle='worker-created',image='C:/Python/python.exe',
owner_sid='owner',session_id=1)
native=dict(role='native',pid=12,created_handle='native-created',
image='D:/Mentor/LibraryManager.exe' if kind=='catalog' else 'D:/Mentor/ExpeditionPCB.exe',
owner_sid='owner',session_id=1)
sessions.write_session_record(root/'session.json',dict(operation_id='owned',operation=operation,
library=str(library),block='Bad',desktop=desktop,processes=[worker]))
sessions.write_session_record(root/'worker-state.json',dict(operation_id='owned',phase='UNCONFIRMED',processes=[native]))
result=dict(status='FAIL',safe_to_continue=False,error_stage='PCB_STARTING',
error_category='MENTOR_DATABASE_LOAD_FAILED',block_name='Bad',evidence_path=str(root/'result.json'))
if kind=='saved':
result.update(error_stage='library_flag',error_category='MENTOR_VERIFY_NOT_COMMITTED',
write_outcome=dict(save_state='COMMITTED',close_state='CLOSED',helper_state='EXITED',interrupted=False))
if kind=='catalog':result=dict(success=False,safe_to_continue=False,detail='catalog close failed')
(root/'request.json').write_text(json.dumps(job))
(root/'result.json').write_text(json.dumps(result))
windows=[dict(hwnd=100,**{'class':'Afx:main'},title='Library Manager' if kind=='catalog' else 'Expedition PCB',
desktop=desktop,enabled=True,documents=[],children=[])]
state=dict(worker_alive=False,native_alive=True,identity_changed=False,posts=[])
monkeypatch.setattr(residual,'_process_handle',lambda pid,**kw:nullcontext(pid))
monkeypatch.setattr(residual,'_handle_identity',lambda handle:
{k:(('replacement' if state['identity_changed'] else v) if k=='created_handle' else v)
for k,v in (worker if handle==11 else native).items() if k in ('created_handle','image')})
monkeypatch.setattr(residual,'_force_ownership',lambda *a:dict(force_user_confirmed=True,owner_sid='owner',session_id=1))
monkeypatch.setattr(residual,'_process_windows',lambda *a,**kw:{12:windows})
monkeypatch.setattr(sessions,'active_write_records',lambda library:[])
wait=win32event.WaitForSingleObject
monkeypatch.setattr(win32event,'WaitForSingleObject',lambda handle,ms:
(win32con.WAIT_TIMEOUT if state['worker_alive' if handle==11 else 'native_alive'] else win32con.WAIT_OBJECT_0)
if handle in (11,12) else wait(handle,ms))
def post(window, hwnd, pid, message):
record=sessions.read_session_record(root/'session.json',evidence_root=root)
assert record.get('owned_idle_cleanup'), 'intent must be durable before native action'
state['posts'].append((hwnd,pid,message))
state['native_alive']=False
monkeypatch.setattr(residual,'_post_window_message',post)
return root,job,result,windows,state
@pytest.mark.parametrize('kind',['startup','saved','catalog'])
def test_owned_idle_client_is_closed_once_without_changing_business_result(tmp_path,monkeypatch,kind):
root,job,result,windows,state=owned_fixture(tmp_path,monkeypatch,kind)
before=(root/'result.json').read_bytes()
assert residual.finish_owned_idle_session(root/'session.json')
assert state['posts']==[(100,12,16)] and not state['native_alive']
residual.finish_owned_idle_session(root/'session.json')
assert state['posts']==[(100,12,16)]
assert (root/'result.json').read_bytes()==before
@pytest.mark.parametrize('obstacle',['worker_alive','identity_changed','documents','hidden_document','unknown',
'progress','desktop','request_identity','save_unknown','other_write','stopped','claim_io','window_race'])
def test_unproved_or_writing_client_is_never_automatically_closed(tmp_path,monkeypatch,obstacle):
root,job,result,windows,state=owned_fixture(tmp_path,monkeypatch)
stop=Event()
if obstacle in ('worker_alive','identity_changed'):state[obstacle]=True
if obstacle=='documents':windows[0]['documents']=[55]
if obstacle=='hidden_document':windows[0]['children'].append(dict(hwnd=55,**{'class':'Afx:document'},visible=False))
if obstacle=='unknown':windows.append(dict(hwnd=200,**{'class':'#32770'},title='Unknown',enabled=True,desktop=job['desktop'],documents=[],children=[]))
if obstacle=='progress':windows[0]['children'].append(dict(hwnd=60,**{'class':'msctls_progress32'}))
if obstacle=='desktop':windows[0]['desktop']='Default'
if obstacle=='request_identity':
job['operation_id']='other';(root/'request.json').write_text(json.dumps(job))
if obstacle=='save_unknown':(root/'save.log').write_text('SAVE_START\n')
if obstacle=='other_write':monkeypatch.setattr(sessions,'active_write_records',lambda _: [dict(operation_id='other')])
if obstacle=='stopped':stop.set()
if obstacle=='claim_io':
monkeypatch.setattr(sessions,'write_session_record',lambda *a,**kw: (_ for _ in ()).throw(OSError('journal unavailable')))
if obstacle=='window_race':
original=sessions.write_session_record
def write(path,value):
original(path,value)
if value.get('owned_idle_cleanup'):windows[0]['documents']=[55]
monkeypatch.setattr(sessions,'write_session_record',write)
residual.finish_owned_idle_session(root/'session.json',stop=stop)
assert not state['posts'] and state['native_alive']
def test_late_release_actively_finishes_owned_idle_client_then_proves_shared_files(tmp_path,monkeypatch):
root,job,result,windows,state=owned_fixture(tmp_path,monkeypatch)
monkeypatch.setattr(sessions,'inspect_session_record',lambda *a,**kw:
dict(status='ACTIVE' if state['native_alive'] else 'UNCONFIRMED'))
def release(library,evidence,**kw):
assert not state['native_alive'], 'resource proof must follow native cleanup'
return dict(status='RELEASE_CONFIRMED',lease_state='RELEASED',library=library,
blocked_resources=[],resource_scope=dict(scope_state='OBSERVED'))
monkeypatch.setattr('cbb_refresh_verify.library_lock.release_retained_library',release)
failed=VerifyResult('FAIL',stderr='database load failed',safe_to_continue=False,
evidence_path=root/'result.json')
updated=lifecycle.recheck_failed_release(job['library'],'Bad',failed)
assert updated.status=='FAIL' and updated.safe_to_continue
assert state['posts']==[(100,12,16)]
def test_closed_client_does_not_imply_shared_database_released(tmp_path,monkeypatch):
root,job,result,windows,state=owned_fixture(tmp_path,monkeypatch)
monkeypatch.setattr(sessions,'inspect_session_record',lambda *a,**kw:
dict(status='ACTIVE' if state['native_alive'] else 'UNCONFIRMED'))
from cbb_refresh_verify.library_lock import LibraryBusy
def release(*a,**kw):raise LibraryBusy('shared database still held by another client')
monkeypatch.setattr('cbb_refresh_verify.library_lock.release_retained_library',release)
failed=VerifyResult('FAIL',safe_to_continue=False,evidence_path=root/'result.json')
updated=lifecycle.recheck_failed_release(job['library'],'Bad',failed)
assert not updated.safe_to_continue and updated.status=='FAIL'
assert state['posts']==[(100,12,16)]
attempt=json.loads((root/'late-release-attempt.json').read_text())
assert 'shared database' in attempt['detail']
def test_retained_verify_lease_does_not_expand_one_target_to_every_cbb(tmp_path,monkeypatch):
from cbb_refresh_verify import verify_runner as runner, library_lock as locks
library=tmp_path/'library/lib.lmc';library.parent.mkdir();library.touch()
other=library.parent/'ReusableBlocksLP/Other/Work/database/cdbsvr/sAddress.adr'
other.parent.mkdir(parents=True);other.write_text('unrelated occupied engineering database')
evidence=tmp_path/'evidence/result.json';evidence.parent.mkdir()
evidence.write_text('{}')
monkeypatch.setattr(runner,'_run_verify_serialized',lambda *a,**kw:
VerifyResult('FAIL',safe_to_continue=False,evidence_path=evidence))
monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners',lambda *_:[])
result=runner._run_verify_task(runner.VerifyRequest(library,'Bad',evidence.parent))
assert not result.safe_to_continue
try:
proof=locks.release_retained_library(library,tmp_path/'release',block_name='Bad')
assert proof['proof_scope']=='BLOCK' and proof['proof_block_name']=='Bad'
assert other.read_text()=='unrelated occupied engineering database'
finally:
with locks._guard:
owner=locks._owners.pop(locks.LibraryLock(library).key,None)
if owner:owner['handle'].Close()
@pytest.mark.parametrize('read_only',[False,True])
def test_background_observer_finishes_owned_idle_client_but_cold_observation_stays_read_only(tmp_path,monkeypatch,read_only):
root,job,result,windows,state=owned_fixture(tmp_path,monkeypatch)
def reconcile(*a,**kw):
return dict(status='ACTIVE' if state['native_alive'] else 'RELEASED',operation_id='owned',
library=job['library'],block='Bad',release_proof=None)
monkeypatch.setattr(sessions,'_reconcile',reconcile)
stop=Event()
outcome=sessions.observe_retained_session(root/'session.json',evidence_root=root,
observe_only=read_only,stop=stop,progress=lambda value:stop.set())
assert outcome['status']==('ACTIVE' if read_only else 'RELEASED')
assert state['posts']==([] if read_only else [(100,12,16)])
def test_real_shared_database_handle_still_prevents_release_after_own_client_exits(tmp_path,monkeypatch):
import win32con,win32file
root,job,result,windows,state=owned_fixture(tmp_path,monkeypatch)
library=Path(job['library'])
shared=library.parent/'SymbolLibs/__ReusableBlocksSymb/icdb.dat'
shared.parent.mkdir(parents=True);shared.write_bytes(b'actual shared database fixture')
monkeypatch.setattr(sessions,'inspect_session_record',lambda *a,**kw:
dict(status='ACTIVE' if state['native_alive'] else 'UNCONFIRMED'))
monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners',lambda *_:[])
held=win32file.CreateFile(str(shared),win32con.GENERIC_READ,0,None,win32con.OPEN_EXISTING,0,None)
try:
failed=VerifyResult('FAIL',safe_to_continue=False,evidence_path=root/'result.json')
updated=lifecycle.recheck_failed_release(library,'Bad',failed)
assert state['posts']==[(100,12,16)] and not updated.safe_to_continue
attempt=json.loads((root/'late-release-attempt.json').read_text())
assert 'icdb.dat' in attempt['detail']
assert attempt['status']=='IN_USE' and attempt['blocked_resources']==[str(shared)]
finally:
held.Close()
@pytest.mark.parametrize('malformed',['request','result','write_outcome'])
def test_malformed_record_never_authorizes_or_crashes_cleanup(tmp_path,monkeypatch,malformed):
root,job,result,windows,state=owned_fixture(tmp_path,monkeypatch,'saved')
if malformed=='write_outcome':
result['write_outcome']=['not facts'];(root/'result.json').write_text(json.dumps(result))
else:
(root/(malformed+'.json')).write_text('[]')
assert not residual.finish_owned_idle_session(root/'session.json')
assert not state['posts']
@pytest.mark.parametrize('changed',['result_block','result_path','state_after_claim'])
def test_wrong_result_or_changed_state_cannot_authorize_normal_close(tmp_path,monkeypatch,changed):
root,job,result,windows,state=owned_fixture(tmp_path,monkeypatch,'saved')
if changed=='result_block':result['block_name']='Other'
if changed=='result_path':result['evidence_path']=str(tmp_path/'other/result.json')
(root/'result.json').write_text(json.dumps(result))
if changed=='state_after_claim':
write=sessions.write_session_record
def changed_state(path,record):
write(path,record)
if record.get('owned_idle_cleanup'):
previous=sessions.read_session_record(root/'worker-state.json',evidence_root=root)
write(root/'worker-state.json',{**previous,'phase':'NATIVE_CALL'})
monkeypatch.setattr(sessions,'write_session_record',changed_state)
assert not residual.finish_owned_idle_session(root/'session.json')
assert not state['posts']
+9
View File
@@ -1,4 +1,6 @@
from threading import Event
from types import SimpleNamespace
import time
import pytest
@@ -15,9 +17,15 @@ def test_real_recovery_handoff_preserves_A_lease_without_blocking_B_or_late_inst
request,original,source=recovery_files
entered,release,done=Event(),Event(),Event();calls=[]
context=BatchTaskContext(str(request.lmc_file),native_policy='external')
from cbb_refresh_verify import operation_queue
# Expire inactivity at the chosen stall, not during variable filesystem setup.
clock=[time.monotonic()]
monkeypatch.setattr(operation_queue,'time',SimpleNamespace(
monotonic=lambda:clock[0] if clock[0] is not None else time.monotonic()))
def hold():
entered.set()
if cancel:context.cancel()
clock[0]=time.monotonic()+1
assert release.wait(5)
def idle(*args):
if boundary=='idle' and not entered.is_set():hold()
@@ -43,6 +51,7 @@ def test_real_recovery_handoff_preserves_A_lease_without_blocking_B_or_late_inst
try:
with pytest.raises(TaskHandoff):context.run(action,timeout_seconds=.3)
assert entered.is_set()
clock[0]=None
with pytest.raises(LibraryBusy):
with LibraryLock(request.lmc_file):pytest.fail('A lease lost during stalled metadata')
def B():
+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()