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
@@ -21,7 +21,6 @@ import json
21
21
  import os
22
22
  import re
23
23
  import shutil
24
- import signal
25
24
  import subprocess
26
25
  import tempfile
27
26
  import threading
@@ -31,6 +30,7 @@ from dataclasses import dataclass
31
30
 
32
31
  from core.secure_atomic import atomic_write_bytes, reject_symlink_components
33
32
  from core.governance.token_budget import estimate_tokens
33
+ from core.runtime.platform_adapter import terminate_process_tree
34
34
 
35
35
 
36
36
  class RunnerAdapterError(ValueError):
@@ -315,43 +315,6 @@ class _OutputCollector:
315
315
  }
316
316
 
317
317
 
318
- def _terminate_process_tree(process: subprocess.Popen[bytes]) -> None:
319
- if os.name == "nt":
320
- try:
321
- process.send_signal(getattr(subprocess, "CTRL_BREAK_EVENT", 1))
322
- except (OSError, ValueError):
323
- pass
324
- try:
325
- process.terminate()
326
- except OSError:
327
- pass
328
- try:
329
- process.wait(timeout=1)
330
- except subprocess.TimeoutExpired:
331
- try:
332
- process.kill()
333
- except OSError:
334
- pass
335
- return
336
- try:
337
- os.killpg(process.pid, signal.SIGTERM)
338
- except (OSError, ProcessLookupError):
339
- try:
340
- process.terminate()
341
- except OSError:
342
- pass
343
- try:
344
- process.wait(timeout=1)
345
- except subprocess.TimeoutExpired:
346
- try:
347
- os.killpg(process.pid, signal.SIGKILL)
348
- except (OSError, ProcessLookupError):
349
- try:
350
- process.kill()
351
- except OSError:
352
- pass
353
-
354
-
355
318
  def _run_bounded(command: list[str], cwd: Path, timeout: float,
356
319
  output_limit: int) -> tuple[int, bool, bool, bytes, dict, bytes, dict]:
357
320
  creationflags = getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0) if os.name == "nt" else 0
