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.
- bugx_cli/__init__.py +6 -0
- bugx_cli/cli.py +1685 -0
- bugx_cli/commands/__init__.py +1 -0
- bugx_cli/commands/advisory.py +94 -0
- bugx_cli/commands/agent.py +4210 -0
- bugx_cli/commands/audit.py +632 -0
- bugx_cli/commands/autonomous.py +260 -0
- bugx_cli/commands/cloud.py +1371 -0
- bugx_cli/commands/daemon.py +50 -0
- bugx_cli/commands/doctor.py +1590 -0
- bugx_cli/commands/goal.py +107 -0
- bugx_cli/commands/interaction.py +248 -0
- bugx_cli/commands/knowledge.py +619 -0
- bugx_cli/commands/lifecycle.py +2763 -0
- bugx_cli/commands/patch.py +1014 -0
- bugx_cli/commands/plugin.py +2749 -0
- bugx_cli/commands/plugin_claude.py +1446 -0
- bugx_cli/commands/plugin_cline.py +269 -0
- bugx_cli/commands/plugin_codex.py +74 -0
- bugx_cli/commands/plugin_funide.py +729 -0
- bugx_cli/commands/plugin_qoder.py +216 -0
- bugx_cli/commands/plugin_zcode.py +710 -0
- bugx_cli/commands/project.py +670 -0
- bugx_cli/commands/report.py +256 -0
- bugx_cli/commands/skill.py +251 -0
- bugx_cli/commands/stats.py +133 -0
- bugx_cli/commands/system.py +2567 -0
- bugx_cli/common.py +906 -0
- bugx_cli/host_adapters.py +1892 -0
- bugx_cli/hosts/__init__.py +80 -0
- bugx_cli/hosts/base.py +99 -0
- bugx_cli/hosts/registry.py +573 -0
- bugx_cli/hosts/template_engine.py +188 -0
- bugx_cli/infra/__init__.py +209 -0
- bugx_cli/infra/ai_advisor.py +851 -0
- bugx_cli/infra/engine_installer.py +1945 -0
- bugx_cli/infra/host_sync.py +548 -0
- bugx_cli/infra/mcp_advisor.py +826 -0
- bugx_cli/infra/security.py +339 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/bugx-mcp-manifest.json +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/CATALOG.json +141 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/README.md +254 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android-interaction.json +81 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android.json +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/desktop-macos.json +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios-interaction.json +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios.json +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/memory-macos.json +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/__init__.py +146 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_artifacts.py +766 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_eval.py +1155 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_execution.py +718 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_orchestrator.py +1351 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_targets.py +877 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_workspace.py +770 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/feature_baseline.py +150 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/README.md +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE.txt +362 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/UPSTREAM.md +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/axe.min.js +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-1024.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-512.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-tight.svg +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar.svg +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-cn.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.svg +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-zh.svg +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/codex.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/dsh.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/project-layout.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/zcode.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/README.md +37 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/manifest.json +94 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/manifest.json +123 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/memory-testing.md +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/manifest.json +155 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/android.md +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/h5.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/ios.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/webview.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/manifest.json +127 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/platform-testing.md +174 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/manifest.json +191 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/graphql.md +5 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/h5.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/oauth.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/upload.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/websocket.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/00-scope.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/INTERFACE.md +61 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/README.md +58 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/__init__.py +109 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph.py +1096 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph_store.py +1868 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/audit_campaign.py +1232 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/behavior_graph.py +465 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/ghsa_advisories.py +174 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/models.py +93 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/mutator.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/patcher.py +126 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/scout.py +278 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/synthesizer.py +207 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/verifier.py +103 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx.md +1299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx_paths.py +1881 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cli-help.txt +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/INTERFACE.md +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/__init__.py +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/auto_sync.py +398 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_client.py +1218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_onboard.py +743 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_schema.py +648 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/consent.py +81 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/device_identity.py +307 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/endpoint_router.py +415 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/flywheel_client.py +769 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/network_transport.py +296 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/onboard_wizard.py +493 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sensitive_filter.py +285 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_pull.py +695 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_push.py +723 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/AGENT_GUIDE.md +359 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/README.md +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-blackbox.md +541 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-opencode.md +469 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-quick.md +44 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-runtime-contract.md +353 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-worker.md +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/engine_gap_contracts.py +473 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/README.md +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/__init__.py +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_ai_review.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_backfill.py +54 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_bootstrap.py +713 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_business.py +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_cli.py +715 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_discovery.py +1429 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_evidence.py +1024 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_forensics.py +124 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_gate.py +277 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_intelligence.py +734 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_manifest.py +396 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_platform.py +77 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_validate.py +241 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/module_coverage.py +157 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/INTERFACE.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/README.md +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/__init__.py +5 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/interaction_preset.py +408 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/engine-integrity.json +2797 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/README.md +49 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/__init__.py +82 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/concurrency_fuzzer.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/differential_oracle.py +1164 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/fuzz_input.py +1291 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/stateful_fuzzer.py +404 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/README.md +61 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/__init__.py +130 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/capacity_planner.py +124 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/dependency_lock.py +317 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/goal_governor.py +754 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/guide_budget.py +458 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/lockdown.sh +50 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/readonly_enforcer.py +154 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/runtime_tool_gate.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/secret_redactor.py +784 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/token_budget.py +38 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/INTERFACE.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/__init__.py +121 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/base.py +111 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/claude.py +99 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/cline.py +298 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/codex.py +300 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/dsh.py +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/opencode.py +209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/pi.py +94 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/zcode.py +99 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/INTERFACE.md +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/__init__.py +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/adapters.py +412 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/autonomous_runner.py +1152 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/cline.py +448 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/common.py +103 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/free_models.py +786 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_bootstrap.py +389 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_evaluators.py +761 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_probe.py +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_provider_arbitrator.py +831 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_registry.py +662 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_usage.py +127 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_process_tracker.py +509 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_registry_gate.py +379 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/pi.py +102 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/provider_facts.py +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/INTERFACE.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/README.md +67 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/__init__.py +140 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_base_usage.py +152 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_codex_usage.py +297 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_dsh_usage.py +184 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_mcp_toml.py +365 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_zcode_usage.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/base.py +479 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/claude.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/cline.py +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/codex.py +1006 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/dsh.py +526 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/opencode.py +358 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/pi.py +308 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/zcode.py +219 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/i18n.py +252 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/README.md +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/__init__.py +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/build_info.py +105 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/client_metadata.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/json_utils.py +22 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/python_runtime.py +540 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/safe_xml.py +221 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_bugx.py +118 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/INTERFACE.md +31 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/README.md +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/__init__.py +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/candidate_revalidation.py +484 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/common.py +1060 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_confirm_phase.py +391 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_settlement.py +1432 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_adjudication.py +666 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_snapshot.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/judge_phase.py +848 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lesson_context.py +536 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lifecycle_reporter.py +627 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/orchestrator_controls.py +686 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_commit.py +567 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_coverage_sync.py +598 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_dry_run.py +817 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_observability.py +367 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_phase.py +1223 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_receipt.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_round_lifecycle.py +786 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_phase.py +1029 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_recon_scout.py +879 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_state_builder.py +1133 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/report_sharing.py +414 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/round_orchestrator.py +1116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/session_runtime.py +1670 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_gates.py +1050 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_interaction.py +1003 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_version_gate.py +879 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_bridge.py +1253 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_coverage.py +423 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_degraded.py +1211 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_barriers.py +424 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_orchestrator.py +1246 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_prior.py +749 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/INTERFACE.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/README.md +160 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/__init__.py +67 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/_facade.py +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/archive_ops.py +630 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/auto_materialization.py +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/bug-log.md +22 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/cli.py +275 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/export_ops.py +554 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_confirmation.py +1316 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_io.py +299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_lifecycle.py +730 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_verification.py +405 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/incidents.py +1005 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson-replay-cases.json +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_ledger.py +241 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_replay.py +272 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/life_ledger.py +668 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/mistake-book.md +130 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/patterns.py +684 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/receipt_contract.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/schema.py +1192 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/sync_ops.py +940 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/tool_experience.py +683 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/verify_life.py +1597 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/lesson-ledger.json +275 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/README.md +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/en-US.json +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/zh-CN.json +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/INTERFACE.md +75 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/__init__.py +128 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/base.py +717 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/channel_lifecycle.py +751 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/graph_handlers.py +222 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/knowledge_handlers.py +536 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/mining_handlers.py +586 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/resource_prompt_table.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/retrieval_handlers.py +249 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/rpc_server.py +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/supervisor_handlers.py +1461 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/telemetry_handlers.py +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/tool_table.py +1030 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/README.md +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/__init__.py +1 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/common.py +363 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/environment.py +567 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/verifier.py +758 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/metadata.txt +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/README.md +157 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/__init__.py +242 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_plan.py +187 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_planner.py +195 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_archetype.py +542 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_router.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/dynamic_flow_analyzer.py +533 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/impact_pruner.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/intent_adjudicator.py +175 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/judge_pipeline.py +1246 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/logic_analysis.py +419 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/prompt_harness.py +1704 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/source_inspector.py +267 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/spec_harvester.py +449 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/target_sandbox_manager.py +573 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/test_capability_verifier.py +1364 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/tools-kb.md +38 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/unit_kind.py +122 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/INTERFACE.md +83 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/SPEC.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/__init__.py +76 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/android_probe.py +552 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/base.py +147 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/codebase_memory_probe.py +647 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/desktop_probe.py +342 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/differential_probe.py +434 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/efficiency_probe.py +232 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ios_binary_probe.py +472 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/memory_probe.py +392 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/miniprogram_probe.py +385 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/mobile_probe.py +466 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/native_probe.py +302 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/openwiki_probe.py +263 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/pattern_probe.py +453 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/platform_probe.py +424 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/probe_registry.py +1770 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_fixture_corpus.py +340 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_probe.py +1510 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_rules.py +1481 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sca_scanner.py +779 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_accessibility.py +149 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_audit.py +513 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_contract.py +273 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_evidence.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_measurements.py +314 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_repair.py +250 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_review.py +133 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_storybook.py +107 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_tokens.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_visual_diff.py +131 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/web_probe.py +714 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/INTERFACE.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/README.md +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/SPEC.md +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/__init__.py +201 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/arbitrator.py +316 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/constants.py +247 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/detector.py +399 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/extractors.py +836 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/fingerprint.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/storage.py +258 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/strategy.py +301 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/codex_dialog_dispatch.md +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_en.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_zh.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/l0_router.md +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/anti_patterns.md +16 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/concurrency_rules.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/memory_leak_rules.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/prompt_injection_defense.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_explore.md +31 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_gate.md +43 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_mutate.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_repair.md +85 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/README.md +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/__init__.py +169 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/fix_watchlist.py +391 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_dynamic.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_repair_loop.py +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_selfcheck.py +862 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/minimize_repro.py +466 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/patch_synthesizer.py +617 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/regression_pack.py +379 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_fixer.py +910 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_loop.py +311 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_repair.py +348 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_rounds.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_scope.py +281 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/self_heal.py +604 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_generator.py +1108 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_quality_auditor.py +410 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_strategy.py +511 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/INTERFACE.md +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/README.md +69 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/SPEC.md +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/__init__.py +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/attestation.py +228 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/authority.py +255 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/finding_report.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/formal_report_builder.py +924 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/html_renderers.py +696 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/models.py +759 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/pdf_exporter.py +231 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/projects_assets.py +730 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_client.py +743 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_data_builder.py +388 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_share.py +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/sast_bridge.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/server.py +832 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/visual_report_builder.py +796 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web-conformance.md +168 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web_conformance.py +428 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/workbench_assets.py +484 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/INTERFACE.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/README.md +161 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/__init__.py +3 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/code_analyzer.py +1720 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/codebase_memory_bridge.py +337 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/context_assembler.py +240 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/corpus_fetch.py +369 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/graph_ego.py +597 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_auto.py +662 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sources.py +168 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sync.py +1003 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/memory_store.py +480 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/query_planner.py +1020 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/rrf_engine.py +137 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_extractor.py +1209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_normalizer.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_spec.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/symbol_index.py +1151 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/universal_code_matcher.py +622 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_bridge.py +476 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_supervisor.py +362 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/README.md +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/PROVENANCE.json +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/crypto.yaml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/network.yaml +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/resilience.yaml +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/storage.yaml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/LICENSE +173 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/PROVENANCE.json +270 -0
- 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
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
- 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
- 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
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-strictmode.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/PROVENANCE.json +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/network.yaml +37 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/platform.yaml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/storage.yaml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/LICENSE +165 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/auth.yaml +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/crypto.yaml +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/logging.yaml +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/network.yaml +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/resilience.yaml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/secrets.yaml +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/storage.yaml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/webview.yaml +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/README.md +198 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/__init__.py +3 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/bugx_logging.py +1464 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/daemon_runner.py +623 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/fixture_solidify.py +444 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/global_telemetry.py +549 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/incident_eval.py +148 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction.py +605 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction_store.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interactive_menu.py +95 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/log_analytics.py +922 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/mining_quality_framework.py +1387 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/model_runner.py +732 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/platform_adapter.py +579 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/prep_validate.py +478 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_graph.py +827 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_init.py +481 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_profile.py +224 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_settings.py +964 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/provider_window.py +97 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/resume_ticket.py +115 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/scenario_eval.py +856 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/seed_drill.py +549 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/self_audit.py +550 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/session_profile.py +205 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/setup_ui_env.py +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/startup_environment.py +859 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/sync_store.py +1421 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/tool_install_targets.py +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/agent-graph.schema.json +368 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/attack-graph.schema.json +88 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/evidence-bundle.schema.json +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/skill-pack.schema.json +230 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/worker-checkpoint.schema.json +119 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/secure_atomic.py +289 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/README.md +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/c.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/cpp.txt +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/css.txt +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/go.txt +46 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/java.txt +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/javascript.txt +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/kotlin.txt +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/python.txt +71 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/rust.txt +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/swift.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/typescript.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/README.md +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/__init__.py +189 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_docs_mcp_server.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_mcp_server.py +1161 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_runtime.py +968 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_session_proof.py +605 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mobile_ui_inspector.py +405 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_pack.py +1214 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_synthesizer.py +1153 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/tools_kb.py +313 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/INTERFACE.md +121 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/README.md +209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/__init__.py +175 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/audit_supervisor.py +1015 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/budget_governor.py +1254 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_handler.py +368 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_pipeline.py +1564 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_sync.py +653 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_events.py +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_sync.py +590 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/cli.py +812 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/context_sync.py +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/coverage_sync.py +115 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_commit.py +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_sync.py +688 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_workflow.py +676 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_policy.py +224 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_sync.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/graph_sync.py +669 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lease_manager.py +788 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lifecycle_blocks.py +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/next_round_sync.py +126 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/observability.py +140 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/recovery_sync.py +165 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/rejection_remedies.py +355 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/round_governor.py +306 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/serial_authorization.py +544 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/start_sync.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/state_store.py +249 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_host.py +511 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_models.py +1143 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/systemic_failure.py +104 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/task_scheduler.py +1640 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_checkpoint.py +230 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_execution.py +265 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_handoff.py +192 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_lifecycle.py +396 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_runtime.py +1005 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_sync.py +89 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/README.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/__init__.py +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/exceptions.py +52 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/graph_models.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/path_containment.py +151 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/target_fingerprint.py +310 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/worker_claim.py +411 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/INTERFACE.md +50 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/README.md +57 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/SPEC.md +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/__init__.py +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/__init__.py +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/base.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/bugx.py +102 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/claude.py +222 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/cline.py +407 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/codex.py +260 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/dsh.py +177 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/opencode.py +218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/pi.py +272 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/registry.py +100 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/zcode.py +312 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/api_routes_post.py +668 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/dispatcher.py +1376 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/docs_session_service.py +473 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/handler.py +674 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/ide_cloud_service.py +526 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/mcp_inspector.py +1747 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/00-base.css +1060 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/01-monitoring.css +802 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/02-header-actions.css +321 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/03-trigger-popover.css +697 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/04-composer.css +628 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/05-skills-center.css +878 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/06-mcp-center.css +623 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/07-skill-detail.css +265 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/08-files-management.css +167 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/09-files-center.css +386 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/10-icons.css +105 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/11-project-options.css +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/12-profile-tab.css +383 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-CXAsl8mr.js +333 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-DHQUtWtx.css +1 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
- 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
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
- 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
- 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
- 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
- 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
- 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
- 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
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
- 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
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
- 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
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
- 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
- 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
- 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
- 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
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/design-tokens.css +113 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/favicon.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/icon-192.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/index.html +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/manifest.webmanifest +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/project-settings.js +9602 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/sw.js +8 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/workspace_service.py +218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/agents/bugx.md +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/dsh-patch.yml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/cordis.patch.yml +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/index.js +219 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/package.json +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx/SKILL.md +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx-dsh/SKILL.md +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/client.js +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/cordis.patch.yml +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/index.js +7 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/package.json +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/mcp-lock.json +3075 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/opencode.json +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/README.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/index.ts +299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/manifest.json +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/skills/bugx/SKILL.md +69 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/connector-meta.json +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/icon.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/skills/bugx/SKILL.md +70 -0
- bugx_cli-0.1.1.dist-info/METADATA +335 -0
- bugx_cli-0.1.1.dist-info/RECORD +762 -0
- bugx_cli-0.1.1.dist-info/WHEEL +5 -0
- bugx_cli-0.1.1.dist-info/entry_points.txt +2 -0
- bugx_cli-0.1.1.dist-info/licenses/LICENSE +55 -0
- bugx_cli-0.1.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1246 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""launch_phases/worker_orchestrator.py - 并发 Worker 生成器与 Task 提示词装配 (DOC-072)。"""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import hashlib
|
|
7
|
+
import json
|
|
8
|
+
import math
|
|
9
|
+
import os
|
|
10
|
+
import platform
|
|
11
|
+
import re
|
|
12
|
+
import stat
|
|
13
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed, wait, FIRST_COMPLETED
|
|
14
|
+
import subprocess
|
|
15
|
+
import time
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
from core.planning.unit_kind import is_internal
|
|
21
|
+
except ImportError: # pragma: no cover
|
|
22
|
+
from core.unit_kind import is_internal
|
|
23
|
+
|
|
24
|
+
from core.host_runtime import host_registry
|
|
25
|
+
|
|
26
|
+
from core.launch_phases.common import (
|
|
27
|
+
resolve_project_root,
|
|
28
|
+
supervisor_state_path,
|
|
29
|
+
uses_project_layout,
|
|
30
|
+
bugx_paths,
|
|
31
|
+
worker_subagent_type,
|
|
32
|
+
)
|
|
33
|
+
from core.launch_phases.supervisor_bridge import get_supervisor
|
|
34
|
+
from core.launch_phases.finding_settlement import findings_payload_path
|
|
35
|
+
from core.launch_phases.session_runtime import load_runtime
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
import core.i18n as i18n
|
|
39
|
+
except ImportError:
|
|
40
|
+
try:
|
|
41
|
+
from core import i18n
|
|
42
|
+
except ImportError:
|
|
43
|
+
i18n = None # type: ignore[assignment]
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
from core.runtime import project_profile
|
|
47
|
+
except ImportError:
|
|
48
|
+
try:
|
|
49
|
+
from core.runtime import project_profile
|
|
50
|
+
except ImportError:
|
|
51
|
+
project_profile = None # type: ignore[assignment]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
from core.coverage import module_coverage
|
|
56
|
+
except ImportError:
|
|
57
|
+
try:
|
|
58
|
+
from core import module_coverage
|
|
59
|
+
except ImportError:
|
|
60
|
+
module_coverage = None
|
|
61
|
+
|
|
62
|
+
from core.supervisor.supervisor_models import (
|
|
63
|
+
UNIT_LEVEL_DEBT,
|
|
64
|
+
note_requests_deep_verification,
|
|
65
|
+
worker_attempts_exhausted,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# ---------------------------------------------------------------------------
|
|
72
|
+
# DOC-256: 架构解耦导出:Worker 先验推荐与阶段屏障
|
|
73
|
+
# ---------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
VERIFICATION_TIER_INSTRUCTIONS = {
|
|
77
|
+
"deep": "必须完成确定性双跑(≥2 次同指纹失败)+ 负对照通过 + 根因锚点核验;满足十项准则才转 confirmed。",
|
|
78
|
+
"standard": "执行标准复现、根因定位和至少一次负向或边界验证;证据不足时标记 candidate。",
|
|
79
|
+
"triage": "只做低成本初筛和证据收集;发现候选必须记录 upgrade_tier=deep,交由深度复验后才能确认。",
|
|
80
|
+
}
|
|
81
|
+
_VERIFICATION_TIER_INSTRUCTIONS = VERIFICATION_TIER_INSTRUCTIONS
|
|
82
|
+
|
|
83
|
+
AUTONOMOUS_MAX_EXTRA_TOOL_CALLS = 12
|
|
84
|
+
AUTONOMOUS_MAX_EXTRA_SECONDS = 600
|
|
85
|
+
|
|
86
|
+
from core.launch_phases.worker_prior import (
|
|
87
|
+
unit_platform,
|
|
88
|
+
worker_id_prefix,
|
|
89
|
+
next_worker_id,
|
|
90
|
+
safe_route_values,
|
|
91
|
+
source_revision,
|
|
92
|
+
unit_matches_path,
|
|
93
|
+
prior_runtime_scan,
|
|
94
|
+
cached_unit_prior,
|
|
95
|
+
build_unit_prior,
|
|
96
|
+
is_confirmed_finding,
|
|
97
|
+
targeted_unit_context,
|
|
98
|
+
recommend_blackbox_tools,
|
|
99
|
+
render_unit_prior,
|
|
100
|
+
knowledge_route_hint,
|
|
101
|
+
lesson_guidance,
|
|
102
|
+
filter_platform_mismatched,
|
|
103
|
+
|
|
104
|
+
worker_host_plugin,
|
|
105
|
+
worker_host_profile,
|
|
106
|
+
order_jobs_longest_first,
|
|
107
|
+
unit_execution_seconds,
|
|
108
|
+
PRIOR_SCHEMA_VERSION,
|
|
109
|
+
KNOWLEDGE_GUIDANCE_CHAR_BUDGET,
|
|
110
|
+
PRIOR_CHAR_BUDGET,
|
|
111
|
+
PRIOR_RUNTIME_CACHE,
|
|
112
|
+
PRIOR_SCAN_BUDGET_SECONDS,
|
|
113
|
+
)
|
|
114
|
+
_PRIOR_SCHEMA_VERSION = PRIOR_SCHEMA_VERSION
|
|
115
|
+
_KNOWLEDGE_GUIDANCE_CHAR_BUDGET = KNOWLEDGE_GUIDANCE_CHAR_BUDGET
|
|
116
|
+
_PRIOR_CHAR_BUDGET = PRIOR_CHAR_BUDGET
|
|
117
|
+
_PRIOR_RUNTIME_CACHE = PRIOR_RUNTIME_CACHE
|
|
118
|
+
_PRIOR_SCAN_BUDGET_SECONDS = PRIOR_SCAN_BUDGET_SECONDS
|
|
119
|
+
_unit_platform = unit_platform
|
|
120
|
+
_worker_id_prefix = worker_id_prefix
|
|
121
|
+
_next_worker_id = next_worker_id
|
|
122
|
+
_safe_route_values = safe_route_values
|
|
123
|
+
_source_revision = source_revision
|
|
124
|
+
_unit_matches_path = unit_matches_path
|
|
125
|
+
_prior_runtime_scan = prior_runtime_scan
|
|
126
|
+
_cached_unit_prior = cached_unit_prior
|
|
127
|
+
_build_unit_prior = build_unit_prior
|
|
128
|
+
_is_confirmed_finding = is_confirmed_finding
|
|
129
|
+
_targeted_unit_context = targeted_unit_context
|
|
130
|
+
_recommend_blackbox_tools = recommend_blackbox_tools
|
|
131
|
+
_render_unit_prior = render_unit_prior
|
|
132
|
+
_knowledge_route_hint = knowledge_route_hint
|
|
133
|
+
_lesson_guidance = lesson_guidance
|
|
134
|
+
|
|
135
|
+
_worker_host_plugin = worker_host_plugin
|
|
136
|
+
_worker_host_profile = worker_host_profile
|
|
137
|
+
_order_jobs_longest_first = order_jobs_longest_first
|
|
138
|
+
_unit_execution_seconds = unit_execution_seconds
|
|
139
|
+
|
|
140
|
+
from core.launch_phases.worker_barriers import (
|
|
141
|
+
looks_rate_limited,
|
|
142
|
+
format_rate_limit_summary,
|
|
143
|
+
sanitize_convention_line,
|
|
144
|
+
conventions_block,
|
|
145
|
+
barrier_probe,
|
|
146
|
+
check_stage_barrier_satisfied,
|
|
147
|
+
behavior_evidence_case_is_valid,
|
|
148
|
+
reject_non_json_constant,
|
|
149
|
+
has_current_behavior_evidence,
|
|
150
|
+
)
|
|
151
|
+
_looks_rate_limited = looks_rate_limited
|
|
152
|
+
_format_rate_limit_summary = format_rate_limit_summary
|
|
153
|
+
_sanitize_convention_line = sanitize_convention_line
|
|
154
|
+
_conventions_block = conventions_block
|
|
155
|
+
_barrier_probe = barrier_probe
|
|
156
|
+
_behavior_evidence_case_is_valid = behavior_evidence_case_is_valid
|
|
157
|
+
_reject_non_json_constant = reject_non_json_constant
|
|
158
|
+
_has_current_behavior_evidence = has_current_behavior_evidence
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def _resolve_pool_capacity(
|
|
163
|
+
*, host: str | None, provider: str | None,
|
|
164
|
+
requested: int | None, pending: int,
|
|
165
|
+
) -> dict[str, object]:
|
|
166
|
+
"""调用容量规划器;导入失败时退回「请求值/待办数」的保守下限,不放大。"""
|
|
167
|
+
|
|
168
|
+
try:
|
|
169
|
+
from core.governance import capacity_planner
|
|
170
|
+
|
|
171
|
+
return capacity_planner.effective_worker_concurrency(
|
|
172
|
+
host=host, provider=provider, requested=requested, pending=pending,
|
|
173
|
+
)
|
|
174
|
+
except (ImportError, OSError, ValueError, RuntimeError):
|
|
175
|
+
value = max(1, min(requested or pending, pending))
|
|
176
|
+
return {
|
|
177
|
+
"value": value, "binding": "fallback", "constraints": {},
|
|
178
|
+
"sources": {}, "ceiling": value,
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _readonly_concurrency_granted(runtime: dict | None) -> bool:
|
|
183
|
+
"""是否显式为**只读并发**授予写权限豁免。
|
|
184
|
+
|
|
185
|
+
默认 False(强互斥)。开启条件必须同时成立:
|
|
186
|
+
* 环境变量 ``BUGX_READONLY_CONCURRENCY=1``(运维显式开关);
|
|
187
|
+
* 运行时声明 ``readonly_enforced=True``(表示执行侧确有只读强制)。
|
|
188
|
+
|
|
189
|
+
为什么这么严:``write_access=False`` 会让 claim 层**不派生** ``file:`` 互斥键,
|
|
190
|
+
同文件多个 worker 可并发。一旦执行侧没有真正的只读强制,这个豁免就等于把
|
|
191
|
+
「两个 worker 同改一个文件」的风险打开——比慢几个数量级更糟。
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
flag = (os.environ.get("BUGX_READONLY_CONCURRENCY") or "").strip()
|
|
195
|
+
if flag != "1":
|
|
196
|
+
return False
|
|
197
|
+
if bool((runtime or {}).get("readonly_enforced")):
|
|
198
|
+
return True
|
|
199
|
+
# 没有执行侧只读视图时,退而要求**校验能力可用**(git 基线可取证)。
|
|
200
|
+
# 这是 build 269 之后新增的门槛:只读声明之所以敢放开同文件并发,是因为
|
|
201
|
+
# checkpoint 会用 claim 时的 git 基线复检越权(``readonly_enforcer``)。
|
|
202
|
+
# 连基线都取不到(非 git 项目)就没有验证手段,必须 fail-closed。
|
|
203
|
+
try:
|
|
204
|
+
from core.governance import readonly_enforcer
|
|
205
|
+
|
|
206
|
+
return readonly_enforcer.snapshot_source_state(Path.cwd()) is not None
|
|
207
|
+
except (ImportError, OSError, ValueError, RuntimeError):
|
|
208
|
+
return False
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
# pi mock 脚枪 fail-closed(OBS3B):这些宿主的 worker 由引擎默认执行器
|
|
212
|
+
# (``worker_runtime._execute_autonomous_worker``)驱动且无宿主 runner,
|
|
213
|
+
# 其 provider 兜底链此前以 ``or "mock"`` 收尾——``workers --execute`` 无显式
|
|
214
|
+
# ``--provider`` 时会**静默**落 mock(引擎诚实记 skipped,但运维预期是真实
|
|
215
|
+
# 宿主通道)。在册宿主的无显式 provider 派发改走仲裁 fail-closed。
|
|
216
|
+
# 仅 pi 完成集成实证在册;新宿主加入前必须完成同型取证(不得凭宿主名猜测)。
|
|
217
|
+
FAIL_CLOSED_PROVIDER_HOSTS: frozenset[str] = frozenset({"pi"})
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def _resolve_fail_closed_provider(
|
|
221
|
+
host: str | None,
|
|
222
|
+
provider: str | None,
|
|
223
|
+
runtime_provider: object,
|
|
224
|
+
*,
|
|
225
|
+
execute: bool,
|
|
226
|
+
) -> tuple[str | None, str | None]:
|
|
227
|
+
"""无显式 provider 时的 fail-closed 默认通道裁决。
|
|
228
|
+
|
|
229
|
+
返回 ``(provider, error)``:``error`` 非空表示仲裁无真实通道,调用方必须
|
|
230
|
+
显式报错终止派发,**绝不**静默落 mock。语义:
|
|
231
|
+
* 非在册宿主 / 提示词模式(execute=False):行为不变,原样返回;
|
|
232
|
+
* 显式 ``--provider`` 或 runtime context 已带 provider:100% 尊重,不仲裁;
|
|
233
|
+
* 在册宿主 + 执行模式 + 无任何显式 provider:``arbitrate_host_provider``
|
|
234
|
+
取最优真实通道;仲裁为空 / mock-only 时返回显式错误。
|
|
235
|
+
"""
|
|
236
|
+
host_key = str(host or "").strip().casefold()
|
|
237
|
+
if host_key not in FAIL_CLOSED_PROVIDER_HOSTS:
|
|
238
|
+
return provider, None
|
|
239
|
+
if not execute:
|
|
240
|
+
return provider, None
|
|
241
|
+
explicit = str(provider or "").strip()
|
|
242
|
+
if explicit:
|
|
243
|
+
return explicit, None
|
|
244
|
+
from_runtime = str(runtime_provider or "").strip()
|
|
245
|
+
if from_runtime:
|
|
246
|
+
return from_runtime, None
|
|
247
|
+
try:
|
|
248
|
+
from core.host_runtime.host_provider_arbitrator import arbitrate_host_provider
|
|
249
|
+
|
|
250
|
+
arbitrated, _model, _cand, _manifest = arbitrate_host_provider(host_key)
|
|
251
|
+
except (ImportError, OSError, ValueError, RuntimeError) as exc:
|
|
252
|
+
return None, (
|
|
253
|
+
f"{host_key} 无可用真实通道,需显式 --provider 或检查宿主配置"
|
|
254
|
+
f"(仲裁失败: {exc})"
|
|
255
|
+
)
|
|
256
|
+
channel = str(arbitrated or "").strip()
|
|
257
|
+
if not channel or channel.casefold() in {"mock", "none"}:
|
|
258
|
+
return None, f"{host_key} 无可用真实通道,需显式 --provider 或检查宿主配置"
|
|
259
|
+
return channel, None
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def workers(
|
|
263
|
+
count: int | None = None,
|
|
264
|
+
strategy: str = "risk",
|
|
265
|
+
execute: bool = False,
|
|
266
|
+
host: str | None = None,
|
|
267
|
+
max_workers: int | None = None,
|
|
268
|
+
subagent_type: str | None = None,
|
|
269
|
+
stagger_seconds: float | None = None,
|
|
270
|
+
model: str | None = None,
|
|
271
|
+
provider: str | None = None,
|
|
272
|
+
executable: str | None = None,
|
|
273
|
+
*,
|
|
274
|
+
dry_run: bool = False,
|
|
275
|
+
brief: bool = False,
|
|
276
|
+
) -> int:
|
|
277
|
+
"""把 Supervisor 可领取单元打印成可直接执行的 Task worker 提示词,或在自治模式下直接执行。
|
|
278
|
+
|
|
279
|
+
宿主执行面/控制面分离的机械入口:pre 之后运行本命令,把输出的 N 个
|
|
280
|
+
worker 提示词**并发**交给宿主 Task/subagent 能力(subagent_type 默认
|
|
281
|
+
bugx-worker;若被派类型缺少
|
|
282
|
+
bugx-supervisor-worker_* MCP 工具,宿主必须改派具备 MCP 的通用类型),
|
|
283
|
+
满足「同一 Life 至少 2 个 worker 真实重叠」的并发门禁。
|
|
284
|
+
参数优先级为显式入参 > 当前 runtime context > 物理宿主探查;不读取全局宿主环境变量。
|
|
285
|
+
"""
|
|
286
|
+
print("=" * 56)
|
|
287
|
+
runtime = load_runtime()
|
|
288
|
+
host_autonomous = bool(runtime.get("autonomous_mode"))
|
|
289
|
+
runtime_host = runtime.get("host")
|
|
290
|
+
selected_host = host if host is not None else runtime_host
|
|
291
|
+
if selected_host is None:
|
|
292
|
+
try:
|
|
293
|
+
from core.supervisor.supervisor_host import detect_host
|
|
294
|
+
selected_host = detect_host(resolve_project_root()).name
|
|
295
|
+
except (ImportError, OSError, RuntimeError, ValueError):
|
|
296
|
+
selected_host = "unknown"
|
|
297
|
+
selected_host = str(selected_host).strip().casefold()
|
|
298
|
+
if not selected_host:
|
|
299
|
+
selected_host = "unknown"
|
|
300
|
+
# 原生 Task 派发能力是插件事实(``engine_run.native_task``);未迁移宿主走基线表。
|
|
301
|
+
native_task_host = host_registry.host_native_task(selected_host)
|
|
302
|
+
host_label, host_worker_facts = _worker_host_profile(selected_host)
|
|
303
|
+
serial_worker_host = bool(host_worker_facts and host_worker_facts["mode"] == "serial")
|
|
304
|
+
runtime_execute = bool(runtime.get("execute"))
|
|
305
|
+
effective_execute = bool(execute or runtime_execute)
|
|
306
|
+
selected_subagent_type = worker_subagent_type(
|
|
307
|
+
subagent_type if subagent_type is not None else runtime.get("subagent_type")
|
|
308
|
+
)
|
|
309
|
+
if host_autonomous and execute and native_task_host:
|
|
310
|
+
print("✗ 自治宿主模式禁止 --execute:Worker 必须由 Claude Code/Codex 原生 Task 执行。")
|
|
311
|
+
return 2
|
|
312
|
+
if not brief:
|
|
313
|
+
print(
|
|
314
|
+
f"bugx worker 生成器:{host_label} 主会话串行执行"
|
|
315
|
+
if serial_worker_host
|
|
316
|
+
else "bugx 并发 worker 生成器:把可领取单元变成 Task 提示词"
|
|
317
|
+
)
|
|
318
|
+
print("=" * 56)
|
|
319
|
+
if not supervisor_state_path().is_file():
|
|
320
|
+
print("✗ 未找到 Supervisor 状态;请先运行 bugx engine --root . pre")
|
|
321
|
+
return 1
|
|
322
|
+
try:
|
|
323
|
+
from core.supervisor import audit_supervisor
|
|
324
|
+
supervisor = get_supervisor()
|
|
325
|
+
state = supervisor.status()
|
|
326
|
+
except (OSError, ValueError, RuntimeError) as exc:
|
|
327
|
+
print(f"✗ Supervisor 状态不可读: {exc}")
|
|
328
|
+
return 1
|
|
329
|
+
if state.status.value in {"COMPLETE", "FAILED"}:
|
|
330
|
+
print(f"✗ Supervisor 状态为 {state.status.value},请先开启新审计 run")
|
|
331
|
+
return 1
|
|
332
|
+
claimed = {
|
|
333
|
+
unit
|
|
334
|
+
for claim in state.claims.values()
|
|
335
|
+
if claim.round_no == state.round_no and claim.state in {"active", "submitted"}
|
|
336
|
+
for unit in claim.unit_ids
|
|
337
|
+
}
|
|
338
|
+
debt_states = UNIT_LEVEL_DEBT
|
|
339
|
+
internal_debt = {
|
|
340
|
+
unit for unit, item in state.coverage.items()
|
|
341
|
+
if is_internal(unit) and item not in {
|
|
342
|
+
"covered", "not_applicable", "removed", "superseded",
|
|
343
|
+
} and not worker_attempts_exhausted(state, unit)
|
|
344
|
+
}
|
|
345
|
+
eligible = supervisor._eligible_units(state)
|
|
346
|
+
pool = {
|
|
347
|
+
unit for unit, item in state.coverage.items()
|
|
348
|
+
if unit in eligible and item in debt_states
|
|
349
|
+
and not worker_attempts_exhausted(state, unit)
|
|
350
|
+
}
|
|
351
|
+
remaining_units = list(pool - claimed)
|
|
352
|
+
# 平台亲和:宿主无法验证其它平台的专属单元(如 Windows 宿主上的
|
|
353
|
+
# darwin.go/linux.go),调度必须跳过并如实汇报,防止空转与假覆盖。
|
|
354
|
+
host_platform = platform.system().lower()
|
|
355
|
+
remaining_units, platform_mismatched = filter_platform_mismatched(
|
|
356
|
+
remaining_units, host_platform,
|
|
357
|
+
)
|
|
358
|
+
if platform_mismatched:
|
|
359
|
+
print(
|
|
360
|
+
f"平台亲和过滤(本机 {host_platform}):{len(platform_mismatched)} 个"
|
|
361
|
+
"跨平台专属单元标记 BLOCKED/待匹配平台宿主,不参与本轮调度:"
|
|
362
|
+
)
|
|
363
|
+
for unit in platform_mismatched[:8]:
|
|
364
|
+
print(f" - {unit}")
|
|
365
|
+
if len(platform_mismatched) > 8:
|
|
366
|
+
print(f" ...(其余 {len(platform_mismatched) - 8} 个略)")
|
|
367
|
+
if not remaining_units:
|
|
368
|
+
if state.coverage_complete:
|
|
369
|
+
print("✓ 全部覆盖单元均已完成覆盖。")
|
|
370
|
+
print(" 下一步:请执行 bugx engine --root . post --final 封存当前 Round 并生成测试报告。")
|
|
371
|
+
return 0
|
|
372
|
+
exhausted_units = sorted(
|
|
373
|
+
unit for unit, status in state.coverage.items()
|
|
374
|
+
if status in debt_states and worker_attempts_exhausted(state, unit)
|
|
375
|
+
)
|
|
376
|
+
if exhausted_units:
|
|
377
|
+
status_val = getattr(state.status, "value", str(state.status))
|
|
378
|
+
print(
|
|
379
|
+
f"✗ 覆盖债务已触发 worker 尝试熔断:{len(exhausted_units)} 个单元已达"
|
|
380
|
+
"尝试上限,本轮无可派发单元(不伪报完成)。"
|
|
381
|
+
)
|
|
382
|
+
print(
|
|
383
|
+
" 说明:这些单元的 coverage 已标记为 blocked,"
|
|
384
|
+
f"而 run 状态为 {status_val};"
|
|
385
|
+
)
|
|
386
|
+
print(
|
|
387
|
+
" 出路:调用 recover(推进 scheduler_epoch 解冻)后重跑 workers,"
|
|
388
|
+
"或执行 finish 结束本 Round 并如实报告未覆盖债务。"
|
|
389
|
+
)
|
|
390
|
+
for unit in exhausted_units[:8]:
|
|
391
|
+
print(f" - {unit}")
|
|
392
|
+
if len(exhausted_units) > 8:
|
|
393
|
+
print(f" ...(其余 {len(exhausted_units) - 8} 个略)")
|
|
394
|
+
return 1
|
|
395
|
+
# 可领集合为空时的分流提示:stale/debt 单元若被本轮终态 claim 占用,
|
|
396
|
+
# 出路是 next-round(释放占用并重领),不是让宿主空转重跑 workers。
|
|
397
|
+
stale_occupied = sorted(
|
|
398
|
+
unit for unit, status in state.coverage.items()
|
|
399
|
+
if status == "stale"
|
|
400
|
+
and any(
|
|
401
|
+
c.unit_ids and unit in c.unit_ids
|
|
402
|
+
and c.state in {"submitted", "active"}
|
|
403
|
+
for c in state.claims.values()
|
|
404
|
+
)
|
|
405
|
+
)
|
|
406
|
+
if stale_occupied:
|
|
407
|
+
print(
|
|
408
|
+
"✗ 当前没有可领取的覆盖单元:stale 单元仍被本轮终态 claim 占用:"
|
|
409
|
+
+ ", ".join(stale_occupied[:5])
|
|
410
|
+
)
|
|
411
|
+
print(
|
|
412
|
+
" 出路:执行 supervisor next-round 推进到下一轮(占用随之释放、"
|
|
413
|
+
"stale 单元重领),或执行 post 结算本 Round。"
|
|
414
|
+
)
|
|
415
|
+
return 1
|
|
416
|
+
print("✗ 当前没有可领取的覆盖单元(全部已领取或已覆盖)")
|
|
417
|
+
return 1
|
|
418
|
+
|
|
419
|
+
# 1. 拓扑与 AST 多因子优先级调度(集成代码智能内在风险倾斜,DOC-060)
|
|
420
|
+
strategy = strategy.strip().lower()
|
|
421
|
+
if strategy not in {"risk", "bfs", "dfs", "hybrid", "auto"}:
|
|
422
|
+
print(f"✗ 未知扫描策略: {strategy}(可选 risk、bfs、dfs、hybrid、auto)")
|
|
423
|
+
return 2
|
|
424
|
+
strategy_info = {"strategy": "legacy-fallback", "reason": "调度器异常,保持原有字典序"}
|
|
425
|
+
unit_risks: dict[str, float] = {}
|
|
426
|
+
surfaces: list[str] = []
|
|
427
|
+
skill_plan: dict[str, Any] | None = None
|
|
428
|
+
scheduler = None
|
|
429
|
+
try:
|
|
430
|
+
from core.supervisor import task_scheduler
|
|
431
|
+
if project_profile is not None:
|
|
432
|
+
try:
|
|
433
|
+
active = bugx_paths.require(resolve_project_root())
|
|
434
|
+
profile_data = project_profile.load_project_profile(active.knowledge_seed)
|
|
435
|
+
if isinstance(profile_data, dict):
|
|
436
|
+
risk_metrics = profile_data.get("risk_metrics") or {}
|
|
437
|
+
classification = profile_data.get("classification") or {}
|
|
438
|
+
surfaces = [str(item) for item in classification.get("surfaces", [])]
|
|
439
|
+
for hotspot in risk_metrics.get("top_risk_hotspots") or []:
|
|
440
|
+
if isinstance(hotspot, dict) and "file" in hotspot:
|
|
441
|
+
unit_risks[str(hotspot["file"])] = float(hotspot.get("risk_score", 50.0))
|
|
442
|
+
skill_plan = profile_data.get("skill_plan")
|
|
443
|
+
if not skill_plan and "strategy" in profile_data:
|
|
444
|
+
skill_plan = profile_data["strategy"].get("skill_plan")
|
|
445
|
+
if not skill_plan:
|
|
446
|
+
strat = project_profile.compile_audit_strategy(profile_data)
|
|
447
|
+
skill_plan = strat.get("skill_plan")
|
|
448
|
+
|
|
449
|
+
# DOC-241: 将 AI 识别的优先级焦点与攻击图谱假说注入调度器风险加权
|
|
450
|
+
try:
|
|
451
|
+
from core.autonomous_cve import attack_graph_store
|
|
452
|
+
for hypo in attack_graph_store.get_hypotheses(resolve_project_root()):
|
|
453
|
+
src = hypo.get("source_file") or hypo.get("target")
|
|
454
|
+
if src:
|
|
455
|
+
unit_risks[str(src)] = max(unit_risks.get(str(src), 0.0), 90.0)
|
|
456
|
+
except Exception:
|
|
457
|
+
pass
|
|
458
|
+
try:
|
|
459
|
+
rev_file = resolve_project_root() / ".bugx" / "state" / "l1-semantic-review.json"
|
|
460
|
+
if rev_file.is_file():
|
|
461
|
+
rev_data = json.loads(rev_file.read_text(encoding="utf-8"))
|
|
462
|
+
p_focus = (rev_data.get("audit_strategy_verdict") or {}).get("priority_focus") or []
|
|
463
|
+
for pf in p_focus:
|
|
464
|
+
if pf:
|
|
465
|
+
unit_risks[str(pf)] = max(unit_risks.get(str(pf), 0.0), 95.0)
|
|
466
|
+
except Exception:
|
|
467
|
+
pass
|
|
468
|
+
except Exception:
|
|
469
|
+
unit_risks = {}
|
|
470
|
+
|
|
471
|
+
sched = task_scheduler.shared_scheduler(
|
|
472
|
+
resolve_project_root(),
|
|
473
|
+
unit_risks=unit_risks,
|
|
474
|
+
traversal_strategy="auto" if strategy == "risk" else strategy,
|
|
475
|
+
surfaces=surfaces,
|
|
476
|
+
)
|
|
477
|
+
scheduler = sched
|
|
478
|
+
# DOC-065: 缺陷反馈闭环驱动任务调度动态加权 (record_defect)
|
|
479
|
+
try:
|
|
480
|
+
fpath = findings_payload_path()
|
|
481
|
+
if fpath and fpath.is_file():
|
|
482
|
+
with open(fpath, "r", encoding="utf-8") as f:
|
|
483
|
+
fdata = json.load(f)
|
|
484
|
+
flist = fdata.get("findings") if isinstance(fdata, dict) else (fdata if isinstance(fdata, list) else [])
|
|
485
|
+
for item in flist:
|
|
486
|
+
if isinstance(item, dict) and _is_confirmed_finding(item):
|
|
487
|
+
file_path = item.get("file") or item.get("path")
|
|
488
|
+
if not file_path and isinstance(item.get("evidence"), list) and item["evidence"]:
|
|
489
|
+
file_path = item["evidence"][0].get("path")
|
|
490
|
+
sev = item.get("severity", "HIGH")
|
|
491
|
+
if file_path:
|
|
492
|
+
sched.record_defect(str(file_path), str(sev))
|
|
493
|
+
except Exception:
|
|
494
|
+
pass
|
|
495
|
+
candidates = sched.rank_units(remaining_units, state.coverage, unit_risks=unit_risks)
|
|
496
|
+
strategy_info = sched.last_strategy_info
|
|
497
|
+
except Exception:
|
|
498
|
+
candidates = sorted(remaining_units)
|
|
499
|
+
print(
|
|
500
|
+
f"扫描策略:{strategy}(实际遍历={strategy_info.get('strategy', 'legacy-fallback')});"
|
|
501
|
+
f"{strategy_info.get('reason', '')}"
|
|
502
|
+
)
|
|
503
|
+
if scheduler is not None:
|
|
504
|
+
deep_upgrades = {
|
|
505
|
+
unit for unit, note in state.unit_notes.items()
|
|
506
|
+
if isinstance(note, dict)
|
|
507
|
+
and note_requests_deep_verification(note.get("note"))
|
|
508
|
+
}
|
|
509
|
+
tier_by_unit = {
|
|
510
|
+
unit: "deep" if unit in deep_upgrades else task_scheduler.verification_tier(
|
|
511
|
+
unit, scheduler._risk_for_unit(unit, unit_risks), surfaces,
|
|
512
|
+
)
|
|
513
|
+
for unit in candidates
|
|
514
|
+
}
|
|
515
|
+
if strategy != "bfs":
|
|
516
|
+
tier_order = {"deep": 0, "standard": 1, "triage": 2}
|
|
517
|
+
original_order = {unit: index for index, unit in enumerate(candidates)}
|
|
518
|
+
candidates = sorted(
|
|
519
|
+
candidates,
|
|
520
|
+
key=lambda unit: (tier_order[tier_by_unit[unit]], original_order[unit]),
|
|
521
|
+
)
|
|
522
|
+
counts = {tier: sum(tier_by_unit.get(unit) == tier for unit in candidates)
|
|
523
|
+
for tier in ("deep", "standard", "triage")}
|
|
524
|
+
print(f"验证深度:deep={counts['deep']} standard={counts['standard']} triage={counts['triage']}(triage 发现候选必须升档复验)")
|
|
525
|
+
print("风险 Top-10:")
|
|
526
|
+
for unit in candidates[:10]:
|
|
527
|
+
print(
|
|
528
|
+
f" - {unit}: score={scheduler.score_unit(unit, state.coverage.get(unit, 'pending'), scheduler._risk_for_unit(unit, unit_risks)):.2f} "
|
|
529
|
+
f"tier={tier_by_unit.get(unit, 'standard')}"
|
|
530
|
+
)
|
|
531
|
+
else:
|
|
532
|
+
tier_by_unit = {unit: "standard" for unit in candidates}
|
|
533
|
+
|
|
534
|
+
# 2. 自适应并发容量动态计算
|
|
535
|
+
runtime_count = runtime.get("workers")
|
|
536
|
+
# F-RSI-20261112-077:0 不是合法并发请求(旧代码校验放行 0 后被下方
|
|
537
|
+
# ``count > 0`` 静默吞掉回退 ceiling——契约与实现不一致)。统一正整数语义。
|
|
538
|
+
if count is not None and (not isinstance(count, int) or isinstance(count, bool) or count <= 0):
|
|
539
|
+
print("✗ worker count 必须是正整数")
|
|
540
|
+
return 2
|
|
541
|
+
if runtime_count is not None and (
|
|
542
|
+
not isinstance(runtime_count, int) or isinstance(runtime_count, bool) or runtime_count <= 0
|
|
543
|
+
):
|
|
544
|
+
print("✗ runtime workers 必须是正整数")
|
|
545
|
+
return 2
|
|
546
|
+
requested_limit = (
|
|
547
|
+
count if isinstance(count, int) and count > 0
|
|
548
|
+
else runtime_count if isinstance(runtime_count, int) and runtime_count > 0
|
|
549
|
+
else state.budget.max_concurrency_ceiling
|
|
550
|
+
)
|
|
551
|
+
# 宿主插件声明串行 Worker 且没有会话内原生 Task 时,进程池模式是唯一的显式
|
|
552
|
+
# 并行逃逸口(并发硬顶也来自插件的 ``worker_runtime.max_concurrency``)。
|
|
553
|
+
process_mode_cap = int(host_worker_facts["max_concurrency"] or 0) if host_worker_facts else 0
|
|
554
|
+
is_process_mode = (
|
|
555
|
+
serial_worker_host
|
|
556
|
+
and bool(host_worker_facts and host_worker_facts["requires_process_mode"])
|
|
557
|
+
and effective_execute
|
|
558
|
+
)
|
|
559
|
+
if serial_worker_host and not is_process_mode and requested_limit > 1:
|
|
560
|
+
print(f"{host_label} Worker 串行模式:本批最多领取 1 个 claim,完成 checkpoint 后再领取下一条。")
|
|
561
|
+
requested_limit = 1
|
|
562
|
+
elif is_process_mode:
|
|
563
|
+
# 宿主没有 in-session Task(subagent_type=...) 原语:进程池是显式逃逸口,
|
|
564
|
+
# 上限取插件声明的并发硬顶。
|
|
565
|
+
if process_mode_cap:
|
|
566
|
+
requested_limit = min(requested_limit, process_mode_cap)
|
|
567
|
+
print(
|
|
568
|
+
f"{host_label} CLI 进程池模式:按自适应容量派发,单批并发上限 {requested_limit}"
|
|
569
|
+
f"(2~{process_mode_cap or requested_limit} 路)。"
|
|
570
|
+
)
|
|
571
|
+
try:
|
|
572
|
+
from core.supervisor import task_scheduler
|
|
573
|
+
ctrl = task_scheduler.AdaptiveConcurrencyController(
|
|
574
|
+
min_concurrency=state.budget.min_concurrency,
|
|
575
|
+
max_concurrency=state.budget.max_concurrency_ceiling,
|
|
576
|
+
)
|
|
577
|
+
adaptive_cap = ctrl.compute_capacity(len(state.active_claims), state.budget, state)
|
|
578
|
+
if state.budget.adaptive_concurrency and state.budget.require_parallel and state.budget.max_concurrency > 1:
|
|
579
|
+
capacity = adaptive_cap
|
|
580
|
+
else:
|
|
581
|
+
capacity = max(0, state.budget.max_concurrency - len(state.active_claims))
|
|
582
|
+
except Exception:
|
|
583
|
+
capacity = max(0, state.budget.max_concurrency - len(state.active_claims))
|
|
584
|
+
|
|
585
|
+
# 只读并发授权(P2)必须满足**两个**条件才声明,缺一不可:
|
|
586
|
+
# 1) 显式开启 ``BUGX_READONLY_CONCURRENCY=1``;
|
|
587
|
+
# 2) 该轮次被强制只读。
|
|
588
|
+
# 审计发现:``fix_mode`` **不构成写授权强制**——它只被 post_phase 消费(决定 open
|
|
589
|
+
# finding 是否放行结算),worker 执行侧(worker_runtime / host_runtime)从不读它,
|
|
590
|
+
# 也没有只读沙箱/挂载。因此「fix_mode=log-only ⇒ worker 不改文件」是**假前提**:
|
|
591
|
+
# 若据此声明只读,同文件并发就会在「模型自作主张改文件」时静默覆盖。
|
|
592
|
+
# 在拿到执行侧强制(只读挂载或 checkpoint 文件指纹校验)之前,默认 ``None``
|
|
593
|
+
# 走历史强互斥——宁可慢,不可覆盖。
|
|
594
|
+
write_access = False if _readonly_concurrency_granted(runtime) else None
|
|
595
|
+
|
|
596
|
+
limit = min(requested_limit, capacity)
|
|
597
|
+
if limit <= 0:
|
|
598
|
+
print("✗ 当前并发槽位已满;等待已有 worker 结算后再派发")
|
|
599
|
+
return 1
|
|
600
|
+
|
|
601
|
+
# 3. 亲和任务打包调度(同文件内聚聚合,最多 3 单元/包)
|
|
602
|
+
try:
|
|
603
|
+
from core.supervisor import task_scheduler
|
|
604
|
+
# DOC-142 实测结论:tier 感知的窄打包(deep 独占 + triage 密集)在
|
|
605
|
+
# slot 受限下把 units_mined 从 24 降到 16(广度 −33%),有效 recall
|
|
606
|
+
# 反而 −14%——宽打包均摊前导段的收益大于专注度收益,故保留原亲和
|
|
607
|
+
# 打包器;本批的增量在"包内每单元投入"(见上方 prior_by_unit)。
|
|
608
|
+
# Bundle 上限随写权限自适应(P4):只读轮次可以更大包(读并发安全、
|
|
609
|
+
# 减少 claim/前导开销),写轮次保持 3(同文件冲突面可控)。上限 5 与
|
|
610
|
+
# claim 层的 ``unit_ids`` 硬上限(1~5)一致,不制造越界。
|
|
611
|
+
max_bundle = 5 if not write_access else 3
|
|
612
|
+
bundles = task_scheduler.AffinityBundler.bundle_units(
|
|
613
|
+
candidates, max_bundle_size=max_bundle,
|
|
614
|
+
)
|
|
615
|
+
desired_workers = min(limit, len(candidates))
|
|
616
|
+
initial_bundle_count = len(bundles)
|
|
617
|
+
if len(bundles) < desired_workers:
|
|
618
|
+
bundles = task_scheduler.AffinityBundler.rebalance_for_parallelism(
|
|
619
|
+
bundles, desired_workers,
|
|
620
|
+
)
|
|
621
|
+
print(
|
|
622
|
+
f"亲和 Bundle 数不足({initial_bundle_count} < {desired_workers}),"
|
|
623
|
+
"已展开为单元级 Bundle 以填满动态并发槽位。"
|
|
624
|
+
)
|
|
625
|
+
except Exception:
|
|
626
|
+
bundles = [[u] for u in candidates]
|
|
627
|
+
|
|
628
|
+
# 尝试完整候选序列;冲突 bundle 跳过后继续补位,避免首个 file mutex
|
|
629
|
+
# 拒绝让后续独立单元空槽等待下一次 workers 调用。
|
|
630
|
+
selected_bundles = bundles
|
|
631
|
+
if dry_run:
|
|
632
|
+
selected_bundles = bundles[:limit]
|
|
633
|
+
if dry_run:
|
|
634
|
+
print(json.dumps({
|
|
635
|
+
"schema_version": 1,
|
|
636
|
+
"dry_run": True,
|
|
637
|
+
"available_units": len(candidates),
|
|
638
|
+
"selected_bundles": selected_bundles,
|
|
639
|
+
"requested_count": requested_limit,
|
|
640
|
+
"capacity": capacity,
|
|
641
|
+
}, ensure_ascii=False, sort_keys=True))
|
|
642
|
+
return 0
|
|
643
|
+
# pi mock 脚枪 fail-closed(OBS3B):在册宿主以执行模式派发且无显式 provider
|
|
644
|
+
# 时,此前会经 supervisor worker_runtime 的 ``or "mock"`` 兜底**静默**落 mock。
|
|
645
|
+
# 这里在 claim 之前收口:仲裁出真实通道则采用(容量规划与任务装配同步感知),
|
|
646
|
+
# 仲裁无真实通道则显式报错终止——绝不静默落 mock,也绝不产生孤儿租约。
|
|
647
|
+
provider_before_fail_closed = provider
|
|
648
|
+
provider, fail_closed_err = _resolve_fail_closed_provider(
|
|
649
|
+
selected_host, provider, runtime.get("provider"),
|
|
650
|
+
execute=effective_execute,
|
|
651
|
+
)
|
|
652
|
+
if fail_closed_err:
|
|
653
|
+
print(f"✗ {fail_closed_err}")
|
|
654
|
+
return 2
|
|
655
|
+
if provider and provider != provider_before_fail_closed:
|
|
656
|
+
print(f" [{selected_host} 通道裁决] 无显式 --provider,fail-closed 选定仲裁最优真实通道: {provider}")
|
|
657
|
+
# 两阶段派发(F-RSI-20261112-077):先为**全部**候选任务包解析互斥作用域,
|
|
658
|
+
# 任何文件型单元解析失败都在**零 claim** 状态下 fail-closed——旧实现
|
|
659
|
+
# raise 发生在预占循环中间,前面已成功 claim 的租约成为无人执行的孤儿
|
|
660
|
+
# (占用并发槽位直到 300s 租约过期)。fail-closed 语义不变,孤儿窗口归零。
|
|
661
|
+
bundle_res_keys: list[list[str]] = []
|
|
662
|
+
for bundle in selected_bundles:
|
|
663
|
+
res_keys = [f"unit:{u}" for u in bundle]
|
|
664
|
+
for u in bundle:
|
|
665
|
+
fp = None
|
|
666
|
+
try:
|
|
667
|
+
from core.supervisor import task_scheduler
|
|
668
|
+
fp, _ = task_scheduler.extract_unit_scope(u)
|
|
669
|
+
except (ImportError, AttributeError):
|
|
670
|
+
pass
|
|
671
|
+
except Exception as exc:
|
|
672
|
+
print(f"! [worker_orchestrator] 提取任务包单元作用域异常 ({u}): {exc}")
|
|
673
|
+
if not fp:
|
|
674
|
+
src = None
|
|
675
|
+
failure: Exception | None = None
|
|
676
|
+
try:
|
|
677
|
+
from core.supervisor.supervisor_models import unit_source_path
|
|
678
|
+
|
|
679
|
+
src = unit_source_path(u)
|
|
680
|
+
except Exception as exc: # noqa: BLE001 - 失败必须可观测,不得静默
|
|
681
|
+
failure = exc
|
|
682
|
+
if src and "." in src.rsplit("/", 1)[-1]:
|
|
683
|
+
fp = src
|
|
684
|
+
elif failure is not None and "." in u.rsplit("/", 1)[-1]:
|
|
685
|
+
# 审计 #18:文件型单元解析不出源文件 ⇒ 缺 ``file:<fp>`` 互斥
|
|
686
|
+
# 作用域,并发派发可能同时改同一个文件。旧实现 ``pass`` 静默
|
|
687
|
+
# 回退,等于把「同文件互斥」降级成「没人保证」。这里 fail-closed。
|
|
688
|
+
print(
|
|
689
|
+
f"! [worker_orchestrator] 无法解析文件型单元 {u} 的源文件作用域"
|
|
690
|
+
f"(缺少文件互斥保护),拒绝派发: {failure}"
|
|
691
|
+
)
|
|
692
|
+
raise ValueError(
|
|
693
|
+
f"无法确定文件型单元 {u} 的互斥作用域,拒绝在缺少 file:<fp> "
|
|
694
|
+
f"保护的情况下派发"
|
|
695
|
+
) from failure
|
|
696
|
+
if fp and f"file:{fp}" not in res_keys:
|
|
697
|
+
res_keys.append(f"file:{fp}")
|
|
698
|
+
bundle_res_keys.append(res_keys)
|
|
699
|
+
|
|
700
|
+
assigned = []
|
|
701
|
+
worker_prefix = _worker_id_prefix(state)
|
|
702
|
+
worker_ids = set(state.claims)
|
|
703
|
+
next_worker_index = 1
|
|
704
|
+
for bundle_index, bundle in enumerate(selected_bundles):
|
|
705
|
+
if len(assigned) >= limit:
|
|
706
|
+
break
|
|
707
|
+
worker_id, next_worker_index = _next_worker_id(
|
|
708
|
+
worker_prefix, worker_ids, next_worker_index,
|
|
709
|
+
)
|
|
710
|
+
res_keys = bundle_res_keys[bundle_index]
|
|
711
|
+
lease_secs = 300.0
|
|
712
|
+
try:
|
|
713
|
+
from core.supervisor import task_scheduler
|
|
714
|
+
lease_secs = float(task_scheduler.ComplexityLeaseCalculator.estimate_lease(bundle))
|
|
715
|
+
except (ImportError, AttributeError):
|
|
716
|
+
lease_secs = 300.0
|
|
717
|
+
except Exception as exc:
|
|
718
|
+
print(f"! [worker_orchestrator] 估算任务包复杂度租约异常 ({bundle}): {exc}")
|
|
719
|
+
lease_secs = 300.0
|
|
720
|
+
|
|
721
|
+
try:
|
|
722
|
+
# 写权限声明(P2/P4):只有真正获得源文件写授权的轮次才声明 write_access=True。
|
|
723
|
+
# log-only / 只读审计轮次声明 False —— 这样同文件的多个只读 claim 可以并发
|
|
724
|
+
# (claim 层不再派生 file: 互斥键),这是同文件串行木桶的根治点;
|
|
725
|
+
# 未声明(None)时 claim 层按历史强互斥处理,绝不因为「没声明」放开写并发。
|
|
726
|
+
claim = supervisor.claim_worker(
|
|
727
|
+
worker_id, unit_ids=bundle, resource_keys=res_keys,
|
|
728
|
+
lease_seconds=lease_secs, allow_bundle=True,
|
|
729
|
+
write_access=write_access,
|
|
730
|
+
)
|
|
731
|
+
except audit_supervisor.ClaimRejected as exc:
|
|
732
|
+
print(f"! 跳过无法预占的任务包 {bundle}: {exc}")
|
|
733
|
+
continue
|
|
734
|
+
assigned.append(claim)
|
|
735
|
+
if not assigned:
|
|
736
|
+
print("✗ 没有成功预占可执行单元;请检查租约、资源冲突或目标漂移")
|
|
737
|
+
return 1
|
|
738
|
+
if scheduler is not None:
|
|
739
|
+
# 守卫(F-RSI-20261112-077):调度器装配失败时 scheduler=None 且
|
|
740
|
+
# ``sched`` 未定义——旧代码靠裸 ``except Exception`` 吞 NameError,
|
|
741
|
+
# 提速路径静默失效不可观测。显式守卫后该分支语义自明。
|
|
742
|
+
try:
|
|
743
|
+
# DOC-140 调度提速:复用它上面已经建好的调度器实例(行 555),
|
|
744
|
+
# 不再第二次构造——每次构造都要全仓建图 + 影响网络 + git diff;
|
|
745
|
+
# 并把整批 advance_cycle 包进 batch_history,只落盘一次。
|
|
746
|
+
with sched.batch_history():
|
|
747
|
+
for c in assigned:
|
|
748
|
+
for cu in c.unit_ids:
|
|
749
|
+
sched.advance_cycle(selected_unit_id=cu, candidate_units=candidates)
|
|
750
|
+
except Exception:
|
|
751
|
+
pass
|
|
752
|
+
try:
|
|
753
|
+
supervisor_state = supervisor_state_path()
|
|
754
|
+
state_display = str(supervisor_state.resolve().relative_to(resolve_project_root().resolve()))
|
|
755
|
+
except (OSError, ValueError):
|
|
756
|
+
state_display = str(supervisor_state_path())
|
|
757
|
+
total_assigned_units = sum(len(c.unit_ids) for c in assigned)
|
|
758
|
+
active_count = len(state.active_claims)
|
|
759
|
+
if active_count > 0:
|
|
760
|
+
print(
|
|
761
|
+
f"[流水线动态补位] 已有活跃 Worker: {active_count} 个,本次填补并发槽位: {len(assigned)} 个;"
|
|
762
|
+
f"剩余未申领单元: {max(0, len(candidates) - total_assigned_units)} 个。"
|
|
763
|
+
)
|
|
764
|
+
print(
|
|
765
|
+
f"可领取单元 {len(candidates)} 个;已原子预占本批 {len(assigned)} 个 worker "
|
|
766
|
+
f"(含 {total_assigned_units} 个单元,requested={requested_limit},"
|
|
767
|
+
f"capacity={capacity},预算 max_concurrency={state.budget.max_concurrency},"
|
|
768
|
+
f"ceiling={state.budget.max_concurrency_ceiling})。"
|
|
769
|
+
)
|
|
770
|
+
if serial_worker_host and not is_process_mode:
|
|
771
|
+
print(f"执行纪律:{host_label} 主会话按序完成唯一 claim,通过 worker MCP 提交 checkpoint 后再继续;")
|
|
772
|
+
print(f" {host_label} 研究子 Agent 不承接 BugX claim,不调用 Task(subagent_type=bugx-worker)。")
|
|
773
|
+
elif is_process_mode:
|
|
774
|
+
sandbox = str(host_worker_facts.get("sandbox_dir") or "") if host_worker_facts else ""
|
|
775
|
+
sandbox_note = f"独立 {sandbox} 沙箱" if sandbox else "独立 Worker 沙箱"
|
|
776
|
+
print(f"执行纪律:每个 claim 在独立 {host_label} CLI 进程与{sandbox_note}中运行;")
|
|
777
|
+
print(" 仅允许 bugx-supervisor-worker 与 bugx-docs MCP,不加载主控 bugx-supervisor。")
|
|
778
|
+
else:
|
|
779
|
+
print("执行纪律:所有 worker 在同一时间窗口并发发起(Task 并行调用);")
|
|
780
|
+
print(" Supervisor 门禁要求同一 Life 至少 2 个 worker 真实重叠;")
|
|
781
|
+
print(" 只有 1 个可执行单元时才允许单 worker(串行需 --allow-serial + 理由)。")
|
|
782
|
+
print(" Worker 必须使用 claim 返回的独立 artifact_root;不得把产物写入共享根目录。")
|
|
783
|
+
if host_autonomous:
|
|
784
|
+
if serial_worker_host and not is_process_mode:
|
|
785
|
+
print(
|
|
786
|
+
f"AUTONOMOUS_HOST_NEXT: 当前 {host_label} 主会话必须执行以上唯一 claim,"
|
|
787
|
+
"通过 worker MCP 完成并验证 checkpoint 后再运行 workers --count 1;"
|
|
788
|
+
"全部单元处理完成后串行处理 confirmed Finding 并调用 post。禁止等待用户确认。"
|
|
789
|
+
)
|
|
790
|
+
elif is_process_mode:
|
|
791
|
+
print(
|
|
792
|
+
f"AUTONOMOUS_HOST_NEXT: {host_label} CLI 进程池已进入滑动窗口;"
|
|
793
|
+
"每个进程必须以持久化 Checkpoint 结束,异常/超时由 Supervisor 回收 claim。"
|
|
794
|
+
)
|
|
795
|
+
else:
|
|
796
|
+
print(
|
|
797
|
+
"AUTONOMOUS_HOST_NEXT: 宿主采用滑动窗口流水线(Sliding Window Pipeline)与错峰防限流模式!\n"
|
|
798
|
+
" 1. 错峰启动:并发启动 Task 时,每个 Task 之间交错 1.5~3.0 秒(或每批 2~3 个分批放行),严禁瞬间同时突发打满上游模型 API;\n"
|
|
799
|
+
" 2. 滑动补位:每当有任意一个 Worker 完成并提交 Checkpoint,若仍有待覆盖单元,立即重新调用 `bugx engine --root . workers` 补位并启动新 Task,"
|
|
800
|
+
"将并发度平滑维持在上限(绝不等待同批长尾任务)。所有单元覆盖完毕后,串行处理 confirmed Finding,"
|
|
801
|
+
"最后调用 post。禁止等待用户确认。"
|
|
802
|
+
)
|
|
803
|
+
state_rel = state_display
|
|
804
|
+
header = "【共享指令】把下面这段粘进每个 worker 的 Task 提示词:"
|
|
805
|
+
if i18n is not None:
|
|
806
|
+
header = i18n.prompt_text("workers.shared_instruction_header", fallback=header)
|
|
807
|
+
print(header)
|
|
808
|
+
print("```text")
|
|
809
|
+
body_fallback = (
|
|
810
|
+
"你是 BugX 并发 worker。宿主已经原子预占了下面给你的 coverage unit(s);不要再次 claim。\n"
|
|
811
|
+
"1. 先确认真实启动(返回的 execution_id 必须保持不变;只能逐字复制预占值,无法确认时省略,禁止生成/替换):\n"
|
|
812
|
+
" python3 \"$(bugx engine path --name audit_supervisor.py)\" worker-start --root . \\\n"
|
|
813
|
+
f" --state {state_rel} --worker <预占 worker_id> --provider <provider>\n"
|
|
814
|
+
"2. 对分配单元完成勘察 → 测试 → 证据复验;所有证据写入预占 claim 返回的 artifact_root;"
|
|
815
|
+
"每个 coverage unit 使用独立、唯一的 artifact 文件,提交 checkpoint 后不得覆盖或修改。\n"
|
|
816
|
+
" 【严禁全量测试】:Worker 仅对分配单元执行最小单测验证(python3 -m unittest tests.test_x),绝对严禁运行全量测试套件(如 run_tests.sh 或 unittest discover)!\n"
|
|
817
|
+
" 【黑盒测试与变异验证】:针对输入解析/并发竞态/状态机单元,优先使用 Worker MCP 专属工具(bugx_fuzz_input / bugx_fuzz_concurrency / bugx_fuzz_stateful)进行变异探测;疑似漏洞提交前必须经 bugx_verify_differential_poc 差分沙盒双跑证实;\n"
|
|
818
|
+
" 没有宿主提供的独立 git worktree 时禁止修改共享源码,修复由宿主串行完成;\n"
|
|
819
|
+
" 不写共享运行态、不写 life、不跑 verify_life.py settle、不生成最终报告。\n"
|
|
820
|
+
"3. 提交 checkpoint(JSON 中 life_delta 必须是数字 0,不能写成字符串 \"0\";artifact_path 必须位于自己的 artifact_root):\n"
|
|
821
|
+
" python3 \"$(bugx engine path --name audit_supervisor.py)\" checkpoint --root . \\\n"
|
|
822
|
+
f" --state {state_rel} --worker <预占 worker_id> --input <payload.json>\n"
|
|
823
|
+
" payload.json 必须包含本次提交唯一且可重试的 checkpoint_id,覆盖所有领取的 units。\n"
|
|
824
|
+
" expected_revision 只有在同一 MCP 响应刚返回该值时才能原样带上;否则省略,禁止猜测 0/1。\n"
|
|
825
|
+
" evidence 的 command/exit_code/status/artifact_sha256 必须来自真实执行;"
|
|
826
|
+
"coverage 状态和 evidence.status 是两套不同枚举:coverage=covered 时 evidence.status=passed,"
|
|
827
|
+
"其他 evidence.status 只能是 failed/error/skipped/blocked,不能把 covered 填进 evidence.status;"
|
|
828
|
+
"每个 candidate finding 内的 evidence 必须是对象数组 [{\"path\": \"<相对路径>\", \"line\": <正整数行号>}],"
|
|
829
|
+
"禁止写成 \"path:line\" 字符串;"
|
|
830
|
+
"artifact_path 必须是"
|
|
831
|
+
"从仓库根开始且位于该 claim artifact_root 下的路径(例如 <artifact_root>/evidence.json),"
|
|
832
|
+
"timestamp 必须是 time.time() 返回的正数 Unix 秒数;run_id、round_no、lease_id、worker_id、"
|
|
833
|
+
"target_fingerprint 必须逐字复制宿主给出的 WORKER_CLAIM_FACTS,禁止自行推导。\n"
|
|
834
|
+
"推荐使用下面的受约束收尾器生成并提交 payload;命令返回非零前不得结束 Task:\n"
|
|
835
|
+
" python3 \"$(bugx engine path --name worker_checkpoint.py)\" finalize --root ."
|
|
836
|
+
f" --state {state_rel} --worker <预占 worker_id>"
|
|
837
|
+
" --status <covered|unverified|partial|blocked>"
|
|
838
|
+
" --artifact <artifact_root/证据文件> --command '<真实验证命令>'"
|
|
839
|
+
" --exit-code <真实退出码> --note '<本次处置事实>'\n"
|
|
840
|
+
" 没有可提交的真实证据时,省略 --artifact 并使用 unverified/partial/blocked;"
|
|
841
|
+
"禁止用收尾器伪造 covered。\n"
|
|
842
|
+
"4. worker-start 本身已被引擎记录为首次心跳(不要单独立即再跳一次,省一个回合);"
|
|
843
|
+
"此后每 ≤5 分钟无新工具调用时才补一次心跳;"
|
|
844
|
+
"长命令(预计 >60s 的探针/测试)开始前调用 MCP bugx_supervisor_begin_long_call "
|
|
845
|
+
f"(expected_seconds≤1800,声明保活窗口,防止租约在命令执行中被回收);"
|
|
846
|
+
"若宿主没有 MCP,\n"
|
|
847
|
+
" 改用 `python3 \"$(bugx engine path --name audit_supervisor.py)\" heartbeat --root . "
|
|
848
|
+
f"--state {state_rel} --worker <预占 worker_id>`;卡住由宿主回收租约。\n"
|
|
849
|
+
" 不要把普通 claim 当成真实执行,也不要调用 launch_bugx.py heartbeat。\n"
|
|
850
|
+
"4a. checkpoint 被拒(run_id/execution_receipt/跨纪元证据)时不要盲目重跑探针:"
|
|
851
|
+
"把探针输出重写到 artifact_root 下的新文件,再用步骤 3 的收尾器"
|
|
852
|
+
"(worker_checkpoint.py finalize)按当前纪元重建合规 checkpoint。"
|
|
853
|
+
)
|
|
854
|
+
if i18n is not None:
|
|
855
|
+
body = i18n.prompt_text("workers.shared_instruction_body", fallback=body_fallback, state_rel=state_rel)
|
|
856
|
+
else:
|
|
857
|
+
body = body_fallback
|
|
858
|
+
body += (
|
|
859
|
+
"\n\n【REAL_ACP_WORKER_MCP_GATE】当前任务由宿主 ACP 启动,安装回执已声明"
|
|
860
|
+
" bugx-supervisor-worker 可用。worker-start、tool_call、heartbeat 和 checkpoint"
|
|
861
|
+
" 必须通过受控协议通道驱动(caller_role=worker):优先直接调用 `bugx-supervisor-worker_*`"
|
|
862
|
+
" MCP 工具;若宿主会话确实未暴露 Worker MCP,允许使用 stdio JSON-RPC 直驱"
|
|
863
|
+
"(`python3 -m core.bugx_mcp_server --role worker`)作为完全等效的控制通道,"
|
|
864
|
+
"不能运行未经协议校验的脚本旁路这些控制操作。"
|
|
865
|
+
"只有当前工具列表无 Worker MCP 且无法通过 stdio 连接服务时才报告 BLOCKED/RECOVERY_REQUIRED。"
|
|
866
|
+
"完成最后一次源码/测试工具调用后,下一步必须立即调用 checkpoint;"
|
|
867
|
+
"不要只输出‘正在提交’或在没有 checkpoint 调用的情况下结束 Task。"
|
|
868
|
+
)
|
|
869
|
+
body += (
|
|
870
|
+
"\n5. 在最终 findings.json 中,若本次实际使用了工具,填写去重后的 `tools` 字符串数组(最多 8 个);"
|
|
871
|
+
"未使用工具则省略该字段。"
|
|
872
|
+
"\n6. 若历史卡片确实适用于当前 finding,在最终 finding 中填写对应 `pattern_id`;不适用不要填写。"
|
|
873
|
+
"\n7. 验证深度由任务包声明:deep 执行完整反事实复核,standard 执行标准复现,triage 只做初筛;"
|
|
874
|
+
"triage 发现必须在 notes 中用单独一行精确标记 `upgrade_tier=deep`,不得把标记嵌入解释句,也不得直接写 confirmed。"
|
|
875
|
+
"\n8. 任务中的机器先验只是待核实线索;按需调用 bugx_knowledge_route/lesson_retrieve,"
|
|
876
|
+
"需要时调用 bugx_oracle_suggest/bugx_harness_status;记录命中、miss 或权限失败,"
|
|
877
|
+
"不把历史卡片正文复制进提示词。triage 档默认跳过知识检索(除非任务文本给出了"
|
|
878
|
+
"具体错误签名),省下的回合用于真实审查。"
|
|
879
|
+
"\n9. 回合预算:triage 总工具调用 ≤6、standard ≤12、deep ≤20(读文件不计入);"
|
|
880
|
+
"达到预算立即提交 checkpoint 如实汇报现状,禁止继续展开。"
|
|
881
|
+
"\n10. **reproduction 必须是可直接执行的命令**,不能把命令和说明拼在一起。"
|
|
882
|
+
"实测踩过:`python3 p.py records the request (no network); u.json shows a=b`"
|
|
883
|
+
" 满足「非空」但跑不起来(bash 语法错误),会被摄入侧判 "
|
|
884
|
+
"`reproduction_not_executable` 直接拒收。说明写进 root_cause,不要粘在命令行里。"
|
|
885
|
+
"\n11. **candidate 不等于完成**。finding 要转 confirmed 必须带 `confirmation` 块:"
|
|
886
|
+
"同指纹 ≥2 次独立运行(两个**不同** channel)+ negative_control outcome=pass + "
|
|
887
|
+
"root_cause_verified + target_execution(target_platform 与 executed_platform 逐字相同)。"
|
|
888
|
+
"只产出 candidate 不转 confirmed,整轮会停在 `finding_confirmation_pending` 并判 BLOCKED"
|
|
889
|
+
"(实测 OctoPrintMCP:4 条高质量 finding 因此全部作废)。"
|
|
890
|
+
"若确实无法完成确认,显式置 `reproducible: false` 并说明原因——"
|
|
891
|
+
"不要留下 reproducible=true 却没有 confirmation 的半成品。"
|
|
892
|
+
)
|
|
893
|
+
lesson_guidance = _lesson_guidance()
|
|
894
|
+
if lesson_guidance:
|
|
895
|
+
body += f"\n\n{lesson_guidance}"
|
|
896
|
+
# DOC-141:每单元上下文优先用定向装配(符号摘要 + 攻击面 + 规则 ID,
|
|
897
|
+
# ~200 字符),通用先验包(~1,100 字符)降级为后备。定向上下文信息
|
|
898
|
+
# 密度更高且 token 更省——同一预算下可覆盖更多单元;完整先验包仍落盘
|
|
899
|
+
# 于 .bugx/state/priors/,worker 可按需自读。
|
|
900
|
+
# DOC-142:定向上下文覆盖包内**每一个**单元。原实现只构 unit_ids[0]
|
|
901
|
+
# ——一个 3 单元亲和包里 2 个单元拿不到任何定向上下文,打包在这里不是
|
|
902
|
+
# 节省 token,而是静默的覆盖回退。
|
|
903
|
+
prior_by_unit: dict[str, str] = {}
|
|
904
|
+
for claim in assigned:
|
|
905
|
+
for unit in claim.unit_ids:
|
|
906
|
+
try:
|
|
907
|
+
# 无论是否使用定向上下文,均可靠预构建机器先验并落盘 .bugx/state/priors/
|
|
908
|
+
# 满足「完整先验包仍落盘于 .bugx/state/priors/,worker 可按需自读」契约
|
|
909
|
+
prior_payload = _build_unit_prior(unit)
|
|
910
|
+
targeted = _targeted_unit_context(
|
|
911
|
+
unit, tier=tier_by_unit.get(unit),
|
|
912
|
+
)
|
|
913
|
+
if targeted:
|
|
914
|
+
# 提取已发现的经验反模式与历史变异种子,以紧凑行形式直接增益定向上下文
|
|
915
|
+
extra_guidance = []
|
|
916
|
+
for item in prior_payload.get("items", []):
|
|
917
|
+
if not isinstance(item, dict):
|
|
918
|
+
continue
|
|
919
|
+
source = item.get("source")
|
|
920
|
+
if source == "evolved_lessons" and item.get("items"):
|
|
921
|
+
for l in item["items"][:2]:
|
|
922
|
+
pid = l.get("pattern_id") or ""
|
|
923
|
+
title = l.get("title") or ""
|
|
924
|
+
summary = l.get("summary") or ""
|
|
925
|
+
desc = f": {summary[:60]}" if summary else ""
|
|
926
|
+
extra_guidance.append(f"- 经验反模式提示:[{pid}] {title}{desc}")
|
|
927
|
+
elif source == "mutation_seeds" and item.get("items"):
|
|
928
|
+
for s in item["items"][:2]:
|
|
929
|
+
iid = s.get("incident_id") or ""
|
|
930
|
+
oracle = s.get("repro_oracle") or ""
|
|
931
|
+
sig = s.get("signature") or ""
|
|
932
|
+
extra_guidance.append(f"- 历史错题变异种子:[{iid}] {sig} (复现参考: {oracle[:80]})")
|
|
933
|
+
# DOC-242: 注入专属 MCP 黑盒工具推荐与场景化调用指引
|
|
934
|
+
tool_hints = _recommend_blackbox_tools(
|
|
935
|
+
unit, targeted_ctx=targeted, tier=tier_by_unit.get(unit),
|
|
936
|
+
)
|
|
937
|
+
if tool_hints:
|
|
938
|
+
extra_guidance.extend(tool_hints)
|
|
939
|
+
prior_text = f"【定向上下文】{targeted}"
|
|
940
|
+
if extra_guidance:
|
|
941
|
+
prior_text += "\n" + "\n".join(extra_guidance)
|
|
942
|
+
prior_by_unit[unit] = prior_text
|
|
943
|
+
else:
|
|
944
|
+
rendered = _render_unit_prior(prior_payload)
|
|
945
|
+
tool_hints = _recommend_blackbox_tools(
|
|
946
|
+
unit, tier=tier_by_unit.get(unit),
|
|
947
|
+
)
|
|
948
|
+
if tool_hints:
|
|
949
|
+
rendered += "\n" + "\n".join(tool_hints)
|
|
950
|
+
prior_by_unit[unit] = rendered
|
|
951
|
+
except Exception as exc: # noqa: BLE001 - prior generation must never block dispatch
|
|
952
|
+
prior_by_unit[unit] = f"【机器先验】degraded: {str(exc)[:160]}(继续标准流程)"
|
|
953
|
+
print(body)
|
|
954
|
+
print("```")
|
|
955
|
+
# DOC-212 设计项 6:项目约定块在主围栏**之外**独立打印——不进 i18n body、
|
|
956
|
+
# 不触碰宿主侧打印,conventions.json 缺失/损坏/消毒后为空时零输出。
|
|
957
|
+
conventions_text = _conventions_block(resolve_project_root())
|
|
958
|
+
if conventions_text:
|
|
959
|
+
print(conventions_text)
|
|
960
|
+
print("完整执行规则见全局引擎 bugx-worker.md(可用 bugx engine path --name bugx-worker.md 定位)。")
|
|
961
|
+
# DOC-140 调度提速:一轮内不变量外提出 per-claim 循环——
|
|
962
|
+
# ① 阶段栅栏判定按 consumes 签名记忆化(原为 claims×stages 次
|
|
963
|
+
# registry.json 全量读);② 攻击图只加载一次(原为每 claim 一次
|
|
964
|
+
# JSON 解析 + from_dict)。
|
|
965
|
+
expected_run_id = state.run_id if isinstance(state.run_id, str) else None
|
|
966
|
+
barrier_probe = _barrier_probe(resolve_project_root(), expected_run_id=expected_run_id)
|
|
967
|
+
preloaded_attack_graph = None
|
|
968
|
+
try:
|
|
969
|
+
from core.autonomous_cve import attack_graph_store
|
|
970
|
+
preloaded_attack_graph = attack_graph_store.load_graph(resolve_project_root())
|
|
971
|
+
except Exception:
|
|
972
|
+
preloaded_attack_graph = None
|
|
973
|
+
|
|
974
|
+
# DOC-140 调度提速:执行阶段从"串行 for"改为"有界并行"。
|
|
975
|
+
# 预占阶段已按容量算出 limit(claims 数),但原实现把所有 claim 排成
|
|
976
|
+
# 单线程队列逐个执行——并发门禁的 peak≥2 只靠 claim 时间戳重叠"被
|
|
977
|
+
# 满足",真实吞吐等于 1。这里保留逐 claim 的任务包装配(依赖打印顺
|
|
978
|
+
# 序与人类可读日志),把重量级的模型执行段并行化。
|
|
979
|
+
parallel_jobs: list[dict[str, Any]] = []
|
|
980
|
+
|
|
981
|
+
for index, claim in enumerate(assigned, 1):
|
|
982
|
+
units_str = ", ".join(claim.unit_ids)
|
|
983
|
+
unit_args = " ".join(f'--unit "{u}"' for u in claim.unit_ids)
|
|
984
|
+
if not brief:
|
|
985
|
+
print("-" * 56)
|
|
986
|
+
print(f"[{index}/{len(assigned)}] {claim.worker_id} → {units_str}")
|
|
987
|
+
bundle_tiers = [
|
|
988
|
+
tier_by_unit.get(u, "standard") for u in claim.unit_ids
|
|
989
|
+
]
|
|
990
|
+
if brief:
|
|
991
|
+
print(json.dumps({
|
|
992
|
+
"worker_id": claim.worker_id,
|
|
993
|
+
"unit_ids": list(claim.unit_ids),
|
|
994
|
+
"lease_id": claim.lease_id,
|
|
995
|
+
"execution_id": claim.execution_id,
|
|
996
|
+
"artifact_root": claim.artifact_root,
|
|
997
|
+
"attempt": claim.attempt,
|
|
998
|
+
}, ensure_ascii=False, sort_keys=True))
|
|
999
|
+
else:
|
|
1000
|
+
print(
|
|
1001
|
+
f"预占 claim:lease_id={claim.lease_id} lease_seconds={claim.lease_seconds:.0f}s "
|
|
1002
|
+
f"execution_id={claim.execution_id} artifact_root={claim.artifact_root} attempt={claim.attempt} "
|
|
1003
|
+
f"tier={'/'.join(bundle_tiers)}"
|
|
1004
|
+
)
|
|
1005
|
+
tier = tier_by_unit.get(claim.unit_ids[0], "standard")
|
|
1006
|
+
knowledge_category, knowledge_query = _knowledge_route_hint(claim.unit_ids[0])
|
|
1007
|
+
unit_prior_context = "\n".join(
|
|
1008
|
+
context
|
|
1009
|
+
for unit in claim.unit_ids
|
|
1010
|
+
if (context := prior_by_unit.get(unit))
|
|
1011
|
+
)
|
|
1012
|
+
claim_facts = (
|
|
1013
|
+
"【WORKER_CLAIM_FACTS:不可改写、不可省略】\n"
|
|
1014
|
+
f"worker_id={claim.worker_id}\n"
|
|
1015
|
+
f"unit_ids={json.dumps(list(claim.unit_ids), ensure_ascii=False)}\n"
|
|
1016
|
+
f"run_id={state.run_id}\n"
|
|
1017
|
+
f"round_no={claim.round_no}\n"
|
|
1018
|
+
f"lease_id={claim.lease_id}\n"
|
|
1019
|
+
f"execution_id={claim.execution_id}\n"
|
|
1020
|
+
f"artifact_root={claim.artifact_root}\n"
|
|
1021
|
+
f"target_fingerprint={state.target_fingerprint}\n"
|
|
1022
|
+
f"state_path={state_rel}\n"
|
|
1023
|
+
"evidence.timestamp 使用 time.time() 的正数 Unix 秒数;artifact_path 使用"
|
|
1024
|
+
"artifact_root/文件名(相对仓库根);artifact_sha256 必须是该文件的 SHA-256。\n"
|
|
1025
|
+
"【执行动作协议(必须严格按此顺序)】:\n"
|
|
1026
|
+
f"① 必须首先调用 MCP 工具 `bugx_supervisor_worker_start(caller_role=\"worker\", worker_id=\"{claim.worker_id}\")` 登记真实开工(严禁省略!严禁传入 process_pid!未调用 worker_start 直接 checkpoint 会被门禁以 -32602 硬拦截并判死);\n"
|
|
1027
|
+
"② 在受控边界内执行当前单元的分析、探查与命令验证;\n"
|
|
1028
|
+
f"③ 完成后必须调用 MCP 工具 `bugx_supervisor_checkpoint` 提交证据(caller_role=\"worker\", worker_id=\"{claim.worker_id}\", checkpoint_id=\"chk-{claim.worker_id}-001\",coverage key 必须逐字来自 unit_ids;省略 expected_revision 防止并发冲突;无法完全验证时提交 coverage=unverified 并填写 notes,此时才免 execution_receipt;coverage=covered 一律必须携带 execution_receipt,契约见下节,禁止以「无需回执」为理由省略)。\n"
|
|
1029
|
+
"【执行回执契约】:coverage=covered / evidence.status=passed 的证据必须额外携带"
|
|
1030
|
+
" execution_receipt(schema_version=1,字段 execution_id、worker_id、lease_id、"
|
|
1031
|
+
"command、exit_code、artifact_path、artifact_sha256、status 必须与本条 evidence 逐字一致,"
|
|
1032
|
+
"禁止多加字段)。自建 payload 漏掉它会被 checkpoint 以 -32602「必须绑定受信 worker "
|
|
1033
|
+
"execution receipt」拒绝——这不是权限问题,而是缺回执。最稳妥:用 "
|
|
1034
|
+
"`python3 \"$(bugx engine path --name worker_checkpoint.py)\" finalize --root . "
|
|
1035
|
+
f"--state {state_rel} --worker {claim.worker_id} --status <covered|unverified|partial|blocked> "
|
|
1036
|
+
"--artifact <artifact_root/证据文件> --command '<真实验证命令>' --exit-code <真实退出码> "
|
|
1037
|
+
"--note '<本次处置事实>'` 生成并提交(它按 claim 回填回执);非 covered 状态不需要回执。\n"
|
|
1038
|
+
"【活性与进程契约】:Task 子代理无常驻 OS 子进程,worker_start 时严禁传入 process_pid"
|
|
1039
|
+
"(省略该字段,仅依靠 heartbeat 与租约期限保活);传入瞬态 Shell PID 会在退出后被直接判死抢占。\n"
|
|
1040
|
+
"coverage/evidence/notes 的 key 只能逐字来自上述 unit_ids;notes 只写单元手记,"
|
|
1041
|
+
"禁止 summary/finding/knowledge 等自由 key。\n"
|
|
1042
|
+
"只使用上述预占身份;不要重新 claim、生成新 ID、猜测字段、猜测 artifact 路径或把任务转交给别的 Worker。"
|
|
1043
|
+
)
|
|
1044
|
+
autonomous_completion = (
|
|
1045
|
+
"【AUTONOMOUS_COMPLETION_BARRIER】\n"
|
|
1046
|
+
"这是无人值守回合:worker-start 成功后立即做覆盖优先的有限探查。首个 worker 工具调用后,"
|
|
1047
|
+
f"最多再执行 {AUTONOMOUS_MAX_EXTRA_TOOL_CALLS} 次工具调用或 "
|
|
1048
|
+
f"{AUTONOMOUS_MAX_EXTRA_SECONDS} 秒,以先到者为准;读取技能、文档、源码和等待 MCP 都计入边界。"
|
|
1049
|
+
"不得继续无边界读码或等待宿主。边界到达时必须写入自己的"
|
|
1050
|
+
"artifact_root 并调用 bugx_supervisor_checkpoint:真实验证通过才提交 coverage=covered +"
|
|
1051
|
+
"结构化 passed evidence;无法在本边界完成则提交 coverage=unverified/partial/blocked 和"
|
|
1052
|
+
"notes(key 只能是本任务 unit_ids)说明已验证事实与重试原因,不能使用 summary/finding/knowledge"
|
|
1053
|
+
"等自由 key,不能空等、伪造 covered 或把半成品当 Finding。没有 Finding"
|
|
1054
|
+
"时也必须提交 checkpoint;checkpoint 成功后再返回宿主。候选 Finding 必须自带可裁决的复现原料:"
|
|
1055
|
+
"file、target_code(失败代码锚点)、poc_cmd、poc_input(失败输入)与 poc_negative_input"
|
|
1056
|
+
"(同命令良性输入);缺原料的候选写进 notes 说明缺什么,不要当 Finding 提交。宿主侧差分验证"
|
|
1057
|
+
"负责完成确定性双跑与负对照复验,提交后每条候选都会被裁决到 confirmed/rejected 终态,"
|
|
1058
|
+
"不会永久挂起阻塞结算。"
|
|
1059
|
+
)
|
|
1060
|
+
task_spec = (
|
|
1061
|
+
f'{claim_facts}\n{autonomous_completion}\n'
|
|
1062
|
+
f'共享指令 + `--worker {claim.worker_id} {unit_args}` 原样交给宿主并发执行;'
|
|
1063
|
+
f'本任务验证深度={tier}:{_VERIFICATION_TIER_INSTRUCTIONS[tier]}\n'
|
|
1064
|
+
f'知识检索建议:category={knowledge_category} query={knowledge_query}'
|
|
1065
|
+
f';命中时填写 pattern_id,miss/权限失败照实记录。\n{unit_prior_context}'
|
|
1066
|
+
)
|
|
1067
|
+
if i18n is not None:
|
|
1068
|
+
task_spec = i18n.prompt_text(
|
|
1069
|
+
"workers.task_spec",
|
|
1070
|
+
fallback=task_spec,
|
|
1071
|
+
worker_id=claim.worker_id,
|
|
1072
|
+
unit_args=unit_args,
|
|
1073
|
+
)
|
|
1074
|
+
# Locale templates are intentionally allowed to replace the prose
|
|
1075
|
+
# task wrapper, but autonomous identity and completion barriers are
|
|
1076
|
+
# protocol data, not translatable copy. Re-attach them after the
|
|
1077
|
+
# locale render so a host cannot lose them through i18n fallback.
|
|
1078
|
+
if host_autonomous:
|
|
1079
|
+
if "WORKER_CLAIM_FACTS" not in task_spec:
|
|
1080
|
+
task_spec = f"{claim_facts}\n{task_spec}"
|
|
1081
|
+
if "AUTONOMOUS_COMPLETION_BARRIER" not in task_spec:
|
|
1082
|
+
task_spec = f"{autonomous_completion}\n{task_spec}"
|
|
1083
|
+
if f"验证深度={tier}" not in task_spec:
|
|
1084
|
+
task_spec += f" 本任务验证深度={tier}:{_VERIFICATION_TIER_INSTRUCTIONS[tier]}"
|
|
1085
|
+
prior_block = unit_prior_context
|
|
1086
|
+
if prior_block and prior_block not in task_spec:
|
|
1087
|
+
task_spec += f"\n知识检索建议:category={knowledge_category} query={knowledge_query};命中时填写 pattern_id,miss/权限失败照实记录。\n{prior_block}"
|
|
1088
|
+
if not brief:
|
|
1089
|
+
if serial_worker_host:
|
|
1090
|
+
sandbox = str(host_worker_facts.get("sandbox_dir") or "") if host_worker_facts else ""
|
|
1091
|
+
label = (
|
|
1092
|
+
f"{host_label} CLI 进程执行(独立 {sandbox or 'Worker'} 沙箱)"
|
|
1093
|
+
if is_process_mode
|
|
1094
|
+
else f"{host_label} 主会话串行执行(无 Task 子 Agent handoff)"
|
|
1095
|
+
)
|
|
1096
|
+
else:
|
|
1097
|
+
label = f'Task(subagent_type="{worker_subagent_type(selected_subagent_type)}")'
|
|
1098
|
+
print(f"{label}:{task_spec}")
|
|
1099
|
+
if not serial_worker_host:
|
|
1100
|
+
print(
|
|
1101
|
+
" [派发提示] 两条等效路径,按宿主形态择快:"
|
|
1102
|
+
"①宿主会话自身暴露 bugx-supervisor-worker_* MCP 工具时,可直接以 "
|
|
1103
|
+
"caller_role=worker 直驱协议通道(worker-start→探针→checkpoint,"
|
|
1104
|
+
"单单元小任务包显著更快);②被派代理类型没有这些 MCP 工具时,"
|
|
1105
|
+
"改派具备 MCP 的通用类型(如 general-purpose)重发同一提示词。"
|
|
1106
|
+
"两条路径都必须走受控协议(MCP 或 stdio JSON-RPC 均可),"
|
|
1107
|
+
"禁止未受控脚本旁路;可在当前会话 runtime context 中指定类型。"
|
|
1108
|
+
)
|
|
1109
|
+
# Harness 的完整装饰文本以前只打印前 6 行而不进入 task_spec,付出
|
|
1110
|
+
# AST/规则/预算计算却不产生实际审计收益。Worker 通过 bugx-worker.md
|
|
1111
|
+
# 按需读取阶段协议;这里只保留轻量 stage 标签,避免无效冷路径。
|
|
1112
|
+
stage_name = "explore"
|
|
1113
|
+
print(" [主动注入 Stage Harness 任务包]: stage=explore (按需读取)")
|
|
1114
|
+
|
|
1115
|
+
is_standalone_exec = effective_execute
|
|
1116
|
+
should_execute = is_standalone_exec and (
|
|
1117
|
+
not host_autonomous
|
|
1118
|
+
or not native_task_host
|
|
1119
|
+
)
|
|
1120
|
+
if should_execute:
|
|
1121
|
+
print(f" [自治驱动] 已装配 Autonomous Worker 任务包: {claim.worker_id}")
|
|
1122
|
+
parallel_jobs.append({
|
|
1123
|
+
"claim": claim,
|
|
1124
|
+
"task_spec": task_spec,
|
|
1125
|
+
"stage_name": stage_name,
|
|
1126
|
+
"model": model,
|
|
1127
|
+
"provider": provider,
|
|
1128
|
+
"executable": executable,
|
|
1129
|
+
})
|
|
1130
|
+
|
|
1131
|
+
if not parallel_jobs:
|
|
1132
|
+
return 0
|
|
1133
|
+
|
|
1134
|
+
# 有界并行执行:默认并发度 = 本批 claim 数(即预占阶段按容量算出的
|
|
1135
|
+
# limit),可由显式 max_workers 或 runtime worker_capacity 收紧。单个 worker 的失败不
|
|
1136
|
+
# 影响同批其他 worker;结果按装配顺序汇总,保证日志确定性。
|
|
1137
|
+
runtime_capacity = runtime.get("worker_capacity")
|
|
1138
|
+
if runtime_capacity is None:
|
|
1139
|
+
runtime_capacity = runtime.get("workers")
|
|
1140
|
+
selected_capacity = max_workers if max_workers is not None else runtime_capacity
|
|
1141
|
+
if selected_capacity is not None and (
|
|
1142
|
+
not isinstance(selected_capacity, int)
|
|
1143
|
+
or isinstance(selected_capacity, bool)
|
|
1144
|
+
or selected_capacity <= 0
|
|
1145
|
+
):
|
|
1146
|
+
print("✗ max_workers/worker_capacity 必须是正整数")
|
|
1147
|
+
return 2
|
|
1148
|
+
# 并发上限 = **多源约束取最小值**(系统资源 / 宿主容量 / provider 配额 / 请求值 /
|
|
1149
|
+
# 待办数)。任何单源决定都会越界:机器只扛 2 路时接口给 10 没用,宿主只支持 5
|
|
1150
|
+
# 时机器给 10 也只能跑 5。测算逻辑见 ``core/capacity_planner.py``,这里只消费裁决。
|
|
1151
|
+
capacity_decision = _resolve_pool_capacity(
|
|
1152
|
+
host=selected_host, provider=provider,
|
|
1153
|
+
requested=selected_capacity, pending=len(parallel_jobs),
|
|
1154
|
+
)
|
|
1155
|
+
pool_workers = int(capacity_decision["value"])
|
|
1156
|
+
if capacity_decision.get("binding") not in {"pending", "requested", None}:
|
|
1157
|
+
print(
|
|
1158
|
+
f" [容量裁决] 并发 {pool_workers}(最弱环节 {capacity_decision['binding']};"
|
|
1159
|
+
f"约束 {capacity_decision['constraints']})"
|
|
1160
|
+
)
|
|
1161
|
+
|
|
1162
|
+
# DOC-193: 派发侧错峰抗限流延迟来自显式参数或当前 runtime context。
|
|
1163
|
+
stagger_value = (
|
|
1164
|
+
stagger_seconds if stagger_seconds is not None
|
|
1165
|
+
else runtime.get("stagger_seconds", 0.0)
|
|
1166
|
+
)
|
|
1167
|
+
try:
|
|
1168
|
+
stagger_secs = float(stagger_value)
|
|
1169
|
+
except (TypeError, ValueError):
|
|
1170
|
+
print("✗ stagger_seconds 必须是非负有限数")
|
|
1171
|
+
return 2
|
|
1172
|
+
if not math.isfinite(stagger_secs) or stagger_secs < 0:
|
|
1173
|
+
print("✗ stagger_seconds 必须是非负有限数")
|
|
1174
|
+
return 2
|
|
1175
|
+
|
|
1176
|
+
def _run_job(job: dict[str, Any]) -> dict[str, Any]:
|
|
1177
|
+
from core.supervisor import worker_runtime
|
|
1178
|
+
claim = job["claim"]
|
|
1179
|
+
res = worker_runtime.execute_autonomous_worker(
|
|
1180
|
+
workspace_root=resolve_project_root(),
|
|
1181
|
+
claim=claim,
|
|
1182
|
+
task_spec=job["task_spec"],
|
|
1183
|
+
stage_name=job["stage_name"],
|
|
1184
|
+
model=job.get("model") or model,
|
|
1185
|
+
provider=job.get("provider") or provider,
|
|
1186
|
+
executable=job.get("executable") or executable,
|
|
1187
|
+
supervisor=supervisor,
|
|
1188
|
+
scheduler=sched,
|
|
1189
|
+
host=selected_host,
|
|
1190
|
+
max_workers=pool_workers,
|
|
1191
|
+
execute=effective_execute,
|
|
1192
|
+
)
|
|
1193
|
+
return {"worker_id": claim.worker_id, "result": res}
|
|
1194
|
+
|
|
1195
|
+
print(f" [自治驱动] 启动滑动窗口流水线执行 {len(parallel_jobs)} 个 Worker 任务(并发度 {pool_workers})...")
|
|
1196
|
+
outcomes: list[tuple[str, dict[str, Any] | None, str | None]] = []
|
|
1197
|
+
rate_limited_units: list[str] = []
|
|
1198
|
+
# 木桶修复(LPT 调度):把**预计最慢**的单元排到队首,让短单元在尾部填缝。
|
|
1199
|
+
# 固定并发下轮次墙钟 ≈ 最慢单元的收尾时间;把所有长单元堆在队尾会让它们
|
|
1200
|
+
# 串行收尾(经典 makespan 木桶)。LPT(Longest Processing Time first)对
|
|
1201
|
+
# makespan 有 ≤4/3·OPT 的界,且只需一个排序,不改并发度、不改账本语义。
|
|
1202
|
+
# 预计耗时优先用**单元级历史**,缺失时退回本批平均值,再缺失则保持原序(稳定)。
|
|
1203
|
+
job_queue = _order_jobs_longest_first(parallel_jobs, supervisor=supervisor)
|
|
1204
|
+
with ThreadPoolExecutor(max_workers=pool_workers, thread_name_prefix="bugx-worker") as pool:
|
|
1205
|
+
futures: dict[Any, dict[str, Any]] = {}
|
|
1206
|
+
# 初始填充并发窗口至 max_workers(带错峰延迟)
|
|
1207
|
+
while job_queue and len(futures) < pool_workers:
|
|
1208
|
+
job = job_queue.pop(0)
|
|
1209
|
+
if futures and stagger_secs > 0:
|
|
1210
|
+
time.sleep(stagger_secs)
|
|
1211
|
+
futures[pool.submit(_run_job, job)] = job
|
|
1212
|
+
|
|
1213
|
+
# 滑动窗口动态补位:任意任务完成立即结算并从队列补充新任务维持并发度
|
|
1214
|
+
while futures:
|
|
1215
|
+
# 等待最早完成的任意一个或多个任务
|
|
1216
|
+
done, _ = wait(list(futures.keys()), return_when=FIRST_COMPLETED)
|
|
1217
|
+
for future in done:
|
|
1218
|
+
job = futures.pop(future)
|
|
1219
|
+
worker_id = job["claim"].worker_id
|
|
1220
|
+
try:
|
|
1221
|
+
payload = future.result()
|
|
1222
|
+
outcomes.append((worker_id, payload["result"], None))
|
|
1223
|
+
print(f" ✓ Worker {worker_id} 完成并提交 Checkpoint: {payload['result'].get('checkpoint_id')}")
|
|
1224
|
+
except Exception as exec_err: # noqa: BLE001 - 单 worker 失败不拖垮同批
|
|
1225
|
+
err_text = str(exec_err)
|
|
1226
|
+
outcomes.append((worker_id, None, err_text))
|
|
1227
|
+
if _looks_rate_limited(err_text):
|
|
1228
|
+
rate_limited_units.extend(job["claim"].unit_ids)
|
|
1229
|
+
print(f" ✗ Worker {worker_id} 自治执行失败: {exec_err}")
|
|
1230
|
+
|
|
1231
|
+
# 流水线动态补位:只要队列中还有任务,立即补满并发窗口
|
|
1232
|
+
while job_queue and len(futures) < pool_workers:
|
|
1233
|
+
next_job = job_queue.pop(0)
|
|
1234
|
+
next_worker_id = next_job["claim"].worker_id
|
|
1235
|
+
if stagger_secs > 0:
|
|
1236
|
+
time.sleep(stagger_secs)
|
|
1237
|
+
print(f" [流水线补位] 动态发起新任务 Worker {next_worker_id} 维持并发度 {pool_workers}...")
|
|
1238
|
+
futures[pool.submit(_run_job, next_job)] = next_job
|
|
1239
|
+
|
|
1240
|
+
succeeded = sum(1 for _, _, err in outcomes if err is None)
|
|
1241
|
+
print(f" [自治驱动] 流水线完成 {succeeded}/{len(parallel_jobs)}")
|
|
1242
|
+
if rate_limited_units:
|
|
1243
|
+
# DOC-212 设计项 5:限流失败的结构化回传——只在此汇总行追加,
|
|
1244
|
+
# 不触碰 dry-run(schema_version:1)与 brief claim 两处 JSON 键集。
|
|
1245
|
+
print(" [自治驱动] " + _format_rate_limit_summary(rate_limited_units))
|
|
1246
|
+
return 0
|