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,940 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""core/ledger/sync_ops.py - 账本云端知识同步、证据回执与审计指标 (DOC-072)。"""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import hashlib
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
import sqlite3
|
|
11
|
+
from collections.abc import Iterable, Mapping
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
from .schema import (
|
|
16
|
+
AUDITED_TABLES,
|
|
17
|
+
DEFAULT_LEDGER,
|
|
18
|
+
PATTERN_OUTCOMES,
|
|
19
|
+
SCHEMA_VERSION,
|
|
20
|
+
LessonLedgerError,
|
|
21
|
+
ID_REGEX,
|
|
22
|
+
INCIDENT_ID_REGEX,
|
|
23
|
+
archive_manifest,
|
|
24
|
+
audit_snapshot,
|
|
25
|
+
canonical_bytes,
|
|
26
|
+
connect_ledger,
|
|
27
|
+
record_event,
|
|
28
|
+
insert_pattern,
|
|
29
|
+
now_iso,
|
|
30
|
+
state_digest,
|
|
31
|
+
sync_state_hash,
|
|
32
|
+
sanitize_text,
|
|
33
|
+
ledger_transaction,
|
|
34
|
+
validate_pattern,
|
|
35
|
+
database_path,
|
|
36
|
+
)
|
|
37
|
+
from .patterns import (
|
|
38
|
+
normalize_pattern,
|
|
39
|
+
pattern_value,
|
|
40
|
+
patterns_are_equal,
|
|
41
|
+
)
|
|
42
|
+
from .incidents import (
|
|
43
|
+
incident_content_hash,
|
|
44
|
+
incident_value,
|
|
45
|
+
insert_incident,
|
|
46
|
+
normalize_incident,
|
|
47
|
+
record_consumption_event_tx,
|
|
48
|
+
)
|
|
49
|
+
from .tool_experience import (
|
|
50
|
+
import_tool_experience_tx,
|
|
51
|
+
normalize_tool_experience_records,
|
|
52
|
+
tool_experience_hash,
|
|
53
|
+
tool_experience_level,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _ledger_workspace_root(path: str | os.PathLike[str]) -> Path:
|
|
58
|
+
db_path = database_path(path).resolve()
|
|
59
|
+
for parent in db_path.parents:
|
|
60
|
+
if parent.name == ".bugx":
|
|
61
|
+
return parent.parent
|
|
62
|
+
return db_path.parent
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def require_verified_incident_evidence(
|
|
66
|
+
path: str | os.PathLike[str],
|
|
67
|
+
incident: Mapping[str, Any],
|
|
68
|
+
receipt: Mapping[str, Any],
|
|
69
|
+
) -> None:
|
|
70
|
+
"""Reject ledger receipts not backed by the matching Supervisor Finding."""
|
|
71
|
+
if (
|
|
72
|
+
receipt.get("subject_type") != "incident"
|
|
73
|
+
or receipt.get("subject_id") != incident.get("incident_id")
|
|
74
|
+
or receipt.get("lifecycle_id") != incident.get("lifecycle_id")
|
|
75
|
+
or receipt.get("round") != incident.get("round")
|
|
76
|
+
or not incident.get("finding_fingerprint")
|
|
77
|
+
):
|
|
78
|
+
raise LessonLedgerError(
|
|
79
|
+
"evidence receipt 缺少与 incident 一致的 Finding 指纹与生命周期绑定"
|
|
80
|
+
)
|
|
81
|
+
try:
|
|
82
|
+
from core.launch_phases.finding_settlement import verify_ledger_incident_receipt
|
|
83
|
+
|
|
84
|
+
verified = verify_ledger_incident_receipt(
|
|
85
|
+
_ledger_workspace_root(path),
|
|
86
|
+
finding_fingerprint=str(incident["finding_fingerprint"]),
|
|
87
|
+
lifecycle_id=str(receipt["lifecycle_id"]),
|
|
88
|
+
round_no=int(receipt["round"]),
|
|
89
|
+
execution_id=str(receipt["run_id"]),
|
|
90
|
+
artifact_sha256=str(receipt["artifact_hash"]),
|
|
91
|
+
)
|
|
92
|
+
except (ImportError, OSError, RuntimeError, TypeError, ValueError) as exc:
|
|
93
|
+
raise LessonLedgerError(
|
|
94
|
+
"无法读取 Supervisor 工件来源,拒绝信任 evidence receipt"
|
|
95
|
+
) from exc
|
|
96
|
+
if not verified:
|
|
97
|
+
raise LessonLedgerError(
|
|
98
|
+
"evidence receipt 未通过 Supervisor Finding、claim、覆盖记录与工件复验"
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def reset_cloud_scope(
|
|
103
|
+
path: str | os.PathLike[str],
|
|
104
|
+
*,
|
|
105
|
+
reason: str = "SYNC_RESYNC_REQUIRED",
|
|
106
|
+
) -> dict[str, int]:
|
|
107
|
+
"""Clear current cloud facts after an explicit server reset requirement.
|
|
108
|
+
|
|
109
|
+
Sync transport state is owned by ``SyncStore``. This function removes
|
|
110
|
+
current patterns, incidents, tool aggregates, derived indexes, and import
|
|
111
|
+
receipts from one local ledger while preserving audit/history tables,
|
|
112
|
+
evidence, feedback, and consumption records for forensics. An empty pull
|
|
113
|
+
alone never calls this function.
|
|
114
|
+
"""
|
|
115
|
+
reason = sanitize_text(reason, "reason")
|
|
116
|
+
|
|
117
|
+
def go(c: sqlite3.Connection) -> dict[str, int]:
|
|
118
|
+
pattern_ids = [
|
|
119
|
+
row[0] for row in c.execute("SELECT pattern_id FROM patterns").fetchall()
|
|
120
|
+
]
|
|
121
|
+
incident_count = int(
|
|
122
|
+
c.execute("SELECT COUNT(*) FROM incidents").fetchone()[0]
|
|
123
|
+
)
|
|
124
|
+
tool_count = int(
|
|
125
|
+
c.execute("SELECT COUNT(*) FROM tool_experience").fetchone()[0]
|
|
126
|
+
)
|
|
127
|
+
if pattern_ids:
|
|
128
|
+
placeholders = ",".join("?" for _ in pattern_ids)
|
|
129
|
+
for table, column in (
|
|
130
|
+
("probes", "pattern_id"),
|
|
131
|
+
("aliases", "pattern_id"),
|
|
132
|
+
("sources", "pattern_id"),
|
|
133
|
+
("occurrences", "pattern_id"),
|
|
134
|
+
):
|
|
135
|
+
c.execute(
|
|
136
|
+
f"DELETE FROM {table} WHERE {column} IN ({placeholders})",
|
|
137
|
+
pattern_ids,
|
|
138
|
+
)
|
|
139
|
+
c.execute("DELETE FROM patterns_fts")
|
|
140
|
+
c.execute("DELETE FROM patterns")
|
|
141
|
+
c.execute("DELETE FROM incidents")
|
|
142
|
+
c.execute("DELETE FROM tool_experience")
|
|
143
|
+
c.execute("DELETE FROM sync_import_receipts")
|
|
144
|
+
record_event(
|
|
145
|
+
c,
|
|
146
|
+
"cloud-scope-reset",
|
|
147
|
+
{
|
|
148
|
+
"reason": reason,
|
|
149
|
+
"patterns": len(pattern_ids),
|
|
150
|
+
"incidents": incident_count,
|
|
151
|
+
"tools": tool_count,
|
|
152
|
+
},
|
|
153
|
+
)
|
|
154
|
+
return {
|
|
155
|
+
"patterns": len(pattern_ids),
|
|
156
|
+
"incidents": incident_count,
|
|
157
|
+
"tools": tool_count,
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return ledger_transaction(path, go)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def record_evidence_receipt(
|
|
164
|
+
path: str | os.PathLike[str], receipt: Mapping[str, Any]
|
|
165
|
+
) -> dict[str, Any]:
|
|
166
|
+
"""Record only an incident receipt bound to verified Supervisor evidence."""
|
|
167
|
+
required = (
|
|
168
|
+
"receipt_id",
|
|
169
|
+
"subject_type",
|
|
170
|
+
"subject_id",
|
|
171
|
+
"run_id",
|
|
172
|
+
"lifecycle_id",
|
|
173
|
+
"artifact_hash",
|
|
174
|
+
)
|
|
175
|
+
for field in required:
|
|
176
|
+
sanitize_text(receipt.get(field), field)
|
|
177
|
+
round_no = receipt.get("round")
|
|
178
|
+
if not isinstance(round_no, int) or isinstance(round_no, bool) or round_no < 1:
|
|
179
|
+
raise LessonLedgerError("evidence receipt round 必须是正整数")
|
|
180
|
+
artifact_hash = str(receipt["artifact_hash"])
|
|
181
|
+
if not re.fullmatch(r"[0-9a-fA-F]{64}", artifact_hash):
|
|
182
|
+
raise LessonLedgerError("evidence receipt artifact_hash 必须是 SHA-256")
|
|
183
|
+
item = {
|
|
184
|
+
"receipt_id": str(receipt["receipt_id"]),
|
|
185
|
+
"subject_type": str(receipt["subject_type"]),
|
|
186
|
+
"subject_id": str(receipt["subject_id"]),
|
|
187
|
+
"run_id": str(receipt["run_id"]),
|
|
188
|
+
"lifecycle_id": str(receipt["lifecycle_id"]),
|
|
189
|
+
"round": round_no,
|
|
190
|
+
"artifact_hash": artifact_hash.lower(),
|
|
191
|
+
"created_at": str(receipt.get("created_at") or now_iso()),
|
|
192
|
+
}
|
|
193
|
+
item["content_hash"] = hashlib.sha256(canonical_bytes(item)).hexdigest()
|
|
194
|
+
|
|
195
|
+
def go(c: sqlite3.Connection):
|
|
196
|
+
subject_type = item["subject_type"]
|
|
197
|
+
subject_id = item["subject_id"]
|
|
198
|
+
if subject_type != "incident":
|
|
199
|
+
raise LessonLedgerError(
|
|
200
|
+
"evidence receipt subject_type 仅支持 incident;pattern 没有可复验的 Supervisor Finding 绑定"
|
|
201
|
+
)
|
|
202
|
+
if not INCIDENT_ID_REGEX.fullmatch(subject_id):
|
|
203
|
+
raise LessonLedgerError("evidence receipt incident subject_id 格式无效")
|
|
204
|
+
if not c.execute(
|
|
205
|
+
"SELECT 1 FROM incidents WHERE incident_id=?", (subject_id,),
|
|
206
|
+
).fetchone():
|
|
207
|
+
raise LessonLedgerError(f"evidence receipt incident 不存在: {subject_id}")
|
|
208
|
+
incident = incident_value(c, subject_id)
|
|
209
|
+
if incident.get("lifecycle_id") is not None and (
|
|
210
|
+
incident.get("lifecycle_id") != item["lifecycle_id"]
|
|
211
|
+
or incident.get("round") != item["round"]
|
|
212
|
+
):
|
|
213
|
+
raise LessonLedgerError("evidence receipt 与 incident 生命周期上下文不一致")
|
|
214
|
+
require_verified_incident_evidence(path, incident, item)
|
|
215
|
+
old = c.execute(
|
|
216
|
+
"SELECT content_hash FROM evidence_receipts WHERE receipt_id=?",
|
|
217
|
+
(item["receipt_id"],),
|
|
218
|
+
).fetchone()
|
|
219
|
+
if old:
|
|
220
|
+
if old[0] != item["content_hash"]:
|
|
221
|
+
raise LessonLedgerError("evidence receipt_id 内容冲突")
|
|
222
|
+
return {"status": "duplicate", "receipt_id": item["receipt_id"]}
|
|
223
|
+
c.execute(
|
|
224
|
+
"INSERT INTO evidence_receipts VALUES (?,?,?,?,?,?,?,?,?)",
|
|
225
|
+
tuple(
|
|
226
|
+
item[x]
|
|
227
|
+
for x in (
|
|
228
|
+
"receipt_id",
|
|
229
|
+
"subject_type",
|
|
230
|
+
"subject_id",
|
|
231
|
+
"run_id",
|
|
232
|
+
"lifecycle_id",
|
|
233
|
+
"round",
|
|
234
|
+
"artifact_hash",
|
|
235
|
+
"created_at",
|
|
236
|
+
"content_hash",
|
|
237
|
+
)
|
|
238
|
+
),
|
|
239
|
+
)
|
|
240
|
+
record_event(
|
|
241
|
+
c,
|
|
242
|
+
"evidence-receipt-recorded",
|
|
243
|
+
{k: item[k] for k in item if k != "artifact_hash"},
|
|
244
|
+
)
|
|
245
|
+
return {"status": "recorded", "receipt_id": item["receipt_id"]}
|
|
246
|
+
|
|
247
|
+
return ledger_transaction(path, go)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def synced_pattern(
|
|
251
|
+
raw: Mapping[str, Any], *, allow_remote_active: bool
|
|
252
|
+
) -> dict[str, Any]:
|
|
253
|
+
"""把 V2 wire pattern 转成本地记录;仅云端 Supervisor 路径可保留 active。"""
|
|
254
|
+
if not isinstance(raw, Mapping):
|
|
255
|
+
raise LessonLedgerError("云端 pattern 必须是对象")
|
|
256
|
+
payload = dict(raw)
|
|
257
|
+
details = (
|
|
258
|
+
payload.get("details")
|
|
259
|
+
if isinstance(payload.get("details"), Mapping)
|
|
260
|
+
else {}
|
|
261
|
+
)
|
|
262
|
+
for key in (
|
|
263
|
+
"playbook",
|
|
264
|
+
"attempts_tried",
|
|
265
|
+
"successful_solution",
|
|
266
|
+
"applicability",
|
|
267
|
+
"false_positive_patterns",
|
|
268
|
+
"oracle_hints",
|
|
269
|
+
"tags",
|
|
270
|
+
"aliases",
|
|
271
|
+
"negative_controls",
|
|
272
|
+
"evidence_requirements",
|
|
273
|
+
):
|
|
274
|
+
if key in details:
|
|
275
|
+
payload[key] = (
|
|
276
|
+
list(details[key])
|
|
277
|
+
if isinstance(details[key], (list, tuple))
|
|
278
|
+
else []
|
|
279
|
+
)
|
|
280
|
+
if isinstance(payload.get("routing_tags"), Mapping):
|
|
281
|
+
payload["routing_tags"] = dict(payload["routing_tags"])
|
|
282
|
+
elif isinstance(details.get("routing_tags"), Mapping):
|
|
283
|
+
payload["routing_tags"] = dict(details["routing_tags"])
|
|
284
|
+
payload["pattern_id"] = payload.get("pattern_id") or payload.get("lesson_id")
|
|
285
|
+
payload["reflection"] = payload.get("reflection") or "云端导入,等待本地证据复核"
|
|
286
|
+
# probes/source_refs 优先走 details 无损列表通道(push 端会把含逗号的
|
|
287
|
+
# 元素原样放这里);仅旧记录(无该通道)才退回逗号拆分。
|
|
288
|
+
for key, fallback in (("probes", ["云端导入待补充验证探针"]),
|
|
289
|
+
("source_refs", ["cloud-sync://remote"])):
|
|
290
|
+
lossless = details.get(key)
|
|
291
|
+
if isinstance(lossless, (list, tuple)) and lossless:
|
|
292
|
+
payload[key] = [str(x) for x in lossless]
|
|
293
|
+
else:
|
|
294
|
+
details.pop(key, None)
|
|
295
|
+
payload[key] = split_sync_values(payload.get(key)) or fallback
|
|
296
|
+
if isinstance(payload.get("tags"), str):
|
|
297
|
+
payload["tags"] = split_sync_values(payload.get("tags"))
|
|
298
|
+
fingerprints = payload.get("finding_fingerprints")
|
|
299
|
+
if isinstance(fingerprints, str):
|
|
300
|
+
try:
|
|
301
|
+
decoded = json.loads(fingerprints)
|
|
302
|
+
except (TypeError, ValueError):
|
|
303
|
+
decoded = None
|
|
304
|
+
payload["finding_fingerprints"] = (
|
|
305
|
+
[str(item) for item in decoded]
|
|
306
|
+
if isinstance(decoded, list)
|
|
307
|
+
else split_sync_values(fingerprints)
|
|
308
|
+
)
|
|
309
|
+
payload["created_at"] = payload.get("created_at") or "1970-01-01T00:00:00Z"
|
|
310
|
+
payload["updated_at"] = payload.get("updated_at") or payload["created_at"]
|
|
311
|
+
remote_status = str(payload.get("status") or "candidate")
|
|
312
|
+
if remote_status not in {"candidate", "active"}:
|
|
313
|
+
raise LessonLedgerError(f"云端 pattern status 不可导入: {remote_status}")
|
|
314
|
+
payload["status"] = "candidate"
|
|
315
|
+
pattern = normalize_pattern(payload)
|
|
316
|
+
pattern["status"] = (
|
|
317
|
+
"active"
|
|
318
|
+
if allow_remote_active and remote_status == "active"
|
|
319
|
+
else "candidate"
|
|
320
|
+
)
|
|
321
|
+
return pattern
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def split_sync_values(value: Any) -> list[str]:
|
|
325
|
+
if isinstance(value, (list, tuple)):
|
|
326
|
+
return [str(item) for item in value if str(item).strip()]
|
|
327
|
+
if isinstance(value, str):
|
|
328
|
+
return [item.strip() for item in value.split(",") if item.strip()]
|
|
329
|
+
return []
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def synced_incident(
|
|
333
|
+
raw: Mapping[str, Any],
|
|
334
|
+
*,
|
|
335
|
+
allow_remote_active: bool,
|
|
336
|
+
c: sqlite3.Connection | None = None,
|
|
337
|
+
) -> dict[str, Any]:
|
|
338
|
+
"""把 V2 wire incident 转成本地记录,并校验 active 的父 pattern。"""
|
|
339
|
+
if not isinstance(raw, Mapping):
|
|
340
|
+
raise LessonLedgerError("云端 incident 必须是对象")
|
|
341
|
+
details = raw.get("details") if isinstance(raw.get("details"), Mapping) else {}
|
|
342
|
+
routing_tags = raw.get("routing_tags")
|
|
343
|
+
if not isinstance(routing_tags, Mapping) and isinstance(
|
|
344
|
+
details.get("routing_tags"), Mapping
|
|
345
|
+
):
|
|
346
|
+
routing_tags = details["routing_tags"]
|
|
347
|
+
remote_status = str(raw.get("status") or "candidate")
|
|
348
|
+
if remote_status not in {"candidate", "active"}:
|
|
349
|
+
raise LessonLedgerError(f"云端 incident status 不可导入: {remote_status}")
|
|
350
|
+
pattern_id = raw.get("lesson_id") or raw.get("pattern_id")
|
|
351
|
+
payload = {
|
|
352
|
+
"incident_id": raw.get("incident_id"),
|
|
353
|
+
"pattern_id": pattern_id,
|
|
354
|
+
"signature": (
|
|
355
|
+
raw.get("signature")
|
|
356
|
+
or raw.get("error_signature")
|
|
357
|
+
or raw.get("title")
|
|
358
|
+
or raw.get("incident_id")
|
|
359
|
+
),
|
|
360
|
+
"summary": raw.get("summary") or raw.get("root_cause") or raw.get("title"),
|
|
361
|
+
"context": (
|
|
362
|
+
details.get("context")
|
|
363
|
+
or raw.get("context")
|
|
364
|
+
or raw.get("summary")
|
|
365
|
+
or raw.get("root_cause")
|
|
366
|
+
),
|
|
367
|
+
"before_snippet": (
|
|
368
|
+
raw.get("before_code") or raw.get("before_snippet") or "redacted"
|
|
369
|
+
),
|
|
370
|
+
"after_snippet": (
|
|
371
|
+
raw.get("after_code") or raw.get("after_snippet") or "redacted"
|
|
372
|
+
),
|
|
373
|
+
"decision": (
|
|
374
|
+
raw.get("decision_chain")
|
|
375
|
+
or raw.get("decision")
|
|
376
|
+
or "explicit review required"
|
|
377
|
+
),
|
|
378
|
+
"duration_seconds": raw.get("duration") or raw.get("duration_seconds") or 0,
|
|
379
|
+
"lifecycle_id": raw.get("lifecycle_id") or "cloud-import",
|
|
380
|
+
"round": raw.get("round") or 1,
|
|
381
|
+
"status": "candidate",
|
|
382
|
+
"actor": "supervisor",
|
|
383
|
+
"created_at": raw.get("created_at") or "1970-01-01T00:00:00Z",
|
|
384
|
+
"updated_at": (
|
|
385
|
+
raw.get("updated_at")
|
|
386
|
+
or raw.get("created_at")
|
|
387
|
+
or "1970-01-01T00:00:00Z"
|
|
388
|
+
),
|
|
389
|
+
"routing_tags": routing_tags or {},
|
|
390
|
+
}
|
|
391
|
+
incident = normalize_incident(payload)
|
|
392
|
+
if allow_remote_active and remote_status == "active" and c is not None:
|
|
393
|
+
if pattern_id:
|
|
394
|
+
parent = c.execute(
|
|
395
|
+
"SELECT status FROM patterns WHERE pattern_id=?", (pattern_id,)
|
|
396
|
+
).fetchone()
|
|
397
|
+
if parent and parent[0] == "active":
|
|
398
|
+
incident["status"] = "active"
|
|
399
|
+
return incident
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
def import_synced_pattern_tx(
|
|
403
|
+
c: sqlite3.Connection, item: Mapping[str, Any]
|
|
404
|
+
) -> str:
|
|
405
|
+
key = str(item["pattern_id"])
|
|
406
|
+
row = c.execute("SELECT 1 FROM patterns WHERE pattern_id=?", (key,)).fetchone()
|
|
407
|
+
if row:
|
|
408
|
+
old = pattern_value(c, key)
|
|
409
|
+
promoted = item.get("status") == "active" and old.get("status") == "candidate"
|
|
410
|
+
if promoted:
|
|
411
|
+
c.execute(
|
|
412
|
+
"UPDATE patterns SET status='active',updated_at=? "
|
|
413
|
+
"WHERE pattern_id=? AND status='candidate'",
|
|
414
|
+
(now_iso(), key),
|
|
415
|
+
)
|
|
416
|
+
record_event(c, "cloud-pattern-activated", {"pattern_id": key})
|
|
417
|
+
if not patterns_are_equal(old, item):
|
|
418
|
+
# 云端记录多半是本账本 push 的回声:经服务端 portal 存储与 wire
|
|
419
|
+
# 规整后常有字段级差异(列表逗号串化、详情字段裁剪)。本地账本
|
|
420
|
+
# 是该记录的权威源,回声一律保留本地并照常推进同步;真实的多设
|
|
421
|
+
# 备分歧由 push 侧 base_version 冲突兜底,不在此硬失败卡死整个
|
|
422
|
+
# 同步流。
|
|
423
|
+
record_event(c, "cloud-echo-kept-local", {"pattern_id": key})
|
|
424
|
+
for fp in item.get("finding_fingerprints", []):
|
|
425
|
+
c.execute(
|
|
426
|
+
"INSERT OR IGNORE INTO occurrences VALUES (?,?,?)",
|
|
427
|
+
(key, fp, now_iso()),
|
|
428
|
+
)
|
|
429
|
+
if promoted:
|
|
430
|
+
return "activated"
|
|
431
|
+
return "duplicate"
|
|
432
|
+
insert_pattern(c, item)
|
|
433
|
+
record_event(
|
|
434
|
+
c,
|
|
435
|
+
"cloud-pattern-imported",
|
|
436
|
+
{"pattern_id": key, "status": item.get("status", "candidate")},
|
|
437
|
+
)
|
|
438
|
+
return "created"
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def import_synced_incident_tx(
|
|
442
|
+
c: sqlite3.Connection, item: Mapping[str, Any]
|
|
443
|
+
) -> str:
|
|
444
|
+
key = str(item["incident_id"])
|
|
445
|
+
pattern_id = item.get("pattern_id")
|
|
446
|
+
if pattern_id is not None and not c.execute(
|
|
447
|
+
"SELECT 1 FROM patterns WHERE pattern_id=?", (pattern_id,)
|
|
448
|
+
).fetchone():
|
|
449
|
+
raise LessonLedgerError(f"云端 incident 关联的 pattern 不存在: {pattern_id}")
|
|
450
|
+
row = c.execute(
|
|
451
|
+
"SELECT content_hash,status FROM incidents WHERE incident_id=?", (key,)
|
|
452
|
+
).fetchone()
|
|
453
|
+
if row:
|
|
454
|
+
promoted = item.get("status") == "active" and row[1] == "candidate"
|
|
455
|
+
if promoted:
|
|
456
|
+
c.execute(
|
|
457
|
+
"UPDATE incidents SET status='active',updated_at=? "
|
|
458
|
+
"WHERE incident_id=? AND status='candidate'",
|
|
459
|
+
(now_iso(), key),
|
|
460
|
+
)
|
|
461
|
+
record_event(c, "cloud-incident-activated", {"incident_id": key})
|
|
462
|
+
if row[0] != item["content_hash"]:
|
|
463
|
+
# 与 pattern 同理:pull 回来的差异多为 push 回声经服务端规整的
|
|
464
|
+
# 字段级噪声,本地保留、照常推进;push 侧版本冲突兜底真实分歧。
|
|
465
|
+
record_event(c, "cloud-echo-kept-local", {"incident_id": key})
|
|
466
|
+
if promoted:
|
|
467
|
+
return "activated"
|
|
468
|
+
return "duplicate"
|
|
469
|
+
insert_incident(c, item)
|
|
470
|
+
record_event(
|
|
471
|
+
c,
|
|
472
|
+
"cloud-incident-imported",
|
|
473
|
+
{
|
|
474
|
+
"incident_id": key,
|
|
475
|
+
"status": item.get("status", "candidate"),
|
|
476
|
+
},
|
|
477
|
+
)
|
|
478
|
+
return "created"
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
def apply_synced_tombstone_tx(
|
|
482
|
+
c: sqlite3.Connection, item: Mapping[str, Any]
|
|
483
|
+
) -> str:
|
|
484
|
+
record_type = str(item.get("record_type") or "")
|
|
485
|
+
record_id = str(item.get("record_id") or "")
|
|
486
|
+
final_status = str(item.get("final_status") or "revoked")
|
|
487
|
+
if (
|
|
488
|
+
record_type not in {"pattern", "incident", "tool_experience", "tool"}
|
|
489
|
+
or not record_id
|
|
490
|
+
):
|
|
491
|
+
raise LessonLedgerError("云端 tombstone 缺少合法 record_type/record_id")
|
|
492
|
+
if final_status not in {"superseded", "retired", "revoked"}:
|
|
493
|
+
final_status = "revoked"
|
|
494
|
+
if record_type in {"tool_experience", "tool"}:
|
|
495
|
+
if "/" not in record_id:
|
|
496
|
+
raise LessonLedgerError(
|
|
497
|
+
"tool experience tombstone record_id 必须是 tool_name/category"
|
|
498
|
+
)
|
|
499
|
+
tool_name, category = record_id.split("/", 1)
|
|
500
|
+
# F-129: 与 DDL 命名契约绑定,按列名取值,禁止依赖列序位置。
|
|
501
|
+
row = c.execute(
|
|
502
|
+
"SELECT tool_name,category,experience_level,record_version,use_count,"
|
|
503
|
+
"hit_count,miss_count,false_positive_count,rejected_count,"
|
|
504
|
+
"independent_lifecycle_count,first_observed_at,last_observed_at,"
|
|
505
|
+
"tool_version,device_id,deleted,deleted_at FROM tool_experience "
|
|
506
|
+
"WHERE tool_name=? AND category=?",
|
|
507
|
+
(tool_name, category),
|
|
508
|
+
).fetchone()
|
|
509
|
+
if not row:
|
|
510
|
+
return "missing"
|
|
511
|
+
if bool(row["deleted"]):
|
|
512
|
+
return "duplicate"
|
|
513
|
+
deleted_at = now_iso()
|
|
514
|
+
content = {
|
|
515
|
+
"tool_name": row["tool_name"],
|
|
516
|
+
"category": row["category"],
|
|
517
|
+
"experience_level": row["experience_level"],
|
|
518
|
+
"record_version": int(row["record_version"]),
|
|
519
|
+
"use_count": int(row["use_count"]),
|
|
520
|
+
"hit_count": int(row["hit_count"]),
|
|
521
|
+
"miss_count": int(row["miss_count"]),
|
|
522
|
+
"false_positive_count": int(row["false_positive_count"]),
|
|
523
|
+
"rejected_count": int(row["rejected_count"]),
|
|
524
|
+
"independent_lifecycle_count": int(row["independent_lifecycle_count"]),
|
|
525
|
+
"first_observed_at": row["first_observed_at"],
|
|
526
|
+
"last_observed_at": row["last_observed_at"],
|
|
527
|
+
"tool_version": row["tool_version"],
|
|
528
|
+
"device_id": row["device_id"],
|
|
529
|
+
"deleted": True,
|
|
530
|
+
"deleted_at": deleted_at,
|
|
531
|
+
}
|
|
532
|
+
c.execute(
|
|
533
|
+
"UPDATE tool_experience SET deleted=1,deleted_at=?,content_hash=? "
|
|
534
|
+
"WHERE tool_name=? AND category=?",
|
|
535
|
+
(deleted_at, tool_experience_hash(content), tool_name, category),
|
|
536
|
+
)
|
|
537
|
+
record_event(
|
|
538
|
+
c,
|
|
539
|
+
"cloud-tombstone-applied",
|
|
540
|
+
{
|
|
541
|
+
"record_type": "tool_experience",
|
|
542
|
+
"record_id": record_id,
|
|
543
|
+
"final_status": "revoked",
|
|
544
|
+
},
|
|
545
|
+
)
|
|
546
|
+
return "applied"
|
|
547
|
+
table = "patterns" if record_type == "pattern" else "incidents"
|
|
548
|
+
key_column = "pattern_id" if table == "patterns" else "incident_id"
|
|
549
|
+
row = c.execute(
|
|
550
|
+
f"SELECT status FROM {table} WHERE {key_column}=?", (record_id,)
|
|
551
|
+
).fetchone()
|
|
552
|
+
if not row:
|
|
553
|
+
return "missing"
|
|
554
|
+
stamp = now_iso()
|
|
555
|
+
changed = row[0] != final_status
|
|
556
|
+
c.execute(
|
|
557
|
+
f"UPDATE {table} SET status=?,updated_at=? WHERE {key_column}=?",
|
|
558
|
+
(final_status, stamp, record_id),
|
|
559
|
+
)
|
|
560
|
+
cascaded = 0
|
|
561
|
+
if record_type == "pattern":
|
|
562
|
+
children = c.execute(
|
|
563
|
+
"SELECT incident_id FROM incidents WHERE pattern_id=? "
|
|
564
|
+
"AND status IN ('candidate','active')",
|
|
565
|
+
(record_id,),
|
|
566
|
+
).fetchall()
|
|
567
|
+
c.execute(
|
|
568
|
+
"UPDATE incidents SET status='revoked',updated_at=? "
|
|
569
|
+
"WHERE pattern_id=? AND status IN ('candidate','active')",
|
|
570
|
+
(stamp, record_id),
|
|
571
|
+
)
|
|
572
|
+
for child in children:
|
|
573
|
+
incident = incident_value(c, child[0])
|
|
574
|
+
c.execute(
|
|
575
|
+
"UPDATE incidents SET content_hash=? WHERE incident_id=?",
|
|
576
|
+
(incident_content_hash(incident), child[0]),
|
|
577
|
+
)
|
|
578
|
+
cascaded = len(children)
|
|
579
|
+
record_event(
|
|
580
|
+
c,
|
|
581
|
+
"cloud-tombstone-applied",
|
|
582
|
+
{
|
|
583
|
+
"record_type": record_type,
|
|
584
|
+
"record_id": record_id,
|
|
585
|
+
"final_status": final_status,
|
|
586
|
+
"cascaded_incidents": cascaded,
|
|
587
|
+
},
|
|
588
|
+
)
|
|
589
|
+
return "applied" if changed or cascaded else "duplicate"
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
def sync_import_content_hash(
|
|
593
|
+
patterns: Iterable[Mapping[str, Any]],
|
|
594
|
+
incidents: Iterable[Mapping[str, Any]],
|
|
595
|
+
tool_records: Iterable[Mapping[str, Any]],
|
|
596
|
+
tombstones: Iterable[Mapping[str, Any]],
|
|
597
|
+
consumption_events: Iterable[Mapping[str, Any]] = (),
|
|
598
|
+
) -> str:
|
|
599
|
+
"""Hash one normalized import batch for crash-safe replay detection."""
|
|
600
|
+
payload = {
|
|
601
|
+
"patterns": sorted(
|
|
602
|
+
(dict(item) for item in patterns),
|
|
603
|
+
key=lambda item: str(
|
|
604
|
+
item.get("pattern_id") or item.get("lesson_id") or ""
|
|
605
|
+
),
|
|
606
|
+
),
|
|
607
|
+
"incidents": sorted(
|
|
608
|
+
(dict(item) for item in incidents),
|
|
609
|
+
key=lambda item: str(item.get("incident_id") or ""),
|
|
610
|
+
),
|
|
611
|
+
"tool_experience": sorted(
|
|
612
|
+
(dict(item) for item in tool_records),
|
|
613
|
+
key=lambda item: (
|
|
614
|
+
str(item.get("tool_name") or ""),
|
|
615
|
+
str(item.get("category") or ""),
|
|
616
|
+
),
|
|
617
|
+
),
|
|
618
|
+
"consumption_events": sorted(
|
|
619
|
+
(dict(item) for item in consumption_events),
|
|
620
|
+
key=lambda item: str(item.get("event_id") or ""),
|
|
621
|
+
),
|
|
622
|
+
"tombstones": sorted(
|
|
623
|
+
(dict(item) for item in tombstones),
|
|
624
|
+
key=lambda item: (
|
|
625
|
+
str(item.get("record_type") or ""),
|
|
626
|
+
str(item.get("record_id") or ""),
|
|
627
|
+
),
|
|
628
|
+
),
|
|
629
|
+
}
|
|
630
|
+
return hashlib.sha256(canonical_bytes(payload)).hexdigest()
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
def sync_import_receipt(
|
|
634
|
+
path: str | os.PathLike[str], snapshot_id: str
|
|
635
|
+
) -> dict[str, Any] | None:
|
|
636
|
+
"""Return the Ledger-side receipt for one remote snapshot, if committed."""
|
|
637
|
+
key = sanitize_text(snapshot_id, "snapshot_id")
|
|
638
|
+
db = database_path(path)
|
|
639
|
+
with connect_ledger(db, readonly=True) as c:
|
|
640
|
+
validate_pattern(c, db)
|
|
641
|
+
row = c.execute(
|
|
642
|
+
"SELECT snapshot_id,manifest_hash,content_hash,record_count,created_at,committed_at "
|
|
643
|
+
"FROM sync_import_receipts WHERE snapshot_id=?",
|
|
644
|
+
(key,),
|
|
645
|
+
).fetchone()
|
|
646
|
+
return dict(row) if row else None
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
def import_synced_records(
|
|
650
|
+
path: str | os.PathLike[str],
|
|
651
|
+
patterns: Iterable[Mapping[str, Any]] = (),
|
|
652
|
+
incidents: Iterable[Mapping[str, Any]] = (),
|
|
653
|
+
tool_records: Iterable[Mapping[str, Any]] = (),
|
|
654
|
+
tombstones: Iterable[Mapping[str, Any]] = (),
|
|
655
|
+
consumption_events: Iterable[Mapping[str, Any]] = (),
|
|
656
|
+
*,
|
|
657
|
+
allow_remote_active: bool = True,
|
|
658
|
+
actor: str = "supervisor",
|
|
659
|
+
snapshot_id: str | None = None,
|
|
660
|
+
manifest_hash: str = "",
|
|
661
|
+
) -> dict[str, Any]:
|
|
662
|
+
"""原子导入一个已验证的云端快照。"""
|
|
663
|
+
if actor != "supervisor":
|
|
664
|
+
raise LessonLedgerError("云端知识导入必须由 Supervisor 提交")
|
|
665
|
+
pattern_items = [
|
|
666
|
+
synced_pattern(item, allow_remote_active=allow_remote_active)
|
|
667
|
+
for item in patterns
|
|
668
|
+
]
|
|
669
|
+
if len({item["pattern_id"] for item in pattern_items}) != len(pattern_items):
|
|
670
|
+
raise LessonLedgerError("导入批次内 pattern_id 不得重复")
|
|
671
|
+
tool_items = normalize_tool_experience_records(tool_records)
|
|
672
|
+
incident_raw = list(incidents)
|
|
673
|
+
incident_items = [
|
|
674
|
+
synced_incident(raw, allow_remote_active=allow_remote_active)
|
|
675
|
+
for raw in incident_raw
|
|
676
|
+
]
|
|
677
|
+
tombstone_items = [dict(item) for item in tombstones]
|
|
678
|
+
consumption_items = []
|
|
679
|
+
for raw in consumption_events:
|
|
680
|
+
if not isinstance(raw, Mapping):
|
|
681
|
+
raise LessonLedgerError("云端 consumption event 必须是对象")
|
|
682
|
+
item = {key: str(raw.get(key) or "") for key in (
|
|
683
|
+
"event_id", "subject_type", "subject_id", "event_type",
|
|
684
|
+
"lifecycle_id", "run_id", "created_at",
|
|
685
|
+
)}
|
|
686
|
+
if not item["event_id"] or item["event_type"] not in {
|
|
687
|
+
"selected", "retrieved", "feedback",
|
|
688
|
+
}:
|
|
689
|
+
raise LessonLedgerError("云端 consumption event 无效")
|
|
690
|
+
consumption_items.append(item)
|
|
691
|
+
snapshot_key = sanitize_text(snapshot_id, "snapshot_id") if snapshot_id else None
|
|
692
|
+
remote_manifest_hash = str(manifest_hash or "")
|
|
693
|
+
content_hash = sync_import_content_hash(
|
|
694
|
+
pattern_items, incident_items, tool_items, tombstone_items,
|
|
695
|
+
consumption_items,
|
|
696
|
+
)
|
|
697
|
+
record_count = (
|
|
698
|
+
len(pattern_items)
|
|
699
|
+
+ len(incident_raw)
|
|
700
|
+
+ len(tool_items)
|
|
701
|
+
+ len(tombstone_items)
|
|
702
|
+
+ len(consumption_items)
|
|
703
|
+
)
|
|
704
|
+
if len({item["incident_id"] for item in incident_items}) != len(incident_items):
|
|
705
|
+
raise LessonLedgerError("导入批次内 incident_id 不得重复")
|
|
706
|
+
|
|
707
|
+
def go(c: sqlite3.Connection):
|
|
708
|
+
if snapshot_key:
|
|
709
|
+
receipt = c.execute(
|
|
710
|
+
"SELECT snapshot_id,manifest_hash,content_hash,record_count,created_at,committed_at "
|
|
711
|
+
"FROM sync_import_receipts WHERE snapshot_id=?",
|
|
712
|
+
(snapshot_key,),
|
|
713
|
+
).fetchone()
|
|
714
|
+
if receipt:
|
|
715
|
+
if receipt[2] != content_hash or (
|
|
716
|
+
remote_manifest_hash
|
|
717
|
+
and receipt[1]
|
|
718
|
+
and receipt[1] != remote_manifest_hash
|
|
719
|
+
):
|
|
720
|
+
raise LessonLedgerError(
|
|
721
|
+
f"snapshot_id 已存在但内容不一致,拒绝重放: {snapshot_key}"
|
|
722
|
+
)
|
|
723
|
+
return {
|
|
724
|
+
"status": "duplicate",
|
|
725
|
+
"receipt": dict(receipt),
|
|
726
|
+
"patterns": {"created": 0, "activated": 0, "duplicate": 0},
|
|
727
|
+
"incidents": {"created": 0, "activated": 0, "duplicate": 0},
|
|
728
|
+
"tools": {"imported": [], "duplicates": [], "stale": []},
|
|
729
|
+
"consumption_events": 0,
|
|
730
|
+
"revision": c.execute("SELECT COUNT(*) FROM events").fetchone()[
|
|
731
|
+
0
|
|
732
|
+
],
|
|
733
|
+
}
|
|
734
|
+
pattern_result = {"created": 0, "activated": 0, "duplicate": 0}
|
|
735
|
+
for item in pattern_items:
|
|
736
|
+
pattern_result[import_synced_pattern_tx(c, item)] += 1
|
|
737
|
+
incident_result = {"created": 0, "activated": 0, "duplicate": 0}
|
|
738
|
+
for raw in incident_raw:
|
|
739
|
+
item = synced_incident(
|
|
740
|
+
raw, allow_remote_active=allow_remote_active, c=c
|
|
741
|
+
)
|
|
742
|
+
incident_result[import_synced_incident_tx(c, item)] += 1
|
|
743
|
+
tool_result = import_tool_experience_tx(c, tool_items)
|
|
744
|
+
consumption_result = {"recorded": 0, "duplicate": 0}
|
|
745
|
+
for item in consumption_items:
|
|
746
|
+
status = record_consumption_event_tx(c, item)["status"]
|
|
747
|
+
consumption_result[status] += 1
|
|
748
|
+
for item in tombstone_items:
|
|
749
|
+
apply_synced_tombstone_tx(c, item)
|
|
750
|
+
if snapshot_key:
|
|
751
|
+
now = now_iso()
|
|
752
|
+
c.execute(
|
|
753
|
+
"INSERT INTO sync_import_receipts(snapshot_id,manifest_hash,content_hash,"
|
|
754
|
+
"record_count,created_at,committed_at) VALUES(?,?,?,?,?,?)",
|
|
755
|
+
(
|
|
756
|
+
snapshot_key,
|
|
757
|
+
remote_manifest_hash,
|
|
758
|
+
content_hash,
|
|
759
|
+
record_count,
|
|
760
|
+
now,
|
|
761
|
+
now,
|
|
762
|
+
),
|
|
763
|
+
)
|
|
764
|
+
record_event(
|
|
765
|
+
c,
|
|
766
|
+
"cloud-import-committed",
|
|
767
|
+
{
|
|
768
|
+
"snapshot_id": snapshot_key,
|
|
769
|
+
"content_hash": content_hash,
|
|
770
|
+
"record_count": record_count,
|
|
771
|
+
},
|
|
772
|
+
)
|
|
773
|
+
return {
|
|
774
|
+
"status": "imported",
|
|
775
|
+
"patterns": pattern_result,
|
|
776
|
+
"incidents": incident_result,
|
|
777
|
+
"tools": tool_result,
|
|
778
|
+
"consumption_events": consumption_result["recorded"],
|
|
779
|
+
"revision": c.execute("SELECT COUNT(*) FROM events").fetchone()[0],
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
return ledger_transaction(path, go)
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
def metrics(path: str | os.PathLike[str]) -> dict[str, Any]:
|
|
786
|
+
"""生成错题本与工具知识库全量审计指标。"""
|
|
787
|
+
db = database_path(path)
|
|
788
|
+
with connect_ledger(db, readonly=True) as c:
|
|
789
|
+
validate_pattern(c, db)
|
|
790
|
+
counts = {x: 0 for x in PATTERN_OUTCOMES}
|
|
791
|
+
for r in c.execute(
|
|
792
|
+
"SELECT outcome,COUNT(*) FROM feedback GROUP BY outcome"
|
|
793
|
+
):
|
|
794
|
+
counts[r[0]] = r[1]
|
|
795
|
+
status = {
|
|
796
|
+
r[0]: r[1]
|
|
797
|
+
for r in c.execute(
|
|
798
|
+
"SELECT status,COUNT(*) FROM patterns GROUP BY status"
|
|
799
|
+
)
|
|
800
|
+
}
|
|
801
|
+
total = sum(status.values())
|
|
802
|
+
feedback = sum(counts.values())
|
|
803
|
+
den = counts["hit"] + counts["false_positive"] + counts["rejected"]
|
|
804
|
+
replayable = c.execute(
|
|
805
|
+
"SELECT COUNT(*) FROM patterns p WHERE EXISTS "
|
|
806
|
+
"(SELECT 1 FROM probes WHERE pattern_id=p.pattern_id AND kind='probe') "
|
|
807
|
+
"AND EXISTS (SELECT 1 FROM probes WHERE pattern_id=p.pattern_id AND kind='negative_control') "
|
|
808
|
+
"AND EXISTS (SELECT 1 FROM probes WHERE pattern_id=p.pattern_id AND kind='evidence')"
|
|
809
|
+
).fetchone()[0]
|
|
810
|
+
guardrail_total = c.execute(
|
|
811
|
+
"SELECT COUNT(*) FROM patterns WHERE EXISTS "
|
|
812
|
+
"(SELECT 1 FROM probes WHERE pattern_id=patterns.pattern_id AND kind='false_positive')"
|
|
813
|
+
).fetchone()[0]
|
|
814
|
+
delayed_rows = [
|
|
815
|
+
(
|
|
816
|
+
json.loads(row[3]).get("pattern_id"),
|
|
817
|
+
json.loads(row[3]).get("signature"),
|
|
818
|
+
)
|
|
819
|
+
for row in c.execute(
|
|
820
|
+
"SELECT seq,type,at,payload,prev_hash,hash FROM events "
|
|
821
|
+
"WHERE type='pattern-delayed-hit'"
|
|
822
|
+
)
|
|
823
|
+
if isinstance(json.loads(row[3]), dict)
|
|
824
|
+
]
|
|
825
|
+
delayed_hits = len(delayed_rows)
|
|
826
|
+
delayed_hit_pattern_ids = sorted(
|
|
827
|
+
{key for key, _ in delayed_rows if key is not None}
|
|
828
|
+
)
|
|
829
|
+
incidents_total = c.execute("SELECT COUNT(*) FROM incidents").fetchone()[0]
|
|
830
|
+
incidents_with_diff = c.execute(
|
|
831
|
+
"SELECT COUNT(*) FROM incidents WHERE diff_ref IS NOT NULL OR commit_ref IS NOT NULL"
|
|
832
|
+
).fetchone()[0]
|
|
833
|
+
tool_feedback_total = c.execute(
|
|
834
|
+
"SELECT COUNT(*) FROM tool_usage"
|
|
835
|
+
).fetchone()[0]
|
|
836
|
+
tool_level_rows = c.execute(
|
|
837
|
+
"SELECT tool_name,COUNT(DISTINCT lifecycle_id) FROM tool_usage "
|
|
838
|
+
"WHERE outcome='hit' GROUP BY tool_name"
|
|
839
|
+
).fetchall()
|
|
840
|
+
tool_levels = {"active": 0, "candidate": 0, "unproven": 0}
|
|
841
|
+
seen_tools = {str(row[0]) for row in tool_level_rows}
|
|
842
|
+
for row in tool_level_rows:
|
|
843
|
+
level = tool_experience_level(int(row[1]))
|
|
844
|
+
tool_levels[level] = tool_levels.get(level, 0) + 1
|
|
845
|
+
unproven = (
|
|
846
|
+
c.execute(
|
|
847
|
+
"SELECT COUNT(DISTINCT tool_name) FROM tool_usage"
|
|
848
|
+
).fetchone()[0]
|
|
849
|
+
- len(seen_tools)
|
|
850
|
+
)
|
|
851
|
+
tool_levels["unproven"] += max(0, unproven)
|
|
852
|
+
knowledge_consumption_events = c.execute(
|
|
853
|
+
"SELECT COUNT(*) FROM consumption_events"
|
|
854
|
+
).fetchone()[0]
|
|
855
|
+
patterns_retrieved = c.execute(
|
|
856
|
+
"SELECT COUNT(DISTINCT subject_id) FROM consumption_events "
|
|
857
|
+
"WHERE subject_type='pattern' AND event_type='retrieved'"
|
|
858
|
+
).fetchone()[0]
|
|
859
|
+
incidents_retrieved = c.execute(
|
|
860
|
+
"SELECT COUNT(DISTINCT subject_id) FROM consumption_events "
|
|
861
|
+
"WHERE subject_type='incident' AND event_type='retrieved'"
|
|
862
|
+
).fetchone()[0]
|
|
863
|
+
tools_retrieved = c.execute(
|
|
864
|
+
"SELECT COUNT(DISTINCT subject_id) FROM consumption_events "
|
|
865
|
+
"WHERE subject_type='tool_experience' AND event_type='retrieved'"
|
|
866
|
+
).fetchone()[0]
|
|
867
|
+
return {
|
|
868
|
+
"schema_version": SCHEMA_VERSION,
|
|
869
|
+
"storage_backend": "sqlite",
|
|
870
|
+
"database": str(db),
|
|
871
|
+
"revision": c.execute("SELECT COUNT(*) FROM events").fetchone()[0],
|
|
872
|
+
"events_archived": sum(
|
|
873
|
+
int(entry.get("record_count", 0))
|
|
874
|
+
for entry in archive_manifest(c)
|
|
875
|
+
),
|
|
876
|
+
"lessons_total": total,
|
|
877
|
+
"patterns_total": total,
|
|
878
|
+
"lessons_active": status.get("active", 0) + status.get("candidate", 0),
|
|
879
|
+
"patterns_by_status": status,
|
|
880
|
+
"occurrences_total": c.execute(
|
|
881
|
+
"SELECT COUNT(*) FROM occurrences"
|
|
882
|
+
).fetchone()[0],
|
|
883
|
+
"probes_total": c.execute("SELECT COUNT(*) FROM probes").fetchone()[0],
|
|
884
|
+
"replayable_patterns": replayable,
|
|
885
|
+
"false_positive_guardrail_patterns": guardrail_total,
|
|
886
|
+
"reviews_total": c.execute("SELECT COUNT(*) FROM reviews").fetchone()[
|
|
887
|
+
0
|
|
888
|
+
],
|
|
889
|
+
"incidents_total": incidents_total,
|
|
890
|
+
"incidents_with_diff": incidents_with_diff,
|
|
891
|
+
"tool_feedback_total": tool_feedback_total,
|
|
892
|
+
"tools_total": c.execute(
|
|
893
|
+
"SELECT COUNT(DISTINCT tool_name) FROM tool_usage"
|
|
894
|
+
).fetchone()[0],
|
|
895
|
+
"tool_experience_levels": tool_levels,
|
|
896
|
+
"knowledge_consumption_events": knowledge_consumption_events,
|
|
897
|
+
"patterns_retrieved": patterns_retrieved,
|
|
898
|
+
"incidents_retrieved": incidents_retrieved,
|
|
899
|
+
"tools_retrieved": tools_retrieved,
|
|
900
|
+
"delayed_hits": delayed_hits,
|
|
901
|
+
"delayed_hit_pattern_ids": delayed_hit_pattern_ids,
|
|
902
|
+
"lessons_used": c.execute(
|
|
903
|
+
"SELECT COUNT(*) FROM patterns WHERE use_count>0"
|
|
904
|
+
).fetchone()[0],
|
|
905
|
+
"usage_total": c.execute(
|
|
906
|
+
"SELECT COALESCE(SUM(use_count),0) FROM patterns"
|
|
907
|
+
).fetchone()[0],
|
|
908
|
+
"feedback_total": feedback,
|
|
909
|
+
"outcomes": counts,
|
|
910
|
+
"feedback_effective_total": feedback - counts.get("not_applicable", 0),
|
|
911
|
+
"feedback_precision": round(counts["hit"] / den, 4) if den else None,
|
|
912
|
+
"hit_rate": round(
|
|
913
|
+
counts["hit"] / (feedback - counts.get("not_applicable", 0)), 4
|
|
914
|
+
)
|
|
915
|
+
if feedback - counts.get("not_applicable", 0)
|
|
916
|
+
else None,
|
|
917
|
+
"feedback_recall": round(
|
|
918
|
+
counts["hit"] / (counts["hit"] + counts["miss"]), 4
|
|
919
|
+
)
|
|
920
|
+
if counts["hit"] + counts["miss"]
|
|
921
|
+
else None,
|
|
922
|
+
"feedback_effectiveness": round(
|
|
923
|
+
counts["hit"] / (feedback - counts.get("not_applicable", 0)), 4
|
|
924
|
+
)
|
|
925
|
+
if feedback - counts.get("not_applicable", 0)
|
|
926
|
+
else None,
|
|
927
|
+
"state_hash": c.execute(
|
|
928
|
+
"SELECT value FROM meta WHERE key='state_hash'"
|
|
929
|
+
).fetchone()[0],
|
|
930
|
+
"head_hash": c.execute(
|
|
931
|
+
"SELECT value FROM meta WHERE key='head_hash'"
|
|
932
|
+
).fetchone()[0],
|
|
933
|
+
"seed_count": int(
|
|
934
|
+
c.execute("SELECT value FROM meta WHERE key='seed_count'").fetchone()[
|
|
935
|
+
0
|
|
936
|
+
]
|
|
937
|
+
)
|
|
938
|
+
if c.execute("SELECT 1 FROM meta WHERE key='seed_count'").fetchone()
|
|
939
|
+
else total,
|
|
940
|
+
}
|