@@ -383,12 +346,12 @@ def _run_bounded(command: list[str], cwd: Path, timeout: float,
383
346
  while process.poll() is None:
384
347
  if stdout_collector.exceeded or stderr_collector.exceeded:
385
348
  output_exceeded = True
386
- _terminate_process_tree(process)
349
+ terminate_process_tree(process)
387
350
  break
388
351
  remaining = deadline - time.monotonic()
389
352
  if remaining <= 0:
390
353
  timed_out = True
391
- _terminate_process_tree(process)
354
+ terminate_process_tree(process)
392
355
  break
393
356
  try:
394
357
  process.wait(timeout=min(0.1, remaining))
@@ -396,7 +359,7 @@ def _run_bounded(command: list[str], cwd: Path, timeout: float,
396
359
  continue
397
360
  finally:
398
361
  if timed_out or output_exceeded:
399
- _terminate_process_tree(process)
362
+ terminate_process_tree(process)
400
363
  for reader in readers:
401
364
  reader.join(timeout=2)
402
365
  for stream in (process.stdout, process.stderr):
@@ -383,7 +383,7 @@ class _OutputCollector:
383
383
  }
384
384
 
385
385
 
386
- def _terminate_process_tree(process: subprocess.Popen[bytes]) -> None:
386
+ def terminate_process_tree(process: subprocess.Popen[bytes]) -> None:
387
387
  if os.name == "nt":
388
388
  try:
389
389
  process.send_signal(getattr(subprocess, "CTRL_BREAK_EVENT", 1))
@@ -447,7 +447,7 @@ def _run_bounded(command: list[str], cwd: Path, env: dict[str, str], timeout: fl
447
447
  process.wait(timeout=timeout)
448
448
  except subprocess.TimeoutExpired:
449
449
  timed_out = True
450
- _terminate_process_tree(process)
450
+ terminate_process_tree(process)
451
451
  finally:
452
452
  for reader in readers:
453
453
  reader.join(timeout=2)
@@ -23,6 +23,8 @@ try:
23
23
  except ImportError: # pragma: no cover - standalone source copy fallback
24
24
  bugx_paths = None # type: ignore[assignment]
25
25
 
26
+ from core.infra.build_info import BASE_VERSION
27
+
26
28
  AGENT_DIR = Path(__file__).resolve().parents[1]
27
29
  REPO_ROOT = AGENT_DIR.parent.parent if AGENT_DIR.parent.name == ".bugx" else AGENT_DIR.parent
28
30
  REQUIRED = (
@@ -73,7 +75,7 @@ def _main_package_name(root: Path) -> str | None:
73
75
  """从项目清单(pyproject.toml)推导主包名;拿不到则返回 None。
74
76
 
75
77
  优先取显式声明的 packages 列表(setuptools/poetry),否则回落到
76
- 规范化后的发行名(``bugx-agent`` → ``bugx_agent``)。发行名与导入名
78
+ 规范化后的发行名(``bugx-cli`` → ``bugx_cli``)。发行名与导入名
77
79
  不一致时由导入探测自然失败,守卫按约定静默跳过。
78
80
  """
79
81
  pyproject = root / "pyproject.toml"
@@ -298,7 +300,7 @@ def ensure_prep_record(root: Path | None = None, *, force: bool = False) -> int:
298
300
  commit = commit or "working-tree"
299
301
 
300
302
  metadata_path = AGENT_DIR / "metadata.txt"
301
- version = "1.0.0"
303
+ version = BASE_VERSION
302
304
  if metadata_path.is_file() and not metadata_path.is_symlink():
303
305
  try:
304
306
  for line in metadata_path.read_text(encoding="utf-8").splitlines():
@@ -141,7 +141,8 @@ def _extract_project_profile_info(dot_bugx: Path, root: Path) -> dict[str, Any]:
141
141
  },
142
142
  "quality_and_risk": {
143
143
  "health_grade": risk.get("health_grade", "B"),
144
- "maintainability_index": round(risk.get("maintainability_index", 0.0), 1),
144
+ # mi=None 表示"未测得"(解析降级),保守显示 0.0(F-RSI-20261115-276)
145
+ "maintainability_index": round(risk.get("maintainability_index") or 0.0, 1),
145
146
  "avg_cyclomatic_complexity": round(risk.get("avg_cyclomatic_complexity", 0.0), 1),
146
147
  "avg_cognitive_complexity": round(risk.get("avg_cognitive_complexity", 0.0), 1),
147
148
  "duplication_percentage": round(risk.get("duplication_percentage", 0.0), 1),
@@ -59,7 +59,7 @@ from dataclasses import asdict, dataclass, field
59
59
  from pathlib import Path
60
60
 
61
61
  REPO_ROOT = Path(__file__).resolve().parents[2]
62
- SCENARIOS_ROOT = (REPO_ROOT / "verification" / "evals" / "scenarios") if (REPO_ROOT / "verification" / "evals").is_dir() else (REPO_ROOT / "evals" / "scenarios")
62
+ SCENARIOS_ROOT = REPO_ROOT / "verification" / "evals" / "scenarios"
63
63
  RECEIPT_SCHEMA = 1
64
64
 
65
65
  #: 级别定义。``runner`` 说明该级由谁执行:本模块或外部组件。
@@ -131,7 +131,17 @@ def _run(argv: list[str], *, cwd: Path, timeout: float = 120.0,
131
131
  merged = {**os.environ, **(env or {})}
132
132
  # 仓库直跑 CLI:子进程 cwd 是场景工作区,须显式指回仓库根;
133
133
  # HOME 隔离:评测的全局引擎读写落在一次性沙箱,不碰真实 ~/.bugx/。
134
- merged["PYTHONPATH"] = str(_repo_root())
134
+ repo_root = _repo_root()
135
+ # 与仓库 wrapper(interfaces/bin/bugx.js)保持同一包入口,避免
136
+ # ``interfaces.cli.bugx_cli`` 的相对包名与内部绝对导入 ``bugx_cli``
137
+ # 分裂,误加载 site-packages 中的旧快照。
138
+ merged["PYTHONPATH"] = os.pathsep.join(
139
+ (str(repo_root / "interfaces" / "cli"), str(repo_root)),
140
+ )
141
+ # L3 等场景验证当前 checkout;不让已安装的旧引擎成为量具。
142
+ merged["BUGX_DEV_MODE"] = "1"
143
+ # 源码树里的版本声明是构建模板;开发态启动门禁需要同一解析值。
144
+ merged["BUGX_VERSION"] = os.environ.get("BUGX_VERSION", "0.1.2")
135
145
  merged["HOME"] = str(_sandbox_home())
136
146
  try:
137
147
  proc = subprocess.run(
@@ -157,6 +167,26 @@ def _materialize(level_dir: Path, dest: Path) -> Path:
157
167
  return dest
158
168
 
159
169
 
170
+ def _init_git_baseline(work: Path) -> tuple[int, str]:
171
+ """为需要真实项目基线的场景创建一次性 Git 仓库。"""
172
+ commands = (
173
+ ["git", "init", "-q", "."],
174
+ ["git", "config", "user.name", "BugX Scenario"],
175
+ ["git", "config", "user.email", "bugx-scenario@invalid"],
176
+ ["git", "add", "-A"],
177
+ [
178
+ "git", "-c", "user.name=BugX Scenario",
179
+ "-c", "user.email=bugx-scenario@invalid",
180
+ "commit", "-qm", "scenario fixture",
181
+ ],
182
+ )
183
+ for argv in commands:
184
+ rc, out, err = _run(argv, cwd=work, timeout=60.0)
185
+ if rc != 0:
186
+ return rc, (err or out)[-300:]
187
+ return 0, ""
188
+
189
+
160
190
  def _repo_root() -> Path:
161
191
  """引擎仓根(core/bugx.md 所在目录的父级)。"""
162
192
  return Path(__file__).resolve().parents[2]
@@ -183,7 +213,7 @@ def _bugx_argv() -> list[str]:
183
213
  快照 CLI 落后仓库多个 build,用它评测仓库修复等于拿旧量具测新代码
184
214
  (实测:快照 430 对仓库 434 的 init 在三个级别全部「拒绝降级」)。
185
215
  """
186
- return [sys.executable, "-m", "interfaces.cli.bugx_cli.cli"]
216
+ return [sys.executable, "-m", "bugx_cli.cli"]
187
217
 
188
218
 
189
219
  #: 覆盖清单的两种真实形态。写成两种不是「兼容性懒惰」——实测 2026-11-03:
@@ -301,8 +331,14 @@ def run_l3_multilang(root: Path, work: Path) -> LevelResult:
301
331
  """
302
332
  result = LevelResult(level="L3", name="多语言", ok=True)
303
333
  started = time.monotonic()
304
- rc, out, err = _run([*_bugx_argv(), "init", "--root", ".", "--cloud-sync", "local"],
305
- cwd=work, timeout=180.0)
334
+ git_rc, git_detail = _init_git_baseline(work)
335
+ if git_rc != 0:
336
+ rc, out, err = git_rc, "", f"Git 基线初始化失败:{git_detail}"
337
+ else:
338
+ rc, out, err = _run(
339
+ [*_bugx_argv(), "init", "--root", ".", "--cloud-sync", "local"],
340
+ cwd=work, timeout=180.0,
341
+ )
306
342
  result.add("init 成功", rc == 0, (err or out)[-300:] if rc != 0 else "")
307
343
  expected = {".py": "python", ".js": "javascript", ".go": "go"}
308
344
  present = {ext: kind for ext, kind in expected.items()
@@ -502,6 +538,10 @@ def run_l4_known_vulns(root: Path, work: Path) -> LevelResult:
502
538
  ("发现率:", "recall"), ("精确率:", "precision"),
503
539
  ("证据有效率:", "evidence_validity"), ("可复现率:", "reproducibility"),
504
540
  ("综合质量分:", "quality"),
541
+ # F-022 管线接线:评测集内嵌 feature baseline 时 completeness
542
+ # 维度随 agent_eval 输出流转(无 baseline 时这些行不存在,跳过)
543
+ ("完备性召回:", "completeness_recall"),
544
+ ("完备性精确:", "completeness_precision"),
505
545
  ):
506
546
  if line.startswith(label):
507
547
  value = line[len(label):].strip()
@@ -510,9 +550,11 @@ def run_l4_known_vulns(root: Path, work: Path) -> LevelResult:
510
550
  parts = line[len("耗时/Token:"):].strip().split("/")
511
551
  metrics["duration"] = parts[0].strip()
512
552
  metrics["tokens"] = parts[-1].strip() if len(parts) > 1 else None
553
+ recall = metrics.get("recall")
513
554
  result.add(
514
- "关键指标可解析", bool(metrics.get("recall")),
515
- f"未能从输出解析发现率:{combined[-200:]}",
555
+ "关键指标可解析", bool(recall),
556
+ (f"发现率:{recall}" if recall
557
+ else f"未能从输出解析发现率:{combined[-200:]}"),
516
558
  )
517
559
  result.duration_seconds = time.monotonic() - started
518
560
  result.metrics = metrics
@@ -641,7 +683,7 @@ BUILTIN_RUNNERS = {
641
683
 
642
684
 
643
685
  #: 在**仓库根**执行、不需要临时工作区的级别。L4/L6 评的是仓库自带的评测集与
644
- #: 故障矩阵,物化到临时目录反而会让它们找不到 ``evals/`` 和 ``scripts/``。
686
+ #: 故障矩阵,物化到临时目录反而会让它们找不到 ``verification/evals/`` 和 ``scripts/``。
645
687
  REPO_LEVELS = frozenset({"L4", "L6", "L7"})
646
688
 
647
689
 
@@ -24,6 +24,8 @@ from datetime import datetime, timezone
24
24
  from pathlib import Path
25
25
  from typing import Any, Mapping, Sequence
26
26
 
27
+ from core.infra.build_info import BASE_VERSION
28
+
27
29
  _CORE_DIR = Path(__file__).resolve().parent.parent if Path(__file__).resolve().parent.name == "skills" else Path(__file__).resolve().parent
28
30
  if str(_CORE_DIR) not in sys.path:
29
31
  sys.path.insert(0, str(_CORE_DIR))
@@ -31,7 +33,7 @@ if str(_CORE_DIR) not in sys.path:
31
33
  JSONRPC_VERSION = "2.0"
32
34
  MCP_PROTOCOL_VERSION = "2024-11-05"
33
35
  SERVER_NAME = "bugx-docs"
34
- SERVER_VERSION = "1.0.0"
36
+ SERVER_VERSION = BASE_VERSION
35
37
  MAX_FILE_BYTES = 1_000_000
36
38
  MAX_FILES = 500
37
39
  MAX_RESULT_BYTES = 12_000
@@ -37,6 +37,8 @@ import threading
37
37
  import time
38
38
  from pathlib import Path
39
39
  from typing import Any, Callable, Mapping, Sequence
40
+
41
+ from core.infra.build_info import BASE_VERSION
40
42
  from urllib.parse import parse_qs, urlparse
41
43
 
42
44
  try:
@@ -171,7 +173,7 @@ def _i18n_prompt(key: str, fallback: str, locale: str | None = None, **kwargs: A
171
173
 
172
174
  MCP_PROTOCOL_VERSION = "2024-11-05"
173
175
  SERVER_NAME = "bugx-supervisor"
174
- SERVER_VERSION = "1.0.0"
176
+ SERVER_VERSION = BASE_VERSION
175
177
  JSONRPC_VERSION = "2.0"
176
178
  # A CLI ``pre`` command is short-lived, while the host MCP stdio process owns
177
179
  # the Session afterwards. Keep the interval well below the time it takes for
@@ -220,8 +222,13 @@ _ControllerLease = _cl._ControllerLease
220
222
  _host_session_heartbeat_once = _cl._host_session_heartbeat_once
221
223
  _host_session_heartbeat_loop = _cl._host_session_heartbeat_loop
222
224
 
225
+ # DEF-2:允许从 McpProtocolError.mcp_error_data 透传到错误回包的结构化字段。
226
+ # 白名单而非全量合并——防止任意异常的可变属性污染 isError 回包的交互门禁字段。
227
+ _MCP_ERROR_DATA_ALLOWED_KEYS = frozenset({"evidence_feedback"})
228
+
229
+
223
230
  def _error_payload(error: BaseException) -> dict[str, object]:
224
- return {
231
+ payload: dict[str, object] = {
225
232
  "error_type": type(error).__name__,
226
233
  "message": str(error) or type(error).__name__,
227
234
  "error_code": "MCP_CALL_FAILED",
@@ -233,6 +240,16 @@ def _error_payload(error: BaseException) -> dict[str, object]:
233
240
  ),
234
241
  "choices": ["retry", "fallback", "later"],
235
242
  }
243
+ # DEF-2 残余缺口:McpProtocolError 携带的结构化拒绝原因(如逐项
244
+ # violations + correct_sample + retry_prompt)随回包 data 透传,宿主/
245
+ # 模型无需从一行纯文本里猜自纠指令。仅白名单已知结构化字段,避免任意
246
+ # 异常的可变属性污染回包;核心交互字段始终以标准值为准不可覆盖。
247
+ extra = getattr(error, "mcp_error_data", None)
248
+ if isinstance(extra, dict):
249
+ for key, value in extra.items():
250
+ if key in _MCP_ERROR_DATA_ALLOWED_KEYS:
251
+ payload[key] = value
252
+ return payload
236
253
 
237
254
 
238
255
  def _call_failure_data(operation: object, error: BaseException) -> dict[str, object]:
@@ -880,6 +897,16 @@ class BugxMcpService:
880
897
  if allowed_roles is None:
881
898
  raise McpProtocolError(_i18n_exc("mcp.unknown_tool", f"未知工具: {name}", name=name))
882
899
  name = resolved_name
900
+ # F-RSI-20261110-039:worker 通道强制 DOC-241 A5 暴露白名单。
901
+ # 13 个工具在 _TOOL_ROLES 声明 worker-only(角色所有权)但被
902
+ # _WORKER_CORE_TOOL_NAMES 从 tools/list 隐藏(暴露契约)——两契约
903
+ # 缺口造成"隐藏但可调"(红探针实测哨兵执行)。角色所有权管"谁能
904
+ # 调",暴露白名单管"worker 该调什么"——分派层以暴露契约收口。
905
+ if self.role == "worker" and name not in _WORKER_CORE_TOOL_NAMES:
906
+ raise McpProtocolError(
907
+ f"{name} 不在 Worker 通道工具白名单内"
908
+ "(DOC-241 A5:Worker 仅暴露 10 个核心原子工具)"
909
+ )
883
910
  call_arguments = dict(arguments)
884
911
  if self.role not in allowed_roles:
885
912
  declared_role = call_arguments.get("caller_role") or self.role
@@ -174,7 +174,7 @@ def check(path: Path = KB_FILE, today: dt.date | None = None,
174
174
  try:
175
175
  legacy = Path(path).parent / "docs" / Path(path).name
176
176
  if legacy.is_file():
177
- hint = (f"(检测到旧 wheel 布局 {legacy}——升级 bugx_agent 或"
177
+ hint = (f"(检测到旧 wheel 布局 {legacy}——升级 bugx-cli 或"
178
178
  f" cp 到 {Path(path)} 后重试)")
179
179
  except OSError:
180
180
  pass
@@ -1,6 +1,6 @@
1
1
  # BugX Supervisor (并发协调与智能体调度仲裁中心)
2
2
 
3
- > **版本契约**: `1.0.0` | **所属分层**: `Layer 3: 并发协调、智能体编排与账本`
3
+ > **版本契约**: `0.1.2` | **所属分层**: `Layer 3: 并发协调、智能体编排与账本`
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.supervisor import claim_unit, submit_checkpoint
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/supervisor --write`.