bugx-cli 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/README.md +193 -185
  2. package/core/README.md +2 -2
  3. package/core/agent/README.md +2 -1
  4. package/core/agent/agent_artifacts.py +8 -6
  5. package/core/agent/agent_eval.py +136 -54
  6. package/core/agent/agent_execution.py +218 -52
  7. package/core/agent/agent_orchestrator.py +14 -8
  8. package/core/agent/agent_targets.py +8 -2
  9. package/core/agent/feature_baseline.py +150 -0
  10. package/core/assets/README.md +3 -2
  11. package/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
  12. package/core/assets/axe-core/LICENSE.txt +362 -0
  13. package/core/assets/axe-core/UPSTREAM.md +10 -0
  14. package/core/assets/axe-core/axe.min.js +12 -0
  15. package/core/assets/bugx-hero-en.svg +74 -0
  16. package/core/assets/bugx-hero-zh.svg +74 -0
  17. package/core/assets/bugx-social-preview.svg +71 -0
  18. package/core/assets/bugx-wechat-group.png +0 -0
  19. package/core/assets/codex.png +0 -0
  20. package/core/assets/dsh.png +0 -0
  21. package/core/assets/webui-chatgpt.jpg +0 -0
  22. package/core/assets/webui-session.jpg +0 -0
  23. package/core/assets/webui-skills.jpg +0 -0
  24. package/core/assets/webui-studio.jpg +0 -0
  25. package/core/assets/webui-zcode.jpg +0 -0
  26. package/core/assets/zcode.png +0 -0
  27. package/core/audit_packs/README.md +2 -0
  28. package/core/audit_packs/pitfalls/auth_crypto.json +64 -0
  29. package/core/audit_packs/pitfalls/file_ssrf_cmd.json +64 -0
  30. package/core/audit_packs/pitfalls/go_backend.json +66 -0
  31. package/core/audit_packs/pitfalls/java_spring.json +64 -0
  32. package/core/audit_packs/pitfalls/js_ts_web.json +67 -0
  33. package/core/audit_packs/pitfalls/python_web.json +82 -0
  34. package/core/autonomous_cve/SPEC.md +1 -1
  35. package/core/autonomous_cve/attack_graph_store.py +152 -106
  36. package/core/autonomous_cve/behavior_graph.py +8 -2
  37. package/core/autonomous_cve/verifier.py +4 -1
  38. package/core/bugx.md +1 -1
  39. package/core/bugx_paths.py +43 -8
  40. package/core/cli-help.txt +66 -0
  41. package/core/cloud_sync/SPEC.md +1 -1
  42. package/core/cloud_sync/cloud_client.py +81 -11
  43. package/core/cloud_sync/cloud_onboard.py +42 -1
  44. package/core/cloud_sync/consent.py +33 -3
  45. package/core/cloud_sync/flywheel_client.py +186 -15
  46. package/core/cloud_sync/network_transport.py +24 -3
  47. package/core/cloud_sync/sensitive_filter.py +2 -2
  48. package/core/cloud_sync/sync_push.py +12 -10
  49. package/core/contracts/AGENT_GUIDE.md +6 -9
  50. package/core/contracts/README.md +2 -2
  51. package/core/contracts/bugx-runtime-contract.md +1 -1
  52. package/core/contracts/bugx-worker.md +1 -1
  53. package/core/contracts/engine_gap_contracts.py +86 -3
  54. package/core/coverage/coverage_discovery.py +599 -29
  55. package/core/coverage/coverage_evidence.py +47 -0
  56. package/core/coverage/coverage_forensics.py +9 -0
  57. package/core/coverage/coverage_validate.py +6 -1
  58. package/core/dev_harness/SPEC.md +1 -1
  59. package/core/engine-integrity.json +670 -442
  60. package/core/fuzzing/concurrency_fuzzer.py +53 -0
  61. package/core/fuzzing/differential_oracle.py +562 -27
  62. package/core/fuzzing/fuzz_input.py +109 -6
  63. package/core/fuzzing/stateful_fuzzer.py +72 -0
  64. package/core/governance/secret_redactor.py +22 -10
  65. package/core/host_acp/SPEC.md +1 -1
  66. package/core/host_acp/__init__.py +4 -4
  67. package/core/host_acp/claude.py +59 -1
  68. package/core/host_acp/cline.py +64 -1
  69. package/core/host_acp/codex.py +56 -1
  70. package/core/host_acp/dsh.py +59 -1
  71. package/core/host_acp/opencode.py +56 -1
  72. package/core/host_acp/pi.py +59 -1
  73. package/core/host_acp/zcode.py +59 -1
  74. package/core/host_runtime/SPEC.md +1 -1
  75. package/core/host_runtime/adapters.py +1 -1
  76. package/core/host_runtime/cline.py +13 -0
  77. package/core/host_runtime/host_evaluators.py +44 -4
  78. package/core/host_runtime/host_probe.py +1 -1
  79. package/core/host_runtime/host_provider_arbitrator.py +116 -62
  80. package/core/host_runtime/host_registry.py +15 -8
  81. package/core/host_runtime/mcp_registry_gate.py +12 -1
  82. package/core/host_runtime/pi.py +102 -0
  83. package/core/host_runtime/provider_facts.py +66 -0
  84. package/core/hosts/SPEC.md +1 -1
  85. package/core/hosts/__init__.py +6 -2
  86. package/core/hosts/_dsh_usage.py +1 -1
  87. package/core/hosts/base.py +32 -4
  88. package/core/hosts/claude.py +55 -0
  89. package/core/hosts/cline.py +6 -2
  90. package/core/hosts/codex.py +58 -0
  91. package/core/hosts/dsh.py +9 -1
  92. package/core/hosts/opencode.py +6 -6
  93. package/core/hosts/pi.py +159 -2
  94. package/core/infra/README.md +4 -2
  95. package/core/infra/__init__.py +2 -0
  96. package/core/infra/build_info.py +22 -3
  97. package/core/infra/client_metadata.py +1 -1
  98. package/core/infra/json_utils.py +22 -0
  99. package/core/launch_phases/README.md +6 -3
  100. package/core/launch_phases/SPEC.md +1 -1
  101. package/core/launch_phases/common.py +21 -2
  102. package/core/launch_phases/finding_confirm_phase.py +170 -5
  103. package/core/launch_phases/finding_settlement.py +188 -1
  104. package/core/launch_phases/judge_phase.py +69 -12
  105. package/core/launch_phases/orchestrator_controls.py +11 -7
  106. package/core/launch_phases/post_coverage_sync.py +9 -2
  107. package/core/launch_phases/post_phase.py +144 -8
  108. package/core/launch_phases/post_receipt.py +12 -1
  109. package/core/launch_phases/pre_phase.py +3 -3
  110. package/core/launch_phases/pre_recon_scout.py +66 -36
  111. package/core/launch_phases/pre_state_builder.py +23 -176
  112. package/core/launch_phases/report_sharing.py +3 -7
  113. package/core/launch_phases/round_orchestrator.py +129 -58
  114. package/core/launch_phases/semantic_recon.py +545 -0
  115. package/core/launch_phases/session_runtime.py +56 -9
  116. package/core/launch_phases/startup_gates.py +36 -8
  117. package/core/launch_phases/startup_interaction.py +68 -12
  118. package/core/launch_phases/startup_version_gate.py +13 -3
  119. package/core/launch_phases/supervisor_bridge.py +46 -17
  120. package/core/launch_phases/supervisor_coverage.py +8 -2
  121. package/core/launch_phases/supervisor_degraded.py +1 -9
  122. package/core/launch_phases/verify_loop.py +767 -0
  123. package/core/launch_phases/worker_barriers.py +15 -5
  124. package/core/launch_phases/worker_orchestrator.py +105 -25
  125. package/core/launch_phases/worker_prior.py +115 -0
  126. package/core/ledger/README.md +2 -1
  127. package/core/ledger/SPEC.md +1 -1
  128. package/core/ledger/_facade.py +2 -1
  129. package/core/ledger/archive_ops.py +60 -2
  130. package/core/ledger/cli.py +6 -1
  131. package/core/ledger/export_ops.py +6 -1
  132. package/core/ledger/finding_confirmation.py +48 -6
  133. package/core/ledger/finding_lifecycle.py +428 -5
  134. package/core/ledger/finding_verification.py +555 -10
  135. package/core/ledger/fp_ledger.py +255 -0
  136. package/core/ledger/incidents.py +10 -4
  137. package/core/ledger/patterns.py +10 -7
  138. package/core/ledger/receipt_contract.py +17 -1
  139. package/core/ledger/sync_ops.py +21 -16
  140. package/core/ledger/tool_experience.py +2 -1
  141. package/core/ledger/verify_life.py +88 -17
  142. package/core/locales/en-US.json +2 -2
  143. package/core/locales/zh-CN.json +2 -2
  144. package/core/mcp_handlers/SPEC.md +1 -1
  145. package/core/mcp_handlers/base.py +23 -3
  146. package/core/mcp_handlers/channel_lifecycle.py +85 -30
  147. package/core/mcp_handlers/retrieval_handlers.py +11 -1
  148. package/core/mcp_handlers/rpc_server.py +6 -1
  149. package/core/mcp_handlers/supervisor_handlers.py +32 -6
  150. package/core/mcp_handlers/tool_table.py +15 -0
  151. package/core/mcp_runtime_support/environment.py +0 -38
  152. package/core/mcp_runtime_support/verifier.py +0 -52
  153. package/core/metadata.txt +2 -3
  154. package/core/planning/README.md +2 -1
  155. package/core/planning/domain_router.py +4 -2
  156. package/core/planning/dynamic_flow_analyzer.py +219 -14
  157. package/core/planning/judge_pipeline.py +87 -4
  158. package/core/planning/prompt_harness.py +57 -15
  159. package/core/planning/prompt_policy_engine.py +386 -0
  160. package/core/planning/spec_harvester.py +4 -4
  161. package/core/probes/INTERFACE.md +11 -1
  162. package/core/probes/SPEC.md +11 -1
  163. package/core/probes/__init__.py +46 -40
  164. package/core/probes/android_probe.py +177 -9
  165. package/core/probes/codebase_memory_probe.py +57 -0
  166. package/core/probes/desktop_probe.py +104 -0
  167. package/core/probes/differential_probe.py +99 -21
  168. package/core/probes/efficiency_probe.py +64 -0
  169. package/core/probes/ios_binary_probe.py +105 -1
  170. package/core/probes/memory_probe.py +66 -0
  171. package/core/probes/miniprogram_probe.py +75 -13
  172. package/core/probes/mobile_probe.py +215 -30
  173. package/core/probes/native_probe.py +88 -0
  174. package/core/probes/openwiki_probe.py +70 -0
  175. package/core/probes/pattern_probe.py +106 -0
  176. package/core/probes/platform_probe.py +81 -0
  177. package/core/probes/probe_registry.py +108 -7
  178. package/core/probes/sast_fixture_corpus.py +340 -0
  179. package/core/probes/sast_probe.py +553 -52
  180. package/core/probes/sast_rules.py +668 -28
  181. package/core/probes/sca_scanner.py +48 -0
  182. package/core/probes/ui_accessibility.py +149 -0
  183. package/core/probes/ui_audit.py +513 -0
  184. package/core/probes/ui_contract.py +273 -0
  185. package/core/probes/ui_evidence.py +212 -0
  186. package/core/probes/ui_measurements.py +314 -0
  187. package/core/probes/ui_repair.py +250 -0
  188. package/core/probes/ui_review.py +133 -0
  189. package/core/probes/ui_storybook.py +107 -0
  190. package/core/probes/ui_tokens.py +185 -0
  191. package/core/probes/ui_visual_diff.py +131 -0
  192. package/core/probes/web_probe.py +373 -18
  193. package/core/project_profiler/SPEC.md +1 -1
  194. package/core/project_profiler/arbitrator.py +6 -1
  195. package/core/project_profiler/detector.py +8 -1
  196. package/core/project_profiler/strategy.py +51 -15
  197. package/core/prompts/README.md +4 -2
  198. package/core/prompts/command_routing_en.md +2 -2
  199. package/core/prompts/command_routing_zh.md +2 -2
  200. package/core/prompts/policies/prompt_policies.json +101 -0
  201. package/core/prompts/stages/stage_repair.md +1 -1
  202. package/core/prompts/stages/stage_verify.defensive.md +42 -0
  203. package/core/prompts/stages/stage_verify.md +44 -0
  204. package/core/repair/README.md +1 -1
  205. package/core/repair/l7_repair_loop.py +1 -4
  206. package/core/repair/rsi_fixer.py +4 -4
  207. package/core/repair/rsi_loop.py +1 -3
  208. package/core/repair/rsi_repair.py +7 -7
  209. package/core/repair/rsi_scope.py +27 -8
  210. package/core/report_engine/SPEC.md +1 -1
  211. package/core/report_engine/attestation.py +8 -4
  212. package/core/report_engine/finding_report.py +2 -1
  213. package/core/report_engine/models.py +7 -9
  214. package/core/report_engine/report_share.py +0 -8
  215. package/core/report_engine/sast_bridge.py +2 -2
  216. package/core/report_engine/server.py +18 -8
  217. package/core/report_engine/web-conformance.md +123 -18
  218. package/core/report_engine/web_conformance.py +21 -52
  219. package/core/retrieval/README.md +2 -1
  220. package/core/retrieval/SPEC.md +1 -1
  221. package/core/retrieval/code_analyzer.py +50 -14
  222. package/core/retrieval/context_assembler.py +7 -1
  223. package/core/retrieval/knowledge_sync.py +108 -14
  224. package/core/retrieval/pitfall_packs.py +277 -0
  225. package/core/retrieval/symbol_index.py +25 -6
  226. package/core/retrieval/universal_code_matcher.py +234 -49
  227. package/core/runtime/README.md +1 -1
  228. package/core/runtime/bugx_logging.py +78 -7
  229. package/core/runtime/fixture_solidify.py +5 -10
  230. package/core/runtime/global_telemetry.py +20 -0
  231. package/core/runtime/incident_eval.py +1 -1
  232. package/core/runtime/model_runner.py +4 -41
  233. package/core/runtime/platform_adapter.py +2 -2
  234. package/core/runtime/prep_validate.py +4 -2
  235. package/core/runtime/project_settings.py +2 -1
  236. package/core/runtime/scenario_eval.py +50 -8
  237. package/core/skills/bugx_docs_mcp_server.py +3 -1
  238. package/core/skills/bugx_mcp_server.py +29 -2
  239. package/core/skills/tools_kb.py +1 -1
  240. package/core/supervisor/README.md +1 -1
  241. package/core/supervisor/SPEC.md +1 -1
  242. package/core/supervisor/budget_governor.py +503 -9
  243. package/core/supervisor/checkpoint_pipeline.py +248 -6
  244. package/core/supervisor/checkpoint_sync.py +13 -0
  245. package/core/supervisor/claim_events.py +1 -1
  246. package/core/supervisor/finding_workflow.py +22 -5
  247. package/core/supervisor/lease_manager.py +1 -1
  248. package/core/supervisor/lifecycle_blocks.py +6 -1
  249. package/core/supervisor/rejection_remedies.py +52 -5
  250. package/core/supervisor/serial_authorization.py +48 -4
  251. package/core/supervisor/task_scheduler.py +2 -2
  252. package/core/supervisor/worker_checkpoint.py +8 -1
  253. package/core/supervisor/worker_runtime.py +8 -2
  254. package/core/supervisor_types/worker_claim.py +9 -0
  255. package/core/webui/README.md +1 -1
  256. package/core/webui/SPEC.md +2 -1
  257. package/core/webui/adapters/claude.py +5 -1
  258. package/core/webui/adapters/cline.py +10 -2
  259. package/core/webui/adapters/codex.py +5 -1
  260. package/core/webui/adapters/dsh.py +5 -1
  261. package/core/webui/docs_session_service.py +2 -2
  262. package/core/webui/mcp_inspector.py +11 -7
  263. package/core/webui/static/00-base.css +1060 -0
  264. package/core/webui/static/01-monitoring.css +802 -0
  265. package/core/webui/static/02-header-actions.css +321 -0
  266. package/core/webui/static/03-trigger-popover.css +697 -0
  267. package/core/webui/static/04-composer.css +628 -0
  268. package/core/webui/static/05-skills-center.css +878 -0
  269. package/core/webui/static/06-mcp-center.css +623 -0
  270. package/core/webui/static/07-skill-detail.css +265 -0
  271. package/core/webui/static/08-files-management.css +167 -0
  272. package/core/webui/static/09-files-center.css +386 -0
  273. package/core/webui/static/10-icons.css +105 -0
  274. package/core/webui/static/11-project-options.css +185 -0
  275. package/core/webui/static/12-profile-tab.css +383 -0
  276. package/core/webui/static/design-tokens.css +113 -0
  277. package/core/webui/static/index.html +14 -1
  278. package/core/webui/workspace_service.py +1 -1
  279. package/docs/07_distribution/01_README_NPM.md +193 -185
  280. package/ecosystem/integrations/README.md +1 -1
  281. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  282. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
  283. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  284. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
  285. package/ecosystem/integrations/opencode/mcp-lock.json +14 -6
  286. package/ecosystem/integrations/opencode/opencode.json +23 -12
  287. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  288. package/ecosystem/integrations/qoder/connector-meta.json +1 -1
  289. package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
  290. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +1 -1
  291. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
  292. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
  293. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
  294. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +2 -2
  295. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
  296. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
  297. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
  298. package/interfaces/bin/bugx.js +37 -0
  299. package/interfaces/cli/bugx_cli/__init__.py +4 -2
  300. package/interfaces/cli/bugx_cli/cli.py +172 -69
  301. package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
  302. package/interfaces/cli/bugx_cli/commands/agent.py +461 -134
  303. package/interfaces/cli/bugx_cli/commands/audit.py +10 -9
  304. package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
  305. package/interfaces/cli/bugx_cli/commands/cloud.py +31 -22
  306. package/interfaces/cli/bugx_cli/commands/doctor.py +449 -204
  307. package/interfaces/cli/bugx_cli/commands/interaction.py +5 -1
  308. package/interfaces/cli/bugx_cli/commands/knowledge.py +5 -4
  309. package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
  310. package/interfaces/cli/bugx_cli/commands/plugin.py +58 -23
  311. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +7 -7
  312. package/interfaces/cli/bugx_cli/commands/plugin_funide.py +2 -1
  313. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +1 -1
  314. package/interfaces/cli/bugx_cli/commands/project.py +6 -13
  315. package/interfaces/cli/bugx_cli/commands/report.py +2 -6
  316. package/interfaces/cli/bugx_cli/commands/system.py +524 -169
  317. package/interfaces/cli/bugx_cli/common.py +21 -15
  318. package/interfaces/cli/bugx_cli/host_adapters.py +29 -54
  319. package/interfaces/cli/bugx_cli/hosts/registry.py +8 -6
  320. package/interfaces/cli/bugx_cli/infra/ai_advisor.py +157 -27
  321. package/interfaces/cli/bugx_cli/infra/engine_installer.py +35 -16
  322. package/interfaces/cli/bugx_cli/infra/host_sync.py +11 -8
  323. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +76 -5
  324. package/interfaces/cli/bugx_cli/infra/security.py +13 -6
  325. package/package.json +30 -15
  326. package/pyproject.toml +60 -9
  327. package/scripts/ensure-python.mjs +7 -7
  328. package/scripts/sync-version.mjs +10 -21
  329. package/scripts/test-npm-wrapper.mjs +1 -1
  330. package/core/assets/bugx-hero-cn.png +0 -0
  331. package/core/assets/bugx-hero-en.png +0 -0
  332. package/core/webui/static/project-settings.css +0 -6458
  333. package/docs/07_distribution/README.md +0 -16
  334. package/docs/README.md +0 -121
  335. package/interfaces/README.md +0 -143
  336. package/interfaces/bin/README.md +0 -35
  337. package/interfaces/cli/README.md +0 -90
  338. package/scripts/README.md +0 -118
