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,1155 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""BugX Agent 行为评测器。
|
|
3
|
+
|
|
4
|
+
它不调用特定模型,而是对任意 Agent 运行产出的结构化 findings 统一评分:
|
|
5
|
+
发现率、精确率、证据有效率、可复现率、耗时和 token。CI 使用固定 golden
|
|
6
|
+
golden 产物验证评分器;协议示例只验证 runner 桥接。真实 Agent 质量必须由
|
|
7
|
+
独立评测集和真实 runner 比较候选运行与基线,不能由示例 runner 自证。
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
# --- 引擎导入根(直接执行脚本时自举 core.* 命名空间)---
|
|
12
|
+
import sys as _sys
|
|
13
|
+
from pathlib import Path as _Path
|
|
14
|
+
|
|
15
|
+
for _p in _Path(__file__).resolve().parents:
|
|
16
|
+
if (_p / "core" / "bugx.md").is_file():
|
|
17
|
+
if str(_p) not in _sys.path:
|
|
18
|
+
_sys.path.insert(0, str(_p))
|
|
19
|
+
break
|
|
20
|
+
del _p
|
|
21
|
+
|
|
22
|
+
import argparse
|
|
23
|
+
import datetime as dt
|
|
24
|
+
import hashlib
|
|
25
|
+
import json
|
|
26
|
+
import os
|
|
27
|
+
import shutil
|
|
28
|
+
import statistics
|
|
29
|
+
import subprocess
|
|
30
|
+
import sys
|
|
31
|
+
import tempfile
|
|
32
|
+
import threading
|
|
33
|
+
import time
|
|
34
|
+
from pathlib import Path
|
|
35
|
+
|
|
36
|
+
# QUA-03:文件哈希只保留一份实现(``symbol_index.file_sha256``)。
|
|
37
|
+
# 本模块与 ``symbol_index`` 都在隔离启动目录的复制清单内,因此该导入
|
|
38
|
+
# 在「core/ 被整体复制到临时目录单独运行」的场景下同样可用。
|
|
39
|
+
AGENT_DIR = Path(__file__).resolve().parent
|
|
40
|
+
if ".bugx" in AGENT_DIR.parts:
|
|
41
|
+
idx = AGENT_DIR.parts.index(".bugx")
|
|
42
|
+
REPO_ROOT = Path(*AGENT_DIR.parts[:idx])
|
|
43
|
+
elif AGENT_DIR.name == "agent" and AGENT_DIR.parent.name == "core":
|
|
44
|
+
REPO_ROOT = AGENT_DIR.parent.parent
|
|
45
|
+
else:
|
|
46
|
+
REPO_ROOT = AGENT_DIR.parent
|
|
47
|
+
|
|
48
|
+
_CORE_DIR = AGENT_DIR.parent if AGENT_DIR.name == "agent" else AGENT_DIR
|
|
49
|
+
for _p in (str(_CORE_DIR), str(REPO_ROOT)):
|
|
50
|
+
if _p not in sys.path:
|
|
51
|
+
sys.path.insert(0, _p)
|
|
52
|
+
|
|
53
|
+
from core.retrieval import symbol_index
|
|
54
|
+
from core.runtime.platform_adapter import terminate_process_tree as _terminate_runner
|
|
55
|
+
_EVALS_DIR = REPO_ROOT / "verification" / "evals"
|
|
56
|
+
DEFAULT_CASES = _EVALS_DIR / "cases.json"
|
|
57
|
+
DEFAULT_FINDINGS = _EVALS_DIR / "golden-findings.json"
|
|
58
|
+
SEVERITY_ORDER = {"info": 0, "low": 1, "medium": 2, "high": 3, "critical": 4}
|
|
59
|
+
# BX-ENGINE-18:finding 严重度的**单一真源**。此前存在三处互不一致的声明——
|
|
60
|
+
# 本表(无 info)、src/bugx_cli/commands/patch.py(补丁域,无 critical)、
|
|
61
|
+
# MCP schema(无 enum,任意 string)——导致真实项目里 1 条 severity="info" 的
|
|
62
|
+
# finding 让确认门 `validate_findings` 抛错、整门 24 条全部不可确认。
|
|
63
|
+
#
|
|
64
|
+
# 约定:
|
|
65
|
+
# * 本表是 **finding 域** 的唯一真源,MCP schema 的 severity enum 由它渲染;
|
|
66
|
+
# * `bugx patch` 的 severity 属**补丁域**(独立词表),不得与本表合并;
|
|
67
|
+
# * `info` 置 0:信息性发现不满足任何 >= low 的最低严重度要求,语义正确。
|
|
68
|
+
FINDING_SEVERITY_LEVELS = tuple(sorted(SEVERITY_ORDER, key=SEVERITY_ORDER.get))
|
|
69
|
+
QUALITY_METRICS = (
|
|
70
|
+
"recall", "precision", "evidence_validity", "reproducibility", "quality_score",
|
|
71
|
+
)
|
|
72
|
+
SAFE_ENV_NAMES = {
|
|
73
|
+
"PATH", "LANG", "LC_ALL", "LC_CTYPE", "PYTHONIOENCODING", "SYSTEMROOT",
|
|
74
|
+
"COMSPEC", "PATHEXT", "TMPDIR", "TEMP", "TMP",
|
|
75
|
+
}
|
|
76
|
+
DEFAULT_BATCH_SIZE = 8
|
|
77
|
+
DEFAULT_MAX_PROMPT_BYTES = 512 * 1024
|
|
78
|
+
MAX_PROMPT_BYTES = 8 * 1024 * 1024
|
|
79
|
+
MAX_BASELINE_FIXTURE_BYTES = 16 * 1024 * 1024
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class EvalError(ValueError):
|
|
83
|
+
"""评测输入协议错误。"""
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def load_json(path: Path) -> dict:
|
|
87
|
+
try:
|
|
88
|
+
value = json.loads(path.read_text(encoding="utf-8"))
|
|
89
|
+
except OSError as exc:
|
|
90
|
+
raise EvalError(f"无法读取 {path}: {exc}") from exc
|
|
91
|
+
except json.JSONDecodeError as exc:
|
|
92
|
+
raise EvalError(f"JSON 无法解析 {path}: {exc}") from exc
|
|
93
|
+
if not isinstance(value, dict):
|
|
94
|
+
raise EvalError(f"{path} 根节点必须是对象")
|
|
95
|
+
return value
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _resolve_in_root(raw: str, root: Path) -> Path | None:
|
|
99
|
+
path = Path(raw)
|
|
100
|
+
if path.is_absolute():
|
|
101
|
+
return None
|
|
102
|
+
try:
|
|
103
|
+
resolved_root = root.resolve(strict=True)
|
|
104
|
+
candidate = root / path
|
|
105
|
+
resolved = candidate.resolve(strict=True)
|
|
106
|
+
resolved.relative_to(resolved_root)
|
|
107
|
+
except (OSError, ValueError):
|
|
108
|
+
return None
|
|
109
|
+
return resolved
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def validate_cases(payload: dict, root: Path = REPO_ROOT) -> list[dict]:
|
|
113
|
+
if payload.get("schema_version") != 1:
|
|
114
|
+
raise EvalError("cases.schema_version 必须为 1")
|
|
115
|
+
cases = payload.get("cases")
|
|
116
|
+
if not isinstance(cases, list) or not cases:
|
|
117
|
+
raise EvalError("cases 必须是非空数组")
|
|
118
|
+
seen: set[str] = set()
|
|
119
|
+
for index, case in enumerate(cases, 1):
|
|
120
|
+
if not isinstance(case, dict):
|
|
121
|
+
raise EvalError(f"case #{index} 必须是对象")
|
|
122
|
+
case_id = case.get("id")
|
|
123
|
+
if not isinstance(case_id, str) or not case_id:
|
|
124
|
+
raise EvalError(f"case #{index} 缺 id")
|
|
125
|
+
if case_id in seen:
|
|
126
|
+
raise EvalError(f"case id 重复: {case_id}")
|
|
127
|
+
seen.add(case_id)
|
|
128
|
+
fixture = case.get("fixture")
|
|
129
|
+
if not isinstance(fixture, str) or _resolve_in_root(fixture, root) is None:
|
|
130
|
+
raise EvalError(f"{case_id} fixture 不存在或逃出仓库: {fixture}")
|
|
131
|
+
minimum = str(case.get("minimum_severity", "")).lower()
|
|
132
|
+
if minimum not in SEVERITY_ORDER:
|
|
133
|
+
raise EvalError(f"{case_id} minimum_severity 无效")
|
|
134
|
+
if not isinstance(case.get("root_cause"), str) or not case["root_cause"]:
|
|
135
|
+
raise EvalError(f"{case_id} 缺 root_cause")
|
|
136
|
+
thresholds = payload.get("thresholds")
|
|
137
|
+
if not isinstance(thresholds, dict):
|
|
138
|
+
raise EvalError("cases.thresholds 必须是对象")
|
|
139
|
+
for key in ("min_recall", "min_precision", "min_evidence_validity", "min_reproducibility"):
|
|
140
|
+
value = thresholds.get(key)
|
|
141
|
+
if not isinstance(value, (int, float)) or isinstance(value, bool) or not 0 <= value <= 1:
|
|
142
|
+
raise EvalError(f"thresholds.{key} 必须在 0..1")
|
|
143
|
+
for key in (
|
|
144
|
+
"max_false_positive_rate", "max_duplicate_rate",
|
|
145
|
+
"max_confidence_brier_score", "min_confirmation_rate",
|
|
146
|
+
):
|
|
147
|
+
if key not in thresholds:
|
|
148
|
+
continue
|
|
149
|
+
value = thresholds[key]
|
|
150
|
+
if not isinstance(value, (int, float)) or isinstance(value, bool) or not 0 <= value <= 1:
|
|
151
|
+
raise EvalError(f"thresholds.{key} 必须在 0..1")
|
|
152
|
+
return cases
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def finding_violations(finding: object) -> list[str]:
|
|
156
|
+
"""返回单条 finding 的**全部**契约违规(不抛错)。
|
|
157
|
+
|
|
158
|
+
BX-ENGINE-18:确认门需要「逐条判定」——单条数据问题只应记为该条的 issues,
|
|
159
|
+
不得让整门失败。本函数是逐条检查的**唯一实现**;:func:`validate_findings`
|
|
160
|
+
复用它并保持 fail-fast(抛首个违规),两者不会漂移。
|
|
161
|
+
"""
|
|
162
|
+
try:
|
|
163
|
+
from core.ledger import finding_confirmation
|
|
164
|
+
except ImportError:
|
|
165
|
+
from core import finding_confirmation
|
|
166
|
+
|
|
167
|
+
if not isinstance(finding, dict):
|
|
168
|
+
return ["finding 必须是对象"]
|
|
169
|
+
issues: list[str] = []
|
|
170
|
+
finding_id = finding.get("id")
|
|
171
|
+
if not isinstance(finding_id, str) or not finding_id:
|
|
172
|
+
issues.append("finding 缺 id")
|
|
173
|
+
finding_id = "<unknown>"
|
|
174
|
+
confirmation = finding.get("confirmation")
|
|
175
|
+
confirmation_state = (
|
|
176
|
+
confirmation.get("state") if isinstance(confirmation, dict) else "candidate"
|
|
177
|
+
)
|
|
178
|
+
severity_value = finding.get("severity")
|
|
179
|
+
severity = str(severity_value or "").lower()
|
|
180
|
+
if severity not in SEVERITY_ORDER and not (
|
|
181
|
+
severity_value is None and confirmation_state != "confirmed"
|
|
182
|
+
):
|
|
183
|
+
issues.append(f"{finding_id} severity 无效")
|
|
184
|
+
for field in ("title", "root_cause"):
|
|
185
|
+
value = finding.get(field)
|
|
186
|
+
if not isinstance(value, str) or not value.strip():
|
|
187
|
+
issues.append(f"{finding_id} 缺 {field}")
|
|
188
|
+
confidence = finding.get("confidence")
|
|
189
|
+
if not isinstance(confidence, (int, float)) or isinstance(confidence, bool) \
|
|
190
|
+
or not 0 <= confidence <= 1:
|
|
191
|
+
issues.append(f"{finding_id} confidence 必须在 0..1")
|
|
192
|
+
evidence = finding.get("evidence")
|
|
193
|
+
if not isinstance(evidence, list) or not evidence:
|
|
194
|
+
issues.append(f"{finding_id} evidence 必须是非空数组")
|
|
195
|
+
else:
|
|
196
|
+
for evidence_index, item in enumerate(evidence, 1):
|
|
197
|
+
if not isinstance(item, dict):
|
|
198
|
+
issues.append(f"{finding_id} evidence #{evidence_index} 必须是对象")
|
|
199
|
+
continue
|
|
200
|
+
if not isinstance(item.get("path"), str) or not item["path"].strip():
|
|
201
|
+
issues.append(f"{finding_id} evidence #{evidence_index} 缺 path")
|
|
202
|
+
line = item.get("line")
|
|
203
|
+
if line is not None and (
|
|
204
|
+
not isinstance(line, int) or isinstance(line, bool) or line < 1
|
|
205
|
+
):
|
|
206
|
+
issues.append(f"{finding_id} evidence #{evidence_index} line 必须是正整数")
|
|
207
|
+
violation = finding_confirmation.reproducible_contract_violation(finding)
|
|
208
|
+
if violation == "not_bool":
|
|
209
|
+
issues.append(f"{finding_id} reproducible 必须是布尔值")
|
|
210
|
+
remediation = finding.get("remediation")
|
|
211
|
+
if remediation is not None and not isinstance(remediation, dict):
|
|
212
|
+
issues.append(f"{finding_id} remediation 必须是对象")
|
|
213
|
+
if violation == "missing_reproduction":
|
|
214
|
+
issues.append(f"{finding_id} 标为可复现时必须提供 reproduction")
|
|
215
|
+
return issues
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def validate_findings(payload: dict) -> list[dict]:
|
|
219
|
+
if payload.get("schema_version") != 1:
|
|
220
|
+
raise EvalError("findings.schema_version 必须为 1")
|
|
221
|
+
findings = payload.get("findings")
|
|
222
|
+
if not isinstance(findings, list):
|
|
223
|
+
raise EvalError("findings 必须是数组")
|
|
224
|
+
duration = payload.get("duration_seconds")
|
|
225
|
+
if not isinstance(duration, (int, float)) or isinstance(duration, bool) or duration < 0:
|
|
226
|
+
raise EvalError("findings.duration_seconds 必须是非负数")
|
|
227
|
+
token_count = payload.get("token_count")
|
|
228
|
+
if token_count is not None and (not isinstance(token_count, int) or isinstance(token_count, bool) or token_count < 0):
|
|
229
|
+
raise EvalError("findings.token_count 必须是非负整数或 null")
|
|
230
|
+
seen: set[str] = set()
|
|
231
|
+
for index, finding in enumerate(findings, 1):
|
|
232
|
+
if not isinstance(finding, dict):
|
|
233
|
+
raise EvalError(f"finding #{index} 必须是对象")
|
|
234
|
+
# id 缺失/重复的文案含序号,保持既有契约不变(逐条检查器不含序号)。
|
|
235
|
+
finding_id = finding.get("id")
|
|
236
|
+
if not isinstance(finding_id, str) or not finding_id:
|
|
237
|
+
raise EvalError(f"finding #{index} 缺 id")
|
|
238
|
+
if finding_id in seen:
|
|
239
|
+
raise EvalError(f"finding id 重复: {finding_id}")
|
|
240
|
+
seen.add(finding_id)
|
|
241
|
+
violations = finding_violations(finding)
|
|
242
|
+
if violations:
|
|
243
|
+
raise EvalError(violations[0])
|
|
244
|
+
return findings
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def _evidence_item_valid(item: object, root: Path) -> bool:
|
|
248
|
+
if not isinstance(item, dict) or not isinstance(item.get("path"), str):
|
|
249
|
+
return False
|
|
250
|
+
resolved = _resolve_in_root(item["path"], root)
|
|
251
|
+
if resolved is None or not resolved.is_file():
|
|
252
|
+
return False
|
|
253
|
+
line = item.get("line")
|
|
254
|
+
if line is None:
|
|
255
|
+
return True
|
|
256
|
+
if not isinstance(line, int) or isinstance(line, bool) or line < 1:
|
|
257
|
+
return False
|
|
258
|
+
try:
|
|
259
|
+
with resolved.open("r", encoding="utf-8", errors="replace") as handle:
|
|
260
|
+
return line <= sum(1 for _ in handle)
|
|
261
|
+
except OSError:
|
|
262
|
+
return False
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def invalid_evidence_ids(findings: list[dict], root: Path = REPO_ROOT) -> list[str]:
|
|
266
|
+
"""列出没有任何真实仓库内证据文件的 finding。"""
|
|
267
|
+
return [
|
|
268
|
+
finding["id"] for finding in findings
|
|
269
|
+
if not any(_evidence_item_valid(item, root) for item in finding["evidence"])
|
|
270
|
+
]
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
# DEF-2:证据契约的正确格式样例(单一真源,拒绝回注与探针共用;只描述契约,
|
|
274
|
+
# 不放宽契约——path 仍必须是 workspace 内真实文件的相对路径)。
|
|
275
|
+
CORRECT_EVIDENCE_SAMPLE = '[{"path": "core/foo.py", "line": 42}]'
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def evidence_item_valid(item: object, root: Path) -> bool:
|
|
279
|
+
"""公开别名:与 ``_evidence_item_valid`` 同一实现(防漂移单一真源)。"""
|
|
280
|
+
return _evidence_item_valid(item, root)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def evidence_item_violation(item: object, root: Path) -> str | None:
|
|
284
|
+
"""单条 evidence 证据项的结构化违规原因(``None`` = 通过契约校验)。
|
|
285
|
+
|
|
286
|
+
DEF-2:checkpoint 摄入侧拒绝时只给一行「缺真实 workspace evidence」,
|
|
287
|
+
模型/宿主不知道缺什么字段、哪个 path 不存在,同因重试烧尽 attempt 预算。
|
|
288
|
+
本函数把 ``_evidence_item_valid`` 的同一套判定谓词展开为可回注重试提示词
|
|
289
|
+
的具体原因;接受条件与 ``_evidence_item_valid`` 逐字同源,绝不放宽
|
|
290
|
+
真实文件/行号契约。
|
|
291
|
+
"""
|
|
292
|
+
if not isinstance(item, dict):
|
|
293
|
+
return (
|
|
294
|
+
f"evidence 项必须是对象(收到 {type(item).__name__}),"
|
|
295
|
+
f"正确格式 {CORRECT_EVIDENCE_SAMPLE}"
|
|
296
|
+
)
|
|
297
|
+
path = item.get("path")
|
|
298
|
+
if not isinstance(path, str) or not path.strip():
|
|
299
|
+
return "evidence 缺 path(必须是非空字符串的 workspace 相对路径)"
|
|
300
|
+
raw = path.strip()
|
|
301
|
+
candidate = Path(raw)
|
|
302
|
+
if candidate.is_absolute():
|
|
303
|
+
return f"evidence path 是绝对路径(必须用相对 workspace 根的路径): {raw[:200]}"
|
|
304
|
+
try:
|
|
305
|
+
resolved_root = root.resolve(strict=True)
|
|
306
|
+
except OSError:
|
|
307
|
+
return f"workspace 根不可解析,无法校验 evidence path: {raw[:200]}"
|
|
308
|
+
resolved = (root / raw).resolve(strict=False)
|
|
309
|
+
try:
|
|
310
|
+
resolved.relative_to(resolved_root)
|
|
311
|
+
except ValueError:
|
|
312
|
+
return f"evidence path 越出 workspace 边界: {raw[:200]}"
|
|
313
|
+
if not resolved.exists():
|
|
314
|
+
return f"evidence path 在 workspace 内不存在(必须是真实文件): {raw[:200]}"
|
|
315
|
+
if not resolved.is_file():
|
|
316
|
+
return f"evidence path 不是普通文件: {raw[:200]}"
|
|
317
|
+
line = item.get("line")
|
|
318
|
+
if line is None:
|
|
319
|
+
return None
|
|
320
|
+
if not isinstance(line, int) or isinstance(line, bool) or line < 1:
|
|
321
|
+
return f"evidence line 必须是正整数(收到 {line!r})"
|
|
322
|
+
try:
|
|
323
|
+
with resolved.open("r", encoding="utf-8", errors="replace") as handle:
|
|
324
|
+
total = sum(1 for _ in handle)
|
|
325
|
+
except OSError:
|
|
326
|
+
return f"evidence path 文件不可读: {raw[:200]}"
|
|
327
|
+
if line > total:
|
|
328
|
+
return f"evidence line 超出文件行数(文件共 {total} 行,收到 {line})"
|
|
329
|
+
return None
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def finding_evidence_violations(finding: dict, root: Path) -> list[str]:
|
|
333
|
+
"""逐条列出 finding 全部 evidence 项的结构化违规(空列表 = 证据有效)。"""
|
|
334
|
+
evidence = finding.get("evidence")
|
|
335
|
+
if not isinstance(evidence, list) or not evidence:
|
|
336
|
+
return ["evidence 必须是非空数组"]
|
|
337
|
+
issues: list[str] = []
|
|
338
|
+
for index, item in enumerate(evidence, 1):
|
|
339
|
+
violation = evidence_item_violation(item, root)
|
|
340
|
+
if violation:
|
|
341
|
+
issues.append(f"evidence[{index}] {violation}")
|
|
342
|
+
return issues
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def _hard_confirmed(finding: dict) -> bool:
|
|
346
|
+
"""Count only findings that pass the shared confirmation gate."""
|
|
347
|
+
try:
|
|
348
|
+
try:
|
|
349
|
+
from core.ledger import finding_confirmation
|
|
350
|
+
except ImportError:
|
|
351
|
+
from core import finding_confirmation
|
|
352
|
+
|
|
353
|
+
return finding_confirmation.is_confirmed(finding)
|
|
354
|
+
except (ImportError, TypeError, ValueError):
|
|
355
|
+
return False
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def score(cases_payload: dict, findings_payload: dict,
|
|
359
|
+
root: Path = REPO_ROOT,
|
|
360
|
+
feature_baseline_payload: dict | None = None) -> dict:
|
|
361
|
+
cases = validate_cases(cases_payload, root)
|
|
362
|
+
findings = validate_findings(findings_payload)
|
|
363
|
+
# F-022:feature baseline 可选。提供时计算 completeness 维度并重分配
|
|
364
|
+
# quality_score 权重(六维度①功能完备性为差异化核心);缺省时行为不变。
|
|
365
|
+
baseline_features = None
|
|
366
|
+
if feature_baseline_payload is not None:
|
|
367
|
+
from core.agent.feature_baseline import (
|
|
368
|
+
completeness_metrics, validate_feature_baseline, COMPLETENESS_WEIGHTED,
|
|
369
|
+
)
|
|
370
|
+
baseline_features = validate_feature_baseline(feature_baseline_payload)
|
|
371
|
+
case_by_id = {case["id"]: case for case in cases}
|
|
372
|
+
matched: dict[str, list[dict]] = {}
|
|
373
|
+
for finding in findings:
|
|
374
|
+
case_id = finding.get("case_id")
|
|
375
|
+
if case_id in case_by_id:
|
|
376
|
+
matched.setdefault(case_id, []).append(finding)
|
|
377
|
+
|
|
378
|
+
found_ids: set[str] = set()
|
|
379
|
+
evidence_ids: set[str] = set()
|
|
380
|
+
reproducible_ids: set[str] = set()
|
|
381
|
+
qualified_counts: dict[str, int] = {}
|
|
382
|
+
correct_finding_ids: set[str] = set()
|
|
383
|
+
true_positive_count = 0
|
|
384
|
+
for case_id, candidates in matched.items():
|
|
385
|
+
case = case_by_id[case_id]
|
|
386
|
+
minimum = SEVERITY_ORDER[case["minimum_severity"].lower()]
|
|
387
|
+
qualified = [
|
|
388
|
+
finding for finding in candidates
|
|
389
|
+
if finding.get("root_cause") == case["root_cause"]
|
|
390
|
+
and SEVERITY_ORDER[str(finding["severity"]).lower()] >= minimum
|
|
391
|
+
]
|
|
392
|
+
if not qualified:
|
|
393
|
+
continue
|
|
394
|
+
# 每 case 只计 1 个 TP;case 内多余的正确 finding 属于重复挖掘,
|
|
395
|
+
# 计入 FP,否则低精确率会被「同一 case 堆多个正确 finding」掩盖。
|
|
396
|
+
true_positive_count += 1
|
|
397
|
+
qualified_counts[case_id] = len(qualified)
|
|
398
|
+
correct_finding_ids.add(qualified[0]["id"])
|
|
399
|
+
found_ids.add(case_id)
|
|
400
|
+
if any(
|
|
401
|
+
any(_evidence_item_valid(item, root) for item in finding["evidence"])
|
|
402
|
+
for finding in qualified
|
|
403
|
+
):
|
|
404
|
+
evidence_ids.add(case_id)
|
|
405
|
+
if any(
|
|
406
|
+
finding.get("reproducible") is True
|
|
407
|
+
and isinstance(finding.get("reproduction"), str)
|
|
408
|
+
and bool(finding["reproduction"].strip())
|
|
409
|
+
for finding in qualified
|
|
410
|
+
):
|
|
411
|
+
reproducible_ids.add(case_id)
|
|
412
|
+
|
|
413
|
+
total_cases = len(cases)
|
|
414
|
+
total_findings = len(findings)
|
|
415
|
+
found = len(found_ids)
|
|
416
|
+
recall = found / total_cases if total_cases else 0.0
|
|
417
|
+
# finding 级精确率:正确命中(每 case 一个)÷ 全部 findings。
|
|
418
|
+
# 旧实现用 found_cases 当分子,会把「同一 case 堆多个正确 finding」
|
|
419
|
+
# 误判为低精度,同时 FPR 却漏计这些冗余——metric 失真。
|
|
420
|
+
precision = true_positive_count / total_findings if total_findings else 0.0
|
|
421
|
+
evidence_validity = len(evidence_ids) / found if found else 0.0
|
|
422
|
+
reproducibility = len(reproducible_ids) / found if found else 0.0
|
|
423
|
+
# FP = 未命中 case 的 finding + case 内超出第一个的正确 finding。
|
|
424
|
+
false_positive_count = (total_findings - true_positive_count)
|
|
425
|
+
duplicate_count = sum(max(0, count - 1) for count in qualified_counts.values())
|
|
426
|
+
false_positive_rate = false_positive_count / total_findings if total_findings else 0.0
|
|
427
|
+
duplicate_rate = duplicate_count / total_findings if total_findings else 0.0
|
|
428
|
+
brier_score = sum(
|
|
429
|
+
(float(finding["confidence"]) - (1.0 if finding["id"] in correct_finding_ids else 0.0)) ** 2
|
|
430
|
+
for finding in findings
|
|
431
|
+
) / total_findings if total_findings else 0.0
|
|
432
|
+
confirmed_findings = sum(_hard_confirmed(finding) for finding in findings)
|
|
433
|
+
heuristic_only_findings = sum(
|
|
434
|
+
isinstance(finding.get("confirmation"), dict)
|
|
435
|
+
and isinstance(finding["confirmation"].get("oracle"), dict)
|
|
436
|
+
and finding["confirmation"]["oracle"].get("tier") == "heuristic"
|
|
437
|
+
for finding in findings
|
|
438
|
+
)
|
|
439
|
+
# 按根因类别的 recall:哪类错题挖不动一目了然(供 seed_drill/复盘对齐)。
|
|
440
|
+
root_cause_buckets: dict[str, dict[str, int]] = {}
|
|
441
|
+
for case in cases:
|
|
442
|
+
bucket = root_cause_buckets.setdefault(
|
|
443
|
+
str(case["root_cause"]), {"cases": 0, "found": 0},
|
|
444
|
+
)
|
|
445
|
+
bucket["cases"] += 1
|
|
446
|
+
if case["id"] in found_ids:
|
|
447
|
+
bucket["found"] += 1
|
|
448
|
+
recall_by_root_cause = {
|
|
449
|
+
cause: round(bucket["found"] / bucket["cases"], 4)
|
|
450
|
+
for cause, bucket in sorted(root_cause_buckets.items())
|
|
451
|
+
if bucket["cases"]
|
|
452
|
+
}
|
|
453
|
+
weighted = (
|
|
454
|
+
recall * 0.40 + precision * 0.25
|
|
455
|
+
+ evidence_validity * 0.20 + reproducibility * 0.15
|
|
456
|
+
)
|
|
457
|
+
metrics = {
|
|
458
|
+
"cases_total": total_cases,
|
|
459
|
+
"cases_found": found,
|
|
460
|
+
"findings_total": total_findings,
|
|
461
|
+
"missed_case_ids": sorted(set(case_by_id) - found_ids),
|
|
462
|
+
"recall": round(recall, 4),
|
|
463
|
+
"recall_by_root_cause": recall_by_root_cause,
|
|
464
|
+
"precision": round(precision, 4),
|
|
465
|
+
"evidence_validity": round(evidence_validity, 4),
|
|
466
|
+
"reproducibility": round(reproducibility, 4),
|
|
467
|
+
"false_positive_count": false_positive_count,
|
|
468
|
+
"false_positive_rate": round(false_positive_rate, 4),
|
|
469
|
+
"duplicate_count": duplicate_count,
|
|
470
|
+
"duplicate_rate": round(duplicate_rate, 4),
|
|
471
|
+
"confidence_brier_score": round(brier_score, 4),
|
|
472
|
+
"confirmed_findings": confirmed_findings,
|
|
473
|
+
"confirmation_rate": round(
|
|
474
|
+
confirmed_findings / total_findings, 4,
|
|
475
|
+
) if total_findings else 0.0,
|
|
476
|
+
"heuristic_only_findings": heuristic_only_findings,
|
|
477
|
+
"quality_score": round(weighted * 100, 2),
|
|
478
|
+
"duration_seconds": round(float(findings_payload["duration_seconds"]), 3),
|
|
479
|
+
"token_count": int(findings_payload["token_count"]),
|
|
480
|
+
"finding_confidence_median": round(statistics.median(
|
|
481
|
+
[float(item["confidence"]) for item in findings]
|
|
482
|
+
), 4) if findings else 0.0,
|
|
483
|
+
}
|
|
484
|
+
if baseline_features is not None:
|
|
485
|
+
completeness = completeness_metrics(baseline_features, findings)
|
|
486
|
+
metrics.update(completeness)
|
|
487
|
+
metrics["quality_score"] = round((
|
|
488
|
+
recall * COMPLETENESS_WEIGHTED["recall"]
|
|
489
|
+
+ precision * COMPLETENESS_WEIGHTED["precision"]
|
|
490
|
+
+ evidence_validity * COMPLETENESS_WEIGHTED["evidence_validity"]
|
|
491
|
+
+ reproducibility * COMPLETENESS_WEIGHTED["reproducibility"]
|
|
492
|
+
+ completeness["completeness_recall"] * COMPLETENESS_WEIGHTED["completeness_recall"]
|
|
493
|
+
) * 100, 2)
|
|
494
|
+
return metrics
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
def threshold_failures(metrics: dict, thresholds: dict) -> list[str]:
|
|
498
|
+
mapping = {
|
|
499
|
+
"min_recall": "recall",
|
|
500
|
+
"min_precision": "precision",
|
|
501
|
+
"min_evidence_validity": "evidence_validity",
|
|
502
|
+
"min_reproducibility": "reproducibility",
|
|
503
|
+
# F-022:completeness 阈值仅在提供 feature baseline(metrics 含键)时检查,
|
|
504
|
+
# 无 baseline 的存量评测集不受影响。
|
|
505
|
+
"min_completeness_recall": "completeness_recall",
|
|
506
|
+
}
|
|
507
|
+
failures = []
|
|
508
|
+
for threshold_name, metric_name in mapping.items():
|
|
509
|
+
if threshold_name not in thresholds or metric_name not in metrics:
|
|
510
|
+
continue
|
|
511
|
+
expected = float(thresholds[threshold_name])
|
|
512
|
+
actual = float(metrics[metric_name])
|
|
513
|
+
if actual < expected:
|
|
514
|
+
failures.append(
|
|
515
|
+
f"{metric_name}={actual:.4f} 低于门槛 {expected:.4f}"
|
|
516
|
+
)
|
|
517
|
+
for threshold_name, metric_name in (
|
|
518
|
+
("max_false_positive_rate", "false_positive_rate"),
|
|
519
|
+
("max_duplicate_rate", "duplicate_rate"),
|
|
520
|
+
("max_confidence_brier_score", "confidence_brier_score"),
|
|
521
|
+
):
|
|
522
|
+
if threshold_name not in thresholds:
|
|
523
|
+
continue
|
|
524
|
+
expected = float(thresholds[threshold_name])
|
|
525
|
+
actual = float(metrics[metric_name])
|
|
526
|
+
if actual > expected:
|
|
527
|
+
failures.append(f"{metric_name}={actual:.4f} 高于门槛 {expected:.4f}")
|
|
528
|
+
if "min_confirmation_rate" in thresholds:
|
|
529
|
+
expected = float(thresholds["min_confirmation_rate"])
|
|
530
|
+
actual = float(metrics["confirmation_rate"])
|
|
531
|
+
if actual < expected:
|
|
532
|
+
failures.append(f"confirmation_rate={actual:.4f} 低于门槛 {expected:.4f}")
|
|
533
|
+
return failures
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
def canonical_digest(payload: dict) -> str:
|
|
537
|
+
encoded = json.dumps(
|
|
538
|
+
payload, ensure_ascii=False, sort_keys=True, separators=(",", ":"),
|
|
539
|
+
).encode("utf-8")
|
|
540
|
+
return hashlib.sha256(encoded).hexdigest()
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
def _fixture_sha256(path: Path | None) -> str:
|
|
544
|
+
"""计算评测 fixture 的 SHA-256,并施加基线摘要的体积上限。
|
|
545
|
+
|
|
546
|
+
QUA-03:分块哈希本身委托给全仓唯一实现 ``symbol_index.file_sha256``
|
|
547
|
+
(同为 1 MiB 分块);本函数只保留**本域特有**的两件事——体积上限与
|
|
548
|
+
``EvalError`` 语义的异常转换。这样摘要算法只在一处维护。
|
|
549
|
+
"""
|
|
550
|
+
if path is None:
|
|
551
|
+
raise EvalError("评测 fixture 不存在或逃出仓库根目录")
|
|
552
|
+
try:
|
|
553
|
+
if path.stat().st_size > MAX_BASELINE_FIXTURE_BYTES:
|
|
554
|
+
raise EvalError(
|
|
555
|
+
f"评测 fixture 超过基线摘要上限: {path} > {MAX_BASELINE_FIXTURE_BYTES} bytes"
|
|
556
|
+
)
|
|
557
|
+
return symbol_index.file_sha256(path)
|
|
558
|
+
except OSError as exc:
|
|
559
|
+
raise EvalError(f"无法读取评测 fixture: {path}: {exc}") from exc
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
def metrics_record(metrics: dict, cases_payload: dict,
|
|
563
|
+
findings_payload: dict, root: Path = REPO_ROOT,
|
|
564
|
+
feature_baseline_payload: dict | None = None) -> dict:
|
|
565
|
+
"""生成可持久化、可比较且不包含评测答案的基线记录。"""
|
|
566
|
+
cases = validate_cases(cases_payload, root)
|
|
567
|
+
cases_fingerprint = {
|
|
568
|
+
"schema_version": cases_payload.get("schema_version"),
|
|
569
|
+
"thresholds": cases_payload.get("thresholds"),
|
|
570
|
+
"cases": [
|
|
571
|
+
{
|
|
572
|
+
"id": case["id"],
|
|
573
|
+
"fixture": case["fixture"],
|
|
574
|
+
"fixture_sha256": _fixture_sha256(_resolve_in_root(case["fixture"], root)),
|
|
575
|
+
}
|
|
576
|
+
for case in cases
|
|
577
|
+
],
|
|
578
|
+
}
|
|
579
|
+
record = {
|
|
580
|
+
"schema_version": 1,
|
|
581
|
+
"created_at": dt.datetime.now(dt.timezone.utc).isoformat(),
|
|
582
|
+
"cases_digest": canonical_digest(cases_fingerprint),
|
|
583
|
+
"findings_digest": canonical_digest(findings_payload),
|
|
584
|
+
"metrics": dict(metrics),
|
|
585
|
+
}
|
|
586
|
+
if feature_baseline_payload is not None:
|
|
587
|
+
# baseline 对比必须绑定同一份功能基准(不同基准的 completeness 不可比)
|
|
588
|
+
record["feature_baseline_digest"] = canonical_digest(feature_baseline_payload)
|
|
589
|
+
return record
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
def baseline_failures(metrics: dict, baseline_payload: dict,
|
|
593
|
+
tolerance: float = 0.0) -> list[str]:
|
|
594
|
+
if not 0 <= tolerance <= 1:
|
|
595
|
+
raise EvalError("baseline tolerance 必须在 0..1")
|
|
596
|
+
baseline = baseline_payload.get("metrics")
|
|
597
|
+
if baseline_payload.get("schema_version") != 1 or not isinstance(baseline, dict):
|
|
598
|
+
raise EvalError("baseline metrics 协议无效")
|
|
599
|
+
failures: list[str] = []
|
|
600
|
+
# F-022:completeness_recall 数据驱动纳入回归对比——基线记录里带了它
|
|
601
|
+
# (生成时提供了 feature baseline)才要求当前运行也有。
|
|
602
|
+
watched = list(QUALITY_METRICS)
|
|
603
|
+
if "completeness_recall" in baseline:
|
|
604
|
+
watched.append("completeness_recall")
|
|
605
|
+
for name in watched:
|
|
606
|
+
expected = baseline.get(name)
|
|
607
|
+
actual = metrics.get(name)
|
|
608
|
+
if not isinstance(expected, (int, float)) or isinstance(expected, bool):
|
|
609
|
+
raise EvalError(f"baseline metrics 缺有效 {name}")
|
|
610
|
+
if not isinstance(actual, (int, float)) or isinstance(actual, bool):
|
|
611
|
+
raise EvalError(f"当前 metrics 缺有效 {name}")
|
|
612
|
+
allowed_drop = tolerance * (100.0 if name == "quality_score" else 1.0)
|
|
613
|
+
if float(actual) + allowed_drop < float(expected):
|
|
614
|
+
failures.append(
|
|
615
|
+
f"{name}={float(actual):.4f} 相比基线 {float(expected):.4f} 回退"
|
|
616
|
+
)
|
|
617
|
+
return failures
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
def _bounded_source(source: str, max_bytes: int | None) -> tuple[str, bool, int]:
|
|
621
|
+
encoded = source.encode("utf-8")
|
|
622
|
+
original_bytes = len(encoded)
|
|
623
|
+
if max_bytes is None or original_bytes <= max_bytes:
|
|
624
|
+
return source, False, original_bytes
|
|
625
|
+
marker = "\n\n[bugx] source truncated; audit only the supplied prefix.\n"
|
|
626
|
+
marker_bytes = marker.encode("utf-8")
|
|
627
|
+
if max_bytes <= len(marker_bytes):
|
|
628
|
+
raise EvalError("max_source_bytes 太小,无法保留截断标记")
|
|
629
|
+
prefix = encoded[:max_bytes - len(marker_bytes)].decode("utf-8", errors="ignore")
|
|
630
|
+
return prefix + marker, True, original_bytes
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
def build_runner_request(cases_payload: dict, root: Path = REPO_ROOT,
|
|
634
|
+
case_ids: set[str] | None = None,
|
|
635
|
+
max_source_bytes: int | None = None) -> dict:
|
|
636
|
+
"""构造不含 root_cause 标准答案的 runner 输入。"""
|
|
637
|
+
if max_source_bytes is not None and (
|
|
638
|
+
not isinstance(max_source_bytes, int)
|
|
639
|
+
or isinstance(max_source_bytes, bool)
|
|
640
|
+
or max_source_bytes < 1024
|
|
641
|
+
):
|
|
642
|
+
raise EvalError("max_source_bytes 必须为至少 1024 的整数")
|
|
643
|
+
cases = validate_cases(cases_payload, root)
|
|
644
|
+
if case_ids is not None:
|
|
645
|
+
unknown = set(case_ids) - {case["id"] for case in cases}
|
|
646
|
+
if unknown:
|
|
647
|
+
raise EvalError("未知 case_id: " + ", ".join(sorted(unknown)))
|
|
648
|
+
cases = [case for case in cases if case["id"] in case_ids]
|
|
649
|
+
if not cases:
|
|
650
|
+
raise EvalError("runner 请求至少需要一个 case")
|
|
651
|
+
public_cases = []
|
|
652
|
+
for case in cases:
|
|
653
|
+
fixture = _resolve_in_root(case["fixture"], root)
|
|
654
|
+
if fixture is None:
|
|
655
|
+
raise EvalError(f"fixture 不可读取: {case['fixture']}")
|
|
656
|
+
try:
|
|
657
|
+
source = fixture.read_text(encoding="utf-8", errors="replace")
|
|
658
|
+
except OSError as exc:
|
|
659
|
+
raise EvalError(f"fixture 不可读取: {case['fixture']}: {exc}") from exc
|
|
660
|
+
bounded, truncated, source_bytes = _bounded_source(source, max_source_bytes)
|
|
661
|
+
public_cases.append({
|
|
662
|
+
"id": case["id"],
|
|
663
|
+
"fixture": case["fixture"],
|
|
664
|
+
"source": bounded,
|
|
665
|
+
"source_bytes": source_bytes,
|
|
666
|
+
"source_truncated": truncated,
|
|
667
|
+
})
|
|
668
|
+
return {
|
|
669
|
+
"schema_version": 1,
|
|
670
|
+
"task": "audit",
|
|
671
|
+
"output_contract": {
|
|
672
|
+
"schema_version": 1,
|
|
673
|
+
"required_top_level": ["token_count", "findings"],
|
|
674
|
+
"required_finding_fields": [
|
|
675
|
+
"id", "case_id", "title", "root_cause", "severity", "confidence",
|
|
676
|
+
"evidence", "reproducible",
|
|
677
|
+
],
|
|
678
|
+
"conditional_fields": {
|
|
679
|
+
"reproduction": "required when reproducible is true",
|
|
680
|
+
},
|
|
681
|
+
},
|
|
682
|
+
"cases": public_cases,
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
def build_runner_requests(cases_payload: dict, root: Path = REPO_ROOT,
|
|
687
|
+
batch_size: int = DEFAULT_BATCH_SIZE,
|
|
688
|
+
max_prompt_bytes: int = DEFAULT_MAX_PROMPT_BYTES,
|
|
689
|
+
max_source_bytes: int | None = None) -> list[dict]:
|
|
690
|
+
"""按 case 数量和 JSON 大小上限构造确定性 runner 批次。"""
|
|
691
|
+
if isinstance(batch_size, bool) or batch_size < 1:
|
|
692
|
+
raise EvalError("batch_size 必须大于 0")
|
|
693
|
+
if (isinstance(max_prompt_bytes, bool)
|
|
694
|
+
or max_prompt_bytes < 1024 or max_prompt_bytes > MAX_PROMPT_BYTES):
|
|
695
|
+
raise EvalError(
|
|
696
|
+
f"max_prompt_bytes 必须在 1024..{MAX_PROMPT_BYTES}"
|
|
697
|
+
)
|
|
698
|
+
request = build_runner_request(
|
|
699
|
+
cases_payload, root, max_source_bytes=max_source_bytes,
|
|
700
|
+
)
|
|
701
|
+
template = dict(request)
|
|
702
|
+
template["cases"] = []
|
|
703
|
+
fixed_bytes = len(json.dumps(template, ensure_ascii=False, separators=(",", ":")))
|
|
704
|
+
batches: list[list[dict]] = []
|
|
705
|
+
current: list[dict] = []
|
|
706
|
+
for case in request["cases"]:
|
|
707
|
+
candidate = [*current, case]
|
|
708
|
+
candidate_bytes = fixed_bytes + len(
|
|
709
|
+
json.dumps(candidate, ensure_ascii=False, separators=(",", ":"))
|
|
710
|
+
)
|
|
711
|
+
if not current and candidate_bytes > max_prompt_bytes:
|
|
712
|
+
raise EvalError(
|
|
713
|
+
f"case {case['id']} 超过 max_prompt_bytes ({candidate_bytes} > "
|
|
714
|
+
f"{max_prompt_bytes});请降低 max_source_bytes 或提高 prompt 上限"
|
|
715
|
+
)
|
|
716
|
+
if current and (len(current) >= batch_size or candidate_bytes > max_prompt_bytes):
|
|
717
|
+
batches.append(current)
|
|
718
|
+
current = [case]
|
|
719
|
+
else:
|
|
720
|
+
current = candidate
|
|
721
|
+
if current:
|
|
722
|
+
batches.append(current)
|
|
723
|
+
total = len(batches)
|
|
724
|
+
result = []
|
|
725
|
+
for index, cases in enumerate(batches, 1):
|
|
726
|
+
batch = dict(request)
|
|
727
|
+
batch["cases"] = cases
|
|
728
|
+
batch["batch"] = {
|
|
729
|
+
"index": index,
|
|
730
|
+
"total": total,
|
|
731
|
+
"case_count": len(cases),
|
|
732
|
+
"estimated_bytes": fixed_bytes + len(
|
|
733
|
+
json.dumps(cases, ensure_ascii=False, separators=(",", ":"))
|
|
734
|
+
),
|
|
735
|
+
}
|
|
736
|
+
result.append(batch)
|
|
737
|
+
return result
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
def _runner_command(runner: str, runner_args: list[str], root: Path = REPO_ROOT) -> list[str]:
|
|
741
|
+
executable = shutil.which(runner)
|
|
742
|
+
if executable is None:
|
|
743
|
+
candidate = Path(runner)
|
|
744
|
+
if candidate.is_file():
|
|
745
|
+
executable = str(candidate.resolve())
|
|
746
|
+
if executable is None:
|
|
747
|
+
raise EvalError(f"runner 不存在或不可执行: {runner}")
|
|
748
|
+
resolved_args: list[str] = []
|
|
749
|
+
for value in runner_args:
|
|
750
|
+
candidate = Path(value)
|
|
751
|
+
rooted = candidate if candidate.is_absolute() else root / candidate
|
|
752
|
+
if rooted.is_file():
|
|
753
|
+
resolved_args.append(str(rooted.resolve()))
|
|
754
|
+
else:
|
|
755
|
+
resolved_args.append(value)
|
|
756
|
+
return [executable, *resolved_args]
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
def _runner_environment(pass_env: list[str] | None = None) -> dict[str, str]:
|
|
760
|
+
names = SAFE_ENV_NAMES | set(pass_env or [])
|
|
761
|
+
environment = {name: os.environ[name] for name in names if name in os.environ}
|
|
762
|
+
environment.setdefault("PYTHONIOENCODING", "utf-8")
|
|
763
|
+
return environment
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
class _RunnerOutput:
|
|
767
|
+
def __init__(self, limit: int) -> None:
|
|
768
|
+
self.limit = limit
|
|
769
|
+
self.prefix = bytearray()
|
|
770
|
+
self.total = 0
|
|
771
|
+
|
|
772
|
+
@property
|
|
773
|
+
def exceeded(self) -> bool:
|
|
774
|
+
return self.total > self.limit
|
|
775
|
+
|
|
776
|
+
def collect(self, stream) -> None:
|
|
777
|
+
while True:
|
|
778
|
+
chunk = stream.read(64 * 1024)
|
|
779
|
+
if not chunk:
|
|
780
|
+
return
|
|
781
|
+
self.total += len(chunk)
|
|
782
|
+
remaining = self.limit - len(self.prefix)
|
|
783
|
+
if remaining > 0:
|
|
784
|
+
self.prefix.extend(chunk[:remaining])
|
|
785
|
+
|
|
786
|
+
def value(self) -> bytes:
|
|
787
|
+
return bytes(self.prefix)
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
def _run_runner_process(command: list[str], input_text: str, cwd: Path,
|
|
791
|
+
env: dict[str, str] | None, timeout: float,
|
|
792
|
+
output_limit: int) -> tuple[int, bool, bool, bytes, bytes]:
|
|
793
|
+
creationflags = getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0) if os.name == "nt" else 0
|
|
794
|
+
try:
|
|
795
|
+
process = subprocess.Popen(
|
|
796
|
+
command,
|
|
797
|
+
cwd=cwd,
|
|
798
|
+
env=env,
|
|
799
|
+
stdin=subprocess.PIPE,
|
|
800
|
+
stdout=subprocess.PIPE,
|
|
801
|
+
stderr=subprocess.PIPE,
|
|
802
|
+
start_new_session=os.name != "nt",
|
|
803
|
+
creationflags=creationflags,
|
|
804
|
+
close_fds=os.name != "nt",
|
|
805
|
+
)
|
|
806
|
+
except OSError as exc:
|
|
807
|
+
raise EvalError(f"runner 启动失败: {exc}") from exc
|
|
808
|
+
stdout = _RunnerOutput(output_limit)
|
|
809
|
+
stderr = _RunnerOutput(output_limit)
|
|
810
|
+
readers = [
|
|
811
|
+
threading.Thread(target=stdout.collect, args=(process.stdout,), daemon=True),
|
|
812
|
+
threading.Thread(target=stderr.collect, args=(process.stderr,), daemon=True),
|
|
813
|
+
]
|
|
814
|
+
for reader in readers:
|
|
815
|
+
reader.start()
|
|
816
|
+
input_bytes = input_text.encode("utf-8")
|
|
817
|
+
|
|
818
|
+
def write_input() -> None:
|
|
819
|
+
try:
|
|
820
|
+
if process.stdin is not None:
|
|
821
|
+
process.stdin.write(input_bytes)
|
|
822
|
+
process.stdin.close()
|
|
823
|
+
except (BrokenPipeError, OSError):
|
|
824
|
+
pass
|
|
825
|
+
|
|
826
|
+
writer = threading.Thread(target=write_input, daemon=True)
|
|
827
|
+
writer.start()
|
|
828
|
+
deadline = time.monotonic() + timeout
|
|
829
|
+
timed_out = False
|
|
830
|
+
output_exceeded = False
|
|
831
|
+
try:
|
|
832
|
+
while process.poll() is None:
|
|
833
|
+
if stdout.exceeded or stderr.exceeded:
|
|
834
|
+
output_exceeded = True
|
|
835
|
+
_terminate_runner(process)
|
|
836
|
+
break
|
|
837
|
+
remaining = deadline - time.monotonic()
|
|
838
|
+
if remaining <= 0:
|
|
839
|
+
timed_out = True
|
|
840
|
+
_terminate_runner(process)
|
|
841
|
+
break
|
|
842
|
+
try:
|
|
843
|
+
process.wait(timeout=min(0.1, remaining))
|
|
844
|
+
except subprocess.TimeoutExpired:
|
|
845
|
+
continue
|
|
846
|
+
finally:
|
|
847
|
+
if timed_out or output_exceeded:
|
|
848
|
+
_terminate_runner(process)
|
|
849
|
+
writer.join(timeout=1)
|
|
850
|
+
for reader in readers:
|
|
851
|
+
reader.join(timeout=2)
|
|
852
|
+
for stream in (process.stdin, process.stdout, process.stderr):
|
|
853
|
+
if stream is not None:
|
|
854
|
+
stream.close()
|
|
855
|
+
output_exceeded = output_exceeded or stdout.exceeded or stderr.exceeded
|
|
856
|
+
return process.returncode or 0, timed_out, output_exceeded, stdout.value(), stderr.value()
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
def _materialize_runner_workspace(request: dict, workspace: Path) -> None:
|
|
860
|
+
"""只写入公开 fixture,不复制 cases/golden 或仓库其他内容。"""
|
|
861
|
+
for case in request["cases"]:
|
|
862
|
+
relative = Path(case["fixture"])
|
|
863
|
+
if relative.is_absolute() or ".." in relative.parts:
|
|
864
|
+
raise EvalError(f"runner fixture 路径不安全: {case['fixture']}")
|
|
865
|
+
target = workspace / relative
|
|
866
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
867
|
+
target.write_text(case["source"], encoding="utf-8")
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
def _isolate_local_runner_files(command: list[str], root: Path,
|
|
871
|
+
workspace: Path) -> list[str]:
|
|
872
|
+
"""复制作为参数传入的仓库内 runner 脚本,避免依赖原仓库 cwd。"""
|
|
873
|
+
isolated = [command[0]]
|
|
874
|
+
runner_dir = workspace / ".runner"
|
|
875
|
+
for index, value in enumerate(command[1:], 1):
|
|
876
|
+
candidate = Path(value)
|
|
877
|
+
try:
|
|
878
|
+
resolved = candidate.resolve(strict=True)
|
|
879
|
+
resolved.relative_to(root.resolve(strict=True))
|
|
880
|
+
except (OSError, ValueError):
|
|
881
|
+
isolated.append(value)
|
|
882
|
+
continue
|
|
883
|
+
if not resolved.is_file():
|
|
884
|
+
isolated.append(value)
|
|
885
|
+
continue
|
|
886
|
+
runner_dir.mkdir(parents=True, exist_ok=True)
|
|
887
|
+
target = runner_dir / f"{index}-{resolved.name}"
|
|
888
|
+
shutil.copy2(resolved, target)
|
|
889
|
+
isolated.append(str(target))
|
|
890
|
+
return isolated
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
def run_agent(cases_payload: dict, runner: str, runner_args: list[str],
|
|
894
|
+
root: Path = REPO_ROOT, timeout_seconds: float = 300.0,
|
|
895
|
+
isolate: bool = True, pass_env: list[str] | None = None,
|
|
896
|
+
max_output_bytes: int = 2_000_000,
|
|
897
|
+
batch_size: int = DEFAULT_BATCH_SIZE,
|
|
898
|
+
max_prompt_bytes: int = DEFAULT_MAX_PROMPT_BYTES,
|
|
899
|
+
max_source_bytes: int | None = None) -> dict:
|
|
900
|
+
"""通过 JSON 协议运行 Agent;默认隔离并按 case 成本分批。"""
|
|
901
|
+
if timeout_seconds <= 0:
|
|
902
|
+
raise EvalError("runner timeout 必须大于 0")
|
|
903
|
+
if max_output_bytes < 1024:
|
|
904
|
+
raise EvalError("runner max output 必须至少为 1024 bytes")
|
|
905
|
+
requests = build_runner_requests(
|
|
906
|
+
cases_payload, root, batch_size, max_prompt_bytes, max_source_bytes,
|
|
907
|
+
)
|
|
908
|
+
command = _runner_command(runner, runner_args, root)
|
|
909
|
+
environment = _runner_environment(pass_env) if isolate else None
|
|
910
|
+
started = time.monotonic()
|
|
911
|
+
outputs: list[dict] = []
|
|
912
|
+
reported_durations: list[float] = []
|
|
913
|
+
for batch_index, request in enumerate(requests, 1):
|
|
914
|
+
try:
|
|
915
|
+
with tempfile.TemporaryDirectory(prefix="bugx-runner-") as temporary:
|
|
916
|
+
workspace = Path(temporary)
|
|
917
|
+
batch_command = command
|
|
918
|
+
if isolate:
|
|
919
|
+
_materialize_runner_workspace(request, workspace)
|
|
920
|
+
batch_command = _isolate_local_runner_files(command, root, workspace)
|
|
921
|
+
returncode, timed_out, output_exceeded, stdout_bytes, stderr_bytes = (
|
|
922
|
+
_run_runner_process(
|
|
923
|
+
batch_command,
|
|
924
|
+
json.dumps(request, ensure_ascii=False),
|
|
925
|
+
workspace if isolate else root,
|
|
926
|
+
environment,
|
|
927
|
+
timeout_seconds,
|
|
928
|
+
max_output_bytes,
|
|
929
|
+
)
|
|
930
|
+
)
|
|
931
|
+
except subprocess.TimeoutExpired as exc:
|
|
932
|
+
raise EvalError(
|
|
933
|
+
f"runner 批次 {batch_index}/{len(requests)} 超时({timeout_seconds:g} 秒)"
|
|
934
|
+
) from exc
|
|
935
|
+
except OSError as exc:
|
|
936
|
+
raise EvalError(f"runner 批次 {batch_index} 启动失败: {exc}") from exc
|
|
937
|
+
if timed_out:
|
|
938
|
+
raise EvalError(
|
|
939
|
+
f"runner 批次 {batch_index}/{len(requests)} 超时({timeout_seconds:g} 秒)"
|
|
940
|
+
)
|
|
941
|
+
if output_exceeded:
|
|
942
|
+
raise EvalError(
|
|
943
|
+
f"runner 批次 {batch_index} 输出过大: "
|
|
944
|
+
f"stdout/stderr 超过 {max_output_bytes} bytes"
|
|
945
|
+
)
|
|
946
|
+
stdout_text = stdout_bytes.decode("utf-8", errors="replace")
|
|
947
|
+
stderr_text = stderr_bytes.decode("utf-8", errors="replace")
|
|
948
|
+
if returncode != 0:
|
|
949
|
+
detail = stderr_text.strip() or stdout_text.strip() or "无错误输出"
|
|
950
|
+
raise EvalError(
|
|
951
|
+
f"runner 返回 {returncode}(批次 {batch_index}/{len(requests)}): {detail}"
|
|
952
|
+
)
|
|
953
|
+
try:
|
|
954
|
+
payload = json.loads(stdout_text)
|
|
955
|
+
except json.JSONDecodeError as exc:
|
|
956
|
+
raise EvalError(f"runner 批次 {batch_index} stdout 不是纯 JSON: {exc}") from exc
|
|
957
|
+
if not isinstance(payload, dict):
|
|
958
|
+
raise EvalError("runner 输出根节点必须是对象")
|
|
959
|
+
payload.setdefault("schema_version", 1)
|
|
960
|
+
payload.setdefault("duration_seconds", 0.0)
|
|
961
|
+
payload.setdefault("token_count", 0)
|
|
962
|
+
payload.setdefault("findings", [])
|
|
963
|
+
validate_findings(payload)
|
|
964
|
+
if isinstance(payload["duration_seconds"], (int, float)):
|
|
965
|
+
reported_durations.append(float(payload["duration_seconds"]))
|
|
966
|
+
outputs.append(payload)
|
|
967
|
+
elapsed = round(time.monotonic() - started, 3)
|
|
968
|
+
findings = [finding for payload in outputs for finding in payload["findings"]]
|
|
969
|
+
payload = dict(outputs[0])
|
|
970
|
+
payload["findings"] = findings
|
|
971
|
+
payload["token_count"] = sum(int(item["token_count"]) for item in outputs)
|
|
972
|
+
payload["duration_seconds"] = elapsed
|
|
973
|
+
if reported_durations:
|
|
974
|
+
payload["runner_reported_duration_seconds"] = round(sum(reported_durations), 3)
|
|
975
|
+
payload["runner_execution"] = {
|
|
976
|
+
"workspace_isolated": isolate,
|
|
977
|
+
"environment_allowlist": sorted(_runner_environment(pass_env)) if isolate else None,
|
|
978
|
+
"network_isolated": False,
|
|
979
|
+
"note": "进程隔离不等于容器/虚拟机边界;网络和宿主文件系统仍需外层沙箱",
|
|
980
|
+
"batches": len(requests),
|
|
981
|
+
"batch_case_counts": [len(request["cases"]) for request in requests],
|
|
982
|
+
}
|
|
983
|
+
validate_findings(payload)
|
|
984
|
+
return payload
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
def _save_json_atomic(path: Path, payload: dict) -> None:
|
|
988
|
+
if not path.parent.is_dir():
|
|
989
|
+
raise EvalError(f"findings 输出目录不存在: {path.parent}")
|
|
990
|
+
descriptor, temporary = tempfile.mkstemp(
|
|
991
|
+
dir=str(path.parent), prefix=f".{path.name}.", suffix=".tmp",
|
|
992
|
+
)
|
|
993
|
+
try:
|
|
994
|
+
with os.fdopen(descriptor, "w", encoding="utf-8") as handle:
|
|
995
|
+
handle.write(json.dumps(payload, ensure_ascii=False, indent=2) + "\n")
|
|
996
|
+
os.replace(temporary, path)
|
|
997
|
+
except BaseException:
|
|
998
|
+
try:
|
|
999
|
+
os.unlink(temporary)
|
|
1000
|
+
except OSError:
|
|
1001
|
+
pass
|
|
1002
|
+
raise
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
def _print_score(metrics: dict, failures: list[str]) -> None:
|
|
1006
|
+
print("[agent_eval] Agent 行为评测")
|
|
1007
|
+
print(f" 发现率: {metrics['cases_found']}/{metrics['cases_total']} "
|
|
1008
|
+
f"({metrics['recall'] * 100:.1f}%)")
|
|
1009
|
+
print(f" 精确率: {metrics['precision'] * 100:.1f}%")
|
|
1010
|
+
print(f" 证据有效率: {metrics['evidence_validity'] * 100:.1f}%")
|
|
1011
|
+
print(f" 可复现率: {metrics['reproducibility'] * 100:.1f}%")
|
|
1012
|
+
print(f" 误报率: {metrics['false_positive_rate'] * 100:.1f}%")
|
|
1013
|
+
print(f" 重复率: {metrics['duplicate_rate'] * 100:.1f}%")
|
|
1014
|
+
print(f" 确认率: {metrics['confirmation_rate'] * 100:.1f}%")
|
|
1015
|
+
print(f" 综合质量分: {metrics['quality_score']:.2f}/100")
|
|
1016
|
+
if "completeness_recall" in metrics:
|
|
1017
|
+
# F-022:feature baseline 提供时输出 completeness 维度(管线解析依赖
|
|
1018
|
+
# 这些行前缀,勿改措辞)
|
|
1019
|
+
print(f" 完备性召回: {metrics['completeness_recall'] * 100:.1f}%")
|
|
1020
|
+
print(f" 完备性精确: {metrics['completeness_precision'] * 100:.1f}%")
|
|
1021
|
+
print(f" 植入缺失检出: {metrics['planted_gaps_found']}/{metrics['planted_gaps_total']}")
|
|
1022
|
+
print(f" 耗时/Token: {metrics['duration_seconds']:.3f}s / {metrics['token_count']}")
|
|
1023
|
+
if metrics["missed_case_ids"]:
|
|
1024
|
+
print(" 漏检: " + ", ".join(metrics["missed_case_ids"]))
|
|
1025
|
+
if metrics.get("missed_gap_ids"):
|
|
1026
|
+
print(" 漏检缺失: " + ", ".join(metrics["missed_gap_ids"]))
|
|
1027
|
+
if failures:
|
|
1028
|
+
print("[agent_eval] FAIL:")
|
|
1029
|
+
for failure in failures:
|
|
1030
|
+
print(f" ✗ {failure}")
|
|
1031
|
+
else:
|
|
1032
|
+
print("[agent_eval] PASS: 所有行为指标达到基线门槛")
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
def main(argv: list[str] | None = None) -> int:
|
|
1036
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
1037
|
+
parser.add_argument("command", choices=("validate", "score", "run"), nargs="?",
|
|
1038
|
+
default="score")
|
|
1039
|
+
parser.add_argument("--cases", type=Path, default=DEFAULT_CASES)
|
|
1040
|
+
parser.add_argument("--findings", type=Path, default=DEFAULT_FINDINGS)
|
|
1041
|
+
parser.add_argument("--root", type=Path, default=REPO_ROOT)
|
|
1042
|
+
parser.add_argument("--json", action="store_true")
|
|
1043
|
+
parser.add_argument("--strict", action="store_true")
|
|
1044
|
+
parser.add_argument(
|
|
1045
|
+
"--protocol-only", action="store_true",
|
|
1046
|
+
help="仅验证 run 的隔离、stdin/stdout JSON 协议与退出码,不计算质量分",
|
|
1047
|
+
)
|
|
1048
|
+
parser.add_argument("--runner", help="run 命令使用的可执行文件或 PATH 命令")
|
|
1049
|
+
parser.add_argument("--runner-arg", action="append", default=[],
|
|
1050
|
+
help="传给 runner 的单个参数,可重复")
|
|
1051
|
+
parser.add_argument("--timeout", type=float, default=300.0)
|
|
1052
|
+
parser.add_argument("--no-isolate", action="store_true",
|
|
1053
|
+
help="兼容模式:runner 使用仓库 cwd 和完整父进程环境")
|
|
1054
|
+
parser.add_argument("--pass-env", action="append", default=[],
|
|
1055
|
+
help="隔离模式额外传入的环境变量名,可重复")
|
|
1056
|
+
parser.add_argument("--max-output-bytes", type=int, default=2_000_000)
|
|
1057
|
+
parser.add_argument("--batch-size", type=int, default=DEFAULT_BATCH_SIZE,
|
|
1058
|
+
help=f"每个 runner 请求最多 case 数(默认 {DEFAULT_BATCH_SIZE})")
|
|
1059
|
+
parser.add_argument("--max-prompt-bytes", type=int, default=DEFAULT_MAX_PROMPT_BYTES,
|
|
1060
|
+
help="单个 runner 请求的 JSON 字节预算")
|
|
1061
|
+
parser.add_argument("--max-source-bytes", type=int,
|
|
1062
|
+
help="显式截断单个 fixture 的 UTF-8 字节数(默认不截断)")
|
|
1063
|
+
parser.add_argument("--save-findings", type=Path)
|
|
1064
|
+
parser.add_argument("--save-metrics", type=Path)
|
|
1065
|
+
parser.add_argument("--baseline-metrics", type=Path)
|
|
1066
|
+
parser.add_argument("--regression-tolerance", type=float, default=0.0)
|
|
1067
|
+
parser.add_argument("--feature-baseline", type=Path,
|
|
1068
|
+
help="功能完备性基准 JSON(F-022):提供时计算 completeness 维度并计入 quality_score")
|
|
1069
|
+
args = parser.parse_args(argv)
|
|
1070
|
+
try:
|
|
1071
|
+
if args.protocol_only and args.command != "run":
|
|
1072
|
+
raise EvalError("--protocol-only 仅可用于 run 命令")
|
|
1073
|
+
if args.protocol_only and (
|
|
1074
|
+
args.strict or args.baseline_metrics is not None
|
|
1075
|
+
or args.save_metrics is not None
|
|
1076
|
+
):
|
|
1077
|
+
raise EvalError(
|
|
1078
|
+
"--protocol-only 不得与 --strict、--baseline-metrics 或 --save-metrics 混用"
|
|
1079
|
+
)
|
|
1080
|
+
cases_payload = load_json(args.cases)
|
|
1081
|
+
validate_cases(cases_payload, args.root)
|
|
1082
|
+
if args.command == "run":
|
|
1083
|
+
if not args.runner:
|
|
1084
|
+
raise EvalError("run 命令必须提供 --runner")
|
|
1085
|
+
findings_payload = run_agent(
|
|
1086
|
+
cases_payload, args.runner, args.runner_arg, args.root, args.timeout,
|
|
1087
|
+
isolate=not args.no_isolate, pass_env=args.pass_env,
|
|
1088
|
+
max_output_bytes=args.max_output_bytes,
|
|
1089
|
+
batch_size=args.batch_size,
|
|
1090
|
+
max_prompt_bytes=args.max_prompt_bytes,
|
|
1091
|
+
max_source_bytes=args.max_source_bytes,
|
|
1092
|
+
)
|
|
1093
|
+
if args.save_findings:
|
|
1094
|
+
_save_json_atomic(args.save_findings, findings_payload)
|
|
1095
|
+
if args.protocol_only:
|
|
1096
|
+
payload = {
|
|
1097
|
+
"ok": True,
|
|
1098
|
+
"mode": "protocol-only",
|
|
1099
|
+
"findings_count": len(findings_payload["findings"]),
|
|
1100
|
+
"runner_execution": findings_payload["runner_execution"],
|
|
1101
|
+
}
|
|
1102
|
+
if args.json:
|
|
1103
|
+
print(json.dumps(payload, ensure_ascii=False, indent=2))
|
|
1104
|
+
else:
|
|
1105
|
+
print(
|
|
1106
|
+
"[agent_eval] PASS: runner 协议、隔离、JSON 输出与退出码有效;"
|
|
1107
|
+
"未执行质量评测"
|
|
1108
|
+
)
|
|
1109
|
+
return 0
|
|
1110
|
+
else:
|
|
1111
|
+
findings_payload = load_json(args.findings)
|
|
1112
|
+
findings = validate_findings(findings_payload)
|
|
1113
|
+
if args.command == "validate":
|
|
1114
|
+
invalid_evidence = invalid_evidence_ids(findings, args.root)
|
|
1115
|
+
if invalid_evidence:
|
|
1116
|
+
raise EvalError("finding 缺真实证据: " + ", ".join(invalid_evidence))
|
|
1117
|
+
print("[agent_eval] OK: cases/findings 协议与证据路径有效")
|
|
1118
|
+
return 0
|
|
1119
|
+
feature_baseline_payload = None
|
|
1120
|
+
if args.feature_baseline:
|
|
1121
|
+
feature_baseline_payload = load_json(args.feature_baseline)
|
|
1122
|
+
elif isinstance(cases_payload.get("feature_baseline"), dict):
|
|
1123
|
+
# F-022 管线接线:feature baseline 可随评测集内嵌(与 cases 同
|
|
1124
|
+
# 版本化),scenario_eval/fixture 场景无需独立 flag 即可启用
|
|
1125
|
+
# completeness 维度。显式 --feature-baseline 优先。
|
|
1126
|
+
feature_baseline_payload = cases_payload["feature_baseline"]
|
|
1127
|
+
metrics = score(cases_payload, findings_payload, args.root,
|
|
1128
|
+
feature_baseline_payload=feature_baseline_payload)
|
|
1129
|
+
failures = threshold_failures(metrics, cases_payload["thresholds"])
|
|
1130
|
+
if args.baseline_metrics:
|
|
1131
|
+
failures.extend(baseline_failures(
|
|
1132
|
+
metrics, load_json(args.baseline_metrics), args.regression_tolerance,
|
|
1133
|
+
))
|
|
1134
|
+
if args.save_metrics:
|
|
1135
|
+
_save_json_atomic(
|
|
1136
|
+
args.save_metrics,
|
|
1137
|
+
metrics_record(metrics, cases_payload, findings_payload, args.root,
|
|
1138
|
+
feature_baseline_payload=feature_baseline_payload),
|
|
1139
|
+
)
|
|
1140
|
+
except EvalError as exc:
|
|
1141
|
+
if args.json:
|
|
1142
|
+
print(json.dumps({"ok": False, "error": str(exc)}, ensure_ascii=False))
|
|
1143
|
+
else:
|
|
1144
|
+
print(f"[agent_eval] ✗ {exc}")
|
|
1145
|
+
return 2
|
|
1146
|
+
if args.json:
|
|
1147
|
+
print(json.dumps({"ok": not failures, "metrics": metrics, "failures": failures},
|
|
1148
|
+
ensure_ascii=False, indent=2))
|
|
1149
|
+
else:
|
|
1150
|
+
_print_score(metrics, failures)
|
|
1151
|
+
return 1 if args.strict and failures else 0
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
if __name__ == "__main__":
|
|
1155
|
+
sys.exit(main())
|