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,1133 @@
1
+ #!/usr/bin/env python3
2
+ """launch_phases/pre_state_builder.py - 选项归一化、预算门禁、会话状态准备与凭据授权。"""
3
+
4
+ from __future__ import annotations
5
+
6
+ import collections
7
+ import dataclasses
8
+ from dataclasses import dataclass, field
9
+ import hashlib
10
+ import json
11
+ import math
12
+ import os
13
+ import re
14
+ import time
15
+ from pathlib import Path
16
+ from typing import Any, Mapping
17
+
18
+ try:
19
+ import core.i18n as i18n
20
+ except ImportError:
21
+ try:
22
+ from core import i18n
23
+ except ImportError:
24
+ i18n = None # type: ignore[assignment]
25
+
26
+ from core.launch_phases.common import (
27
+ FIX_MODES,
28
+ resolve_project_root,
29
+ uses_project_layout,
30
+ child_environment,
31
+ run_child,
32
+ POLLING_DECISION_REQUIRED,
33
+ REVIEW_DECISION_LATER,
34
+ REPORT_POLICY_DEFAULT,
35
+ STRATEGY_PLAN_ACTIONS,
36
+ COMMIT_POLICIES,
37
+ REVIEW_MODES,
38
+ STARTUP_INTERACTION_CHOICES,
39
+ STARTUP_INTERACTION_MODES,
40
+ host_serial_worker,
41
+ run_verify_life,
42
+ bugx_paths,
43
+ )
44
+ from core.launch_phases.session_runtime import (
45
+ baseline_json,
46
+ set_review_mode,
47
+ set_polling_policy,
48
+ set_commit_policy,
49
+ load_runtime,
50
+ save_runtime,
51
+ iso_time,
52
+ runtime_lock,
53
+ start_runtime,
54
+ refresh_runtime_paths,
55
+ )
56
+ from core.launch_phases.supervisor_bridge import (
57
+ run_tools_kb,
58
+ degraded_gate,
59
+ supervisor_mcp_gate,
60
+ auto_provision_accelerators,
61
+ autonomous_degraded_choices,
62
+ report_degraded_probes,
63
+ run_preflight_probes,
64
+ )
65
+ from core.launch_phases.report_sharing import normalize_report_policy
66
+ from core.launch_phases.startup_gates import (
67
+ aborted_session_gate,
68
+ check_global_budget_gate,
69
+ check_stage_prompts_integrity,
70
+ coverage_startup_gate,
71
+ detect_startup_environment,
72
+ mark_strategy_customized,
73
+ refresh_startup_todo,
74
+ )
75
+ from core.launch_phases.startup_interaction import (
76
+ compile_strategy_plan,
77
+ report_policy_startup_gate,
78
+ strategy_plan_gate,
79
+ )
80
+
81
+ #: 运行态 ``report_policy_source`` 的「用户已决策」取值集合。
82
+ #: 命中即表示交互三选一门禁已有答案,不再重复询问;``default`` /
83
+ #: ``autonomous`` 是系统兜底,不算用户决策。
84
+ _REPORT_POLICY_DECIDED_SOURCES = frozenset({"cli", "profile", "config", "gate"})
85
+
86
+ def _startup_policy_config(
87
+ root: Path, cli_overrides: dict[str, Any] | None = None,
88
+ ) -> dict[str, str]:
89
+ """Load the pre-phase policy resolver without a module-level import cycle."""
90
+ from core.launch_phases.pre_phase import startup_policy_config as resolve_policy
91
+
92
+ return resolve_policy(root, cli_overrides)
93
+
94
+
95
+ def startup_policy_explicit_keys(root: Path) -> frozenset[str]:
96
+ """Load the pre-phase explicit-policy reader without dynamic dispatch."""
97
+ from core.launch_phases.pre_phase import startup_policy_explicit_keys as read_keys
98
+
99
+ return read_keys(root)
100
+
101
+ def begin_new_session(
102
+ bootstrap_coverage: bool = False, *, autonomous: bool = False,
103
+ ) -> tuple[dict, bool, int | None]:
104
+ """在已完成 Session 后创建新的 Session/首个 Round。
105
+
106
+ 新 Session 的覆盖清单门禁必须先于运行态创建。清单缺失时可以让新
107
+ Session 停留在 ``created``/待引导状态,但不能先写入 running runtime
108
+ 再把它错误收尾为 ``aborted``。返回值中的第三项用于把结构化门禁码
109
+ 交回 ``pre``,避免把“等待用户选择”误报成创建失败。
110
+ """
111
+ if not uses_project_layout() or bugx_paths is None:
112
+ runtime, started = start_runtime(new_lifecycle=True, new_session=True)
113
+ return runtime, started, None
114
+ previous = load_runtime()
115
+ previous_mode = (baseline_json() or {}).get("mode")
116
+ inherited = {
117
+ key: previous.get(key)
118
+ for key in (
119
+ "polling_policy", "review_mode", "review_mode_deferred",
120
+ "commit_policy", "report_policy", "sync_status",
121
+ )
122
+ }
123
+ try:
124
+ bugx_paths.create_session(resolve_project_root())
125
+ refresh_runtime_paths()
126
+ # create_session() has switched current.json to the new lifecycle, but
127
+ # no runtime has been created yet. Check the new lifecycle's coverage
128
+ # gate at this safe boundary BEFORE resetting the life ledger: a
129
+ # blocked/missing manifest must not consume the reset or clear the
130
+ # previous runnable state, and a fresh Session must not be turned
131
+ # into an aborted run by a missing manifest.
132
+ coverage_gate = coverage_startup_gate(
133
+ bootstrap_confirmed=bootstrap_coverage, autonomous=autonomous,
134
+ )
135
+ if coverage_gate != 0:
136
+ return load_runtime(), False, coverage_gate
137
+ if run_verify_life("reset", "--confirm-reset") != 0:
138
+ return load_runtime(), False, 1
139
+ if previous_mode in {"auto", "log-only"}:
140
+ if run_verify_life("set-mode", "--mode", previous_mode) != 0:
141
+ return load_runtime(), False, 1
142
+ # create_session() has already switched current.json to the new
143
+ # polling. Explicitly pass new_session so runtime identity, reports,
144
+ # and lifecycle history cannot accidentally remain attached to the
145
+ # completed/aborted Session from the previous startup.
146
+ runtime, started = start_runtime(new_lifecycle=True, new_session=True)
147
+ if started:
148
+ runtime.update({key: value for key, value in inherited.items() if value is not None})
149
+ runtime["startup_observation"] = "completed"
150
+ runtime["startup_intent"] = "new_session"
151
+ save_runtime(runtime)
152
+ return runtime, started, None
153
+ except (OSError, ValueError, RuntimeError) as exc:
154
+ print(f"[launch_bugx] ✗ 新 Session 创建失败: {exc}")
155
+ return previous, False, 1
156
+
157
+
158
+ class RuntimeMemo:
159
+ """PERF-05:``pre()`` 内单一 runtime 快照,仅在已知写操作后显式刷新。
160
+
161
+ 未刷新时返回同一对象,因此不会在写操作之后继续使用陈旧数据;
162
+ 拆分为步骤函数后以显式对象传递,保持与原闭包完全一致的语义。
163
+ """
164
+
165
+ __slots__ = ("_state",)
166
+
167
+ def __init__(self) -> None:
168
+ self._state: dict | None = None
169
+
170
+ def get(self, *, refresh: bool = False) -> dict:
171
+ """返回当前快照;``refresh=True`` 时强制重新读盘。"""
172
+ if refresh or self._state is None:
173
+ self._state = load_runtime()
174
+ return self._state
175
+
176
+ def seed(self, state: dict) -> None:
177
+ """在已知写操作之后接管新快照(等价于原 ``runtime_state = runtime``)。"""
178
+ self._state = state
179
+
180
+
181
+ @dataclass
182
+ class PreState:
183
+ """``pre()`` 门禁序列在步骤函数之间流转的可变状态载体。
184
+
185
+ 原先 600+ 行函数体里的启动决策变量集中到此对象,使每个门禁块
186
+ 可以独立成函数而不必以 8+ 个位置参数互相传递。字段语义与原始
187
+ 局部变量逐字对应,赋值顺序不变。
188
+ """
189
+
190
+ # 命令行显式参数(归一化后的值)
191
+ host: str | None = None
192
+ polling_policy: str | None = None
193
+ review_mode: str | None = None
194
+ review_mode_deferred: bool = False
195
+ fix_mode: str | None = None
196
+ commit_policy: str | None = None
197
+ session_recovery: str | None = None
198
+ startup_action: str | None = None
199
+ report_policy: str | None = None
200
+ # report_policy 的取值来源(cli/profile/config/gate/autonomous/default),
201
+ # 持久化为 runtime["report_policy_source"],用于判定三选一门禁是否已作答。
202
+ report_policy_source: str = "default"
203
+ # ``--replay-share-pending``:显式授权在 report_policy=local 下重放队列。
204
+ replay_share_pending_force: bool = False
205
+ strategy_plan: str | None = None
206
+ life_kind: str = "mine"
207
+ startup_interaction: str | None = None
208
+ profile: str | None = None
209
+ ignore_global_budget: bool = False
210
+ refresh_probes: bool = False
211
+ autonomous_mode: bool = False
212
+ max_round_wall_seconds: str | float | None = None
213
+ autonomous_policy: dict[str, Any] | None = None
214
+ tooling_choices: dict[str, str] | None = None
215
+ lesson_query: str = ""
216
+ lesson_category: str | None = None
217
+ allow_serial: bool = False
218
+ serial_reason: str | None = None
219
+ bootstrap_coverage: bool = False
220
+ # 派生标志
221
+ noninteractive_startup: bool = False
222
+ # 运行态现值
223
+ current_runtime: dict = field(default_factory=dict)
224
+ current_review_mode: str | None = None
225
+ current_review_deferred: bool = False
226
+ current_policy: str | None = None
227
+ current_fix_mode: str | None = None
228
+ current_commit_policy: str | None = None
229
+ life_state: dict = field(default_factory=dict)
230
+ aborted_new_session: bool = False
231
+ # 会话启动与就绪输出
232
+ new_session_started: bool = False
233
+ runtime: dict = field(default_factory=dict)
234
+ started: bool = False
235
+ supervisor_state: dict = field(default_factory=dict)
236
+ lesson_context: dict = field(default_factory=dict)
237
+ project_profile_prepared: bool = False
238
+ project_profile_data: dict[str, Any] | None = None
239
+
240
+
241
+ def normalize_pre_options(st: "_PreState") -> int:
242
+ """参数校验与归一化:profile 回填 + 逐项合法性门禁。
243
+
244
+ 原 ``pre()`` 393-474 逐字迁移;仅把原先的函数局部变量换成
245
+ ``_PreState`` 字段,校验顺序、错误文案与退出码完全不变。"""
246
+ profile = st.profile
247
+ polling_policy = st.polling_policy
248
+ review_mode = st.review_mode
249
+ fix_mode = st.fix_mode
250
+ commit_policy = st.commit_policy
251
+ session_recovery = st.session_recovery
252
+ startup_action = st.startup_action
253
+ report_policy = st.report_policy
254
+ strategy_plan = st.strategy_plan
255
+ life_kind = st.life_kind
256
+ startup_interaction = st.startup_interaction
257
+ review_mode_deferred = st.review_mode_deferred
258
+ cli_policy = {
259
+ "polling_policy": st.polling_policy,
260
+ "review_mode": st.review_mode,
261
+ "fix_mode": st.fix_mode,
262
+ "commit_policy": st.commit_policy,
263
+ "session_recovery": st.session_recovery,
264
+ "startup_action": st.startup_action,
265
+ "report_policy": st.report_policy,
266
+ }
267
+ profile_cfg = {}
268
+ if st.max_round_wall_seconds is not None:
269
+ try:
270
+ st.max_round_wall_seconds = float(st.max_round_wall_seconds)
271
+ except (TypeError, ValueError):
272
+ st.max_round_wall_seconds = None
273
+ if (st.max_round_wall_seconds is None
274
+ or not math.isfinite(st.max_round_wall_seconds)
275
+ or st.max_round_wall_seconds <= 0):
276
+ print("[launch_bugx] ✗ --max-round-wall-seconds 必须是正的有限秒数")
277
+ return 2
278
+ try:
279
+ from core.runtime import session_profile
280
+ except Exception:
281
+ if st.autonomous_mode:
282
+ print("[launch_bugx] ✗ 自治策略无效,拒绝猜测默认值")
283
+ return 2
284
+ profile_cfg = {}
285
+ else:
286
+ try:
287
+ profile_cfg = session_profile.load_profile(profile, root=resolve_project_root()) or {}
288
+ if st.autonomous_mode:
289
+ # Explicit CLI opt-in uses the audited preset, while a project
290
+ # profile may override only already-defined scalar fields.
291
+ preset = session_profile.load_profile("autonomous", root=resolve_project_root()) or {}
292
+ preset.update(profile_cfg)
293
+ profile_cfg = preset
294
+ st.autonomous_policy = session_profile.autonomous_policy(profile_cfg)
295
+ except session_profile.LegacySharePolicyError as exc:
296
+ print(f"[launch_bugx] ✗ 已移除的启动配置:{exc}")
297
+ return 2
298
+ except Exception:
299
+ if st.autonomous_mode:
300
+ print("[launch_bugx] ✗ 自治策略无效,拒绝猜测默认值")
301
+ return 2
302
+ profile_cfg = {}
303
+
304
+ if st.autonomous_policy is not None:
305
+ st.autonomous_mode = True
306
+
307
+ if profile_cfg:
308
+ if polling_policy is None and profile_cfg.get("polling_policy"):
309
+ polling_policy = profile_cfg["polling_policy"]
310
+ if review_mode is None and profile_cfg.get("review_mode"):
311
+ review_mode = profile_cfg["review_mode"]
312
+ if fix_mode is None and profile_cfg.get("fix_mode"):
313
+ fix_mode = profile_cfg["fix_mode"]
314
+ if commit_policy is None and profile_cfg.get("commit_policy"):
315
+ commit_policy = profile_cfg["commit_policy"]
316
+ if session_recovery is None and profile_cfg.get("session_recovery"):
317
+ session_recovery = profile_cfg["session_recovery"]
318
+ if startup_action is None and profile_cfg.get("startup_action"):
319
+ startup_action = profile_cfg["startup_action"]
320
+ if report_policy is None and profile_cfg.get("report_policy"):
321
+ report_policy = profile_cfg["report_policy"]
322
+ if st.autonomous_mode:
323
+ # In autonomous mode every strategy gate has a deterministic value;
324
+ # explicit CLI values remain honored, but no missing value reaches an
325
+ # interactive resolver.
326
+ autonomous_defaults = {
327
+ "polling_policy": "auto",
328
+ "review_mode": "mcp-auto",
329
+ "fix_mode": "auto",
330
+ "commit_policy": "round",
331
+ "session_recovery": "resume",
332
+ "startup_action": "start",
333
+ # DOC-236 C6:无人值守默认只保留本地报告(不对外提交)。
334
+ "report_policy": "local",
335
+ "strategy_plan": "approve",
336
+ }
337
+ polling_policy = polling_policy or autonomous_defaults["polling_policy"]
338
+ review_mode = review_mode or autonomous_defaults["review_mode"]
339
+ fix_mode = fix_mode or autonomous_defaults["fix_mode"]
340
+ commit_policy = commit_policy or autonomous_defaults["commit_policy"]
341
+ session_recovery = session_recovery or autonomous_defaults["session_recovery"]
342
+ startup_action = startup_action or autonomous_defaults["startup_action"]
343
+ report_policy = report_policy or autonomous_defaults["report_policy"]
344
+ strategy_plan = strategy_plan or autonomous_defaults["strategy_plan"]
345
+ st.bootstrap_coverage = bool(
346
+ (st.autonomous_policy or {}).get("coverage_bootstrap", True)
347
+ )
348
+
349
+ try:
350
+ layered = _startup_policy_config(resolve_project_root(), cli_policy)
351
+ except (OSError, UnicodeError, ValueError) as exc:
352
+ print(f"[launch_bugx] ✗ 启动报告提交策略配置无效:{exc}")
353
+ return 2
354
+ for key in cli_policy:
355
+ if cli_policy[key] is not None:
356
+ continue
357
+ profile_value = profile_cfg.get(key) if profile is not None else None
358
+ value = profile_value if isinstance(profile_value, str) else layered.get(key)
359
+ if key == "polling_policy":
360
+ polling_policy = value
361
+ elif key == "review_mode":
362
+ review_mode = value
363
+ elif key == "fix_mode":
364
+ fix_mode = value
365
+ elif key == "commit_policy":
366
+ commit_policy = value
367
+ elif key == "session_recovery":
368
+ session_recovery = value
369
+ elif key == "startup_action":
370
+ startup_action = value
371
+
372
+ # report_policy has an explicit source precedence that must not be
373
+ # accidentally changed by the generic startup-policy loop:
374
+ # CLI > selected/active profile > user/project config > safe default.
375
+ if st.report_policy is not None:
376
+ report_policy = st.report_policy
377
+ else:
378
+ profile_report_policy = profile_cfg.get("report_policy")
379
+ if isinstance(profile_report_policy, str) and profile_report_policy.strip():
380
+ report_policy = profile_report_policy
381
+ else:
382
+ report_policy = layered.get("report_policy", REPORT_POLICY_DEFAULT)
383
+
384
+ environment = detect_startup_environment()
385
+ terminal_interactive = bool(
386
+ environment is not None
387
+ and getattr(environment, "stdin_tty", False)
388
+ and getattr(environment, "stdout_tty", False)
389
+ )
390
+ # 无 TTY 不再单独触发非交互启动:探针已识别 native-question 宿主时,
391
+ # 策略门禁应经 BUGX_INTERACTION_REQUEST 交给宿主单选(与 git/云端门禁
392
+ # 同一通道),而不是把推荐预设静默当作用户批准。真正的 headless/ACP/
393
+ # blocked 交互面仍走自动只读路径(下方 interface/interaction 白名单判定)。
394
+ noninteractive_startup = st.autonomous_mode or environment is None or (
395
+ not terminal_interactive
396
+ and getattr(environment, "interaction", None)
397
+ not in {"native-question", "tty-radio", "text-menu"}
398
+ )
399
+ if noninteractive_startup:
400
+ # Headless/ACP launchers cannot answer a strategy questionnaire. Keep
401
+ # the automatic path read-only unless explicitly requested via CLI with approve.
402
+ if st.strategy_plan != "approve":
403
+ fix_mode = "log-only"
404
+ commit_policy = "manual"
405
+ strategy_plan = "approve"
406
+ else:
407
+ if fix_mode is None:
408
+ fix_mode = "log-only"
409
+ if commit_policy is None:
410
+ commit_policy = "manual"
411
+ if strategy_plan is None:
412
+ strategy_plan = "approve"
413
+ st.noninteractive_startup = noninteractive_startup
414
+ if startup_interaction is not None:
415
+ action_val = startup_interaction.strip().lower()
416
+ # 两套值域曾经被错误合并,导致 ``--startup-interaction auto``(help 里
417
+ # 白纸黑字声明的合法值)被判非法并返回 2,非交互启动直接失败:
418
+ # * ``auto|prompt``——本 flag 的原生语义:声明调用方如何应对启动门禁,
419
+ # 它不是「对某个门禁的作答」,因此只影响是否走自动决策,见下方
420
+ # ``noninteractive_startup`` 的推导,不在这里短路退出。
421
+ # * ``restart_host|run_tty|later``——MCP 门禁的**作答**,才需要短路。
422
+ if action_val in STARTUP_INTERACTION_MODES:
423
+ pass
424
+ elif action_val in STARTUP_INTERACTION_CHOICES or action_val in {"1", "2", "3"}:
425
+ if action_val in {"later", "3"}:
426
+ print("[launch_bugx] 已选择下次再说,本轮启动停止。")
427
+ return POLLING_DECISION_REQUIRED
428
+ elif action_val in {"restart_host", "1"}:
429
+ print("[launch_bugx] 已选择重启宿主,请重启当前宿主会话后重试。")
430
+ return POLLING_DECISION_REQUIRED
431
+ elif action_val in {"run_tty", "2"}:
432
+ print("[launch_bugx] 已选择在真实 TTY 中运行,请在外部终端中执行启动命令。")
433
+ return POLLING_DECISION_REQUIRED
434
+ else:
435
+ valid = "、".join(sorted(STARTUP_INTERACTION_MODES | STARTUP_INTERACTION_CHOICES))
436
+ print(f"[launch_bugx] ✗ 交互方式选择无效:只能是 {valid}")
437
+ return 2
438
+
439
+ # DOC-236 C1:`--review-mode later` 是"本轮不启动"。此时**任何运行态都不得
440
+ # 落盘**——旧实现会先走到下面的 `report_policy` 持久化(`save_runtime`),
441
+ # 于是"下次再说"仍然在磁盘上留下 runtime 状态。故此处前置短路,优先于持久化。
442
+ if review_mode == REVIEW_DECISION_LATER:
443
+ print("[launch_bugx] 已选择下次再说,本轮启动停止。")
444
+ return POLLING_DECISION_REQUIRED
445
+
446
+ # DOC-236 C6 补齐(2026-11-09 复盘 4.3-1):report_policy 此前只有
447
+ # CLI/config 入口,交互态用户被钉死在默认 local,无「不上报/上报云端」
448
+ # 入口。这里先只判定**显式来源**;历史决策回读与三选一门禁必须等到
449
+ # 下方全部参数校验通过之后执行(非法参数不得读 runtime、不得弹请求)。
450
+ report_policy_source = "default"
451
+ if st.report_policy is not None:
452
+ report_policy_source = "cli"
453
+ elif isinstance(profile_cfg.get("report_policy"), str) \
454
+ and profile_cfg["report_policy"].strip():
455
+ report_policy_source = "profile"
456
+ elif "report_policy" in startup_policy_explicit_keys(resolve_project_root()):
457
+ report_policy_source = "config"
458
+ elif st.autonomous_mode:
459
+ report_policy_source = "autonomous"
460
+
461
+ # DOC-236 C6:非法值 fail-closed(不得静默回退默认值);缺省值也必须
462
+ # 在 L1 这里落盘,L5 不再猜测或回退未声明的提交策略。
463
+ try:
464
+ report_val = normalize_report_policy(report_policy)
465
+ except ValueError as exc:
466
+ print(f"[launch_bugx] ✗ 报告提交策略无效:{exc}")
467
+ return 2
468
+ report_val = report_val or REPORT_POLICY_DEFAULT
469
+
470
+ if strategy_plan is not None:
471
+ normalized_strat = strategy_plan.strip().lower()
472
+ if normalized_strat not in STRATEGY_PLAN_ACTIONS and normalized_strat not in {"1", "2", "3"}:
473
+ print("[launch_bugx] ✗ 作战方案策略无效:只能是 approve、customize 或 later")
474
+ return 2
475
+
476
+ review_mode_deferred = False
477
+ if review_mode is not None and review_mode not in REVIEW_MODES:
478
+ print("[launch_bugx] ✗ 启动前审查方式无效:只能是 manual 或 mcp-auto")
479
+ return 2
480
+ if fix_mode is not None and fix_mode not in FIX_MODES:
481
+ print(
482
+ "[launch_bugx] ✗ 启动前修复方式无效:只能是 "
483
+ + " 或 ".join(FIX_MODES)
484
+ )
485
+ return 2
486
+ if life_kind not in {"mine", "fix"}:
487
+ print("[launch_bugx] ✗ Life 类型无效:只能是 mine 或 fix")
488
+ return 2
489
+ is_serial_host = host_serial_worker(st.host)
490
+ if st.allow_serial and life_kind != "fix" and not is_serial_host:
491
+ print("[launch_bugx] ✗ --allow-serial 仅允许用于 fix Life")
492
+ return 2
493
+ if st.allow_serial and (
494
+ not isinstance(st.serial_reason, str) or not st.serial_reason.strip()
495
+ ):
496
+ print("[launch_bugx] ✗ --allow-serial 必须同时提供非空 --serial-reason")
497
+ return 2
498
+ if commit_policy is not None and commit_policy.strip().lower() in {
499
+ "none", "no-submit", "no_submit", "不提交", "不自动提交",
500
+ }:
501
+ commit_policy = "manual"
502
+ if commit_policy is not None and commit_policy not in COMMIT_POLICIES - {"not_applicable"}:
503
+ print("[launch_bugx] ✗ 启动前提交策略无效:只能是 life、round、none 或 manual")
504
+ return 2
505
+ # 全部参数校验通过后才允许回读历史决策 / 发射三选一门禁。
506
+ if report_policy_source == "default" and not noninteractive_startup:
507
+ try:
508
+ previous_runtime = load_runtime()
509
+ except (OSError, ValueError):
510
+ previous_runtime = {}
511
+ inherited = previous_runtime.get("report_policy")
512
+ if str(previous_runtime.get("report_policy_source") or "") \
513
+ in _REPORT_POLICY_DECIDED_SOURCES \
514
+ and isinstance(inherited, str) and inherited.strip():
515
+ try:
516
+ inherited_val = normalize_report_policy(inherited)
517
+ except ValueError:
518
+ inherited_val = None
519
+ if inherited_val is not None:
520
+ report_policy = inherited_val
521
+ report_policy_source = "gate"
522
+ if report_policy_source == "default":
523
+ gate_code, gate_policy = report_policy_startup_gate(
524
+ environment, autonomous=st.autonomous_mode,
525
+ )
526
+ if gate_code != 0:
527
+ return gate_code
528
+ report_policy = gate_policy
529
+ report_policy_source = "gate"
530
+ report_val = normalize_report_policy(report_policy) or REPORT_POLICY_DEFAULT
531
+ # Validate the complete option set before the first runtime write. An
532
+ # invalid authorization must fail without touching any project lifecycle.
533
+ try:
534
+ with runtime_lock():
535
+ rt = load_runtime()
536
+ rt["report_policy"] = report_val
537
+ rt["report_policy_source"] = report_policy_source
538
+ save_runtime(rt)
539
+ except (OSError, TimeoutError, ValueError, RuntimeError) as exc:
540
+ print(f"[launch_bugx] ✗ 报告提交策略持久化失败:{exc}(硬阻断,拒绝继续启动)")
541
+ return 1
542
+ report_policy = report_val
543
+ st.polling_policy = polling_policy
544
+ st.review_mode = review_mode
545
+ st.fix_mode = fix_mode
546
+ st.commit_policy = commit_policy
547
+ st.session_recovery = session_recovery
548
+ st.startup_action = startup_action
549
+ st.report_policy = report_policy
550
+ st.report_policy_source = report_policy_source
551
+ st.strategy_plan = strategy_plan
552
+ st.life_kind = life_kind
553
+ st.review_mode_deferred = review_mode_deferred
554
+ return 0
555
+
556
+
557
+ def run_preflight_budget_gates(st: "_PreState") -> int:
558
+ """阶段提示词完整性防偷懒门禁 + 全局每日预算熔断门禁。
559
+
560
+ 原 ``pre()`` 476-496 逐字迁移。"""
561
+ ignore_global_budget = st.ignore_global_budget
562
+ # DOC-034 阶段 3:阶段提示词加载完整性防偷懒门禁(缺失立即阻断,不静默继续)
563
+ check_prompts_fn = check_stage_prompts_integrity
564
+ prompts_ok, prompts_err = check_prompts_fn()
565
+ if not prompts_ok:
566
+ err = f"[launch_bugx] ✗ 阶段提示词章节缺失/加载失败: {prompts_err}(防偷懒门禁阻断)"
567
+ if i18n is not None:
568
+ err = i18n.exception_text("orchestrator.stage_prompts_failed", fallback=err, error=prompts_err)
569
+ print(err)
570
+ return 1
571
+
572
+ # DOC-049 全局每日预算与配额熔断门禁(超限立即阻断,防止 API 账单穿透)
573
+ check_budget_fn = check_global_budget_gate
574
+ budget_ok, budget_err = check_budget_fn(ignore_budget=ignore_global_budget)
575
+ if not budget_ok:
576
+ err = f"[launch_bugx] ✗ 全局预算熔断阻断: {budget_err}"
577
+ if i18n is not None:
578
+ err = i18n.exception_text("orchestrator.budget_blocked", fallback=err, error=budget_err)
579
+ print(err)
580
+ return 1
581
+ return 0
582
+
583
+
584
+ def resolve_resume_state(st: "_PreState", memo: "_RuntimeMemo") -> int:
585
+ """读取运行态现值并恢复中断会话、持久化轮询策略。
586
+
587
+ 原 ``pre()`` 498-551 逐字迁移;``_runtime()`` 换为显式 memo 访问器,
588
+ 以保持 PERF-05 的单快照语义。"""
589
+ review_mode = st.review_mode
590
+ startup_action = st.startup_action
591
+ polling_policy = st.polling_policy
592
+ session_recovery = st.session_recovery
593
+ review_mode_deferred = st.review_mode_deferred
594
+ current_runtime = st.current_runtime
595
+ current_review_mode = st.current_review_mode
596
+ current_review_deferred = st.current_review_deferred
597
+ current_policy = st.current_policy
598
+ current_commit_policy = st.current_commit_policy
599
+ aborted_new_session = st.aborted_new_session
600
+ try:
601
+ current_runtime = memo.get()
602
+ current_policy = current_runtime.get("polling_policy")
603
+ current_review_mode = current_runtime.get("review_mode")
604
+ current_review_deferred = bool(
605
+ current_runtime.get("review_mode_deferred", False)
606
+ )
607
+ current_commit_policy = current_runtime.get("commit_policy")
608
+ if current_review_deferred and not current_runtime.get("active", False):
609
+ current_review_mode = None
610
+ except (OSError, ValueError) as exc:
611
+ print(f"[launch_bugx] ✗ 无法读取启动决策: {exc}")
612
+ return 1
613
+
614
+ if polling_policy is not None:
615
+ try:
616
+ set_polling_policy(polling_policy)
617
+ except (OSError, TimeoutError, ValueError) as exc:
618
+ print(f"[launch_bugx] ✗ 启动前轮询策略无效: {exc}")
619
+ return 2
620
+ if session_recovery is not None and session_recovery not in {"resume", "new"}:
621
+ print("[launch_bugx] ✗ --session-recovery 只能是 resume 或 new")
622
+ return 2
623
+ if st.autonomous_mode:
624
+ aborted_code, aborted_choice = aborted_session_gate(
625
+ current_runtime, explicit_choice=session_recovery, autonomous=True,
626
+ )
627
+ else:
628
+ # Keep the legacy call shape for host adapters that patch this gate.
629
+ aborted_code, aborted_choice = aborted_session_gate(
630
+ current_runtime, explicit_choice=session_recovery,
631
+ )
632
+ if aborted_code != 0:
633
+ return aborted_code
634
+ aborted_new_session = (aborted_choice == "new")
635
+ if aborted_choice == "resume":
636
+ print("↻ 已选择恢复上一次会话,继续启动流程。")
637
+ st.current_runtime = current_runtime
638
+ st.current_review_mode = current_review_mode
639
+ st.current_review_deferred = current_review_deferred
640
+ st.current_policy = current_policy
641
+ st.current_commit_policy = current_commit_policy
642
+ st.startup_action = startup_action
643
+ st.review_mode = review_mode
644
+ st.review_mode_deferred = review_mode_deferred
645
+ st.aborted_new_session = aborted_new_session
646
+ return 0
647
+
648
+
649
+ def derive_and_persist_decisions(st: "_PreState", memo: "_RuntimeMemo") -> int:
650
+ """推导有效决策、执行作战方案策略门禁并持久化审查/轮询/提交/修复方式。
651
+
652
+ 原 ``pre()`` 553-625 逐字迁移。"""
653
+ review_mode = st.review_mode
654
+ review_mode_deferred = st.review_mode_deferred
655
+ current_review_mode = st.current_review_mode
656
+ polling_policy = st.polling_policy
657
+ current_policy = st.current_policy
658
+ fix_mode = st.fix_mode
659
+ current_fix_mode = st.current_fix_mode
660
+ commit_policy = st.commit_policy
661
+ current_commit_policy = st.current_commit_policy
662
+ strategy_plan = st.strategy_plan
663
+ life_state = st.life_state
664
+ current_review_deferred = st.current_review_deferred
665
+ life_state = baseline_json() or {}
666
+ current_fix_mode = life_state.get("mode")
667
+ if current_fix_mode not in {"auto", "log-only"}:
668
+ current_fix_mode = None
669
+ if current_fix_mode == "log-only":
670
+ current_commit_policy = "not_applicable"
671
+
672
+ eff_review = review_mode or current_review_mode
673
+ eff_polling = polling_policy or current_policy
674
+ eff_fix = fix_mode or current_fix_mode
675
+ eff_commit = commit_policy or current_commit_policy
676
+ has_all_startup_decisions = (
677
+ eff_review is not None
678
+ and eff_polling is not None
679
+ and eff_fix is not None
680
+ and (eff_commit is not None or eff_fix == "log-only")
681
+ )
682
+ if (
683
+ not st.noninteractive_startup
684
+ and st.autonomous_mode
685
+ and has_all_startup_decisions
686
+ and strategy_plan is None
687
+ ):
688
+ # 期间只有 ``set_polling_policy`` 可能写盘,且不改 ``strategy_plan``;
689
+ # 复用快照与重新读盘等价,因此无需再次读盘。
690
+ current_strat = (memo.get().get("strategy_plan") or {}).get("status")
691
+ if current_strat != "approved":
692
+ mark_strategy_customized(compile_strategy_plan())
693
+ else:
694
+ plan_data = None
695
+ if st.noninteractive_startup:
696
+ plan_data = compile_strategy_plan(resolve_project_root())
697
+ preset = dict(plan_data.get("recommended_preset") or {})
698
+ preset.update(fix_mode="log-only", commit_policy="manual")
699
+ plan_data["recommended_preset"] = preset
700
+ strat_code, strat_decision = strategy_plan_gate(
701
+ strategy_choice="approve" if st.noninteractive_startup else strategy_plan,
702
+ environment=detect_startup_environment(),
703
+ plan_data=plan_data,
704
+ cli_fix_mode=fix_mode,
705
+ )
706
+ if strat_code != 0:
707
+ return strat_code
708
+ if strat_decision == "approved":
709
+ # ``strategy_plan_gate`` 可能经 ``_apply_approved_strategy`` 写盘。
710
+ # current_* 必须播种为盘面真实值(preset 已落盘),下方比较才能
711
+ # 发现 CLI 显式值与盘面的差异并正确持久化——旧实现把 current_*
712
+ # 播种成 CLI 值,显式 --review-mode 等被 preset 静默吞掉。
713
+ current_runtime = memo.get(refresh=True)
714
+ current_review_mode = current_runtime.get("review_mode")
715
+ current_policy = current_runtime.get("polling_policy")
716
+ current_commit_policy = current_runtime.get("commit_policy")
717
+ current_fix_mode = (baseline_json() or {}).get("mode")
718
+ if review_mode is None:
719
+ review_mode = current_review_mode or "manual"
720
+ if polling_policy is None:
721
+ polling_policy = current_policy or "auto"
722
+ if commit_policy is None:
723
+ commit_policy = current_commit_policy or "round"
724
+ if fix_mode is None:
725
+ fix_mode = current_fix_mode or "auto"
726
+
727
+ try:
728
+ if review_mode is not None and current_review_mode != review_mode:
729
+ set_review_mode(review_mode, deferred=review_mode_deferred)
730
+ current_review_mode = review_mode
731
+ current_review_deferred = review_mode_deferred
732
+ elif review_mode is not None:
733
+ current_review_deferred = review_mode_deferred
734
+ if polling_policy is not None and current_policy != polling_policy:
735
+ set_polling_policy(polling_policy)
736
+ current_policy = polling_policy
737
+ if commit_policy is not None and current_commit_policy != commit_policy:
738
+ set_commit_policy(commit_policy)
739
+ current_commit_policy = commit_policy
740
+ except (OSError, TimeoutError, ValueError) as exc:
741
+ print(f"[launch_bugx] ✗ 启动前策略无效: {exc}")
742
+ return 2
743
+ if fix_mode is not None and current_fix_mode != fix_mode:
744
+ if run_verify_life("set-mode", "--mode", fix_mode, "--confirm") != 0:
745
+ if run_verify_life("check") != 0 and run_verify_life("repair") == 0 and run_verify_life("check") == 0:
746
+ print("→ 基线修复后重试修复方式设置…")
747
+ if run_verify_life("set-mode", "--mode", fix_mode, "--confirm") != 0:
748
+ print(f"[launch_bugx] ✗ 修复方式持久化失败: {fix_mode}(硬阻断,拒绝继续启动)")
749
+ return 1
750
+ else:
751
+ print(f"[launch_bugx] ✗ 修复方式持久化失败: {fix_mode}(硬阻断,拒绝继续启动)")
752
+ return 1
753
+ current_fix_mode = fix_mode
754
+ st.life_state = life_state
755
+ st.current_fix_mode = current_fix_mode
756
+ st.review_mode = review_mode
757
+ st.polling_policy = polling_policy
758
+ st.commit_policy = commit_policy
759
+ st.fix_mode = fix_mode
760
+ st.current_review_mode = current_review_mode
761
+ st.current_review_deferred = current_review_deferred
762
+ st.current_policy = current_policy
763
+ st.current_commit_policy = current_commit_policy
764
+ return 0
765
+
766
+
767
+ def run_tools_and_preflight_gates(st: "_PreState", memo: "_RuntimeMemo") -> int:
768
+ """工具知识库校验、预飞探针扇出、降级门禁与基线 check/repair。
769
+
770
+ 原 ``pre()`` 769-828 逐字迁移。末尾的 ``_replay_share_pending()`` 刻意
771
+ 留在 ``pre()`` 编排层内联——见 ``pre()`` 内的说明。"""
772
+ refresh_probes = st.refresh_probes
773
+ tooling_choices = st.tooling_choices
774
+ review_mode = st.review_mode
775
+ current_review_mode = st.current_review_mode
776
+ current_review_deferred = st.current_review_deferred
777
+ refresh_startup_todo(
778
+ "tools",
779
+ reason="启动配置和最终启动动作已确认,进入工具与 MCP 准备",
780
+ environment=detect_startup_environment(),
781
+ )
782
+ try:
783
+ # ``supervisor_mcp_gate`` 可能经 ``set_review_mode`` 写盘,必须刷新。
784
+ refreshed_runtime = memo.get(refresh=True)
785
+ current_review_mode = refreshed_runtime.get("review_mode") or current_review_mode
786
+ current_review_deferred = bool(
787
+ refreshed_runtime.get("review_mode_deferred", current_review_deferred)
788
+ )
789
+ if current_review_mode == "manual" and current_review_deferred:
790
+ review_mode = "manual"
791
+ except (OSError, ValueError):
792
+ pass
793
+
794
+ print("=" * 56)
795
+ print("bugx 启动前协议:校验基线 → 建立快照 → 输出外部基线")
796
+ print("=" * 56)
797
+
798
+ if run_tools_kb() != 0:
799
+ print("✗ tools-kb 存在过期/缺日期条目,先搜索更新后再启动")
800
+ return 1
801
+ # PERF-09 / DES-13:启动前探针由 probe_registry 按 lifecycle="preflight"
802
+ # 统一驱动,并在同一个并发扇出里各执行一次;不再手写 5 个顺序包装
803
+ # (原先 5 个探针各起一个解释器,随后环境画像又把它们重跑一遍)。
804
+ probe_result = run_preflight_probes(
805
+ refresh=refresh_probes,
806
+ include_profile=True,
807
+ project_profile_data=st.project_profile_data,
808
+ )
809
+ if len(probe_result) == 3:
810
+ probe_code, degraded_probes, preflight_profile = probe_result
811
+ else: # Preserve patched/legacy test doubles that return the public pair.
812
+ probe_code, degraded_probes = probe_result
813
+ preflight_profile = {}
814
+ if probe_code != 0:
815
+ return probe_code
816
+ report_degraded_probes(degraded=degraded_probes)
817
+ runtime_state = memo.get(refresh=True)
818
+ audit_strategy = runtime_state.get("audit_strategy")
819
+ skill_plan = (
820
+ audit_strategy.get("skill_plan")
821
+ if isinstance(audit_strategy, dict)
822
+ else None
823
+ )
824
+ try:
825
+ from core.governance import runtime_tool_gate
826
+
827
+ selected_tool_ids = runtime_tool_gate.required_tool_ids_for_active_stages(
828
+ skill_plan if isinstance(skill_plan, dict) else None,
829
+ )
830
+ except Exception as exc:
831
+ print(f"✗ required Skill Pack stage tools 无法解析:{type(exc).__name__}: {exc}")
832
+ return 1
833
+ # DOC-180 / 反官僚主义:无论是否自治模式,优先尝试自愈安装/装配加速器,杜绝能自愈非要降级
834
+ if degraded_probes:
835
+ degraded_probes, provisioned = auto_provision_accelerators(
836
+ resolve_project_root(), degraded_probes, required_tools=selected_tool_ids,
837
+ )
838
+ if provisioned:
839
+ print("[launch_bugx] ✓ 环境加速器已就地自愈装配:" + "; ".join(provisioned))
840
+
841
+ try:
842
+ readiness_receipt = runtime_tool_gate.enforce_required_runtime_tools(
843
+ resolve_project_root(),
844
+ skill_plan if isinstance(skill_plan, dict) else None,
845
+ runtime_state.get("project_classification"),
846
+ preflight_profile,
847
+ )
848
+ except Exception as exc:
849
+ print(f"✗ required Skill Pack runtime tool gate 异常:{type(exc).__name__}: {exc}")
850
+ return 1
851
+ if readiness_receipt and readiness_receipt.get("status") != "READY":
852
+ print("✗ required Skill Pack runtime tool gate: BLOCKED")
853
+ for item in readiness_receipt.get("tools", []):
854
+ if item.get("status") not in {"READY", "NOT_APPLICABLE", "OPTIONAL"}:
855
+ print(f" - {item.get('name')}: {item.get('status')}")
856
+ for check in item.get("checks", [])[:4]:
857
+ if isinstance(check, dict):
858
+ print(f" {check.get('name')}: {check.get('detail')}")
859
+ if readiness_receipt.get("error"):
860
+ print(f" 原因:{readiness_receipt['error']}")
861
+ if readiness_receipt.get("receipt_path"):
862
+ print(f" 收据:{readiness_receipt['receipt_path']}")
863
+ return 1
864
+ if readiness_receipt:
865
+ print(
866
+ "[launch_bugx] ✓ 当前 Skill Pack 的必需运行时工具已就绪 "
867
+ f"({readiness_receipt.get('skill_id')})"
868
+ )
869
+
870
+ # DOC-236 C1:删除"命令行显式允许回退"分支——缺能力只能自愈,自愈不成即阻断;
871
+ # 无自动安装器的专有工具走 config.json `tooling_exemptions` 显式豁免(见 degraded_gate)。
872
+ if st.autonomous_mode:
873
+ if degraded_probes:
874
+ choices = autonomous_degraded_choices(degraded_probes)
875
+ if not degraded_gate(degraded_probes, explicit_choices=choices):
876
+ return 1
877
+ print("[launch_bugx] ✓ 自治模式仅保留结构化自愈成功、非适用剪枝或显式审计豁免")
878
+ else:
879
+ print("[launch_bugx] ✓ 自治模式加速器自动装配完成,环境满血就绪!")
880
+ elif not degraded_gate(degraded_probes, explicit_choices=tooling_choices):
881
+ return POLLING_DECISION_REQUIRED
882
+ if run_verify_life("check") != 0:
883
+ print("→ 基线不一致,先 repair 恢复…")
884
+ if run_verify_life("repair") != 0:
885
+ print("✗ repair 无法自动修复(可能 history 被篡改),基线不可用。")
886
+ print(" 请人工复核 bugx-life.json,或 reset 后重建。")
887
+ return 1
888
+ if run_verify_life("check") != 0:
889
+ print("✗ repair 后仍不一致,基线不可用。")
890
+ return 1
891
+ print("✓ 基线已修复")
892
+ st.review_mode = review_mode
893
+ st.current_review_mode = current_review_mode
894
+ st.current_review_deferred = current_review_deferred
895
+ return 0
896
+
897
+
898
+ def ensure_autonomous_prep_record(root: Path | None = None) -> int:
899
+ """Replace only the untouched init template with observed facts.
900
+
901
+ Autonomous runs cannot wait for a human to fill the preparation form, but
902
+ they must not overwrite a user-authored record or weaken ``prep_validate``.
903
+ Any non-template invalid record remains a hard post gate failure.
904
+ """
905
+ root = (root or resolve_project_root()).resolve()
906
+ try:
907
+ from core.runtime import prep_validate
908
+ return prep_validate.ensure_prep_record(root)
909
+ except Exception as exc:
910
+ print(f"[launch_bugx] ✗ 准备记录生成失败: {exc}")
911
+ return 1
912
+
913
+
914
+ def start_or_resume_session(st: "_PreState", memo: "_RuntimeMemo") -> int:
915
+ """会话启动:中断/完成会话的新建引导。
916
+
917
+ 原 ``pre()`` 830-862 逐字迁移。其后的覆盖清单门禁与快照刻意留在
918
+ ``pre()`` 编排层内联——见 ``pre()`` 内的说明。"""
919
+ aborted_new_session = st.aborted_new_session
920
+ bootstrap_coverage = st.bootstrap_coverage
921
+ life_state = st.life_state
922
+ new_session_started = st.new_session_started
923
+ life_state = baseline_json()
924
+ try:
925
+ # 期间没有任何 runtime 写操作(子进程 verify_life 不写 runtime.json),
926
+ # 直接复用快照即可。
927
+ previous_runtime = memo.get()
928
+ except (OSError, ValueError):
929
+ previous_runtime = {}
930
+ new_session_started = False
931
+ if aborted_new_session:
932
+ print("↻ 上一个 Session 已中断,按显式新建请求创建新的 Session 和首个 Round。")
933
+ runtime, started, startup_code = _begin_new_session(
934
+ autonomous=st.autonomous_mode,
935
+ )
936
+ if not started:
937
+ if startup_code is not None:
938
+ return startup_code
939
+ print("✗ 新 Session 未能建立,保留原中断状态并停止启动。")
940
+ return 1
941
+ new_session_started = True
942
+ life_state = baseline_json()
943
+ elif (not previous_runtime.get("active")
944
+ and previous_runtime.get("lifecycle_terminal")):
945
+ print("↻ 上一个 Session 已完成,正在创建新的 Session 和首个 Round。")
946
+ runtime, started, startup_code = _begin_new_session(
947
+ bootstrap_coverage=bootstrap_coverage, autonomous=st.autonomous_mode,
948
+ )
949
+ if not started:
950
+ if startup_code is not None:
951
+ return startup_code
952
+ print("✗ 新 Session 未能建立,保留原完成状态并停止启动。")
953
+ return 1
954
+ new_session_started = True
955
+ life_state = baseline_json()
956
+ elif isinstance(life_state, dict) and life_state.get("life", 1) <= 0:
957
+ print("✝ 当前 Life 已耗尽,但上一 Session 尚未安全收尾;进入恢复检查。")
958
+ print(" 请先恢复或修复当前运行状态,禁止覆盖未完成 Session。")
959
+ return 1
960
+ st.life_state = life_state
961
+ st.new_session_started = new_session_started
962
+ return 0
963
+
964
+
965
+ def serial_runtime_identity(runtime: Mapping[str, object]) -> dict[str, object]:
966
+ """Validate the runtime-owned identity before it can bind a Supervisor run."""
967
+ life_no = runtime.get("life_no")
968
+ if isinstance(life_no, bool) or not isinstance(life_no, int) or life_no < 1:
969
+ raise ValueError("runtime life_no must be a positive integer")
970
+
971
+ lifecycle_id = runtime.get("lifecycle_id")
972
+ if not isinstance(lifecycle_id, str) or not lifecycle_id.strip():
973
+ raise ValueError("runtime lifecycle_id must be a non-empty string")
974
+ for field_name in ("round_id",):
975
+ value = runtime.get(field_name)
976
+ if value is not None and value != lifecycle_id:
977
+ raise ValueError(f"runtime {field_name} does not match lifecycle_id")
978
+
979
+ expected_life_id = f"life-{life_no}"
980
+ runtime_life_id = runtime.get("life_id")
981
+ if runtime_life_id is not None and runtime_life_id != expected_life_id:
982
+ raise ValueError("runtime life_id does not match life_no")
983
+
984
+ session_ids: list[str] = []
985
+ for field_name in ("session_id", "polling_id"):
986
+ value = runtime.get(field_name)
987
+ if value is None:
988
+ continue
989
+ if not isinstance(value, str) or not value.strip():
990
+ raise ValueError(f"runtime {field_name} must be a non-empty string")
991
+ session_ids.append(value)
992
+ if not session_ids:
993
+ raise ValueError("runtime session identity is missing")
994
+ if any(value != session_ids[0] for value in session_ids[1:]):
995
+ raise ValueError("runtime session_id and polling_id conflict")
996
+
997
+ life_kind = runtime.get("life_kind")
998
+ host = str(runtime.get("host") or "").strip().casefold()
999
+ if life_kind == "fix":
1000
+ pass
1001
+ elif life_kind == "mine" and host_serial_worker(host):
1002
+ pass
1003
+ else:
1004
+ raise ValueError(
1005
+ f"serial authorization only supports fix Life or mine Life on a serial-worker host ({host})"
1006
+ )
1007
+ return {
1008
+ "session_id": session_ids[0],
1009
+ "lifecycle_id": lifecycle_id,
1010
+ "round_id": lifecycle_id,
1011
+ "life_id": expected_life_id,
1012
+ "life_no": life_no,
1013
+ "life_kind": life_kind,
1014
+ }
1015
+
1016
+
1017
+ def serial_authorization_intent(
1018
+ runtime: dict, supervisor_state: object, serial_reason: str,
1019
+ ) -> dict[str, object]:
1020
+ """Build the bounded pending record from matching runtime and Supervisor identities."""
1021
+ from core.supervisor.serial_authorization import derive_serial_policy_hash
1022
+
1023
+ def value(name: str) -> object:
1024
+ if isinstance(supervisor_state, Mapping):
1025
+ return supervisor_state.get(name)
1026
+ return getattr(supervisor_state, name, None)
1027
+
1028
+ runtime_identity = _serial_runtime_identity(runtime)
1029
+ lifecycle_id = runtime_identity["lifecycle_id"]
1030
+ identity: dict[str, object] = {
1031
+ "runtime_run_uuid": runtime.get("run_id"),
1032
+ "supervisor_run_id": value("run_id"),
1033
+ "session_id": value("session_id"),
1034
+ "lifecycle_id": lifecycle_id,
1035
+ "round_id": value("round_id"),
1036
+ "life_id": value("life_id"),
1037
+ "life_kind": value("life_kind"),
1038
+ "round_no": value("round_no"),
1039
+ }
1040
+ for field_name in ("session_id", "round_id", "life_id"):
1041
+ if identity[field_name] != runtime_identity[field_name]:
1042
+ raise ValueError(
1043
+ f"Supervisor {field_name} does not match runtime identity"
1044
+ )
1045
+ if identity["life_kind"] != runtime_identity["life_kind"]:
1046
+ raise ValueError("Supervisor Life kind does not match runtime identity")
1047
+ reason_digest = hashlib.sha256(serial_reason.encode("utf-8")).hexdigest()
1048
+ base_policy_hash = runtime.get("autonomous_policy_hash")
1049
+ policy_hash = derive_serial_policy_hash(
1050
+ identity=identity,
1051
+ base_policy_hash=base_policy_hash,
1052
+ serial_reason_sha256=reason_digest,
1053
+ )
1054
+ return {
1055
+ "schema_version": 1,
1056
+ "status": "pending",
1057
+ "authorization_source": "pre_cli",
1058
+ "allow_serial": True,
1059
+ "identity": identity,
1060
+ "base_policy_hash": base_policy_hash,
1061
+ "serial_reason_sha256": reason_digest,
1062
+ "policy_hash": policy_hash,
1063
+ }
1064
+
1065
+
1066
+ def persist_serial_authorization_record(
1067
+ runtime: dict, expected: dict[str, object], memo: "_RuntimeMemo", *,
1068
+ receipt: dict[str, object] | None = None,
1069
+ ) -> dict[str, object]:
1070
+ """Persist pending before issuing, then atomically bind the Supervisor receipt."""
1071
+ with runtime_lock():
1072
+ latest = load_runtime()
1073
+ if latest.get("run_id") != runtime.get("run_id"):
1074
+ raise ValueError("runtime identity changed during serial authorization")
1075
+ existing = latest.get("serial_authorization")
1076
+ # 回执是**运行级**凭据:`start_runtime` 每次调用都会铸造新的 run_id
1077
+ # (同一会话被再次 `pre` resume 时亦然),因此绑定旧 run 的回执属于
1078
+ # **陈旧**而非冲突。若按冲突处理,重复 `bugx pre --allow-serial`
1079
+ # 会永久失败(实测 test_auto_stop_uses_total_findings_of_big_lifecycle
1080
+ # 命中 `runtime serial authorization conflicts with explicit pre inputs`)。
1081
+ if isinstance(existing, Mapping):
1082
+ stored_identity = existing.get("identity")
1083
+ stored_run = (
1084
+ stored_identity.get("runtime_run_uuid")
1085
+ if isinstance(stored_identity, Mapping) else None
1086
+ )
1087
+ if stored_run != latest.get("run_id"):
1088
+ existing = None
1089
+ if existing is not None:
1090
+ if not isinstance(existing, Mapping):
1091
+ raise ValueError("runtime serial authorization record is malformed")
1092
+ expected_fields = set(expected)
1093
+ allowed = (expected_fields, expected_fields | {"receipt"})
1094
+ if set(existing) not in allowed or any(
1095
+ existing.get(key) != value
1096
+ for key, value in expected.items() if key != "status"
1097
+ ):
1098
+ raise ValueError("runtime serial authorization conflicts with explicit pre inputs")
1099
+ status = existing.get("status")
1100
+ if status not in {"pending", "authorized"}:
1101
+ raise ValueError("runtime serial authorization has an invalid status")
1102
+ if status == "authorized":
1103
+ if receipt is not None and existing.get("receipt") != receipt:
1104
+ raise ValueError("runtime serial authorization receipt changed")
1105
+ memo.seed(latest)
1106
+ return dict(existing)
1107
+ if "receipt" in existing:
1108
+ raise ValueError("pending serial authorization cannot contain a receipt")
1109
+ record = dict(expected)
1110
+ if receipt is not None:
1111
+ record["status"] = "authorized"
1112
+ record["receipt"] = receipt
1113
+ latest["serial_authorization"] = record
1114
+ save_runtime(latest)
1115
+ memo.seed(latest)
1116
+ return record
1117
+
1118
+
1119
+
1120
+
1121
+ _begin_new_session = begin_new_session
1122
+ _RuntimeMemo = RuntimeMemo
1123
+ _PreState = PreState
1124
+ _normalize_pre_options = normalize_pre_options
1125
+ _run_preflight_budget_gates = run_preflight_budget_gates
1126
+ _resolve_resume_state = resolve_resume_state
1127
+ _derive_and_persist_decisions = derive_and_persist_decisions
1128
+ _run_tools_and_preflight_gates = run_tools_and_preflight_gates
1129
+ _ensure_autonomous_prep_record = ensure_autonomous_prep_record
1130
+ _start_or_resume_session = start_or_resume_session
1131
+ _serial_runtime_identity = serial_runtime_identity
1132
+ _serial_authorization_intent = serial_authorization_intent
1133
+ _persist_serial_authorization_record = persist_serial_authorization_record