@@ -28,25 +28,14 @@
28
28
  它检查 `lang`、图片 `alt`、表单控件和交互元素的可访问名称、重复 ID、ARIA ID 引用。
29
29
  静态规则失败要形成 Finding;扫描不完整不能报告为通过。
30
30
 
31
- 2. 再使用 Playwright 或目标项目的浏览器自动化执行动态检查:键盘/焦点、Accessibility Tree、
32
- 最终样式对比度、200%/400% 重排和 loading/error/empty/disabled 状态。截图、DOM/可访问性树、
33
- 网络和控制台记录必须绑定页面、视口、浏览器版本和复现步骤。
34
-
35
- 3. 如需将外部动态证据纳入机器门禁,使用最小 JSON:
36
-
37
- ```json
38
- {
39
- "checks": {
40
- "keyboard-focus": {"status": "PASS", "evidence": "playwright:..."},
41
- "aria-tree": {"status": "PASS", "evidence": "playwright:..."},
42
- "contrast": {"status": "PASS", "evidence": "playwright:..."},
43
- "reflow-zoom": {"status": "PASS", "evidence": "playwright:..."},
44
- "state-feedback": {"status": "PASS", "evidence": "playwright:..."}
45
- }
46
- }
47
- ```
31
+ 2. 使用 `bugx probe ui --root . --url http://127.0.0.1:8080 --journeys`。探针在浏览器中
32
+ 采集截图、DOM/ARIA、缩放、键盘步骤和业务状态,运行随包发布的 axe-core。收据记录
33
+ 规则 ID、影响、元素定位和待确认项。axe-core 的 `incomplete` 对应 `UNVERIFIED`。
48
34
 
