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,1108 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""core/test_generator.py - 自动化全息测试用例与脚手架生成引擎。
|
|
3
|
+
|
|
4
|
+
根据目标单元的 AST 符号签名(函数、方法、类、参数类型、默认值)与推荐的测试技术
|
|
5
|
+
(boundary, negative-control, property-based, concurrency, state-machine 等),
|
|
6
|
+
自动生成具备标准 Arrange-Act-Assert (AAA) 结构的高质量、可执行测试套件或自包含 PoC 脚本。
|
|
7
|
+
|
|
8
|
+
集成上下文感知测试用例合成器 (ContextualTestSynthesizer) 与毫秒级编译/语法门禁 (verify_code_syntax)。
|
|
9
|
+
生成可运行的 AAA 测试脚手架。没有业务 oracle 时只执行 smoke call;不会推测返回值或异常契约。
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
# --- 引擎导入根(直接执行脚本时自举 core.* 命名空间)---
|
|
14
|
+
import sys as _sys
|
|
15
|
+
from pathlib import Path as _Path
|
|
16
|
+
|
|
17
|
+
for _p in _Path(__file__).resolve().parents:
|
|
18
|
+
if (_p / "core" / "bugx.md").is_file():
|
|
19
|
+
if str(_p) not in _sys.path:
|
|
20
|
+
_sys.path.insert(0, str(_p))
|
|
21
|
+
break
|
|
22
|
+
del _p
|
|
23
|
+
|
|
24
|
+
import argparse
|
|
25
|
+
import ast
|
|
26
|
+
import json
|
|
27
|
+
import os
|
|
28
|
+
import re
|
|
29
|
+
import shutil
|
|
30
|
+
import subprocess
|
|
31
|
+
import sys
|
|
32
|
+
from dataclasses import dataclass, field
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
from typing import Any, Sequence
|
|
35
|
+
|
|
36
|
+
if str(Path(__file__).resolve().parent.parent) not in sys.path:
|
|
37
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
38
|
+
if str(Path(__file__).resolve().parent.parent.parent) not in sys.path:
|
|
39
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent))
|
|
40
|
+
|
|
41
|
+
__all__ = [
|
|
42
|
+
"ContextualTestSynthesizer",
|
|
43
|
+
"GeneratorError",
|
|
44
|
+
"ParameterInfo",
|
|
45
|
+
"TargetSymbol",
|
|
46
|
+
"TypeDescriptor",
|
|
47
|
+
"extract_target_symbol",
|
|
48
|
+
"generate_standalone_poc",
|
|
49
|
+
"generate_unittest_suite",
|
|
50
|
+
"verify_code_syntax",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class GeneratorError(ValueError):
|
|
55
|
+
"""测试用例生成异常。"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@dataclass
|
|
59
|
+
class ParameterInfo:
|
|
60
|
+
name: str
|
|
61
|
+
type_hint: str = "Any"
|
|
62
|
+
default_repr: str | None = None
|
|
63
|
+
has_default: bool = False
|
|
64
|
+
is_vararg: bool = False
|
|
65
|
+
is_kwarg: bool = False
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@dataclass
|
|
69
|
+
class TargetSymbol:
|
|
70
|
+
name: str
|
|
71
|
+
qualname: str
|
|
72
|
+
is_method: bool
|
|
73
|
+
class_name: str | None
|
|
74
|
+
is_async: bool
|
|
75
|
+
parameters: list[ParameterInfo]
|
|
76
|
+
return_hint: str
|
|
77
|
+
docstring: str
|
|
78
|
+
file_path: str
|
|
79
|
+
start_line: int
|
|
80
|
+
end_line: int
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass
|
|
84
|
+
class TypeDescriptor:
|
|
85
|
+
"""结构化类型元数据描述符。"""
|
|
86
|
+
|
|
87
|
+
kind: str # "primitive", "optional", "union", "list", "dict", "tuple", "set", "path", "any"
|
|
88
|
+
name: str = ""
|
|
89
|
+
inner: TypeDescriptor | None = None
|
|
90
|
+
elements: list[TypeDescriptor] = field(default_factory=list)
|
|
91
|
+
key_type: TypeDescriptor | None = None
|
|
92
|
+
val_type: TypeDescriptor | None = None
|
|
93
|
+
raw_str: str = ""
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _parse_type_ast(node: ast.AST) -> TypeDescriptor:
|
|
97
|
+
"""递归解析 AST 形式的复杂类型注解。"""
|
|
98
|
+
if isinstance(node, ast.Name):
|
|
99
|
+
nid = node.id
|
|
100
|
+
if nid.lower() in ("int", "float", "str", "bool", "bytes"):
|
|
101
|
+
return TypeDescriptor(kind="primitive", name=nid.lower(), raw_str=nid)
|
|
102
|
+
if nid in ("Path", "PurePath", "PosixPath", "WindowsPath"):
|
|
103
|
+
return TypeDescriptor(kind="path", name=nid, raw_str=nid)
|
|
104
|
+
if nid in ("list", "List", "Sequence", "Iterable", "MutableSequence"):
|
|
105
|
+
return TypeDescriptor(kind="list", name=nid, inner=TypeDescriptor(kind="any"), raw_str=nid)
|
|
106
|
+
if nid in ("dict", "Dict", "Mapping", "MutableMapping"):
|
|
107
|
+
return TypeDescriptor(kind="dict", name=nid, raw_str=nid)
|
|
108
|
+
if nid in ("set", "Set"):
|
|
109
|
+
return TypeDescriptor(kind="set", name=nid, raw_str=nid)
|
|
110
|
+
if nid in ("tuple", "Tuple"):
|
|
111
|
+
return TypeDescriptor(kind="tuple", name=nid, raw_str=nid)
|
|
112
|
+
if nid in ("None", "NoneType"):
|
|
113
|
+
return TypeDescriptor(kind="primitive", name="None", raw_str="None")
|
|
114
|
+
return TypeDescriptor(kind="any", name=nid, raw_str=nid)
|
|
115
|
+
|
|
116
|
+
if isinstance(node, ast.Attribute):
|
|
117
|
+
attr = node.attr
|
|
118
|
+
if attr in ("Path", "PurePath", "PosixPath", "WindowsPath"):
|
|
119
|
+
return TypeDescriptor(kind="path", name=attr, raw_str=attr)
|
|
120
|
+
if attr in ("Optional", "Union", "List", "Dict", "Sequence", "Iterable", "Set", "Tuple", "Any"):
|
|
121
|
+
return _parse_type_ast(ast.Name(id=attr, ctx=ast.Load()))
|
|
122
|
+
return TypeDescriptor(kind="any", name=attr, raw_str=attr)
|
|
123
|
+
|
|
124
|
+
if isinstance(node, ast.Constant):
|
|
125
|
+
if node.value is None:
|
|
126
|
+
return TypeDescriptor(kind="primitive", name="None", raw_str="None")
|
|
127
|
+
return TypeDescriptor(kind="primitive", name=str(node.value), raw_str=str(node.value))
|
|
128
|
+
|
|
129
|
+
if isinstance(node, ast.BinOp) and isinstance(node.op, ast.BitOr):
|
|
130
|
+
left_desc = _parse_type_ast(node.left)
|
|
131
|
+
right_desc = _parse_type_ast(node.right)
|
|
132
|
+
if left_desc.name == "None":
|
|
133
|
+
return TypeDescriptor(kind="optional", inner=right_desc, raw_str="optional")
|
|
134
|
+
if right_desc.name == "None":
|
|
135
|
+
return TypeDescriptor(kind="optional", inner=left_desc, raw_str="optional")
|
|
136
|
+
elements: list[TypeDescriptor] = []
|
|
137
|
+
for d in (left_desc, right_desc):
|
|
138
|
+
if d.kind == "union":
|
|
139
|
+
elements.extend(d.elements)
|
|
140
|
+
else:
|
|
141
|
+
elements.append(d)
|
|
142
|
+
return TypeDescriptor(kind="union", elements=elements, raw_str="union")
|
|
143
|
+
|
|
144
|
+
if isinstance(node, ast.Subscript):
|
|
145
|
+
val_name = ""
|
|
146
|
+
if isinstance(node.value, ast.Name):
|
|
147
|
+
val_name = node.value.id
|
|
148
|
+
elif isinstance(node.value, ast.Attribute):
|
|
149
|
+
val_name = node.value.attr
|
|
150
|
+
|
|
151
|
+
if val_name == "Optional":
|
|
152
|
+
inner_desc = _parse_type_ast(node.slice)
|
|
153
|
+
return TypeDescriptor(kind="optional", inner=inner_desc, raw_str="Optional")
|
|
154
|
+
|
|
155
|
+
if val_name == "Union":
|
|
156
|
+
elements = []
|
|
157
|
+
if isinstance(node.slice, ast.Tuple):
|
|
158
|
+
for elt in node.slice.elts:
|
|
159
|
+
elements.append(_parse_type_ast(elt))
|
|
160
|
+
else:
|
|
161
|
+
elements.append(_parse_type_ast(node.slice))
|
|
162
|
+
has_none = any(e.name == "None" for e in elements)
|
|
163
|
+
non_none = [e for e in elements if e.name != "None"]
|
|
164
|
+
if has_none and len(non_none) == 1:
|
|
165
|
+
return TypeDescriptor(kind="optional", inner=non_none[0], raw_str="Optional")
|
|
166
|
+
return TypeDescriptor(kind="union", elements=elements, raw_str="Union")
|
|
167
|
+
|
|
168
|
+
if val_name in ("list", "List", "Sequence", "Iterable", "MutableSequence"):
|
|
169
|
+
inner_desc = _parse_type_ast(node.slice)
|
|
170
|
+
return TypeDescriptor(kind="list", inner=inner_desc, raw_str=f"list[{inner_desc.name}]")
|
|
171
|
+
|
|
172
|
+
if val_name in ("dict", "Dict", "Mapping", "MutableMapping"):
|
|
173
|
+
k_desc, v_desc = None, None
|
|
174
|
+
if isinstance(node.slice, ast.Tuple) and len(node.slice.elts) == 2:
|
|
175
|
+
k_desc = _parse_type_ast(node.slice.elts[0])
|
|
176
|
+
v_desc = _parse_type_ast(node.slice.elts[1])
|
|
177
|
+
return TypeDescriptor(kind="dict", key_type=k_desc, val_type=v_desc, raw_str="dict")
|
|
178
|
+
|
|
179
|
+
if val_name in ("set", "Set"):
|
|
180
|
+
inner_desc = _parse_type_ast(node.slice)
|
|
181
|
+
return TypeDescriptor(kind="set", inner=inner_desc, raw_str="set")
|
|
182
|
+
|
|
183
|
+
if val_name in ("tuple", "Tuple"):
|
|
184
|
+
elts = []
|
|
185
|
+
if isinstance(node.slice, ast.Tuple):
|
|
186
|
+
for elt in node.slice.elts:
|
|
187
|
+
elts.append(_parse_type_ast(elt))
|
|
188
|
+
else:
|
|
189
|
+
elts.append(_parse_type_ast(node.slice))
|
|
190
|
+
return TypeDescriptor(kind="tuple", elements=elts, raw_str="tuple")
|
|
191
|
+
|
|
192
|
+
return TypeDescriptor(kind="any", raw_str=ast.unparse(node) if hasattr(ast, "unparse") else "")
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def parse_type_annotation(hint: str) -> TypeDescriptor:
|
|
196
|
+
"""解析任意类型注解字符串,返回结构化 TypeDescriptor。"""
|
|
197
|
+
if not hint or hint.strip() in ("", "Any", "object"):
|
|
198
|
+
return TypeDescriptor(kind="any", raw_str=hint or "Any")
|
|
199
|
+
hint_clean = hint.strip()
|
|
200
|
+
try:
|
|
201
|
+
tree = ast.parse(hint_clean, mode="eval")
|
|
202
|
+
return _parse_type_ast(tree.body)
|
|
203
|
+
except Exception:
|
|
204
|
+
# 正则与关键词降级容错
|
|
205
|
+
h_low = hint_clean.lower()
|
|
206
|
+
if "optional[" in h_low or "| none" in h_low or "none |" in h_low:
|
|
207
|
+
return TypeDescriptor(kind="optional", raw_str=hint_clean)
|
|
208
|
+
if "union[" in h_low or " | " in h_low:
|
|
209
|
+
return TypeDescriptor(kind="union", raw_str=hint_clean)
|
|
210
|
+
if "list[dict" in h_low or "sequence[dict" in h_low:
|
|
211
|
+
return TypeDescriptor(kind="list", inner=TypeDescriptor(kind="dict"), raw_str=hint_clean)
|
|
212
|
+
if "list[" in h_low or "sequence[" in h_low:
|
|
213
|
+
return TypeDescriptor(kind="list", raw_str=hint_clean)
|
|
214
|
+
if "dict[" in h_low or "mapping[" in h_low:
|
|
215
|
+
return TypeDescriptor(kind="dict", raw_str=hint_clean)
|
|
216
|
+
if "path" in h_low:
|
|
217
|
+
return TypeDescriptor(kind="path", raw_str=hint_clean)
|
|
218
|
+
if "int" in h_low:
|
|
219
|
+
return TypeDescriptor(kind="primitive", name="int", raw_str=hint_clean)
|
|
220
|
+
if "float" in h_low:
|
|
221
|
+
return TypeDescriptor(kind="primitive", name="float", raw_str=hint_clean)
|
|
222
|
+
if "str" in h_low:
|
|
223
|
+
return TypeDescriptor(kind="primitive", name="str", raw_str=hint_clean)
|
|
224
|
+
if "bool" in h_low:
|
|
225
|
+
return TypeDescriptor(kind="primitive", name="bool", raw_str=hint_clean)
|
|
226
|
+
return TypeDescriptor(kind="any", raw_str=hint_clean)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
class ContextualTestSynthesizer:
|
|
230
|
+
"""上下文感知、语义推断的测试用例生成器。
|
|
231
|
+
|
|
232
|
+
基于参数名称语义推断与复杂类型注解(Optional, Union, list[dict], Path, Sequence 等),
|
|
233
|
+
合成高保真合法基准输入、结构化极端边界值与反事实负对照毒化值。
|
|
234
|
+
"""
|
|
235
|
+
|
|
236
|
+
# 标准合规 JWT 样例
|
|
237
|
+
SAMPLE_JWT = (
|
|
238
|
+
'"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.'
|
|
239
|
+
'eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlRlc3QiLCJpYXQiOjE1MTYyMzkwMjJ9.'
|
|
240
|
+
'4phN4_39Fm8_k7654x_sample"'
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
def _match_semantic_param(self, name: str) -> str | None:
|
|
244
|
+
"""根据参数名称语义匹配专属基准值。"""
|
|
245
|
+
if not name:
|
|
246
|
+
return None
|
|
247
|
+
norm = name.lower().strip().replace("-", "_")
|
|
248
|
+
parts = set(norm.split("_"))
|
|
249
|
+
|
|
250
|
+
# port -> 8080
|
|
251
|
+
if norm == "port" or norm.endswith("_port") or "port" in parts:
|
|
252
|
+
return "8080"
|
|
253
|
+
|
|
254
|
+
# amount / balance / price -> 100.0
|
|
255
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("amount", "balance", "price", "cost", "fee")):
|
|
256
|
+
return "100.0"
|
|
257
|
+
|
|
258
|
+
# email -> "user_test@example.com"
|
|
259
|
+
if "email" in parts or "mail" in parts or norm.endswith("email"):
|
|
260
|
+
return '"user_test@example.com"'
|
|
261
|
+
|
|
262
|
+
# uuid -> "12345678-1234-5678-1234-567812345678"
|
|
263
|
+
if "uuid" in parts or "guid" in parts or norm.endswith("uuid"):
|
|
264
|
+
return '"12345678-1234-5678-1234-567812345678"'
|
|
265
|
+
|
|
266
|
+
# timestamp / date -> "2026-10-27T00:00:00Z"
|
|
267
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("timestamp", "date", "datetime", "created_at", "updated_at")):
|
|
268
|
+
return '"2026-10-27T00:00:00Z"'
|
|
269
|
+
|
|
270
|
+
# url -> "https://api.example.com/v1/test"
|
|
271
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("url", "uri", "endpoint", "link")):
|
|
272
|
+
return '"https://api.example.com/v1/test"'
|
|
273
|
+
|
|
274
|
+
# token -> 合法 JWT 样例
|
|
275
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("token", "jwt", "bearer", "auth_token")):
|
|
276
|
+
return self.SAMPLE_JWT
|
|
277
|
+
|
|
278
|
+
# ip -> "127.0.0.1"
|
|
279
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("ip", "ipv4", "host_ip", "client_ip", "ip_address")):
|
|
280
|
+
return '"127.0.0.1"'
|
|
281
|
+
|
|
282
|
+
# 通用语义启发式推断
|
|
283
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("username", "user", "author", "owner")):
|
|
284
|
+
return '"test_user"'
|
|
285
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("password", "secret", "passwd")):
|
|
286
|
+
return '"Secret_12345!"'
|
|
287
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("phone", "mobile", "tel")):
|
|
288
|
+
return '"+12345678901"'
|
|
289
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("host", "hostname", "domain")):
|
|
290
|
+
return '"localhost"'
|
|
291
|
+
|
|
292
|
+
return None
|
|
293
|
+
|
|
294
|
+
def synthesize_valid_value(self, param_name: str = "", type_hint: str = "Any", docstring: str = "") -> str:
|
|
295
|
+
"""根据参数名、类型注解及上下文语义合成高保真合法基准输入。"""
|
|
296
|
+
# 1. 优先尝试参数名称语义智能推断
|
|
297
|
+
semantic_val = self._match_semantic_param(param_name)
|
|
298
|
+
if semantic_val is not None:
|
|
299
|
+
return semantic_val
|
|
300
|
+
|
|
301
|
+
# 2. 复杂类型注解 AST 解析与合成
|
|
302
|
+
type_desc = parse_type_annotation(type_hint)
|
|
303
|
+
return self._synthesize_from_descriptor(param_name, type_desc)
|
|
304
|
+
|
|
305
|
+
def _synthesize_from_descriptor(self, param_name: str, desc: TypeDescriptor) -> str:
|
|
306
|
+
if desc.kind == "optional":
|
|
307
|
+
if desc.inner:
|
|
308
|
+
return self._synthesize_from_descriptor(param_name, desc.inner)
|
|
309
|
+
return "10"
|
|
310
|
+
|
|
311
|
+
if desc.kind == "union":
|
|
312
|
+
non_none = [e for e in desc.elements if e.name != "None"]
|
|
313
|
+
target_desc = non_none[0] if non_none else desc.elements[0]
|
|
314
|
+
return self._synthesize_from_descriptor(param_name, target_desc)
|
|
315
|
+
|
|
316
|
+
if desc.kind == "path":
|
|
317
|
+
return 'Path("test_file.txt")'
|
|
318
|
+
|
|
319
|
+
if desc.kind == "list":
|
|
320
|
+
if desc.inner and desc.inner.kind == "dict":
|
|
321
|
+
return '[{"sample_key": "sample_value"}]'
|
|
322
|
+
if desc.inner and desc.inner.name == "int":
|
|
323
|
+
return "[1, 2, 3]"
|
|
324
|
+
if desc.inner and desc.inner.name == "str":
|
|
325
|
+
return '["item_1", "item_2"]'
|
|
326
|
+
if desc.inner and desc.inner.name == "float":
|
|
327
|
+
return "[1.0, 2.0, 3.0]"
|
|
328
|
+
return '["item_1", "item_2"]'
|
|
329
|
+
|
|
330
|
+
if desc.kind == "dict":
|
|
331
|
+
return '{"sample_key": "sample_value"}'
|
|
332
|
+
|
|
333
|
+
if desc.kind == "tuple":
|
|
334
|
+
if desc.elements:
|
|
335
|
+
return f"({', '.join(self._synthesize_from_descriptor(param_name, e) for e in desc.elements)})"
|
|
336
|
+
return "(1, 2)"
|
|
337
|
+
|
|
338
|
+
if desc.kind == "set":
|
|
339
|
+
return '{"item_1", "item_2"}'
|
|
340
|
+
|
|
341
|
+
if desc.kind == "primitive":
|
|
342
|
+
if desc.name == "int":
|
|
343
|
+
p_low = param_name.lower().strip()
|
|
344
|
+
if p_low in ("a", "x", "left", "first"):
|
|
345
|
+
return "10"
|
|
346
|
+
if p_low in ("b", "y", "right", "second"):
|
|
347
|
+
return "20"
|
|
348
|
+
if any(k in p_low for k in ("id", "count", "num", "size", "limit", "total")):
|
|
349
|
+
return "10"
|
|
350
|
+
return "1"
|
|
351
|
+
|
|
352
|
+
if desc.name == "float":
|
|
353
|
+
p_low = param_name.lower().strip()
|
|
354
|
+
if p_low in ("a", "x", "left", "first"):
|
|
355
|
+
return "1.0"
|
|
356
|
+
if p_low in ("b", "y", "right", "second"):
|
|
357
|
+
return "2.0"
|
|
358
|
+
if any(k in p_low for k in ("rate", "ratio", "weight", "percent")):
|
|
359
|
+
return "0.5"
|
|
360
|
+
if any(k in p_low for k in ("timeout", "delay", "latency", "duration")):
|
|
361
|
+
return "5.0"
|
|
362
|
+
return "1.5"
|
|
363
|
+
|
|
364
|
+
if desc.name == "str":
|
|
365
|
+
if param_name:
|
|
366
|
+
return f'"sample_{param_name.lower()}"'
|
|
367
|
+
return '"sample_string"'
|
|
368
|
+
|
|
369
|
+
if desc.name == "bool":
|
|
370
|
+
return "True"
|
|
371
|
+
|
|
372
|
+
if desc.name == "bytes":
|
|
373
|
+
return 'b"sample_bytes"'
|
|
374
|
+
|
|
375
|
+
if desc.name == "None":
|
|
376
|
+
return "None"
|
|
377
|
+
|
|
378
|
+
# Any / fallback
|
|
379
|
+
if param_name:
|
|
380
|
+
inferred = _infer_type_from_name_and_annotation(param_name, None)
|
|
381
|
+
if inferred != "Any":
|
|
382
|
+
return self._synthesize_from_descriptor(param_name, parse_type_annotation(inferred))
|
|
383
|
+
return f'"sample_{param_name.lower()}"'
|
|
384
|
+
return '"test_value"'
|
|
385
|
+
|
|
386
|
+
def synthesize_boundary_values(self, param_name: str = "", type_hint: str = "Any", docstring: str = "") -> list[str]:
|
|
387
|
+
"""根据参数语义与类型注解生成结构化边界测试值与异常变异值。"""
|
|
388
|
+
norm = param_name.lower().strip().replace("-", "_")
|
|
389
|
+
parts = set(norm.split("_"))
|
|
390
|
+
|
|
391
|
+
# 语义边界值
|
|
392
|
+
if norm == "port" or norm.endswith("_port") or "port" in parts:
|
|
393
|
+
return ["0", "1", "65535", "65536", "-1"]
|
|
394
|
+
|
|
395
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("amount", "balance", "price", "cost", "fee")):
|
|
396
|
+
return ["0.0", "-0.01", "1000000.0", "float('inf')", "float('nan')"]
|
|
397
|
+
|
|
398
|
+
if "email" in parts or "mail" in parts or norm.endswith("email"):
|
|
399
|
+
return ['""', '"user@localhost"', '"invalid-email"', '"a" * 256 + "@example.com"']
|
|
400
|
+
|
|
401
|
+
if "uuid" in parts or "guid" in parts or norm.endswith("uuid"):
|
|
402
|
+
return ['""', '"00000000-0000-0000-0000-000000000000"', '"invalid-uuid"']
|
|
403
|
+
|
|
404
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("timestamp", "date", "datetime", "created_at", "updated_at")):
|
|
405
|
+
return ['""', '"1970-01-01T00:00:00Z"', '"9999-12-31T23:59:59Z"', '"invalid-date"']
|
|
406
|
+
|
|
407
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("url", "uri", "endpoint", "link")):
|
|
408
|
+
return ['""', '"http://localhost"', '"not_a_url"', '"https://" + "a" * 2048']
|
|
409
|
+
|
|
410
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("token", "jwt", "bearer", "auth_token")):
|
|
411
|
+
return ['""', '"expired.token.jwt"', '"Bearer "']
|
|
412
|
+
|
|
413
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("ip", "ipv4", "host_ip", "client_ip")):
|
|
414
|
+
return ['""', '"0.0.0.0"', '"255.255.255.255"', '"999.999.999.999"']
|
|
415
|
+
|
|
416
|
+
# 复杂类型边界值
|
|
417
|
+
type_desc = parse_type_annotation(type_hint)
|
|
418
|
+
return self._synthesize_boundary_from_desc(param_name, type_desc)
|
|
419
|
+
|
|
420
|
+
def _synthesize_boundary_from_desc(self, param_name: str, desc: TypeDescriptor) -> list[str]:
|
|
421
|
+
if desc.kind == "optional":
|
|
422
|
+
inner_boundaries = (
|
|
423
|
+
self._synthesize_boundary_from_desc(param_name, desc.inner)
|
|
424
|
+
if desc.inner
|
|
425
|
+
else ["0", '""']
|
|
426
|
+
)
|
|
427
|
+
return ["None"] + [b for b in inner_boundaries if b != "None"]
|
|
428
|
+
|
|
429
|
+
if desc.kind == "union":
|
|
430
|
+
combined: list[str] = []
|
|
431
|
+
has_none = any(e.name == "None" for e in desc.elements)
|
|
432
|
+
if has_none:
|
|
433
|
+
combined.append("None")
|
|
434
|
+
for elem in desc.elements:
|
|
435
|
+
if elem.name != "None":
|
|
436
|
+
for b in self._synthesize_boundary_from_desc(param_name, elem):
|
|
437
|
+
if b not in combined:
|
|
438
|
+
combined.append(b)
|
|
439
|
+
return combined or ["None", '""', "0"]
|
|
440
|
+
|
|
441
|
+
if desc.kind == "path":
|
|
442
|
+
return ['Path(".")', 'Path("/dev/null")', 'Path("/nonexistent/file.txt")', 'Path("/etc/passwd")']
|
|
443
|
+
|
|
444
|
+
if desc.kind == "list":
|
|
445
|
+
if desc.inner and desc.inner.kind == "dict":
|
|
446
|
+
return ["[]", "[{}]", "[{'nested': {'depth': 100}}]", "[{'key': None}]"]
|
|
447
|
+
if desc.inner and desc.inner.name == "int":
|
|
448
|
+
return ["[]", "[0]", "[-1]", "[1] * 1000"]
|
|
449
|
+
if desc.inner and desc.inner.name == "str":
|
|
450
|
+
return ["[]", '[""]', '["a" * 1000]']
|
|
451
|
+
return ["[]", "[None]", "[i for i in range(1000)]"]
|
|
452
|
+
|
|
453
|
+
if desc.kind == "dict":
|
|
454
|
+
return ["{}", '{"__proto__": True}', '{"nested": {"depth": 100}}', '{"": ""}']
|
|
455
|
+
|
|
456
|
+
if desc.kind == "primitive":
|
|
457
|
+
if desc.name == "int":
|
|
458
|
+
return ["0", "-1", "9223372036854775807", "-9223372036854775808"]
|
|
459
|
+
if desc.name == "float":
|
|
460
|
+
return ["0.0", "-0.0", "float('inf')", "float('-inf')", "float('nan')", "1e308"]
|
|
461
|
+
if desc.name == "str":
|
|
462
|
+
return ['""', '"A" * 4096', '"🚀你好世界\\x00\\n\\r"', '"../../etc/passwd"', '"\' OR \'1\'=\'1"']
|
|
463
|
+
if desc.name == "bool":
|
|
464
|
+
return ["False", "True"]
|
|
465
|
+
if desc.name == "bytes":
|
|
466
|
+
return [b'""', b'"\\x00" * 1024', b'"\\xff" * 1024']
|
|
467
|
+
|
|
468
|
+
return ["None", '""', "0"]
|
|
469
|
+
|
|
470
|
+
def synthesize_poison_value(self, param_name: str = "", type_hint: str = "Any") -> str:
|
|
471
|
+
"""合成用于负对照的反事实毒化值。"""
|
|
472
|
+
type_desc = parse_type_annotation(type_hint)
|
|
473
|
+
if type_desc.kind == "optional" and type_desc.inner:
|
|
474
|
+
type_desc = type_desc.inner
|
|
475
|
+
|
|
476
|
+
if type_desc.kind == "primitive" and type_desc.name in ("int", "float"):
|
|
477
|
+
return '"invalid_string_instead_of_number"'
|
|
478
|
+
|
|
479
|
+
if type_desc.kind == "primitive" and type_desc.name == "str":
|
|
480
|
+
return "12345"
|
|
481
|
+
|
|
482
|
+
if type_desc.kind == "path":
|
|
483
|
+
return "12345"
|
|
484
|
+
|
|
485
|
+
if type_desc.kind == "list":
|
|
486
|
+
return '"string_instead_of_list"'
|
|
487
|
+
|
|
488
|
+
if type_desc.kind == "dict":
|
|
489
|
+
return '"string_instead_of_dict"'
|
|
490
|
+
|
|
491
|
+
norm = param_name.lower().strip().replace("-", "_")
|
|
492
|
+
parts = set(norm.split("_"))
|
|
493
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("port", "amount", "balance", "price", "count", "num")):
|
|
494
|
+
return '"invalid_string_instead_of_number"'
|
|
495
|
+
if any(k in parts or norm.endswith(f"_{k}") or norm == k for k in ("email", "uuid", "timestamp", "date", "url", "token", "ip")):
|
|
496
|
+
return "12345"
|
|
497
|
+
|
|
498
|
+
return "object()"
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
_DEFAULT_SYNTHESIZER = ContextualTestSynthesizer()
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
def _sample_valid_value(type_hint: str, param_name: str = "") -> str:
|
|
505
|
+
"""向下兼容的合法基准值合成门禁。"""
|
|
506
|
+
return _DEFAULT_SYNTHESIZER.synthesize_valid_value(param_name, type_hint)
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
def _sample_boundary_values(type_hint: str, param_name: str = "") -> list[str]:
|
|
510
|
+
"""向下兼容的边界值集合合成门禁。"""
|
|
511
|
+
return _DEFAULT_SYNTHESIZER.synthesize_boundary_values(param_name, type_hint)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
def _sample_poison_value(type_hint: str, param_name: str = "") -> str:
|
|
515
|
+
"""向下兼容的毒化值合成门禁。"""
|
|
516
|
+
return _DEFAULT_SYNTHESIZER.synthesize_poison_value(param_name, type_hint)
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
def verify_code_syntax(
|
|
520
|
+
code_str: str,
|
|
521
|
+
language: str = "python",
|
|
522
|
+
timeout_seconds: float = 2.0,
|
|
523
|
+
) -> tuple[bool, str | None]:
|
|
524
|
+
"""毫秒级编译与语法合法性检查门禁函数。
|
|
525
|
+
|
|
526
|
+
- Python: 进程内 ast.parse 极速校验(微秒级,零子进程开销);
|
|
527
|
+
- 若语法错误,返回 (False, "Line X, Col Y: SyntaxError msg");
|
|
528
|
+
- 其它语言: 进程隔离沙箱在 timeout_seconds 约束下编译/静态检查,若缺少环境安全优雅回退。
|
|
529
|
+
"""
|
|
530
|
+
lang = (language or "python").lower().strip()
|
|
531
|
+
if lang in ("python", "py", "python3"):
|
|
532
|
+
try:
|
|
533
|
+
ast.parse(code_str)
|
|
534
|
+
return (True, None)
|
|
535
|
+
except SyntaxError as exc:
|
|
536
|
+
lineno = exc.lineno or 1
|
|
537
|
+
offset = exc.offset or 1
|
|
538
|
+
msg = exc.msg or "invalid syntax"
|
|
539
|
+
return (False, f"Line {lineno}, Col {offset}: SyntaxError {msg}")
|
|
540
|
+
except Exception as exc:
|
|
541
|
+
return (False, f"Line 1, Col 1: SyntaxError {exc}")
|
|
542
|
+
|
|
543
|
+
# 异构语言本地静态/语法检查(具备 timeout_seconds 硬超时与缺少环境时的优雅安全回退)
|
|
544
|
+
if lang in ("javascript", "js", "node"):
|
|
545
|
+
node_bin = shutil.which("node")
|
|
546
|
+
if not node_bin:
|
|
547
|
+
return (True, None)
|
|
548
|
+
try:
|
|
549
|
+
proc = subprocess.run(
|
|
550
|
+
[node_bin, "--check", "-e", code_str],
|
|
551
|
+
capture_output=True,
|
|
552
|
+
text=True,
|
|
553
|
+
timeout=timeout_seconds,
|
|
554
|
+
)
|
|
555
|
+
if proc.returncode != 0:
|
|
556
|
+
err = proc.stderr.strip() or proc.stdout.strip()
|
|
557
|
+
return (False, f"Line 1, Col 1: SyntaxError {err}")
|
|
558
|
+
return (True, None)
|
|
559
|
+
except subprocess.TimeoutExpired:
|
|
560
|
+
return (False, f"Line 1, Col 1: SyntaxError check timed out after {timeout_seconds}s")
|
|
561
|
+
except Exception:
|
|
562
|
+
return (True, None)
|
|
563
|
+
|
|
564
|
+
if lang in ("bash", "sh", "shell"):
|
|
565
|
+
bash_bin = shutil.which("bash") or shutil.which("sh")
|
|
566
|
+
if not bash_bin:
|
|
567
|
+
return (True, None)
|
|
568
|
+
try:
|
|
569
|
+
proc = subprocess.run(
|
|
570
|
+
[bash_bin, "-n", "-c", code_str],
|
|
571
|
+
capture_output=True,
|
|
572
|
+
text=True,
|
|
573
|
+
timeout=timeout_seconds,
|
|
574
|
+
)
|
|
575
|
+
if proc.returncode != 0:
|
|
576
|
+
err = proc.stderr.strip() or proc.stdout.strip()
|
|
577
|
+
return (False, f"Line 1, Col 1: SyntaxError {err}")
|
|
578
|
+
return (True, None)
|
|
579
|
+
except subprocess.TimeoutExpired:
|
|
580
|
+
return (False, f"Line 1, Col 1: SyntaxError check timed out after {timeout_seconds}s")
|
|
581
|
+
except Exception:
|
|
582
|
+
return (True, None)
|
|
583
|
+
|
|
584
|
+
return (True, None)
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
def _infer_type_from_name_and_annotation(name: str, annotation_node: ast.AST | None, docstring: str = "") -> str:
|
|
588
|
+
if annotation_node is not None:
|
|
589
|
+
try:
|
|
590
|
+
return ast.unparse(annotation_node).strip()
|
|
591
|
+
except Exception:
|
|
592
|
+
pass
|
|
593
|
+
|
|
594
|
+
lower = name.lower()
|
|
595
|
+
if any(k in lower for k in ("id", "count", "num", "size", "length", "port", "age", "index", "code")):
|
|
596
|
+
return "int"
|
|
597
|
+
if any(k in lower for k in ("name", "title", "path", "url", "str", "desc", "msg", "key", "token", "hash", "email", "uuid")):
|
|
598
|
+
return "str"
|
|
599
|
+
if any(k in lower for k in ("is_", "has_", "can_", "flag", "enabled", "strict", "allow")):
|
|
600
|
+
return "bool"
|
|
601
|
+
if any(k in lower for k in ("rate", "ratio", "weight", "timeout", "latency", "score", "factor", "amount", "balance", "price")):
|
|
602
|
+
return "float"
|
|
603
|
+
if any(k in lower for k in ("items", "list", "array", "rows", "lines", "values", "args")):
|
|
604
|
+
return "list"
|
|
605
|
+
if any(k in lower for k in ("data", "payload", "config", "options", "mapping", "dict", "info")):
|
|
606
|
+
return "dict"
|
|
607
|
+
|
|
608
|
+
if docstring:
|
|
609
|
+
pattern = re.compile(rf":type\s+{name}\s*:\s*([\w\[\],\s]+)", re.I)
|
|
610
|
+
match = pattern.search(docstring)
|
|
611
|
+
if match:
|
|
612
|
+
return match.group(1).strip()
|
|
613
|
+
return "Any"
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
def _return_assertion(result_name: str, return_hint: str) -> str:
|
|
617
|
+
"""Assert only a concrete declared return type; object/Any carries no oracle."""
|
|
618
|
+
hint = return_hint.strip().strip("'\"")
|
|
619
|
+
if hint in {"None", "NoneType"}:
|
|
620
|
+
return f"self.assertIsNone({result_name})"
|
|
621
|
+
if hint in {"bool", "int", "float", "str", "list", "dict", "tuple", "set", "bytes"}:
|
|
622
|
+
return f"self.assertIsInstance({result_name}, {hint})"
|
|
623
|
+
return ""
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
def extract_target_symbol(file_path: Path, scope: str) -> TargetSymbol:
|
|
627
|
+
if not file_path.is_file():
|
|
628
|
+
raise GeneratorError(f"目标文件不存在: {file_path}")
|
|
629
|
+
|
|
630
|
+
symbol_name = scope.split("::")[-1].strip() if "::" in scope else scope.strip()
|
|
631
|
+
class_name = None
|
|
632
|
+
func_name = symbol_name
|
|
633
|
+
if "." in symbol_name:
|
|
634
|
+
parts = symbol_name.split(".", 1)
|
|
635
|
+
class_name = parts[0]
|
|
636
|
+
func_name = parts[1]
|
|
637
|
+
|
|
638
|
+
try:
|
|
639
|
+
source = file_path.read_text(encoding="utf-8", errors="replace")
|
|
640
|
+
tree = ast.parse(source, filename=str(file_path))
|
|
641
|
+
except Exception as exc:
|
|
642
|
+
raise GeneratorError(f"无法解析目标源文件 AST: {file_path}: {exc}") from exc
|
|
643
|
+
|
|
644
|
+
target_node: ast.FunctionDef | ast.AsyncFunctionDef | ast.ClassDef | None = None
|
|
645
|
+
parent_class: str | None = None
|
|
646
|
+
|
|
647
|
+
for node in tree.body:
|
|
648
|
+
if isinstance(node, ast.ClassDef):
|
|
649
|
+
if class_name and node.name == class_name:
|
|
650
|
+
for sub in node.body:
|
|
651
|
+
if isinstance(sub, (ast.FunctionDef, ast.AsyncFunctionDef)) and sub.name == func_name:
|
|
652
|
+
target_node = sub
|
|
653
|
+
parent_class = class_name
|
|
654
|
+
break
|
|
655
|
+
elif not class_name and node.name == func_name:
|
|
656
|
+
# 目标本身是一个类
|
|
657
|
+
target_node = node
|
|
658
|
+
break
|
|
659
|
+
elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
|
660
|
+
if not class_name and node.name == func_name:
|
|
661
|
+
target_node = node
|
|
662
|
+
break
|
|
663
|
+
|
|
664
|
+
if target_node is None:
|
|
665
|
+
raise GeneratorError(f"在 {file_path} 中未找到目标符号: {scope}")
|
|
666
|
+
|
|
667
|
+
docstring = ast.get_docstring(target_node) or ""
|
|
668
|
+
start_line = target_node.lineno
|
|
669
|
+
end_line = getattr(target_node, "end_lineno", start_line)
|
|
670
|
+
|
|
671
|
+
if isinstance(target_node, ast.ClassDef):
|
|
672
|
+
# 如果目标是类,解析其 __init__
|
|
673
|
+
init_node = next(
|
|
674
|
+
(n for n in target_node.body if isinstance(n, ast.FunctionDef) and n.name == "__init__"),
|
|
675
|
+
None,
|
|
676
|
+
)
|
|
677
|
+
params: list[ParameterInfo] = []
|
|
678
|
+
if init_node:
|
|
679
|
+
args_list = init_node.args
|
|
680
|
+
defaults = [None] * (len(args_list.args) - len(args_list.defaults)) + list(args_list.defaults)
|
|
681
|
+
for arg_node, def_node in zip(args_list.args, defaults):
|
|
682
|
+
if arg_node.arg in ("self", "cls"):
|
|
683
|
+
continue
|
|
684
|
+
th = _infer_type_from_name_and_annotation(arg_node.arg, arg_node.annotation, docstring)
|
|
685
|
+
def_repr = ast.unparse(def_node) if def_node is not None else None
|
|
686
|
+
params.append(ParameterInfo(
|
|
687
|
+
name=arg_node.arg,
|
|
688
|
+
type_hint=th,
|
|
689
|
+
default_repr=def_repr,
|
|
690
|
+
has_default=def_node is not None,
|
|
691
|
+
))
|
|
692
|
+
return TargetSymbol(
|
|
693
|
+
name=target_node.name,
|
|
694
|
+
qualname=target_node.name,
|
|
695
|
+
is_method=False,
|
|
696
|
+
class_name=None,
|
|
697
|
+
is_async=False,
|
|
698
|
+
parameters=params,
|
|
699
|
+
return_hint=target_node.name,
|
|
700
|
+
docstring=docstring,
|
|
701
|
+
file_path=str(file_path),
|
|
702
|
+
start_line=start_line,
|
|
703
|
+
end_line=end_line,
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
# 目标是函数或方法
|
|
707
|
+
is_method = parent_class is not None
|
|
708
|
+
is_async = isinstance(target_node, ast.AsyncFunctionDef)
|
|
709
|
+
args_list = target_node.args
|
|
710
|
+
defaults = [None] * (len(args_list.args) - len(args_list.defaults)) + list(args_list.defaults)
|
|
711
|
+
params = []
|
|
712
|
+
for arg_node, def_node in zip(args_list.args, defaults):
|
|
713
|
+
if is_method and arg_node.arg in ("self", "cls"):
|
|
714
|
+
continue
|
|
715
|
+
th = _infer_type_from_name_and_annotation(arg_node.arg, arg_node.annotation, docstring)
|
|
716
|
+
def_repr = ast.unparse(def_node) if def_node is not None else None
|
|
717
|
+
params.append(ParameterInfo(
|
|
718
|
+
name=arg_node.arg,
|
|
719
|
+
type_hint=th,
|
|
720
|
+
default_repr=def_repr,
|
|
721
|
+
has_default=def_node is not None,
|
|
722
|
+
))
|
|
723
|
+
|
|
724
|
+
return_hint = "Any"
|
|
725
|
+
if target_node.returns:
|
|
726
|
+
try:
|
|
727
|
+
return_hint = ast.unparse(target_node.returns).strip()
|
|
728
|
+
except Exception:
|
|
729
|
+
pass
|
|
730
|
+
|
|
731
|
+
qualname = f"{parent_class}.{func_name}" if parent_class else func_name
|
|
732
|
+
return TargetSymbol(
|
|
733
|
+
name=func_name,
|
|
734
|
+
qualname=qualname,
|
|
735
|
+
is_method=is_method,
|
|
736
|
+
class_name=parent_class,
|
|
737
|
+
is_async=is_async,
|
|
738
|
+
parameters=params,
|
|
739
|
+
return_hint=return_hint,
|
|
740
|
+
docstring=docstring,
|
|
741
|
+
file_path=str(file_path),
|
|
742
|
+
start_line=start_line,
|
|
743
|
+
end_line=end_line,
|
|
744
|
+
)
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
def generate_unittest_suite(
|
|
748
|
+
symbol: TargetSymbol,
|
|
749
|
+
techniques: Sequence[str] | None = None,
|
|
750
|
+
output_path: Path | None = None,
|
|
751
|
+
assert_expr: str = "",
|
|
752
|
+
expected_exception: str = "",
|
|
753
|
+
) -> str:
|
|
754
|
+
"""生成 AAA 测试脚手架;不猜测目标的返回值或非法输入异常契约。"""
|
|
755
|
+
tech_set = set(techniques or ["boundary", "negative-control"])
|
|
756
|
+
assert_expr = assert_expr.strip()
|
|
757
|
+
expected_exception = expected_exception.strip()
|
|
758
|
+
if assert_expr:
|
|
759
|
+
try:
|
|
760
|
+
ast.parse(assert_expr, mode="eval")
|
|
761
|
+
except SyntaxError as exc:
|
|
762
|
+
raise GeneratorError(f"断言表达式无效: {exc.msg}") from exc
|
|
763
|
+
if expected_exception and not re.fullmatch(
|
|
764
|
+
r"[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*",
|
|
765
|
+
expected_exception,
|
|
766
|
+
):
|
|
767
|
+
raise GeneratorError("预期异常必须是类名或限定类名")
|
|
768
|
+
|
|
769
|
+
path_obj = Path(symbol.file_path).resolve()
|
|
770
|
+
module_stem = path_obj.stem
|
|
771
|
+
dir_path = str(path_obj.parent)
|
|
772
|
+
|
|
773
|
+
lines: list[str] = [
|
|
774
|
+
"#!/usr/bin/env python3",
|
|
775
|
+
f'"""由 BugX 测试生成器合成: 针对 {symbol.qualname} 的 AAA 测试脚手架。',
|
|
776
|
+
"",
|
|
777
|
+
"默认调用是 smoke check;除非调用者提供 oracle,否则不会声称结果或异常契约已验证。",
|
|
778
|
+
"边界输入与负对照仅作候选场景;负对照要求显式预期异常。",
|
|
779
|
+
]
|
|
780
|
+
if "concurrency" in tech_set:
|
|
781
|
+
lines.append(" 5. Concurrency 并发竞态与线程安全测试")
|
|
782
|
+
if "state-machine" in tech_set:
|
|
783
|
+
lines.append(" 6. Stateful 状态机非法跃迁与重入测试")
|
|
784
|
+
lines.extend([
|
|
785
|
+
'"""',
|
|
786
|
+
"",
|
|
787
|
+
"from __future__ import annotations",
|
|
788
|
+
"",
|
|
789
|
+
"import os",
|
|
790
|
+
"import sys",
|
|
791
|
+
"import unittest",
|
|
792
|
+
])
|
|
793
|
+
if symbol.is_async:
|
|
794
|
+
lines.append("import asyncio")
|
|
795
|
+
if "concurrency" in tech_set:
|
|
796
|
+
lines.append("import concurrent.futures")
|
|
797
|
+
lines.extend([
|
|
798
|
+
"from pathlib import Path",
|
|
799
|
+
"",
|
|
800
|
+
"# --- 安全引入目标模块 ---",
|
|
801
|
+
f"TARGET_DIR = os.environ.get('BUGX_TEST_TARGET_DIR', {repr(dir_path)})",
|
|
802
|
+
"if TARGET_DIR not in sys.path:",
|
|
803
|
+
" sys.path.insert(0, TARGET_DIR)",
|
|
804
|
+
"",
|
|
805
|
+
f"import {module_stem} as target_module",
|
|
806
|
+
"",
|
|
807
|
+
"",
|
|
808
|
+
f"class Test{symbol.name.replace('_', ' ').title().replace(' ', '')}Coverage(unittest.TestCase):",
|
|
809
|
+
' """针对目标符号的标准化 AAA 测试用例集。"""',
|
|
810
|
+
"",
|
|
811
|
+
" def setUp(self) -> None:",
|
|
812
|
+
' """[Arrange] 前置环境初始化。"""',
|
|
813
|
+
])
|
|
814
|
+
|
|
815
|
+
if symbol.is_method and symbol.class_name:
|
|
816
|
+
lines.append(f" # 实例化类 {symbol.class_name}")
|
|
817
|
+
lines.append(f" cls_obj = getattr(target_module, {repr(symbol.class_name)}, None)")
|
|
818
|
+
lines.append(" self.assertIsNotNone(cls_obj, '被测类不存在')")
|
|
819
|
+
lines.append(" try:")
|
|
820
|
+
lines.append(" self.instance = cls_obj()")
|
|
821
|
+
lines.append(" except TypeError:")
|
|
822
|
+
lines.append(" # 构造函数需要参数时的降级安全实例化")
|
|
823
|
+
lines.append(" self.instance = cls_obj.__new__(cls_obj)")
|
|
824
|
+
else:
|
|
825
|
+
lines.append(" pass")
|
|
826
|
+
|
|
827
|
+
lines.extend([
|
|
828
|
+
"",
|
|
829
|
+
" def tearDown(self) -> None:",
|
|
830
|
+
' """[Teardown] 后置清理与资源释放。"""',
|
|
831
|
+
" pass",
|
|
832
|
+
"",
|
|
833
|
+
])
|
|
834
|
+
|
|
835
|
+
synthesizer = _DEFAULT_SYNTHESIZER
|
|
836
|
+
|
|
837
|
+
# 1. Happy Path 测试
|
|
838
|
+
lines.extend([
|
|
839
|
+
" def test_happy_path_execution(self) -> None:",
|
|
840
|
+
' """[Happy Path] 验证合法基准输入下的正常执行与有效返回值。"""',
|
|
841
|
+
" # Arrange",
|
|
842
|
+
])
|
|
843
|
+
for p in symbol.parameters:
|
|
844
|
+
lines.append(f" {p.name} = {synthesizer.synthesize_valid_value(p.name, p.type_hint)}")
|
|
845
|
+
|
|
846
|
+
caller = f"self.instance.{symbol.name}" if symbol.is_method else f"target_module.{symbol.name}"
|
|
847
|
+
call_stmt = f"{caller}({', '.join(p.name for p in symbol.parameters)})"
|
|
848
|
+
if symbol.is_async:
|
|
849
|
+
call_stmt = f"asyncio.run({call_stmt})"
|
|
850
|
+
|
|
851
|
+
lines.extend([
|
|
852
|
+
"",
|
|
853
|
+
" # Act",
|
|
854
|
+
f" res = {call_stmt}",
|
|
855
|
+
])
|
|
856
|
+
if assert_expr:
|
|
857
|
+
lines.extend([
|
|
858
|
+
"",
|
|
859
|
+
" # Assert",
|
|
860
|
+
f" self.assertTrue({assert_expr}, '调用结果不符合提供的 oracle')",
|
|
861
|
+
])
|
|
862
|
+
else:
|
|
863
|
+
inferred_assertion = _return_assertion("res", symbol.return_hint)
|
|
864
|
+
if inferred_assertion:
|
|
865
|
+
lines.extend(["", " # Assert", f" {inferred_assertion}"])
|
|
866
|
+
else:
|
|
867
|
+
lines.extend([
|
|
868
|
+
"",
|
|
869
|
+
" # Smoke call only: provide --assert-expr for a semantic oracle.",
|
|
870
|
+
])
|
|
871
|
+
lines.append("")
|
|
872
|
+
|
|
873
|
+
# 2. Boundary 测试
|
|
874
|
+
lines.extend([
|
|
875
|
+
" def test_boundary_values(self) -> None:",
|
|
876
|
+
' """[Boundary] 验证极限边界参数下的防御性行为(未发生无防护崩溃)。"""',
|
|
877
|
+
])
|
|
878
|
+
if not symbol.parameters:
|
|
879
|
+
lines.append(" # 目标无参数,直接调用验证边界")
|
|
880
|
+
lines.append(f" res = {call_stmt}")
|
|
881
|
+
inferred_assertion = _return_assertion("res", symbol.return_hint)
|
|
882
|
+
if inferred_assertion:
|
|
883
|
+
lines.append(f" {inferred_assertion}")
|
|
884
|
+
else:
|
|
885
|
+
first_param = symbol.parameters[0]
|
|
886
|
+
boundaries = synthesizer.synthesize_boundary_values(first_param.name, first_param.type_hint)
|
|
887
|
+
lines.append(f" boundary_candidates = [{', '.join(boundaries)}]")
|
|
888
|
+
lines.append(" for b_val in boundary_candidates:")
|
|
889
|
+
lines.append(" with self.subTest(boundary_val=b_val):")
|
|
890
|
+
lines.append(" try:")
|
|
891
|
+
boundary_args = [f"b_val" if idx == 0 else synthesizer.synthesize_valid_value(p.name, p.type_hint)
|
|
892
|
+
for idx, p in enumerate(symbol.parameters)]
|
|
893
|
+
b_call = f"{caller}({', '.join(boundary_args)})"
|
|
894
|
+
if symbol.is_async:
|
|
895
|
+
b_call = f"asyncio.run({b_call})"
|
|
896
|
+
lines.append(f" res = {b_call}")
|
|
897
|
+
inferred_assertion = _return_assertion("res", symbol.return_hint)
|
|
898
|
+
if inferred_assertion:
|
|
899
|
+
lines.append(f" {inferred_assertion}")
|
|
900
|
+
lines.append(" except (ValueError, TypeError, KeyError, IndexError, ArithmeticError):")
|
|
901
|
+
lines.append(" # 预期内的合法输入防御异常")
|
|
902
|
+
lines.append(" pass")
|
|
903
|
+
lines.append("")
|
|
904
|
+
|
|
905
|
+
# 3. A negative control needs a caller-supplied exception contract.
|
|
906
|
+
if "negative-control" in tech_set and expected_exception and symbol.parameters:
|
|
907
|
+
lines.extend([
|
|
908
|
+
" def test_negative_control_dual_oracle(self) -> None:",
|
|
909
|
+
' """[Negative Control] 使用调用者声明的异常契约做反事实对照。"""',
|
|
910
|
+
])
|
|
911
|
+
for p in symbol.parameters:
|
|
912
|
+
lines.append(f" valid_{p.name} = {synthesizer.synthesize_valid_value(p.name, p.type_hint)}")
|
|
913
|
+
normal_call = f"{caller}({', '.join(f'valid_{p.name}' for p in symbol.parameters)})"
|
|
914
|
+
if symbol.is_async:
|
|
915
|
+
normal_call = f"asyncio.run({normal_call})"
|
|
916
|
+
lines.append(f" res = {normal_call}")
|
|
917
|
+
if assert_expr:
|
|
918
|
+
lines.append(f" self.assertTrue({assert_expr}, '正向对照不符合提供的 oracle')")
|
|
919
|
+
else:
|
|
920
|
+
inferred_assertion = _return_assertion("res", symbol.return_hint)
|
|
921
|
+
if inferred_assertion:
|
|
922
|
+
lines.append(f" {inferred_assertion}")
|
|
923
|
+
lines.append("")
|
|
924
|
+
poison_param = symbol.parameters[0]
|
|
925
|
+
poison_val = synthesizer.synthesize_poison_value(poison_param.name, poison_param.type_hint)
|
|
926
|
+
poison_args = ["poison_val" if idx == 0 else f"valid_{p.name}"
|
|
927
|
+
for idx, p in enumerate(symbol.parameters)]
|
|
928
|
+
poison_call = f"{caller}({', '.join(poison_args)})"
|
|
929
|
+
if symbol.is_async:
|
|
930
|
+
poison_call = f"asyncio.run({poison_call})"
|
|
931
|
+
lines.append(f" poison_val = {poison_val}")
|
|
932
|
+
lines.append(f" with self.assertRaises({expected_exception}):")
|
|
933
|
+
lines.append(f" {poison_call}")
|
|
934
|
+
lines.append("")
|
|
935
|
+
lines.append("")
|
|
936
|
+
|
|
937
|
+
# 4. 并发测试(若策略包含 concurrency)
|
|
938
|
+
if "concurrency" in tech_set:
|
|
939
|
+
lines.extend([
|
|
940
|
+
" def test_concurrency_race_safety(self) -> None:",
|
|
941
|
+
' """[Concurrency] 并发多线程交错轰炸,检测 TOCTOU 与竞态状态破坏。"""',
|
|
942
|
+
" errors: list[Exception] = []",
|
|
943
|
+
" def worker():",
|
|
944
|
+
" try:",
|
|
945
|
+
f" {call_stmt}",
|
|
946
|
+
" except Exception as exc:",
|
|
947
|
+
" errors.append(exc)",
|
|
948
|
+
"",
|
|
949
|
+
" with concurrent.futures.ThreadPoolExecutor(max_workers=8) as pool:",
|
|
950
|
+
" futures = [pool.submit(worker) for _ in range(20)]",
|
|
951
|
+
" concurrent.futures.wait(futures)",
|
|
952
|
+
"",
|
|
953
|
+
" self.assertEqual(len(errors), 0, f'并发执行发生未受控竞争错误: {errors}')",
|
|
954
|
+
"",
|
|
955
|
+
])
|
|
956
|
+
|
|
957
|
+
# 5. 状态机测试(若策略包含 state-machine)
|
|
958
|
+
if "state-machine" in tech_set:
|
|
959
|
+
lines.extend([
|
|
960
|
+
" def test_state_reentrancy_and_idempotency(self) -> None:",
|
|
961
|
+
' """[Stateful] 状态机重入与重复操作连续调用校验。"""',
|
|
962
|
+
f" first_run = {call_stmt}",
|
|
963
|
+
f" second_run = {call_stmt}",
|
|
964
|
+
" # 连续两次调用不应导致内部状态崩溃",
|
|
965
|
+
])
|
|
966
|
+
first_assertion = _return_assertion("first_run", symbol.return_hint)
|
|
967
|
+
second_assertion = _return_assertion("second_run", symbol.return_hint)
|
|
968
|
+
if first_assertion and second_assertion:
|
|
969
|
+
lines.extend([f" {first_assertion}", f" {second_assertion}"])
|
|
970
|
+
lines.append("")
|
|
971
|
+
|
|
972
|
+
lines.extend([
|
|
973
|
+
'if __name__ == "__main__":',
|
|
974
|
+
" unittest.main()",
|
|
975
|
+
"",
|
|
976
|
+
])
|
|
977
|
+
|
|
978
|
+
content = "\n".join(lines)
|
|
979
|
+
|
|
980
|
+
# 确定性物理语法门禁校验
|
|
981
|
+
is_valid, syntax_err = verify_code_syntax(content, language="python")
|
|
982
|
+
if not is_valid:
|
|
983
|
+
raise GeneratorError(f"生成的单元测试代码未通过语法编译门禁: {syntax_err}")
|
|
984
|
+
|
|
985
|
+
if output_path:
|
|
986
|
+
out = Path(output_path)
|
|
987
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
988
|
+
out.write_text(content, encoding="utf-8")
|
|
989
|
+
return content
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
def generate_standalone_poc(
|
|
993
|
+
symbol: TargetSymbol,
|
|
994
|
+
assert_expr: str = "",
|
|
995
|
+
expected_exception: str = "",
|
|
996
|
+
setup_code: str = "",
|
|
997
|
+
custom_call: str = "",
|
|
998
|
+
output_path: Path | None = None,
|
|
999
|
+
) -> str:
|
|
1000
|
+
"""合成单文件、零依赖自包含独立验证脚本,严格遵循 0/1 退出码契约。"""
|
|
1001
|
+
from core.repair.minimize_repro import synthesize_standalone_repro
|
|
1002
|
+
|
|
1003
|
+
path_obj = Path(symbol.file_path).resolve()
|
|
1004
|
+
caller = f"target.{symbol.name}"
|
|
1005
|
+
synthesizer = _DEFAULT_SYNTHESIZER
|
|
1006
|
+
if custom_call.strip():
|
|
1007
|
+
call_expr = custom_call.strip()
|
|
1008
|
+
elif symbol.is_method and symbol.class_name:
|
|
1009
|
+
call_expr = f"target.{symbol.class_name}().{symbol.name}({', '.join(synthesizer.synthesize_valid_value(p.name, p.type_hint) for p in symbol.parameters)})"
|
|
1010
|
+
else:
|
|
1011
|
+
call_expr = f"{caller}({', '.join(synthesizer.synthesize_valid_value(p.name, p.type_hint) for p in symbol.parameters)})"
|
|
1012
|
+
|
|
1013
|
+
if "Path(" in call_expr and "from pathlib import Path" not in setup_code:
|
|
1014
|
+
setup_code = ("from pathlib import Path\n" + setup_code).strip()
|
|
1015
|
+
|
|
1016
|
+
code = synthesize_standalone_repro(
|
|
1017
|
+
target_module=str(path_obj),
|
|
1018
|
+
call_expr=call_expr,
|
|
1019
|
+
expected_exception=expected_exception,
|
|
1020
|
+
assert_expr=assert_expr,
|
|
1021
|
+
setup_code=setup_code,
|
|
1022
|
+
output_path=output_path,
|
|
1023
|
+
)
|
|
1024
|
+
|
|
1025
|
+
# 确定性物理语法门禁校验
|
|
1026
|
+
is_valid, syntax_err = verify_code_syntax(code, language="python")
|
|
1027
|
+
if not is_valid:
|
|
1028
|
+
if output_path and Path(output_path).exists():
|
|
1029
|
+
Path(output_path).unlink(missing_ok=True)
|
|
1030
|
+
raise GeneratorError(f"生成的独立 PoC 脚本未通过语法编译门禁: {syntax_err}")
|
|
1031
|
+
|
|
1032
|
+
return code
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
def main(argv: list[str] | None = None) -> int:
|
|
1036
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
1037
|
+
parser.add_argument("--root", type=Path, default=Path.cwd(), help="项目根路径")
|
|
1038
|
+
parser.add_argument("--file", type=Path, help="目标源文件路径(相对或绝对)")
|
|
1039
|
+
parser.add_argument("--scope", required=True, help="被测单元符号范围,如 path/foo.py::MyClass.func")
|
|
1040
|
+
parser.add_argument("--techniques", default="boundary,negative-control", help="测试策略逗号分隔列表")
|
|
1041
|
+
parser.add_argument("--out", type=Path, help="生成的测试文件保存路径")
|
|
1042
|
+
parser.add_argument("--standalone", action="store_true", help="是否生成单文件 0/1 独立验证 PoC 脚本")
|
|
1043
|
+
parser.add_argument("--assert-expr", default="", help="PoC 模式下的成功断言表达式")
|
|
1044
|
+
parser.add_argument("--expected-exc", default="", help="PoC 模式下的预期缺陷异常类名")
|
|
1045
|
+
parser.add_argument("--json", action="store_true", help="输出机器可读 JSON")
|
|
1046
|
+
args = parser.parse_args(argv)
|
|
1047
|
+
|
|
1048
|
+
root = args.root.resolve()
|
|
1049
|
+
scope = args.scope.strip()
|
|
1050
|
+
if args.file:
|
|
1051
|
+
target_file = (root / args.file).resolve() if not args.file.is_absolute() else args.file
|
|
1052
|
+
elif "::" in scope:
|
|
1053
|
+
target_file = (root / scope.split("::", 1)[0]).resolve()
|
|
1054
|
+
else:
|
|
1055
|
+
target_file = (root / scope).resolve()
|
|
1056
|
+
|
|
1057
|
+
try:
|
|
1058
|
+
symbol = extract_target_symbol(target_file, scope)
|
|
1059
|
+
techniques = [t.strip() for t in args.techniques.split(",") if t.strip()]
|
|
1060
|
+
|
|
1061
|
+
if args.standalone:
|
|
1062
|
+
code = generate_standalone_poc(
|
|
1063
|
+
symbol,
|
|
1064
|
+
assert_expr=args.assert_expr,
|
|
1065
|
+
expected_exception=args.expected_exc,
|
|
1066
|
+
output_path=args.out,
|
|
1067
|
+
)
|
|
1068
|
+
else:
|
|
1069
|
+
code = generate_unittest_suite(
|
|
1070
|
+
symbol,
|
|
1071
|
+
techniques=techniques,
|
|
1072
|
+
output_path=args.out,
|
|
1073
|
+
assert_expr=args.assert_expr,
|
|
1074
|
+
expected_exception=args.expected_exc,
|
|
1075
|
+
)
|
|
1076
|
+
|
|
1077
|
+
if args.json:
|
|
1078
|
+
result = {
|
|
1079
|
+
"status": "success",
|
|
1080
|
+
"scope": scope,
|
|
1081
|
+
"target_symbol": {
|
|
1082
|
+
"name": symbol.name,
|
|
1083
|
+
"qualname": symbol.qualname,
|
|
1084
|
+
"is_method": symbol.is_method,
|
|
1085
|
+
"is_async": symbol.is_async,
|
|
1086
|
+
"parameters": [
|
|
1087
|
+
{"name": p.name, "type_hint": p.type_hint, "has_default": p.has_default}
|
|
1088
|
+
for p in symbol.parameters
|
|
1089
|
+
],
|
|
1090
|
+
},
|
|
1091
|
+
"techniques": techniques,
|
|
1092
|
+
"output_path": str(args.out) if args.out else None,
|
|
1093
|
+
"lines_count": len(code.splitlines()),
|
|
1094
|
+
}
|
|
1095
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
1096
|
+
else:
|
|
1097
|
+
if args.out:
|
|
1098
|
+
print(f"[test_generator] ✓ 成功为 {scope} 生成测试脚手架 -> {args.out}")
|
|
1099
|
+
else:
|
|
1100
|
+
print(code)
|
|
1101
|
+
return 0
|
|
1102
|
+
except GeneratorError as exc:
|
|
1103
|
+
print(f"[test_generator] ✗ 错误: {exc}", file=sys.stderr)
|
|
1104
|
+
return 2
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
if __name__ == "__main__":
|
|
1108
|
+
raise SystemExit(main())
|