bugx-cli 0.1.1__py3-none-any.whl

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 (762) hide show
  1. bugx_cli/__init__.py +6 -0
  2. bugx_cli/cli.py +1685 -0
  3. bugx_cli/commands/__init__.py +1 -0
  4. bugx_cli/commands/advisory.py +94 -0
  5. bugx_cli/commands/agent.py +4210 -0
  6. bugx_cli/commands/audit.py +632 -0
  7. bugx_cli/commands/autonomous.py +260 -0
  8. bugx_cli/commands/cloud.py +1371 -0
  9. bugx_cli/commands/daemon.py +50 -0
  10. bugx_cli/commands/doctor.py +1590 -0
  11. bugx_cli/commands/goal.py +107 -0
  12. bugx_cli/commands/interaction.py +248 -0
  13. bugx_cli/commands/knowledge.py +619 -0
  14. bugx_cli/commands/lifecycle.py +2763 -0
  15. bugx_cli/commands/patch.py +1014 -0
  16. bugx_cli/commands/plugin.py +2749 -0
  17. bugx_cli/commands/plugin_claude.py +1446 -0
  18. bugx_cli/commands/plugin_cline.py +269 -0
  19. bugx_cli/commands/plugin_codex.py +74 -0
  20. bugx_cli/commands/plugin_funide.py +729 -0
  21. bugx_cli/commands/plugin_qoder.py +216 -0
  22. bugx_cli/commands/plugin_zcode.py +710 -0
  23. bugx_cli/commands/project.py +670 -0
  24. bugx_cli/commands/report.py +256 -0
  25. bugx_cli/commands/skill.py +251 -0
  26. bugx_cli/commands/stats.py +133 -0
  27. bugx_cli/commands/system.py +2567 -0
  28. bugx_cli/common.py +906 -0
  29. bugx_cli/host_adapters.py +1892 -0
  30. bugx_cli/hosts/__init__.py +80 -0
  31. bugx_cli/hosts/base.py +99 -0
  32. bugx_cli/hosts/registry.py +573 -0
  33. bugx_cli/hosts/template_engine.py +188 -0
  34. bugx_cli/infra/__init__.py +209 -0
  35. bugx_cli/infra/ai_advisor.py +851 -0
  36. bugx_cli/infra/engine_installer.py +1945 -0
  37. bugx_cli/infra/host_sync.py +548 -0
  38. bugx_cli/infra/mcp_advisor.py +826 -0
  39. bugx_cli/infra/security.py +339 -0
  40. bugx_cli-0.1.1.data/data/share/bugx-agent/bugx-mcp-manifest.json +53 -0
  41. bugx_cli-0.1.1.data/data/share/bugx-agent/core/CATALOG.json +141 -0
  42. bugx_cli-0.1.1.data/data/share/bugx-agent/core/README.md +254 -0
  43. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/README.md +35 -0
  44. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android-interaction.json +81 -0
  45. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android.json +24 -0
  46. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/desktop-macos.json +20 -0
  47. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios-interaction.json +34 -0
  48. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios.json +23 -0
  49. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/memory-macos.json +24 -0
  50. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/README.md +51 -0
  51. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/__init__.py +146 -0
  52. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_artifacts.py +766 -0
  53. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_eval.py +1155 -0
  54. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_execution.py +718 -0
  55. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_orchestrator.py +1351 -0
  56. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_targets.py +877 -0
  57. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_workspace.py +770 -0
  58. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/feature_baseline.py +150 -0
  59. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/README.md +24 -0
  60. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
  61. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE.txt +362 -0
  62. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/UPSTREAM.md +10 -0
  63. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/axe.min.js +12 -0
  64. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-1024.png +0 -0
  65. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-512.png +0 -0
  66. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-tight.svg +23 -0
  67. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar.svg +28 -0
  68. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-cn.png +0 -0
  69. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.png +0 -0
  70. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.svg +74 -0
  71. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-zh.svg +74 -0
  72. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/codex.png +0 -0
  73. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/dsh.png +0 -0
  74. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/project-layout.md +42 -0
  75. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/zcode.png +0 -0
  76. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/README.md +37 -0
  77. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/manifest.json +94 -0
  78. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/00-scope.md +14 -0
  79. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
  80. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
  81. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
  82. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/manifest.json +123 -0
  83. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
  84. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
  85. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
  86. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
  87. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
  88. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/memory-testing.md +227 -0
  89. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/manifest.json +155 -0
  90. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/android.md +19 -0
  91. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/h5.md +18 -0
  92. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/ios.md +25 -0
  93. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
  94. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/webview.md +18 -0
  95. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
  96. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
  97. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
  98. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
  99. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
  100. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
  101. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/manifest.json +127 -0
  102. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/00-scope.md +14 -0
  103. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
  104. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
  105. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
  106. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
  107. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/platform-testing.md +174 -0
  108. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/manifest.json +191 -0
  109. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/graphql.md +5 -0
  110. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/h5.md +18 -0
  111. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
  112. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/oauth.md +4 -0
  113. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/upload.md +4 -0
  114. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/websocket.md +4 -0
  115. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/00-scope.md +13 -0
  116. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
  117. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
  118. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
  119. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
  120. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
  121. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
  122. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
  123. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
  124. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/INTERFACE.md +61 -0
  125. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/README.md +58 -0
  126. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/SPEC.md +25 -0
  127. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/__init__.py +109 -0
  128. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph.py +1096 -0
  129. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph_store.py +1868 -0
  130. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/audit_campaign.py +1232 -0
  131. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/behavior_graph.py +465 -0
  132. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/ghsa_advisories.py +174 -0
  133. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/models.py +93 -0
  134. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/mutator.py +87 -0
  135. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/patcher.py +126 -0
  136. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/scout.py +278 -0
  137. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/synthesizer.py +207 -0
  138. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/verifier.py +103 -0
  139. bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx.md +1299 -0
  140. bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx_paths.py +1881 -0
  141. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cli-help.txt +66 -0
  142. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/INTERFACE.md +32 -0
  143. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/README.md +62 -0
  144. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/SPEC.md +25 -0
  145. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/__init__.py +23 -0
  146. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/auto_sync.py +398 -0
  147. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_client.py +1218 -0
  148. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_onboard.py +743 -0
  149. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_schema.py +648 -0
  150. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/consent.py +81 -0
  151. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/device_identity.py +307 -0
  152. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/endpoint_router.py +415 -0
  153. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/flywheel_client.py +769 -0
  154. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/network_transport.py +296 -0
  155. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/onboard_wizard.py +493 -0
  156. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sensitive_filter.py +285 -0
  157. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_pull.py +695 -0
  158. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_push.py +723 -0
  159. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/AGENT_GUIDE.md +359 -0
  160. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/README.md +34 -0
  161. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-blackbox.md +541 -0
  162. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-opencode.md +469 -0
  163. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-quick.md +44 -0
  164. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-runtime-contract.md +353 -0
  165. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-worker.md +470 -0
  166. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/engine_gap_contracts.py +473 -0
  167. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/README.md +70 -0
  168. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/__init__.py +106 -0
  169. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_ai_review.py +185 -0
  170. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_backfill.py +54 -0
  171. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_bootstrap.py +713 -0
  172. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_business.py +36 -0
  173. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_cli.py +715 -0
  174. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_discovery.py +1429 -0
  175. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_evidence.py +1024 -0
  176. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_forensics.py +124 -0
  177. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_gate.py +277 -0
  178. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_intelligence.py +734 -0
  179. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_manifest.py +396 -0
  180. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_platform.py +77 -0
  181. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_validate.py +241 -0
  182. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/module_coverage.py +157 -0
  183. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/INTERFACE.md +20 -0
  184. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/README.md +21 -0
  185. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/SPEC.md +25 -0
  186. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/__init__.py +5 -0
  187. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/interaction_preset.py +408 -0
  188. bugx_cli-0.1.1.data/data/share/bugx-agent/core/engine-integrity.json +2797 -0
  189. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/README.md +49 -0
  190. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/__init__.py +82 -0
  191. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/concurrency_fuzzer.py +435 -0
  192. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/differential_oracle.py +1164 -0
  193. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/fuzz_input.py +1291 -0
  194. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/stateful_fuzzer.py +404 -0
  195. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/README.md +61 -0
  196. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/__init__.py +130 -0
  197. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/capacity_planner.py +124 -0
  198. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/dependency_lock.py +317 -0
  199. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/goal_governor.py +754 -0
  200. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/guide_budget.py +458 -0
  201. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/lockdown.sh +50 -0
  202. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/readonly_enforcer.py +154 -0
  203. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/runtime_tool_gate.py +373 -0
  204. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/secret_redactor.py +784 -0
  205. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/token_budget.py +38 -0
  206. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/INTERFACE.md +36 -0
  207. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/README.md +51 -0
  208. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/SPEC.md +25 -0
  209. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/__init__.py +121 -0
  210. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/base.py +111 -0
  211. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/claude.py +99 -0
  212. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/cline.py +298 -0
  213. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/codex.py +300 -0
  214. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/dsh.py +106 -0
  215. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/opencode.py +209 -0
  216. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/pi.py +94 -0
  217. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/zcode.py +99 -0
  218. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/INTERFACE.md +24 -0
  219. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/README.md +62 -0
  220. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/SPEC.md +25 -0
  221. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/__init__.py +21 -0
  222. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/adapters.py +412 -0
  223. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/autonomous_runner.py +1152 -0
  224. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/cline.py +448 -0
  225. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/common.py +103 -0
  226. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/free_models.py +786 -0
  227. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_bootstrap.py +389 -0
  228. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_evaluators.py +761 -0
  229. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_probe.py +41 -0
  230. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_provider_arbitrator.py +831 -0
  231. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_registry.py +662 -0
  232. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_usage.py +127 -0
  233. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_process_tracker.py +509 -0
  234. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_registry_gate.py +379 -0
  235. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/pi.py +102 -0
  236. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/provider_facts.py +66 -0
  237. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/INTERFACE.md +51 -0
  238. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/README.md +67 -0
  239. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/SPEC.md +25 -0
  240. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/__init__.py +140 -0
  241. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_base_usage.py +152 -0
  242. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_codex_usage.py +297 -0
  243. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_dsh_usage.py +184 -0
  244. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_mcp_toml.py +365 -0
  245. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_zcode_usage.py +269 -0
  246. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/base.py +479 -0
  247. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/claude.py +212 -0
  248. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/cline.py +229 -0
  249. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/codex.py +1006 -0
  250. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/dsh.py +526 -0
  251. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/opencode.py +358 -0
  252. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/pi.py +308 -0
  253. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/zcode.py +219 -0
  254. bugx_cli-0.1.1.data/data/share/bugx-agent/core/i18n.py +252 -0
  255. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/README.md +41 -0
  256. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/__init__.py +17 -0
  257. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/build_info.py +105 -0
  258. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/client_metadata.py +185 -0
  259. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/json_utils.py +22 -0
  260. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/python_runtime.py +540 -0
  261. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/safe_xml.py +221 -0
  262. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_bugx.py +118 -0
  263. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/INTERFACE.md +31 -0
  264. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/README.md +106 -0
  265. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/SPEC.md +25 -0
  266. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/__init__.py +29 -0
  267. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/candidate_revalidation.py +484 -0
  268. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/common.py +1060 -0
  269. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_confirm_phase.py +391 -0
  270. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_settlement.py +1432 -0
  271. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_adjudication.py +666 -0
  272. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_snapshot.py +357 -0
  273. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/judge_phase.py +848 -0
  274. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lesson_context.py +536 -0
  275. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lifecycle_reporter.py +627 -0
  276. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/orchestrator_controls.py +686 -0
  277. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_commit.py +567 -0
  278. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_coverage_sync.py +598 -0
  279. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_dry_run.py +817 -0
  280. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_observability.py +367 -0
  281. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_phase.py +1223 -0
  282. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_receipt.py +373 -0
  283. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_round_lifecycle.py +786 -0
  284. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_phase.py +1029 -0
  285. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_recon_scout.py +879 -0
  286. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_state_builder.py +1133 -0
  287. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/report_sharing.py +414 -0
  288. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/round_orchestrator.py +1116 -0
  289. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/session_runtime.py +1670 -0
  290. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_gates.py +1050 -0
  291. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_interaction.py +1003 -0
  292. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_version_gate.py +879 -0
  293. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_bridge.py +1253 -0
  294. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_coverage.py +423 -0
  295. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_degraded.py +1211 -0
  296. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_barriers.py +424 -0
  297. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_orchestrator.py +1246 -0
  298. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_prior.py +749 -0
  299. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/INTERFACE.md +35 -0
  300. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/README.md +160 -0
  301. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/SPEC.md +25 -0
  302. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/__init__.py +67 -0
  303. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/_facade.py +227 -0
  304. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/archive_ops.py +630 -0
  305. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/auto_materialization.py +459 -0
  306. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/bug-log.md +22 -0
  307. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/cli.py +275 -0
  308. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/export_ops.py +554 -0
  309. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_confirmation.py +1316 -0
  310. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_io.py +299 -0
  311. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_lifecycle.py +730 -0
  312. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_verification.py +405 -0
  313. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/incidents.py +1005 -0
  314. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson-replay-cases.json +20 -0
  315. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_ledger.py +241 -0
  316. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_replay.py +272 -0
  317. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/life_ledger.py +668 -0
  318. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/mistake-book.md +130 -0
  319. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/patterns.py +684 -0
  320. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/receipt_contract.py +269 -0
  321. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/schema.py +1192 -0
  322. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/sync_ops.py +940 -0
  323. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/tool_experience.py +683 -0
  324. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/verify_life.py +1597 -0
  325. bugx_cli-0.1.1.data/data/share/bugx-agent/core/lesson-ledger.json +275 -0
  326. bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/README.md +19 -0
  327. bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/en-US.json +462 -0
  328. bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/zh-CN.json +462 -0
  329. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/INTERFACE.md +75 -0
  330. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/README.md +62 -0
  331. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/SPEC.md +25 -0
  332. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/__init__.py +128 -0
  333. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/base.py +717 -0
  334. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/channel_lifecycle.py +751 -0
  335. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/graph_handlers.py +222 -0
  336. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/knowledge_handlers.py +536 -0
  337. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/mining_handlers.py +586 -0
  338. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/resource_prompt_table.py +116 -0
  339. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/retrieval_handlers.py +249 -0
  340. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/rpc_server.py +470 -0
  341. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/supervisor_handlers.py +1461 -0
  342. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/telemetry_handlers.py +227 -0
  343. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/tool_table.py +1030 -0
  344. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/README.md +21 -0
  345. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/__init__.py +1 -0
  346. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/common.py +363 -0
  347. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/environment.py +567 -0
  348. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/verifier.py +758 -0
  349. bugx_cli-0.1.1.data/data/share/bugx-agent/core/metadata.txt +4 -0
  350. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/README.md +157 -0
  351. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/__init__.py +242 -0
  352. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_plan.py +187 -0
  353. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_planner.py +195 -0
  354. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_archetype.py +542 -0
  355. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_router.py +269 -0
  356. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/dynamic_flow_analyzer.py +533 -0
  357. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/impact_pruner.py +435 -0
  358. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/intent_adjudicator.py +175 -0
  359. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/judge_pipeline.py +1246 -0
  360. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/logic_analysis.py +419 -0
  361. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/prompt_harness.py +1704 -0
  362. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/source_inspector.py +267 -0
  363. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/spec_harvester.py +449 -0
  364. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/target_sandbox_manager.py +573 -0
  365. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/test_capability_verifier.py +1364 -0
  366. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/tools-kb.md +38 -0
  367. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/unit_kind.py +122 -0
  368. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/INTERFACE.md +83 -0
  369. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/README.md +51 -0
  370. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/SPEC.md +36 -0
  371. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/__init__.py +76 -0
  372. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/android_probe.py +552 -0
  373. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/base.py +147 -0
  374. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/codebase_memory_probe.py +647 -0
  375. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/desktop_probe.py +342 -0
  376. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/differential_probe.py +434 -0
  377. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/efficiency_probe.py +232 -0
  378. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ios_binary_probe.py +472 -0
  379. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/memory_probe.py +392 -0
  380. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/miniprogram_probe.py +385 -0
  381. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/mobile_probe.py +466 -0
  382. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/native_probe.py +302 -0
  383. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/openwiki_probe.py +263 -0
  384. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/pattern_probe.py +453 -0
  385. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/platform_probe.py +424 -0
  386. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/probe_registry.py +1770 -0
  387. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_fixture_corpus.py +340 -0
  388. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_probe.py +1510 -0
  389. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_rules.py +1481 -0
  390. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sca_scanner.py +779 -0
  391. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_accessibility.py +149 -0
  392. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_audit.py +513 -0
  393. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_contract.py +273 -0
  394. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_evidence.py +212 -0
  395. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_measurements.py +314 -0
  396. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_repair.py +250 -0
  397. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_review.py +133 -0
  398. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_storybook.py +107 -0
  399. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_tokens.py +185 -0
  400. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_visual_diff.py +131 -0
  401. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/web_probe.py +714 -0
  402. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/INTERFACE.md +62 -0
  403. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/README.md +53 -0
  404. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/SPEC.md +28 -0
  405. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/__init__.py +201 -0
  406. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/arbitrator.py +316 -0
  407. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/constants.py +247 -0
  408. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/detector.py +399 -0
  409. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/extractors.py +836 -0
  410. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/fingerprint.py +116 -0
  411. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/storage.py +258 -0
  412. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/strategy.py +301 -0
  413. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/README.md +35 -0
  414. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/codex_dialog_dispatch.md +9 -0
  415. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_en.md +42 -0
  416. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_zh.md +42 -0
  417. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/l0_router.md +47 -0
  418. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/anti_patterns.md +16 -0
  419. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/concurrency_rules.md +14 -0
  420. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/memory_leak_rules.md +13 -0
  421. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/prompt_injection_defense.md +13 -0
  422. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_explore.md +31 -0
  423. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_gate.md +43 -0
  424. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_mutate.md +42 -0
  425. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_repair.md +85 -0
  426. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/README.md +74 -0
  427. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/__init__.py +169 -0
  428. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/fix_watchlist.py +391 -0
  429. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_dynamic.py +418 -0
  430. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_repair_loop.py +462 -0
  431. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_selfcheck.py +862 -0
  432. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/minimize_repro.py +466 -0
  433. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/patch_synthesizer.py +617 -0
  434. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/regression_pack.py +379 -0
  435. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_fixer.py +910 -0
  436. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_loop.py +311 -0
  437. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_repair.py +348 -0
  438. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_rounds.py +212 -0
  439. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_scope.py +281 -0
  440. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/self_heal.py +604 -0
  441. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_generator.py +1108 -0
  442. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_quality_auditor.py +410 -0
  443. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_strategy.py +511 -0
  444. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/INTERFACE.md +59 -0
  445. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/README.md +69 -0
  446. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/SPEC.md +28 -0
  447. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/__init__.py +47 -0
  448. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/attestation.py +228 -0
  449. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/authority.py +255 -0
  450. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/finding_report.py +418 -0
  451. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/formal_report_builder.py +924 -0
  452. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/html_renderers.py +696 -0
  453. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/models.py +759 -0
  454. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/pdf_exporter.py +231 -0
  455. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/projects_assets.py +730 -0
  456. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_client.py +743 -0
  457. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_data_builder.py +388 -0
  458. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_share.py +459 -0
  459. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/sast_bridge.py +116 -0
  460. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/server.py +832 -0
  461. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/visual_report_builder.py +796 -0
  462. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web-conformance.md +168 -0
  463. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web_conformance.py +428 -0
  464. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/workbench_assets.py +484 -0
  465. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/INTERFACE.md +20 -0
  466. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/README.md +161 -0
  467. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/SPEC.md +25 -0
  468. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/__init__.py +3 -0
  469. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/code_analyzer.py +1720 -0
  470. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/codebase_memory_bridge.py +337 -0
  471. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/context_assembler.py +240 -0
  472. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/corpus_fetch.py +369 -0
  473. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/graph_ego.py +597 -0
  474. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_auto.py +662 -0
  475. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sources.py +168 -0
  476. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sync.py +1003 -0
  477. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/memory_store.py +480 -0
  478. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/query_planner.py +1020 -0
  479. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/rrf_engine.py +137 -0
  480. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_extractor.py +1209 -0
  481. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_normalizer.py +373 -0
  482. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_spec.py +357 -0
  483. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/symbol_index.py +1151 -0
  484. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/universal_code_matcher.py +622 -0
  485. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_bridge.py +476 -0
  486. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_supervisor.py +362 -0
  487. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/README.md +33 -0
  488. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/PROVENANCE.json +30 -0
  489. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/crypto.yaml +36 -0
  490. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/network.yaml +20 -0
  491. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/resilience.yaml +47 -0
  492. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/storage.yaml +48 -0
  493. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/LICENSE +173 -0
  494. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/PROVENANCE.json +270 -0
  495. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-asymmetric-key-pair-used-for-multiple-purposes.yml +13 -0
  496. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
  497. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
  498. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
  499. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
  500. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
  501. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
  502. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
  503. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
  504. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
  505. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
  506. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml +36 -0
  507. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-manifest.yml +15 -0
  508. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
  509. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
  510. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
  511. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
  512. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
  513. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
  514. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
  515. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
  516. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
  517. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
  518. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
  519. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
  520. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
  521. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
  522. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
  523. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
  524. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
  525. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
  526. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
  527. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
  528. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
  529. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
  530. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
  531. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
  532. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
  533. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
  534. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
  535. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
  536. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
  537. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
  538. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
  539. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-strictmode.yml +10 -0
  540. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
  541. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
  542. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
  543. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
  544. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
  545. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/PROVENANCE.json +26 -0
  546. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/network.yaml +37 -0
  547. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/platform.yaml +36 -0
  548. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/storage.yaml +48 -0
  549. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/LICENSE +165 -0
  550. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
  551. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/auth.yaml +59 -0
  552. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/crypto.yaml +66 -0
  553. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
  554. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
  555. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/logging.yaml +23 -0
  556. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/network.yaml +55 -0
  557. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/resilience.yaml +29 -0
  558. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/secrets.yaml +33 -0
  559. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/storage.yaml +29 -0
  560. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/webview.yaml +32 -0
  561. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/README.md +198 -0
  562. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/__init__.py +3 -0
  563. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/bugx_logging.py +1464 -0
  564. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/daemon_runner.py +623 -0
  565. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/fixture_solidify.py +444 -0
  566. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/global_telemetry.py +549 -0
  567. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/incident_eval.py +148 -0
  568. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction.py +605 -0
  569. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction_store.py +435 -0
  570. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interactive_menu.py +95 -0
  571. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/log_analytics.py +922 -0
  572. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/mining_quality_framework.py +1387 -0
  573. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/model_runner.py +732 -0
  574. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/platform_adapter.py +579 -0
  575. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/prep_validate.py +478 -0
  576. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_graph.py +827 -0
  577. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_init.py +481 -0
  578. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_profile.py +224 -0
  579. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_settings.py +964 -0
  580. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/provider_window.py +97 -0
  581. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/resume_ticket.py +115 -0
  582. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/scenario_eval.py +856 -0
  583. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/seed_drill.py +549 -0
  584. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/self_audit.py +550 -0
  585. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/session_profile.py +205 -0
  586. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/setup_ui_env.py +229 -0
  587. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/startup_environment.py +859 -0
  588. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/sync_store.py +1421 -0
  589. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/tool_install_targets.py +18 -0
  590. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/README.md +35 -0
  591. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/agent-graph.schema.json +368 -0
  592. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/attack-graph.schema.json +88 -0
  593. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/evidence-bundle.schema.json +33 -0
  594. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/skill-pack.schema.json +230 -0
  595. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/worker-checkpoint.schema.json +119 -0
  596. bugx_cli-0.1.1.data/data/share/bugx-agent/core/secure_atomic.py +289 -0
  597. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/README.md +55 -0
  598. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/c.txt +29 -0
  599. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/cpp.txt +32 -0
  600. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/css.txt +70 -0
  601. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/go.txt +46 -0
  602. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/java.txt +30 -0
  603. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/javascript.txt +55 -0
  604. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/kotlin.txt +28 -0
  605. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/python.txt +71 -0
  606. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/rust.txt +53 -0
  607. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/swift.txt +29 -0
  608. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/typescript.txt +29 -0
  609. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/README.md +53 -0
  610. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/__init__.py +189 -0
  611. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_docs_mcp_server.py +418 -0
  612. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_mcp_server.py +1161 -0
  613. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_runtime.py +968 -0
  614. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_session_proof.py +605 -0
  615. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mobile_ui_inspector.py +405 -0
  616. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_pack.py +1214 -0
  617. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_synthesizer.py +1153 -0
  618. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/tools_kb.py +313 -0
  619. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/INTERFACE.md +121 -0
  620. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/README.md +209 -0
  621. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/SPEC.md +25 -0
  622. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/__init__.py +175 -0
  623. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/audit_supervisor.py +1015 -0
  624. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/budget_governor.py +1254 -0
  625. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_handler.py +368 -0
  626. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_pipeline.py +1564 -0
  627. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_sync.py +653 -0
  628. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_events.py +74 -0
  629. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_sync.py +590 -0
  630. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/cli.py +812 -0
  631. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/context_sync.py +55 -0
  632. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/coverage_sync.py +115 -0
  633. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_commit.py +470 -0
  634. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_sync.py +688 -0
  635. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_workflow.py +676 -0
  636. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_policy.py +224 -0
  637. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_sync.py +185 -0
  638. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/graph_sync.py +669 -0
  639. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lease_manager.py +788 -0
  640. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lifecycle_blocks.py +129 -0
  641. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/next_round_sync.py +126 -0
  642. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/observability.py +140 -0
  643. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/recovery_sync.py +165 -0
  644. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/rejection_remedies.py +355 -0
  645. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/round_governor.py +306 -0
  646. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/serial_authorization.py +544 -0
  647. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/start_sync.py +87 -0
  648. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/state_store.py +249 -0
  649. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_host.py +511 -0
  650. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_models.py +1143 -0
  651. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/systemic_failure.py +104 -0
  652. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/task_scheduler.py +1640 -0
  653. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_checkpoint.py +230 -0
  654. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_execution.py +265 -0
  655. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_handoff.py +192 -0
  656. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_lifecycle.py +396 -0
  657. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_runtime.py +1005 -0
  658. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_sync.py +89 -0
  659. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/README.md +36 -0
  660. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/__init__.py +0 -0
  661. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/exceptions.py +52 -0
  662. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/graph_models.py +357 -0
  663. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/path_containment.py +151 -0
  664. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/target_fingerprint.py +310 -0
  665. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/worker_claim.py +411 -0
  666. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/INTERFACE.md +50 -0
  667. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/README.md +57 -0
  668. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/SPEC.md +26 -0
  669. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/__init__.py +11 -0
  670. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/__init__.py +27 -0
  671. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/base.py +87 -0
  672. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/bugx.py +102 -0
  673. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/claude.py +222 -0
  674. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/cline.py +407 -0
  675. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/codex.py +260 -0
  676. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/dsh.py +177 -0
  677. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/opencode.py +218 -0
  678. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/pi.py +272 -0
  679. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/registry.py +100 -0
  680. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/zcode.py +312 -0
  681. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/api_routes_post.py +668 -0
  682. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/dispatcher.py +1376 -0
  683. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/docs_session_service.py +473 -0
  684. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/handler.py +674 -0
  685. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/ide_cloud_service.py +526 -0
  686. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/mcp_inspector.py +1747 -0
  687. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/00-base.css +1060 -0
  688. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/01-monitoring.css +802 -0
  689. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/02-header-actions.css +321 -0
  690. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/03-trigger-popover.css +697 -0
  691. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/04-composer.css +628 -0
  692. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/05-skills-center.css +878 -0
  693. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/06-mcp-center.css +623 -0
  694. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/07-skill-detail.css +265 -0
  695. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/08-files-management.css +167 -0
  696. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/09-files-center.css +386 -0
  697. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/10-icons.css +105 -0
  698. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/11-project-options.css +185 -0
  699. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/12-profile-tab.css +383 -0
  700. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-CXAsl8mr.js +333 -0
  701. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-DHQUtWtx.css +1 -0
  702. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
  703. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
  704. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-Bb4u56_6.woff +0 -0
  705. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
  706. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-CWV284fw.woff2 +0 -0
  707. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-DLkyKLvH.woff +0 -0
  708. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-8-8HP2PF.woff +0 -0
  709. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-DaDZE_Na.woff2 +0 -0
  710. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-BccYJ-vZ.woff +0 -0
  711. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-Cw5-AHNN.woff2 +0 -0
  712. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
  713. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-z-Q6FFuG.woff +0 -0
  714. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
  715. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-Dn3IlU-Z.woff +0 -0
  716. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
  717. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
  718. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-CEpydyUl.woff +0 -0
  719. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-Cp7z-ARB.woff2 +0 -0
  720. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-BYjRCDVy.woff2 +0 -0
  721. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-D-qasQTj.woff +0 -0
  722. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
  723. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
  724. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
  725. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
  726. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/design-tokens.css +113 -0
  727. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/favicon.png +0 -0
  728. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/icon-192.png +0 -0
  729. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/index.html +55 -0
  730. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/manifest.webmanifest +19 -0
  731. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/project-settings.js +9602 -0
  732. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/sw.js +8 -0
  733. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/workspace_service.py +218 -0
  734. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/agents/bugx.md +27 -0
  735. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/dsh-patch.yml +18 -0
  736. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/cordis.patch.yml +4 -0
  737. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/index.js +219 -0
  738. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/package.json +28 -0
  739. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx/SKILL.md +70 -0
  740. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx-dsh/SKILL.md +229 -0
  741. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/client.js +87 -0
  742. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/cordis.patch.yml +4 -0
  743. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/index.js +7 -0
  744. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/package.json +27 -0
  745. bugx_cli-0.1.1.data/data/share/bugx-agent/mcp-lock.json +3075 -0
  746. bugx_cli-0.1.1.data/data/share/bugx-agent/opencode.json +129 -0
  747. bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/README.md +12 -0
  748. bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/index.ts +299 -0
  749. bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/manifest.json +11 -0
  750. bugx_cli-0.1.1.data/data/share/bugx-agent/pi/skills/bugx/SKILL.md +69 -0
  751. bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
  752. bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
  753. bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
  754. bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/connector-meta.json +19 -0
  755. bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/icon.png +0 -0
  756. bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/skills/bugx/SKILL.md +70 -0
  757. bugx_cli-0.1.1.dist-info/METADATA +335 -0
  758. bugx_cli-0.1.1.dist-info/RECORD +762 -0
  759. bugx_cli-0.1.1.dist-info/WHEEL +5 -0
  760. bugx_cli-0.1.1.dist-info/entry_points.txt +2 -0
  761. bugx_cli-0.1.1.dist-info/licenses/LICENSE +55 -0
  762. bugx_cli-0.1.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1161 @@
