bugx-cli 0.0.0-stage → 0.1.0

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 (751) hide show
  1. package/LICENSE +55 -0
  2. package/README.md +280 -2
  3. package/core/CATALOG.json +141 -0
  4. package/core/README.md +254 -0
  5. package/core/adapters/README.md +35 -0
  6. package/core/adapters/android-interaction.json +81 -0
  7. package/core/adapters/android.json +24 -0
  8. package/core/adapters/desktop-macos.json +20 -0
  9. package/core/adapters/ios-interaction.json +34 -0
  10. package/core/adapters/ios.json +23 -0
  11. package/core/adapters/memory-macos.json +24 -0
  12. package/core/agent/README.md +50 -0
  13. package/core/agent/__init__.py +146 -0
  14. package/core/agent/agent_artifacts.py +764 -0
  15. package/core/agent/agent_eval.py +1073 -0
  16. package/core/agent/agent_execution.py +552 -0
  17. package/core/agent/agent_orchestrator.py +1345 -0
  18. package/core/agent/agent_targets.py +871 -0
  19. package/core/agent/agent_workspace.py +770 -0
  20. package/core/assets/README.md +24 -0
  21. package/core/assets/bugx-avatar-1024.png +0 -0
  22. package/core/assets/bugx-avatar-512.png +0 -0
  23. package/core/assets/bugx-avatar-tight.svg +23 -0
  24. package/core/assets/bugx-avatar.svg +28 -0
  25. package/core/assets/bugx-hero-cn.png +0 -0
  26. package/core/assets/bugx-hero-en.png +0 -0
  27. package/core/assets/project-layout.md +42 -0
  28. package/core/audit_packs/README.md +37 -0
  29. package/core/audit_packs/data-audit/manifest.json +94 -0
  30. package/core/audit_packs/data-audit/stages/00-scope.md +14 -0
  31. package/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
  32. package/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
  33. package/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
  34. package/core/audit_packs/desktop-audit/manifest.json +123 -0
  35. package/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
  36. package/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
  37. package/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
  38. package/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
  39. package/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
  40. package/core/audit_packs/memory-testing.md +227 -0
  41. package/core/audit_packs/mobile-audit/manifest.json +155 -0
  42. package/core/audit_packs/mobile-audit/modules/android.md +19 -0
  43. package/core/audit_packs/mobile-audit/modules/h5.md +18 -0
  44. package/core/audit_packs/mobile-audit/modules/ios.md +25 -0
  45. package/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
  46. package/core/audit_packs/mobile-audit/modules/webview.md +18 -0
  47. package/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
  48. package/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
  49. package/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
  50. package/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
  51. package/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
  52. package/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
  53. package/core/audit_packs/native-audit/manifest.json +127 -0
  54. package/core/audit_packs/native-audit/stages/00-scope.md +14 -0
  55. package/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
  56. package/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
  57. package/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
  58. package/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
  59. package/core/audit_packs/platform-testing.md +174 -0
  60. package/core/audit_packs/web-audit/manifest.json +191 -0
  61. package/core/audit_packs/web-audit/modules/graphql.md +5 -0
  62. package/core/audit_packs/web-audit/modules/h5.md +18 -0
  63. package/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
  64. package/core/audit_packs/web-audit/modules/oauth.md +4 -0
  65. package/core/audit_packs/web-audit/modules/upload.md +4 -0
  66. package/core/audit_packs/web-audit/modules/websocket.md +4 -0
  67. package/core/audit_packs/web-audit/stages/00-scope.md +13 -0
  68. package/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
  69. package/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
  70. package/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
  71. package/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
  72. package/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
  73. package/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
  74. package/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
  75. package/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
  76. package/core/autonomous_cve/INTERFACE.md +61 -0
  77. package/core/autonomous_cve/README.md +58 -0
  78. package/core/autonomous_cve/SPEC.md +25 -0
  79. package/core/autonomous_cve/__init__.py +109 -0
  80. package/core/autonomous_cve/attack_graph.py +1096 -0
  81. package/core/autonomous_cve/attack_graph_store.py +1822 -0
  82. package/core/autonomous_cve/audit_campaign.py +1232 -0
  83. package/core/autonomous_cve/behavior_graph.py +459 -0
  84. package/core/autonomous_cve/ghsa_advisories.py +174 -0
  85. package/core/autonomous_cve/models.py +93 -0
  86. package/core/autonomous_cve/mutator.py +87 -0
  87. package/core/autonomous_cve/patcher.py +126 -0
  88. package/core/autonomous_cve/scout.py +278 -0
  89. package/core/autonomous_cve/synthesizer.py +207 -0
  90. package/core/autonomous_cve/verifier.py +100 -0
  91. package/core/bugx.md +1299 -0
  92. package/core/bugx_paths.py +1846 -0
  93. package/core/cloud_sync/INTERFACE.md +32 -0
  94. package/core/cloud_sync/README.md +62 -0
  95. package/core/cloud_sync/SPEC.md +25 -0
  96. package/core/cloud_sync/__init__.py +23 -0
  97. package/core/cloud_sync/auto_sync.py +398 -0
  98. package/core/cloud_sync/cloud_client.py +1199 -0
  99. package/core/cloud_sync/cloud_onboard.py +702 -0
  100. package/core/cloud_sync/cloud_schema.py +648 -0
  101. package/core/cloud_sync/consent.py +81 -0
  102. package/core/cloud_sync/device_identity.py +307 -0
  103. package/core/cloud_sync/endpoint_router.py +415 -0
  104. package/core/cloud_sync/flywheel_client.py +760 -0
  105. package/core/cloud_sync/network_transport.py +275 -0
  106. package/core/cloud_sync/onboard_wizard.py +493 -0
  107. package/core/cloud_sync/sensitive_filter.py +285 -0
  108. package/core/cloud_sync/sync_pull.py +695 -0
  109. package/core/cloud_sync/sync_push.py +721 -0
  110. package/core/contracts/AGENT_GUIDE.md +362 -0
  111. package/core/contracts/README.md +34 -0
  112. package/core/contracts/bugx-blackbox.md +541 -0
  113. package/core/contracts/bugx-opencode.md +469 -0
  114. package/core/contracts/bugx-quick.md +44 -0
  115. package/core/contracts/bugx-runtime-contract.md +353 -0
  116. package/core/contracts/bugx-worker.md +470 -0
  117. package/core/contracts/engine_gap_contracts.py +390 -0
  118. package/core/coverage/README.md +70 -0
  119. package/core/coverage/__init__.py +106 -0
  120. package/core/coverage/coverage_ai_review.py +185 -0
  121. package/core/coverage/coverage_backfill.py +54 -0
  122. package/core/coverage/coverage_bootstrap.py +713 -0
  123. package/core/coverage/coverage_business.py +36 -0
  124. package/core/coverage/coverage_cli.py +715 -0
  125. package/core/coverage/coverage_discovery.py +859 -0
  126. package/core/coverage/coverage_evidence.py +977 -0
  127. package/core/coverage/coverage_forensics.py +115 -0
  128. package/core/coverage/coverage_gate.py +277 -0
  129. package/core/coverage/coverage_intelligence.py +734 -0
  130. package/core/coverage/coverage_manifest.py +396 -0
  131. package/core/coverage/coverage_platform.py +77 -0
  132. package/core/coverage/coverage_validate.py +236 -0
  133. package/core/coverage/module_coverage.py +157 -0
  134. package/core/dev_harness/INTERFACE.md +20 -0
  135. package/core/dev_harness/README.md +21 -0
  136. package/core/dev_harness/SPEC.md +25 -0
  137. package/core/dev_harness/__init__.py +5 -0
  138. package/core/dev_harness/interaction_preset.py +408 -0
  139. package/core/engine-integrity.json +2625 -0
  140. package/core/fuzzing/README.md +49 -0
  141. package/core/fuzzing/__init__.py +82 -0
  142. package/core/fuzzing/concurrency_fuzzer.py +382 -0
  143. package/core/fuzzing/differential_oracle.py +629 -0
  144. package/core/fuzzing/fuzz_input.py +1188 -0
  145. package/core/fuzzing/stateful_fuzzer.py +332 -0
  146. package/core/governance/README.md +61 -0
  147. package/core/governance/__init__.py +130 -0
  148. package/core/governance/capacity_planner.py +124 -0
  149. package/core/governance/dependency_lock.py +317 -0
  150. package/core/governance/goal_governor.py +754 -0
  151. package/core/governance/guide_budget.py +458 -0
  152. package/core/governance/lockdown.sh +50 -0
  153. package/core/governance/readonly_enforcer.py +154 -0
  154. package/core/governance/runtime_tool_gate.py +373 -0
  155. package/core/governance/secret_redactor.py +772 -0
  156. package/core/governance/token_budget.py +38 -0
  157. package/core/host_acp/INTERFACE.md +36 -0
  158. package/core/host_acp/README.md +51 -0
  159. package/core/host_acp/SPEC.md +25 -0
  160. package/core/host_acp/__init__.py +121 -0
  161. package/core/host_acp/base.py +111 -0
  162. package/core/host_acp/claude.py +41 -0
  163. package/core/host_acp/cline.py +235 -0
  164. package/core/host_acp/codex.py +245 -0
  165. package/core/host_acp/dsh.py +48 -0
  166. package/core/host_acp/opencode.py +154 -0
  167. package/core/host_acp/pi.py +36 -0
  168. package/core/host_acp/zcode.py +41 -0
  169. package/core/host_runtime/INTERFACE.md +24 -0
  170. package/core/host_runtime/README.md +62 -0
  171. package/core/host_runtime/SPEC.md +25 -0
  172. package/core/host_runtime/__init__.py +21 -0
  173. package/core/host_runtime/adapters.py +412 -0
  174. package/core/host_runtime/autonomous_runner.py +1152 -0
  175. package/core/host_runtime/cline.py +435 -0
  176. package/core/host_runtime/common.py +103 -0
  177. package/core/host_runtime/free_models.py +786 -0
  178. package/core/host_runtime/host_bootstrap.py +389 -0
  179. package/core/host_runtime/host_evaluators.py +721 -0
  180. package/core/host_runtime/host_probe.py +41 -0
  181. package/core/host_runtime/host_provider_arbitrator.py +777 -0
  182. package/core/host_runtime/host_registry.py +655 -0
  183. package/core/host_runtime/host_usage.py +127 -0
  184. package/core/host_runtime/mcp_process_tracker.py +509 -0
  185. package/core/host_runtime/mcp_registry_gate.py +368 -0
  186. package/core/hosts/INTERFACE.md +51 -0
  187. package/core/hosts/README.md +67 -0
  188. package/core/hosts/SPEC.md +25 -0
  189. package/core/hosts/__init__.py +136 -0
  190. package/core/hosts/_base_usage.py +152 -0
  191. package/core/hosts/_codex_usage.py +297 -0
  192. package/core/hosts/_dsh_usage.py +184 -0
  193. package/core/hosts/_mcp_toml.py +365 -0
  194. package/core/hosts/_zcode_usage.py +269 -0
  195. package/core/hosts/base.py +451 -0
  196. package/core/hosts/claude.py +157 -0
  197. package/core/hosts/cline.py +225 -0
  198. package/core/hosts/codex.py +948 -0
  199. package/core/hosts/dsh.py +518 -0
  200. package/core/hosts/opencode.py +358 -0
  201. package/core/hosts/pi.py +151 -0
  202. package/core/hosts/zcode.py +219 -0
  203. package/core/i18n.py +252 -0
  204. package/core/infra/README.md +39 -0
  205. package/core/infra/__init__.py +15 -0
  206. package/core/infra/build_info.py +86 -0
  207. package/core/infra/client_metadata.py +185 -0
  208. package/core/infra/python_runtime.py +540 -0
  209. package/core/infra/safe_xml.py +221 -0
  210. package/core/launch_bugx.py +118 -0
  211. package/core/launch_phases/INTERFACE.md +31 -0
  212. package/core/launch_phases/README.md +106 -0
  213. package/core/launch_phases/SPEC.md +25 -0
  214. package/core/launch_phases/__init__.py +29 -0
  215. package/core/launch_phases/candidate_revalidation.py +484 -0
  216. package/core/launch_phases/common.py +1041 -0
  217. package/core/launch_phases/finding_confirm_phase.py +387 -0
  218. package/core/launch_phases/finding_settlement.py +1245 -0
  219. package/core/launch_phases/findings_adjudication.py +666 -0
  220. package/core/launch_phases/findings_snapshot.py +357 -0
  221. package/core/launch_phases/judge_phase.py +791 -0
  222. package/core/launch_phases/lesson_context.py +536 -0
  223. package/core/launch_phases/lifecycle_reporter.py +627 -0
  224. package/core/launch_phases/orchestrator_controls.py +682 -0
  225. package/core/launch_phases/post_commit.py +567 -0
  226. package/core/launch_phases/post_coverage_sync.py +591 -0
  227. package/core/launch_phases/post_dry_run.py +817 -0
  228. package/core/launch_phases/post_observability.py +367 -0
  229. package/core/launch_phases/post_phase.py +1087 -0
  230. package/core/launch_phases/post_receipt.py +362 -0
  231. package/core/launch_phases/post_round_lifecycle.py +786 -0
  232. package/core/launch_phases/pre_phase.py +1029 -0
  233. package/core/launch_phases/pre_recon_scout.py +862 -0
  234. package/core/launch_phases/pre_state_builder.py +1286 -0
  235. package/core/launch_phases/report_sharing.py +414 -0
  236. package/core/launch_phases/round_orchestrator.py +1133 -0
  237. package/core/launch_phases/session_runtime.py +1623 -0
  238. package/core/launch_phases/startup_gates.py +1022 -0
  239. package/core/launch_phases/startup_interaction.py +947 -0
  240. package/core/launch_phases/startup_version_gate.py +873 -0
  241. package/core/launch_phases/supervisor_bridge.py +1224 -0
  242. package/core/launch_phases/supervisor_coverage.py +417 -0
  243. package/core/launch_phases/supervisor_degraded.py +1219 -0
  244. package/core/launch_phases/worker_barriers.py +414 -0
  245. package/core/launch_phases/worker_orchestrator.py +1166 -0
  246. package/core/launch_phases/worker_prior.py +749 -0
  247. package/core/ledger/INTERFACE.md +35 -0
  248. package/core/ledger/README.md +160 -0
  249. package/core/ledger/SPEC.md +25 -0
  250. package/core/ledger/__init__.py +67 -0
  251. package/core/ledger/_facade.py +226 -0
  252. package/core/ledger/archive_ops.py +572 -0
  253. package/core/ledger/auto_materialization.py +459 -0
  254. package/core/ledger/bug-log.md +22 -0
  255. package/core/ledger/cli.py +270 -0
  256. package/core/ledger/export_ops.py +549 -0
  257. package/core/ledger/finding_confirmation.py +1274 -0
  258. package/core/ledger/finding_io.py +299 -0
  259. package/core/ledger/finding_lifecycle.py +307 -0
  260. package/core/ledger/finding_verification.py +369 -0
  261. package/core/ledger/incidents.py +999 -0
  262. package/core/ledger/lesson-replay-cases.json +20 -0
  263. package/core/ledger/lesson_ledger.py +241 -0
  264. package/core/ledger/lesson_replay.py +272 -0
  265. package/core/ledger/life_ledger.py +668 -0
  266. package/core/ledger/mistake-book.md +130 -0
  267. package/core/ledger/patterns.py +681 -0
  268. package/core/ledger/receipt_contract.py +253 -0
  269. package/core/ledger/schema.py +1192 -0
  270. package/core/ledger/sync_ops.py +935 -0
  271. package/core/ledger/tool_experience.py +682 -0
  272. package/core/ledger/verify_life.py +1526 -0
  273. package/core/lesson-ledger.json +275 -0
  274. package/core/locales/README.md +19 -0
  275. package/core/locales/en-US.json +462 -0
  276. package/core/locales/zh-CN.json +462 -0
  277. package/core/mcp_handlers/INTERFACE.md +75 -0
  278. package/core/mcp_handlers/README.md +62 -0
  279. package/core/mcp_handlers/SPEC.md +25 -0
  280. package/core/mcp_handlers/__init__.py +128 -0
  281. package/core/mcp_handlers/base.py +697 -0
  282. package/core/mcp_handlers/channel_lifecycle.py +696 -0
  283. package/core/mcp_handlers/graph_handlers.py +222 -0
  284. package/core/mcp_handlers/knowledge_handlers.py +536 -0
  285. package/core/mcp_handlers/mining_handlers.py +586 -0
  286. package/core/mcp_handlers/resource_prompt_table.py +116 -0
  287. package/core/mcp_handlers/retrieval_handlers.py +239 -0
  288. package/core/mcp_handlers/rpc_server.py +465 -0
  289. package/core/mcp_handlers/supervisor_handlers.py +1435 -0
  290. package/core/mcp_handlers/telemetry_handlers.py +227 -0
  291. package/core/mcp_handlers/tool_table.py +1015 -0
  292. package/core/mcp_runtime_support/README.md +21 -0
  293. package/core/mcp_runtime_support/__init__.py +1 -0
  294. package/core/mcp_runtime_support/common.py +363 -0
  295. package/core/mcp_runtime_support/environment.py +605 -0
  296. package/core/mcp_runtime_support/verifier.py +810 -0
  297. package/core/metadata.txt +5 -0
  298. package/core/planning/README.md +157 -0
  299. package/core/planning/__init__.py +242 -0
  300. package/core/planning/capability_plan.py +187 -0
  301. package/core/planning/capability_planner.py +195 -0
  302. package/core/planning/domain_archetype.py +542 -0
  303. package/core/planning/domain_router.py +267 -0
  304. package/core/planning/dynamic_flow_analyzer.py +328 -0
  305. package/core/planning/impact_pruner.py +435 -0
  306. package/core/planning/intent_adjudicator.py +175 -0
  307. package/core/planning/judge_pipeline.py +1163 -0
  308. package/core/planning/logic_analysis.py +419 -0
  309. package/core/planning/prompt_harness.py +1702 -0
  310. package/core/planning/source_inspector.py +267 -0
  311. package/core/planning/spec_harvester.py +449 -0
  312. package/core/planning/target_sandbox_manager.py +573 -0
  313. package/core/planning/test_capability_verifier.py +1364 -0
  314. package/core/planning/tools-kb.md +38 -0
  315. package/core/planning/unit_kind.py +122 -0
  316. package/core/probes/INTERFACE.md +73 -0
  317. package/core/probes/README.md +51 -0
  318. package/core/probes/SPEC.md +26 -0
  319. package/core/probes/__init__.py +70 -0
  320. package/core/probes/android_probe.py +384 -0
  321. package/core/probes/base.py +147 -0
  322. package/core/probes/codebase_memory_probe.py +590 -0
  323. package/core/probes/desktop_probe.py +238 -0
  324. package/core/probes/differential_probe.py +356 -0
  325. package/core/probes/efficiency_probe.py +168 -0
  326. package/core/probes/ios_binary_probe.py +368 -0
  327. package/core/probes/memory_probe.py +326 -0
  328. package/core/probes/miniprogram_probe.py +323 -0
  329. package/core/probes/mobile_probe.py +281 -0
  330. package/core/probes/native_probe.py +214 -0
  331. package/core/probes/openwiki_probe.py +193 -0
  332. package/core/probes/pattern_probe.py +347 -0
  333. package/core/probes/platform_probe.py +343 -0
  334. package/core/probes/probe_registry.py +1669 -0
  335. package/core/probes/sast_probe.py +1009 -0
  336. package/core/probes/sast_rules.py +841 -0
  337. package/core/probes/sca_scanner.py +731 -0
  338. package/core/probes/web_probe.py +359 -0
  339. package/core/project_profiler/INTERFACE.md +62 -0
  340. package/core/project_profiler/README.md +53 -0
  341. package/core/project_profiler/SPEC.md +28 -0
  342. package/core/project_profiler/__init__.py +201 -0
  343. package/core/project_profiler/arbitrator.py +311 -0
  344. package/core/project_profiler/constants.py +247 -0
  345. package/core/project_profiler/detector.py +392 -0
  346. package/core/project_profiler/extractors.py +836 -0
  347. package/core/project_profiler/fingerprint.py +116 -0
  348. package/core/project_profiler/storage.py +258 -0
  349. package/core/project_profiler/strategy.py +265 -0
  350. package/core/prompts/README.md +35 -0
  351. package/core/prompts/codex_dialog_dispatch.md +9 -0
  352. package/core/prompts/command_routing_en.md +42 -0
  353. package/core/prompts/command_routing_zh.md +42 -0
  354. package/core/prompts/l0_router.md +47 -0
  355. package/core/prompts/rules/anti_patterns.md +16 -0
  356. package/core/prompts/rules/concurrency_rules.md +14 -0
  357. package/core/prompts/rules/memory_leak_rules.md +13 -0
  358. package/core/prompts/rules/prompt_injection_defense.md +13 -0
  359. package/core/prompts/stages/stage_explore.md +31 -0
  360. package/core/prompts/stages/stage_gate.md +43 -0
  361. package/core/prompts/stages/stage_mutate.md +42 -0
  362. package/core/prompts/stages/stage_repair.md +85 -0
  363. package/core/repair/README.md +74 -0
  364. package/core/repair/__init__.py +169 -0
  365. package/core/repair/fix_watchlist.py +391 -0
  366. package/core/repair/l7_dynamic.py +418 -0
  367. package/core/repair/l7_repair_loop.py +465 -0
  368. package/core/repair/l7_selfcheck.py +862 -0
  369. package/core/repair/minimize_repro.py +466 -0
  370. package/core/repair/patch_synthesizer.py +617 -0
  371. package/core/repair/regression_pack.py +379 -0
  372. package/core/repair/rsi_fixer.py +910 -0
  373. package/core/repair/rsi_loop.py +313 -0
  374. package/core/repair/rsi_repair.py +348 -0
  375. package/core/repair/rsi_rounds.py +212 -0
  376. package/core/repair/rsi_scope.py +262 -0
  377. package/core/repair/self_heal.py +604 -0
  378. package/core/repair/test_generator.py +1108 -0
  379. package/core/repair/test_quality_auditor.py +410 -0
  380. package/core/repair/test_strategy.py +511 -0
  381. package/core/report_engine/INTERFACE.md +59 -0
  382. package/core/report_engine/README.md +69 -0
  383. package/core/report_engine/SPEC.md +28 -0
  384. package/core/report_engine/__init__.py +47 -0
  385. package/core/report_engine/attestation.py +224 -0
  386. package/core/report_engine/authority.py +255 -0
  387. package/core/report_engine/finding_report.py +417 -0
  388. package/core/report_engine/formal_report_builder.py +924 -0
  389. package/core/report_engine/html_renderers.py +696 -0
  390. package/core/report_engine/models.py +761 -0
  391. package/core/report_engine/pdf_exporter.py +231 -0
  392. package/core/report_engine/projects_assets.py +730 -0
  393. package/core/report_engine/report_client.py +743 -0
  394. package/core/report_engine/report_data_builder.py +388 -0
  395. package/core/report_engine/report_share.py +459 -0
  396. package/core/report_engine/sast_bridge.py +116 -0
  397. package/core/report_engine/server.py +822 -0
  398. package/core/report_engine/visual_report_builder.py +796 -0
  399. package/core/report_engine/web-conformance.md +63 -0
  400. package/core/report_engine/web_conformance.py +459 -0
  401. package/core/report_engine/workbench_assets.py +484 -0
  402. package/core/retrieval/INTERFACE.md +20 -0
  403. package/core/retrieval/README.md +161 -0
  404. package/core/retrieval/SPEC.md +25 -0
  405. package/core/retrieval/__init__.py +3 -0
  406. package/core/retrieval/code_analyzer.py +1684 -0
  407. package/core/retrieval/codebase_memory_bridge.py +337 -0
  408. package/core/retrieval/context_assembler.py +234 -0
  409. package/core/retrieval/corpus_fetch.py +369 -0
  410. package/core/retrieval/graph_ego.py +597 -0
  411. package/core/retrieval/knowledge_auto.py +662 -0
  412. package/core/retrieval/knowledge_sources.py +168 -0
  413. package/core/retrieval/knowledge_sync.py +909 -0
  414. package/core/retrieval/memory_store.py +480 -0
  415. package/core/retrieval/query_planner.py +1020 -0
  416. package/core/retrieval/rrf_engine.py +137 -0
  417. package/core/retrieval/slice_extractor.py +1209 -0
  418. package/core/retrieval/slice_normalizer.py +373 -0
  419. package/core/retrieval/slice_spec.py +357 -0
  420. package/core/retrieval/symbol_index.py +1132 -0
  421. package/core/retrieval/universal_code_matcher.py +437 -0
  422. package/core/retrieval/xerj_bridge.py +476 -0
  423. package/core/retrieval/xerj_supervisor.py +362 -0
  424. package/core/rules/README.md +33 -0
  425. package/core/rules/ios/PROVENANCE.json +30 -0
  426. package/core/rules/ios/crypto.yaml +36 -0
  427. package/core/rules/ios/network.yaml +20 -0
  428. package/core/rules/ios/resilience.yaml +47 -0
  429. package/core/rules/ios/storage.yaml +48 -0
  430. package/core/rules/mastg/LICENSE +173 -0
  431. package/core/rules/mastg/PROVENANCE.json +270 -0
  432. package/core/rules/mastg/mastg-android-asymmetric-key-pair-used-for-multiple-purposes.yml +13 -0
  433. package/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
  434. package/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
  435. package/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
  436. package/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
  437. package/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
  438. package/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
  439. package/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
  440. package/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
  441. package/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
  442. package/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
  443. package/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml +36 -0
  444. package/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-manifest.yml +15 -0
  445. package/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
  446. package/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
  447. package/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
  448. package/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
  449. package/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
  450. package/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
  451. package/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
  452. package/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
  453. package/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
  454. package/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
  455. package/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
  456. package/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
  457. package/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
  458. package/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
  459. package/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
  460. package/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
  461. package/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
  462. package/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
  463. package/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
  464. package/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
  465. package/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
  466. package/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
  467. package/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
  468. package/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
  469. package/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
  470. package/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
  471. package/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
  472. package/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
  473. package/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
  474. package/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
  475. package/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
  476. package/core/rules/mastg/mastg-android-strictmode.yml +10 -0
  477. package/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
  478. package/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
  479. package/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
  480. package/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
  481. package/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
  482. package/core/rules/miniprogram/PROVENANCE.json +26 -0
  483. package/core/rules/miniprogram/network.yaml +37 -0
  484. package/core/rules/miniprogram/platform.yaml +36 -0
  485. package/core/rules/miniprogram/storage.yaml +48 -0
  486. package/core/rules/mobsfscan-swift/LICENSE +165 -0
  487. package/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
  488. package/core/rules/mobsfscan-swift/auth.yaml +59 -0
  489. package/core/rules/mobsfscan-swift/crypto.yaml +66 -0
  490. package/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
  491. package/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
  492. package/core/rules/mobsfscan-swift/logging.yaml +23 -0
  493. package/core/rules/mobsfscan-swift/network.yaml +55 -0
  494. package/core/rules/mobsfscan-swift/resilience.yaml +29 -0
  495. package/core/rules/mobsfscan-swift/secrets.yaml +33 -0
  496. package/core/rules/mobsfscan-swift/storage.yaml +29 -0
  497. package/core/rules/mobsfscan-swift/webview.yaml +32 -0
  498. package/core/runtime/README.md +198 -0
  499. package/core/runtime/__init__.py +3 -0
  500. package/core/runtime/bugx_logging.py +1393 -0
  501. package/core/runtime/daemon_runner.py +623 -0
  502. package/core/runtime/fixture_solidify.py +449 -0
  503. package/core/runtime/global_telemetry.py +549 -0
  504. package/core/runtime/incident_eval.py +148 -0
  505. package/core/runtime/interaction.py +605 -0
  506. package/core/runtime/interaction_store.py +435 -0
  507. package/core/runtime/interactive_menu.py +95 -0
  508. package/core/runtime/log_analytics.py +922 -0
  509. package/core/runtime/mining_quality_framework.py +1387 -0
  510. package/core/runtime/model_runner.py +769 -0
  511. package/core/runtime/platform_adapter.py +579 -0
  512. package/core/runtime/prep_validate.py +476 -0
  513. package/core/runtime/project_graph.py +827 -0
  514. package/core/runtime/project_init.py +481 -0
  515. package/core/runtime/project_profile.py +224 -0
  516. package/core/runtime/project_settings.py +963 -0
  517. package/core/runtime/provider_window.py +97 -0
  518. package/core/runtime/resume_ticket.py +115 -0
  519. package/core/runtime/scenario_eval.py +814 -0
  520. package/core/runtime/seed_drill.py +549 -0
  521. package/core/runtime/self_audit.py +550 -0
  522. package/core/runtime/session_profile.py +205 -0
  523. package/core/runtime/setup_ui_env.py +229 -0
  524. package/core/runtime/startup_environment.py +859 -0
  525. package/core/runtime/sync_store.py +1421 -0
  526. package/core/runtime/tool_install_targets.py +18 -0
  527. package/core/schemas/README.md +35 -0
  528. package/core/schemas/agent-graph.schema.json +368 -0
  529. package/core/schemas/attack-graph.schema.json +88 -0
  530. package/core/schemas/evidence-bundle.schema.json +33 -0
  531. package/core/schemas/skill-pack.schema.json +230 -0
  532. package/core/schemas/worker-checkpoint.schema.json +119 -0
  533. package/core/secure_atomic.py +289 -0
  534. package/core/seed_corpus/README.md +55 -0
  535. package/core/seed_corpus/c.txt +29 -0
  536. package/core/seed_corpus/cpp.txt +32 -0
  537. package/core/seed_corpus/css.txt +70 -0
  538. package/core/seed_corpus/go.txt +46 -0
  539. package/core/seed_corpus/java.txt +30 -0
  540. package/core/seed_corpus/javascript.txt +55 -0
  541. package/core/seed_corpus/kotlin.txt +28 -0
  542. package/core/seed_corpus/python.txt +71 -0
  543. package/core/seed_corpus/rust.txt +53 -0
  544. package/core/seed_corpus/swift.txt +29 -0
  545. package/core/seed_corpus/typescript.txt +29 -0
  546. package/core/skills/README.md +53 -0
  547. package/core/skills/__init__.py +189 -0
  548. package/core/skills/bugx_docs_mcp_server.py +416 -0
  549. package/core/skills/bugx_mcp_server.py +1134 -0
  550. package/core/skills/mcp_runtime.py +968 -0
  551. package/core/skills/mcp_session_proof.py +605 -0
  552. package/core/skills/mobile_ui_inspector.py +405 -0
  553. package/core/skills/skill_pack.py +1214 -0
  554. package/core/skills/skill_synthesizer.py +1153 -0
  555. package/core/skills/tools_kb.py +313 -0
  556. package/core/supervisor/INTERFACE.md +121 -0
  557. package/core/supervisor/README.md +209 -0
  558. package/core/supervisor/SPEC.md +25 -0
  559. package/core/supervisor/__init__.py +175 -0
  560. package/core/supervisor/audit_supervisor.py +1015 -0
  561. package/core/supervisor/budget_governor.py +760 -0
  562. package/core/supervisor/checkpoint_handler.py +368 -0
  563. package/core/supervisor/checkpoint_pipeline.py +1322 -0
  564. package/core/supervisor/checkpoint_sync.py +640 -0
  565. package/core/supervisor/claim_events.py +74 -0
  566. package/core/supervisor/claim_sync.py +590 -0
  567. package/core/supervisor/cli.py +812 -0
  568. package/core/supervisor/context_sync.py +55 -0
  569. package/core/supervisor/coverage_sync.py +115 -0
  570. package/core/supervisor/finding_commit.py +470 -0
  571. package/core/supervisor/finding_sync.py +688 -0
  572. package/core/supervisor/finding_workflow.py +659 -0
  573. package/core/supervisor/finish_policy.py +224 -0
  574. package/core/supervisor/finish_sync.py +185 -0
  575. package/core/supervisor/graph_sync.py +669 -0
  576. package/core/supervisor/lease_manager.py +788 -0
  577. package/core/supervisor/lifecycle_blocks.py +124 -0
  578. package/core/supervisor/next_round_sync.py +126 -0
  579. package/core/supervisor/observability.py +140 -0
  580. package/core/supervisor/recovery_sync.py +165 -0
  581. package/core/supervisor/rejection_remedies.py +308 -0
  582. package/core/supervisor/round_governor.py +306 -0
  583. package/core/supervisor/serial_authorization.py +500 -0
  584. package/core/supervisor/start_sync.py +87 -0
  585. package/core/supervisor/state_store.py +249 -0
  586. package/core/supervisor/supervisor_host.py +511 -0
  587. package/core/supervisor/supervisor_models.py +1143 -0
  588. package/core/supervisor/systemic_failure.py +104 -0
  589. package/core/supervisor/task_scheduler.py +1640 -0
  590. package/core/supervisor/worker_checkpoint.py +223 -0
  591. package/core/supervisor/worker_execution.py +265 -0
  592. package/core/supervisor/worker_handoff.py +192 -0
  593. package/core/supervisor/worker_lifecycle.py +396 -0
  594. package/core/supervisor/worker_runtime.py +999 -0
  595. package/core/supervisor/worker_sync.py +89 -0
  596. package/core/supervisor_types/README.md +36 -0
  597. package/core/supervisor_types/__init__.py +0 -0
  598. package/core/supervisor_types/exceptions.py +52 -0
  599. package/core/supervisor_types/graph_models.py +357 -0
  600. package/core/supervisor_types/path_containment.py +151 -0
  601. package/core/supervisor_types/target_fingerprint.py +310 -0
  602. package/core/supervisor_types/worker_claim.py +402 -0
  603. package/core/webui/INTERFACE.md +50 -0
  604. package/core/webui/README.md +57 -0
  605. package/core/webui/SPEC.md +25 -0
  606. package/core/webui/__init__.py +11 -0
  607. package/core/webui/adapters/__init__.py +27 -0
  608. package/core/webui/adapters/base.py +87 -0
  609. package/core/webui/adapters/bugx.py +102 -0
  610. package/core/webui/adapters/claude.py +218 -0
  611. package/core/webui/adapters/cline.py +399 -0
  612. package/core/webui/adapters/codex.py +256 -0
  613. package/core/webui/adapters/dsh.py +173 -0
  614. package/core/webui/adapters/opencode.py +218 -0
  615. package/core/webui/adapters/pi.py +272 -0
  616. package/core/webui/adapters/registry.py +100 -0
  617. package/core/webui/adapters/zcode.py +312 -0
  618. package/core/webui/api_routes_post.py +668 -0
  619. package/core/webui/dispatcher.py +1376 -0
  620. package/core/webui/docs_session_service.py +473 -0
  621. package/core/webui/handler.py +674 -0
  622. package/core/webui/ide_cloud_service.py +526 -0
  623. package/core/webui/mcp_inspector.py +1743 -0
  624. package/core/webui/static/assets/index-CXAsl8mr.js +333 -0
  625. package/core/webui/static/assets/index-DHQUtWtx.css +1 -0
  626. package/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
  627. package/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
  628. package/core/webui/static/assets/source-serif-4-cyrillic-500-normal-Bb4u56_6.woff +0 -0
  629. package/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
  630. package/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-CWV284fw.woff2 +0 -0
  631. package/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-DLkyKLvH.woff +0 -0
  632. package/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-8-8HP2PF.woff +0 -0
  633. package/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-DaDZE_Na.woff2 +0 -0
  634. package/core/webui/static/assets/source-serif-4-greek-400-normal-BccYJ-vZ.woff +0 -0
  635. package/core/webui/static/assets/source-serif-4-greek-400-normal-Cw5-AHNN.woff2 +0 -0
  636. package/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
  637. package/core/webui/static/assets/source-serif-4-greek-500-normal-z-Q6FFuG.woff +0 -0
  638. package/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
  639. package/core/webui/static/assets/source-serif-4-latin-400-normal-Dn3IlU-Z.woff +0 -0
  640. package/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
  641. package/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
  642. package/core/webui/static/assets/source-serif-4-latin-ext-400-normal-CEpydyUl.woff +0 -0
  643. package/core/webui/static/assets/source-serif-4-latin-ext-400-normal-Cp7z-ARB.woff2 +0 -0
  644. package/core/webui/static/assets/source-serif-4-latin-ext-500-normal-BYjRCDVy.woff2 +0 -0
  645. package/core/webui/static/assets/source-serif-4-latin-ext-500-normal-D-qasQTj.woff +0 -0
  646. package/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
  647. package/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
  648. package/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
  649. package/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
  650. package/core/webui/static/favicon.png +0 -0
  651. package/core/webui/static/icon-192.png +0 -0
  652. package/core/webui/static/index.html +42 -0
  653. package/core/webui/static/manifest.webmanifest +19 -0
  654. package/core/webui/static/project-settings.css +6458 -0
  655. package/core/webui/static/project-settings.js +9602 -0
  656. package/core/webui/static/sw.js +8 -0
  657. package/core/webui/workspace_service.py +218 -0
  658. package/docs/07_distribution/01_README_NPM.md +281 -0
  659. package/docs/07_distribution/README.md +16 -0
  660. package/docs/README.md +121 -0
  661. package/ecosystem/README.md +129 -0
  662. package/ecosystem/integrations/README.md +38 -0
  663. package/ecosystem/integrations/cline/skills/bugx/SKILL.md +69 -0
  664. package/ecosystem/integrations/dsh/agents/bugx.md +27 -0
  665. package/ecosystem/integrations/dsh/dsh-patch.yml +18 -0
  666. package/ecosystem/integrations/dsh/mcp/cordis.patch.yml +4 -0
  667. package/ecosystem/integrations/dsh/mcp/index.js +219 -0
  668. package/ecosystem/integrations/dsh/mcp/package.json +28 -0
  669. package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +70 -0
  670. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +229 -0
  671. package/ecosystem/integrations/dsh/ui/client.js +87 -0
  672. package/ecosystem/integrations/dsh/ui/cordis.patch.yml +4 -0
  673. package/ecosystem/integrations/dsh/ui/index.js +7 -0
  674. package/ecosystem/integrations/dsh/ui/package.json +27 -0
  675. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +53 -0
  676. package/ecosystem/integrations/opencode/mcp-lock.json +3067 -0
  677. package/ecosystem/integrations/opencode/opencode.json +118 -0
  678. package/ecosystem/integrations/pi/extensions/bugx/README.md +12 -0
  679. package/ecosystem/integrations/pi/extensions/bugx/index.ts +299 -0
  680. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +11 -0
  681. package/ecosystem/integrations/pi/skills/bugx/SKILL.md +69 -0
  682. package/ecosystem/integrations/qoder/CONNECTORS.md +54 -0
  683. package/ecosystem/integrations/qoder/connector-meta.json +21 -0
  684. package/ecosystem/integrations/workbuddy/connector-meta.json +19 -0
  685. package/ecosystem/integrations/workbuddy/icon.png +0 -0
  686. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +70 -0
  687. package/ecosystem/plugins/README.md +37 -0
  688. package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +17 -0
  689. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +16 -0
  690. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +41 -0
  691. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +19 -0
  692. package/ecosystem/plugins/bugx/agents/bugx-judge.md +71 -0
  693. package/ecosystem/plugins/bugx/agents/bugx-worker.md +31 -0
  694. package/ecosystem/plugins/bugx/agents/bugx.md +74 -0
  695. package/ecosystem/plugins/bugx/assets/bugx-avatar-512.png +0 -0
  696. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +118 -0
  697. package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
  698. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +229 -0
  699. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
  700. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
  701. package/interfaces/README.md +143 -0
  702. package/interfaces/bin/README.md +35 -0
  703. package/interfaces/bin/bugx.js +80 -0
  704. package/interfaces/cli/README.md +90 -0
  705. package/interfaces/cli/bugx_cli/__init__.py +4 -0
  706. package/interfaces/cli/bugx_cli/cli.py +1678 -0
  707. package/interfaces/cli/bugx_cli/commands/__init__.py +1 -0
  708. package/interfaces/cli/bugx_cli/commands/advisory.py +94 -0
  709. package/interfaces/cli/bugx_cli/commands/agent.py +3944 -0
  710. package/interfaces/cli/bugx_cli/commands/audit.py +632 -0
  711. package/interfaces/cli/bugx_cli/commands/autonomous.py +260 -0
  712. package/interfaces/cli/bugx_cli/commands/cloud.py +1370 -0
  713. package/interfaces/cli/bugx_cli/commands/daemon.py +50 -0
  714. package/interfaces/cli/bugx_cli/commands/doctor.py +1345 -0
  715. package/interfaces/cli/bugx_cli/commands/goal.py +107 -0
  716. package/interfaces/cli/bugx_cli/commands/interaction.py +244 -0
  717. package/interfaces/cli/bugx_cli/commands/knowledge.py +617 -0
  718. package/interfaces/cli/bugx_cli/commands/lifecycle.py +2763 -0
  719. package/interfaces/cli/bugx_cli/commands/patch.py +1014 -0
  720. package/interfaces/cli/bugx_cli/commands/plugin.py +2714 -0
  721. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +1446 -0
  722. package/interfaces/cli/bugx_cli/commands/plugin_cline.py +269 -0
  723. package/interfaces/cli/bugx_cli/commands/plugin_codex.py +74 -0
  724. package/interfaces/cli/bugx_cli/commands/plugin_funide.py +728 -0
  725. package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +216 -0
  726. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +710 -0
  727. package/interfaces/cli/bugx_cli/commands/project.py +670 -0
  728. package/interfaces/cli/bugx_cli/commands/report.py +260 -0
  729. package/interfaces/cli/bugx_cli/commands/skill.py +251 -0
  730. package/interfaces/cli/bugx_cli/commands/stats.py +133 -0
  731. package/interfaces/cli/bugx_cli/commands/system.py +2567 -0
  732. package/interfaces/cli/bugx_cli/common.py +898 -0
  733. package/interfaces/cli/bugx_cli/host_adapters.py +1917 -0
  734. package/interfaces/cli/bugx_cli/hosts/__init__.py +80 -0
  735. package/interfaces/cli/bugx_cli/hosts/base.py +99 -0
  736. package/interfaces/cli/bugx_cli/hosts/registry.py +571 -0
  737. package/interfaces/cli/bugx_cli/hosts/template_engine.py +188 -0
  738. package/interfaces/cli/bugx_cli/infra/__init__.py +209 -0
  739. package/interfaces/cli/bugx_cli/infra/ai_advisor.py +721 -0
  740. package/interfaces/cli/bugx_cli/infra/engine_installer.py +1937 -0
  741. package/interfaces/cli/bugx_cli/infra/host_sync.py +545 -0
  742. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +755 -0
  743. package/interfaces/cli/bugx_cli/infra/security.py +332 -0
  744. package/package.json +98 -4
  745. package/pyproject.toml +246 -0
  746. package/scripts/README.md +118 -0
  747. package/scripts/ensure-python.mjs +97 -0
  748. package/scripts/isolate-npm-readme.mjs +40 -0
  749. package/scripts/runtime.lock.json +31 -0
  750. package/scripts/sync-version.mjs +37 -0
  751. package/scripts/test-npm-wrapper.mjs +265 -0
