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
@@ -13,6 +13,7 @@ from pathlib import Path
13
13
  from typing import Any, Callable, Mapping, Sequence
14
14
 
15
15
  from core.runtime import bugx_logging
16
+ from core.infra.build_info import BASE_VERSION
16
17
  import core.bugx_paths as bugx_paths
17
18
  from core.mcp_handlers import (
18
19
  MAX_MCP_REQUEST_BYTES,
@@ -24,7 +25,7 @@ from core.mcp_handlers import (
24
25
 
25
26
  MCP_PROTOCOL_VERSION = "2024-11-05"
26
27
  SERVER_NAME = "bugx-supervisor"
27
- SERVER_VERSION = "1.0.0"
28
+ SERVER_VERSION = BASE_VERSION
28
29
  JSONRPC_VERSION = "2.0"
29
30
  HOST_SESSION_HEARTBEAT_INTERVAL_SECONDS = 5.0
30
31
  MCP_ROLES = {"host", "worker"}
@@ -122,6 +123,9 @@ def serve(
122
123
 
123
124
  channel_idle_monitor_func = _get_bms_attr("_channel_idle_monitor_loop", _cl._channel_idle_monitor_loop)
124
125
  channel_stop = threading.Event()
126
+ # 第四批修复(收尾空转治理):记录启动时的父进程 PID,供孤儿 owner
127
+ # 快速自释放判定(宿主进程死亡后 controller 不再空转满 idle 超时)。
128
+ initial_parent_pid = os.getppid()
125
129
  channel_monitor = threading.Thread(
126
130
  target=channel_idle_monitor_func,
127
131
  args=(service, activity, channel_stop),
@@ -129,6 +133,7 @@ def serve(
129
133
  "lease": controller_lease,
130
134
  "interval": idle_interval,
131
135
  "exit_hook": exit_hook,
136
+ "initial_parent_pid": initial_parent_pid,
132
137
  },
133
138
  name=f"bugx-{role}-channel-idle-monitor",
134
139
  daemon=True,
@@ -468,6 +468,11 @@ def handle_supervisor_confirm_finding(
468
468
  try:
469
469
  # L1-ADV-D1:裁决证据由引擎核验 receipt 派生并自检,缺料即 fail-closed;
470
470
  # handler 不再自己写 confirmation(旧实现只写 {state,reason,at} 必然堵死 post)。
471
+ severity = arguments.get("severity")
472
+ if severity is not None and (
473
+ not isinstance(severity, str) or not severity.strip()
474
+ ):
475
+ raise McpProtocolError("severity 必须是非空字符串", code=-32602)
471
476
  supervisor.confirm_finding(
472
477
  finding=finding_id.strip(),
473
478
  decision=decision,
@@ -478,6 +483,7 @@ def handle_supervisor_confirm_finding(
478
483
  ),
479
484
  root_cause_verified=root_cause_verified,
480
485
  remediation=remediation,
486
+ severity=severity,
481
487
  oracle=oracle,
482
488
  target_platform=(
483
489
  target_platform.strip() if isinstance(target_platform, str) else None
@@ -780,17 +786,30 @@ def handle_supervisor_claim(service: Any, arguments: Mapping[str, object]) -> di
780
786
  # 旧实现吞掉 start_worker 异常并返回 claimed,随后 start timeout 回收 claim,
781
787
  # 子代理只能在数百秒后发现 checkpoint 不可提交。调用方必须紧接 worker_start;
782
788
  # 本返回明确 execution_state=claimed,禁止伪装 running。
783
- result["epoch"] = 1
789
+ # F-RSI-20261110-043:报告真实调度代数——claim 序列化产物含
790
+ # scheduler_epoch(rebind_target 每次 +1),submit_finding 的
791
+ # STALE_LEASE 校验按它比对;硬编码 1 会让 rebind 后(epoch>=2)的
792
+ # worker 按返回值提交必撞 STALE_LEASE(1.0.0 时代补丁 12 残留,
793
+ # 其原子启动块已被 claim!=started 契约移除)。
794
+ result["epoch"] = result.get("scheduler_epoch", 1)
784
795
  result["start_required"] = True
785
796
  return result
786
797
 
787
798
 
788
799
  def handle_supervisor_reopen_finding(service: Any, arguments: Mapping[str, object]) -> dict[str, object]:
789
800
  service._require_role(arguments, "bugx_supervisor_reopen_finding", "host")
790
- return project_state(service.get_supervisor().reopen_finding(
791
- arguments.get("finding_id"), reason=arguments.get("reason"),
792
- expected_revision=arguments.get("expected_revision"),
793
- ))
801
+ # F-RSI-20261110-040:与 confirm_finding 同契约——Supervisor 层校验失败
802
+ # (InvalidCheckpoint 是 SupervisorError/RuntimeError,非 ValueError)转
803
+ # -32602 结构化拒绝;原实现原样穿透落 rpc 泛化分支(无错误码)。
804
+ try:
805
+ return project_state(service.get_supervisor().reopen_finding(
806
+ arguments.get("finding_id"), reason=arguments.get("reason"),
807
+ expected_revision=arguments.get("expected_revision"),
808
+ ))
809
+ except audit_supervisor.SupervisorError as exc:
810
+ raise McpProtocolError(str(exc), code=-32602) from exc
811
+ except ValueError as exc:
812
+ raise McpProtocolError(str(exc), code=-32602) from exc
794
813
 
795
814
 
796
815
  def handle_supervisor_admit_business(service: Any, arguments: Mapping[str, object]) -> dict[str, object]:
@@ -927,7 +946,14 @@ def handle_supervisor_checkpoint(service: Any, arguments: Mapping[str, object])
927
946
  }
928
947
  return project_state(state, coverage_delta=delta)
929
948
  except audit_supervisor.SupervisorError as exc:
930
- raise McpProtocolError(str(exc), code=-32602) from exc
949
+ # DEF-2 残余缺口:checkpoint_pipeline 在 evidence 校验拒绝时把逐项
950
+ # violations + correct_sample + retry_prompt 挂在异常的 evidence_feedback
951
+ # 上;旧实现只转 str(exc),宿主拿到一行文本无法自纠。透传结构化字段到
952
+ # McpProtocolError.data,由 rpc_server 回包 data 携带,与 finalize CLI
953
+ # 通道(worker_checkpoint.main 的 payload)形成对称。
954
+ feedback = getattr(exc, "evidence_feedback", None)
955
+ error_data = {"evidence_feedback": feedback} if isinstance(feedback, dict) and feedback else None
956
+ raise McpProtocolError(str(exc), code=-32602, data=error_data) from exc
931
957
 
932
958
 
933
959
  def handle_supervisor_salvage_checkpoint(service: Any, arguments: Mapping[str, object]) -> dict[str, object]:
@@ -943,6 +943,21 @@ def _build_tool_table() -> tuple[tuple[frozenset[str], dict[str, object]], ...]:
943
943
  + " 重试必须复用同一 checkpoint_id。"
944
944
  )
945
945
  break
946
+ # F-RSI-20261110-048:角色专属工具的 caller_role 声明由 roles 派生
947
+ # 补齐(构建期自愈)。此前 11 个 worker/host 专属工具的 inputSchema
948
+ # 缺 caller_role 属性——schema 不告诉调用方该显式声明角色,与
949
+ # submit_finding 范式(required + enum)漂移。共享工具免声明
950
+ # (通道缺省回退即正确语义)。
951
+ for roles, definition in table:
952
+ schema = definition.get("inputSchema")
953
+ if not isinstance(schema, dict):
954
+ continue
955
+ props = schema.setdefault("properties", {})
956
+ if roles != _SHARED_ROLES and "caller_role" not in props:
957
+ props["caller_role"] = {"type": "string", "enum": sorted(roles)}
958
+ required = schema.setdefault("required", [])
959
+ if "caller_role" not in required:
960
+ required.insert(0, "caller_role")
946
961
  return table
947
962
 
948
963
 
@@ -3,7 +3,6 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import os
6
- import re
7
6
  import shutil
8
7
  import subprocess
9
8
  import sys
@@ -137,30 +136,6 @@ def _python_version_of(executable: str) -> str:
137
136
  return version if completed.returncode == 0 else ""
138
137
 
139
138
 
140
- def _normalize_python_spec(spec: str) -> str:
141
- """把 ``"3.12"`` 归一化为 ``"==3.12"``(前缀匹配);约束原样返回。"""
142
- text = str(spec).strip()
143
- if re.fullmatch(r"\d+\.\d+", text):
144
- return f"=={text}"
145
- return text
146
-
147
-
148
- def _allowed_minors(spec: str) -> list[tuple[int, int]]:
149
- """枚举满足约束的 ``(major, minor)`` 候选,升序。
150
-
151
- 用于"本机该找哪些解释器"以及"需要自愈时该装哪个版本";
152
- 上界来自约束本身(如 ``<3.14`` ⇒ 最高 3.13),因此**不写死**小版本。
153
- """
154
- normalized = _normalize_python_spec(spec)
155
- results: list[tuple[int, int]] = []
156
- for major in (3,):
157
- for minor in range(8, 20):
158
- ok, _detail = check_python_requires(normalized, (major, minor, 0))
159
- if ok:
160
- results.append((major, minor))
161
- return results
162
-
163
-
164
139
  def _uv_managed_python(minor_spec: str) -> str:
165
140
  """用 uv **自愈**获取指定 ``X.Y`` 解释器(本地已有则复用,缺失才联网安装)。
166
141
 
@@ -499,19 +474,6 @@ def _resolve_pypi_entry(staging: Path, env_id: str, entry_name: str) -> str:
499
474
  return candidate.relative_to(staging).as_posix()
500
475
 
501
476
 
502
- def _read_pyvenv_version(config_path: Path) -> str:
503
- """从 venv 的 ``pyvenv.cfg`` 读取解释器版本(``version_info = X.Y.Z``)。"""
504
- try:
505
- text = config_path.read_text(encoding="utf-8", errors="ignore")
506
- except OSError:
507
- return ""
508
- for line in text.splitlines():
509
- key, _, value = line.partition("=")
510
- if key.strip() in ("version_info", "version"):
511
- return value.strip()
512
- return ""
513
-
514
-
515
477
  def _check_venv_shebang(
516
478
  runtime_dir: Path, entry_path: Path, entry_rel: str,
517
479
  published_dir: Path | None = None,
@@ -277,58 +277,6 @@ def load_lock(lock_path: Path) -> dict:
277
277
  return lock
278
278
 
279
279
 
280
- def parse_python_requires(spec: str) -> tuple[tuple[str, tuple[int, ...]], ...]:
281
- """解析 ``python_requires``(支持 ``>=``/``>``/``<=``/``<``/``==``/``!=`` 逗号列表)。
282
-
283
- **fail-closed**:任何无法解析的片段直接抛 ``McpRuntimeError``(DOC-235 设计项 3)。
284
- """
285
- clauses: list[tuple[str, tuple[int, ...]]] = []
286
- for raw in str(spec).split(","):
287
- clause = raw.strip()
288
- if not clause:
289
- continue
290
- operator = ""
291
- for candidate in PYTHON_REQUIRES_OPERATORS:
292
- if clause.startswith(candidate):
293
- operator = candidate
294
- break
295
- if not operator:
296
- raise McpRuntimeError(f"python_requires 片段缺少合法运算符: {clause!r}")
297
- version = clause[len(operator):].strip()
298
- parts = version.split(".")
299
- if not parts or any(not part.isdigit() for part in parts):
300
- raise McpRuntimeError(f"python_requires 版本号非法: {version!r}")
301
- clauses.append((operator, tuple(int(part) for part in parts)))
302
- if not clauses:
303
- raise McpRuntimeError("python_requires 不能为空")
304
- return tuple(clauses)
305
-
306
-
307
- def check_python_requires(
308
- spec: str, version: tuple[int, ...] | None = None,
309
- ) -> tuple[bool, str]:
310
- """校验解释器版本是否满足 ``python_requires``;返回 (是否满足, 说明)。"""
311
- clauses = parse_python_requires(spec)
312
- current = tuple(version) if version is not None else tuple(sys.version_info[:3])
313
- shown = ".".join(str(item) for item in current)
314
- for operator, wanted in clauses:
315
- have = current[: len(wanted)]
316
- satisfied = {
317
- ">=": have >= wanted,
318
- ">": have > wanted,
319
- "<=": have <= wanted,
320
- "<": have < wanted,
321
- "==": have == wanted,
322
- "!=": have != wanted,
323
- }[operator]
324
- if not satisfied:
325
- return False, (
326
- f"python_requires {spec!r} 不满足:当前解释器 {shown} "
327
- f"(lock 由更高版本解析,禁止降级解析)"
328
- )
329
- return True, f"python_requires {spec!r} 满足(当前 {shown})"
330
-
331
-
332
280
  def lock_hash(lock: dict) -> str:
333
281
  return sha256_hex(canonical_json_bytes(lock))
334
282
 
package/core/metadata.txt CHANGED
@@ -1,5 +1,4 @@
1
- bugx_version: "1.0.0"
1
+ bugx_version: "0.1.1"
2
2
  bugx_channel: "stable"
3
3
  bugx_marker: "stable"
4
- build_id: 468
5
-
4
+ build_id: 9
@@ -1,6 +1,6 @@
1
1
  # BugX Planning & Slicing 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
 
@@ -115,7 +115,9 @@ class DomainSpecializedRouter:
115
115
  if any(kw in lowered for kw in ("android", "apk", "manifest.xml", ".kt", "gradle")):
116
116
  return "mobile_android", ("android_probe",)
117
117
  if any(kw in lowered for kw in ("ios", ".swift", "info.plist", "macho", "xcode")):
118
- return "mobile_ios", ("ios_probe",)
118
+ # 路由到 probe_registry 真实注册名 ios_binary(ios_binary_probe.py),
119
+ # 不再产出幽灵名 ios_probe(该名在任何注册表/CLI 中均不存在)。
120
+ return "mobile_ios", ("ios_binary",)
119
121
 
120
122
  # C. Web 动态端点与前端页面
121
123
  if any(kw in lowered for kw in ("web", "front", "html", "page", "route", "view")):
@@ -131,7 +133,7 @@ class DomainSpecializedRouter:
131
133
  if "android" in frameworks or "mobile" in forms:
132
134
  return "mobile_android", ("android_probe",)
133
135
  if "ios" in frameworks:
134
- return "mobile_ios", ("ios_probe",)
136
+ return "mobile_ios", ("ios_binary",)
135
137
  if "web" in forms or "ui" in surfaces:
136
138
  return "web", ("web_dynamic_probe",)
137
139
  if "embedded" in forms:
@@ -82,6 +82,139 @@ WEAK_TRANSFORMS = [
82
82
  r"\.toLowerCase\(\)", r"\.lower\(\)", r"\(string\)", r"\.to_s\b",
83
83
  ]
84
84
 
85
+ # 字符串字面量起始引号(三引号优先,单双引号其次)。
86
+ # 反引号(JS/TS 模板字面量)**不在**此列:``${host}`` 的插值必须能被折叠。
87
+ _LITERAL_QUOTES = ('"""', "'''", '"', "'")
88
+
89
+
90
+ def _literal_end(expr: str, start: int, quote: str) -> int:
91
+ """从 ``start`` 起找 ``quote`` 的收尾位置(返回结束后的下标),找不到返回 -1。"""
92
+ index = start
93
+ while index < len(expr):
94
+ char = expr[index]
95
+ if char == "\\":
96
+ index += 2
97
+ continue
98
+ if expr.startswith(quote, index):
99
+ return index + len(quote)
100
+ # 单行引号不跨行;跨行说明解析器给的实参文本本身不完整,交由调用方兜底。
101
+ if len(quote) == 1 and char == "\n":
102
+ return -1
103
+ index += 1
104
+ return -1
105
+
106
+
107
+ def _matching_brace(text: str, start: int) -> int:
108
+ """``text[start] == '{'``,返回与之配对的 ``}`` 之后的下标,找不到返回 -1。"""
109
+ depth = 0
110
+ index = start
111
+ while index < len(text):
112
+ char = text[index]
113
+ if char in "\"'":
114
+ end = _literal_end(text, index + 1, char)
115
+ if end < 0:
116
+ return -1
117
+ index = end
118
+ continue
119
+ if char == "\\":
120
+ index += 2
121
+ continue
122
+ if char == "{":
123
+ depth += 1
124
+ elif char == "}":
125
+ depth -= 1
126
+ if depth == 0:
127
+ return index + 1
128
+ index += 1
129
+ return -1
130
+
131
+
132
+ def _fstring_body_spans(body: str, depth: int = 0) -> list[tuple[bool, str]]:
133
+ """f-string 体内:``{...}`` 是代码(插值),其余是字面量文本。
134
+
135
+ ``{{`` / ``}}`` 是转义后的普通花括号,按字面量处理。
136
+ """
137
+ spans: list[tuple[bool, str]] = []
138
+ buffer: list[str] = []
139
+ index = 0
140
+ while index < len(body):
141
+ char = body[index]
142
+ if char in "{}" and index + 1 < len(body) and body[index + 1] == char:
143
+ buffer.append(char * 2)
144
+ index += 2
145
+ continue
146
+ if char != "{":
147
+ buffer.append(char)
148
+ index += 1
149
+ continue
150
+ end = _matching_brace(body, index)
151
+ if end < 0:
152
+ buffer.append(body[index:])
153
+ break
154
+ if buffer:
155
+ spans.append((False, "".join(buffer)))
156
+ buffer = []
157
+ spans.append((True, "{"))
158
+ spans.extend(_split_code_and_literals(body[index + 1:end - 1], depth + 1))
159
+ spans.append((True, "}"))
160
+ index = end
161
+ if buffer:
162
+ spans.append((False, "".join(buffer)))
163
+ return spans
164
+
165
+
166
+ def _split_code_and_literals(expr: str, depth: int = 0) -> list[tuple[bool, str]]:
167
+ """把实参文本切成 ``(是否代码, 片段)``。
168
+
169
+ 普通字符串字面量(``"..."``、``'...'``、三引号)内部**不是代码**,变量折叠
170
+ 不得进入;f-string 的**字面量文本**同样不是代码,只有 ``{...}`` 插值段是。
171
+ 反引号模板字面量按代码处理(``${host}`` 必须能被折叠)。
172
+ 引号未闭合时退回"整段都是代码",保持与旧实现一致的兜底行为。
173
+ """
174
+ spans: list[tuple[bool, str]] = []
175
+ buffer: list[str] = []
176
+ index = 0
177
+ while index < len(expr):
178
+ char = expr[index]
179
+ if char not in "\"'":
180
+ buffer.append(char)
181
+ index += 1
182
+ continue
183
+
184
+ # 紧邻引号的标识符字母就是字符串前缀(f / r / b / u / rf ...)。
185
+ prefix_start = index
186
+ while prefix_start > 0 and (expr[prefix_start - 1].isalnum() or expr[prefix_start - 1] == "_"):
187
+ prefix_start -= 1
188
+ prefix = expr[prefix_start:index].lower()
189
+
190
+ quote = next((q for q in _LITERAL_QUOTES if expr.startswith(q, index)), char)
191
+ end = _literal_end(expr, index + len(quote), quote)
192
+ if end < 0:
193
+ buffer.append(expr[index:])
194
+ break
195
+ if "f" in prefix and depth < 3:
196
+ # f-string:插值是代码,必须继续参与折叠(SQLI/SSRF 的插值判据依赖它);
197
+ # 但字面量文本不是代码,不能被同名变量替换。
198
+ buffer.append(quote)
199
+ spans.append((True, "".join(buffer)))
200
+ buffer = []
201
+ spans.extend(
202
+ _fstring_body_spans(expr[index + len(quote):end - len(quote)], depth)
203
+ )
204
+ spans.append((True, quote))
205
+ index = end
206
+ continue
207
+
208
+ if buffer:
209
+ spans.append((True, "".join(buffer)))
210
+ buffer = []
211
+ spans.append((False, expr[index:end]))
212
+ index = end
213
+
214
+ if buffer:
215
+ spans.append((True, "".join(buffer)))
216
+ return spans
217
+
85
218
 
86
219
  @dataclass
87
220
  class FlowVariable:
@@ -180,7 +313,14 @@ class DynamicFlowAnalyzer:
180
313
  parts.append(val)
181
314
  if not c:
182
315
  all_const = False
183
- return "".join(parts), all_const
316
+ folded = "".join(parts)
317
+ # 含插值的 f-string 必须保留 ``f`` 前缀:折叠只做「值归一化」,不能
318
+ # 把动态插值抹平成普通字面量。下游的 SQLi/CMDi 规则靠「这是不是动态
319
+ # 拼出来的串」判定,前缀一丢,`execute(query)` 里 query 的插值痕迹
320
+ # 就彻底不可见(实测靶场种子 ① 因此漏检)。
321
+ if not all_const:
322
+ return 'f"' + folded + '"', False
323
+ return folded, all_const
184
324
 
185
325
  # FormattedValue
186
326
  if isinstance(node, ast.FormattedValue):
@@ -275,6 +415,56 @@ class DynamicFlowAnalyzer:
275
415
  return m_pure.group(1), True
276
416
  return curr, False
277
417
 
418
+ # 顶层关键字实参的起点(排除 ``==`` 比较)。
419
+ _KWARG_START_RE = re.compile(r",\s*[A-Za-z_][A-Za-z0-9_]*\s*=(?!=)")
420
+
421
+ def payload_portion(self, args: str) -> str:
422
+ """取第一个关键字实参之前的部分——注入类规则的载荷面。"""
423
+ if not args:
424
+ return args
425
+ match = self._KWARG_START_RE.search(args)
426
+ return args[: match.start()] if match else args
427
+
428
+ # 标识符边界:不替换更长标识符的前缀,也不替换关键字实参名(``timeout=``)。
429
+ _IDENT_RE = re.compile(
430
+ r"(?<![A-Za-z0-9_$])([A-Za-z_$][A-Za-z0-9_$]*)(?![\w$])(?!\s*=(?!=))"
431
+ )
432
+
433
+ def _substitute_vars_once(
434
+ self, expr: str, env: dict[str, FlowVariable]
435
+ ) -> tuple[str, bool]:
436
+ """在表达式上**单次**替换变量引用,替换结果不再参与匹配。
437
+
438
+ 返回 ``(替换后表达式, 是否引用了受污染变量)``。
439
+
440
+ 替换只在**代码面**上做:普通字符串字面量(含三引号)内部不是代码,
441
+ 按标识符直接替换会**凭空篡改分析对象**——实测 ``help="... cloud sync"``
442
+ 里的 ``cloud`` 被同名变量替换成 ``subparsers.add_parser('cloud')``,
443
+ 静态 DDL 里的列名被替换成 f-string,整段实参变成源码里不存在的东西。
444
+ 全仓 317 个调用点存在这种改写。
445
+
446
+ f-string / 模板字面量(``f"..."``、``rf'...'``、JS 反引号)**整体仍按
447
+ 代码处理**:``f"SELECT * FROM {table}"`` 的 ``{table}``、``${host}``
448
+ 必须能被折叠还原,SQLI 与 SSRF 的插值判据都建立在折叠后的文本上。
449
+ """
450
+ if not expr or not env:
451
+ return expr, False
452
+ tainted = False
453
+
454
+ def _repl(match: re.Match[str]) -> str:
455
+ nonlocal tainted
456
+ var = env.get(match.group(1))
457
+ if var is None:
458
+ return match.group(0)
459
+ if var.is_tainted:
460
+ tainted = True
461
+ return var.value
462
+
463
+ pieces: list[str] = []
464
+ for is_code, chunk in _split_code_and_literals(expr):
465
+ pieces.append(self._IDENT_RE.sub(_repl, chunk) if is_code else chunk)
466
+ return "".join(pieces), tainted
467
+
278
468
  def resolve_call_target(
279
469
  self, callee: str, args_raw: str, env: dict[str, FlowVariable], snippet: str = ""
280
470
  ) -> tuple[str, str, bool]:
@@ -289,20 +479,31 @@ class DynamicFlowAnalyzer:
289
479
  if env[callee].is_tainted:
290
480
  is_tainted = True
291
481
  else:
292
- for name, var in env.items():
293
- pat = rf"(?<![A-Za-z0-9_$]){re.escape(name)}(?![A-Za-z0-9_$])"
294
- if re.search(pat, resolved_callee):
295
- resolved_callee = re.sub(pat, var.value, resolved_callee)
296
- if var.is_tainted:
297
- is_tainted = True
482
+ resolved_callee, tainted_by_callee = self._substitute_vars_once(
483
+ resolved_callee, env
484
+ )
485
+ is_tainted = is_tainted or tainted_by_callee
298
486
 
299
487
  # 2. 还原实参中的变量
300
- for name, var in env.items():
301
- pat = rf"(?<![A-Za-z0-9_$]){re.escape(name)}(?![A-Za-z0-9_$])"
302
- if re.search(pat, resolved_args):
303
- resolved_args = re.sub(pat, var.value, resolved_args)
304
- if var.is_tainted:
305
- is_tainted = True
488
+ #
489
+ # 必须**单次扫描、不回扫替换结果**。原先按 env 逐项 ``re.sub`` 的写法会让
490
+ # 替换进去的文本被后续变量名再次替换,产生级联污染:实测
491
+ # ``corpus_fetch.py`` 的 ``urlopen(req, timeout=timeout, ...)`` 被还原成
492
+ # 一整段把多个函数里 ``req`` 的赋值、``pool.submit(...)`` 片段拼在一起的
493
+ # 垃圾文本,进而被拼接检测判成动态构造(假 SSRF)。单次替换用一次
494
+ # ``re.sub`` + 回调实现:只在**原始实参**上找标识符,替换结果不再参与匹配。
495
+ resolved_args, _ = self._substitute_vars_once(resolved_args, env)
496
+ # 污点传播同样只看载荷面:`env=environment` 这类配置实参即使本身来自
497
+ # `os.environ`,也不构成注入面(见下方 payload_portion 说明)。
498
+ payload = self.payload_portion(args_raw)
499
+ if any(
500
+ var.is_tainted
501
+ and re.search(
502
+ rf"(?<![A-Za-z0-9_$]){re.escape(var.name)}(?![A-Za-z0-9_$])", payload
503
+ )
504
+ for var in env.values()
505
+ ):
506
+ is_tainted = True
306
507
 
307
508
  # 3. 检查 getattr(os, "system") 或 getattr(os, system) 字符串内嵌动态调用还原
308
509
  m_getattr = re.search(r"getattr\(([^,]+),\s*['\"]?([A-Za-z0-9_]+)['\"]?\)", resolved_callee)
@@ -322,7 +523,11 @@ class DynamicFlowAnalyzer:
322
523
  chain_raw = m_chain.group(1).strip()
323
524
  resolved_args = self._resolve_line_vars(chain_raw, env)
324
525
 
325
- if self.has_framework_source(resolved_args):
526
+ # 污点只看**载荷面**(第一个关键字实参之前)。注入类规则的注入点是命令/查询
527
+ # 串本身;把 `env=os.environ.copy()`、`cwd=`、`timeout=` 这类配置实参也算进去,
528
+ # 会让 `subprocess.run(cmd, env=os.environ.copy())` 这种完全正常的调用被判成
529
+ # 命令注入(实测仓库自身就有一条 critical 假阳性)。
530
+ if self.has_framework_source(self.payload_portion(resolved_args)):
326
531
  is_tainted = True
327
532
 
328
533
  return resolved_callee, resolved_args, is_tainted