bugx-cli 0.1.0 → 0.1.1

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 (311) hide show
  1. package/README.md +190 -186
  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/axe-core/LICENSE-3RD-PARTY.txt +66 -0
  11. package/core/assets/axe-core/LICENSE.txt +362 -0
  12. package/core/assets/axe-core/UPSTREAM.md +10 -0
  13. package/core/assets/axe-core/axe.min.js +12 -0
  14. package/core/assets/bugx-hero-en.svg +74 -0
  15. package/core/assets/bugx-hero-zh.svg +74 -0
  16. package/core/assets/codex.png +0 -0
  17. package/core/assets/dsh.png +0 -0
  18. package/core/assets/webui-chatgpt.jpg +0 -0
  19. package/core/assets/webui-session.jpg +0 -0
  20. package/core/assets/webui-skills.jpg +0 -0
  21. package/core/assets/webui-studio.jpg +0 -0
  22. package/core/assets/webui-zcode.jpg +0 -0
  23. package/core/assets/zcode.png +0 -0
  24. package/core/autonomous_cve/SPEC.md +1 -1
  25. package/core/autonomous_cve/attack_graph_store.py +152 -106
  26. package/core/autonomous_cve/behavior_graph.py +8 -2
  27. package/core/autonomous_cve/verifier.py +4 -1
  28. package/core/bugx.md +1 -1
  29. package/core/bugx_paths.py +43 -8
  30. package/core/cli-help.txt +66 -0
  31. package/core/cloud_sync/SPEC.md +1 -1
  32. package/core/cloud_sync/cloud_client.py +25 -6
  33. package/core/cloud_sync/cloud_onboard.py +42 -1
  34. package/core/cloud_sync/flywheel_client.py +16 -7
  35. package/core/cloud_sync/network_transport.py +24 -3
  36. package/core/cloud_sync/sensitive_filter.py +2 -2
  37. package/core/cloud_sync/sync_push.py +12 -10
  38. package/core/contracts/AGENT_GUIDE.md +6 -9
  39. package/core/contracts/README.md +2 -2
  40. package/core/contracts/bugx-runtime-contract.md +1 -1
  41. package/core/contracts/bugx-worker.md +1 -1
  42. package/core/contracts/engine_gap_contracts.py +86 -3
  43. package/core/coverage/coverage_discovery.py +599 -29
  44. package/core/coverage/coverage_evidence.py +47 -0
  45. package/core/coverage/coverage_forensics.py +9 -0
  46. package/core/coverage/coverage_validate.py +6 -1
  47. package/core/dev_harness/SPEC.md +1 -1
  48. package/core/engine-integrity.json +591 -419
  49. package/core/fuzzing/concurrency_fuzzer.py +53 -0
  50. package/core/fuzzing/differential_oracle.py +562 -27
  51. package/core/fuzzing/fuzz_input.py +109 -6
  52. package/core/fuzzing/stateful_fuzzer.py +72 -0
  53. package/core/governance/secret_redactor.py +22 -10
  54. package/core/host_acp/SPEC.md +1 -1
  55. package/core/host_acp/__init__.py +4 -4
  56. package/core/host_acp/claude.py +59 -1
  57. package/core/host_acp/cline.py +64 -1
  58. package/core/host_acp/codex.py +56 -1
  59. package/core/host_acp/dsh.py +59 -1
  60. package/core/host_acp/opencode.py +56 -1
  61. package/core/host_acp/pi.py +59 -1
  62. package/core/host_acp/zcode.py +59 -1
  63. package/core/host_runtime/SPEC.md +1 -1
  64. package/core/host_runtime/adapters.py +1 -1
  65. package/core/host_runtime/cline.py +13 -0
  66. package/core/host_runtime/host_evaluators.py +44 -4
  67. package/core/host_runtime/host_probe.py +1 -1
  68. package/core/host_runtime/host_provider_arbitrator.py +116 -62
  69. package/core/host_runtime/host_registry.py +15 -8
  70. package/core/host_runtime/mcp_registry_gate.py +12 -1
  71. package/core/host_runtime/pi.py +102 -0
  72. package/core/host_runtime/provider_facts.py +66 -0
  73. package/core/hosts/SPEC.md +1 -1
  74. package/core/hosts/__init__.py +6 -2
  75. package/core/hosts/_dsh_usage.py +1 -1
  76. package/core/hosts/base.py +32 -4
  77. package/core/hosts/claude.py +55 -0
  78. package/core/hosts/cline.py +6 -2
  79. package/core/hosts/codex.py +58 -0
  80. package/core/hosts/dsh.py +9 -1
  81. package/core/hosts/opencode.py +6 -6
  82. package/core/hosts/pi.py +159 -2
  83. package/core/infra/README.md +4 -2
  84. package/core/infra/__init__.py +2 -0
  85. package/core/infra/build_info.py +22 -3
  86. package/core/infra/client_metadata.py +1 -1
  87. package/core/infra/json_utils.py +22 -0
  88. package/core/launch_phases/README.md +2 -2
  89. package/core/launch_phases/SPEC.md +1 -1
  90. package/core/launch_phases/common.py +21 -2
  91. package/core/launch_phases/finding_confirm_phase.py +5 -1
  92. package/core/launch_phases/finding_settlement.py +188 -1
  93. package/core/launch_phases/judge_phase.py +69 -12
  94. package/core/launch_phases/orchestrator_controls.py +11 -7
  95. package/core/launch_phases/post_coverage_sync.py +9 -2
  96. package/core/launch_phases/post_phase.py +139 -3
  97. package/core/launch_phases/post_receipt.py +12 -1
  98. package/core/launch_phases/pre_phase.py +3 -3
  99. package/core/launch_phases/pre_recon_scout.py +53 -36
  100. package/core/launch_phases/pre_state_builder.py +23 -176
  101. package/core/launch_phases/round_orchestrator.py +15 -32
  102. package/core/launch_phases/session_runtime.py +56 -9
  103. package/core/launch_phases/startup_gates.py +36 -8
  104. package/core/launch_phases/startup_interaction.py +68 -12
  105. package/core/launch_phases/startup_version_gate.py +9 -3
  106. package/core/launch_phases/supervisor_bridge.py +46 -17
  107. package/core/launch_phases/supervisor_coverage.py +8 -2
  108. package/core/launch_phases/supervisor_degraded.py +1 -9
  109. package/core/launch_phases/worker_barriers.py +15 -5
  110. package/core/launch_phases/worker_orchestrator.py +105 -25
  111. package/core/ledger/README.md +1 -1
  112. package/core/ledger/SPEC.md +1 -1
  113. package/core/ledger/_facade.py +2 -1
  114. package/core/ledger/archive_ops.py +60 -2
  115. package/core/ledger/cli.py +6 -1
  116. package/core/ledger/export_ops.py +6 -1
  117. package/core/ledger/finding_confirmation.py +48 -6
  118. package/core/ledger/finding_lifecycle.py +428 -5
  119. package/core/ledger/finding_verification.py +44 -8
  120. package/core/ledger/incidents.py +10 -4
  121. package/core/ledger/patterns.py +10 -7
  122. package/core/ledger/receipt_contract.py +17 -1
  123. package/core/ledger/sync_ops.py +21 -16
  124. package/core/ledger/tool_experience.py +2 -1
  125. package/core/ledger/verify_life.py +88 -17
  126. package/core/locales/en-US.json +2 -2
  127. package/core/locales/zh-CN.json +2 -2
  128. package/core/mcp_handlers/SPEC.md +1 -1
  129. package/core/mcp_handlers/base.py +23 -3
  130. package/core/mcp_handlers/channel_lifecycle.py +85 -30
  131. package/core/mcp_handlers/retrieval_handlers.py +11 -1
  132. package/core/mcp_handlers/rpc_server.py +6 -1
  133. package/core/mcp_handlers/supervisor_handlers.py +32 -6
  134. package/core/mcp_handlers/tool_table.py +15 -0
  135. package/core/mcp_runtime_support/environment.py +0 -38
  136. package/core/mcp_runtime_support/verifier.py +0 -52
  137. package/core/metadata.txt +2 -3
  138. package/core/planning/README.md +1 -1
  139. package/core/planning/domain_router.py +4 -2
  140. package/core/planning/dynamic_flow_analyzer.py +219 -14
  141. package/core/planning/judge_pipeline.py +87 -4
  142. package/core/planning/prompt_harness.py +7 -5
  143. package/core/planning/spec_harvester.py +4 -4
  144. package/core/probes/INTERFACE.md +11 -1
  145. package/core/probes/SPEC.md +11 -1
  146. package/core/probes/__init__.py +46 -40
  147. package/core/probes/android_probe.py +177 -9
  148. package/core/probes/codebase_memory_probe.py +57 -0
  149. package/core/probes/desktop_probe.py +104 -0
  150. package/core/probes/differential_probe.py +99 -21
  151. package/core/probes/efficiency_probe.py +64 -0
  152. package/core/probes/ios_binary_probe.py +105 -1
  153. package/core/probes/memory_probe.py +66 -0
  154. package/core/probes/miniprogram_probe.py +75 -13
  155. package/core/probes/mobile_probe.py +215 -30
  156. package/core/probes/native_probe.py +88 -0
  157. package/core/probes/openwiki_probe.py +70 -0
  158. package/core/probes/pattern_probe.py +106 -0
  159. package/core/probes/platform_probe.py +81 -0
  160. package/core/probes/probe_registry.py +108 -7
  161. package/core/probes/sast_fixture_corpus.py +340 -0
  162. package/core/probes/sast_probe.py +553 -52
  163. package/core/probes/sast_rules.py +668 -28
  164. package/core/probes/sca_scanner.py +48 -0
  165. package/core/probes/ui_accessibility.py +149 -0
  166. package/core/probes/ui_audit.py +513 -0
  167. package/core/probes/ui_contract.py +273 -0
  168. package/core/probes/ui_evidence.py +212 -0
  169. package/core/probes/ui_measurements.py +314 -0
  170. package/core/probes/ui_repair.py +250 -0
  171. package/core/probes/ui_review.py +133 -0
  172. package/core/probes/ui_storybook.py +107 -0
  173. package/core/probes/ui_tokens.py +185 -0
  174. package/core/probes/ui_visual_diff.py +131 -0
  175. package/core/probes/web_probe.py +373 -18
  176. package/core/project_profiler/SPEC.md +1 -1
  177. package/core/project_profiler/arbitrator.py +6 -1
  178. package/core/project_profiler/detector.py +8 -1
  179. package/core/project_profiler/strategy.py +51 -15
  180. package/core/prompts/command_routing_en.md +2 -2
  181. package/core/prompts/command_routing_zh.md +2 -2
  182. package/core/prompts/stages/stage_repair.md +1 -1
  183. package/core/repair/README.md +1 -1
  184. package/core/repair/l7_repair_loop.py +1 -4
  185. package/core/repair/rsi_fixer.py +4 -4
  186. package/core/repair/rsi_loop.py +1 -3
  187. package/core/repair/rsi_repair.py +7 -7
  188. package/core/repair/rsi_scope.py +27 -8
  189. package/core/report_engine/SPEC.md +1 -1
  190. package/core/report_engine/attestation.py +8 -4
  191. package/core/report_engine/finding_report.py +2 -1
  192. package/core/report_engine/models.py +7 -9
  193. package/core/report_engine/sast_bridge.py +2 -2
  194. package/core/report_engine/server.py +18 -8
  195. package/core/report_engine/web-conformance.md +123 -18
  196. package/core/report_engine/web_conformance.py +21 -52
  197. package/core/retrieval/README.md +1 -1
  198. package/core/retrieval/SPEC.md +1 -1
  199. package/core/retrieval/code_analyzer.py +50 -14
  200. package/core/retrieval/context_assembler.py +7 -1
  201. package/core/retrieval/knowledge_sync.py +108 -14
  202. package/core/retrieval/symbol_index.py +25 -6
  203. package/core/retrieval/universal_code_matcher.py +234 -49
  204. package/core/runtime/README.md +1 -1
  205. package/core/runtime/bugx_logging.py +78 -7
  206. package/core/runtime/fixture_solidify.py +5 -10
  207. package/core/runtime/incident_eval.py +1 -1
  208. package/core/runtime/model_runner.py +4 -41
  209. package/core/runtime/platform_adapter.py +2 -2
  210. package/core/runtime/prep_validate.py +4 -2
  211. package/core/runtime/project_settings.py +2 -1
  212. package/core/runtime/scenario_eval.py +50 -8
  213. package/core/skills/bugx_docs_mcp_server.py +3 -1
  214. package/core/skills/bugx_mcp_server.py +29 -2
  215. package/core/skills/tools_kb.py +1 -1
  216. package/core/supervisor/README.md +1 -1
  217. package/core/supervisor/SPEC.md +1 -1
  218. package/core/supervisor/budget_governor.py +503 -9
  219. package/core/supervisor/checkpoint_pipeline.py +248 -6
  220. package/core/supervisor/checkpoint_sync.py +13 -0
  221. package/core/supervisor/claim_events.py +1 -1
  222. package/core/supervisor/finding_workflow.py +22 -5
  223. package/core/supervisor/lease_manager.py +1 -1
  224. package/core/supervisor/lifecycle_blocks.py +6 -1
  225. package/core/supervisor/rejection_remedies.py +52 -5
  226. package/core/supervisor/serial_authorization.py +48 -4
  227. package/core/supervisor/task_scheduler.py +2 -2
  228. package/core/supervisor/worker_checkpoint.py +8 -1
  229. package/core/supervisor/worker_runtime.py +8 -2
  230. package/core/supervisor_types/worker_claim.py +9 -0
  231. package/core/webui/README.md +1 -1
  232. package/core/webui/SPEC.md +2 -1
  233. package/core/webui/adapters/claude.py +5 -1
  234. package/core/webui/adapters/cline.py +10 -2
  235. package/core/webui/adapters/codex.py +5 -1
  236. package/core/webui/adapters/dsh.py +5 -1
  237. package/core/webui/docs_session_service.py +2 -2
  238. package/core/webui/mcp_inspector.py +11 -7
  239. package/core/webui/static/00-base.css +1060 -0
  240. package/core/webui/static/01-monitoring.css +802 -0
  241. package/core/webui/static/02-header-actions.css +321 -0
  242. package/core/webui/static/03-trigger-popover.css +697 -0
  243. package/core/webui/static/04-composer.css +628 -0
  244. package/core/webui/static/05-skills-center.css +878 -0
  245. package/core/webui/static/06-mcp-center.css +623 -0
  246. package/core/webui/static/07-skill-detail.css +265 -0
  247. package/core/webui/static/08-files-management.css +167 -0
  248. package/core/webui/static/09-files-center.css +386 -0
  249. package/core/webui/static/10-icons.css +105 -0
  250. package/core/webui/static/11-project-options.css +185 -0
  251. package/core/webui/static/12-profile-tab.css +383 -0
  252. package/core/webui/static/design-tokens.css +113 -0
  253. package/core/webui/static/index.html +14 -1
  254. package/core/webui/workspace_service.py +1 -1
  255. package/docs/07_distribution/01_README_NPM.md +190 -186
  256. package/ecosystem/integrations/README.md +1 -1
  257. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  258. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
  259. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  260. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
  261. package/ecosystem/integrations/opencode/mcp-lock.json +14 -6
  262. package/ecosystem/integrations/opencode/opencode.json +23 -12
  263. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  264. package/ecosystem/integrations/qoder/connector-meta.json +1 -1
  265. package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
  266. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +1 -1
  267. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
  268. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
  269. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
  270. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +2 -2
  271. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
  272. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
  273. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
  274. package/interfaces/bin/bugx.js +37 -0
  275. package/interfaces/cli/bugx_cli/__init__.py +4 -2
  276. package/interfaces/cli/bugx_cli/cli.py +11 -4
  277. package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
  278. package/interfaces/cli/bugx_cli/commands/agent.py +339 -73
  279. package/interfaces/cli/bugx_cli/commands/audit.py +2 -2
  280. package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
  281. package/interfaces/cli/bugx_cli/commands/cloud.py +4 -3
  282. package/interfaces/cli/bugx_cli/commands/doctor.py +449 -204
  283. package/interfaces/cli/bugx_cli/commands/interaction.py +5 -1
  284. package/interfaces/cli/bugx_cli/commands/knowledge.py +2 -0
  285. package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
  286. package/interfaces/cli/bugx_cli/commands/plugin.py +55 -20
  287. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +7 -7
  288. package/interfaces/cli/bugx_cli/commands/plugin_funide.py +2 -1
  289. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +1 -1
  290. package/interfaces/cli/bugx_cli/commands/report.py +2 -6
  291. package/interfaces/cli/bugx_cli/commands/system.py +11 -11
  292. package/interfaces/cli/bugx_cli/common.py +15 -7
  293. package/interfaces/cli/bugx_cli/host_adapters.py +29 -54
  294. package/interfaces/cli/bugx_cli/hosts/registry.py +8 -6
  295. package/interfaces/cli/bugx_cli/infra/ai_advisor.py +157 -27
  296. package/interfaces/cli/bugx_cli/infra/engine_installer.py +18 -10
  297. package/interfaces/cli/bugx_cli/infra/host_sync.py +11 -8
  298. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +76 -5
  299. package/interfaces/cli/bugx_cli/infra/security.py +13 -6
  300. package/package.json +2 -1
  301. package/pyproject.toml +20 -8
  302. package/scripts/ensure-python.mjs +7 -7
  303. package/scripts/sync-version.mjs +10 -21
  304. package/scripts/test-npm-wrapper.mjs +1 -1
  305. package/core/webui/static/project-settings.css +0 -6458
  306. package/docs/07_distribution/README.md +0 -16
  307. package/docs/README.md +0 -121
  308. package/interfaces/README.md +0 -143
  309. package/interfaces/bin/README.md +0 -35
  310. package/interfaces/cli/README.md +0 -90
  311. package/scripts/README.md +0 -118