@@ -0,0 +1,1015 @@
1
+ #!/usr/bin/env python3
2
+ """core/mcp_handlers/tool_table.py - MCP 工具元数据表与输入 Schema 声明。"""
3
+
4
+ from __future__ import annotations
5
+
6
+ import sys
7
+ from typing import Any
8
+ from core.planning import unit_kind
9
+ from core.mcp_handlers import (
10
+ HANDLER_REGISTRY,
11
+ MAX_ARTIFACT_PATH_LENGTH,
12
+ MAX_COMMAND_LENGTH,
13
+ MAX_COVERAGE_PER_CHECKPOINT,
14
+ MAX_EVIDENCE_PER_CHECKPOINT,
15
+ MAX_FINDING_FIELD_LENGTH,
16
+ MAX_FINDING_FINGERPRINT_LENGTH,
17
+ MAX_FINDINGS_PER_CHECKPOINT,
18
+ MAX_MCP_JSON_DEPTH,
19
+ MAX_MCP_JSON_KEYS,
20
+ MAX_MCP_REQUEST_BYTES,
21
+ MAX_UNITS_PER_CLAIM,
22
+ )
23
+ from core.supervisor import audit_supervisor
24
+ from core.supervisor.supervisor_models import (
25
+ VALID_COVERAGE_STATES,
26
+ VALID_EVIDENCE_STATES,
27
+ )
28
+ LEASE_SECONDS_MAX = audit_supervisor.MAX_LEASE_SECONDS
29
+
30
+ _HOST_ONLY = frozenset({"host"})
31
+ _WORKER_ONLY = frozenset({"worker"})
32
+ _SHARED_ROLES = frozenset({"host", "worker"})
33
+
34
+ UNIT_BUSINESS_PATTERN = f"^{unit_kind.UnitKind.BUSINESS.value}:.+"
35
+
36
+
37
+ def _finding_severity_levels() -> tuple[str, ...]:
38
+ """finding 严重度单一真源(BX-ENGINE-18);委托给唯一访问器。"""
39
+ try:
40
+ from core.supervisor.supervisor_models import finding_severity_levels
41
+
42
+ return finding_severity_levels()
43
+ except ImportError:
44
+ return ("info", "low", "medium", "high", "critical")
45
+
46
+
47
+ _FINDING_SEVERITY_LEVELS = _finding_severity_levels()
48
+
49
+ def _build_tool_table() -> tuple[tuple[frozenset[str], dict[str, object]], ...]:
50
+ """构建 MCP 工具元数据表 —— 角色归属与 JSON schema 的唯一声明处。
51
+
52
+ DES-08:每个工具的角色与其 ``inputSchema`` 在此同处声明,使「新增一个工具」
53
+ 只需改这一处;``HOST_TOOLS`` / ``WORKER_TOOLS`` / ``READ_ONLY_TOOLS``
54
+ 由本表派生,``HANDLER_REGISTRY`` 由 ``_assert_tool_registry_consistent()``
55
+ 在导入期强制校验。
56
+ """
57
+ string_array = {"type": "array", "items": {"type": "string"}}
58
+ finding_schema = {
59
+ "type": "array", "maxItems": 50,
60
+ "items": {
61
+ "type": "object", "required": ["fingerprint"],
62
+ "properties": {
63
+ "fingerprint": {"type": "string", "minLength": 1, "maxLength": 256},
64
+ "id": {"type": "string", "minLength": 1, "maxLength": 256},
65
+ "case_id": {"type": "string", "minLength": 1, "maxLength": 256},
66
+ "title": {"type": "string", "minLength": 1, "maxLength": 4096},
67
+ "root_cause": {"type": "string", "minLength": 1, "maxLength": 4096},
68
+ "severity": {
69
+ # BX-ENGINE-18:由 finding 严重度单一真源渲染 enum,
70
+ # 消除「schema 无 enum / 门禁有词表」的漂移面。
71
+ "type": "string", "maxLength": 32,
72
+ "enum": list(_FINDING_SEVERITY_LEVELS),
73
+ },
74
+ "confidence": {"type": "number", "minimum": 0, "maximum": 1},
75
+ "evidence": {
76
+ "type": "array", "minItems": 1, "maxItems": 50,
77
+ "items": {"type": "object", "required": ["path"],
78
+ "properties": {
79
+ "path": {"type": "string", "minLength": 1, "maxLength": 1024},
80
+ "line": {"type": "integer", "minimum": 1},
81
+ }, "additionalProperties": True},
82
+ },
83
+ "reproducible": {"type": "boolean"},
84
+ "reproduction": {"type": "string", "maxLength": 4096},
85
+ # PE-20261005-003 集成:结构化复现三件套(W3),自动裁决据此
86
+ # 认定"真实复现步骤";非空字符串才入 state。
87
+ "poc_cmd": {"type": "string", "minLength": 1, "maxLength": 4096},
88
+ "poc_input": {"type": "string", "minLength": 1, "maxLength": 4096},
89
+ "poc_negative_input": {"type": "string", "maxLength": 4096},
90
+ },
91
+ # Supervisor performs the shared bounded JSON validation; unknown
92
+ # finding fields remain forward-compatible with agent_eval.
93
+ "additionalProperties": True,
94
+ },
95
+ }
96
+ evidence_schema = {
97
+ "type": "object",
98
+ "maxProperties": MAX_EVIDENCE_PER_CHECKPOINT,
99
+ "additionalProperties": {
100
+ "type": "object",
101
+ "required": [
102
+ "command", "exit_code", "artifact_path", "artifact_sha256",
103
+ "target_fingerprint", "timestamp", "worker_id", "run_id",
104
+ "round_no", "lease_id", "status",
105
+ ],
106
+ "properties": {
107
+ "command": {
108
+ "type": "string", "minLength": 1,
109
+ "maxLength": MAX_COMMAND_LENGTH,
110
+ "description": "真实执行的验证命令,不是计划命令。",
111
+ },
112
+ "exit_code": {
113
+ "type": "integer",
114
+ "description": "真实验证命令退出码;status=passed 时必须为 0。",
115
+ },
116
+ "artifact_path": {
117
+ "type": "string", "minLength": 1,
118
+ "maxLength": MAX_ARTIFACT_PATH_LENGTH,
119
+ "description": "当前 claim artifact_root 内、相对仓库根的文件路径。",
120
+ },
121
+ "artifact_sha256": {
122
+ "type": "string", "pattern": "^[0-9a-fA-F]{64}$",
123
+ "description": "artifact 文件实际 SHA-256。",
124
+ },
125
+ "target_fingerprint": {"type": "string", "minLength": 1},
126
+ "timestamp": {"type": "number", "exclusiveMinimum": 0},
127
+ "worker_id": {"type": "string", "minLength": 1},
128
+ "run_id": {"type": "string", "minLength": 1},
129
+ "round_no": {"type": "integer", "minimum": 1},
130
+ "lease_id": {"type": "string", "minLength": 1},
131
+ "status": {
132
+ "type": "string", "enum": sorted(VALID_EVIDENCE_STATES),
133
+ "description": (
134
+ "证据状态。covered 是 coverage 值,不是 evidence 值;"
135
+ "覆盖通过时使用 passed。"
136
+ ),
137
+ },
138
+ "execution_receipt": {
139
+ "type": "object",
140
+ "required": [
141
+ "schema_version", "execution_id", "worker_id", "lease_id",
142
+ "command", "exit_code", "artifact_path", "artifact_sha256", "status",
143
+ ],
144
+ "properties": {
145
+ "schema_version": {"type": "integer", "const": 1},
146
+ "execution_id": {"type": "string", "minLength": 1},
147
+ "worker_id": {"type": "string", "minLength": 1},
148
+ "lease_id": {"type": "string", "minLength": 1},
149
+ "command": {"type": "string", "minLength": 1, "maxLength": MAX_COMMAND_LENGTH},
150
+ "exit_code": {"type": "integer"},
151
+ "artifact_path": {"type": "string", "minLength": 1, "maxLength": MAX_ARTIFACT_PATH_LENGTH},
152
+ "artifact_sha256": {"type": "string", "pattern": "^[0-9a-fA-F]{64}$"},
153
+ "status": {"type": "string", "enum": sorted(VALID_EVIDENCE_STATES)},
154
+ },
155
+ "additionalProperties": False,
156
+ },
157
+ },
158
+ },
159
+ }
160
+ table: tuple[tuple[frozenset[str], dict[str, object]], ...] = (
161
+ (_HOST_ONLY, {
162
+ "name": "bugx_supervisor_start",
163
+ "description": "启动或幂等复用当前 BugX Session 的本地 Supervisor。",
164
+ "inputSchema": {"type": "object", "properties": {
165
+ "caller_role": {"type": "string", "enum": ["host"]},
166
+ "run_id": {"type": "string"}, "life_score": {"type": "number"},
167
+ "max_rounds": {"type": "integer", "minimum": 1},
168
+ "max_wall_seconds": {"type": "number", "exclusiveMinimum": 0},
169
+ "max_round_wall_seconds": {"type": "number", "exclusiveMinimum": 0},
170
+ "max_tool_calls": {"type": "integer", "minimum": 0},
171
+ "max_cost_units": {"type": "number", "minimum": 0},
172
+ "max_concurrency": {
173
+ "type": "integer", "minimum": 1,
174
+ "description": "省略时按当前机器承载能力动态解析",
175
+ },
176
+ "allow_serial": {"type": "boolean"}, "serial_reason": {"type": "string"},
177
+ "require_confirmation": {"type": "boolean", "const": True, "default": True},
178
+ "project_id": {"type": "string"}, "session_id": {"type": "string"},
179
+ "round_id": {"type": "string"}, "life_id": {"type": "string"},
180
+ "plan_hash": {"type": "string"}, "life_kind": {"type": "string", "enum": ["mine", "fix"]},
181
+ "clean_aborted": {
182
+ "type": "boolean", "default": False,
183
+ "description": "无人值守清理 aborted runtime gate 后启动新 run;省略时保持交互阻断",
184
+ },
185
+ }, "required": ["caller_role"]},
186
+ }),
187
+ (_HOST_ONLY, {
188
+ "name": "bugx_supervisor_findings",
189
+ "description": "DOC-230 3.8 第 4 项:修复历史 finding 的 severity(脏数据出口)。只改 severity 字段,绝不改动确认状态;值必须命中写侧词表;真实变更写 finding_severity_repaired 审计事件;幂等调用不推进 revision。角色归属以工具表为单一真源(DOC-230 3.6):handler 与 schema 均为 host-only。",
190
+ "inputSchema": {"type": "object", "required": ["caller_role", "fix_severity", "finding", "severity"], "properties": {
191
+ "caller_role": {"type": "string", "enum": ["host"]},
192
+ "fix_severity": {"type": "boolean", "const": True, "description": "当前唯一支持的写操作;显式声明 type 让客户端拿到布尔类型信息(裸 const 会被部分宿主序列化成字符串后拒收,实测 2026-11-09)"},
193
+ "finding": {"type": "string", "minLength": 1, "maxLength": 512, "description": "finding_key / fingerprint / id / finding_id 任一"},
194
+ "severity": {"type": "string", "enum": list(_FINDING_SEVERITY_LEVELS)},
195
+ "reason": {"type": "string", "minLength": 1, "maxLength": 512, "description": "合法值之间改级的理由(C1/A12:severity 参与 Life 奖励与评分判定,静默改级会成为刷分/藏缺陷工具);修复非法值无需提供"},
196
+ "expected_revision": {"type": "integer", "minimum": 0},
197
+ }},
198
+ }),
199
+ (_HOST_ONLY, {
200
+ "name": "bugx_supervisor_reset_budget",
201
+ "description": "预算耗尽时开启新的预算 epoch;保留 findings、coverage 和 history,必要时 force 回收残留租约。角色归属以工具表为单一真源(DOC-230 3.6):handler 与 schema 均为 host-only。",
202
+ "inputSchema": {"type": "object", "properties": {
203
+ "caller_role": {"type": "string", "enum": ["host"]},
204
+ "expected_revision": {"type": "integer", "minimum": 0},
205
+ "force": {"type": "boolean", "default": False},
206
+ "renew_wall_clock": {"type": "boolean", "default": False},
207
+ "max_rounds": {"type": "integer", "minimum": 1},
208
+ "max_wall_seconds": {"type": "number", "exclusiveMinimum": 0},
209
+ "max_round_wall_seconds": {"type": "number", "exclusiveMinimum": 0},
210
+ "max_tool_calls": {"type": "integer", "minimum": 0},
211
+ "max_cost_units": {"type": "number", "minimum": 0},
212
+ "max_concurrency": {"type": "integer", "minimum": 1},
213
+ "allow_serial": {"type": "boolean"},
214
+ "serial_reason": {"type": "string"},
215
+ "require_confirmation": {"type": "boolean", "const": True, "default": True},
216
+ }, "required": ["caller_role"]},
217
+ }),
218
+ (_HOST_ONLY, {
219
+ "name": "bugx_supervisor_rebind_target",
220
+ "description": "覆盖计划已重建且 workspace fingerprint 发生变化时,显式重绑 Supervisor 目标并保留历史证据。角色归属以工具表为单一真源(DOC-230 3.6):handler 与 schema 均为 host-only。",
221
+ "inputSchema": {"type": "object", "required": ["caller_role", "reason"], "properties": {
222
+ "caller_role": {"type": "string", "enum": ["host"]},
223
+ "reason": {"type": "string", "minLength": 1, "maxLength": 512},
224
+ "expected_revision": {"type": "integer", "minimum": 0},
225
+ }},
226
+ }),
227
+ (_HOST_ONLY, {
228
+ "name": "bugx_supervisor_sync_finding_decisions",
229
+ "description": "校验活动 lifecycle 的 findings.json 绑定、现有候选 key、确认工件与 remediation 后,将审核决策同步到 Supervisor 权威状态。可显式请求把相同 key 候选的 title/root_cause/location/description 恢复为 Supervisor 原值;fingerprint/id 不匹配仍拒绝。",
230
+ "inputSchema": {"type": "object", "properties": {
231
+ "caller_role": {"type": "string", "enum": ["host"]},
232
+ "expected_revision": {"type": "integer", "minimum": 0},
233
+ "canonicalize_report_identity": {
234
+ "type": "boolean", "default": False,
235
+ "description": "仅修复相同 key 候选的非 key 身份字段;未知 key、fingerprint/id 不匹配仍拒绝。",
236
+ },
237
+ }, "required": ["caller_role"]},
238
+ }),
239
+ (_HOST_ONLY, {
240
+ "name": "bugx_supervisor_verify_finding",
241
+ "description": "宿主受控验证一条 Finding:引擎执行两次独立正例和固定负对照,记录原始输出与 hash;Worker 自报字段不具备确认资格。",
242
+ "inputSchema": {"type": "object", "required": ["caller_role", "finding", "recipe"], "properties": {
243
+ "caller_role": {"type": "string", "enum": ["host"]},
244
+ "finding": {"type": "string", "minLength": 1, "maxLength": 512},
245
+ "recipe": {"type": "object", "description": "预先固定的 positive/negative_control argv、cwd、oracle_reference、oracle_hash 与判据。"},
246
+ "request_id": {"type": "string", "minLength": 1, "maxLength": 128},
247
+ "expected_revision": {"type": "integer", "minimum": 0},
248
+ }},
249
+ }),
250
+ (_HOST_ONLY, {
251
+ "name": "bugx_supervisor_confirm_finding",
252
+ "description": (
253
+ "宿主原子确认或驳回一个 Finding:证据由引擎核验 receipt 派生并自检"
254
+ "(confirmed 必须已有 bugx_supervisor_verify_finding 的 CONFIRMED receipt),"
255
+ "缺料即拒绝,不再写入不可收敛的 confirmation。"
256
+ ),
257
+ "inputSchema": {"type": "object", "required": [
258
+ "caller_role", "finding_id", "decision", "reason",
259
+ ], "properties": {
260
+ "caller_role": {"type": "string", "enum": ["host"]},
261
+ "finding_id": {"type": "string", "minLength": 1},
262
+ "decision": {"type": "string", "enum": ["confirmed", "rejected"]},
263
+ "reason": {"type": "string", "minLength": 1, "maxLength": 2000},
264
+ "expected_revision": {"type": "integer", "minimum": 0},
265
+ "rejection_class": {
266
+ "type": "string", "description": "rejected 必填:expected_behavior/environment/tool_failure/duplicate/insufficient_evidence/flaky/not_reproducible。",
267
+ },
268
+ "root_cause_verified": {
269
+ "type": "boolean", "description": "confirmed 必填 true:宿主对根因的显式断言(引擎记录,不代为生成)。",
270
+ },
271
+ "oracle": {
272
+ "type": "object",
273
+ "description": "confirmed 需要 tier(requirement/contract/test/invariant/differential)与 provenance_kind(user-approved/repository-contract/external-spec/independent-implementation/runtime-invariant);verified 与 independent_from_change 由引擎按 oracle_hash 与证据文件核算,不接受声明。",
274
+ "properties": {
275
+ "tier": {"type": "string"},
276
+ "provenance_kind": {"type": "string"},
277
+ "reference": {"type": "string", "description": "可选断言:必须与核验 recipe 的 oracle_reference 一致。"},
278
+ },
279
+ },
280
+ "target_platform": {"type": "string", "description": "可选:目标平台标识,缺省 source。"},
281
+ "remediation": {
282
+ "type": "object",
283
+ "description": "可选修复记录:decision=fixed 需 fix_ref(commit_ref/test_ref)+ verification_passed=true;deferred 需 proposal/verification_plan/blast_radius。",
284
+ },
285
+ }},
286
+ }),
287
+ (_HOST_ONLY, {
288
+ "name": "bugx_supervisor_bootstrap_coverage",
289
+ "description": "在用户明确选择‘运行引导创建’后,安全创建当前生命周期覆盖清单;不改写活动 Supervisor。",
290
+ "inputSchema": {"type": "object", "required": ["caller_role", "confirmed"], "properties": {
291
+ "caller_role": {"type": "string", "enum": ["host"]},
292
+ "confirmed": {"type": "boolean", "description": "宿主原生单选已返回运行引导创建"},
293
+ }},
294
+ }),
295
+ (_SHARED_ROLES, {"name": "bugx_supervisor_status", "description": "读取状态、回收过期租约并返回下一动作;支持传入 since_revision 进行增量轮询。", "inputSchema": {"type": "object", "properties": {"since_revision": {"type": "integer", "minimum": 0, "description": "增量游标:若传入且与当前 revision 一致,返回最小未变更快照"}}}},),
296
+ (_SHARED_ROLES, {"name": "bugx_supervisor_gate", "description": "检查当前 Life 是否满足并发门禁;支持传入 since_revision 进行增量轮询。", "inputSchema": {"type": "object", "properties": {"since_revision": {"type": "integer", "minimum": 0, "description": "增量游标:若传入且与当前 revision 一致,返回最小未变更快照"}}}},),
297
+ (_SHARED_ROLES, {"name": "bugx_supervisor_coverage", "description": "按 unit_id、status_filter 或 revision 增量读取覆盖状态,避免传输全量 coverage。", "inputSchema": {"type": "object", "properties": {"unit_id": {"type": "string", "minLength": 1}, "status_filter": {"type": "string", "enum": sorted(VALID_COVERAGE_STATES)}, "since_revision": {"type": "integer", "minimum": 0}}}},),
298
+ (_HOST_ONLY, {
299
+ "name": "bugx_supervisor_reopen_finding",
300
+ "description": "宿主有审计理由地重开误报/拒绝记录;仅退回待验证,保留旧证据,不直接确认。",
301
+ "inputSchema": {"type": "object", "required": ["caller_role", "finding_id", "reason", "expected_revision"],
302
+ "properties": {"caller_role": {"type": "string", "enum": ["host"]},
303
+ "finding_id": {"type": "string", "minLength": 1},
304
+ "reason": {"type": "string", "minLength": 1, "maxLength": 2000},
305
+ "expected_revision": {"type": "integer", "minimum": 0}}},
306
+ }),
307
+ (_HOST_ONLY, {"name": "bugx_supervisor_admit_business", "description": "宿主显式授权高风险业务链路提前进入候选队列;不改变覆盖完成判定。", "inputSchema": {"type": "object", "required": ["caller_role", "unit_id", "risk_score", "reason"], "properties": {"caller_role": {"type": "string", "enum": ["host"]}, "unit_id": {"type": "string", "pattern": UNIT_BUSINESS_PATTERN}, "risk_score": {"type": "number", "minimum": 70, "maximum": 100}, "reason": {"type": "string", "minLength": 1, "maxLength": 512}, "expected_revision": {"type": "integer"}}}},),
308
+ (_WORKER_ONLY, {"name": "bugx_supervisor_claim", "description": "为一个 Worker 领取独立覆盖单元/亲和任务包、资源租约和专属 artifact_root。提交后可用 continue_worker=true 由同一身份继续领取未完成单元,也可在同一 Round 接手 expired/released worker。", "inputSchema": {"type": "object", "required": ["caller_role", "worker_id"], "properties": {"caller_role": {"type": "string", "enum": ["worker"]}, "worker_id": {"type": "string"}, "lease_seconds": {"type": "number", "exclusiveMinimum": 0, "maximum": LEASE_SECONDS_MAX}, "unit_ids": {"type": "array", "minItems": 1, "maxItems": 1, "items": {"type": "string"}}, "allow_bundle": {"type": "boolean", "default": False}, "continue_worker": {"type": "boolean", "default": False}, "process_pid": {"type": "integer", "minimum": 1, "description": "真实 Worker/执行进程 PID;不能填 Supervisor、MCP 服务或时间戳等占位 PID,否则会被僵尸检测回收。"}, "resource_keys": string_array, "supersede_worker_id": {"type": "string", "minLength": 1}, "recover_expired": {"type": "boolean", "default": False, "description": "PE-20261005-003:同名单 worker 已终态(expired/released)时一键接手——继承 unit_ids/artifact_root 重新计时,返回 recovered_from;宿主随后走 worker_start(无 PID)+ checkpoint 代交成品。"}, "expected_revision": {"type": "integer"}, "worker_role": {"type": "string"}, "preferred_affinity": {"type": "string"}}}},),
309
+ (_WORKER_ONLY, {"name": "bugx_supervisor_worker_start", "description": "确认 Worker 已由宿主真实启动;只有确认后才计入并发重叠。", "inputSchema": {"type": "object", "required": ["caller_role", "worker_id"], "properties": {"caller_role": {"type": "string", "enum": ["worker"]}, "worker_id": {"type": "string"}, "provider": {"type": "string", "minLength": 1, "maxLength": 128}, "execution_id": {"type": "string"}, "process_pid": {"type": "integer", "minimum": 1, "description": "真实且当前存活的 Worker/执行进程 PID;不要传 MCP 服务进程或虚构 PID。"}, "expected_revision": {"type": "integer"}}}},),
310
+ (_WORKER_ONLY, {"name": "bugx_supervisor_tool_call", "description": "记录 Worker 已执行的一次工具调用及成本;不会执行命令。", "inputSchema": {"type": "object", "required": ["caller_role", "worker_id"], "properties": {"caller_role": {"type": "string", "enum": ["worker"]}, "worker_id": {"type": "string"}, "cost_units": {"type": "number", "minimum": 0}, "tool_name": {"type": "string"}, "expected_revision": {"type": "integer"}}}},),
311
+ (_WORKER_ONLY, {"name": "bugx_supervisor_heartbeat", "description": "续租 Worker lease;不会执行工具或改变生命值。带 PID 的租约必须回显 claim 返回的 heartbeat_nonce。", "inputSchema": {"type": "object", "required": ["caller_role", "worker_id"], "properties": {"caller_role": {"type": "string", "enum": ["worker"]}, "worker_id": {"type": "string"}, "lease_seconds": {"type": "number", "exclusiveMinimum": 0, "maximum": LEASE_SECONDS_MAX}, "heartbeat_nonce": {"type": "string", "minLength": 1, "maxLength": 128}, "expected_revision": {"type": "integer"}}}},),
312
+ (_WORKER_ONLY, {"name": "bugx_supervisor_checkpoint", "description": "提交 Worker 的发现、覆盖、证据、错误签名和断点手记;支持同任务包内最多 5 个亲和单元批量提交。coverage/evidence/notes 的 key 必须逐字来自本次 claim 的 unit_ids,禁止 summary/finding/knowledge 等自由 key;coverage 使用 covered/unverified 等覆盖状态;evidence.status 必须使用 passed/failed/error/skipped/blocked,不能填 covered。life_delta 必须是数字 0。", "inputSchema": {"type": "object", "required": ["caller_role", "worker_id", "checkpoint_id"], "properties": {"caller_role": {"type": "string", "enum": ["worker"]}, "worker_id": {"type": "string"}, "checkpoint_id": {"type": "string", "minLength": 1, "description": "同一有效载荷重试必须复用同一个 checkpoint_id"}, "findings": finding_schema, "coverage": {"type": "object", "maxProperties": 5, "additionalProperties": {"type": "string", "enum": ["pending", "covered", "blocked", "unverified", "partial", "not_applicable", "stale", "removed", "superseded", "corrupted"]}}, "evidence": evidence_schema, "signatures": {"type": "array", "maxItems": 10, "items": {"type": "string", "minLength": 1, "maxLength": 512}}, "notes": {"type": "object", "maxProperties": 5, "description": "仅可写当前 claim 的精确 unit_id -> 单元断点手记;禁止 summary/finding/knowledge 等自由 key。", "additionalProperties": {"type": "string", "minLength": 1, "maxLength": 2000}}, "life_delta": {"type": "number", "const": 0, "default": 0, "description": "必须为 JSON 数字 0,不能写成字符串。"}, "expected_revision": {"type": "integer"}}}},),
313
+ (_HOST_ONLY, {"name": "bugx_supervisor_salvage_checkpoint", "description": "DOC-203 D2:宿主代交 state=expired 的 worker claim 已固化 checkpoint(PE-20261005-003 恢复闭环的落账通道)。与 worker 通道同强度校验:五元组绑定(worker_id/run_id/round_no/lease_id/target_fingerprint)+ 工件盘上 sha256 重算 + 工件 mtime 不早于本 claim 领取时刻 + findings 不得携带 confirmation 块 + 每 claim 一次性(salvaged_at)。熔断(worker_attempts_exhausted)不放宽:salvage 只落账已完成证据,不产生新 claim。", "inputSchema": {"type": "object", "required": ["caller_role", "worker_id", "checkpoint_id"], "properties": {"caller_role": {"type": "string", "enum": ["host"]}, "worker_id": {"type": "string"}, "checkpoint_id": {"type": "string", "minLength": 1}, "findings": finding_schema, "coverage": {"type": "object", "maxProperties": 5, "additionalProperties": {"type": "string", "enum": ["pending", "covered", "blocked", "unverified", "partial", "not_applicable", "stale", "removed", "superseded", "corrupted"]}}, "evidence": evidence_schema, "signatures": {"type": "array", "maxItems": 10, "items": {"type": "string", "minLength": 1, "maxLength": 512}}, "notes": {"type": "object", "maxProperties": 5, "additionalProperties": {"type": "string", "minLength": 1, "maxLength": 2000}}, "life_delta": {"type": "number", "const": 0, "default": 0}, "expected_revision": {"type": "integer"}}}},),
314
+ (_WORKER_ONLY, {"name": "bugx_supervisor_begin_long_call", "description": "DOC-203 D3:为一次不可分的长工具调用(如 10-20 分钟探针)声明保活窗口。租约推进到 max(当前值, min(now+expected_seconds+60, total_lease_deadline))——绝不缩短现有租约;窗口内不回收,窗口结束照常回收(活性语义保留)。每 claim 最多 5 次;调用同时刷新心跳活性。", "inputSchema": {"type": "object", "required": ["caller_role", "worker_id", "expected_seconds"], "properties": {"caller_role": {"type": "string", "enum": ["worker"]}, "worker_id": {"type": "string"}, "expected_seconds": {"type": "number", "exclusiveMinimum": 0, "maximum": 1800}, "expected_revision": {"type": "integer"}}}},),
315
+ (_WORKER_ONLY, {
316
+ "name": "bugx_supervisor_run_sandboxed_probe",
317
+ "description": "按已启动 claim 的 lease_id/execution_id 以 shell=False 执行单条 argv,自动保存输出并返回 evidence(含 SHA-256 和 execution_receipt),可原样用于 checkpoint;不自动判定覆盖。这是有界执行,不是文件系统隔离沙箱。",
318
+ "inputSchema": {
319
+ "type": "object",
320
+ "required": ["caller_role", "worker_id", "lease_id", "execution_id", "command"],
321
+ "properties": {
322
+ "caller_role": {"type": "string", "enum": ["worker"]},
323
+ "worker_id": {"type": "string"},
324
+ "lease_id": {"type": "string", "minLength": 1},
325
+ "execution_id": {"type": "string", "minLength": 1},
326
+ "command": {
327
+ "description": "argv 参数数组;不启 shell。每次只执行一条命令,由 MCP 捕获 stdout/stderr。",
328
+ "type": "array",
329
+ "minItems": 1,
330
+ "maxItems": 64,
331
+ "items": {"type": "string", "minLength": 1, "maxLength": 4096},
332
+ },
333
+ "timeout_seconds": {"type": "number", "minimum": 0.5, "maximum": 60.0, "default": 10.0},
334
+ "env": {"type": "object"},
335
+ "expected_revision": {"type": "integer"},
336
+ },
337
+ },
338
+ }),
339
+ (_WORKER_ONLY, {
340
+ "name": "bugx_supervisor_submit_finding",
341
+ "description": "强类型提交漏洞发现与双向差分证据对;强校验 Epoch 租约代数与反事实双向证据。",
342
+ "inputSchema": {
343
+ "type": "object",
344
+ "required": ["caller_role", "worker_id", "finding", "differential_evidence"],
345
+ "properties": {
346
+ "caller_role": {"type": "string", "enum": ["worker"]},
347
+ "worker_id": {"type": "string"},
348
+ "epoch": {"type": "integer", "minimum": 1},
349
+ "finding": {
350
+ "type": "object",
351
+ "required": ["fingerprint", "title", "severity", "root_cause"],
352
+ "properties": {
353
+ "fingerprint": {"type": "string", "minLength": 1, "maxLength": 256},
354
+ "id": {"type": "string"},
355
+ "title": {"type": "string", "minLength": 1},
356
+ "severity": {"type": "string", "enum": list(_FINDING_SEVERITY_LEVELS)},
357
+ "cwe": {"type": "string"},
358
+ "cvss": {"type": "number", "minimum": 0, "maximum": 10},
359
+ "root_cause": {"type": "string", "minLength": 1},
360
+ "remediation": {"type": "string"},
361
+ },
362
+ "additionalProperties": True,
363
+ },
364
+ "differential_evidence": {
365
+ "type": "object",
366
+ "required": ["baseline_payload", "baseline_response", "exploit_payload", "exploit_response"],
367
+ "properties": {
368
+ "baseline_payload": {"type": "string"},
369
+ "baseline_response": {"type": "string"},
370
+ "exploit_payload": {"type": "string"},
371
+ "exploit_response": {"type": "string"},
372
+ "assertion_differential": {"type": "string"},
373
+ },
374
+ "additionalProperties": True,
375
+ },
376
+ "expected_revision": {"type": "integer"},
377
+ },
378
+ },
379
+ }),
380
+ (_HOST_ONLY, {"name": "bugx_supervisor_next_round", "description": "在所有 Worker 提交且并发门禁满足后推进下一 Round。gate_failure_mode=report 时门禁未满足返回结构化 GATE_UNSATISFIED(只读、无副作用),供自治宿主程序化决策;缺省使用 report,交互宿主可显式选择 prompt_user。", "inputSchema": {"type": "object", "required": ["caller_role"], "properties": {"caller_role": {"type": "string", "enum": ["host"]}, "expected_revision": {"type": "integer"}, "gate_failure_mode": {"type": "string", "enum": ["prompt_user", "report"], "default": "report"}}}},),
381
+ (_HOST_ONLY, {"name": "bugx_supervisor_bind_context", "description": "由宿主把控制面绑定到下一 Life 的 Project/Session/Round/plan(不创建新 Round)。", "inputSchema": {"type": "object", "required": ["caller_role"], "properties": {"caller_role": {"type": "string", "enum": ["host"]}, "project_id": {"type": "string"}, "session_id": {"type": "string"}, "round_id": {"type": "string"}, "life_id": {"type": "string"}, "plan_hash": {"type": "string"}}}},),
382
+ (_HOST_ONLY, {"name": "bugx_supervisor_finish", "description": "由宿主在覆盖、证据和并发门禁完成后结束 Supervisor run。", "inputSchema": {"type": "object", "required": ["caller_role"], "properties": {"caller_role": {"type": "string", "enum": ["host"]}, "coverage_complete": {"type": ["boolean", "null"]}, "expected_revision": {"type": "integer"}}}},),
383
+ (_HOST_ONLY, {"name": "bugx_supervisor_fail", "description": "由宿主记录不可恢复的 Supervisor 失败并释放租约。", "inputSchema": {"type": "object", "required": ["caller_role", "reason"], "properties": {"caller_role": {"type": "string", "enum": ["host"]}, "reason": {"type": "string"}, "expected_revision": {"type": "integer"}}}},),
384
+ (_HOST_ONLY, {"name": "bugx_supervisor_recover", "description": "由宿主从主状态或合法备份恢复并返回当前状态;可显式隔离历史 worker 尝试计数,损坏时明确失败。", "inputSchema": {"type": "object", "required": ["caller_role"], "properties": {"caller_role": {"type": "string", "enum": ["host"]}, "reset_worker_attempts": {"type": "boolean", "default": False, "description": "将 expired/released/submitted 历史 claim fence 到旧代际,解除全 Run 尝试硬顶"}}}},),
385
+ (_HOST_ONLY, {
386
+ "name": "graph_start",
387
+ "description": "建立私有项目快照和确定性 Recon→Repro→Review→(Patch)→Check→Report 图;由 Host 自行启动原生 Agent。",
388
+ "inputSchema": {
389
+ "type": "object",
390
+ "required": [
391
+ "caller_role", "target", "goal", "modifications", "invariants",
392
+ "ownership_boundaries", "acceptance_criteria", "target_files",
393
+ ],
394
+ "properties": {
395
+ "caller_role": {"type": "string", "enum": ["host"]},
396
+ "target": {"type": "string", "minLength": 1, "maxLength": 2048},
397
+ "goal": {"type": "string", "minLength": 1, "maxLength": 8192},
398
+ "modifications": {"type": "array", "minItems": 1, "maxItems": 64,
399
+ "items": {"type": "string", "minLength": 1, "maxLength": 8192}},
400
+ "invariants": {"type": "array", "minItems": 1, "maxItems": 64,
401
+ "items": {"type": "string", "minLength": 1, "maxLength": 8192}},
402
+ "ownership_boundaries": {"type": "array", "minItems": 1, "maxItems": 64,
403
+ "items": {"type": "string", "minLength": 1, "maxLength": 8192}},
404
+ "acceptance_criteria": {"type": "array", "minItems": 1, "maxItems": 64,
405
+ "items": {"type": "string", "minLength": 1, "maxLength": 8192}},
406
+ "target_files": {"type": "array", "minItems": 1, "maxItems": 100,
407
+ "items": {"type": "string", "minLength": 1, "maxLength": 512}},
408
+ "include_patch": {"type": "boolean", "default": False},
409
+ "max_concurrency": {"type": "integer", "minimum": 1, "maximum": 16, "default": 1},
410
+ },
411
+ },
412
+ }),
413
+ (_HOST_ONLY, {
414
+ "name": "graph_next",
415
+ "description": "返回依赖就绪且容量允许的下一 GraphTask,并保留该任务直至 Host 绑定 Agent。",
416
+ "inputSchema": {"type": "object", "required": ["caller_role", "graph_id"], "properties": {
417
+ "caller_role": {"type": "string", "enum": ["host"]},
418
+ "graph_id": {"type": "string", "pattern": "^[0-9a-f]{32}$"},
419
+ }},
420
+ }),
421
+ (_HOST_ONLY, {
422
+ "name": "graph_bind_agent",
423
+ "description": "登记 Host 已启动的原生子 Agent 身份;Review 身份必须不同于 Recon/Repro 生产者。",
424
+ "inputSchema": {"type": "object", "required": [
425
+ "caller_role", "graph_id", "task_id", "native_agent_id",
426
+ ], "properties": {
427
+ "caller_role": {"type": "string", "enum": ["host"]},
428
+ "graph_id": {"type": "string", "pattern": "^[0-9a-f]{32}$"},
429
+ "task_id": {"type": "string", "minLength": 1},
430
+ "native_agent_id": {"type": "string", "minLength": 1, "maxLength": 256},
431
+ }},
432
+ }),
433
+ (_HOST_ONLY, {
434
+ "name": "graph_cancel",
435
+ "description": "Fence 图中未终结任务并回收私有快照;不声称能从引擎直接停止宿主原生 Agent。",
436
+ "inputSchema": {"type": "object", "required": [
437
+ "caller_role", "graph_id", "reason",
438
+ ], "properties": {
439
+ "caller_role": {"type": "string", "enum": ["host"]},
440
+ "graph_id": {"type": "string", "pattern": "^[0-9a-f]{32}$"},
441
+ "task_id": {"type": "string"},
442
+ "reason": {"type": "string", "minLength": 1, "maxLength": 2048},
443
+ }},
444
+ }),
445
+ (_HOST_ONLY, {
446
+ "name": "graph_finalize",
447
+ "description": "Host 对终态图收尾裁决并固化不可覆盖的最终报告账本。",
448
+ "inputSchema": {"type": "object", "required": [
449
+ "caller_role", "graph_id", "decision", "summary",
450
+ ], "properties": {
451
+ "caller_role": {"type": "string", "enum": ["host"]},
452
+ "graph_id": {"type": "string", "pattern": "^[0-9a-f]{32}$"},
453
+ "decision": {"type": "string", "enum": ["accepted", "rejected", "inconclusive"]},
454
+ "summary": {"type": "string", "minLength": 1, "maxLength": 8192},
455
+ }},
456
+ }),
457
+ (_WORKER_ONLY, {
458
+ "name": "graph_context",
459
+ "description": "Worker 依绑定 Task 读取声明的快照文件和父工件;必须匹配 Host 注入的 BUGX_NATIVE_AGENT_ID 与 fencing token。",
460
+ "inputSchema": {"type": "object", "required": [
461
+ "caller_role", "graph_id", "task_id", "native_agent_id", "fencing_token",
462
+ ], "properties": {
463
+ "caller_role": {"type": "string", "enum": ["worker"]},
464
+ "graph_id": {"type": "string", "pattern": "^[0-9a-f]{32}$"},
465
+ "task_id": {"type": "string", "minLength": 1},
466
+ "native_agent_id": {"type": "string", "minLength": 1, "maxLength": 256},
467
+ "fencing_token": {"type": "integer", "minimum": 1},
468
+ }},
469
+ }),
470
+ (_WORKER_ONLY, {
471
+ "name": "graph_run_check",
472
+ "description": "Worker 提交受限 CheckPlan;引擎只运行 tests/ 下的 test_*.py unittest 并返回 Observation。",
473
+ "inputSchema": {"type": "object", "required": [
474
+ "caller_role", "graph_id", "task_id", "native_agent_id", "fencing_token", "plan",
475
+ ], "properties": {
476
+ "caller_role": {"type": "string", "enum": ["worker"]},
477
+ "graph_id": {"type": "string", "pattern": "^[0-9a-f]{32}$"},
478
+ "task_id": {"type": "string", "minLength": 1},
479
+ "native_agent_id": {"type": "string", "minLength": 1, "maxLength": 256},
480
+ "fencing_token": {"type": "integer", "minimum": 1},
481
+ "plan": {"type": "object", "required": ["test_files"], "additionalProperties": False,
482
+ "properties": {
483
+ "test_files": {"type": "array", "minItems": 1, "maxItems": 20,
484
+ "items": {"type": "string", "minLength": 1, "maxLength": 512}},
485
+ "timeout_seconds": {"type": "integer", "minimum": 1, "maximum": 300, "default": 60},
486
+ "plan_id": {"type": "string", "maxLength": 128},
487
+ }},
488
+ }},
489
+ }),
490
+ (_WORKER_ONLY, {
491
+ "name": "graph_checkpoint",
492
+ "description": "Worker 提交 bounded artifact envelope 与 SHA-256 内容寻址附件;每阶段最多 3 次 attempt。",
493
+ "inputSchema": {"type": "object", "required": [
494
+ "caller_role", "graph_id", "task_id", "native_agent_id", "fencing_token", "envelope",
495
+ ], "properties": {
496
+ "caller_role": {"type": "string", "enum": ["worker"]},
497
+ "graph_id": {"type": "string", "pattern": "^[0-9a-f]{32}$"},
498
+ "task_id": {"type": "string", "minLength": 1},
499
+ "native_agent_id": {"type": "string", "minLength": 1, "maxLength": 256},
500
+ "fencing_token": {"type": "integer", "minimum": 1},
501
+ "envelope": {"type": "object", "required": ["outcome", "summary"],
502
+ "properties": {
503
+ "outcome": {"type": "string", "enum": ["complete", "needs_revision", "failed"]},
504
+ "summary": {"type": "string", "minLength": 1, "maxLength": 8192},
505
+ "reason": {"type": "string", "maxLength": 8192},
506
+ "context": {"type": "object", "maxProperties": 5000},
507
+ "retry_stage": {"type": "string", "enum": ["Recon", "Repro"]},
508
+ "result": {"type": "object"},
509
+ }},
510
+ "attachments": {"type": "array", "maxItems": 50, "items": {
511
+ "type": "object", "required": ["filename", "sha256", "content_base64"],
512
+ "properties": {
513
+ "filename": {"type": "string", "minLength": 1, "maxLength": 512},
514
+ "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
515
+ "content_base64": {"type": "string"},
516
+ },
517
+ }},
518
+ }},
519
+ }),
520
+ (_SHARED_ROLES, {"name": "bugx_knowledge_route", "description": "按项目分类、阶段和错误签名自动判断是否需要检索;高风险时复用有界错题/incident 检索,低风险不检索,不注入历史正文。", "inputSchema": {"type": "object", "properties": {"trigger": {"type": "string", "enum": ["preflight", "strategy", "finding", "failure"], "default": "preflight"}, "query": {"type": "string", "maxLength": 512}, "category": {"type": "string", "maxLength": 96}, "signatures": {"type": "array", "maxItems": 10, "items": {"type": "string", "minLength": 1, "maxLength": 512}}, "context": {"type": "object", "maxProperties": 12}}}},),
521
+ (_SHARED_ROLES, {"name": "bugx_harness_status", "description": "读取当前项目会话的共享验证 harness 注册表;只读,不安装依赖、不执行命令。", "inputSchema": {"type": "object", "properties": {}}},),
522
+ (_SHARED_ROLES, {"name": "bugx_oracle_suggest", "description": "按单元/分类读取或提取有界 repository-contract Oracle 候选;结果仅供参考,不能直接确认 Finding。", "inputSchema": {"type": "object", "properties": {"unit": {"type": "string", "maxLength": 512}, "query": {"type": "string", "maxLength": 512}, "limit": {"type": "integer", "minimum": 1, "maximum": 5, "default": 5}}}},),
523
+ (_SHARED_ROLES, {"name": "bugx_lesson_retrieve", "description": "按当前分类/查询按需检索最多 3 张错题经验卡(只读,600 token 上限);只用于快速碰撞,不是提示词注入。", "inputSchema": {"type": "object", "properties": {"query": {"type": "string"}, "category": {"type": "string"}, "limit": {"type": "integer", "minimum": 1, "maximum": 3}, "token_budget": {"type": "integer", "minimum": 100, "maximum": 600}}}},),
524
+ (_SHARED_ROLES, {"name": "bugx_tool_matrix", "description": "读取实测「问题类别 → 工具」命中矩阵,校正场景选型(只读)。", "inputSchema": {"type": "object", "properties": {}}},),
525
+ (_SHARED_ROLES, {"name": "bugx_incident_hints", "description": "有真实错误签名时按需检索最多 2 个 incident 做快速碰撞(只读、有界,不注入完整卡片)。", "inputSchema": {"type": "object", "properties": {"signatures": string_array, "limit": {"type": "integer", "minimum": 1, "maximum": 2}}}},),
526
+ (_SHARED_ROLES, {"name": "bugx_request_token_renewal", "description": "针对复杂长 PoC 或深度调用链申请动态 Token 续期(单次 +400 Tokens,单生命周期最多 2 次,上限 2400 Tokens)。", "inputSchema": {"type": "object", "required": ["reason"], "properties": {"reason": {"type": "string", "maxLength": 128}, "needed": {"type": "integer", "minimum": 100, "maximum": 800, "default": 400}}}},),
527
+ (_SHARED_ROLES, {"name": "bugx_efficiency_card", "description": "读取最近几轮的效率/校准卡片(time/credited、注入卡片利用率;只读)。", "inputSchema": {"type": "object", "properties": {}}},),
528
+ (_SHARED_ROLES, {
529
+ "name": "bugx_get_stage_harness",
530
+ "description": "获取 BugX 2.0 阶段专精系统提示词与规则切片(按阶段按需获取,支持 gate/explore/mutate/repair/l0 及规则切片)。",
531
+ "inputSchema": {
532
+ "type": "object",
533
+ "required": ["stage"],
534
+ "properties": {
535
+ "stage": {
536
+ "type": "string",
537
+ "description": "阶段标识符:gate / explore / mutate / repair / l0",
538
+ "enum": ["gate", "explore", "mutate", "repair", "l0"],
539
+ },
540
+ "unit_id": {
541
+ "type": "string",
542
+ "description": "可选:当前认领的覆盖单元 ID,用于自动提取匹配的 L2 规则片段",
543
+ },
544
+ "rule": {
545
+ "type": "string",
546
+ "description": "可选:按需加载的 L2 专项规则库 (concurrency / memory_leak / prompt_injection / anti_patterns)",
547
+ "enum": ["concurrency", "memory_leak", "prompt_injection", "anti_patterns"],
548
+ },
549
+ "context": {
550
+ "type": "object",
551
+ "description": "可选:动态注入的上下文事实键值对",
552
+ },
553
+ "source_code": {
554
+ "type": "string",
555
+ "description": "可选:单元源码片段,供 AST 静态推断更精准的 L2 专项规则切片",
556
+ },
557
+ },
558
+ },
559
+ }),
560
+ (_SHARED_ROLES, {
561
+ "name": "bugx_distill_evidence",
562
+ "description": "结构化长堆栈与 Fuzz 输出证据蒸馏器;抽取关键异常、行号定位与断言差异至 ≤15 行,支持文本或 JSON 格式(只读)。",
563
+ "inputSchema": {
564
+ "type": "object",
565
+ "required": ["raw_output"],
566
+ "properties": {
567
+ "raw_output": {
568
+ "type": "string",
569
+ "description": "待蒸馏的原始终端输出、Traceback 或 Fuzz 日志",
570
+ },
571
+ "max_lines": {
572
+ "type": "integer",
573
+ "minimum": 1,
574
+ "maximum": 50,
575
+ "default": 15,
576
+ "description": "最大输出行数,默认 15",
577
+ },
578
+ "format": {
579
+ "type": "string",
580
+ "enum": ["text", "json"],
581
+ "default": "text",
582
+ "description": "输出格式:text(纯文本提要)或 json(结构化字典)",
583
+ },
584
+ },
585
+ },
586
+ }),
587
+ (_SHARED_ROLES, {
588
+ "name": "bugx_inspect_source",
589
+ "description": "安全提取源文件切片与代码视窗(具备越界自愈、UTF-8 容错、沙箱防逃逸与透明符号自愈切片路由)。",
590
+ "inputSchema": {
591
+ "type": "object",
592
+ "required": ["path"],
593
+ "properties": {
594
+ "path": {"type": "string", "description": "目标文件相对或绝对路径"},
595
+ "symbol": {"type": "string", "description": "可选符号名,指定时自动路由至高密度语法自愈切片"},
596
+ "method": {"type": "string", "description": "可选方法名别名"},
597
+ "kind": {"type": "string", "description": "可选种类过滤 (function/method/class)"},
598
+ "start_line": {"type": "integer", "minimum": 1, "default": 1, "description": "起始行号(1-based)"},
599
+ "end_line": {"type": "integer", "minimum": 1, "default": 200, "description": "结束行号(1-based)"},
600
+ "numbered": {"type": "boolean", "default": True, "description": "是否返回带行号的文本"},
601
+ "max_lines": {"type": "integer", "minimum": 1, "maximum": 1000, "default": 500, "description": "单次最大行数上限"},
602
+ },
603
+ },
604
+ }),
605
+ (_SHARED_ROLES, {
606
+ "name": "bugx_scheduling_telemetry",
607
+ "description": "读取当前 Supervisor 调度遥测指标与并发利用率看板(AIMD 容量、排队/执行时延、抢占与活跃 Worker)。",
608
+ "inputSchema": {"type": "object", "properties": {}},
609
+ }),
610
+ (_SHARED_ROLES, {
611
+ "name": "bugx_global_telemetry",
612
+ "description": "查询跨项目的全局时间与 Token 计量治理看板、项目 ROI 排行及每日消耗趋势(DOC-049)。",
613
+ "inputSchema": {
614
+ "type": "object",
615
+ "properties": {
616
+ "days": {
617
+ "type": "integer",
618
+ "minimum": 1,
619
+ "maximum": 365,
620
+ "default": 30,
621
+ "description": "统计时间窗口天数(默认 30 天)",
622
+ },
623
+ "project_filter": {
624
+ "type": "string",
625
+ "description": "可选项目名称过滤关键词",
626
+ },
627
+ },
628
+ },
629
+ }),
630
+ (_SHARED_ROLES, {
631
+ "name": "bugx_retrieval_metrics",
632
+ "description": "查询与记录混合检索与结构化切片管线的 P50/P99 时延与 Token 密度遥测指标(DOC-234)。",
633
+ "inputSchema": {
634
+ "type": "object",
635
+ "properties": {
636
+ "operation": {
637
+ "type": "string",
638
+ "description": "可选待上报检索原语名称:rrf, slice, memory, ego",
639
+ },
640
+ "duration_ms": {
641
+ "type": "number",
642
+ "description": "执行耗时(毫秒)",
643
+ },
644
+ "tokens": {
645
+ "type": "number",
646
+ "description": "上下文估算 Token 数",
647
+ },
648
+ "output_bytes": {
649
+ "type": "number",
650
+ "description": "产物字节数",
651
+ },
652
+ "samples": {
653
+ "type": "array",
654
+ "description": "批量上报样本数组",
655
+ "items": {"type": "object"},
656
+ },
657
+ },
658
+ },
659
+ }),
660
+ (_WORKER_ONLY, {
661
+ "name": "bugx_fuzz_concurrency",
662
+ "description": "并发竞态与时序死锁专项扰动工具:注入微秒级上下文切换抖动并检测数据竞态或死锁。",
663
+ "inputSchema": {
664
+ "type": "object",
665
+ "required": ["target_cmd"],
666
+ "properties": {
667
+ "target_cmd": {
668
+ "type": "array",
669
+ "items": {"type": "string"},
670
+ "minItems": 1,
671
+ "description": "要并发压测的命令 argv 数组(如 [\"python3\",\"-m\",\"unittest\",\"tests/test_x.py\"]);不接受字符串命令",
672
+ },
673
+ "threads": {"type": "integer", "minimum": 1, "maximum": 32, "default": 8},
674
+ "iterations": {"type": "integer", "minimum": 1, "maximum": 200, "default": 30},
675
+ "timeout": {"type": "number", "minimum": 0.5, "maximum": 30.0, "default": 2.0},
676
+ },
677
+ },
678
+ }),
679
+ (_WORKER_ONLY, {
680
+ "name": "bugx_fuzz_stateful",
681
+ "description": "状态机反常序突变推演工具:自动生成跳步、重入、撤销后执行变异调用序列,用于挖掘业务逻辑漏洞。",
682
+ "inputSchema": {
683
+ "type": "object",
684
+ "required": ["transitions"],
685
+ "properties": {
686
+ "transitions": {
687
+ "type": "array",
688
+ "items": {
689
+ "type": "object",
690
+ "required": ["action", "from_state", "to_state"],
691
+ "properties": {
692
+ "action": {"type": "string"},
693
+ "from_state": {"type": "string"},
694
+ "to_state": {"type": "string"},
695
+ "requires_auth": {"type": "boolean"},
696
+ },
697
+ },
698
+ },
699
+ "max_length": {"type": "integer", "minimum": 2, "maximum": 6, "default": 4},
700
+ "max_sequences": {"type": "integer", "minimum": 1, "maximum": 50, "default": 20},
701
+ },
702
+ },
703
+ }),
704
+ (_WORKER_ONLY, {
705
+ "name": "bugx_verify_differential_poc",
706
+ "description": "确定性沙盒双跑差分验证器:在两个独立临时沙盒中双跑 PoC 并清洗地址/临时目录噪音,裁决 CONFIRMED_DETERMINISTIC / FLAKY_JITTER / FALSE_POSITIVE。",
707
+ "inputSchema": {
708
+ "type": "object",
709
+ "required": ["command_template", "poc_input"],
710
+ "properties": {
711
+ "command_template": {"type": "string", "description": "命令模板(含 {input} 占位符)"},
712
+ "poc_input": {
713
+ "description": "PoC 输入数据内容、项目内文件路径,或 JSON 对象/数组;结构化值按 JSON 文件传给命令",
714
+ "anyOf": [
715
+ {"type": "string", "minLength": 1},
716
+ {"type": "object"},
717
+ {"type": "array"},
718
+ ],
719
+ },
720
+ "timeout": {"type": "number", "minimum": 1.0, "maximum": 30.0, "default": 10.0},
721
+ },
722
+ },
723
+ }),
724
+ (_WORKER_ONLY, {
725
+ "name": "bugx_ingest_coverage",
726
+ "description": "真实测试覆盖率报告回填工具:解析测试套件生成的 lcov/cobertura/coveragepy 报告,自动将对应物理单元与端点标记为已覆盖。",
727
+ "inputSchema": {
728
+ "type": "object",
729
+ "required": ["report_path"],
730
+ "properties": {
731
+ "report_path": {"type": "string", "description": "测试覆盖报告文件相对或绝对路径"},
732
+ "format_hint": {"type": "string", "enum": ["lcov", "jacoco", "coveragepy", "generic"], "description": "可选指定格式"},
733
+ },
734
+ },
735
+ }),
736
+ (_WORKER_ONLY, {
737
+ "name": "bugx_inspect_mobile_ui",
738
+ "description": "移动端 UI 几何与无障碍 Oracle 质检工具:执行 Overlap、Clipping、Touch Target、Safe Area 等机械判定并产出 Failure Pack。",
739
+ "inputSchema": {
740
+ "type": "object",
741
+ "required": ["dump_path_or_content"],
742
+ "properties": {
743
+ "dump_path_or_content": {"type": "string", "description": "UI 视图树 XML 或 WDA JSON 路径/文本内容"},
744
+ "is_ios": {"type": "boolean", "default": False},
745
+ "density": {"type": "number", "default": 1.0},
746
+ },
747
+ },
748
+ }),
749
+ (_WORKER_ONLY, {
750
+ "name": "bugx_fuzz_input",
751
+ "description": "目标程序变异模糊测试工具:对 CLI、解析器、端点注入变异输入序列,并检测崩溃、挂起与异常签名。",
752
+ "inputSchema": {
753
+ "type": "object",
754
+ "required": ["cmd"],
755
+ "properties": {
756
+ "cmd": {"type": "string", "description": "目标执行命令(可含 {input} 占位符或作为 stdin 输入源)"},
757
+ "input_content": {"type": "string", "description": "初始变异种子内容(纯文本,不再被当作文件路径)"},
758
+ "input_path": {"type": "string", "description": "项目内的种子文件相对路径(必须位于项目根目录内,不含符号链接);与 input_content 互斥"},
759
+ "iterations": {"type": "integer", "minimum": 1, "maximum": 200, "default": 30},
760
+ "timeout": {"type": "number", "minimum": 0.1, "maximum": 30.0, "default": 2.0},
761
+ "language": {"type": "string", "enum": ["python", "go", "java", "generic"], "description": "语言异常规则调度"},
762
+ "seed": {"type": "integer", "description": "随机数种子(用于确定性重放)"},
763
+ },
764
+ },
765
+ }),
766
+ (_WORKER_ONLY, {
767
+ "name": "bugx_minimize_repro",
768
+ "description": "PoC 失败样本分层 delta-debugging 最小化工具:对崩溃触发样本做行级/语法/字节块切除,提取最小复现证据。",
769
+ "inputSchema": {
770
+ "type": "object",
771
+ "required": ["cmd"],
772
+ "properties": {
773
+ "cmd": {"type": "string", "description": "复现验证命令(含 {input} 占位符)"},
774
+ "input_data": {"type": "string", "description": "待切除最小化的崩溃输入文本(纯内容,不再被当作文件路径)"},
775
+ "input_path": {"type": "string", "description": "项目内的样本文件相对路径(必须位于项目根目录内,不含符号链接);与 input_data 二选一"},
776
+ "timeout": {"type": "number", "minimum": 0.5, "maximum": 30.0, "default": 5.0},
777
+ "hierarchical": {"type": "boolean", "default": True, "description": "是否开启行级优先两阶段分层切除"},
778
+ },
779
+ },
780
+ }),
781
+ (_WORKER_ONLY, {
782
+ "name": "bugx_query_behavior_graph",
783
+ "description": "行为图谱与逻辑异常推断工具:查询系统调用拓扑并自动推断无鉴权暴露端点、孤儿死事件与跨模块配置分歧。",
784
+ "inputSchema": {
785
+ "type": "object",
786
+ "properties": {
787
+ "file_filter": {"type": "string", "description": "按文件相对路径过滤图谱节点"},
788
+ "include_anomalies": {"type": "boolean", "default": True, "description": "是否同时执行行为异常拓扑推断"},
789
+ },
790
+ },
791
+ }),
792
+ (_WORKER_ONLY, {
793
+ "name": "bugx_audit_web_conformance",
794
+ "description": "Web 标准合规与契约质检工具:静态扫描项目前端与 API,检测 HTTP 动词安全、CORS/CSP 头、IDOR 边界与分页参数合规。",
795
+ "inputSchema": {
796
+ "type": "object",
797
+ "properties": {
798
+ "files": {"type": "array", "items": {"type": "string"}, "description": "指定扫描的目标文件相对路径列表"},
799
+ },
800
+ },
801
+ }),
802
+ (_SHARED_ROLES, {
803
+ "name": "bugx_mining_explore",
804
+ "description": "全息可挖掘功能主体勘测工具:AST 扫描代码库,自动识别 HTTP 路由、CLI 分支、并发临界区、反序列化与状态流转,映射威胁模型与推荐 Oracle。",
805
+ "inputSchema": {
806
+ "type": "object",
807
+ "properties": {
808
+ "subpath": {"type": "string", "description": "相对项目根目录的子路径或目标文件过滤"},
809
+ "risk_level": {
810
+ "type": "string",
811
+ "enum": ["ALL", "CRITICAL", "HIGH", "MEDIUM", "LOW"],
812
+ "default": "ALL",
813
+ "description": "过滤指定风险等级的功能主体",
814
+ },
815
+ },
816
+ },
817
+ }),
818
+ (_SHARED_ROLES, {
819
+ "name": "bugx_mining_audit",
820
+ "description": "漏洞挖掘方案与用例四维量化审计工具:从准确性、完整性、有效性、全面性四维度 100 分制量化评估挖掘规划,输出等级、门禁结论与违规清单。DEGRADED 不等于通过:返回 status=blocked 时必须先取得用户决策,再显式传 allow_degraded=true 重审。",
821
+ "inputSchema": {
822
+ "type": "object",
823
+ "properties": {
824
+ "plan": {"type": "object", "description": "内存中待审计的挖掘方案 JSON 对象"},
825
+ "plan_file": {"type": "string", "description": "相对项目根目录的方案文件路径(如 .bugx/campaign.json)"},
826
+ "min_score": {"type": "number", "minimum": 0, "maximum": 100, "default": 80.0, "description": "及格线分数"},
827
+ "strict": {"type": "boolean", "default": False, "description": "是否开启严格阻断模式(有任何硬违规即判定失败)"},
828
+ "allow_degraded": {"type": "boolean", "default": False, "description": "是否显式接受降级(DEGRADED)方案;默认 false,此时降级方案判为 blocked"},
829
+ },
830
+ },
831
+ }),
832
+ (_HOST_ONLY, {
833
+ "name": "bugx_mining_harden",
834
+ "description": "挖掘方案自动加固与 Oracle 强化工具:自动注入代码库中遗漏的高危功能主体,补全 DAG 依赖并将弱断言升级为深度状态不变式。",
835
+ "inputSchema": {
836
+ "type": "object",
837
+ "properties": {
838
+ "plan": {"type": "object", "description": "内存中待加固的原始方案 JSON 对象"},
839
+ "plan_file": {"type": "string", "description": "相对项目根目录的输入方案文件路径"},
840
+ "output_file": {"type": "string", "description": "加固后方案另存为的项目相对路径(可选)"},
841
+ },
842
+ },
843
+ }),
844
+ (_WORKER_ONLY, {
845
+ "name": "bugx_test_verify",
846
+ "description": "测试用例杀伤力变异沙箱验证工具:在受控隔离沙箱中对目标代码注入 6 类 AST 语义变异,实测测试用例真实击杀率 (Mutation Score) 并评级。",
847
+ "inputSchema": {
848
+ "type": "object",
849
+ "required": ["target_path", "test_target"],
850
+ "properties": {
851
+ "target_path": {"type": "string", "description": "被测 Python 源码文件相对路径"},
852
+ "test_target": {"type": "string", "description": "测试命令(如 python3 -m unittest tests/test_calc.py)或测试文件路径"},
853
+ "max_mutants": {"type": "integer", "minimum": 1, "maximum": 50, "default": 20, "description": "最大变异体评估上限"},
854
+ "timeout_sec": {"type": "number", "minimum": 0.5, "maximum": 10.0, "default": 2.0, "description": "单个变异体看门狗超时(秒)"},
855
+ "operators": {
856
+ "type": "array",
857
+ "items": {"type": "string", "enum": ["ROR", "AOR", "LCR", "BCR", "EOR", "SVR"]},
858
+ "description": "启用的变异算子白名单过滤",
859
+ },
860
+ },
861
+ },
862
+ }),
863
+ (_SHARED_ROLES, {
864
+ "name": "bugx_test_mutate",
865
+ "description": "AST 语义变异体只读预览工具:针对目标 Python 文件生成可能的微观逻辑变异列表,供编写高杀伤力断言参考(不执行测试命令)。",
866
+ "inputSchema": {
867
+ "type": "object",
868
+ "required": ["target_path"],
869
+ "properties": {
870
+ "target_path": {"type": "string", "description": "目标 Python 源码文件相对路径"},
871
+ "max_mutants": {"type": "integer", "minimum": 1, "maximum": 100, "default": 30, "description": "最大生成变异体上限"},
872
+ "operators": {
873
+ "type": "array",
874
+ "items": {"type": "string", "enum": ["ROR", "AOR", "LCR", "BCR", "EOR", "SVR"]},
875
+ "description": "启用的变异算子白名单过滤",
876
+ },
877
+ },
878
+ },
879
+ }),
880
+ (_SHARED_ROLES, {
881
+ "name": "bugx_retrieve_slice",
882
+ "description": "结构化检索代码块切片(支持按语言、符号名、种类有界提取与语法自愈)。",
883
+ "inputSchema": {
884
+ "type": "object",
885
+ "required": ["target"],
886
+ "properties": {
887
+ "target": {"type": "string", "description": "目标源文件相对路径"},
888
+ "symbol": {"type": "string", "description": "可选符号名过滤(如函数或类名)"},
889
+ "kind": {"type": "string", "enum": ["function", "method", "class", "type", "module", "fragment"], "description": "可选切片种类过滤"},
890
+ "to_executable": {"type": "boolean", "default": False, "description": "是否对切片生成自愈后的可直接解析执行视图"},
891
+ "include_context": {"type": "boolean", "default": False, "description": "是否附带文件导入头与局部拓扑的阶梯渐进上下文"},
892
+ "max_slices": {"type": "integer", "minimum": 1, "maximum": 20, "default": 5, "description": "最大返回切片数"},
893
+ },
894
+ },
895
+ }),
896
+ (_SHARED_ROLES, {
897
+ "name": "bugx_extract_ego_subgraph",
898
+ "description": "提取指定中心节点的 k-hop 局部有界调用/依赖拓扑子图(防上下文爆炸)。",
899
+ "inputSchema": {
900
+ "type": "object",
901
+ "required": ["center_node"],
902
+ "properties": {
903
+ "center_node": {"type": "string", "description": "中心节点标识(如符号名或节点 ID)"},
904
+ "depth": {"type": "integer", "minimum": 1, "maximum": 2, "default": 1, "description": "跳数深度(1 或 2)"},
905
+ "direction": {"type": "string", "enum": ["both", "inbound", "outbound"], "default": "both", "description": "遍历方向"},
906
+ "graph": {"type": "object", "description": "可选自定义子图映射"},
907
+ },
908
+ },
909
+ }),
910
+ (_SHARED_ROLES, {
911
+ "name": "bugx_memory_query",
912
+ "description": "在隔离命名空间内执行确定性记忆检索与经验知识召回(FTS5 BM25 排序与敏感凭据物理隔离)。",
913
+ "inputSchema": {
914
+ "type": "object",
915
+ "required": ["namespace", "query"],
916
+ "properties": {
917
+ "namespace": {"type": "string", "description": "记忆命名空间(如 repo:default 或 framework:lessons)"},
918
+ "query": {"type": "string", "description": "检索文本"},
919
+ "top_k": {"type": "integer", "minimum": 1, "maximum": 20, "default": 5, "description": "最大召回条目数"},
920
+ "db_path": {"type": "string", "description": "可选指定数据库路径,默认使用会话内 SQLite"},
921
+ },
922
+ },
923
+ }),
924
+ )
925
+ # Keep the large checkpoint schema readable above while making the
926
+ # transport retry contract explicit in one place. The engine accepts an
927
+ # omitted id for direct legacy callers; MCP does not, because a lost
928
+ # response must be replayable without duplicating findings.
929
+ # DES-08:该补丁在**建表时一次性应用**,故 ``_TOOL_TABLE`` 已是终态。
930
+ # 旧实现把 definitions 建在函数内、每次调用都重新追加一次描述后缀。
931
+ for _roles, definition in table:
932
+ if definition["name"] == "bugx_supervisor_checkpoint":
933
+ schema = definition["inputSchema"]
934
+ required = list(schema.get("required", []))
935
+ if "checkpoint_id" not in required:
936
+ required.append("checkpoint_id")
937
+ schema["required"] = required
938
+ schema["properties"]["checkpoint_id"] = {
939
+ "type": "string", "minLength": 1, "maxLength": 128,
940
+ }
941
+ definition["description"] = (
942
+ str(definition["description"])
943
+ + " 重试必须复用同一 checkpoint_id。"
944
+ )
945
+ break
946
+ return table
947
+
948
+
949
+ _TOOL_TABLE = _build_tool_table()
950
+ _TOOL_ROLES = {definition["name"]: roles for roles, definition in _TOOL_TABLE}
951
+
952
+ # 三个角色集合由单一真源派生(原先为三份手工维护的字面量)。
953
+ HOST_TOOLS = frozenset(d["name"] for roles, d in _TOOL_TABLE if roles == _HOST_ONLY)
954
+ WORKER_TOOLS = frozenset(d["name"] for roles, d in _TOOL_TABLE if roles == _WORKER_ONLY)
955
+ READ_ONLY_TOOLS = frozenset(d["name"] for roles, d in _TOOL_TABLE if roles == _SHARED_ROLES)
956
+
957
+
958
+ def _get_active_tool_table() -> Any:
959
+ mod = sys.modules.get("core.skills.bugx_mcp_server")
960
+ table = getattr(mod, "_TOOL_TABLE", None) if mod is not None else None
961
+ if table is not None:
962
+ return table
963
+ return _TOOL_TABLE
964
+
965
+
966
+ def _assert_tool_registry_consistent() -> None:
967
+ """DES-08 漂移守卫:定义表与 handler 分发表必须**逐名一致**。
968
+
969
+ 导入期 fail-closed 校验:任一侧新增/改名而未同步另一侧时模块直接拒绝加载,
970
+ 而不是静默提供一个「被宣告但无法分发」或「能分发但未被宣告」的工具。
971
+ """
972
+ table = _get_active_tool_table()
973
+ defined = frozenset(definition["name"] for _roles, definition in table)
974
+ handlers = frozenset(HANDLER_REGISTRY)
975
+ if defined != handlers:
976
+ missing = sorted(defined - handlers)
977
+ orphan = sorted(handlers - defined)
978
+ raise RuntimeError(
979
+ "MCP 工具元数据与 handler 注册表不一致:"
980
+ f"缺少 handler 的定义={missing};缺少定义的 handler={orphan}"
981
+ )
982
+
983
+
984
+ _assert_tool_registry_consistent()
985
+
986
+
987
+ _WORKER_CORE_TOOL_NAMES = frozenset({
988
+ "bugx_supervisor_claim",
989
+ "bugx_supervisor_worker_start",
990
+ "bugx_supervisor_heartbeat",
991
+ "bugx_supervisor_begin_long_call",
992
+ "bugx_inspect_source",
993
+ "bugx_supervisor_run_sandboxed_probe",
994
+ "bugx_test_verify",
995
+ "bugx_supervisor_submit_finding",
996
+ "bugx_supervisor_checkpoint",
997
+ "bugx_supervisor_status",
998
+ })
999
+
1000
+
1001
+ def _tool_definitions(role: str | None = None) -> list[dict[str, object]]:
1002
+ """返回 MCP 工具定义列表,可按角色过滤。
1003
+
1004
+ DES-08:本函数渲染 ``_TOOL_TABLE``。
1005
+ DOC-241 A5:Worker 角色严格仅暴露 9 个核心原子工具(<= 10),
1006
+ 消除 32 个冗余工具对大模型 Context 的浪费与幻觉。
1007
+ """
1008
+ table = _get_active_tool_table()
1009
+ if role is None:
1010
+ return [definition for _roles, definition in table]
1011
+ if role == "worker":
1012
+ return [definition for roles, definition in table if definition["name"] in _WORKER_CORE_TOOL_NAMES]
1013
+ return [definition for roles, definition in table if role in roles]
1014
+
1015
+