49
- 然后执行 `web_conformance.py check --dynamic-evidence <file> --strict`。
35
+ 3. 执行 `web_conformance.py check --root . --dynamic-evidence <file> --strict`,其中
36
+ `<file>` 为第 2 步生成的 `dynamic-evidence.json`。它引用同目录的 `manifest.json`,
37
+ 核对项目根、run ID、清单哈希、视口与 PNG 尺寸以及实际截图哈希,并重新计算动态结论。
38
+ 旧式手填 `status/evidence` 或移动、替换任一产物会得到 `UNVERIFIED`,需重新生成同轮收据。
50
39
 
51
40
  ## 结果语义
52
41
 
@@ -58,6 +47,122 @@
58
47
 
59
48
  缺少 Playwright 时不能把静态检查结果升级为完整 Web 合规;只能报告静态结果和动态
60
49
  `BLOCKED/UNVERIFIED`。主观配色或设计偏好没有项目契约、标准条款和复现证据时,不立案。
50
+
51
+ ## 项目 UI 规则
52
+
53
+ 在目标项目的 `DESIGN.md` 中写设计意图,并用一个 `bugx-ui` JSON 围栏声明可执行部分。
54
+ 页面选择器使用 CSS。这个例子声明了一个加载场景,`error`、`empty` 和 `disabled` 按同样
55
+ 方式各自提供场景。禁用场景至少断言一个 `"disabled": true`。
56
+
57
+ ```bugx-ui
58
+ {
59
+ "version": 1,
60
+ "tokens": {"--space-control": "16px", "--ink-primary": "#222222", "--surface": null},
61
+ "components": [
62
+ {"id": "button-padding", "selector": ".action", "styles": {"padding-top": "--space-control"}},
63
+ {"id": "card-alignment", "selector": ".cards > article", "align": "top", "tolerance_px": 2,
64
+ "profiles": ["desktop", "tablet"]}
65
+ ],
66
+ "contrast": [
67
+ {"id": "search-focus", "selector": "#search", "property": "outline-color",
68
+ "against": "parent", "focus": true}
69
+ ],
70
+ "reflow": [
71
+ {"id": "results", "selector": "#results"},
72
+ {"id": "search", "selector": "#search", "interactive": true}
73
+ ],
74
+ "journeys": [
75
+ {"id": "results-loading", "state": "loading", "path": "/qa/results?fixture=loading",
76
+ "actions": [{"type": "click", "selector": "#load"}],
77
+ "expect": [{"selector": "#feedback", "text": "Loading",
78
+ "attributes": {"role": "status", "aria-busy": "true"}}]}
79
+ ],
80
+ "keyboard": [
81
+ {"id": "dialog", "path": "/qa/results",
82
+ "steps": [{"key": "Tab", "focus": "#open"},
83
+ {"key": "Enter", "focus": "#close"},
84
+ {"key": "Tab", "focus": "#confirm"},
85
+ {"key": "Shift+Tab", "focus": "#close"},
86
+ {"key": "Escape", "focus": "#open"}]}
87
+ ]
88
+ }
89
+ ```
90
+
91
+ - `tokens` 检查根节点 CSS 自定义属性。值为 `null` 时只检查存在性。组件 `styles` 可以引用
92
+ 组件作用域中的 token,也可以直接声明预期 CSS 值。`align` 支持 `left`、`top`、`right`、
93
+ `center-x`,以至少两个可见实例计算偏差。
94
+ - `token_source` 从项目内 JSON 读取期望值。`format` 为 `dtcg` 或 `style-dictionary`,
95
+ `map` 将根 CSS 变量指向点号分隔的 token 路径。它可与不同名称的内联 `tokens` 共用。
96
+ 支持常见 CSS 标量、sRGB 颜色、带单位尺寸、时长、字体族与同文件别名。DTCG
97
+ `$ref` 支持同文件 JSON Pointer;组 `$extends` 和无法表示为单个 CSS 值的复合类型会报告输入错误。
98
+ - `contrast` 检查指定控件的 `background-color`、`border-top-color` 或 `outline-color`。
99
+ `against` 为 `parent` 或 `self`,以实际相邻表面为准。探针另外测量视口内的常规 DOM
100
+ 文字,合成可确定的透明图层。渐变、图像背景、不可分辨的覆盖层和嵌入内容保留
101
+ `UNVERIFIED`。请用显式状态路径覆盖需要单独检查的页面。
102
+ - `reflow` 每个选择器应指向一个在所有审计视口保持可见的元素。`interactive` 同时检查点击
103
+ 可操作性,使用 Playwright 的试运行模式。原生缩放以 1280×1024 为基线,在 200% 和
104
+ 400% 下验证实际 CSS 视口、页面溢出与关键元素。报告属于本次页面和选择器范围。
105
+ - `journeys` 每条从独立上下文开始。`path` 为同源路径,可省略。动作支持 `click`、`fill`、
106
+ `press`、`select_option`、`wait_for`,断言支持 `text`、`attributes`、`visible` 和
107
+ `disabled`。短暂状态应提供可重复的测试数据或 QA 路径。
108
+ - 在 Storybook 模式,`journeys` 和 `keyboard` 也可用 `story` 指定已渲染场景的 ID。
109
+ `story` 和 `path` 二选一;状态仍由项目断言判定。
110
+ - `keyboard` 在独立浏览器上下文里逐步发出真实按键,记录预期和实际焦点,并检查声明元素的
111
+ outline、阴影、边框或背景样式变化。可用 `indicator` 指定承载焦点样式的 CSS 选择器,默认
112
+ 为 `focus` 元素。弹窗内的正反向遍历、退出和恢复由项目步骤声明。没有旅程或缺少可用的
113
+ 未聚焦样式样本时,键盘结果为 `UNVERIFIED`。焦点颜色的定量检查由 `contrast` 声明。
114
+ - 本机 Ollama 配置有视觉模型时,可用 `--vision-model <本地模型标签>` 生成绑定图片哈希的
115
+ `ADVISORY` 点评。标题层级、对齐、排版、密度和一致性分别评审,机器门禁仍以测量为准。
116
+ - `--repair-css tokens.css` 预览已声明值的修复补丁。目标是项目内只有一个 `:root` 块的
117
+ token 样式表。附加 `--apply` 后,回环地址服务须加载这份 CSS。探针保存原文件、复测
118
+ 六个默认视口及已启用的状态,回归时恢复原字节。文件在复测期间被另一个进程编辑时,
119
+ 使用 `repair.json` 中的备份和补丁核对,状态为 `RECOVERY_REQUIRED`。
120
+
121
+ ## 接入 Storybook 和设计 token
122
+
123
+ Storybook 以已运行或已构建并提供 HTTP 服务的站点为输入。先列出可渲染条目,再按精确 ID 审计。
124
+
125
+ ```bash
126
+ bugx probe ui --storybook http://127.0.0.1:6006 --list-stories
127
+ bugx probe ui --root . --storybook http://127.0.0.1:6006 \
128
+ --story button--default --journeys --strict
129
+ ```
130
+
131
+ 探针读取 `index.json` v4/v5,打开对应的 `iframe.html` 画布并核对所选 ID。axe-core
132
+ 检查画布范围。收据包含 index 哈希、story ID 和预览 URL。Storybook 模式下,
133
+ `--reference-url` 指向参考 Storybook 的基地址,并在两端匹配同一个 ID。
134
+
135
+ 在现有 `bugx-ui` JSON 中加入类似字段。项目按自己的生成规则映射 CSS 变量名称。
136
+
137
+ ```json
138
+ {
139
+ "token_source": {
140
+ "file": "design/tokens.json",
141
+ "format": "dtcg",
142
+ "map": {"--space-control": "space.control", "--ink-primary": "color.primary"}
143
+ }
144
+ }
145
+ ```
146
+
147
+ Style Dictionary 传统 JSON 使用 `"format": "style-dictionary"`。令牌文件的路径、格式、映射
148
+ 和 SHA-256 写入设计收据。CSS 期望值由输入 JSON 解析,实际值来自浏览器的计算样式。
149
+
150
+ ## 参考页面视觉对照
151
+
152
+ 在同一浏览器版本、视口、缩放和主题下渲染认可的参考页面与当前页面。两个地址需要能执行
153
+ 同样的已声明场景。可重复指定 `--visual-mask` 屏蔽时间戳等动态内容。
154
+
155
+ ```bash
156
+ bugx probe ui --root . --url http://127.0.0.1:8080 \
157
+ --reference-url http://127.0.0.1:8081 --journeys \
158
+ --visual-mask '[data-volatile]' --visual-max-diff 0.001 --strict
159
+ ```
160
+
161
+ 任一 RGB 通道变化超过 16 的像素计为变化。`--visual-max-diff` 是允许变化的像素比例,
162
+ 默认为 0.001,即 0.1%。`visual-diff/` 保存差异图、边界和掩码,证据不足标记
163
+ `UNVERIFIED`。同一参考收据可用于 `--repair-css ... --apply` 的复测。某个场景新增的差异
164
+ 超过阈值时回滚,即使总差异数量减少。无法比较全部场景时,修复在写入前阻断。
165
+
61
166
  > 运行前置:BugX 核心要求 Python `>=3.11`。本文中的 `python3` 命令只表示已通过版本