1
+ #!/usr/bin/env python3
2
+ """BugX 本地 Supervisor MCP 服务。
3
+
4
+ 这是一个无第三方依赖的 MCP stdio 适配层。它只把现有
5
+ ``audit_supervisor.Supervisor`` 的状态机暴露给宿主 AI,不执行 worker 命令,
6
+ 不执行 worker 命令,不访问网络,也不把 ``.bugx`` 的事实源迁移到 MCP 服务进程之外。
7
+
8
+ 每个请求都是一次有限的状态操作;服务不会通过长轮询阻塞等待 worker。宿主应
9
+ 根据 ``next_action`` 决定下一次调用,lease 超时则由 Supervisor 的 status/gate
10
+ 操作回收并记录。
11
+ """
12
+
13
+ from __future__ import annotations
14
+ # --- 引擎导入根(直接执行脚本时自举 core.* 命名空间)---
15
+ import sys as _sys
16
+ from pathlib import Path as _Path
17
+
18
+ for _p in _Path(__file__).resolve().parents:
19
+ if (_p / "core" / "bugx.md").is_file():
20
+ if str(_p) not in _sys.path:
21
+ _sys.path.insert(0, str(_p))
22
+ break
23
+ del _p
24
+
25
+ import argparse
26
+ import atexit
27
+ import errno
28
+ import hashlib
29
+ import json
30
+ import math
31
+ import os
32
+ import re
33
+ import signal
34
+ import subprocess
35
+ import sys
36
+ import threading
37
+ import time
38
+ from pathlib import Path
39
+ from typing import Any, Callable, Mapping, Sequence
40
+
41
+ from core.infra.build_info import BASE_VERSION
42
+ from urllib.parse import parse_qs, urlparse
43
+
44
+ try:
45
+ import fcntl
46
+ except ImportError: # pragma: no cover - Windows hosts use msvcrt or fallback.
47
+ fcntl = None # type: ignore[assignment]
48
+
49
+ try:
50
+ import msvcrt
51
+ except ImportError:
52
+ msvcrt = None # type: ignore[assignment]
53
+
54
+ _CORE_DIR = Path(__file__).resolve().parent.parent if Path(__file__).resolve().parent.name == "skills" else Path(__file__).resolve().parent
55
+ _REPO_ROOT = _CORE_DIR.parent
56
+ for _p in (str(_REPO_ROOT), str(_CORE_DIR)):
57
+ if _p not in sys.path:
58
+ sys.path.insert(0, _p)
59
+
60
+ # 这些是核心领域模块(core/),缺失即安装损坏:直接 import 让错误在
61
+ # 启动时显式失败,不再用 None 兜底掩盖(DOC-031)。
62
+ from core.supervisor import audit_supervisor
63
+ import core.bugx_paths as bugx_paths
64
+ # 双入口守卫(**不是**兼容别名):本模块既被包内导入,也被宿主以
65
+ # ``python core/skills/<name>.py`` 直接当脚本启动(MCP stdio 子进程)。
66
+ # 脚本模式下 ``__package__`` 为空,相对导入会 ``ImportError: attempted
67
+ # relative import with no known parent package``;此时改用绝对点号名。
68
+ # 两条路径指向**同一个**文件,不存在第二套实现。
69
+ if __package__:
70
+ from . import mcp_session_proof
71
+ else:
72
+ from core.skills import mcp_session_proof
73
+ from core.runtime import bugx_logging
74
+ from core.coverage import coverage_bootstrap
75
+ from core.coverage import module_coverage
76
+ from core.retrieval import knowledge_sources
77
+ import core.secure_atomic as secure_atomic
78
+ from core.planning import unit_kind
79
+ from core.supervisor import checkpoint_pipeline
80
+ from core.supervisor.supervisor_models import VALID_COVERAGE_STATES, VALID_EVIDENCE_STATES
81
+
82
+ # LOG-06:租约上限的单一来源。此前 inputSchema 硬编码 3600,而
83
+ # supervisor_models.MAX_LEASE_SECONDS 是 14400(注释还写「1 小时」),
84
+ # task_scheduler 的推算上限又是 3600——三处漂移。直接引用常量,
85
+ # 让 test_consistency 之外也能靠符号本身保持同步。
86
+ LEASE_SECONDS_MAX = audit_supervisor.MAX_LEASE_SECONDS
87
+
88
+ # DES-05:业务单元前缀的单一来源。schema 里的正则此前硬编码 "^业务:.+",
89
+ # 与 unit_kind.PREFIXES 分离——新增单元类型时会漏改协议层校验,导致
90
+ # 「协议层接受、领域层不认」或反之的静默不一致。
91
+ UNIT_BUSINESS_PATTERN = f"^{unit_kind.UnitKind.BUSINESS.value}:.+"
92
+
93
+ from core.mcp_handlers import (
94
+ HANDLER_REGISTRY,
95
+ MAX_ARTIFACT_PATH_LENGTH,
96
+ MAX_COMMAND_LENGTH,
97
+ MAX_COVERAGE_PER_CHECKPOINT,
98
+ MAX_EVIDENCE_PER_CHECKPOINT,
99
+ MAX_FINDING_FIELD_LENGTH,
100
+ MAX_FINDING_FINGERPRINT_LENGTH,
101
+ MAX_FINDINGS_PER_CHECKPOINT,
102
+ MAX_MCP_JSON_DEPTH,
103
+ MAX_MCP_JSON_KEYS,
104
+ MAX_MCP_REQUEST_BYTES,
105
+ MAX_UNITS_PER_CLAIM,
106
+ McpProtocolError,
107
+ TOKEN_BASE_BUDGET,
108
+ TOKEN_HARD_CEILING,
109
+ TOKEN_MAX_RENEWALS,
110
+ TOKEN_NEEDED_MAX,
111
+ TOKEN_NEEDED_MIN,
112
+ TOKEN_REASON_MAX_LENGTH,
113
+ TOKEN_RENEWAL_MAX_GRANT,
114
+ TOKEN_RENEWAL_STATE_VERSION,
115
+ bool_argument,
116
+ check_json_depth_and_keys,
117
+ compact_json,
118
+ format_result,
119
+ next_action,
120
+ number_argument,
121
+ optional_string,
122
+ optional_string_array_argument,
123
+ project_state,
124
+ recovery_chain,
125
+ serialize_value,
126
+ string_array_argument,
127
+ validate_checkpoint_sizes,
128
+ )
129
+
130
+
131
+ def _finding_severity_levels() -> tuple[str, ...]:
132
+ """finding 严重度单一真源(BX-ENGINE-18);委托给唯一访问器。
133
+
134
+ 仅为渲染 MCP schema 的 ``severity`` enum,避免「schema 无 enum / 门禁有词表」
135
+ 再次漂移。词表与 fallback 快照的唯一定义在
136
+ ``supervisor_models.finding_severity_levels``,此处不再复制字面量。
137
+ """
138
+ try:
139
+ from core.supervisor.supervisor_models import finding_severity_levels
140
+
141
+ return finding_severity_levels()
142
+ except ImportError: # pragma: no cover - 引擎目录不完整时
143
+ return ("info", "low", "medium", "high", "critical")
144
+
145
+
146
+ _FINDING_SEVERITY_LEVELS = _finding_severity_levels()
147
+
148
+ def _i18n_exc(key: str, fallback: str, locale: str | None = None, **kwargs: Any) -> str:
149
+ try:
150
+ import core.i18n as i18n
151
+ return i18n.exception_text(key, locale=locale, fallback=fallback, **kwargs)
152
+ except Exception:
153
+ if not kwargs:
154
+ return fallback
155
+ try:
156
+ return fallback.format(**kwargs)
157
+ except Exception:
158
+ return fallback
159
+
160
+
161
+ def _i18n_prompt(key: str, fallback: str, locale: str | None = None, **kwargs: Any) -> str:
162
+ try:
163
+ import core.i18n as i18n
164
+ return i18n.prompt_text(key, locale=locale, fallback=fallback, **kwargs)
165
+ except Exception:
166
+ if not kwargs:
167
+ return fallback
168
+ try:
169
+ return fallback.format(**kwargs)
170
+ except Exception:
171
+ return fallback
172
+
173
+
174
+ MCP_PROTOCOL_VERSION = "2024-11-05"
175
+ SERVER_NAME = "bugx-supervisor"
176
+ SERVER_VERSION = BASE_VERSION
177
+ JSONRPC_VERSION = "2.0"
178
+ # A CLI ``pre`` command is short-lived, while the host MCP stdio process owns
179
+ # the Session afterwards. Keep the interval well below the time it takes for
180
+ # the next CLI phase to start so a new polling scope is claimed before the
181
+ # runtime orphan detector sees the pre process as dead.
182
+ HOST_SESSION_HEARTBEAT_INTERVAL_SECONDS = 5.0
183
+ MCP_ROLES = {"host", "worker"}
184
+ # DES-08:MCP 工具元数据的**单一真源**。
185
+ #
186
+ # 原先工具元数据分散在三处维护,任一处笔误都会静默产生「被宣告但无法分发」
187
+ # 或「能分发但未被宣告」的工具:
188
+ # 1. HOST_TOOLS / WORKER_TOOLS / READ_ONLY_TOOLS 三个角色集合(原在本处);
189
+ # 2. ``_tool_definitions()`` 内的 41 条 schema 字面量;
190
+ # 3. ``mcp_handlers.HANDLER_REGISTRY``(工具名 -> 实现的分发表)。
191
+ # 现在:角色归属与 schema 在 ``_build_tool_table()`` 里**同处声明**,三个集合由它派生,
192
+ # 分发表由模块底部的 ``_assert_tool_registry_consistent()`` 强制校验。
193
+ #
194
+ # 角色语义:三个集合**两两不相交**,并集即全部工具。
195
+ # _HOST_ONLY 仅宿主可调用;_WORKER_ONLY 仅 Worker 可调用;_SHARED_ROLES 双方均可。
196
+ _HOST_ONLY = frozenset({"host"})
197
+ _WORKER_ONLY = frozenset({"worker"})
198
+ _SHARED_ROLES = frozenset({"host", "worker"})
199
+
200
+ # (Protocol caps and McpProtocolError imported from mcp_handlers)
201
+
202
+
203
+ import core.mcp_handlers.channel_lifecycle as _cl
204
+
205
+ _pid_alive = _cl._pid_alive
206
+ _idle_self_exit_seconds = _cl._idle_self_exit_seconds
207
+ _ChannelActivity = _cl._ChannelActivity
208
+ _channel_active_claim_keys = _cl._channel_active_claim_keys
209
+ _channel_idle_exit_reason = _cl._channel_idle_exit_reason
210
+ _record_lease_event = _cl._record_lease_event
211
+ _channel_self_retire = _cl._channel_self_retire
212
+ _channel_idle_monitor_loop = _cl._channel_idle_monitor_loop
213
+ _read_lease_holder = _cl._read_lease_holder
214
+ _holder_idle_seconds = _cl._holder_idle_seconds
215
+ _takeover_holder = _cl._takeover_holder
216
+ _host_channel_state_path = _cl._host_channel_state_path
217
+ _clear_host_channel_unavailable = _cl._clear_host_channel_unavailable
218
+ _run_external = _cl._run_external
219
+ _holder_started_at = _cl._holder_started_at
220
+ _record_host_channel_unavailable = _cl._record_host_channel_unavailable
221
+ _ControllerLease = _cl._ControllerLease
222
+ _host_session_heartbeat_once = _cl._host_session_heartbeat_once
223
+ _host_session_heartbeat_loop = _cl._host_session_heartbeat_loop
224
+
225
+ # DEF-2:允许从 McpProtocolError.mcp_error_data 透传到错误回包的结构化字段。
226
+ # 白名单而非全量合并——防止任意异常的可变属性污染 isError 回包的交互门禁字段。
227
+ _MCP_ERROR_DATA_ALLOWED_KEYS = frozenset({"evidence_feedback"})
228
+
229
+
230
+ def _error_payload(error: BaseException) -> dict[str, object]:
231
+ payload: dict[str, object] = {
232
+ "error_type": type(error).__name__,
233
+ "message": str(error) or type(error).__name__,
234
+ "error_code": "MCP_CALL_FAILED",
235
+ "interactive_required": True,
236
+ "next_action": "PROMPT_USER",
237
+ "prompt": (
238
+ "MCP 调用失败,请立即询问用户:1) 立即重试 2) 本轮切换手动/回退 "
239
+ "3) 下次再说(停止本轮)"
240
+ ),
241
+ "choices": ["retry", "fallback", "later"],
242
+ }
243
+ # DEF-2 残余缺口:McpProtocolError 携带的结构化拒绝原因(如逐项
244
+ # violations + correct_sample + retry_prompt)随回包 data 透传,宿主/
245
+ # 模型无需从一行纯文本里猜自纠指令。仅白名单已知结构化字段,避免任意
246
+ # 异常的可变属性污染回包;核心交互字段始终以标准值为准不可覆盖。
247
+ extra = getattr(error, "mcp_error_data", None)
248
+ if isinstance(extra, dict):
249
+ for key, value in extra.items():
250
+ if key in _MCP_ERROR_DATA_ALLOWED_KEYS:
251
+ payload[key] = value
252
+ return payload
253
+
254
+
255
+ def _call_failure_data(operation: object, error: BaseException) -> dict[str, object]:
256
+ """为 tools/call 协议错误提供可被宿主直接呈现的交互门禁。"""
257
+ payload = _error_payload(error)
258
+ payload["operation"] = str(operation or "unknown")
259
+ return payload
260
+
261
+
262
+ # (next_action imported from mcp_handlers)
263
+
264
+
265
+ class BugxMcpService:
266
+ """MCP facade bound to one project and active lifecycle.
267
+
268
+ Construction is deliberately fail-closed: it never creates or repairs the
269
+ ``.bugx`` layout on its own. A missing or incomplete layout must be
270
+ created through an explicit, host-confirmed entry (``bugx init`` /
271
+ ``bugx_paths.initialize`` or a host-driven bootstrap), so an arbitrary
272
+ directory opened by a host cannot silently become a BugX project.
273
+ """
274
+
275
+ # Controlled explicit initialization entry retained for hosts that need
276
+ # to bootstrap a fresh workspace. It requires an explicit host
277
+ # confirmation and never runs implicitly from construction.
278
+ @staticmethod
279
+ def initialize_project(root: Path, *, bugx_version: str = SERVER_VERSION) -> object:
280
+ """Explicit, host-confirmed project initialization entry.
281
+
282
+ Callers must have obtained user/host confirmation before invoking.
283
+ This is the only MCP-side path that may create ``.bugx``.
284
+ """
285
+ target = root.expanduser().resolve()
286
+ if not target.is_dir():
287
+ raise McpProtocolError(f"项目根目录不是目录: {target}")
288
+ return bugx_paths.initialize(target, bugx_version=bugx_version)
289
+
290
+ def __init__(self, root: Path, *, role: str = "host") -> None:
291
+ self.root = root.expanduser().resolve()
292
+ if not self.root.is_dir():
293
+ raise McpProtocolError(f"项目根目录不是目录: {self.root}")
294
+ if role not in MCP_ROLES:
295
+ raise McpProtocolError(f"MCP role 必须是 {sorted(MCP_ROLES)}")
296
+ self.role = role
297
+ # Host injects this identity only into the dedicated Worker stdio
298
+ # process it launches. A caller-supplied MCP argument is never enough
299
+ # to authenticate a graph Worker.
300
+ self.native_agent_id = (
301
+ os.environ.get("BUGX_NATIVE_AGENT_ID") if role == "worker" else None
302
+ )
303
+ # ``tools/list`` can happen before ``pre`` creates a new polling
304
+ # scope. Retain only the bounded names so a later request/heartbeat
305
+ # can republish the same receipt into the current scope.
306
+ self._session_tool_names: tuple[str, ...] = ()
307
+ # DOC-230 3.1 层 2 / 3.2:由 ``serve()`` 注入的通道活动记录。
308
+ # 非 stdio 场景(进程内服务、测试)保持 None,行为完全不变。
309
+ self.activity: _ChannelActivity | None = None
310
+ # A stdio process can outlive a BugX polling scope. Bind its proof to
311
+ # one UUID and refresh the scope fields on each publication so a stale
312
+ # PID or a replacement connection cannot overwrite this receipt.
313
+ self._session_instance_id = mcp_session_proof.new_instance_id()
314
+ self._session_process_start_token = mcp_session_proof.process_start_token(os.getpid())
315
+ self._session_last_request_at: float | None = None
316
+ self._session_last_progress_at: float | None = None
317
+ # Fail-closed: do not touch the filesystem here. Layout validation
318
+ # is deferred to _scope() so construction has no side effects.
319
+
320
+ def _scope(self):
321
+ try:
322
+ return bugx_paths.require(self.root)
323
+ except bugx_paths.LayoutError as exc:
324
+ # Surface as a structured MCP protocol error so hosts can prompt
325
+ # for explicit initialization instead of silently creating state.
326
+ raise McpProtocolError(
327
+ f"[INITIALIZATION_REQUIRED] 项目未初始化或布局不完整: {exc};请先通过受控入口初始化(bugx install --root . --agent {self.role} --non-interactive)",
328
+ code=-32602,
329
+ ) from exc
330
+
331
+ def is_initialized(self) -> bool:
332
+ """Check whether the active workspace layout is complete."""
333
+ try:
334
+ bugx_paths.require(self.root)
335
+ return True
336
+ except bugx_paths.LayoutError:
337
+ return False
338
+
339
+ def acquire_controller_lease(self) -> _ControllerLease:
340
+ """Acquire the single IDE control lease for the host channel."""
341
+ if self.role != "host":
342
+ raise McpProtocolError("worker MCP 通道不能持有主控租约")
343
+ lease = _ControllerLease(self._scope().state_root / "controller.lock")
344
+ lease.acquire()
345
+ return lease
346
+
347
+ def _session_proof_path(self) -> Path:
348
+ return mcp_session_proof.proof_path(
349
+ self._scope().state_root, self._session_instance_id,
350
+ )
351
+
352
+ def _session_scope_fields(self) -> tuple[str | None, str | None, int]:
353
+ """Read the current lifecycle binding without making one up."""
354
+ lifecycle_id: str | None = None
355
+ scope: str | None = None
356
+ generation = 0
357
+ try:
358
+ current = bugx_paths.read_current(self.root)
359
+ lifecycle_id = str(
360
+ current.get("lifecycle_id") or current.get("polling_id") or ""
361
+ ).strip() or None
362
+ scope = str(current.get("scope") or lifecycle_id or "").strip() or None
363
+ raw_generation = current.get("scope_generation", 0)
364
+ if isinstance(raw_generation, int) and not isinstance(raw_generation, bool):
365
+ generation = max(0, raw_generation)
366
+ except Exception:
367
+ pass
368
+ if scope is None:
369
+ try:
370
+ scope = self._scope().lifecycle_root.name
371
+ except Exception:
372
+ pass
373
+ return lifecycle_id, scope, generation
374
+
375
+ def _session_entrypoint_hash(self) -> str:
376
+ try:
377
+ return __import__("hashlib").sha256(
378
+ Path(__file__).read_bytes()
379
+ ).hexdigest()
380
+ except OSError:
381
+ return "0" * 64
382
+
383
+ def _touch_session_request(self) -> None:
384
+ self._session_last_request_at = time.time()
385
+ try:
386
+ mcp_session_proof.update_proof(
387
+ self._scope().state_root, self._session_instance_id,
388
+ last_request_at=self._session_last_request_at,
389
+ inflight=1,
390
+ )
391
+ except (OSError, ValueError, RuntimeError):
392
+ pass
393
+
394
+ def _touch_session_progress(self) -> None:
395
+ self._session_last_progress_at = time.time()
396
+ try:
397
+ mcp_session_proof.update_proof(
398
+ self._scope().state_root, self._session_instance_id,
399
+ last_progress_at=self._session_last_progress_at,
400
+ inflight=0,
401
+ )
402
+ except (OSError, ValueError, RuntimeError):
403
+ pass
404
+
405
+ def write_session_proof(self, tool_names: Sequence[str]) -> Path:
406
+ """Publish a bounded receipt after the real MCP tools/list handshake."""
407
+ names = tuple(str(name)[:256] for name in list(tool_names)[:256])
408
+ self._session_tool_names = names
409
+ now = time.time()
410
+ lifecycle_id, scope, generation = self._session_scope_fields()
411
+ phase = mcp_session_proof.PHASE_ACTIVE
412
+ try:
413
+ existing = mcp_session_proof.read_proof(
414
+ self._session_proof_path(),
415
+ expected_instance_id=self._session_instance_id,
416
+ )
417
+ phase = str(existing.get("phase") or phase)
418
+ self._session_last_request_at = existing.get("last_request_at") # type: ignore[assignment]
419
+ self._session_last_progress_at = existing.get("last_progress_at") # type: ignore[assignment]
420
+ except (OSError, ValueError, RuntimeError):
421
+ pass
422
+ return mcp_session_proof.write_proof(
423
+ self._scope().state_root,
424
+ {
425
+ "schema_version": mcp_session_proof.SCHEMA_VERSION,
426
+ "server": SERVER_NAME,
427
+ "server_version": SERVER_VERSION,
428
+ "root": str(self.root),
429
+ "scope": scope,
430
+ "lifecycle_id": lifecycle_id,
431
+ "scope_generation": generation,
432
+ "role": self.role,
433
+ "instance_id": self._session_instance_id,
434
+ "pid": os.getpid(),
435
+ "process_start_token": self._session_process_start_token,
436
+ "engine_build": SERVER_VERSION,
437
+ "entrypoint_hash": self._session_entrypoint_hash(),
438
+ "transport": "stdio",
439
+ "phase": phase,
440
+ "written_at": now,
441
+ "proof_written_at": now,
442
+ "last_request_at": self._session_last_request_at,
443
+ "last_progress_at": self._session_last_progress_at,
444
+ "inflight": 0,
445
+ "loaded": True,
446
+ "callable": True,
447
+ "healthy": phase == mcp_session_proof.PHASE_ACTIVE,
448
+ "tool_names": list(names),
449
+ },
450
+ instance=self._session_instance_id,
451
+ now=now,
452
+ )
453
+
454
+ def refresh_session_proof(self) -> Path | None:
455
+ """Republish the tools/list receipt after the current scope changes.
456
+
457
+ OpenCode keeps MCP stdio processes alive across BugX Session creation.
458
+ The service therefore cannot treat the scope captured at process start
459
+ as authoritative. A refresh is best-effort for MCP availability; the
460
+ autonomous lifecycle gate remains the fail-closed authority.
461
+ """
462
+ if not self._session_tool_names:
463
+ return None
464
+ try:
465
+ return self.write_session_proof(self._session_tool_names)
466
+ except (OSError, ValueError, RuntimeError):
467
+ return None
468
+
469
+ def clear_session_proof(self) -> None:
470
+ """Cooperatively close this connection without deleting its receipt."""
471
+ try:
472
+ mcp_session_proof.set_phase(
473
+ self._scope().state_root, self._session_instance_id,
474
+ mcp_session_proof.PHASE_RETIRING,
475
+ )
476
+ mcp_session_proof.set_phase(
477
+ self._scope().state_root, self._session_instance_id,
478
+ mcp_session_proof.PHASE_CLOSED,
479
+ )
480
+ except (OSError, UnicodeError, ValueError, RuntimeError):
481
+ return
482
+
483
+ def get_supervisor(self, *, budget: Any = None):
484
+ active = self._scope()
485
+ return audit_supervisor.Supervisor(
486
+ self.root,
487
+ budget=budget,
488
+ state_path=active.supervisor,
489
+ )
490
+
491
+ def _coverage_units(self) -> list[str]:
492
+ active = self._scope()
493
+ manifest = active.state_root / "module-coverage.md"
494
+ if not manifest.is_file() or manifest.is_symlink():
495
+ raise McpProtocolError(f"覆盖清单缺失或不安全: {manifest}")
496
+ return checkpoint_pipeline.load_manifest_units(self.root, manifest)
497
+
498
+ @staticmethod
499
+ def _coverage_bootstrap_gate(state: Mapping[str, object]) -> dict[str, object]:
500
+ return {
501
+ "status": "COVERAGE_BOOTSTRAP_REQUIRED",
502
+ "interactive_required": True,
503
+ "next_action": "PROMPT_USER",
504
+ "gate": "coverage_bootstrap",
505
+ "question": "覆盖清单尚未建立,是否运行引导创建?",
506
+ "multiple": False,
507
+ "options": [
508
+ {
509
+ "label": "运行引导创建",
510
+ "description": "由 BugX Supervisor 创建本生命周期的最小覆盖单元,然后自动重试启动",
511
+ "value": "bootstrap",
512
+ },
513
+ {
514
+ "label": "下次再说",
515
+ "description": "停止本轮启动,不创建或修改任何运行态清单",
516
+ "value": "later",
517
+ },
518
+ ],
519
+ "detail": str(state.get("detail") or "覆盖清单缺失"),
520
+ "path": state.get("path"),
521
+ }
522
+
523
+ def _consumption_ids(self) -> tuple[str, str]:
524
+ """Resolve the current Session/Round/Life/run for knowledge consumption.
525
+
526
+ The ledger must be able to audit which lifecycle and run actually
527
+ consumed a pattern/incident. Using a fixed ``mcp`` placeholder hides
528
+ the true Session/Round/Life/run and breaks the host's traceability
529
+ gate. We therefore bind to the authoritative project layout and, when
530
+ a Supervisor run exists, to its live ``run_id``.
531
+ """
532
+ lifecycle_id: str | None = None
533
+ run_id: str | None = None
534
+ # Primary lifecycle is the authoritative project current (Life).
535
+ try:
536
+ cur = bugx_paths.read_current(self.root)
537
+ lifecycle_id = str(cur.get("lifecycle_id") or cur.get("polling_id") or "")
538
+ if not run_id:
539
+ base_lifecycle = cur.get("lifecycle_id")
540
+ base_polling = cur.get("polling_id")
541
+ # PE-20261005-003: 诊断兜底与 Supervisor 生成侧同形(polling 限定)
542
+ if base_lifecycle and base_polling:
543
+ run_id = f"lifecycle-{base_polling}-{base_lifecycle}"
544
+ elif base_lifecycle or base_polling:
545
+ run_id = f"lifecycle-{base_lifecycle or base_polling}"
546
+ except Exception:
547
+ pass
548
+ # Prefer the live Supervisor run_id when a run exists; keep lifecycle
549
+ # as the current Life (not the polling Session) for ledger indexing.
550
+ try:
551
+ sup = self.get_supervisor()
552
+ st = sup.status()
553
+ rid = getattr(st, "run_id", None)
554
+ if isinstance(rid, str) and rid.strip():
555
+ run_id = rid.strip()
556
+ # If Supervisor has an explicit life_id, it is authoritative for
557
+ # the Life; otherwise keep the current lifecycle.
558
+ lid = getattr(st, "life_id", None)
559
+ if isinstance(lid, str) and lid.strip():
560
+ lifecycle_id = lid.strip()
561
+ except Exception:
562
+ pass
563
+ # Final fallback: use the scope's lifecycle when readable.
564
+ if not lifecycle_id or not run_id:
565
+ try:
566
+ sc = self._scope()
567
+ if not lifecycle_id:
568
+ lifecycle_id = sc.lifecycle_root.name
569
+ if not run_id:
570
+ # PE-20261005-003: 与 Supervisor 生成侧同形(polling 限定)
571
+ _polling_name = sc.lifecycle_root.parent.parent.name
572
+ run_id = (
573
+ f"lifecycle-{_polling_name}-{sc.lifecycle_root.name}"
574
+ if _polling_name.startswith("polling-")
575
+ else f"lifecycle-{sc.lifecycle_root.name}"
576
+ )
577
+ except Exception:
578
+ pass
579
+ lifecycle_id = (lifecycle_id or "unknown").strip() or "unknown"
580
+ run_id = (run_id or "unknown").strip() or "unknown"
581
+ # Never return the old placeholder; it would hide the real binding.
582
+ if lifecycle_id == "mcp":
583
+ lifecycle_id = "unknown"
584
+ if run_id == "mcp":
585
+ run_id = "unknown"
586
+ return lifecycle_id, run_id
587
+
588
+ def _request_token_renewal(self, *, reason: str, needed: int) -> dict[str, object]:
589
+ """Atomically account for a bounded token renewal in the active lifecycle."""
590
+ try:
591
+ with bugx_paths._project_lock(self.root):
592
+ scope = self._scope()
593
+ state_path = scope.state_root / "mcp-token-renewal.json"
594
+ try:
595
+ secure_atomic.reject_symlink_components(state_path)
596
+ except secure_atomic.AtomicWriteError as exc:
597
+ raise McpProtocolError(
598
+ f"动态续命状态路径不安全: {state_path}", code=-32602,
599
+ ) from exc
600
+
601
+ if state_path.exists():
602
+ if state_path.is_symlink() or not state_path.is_file():
603
+ raise McpProtocolError(
604
+ "动态续命状态损坏,拒绝重置", code=-32602,
605
+ )
606
+ try:
607
+ if state_path.stat().st_size > 65536:
608
+ raise ValueError("state too large")
609
+ state = json.loads(state_path.read_text(encoding="utf-8"))
610
+ except (OSError, UnicodeError, ValueError, json.JSONDecodeError) as exc:
611
+ raise McpProtocolError(
612
+ "动态续命状态损坏,拒绝重置", code=-32602,
613
+ ) from exc
614
+ else:
615
+ state = {
616
+ "schema_version": TOKEN_RENEWAL_STATE_VERSION,
617
+ "lifecycle_id": scope.lifecycle_root.name,
618
+ "renewals_used": 0,
619
+ "granted_tokens": 0,
620
+ "reason_digests": [],
621
+ }
622
+
623
+ if not isinstance(state, dict):
624
+ raise McpProtocolError("动态续命状态损坏,拒绝重置", code=-32602)
625
+ renewals_used = state.get("renewals_used")
626
+ granted_tokens = state.get("granted_tokens")
627
+ reason_digests = state.get("reason_digests")
628
+ if (
629
+ state.get("schema_version") != TOKEN_RENEWAL_STATE_VERSION
630
+ or state.get("lifecycle_id") != scope.lifecycle_root.name
631
+ or isinstance(renewals_used, bool)
632
+ or not isinstance(renewals_used, int)
633
+ or not 0 <= renewals_used <= TOKEN_MAX_RENEWALS
634
+ or isinstance(granted_tokens, bool)
635
+ or not isinstance(granted_tokens, int)
636
+ or not 0 <= granted_tokens <= TOKEN_RENEWAL_MAX_GRANT * TOKEN_MAX_RENEWALS
637
+ or TOKEN_BASE_BUDGET + granted_tokens > TOKEN_HARD_CEILING
638
+ or granted_tokens < renewals_used * TOKEN_NEEDED_MIN
639
+ or granted_tokens > renewals_used * TOKEN_RENEWAL_MAX_GRANT
640
+ or not isinstance(reason_digests, list)
641
+ or len(reason_digests) != renewals_used
642
+ or any(
643
+ not isinstance(item, str) or len(item) != 64
644
+ or any(char not in "0123456789abcdef" for char in item)
645
+ for item in reason_digests
646
+ )
647
+ ):
648
+ raise McpProtocolError("动态续命状态损坏,拒绝重置", code=-32602)
649
+
650
+ current_budget = TOKEN_BASE_BUDGET + granted_tokens
651
+ if renewals_used >= TOKEN_MAX_RENEWALS:
652
+ return {
653
+ "status": "ok",
654
+ "approved": False,
655
+ "granted_tokens": 0,
656
+ "renewals_used": renewals_used,
657
+ "renewals_remaining": 0,
658
+ "current_budget": current_budget,
659
+ }
660
+
661
+ grant = min(
662
+ needed,
663
+ TOKEN_RENEWAL_MAX_GRANT,
664
+ TOKEN_HARD_CEILING - current_budget,
665
+ )
666
+ if grant <= 0:
667
+ return {
668
+ "status": "ok",
669
+ "approved": False,
670
+ "granted_tokens": 0,
671
+ "renewals_used": renewals_used,
672
+ "renewals_remaining": 0,
673
+ "current_budget": current_budget,
674
+ }
675
+
676
+ state["renewals_used"] = renewals_used + 1
677
+ state["granted_tokens"] = granted_tokens + grant
678
+ state["reason_digests"] = [
679
+ *reason_digests,
680
+ hashlib.sha256(reason.encode("utf-8")).hexdigest(),
681
+ ]
682
+ secure_atomic.atomic_write_json(
683
+ state_path, state, mode=0o600, parent_mode=0o700,
684
+ )
685
+ return {
686
+ "status": "ok",
687
+ "approved": True,
688
+ "granted_tokens": grant,
689
+ "renewals_used": renewals_used + 1,
690
+ "renewals_remaining": TOKEN_MAX_RENEWALS - renewals_used - 1,
691
+ "current_budget": current_budget + grant,
692
+ }
693
+ except McpProtocolError:
694
+ raise
695
+ except (bugx_paths.LayoutError, OSError, secure_atomic.AtomicWriteError) as exc:
696
+ raise McpProtocolError(f"动态续命状态不可用: {exc}", code=-32602) from exc
697
+
698
+ def _host_channel_state(self) -> dict[str, object]:
699
+ """DOC-230 3.3:返回 host 通道可用性,供 status 内联给 worker 通道。
700
+
701
+ - 本进程就是 host → 必然可用;
702
+ - 否则读取 host 启动失败时落盘的冲突记录(带 TTL,避免陈旧误报);
703
+ - 无记录/记录过期 → `available=None`(**未观察到冲突**,不等于可用)。
704
+ """
705
+ if self.role == "host":
706
+ return {
707
+ "available": True, "blocked_by": None,
708
+ "idle_seconds": None, "how_to_unblock": None, "observed": True,
709
+ }
710
+ path = _host_channel_state_path(self._scope().state_root)
711
+ payload: object = None
712
+ try:
713
+ if path.is_file() and not path.is_symlink():
714
+ payload = json.loads(path.read_text(encoding="utf-8"))
715
+ except (OSError, UnicodeError, json.JSONDecodeError):
716
+ payload = None
717
+ if not isinstance(payload, Mapping):
718
+ return {
719
+ "available": None, "blocked_by": None,
720
+ "idle_seconds": None, "how_to_unblock": None, "observed": False,
721
+ }
722
+ observed_at = payload.get("observed_at")
723
+ ttl = payload.get("ttl_seconds")
724
+ fresh = (
725
+ isinstance(observed_at, (int, float)) and not isinstance(observed_at, bool)
726
+ and isinstance(ttl, (int, float)) and not isinstance(ttl, bool)
727
+ and (time.time() - float(observed_at)) <= float(ttl)
728
+ )
729
+ if not fresh:
730
+ return {
731
+ "available": None, "blocked_by": None,
732
+ "idle_seconds": None, "how_to_unblock": None,
733
+ "observed": False, "stale": True,
734
+ }
735
+ return {
736
+ "available": False,
737
+ "blocked_by": {
738
+ "holder_pid": payload.get("holder_pid"),
739
+ "holder_started_at": payload.get("holder_started_at"),
740
+ "observed_at": observed_at,
741
+ },
742
+ "idle_seconds": payload.get("holder_idle_seconds"),
743
+ "how_to_unblock": payload.get("how_to_unblock"),
744
+ "observed": True,
745
+ }
746
+
747
+ def _status_payload(self, supervisor: Any) -> dict[str, object]:
748
+ try:
749
+ snapshot = supervisor.status_with_gate()
750
+ except audit_supervisor.NoRunError:
751
+ return {
752
+ "status": "NO_RUN",
753
+ "next_action": "START_RUN",
754
+ # DOC-230 3.3:即使尚未 start,worker 通道也必须能判断自己
755
+ # 是否具备恢复能力(否则「静默降级」在这一刻最易发生)。
756
+ "host_channel": self._host_channel_state(),
757
+ "root": str(self.root),
758
+ }
759
+ state_payload = snapshot["state"]
760
+ gate = snapshot["parallel_gate"]
761
+ if isinstance(state_payload, dict):
762
+ state_payload = dict(state_payload)
763
+ for field, limit in (("history", 50), ("findings", 100), ("parallel_proof_history", 20)):
764
+ value = state_payload.get(field)
765
+ if isinstance(value, list) and len(value) > limit:
766
+ state_payload[field] = value[-limit:]
767
+ state_payload[f"{field}_truncated"] = True
768
+ # 控制面决策必须消费原始未压缩投影的完整 state 字典
769
+ action_val = next_action(state_payload, gate)
770
+ host_channel = self._host_channel_state()
771
+ chain_val = recovery_chain(
772
+ state_payload, gate, caller_role=self.role,
773
+ host_channel=host_channel.get("blocked_by"),
774
+ )
775
+ payload = project_state(state_payload)
776
+ payload["parallel_gate"] = gate
777
+ payload["next_action"] = action_val
778
+ payload["host_channel"] = host_channel
779
+ payload["recovery_chain"] = chain_val
780
+ payload["root"] = str(self.root)
781
+ return payload
782
+
783
+ def _budget(self, arguments: Mapping[str, object]):
784
+ allow_serial = bool_argument(arguments, "allow_serial", False)
785
+ serial_reason = arguments.get("serial_reason")
786
+ if serial_reason is not None and not isinstance(serial_reason, str):
787
+ raise McpProtocolError("serial_reason 必须是字符串或 null")
788
+ require_confirmation = bool_argument(arguments, "require_confirmation", True)
789
+ if not require_confirmation:
790
+ raise McpProtocolError(
791
+ "Supervisor MCP 强制启用 Finding confirmation;"
792
+ "require_confirmation 只能为 true"
793
+ )
794
+ try:
795
+ # Resolve the adaptive concurrency pair once. RunBudget's default
796
+ # factories otherwise resolve the host again while constructing the
797
+ # ceiling, so a config/environment change between the two reads can
798
+ # produce an inconsistent budget (and makes the protocol hard to
799
+ # test deterministically).
800
+ system_concurrency, system_ceiling = (
801
+ audit_supervisor.resolve_system_concurrency()
802
+ )
803
+ return audit_supervisor.RunBudget(
804
+ max_rounds=number_argument(arguments, "max_rounds", 10, integer=True),
805
+ max_wall_seconds=number_argument(arguments, "max_wall_seconds", 3600.0),
806
+ max_round_wall_seconds=number_argument(
807
+ arguments, "max_round_wall_seconds", 1800.0,
808
+ ),
809
+ max_tool_calls=number_argument(
810
+ arguments, "max_tool_calls", 1000, integer=True,
811
+ ),
812
+ max_cost_units=number_argument(
813
+ arguments, "max_cost_units", 10000.0,
814
+ ),
815
+ max_concurrency=number_argument(
816
+ arguments, "max_concurrency",
817
+ system_concurrency,
818
+ integer=True,
819
+ ),
820
+ max_concurrency_ceiling=system_ceiling,
821
+ require_parallel=not allow_serial,
822
+ serial_reason=serial_reason,
823
+ require_confirmation=require_confirmation,
824
+ )
825
+ except (TypeError, ValueError) as exc:
826
+ raise McpProtocolError(f"budget 参数无效: {exc}") from exc
827
+
828
+ def _require_role(
829
+ self, arguments: Mapping[str, object], tool_name: str, *allowed: str,
830
+ ) -> str:
831
+ """Enforce both the declared role and this MCP channel's role.
832
+
833
+ A caller-supplied ``caller_role`` is not an identity proof. The
834
+ actual boundary is the separately configured host/worker stdio
835
+ service, whose tools are filtered by role. The declaration remains
836
+ required as an explicit protocol assertion and audit field.
837
+
838
+ DOC-230 3.6:``_TOOL_ROLES`` 是角色归属的**单一真源**。handler 声明的
839
+ 允许角色必须与工具表一致;否则会重现「worker 通道列出工具、调用却必拒」
840
+ 的虚假可用性(BX-ENGINE-16)。此处 fail-closed 报错,把漂移暴露在第一次
841
+ 调用而不是用户排障时。
842
+ """
843
+ declared_roles = _TOOL_ROLES.get(tool_name)
844
+ if declared_roles is not None and set(allowed) != set(declared_roles):
845
+ raise McpProtocolError(
846
+ f"{tool_name} 角色声明与工具表不一致:"
847
+ f"handler={sorted(allowed)} table={sorted(declared_roles)}"
848
+ )
849
+ role = arguments.get("caller_role")
850
+ if not role and self.role in set(allowed):
851
+ role = self.role
852
+ if not isinstance(role, str) or role not in set(allowed):
853
+ raise McpProtocolError(
854
+ f"{tool_name} 需要 caller_role={('/'.join(allowed))}"
855
+ )
856
+ if role != self.role:
857
+ raise McpProtocolError(
858
+ f"{tool_name} 不允许在 {self.role} MCP 通道中以 {role} 身份调用"
859
+ )
860
+ return role
861
+
862
+ def call(self, name: str, arguments: Mapping[str, object]) -> dict[str, object]:
863
+ if not isinstance(arguments, Mapping):
864
+ raise McpProtocolError("tools/call arguments 必须是对象", code=-32602)
865
+ # Generic bounded check for all tool arguments (depth/keys/size)
866
+ if len(arguments) > 200:
867
+ raise McpProtocolError("arguments 键过多", code=-32602)
868
+ check_json_depth_and_keys(arguments)
869
+ # DOC-230 3.1 层 2 / 3.2:stdin 服务场景下把每次工具调用记为通道活动,
870
+ # 并统计 inflight,使空闲自退既不误退"正在执行"的调用,也能在被遗弃时
871
+ # 主动让位。非 stdio 场景(activity 为 None)行为完全不变。
872
+ activity = self.activity
873
+ if activity is not None:
874
+ activity.enter()
875
+ activity.touch(worker_id=arguments.get("worker_id"))
876
+ try:
877
+ return self._call_locked(name, arguments)
878
+ finally:
879
+ if activity is not None:
880
+ activity.leave()
881
+
882
+ def _call_locked(self, name: str, arguments: Mapping[str, object]) -> dict[str, object]:
883
+ def _resolve_tool_name(tool_name: str) -> str:
884
+ if tool_name in _TOOL_ROLES:
885
+ return tool_name
886
+ candidates = [
887
+ f"bugx_supervisor_{tool_name}",
888
+ f"bugx_supervisor_worker_{tool_name}",
889
+ ]
890
+ for candidate in candidates:
891
+ if candidate in _TOOL_ROLES:
892
+ return candidate
893
+ return tool_name
894
+
895
+ resolved_name = _resolve_tool_name(name)
896
+ allowed_roles = _TOOL_ROLES.get(resolved_name)
897
+ if allowed_roles is None:
898
+ raise McpProtocolError(_i18n_exc("mcp.unknown_tool", f"未知工具: {name}", name=name))
899
+ name = resolved_name
900
+ # F-RSI-20261110-039:worker 通道强制 DOC-241 A5 暴露白名单。
901
+ # 13 个工具在 _TOOL_ROLES 声明 worker-only(角色所有权)但被
902
+ # _WORKER_CORE_TOOL_NAMES 从 tools/list 隐藏(暴露契约)——两契约
903
+ # 缺口造成"隐藏但可调"(红探针实测哨兵执行)。角色所有权管"谁能
904
+ # 调",暴露白名单管"worker 该调什么"——分派层以暴露契约收口。
905
+ if self.role == "worker" and name not in _WORKER_CORE_TOOL_NAMES:
906
+ raise McpProtocolError(
907
+ f"{name} 不在 Worker 通道工具白名单内"
908
+ "(DOC-241 A5:Worker 仅暴露 10 个核心原子工具)"
909
+ )
910
+ call_arguments = dict(arguments)
911
+ if self.role not in allowed_roles:
912
+ declared_role = call_arguments.get("caller_role") or self.role
913
+ target_channel = "bugx-supervisor-worker" if "worker" in allowed_roles else "bugx-supervisor"
914
+ required_role_desc = next(iter(allowed_roles)) if allowed_roles in (_HOST_ONLY, _WORKER_ONLY) else "/".join(sorted(allowed_roles))
915
+ raise McpProtocolError(
916
+ f"{name} 需要 caller_role={required_role_desc} 且不允许在 {self.role} MCP 通道中以 {declared_role!r} 身份调用;"
917
+ f"请切换至 MCP 服务通道 '{target_channel}'"
918
+ )
919
+ if allowed_roles in (_HOST_ONLY, _WORKER_ONLY):
920
+ required_role = next(iter(allowed_roles))
921
+ # The stdio server itself is the role boundary.
922
+ # If caller_role was omitted, directly infer it from required_role / self.role.
923
+ if not call_arguments.get("caller_role"):
924
+ call_arguments["caller_role"] = required_role
925
+ elif call_arguments.get("caller_role") != required_role:
926
+ raise McpProtocolError(f"{name} 需要 caller_role={required_role}")
927
+ if self.role == "host":
928
+ # The daemon may have started before CLI pre created runtime.json;
929
+ # claim the live host on the first host request instead of waiting
930
+ # for the next periodic tick.
931
+ _host_session_heartbeat_once(self.root)
932
+ # The request may be the first request after a new polling scope was
933
+ # created. Refresh the role-bound proof before dispatching the tool.
934
+ self.refresh_session_proof()
935
+ self._touch_session_request()
936
+ try:
937
+ return HANDLER_REGISTRY[name](self, call_arguments)
938
+ finally:
939
+ self._touch_session_progress()
940
+
941
+ def _knowledge(self):
942
+ """延迟加载错题账本模块;让 worker 一条调用拿到经验卡。"""
943
+ module = getattr(self, "_knowledge_module", None)
944
+ if module is not None:
945
+ return module
946
+ from core.ledger import lesson_ledger
947
+
948
+ self._knowledge_module = lesson_ledger
949
+ return lesson_ledger
950
+
951
+ def _runtime_intelligence(self) -> list:
952
+ """只读读取 runtime 的 intelligence_history(缺省为空列表)。"""
953
+ try:
954
+ state = json.loads(
955
+ self._scope().runtime.read_text(encoding="utf-8"),
956
+ )
957
+ except (OSError, json.JSONDecodeError):
958
+ return []
959
+ history = state.get("intelligence_history")
960
+ return history if isinstance(history, list) else []
961
+
962
+ def read_resource(self, uri: str) -> dict[str, object]:
963
+ """只读读取 BugX 核心事实态 MCP Resource。"""
964
+ self.refresh_session_proof()
965
+ MAX_RESOURCE_BYTES = 262144
966
+ if uri == "bugx://state/status":
967
+ mime_type = "application/json"
968
+ try:
969
+ payload = self._status_payload(self.get_supervisor())
970
+ except audit_supervisor.NoRunError:
971
+ payload = {"status": "NO_RUN", "detail": "无正在运行的 Supervisor", "root": str(self.root)}
972
+ except McpProtocolError as exc:
973
+ payload = {"status": "NOT_INITIALIZED", "detail": str(exc), "root": str(self.root)}
974
+ text = json.dumps(payload, ensure_ascii=False, indent=2)
975
+ elif uri == "bugx://state/coverage" or uri.startswith("bugx://state/coverage?"):
976
+ mime_type = "application/json"
977
+ try:
978
+ st = self.get_supervisor().status()
979
+ query = parse_qs(urlparse(uri).query)
980
+ offset = max(0, int(query.get("offset", [0])[0]))
981
+ limit = min(500, max(1, int(query.get("limit", [200])[0])))
982
+ items = sorted(st.coverage.items())
983
+ page = dict(items[offset:offset + limit])
984
+ payload = {
985
+ "coverage": page,
986
+ "debt": st.coverage_debt,
987
+ "complete": st.coverage_complete,
988
+ "total_units": len(st.coverage),
989
+ "offset": offset,
990
+ "limit": limit,
991
+ "next_offset": offset + limit if offset + limit < len(items) else None,
992
+ }
993
+ except audit_supervisor.NoRunError:
994
+ payload = {"status": "NO_RUN", "detail": "无正在运行的 Supervisor"}
995
+ except (McpProtocolError, ValueError) as exc:
996
+ payload = {"status": "NOT_INITIALIZED", "detail": str(exc)}
997
+ text = json.dumps(payload, ensure_ascii=False, indent=2)
998
+ elif uri == "bugx://findings/recent":
999
+ mime_type = "application/json"
1000
+ try:
1001
+ st = self.get_supervisor().status()
1002
+ payload = {
1003
+ "status": "ok",
1004
+ "findings_count": len(st.findings),
1005
+ "findings": list(st.findings),
1006
+ }
1007
+ except audit_supervisor.NoRunError:
1008
+ payload = {"status": "NO_RUN", "detail": "无正在运行的 Supervisor"}
1009
+ except McpProtocolError as exc:
1010
+ payload = {"status": "NOT_INITIALIZED", "detail": str(exc)}
1011
+ text = json.dumps(payload, ensure_ascii=False, indent=2)
1012
+ elif uri == "bugx://knowledge/mistakes":
1013
+ mime_type = "text/markdown"
1014
+ try:
1015
+ scope = self._scope()
1016
+ shared = knowledge_sources.retrieve_patterns(
1017
+ self._knowledge(), scope.knowledge_seed,
1018
+ scope.global_knowledge_seed, limit=10, runtime_only=True,
1019
+ )
1020
+ if scope.mistake_book.is_file():
1021
+ text = scope.mistake_book.read_text(encoding="utf-8")
1022
+ else:
1023
+ text = "# BugX Mistakes & Anti-Patterns\n\n暂无错题记录。"
1024
+ global_lessons = [
1025
+ item for item in shared
1026
+ if item.get("knowledge_source") == "global"
1027
+ ]
1028
+ if global_lessons:
1029
+ lines = [text.rstrip(), "", "# Shared Active Knowledge", ""]
1030
+ for l in global_lessons:
1031
+ title = l.get("title") or l.get("pattern_id") or "Lesson"
1032
+ lines.append(f"## {title}")
1033
+ if l.get("reflection"):
1034
+ lines.append(f"{l.get('reflection')}\n")
1035
+ text = "\n".join(lines)
1036
+ elif not scope.mistake_book.is_file() and shared:
1037
+ lines = ["# BugX Mistakes & Anti-Patterns", ""]
1038
+ for l in shared:
1039
+ title = l.get("title") or l.get("pattern_id") or "Lesson"
1040
+ lines.append(f"## {title}")
1041
+ if l.get("reflection"):
1042
+ lines.append(f"{l.get('reflection')}\n")
1043
+ text = "\n".join(lines)
1044
+ except Exception:
1045
+ text = "# BugX Mistakes & Anti-Patterns\n\n暂无错题记录。"
1046
+ elif uri == "bugx://profile/target":
1047
+ mime_type = "application/json"
1048
+ try:
1049
+ from core.runtime import project_profile
1050
+ profile = None
1051
+ try:
1052
+ profile = project_profile.load_project_profile(self._scope().knowledge_seed)
1053
+ except Exception:
1054
+ profile = None
1055
+ if not profile:
1056
+ profile = project_profile.detect_project_profile(self.root)
1057
+ text = json.dumps(profile, ensure_ascii=False, indent=2)
1058
+ except Exception as exc:
1059
+ text = json.dumps({"error": f"无法生成目标项目画像: {exc}"}, ensure_ascii=False, indent=2)
1060
+ else:
1061
+ raise McpProtocolError(f"未知或非法的 Resource URI: {uri}", code=-32602)
1062
+
1063
+ encoded = text.encode("utf-8")
1064
+ if len(encoded) > MAX_RESOURCE_BYTES:
1065
+ text = encoded[:MAX_RESOURCE_BYTES].decode("utf-8", errors="ignore") + "\n... [truncated]"
1066
+
1067
+ return {
1068
+ "contents": [
1069
+ {
1070
+ "uri": uri,
1071
+ "mimeType": mime_type,
1072
+ "text": text,
1073
+ }
1074
+ ]
1075
+ }
1076
+
1077
+ def get_prompt(self, name: str, arguments: Mapping[str, object]) -> dict[str, object]:
1078
+ """按阶段装配标准 MCP Prompt 工作流消息。"""
1079
+ prompt_map = {
1080
+ "bugx-audit-explore": ("explore", _i18n_prompt("mcp.explore_title", "BugX 勘察与代码单元初筛")),
1081
+ "bugx-fuzz-mutate": ("mutate", _i18n_prompt("mcp.mutate_title", "BugX 模糊测试与状态变异挖掘")),
1082
+ "bugx-repro-verify": ("repair", _i18n_prompt("mcp.repair_title", "BugX 最小复现与差分修复")),
1083
+ "bugx-gate-decision": ("gate", _i18n_prompt("mcp.gate_title", "BugX 会话启动与门禁裁决")),
1084
+ }
1085
+ if name not in prompt_map:
1086
+ raise McpProtocolError(_i18n_exc("mcp.unknown_prompt_template", f"未知 Prompt 模版: {name}", name=name), code=-32602)
1087
+ stage, desc = prompt_map[name]
1088
+ unit_id = arguments.get("unit_id")
1089
+ rule_name = arguments.get("rule")
1090
+ context = arguments.get("context")
1091
+ if context is not None and not isinstance(context, Mapping):
1092
+ raise McpProtocolError(_i18n_exc("mcp.context_must_be_object", "context 必须是对象"), code=-32602)
1093
+ from core.planning import prompt_harness
1094
+ try:
1095
+ content = prompt_harness.get_stage_prompt(stage, context=context, root=self.root)
1096
+ except (ValueError, FileNotFoundError) as exc:
1097
+ raise McpProtocolError(str(exc), code=-32602)
1098
+
1099
+ rule_slice = None
1100
+ if unit_id and isinstance(unit_id, str):
1101
+ rule_slice = prompt_harness.detect_unit_rule_slice(unit_id, root=self.root)
1102
+ elif rule_name and isinstance(rule_name, str):
1103
+ try:
1104
+ rule_content = prompt_harness.load_rule(rule_name, root=self.root)
1105
+ rule_slice = f"【专项规则 - {rule_name}】\n" + rule_content
1106
+ except (ValueError, FileNotFoundError):
1107
+ rule_slice = None
1108
+
1109
+ if rule_slice:
1110
+ content = f"{content}\n\n{rule_slice}"
1111
+
1112
+ return {
1113
+ "description": desc,
1114
+ "messages": [
1115
+ {
1116
+ "role": "user",
1117
+ "content": {
1118
+ "type": "text",
1119
+ "text": content,
1120
+ },
1121
+ }
1122
+ ],
1123
+ }
1124
+
1125
+
1126
+
1127
+
1128
+ try:
1129
+ import core.mcp_handlers.resource_prompt_table as _rpt
1130
+ import core.mcp_handlers.tool_table as _tt
1131
+ import core.mcp_handlers.rpc_server as _rpc
1132
+ except ImportError:
1133
+ import core.mcp_handlers.resource_prompt_table as _rpt
1134
+ import core.mcp_handlers.tool_table as _tt
1135
+ import core.mcp_handlers.rpc_server as _rpc
1136
+
1137
+ _resource_definitions = _rpt._resource_definitions
1138
+ _prompt_definitions = _rpt._prompt_definitions
1139
+
1140
+ _build_tool_table = _tt._build_tool_table
1141
+ _assert_tool_registry_consistent = _tt._assert_tool_registry_consistent
1142
+ _tool_definitions = _tt._tool_definitions
1143
+ _TOOL_TABLE = _tt._TOOL_TABLE
1144
+ _TOOL_ROLES = _tt._TOOL_ROLES
1145
+ _WORKER_CORE_TOOL_NAMES = _tt._WORKER_CORE_TOOL_NAMES
1146
+ HOST_TOOLS = _tt.HOST_TOOLS
1147
+ WORKER_TOOLS = _tt.WORKER_TOOLS
1148
+ READ_ONLY_TOOLS = _tt.READ_ONLY_TOOLS
1149
+
1150
+ _response = _rpc._response
1151
+ _rpc_error = _rpc._rpc_error
1152
+ _line_is_complete = _rpc._line_is_complete
1153
+ _safe_tool_call_summary = _rpc._safe_tool_call_summary
1154
+ serve = _rpc.serve
1155
+ _resolve_serve_root = _rpc._resolve_serve_root
1156
+ main = _rpc.main
1157
+
1158
+ _assert_tool_registry_consistent()
1159
+
1160
+ if __name__ == "__main__":
1161
+ raise SystemExit(main())