bugx-cli 0.0.0-stage → 0.1.0
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.
- package/LICENSE +55 -0
- package/README.md +280 -2
- package/core/CATALOG.json +141 -0
- package/core/README.md +254 -0
- package/core/adapters/README.md +35 -0
- package/core/adapters/android-interaction.json +81 -0
- package/core/adapters/android.json +24 -0
- package/core/adapters/desktop-macos.json +20 -0
- package/core/adapters/ios-interaction.json +34 -0
- package/core/adapters/ios.json +23 -0
- package/core/adapters/memory-macos.json +24 -0
- package/core/agent/README.md +50 -0
- package/core/agent/__init__.py +146 -0
- package/core/agent/agent_artifacts.py +764 -0
- package/core/agent/agent_eval.py +1073 -0
- package/core/agent/agent_execution.py +552 -0
- package/core/agent/agent_orchestrator.py +1345 -0
- package/core/agent/agent_targets.py +871 -0
- package/core/agent/agent_workspace.py +770 -0
- package/core/assets/README.md +24 -0
- package/core/assets/bugx-avatar-1024.png +0 -0
- package/core/assets/bugx-avatar-512.png +0 -0
- package/core/assets/bugx-avatar-tight.svg +23 -0
- package/core/assets/bugx-avatar.svg +28 -0
- package/core/assets/bugx-hero-cn.png +0 -0
- package/core/assets/bugx-hero-en.png +0 -0
- package/core/assets/project-layout.md +42 -0
- package/core/audit_packs/README.md +37 -0
- package/core/audit_packs/data-audit/manifest.json +94 -0
- package/core/audit_packs/data-audit/stages/00-scope.md +14 -0
- package/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
- package/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
- package/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
- package/core/audit_packs/desktop-audit/manifest.json +123 -0
- package/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
- package/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
- package/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
- package/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
- package/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
- package/core/audit_packs/memory-testing.md +227 -0
- package/core/audit_packs/mobile-audit/manifest.json +155 -0
- package/core/audit_packs/mobile-audit/modules/android.md +19 -0
- package/core/audit_packs/mobile-audit/modules/h5.md +18 -0
- package/core/audit_packs/mobile-audit/modules/ios.md +25 -0
- package/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
- package/core/audit_packs/mobile-audit/modules/webview.md +18 -0
- package/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
- package/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
- package/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
- package/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
- package/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
- package/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
- package/core/audit_packs/native-audit/manifest.json +127 -0
- package/core/audit_packs/native-audit/stages/00-scope.md +14 -0
- package/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
- package/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
- package/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
- package/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
- package/core/audit_packs/platform-testing.md +174 -0
- package/core/audit_packs/web-audit/manifest.json +191 -0
- package/core/audit_packs/web-audit/modules/graphql.md +5 -0
- package/core/audit_packs/web-audit/modules/h5.md +18 -0
- package/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
- package/core/audit_packs/web-audit/modules/oauth.md +4 -0
- package/core/audit_packs/web-audit/modules/upload.md +4 -0
- package/core/audit_packs/web-audit/modules/websocket.md +4 -0
- package/core/audit_packs/web-audit/stages/00-scope.md +13 -0
- package/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
- package/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
- package/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
- package/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
- package/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
- package/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
- package/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
- package/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
- package/core/autonomous_cve/INTERFACE.md +61 -0
- package/core/autonomous_cve/README.md +58 -0
- package/core/autonomous_cve/SPEC.md +25 -0
- package/core/autonomous_cve/__init__.py +109 -0
- package/core/autonomous_cve/attack_graph.py +1096 -0
- package/core/autonomous_cve/attack_graph_store.py +1822 -0
- package/core/autonomous_cve/audit_campaign.py +1232 -0
- package/core/autonomous_cve/behavior_graph.py +459 -0
- package/core/autonomous_cve/ghsa_advisories.py +174 -0
- package/core/autonomous_cve/models.py +93 -0
- package/core/autonomous_cve/mutator.py +87 -0
- package/core/autonomous_cve/patcher.py +126 -0
- package/core/autonomous_cve/scout.py +278 -0
- package/core/autonomous_cve/synthesizer.py +207 -0
- package/core/autonomous_cve/verifier.py +100 -0
- package/core/bugx.md +1299 -0
- package/core/bugx_paths.py +1846 -0
- package/core/cloud_sync/INTERFACE.md +32 -0
- package/core/cloud_sync/README.md +62 -0
- package/core/cloud_sync/SPEC.md +25 -0
- package/core/cloud_sync/__init__.py +23 -0
- package/core/cloud_sync/auto_sync.py +398 -0
- package/core/cloud_sync/cloud_client.py +1199 -0
- package/core/cloud_sync/cloud_onboard.py +702 -0
- package/core/cloud_sync/cloud_schema.py +648 -0
- package/core/cloud_sync/consent.py +81 -0
- package/core/cloud_sync/device_identity.py +307 -0
- package/core/cloud_sync/endpoint_router.py +415 -0
- package/core/cloud_sync/flywheel_client.py +760 -0
- package/core/cloud_sync/network_transport.py +275 -0
- package/core/cloud_sync/onboard_wizard.py +493 -0
- package/core/cloud_sync/sensitive_filter.py +285 -0
- package/core/cloud_sync/sync_pull.py +695 -0
- package/core/cloud_sync/sync_push.py +721 -0
- package/core/contracts/AGENT_GUIDE.md +362 -0
- package/core/contracts/README.md +34 -0
- package/core/contracts/bugx-blackbox.md +541 -0
- package/core/contracts/bugx-opencode.md +469 -0
- package/core/contracts/bugx-quick.md +44 -0
- package/core/contracts/bugx-runtime-contract.md +353 -0
- package/core/contracts/bugx-worker.md +470 -0
- package/core/contracts/engine_gap_contracts.py +390 -0
- package/core/coverage/README.md +70 -0
- package/core/coverage/__init__.py +106 -0
- package/core/coverage/coverage_ai_review.py +185 -0
- package/core/coverage/coverage_backfill.py +54 -0
- package/core/coverage/coverage_bootstrap.py +713 -0
- package/core/coverage/coverage_business.py +36 -0
- package/core/coverage/coverage_cli.py +715 -0
- package/core/coverage/coverage_discovery.py +859 -0
- package/core/coverage/coverage_evidence.py +977 -0
- package/core/coverage/coverage_forensics.py +115 -0
- package/core/coverage/coverage_gate.py +277 -0
- package/core/coverage/coverage_intelligence.py +734 -0
- package/core/coverage/coverage_manifest.py +396 -0
- package/core/coverage/coverage_platform.py +77 -0
- package/core/coverage/coverage_validate.py +236 -0
- package/core/coverage/module_coverage.py +157 -0
- package/core/dev_harness/INTERFACE.md +20 -0
- package/core/dev_harness/README.md +21 -0
- package/core/dev_harness/SPEC.md +25 -0
- package/core/dev_harness/__init__.py +5 -0
- package/core/dev_harness/interaction_preset.py +408 -0
- package/core/engine-integrity.json +2625 -0
- package/core/fuzzing/README.md +49 -0
- package/core/fuzzing/__init__.py +82 -0
- package/core/fuzzing/concurrency_fuzzer.py +382 -0
- package/core/fuzzing/differential_oracle.py +629 -0
- package/core/fuzzing/fuzz_input.py +1188 -0
- package/core/fuzzing/stateful_fuzzer.py +332 -0
- package/core/governance/README.md +61 -0
- package/core/governance/__init__.py +130 -0
- package/core/governance/capacity_planner.py +124 -0
- package/core/governance/dependency_lock.py +317 -0
- package/core/governance/goal_governor.py +754 -0
- package/core/governance/guide_budget.py +458 -0
- package/core/governance/lockdown.sh +50 -0
- package/core/governance/readonly_enforcer.py +154 -0
- package/core/governance/runtime_tool_gate.py +373 -0
- package/core/governance/secret_redactor.py +772 -0
- package/core/governance/token_budget.py +38 -0
- package/core/host_acp/INTERFACE.md +36 -0
- package/core/host_acp/README.md +51 -0
- package/core/host_acp/SPEC.md +25 -0
- package/core/host_acp/__init__.py +121 -0
- package/core/host_acp/base.py +111 -0
- package/core/host_acp/claude.py +41 -0
- package/core/host_acp/cline.py +235 -0
- package/core/host_acp/codex.py +245 -0
- package/core/host_acp/dsh.py +48 -0
- package/core/host_acp/opencode.py +154 -0
- package/core/host_acp/pi.py +36 -0
- package/core/host_acp/zcode.py +41 -0
- package/core/host_runtime/INTERFACE.md +24 -0
- package/core/host_runtime/README.md +62 -0
- package/core/host_runtime/SPEC.md +25 -0
- package/core/host_runtime/__init__.py +21 -0
- package/core/host_runtime/adapters.py +412 -0
- package/core/host_runtime/autonomous_runner.py +1152 -0
- package/core/host_runtime/cline.py +435 -0
- package/core/host_runtime/common.py +103 -0
- package/core/host_runtime/free_models.py +786 -0
- package/core/host_runtime/host_bootstrap.py +389 -0
- package/core/host_runtime/host_evaluators.py +721 -0
- package/core/host_runtime/host_probe.py +41 -0
- package/core/host_runtime/host_provider_arbitrator.py +777 -0
- package/core/host_runtime/host_registry.py +655 -0
- package/core/host_runtime/host_usage.py +127 -0
- package/core/host_runtime/mcp_process_tracker.py +509 -0
- package/core/host_runtime/mcp_registry_gate.py +368 -0
- package/core/hosts/INTERFACE.md +51 -0
- package/core/hosts/README.md +67 -0
- package/core/hosts/SPEC.md +25 -0
- package/core/hosts/__init__.py +136 -0
- package/core/hosts/_base_usage.py +152 -0
- package/core/hosts/_codex_usage.py +297 -0
- package/core/hosts/_dsh_usage.py +184 -0
- package/core/hosts/_mcp_toml.py +365 -0
- package/core/hosts/_zcode_usage.py +269 -0
- package/core/hosts/base.py +451 -0
- package/core/hosts/claude.py +157 -0
- package/core/hosts/cline.py +225 -0
- package/core/hosts/codex.py +948 -0
- package/core/hosts/dsh.py +518 -0
- package/core/hosts/opencode.py +358 -0
- package/core/hosts/pi.py +151 -0
- package/core/hosts/zcode.py +219 -0
- package/core/i18n.py +252 -0
- package/core/infra/README.md +39 -0
- package/core/infra/__init__.py +15 -0
- package/core/infra/build_info.py +86 -0
- package/core/infra/client_metadata.py +185 -0
- package/core/infra/python_runtime.py +540 -0
- package/core/infra/safe_xml.py +221 -0
- package/core/launch_bugx.py +118 -0
- package/core/launch_phases/INTERFACE.md +31 -0
- package/core/launch_phases/README.md +106 -0
- package/core/launch_phases/SPEC.md +25 -0
- package/core/launch_phases/__init__.py +29 -0
- package/core/launch_phases/candidate_revalidation.py +484 -0
- package/core/launch_phases/common.py +1041 -0
- package/core/launch_phases/finding_confirm_phase.py +387 -0
- package/core/launch_phases/finding_settlement.py +1245 -0
- package/core/launch_phases/findings_adjudication.py +666 -0
- package/core/launch_phases/findings_snapshot.py +357 -0
- package/core/launch_phases/judge_phase.py +791 -0
- package/core/launch_phases/lesson_context.py +536 -0
- package/core/launch_phases/lifecycle_reporter.py +627 -0
- package/core/launch_phases/orchestrator_controls.py +682 -0
- package/core/launch_phases/post_commit.py +567 -0
- package/core/launch_phases/post_coverage_sync.py +591 -0
- package/core/launch_phases/post_dry_run.py +817 -0
- package/core/launch_phases/post_observability.py +367 -0
- package/core/launch_phases/post_phase.py +1087 -0
- package/core/launch_phases/post_receipt.py +362 -0
- package/core/launch_phases/post_round_lifecycle.py +786 -0
- package/core/launch_phases/pre_phase.py +1029 -0
- package/core/launch_phases/pre_recon_scout.py +862 -0
- package/core/launch_phases/pre_state_builder.py +1286 -0
- package/core/launch_phases/report_sharing.py +414 -0
- package/core/launch_phases/round_orchestrator.py +1133 -0
- package/core/launch_phases/session_runtime.py +1623 -0
- package/core/launch_phases/startup_gates.py +1022 -0
- package/core/launch_phases/startup_interaction.py +947 -0
- package/core/launch_phases/startup_version_gate.py +873 -0
- package/core/launch_phases/supervisor_bridge.py +1224 -0
- package/core/launch_phases/supervisor_coverage.py +417 -0
- package/core/launch_phases/supervisor_degraded.py +1219 -0
- package/core/launch_phases/worker_barriers.py +414 -0
- package/core/launch_phases/worker_orchestrator.py +1166 -0
- package/core/launch_phases/worker_prior.py +749 -0
- package/core/ledger/INTERFACE.md +35 -0
- package/core/ledger/README.md +160 -0
- package/core/ledger/SPEC.md +25 -0
- package/core/ledger/__init__.py +67 -0
- package/core/ledger/_facade.py +226 -0
- package/core/ledger/archive_ops.py +572 -0
- package/core/ledger/auto_materialization.py +459 -0
- package/core/ledger/bug-log.md +22 -0
- package/core/ledger/cli.py +270 -0
- package/core/ledger/export_ops.py +549 -0
- package/core/ledger/finding_confirmation.py +1274 -0
- package/core/ledger/finding_io.py +299 -0
- package/core/ledger/finding_lifecycle.py +307 -0
- package/core/ledger/finding_verification.py +369 -0
- package/core/ledger/incidents.py +999 -0
- package/core/ledger/lesson-replay-cases.json +20 -0
- package/core/ledger/lesson_ledger.py +241 -0
- package/core/ledger/lesson_replay.py +272 -0
- package/core/ledger/life_ledger.py +668 -0
- package/core/ledger/mistake-book.md +130 -0
- package/core/ledger/patterns.py +681 -0
- package/core/ledger/receipt_contract.py +253 -0
- package/core/ledger/schema.py +1192 -0
- package/core/ledger/sync_ops.py +935 -0
- package/core/ledger/tool_experience.py +682 -0
- package/core/ledger/verify_life.py +1526 -0
- package/core/lesson-ledger.json +275 -0
- package/core/locales/README.md +19 -0
- package/core/locales/en-US.json +462 -0
- package/core/locales/zh-CN.json +462 -0
- package/core/mcp_handlers/INTERFACE.md +75 -0
- package/core/mcp_handlers/README.md +62 -0
- package/core/mcp_handlers/SPEC.md +25 -0
- package/core/mcp_handlers/__init__.py +128 -0
- package/core/mcp_handlers/base.py +697 -0
- package/core/mcp_handlers/channel_lifecycle.py +696 -0
- package/core/mcp_handlers/graph_handlers.py +222 -0
- package/core/mcp_handlers/knowledge_handlers.py +536 -0
- package/core/mcp_handlers/mining_handlers.py +586 -0
- package/core/mcp_handlers/resource_prompt_table.py +116 -0
- package/core/mcp_handlers/retrieval_handlers.py +239 -0
- package/core/mcp_handlers/rpc_server.py +465 -0
- package/core/mcp_handlers/supervisor_handlers.py +1435 -0
- package/core/mcp_handlers/telemetry_handlers.py +227 -0
- package/core/mcp_handlers/tool_table.py +1015 -0
- package/core/mcp_runtime_support/README.md +21 -0
- package/core/mcp_runtime_support/__init__.py +1 -0
- package/core/mcp_runtime_support/common.py +363 -0
- package/core/mcp_runtime_support/environment.py +605 -0
- package/core/mcp_runtime_support/verifier.py +810 -0
- package/core/metadata.txt +5 -0
- package/core/planning/README.md +157 -0
- package/core/planning/__init__.py +242 -0
- package/core/planning/capability_plan.py +187 -0
- package/core/planning/capability_planner.py +195 -0
- package/core/planning/domain_archetype.py +542 -0
- package/core/planning/domain_router.py +267 -0
- package/core/planning/dynamic_flow_analyzer.py +328 -0
- package/core/planning/impact_pruner.py +435 -0
- package/core/planning/intent_adjudicator.py +175 -0
- package/core/planning/judge_pipeline.py +1163 -0
- package/core/planning/logic_analysis.py +419 -0
- package/core/planning/prompt_harness.py +1702 -0
- package/core/planning/source_inspector.py +267 -0
- package/core/planning/spec_harvester.py +449 -0
- package/core/planning/target_sandbox_manager.py +573 -0
- package/core/planning/test_capability_verifier.py +1364 -0
- package/core/planning/tools-kb.md +38 -0
- package/core/planning/unit_kind.py +122 -0
- package/core/probes/INTERFACE.md +73 -0
- package/core/probes/README.md +51 -0
- package/core/probes/SPEC.md +26 -0
- package/core/probes/__init__.py +70 -0
- package/core/probes/android_probe.py +384 -0
- package/core/probes/base.py +147 -0
- package/core/probes/codebase_memory_probe.py +590 -0
- package/core/probes/desktop_probe.py +238 -0
- package/core/probes/differential_probe.py +356 -0
- package/core/probes/efficiency_probe.py +168 -0
- package/core/probes/ios_binary_probe.py +368 -0
- package/core/probes/memory_probe.py +326 -0
- package/core/probes/miniprogram_probe.py +323 -0
- package/core/probes/mobile_probe.py +281 -0
- package/core/probes/native_probe.py +214 -0
- package/core/probes/openwiki_probe.py +193 -0
- package/core/probes/pattern_probe.py +347 -0
- package/core/probes/platform_probe.py +343 -0
- package/core/probes/probe_registry.py +1669 -0
- package/core/probes/sast_probe.py +1009 -0
- package/core/probes/sast_rules.py +841 -0
- package/core/probes/sca_scanner.py +731 -0
- package/core/probes/web_probe.py +359 -0
- package/core/project_profiler/INTERFACE.md +62 -0
- package/core/project_profiler/README.md +53 -0
- package/core/project_profiler/SPEC.md +28 -0
- package/core/project_profiler/__init__.py +201 -0
- package/core/project_profiler/arbitrator.py +311 -0
- package/core/project_profiler/constants.py +247 -0
- package/core/project_profiler/detector.py +392 -0
- package/core/project_profiler/extractors.py +836 -0
- package/core/project_profiler/fingerprint.py +116 -0
- package/core/project_profiler/storage.py +258 -0
- package/core/project_profiler/strategy.py +265 -0
- package/core/prompts/README.md +35 -0
- package/core/prompts/codex_dialog_dispatch.md +9 -0
- package/core/prompts/command_routing_en.md +42 -0
- package/core/prompts/command_routing_zh.md +42 -0
- package/core/prompts/l0_router.md +47 -0
- package/core/prompts/rules/anti_patterns.md +16 -0
- package/core/prompts/rules/concurrency_rules.md +14 -0
- package/core/prompts/rules/memory_leak_rules.md +13 -0
- package/core/prompts/rules/prompt_injection_defense.md +13 -0
- package/core/prompts/stages/stage_explore.md +31 -0
- package/core/prompts/stages/stage_gate.md +43 -0
- package/core/prompts/stages/stage_mutate.md +42 -0
- package/core/prompts/stages/stage_repair.md +85 -0
- package/core/repair/README.md +74 -0
- package/core/repair/__init__.py +169 -0
- package/core/repair/fix_watchlist.py +391 -0
- package/core/repair/l7_dynamic.py +418 -0
- package/core/repair/l7_repair_loop.py +465 -0
- package/core/repair/l7_selfcheck.py +862 -0
- package/core/repair/minimize_repro.py +466 -0
- package/core/repair/patch_synthesizer.py +617 -0
- package/core/repair/regression_pack.py +379 -0
- package/core/repair/rsi_fixer.py +910 -0
- package/core/repair/rsi_loop.py +313 -0
- package/core/repair/rsi_repair.py +348 -0
- package/core/repair/rsi_rounds.py +212 -0
- package/core/repair/rsi_scope.py +262 -0
- package/core/repair/self_heal.py +604 -0
- package/core/repair/test_generator.py +1108 -0
- package/core/repair/test_quality_auditor.py +410 -0
- package/core/repair/test_strategy.py +511 -0
- package/core/report_engine/INTERFACE.md +59 -0
- package/core/report_engine/README.md +69 -0
- package/core/report_engine/SPEC.md +28 -0
- package/core/report_engine/__init__.py +47 -0
- package/core/report_engine/attestation.py +224 -0
- package/core/report_engine/authority.py +255 -0
- package/core/report_engine/finding_report.py +417 -0
- package/core/report_engine/formal_report_builder.py +924 -0
- package/core/report_engine/html_renderers.py +696 -0
- package/core/report_engine/models.py +761 -0
- package/core/report_engine/pdf_exporter.py +231 -0
- package/core/report_engine/projects_assets.py +730 -0
- package/core/report_engine/report_client.py +743 -0
- package/core/report_engine/report_data_builder.py +388 -0
- package/core/report_engine/report_share.py +459 -0
- package/core/report_engine/sast_bridge.py +116 -0
- package/core/report_engine/server.py +822 -0
- package/core/report_engine/visual_report_builder.py +796 -0
- package/core/report_engine/web-conformance.md +63 -0
- package/core/report_engine/web_conformance.py +459 -0
- package/core/report_engine/workbench_assets.py +484 -0
- package/core/retrieval/INTERFACE.md +20 -0
- package/core/retrieval/README.md +161 -0
- package/core/retrieval/SPEC.md +25 -0
- package/core/retrieval/__init__.py +3 -0
- package/core/retrieval/code_analyzer.py +1684 -0
- package/core/retrieval/codebase_memory_bridge.py +337 -0
- package/core/retrieval/context_assembler.py +234 -0
- package/core/retrieval/corpus_fetch.py +369 -0
- package/core/retrieval/graph_ego.py +597 -0
- package/core/retrieval/knowledge_auto.py +662 -0
- package/core/retrieval/knowledge_sources.py +168 -0
- package/core/retrieval/knowledge_sync.py +909 -0
- package/core/retrieval/memory_store.py +480 -0
- package/core/retrieval/query_planner.py +1020 -0
- package/core/retrieval/rrf_engine.py +137 -0
- package/core/retrieval/slice_extractor.py +1209 -0
- package/core/retrieval/slice_normalizer.py +373 -0
- package/core/retrieval/slice_spec.py +357 -0
- package/core/retrieval/symbol_index.py +1132 -0
- package/core/retrieval/universal_code_matcher.py +437 -0
- package/core/retrieval/xerj_bridge.py +476 -0
- package/core/retrieval/xerj_supervisor.py +362 -0
- package/core/rules/README.md +33 -0
- package/core/rules/ios/PROVENANCE.json +30 -0
- package/core/rules/ios/crypto.yaml +36 -0
- package/core/rules/ios/network.yaml +20 -0
- package/core/rules/ios/resilience.yaml +47 -0
- package/core/rules/ios/storage.yaml +48 -0
- package/core/rules/mastg/LICENSE +173 -0
- package/core/rules/mastg/PROVENANCE.json +270 -0
- package/core/rules/mastg/mastg-android-asymmetric-key-pair-used-for-multiple-purposes.yml +13 -0
- package/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
- package/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
- package/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
- package/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
- package/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
- package/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
- package/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
- package/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
- package/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
- package/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
- package/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml +36 -0
- package/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-manifest.yml +15 -0
- package/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
- package/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
- package/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
- package/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
- package/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
- package/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
- package/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
- package/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
- package/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
- package/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
- package/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
- package/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
- package/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
- package/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
- package/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
- package/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
- package/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
- package/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
- package/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
- package/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
- package/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
- package/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
- package/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
- package/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
- package/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
- package/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
- package/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
- package/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
- package/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
- package/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
- package/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
- package/core/rules/mastg/mastg-android-strictmode.yml +10 -0
- package/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
- package/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
- package/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
- package/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
- package/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
- package/core/rules/miniprogram/PROVENANCE.json +26 -0
- package/core/rules/miniprogram/network.yaml +37 -0
- package/core/rules/miniprogram/platform.yaml +36 -0
- package/core/rules/miniprogram/storage.yaml +48 -0
- package/core/rules/mobsfscan-swift/LICENSE +165 -0
- package/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
- package/core/rules/mobsfscan-swift/auth.yaml +59 -0
- package/core/rules/mobsfscan-swift/crypto.yaml +66 -0
- package/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
- package/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
- package/core/rules/mobsfscan-swift/logging.yaml +23 -0
- package/core/rules/mobsfscan-swift/network.yaml +55 -0
- package/core/rules/mobsfscan-swift/resilience.yaml +29 -0
- package/core/rules/mobsfscan-swift/secrets.yaml +33 -0
- package/core/rules/mobsfscan-swift/storage.yaml +29 -0
- package/core/rules/mobsfscan-swift/webview.yaml +32 -0
- package/core/runtime/README.md +198 -0
- package/core/runtime/__init__.py +3 -0
- package/core/runtime/bugx_logging.py +1393 -0
- package/core/runtime/daemon_runner.py +623 -0
- package/core/runtime/fixture_solidify.py +449 -0
- package/core/runtime/global_telemetry.py +549 -0
- package/core/runtime/incident_eval.py +148 -0
- package/core/runtime/interaction.py +605 -0
- package/core/runtime/interaction_store.py +435 -0
- package/core/runtime/interactive_menu.py +95 -0
- package/core/runtime/log_analytics.py +922 -0
- package/core/runtime/mining_quality_framework.py +1387 -0
- package/core/runtime/model_runner.py +769 -0
- package/core/runtime/platform_adapter.py +579 -0
- package/core/runtime/prep_validate.py +476 -0
- package/core/runtime/project_graph.py +827 -0
- package/core/runtime/project_init.py +481 -0
- package/core/runtime/project_profile.py +224 -0
- package/core/runtime/project_settings.py +963 -0
- package/core/runtime/provider_window.py +97 -0
- package/core/runtime/resume_ticket.py +115 -0
- package/core/runtime/scenario_eval.py +814 -0
- package/core/runtime/seed_drill.py +549 -0
- package/core/runtime/self_audit.py +550 -0
- package/core/runtime/session_profile.py +205 -0
- package/core/runtime/setup_ui_env.py +229 -0
- package/core/runtime/startup_environment.py +859 -0
- package/core/runtime/sync_store.py +1421 -0
- package/core/runtime/tool_install_targets.py +18 -0
- package/core/schemas/README.md +35 -0
- package/core/schemas/agent-graph.schema.json +368 -0
- package/core/schemas/attack-graph.schema.json +88 -0
- package/core/schemas/evidence-bundle.schema.json +33 -0
- package/core/schemas/skill-pack.schema.json +230 -0
- package/core/schemas/worker-checkpoint.schema.json +119 -0
- package/core/secure_atomic.py +289 -0
- package/core/seed_corpus/README.md +55 -0
- package/core/seed_corpus/c.txt +29 -0
- package/core/seed_corpus/cpp.txt +32 -0
- package/core/seed_corpus/css.txt +70 -0
- package/core/seed_corpus/go.txt +46 -0
- package/core/seed_corpus/java.txt +30 -0
- package/core/seed_corpus/javascript.txt +55 -0
- package/core/seed_corpus/kotlin.txt +28 -0
- package/core/seed_corpus/python.txt +71 -0
- package/core/seed_corpus/rust.txt +53 -0
- package/core/seed_corpus/swift.txt +29 -0
- package/core/seed_corpus/typescript.txt +29 -0
- package/core/skills/README.md +53 -0
- package/core/skills/__init__.py +189 -0
- package/core/skills/bugx_docs_mcp_server.py +416 -0
- package/core/skills/bugx_mcp_server.py +1134 -0
- package/core/skills/mcp_runtime.py +968 -0
- package/core/skills/mcp_session_proof.py +605 -0
- package/core/skills/mobile_ui_inspector.py +405 -0
- package/core/skills/skill_pack.py +1214 -0
- package/core/skills/skill_synthesizer.py +1153 -0
- package/core/skills/tools_kb.py +313 -0
- package/core/supervisor/INTERFACE.md +121 -0
- package/core/supervisor/README.md +209 -0
- package/core/supervisor/SPEC.md +25 -0
- package/core/supervisor/__init__.py +175 -0
- package/core/supervisor/audit_supervisor.py +1015 -0
- package/core/supervisor/budget_governor.py +760 -0
- package/core/supervisor/checkpoint_handler.py +368 -0
- package/core/supervisor/checkpoint_pipeline.py +1322 -0
- package/core/supervisor/checkpoint_sync.py +640 -0
- package/core/supervisor/claim_events.py +74 -0
- package/core/supervisor/claim_sync.py +590 -0
- package/core/supervisor/cli.py +812 -0
- package/core/supervisor/context_sync.py +55 -0
- package/core/supervisor/coverage_sync.py +115 -0
- package/core/supervisor/finding_commit.py +470 -0
- package/core/supervisor/finding_sync.py +688 -0
- package/core/supervisor/finding_workflow.py +659 -0
- package/core/supervisor/finish_policy.py +224 -0
- package/core/supervisor/finish_sync.py +185 -0
- package/core/supervisor/graph_sync.py +669 -0
- package/core/supervisor/lease_manager.py +788 -0
- package/core/supervisor/lifecycle_blocks.py +124 -0
- package/core/supervisor/next_round_sync.py +126 -0
- package/core/supervisor/observability.py +140 -0
- package/core/supervisor/recovery_sync.py +165 -0
- package/core/supervisor/rejection_remedies.py +308 -0
- package/core/supervisor/round_governor.py +306 -0
- package/core/supervisor/serial_authorization.py +500 -0
- package/core/supervisor/start_sync.py +87 -0
- package/core/supervisor/state_store.py +249 -0
- package/core/supervisor/supervisor_host.py +511 -0
- package/core/supervisor/supervisor_models.py +1143 -0
- package/core/supervisor/systemic_failure.py +104 -0
- package/core/supervisor/task_scheduler.py +1640 -0
- package/core/supervisor/worker_checkpoint.py +223 -0
- package/core/supervisor/worker_execution.py +265 -0
- package/core/supervisor/worker_handoff.py +192 -0
- package/core/supervisor/worker_lifecycle.py +396 -0
- package/core/supervisor/worker_runtime.py +999 -0
- package/core/supervisor/worker_sync.py +89 -0
- package/core/supervisor_types/README.md +36 -0
- package/core/supervisor_types/__init__.py +0 -0
- package/core/supervisor_types/exceptions.py +52 -0
- package/core/supervisor_types/graph_models.py +357 -0
- package/core/supervisor_types/path_containment.py +151 -0
- package/core/supervisor_types/target_fingerprint.py +310 -0
- package/core/supervisor_types/worker_claim.py +402 -0
- package/core/webui/INTERFACE.md +50 -0
- package/core/webui/README.md +57 -0
- package/core/webui/SPEC.md +25 -0
- package/core/webui/__init__.py +11 -0
- package/core/webui/adapters/__init__.py +27 -0
- package/core/webui/adapters/base.py +87 -0
- package/core/webui/adapters/bugx.py +102 -0
- package/core/webui/adapters/claude.py +218 -0
- package/core/webui/adapters/cline.py +399 -0
- package/core/webui/adapters/codex.py +256 -0
- package/core/webui/adapters/dsh.py +173 -0
- package/core/webui/adapters/opencode.py +218 -0
- package/core/webui/adapters/pi.py +272 -0
- package/core/webui/adapters/registry.py +100 -0
- package/core/webui/adapters/zcode.py +312 -0
- package/core/webui/api_routes_post.py +668 -0
- package/core/webui/dispatcher.py +1376 -0
- package/core/webui/docs_session_service.py +473 -0
- package/core/webui/handler.py +674 -0
- package/core/webui/ide_cloud_service.py +526 -0
- package/core/webui/mcp_inspector.py +1743 -0
- package/core/webui/static/assets/index-CXAsl8mr.js +333 -0
- package/core/webui/static/assets/index-DHQUtWtx.css +1 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-500-normal-Bb4u56_6.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-CWV284fw.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-DLkyKLvH.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-8-8HP2PF.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-DaDZE_Na.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-greek-400-normal-BccYJ-vZ.woff +0 -0
- package/core/webui/static/assets/source-serif-4-greek-400-normal-Cw5-AHNN.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-greek-500-normal-z-Q6FFuG.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-400-normal-Dn3IlU-Z.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-400-normal-CEpydyUl.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-400-normal-Cp7z-ARB.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-500-normal-BYjRCDVy.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-500-normal-D-qasQTj.woff +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
- package/core/webui/static/favicon.png +0 -0
- package/core/webui/static/icon-192.png +0 -0
- package/core/webui/static/index.html +42 -0
- package/core/webui/static/manifest.webmanifest +19 -0
- package/core/webui/static/project-settings.css +6458 -0
- package/core/webui/static/project-settings.js +9602 -0
- package/core/webui/static/sw.js +8 -0
- package/core/webui/workspace_service.py +218 -0
- package/docs/07_distribution/01_README_NPM.md +281 -0
- package/docs/07_distribution/README.md +16 -0
- package/docs/README.md +121 -0
- package/ecosystem/README.md +129 -0
- package/ecosystem/integrations/README.md +38 -0
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +69 -0
- package/ecosystem/integrations/dsh/agents/bugx.md +27 -0
- package/ecosystem/integrations/dsh/dsh-patch.yml +18 -0
- package/ecosystem/integrations/dsh/mcp/cordis.patch.yml +4 -0
- package/ecosystem/integrations/dsh/mcp/index.js +219 -0
- package/ecosystem/integrations/dsh/mcp/package.json +28 -0
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +70 -0
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +229 -0
- package/ecosystem/integrations/dsh/ui/client.js +87 -0
- package/ecosystem/integrations/dsh/ui/cordis.patch.yml +4 -0
- package/ecosystem/integrations/dsh/ui/index.js +7 -0
- package/ecosystem/integrations/dsh/ui/package.json +27 -0
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +53 -0
- package/ecosystem/integrations/opencode/mcp-lock.json +3067 -0
- package/ecosystem/integrations/opencode/opencode.json +118 -0
- package/ecosystem/integrations/pi/extensions/bugx/README.md +12 -0
- package/ecosystem/integrations/pi/extensions/bugx/index.ts +299 -0
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +11 -0
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +69 -0
- package/ecosystem/integrations/qoder/CONNECTORS.md +54 -0
- package/ecosystem/integrations/qoder/connector-meta.json +21 -0
- package/ecosystem/integrations/workbuddy/connector-meta.json +19 -0
- package/ecosystem/integrations/workbuddy/icon.png +0 -0
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +70 -0
- package/ecosystem/plugins/README.md +37 -0
- package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +17 -0
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +16 -0
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +41 -0
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +19 -0
- package/ecosystem/plugins/bugx/agents/bugx-judge.md +71 -0
- package/ecosystem/plugins/bugx/agents/bugx-worker.md +31 -0
- package/ecosystem/plugins/bugx/agents/bugx.md +74 -0
- package/ecosystem/plugins/bugx/assets/bugx-avatar-512.png +0 -0
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +118 -0
- package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +229 -0
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
- package/interfaces/README.md +143 -0
- package/interfaces/bin/README.md +35 -0
- package/interfaces/bin/bugx.js +80 -0
- package/interfaces/cli/README.md +90 -0
- package/interfaces/cli/bugx_cli/__init__.py +4 -0
- package/interfaces/cli/bugx_cli/cli.py +1678 -0
- package/interfaces/cli/bugx_cli/commands/__init__.py +1 -0
- package/interfaces/cli/bugx_cli/commands/advisory.py +94 -0
- package/interfaces/cli/bugx_cli/commands/agent.py +3944 -0
- package/interfaces/cli/bugx_cli/commands/audit.py +632 -0
- package/interfaces/cli/bugx_cli/commands/autonomous.py +260 -0
- package/interfaces/cli/bugx_cli/commands/cloud.py +1370 -0
- package/interfaces/cli/bugx_cli/commands/daemon.py +50 -0
- package/interfaces/cli/bugx_cli/commands/doctor.py +1345 -0
- package/interfaces/cli/bugx_cli/commands/goal.py +107 -0
- package/interfaces/cli/bugx_cli/commands/interaction.py +244 -0
- package/interfaces/cli/bugx_cli/commands/knowledge.py +617 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +2763 -0
- package/interfaces/cli/bugx_cli/commands/patch.py +1014 -0
- package/interfaces/cli/bugx_cli/commands/plugin.py +2714 -0
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +1446 -0
- package/interfaces/cli/bugx_cli/commands/plugin_cline.py +269 -0
- package/interfaces/cli/bugx_cli/commands/plugin_codex.py +74 -0
- package/interfaces/cli/bugx_cli/commands/plugin_funide.py +728 -0
- package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +216 -0
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +710 -0
- package/interfaces/cli/bugx_cli/commands/project.py +670 -0
- package/interfaces/cli/bugx_cli/commands/report.py +260 -0
- package/interfaces/cli/bugx_cli/commands/skill.py +251 -0
- package/interfaces/cli/bugx_cli/commands/stats.py +133 -0
- package/interfaces/cli/bugx_cli/commands/system.py +2567 -0
- package/interfaces/cli/bugx_cli/common.py +898 -0
- package/interfaces/cli/bugx_cli/host_adapters.py +1917 -0
- package/interfaces/cli/bugx_cli/hosts/__init__.py +80 -0
- package/interfaces/cli/bugx_cli/hosts/base.py +99 -0
- package/interfaces/cli/bugx_cli/hosts/registry.py +571 -0
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +188 -0
- package/interfaces/cli/bugx_cli/infra/__init__.py +209 -0
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +721 -0
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +1937 -0
- package/interfaces/cli/bugx_cli/infra/host_sync.py +545 -0
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +755 -0
- package/interfaces/cli/bugx_cli/infra/security.py +332 -0
- package/package.json +98 -4
- package/pyproject.toml +246 -0
- package/scripts/README.md +118 -0
- package/scripts/ensure-python.mjs +97 -0
- package/scripts/isolate-npm-readme.mjs +40 -0
- package/scripts/runtime.lock.json +31 -0
- package/scripts/sync-version.mjs +37 -0
- package/scripts/test-npm-wrapper.mjs +265 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bugx-opencode
|
|
3
|
+
description: "BugX 对抗审计在 OpenCode 宿主的操作手册。当宿主发起/执行 BugX 漏洞挖掘、代码审计、对抗测试,或遇到 bugx engine pre 门禁、MCP 会话冲突(session_occupied)、Worker 派发(bugx-worker subagent)、headless/ACP 验收、判读式审计(judge)、findings 确认协议、post 结算封存等问题时使用。触发词:bugx 审计、漏洞挖掘、pre 门禁、session_occupied、bugx-worker、judge collect、post --final。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BugX × OpenCode 使用手册(实战复盘版)
|
|
7
|
+
|
|
8
|
+
引擎源码仓库 `/Users/sp/workspace/bug-hunter`(dev 分支)。本手册共性部分继承
|
|
9
|
+
`bugx-zcode` skill(判读式审计/确认协议/坑位),特性部分按 OpenCode 宿主契约
|
|
10
|
+
(`core/contracts/bugx-opencode.md`)微调。所有坑位均实证。
|
|
11
|
+
|
|
12
|
+
## 〇、最短路径决策树
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
要审计一个项目
|
|
16
|
+
└─ cd <项目根> && opencode # 必须在项目根启动(MCP 是 --root . 相对绑定)
|
|
17
|
+
└─ agent 列表选 bugx(或默认对话说「用 bugx 审计」)
|
|
18
|
+
└─ bugx engine --root . pre # 交互 TUI:启动门禁逐组原生 question 询问
|
|
19
|
+
└─ 判读式五步(见 §四)→ post --final
|
|
20
|
+
└─ 失败先查 .bugx/.../state/judge/judge-log.jsonl(结构化事件流)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 一、OpenCode 特性事实(先记牢再动手)
|
|
24
|
+
|
|
25
|
+
1. **项目级 MCP**:`opencode.json` 在**项目根**(三个 bugx MCP:host/worker/docs,
|
|
26
|
+
`command: ["bugx", ...]` 走 PATH,`--root .` 相对绑定)。与 ZCode 的用户级单例
|
|
27
|
+
不同——**换项目无需 rebind,切靶场即换上下文**;但必须从项目根启动 TUI。
|
|
28
|
+
2. **agent 入口**:`.opencode/agents/bugx.md`(mode: all)+ `bugx-worker.md`;
|
|
29
|
+
全局软链 `~/.config/opencode/agents/`。
|
|
30
|
+
3. **权限形态**:agent 权限矩阵 `execute: deny`(仅白名单例外,含
|
|
31
|
+
`*bugx engine* pre*` / `*bugx engine* post*`)。**一切动作走 MCP 工具或
|
|
32
|
+
白名单 shell**,禁止绕过。
|
|
33
|
+
4. **交互原语**:TUI `interaction=question` 必须用宿主原生 `question` 工具
|
|
34
|
+
(单选 `multiple=false`,**一次只传一个阶段问题**),禁止普通文本提问替代;
|
|
35
|
+
无效/取消/失败留在当前阶段,不得自行降级。
|
|
36
|
+
|
|
37
|
+
## 二、启动与门禁(含 --dev 场景闸门)
|
|
38
|
+
|
|
39
|
+
1. **交互 TUI(用户在场)**:`bugx engine --root . pre` **不带任何跳过旗标**——
|
|
40
|
+
启动门禁(云端/方案/审查/轮询/修复/提交/报告处置)逐组原生 question 询问用户,逐项确认。
|
|
41
|
+
2. **⚠ --dev 场景闸门**:`pre --dev` 仅允许 ①用户明确要求无人值守 ②同一靶场
|
|
42
|
+
重验快审。**用户在场禁止默认用 --dev**;拿不准就先问用户选哪种模式。
|
|
43
|
+
headless/ACP 场景用 `pre --autonomous`(见 §三.4),也不是 --dev。
|
|
44
|
+
3. **resume 语义坑**:`runtime.active=true`(上一轮没跑 `post --final`)时,
|
|
45
|
+
pre 走会话恢复(resume)**静默跳过门禁**。中断后必须先收口(`post --final`
|
|
46
|
+
或确认 aborted 终态)再重跑 pre,否则永远不询问。
|
|
47
|
+
4. **pre 必须前台同步**:OpenCode v2 原生 shell 显式 `workdir`=项目根、
|
|
48
|
+
`timeout=300000`;禁止 `timeout` 包装、`&`/`nohup`/后台会话、sleep/ps 轮询、
|
|
49
|
+
输出重定向到项目根之外。工具超时记 `BLOCKED`,不得伪造退出码。
|
|
50
|
+
5. **门禁防逃逸锁**:严禁在对话文本里自述「我选选项 1」绕过门禁——启动决策必须
|
|
51
|
+
由 pre 写入 `.bugx/` 状态机,未写入前拒绝配 Worker。
|
|
52
|
+
|
|
53
|
+
## 三、OpenCode 特有纪律
|
|
54
|
+
|
|
55
|
+
1. **MCP 会话证明优先**:先调当前会话已加载的 `bugx-supervisor` Host MCP
|
|
56
|
+
(真实 MCP 在 tools/list 后写入短期会话证明,CLI 子进程读取该证明)。
|
|
57
|
+
**禁止**从 shell 再启动 `bugx mcp serve` / `bugx mcp probe` / stdio 探针——
|
|
58
|
+
会与 host controller lease 冲突得到 `session_occupied`。
|
|
59
|
+
2. **Worker 派发(C 路径代表)**:主 Agent 用 OpenCode v2 原生 `subagent` 工具,
|
|
60
|
+
agent ID `bugx-worker`,**每次调用必须显式传 `background=false`**(前台等结果)。
|
|
61
|
+
主 Agent 自己读 `bugx engine --root . workers` 完整输出,把完整任务块原样交子
|
|
62
|
+
Agent;严禁把 CLI 命令文本当 Worker prompt、不得省略 `WORKER_CLAIM_FACTS`。
|
|
63
|
+
Worker 首个工具调用:无预占事实 → `claim`;有完整预占事实 → `worker_start`。
|
|
64
|
+
两者成功前禁止任何项目探索。父 Agent 不代跑探测、不写 artifact、不调 Worker
|
|
65
|
+
MCP;必须等到每个 Worker 结果返回再推进,Worker 仍 active 时不得结束回合。
|
|
66
|
+
3. **headless/ACP 验收**:`opencode run --format json -f <prompt_file> <message>`;
|
|
67
|
+
`question` 工具会被宿主静默阻断(interaction=blocked)⇒ 此场景走
|
|
68
|
+
`pre --autonomous` + 显式门禁参数。ACP `session/new` 默认选项目主 Agent——
|
|
69
|
+
验收客户端必须先 `session/set_mode` 显式选 `bugx`,不可用则 fail-closed,
|
|
70
|
+
不得拿默认 Agent 结果冒充 BugX 验收。
|
|
71
|
+
4. **状态机与账本**:`.bugx/` 是运行态账本与证据库,严禁把运行时产物写进生产
|
|
72
|
+
源码与依赖(与所有宿主一致)。
|
|
73
|
+
|
|
74
|
+
## 四、判读式五步标准流(共性,每步一条命令)
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
bugx engine --root . pre # 交互场景:启动门禁逐组询问(用户逐项确认)
|
|
78
|
+
bugx engine --root . judge --all # 一次领满容量内全部单元;判读包并发给 bugx-judge
|
|
79
|
+
bugx engine --root . judge --settle-dir <verdicts目录>
|
|
80
|
+
bugx engine --root . findings-confirm --from-verdicts <verdicts.json>
|
|
81
|
+
bugx engine --root . post --final # 会话最后一条引擎命令必须是 --final
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- **回合自检**:`state/judge/judge-log.jsonl` 里 `collect_summary` >2 次 = 在
|
|
85
|
+
浪费回合(judge collect 必须单轮领满);findings-confirm 拆多轮同理
|
|
86
|
+
(一条命令 ~6s,实测拆散拖到 235s)。
|
|
87
|
+
- **submit_finding 定级口径**:必带 `confidence`(≥2 独立通道 observations +
|
|
88
|
+
negative_control pass ⇒ ≥0.75;差分哨兵 SENTINEL ⇒ ≥0.85);severity 按
|
|
89
|
+
CWE 口径(任意代码执行/命令注入 = CRITICAL;SQL 注入/路径穿越/硬编码云凭据
|
|
90
|
+
= HIGH),不得因不确定保守降级——否则引擎 fallback 会把 confirmed 缺陷
|
|
91
|
+
兜底成 0.35。
|
|
92
|
+
- **证据落盘**:验收要求 artifact 在案时,probe 输出写 claim 的 `artifact_root`
|
|
93
|
+
相对路径,checkpoint finalize 用 `--artifact`(多单元 `--artifacts-json`)。
|
|
94
|
+
|
|
95
|
+
## 五、确认协议要点(共性)
|
|
96
|
+
|
|
97
|
+
finding 转 confirmed:同指纹 ≥2 次独立运行 + ≥2 独立通道 + negative_control
|
|
98
|
+
`pass`(不是 "OK")+ `root_cause_verified`;`target_execution` 的
|
|
99
|
+
`target_platform` 与 `executed_platform` **逐字相同**(darwin ≠
|
|
100
|
+
darwin-arm64-cpython-3.14)。findings.json 顶层 `run_binding.run_id` 用
|
|
101
|
+
`lifecycle-<polling>-<lifecycle>` 形式,`round` 与 runtime 当前轮逐字一致。
|
|
102
|
+
|
|
103
|
+
finding 的 `reproduction` 字段必须非空且可被第三方独立执行;`confirmation`
|
|
104
|
+
块必须带 `state:"reproduced"` 与非 heuristic 的 `oracle`(含
|
|
105
|
+
`provenance.independent_from_change:true`)。这两个字段名由
|
|
106
|
+
`core/ledger/finding_confirmation.py` 的 `confirmation_issues()` 直接读取,
|
|
107
|
+
写错或省略都会使候选永久停在 pending。复现脚本必须打印非空失败观测再
|
|
108
|
+
`exit 1`,否则只有 `engine-verify:exit-code` 单通道,门禁拒绝。
|
|
109
|
+
|
|
110
|
+
## 六、坑位表
|
|
111
|
+
|
|
112
|
+
| 症状 | 根因 | 对策 |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| pre 没弹门禁询问 | runtime 悬挂(上轮没 `--final`)→ resume | 收口后重跑;交互场景 pre 不带跳过旗标 |
|
|
115
|
+
| `session_occupied` | shell 重复起 serve / stdio 探针 | 只用会话内已装配的 MCP;禁 shell 探针 |
|
|
116
|
+
| Worker 没跑 / 提前结束回合 | subagent 未传 `background=false`,或父 Agent 先输出了结束文本 | 每次显式 `background=false`;Worker active 时主 Agent 必须等待 |
|
|
117
|
+
| ACP 验收拿默认 Agent 冒充 | `session/new` 默认主 Agent | 先 `session/set_mode` 选 `bugx`,不可用 fail-closed |
|
|
118
|
+
| pre 超时被记失败 | 工具级 timeout 包装/后台化 | 前台 300s 同步等待,超时如实记 BLOCKED |
|
|
119
|
+
| checkpoint 三连拒 | 手拼 payload | 用 `worker_checkpoint.py finalize`(自动绑指纹与 receipt) |
|
|
120
|
+
| post 报「必须紧接活动 pre」 | runtime aborted | 重跑 pre 走恢复;supervisor 冻结则 `pre --session-recovery new` |
|
|
121
|
+
| 引擎从 `~/.bugx/core` 加载 | 改了源码没同步 | `bugx install` 同步全局;只 pip install 不够 |
|
|
122
|
+
|
|
123
|
+
## 七、验收基线
|
|
124
|
+
|
|
125
|
+
- 交互 TUI 首轮 pre 启动门禁逐组原生 question 询问(用户逐项确认)
|
|
126
|
+
- 覆盖单元恰等于产品文件;judge 单轮领满;settle/确认秒级;judge-log 事件齐全
|
|
127
|
+
- post --final 收口后 runtime 终态明确(COMPLETE / ABORTED / BLOCKED /
|
|
128
|
+
RECOVERY_REQUIRED),无 NEXT_ROUND 悬挂
|
|
129
|
+
- 结构化失败原因输出,无静默降级;退出码 0 即收口成功
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bugx-zcode
|
|
3
|
+
description: BugX 漏洞挖掘引擎在 ZCode 宿主下的专属使用手册——新环境快速接入(构建/安装/doctor)、启动挖掘标准流程(pre 启动门禁→workers→checkpoint→post)、本机实证过的坑位与对策(MCP root 漂移、worker 误回收、findings 格式、死锁链、token 上报、云端面板、重置)。当用户要在 ZCode 里启动/排障/重置 BugX 审计、配置新环境、解释 BugX 报错或 token/报告不更新时使用本 skill。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BugX × ZCode 使用手册(实战复盘版)
|
|
7
|
+
|
|
8
|
+
本手册由 2026-11-01~04 在 bugxtest 项目的多轮真实审计复盘提炼。所有坑位都在
|
|
9
|
+
本机实证过并已在引擎源码修复(源码仓库 `/Users/sp/workspace/bug-hunter`,dev 分支)。
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### 0.与通用 bugx skill 的关系(先读)
|
|
13
|
+
|
|
14
|
+
本手册与通用 `bugx` skill(`~/.agents/skills/bugx` 及插件副本)**并存且互补**:
|
|
15
|
+
通用版承载生命周期协议(含启动门禁逐组原生单选询问);本手册是 OpenCode 之外的
|
|
16
|
+
宿主增补(ZCode 直驱/坑位/快审配方)。**任何快审配方都不得跳过用户交互**——
|
|
17
|
+
门禁流程以通用 skill 的启动门禁逐组询问 + 本手册 8.6 闭环为准;两者冲突时,
|
|
18
|
+
交互纪律优先于效率配方。
|
|
19
|
+
|
|
20
|
+
## 〇、最短路径决策树
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
要审计一个项目
|
|
24
|
+
└─ bugx engine --root . pre(门禁逐组单选:云端/方案/审查/轮询/修复/提交)
|
|
25
|
+
└─ 小/中项目(首要路径):按「三·六 判读式」跑
|
|
26
|
+
collect(--all) → 并发 bugx-judge → settle-dir → findings-confirm → post
|
|
27
|
+
└─ 需要宿主原生子代理并发的超大项目:按「三·五 worker 协议」跑 workers
|
|
28
|
+
└─ 失败先查 .bugx/.../state/judge/judge-log.jsonl(结构化事件流)
|
|
29
|
+
再查 state/verification/*/receipt.json(引擎实证收据)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 一、新环境快速接入(fresh machine checklist)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# 1. 前置:Python >= 3.11(推荐 3.14)
|
|
36
|
+
# 2. 获取引擎(二选一)
|
|
37
|
+
pip install bugx_agent # 官方 wheel
|
|
38
|
+
# 或从源码仓库本地构建(维护者口径,不走 Jenkins 门禁):
|
|
39
|
+
cd /path/to/bug-hunter && python3 -m build --no-isolation --wheel --outdir dist . \
|
|
40
|
+
&& python3 -m pip install --force-reinstall dist/bugx_agent-*.whl
|
|
41
|
+
|
|
42
|
+
# 3. 绑定项目 + 装宿主 agent(ZCode 走用户级)
|
|
43
|
+
bugx install --root <项目绝对路径> --agent zcode --non-interactive
|
|
44
|
+
# 可选:Codex 全局级(任意目录可用,--root . 相对绑定)
|
|
45
|
+
bugx install --root <项目> --agent codex --non-interactive
|
|
46
|
+
|
|
47
|
+
# 4. 重启 ZCode 会话(宿主 MCP 进程在新会话才拉起,旧进程不改血)
|
|
48
|
+
|
|
49
|
+
# 5. 体检(必须全绿再开工)
|
|
50
|
+
bugx doctor --root <项目>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
要点:
|
|
54
|
+
- **改完引擎源码必须重建 wheel 并 reinstall**——全局引擎 `~/.bugx/core` 可以热同步,
|
|
55
|
+
但已装 CLI 仍是旧逻辑,热同步掩盖不了 wheel 滞后。
|
|
56
|
+
- ZCode 的 MCP 配置是**用户级全局单例**(`~/.zcode/cli/config.json`,--root 钉在最后一次
|
|
57
|
+
install 的项目);切项目用 `bugx install --root <新项目>` 重绑。引擎已有 root 自愈
|
|
58
|
+
(陈旧 root 回退 BUGX_PROJECT_ROOT/cwd),但**仅对新 spawn 的进程生效**。
|
|
59
|
+
|
|
60
|
+
## 一·五、开发模式(改源码免安装验证)
|
|
61
|
+
|
|
62
|
+
有两个 "dev",**不要混淆**:
|
|
63
|
+
|
|
64
|
+
1. **`--dev` 挖掘策略旗标**(引擎侧):`bugx engine pre --dev` 启用自治预设——git 未初始化时
|
|
65
|
+
`auto_init`、云同步 pending 自动落 local、作战方案自动批准、修复预设 log-only、轮询 auto、
|
|
66
|
+
Round 提交。全程零交互门禁,适合快速测试。
|
|
67
|
+
2. **`BUGX_DEV_MODE=1` 源码指向开发模式**(CLI 侧,d0cf82d6):进程本身跑在源码仓库时,
|
|
68
|
+
`asset_root()` 与 `global_engine_root()` 解析到仓库 `core/`——**改源码即时生效,免构建免安装**。
|
|
69
|
+
入口 `~/.local/bin/bugx-dev`(= `PYTHONPATH=<repo>/src + BUGX_DEV_MODE=1 + python3 -m bugx_cli.cli`,
|
|
70
|
+
直调模块入口,不依赖 console script)。`BUGX_DEV_ASSET_ROOT=1` 为兼容别名;显式
|
|
71
|
+
`BUGX_GLOBAL_ENGINE_ROOT` 优先级最高。
|
|
72
|
+
|
|
73
|
+
**开发工作流**:改仓库源码 → `bugx-dev <任意子命令>` 即时验证 → 要进生产时二选一:
|
|
74
|
+
`BUGX_GLOBAL_ENGINE_ROOT=~/.bugx/core bugx-dev install --root <项目> --agent zcode --non-interactive --force`
|
|
75
|
+
(显式目的地 + force,绕开防自污染守卫的合法开发发布路径),或照旧
|
|
76
|
+
`python3 -m build --no-isolation --wheel` + `pip install --force-reinstall` + `bugx install`。
|
|
77
|
+
|
|
78
|
+
**红线与坑位(全部实证)**:
|
|
79
|
+
- **严禁用 `pip install -e` editable 安装做开发**:实测会移除 `bugx` console script(生产命令
|
|
80
|
+
直接断)、wheel 载荷 `share/bugx-agent/core/` 残缺,且引擎资产契约显式排除 editable——
|
|
81
|
+
自愈拒绝用 RECORD 恢复,生产链路整体断裂。开发验证只走 `bugx-dev`。
|
|
82
|
+
- dev 模式下 `install` 目的地解析到仓库 core,会被「拒绝把引擎布署到源码仓库」守卫拦下
|
|
83
|
+
(防 wheel 旧资产覆盖开发树)——按上面 force 路径发布。
|
|
84
|
+
- build_id 连续 bump 会触发宿主入口失配门禁:bump 前确认无活跃挖掘轮,bump 后宿主入口
|
|
85
|
+
需重新装配(`bugx install`);动 `core/**` 后必须重签 `core/engine-integrity.json`。
|
|
86
|
+
- dev 模式只影响该进程;ZCode 的 MCP 服务器仍跑安装副本(生产隔离是有意设计)。
|
|
87
|
+
- **bugx-worker 代理定义已授权 Worker 通道 MCP 工具**(claim/worker_start/heartbeat/
|
|
88
|
+
run_sandboxed_probe/checkpoint/begin_long_call/status/submit_finding)——被派子代理
|
|
89
|
+
可直接调 MCP,无需 Bash rpc 回退。改动 tools 行后需重启宿主会话才生效。
|
|
90
|
+
- **确认协议**:finding 转 confirmed 需走 `finding_confirmation.py transition`(schema
|
|
91
|
+
见 `docs/03_ai/01_AI_REFERENCE.md`),同指纹 ≥2 次独立运行 + ≥2 独立通道 + negative_control
|
|
92
|
+
pass + root_cause_verified;详见下方「二·五、确认协议」章节。
|
|
93
|
+
|
|
94
|
+
## 二、启动挖掘标准流程(ZCode 宿主)
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
export BUGX_PROJECT_ROOT=<项目根> # 会话开始先设
|
|
98
|
+
bugx engine --root . pre # 门禁引擎,输出 BUGX_INTERACTION_REQUEST
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
1. **门禁逐组询问**(每次只呈现一个单选,用宿主原生单选控件如 AskUserQuestion):
|
|
102
|
+
git 环境 → 云端同步 → 审计作战方案 → (审查/轮询/修复/提交按批准预设折叠)。
|
|
103
|
+
用户未作答时按其既定意图选非阻断项并如实告知(例:本地模式)。
|
|
104
|
+
2. **云端同步**:`bugx cloud onboard on`(凭据过期 → `bugx auth login` 走 device-code;
|
|
105
|
+
被拒 `data_sharing_revoked` → `bugx config set telemetry.data_sharing true` 需用户确认)。
|
|
106
|
+
3. **策略批准**:`bugx engine --root . pre --strategy-plan approve` → 基线就绪。
|
|
107
|
+
4. **workers**:`bugx engine --root . workers` 生成预占(lease/execution_id/artifact_root
|
|
108
|
+
在输出里,或读 supervisor.json 的 active claims)。单单元 → 单 worker 例外,无需凑并发。
|
|
109
|
+
5. **worker-start 必须紧跟 claim**(拖延会触发 `claim_start_timeout_reclaimed`):
|
|
110
|
+
```bash
|
|
111
|
+
python3 "$(bugx engine path --name audit_supervisor.py)" worker-start \
|
|
112
|
+
--root . --state <supervisor.json> --worker <worker_id> \
|
|
113
|
+
--provider zcode --execution-id exec-<同 lease id>
|
|
114
|
+
```
|
|
115
|
+
6. **探针/测试** → 证据写进 `artifact_root` → **finalize**(勿手拼 payload):
|
|
116
|
+
```bash
|
|
117
|
+
python3 "$(bugx engine path --name worker_checkpoint.py)" finalize \
|
|
118
|
+
--root . --state <supervisor.json> --worker <worker_id> \
|
|
119
|
+
--status covered --artifact <artifact_root 内相对路径> \
|
|
120
|
+
--command "<真实命令>" --exit-code 0 --tokens <subagent_tokens> \
|
|
121
|
+
--note "<处置事实>"
|
|
122
|
+
```
|
|
123
|
+
`--tokens` 传 Agent 结果里的 `subagent_tokens`(精确上报);它被
|
|
124
|
+
Supervisor 计入 claim/账本 → Round 报告 → 云端运行汇总。
|
|
125
|
+
7. **findings.json**(lifecycle 根目录):必含 `schema_version:1`、`duration_seconds`、
|
|
126
|
+
`run_binding.run_id` 用**跨会话稳定的 supervisor run_id**
|
|
127
|
+
(`lifecycle-<polling>-<lifecycle>` 形式)。0 缺陷也要写(空数组)。
|
|
128
|
+
8. **结算**:
|
|
129
|
+
```bash
|
|
130
|
+
export BH_PRE_BASELINE=<pre 输出的 pre-baseline.json 路径>
|
|
131
|
+
bugx engine --root . post # 自动结算 + Round 报告 + auto 续轮
|
|
132
|
+
bugx engine --root . post --final # 全覆盖收口封存
|
|
133
|
+
```
|
|
134
|
+
**绝不在 post 之前手动 `audit_supervisor.py finish`**——post 自带决策同步+收尾;
|
|
135
|
+
提前 finish 会把 supervisor 冻结在终态,runtime 无法重建(死锁)。
|
|
136
|
+
|
|
137
|
+
## 二·五、确认协议与多单元结算(实测全流程)
|
|
138
|
+
|
|
139
|
+
挖掘产出 candidate 后,把 9 条候选全部转为 confirmed 的**完整模板**(每步都是实测踩过的坑):
|
|
140
|
+
|
|
141
|
+
1. **每条 finding 两次独立运行复现**(同指纹):`python3 -c` 反事实探针各跑一次,输出落
|
|
142
|
+
`state/host-confirmation/<slug>-a.json / -b.json`(记录 artifact_path + sha256)。
|
|
143
|
+
2. **transition 输入 schema**(逐项必须,缺一即拒):
|
|
144
|
+
顶层 `{"schema_version":1, "duration_seconds":0, "findings":[…]}`;
|
|
145
|
+
finding 内 `id/fingerprint/title/severity/confidence/root_cause/evidence/path+line/reproducible/reproduction`;
|
|
146
|
+
`confirmation` 块:`state:"reproduced"` + `oracle{tier:"differential",reference,provenance{kind:"runtime-invariant",independent_from_change:true,verified:true}}` +
|
|
147
|
+
`observations[]`(**同指纹 ≥2 次独立运行**,每条带 run_id/channel/**两个不同 channel**/fingerprint/reference/outcome:"failure"/artifact_path+sha256 成对)+
|
|
148
|
+
`negative_control{outcome:"pass",reference}` + `root_cause{location,mechanism}` + 顶层 `root_cause_verified:true` +
|
|
149
|
+
`target_execution{target_platform 与 executed_platform **逐字相同**,executed:true,simulated:false,outcome:"failure",errors:[]}`。
|
|
150
|
+
3. **平台串坑**:`"darwin"` ≠ `"darwin-arm64-cpython-3.14"`——必须完整一致,否则「目标平台与实际执行平台不一致」。
|
|
151
|
+
4. **负对照坑**:`outcome` 必须是 `"pass"` 不是 `"OK"`;`OBSERVATION_OUTCOMES = {failure, pass, blocked}`。
|
|
152
|
+
5. **findings.json 双层结构**:post 快照校验要求顶层 `run_id` + `run_binding{run_id,lifecycle_id,round}` 且与
|
|
153
|
+
`state/runtime.json` 逐字一致;`round` 用 runtime/生命期当前轮次。
|
|
154
|
+
6. **恢复会话后**:新版引擎自动收养 supervisor run_id(e7409067),不再出现身份分裂。
|
|
155
|
+
7. **fingerprint 命名**:避免生成含 `sk-` 内嵌子串的缩写(如 `task-kwargs` 内嵌 `sk-kwargs` 会误触秘钥扫描,
|
|
156
|
+
已加词边界断言修复,但旧引擎仍会拒)。
|
|
157
|
+
8. **确认完成后**:写回 lifecycle `findings.json`(confirmed 状态 + confirmation 块)→ post 自动结算
|
|
158
|
+
(auto-settle confirmed=N, credited=…)→ 复盘自动落账 → Round 报告封存。
|
|
159
|
+
9. **业务链路单元**(业务:EPxx/Bxxx)在内部单元 100% covered 后由引擎自动解锁,无需手工干预;
|
|
160
|
+
stale 单元在 next-round 后自动可重领。
|
|
161
|
+
|
|
162
|
+
## 三、坑位与对策(全部实证)
|
|
163
|
+
|
|
164
|
+
| 症状 | 根因 | 对策 |
|
|
165
|
+
|------|------|------|
|
|
166
|
+
| post 报"必须紧接活动 pre/runtime 会话" | runtime aborted(MCP 会话证明中断) | 重跑 `pre` 走会话恢复;supervisor 若已被手动 finish 冻结 → `pre --session-recovery new` 开新 polling |
|
|
167
|
+
| 新生命周期 post 报"寿命文件不存在" / findings 绑定 mismatch | 旧版 auto 续轮时序缺陷(已修) | 升级到修复版;旧数据手工兜底 = `verify_life.py reset --confirm-reset` + `set-mode` + 补 findings.json(run_id 用 supervisor 的 `lifecycle-*` 形式) |
|
|
168
|
+
| MCP 工具报 `INITIALIZATION_REQUIRED`(root 指向奇怪目录) | 用户级 MCP 单例 root 钉死 | 会话内走受控回退:`bugx supervisor rpc --root <项目> --role worker --tool <tool> --args '<json>'`;根治 = 重启宿主 + 修复版引擎(serve root 自愈) |
|
|
169
|
+
| worker 刚启动就被 `silent_unpid_worker_reclaimed` 回收 | 旧版 worker_start 漏写 mono 心跳镜像(已修) | 升级修复版;行为约定不变:worker_start 后立即心跳一次,此后 ≤5 分钟一次 |
|
|
170
|
+
| checkpoint 三连拒(run_id/receipt/跨纪元) | 手拼 payload 顺序坑 | 用 `worker_checkpoint.py finalize`(自动绑 workspace 指纹 + execution_receipt);被拒后把探针输出重写到 artifact_root 新文件再 finalize,勿盲目重跑 |
|
|
171
|
+
| 报告/清单里出现 `.bugx-project.json`、`plugins/bugx/`、`evals/` | 引擎自产工件被当审计单元(三变种,均已修) | 升级修复版;`plugins/bugx/` 已由安装器自声明进 .gitignore |
|
|
172
|
+
| Gate 2 不问直接自动批准 | 旧版把无 TTY 当无交互(已修:native-question 宿主照常询问) | 升级修复版 |
|
|
173
|
+
| 云端面板"总 Token / 运行次数"恒 0 | `report_policy=local` 只入队不上传(默认隐私策略) | 想上看板:项目 config 持久化 `report_policy=submit`(`bugx config` / 手改 `.bugx/config.json`);历史 pending 可按 `report_share.share_run` 受控重放 |
|
|
174
|
+
| 结算每轮打 `⚠ 回归看护 ModuleNotFoundError` | 旧版裸导入死路径(已修) | 升级修复版;该警告此前意味着巡查从未运行 |
|
|
175
|
+
| 报告吹"95.34% ELITE"但没跑变异 | 旧版报告引擎硬编码兜底(已修) | 升级修复版;未执行的验证维度如实标 NOT-EXERCISED/TRIAGE |
|
|
176
|
+
|
|
177
|
+
## 三·五、并发 Worker 协议与性能边界
|
|
178
|
+
|
|
179
|
+
- 保留 `bugx-worker` 子代理并发;不要把直驱当作默认优化。Worker 必须先 `claim`,再立即显式 `worker_start`,首个工具调用为 `heartbeat`。
|
|
180
|
+
- Worker checkpoint 不依赖全局 `expected_revision`。MCP handler 在 Supervisor 文件锁内直接提交,以 claim/lease/execution/checkpoint_id + payload digest 围栏;同 ID 同 payload 重试只做幂等确认,异 payload 或异 Worker 一律拒绝。
|
|
181
|
+
- `claim` 只建立租约并返回 `start_required=true`;启动错误不得吞掉。`worker_start` 对同 execution_id 幂等,换 execution_id 必须拒绝。
|
|
182
|
+
- 多 unit bundle 的每个 unit 必须有独立 artifact;`worker_checkpoint.py finalize --artifacts-json '{"unit-a":"...","unit-b":"..."}'` 才可提交。单一 `--artifact` 只适用于单 unit,禁止复制证据条目。
|
|
183
|
+
- 调度器通过 `shared_scheduler()` 复用建图结果;策略参数、清单指纹变化才失效。冲突 bundle 要继续尝试后续候选补位;Harness 若不进入实际 task_spec 就不要计算完整装饰文本。
|
|
184
|
+
- 轮次恢复不得静默铸造新 `run_id`,Supervisor hash-chain 损坏只能 fail-closed 并从完整备份恢复,绝不手工改历史事件、`hash` 或 `prev_hash`。正式 findings 结算必须有 sync seal;缺 seal 时先执行 findings sync。
|
|
185
|
+
|
|
186
|
+
## 三·六、判读式并发审计(judge,默认推荐路径)
|
|
187
|
+
|
|
188
|
+
2026-11-03 性能复盘的根因修复:旧 worker 路径每个动作烧一个模型回合
|
|
189
|
+
(35 回合≈18 分钟,探针本身仅 0.4 秒)。判读式把「想」和「做」拆开:
|
|
190
|
+
|
|
191
|
+
- **机器做流程(宿主,毫秒级)**:claim→边界电池探针→artifact/sha256/
|
|
192
|
+
execution_receipt→checkpoint 全部确定性完成;
|
|
193
|
+
- **AI 只判断(bugx-judge 子代理,一回合)**:输入是判读包(源码切片+
|
|
194
|
+
电池实测输出),只输出裁决 JSON;不执行命令、不读文件、不碰协议。
|
|
195
|
+
|
|
196
|
+
**标准一轮(宿主 5 个回合封顶)**:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
bugx engine --root . judge --all # 一次领满容量内全部文件(按符号切平凡/风险组)
|
|
200
|
+
# 把每个判读包并发交给 subagent_type=bugx-judge(一回合出裁决 JSON,
|
|
201
|
+
# 判读员用 Write 自写 verdict 文件到目录)
|
|
202
|
+
bugx engine --root . judge --settle-dir <verdicts目录> # 收割+复现实跑+机械收口
|
|
203
|
+
bugx engine --root . findings-confirm --from-verdicts <verdicts.json>
|
|
204
|
+
# judge 附带的 assert 型正/负命令自动生成
|
|
205
|
+
# recipe+oracle 文件并走引擎双跑确认(~6 秒)
|
|
206
|
+
bugx engine --root . post # 结算(log-only 模式允许保留待修复缺陷收口)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
实测(l4adv 对抗靶场 22 单元,3 个 Life 全轮闭环):collect 3-13s/批 +
|
|
210
|
+
6 判读员并行 7-37s + settle 2-4s;确认段一条命令 5.7s(旧手工 14 分钟)。
|
|
211
|
+
|
|
212
|
+
- **机器初审**:静态平凡+动态全过(`print("hello")` 类)、或证据全为
|
|
213
|
+
`symbol-missing` 伪影(artifact-only)→ 零模型关单;文件内按符号切分,
|
|
214
|
+
风险符号不拖累同文件平凡符号。
|
|
215
|
+
- **电池探针**:valid-input(按 type hints 构造合法入参,typed 函数首轮即得
|
|
216
|
+
passed 证据)+ inspect + 8 边界值 + 差分哨兵(`shell=True/subprocess/
|
|
217
|
+
os.system/eval(` 或反哺风险 token 命中时,`; touch`/`$(touch)` 双载荷实测
|
|
218
|
+
SENTINEL)+ 资产探针(yaml/json 解析)。
|
|
219
|
+
- **规则反哺**:裁决可带 `rule_feedback`——risk_tokens(更严,即时生效,且触发
|
|
220
|
+
差分哨兵采集)/ safe_calls、artifact_markers(更松,≥3 独立单元确认才晋升);
|
|
221
|
+
规则在 `.bugx/knowledge/judge-rules.json`,项目级持久可人工编辑。
|
|
222
|
+
- **定向探针一跳**:`insufficient_data` 可带 `probe_requests`(≤3 条),宿主执行后
|
|
223
|
+
出增广包供复审;服务端硬上限一跳(已有 roundup 的单元再请求会被忽略)。
|
|
224
|
+
- **业务链路组合关单**:内部 100% 后,参与单元全 covered + 图边证据在案 →
|
|
225
|
+
双端冒烟探针取证 → 机器关单(3/3 实测)。
|
|
226
|
+
- **指纹变体归并**:同一漏洞跨单元不同指纹时按证据 (path,line) 重叠归并主指纹,
|
|
227
|
+
不重复计命。
|
|
228
|
+
- **结构化日志**:`state/judge/judge-log.jsonl` 记录 classify 逐单元路由、
|
|
229
|
+
collect/settle 汇总、反哺明细、逐裁决耗时——排查第一站。
|
|
230
|
+
|
|
231
|
+
坑位(实证):
|
|
232
|
+
- 引擎从 `~/.bugx/core` 全局副本加载——改源码后必须 `bugx install` 同步全局,
|
|
233
|
+
只 pip install wheel 不够;
|
|
234
|
+
- 同文件多单元受 file 互斥约束:collect 候选池必须是**全量 pending**
|
|
235
|
+
(rank 只定序),否则批凑不满;
|
|
236
|
+
- settle 的单元证据必须选 **status=passed 且 exit_code=0** 的探针;
|
|
237
|
+
电池全 error 时诚实记 unverified,不许拿 error 探针冒充 covered;
|
|
238
|
+
- 判读包里的 AttributeError 多为探针伪影(解绑调用 __init__),
|
|
239
|
+
judge 已按契约正确过滤——不要把这些当 finding。
|
|
240
|
+
- 并发容量来自 `BUGX_MAX_CONCURRENCY` / `~/.bugx/config.json`(ceiling 16,
|
|
241
|
+
collect 日志会打印当前容量)。waves 宽度不能超过容量;判读员想跑更宽需先
|
|
242
|
+
调大容量再重跑 pre。
|
|
243
|
+
- `settle-dir` 处理过的裁决文件会自动归档 `processed/`,重跑不会重复消费;
|
|
244
|
+
若见"无活动 judge claim(可能已过期)"说明该单元已在更早一轮结算。
|
|
245
|
+
- findings.json 的 `run_binding.round` 必须等于当前 runtime round;轮次推进后
|
|
246
|
+
由 `findings-confirm --from-verdicts` 自动对齐,勿手工改。
|
|
247
|
+
- **判读包全文走文件不走 stdout**(2026-11-08 实证):`judge --all` 会把整包
|
|
248
|
+
刷到 stdout,宿主用 `tail` 截取会丢包——必须 `> /tmp/judge-packages.txt`
|
|
249
|
+
重定向后整读;包同时落盘 `state/judge/packages-<ts>.json`(collect 输出
|
|
250
|
+
尾行就是该路径),丢失时直接读文件,不要重跑 collect。
|
|
251
|
+
- `judge --all` 见 "max_concurrency 已满" 跳过(实测容量明明未满):这是
|
|
252
|
+
collect 批凑与 file 互斥的调度残差,**结算本批后再跑一次 `judge --all`**
|
|
253
|
+
即可收尾(第三轮会自动做业务链路组合关单),不要原地重试。
|
|
254
|
+
|
|
255
|
+
## 三·七、findings-confirm 契约(2026-11-08 复盘实证,修复版引擎已内建)
|
|
256
|
+
|
|
257
|
+
确认段是判读式链路此前最大的隐性耗时源(本轮实测 5 个宿主回合全烧在
|
|
258
|
+
契约试错上)。修复后的契约——**旧引擎按"坑位"对照,修复版按"内建"理解**:
|
|
259
|
+
|
|
260
|
+
- **judge 只给纯代码体**:`verification_positive/negative` 放在
|
|
261
|
+
**finding 内部**(不是 verdict 顶层);不得带 `python3 -c '...'` 外壳
|
|
262
|
+
(引擎 `_wrap()` 自动包装,二次包装 = SyntaxError)。旧版提示词写
|
|
263
|
+
"一条 python3 -c 代码"属契约措辞 bug,已在 dev 仓库修正。
|
|
264
|
+
- **正例契约由引擎代尽**(修复版):`_wrap_positive()` 用 exec 包装自动
|
|
265
|
+
(a) 剥离习惯性外壳、(b) 退出码归一化 1/0(judge 给 2/3 也认)、
|
|
266
|
+
(c) 自动打印 `BUGX_VERIFY_POSITIVE rc=N` 观测行满足双证据通道门禁
|
|
267
|
+
(旧版纯静默 SystemExit 会被 `缺两个独立证据通道` 拒)、(d) 代码崩溃
|
|
268
|
+
fail-toward-gate(exit 0 拒确认,不误升 confirmed)。负对照保持裸执行。
|
|
269
|
+
- **多通道门禁**(finding_confirmation.py `confirmation_issues`):≥2 次独立
|
|
270
|
+
复现 + ≥2 证据通道 + 负对照 pass + root_cause_verified + target_execution
|
|
271
|
+
平台串逐字一致。遇到 CANDIDATE 拒确认时**先读
|
|
272
|
+
`state/verification/<id>/receipt.json`**——positive_runs/negative_control
|
|
273
|
+
的 exit_code + stderr 就是失败原因,不要盲改重跑。
|
|
274
|
+
- **verdict JSON 控制字符**:judge 自写文件常带裸换行(strict JSON 解析
|
|
275
|
+
失败)。修复版 settle_dir / parse_verdict / build_recipes_from_verdicts
|
|
276
|
+
均已 strict=False 宽容;旧引擎宿主侧预处理一次即可,不必反复让 judge 重写。
|
|
277
|
+
- **settle 行撕裂**:`derive_settle_line` 旧版把多行 reproduction 原样内嵌
|
|
278
|
+
findings_roundN.txt,续行被 verify_life 证据校验判为"无证据编造"拒结算
|
|
279
|
+
(实测 `sys.path.insert(0, os.getcwd())` 续行被拒)。修复版已空白展平;
|
|
280
|
+
旧引擎手工把 findings.json 里 reproduction 压成单行再 post。
|
|
281
|
+
- **组级信号聚合**:修复版 judge_phase 对 unit_group 并集聚合风险标签;
|
|
282
|
+
旧版 last-write-wins 会让组内无信号尾单元把 `eval(→code-exec` 整组冲掉
|
|
283
|
+
(实测 evals.py 判读包 static_signals 丢失)。
|
|
284
|
+
- **SQL 变量中转盲区**:修复版 static_profile 增加 AST 检测
|
|
285
|
+
(`q = f"...{kw}"` → `execute(q)` 命中 sql-concat),差分哨兵新增
|
|
286
|
+
`sql-union` 载荷(UNION SELECT SENTINEL 回值检测,实测 search_users
|
|
287
|
+
SENTINEL=True)。旧版电池只含 shell 语义哨兵——**判读员依据
|
|
288
|
+
"SENTINEL=False ⇒ clean" 关单 SQL 函数是假阴性**,宿主收到含
|
|
289
|
+
`.execute(` 的判读包应主动补定向 SQL 探针。
|
|
290
|
+
- **首次 `pre` 未建立 runtime**:`pre --dev` 打印 `BUGX_RESUME_TICKET`
|
|
291
|
+
且 exit 0 但 `supervisor.json` 不存在(后续 judge 报 NoRunError)→
|
|
292
|
+
**直接重跑同一条 `pre --dev` 即续上**(第二次会完成基线+Supervisor)。
|
|
293
|
+
ticket 的 `reload_workspace_and_resume` 是 ChatGPT 宿主语义,ZCode 不适用。
|
|
294
|
+
|
|
295
|
+
## 三·八、会话提速纪律(2026-11-09 实测 34 分钟复盘固化,build.423 引擎已配套加固)
|
|
296
|
+
|
|
297
|
+
> 背景:判读式审计机器时间合计 <40s,其余全部是判读员推理墙钟 + 宿主回合延迟。
|
|
298
|
+
> 本节五条纪律来自一次超时 3 倍的真实复盘;其中两条已由引擎配套修复(标注)。
|
|
299
|
+
|
|
300
|
+
1. **判读产物一律全新目录**:`mktemp -d` 创建 verdicts 目录,settle 前目录内
|
|
301
|
+
只允许 `verdict-*.json`。复用 `/tmp/bugx-verdicts` 曾让陈旧判读包按文件序
|
|
302
|
+
先消费、把 5 个单元错误关单(insufficient_data)并触发同轮领取围栏,
|
|
303
|
+
被迫 next_round + 二次 collect + 多派一轮判读员。
|
|
304
|
+
【引擎配套】build.423 起 `settle_dir` 只认显式 `verdict` 字段,缺字段的
|
|
305
|
+
噪声文件跳过并计入 `settle_dir.skipped_no_verdict`——但全新目录仍是纪律。
|
|
306
|
+
2. **verification 代码体由宿主预置模板**:judge 只填载荷参数,宿主按指纹类型
|
|
307
|
+
(SQL 注入 / eval / 路径穿越 / 硬编码凭据)备好正负对照骨架。
|
|
308
|
+
【引擎配套】build.423 起 judge 提示词已明确"负对照必须在当前带缺陷代码上
|
|
309
|
+
exit 0,禁止假设修复后行为/不存在的机制";宿主模板仍是第一道防线。
|
|
310
|
+
已知必败形态:为不存在的 env 覆盖写 reload 断言;`except: SystemExit(0)`
|
|
311
|
+
吞异常;POS 里用 `subprocess.run(shell=True)` 兜底伪造哨兵。
|
|
312
|
+
3. **写入通道先探 1 次再放量**:未验证的 MCP/CLI 通道并发批量调用,失败会
|
|
313
|
+
成倍浪费回合(实测 fix_severity 因 schema 裸 const 被序列化问题连拒 6 次)。
|
|
314
|
+
【引擎配套】build.423 起 tool_table 的布尔 const 均已带 `type: boolean`。
|
|
315
|
+
4. **host 通道是单例**:宿主 MCP 已持项目 `controller.lock` 时,CLI
|
|
316
|
+
`supervisor rpc --role host` 的 serve 子进程拿不到主控租约即退出
|
|
317
|
+
(fail-closed 设计,非缺陷)——不要把 rpc 当 host 通道回退;host 写操作
|
|
318
|
+
(findings 修复等)走宿主 MCP 工具,通道坏了先修 MCP 而不是绕行。
|
|
319
|
+
5. **排查顺序:结构化日志 → 定点源码**:确认段被拒先读
|
|
320
|
+
`state/verification/<id>/receipt.json`;judge 异常先读
|
|
321
|
+
`state/judge/judge-log.jsonl`(`settle_dir.skipped_no_verdict`、
|
|
322
|
+
`settle_ok.verdict` 逐事件可查);结算被拒先读 post 的结构化 reason+detail。
|
|
323
|
+
源码考古限定在 grep 报错字符串命中的函数体,禁止顺序通读引擎模块。
|
|
324
|
+
|
|
325
|
+
## 四、Token 与用量核验(ZCode 专属)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
- Worker 精确值:Agent 工具结果的 `subagent_tokens` → finalize `--tokens`。
|
|
329
|
+
- 本地核验/主会话开销:ZCode 本地 DB `~/.zcode/cli/db/db.sqlite`(只读
|
|
330
|
+
`mode=ro`,勿 immutable——WAL 里有最新数据)。关键表:
|
|
331
|
+
`session`(`project_id`/`directory` 精确匹配项目根;worker 子会话标题前缀
|
|
332
|
+
`你是 BugX 并发 Worker`)、`model_usage`(`started_at` **毫秒** epoch,
|
|
333
|
+
input/output/reasoning/cache_read/computed_total、`duration_ms`、`model_id`)。
|
|
334
|
+
- 引擎已内置 `core/hosts/_zcode_usage.py`(ZCode 专属,host==zcode 门控):
|
|
335
|
+
post 时按 lifecycle 时间窗输出 `调度侧 Token / Worker Token(DB 核验)/
|
|
336
|
+
模型用量(数组)/ 模型调用时长汇总`,明细落 lifecycle `state/zcode-usage.json`,
|
|
337
|
+
**只进本地报告不上云**(云端 schema 白名单不认宿主键,防整包 400)。
|
|
338
|
+
|
|
339
|
+
## 五、重置与恢复
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
# 杀掉绑在本项目的 MCP 进程(防文件锁),然后归档重建运行态:
|
|
343
|
+
ps aux | grep "mcp serve" | grep -v grep # 找 cwd=本项目的 PID → kill
|
|
344
|
+
bugx reset --scope project --root <项目> --yes
|
|
345
|
+
# 可恢复备份在 ~/.bugx/reset-backups/project/<项目hash>/<时间戳>/
|
|
346
|
+
```
|
|
347
|
+
保留:git 历史、错题集(`--reset-knowledge` 才清)、宿主入口。云端身份标记
|
|
348
|
+
`.bugx-project.json` 设计为随仓库提交,勿删勿 ignore。
|
|
349
|
+
|
|
350
|
+
## 六、修复重放(升级 CLI 覆盖热修复时)
|
|
351
|
+
|
|
352
|
+
`bugx update` / `pip install` 官方 wheel 会覆盖运行副本。重放:
|
|
353
|
+
1. `cd /path/to/bug-hunter && python3 -m build --no-isolation --wheel --outdir dist .`
|
|
354
|
+
2. `pip install --force-reinstall dist/bugx_agent-*.whl && bugx install --root <项目> --agent zcode`
|
|
355
|
+
3. `bugx doctor` 全绿(完整性清单自动随包);详见记忆文件
|
|
356
|
+
`bugx-engine-patches-2026-11`(16+ 项修复逐条清单)。
|
|
357
|
+
|
|
358
|
+
## 七、验收基线(修复版应有的行为)
|
|
359
|
+
|
|
360
|
+
- pre 启动门禁逐组询问;方案摘要画像正确(hello-world → `cli | 基础逻辑`)
|
|
361
|
+
- 覆盖单元**恰好等于产品文件**(无引擎自产工件混入)
|
|
362
|
+
- 判读式一轮:collect 打印逐单元「初审 route」行 + 容量 + 耗时;judge 波次
|
|
363
|
+
并发且不超容量;settle/确认均为秒级;`judge-log.jsonl` 事件齐全
|
|
364
|
+
- 对抗靶场基线(Ground Truth):SQL 注入 / 命令注入 / 路径穿越均 confirmed
|
|
365
|
+
(high),免密探活与抖动样本零误报,业务链路组合关单 3/3
|
|
366
|
+
- Round 报告含真实 Token 消耗、调度侧/模型用量行;云端面板随 submit 策略更新
|
|
367
|
+
- 任何环节失败输出**结构化原因**,无静默降级;`post` 退出码 0 即收口成功
|
|
368
|
+
|
|
369
|
+
## 八、靶场快审配方(2026-11-08 zcode 实战复盘固化)
|
|
370
|
+
|
|
371
|
+
> 背景:桌面靶场(hello world + 5 种子缺陷,9 文件/117 行)zcode 轮实测
|
|
372
|
+
> 16 分钟总时长,但 **bugx 引擎机器时间合计 <60s**,其余全部是宿主 Agent
|
|
373
|
+
> 的 LLM 推理回合(判读员裁决 + 宿主组织调用)。本节把回合数压到最少。
|
|
374
|
+
|
|
375
|
+
### 8.1 回合预算与耗时构成(实测口径)
|
|
376
|
+
|
|
377
|
+
| 阶段 | 机器时间 | 宿主回合 | 说明 |
|
|
378
|
+
|---|---|---|---|
|
|
379
|
+
| pre 门禁三段 | ~27s | 3–4 回合 | **仅无人值守/重验快审**可 `pre --dev`;用户在场一律走完整询问(见 8.2 场景闸门) |
|
|
380
|
+
| judge collect | 3–13s/轮 | **必须 ≤1 轮** | 一次 `judge --all` 领满容量内全部单元,禁止分多次 |
|
|
381
|
+
| bugx-judge 判读员 | 秒级/个 | 并发一跳 | 每个判读员**一回合出裁决 JSON**,不执行命令不读文件 |
|
|
382
|
+
| settle-dir | 2–4s | 1 回合 | 一条命令收割全部裁决 |
|
|
383
|
+
| findings-confirm | ~6s | 1 回合 | `--from-verdicts` 一条命令;实测曾被拆成多轮拖到 235s |
|
|
384
|
+
| post | ~3.4s | 1 回合 | **用 `--final` 收口**(见 8.3) |
|
|
385
|
+
|
|
386
|
+
**自检规则**:会话中 `judge-log.jsonl` 的 `collect_summary` 事件 >2 次 =
|
|
387
|
+
你在浪费回合——回到 8.2 配方重来。
|
|
388
|
+
|
|
389
|
+
### 8.2 五步标准流(每步一条命令,总回合 ≤6)
|
|
390
|
+
|
|
391
|
+
> **⚠ 场景闸门(先判断再执行)**:`pre --dev` **只允许**在两种场景使用——
|
|
392
|
+
> ①用户明确要求无人值守/全自动;②同一靶场的重验快审(用户已声明不看门禁)。
|
|
393
|
+
> **用户在场做交互验证时,pre 一律不带 `--dev`**,让引擎走启动门禁逐组
|
|
394
|
+
> 询问(宿主原生单选控件),由用户逐项确认。拿不准时直接问用户:
|
|
395
|
+
> 「本次审计用完整门禁流程,还是 --dev 快审模式?」——禁止默认替用户选 --dev。
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
bugx engine --root . pre # 交互默认:收到 REQUEST 后按 8.6 问用户;
|
|
399
|
+
# --dev 仅限用户明确要求无人值守(见 8.2 闸门)
|
|
400
|
+
bugx engine --root . judge --all # 一次领满;把判读包并发给 bugx-judge
|
|
401
|
+
bugx engine --root . judge --settle-dir <verdicts目录>
|
|
402
|
+
bugx engine --root . findings-confirm --from-verdicts <verdicts.json>
|
|
403
|
+
bugx engine --root . post --final # --final 见 8.3
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### 8.3 会话终态封存(防 NEXT_ROUND 悬挂)
|
|
407
|
+
|
|
408
|
+
实测缺陷:宿主会话结束时只跑了 `post`,runtime 停在 `running` /
|
|
409
|
+
supervisor 停在 `NEXT_ROUND`,会话以 aborted 结算收场。**每个审计会话的
|
|
410
|
+
最后一条引擎命令必须是**:
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
bugx engine --root . post --final
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
`--final` 才做全覆盖收口封存;不带它引擎合法地留待续轮(交互场景正确,
|
|
417
|
+
无人值守/靶场验证场景错误)。
|
|
418
|
+
|
|
419
|
+
### 8.4 submit_finding 定级口径(修 confidence 0.35 兜底误伤)
|
|
420
|
+
|
|
421
|
+
引擎 fallback:宿主提交不带 `confidence` 时按证据文本给 0.6(含「复现」
|
|
422
|
+
关键词)或 **0.35**(否则)——实测靶场 5 条 confirmed 缺陷全部被兜到 0.35。
|
|
423
|
+
**提交 finding 时必须显式携带**:
|
|
424
|
+
|
|
425
|
+
- `confidence`:有 ≥2 独立通道 observations + negative_control pass ⇒ **≥0.75**;
|
|
426
|
+
差分哨兵 SENTINEL 实证 ⇒ **≥0.85**
|
|
427
|
+
- `severity` 按 CWE 标准口径,不得因不确定而保守降级:
|
|
428
|
+
任意代码执行 / 命令注入 = **CRITICAL**;SQL 注入 / 路径穿越 /
|
|
429
|
+
硬编码云凭据 = **HIGH**;信息泄露 / 弱配置 = MEDIUM 以下
|
|
430
|
+
|
|
431
|
+
判定依据已经过确认协议(同指纹 ≥2 次独立运行)的,置信度就是证据强度,
|
|
432
|
+
不要再按「感觉」打折。
|
|
433
|
+
|
|
434
|
+
### 8.5 证据落盘(artifact 规范)
|
|
435
|
+
|
|
436
|
+
判读式路径的探针输出默认内嵌在 findings.observations(含 stdout_sha256),
|
|
437
|
+
独立 artifact 目录为空。若验收要求 artifact 文件在案:宿主执行
|
|
438
|
+
`run_sandboxed_probe` 后把输出写进 claim 的 `artifact_root` 相对路径,
|
|
439
|
+
再 checkpoint finalize 时 `--artifact` 指向它(多单元用 `--artifacts-json`)。
|
|
440
|
+
|
|
441
|
+
### 8.6 门禁交互协议闭环(BUGX_INTERACTION_REQUEST 处理,实测踩坑固化)
|
|
442
|
+
|
|
443
|
+
引擎在宿主 agent(非 TTY)下跑 `pre` 时**不挂起等待**:打印一行
|
|
444
|
+
`BUGX_INTERACTION_REQUEST {question JSON}` 后以 rc=1 退出(设计如此)。
|
|
445
|
+
实测失败形态:agent 收到 REQUEST 未处理 → 直接放弃或降级 `--dev` →
|
|
446
|
+
用户全程看不到对话框。**必须走完闭环**:
|
|
447
|
+
|
|
448
|
+
1. 解析 REQUEST JSON(字段:gate / question / options[].value+label / action)
|
|
449
|
+
2. 用宿主原生单选控件(AskUserQuestion / question,`multiple=false`)把
|
|
450
|
+
**当前这一组**问题呈现给用户;一次一组,禁止文本代答、禁止一次全问
|
|
451
|
+
3. 用户作答后**用对应 CLI 旗标重跑 pre** 把答案写回引擎状态机:
|
|
452
|
+
`--cloud-sync <选择>` / `--review-mode <mode>` / `--polling <policy>` /
|
|
453
|
+
`--fix-mode <fix>` / `--commit-policy <policy>` /
|
|
454
|
+
`--report-policy <none|local|submit>`(报告处置三选一)
|
|
455
|
+
4. 重复 1–3 直到下一组 REQUEST 出现或 pre 以 rc=0 通过(逐组完成,门禁数量取决于未决项)
|
|
456
|
+
5. 用户取消/超时:停在当前 gate 并如实告知,**不得降级 --dev 绕过**
|
|
457
|
+
|
|
458
|
+
已确认的选项值可直接映射旗标时(如云端=local),在提问前注明将使用的
|
|
459
|
+
旗标,让用户知情确认。
|