62
167
  > 校验的解释器;系统 Python 3.9 不满足契约,请先按 `core/contracts/AGENT_GUIDE.md` 设置
63
168
  > `BUGX_PYTHON`,或优先使用 `bugx` CLI。
@@ -28,6 +28,8 @@ import json
28
28
  import os
29
29
  from typing import Any
30
30
 
31
+ from core.probes.ui_evidence import load_ui_evidence
32
+
31
33
 
32
34
  SCHEMA_VERSION = 1
33
35
  STANDARD_ORACLES = (
@@ -52,11 +54,9 @@ SKIP_DIRS = {
52
54
  }
53
55
  MAX_FILES = 5000
54
56
  MAX_BYTES = 2 * 1024 * 1024
55
- VALID_DYNAMIC_STATUSES = {"PASS", "FAIL", "BLOCKED", "UNVERIFIED", "DEFERRED"}
56
-
57
57
  DYNAMIC_RULES: tuple[tuple[str, str], ...] = (
58
- ("keyboard-focus", "键盘可操作、焦点可见且不被遮挡,无焦点陷阱"),
59
- ("aria-tree", "最终 Accessibility Tree 的角色、名称、状态和关系正确"),
58
+ ("keyboard-focus", "声明的真实键盘步骤、焦点指示、退出与恢复"),
59
+ ("aria-tree", "渲染后的 ARIA 树和已执行的 axe-core 自动规则"),
60
60
  ("contrast", "最终渲染样式满足文字、非文本和焦点指示器对比度要求"),
61
61
  ("reflow-zoom", "200% 放大、400% 重排/320 CSS px 和方向变化后仍可操作"),
62
62
  ("state-feedback", "loading/error/empty/disabled 状态有可感知且语义正确的反馈"),
@@ -307,57 +307,26 @@ def _check_document(path: Path, root: Path) -> list[dict[str, Any]]:
307
307
 
308
308
 
309
309
  def _dynamic_checks(
310
- evidence_path: Path | None, *, preflight: bool = False
310
+ evidence_path: Path | None, *, root: Path, preflight: bool = False
311
311
  ) -> list[dict[str, Any]]:
312
- if evidence_path is None and preflight:
312
+ if evidence_path is None:
313
+ status = "DEFERRED" if preflight else "BLOCKED"
313
314
  return [
314
- _check(
315
- f"dynamic.{rule_id}",
316
- "WCAG 2.2 AA / WAI-ARIA 1.2",
317
- "DEFERRED",
318
- message=f"动态规则在运行期通过浏览器测试检验({description}),预检阶段免检",
319
- )
315
+ _check(f"dynamic.{rule_id}", "WCAG 2.2 AA / WAI-ARIA 1.2", status,
316
+ message=f"需要浏览器动态证据:{description}")
320
317
  for rule_id, description in DYNAMIC_RULES
321
318
  ]
322
- payload: dict[str, Any] = {}
323
- if evidence_path is not None:
324
- try:
325
- loaded = json.loads(evidence_path.read_text(encoding="utf-8"))
326
- except (OSError, json.JSONDecodeError) as exc:
327
- return [_check(
328
- "dynamic-evidence", "WCAG 2.2 AA / WAI-ARIA 1.2", "UNVERIFIED",
329
- path=str(evidence_path), line=1, message=f"动态证据不可读取或不是 JSON:{exc}",
330
- )]
331
- if not isinstance(loaded, dict) or not isinstance(loaded.get("checks"), dict):
332
- return [_check(
333
- "dynamic-evidence", "WCAG 2.2 AA / WAI-ARIA 1.2", "UNVERIFIED",
334
- path=str(evidence_path), line=1, message="动态证据必须是 {checks: {rule_id: {status,evidence}}}",
335
- )]
336
- payload = loaded["checks"]
337
- results: list[dict[str, Any]] = []
338
- for rule_id, description in DYNAMIC_RULES:
339
- item = payload.get(rule_id)
340
- if not isinstance(item, dict):
341
- results.append(_check(
342
- f"dynamic.{rule_id}", "WCAG 2.2 AA / WAI-ARIA 1.2", "BLOCKED",
343
- message=f"缺少浏览器动态证据:{description}",
344
- ))
345
- continue
346
- status = str(item.get("status", "")).upper()
347
- evidence = str(item.get("evidence", "")).strip()
348
- if status not in VALID_DYNAMIC_STATUSES:
349
- status = "UNVERIFIED"
350
- message = f"动态证据状态无效:{item.get('status')!r}"
351
- elif status in {"PASS", "FAIL"} and not evidence:
352
- status = "UNVERIFIED"
353
- message = "PASS/FAIL 必须携带可定位的浏览器证据"
354
- else:
355
- message = str(item.get("message") or description)
356
- results.append(_check(
357
- f"dynamic.{rule_id}", "WCAG 2.2 AA / WAI-ARIA 1.2", status,
358
- message=message, evidence=evidence,
359
- ))
360
- return results
319
+ try:
320
+ verified = load_ui_evidence(evidence_path, root)
321
+ return [
322
+ _check(f"dynamic.{rule_id}", "WCAG 2.2 AA / WAI-ARIA 1.2", **verified[rule_id])
323
+ for rule_id, _ in DYNAMIC_RULES
324
+ ]
325
+ except (OSError, ValueError, KeyError, TypeError, AttributeError) as exc:
326
+ return [_check(
327
+ "dynamic-evidence", "WCAG 2.2 AA / WAI-ARIA 1.2", "UNVERIFIED",
328
+ path=str(evidence_path), line=1, message=f"动态证据校验失败:{exc}",
329
+ )]
361
330
 
362
331
 
363
332
  def check_project(
@@ -390,7 +359,7 @@ def check_project(
390
359
  "static-scan-limit", "HTML/WHATWG semantic conformance", "BLOCKED",
391
360
  message=f"源码文件超过扫描上限 {MAX_FILES},静态结果不完整",
392
361
  ))
393
- checks.extend(_dynamic_checks(dynamic_evidence, preflight=preflight))
362
+ checks.extend(_dynamic_checks(dynamic_evidence, root=root, preflight=preflight))
394
363
  summary = Counter(item["status"] for item in checks)
395
364
  status = "FAIL" if summary["FAIL"] else "BLOCKED" if summary["BLOCKED"] or summary["UNVERIFIED"] else "PASS"
396
365
  return {
@@ -1,6 +1,6 @@
1
1
  # BugX Retrieval Engine (代码切片、拓扑与混合检索增强引擎)
2
2
 
3
- > **版本契约**: `1.0.0` | **所属分层**: `Layer 2: 分析、切片与探测引擎`
3
+ > **版本契约**: `0.1.2` | **所属分层**: `Layer 2: 分析、切片与探测引擎`
4
4
  > **工程规范**: 参见 [`docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md`](../../docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md)
5
5
  > **守卫机制**: `scripts/verify_directory_indices.py` (100% 物理条目索引覆盖)
6
6
 
@@ -39,6 +39,7 @@ core/retrieval/
39
39
  │ ├── knowledge_sources.py # 知识来源拓扑解析与分层路径映射
40
40
  │ ├── knowledge_sync.py # 多项目/云端安全知识库增量双向同步
41
41
  │ ├── corpus_fetch.py # 种子测试语料与开源高质量安全样本抓取
42
+ │ ├── pitfall_packs.py # 按技术栈按需挂载的冷启动漏洞先验包与双路 RRF 检索引擎 (P1)
42
43
  │ └── code_analyzer.py # 多语言代码静态语义分析与复杂度度量器
43
44
  │
44
45
  └── 6. 包初始化与导出门面
@@ -21,5 +21,5 @@ from core.retrieval import search_context
21
21
  ```
22
22
 
23
23
  ## 5. Maintenance & Verification
24
- - Unit & regression tests for this package are registered in `tests/test_registry.json`.
24
+ - Verification is performed with short-lived tests outside the repository; no persistent `tests/` registry is retained.
25
25
  - Changes to exported interfaces must be synchronized via `python3 scripts/gen_interface_spec.py --package core/retrieval --write`.
@@ -248,9 +248,13 @@ def _analyze_python_ast(raw_bytes: bytes | str, sloc: int = 1) -> dict[str, Any]
248
248
  try:
249
249
  tree = ast.parse(raw_bytes)
250
250
  except Exception:
251
+ # 解析失败必须可区分(F-RSI-20261115-276):解析器失效/新语法等场景下
252
+ # 返回满分 mi=100.0 会把系统性解析失败伪装成最优健康度。mi 不可信时
253
+ # 返回 None 并携带 parse_status="failed",由调用方与聚合层显式处理。
251
254
  return {
252
255
  "cc": 1, "cognitive": 0, "max_depth": 1, "functions": 0, "classes": 0,
253
- "god_functions": 0, "taint_flows": [], "imports": [], "maintainability_index": 100.0,
256
+ "god_functions": 0, "taint_flows": [], "imports": [],
257
+ "maintainability_index": None, "parse_status": "failed",
254
258
  }
255
259
 
256
260
  class Visitor(ast.NodeVisitor):
@@ -646,6 +650,7 @@ def _analyze_python_ast(raw_bytes: bytes | str, sloc: int = 1) -> dict[str, Any]
646
650
  "imports": visitor.imports,
647
651
  "halstead_volume": round(halstead_v, 2),
648
652
  "maintainability_index": norm_mi,
653
+ "parse_status": "ok",
649
654
  }
650
655
 
651
656
 
@@ -895,8 +900,9 @@ def analyze_file_risk(
895
900
  return {
896
901
  "cc": 1, "cognitive": 0, "max_depth": 1, "functions": 0, "classes": 0,
897
902
  "god_functions": 0, "god_module": False, "sinks": 0,
898
- "taint_flows": [], "critical_sinks": [], "mitigations": [], "secrets": [], "imports": [], "maintainability_index": 100.0,
899
- "risk_score": 0.0, "tags": [],
903
+ "taint_flows": [], "critical_sinks": [], "mitigations": [], "secrets": [], "imports": [],
904
+ "maintainability_index": None, "parse_status": "unreadable",
905
+ "risk_score": 0.0, "tags": ["unreadable"],
900
906
  }
901
907
  text = raw_bytes.decode("utf-8", errors="ignore")
902
908
 
@@ -913,7 +919,8 @@ def analyze_file_risk(
913
919
  else:
914
920
  struct = {
915
921
  "cc": 1, "cognitive": 0, "max_depth": 1, "functions": 0, "classes": 0,
916
- "god_functions": 0, "taint_flows": [], "critical_sinks": [], "mitigations": [], "imports": [], "maintainability_index": 100.0,
922
+ "god_functions": 0, "taint_flows": [], "critical_sinks": [], "mitigations": [], "imports": [],
923
+ "maintainability_index": None, "parse_status": "not_applicable",
917
924
  }
918
925
  non_code_mask = set()
919
926
 
@@ -925,7 +932,8 @@ def analyze_file_risk(
925
932
  cc = struct.get("cc", 1)
926
933
  cognitive = struct.get("cognitive", 0)
927
934
  max_depth = struct.get("max_depth", 1)
928
- mi = struct.get("maintainability_index", 100.0)
935
+ mi = struct.get("maintainability_index")
936
+ parse_status = struct.get("parse_status", "ok")
929
937
 
930
938
  # God Module: only for production code
931
939
  is_god_module = False
@@ -953,8 +961,12 @@ def analyze_file_risk(
953
961
  tags.append("mitigated-control")
954
962
  if len(secrets) > 0:
955
963
  tags.append("hardcoded-secret")
956
- if mi < 40.0:
964
+ if mi is not None and mi < 40.0:
957
965
  tags.append("low-maintainability")
966
+ if parse_status == "failed":
967
+ # 解析失败必须出现在标签面(F-RSI-20261115-276):无结构的"满分"伪装
968
+ # 被移除后,文件级降级信号在 hotspots/tags 通道保持可见。
969
+ tags.append("parse-failed")
958
970
 
959
971
  # Composite Risk score calculation (0 ~ 100) - 彻底废除复杂度即风险,确立高危一票置顶
960
972
  if len(critical_sinks) > 0 or len(taints) > 0:
@@ -972,7 +984,7 @@ def analyze_file_risk(
972
984
  + (sinks * 3.0)
973
985
  + (len(secrets) * 6.0)
974
986
  + (max_depth * 1.5)
975
- + (10.0 if mi < 40.0 else 0.0),
987
+ + (10.0 if (mi is not None and mi < 40.0) else 0.0),
976
988
  )
977
989
 
978
990
  risk_score = round(min(100.0, max(10.0, base_score)), 1)
@@ -992,6 +1004,7 @@ def analyze_file_risk(
992
1004
  "secrets": secrets,
993
1005
  "imports": struct.get("imports", []),
994
1006
  "maintainability_index": mi,
1007
+ "parse_status": parse_status,
995
1008
  "risk_score": risk_score,
996
1009
  "tags": tags,
997
1010
  }
@@ -1397,6 +1410,7 @@ def analyze_codebase(
1397
1410
  all_critical_sinks: list[dict[str, Any]] = []
1398
1411
  all_secrets: list[dict[str, Any]] = []
1399
1412
  maintainability_scores: list[float] = []
1413
+ maintainability_parse_failed_files = 0
1400
1414
  file_import_map: dict[str, list[str]] = {}
1401
1415
  prod_files_list: list[tuple[str, Path, int, str]] = []
1402
1416
  # Per-pass cache of decoded production source text. ``count_file_lines``,
@@ -1457,7 +1471,14 @@ def analyze_codebase(
1457
1471
  if cog > max_cognitive:
1458
1472
  max_cognitive = cog
1459
1473
 
1460
- maintainability_scores.append(risk_info.get("maintainability_index", 100.0))
1474
+ file_mi = risk_info.get("maintainability_index")
1475
+ if file_mi is None:
1476
+ # 解析/读取失败的文件不进入均值(F-RSI-20261115-276):假满分
1477
+ # 会污染聚合,降级文件计数显式暴露给度量看板。
1478
+ if risk_info.get("parse_status", "ok") in {"failed", "unreadable"}:
1479
+ maintainability_parse_failed_files += 1
1480
+ else:
1481
+ maintainability_scores.append(file_mi)
1461
1482
  if risk_info.get("critical_sinks"):
1462
1483
  for cs in risk_info["critical_sinks"]:
1463
1484
  all_critical_sinks.append({
@@ -1500,7 +1521,7 @@ def analyze_codebase(
1500
1521
  "risk_score": risk_info["risk_score"],
1501
1522
  "cyclomatic_complexity": cc,
1502
1523
  "cognitive_complexity": cog,
1503
- "maintainability_index": risk_info.get("maintainability_index", 100.0),
1524
+ "maintainability_index": risk_info.get("maintainability_index"),
1504
1525
  "sensitive_sinks": risk_info["sinks"],
1505
1526
  "max_depth": risk_info["max_depth"],
1506
1527
  "sloc": sloc,
@@ -1601,8 +1622,20 @@ def analyze_codebase(
1601
1622
 
1602
1623
  avg_cc = round(total_cc / max(1, code_files), 1) if code_files > 0 else 1.0
1603
1624
  avg_cog = round(total_cognitive / max(1, code_files), 1) if code_files > 0 else 0.0
1604
- avg_mi = round(sum(maintainability_scores) / max(1, len(maintainability_scores)), 1) if maintainability_scores else 100.0
1605
- mi_grade = "🟢 良好" if avg_mi >= 65 else ("🟡 关注" if avg_mi >= 40 else "🔴 恶化")
1625
+ # 聚合均值只取可解析文件(F-RSI-20261115-276):无可解析文件时不得伪装
1626
+ # 满分 100.0,以 None 表示"未测得",输出层降级为 0.0 并携带降级计数。
1627
+ avg_mi = (
1628
+ round(sum(maintainability_scores) / len(maintainability_scores), 1)
1629
+ if maintainability_scores else None
1630
+ )
1631
+ if avg_mi is None:
1632
+ mi_grade = "⚪ 未测得(无可解析代码文件)"
1633
+ elif avg_mi >= 65:
1634
+ mi_grade = "🟢 良好"
1635
+ elif avg_mi >= 40:
1636
+ mi_grade = "🟡 关注"
1637
+ else:
1638
+ mi_grade = "🔴 恶化"
1606
1639
 
1607
1640
  health_grade = compute_health_grade(avg_cc, total_god_modules, test_to_code_ratio)
1608
1641
 
@@ -1650,9 +1683,11 @@ def analyze_codebase(
1650
1683
  "modules": modules_breakdown,
1651
1684
  "scale_estimation": scale,
1652
1685
  "maintainability": {
1653
- "maintainability_index": avg_mi,
1654
- "avg_maintainability_index": avg_mi,
1686
+ "maintainability_index": avg_mi if avg_mi is not None else 0.0,
1687
+ "avg_maintainability_index": avg_mi if avg_mi is not None else 0.0,
1655
1688
  "maintainability_grade": mi_grade,
1689
+ "parse_failed_files": maintainability_parse_failed_files,
1690
+ "measured_files": len(maintainability_scores),
1656
1691
  "avg_cognitive_complexity": avg_cog,
1657
1692
  "max_cognitive_complexity": max_cognitive,
1658
1693
  },
@@ -1674,7 +1709,8 @@ def analyze_codebase(
1674
1709
  "secrets": all_secrets,
1675
1710
  "critical_sinks": all_critical_sinks,
1676
1711
  "taint_flows": all_taints,
1677
- "maintainability_index": avg_mi,
1712
+ "maintainability_index": avg_mi if avg_mi is not None else 0.0,
1713
+ "maintainability_parse_failed_files": maintainability_parse_failed_files,
1678
1714
  "avg_cognitive_complexity": avg_cog,
1679
1715
  "duplication_percentage": duplication_info.get("duplication_percentage", 0.0),
1680
1716
  "circular_dependencies_count": architecture_info.get("total_cycles", 0),
@@ -50,6 +50,12 @@ TIER_SYMBOL_BUDGET = {"deep": 14, "standard": 8, "triage": 5}
50
50
  RULE_CORPUS_RELATIVE = "prompts/rules"
51
51
 
52
52
 
53
+ def _strip_dot_prefix(path: str) -> str:
54
+ """剥 "./" 前缀(F-029):str.lstrip("./") 是字符集剥离,会吃掉
55
+ 点前缀文件名(.bugx/.tests/.github)的开头点——symbol_index.py:198
56
+ 已记载该坑,本仓其余站点此番统一对齐。"""
57
+ return path[2:] if path.startswith("./") else path
58
+
53
59
  def _core_root(root: Path | None) -> Path:
54
60
  if root is not None:
55
61
  return Path(root).resolve()
@@ -63,7 +69,7 @@ def _core_root(root: Path | None) -> Path:
63
69
 
64
70
  def _unit_path(unit: str, root: Path) -> Path | None:
65
71
  """把 unit id(可能带 ::symbol 后缀)解析到真实文件。"""
66
- rel = str(unit).split("::", 1)[0].replace("\\", "/").lstrip("./")
72
+ rel = _strip_dot_prefix(str(unit).split("::", 1)[0].replace("\\", "/"))
67
73
  if not rel:
68
74
  return None
69
75
  candidate = root / rel