@@ -134,7 +134,7 @@ def build_work_order(payload: dict, *, root: Path,
134
134
  "1) `python3 -m core.repair.l7_selfcheck"
135
135
  + (" --dynamic" if dynamic else "") + "` 退出码 0;"
136
136
  "2) `python3 -m core.runtime.scenario_eval --level L7` 通过;"
137
- "3) 不修改 evals/ 下的评测断言与基线。"
137
+ "3) 不修改 verification/evals/ 下的评测断言与基线。"
138
138
  "仅让其中一条变绿不构成修复——L7 的六项检查互相独立,"
139
139
  "让目标项变绿而弄红其他项同样算失败。"
140
140
  ),
@@ -147,9 +147,6 @@ def build_work_order(payload: dict, *, root: Path,
147
147
  "integrations/",
148
148
  ],
149
149
  "forbidden": [
150
- "evals/golden-findings.json",
151
- "evals/cases.json",
152
- "evals/scenario-baseline.json",
153
150
  "verification/evals/golden-findings.json",
154
151
  "verification/evals/cases.json",
155
152
  "verification/evals/scenario-baseline.json",
@@ -173,7 +173,7 @@ def build_fix_prompt(work_order: dict, *, mode: str, tree: Path | None = None) -
173
173
  "",
174
174
  "## 关于全量测试(重要:不要在本次修复里跑)",
175
175
  "",
176
- "**不要执行 `pytest tests/ -q` 或任何全量测试。**",
176
+ "**不要在仓库内保留或执行仓库级 `pytest tests/ -q`;验证只能使用目标项目或临时目录。**",
177
177
  "",
178
178
  "本仓库全量测试有 3600+ 条、约 24 分钟。修复 agent 的预算是分钟级,",
179
179
  "一旦开始跑全量测试就会耗尽预算,最终超时被杀——**代码改对了也会被",
@@ -187,8 +187,8 @@ def build_fix_prompt(work_order: dict, *, mode: str, tree: Path | None = None) -
187
187
  "",
188
188
  "## 范围限制",
189
189
  "禁止修改:",
190
- "- `evals/golden-findings.json`、`evals/cases.json`(评测断言)",
191
- "- `evals/*baseline*.json`(基线/门槛)",
190
+ "- `verification/evals/golden-findings.json`、`verification/evals/cases.json`(评测断言)",
191
+ "- `verification/evals/*baseline*.json`(基线/门槛)",
192
192
  "- 任何以「让评测变绿」为目的的断言调整",
193
193
  "",
194
194
  f"当前修复模式:{mode}({rsi_scope.mode_description(mode)})",
@@ -757,7 +757,7 @@ def attempt_fix(work_order: dict, *, host: str = "dsh", root: Path | None = None
757
757
  # ``regression_commands`` 让调用方指定「对本缺陷有意义的回归集」。
758
758
  # L7 的修复只需重跑 l7_selfcheck(0.00s),没必要跑全量 pytest
759
759
  # (数分钟)——门禁要拦的是「改坏别处」,不是「必须跑全量」。
760
- # 缺省仍走 pytest tests/,保持对通用工单的行为不变。
760
+ # 缺省仍在目标项目中运行其自身测试,仓库本身不提供 tests/ 目录。
761
761
  if regression_commands:
762
762
  for argv in regression_commands:
763
763
  reg_rc, reg_out, reg_err = _run(
@@ -262,9 +262,7 @@ def main(argv: list[str] | None = None) -> int:
262
262
  parser.add_argument("--rounds", type=int, default=3)
263
263
  parser.add_argument("--converge-after", type=int, default=2)
264
264
  parser.add_argument("--baseline", default=str(
265
- (REPO_ROOT / "verification" / "evals" / "scenario-baseline.json")
266
- if (REPO_ROOT / "verification" / "evals").is_dir()
267
- else (REPO_ROOT / "evals" / "scenario-baseline.json")))
265
+ REPO_ROOT / "verification" / "evals" / "scenario-baseline.json"))
268
266
  parser.add_argument("--out", default=None)
269
267
  parser.add_argument("--source-root", default=None,
270
268
  help="发现证据的解析根(缺省=仓库根)")
@@ -83,8 +83,8 @@ def _case_golden_desync(root: Path) -> list[str]:
83
83
 
84
84
  这类不一致正是「只写 case 不写 golden」留下的痕迹,已经实测踩过两次。
85
85
  """
86
- cases_path = root / "evals" / "cases.json"
87
- golden_path = root / "evals" / "golden-findings.json"
86
+ cases_path = root / "verification" / "evals" / "cases.json"
87
+ golden_path = root / "verification" / "evals" / "golden-findings.json"
88
88
  if not cases_path.is_file() or not golden_path.is_file():
89
89
  return []
90
90
  try:
@@ -105,8 +105,8 @@ def _case_golden_desync(root: Path) -> list[str]:
105
105
 
106
106
  def _orphan_fixtures(root: Path) -> list[str]:
107
107
  """找出没被任何 case 引用的 fixture 文件(语义不变的残留)。"""
108
- cases_path = root / "evals" / "cases.json"
109
- fixtures_dir = root / "evals" / "fixtures"
108
+ cases_path = root / "verification" / "evals" / "cases.json"
109
+ fixtures_dir = root / "verification" / "evals" / "fixtures"
110
110
  if not cases_path.is_file() or not fixtures_dir.is_dir():
111
111
  return []
112
112
  try:
@@ -125,7 +125,7 @@ def _orphan_fixtures(root: Path) -> list[str]:
125
125
 
126
126
 
127
127
  def _duplicate_case_ids(root: Path) -> list[str]:
128
- cases_path = root / "evals" / "cases.json"
128
+ cases_path = root / "verification" / "evals" / "cases.json"
129
129
  if not cases_path.is_file():
130
130
  return []
131
131
  try:
@@ -250,7 +250,7 @@ def repair_noise(root: Path, *, dry_run: bool = False) -> dict[str, object]:
250
250
  for name in _orphan_fixtures(root):
251
251
  if not dry_run:
252
252
  try:
253
- (root / "evals" / "fixtures" / name).unlink()
253
+ (root / "verification" / "evals" / "fixtures" / name).unlink()
254
254
  except OSError:
255
255
  continue
256
256
  removed_fixtures.append(name)
@@ -259,7 +259,7 @@ def repair_noise(root: Path, *, dry_run: bool = False) -> dict[str, object]:
259
259
  if dry_run:
260
260
  removed_duplicates.append(case_id)
261
261
  continue
262
- cases_path = root / "evals" / "cases.json"
262
+ cases_path = root / "verification" / "evals" / "cases.json"
263
263
  try:
264
264
  payload = json.loads(cases_path.read_text(encoding="utf-8"))
265
265
  except (OSError, ValueError):
@@ -30,6 +30,10 @@
30
30
 
31
31
  这五条都是**可机械检查**的。守卫的价值就在于它不需要理解改动意图,
32
32
  只看形状就能拦下绝大多数跑偏。
33
+
34
+ F-RSI-20261110-026 补第六条:**6. 不许纯内容修改既有条目**——ID 集合
35
+ 不变但指纹变了(改 minimum_severity/severity 期望值)与「保住形状、改掉
36
+ 答案」同构,full 模式与 guarded 一样由 content_digests 拦截。
33
37
  """
34
38
 
35
39
  from __future__ import annotations
@@ -46,15 +50,11 @@ VALID_MODES = (GUARDED, FULL)
46
50
 
47
51
  #: 模式 2 下允许触碰的评测文件(相对仓库根)。
48
52
  ASSERTION_FILES = (
49
- "evals/cases.json",
50
- "evals/golden-findings.json",
51
53
  "verification/evals/cases.json",
52
54
  "verification/evals/golden-findings.json",
53
55
  )
54
56
  #: 模式 2 下**永远**不许改的文件。门槛数值一改,一切都能通过。
55
57
  FORBIDDEN_FILES = (
56
- "evals/scenario-baseline.json",
57
- "evals/baseline-metrics.json",
58
58
  "verification/evals/scenario-baseline.json",
59
59
  "verification/evals/baseline-metrics.json",
60
60
  )
@@ -88,10 +88,7 @@ def _load(path: Path) -> dict:
88
88
 
89
89
 
90
90
  def _eval_file(root: Path, name: str) -> Path:
91
- p = root / "verification" / "evals" / name
92
- if p.exists() or (root / "verification" / "evals").is_dir():
93
- return p
94
- return root / "evals" / name
91
+ return root / "verification" / "evals" / name
95
92
 
96
93
 
97
94
  def _case_ids(root: Path) -> set[str]:
@@ -232,6 +229,28 @@ def check_assertion_change(before: dict, after: dict,
232
229
  "阈值被修改。降低 min_recall 之类能让一切通过,"
233
230
  "这比修 bug 容易得多——所以永远不许自动改。"
234
231
  )
232
+
233
+ # F-RSI-20261110-026:full 模式必须沿用 content_digests 防线。
234
+ # guarded 模式有指纹检查(ID 不变但期望值被改写→拦),full 模式此前
235
+ # 只查 ID 集合与阈值——同 ID 纯内容修改(cases 的 minimum_severity
236
+ # high→low、golden 的 severity high→info)既不增也不减,四项形状检查
237
+ # 全部通过=「保住形状、改掉答案」的 Goodhart 入口敞开(红探针实锤)。
238
+ # 机械判据与模块哲学一致:指纹变了但 ID 集合没变 → 拒。
239
+ # 合法的新增路径(配对加 case+golden)会同时改 ID 集合与指纹,不命中。
240
+ ids_changed = (
241
+ set(before.get("case_ids") or []) != set(after.get("case_ids") or [])
242
+ or set(before.get("golden_case_ids") or [])
243
+ != set(after.get("golden_case_ids") or [])
244
+ )
245
+ digests_changed = (
246
+ before.get("content_digests") != after.get("content_digests")
247
+ )
248
+ if digests_changed and not ids_changed:
249
+ problems.append(
250
+ "断言文件内容被修改但无任何 ID 增删:对既有条目的纯内容编辑"
251
+ "(如改 minimum_severity/severity 期望值)是「保住形状、改掉答案」"
252
+ "的 Goodhart 入口,full 模式同样禁止。新增知识走配对新增路径。"
253
+ )
235
254
  return problems
236
255
 
237
256
 
@@ -24,5 +24,5 @@ open("report.md", "w", encoding="utf-8").write(report.render_markdown())
24
24
  ```
25
25
 
26
26
  ## 5. Maintenance & Verification
27
- - Unit & regression tests for this package are registered in `tests/test_registry.json`.
27
+ - Verification is performed with short-lived tests outside the repository; no persistent `tests/` registry is retained.
28
28
  - Changes to exported interfaces must be synchronized via `python3 scripts/gen_interface_spec.py --package core/report_engine --write`.
@@ -138,10 +138,14 @@ class Attestation:
138
138
  (``verification_executed == total_findings`` 且全通过)才记为实测。
139
139
  零发现(空集统计)、或只验证了其中一部分,都只能标 ``NOT-EXERCISED``。
140
140
  """
141
- measured = (
142
- self.findings_present
143
- and self.verification_executed == self.total_findings
144
- ) or self.mutation_exercised
141
+ # 「零假阳性」必须逐条可证:mutation_exercised 只能提升**已报告发现**
142
+ # 的证据等级,不能在零发现(total_findings==0)时把空集渲染成 PASS。
143
+ # 原写法 `... or self.mutation_exercised` 让「零发现+已变异」得 PASS,
144
+ # 与本方法 docstring「零发现只能标 NOT-EXERCISED」直接矛盾。
145
+ measured = self.findings_present and (
146
+ self.verification_executed == self.total_findings
147
+ or self.mutation_exercised
148
+ )
145
149
  return measured_verdict(measured, True)
146
150
 
147
151
  def negative_control_verdict(self) -> str:
@@ -28,6 +28,7 @@ for _p in (str(_REPO_ROOT), str(_CURRENT_DIR)):
28
28
 
29
29
  from core.agent import agent_eval
30
30
  from core.ledger import finding_confirmation
31
+ from core.infra.build_info import BASE_VERSION
31
32
 
32
33
  # DES-02:以下原语已下沉到 finding_io(finding_lifecycle 也依赖它们,
33
34
  # 原先构成 finding_report <-> finding_lifecycle 双向依赖)。这里再导出,
@@ -38,7 +39,7 @@ from core.ledger.finding_io import ( # noqa: F401 (re-export)
38
39
  write_atomic,
39
40
  )
40
41
 
41
- VERSION = "1.0.0"
42
+ VERSION = BASE_VERSION
42
43
  SARIF_SCHEMA = "https://json.schemastore.org/sarif-2.1.0.json"
43
44
  LEVELS = {"critical": "error", "high": "error", "medium": "warning", "low": "note"}
44
45
 
@@ -9,6 +9,8 @@ from datetime import datetime, timezone
9
9
  from pathlib import Path
10
10
  from typing import Any, Dict, List, Optional
11
11
 
12
+ from core.infra.build_info import BASE_VERSION
13
+
12
14
  #: 报告承认的严重度词表(大写)。 Supervisor 侧用小写,这里统一大写呈现。
13
15
  _KNOWN_SEVERITIES = frozenset({"CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"})
14
16
  #: 严重度 → 处置 SLA(小时)。只用于呈现,不参与门禁判定。
@@ -147,8 +149,8 @@ class VulnerabilityFinding:
147
149
  cwe_title = ""
148
150
  if cwe_id:
149
151
  # 懒导入:sast_bridge 反向依赖 models,模块级导入会成环。
150
- from .sast_bridge import _CWE_TITLES
151
- cwe_title = _CWE_TITLES.get(cwe_id, "")
152
+ from .sast_bridge import CWE_TITLES
153
+ cwe_title = CWE_TITLES.get(cwe_id, "")
152
154
 
153
155
  cvss_score: Optional[float] = None
154
156
  raw_cvss = finding.get("cvss")
@@ -318,12 +320,8 @@ class ReportDataBundle:
318
320
 
319
321
  @classmethod
320
322
  def from_eval_dir(cls, eval_dir: Path | str) -> ReportDataBundle:
321
- """从 evals/oss 目录中的结构化审计收据中自动聚合生成数据总线。"""
323
+ """从 verification/evals/oss 目录中的结构化审计收据中聚合数据总线。"""
322
324
  eval_path = Path(eval_dir).resolve()
323
- if not eval_path.exists() and "/evals/" in str(eval_path):
324
- alt = Path(str(eval_path).replace("/evals/", "/verification/evals/"))
325
- if alt.exists():
326
- eval_path = alt
327
325
  if not eval_path.exists():
328
326
  raise FileNotFoundError(f"Evaluation directory not found: {eval_path}")
329
327
 
@@ -491,7 +489,7 @@ class ReportDataBundle:
491
489
  report_id=f"BUGX-AUDIT-{datetime.now(timezone.utc).strftime('%Y%m%d')}-001",
492
490
  title="BugX 企业级全语种控制流安全审计与攻防渗透综合报告",
493
491
  created_at=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC"),
494
- auditor="BugX Autonomous Security Intelligence & Mutation Engine v1.0.0",
492
+ auditor=f"BugX Autonomous Security Intelligence & Mutation Engine v{BASE_VERSION}",
495
493
  # 范围陈述必须来自收据实况:语言数/靶标数/验证深度,不硬编码
496
494
  # "7 大语言 42 类别"之类的宣传文案(实测单语言收据也照抄全文)。
497
495
  assessment_scope=(
@@ -633,7 +631,7 @@ class ReportDataBundle:
633
631
  ),
634
632
  title=f"BugX 源码级安全审计报告 · {project_root.name}",
635
633
  created_at=datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC"),
636
- auditor="BugX Autonomous Security Intelligence & Mutation Engine v1.0.0",
634
+ auditor=f"BugX Autonomous Security Intelligence & Mutation Engine v{BASE_VERSION}",
637
635
  assessment_scope=f"{scope}(验证深度:白盒裁判与执行探针,未执行变异突防)",
638
636
  metrics=metrics,
639
637
  languages=[],
@@ -35,7 +35,7 @@ _SEVERITY_MAP: Dict[str, str] = {
35
35
  }
36
36
 
37
37
  #: 常见 CWE 的标题。缺失时保留空标题,渲染层输出「未映射 CWE」而不是编号占位。
38
- _CWE_TITLES: Dict[str, str] = {
38
+ CWE_TITLES: Dict[str, str] = {
39
39
  "CWE-22": "Improper Limitation of a Pathname to a Restricted Directory",
40
40
  "CWE-78": "Improper Neutralization of Special Elements used in an OS Command",
41
41
  "CWE-79": "Improper Neutralization of Input During Web Page Generation",
@@ -102,7 +102,7 @@ def finding_from_sast(
102
102
  category=str(item.get("category") or rule_id),
103
103
  severity=severity,
104
104
  cwe_id=cwe_id,
105
- cwe_title=_CWE_TITLES.get(cwe_id, ""),
105
+ cwe_title=CWE_TITLES.get(cwe_id, ""),
106
106
  surface_id=f"{rel_path}:{line_no}" if rel_path else rule_id,
107
107
  target_path=rel_path,
108
108
  description=message,
@@ -10,6 +10,7 @@ import hashlib
10
10
  import html
11
11
  import http.server
12
12
  import json
13
+ import sys
13
14
  import socketserver
14
15
  import tempfile
15
16
  import threading
@@ -128,7 +129,7 @@ class _ProjectRegistry:
128
129
  ),
129
130
  )
130
131
  # 3. evals-oss-ecosystem
131
- evals_path = (self.repo_root / "verification" / "evals" / "oss") if (self.repo_root / "verification" / "evals").is_dir() else (self.repo_root / "evals" / "oss")
132
+ evals_path = self.repo_root / "verification" / "evals" / "oss"
132
133
  self._projects["evals-oss-ecosystem"] = ProjectWorkspaceInfo(
133
134
  id="evals-oss-ecosystem",
134
135
  name="Multi-Language OSS Targets Cluster",
@@ -153,7 +154,7 @@ class _ProjectRegistry:
153
154
  ),
154
155
  )
155
156
  # 4. oss-adm-zip
156
- adm_path = (self.repo_root / "verification" / "evals" / "oss" / "reports" / "adm-zip") if (self.repo_root / "verification" / "evals").is_dir() else (self.repo_root / "evals" / "oss" / "reports" / "adm-zip")
157
+ adm_path = self.repo_root / "verification" / "evals" / "oss" / "reports" / "adm-zip"
157
158
  self._projects["oss-adm-zip"] = ProjectWorkspaceInfo(
158
159
  id="oss-adm-zip",
159
160
  name="OSS adm-zip Deserialization Sandbox",
@@ -550,8 +551,11 @@ class _DualTrackHTTPHandler(http.server.BaseHTTPRequestHandler):
550
551
  self._cached_body = body
551
552
  if self.webui_handler.handle_api_post(self.path, self, body):
552
553
  return
553
- except Exception:
554
- pass
554
+ except Exception as exc:
555
+ # F-RSI-20261115-231:内部错误不得伪装成 404(REST 语义失真)
556
+ # 且零可观测。降级保留(404 响应不变),stderr 留痕供调试。
557
+ print(f"[report_engine] ⚠ API handler 异常(降级 404): "
558
+ f"{type(exc).__name__}: {exc}", file=sys.stderr)
555
559
 
556
560
  if path.startswith("/api/projects/") and path.endswith("/config"):
557
561
  parts = path.strip("/").split("/")
@@ -603,8 +607,11 @@ class _DualTrackHTTPHandler(http.server.BaseHTTPRequestHandler):
603
607
  try:
604
608
  if self.webui_handler.handle_api_delete(self.path, self):
605
609
  return
606
- except Exception:
607
- pass
610
+ except Exception as exc:
611
+ # F-RSI-20261115-231:内部错误不得伪装成 404(REST 语义失真)
612
+ # 且零可观测。降级保留(404 响应不变),stderr 留痕供调试。
613
+ print(f"[report_engine] ⚠ API handler 异常(降级 404): "
614
+ f"{type(exc).__name__}: {exc}", file=sys.stderr)
608
615
  self._send_api_error(404, "Endpoint not found")
609
616
 
610
617
  def do_PATCH(self) -> None:
@@ -614,8 +621,11 @@ class _DualTrackHTTPHandler(http.server.BaseHTTPRequestHandler):
614
621
  body = self.rfile.read(content_length) if content_length > 0 else b""
615
622
  if self.webui_handler.handle_api_patch(self.path, self, body):
616
623
  return
617
- except Exception:
618
- pass
624
+ except Exception as exc:
625
+ # F-RSI-20261115-231:内部错误不得伪装成 404(REST 语义失真)
626
+ # 且零可观测。降级保留(404 响应不变),stderr 留痕供调试。
627
+ print(f"[report_engine] ⚠ API handler 异常(降级 404): "
628
+ f"{type(exc).__name__}: {exc}", file=sys.stderr)
619
629
  self._send_api_error(404, "Endpoint not found")
620
630
 
621
631
  def do_OPTIONS(self) -> None:
@@ -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.1` | **所属分层**: `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
 
@@ -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`.