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,1143 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Supervisor 数据模型、异常体系与状态契约定义 (DOC-036)。"""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import copy
|
|
8
|
+
from core.planning import unit_kind
|
|
9
|
+
import hashlib
|
|
10
|
+
import json
|
|
11
|
+
import math
|
|
12
|
+
import os
|
|
13
|
+
import re
|
|
14
|
+
import core.secure_atomic as secure_atomic
|
|
15
|
+
import socket
|
|
16
|
+
import subprocess
|
|
17
|
+
import sys
|
|
18
|
+
import time
|
|
19
|
+
from datetime import datetime, timezone
|
|
20
|
+
from dataclasses import dataclass, field
|
|
21
|
+
from enum import Enum
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from typing import Callable, Iterable, Mapping, Sequence
|
|
24
|
+
|
|
25
|
+
SCHEMA_VERSION = 2
|
|
26
|
+
DEFAULT_STATE_RELATIVE_PATH = Path(".bugx") / "state" / "supervisor.json"
|
|
27
|
+
LEGACY_STATE_RELATIVE_PATH = Path(".audit_supervisor") / "run-state.json"
|
|
28
|
+
FINDING_SEVERITY_ALIASES = {
|
|
29
|
+
"p0": "critical",
|
|
30
|
+
"p1": "high",
|
|
31
|
+
"p2": "medium",
|
|
32
|
+
"p3": "low",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def normalize_finding_severity(value: object) -> object:
|
|
37
|
+
"""Normalize common priority aliases to the confirmation schema levels."""
|
|
38
|
+
if not isinstance(value, str):
|
|
39
|
+
return value
|
|
40
|
+
normalized = value.strip().lower()
|
|
41
|
+
return FINDING_SEVERITY_ALIASES.get(normalized, normalized)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def finding_severity_levels() -> tuple[str, ...]:
|
|
45
|
+
"""finding 严重度词表的**唯一访问器**(BX-ENGINE-18 / DOC-230 §3.8 第 1 项)。
|
|
46
|
+
|
|
47
|
+
真源是 ``agent_eval.FINDING_SEVERITY_LEVELS``(由 ``SEVERITY_ORDER`` 派生)。
|
|
48
|
+
写侧归一化、MCP schema 的 ``enum``、修复通道的白名单**都从这里取**,避免
|
|
49
|
+
再次出现「schema 无 enum / 门禁有词表」的三源漂移。导入不可用时退回同一
|
|
50
|
+
集合的内联快照,保证引擎目录不完整时仍自洽(守卫测试比对两者一致)。
|
|
51
|
+
"""
|
|
52
|
+
try:
|
|
53
|
+
from core.agent import agent_eval
|
|
54
|
+
|
|
55
|
+
return tuple(agent_eval.FINDING_SEVERITY_LEVELS)
|
|
56
|
+
except (ImportError, AttributeError): # pragma: no cover - 引擎目录不完整时
|
|
57
|
+
return ("info", "low", "medium", "high", "critical")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
COVERAGE_PENDING = "pending"
|
|
61
|
+
COVERAGE_COVERED = "covered"
|
|
62
|
+
COVERAGE_BLOCKED = "blocked"
|
|
63
|
+
COVERAGE_UNVERIFIED = "unverified"
|
|
64
|
+
COVERAGE_PARTIAL = "partial"
|
|
65
|
+
COVERAGE_NOT_APPLICABLE = "not_applicable"
|
|
66
|
+
COVERAGE_STALE = "stale"
|
|
67
|
+
COVERAGE_REMOVED = "removed"
|
|
68
|
+
COVERAGE_SUPERSEDED = "superseded"
|
|
69
|
+
COVERAGE_CORRUPTED = "corrupted"
|
|
70
|
+
VALID_COVERAGE_STATES = {
|
|
71
|
+
COVERAGE_PENDING,
|
|
72
|
+
COVERAGE_COVERED,
|
|
73
|
+
COVERAGE_BLOCKED,
|
|
74
|
+
COVERAGE_UNVERIFIED,
|
|
75
|
+
COVERAGE_PARTIAL,
|
|
76
|
+
COVERAGE_NOT_APPLICABLE,
|
|
77
|
+
COVERAGE_STALE,
|
|
78
|
+
COVERAGE_REMOVED,
|
|
79
|
+
COVERAGE_SUPERSEDED,
|
|
80
|
+
COVERAGE_CORRUPTED,
|
|
81
|
+
}
|
|
82
|
+
# Evidence status is separate from coverage status: ``covered`` describes the
|
|
83
|
+
# unit, while ``passed`` describes the verification evidence.
|
|
84
|
+
VALID_EVIDENCE_STATES = {"passed", "failed", "error", "skipped", "blocked"}
|
|
85
|
+
# 覆盖债务分类:单元级债务(可重试/需资源/需证据) vs 全局阻塞
|
|
86
|
+
UNIT_LEVEL_DEBT = {COVERAGE_PENDING, COVERAGE_PARTIAL, COVERAGE_UNVERIFIED, COVERAGE_STALE, COVERAGE_BLOCKED}
|
|
87
|
+
GLOBAL_BLOCKED = {COVERAGE_CORRUPTED}
|
|
88
|
+
TERMINAL_COVERED = {COVERAGE_COVERED, COVERAGE_NOT_APPLICABLE, COVERAGE_REMOVED, COVERAGE_SUPERSEDED}
|
|
89
|
+
SHA256_RE = re.compile(r"^[0-9a-fA-F]{64}$")
|
|
90
|
+
# checkpoint 单次最多携带 10 个错误签名;状态里滚动保留最近 20 条。
|
|
91
|
+
MAX_SIGNATURES_PER_CHECKPOINT = 10
|
|
92
|
+
MAX_RECENT_SIGNATURES = 20
|
|
93
|
+
# Keep state reads bounded even when a long-running supervisor emits an event
|
|
94
|
+
# for every heartbeat/expiry. The hash-chain anchor below preserves audit
|
|
95
|
+
# continuity after old events are compacted.
|
|
96
|
+
MAX_HISTORY_EVENTS = 1000
|
|
97
|
+
MAX_SIGNATURE_LENGTH = 512
|
|
98
|
+
# unit-notes:每个覆盖单元保留最新一条手记,总量封顶防膨胀。
|
|
99
|
+
MAX_UNIT_NOTES = 200
|
|
100
|
+
MAX_UNIT_NOTE_LENGTH = 2000
|
|
101
|
+
|
|
102
|
+
GRAPH_GOALS = {"find_bugs", "repair_preview"}
|
|
103
|
+
GRAPH_STAGES = {"recon", "repro", "review", "patch", "check", "report"}
|
|
104
|
+
GRAPH_TASK_STATES = {
|
|
105
|
+
"queued", "reserved", "running", "artifact_ready", "submitted", "completed",
|
|
106
|
+
}
|
|
107
|
+
GRAPH_ASSESSMENTS = {"candidate", "confirmed", "rejected", "needs_context", "static_supported"}
|
|
108
|
+
GRAPH_EVIDENCE_LEVELS = {"source_review", "reproduced", "regression_verified"}
|
|
109
|
+
GRAPH_REMEDIATIONS = {
|
|
110
|
+
"not_requested", "proposed", "fix_verified", "fix_failed", "regression_incomplete",
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def unit_source_path(unit: object) -> str:
|
|
115
|
+
"""Extract only the source-file portion of a coverage unit identifier.
|
|
116
|
+
|
|
117
|
+
Coverage IDs may carry a kind prefix, an optional line number, and a
|
|
118
|
+
symbol (for example ``内部:12:core/foo.py::handler``). A symbol or a
|
|
119
|
+
finding ID is not a filesystem path and must never be manufactured as
|
|
120
|
+
evidence.
|
|
121
|
+
|
|
122
|
+
这里(``supervisor_models``)是唯一实现:claim 期的同文件互斥键派生与
|
|
123
|
+
checkpoint 期的证据路径回填都必须用同一套解析,否则两处会各自漂移。
|
|
124
|
+
"""
|
|
125
|
+
text = str(unit or "").strip()
|
|
126
|
+
if not text:
|
|
127
|
+
return ""
|
|
128
|
+
if "::" in text:
|
|
129
|
+
text = text.split("::", 1)[0]
|
|
130
|
+
parts = text.split(":", 2)
|
|
131
|
+
if len(parts) == 3 and parts[1].strip().isdigit():
|
|
132
|
+
text = parts[2]
|
|
133
|
+
elif len(parts) >= 2 and parts[0].strip() in {"内部", "业务"}:
|
|
134
|
+
text = parts[1]
|
|
135
|
+
return text.strip()
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _graph_strings(value: object, name: str) -> tuple[str, ...]:
|
|
139
|
+
if not isinstance(value, (list, tuple)):
|
|
140
|
+
raise PersistenceError(f"{name} 必须是数组")
|
|
141
|
+
if any(not isinstance(item, str) for item in value):
|
|
142
|
+
raise PersistenceError(f"{name} 必须只包含字符串")
|
|
143
|
+
result = tuple(str(item).strip() for item in value)
|
|
144
|
+
if any(not item for item in result) or len(set(result)) != len(result):
|
|
145
|
+
raise PersistenceError(f"{name} 不能为空或重复")
|
|
146
|
+
return result
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _graph_digest(value: object, name: str, *, optional: bool = False) -> str | None:
|
|
150
|
+
if optional and value is None:
|
|
151
|
+
return None
|
|
152
|
+
if not isinstance(value, str) or not SHA256_RE.fullmatch(value):
|
|
153
|
+
raise PersistenceError(f"{name} 必须是 SHA-256")
|
|
154
|
+
return value.lower()
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
from core.supervisor_types.exceptions import (
|
|
158
|
+
SupervisorError,
|
|
159
|
+
NoRunError,
|
|
160
|
+
RunAlreadyStarted,
|
|
161
|
+
InvalidTransition,
|
|
162
|
+
BudgetExhausted,
|
|
163
|
+
ClaimRejected,
|
|
164
|
+
LeaseExpired,
|
|
165
|
+
RevisionConflict,
|
|
166
|
+
InvalidCheckpoint,
|
|
167
|
+
PersistenceError,
|
|
168
|
+
WorkspacePathError,
|
|
169
|
+
ConcurrencyNotSatisfied,
|
|
170
|
+
)
|
|
171
|
+
from core.supervisor_types.path_containment import (
|
|
172
|
+
confined_path,
|
|
173
|
+
has_lexical_symlink,
|
|
174
|
+
confined_regular_file,
|
|
175
|
+
worker_artifact_root,
|
|
176
|
+
confined_worker_artifact,
|
|
177
|
+
atomic_write_bytes,
|
|
178
|
+
)
|
|
179
|
+
import core.supervisor_types.target_fingerprint as _st_tf
|
|
180
|
+
import core.supervisor_types.graph_models as _st_gm
|
|
181
|
+
|
|
182
|
+
_boot_time_token = _st_tf._boot_time_token
|
|
183
|
+
_process_start_timestamp = _st_tf._process_start_timestamp
|
|
184
|
+
_manifest_units_blob = _st_tf._manifest_units_blob
|
|
185
|
+
_git_ref_token = _st_tf._git_ref_token
|
|
186
|
+
_git_head_cached = _st_tf._git_head_cached
|
|
187
|
+
|
|
188
|
+
_graph_strings = _st_gm._graph_strings
|
|
189
|
+
_graph_digest = _st_gm._graph_digest
|
|
190
|
+
from core.supervisor_types.target_fingerprint import (
|
|
191
|
+
MAX_JSON_DEPTH,
|
|
192
|
+
MAX_JSON_KEYS,
|
|
193
|
+
MAX_PROCESS_START_TOKEN_LENGTH,
|
|
194
|
+
canonical_json,
|
|
195
|
+
process_start_token,
|
|
196
|
+
default_coverage_manifest,
|
|
197
|
+
invalidate_git_head_cache,
|
|
198
|
+
target_identity,
|
|
199
|
+
workspace_fingerprint,
|
|
200
|
+
fingerprint_for_units,
|
|
201
|
+
git_target_fingerprint,
|
|
202
|
+
finite_number,
|
|
203
|
+
check_depth_and_keys,
|
|
204
|
+
)
|
|
205
|
+
from core.supervisor_types.graph_models import (
|
|
206
|
+
GRAPH_GOALS,
|
|
207
|
+
GRAPH_STAGES,
|
|
208
|
+
GRAPH_TASK_STATES,
|
|
209
|
+
GRAPH_ASSESSMENTS,
|
|
210
|
+
GRAPH_EVIDENCE_LEVELS,
|
|
211
|
+
GRAPH_REMEDIATIONS,
|
|
212
|
+
GraphTask,
|
|
213
|
+
AgentBinding,
|
|
214
|
+
BugRecord,
|
|
215
|
+
GraphRun,
|
|
216
|
+
)
|
|
217
|
+
from core.supervisor_types.worker_claim import (
|
|
218
|
+
WorkerClaim,
|
|
219
|
+
)
|
|
220
|
+
def note_requests_deep_verification(note: object) -> bool:
|
|
221
|
+
"""Recognize the explicit triage-upgrade sentinel, never prose mentions."""
|
|
222
|
+
return isinstance(note, str) and any(
|
|
223
|
+
line.strip().casefold() == "upgrade_tier=deep"
|
|
224
|
+
for line in note.splitlines()
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
# ── Worker checkpoint 容量与字段长度上限(MCP 与引擎一致,fail-closed) ──
|
|
229
|
+
MAX_FINDINGS_PER_CHECKPOINT = 50
|
|
230
|
+
MAX_COVERAGE_PER_CHECKPOINT = 5 # DOC-044 支持亲和任务包,单个 Worker 每次最多 5 个覆盖单元
|
|
231
|
+
MAX_EVIDENCE_PER_CHECKPOINT = 5
|
|
232
|
+
MAX_UNITS_PER_CLAIM = 5
|
|
233
|
+
MAX_COMMAND_LENGTH = 8192
|
|
234
|
+
MAX_ARTIFACT_PATH_LENGTH = 1024
|
|
235
|
+
MAX_FINDING_FINGERPRINT_LENGTH = 256
|
|
236
|
+
MAX_FINDING_FIELD_LENGTH = 4096
|
|
237
|
+
MAX_JSON_DEPTH = 32
|
|
238
|
+
MAX_JSON_KEYS = 5000
|
|
239
|
+
# checkpoint artifact 先 stat 后流式哈希:超过 8MB 直接拒绝,防止 Worker
|
|
240
|
+
# 用超大 artifact 把 Supervisor 内存打爆(P2-2)。
|
|
241
|
+
MAX_ARTIFACT_BYTES = 8 * 1024 * 1024
|
|
242
|
+
ARTIFACT_HASH_CHUNK_BYTES = 8 * 1024
|
|
243
|
+
# worker lease 上限 1 小时(LOG-06)。此处必须与两处声明逐字一致:
|
|
244
|
+
# * ``core/bugx_mcp_server.py`` 的 ``lease_seconds.inputSchema.maximum``;
|
|
245
|
+
# * ``core/task_scheduler.py`` 的租约时长推算上限。
|
|
246
|
+
# 历史漂移:本常量曾是 14400(4 小时)而注释写「1 小时」,schema 与推算器
|
|
247
|
+
# 都是 3600;绕过 inputSchema 校验的调用方因此能拿到 4 倍于防护目标的租约,
|
|
248
|
+
# 长期占用并发额度并与 max_round_wall_seconds 的轮次预算脱节。
|
|
249
|
+
MAX_LEASE_SECONDS = 3600
|
|
250
|
+
# 租约总时长乘数:单 claim 的寿命上限 = 初始租约 × (DEFAULT_MAX_RENEWALS + 1)。
|
|
251
|
+
# 它**不再**表示「续租次数上限」——续租次数只做审计计数,寿命只由
|
|
252
|
+
# ``total_lease_deadline`` 决定,故寿命与心跳节奏无关。
|
|
253
|
+
DEFAULT_MAX_RENEWALS = 10
|
|
254
|
+
MAX_WORKER_ATTEMPTS = 3
|
|
255
|
+
# DOC-205 S2: 全 Run 跨代际累计尝试上限,防止多轮次死循环永远重试无望单元
|
|
256
|
+
MAX_RUN_WORKER_ATTEMPTS = 6
|
|
257
|
+
# DOC-203 D3:worker 单次长调用声明的上限(秒)。inputSchema.maximum
|
|
258
|
+
# (core/bugx_mcp_server.py)与 lease_manager 的推进公式必须共用本常量,
|
|
259
|
+
# 避免重现 MAX_LEASE_SECONDS 的历史漂移(见上方注释)。
|
|
260
|
+
MAX_LONG_CALL_SECONDS = 1800
|
|
261
|
+
# DOC-204 L1:同 (operation, gate) 组合每 run 的 lifecycle_blocked 上限。
|
|
262
|
+
MAX_LIFECYCLE_BLOCKED_PER_GATE = 50
|
|
263
|
+
# DOC-203 D3:每个 claim 允许的长调用声明次数上限;总占用仍受
|
|
264
|
+
# total_lease_deadline 与 run 级 max_wall_seconds 双重封顶。
|
|
265
|
+
MAX_LONG_CALLS_PER_CLAIM = 5
|
|
266
|
+
# A hostname may legally be longer than the historical 256-byte token limit.
|
|
267
|
+
# Keep the persisted fingerprint bounded while leaving room for all four
|
|
268
|
+
# identity fields.
|
|
269
|
+
MAX_PROCESS_START_TOKEN_LENGTH = 1024
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def worker_attempts_exhausted(state: object, unit_id: str) -> bool:
|
|
273
|
+
"""Return whether a unit has used all retryable worker attempts.
|
|
274
|
+
|
|
275
|
+
Attempts belong to the current scheduler epoch. A target rebind or
|
|
276
|
+
explicit state recovery fences the old claims, so their retry history
|
|
277
|
+
must not consume the new target generation's budget. The newest claim
|
|
278
|
+
for the unit is authoritative: an active attempt is still allowed to
|
|
279
|
+
finish, ``superseded`` is only a historical marker, and a submitted
|
|
280
|
+
attempt exhausts the unit only when the unit is still non-terminal.
|
|
281
|
+
Bundle claims are evaluated per unit through the shared coverage map.
|
|
282
|
+
|
|
283
|
+
DOC-205 S2: 若跨代际累计已尝试达 MAX_RUN_WORKER_ATTEMPTS 且未终态,
|
|
284
|
+
作为全 Run 级硬顶判定熔断,防止跨轮死循环。
|
|
285
|
+
"""
|
|
286
|
+
coverage = getattr(state, "coverage", {}) or {}
|
|
287
|
+
if coverage.get(unit_id) in TERMINAL_COVERED:
|
|
288
|
+
return False
|
|
289
|
+
|
|
290
|
+
claims = getattr(state, "claims", {}) or {}
|
|
291
|
+
# 全 Run 累计已终结尝试计数(不包含仍在 active 的进行中尝试与 superseded 标记)
|
|
292
|
+
total_non_active_attempts = sum(
|
|
293
|
+
1
|
|
294
|
+
for claim in claims.values()
|
|
295
|
+
if unit_id in getattr(claim, "unit_ids", ())
|
|
296
|
+
and getattr(claim, "state", "") in {"expired", "released", "submitted"}
|
|
297
|
+
and not getattr(claim, "fenced_from_attempts", False)
|
|
298
|
+
)
|
|
299
|
+
if total_non_active_attempts >= MAX_RUN_WORKER_ATTEMPTS:
|
|
300
|
+
return True
|
|
301
|
+
|
|
302
|
+
current_epoch = getattr(state, "scheduler_epoch", None)
|
|
303
|
+
latest_claim = None
|
|
304
|
+
latest_key: tuple[int, float, str] | None = None
|
|
305
|
+
for claim in claims.values():
|
|
306
|
+
if unit_id not in getattr(claim, "unit_ids", ()):
|
|
307
|
+
continue
|
|
308
|
+
claim_epoch = getattr(claim, "scheduler_epoch", current_epoch)
|
|
309
|
+
if current_epoch is not None and claim_epoch != current_epoch:
|
|
310
|
+
continue
|
|
311
|
+
attempt = int(getattr(claim, "attempt", 0))
|
|
312
|
+
claimed_at = getattr(claim, "claimed_at", 0.0)
|
|
313
|
+
if not isinstance(claimed_at, (int, float)):
|
|
314
|
+
claimed_at = 0.0
|
|
315
|
+
key = (attempt, float(claimed_at), str(getattr(claim, "worker_id", "")))
|
|
316
|
+
if latest_key is None or key > latest_key:
|
|
317
|
+
latest_key = key
|
|
318
|
+
latest_claim = claim
|
|
319
|
+
|
|
320
|
+
if latest_claim is None or latest_key is None:
|
|
321
|
+
return False
|
|
322
|
+
if latest_key[0] < MAX_WORKER_ATTEMPTS:
|
|
323
|
+
return False
|
|
324
|
+
claim_state = getattr(latest_claim, "state", "")
|
|
325
|
+
if claim_state in {"expired", "released"}:
|
|
326
|
+
return True
|
|
327
|
+
if claim_state == "submitted":
|
|
328
|
+
return coverage.get(unit_id) not in TERMINAL_COVERED
|
|
329
|
+
# In particular, an active third attempt is allowed to finish and a
|
|
330
|
+
# superseded claim does not independently consume the current generation.
|
|
331
|
+
return False
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
class Status(str, Enum):
|
|
335
|
+
"""Supervisor 对外暴露的明确状态。"""
|
|
336
|
+
|
|
337
|
+
RUNNING = "RUNNING"
|
|
338
|
+
CHECKPOINT = "CHECKPOINT"
|
|
339
|
+
NEXT_ROUND = "NEXT_ROUND"
|
|
340
|
+
STALLED = "STALLED"
|
|
341
|
+
INCOMPLETE = "INCOMPLETE"
|
|
342
|
+
COMPLETE = "COMPLETE"
|
|
343
|
+
BUDGET_EXHAUSTED = "BUDGET_EXHAUSTED"
|
|
344
|
+
FAILED = "FAILED"
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def resolve_system_concurrency() -> tuple[int, int]:
|
|
350
|
+
"""根据系统硬件(CPU 核心数)、系统配置与环境变量解析 (max_concurrency, max_concurrency_ceiling)。"""
|
|
351
|
+
# 1. 环境变量显式覆盖
|
|
352
|
+
env_max = os.environ.get("BUGX_MAX_CONCURRENCY") or os.environ.get("BUGX_WORKERS_MAX")
|
|
353
|
+
env_ceiling = os.environ.get("BUGX_MAX_CONCURRENCY_CEILING")
|
|
354
|
+
|
|
355
|
+
# 2. 系统配置文件覆盖(若存在 ~/.bugx/config.json 或 cloud-config.json)
|
|
356
|
+
cfg_max: int | None = None
|
|
357
|
+
cfg_ceiling: int | None = None
|
|
358
|
+
try:
|
|
359
|
+
cfg_paths = [
|
|
360
|
+
Path.home() / ".bugx" / "config.json",
|
|
361
|
+
Path.home() / ".bugx" / "cloud-config.json",
|
|
362
|
+
]
|
|
363
|
+
for cfg_p in cfg_paths:
|
|
364
|
+
if cfg_p.is_file():
|
|
365
|
+
cfg_data = json.loads(cfg_p.read_text(encoding="utf-8"))
|
|
366
|
+
if isinstance(cfg_data, dict):
|
|
367
|
+
if "max_concurrency" in cfg_data and isinstance(cfg_data["max_concurrency"], (int, float)):
|
|
368
|
+
cfg_max = int(cfg_data["max_concurrency"])
|
|
369
|
+
elif "max_workers" in cfg_data and isinstance(cfg_data["max_workers"], (int, float)):
|
|
370
|
+
cfg_max = int(cfg_data["max_workers"])
|
|
371
|
+
if "max_concurrency_ceiling" in cfg_data and isinstance(cfg_data["max_concurrency_ceiling"], (int, float)):
|
|
372
|
+
cfg_ceiling = int(cfg_data["max_concurrency_ceiling"])
|
|
373
|
+
if cfg_max is not None:
|
|
374
|
+
break
|
|
375
|
+
except Exception:
|
|
376
|
+
pass
|
|
377
|
+
|
|
378
|
+
# 3. 硬件拓扑自适应决策
|
|
379
|
+
cores = os.cpu_count() or 4
|
|
380
|
+
if cores <= 2:
|
|
381
|
+
base_concurrency = 2
|
|
382
|
+
base_ceiling = 4
|
|
383
|
+
elif cores <= 4:
|
|
384
|
+
base_concurrency = cores
|
|
385
|
+
base_ceiling = 8
|
|
386
|
+
elif cores <= 8:
|
|
387
|
+
base_concurrency = cores
|
|
388
|
+
base_ceiling = max(12, cores * 2)
|
|
389
|
+
else:
|
|
390
|
+
# 逻辑核数就是默认可承载上限;不再把大机器截断到 16/32。
|
|
391
|
+
base_concurrency = cores
|
|
392
|
+
base_ceiling = cores * 2
|
|
393
|
+
|
|
394
|
+
final_concurrency = cfg_max if (cfg_max is not None and cfg_max >= 1) else base_concurrency
|
|
395
|
+
final_ceiling = cfg_ceiling if (cfg_ceiling is not None and cfg_ceiling >= final_concurrency) else base_ceiling
|
|
396
|
+
|
|
397
|
+
if env_max and env_max.strip().isdigit() and int(env_max.strip()) >= 1:
|
|
398
|
+
final_concurrency = int(env_max.strip())
|
|
399
|
+
final_ceiling = max(final_ceiling, final_concurrency)
|
|
400
|
+
if env_ceiling and env_ceiling.strip().isdigit() and int(env_ceiling.strip()) >= final_concurrency:
|
|
401
|
+
final_ceiling = int(env_ceiling.strip())
|
|
402
|
+
|
|
403
|
+
return final_concurrency, max(final_concurrency, final_ceiling)
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
def _default_max_concurrency() -> int:
|
|
407
|
+
return resolve_system_concurrency()[0]
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def _default_max_concurrency_ceiling() -> int:
|
|
411
|
+
return resolve_system_concurrency()[1]
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
@dataclass(frozen=True)
|
|
415
|
+
class RunBudget:
|
|
416
|
+
"""独立于 life 的 run 预算。
|
|
417
|
+
|
|
418
|
+
``max_rounds`` 是 run 内的绝对轮次上限;``max_wall_seconds`` 是整个
|
|
419
|
+
run 的不可续期硬上限;``max_round_wall_seconds``、``max_tool_calls``
|
|
420
|
+
和 ``max_cost_units`` 按 budget epoch 计算。reset_budget 会保留审计
|
|
421
|
+
历史并开启新 epoch,但不能扩大或重启全局墙钟。
|
|
422
|
+
"""
|
|
423
|
+
|
|
424
|
+
max_rounds: int = 25
|
|
425
|
+
max_wall_seconds: float = 14400.0
|
|
426
|
+
max_round_wall_seconds: float = 1800.0
|
|
427
|
+
max_tool_calls: int = 1000
|
|
428
|
+
max_cost_units: float = 10000.0
|
|
429
|
+
max_concurrency: int = field(default_factory=_default_max_concurrency)
|
|
430
|
+
require_parallel: bool = True
|
|
431
|
+
serial_reason: str | None = None
|
|
432
|
+
# Generic callers may opt in; BugX's host integrations enable this by
|
|
433
|
+
# default so an unverified finding cannot close an audit run.
|
|
434
|
+
require_confirmation: bool = False
|
|
435
|
+
adaptive_concurrency: bool = True
|
|
436
|
+
min_concurrency: int = 2
|
|
437
|
+
max_concurrency_ceiling: int = field(default_factory=_default_max_concurrency_ceiling)
|
|
438
|
+
|
|
439
|
+
@classmethod
|
|
440
|
+
def calculate_adaptive_round_budget(
|
|
441
|
+
cls,
|
|
442
|
+
pending_units_count: int,
|
|
443
|
+
concurrency: int = 4,
|
|
444
|
+
unit_baseline_seconds: float = 60.0,
|
|
445
|
+
) -> float:
|
|
446
|
+
"""根据待测单元与并发度自适应推算单轮墙钟预算 (DOC-196)。"""
|
|
447
|
+
batches = max(1, math.ceil(max(1, pending_units_count) / max(1, concurrency)))
|
|
448
|
+
raw = batches * unit_baseline_seconds
|
|
449
|
+
return float(max(600.0, min(7200.0, raw)))
|
|
450
|
+
|
|
451
|
+
def __post_init__(self) -> None:
|
|
452
|
+
if self.max_concurrency is None:
|
|
453
|
+
object.__setattr__(self, "max_concurrency", _default_max_concurrency())
|
|
454
|
+
if self.max_concurrency_ceiling is None:
|
|
455
|
+
object.__setattr__(
|
|
456
|
+
self, "max_concurrency_ceiling",
|
|
457
|
+
max(self.max_concurrency, _default_max_concurrency_ceiling()),
|
|
458
|
+
)
|
|
459
|
+
rounds = finite_number(self.max_rounds, "max_rounds", integer=True)
|
|
460
|
+
calls = finite_number(self.max_tool_calls, "max_tool_calls", integer=True)
|
|
461
|
+
concurrency = finite_number(
|
|
462
|
+
self.max_concurrency, "max_concurrency", integer=True,
|
|
463
|
+
)
|
|
464
|
+
wall = finite_number(self.max_wall_seconds, "max_wall_seconds")
|
|
465
|
+
round_wall = finite_number(
|
|
466
|
+
self.max_round_wall_seconds, "max_round_wall_seconds",
|
|
467
|
+
)
|
|
468
|
+
cost = finite_number(self.max_cost_units, "max_cost_units")
|
|
469
|
+
if rounds < 1:
|
|
470
|
+
raise ValueError("max_rounds 必须 >= 1")
|
|
471
|
+
if calls < 0:
|
|
472
|
+
raise ValueError("max_tool_calls 必须 >= 0")
|
|
473
|
+
if concurrency < 1:
|
|
474
|
+
raise ValueError("max_concurrency 必须 >= 1")
|
|
475
|
+
if wall <= 0 or round_wall <= 0:
|
|
476
|
+
raise ValueError("wall budget 必须 > 0")
|
|
477
|
+
if cost < 0:
|
|
478
|
+
raise ValueError("max_cost_units 必须 >= 0")
|
|
479
|
+
if not isinstance(self.require_parallel, bool):
|
|
480
|
+
raise ValueError("require_parallel 必须是布尔值")
|
|
481
|
+
if not isinstance(self.require_confirmation, bool):
|
|
482
|
+
raise ValueError("require_confirmation 必须是布尔值")
|
|
483
|
+
if not isinstance(self.adaptive_concurrency, bool):
|
|
484
|
+
raise ValueError("adaptive_concurrency 必须是布尔值")
|
|
485
|
+
min_c = finite_number(self.min_concurrency, "min_concurrency", integer=True)
|
|
486
|
+
max_c = finite_number(self.max_concurrency_ceiling, "max_concurrency_ceiling", integer=True)
|
|
487
|
+
if min_c < 1:
|
|
488
|
+
raise ValueError("min_concurrency 必须 >= 1")
|
|
489
|
+
if max_c < concurrency:
|
|
490
|
+
raise ValueError("max_concurrency_ceiling 必须 >= max_concurrency")
|
|
491
|
+
if not self.require_parallel:
|
|
492
|
+
if not isinstance(self.serial_reason, str) or not self.serial_reason.strip():
|
|
493
|
+
raise ValueError("允许串行时必须提供 serial_reason")
|
|
494
|
+
elif self.serial_reason is not None and not isinstance(self.serial_reason, str):
|
|
495
|
+
raise ValueError("serial_reason 必须是字符串或 null")
|
|
496
|
+
|
|
497
|
+
def to_dict(self) -> dict[str, int | float | bool | str | None]:
|
|
498
|
+
return {
|
|
499
|
+
"max_rounds": self.max_rounds,
|
|
500
|
+
"max_wall_seconds": self.max_wall_seconds,
|
|
501
|
+
"max_round_wall_seconds": self.max_round_wall_seconds,
|
|
502
|
+
"max_tool_calls": self.max_tool_calls,
|
|
503
|
+
"max_cost_units": self.max_cost_units,
|
|
504
|
+
"max_concurrency": self.max_concurrency,
|
|
505
|
+
"require_parallel": self.require_parallel,
|
|
506
|
+
"serial_reason": self.serial_reason,
|
|
507
|
+
"require_confirmation": self.require_confirmation,
|
|
508
|
+
"adaptive_concurrency": self.adaptive_concurrency,
|
|
509
|
+
"min_concurrency": self.min_concurrency,
|
|
510
|
+
"max_concurrency_ceiling": self.max_concurrency_ceiling,
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
@classmethod
|
|
514
|
+
def from_dict(cls, value: Mapping[str, object]) -> "RunBudget":
|
|
515
|
+
required = {
|
|
516
|
+
"max_rounds", "max_wall_seconds", "max_round_wall_seconds",
|
|
517
|
+
"max_tool_calls", "max_cost_units",
|
|
518
|
+
}
|
|
519
|
+
missing = required - set(value)
|
|
520
|
+
if missing:
|
|
521
|
+
raise PersistenceError(f"budget 缺字段: {sorted(missing)}")
|
|
522
|
+
try:
|
|
523
|
+
require_parallel = value.get("require_parallel", True)
|
|
524
|
+
serial_reason = value.get("serial_reason")
|
|
525
|
+
require_confirmation = value.get("require_confirmation", False)
|
|
526
|
+
adaptive_concurrency = value.get("adaptive_concurrency", True)
|
|
527
|
+
min_concurrency = value.get("min_concurrency", 2)
|
|
528
|
+
max_c_val = value.get("max_concurrency")
|
|
529
|
+
max_concurrency = int(max_c_val) if max_c_val is not None else _default_max_concurrency()
|
|
530
|
+
max_ceiling_val = value.get("max_concurrency_ceiling")
|
|
531
|
+
max_concurrency_ceiling = (
|
|
532
|
+
int(max_ceiling_val) if max_ceiling_val is not None
|
|
533
|
+
else max(max_concurrency, _default_max_concurrency_ceiling())
|
|
534
|
+
)
|
|
535
|
+
if not isinstance(require_parallel, bool):
|
|
536
|
+
raise ValueError("require_parallel 必须是布尔值")
|
|
537
|
+
if serial_reason is not None and not isinstance(serial_reason, str):
|
|
538
|
+
raise ValueError("serial_reason 必须是字符串或 null")
|
|
539
|
+
if not isinstance(require_confirmation, bool):
|
|
540
|
+
raise ValueError("require_confirmation 必须是布尔值")
|
|
541
|
+
if not isinstance(adaptive_concurrency, bool):
|
|
542
|
+
raise ValueError("adaptive_concurrency 必须是布尔值")
|
|
543
|
+
return cls(
|
|
544
|
+
max_rounds=int(value["max_rounds"]),
|
|
545
|
+
max_wall_seconds=float(value["max_wall_seconds"]),
|
|
546
|
+
max_round_wall_seconds=float(value["max_round_wall_seconds"]),
|
|
547
|
+
max_tool_calls=int(value["max_tool_calls"]),
|
|
548
|
+
max_cost_units=float(value["max_cost_units"]),
|
|
549
|
+
max_concurrency=max_concurrency,
|
|
550
|
+
require_parallel=require_parallel,
|
|
551
|
+
serial_reason=serial_reason,
|
|
552
|
+
require_confirmation=require_confirmation,
|
|
553
|
+
adaptive_concurrency=adaptive_concurrency,
|
|
554
|
+
min_concurrency=int(min_concurrency),
|
|
555
|
+
max_concurrency_ceiling=max_concurrency_ceiling,
|
|
556
|
+
)
|
|
557
|
+
except (TypeError, ValueError) as exc:
|
|
558
|
+
raise PersistenceError(f"budget 无效: {exc}") from exc
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
def load_unit_notes(value: object) -> dict[str, dict[str, object]]:
|
|
562
|
+
"""从持久化状态恢复 unit-notes;无效条目静默丢弃(不阻断恢复)。"""
|
|
563
|
+
if not isinstance(value, Mapping):
|
|
564
|
+
return {}
|
|
565
|
+
notes: dict[str, dict[str, object]] = {}
|
|
566
|
+
for unit_id, item in value.items():
|
|
567
|
+
if not isinstance(unit_id, str) or not isinstance(item, Mapping):
|
|
568
|
+
continue
|
|
569
|
+
note = item.get("note")
|
|
570
|
+
if not isinstance(note, str) or not note.strip():
|
|
571
|
+
continue
|
|
572
|
+
notes[unit_id] = {
|
|
573
|
+
"worker_id": str(item.get("worker_id", "unknown")),
|
|
574
|
+
"note": note,
|
|
575
|
+
"at": item.get("at", 0.0),
|
|
576
|
+
}
|
|
577
|
+
return dict(list(notes.items())[-MAX_UNIT_NOTES:])
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
@dataclass
|
|
581
|
+
class SchedulingMetrics:
|
|
582
|
+
"""调度层全链路性能度量与遥测快照 (DOC-044)。"""
|
|
583
|
+
|
|
584
|
+
total_claims: int = 0
|
|
585
|
+
total_completed: int = 0
|
|
586
|
+
total_preempted: int = 0
|
|
587
|
+
total_expired: int = 0
|
|
588
|
+
total_queue_seconds: float = 0.0
|
|
589
|
+
total_execution_seconds: float = 0.0
|
|
590
|
+
max_queue_seconds: float = 0.0
|
|
591
|
+
max_execution_seconds: float = 0.0
|
|
592
|
+
|
|
593
|
+
def to_dict(self) -> dict[str, Any]:
|
|
594
|
+
avg_q = self.total_queue_seconds / max(1, self.total_claims)
|
|
595
|
+
avg_e = self.total_execution_seconds / max(1, self.total_completed)
|
|
596
|
+
return {
|
|
597
|
+
"total_claims": self.total_claims,
|
|
598
|
+
"total_completed": self.total_completed,
|
|
599
|
+
"total_preempted": self.total_preempted,
|
|
600
|
+
"total_expired": self.total_expired,
|
|
601
|
+
"total_queue_seconds": round(self.total_queue_seconds, 3),
|
|
602
|
+
"total_execution_seconds": round(self.total_execution_seconds, 3),
|
|
603
|
+
"max_queue_seconds": round(self.max_queue_seconds, 3),
|
|
604
|
+
"max_execution_seconds": round(self.max_execution_seconds, 3),
|
|
605
|
+
"avg_queue_seconds": round(avg_q, 3),
|
|
606
|
+
"avg_execution_seconds": round(avg_e, 3),
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
@classmethod
|
|
610
|
+
def from_dict(cls, value: Mapping[str, Any] | None) -> "SchedulingMetrics":
|
|
611
|
+
if not isinstance(value, Mapping):
|
|
612
|
+
return cls()
|
|
613
|
+
return cls(
|
|
614
|
+
total_claims=int(value.get("total_claims", 0)),
|
|
615
|
+
total_completed=int(value.get("total_completed", 0)),
|
|
616
|
+
total_preempted=int(value.get("total_preempted", 0)),
|
|
617
|
+
total_expired=int(value.get("total_expired", 0)),
|
|
618
|
+
total_queue_seconds=float(value.get("total_queue_seconds", 0.0)),
|
|
619
|
+
total_execution_seconds=float(value.get("total_execution_seconds", 0.0)),
|
|
620
|
+
max_queue_seconds=float(value.get("max_queue_seconds", 0.0)),
|
|
621
|
+
max_execution_seconds=float(value.get("max_execution_seconds", 0.0)),
|
|
622
|
+
)
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
@dataclass
|
|
626
|
+
class RunState:
|
|
627
|
+
"""可持久化的 Supervisor 状态快照。"""
|
|
628
|
+
|
|
629
|
+
run_id: str
|
|
630
|
+
status: Status
|
|
631
|
+
round_no: int
|
|
632
|
+
life_score: float
|
|
633
|
+
budget: RunBudget
|
|
634
|
+
started_at: float
|
|
635
|
+
budget_started_at: float
|
|
636
|
+
round_started_at: float
|
|
637
|
+
# D3:墙钟高水位——本 run 已观测到的最晚墙钟时刻。预算判定用
|
|
638
|
+
# ``max(now, clock_high_water)`` 作为有效 now,使「已计时长」的记账
|
|
639
|
+
# 只增不减:系统时钟回拨不得把已耗掉的墙钟预算还回来(不得续命)。
|
|
640
|
+
clock_high_water: float = 0.0
|
|
641
|
+
life_kind: str = "mine"
|
|
642
|
+
budget_epoch: int = 0
|
|
643
|
+
scheduler_epoch: int = 0
|
|
644
|
+
tool_calls: int = 0
|
|
645
|
+
budget_tool_calls: int = 0
|
|
646
|
+
cost_units: float = 0.0
|
|
647
|
+
budget_cost_units: float = 0.0
|
|
648
|
+
# 算力消耗与多轮版本控制 (DOC-196)
|
|
649
|
+
tokens_consumed: int = 0
|
|
650
|
+
token_accounting: dict[str, int] = field(default_factory=dict)
|
|
651
|
+
round_version: int = 1
|
|
652
|
+
budget_exhausted: bool = False
|
|
653
|
+
budget_reasons: list[str] = field(default_factory=list)
|
|
654
|
+
claims: dict[str, WorkerClaim] = field(default_factory=dict)
|
|
655
|
+
findings: list[dict[str, object]] = field(default_factory=list)
|
|
656
|
+
# A5: report publication cursor and seal are persisted with the same
|
|
657
|
+
# Supervisor snapshot as findings, so readers never observe a newer report
|
|
658
|
+
# paired with an older state revision.
|
|
659
|
+
findings_revision: int = 0
|
|
660
|
+
report_seal: dict[str, object] | None = None
|
|
661
|
+
report_consumption: dict[str, object] = field(default_factory=lambda: {"phase": "OPEN"})
|
|
662
|
+
verification_runs: list[dict[str, object]] = field(default_factory=list)
|
|
663
|
+
verification_protocol_version: int = 2
|
|
664
|
+
confirmation_gate: dict[str, object] = field(default_factory=lambda: {
|
|
665
|
+
"ready": True, "total": 0, "confirmed": 0, "rejected": 0, "pending": 0,
|
|
666
|
+
})
|
|
667
|
+
scheduling_metrics: SchedulingMetrics = field(default_factory=SchedulingMetrics)
|
|
668
|
+
coverage: dict[str, str] = field(default_factory=dict)
|
|
669
|
+
history: list[dict[str, object]] = field(default_factory=list)
|
|
670
|
+
audit_head: str = ""
|
|
671
|
+
# Hash-chain anchor for the first retained event after bounded compaction.
|
|
672
|
+
history_base_seq: int = 1
|
|
673
|
+
history_base_hash: str = ""
|
|
674
|
+
revision: int = 0
|
|
675
|
+
completed_at: float | None = None
|
|
676
|
+
last_error: str | None = None
|
|
677
|
+
round_max_active_workers: int = 0
|
|
678
|
+
round_overlap_seconds: float = 0.0
|
|
679
|
+
# 跨单元系统级故障级联熔断 (DOC-242)
|
|
680
|
+
systemic_failures: dict[str, str] = field(default_factory=dict)
|
|
681
|
+
systemic_failure_units: dict[str, str] = field(default_factory=dict)
|
|
682
|
+
round_parallel_active_since: float | None = None
|
|
683
|
+
parallel_history: list[dict[str, object]] = field(default_factory=list)
|
|
684
|
+
# reset_budget 不会抹掉已经完成的并发证明;它们按 epoch 留在这里。
|
|
685
|
+
parallel_proof_history: list[dict[str, object]] = field(default_factory=list)
|
|
686
|
+
# Persisted AIMD state so each workers/claim process continues the same
|
|
687
|
+
# adaptive window instead of resetting to min_concurrency.
|
|
688
|
+
adaptive_concurrency_window: float | None = None
|
|
689
|
+
adaptive_success_streak: int = 0
|
|
690
|
+
adaptive_failure_streak: int = 0
|
|
691
|
+
# worker 提交的可复现错误签名(有界);供 incident hints 检索深案例。
|
|
692
|
+
recent_signatures: list[str] = field(default_factory=list)
|
|
693
|
+
# 断点手记:unit_id -> {worker_id, note, at};恢复/接手 worker 的上下文。
|
|
694
|
+
unit_notes: dict[str, dict[str, object]] = field(default_factory=dict)
|
|
695
|
+
# BugX 层级绑定:Supervisor 只负责当前 Life 的 Worker 控制面,但必须
|
|
696
|
+
# 能证明该控制面属于哪个项目、Session、Round 及冻结计划。
|
|
697
|
+
project_id: str | None = None
|
|
698
|
+
session_id: str | None = None
|
|
699
|
+
round_id: str | None = None
|
|
700
|
+
life_id: str | None = None
|
|
701
|
+
plan_hash: str | None = None
|
|
702
|
+
# Snapshot of the source/coverage target when this run was created.
|
|
703
|
+
target_fingerprint: str | None = None
|
|
704
|
+
business_admissions: dict[str, dict[str, object]] = field(default_factory=dict)
|
|
705
|
+
# Optional DOC-232 graph state shares this snapshot, lock, revision, and
|
|
706
|
+
# event chain with ordinary Supervisor state.
|
|
707
|
+
agent_graph: GraphRun | None = None
|
|
708
|
+
dirty: bool = field(default=False, repr=False, compare=False)
|
|
709
|
+
|
|
710
|
+
@property
|
|
711
|
+
def active_claims(self) -> dict[str, WorkerClaim]:
|
|
712
|
+
return {
|
|
713
|
+
worker_id: claim
|
|
714
|
+
for worker_id, claim in self.claims.items()
|
|
715
|
+
if claim.active
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
# A3:NA 比例硬上限。无上限时"把难挖的单元标成 not_applicable"是收敛
|
|
719
|
+
# 捷径——覆盖率 100% 但实际啥也没挖。上限让覆盖率保持诚实;超限时
|
|
720
|
+
# coverage_complete 仍为真(单元确实都有终态交代),但
|
|
721
|
+
# coverage_na_over_limit 暴露该事实,供结算门禁裁决。
|
|
722
|
+
MAX_NOT_APPLICABLE_RATIO = 0.20
|
|
723
|
+
|
|
724
|
+
@property
|
|
725
|
+
def coverage_complete(self) -> bool:
|
|
726
|
+
return bool(self.coverage) and all(
|
|
727
|
+
state in TERMINAL_COVERED for state in self.coverage.values()
|
|
728
|
+
)
|
|
729
|
+
|
|
730
|
+
@property
|
|
731
|
+
def not_applicable_ratio(self) -> float:
|
|
732
|
+
if not self.coverage:
|
|
733
|
+
return 0.0
|
|
734
|
+
na = sum(
|
|
735
|
+
1 for s in self.coverage.values()
|
|
736
|
+
if s == COVERAGE_NOT_APPLICABLE
|
|
737
|
+
)
|
|
738
|
+
return na / len(self.coverage)
|
|
739
|
+
|
|
740
|
+
@property
|
|
741
|
+
def coverage_na_over_limit(self) -> bool:
|
|
742
|
+
"""NA 比例超限——覆盖"完成"但成色不足,需人工/门禁复核。"""
|
|
743
|
+
return self.not_applicable_ratio > self.MAX_NOT_APPLICABLE_RATIO
|
|
744
|
+
|
|
745
|
+
@property
|
|
746
|
+
def coverage_debt(self) -> dict[str, object]:
|
|
747
|
+
"""按 DOC-011 §5.4/§5.5 分类覆盖债务:单元级债务 vs 全局阻塞 vs 已终态。"""
|
|
748
|
+
counts: dict[str, int] = {state: 0 for state in VALID_COVERAGE_STATES}
|
|
749
|
+
for state in self.coverage.values():
|
|
750
|
+
counts[state] = counts.get(state, 0) + 1
|
|
751
|
+
unit_debt = sum(counts.get(k, 0) for k in UNIT_LEVEL_DEBT)
|
|
752
|
+
global_blocked = sum(counts.get(k, 0) for k in GLOBAL_BLOCKED)
|
|
753
|
+
covered = sum(counts.get(k, 0) for k in TERMINAL_COVERED)
|
|
754
|
+
return {
|
|
755
|
+
"total": len(self.coverage),
|
|
756
|
+
"covered": covered,
|
|
757
|
+
"unit_debt": unit_debt,
|
|
758
|
+
"global_blocked": global_blocked,
|
|
759
|
+
"by_state": counts,
|
|
760
|
+
"has_unit_debt": unit_debt > 0,
|
|
761
|
+
"has_global_block": global_blocked > 0,
|
|
762
|
+
# A3:NA 成色——超限时覆盖虽"完成"但不可信,调度/结算应可见。
|
|
763
|
+
"not_applicable_ratio": round(self.not_applicable_ratio, 4),
|
|
764
|
+
"na_over_limit": self.coverage_na_over_limit,
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
def to_dict(self) -> dict[str, object]:
|
|
768
|
+
return {
|
|
769
|
+
"schema_version": SCHEMA_VERSION,
|
|
770
|
+
"run_id": self.run_id,
|
|
771
|
+
"status": self.status.value,
|
|
772
|
+
"round_no": self.round_no,
|
|
773
|
+
"life_score": self.life_score,
|
|
774
|
+
"life_kind": self.life_kind,
|
|
775
|
+
"budget": self.budget.to_dict(),
|
|
776
|
+
"started_at": self.started_at,
|
|
777
|
+
"budget_started_at": self.budget_started_at,
|
|
778
|
+
"round_started_at": self.round_started_at,
|
|
779
|
+
"clock_high_water": self.clock_high_water,
|
|
780
|
+
"budget_epoch": self.budget_epoch,
|
|
781
|
+
"scheduler_epoch": self.scheduler_epoch,
|
|
782
|
+
"tool_calls": self.tool_calls,
|
|
783
|
+
"budget_tool_calls": self.budget_tool_calls,
|
|
784
|
+
"cost_units": self.cost_units,
|
|
785
|
+
"budget_cost_units": self.budget_cost_units,
|
|
786
|
+
"budget_exhausted": self.budget_exhausted,
|
|
787
|
+
"budget_reasons": list(self.budget_reasons),
|
|
788
|
+
"claims": {
|
|
789
|
+
worker_id: claim.to_dict()
|
|
790
|
+
for worker_id, claim in sorted(self.claims.items())
|
|
791
|
+
},
|
|
792
|
+
"findings": copy.deepcopy(self.findings),
|
|
793
|
+
"findings_revision": self.findings_revision,
|
|
794
|
+
"report_seal": copy.deepcopy(self.report_seal),
|
|
795
|
+
"report_consumption": copy.deepcopy(self.report_consumption),
|
|
796
|
+
"verification_runs": copy.deepcopy(self.verification_runs),
|
|
797
|
+
"verification_protocol_version": self.verification_protocol_version,
|
|
798
|
+
"confirmation_gate": copy.deepcopy(self.confirmation_gate),
|
|
799
|
+
"coverage": dict(sorted(self.coverage.items())),
|
|
800
|
+
"business_admissions": copy.deepcopy(self.business_admissions),
|
|
801
|
+
"history": copy.deepcopy(self.history),
|
|
802
|
+
# A1:惰性校验锚点随状态持久化,使跨进程的每次加载都跳过
|
|
803
|
+
# 已校验前缀的重算(history 无界增长下的二次瓶颈)。
|
|
804
|
+
_HISTORY_ANCHOR_KEY: (
|
|
805
|
+
dict(getattr(self, _HISTORY_ANCHOR_KEY, None) or {})
|
|
806
|
+
if getattr(self, _HISTORY_ANCHOR_KEY, None) else None
|
|
807
|
+
),
|
|
808
|
+
"audit_head": self.audit_head,
|
|
809
|
+
"history_base_seq": self.history_base_seq,
|
|
810
|
+
"history_base_hash": self.history_base_hash,
|
|
811
|
+
"revision": self.revision,
|
|
812
|
+
"completed_at": self.completed_at,
|
|
813
|
+
"last_error": self.last_error,
|
|
814
|
+
"round_max_active_workers": self.round_max_active_workers,
|
|
815
|
+
"round_overlap_seconds": self.round_overlap_seconds,
|
|
816
|
+
"round_parallel_active_since": self.round_parallel_active_since,
|
|
817
|
+
"parallel_history": copy.deepcopy(self.parallel_history),
|
|
818
|
+
"parallel_proof_history": copy.deepcopy(self.parallel_proof_history),
|
|
819
|
+
"adaptive_concurrency_window": self.adaptive_concurrency_window,
|
|
820
|
+
"adaptive_success_streak": self.adaptive_success_streak,
|
|
821
|
+
"adaptive_failure_streak": self.adaptive_failure_streak,
|
|
822
|
+
"recent_signatures": list(self.recent_signatures),
|
|
823
|
+
"unit_notes": copy.deepcopy(self.unit_notes),
|
|
824
|
+
"project_id": self.project_id,
|
|
825
|
+
"session_id": self.session_id,
|
|
826
|
+
"round_id": self.round_id,
|
|
827
|
+
"life_id": self.life_id,
|
|
828
|
+
"plan_hash": self.plan_hash,
|
|
829
|
+
"target_fingerprint": self.target_fingerprint,
|
|
830
|
+
"agent_graph": (
|
|
831
|
+
None if self.agent_graph is None else self.agent_graph.to_dict()
|
|
832
|
+
),
|
|
833
|
+
"scheduling_metrics": self.scheduling_metrics.to_dict(),
|
|
834
|
+
"tokens_consumed": self.tokens_consumed,
|
|
835
|
+
"token_accounting": copy.deepcopy(self.token_accounting),
|
|
836
|
+
"round_version": self.round_version,
|
|
837
|
+
"systemic_failures": copy.deepcopy(self.systemic_failures),
|
|
838
|
+
"systemic_failure_units": copy.deepcopy(self.systemic_failure_units),
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
@classmethod
|
|
842
|
+
def from_dict(cls, value: Mapping[str, object]) -> "RunState":
|
|
843
|
+
schema_version = value.get("schema_version")
|
|
844
|
+
if schema_version not in {1, SCHEMA_VERSION}:
|
|
845
|
+
raise PersistenceError("不支持的 Supervisor state schema")
|
|
846
|
+
try:
|
|
847
|
+
try:
|
|
848
|
+
status = Status(str(value["status"]))
|
|
849
|
+
except ValueError:
|
|
850
|
+
status = Status.RUNNING
|
|
851
|
+
budget = RunBudget.from_dict(value["budget"]) # type: ignore[arg-type]
|
|
852
|
+
claims_raw = value.get("claims", {})
|
|
853
|
+
if not isinstance(claims_raw, Mapping):
|
|
854
|
+
raise TypeError("claims 必须是对象")
|
|
855
|
+
claims = {}
|
|
856
|
+
for raw_key, item in claims_raw.items():
|
|
857
|
+
claim_obj = WorkerClaim.from_dict(item) # type: ignore[arg-type]
|
|
858
|
+
if str(raw_key) != claim_obj.worker_id:
|
|
859
|
+
raise PersistenceError(
|
|
860
|
+
f"claims key '{raw_key}' 与 claim.worker_id '{claim_obj.worker_id}' 不一致"
|
|
861
|
+
)
|
|
862
|
+
claims[claim_obj.worker_id] = claim_obj
|
|
863
|
+
findings_raw = value.get("findings", [])
|
|
864
|
+
confirmation_raw = value.get("confirmation_gate", {
|
|
865
|
+
"ready": True, "total": 0, "confirmed": 0, "rejected": 0, "pending": 0,
|
|
866
|
+
})
|
|
867
|
+
coverage_raw = value.get("coverage", {})
|
|
868
|
+
history_raw = value.get("history", [])
|
|
869
|
+
if not isinstance(findings_raw, list):
|
|
870
|
+
raise TypeError("findings 必须是数组")
|
|
871
|
+
findings = copy.deepcopy(findings_raw)
|
|
872
|
+
for finding in findings:
|
|
873
|
+
if isinstance(finding, dict) and "severity" in finding:
|
|
874
|
+
finding["severity"] = normalize_finding_severity(
|
|
875
|
+
finding["severity"]
|
|
876
|
+
)
|
|
877
|
+
if not isinstance(confirmation_raw, Mapping):
|
|
878
|
+
raise TypeError("confirmation_gate 必须是对象")
|
|
879
|
+
if not isinstance(coverage_raw, Mapping):
|
|
880
|
+
raise TypeError("coverage 必须是对象")
|
|
881
|
+
if not isinstance(history_raw, list):
|
|
882
|
+
raise TypeError("history 必须是数组")
|
|
883
|
+
state = cls(
|
|
884
|
+
run_id=str(value["run_id"]),
|
|
885
|
+
status=status,
|
|
886
|
+
round_no=int(value["round_no"]),
|
|
887
|
+
life_score=float(value["life_score"]),
|
|
888
|
+
life_kind=str(value.get("life_kind", "mine")),
|
|
889
|
+
budget=budget,
|
|
890
|
+
started_at=float(value["started_at"]),
|
|
891
|
+
budget_started_at=float(value["budget_started_at"]),
|
|
892
|
+
round_started_at=float(value["round_started_at"]),
|
|
893
|
+
# D3:旧快照无此字段时回落 0.0(=「尚未观测」),首次预算
|
|
894
|
+
# 判定即从当前墙钟重建水位;水位本身只是防回拨的下界。
|
|
895
|
+
clock_high_water=float(value.get("clock_high_water", 0.0)),
|
|
896
|
+
budget_epoch=int(value.get("budget_epoch", 0)),
|
|
897
|
+
scheduler_epoch=int(value.get("scheduler_epoch", 0)),
|
|
898
|
+
tool_calls=int(value.get("tool_calls", 0)),
|
|
899
|
+
budget_tool_calls=int(value.get("budget_tool_calls", 0)),
|
|
900
|
+
cost_units=float(value.get("cost_units", 0.0)),
|
|
901
|
+
budget_cost_units=float(value.get("budget_cost_units", 0.0)),
|
|
902
|
+
budget_exhausted=bool(value.get("budget_exhausted", False)),
|
|
903
|
+
budget_reasons=[str(item) for item in value.get("budget_reasons", [])],
|
|
904
|
+
claims=claims,
|
|
905
|
+
findings=findings, # type: ignore[arg-type]
|
|
906
|
+
findings_revision=int(value.get("findings_revision", 0)),
|
|
907
|
+
report_seal=(
|
|
908
|
+
None if value.get("report_seal") is None
|
|
909
|
+
else copy.deepcopy(dict(value.get("report_seal")))
|
|
910
|
+
),
|
|
911
|
+
report_consumption=copy.deepcopy(dict(value.get("report_consumption", {"phase": "OPEN"}))),
|
|
912
|
+
verification_runs=copy.deepcopy(value.get("verification_runs", [])),
|
|
913
|
+
verification_protocol_version=int(value.get("verification_protocol_version", 1)),
|
|
914
|
+
confirmation_gate=copy.deepcopy(dict(confirmation_raw)),
|
|
915
|
+
coverage={str(key): str(item) for key, item in coverage_raw.items()},
|
|
916
|
+
history=copy.deepcopy(history_raw), # type: ignore[arg-type]
|
|
917
|
+
audit_head=str(value.get("audit_head", "")),
|
|
918
|
+
history_base_seq=int(value.get("history_base_seq", 1)),
|
|
919
|
+
history_base_hash=str(value.get("history_base_hash", "")),
|
|
920
|
+
revision=int(value.get("revision", 0)),
|
|
921
|
+
completed_at=(
|
|
922
|
+
None if value.get("completed_at") is None
|
|
923
|
+
else float(value["completed_at"])
|
|
924
|
+
),
|
|
925
|
+
last_error=(
|
|
926
|
+
None if value.get("last_error") is None
|
|
927
|
+
else str(value["last_error"])
|
|
928
|
+
),
|
|
929
|
+
round_max_active_workers=int(
|
|
930
|
+
value.get("round_max_active_workers", 0)
|
|
931
|
+
),
|
|
932
|
+
round_overlap_seconds=float(
|
|
933
|
+
value.get("round_overlap_seconds", 0.0)
|
|
934
|
+
),
|
|
935
|
+
round_parallel_active_since=(
|
|
936
|
+
None if value.get("round_parallel_active_since") is None
|
|
937
|
+
else float(value["round_parallel_active_since"])
|
|
938
|
+
),
|
|
939
|
+
parallel_history=copy.deepcopy(
|
|
940
|
+
value.get("parallel_history", [])
|
|
941
|
+
),
|
|
942
|
+
parallel_proof_history=copy.deepcopy(
|
|
943
|
+
value.get("parallel_proof_history", [])
|
|
944
|
+
),
|
|
945
|
+
adaptive_concurrency_window=(
|
|
946
|
+
None if value.get("adaptive_concurrency_window") is None
|
|
947
|
+
else float(value["adaptive_concurrency_window"])
|
|
948
|
+
),
|
|
949
|
+
adaptive_success_streak=int(
|
|
950
|
+
value.get("adaptive_success_streak", 0)
|
|
951
|
+
),
|
|
952
|
+
adaptive_failure_streak=int(
|
|
953
|
+
value.get("adaptive_failure_streak", 0)
|
|
954
|
+
),
|
|
955
|
+
recent_signatures=[
|
|
956
|
+
str(item) for item in value.get("recent_signatures", [])
|
|
957
|
+
if isinstance(item, str) and item.strip()
|
|
958
|
+
],
|
|
959
|
+
unit_notes=load_unit_notes(value.get("unit_notes")),
|
|
960
|
+
project_id=(None if value.get("project_id") is None else str(value.get("project_id"))),
|
|
961
|
+
session_id=(None if value.get("session_id") is None else str(value.get("session_id"))),
|
|
962
|
+
round_id=(None if value.get("round_id") is None else str(value.get("round_id"))),
|
|
963
|
+
life_id=(None if value.get("life_id") is None else str(value.get("life_id"))),
|
|
964
|
+
plan_hash=(None if value.get("plan_hash") is None else str(value.get("plan_hash"))),
|
|
965
|
+
target_fingerprint=(
|
|
966
|
+
None if value.get("target_fingerprint") is None
|
|
967
|
+
else str(value.get("target_fingerprint"))
|
|
968
|
+
),
|
|
969
|
+
agent_graph=(
|
|
970
|
+
None if value.get("agent_graph") is None
|
|
971
|
+
else GraphRun.from_dict(value["agent_graph"]) # type: ignore[arg-type]
|
|
972
|
+
),
|
|
973
|
+
scheduling_metrics=SchedulingMetrics.from_dict(
|
|
974
|
+
value.get("scheduling_metrics") # type: ignore[arg-type]
|
|
975
|
+
),
|
|
976
|
+
tokens_consumed=int(value.get("tokens_consumed", 0)),
|
|
977
|
+
token_accounting=dict(value.get("token_accounting", {})),
|
|
978
|
+
round_version=int(value.get("round_version", 1)),
|
|
979
|
+
systemic_failures=dict(value.get("systemic_failures", {})),
|
|
980
|
+
systemic_failure_units=dict(value.get("systemic_failure_units", {})),
|
|
981
|
+
)
|
|
982
|
+
except (KeyError, TypeError, ValueError) as exc:
|
|
983
|
+
raise PersistenceError(f"state 无效: {exc}") from exc
|
|
984
|
+
admissions = value.get("business_admissions")
|
|
985
|
+
if "business_admissions" not in value:
|
|
986
|
+
admissions = {}
|
|
987
|
+
for event in state.history:
|
|
988
|
+
if event.get("type") == "target_rebound":
|
|
989
|
+
admissions.clear()
|
|
990
|
+
elif event.get("type") == "business_admission":
|
|
991
|
+
admissions[event.get("unit")] = {
|
|
992
|
+
"reason": event.get("reason"), "risk_score": event.get("risk_score"),
|
|
993
|
+
}
|
|
994
|
+
if not isinstance(admissions, dict):
|
|
995
|
+
raise PersistenceError("business_admissions 必须是对象")
|
|
996
|
+
for unit, record in admissions.items():
|
|
997
|
+
if (not isinstance(unit, str) or not unit_kind.is_business(unit)
|
|
998
|
+
or unit not in state.coverage or not isinstance(record, dict)
|
|
999
|
+
or not isinstance(record.get("reason"), str) or not record["reason"].strip()
|
|
1000
|
+
or isinstance(record.get("risk_score"), bool)
|
|
1001
|
+
or not isinstance(record.get("risk_score"), (int, float))
|
|
1002
|
+
or not 70 <= record["risk_score"] <= 100):
|
|
1003
|
+
raise PersistenceError("business_admissions 包含无效授权")
|
|
1004
|
+
state.business_admissions = copy.deepcopy(admissions)
|
|
1005
|
+
if not state.run_id or state.round_no < 1 or state.revision < 0:
|
|
1006
|
+
raise PersistenceError("state 基本字段无效")
|
|
1007
|
+
if state.history_base_seq < 1 or not isinstance(state.history_base_hash, str):
|
|
1008
|
+
raise PersistenceError("history anchor 无效")
|
|
1009
|
+
finite_fields = (
|
|
1010
|
+
"life_score", "started_at", "budget_started_at", "round_started_at",
|
|
1011
|
+
"cost_units", "budget_cost_units", "round_overlap_seconds",
|
|
1012
|
+
"clock_high_water",
|
|
1013
|
+
)
|
|
1014
|
+
for name in finite_fields:
|
|
1015
|
+
value = getattr(state, name)
|
|
1016
|
+
if not math.isfinite(float(value)):
|
|
1017
|
+
raise PersistenceError(f"state {name} 必须是有限数字")
|
|
1018
|
+
if state.clock_high_water < 0:
|
|
1019
|
+
raise PersistenceError("state clock_high_water 不能为负")
|
|
1020
|
+
for name in ("completed_at", "round_parallel_active_since"):
|
|
1021
|
+
value = getattr(state, name)
|
|
1022
|
+
if value is not None and not math.isfinite(float(value)):
|
|
1023
|
+
raise PersistenceError(f"state {name} 必须是有限数字或 null")
|
|
1024
|
+
if state.adaptive_concurrency_window is not None and (
|
|
1025
|
+
not math.isfinite(float(state.adaptive_concurrency_window))
|
|
1026
|
+
or state.adaptive_concurrency_window <= 0
|
|
1027
|
+
):
|
|
1028
|
+
raise PersistenceError("state adaptive_concurrency_window 必须是正数或 null")
|
|
1029
|
+
integer_fields = (
|
|
1030
|
+
"budget_epoch", "scheduler_epoch", "tool_calls", "budget_tool_calls",
|
|
1031
|
+
"round_max_active_workers", "adaptive_success_streak",
|
|
1032
|
+
"adaptive_failure_streak", "findings_revision", "verification_protocol_version",
|
|
1033
|
+
)
|
|
1034
|
+
if any(isinstance(getattr(state, name), bool) or getattr(state, name) < 0
|
|
1035
|
+
for name in integer_fields):
|
|
1036
|
+
raise PersistenceError("state 计数器必须是非负整数")
|
|
1037
|
+
if state.cost_units < 0 or state.budget_cost_units < 0:
|
|
1038
|
+
raise PersistenceError("state cost_units 不能为负")
|
|
1039
|
+
if state.life_kind not in {"mine", "fix"}:
|
|
1040
|
+
raise PersistenceError("state life_kind 必须是 mine 或 fix")
|
|
1041
|
+
for name in ("project_id", "session_id", "round_id", "life_id"):
|
|
1042
|
+
value = getattr(state, name)
|
|
1043
|
+
if value is not None and not value.strip():
|
|
1044
|
+
raise PersistenceError(f"state {name} 不能是空字符串")
|
|
1045
|
+
if state.plan_hash is not None and not SHA256_RE.fullmatch(state.plan_hash):
|
|
1046
|
+
raise PersistenceError("state plan_hash 必须是 SHA-256")
|
|
1047
|
+
if state.target_fingerprint is not None and not state.target_fingerprint.strip():
|
|
1048
|
+
raise PersistenceError("state target_fingerprint 不能是空字符串")
|
|
1049
|
+
# completed_at is mandatory for every formally finished terminal
|
|
1050
|
+
# status; budget_exhausted alone does not imply completion.
|
|
1051
|
+
# D2:INCOMPLETE 是 finish 三分支写下的收尾终态,同受此不变量约束。
|
|
1052
|
+
if state.status in {
|
|
1053
|
+
Status.COMPLETE, Status.FAILED, Status.INCOMPLETE,
|
|
1054
|
+
} and state.completed_at is None:
|
|
1055
|
+
raise PersistenceError(
|
|
1056
|
+
"status=COMPLETE/INCOMPLETE/FAILED 时必须设置 completed_at"
|
|
1057
|
+
)
|
|
1058
|
+
if any(item not in VALID_COVERAGE_STATES for item in state.coverage.values()):
|
|
1059
|
+
raise PersistenceError("coverage 含未知状态")
|
|
1060
|
+
if state.round_max_active_workers < 0 or state.round_overlap_seconds < 0:
|
|
1061
|
+
raise PersistenceError("并发观测字段无效")
|
|
1062
|
+
if not isinstance(state.parallel_history, list):
|
|
1063
|
+
raise PersistenceError("parallel_history 必须是数组")
|
|
1064
|
+
if not isinstance(state.parallel_proof_history, list):
|
|
1065
|
+
raise PersistenceError("parallel_proof_history 必须是数组")
|
|
1066
|
+
if not isinstance(state.confirmation_gate, dict):
|
|
1067
|
+
raise PersistenceError("confirmation_gate 必须是对象")
|
|
1068
|
+
if state.report_seal is not None and not isinstance(state.report_seal, dict):
|
|
1069
|
+
raise PersistenceError("report_seal 必须是对象或 null")
|
|
1070
|
+
if not isinstance(state.report_consumption, dict):
|
|
1071
|
+
raise PersistenceError("report_consumption 必须是对象")
|
|
1072
|
+
if state.report_consumption.get("phase", "OPEN") not in {
|
|
1073
|
+
"OPEN", "POSTING", "SETTLED",
|
|
1074
|
+
"RECOVERY_REQUIRED",
|
|
1075
|
+
}:
|
|
1076
|
+
raise PersistenceError("report_consumption.phase 无效")
|
|
1077
|
+
if not isinstance(state.verification_runs, list):
|
|
1078
|
+
raise PersistenceError("verification_runs 必须是数组")
|
|
1079
|
+
if state.verification_protocol_version not in {1, 2}:
|
|
1080
|
+
raise PersistenceError("verification_protocol_version 不支持")
|
|
1081
|
+
validate_history(state)
|
|
1082
|
+
return state
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
def event_hash(event: Mapping[str, object]) -> str:
|
|
1086
|
+
body = {key: value for key, value in event.items() if key != "hash"}
|
|
1087
|
+
return hashlib.sha256(canonical_json(body)).hexdigest()
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
# A1:history 无界增长使每次 _mutate 的全链校验成为二次瓶颈。锚点机制:
|
|
1091
|
+
# state 持久化「已校验到第 N 条、该条 hash 为 H」后,加载时只需重算
|
|
1092
|
+
# 第 N 条的 hash 与锚点比对(O(1) 证明前缀未被篡改),再校验其后的事件。
|
|
1093
|
+
# 语义不变:任何对前缀的篡改都会打破锚点 hash 而被发现。
|
|
1094
|
+
_HISTORY_ANCHOR_KEY = "history_anchor"
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
def validate_history(state: RunState) -> None:
|
|
1098
|
+
total = len(state.history)
|
|
1099
|
+
start_index = 0
|
|
1100
|
+
previous = state.history_base_hash
|
|
1101
|
+
expected_seq = state.history_base_seq
|
|
1102
|
+
anchor = getattr(state, _HISTORY_ANCHOR_KEY, None)
|
|
1103
|
+
if isinstance(anchor, Mapping) and total:
|
|
1104
|
+
try:
|
|
1105
|
+
anchor_seq = int(anchor.get("seq", 0))
|
|
1106
|
+
anchor_hash = str(anchor.get("hash", ""))
|
|
1107
|
+
except (TypeError, ValueError):
|
|
1108
|
+
anchor_seq, anchor_hash = 0, ""
|
|
1109
|
+
anchor_index = anchor_seq - state.history_base_seq
|
|
1110
|
+
if 0 <= anchor_index < total:
|
|
1111
|
+
event = state.history[anchor_index]
|
|
1112
|
+
if (isinstance(event, Mapping)
|
|
1113
|
+
and event.get("seq") == anchor_seq
|
|
1114
|
+
and event.get("hash") == anchor_hash
|
|
1115
|
+
and event.get("hash") == event_hash(event)):
|
|
1116
|
+
# 前缀锚点自证通过:跳过前 anchor_seq 条的重算。
|
|
1117
|
+
start_index = anchor_index + 1
|
|
1118
|
+
previous = anchor_hash
|
|
1119
|
+
expected_seq = anchor_seq + 1
|
|
1120
|
+
for expected_seq, event in enumerate(
|
|
1121
|
+
state.history[start_index:], start=expected_seq,
|
|
1122
|
+
):
|
|
1123
|
+
if not isinstance(event, Mapping):
|
|
1124
|
+
raise PersistenceError("history 事件必须是对象")
|
|
1125
|
+
if event.get("seq") != expected_seq:
|
|
1126
|
+
raise PersistenceError("history seq 不连续")
|
|
1127
|
+
if event.get("prev_hash", "") != previous:
|
|
1128
|
+
raise PersistenceError("history hash-chain 前置 hash 不一致")
|
|
1129
|
+
stored_hash = event.get("hash")
|
|
1130
|
+
if not isinstance(stored_hash, str) or stored_hash != event_hash(event):
|
|
1131
|
+
raise PersistenceError("history hash-chain 校验失败")
|
|
1132
|
+
previous = stored_hash
|
|
1133
|
+
expected_seq += 1
|
|
1134
|
+
if state.audit_head != previous:
|
|
1135
|
+
raise PersistenceError("audit_head 与 history 不一致")
|
|
1136
|
+
# 校验完成后推进锚点,使下次加载继续受益。
|
|
1137
|
+
if total:
|
|
1138
|
+
object.__setattr__(state, _HISTORY_ANCHOR_KEY, {
|
|
1139
|
+
"seq": state.history_base_seq + total - 1,
|
|
1140
|
+
"hash": previous,
|
|
1141
|
+
})
|
|
1142
|
+
|
|
1143
|
+
|