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,1254 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""core/supervisor/budget_governor.py - Supervisor 预算管控与并发协调服务 (DOC-070)。
|
|
3
|
+
|
|
4
|
+
负责轮次截止期、软硬预算监控、并发状态对齐、僵尸检测及预算耗尽状态转换。
|
|
5
|
+
|
|
6
|
+
恢复会话结算语义(2026-11-17 用户裁决,三维度):
|
|
7
|
+
|
|
8
|
+
* 维度 1【继承豁免】:expired claim 的单元若已 100% 沿链继承覆盖(清单行带
|
|
9
|
+
``inherited_from`` 备注且 ``coverage_discovery.resolve_inherited_evidence``
|
|
10
|
+
溯源可达祖先 passed 证据),该 claim 标记 ``superseded_by_inheritance``
|
|
11
|
+
并从并行门的 expired 重试债集合移除,不再重派;未覆盖单元才进入重派路径。
|
|
12
|
+
标记以 hash-chain 事件 ``expired_claim_superseded_by_inheritance`` 落账
|
|
13
|
+
(不改动 WorkerClaim 持久化 schema);豁免按当前清单状态**确定性重算**,
|
|
14
|
+
清单继承引用被内容失效撤回时重试债如实回归。
|
|
15
|
+
* 维度 2【恢复场景豁免】:并行门(require_parallel 的并发证明债)对恢复
|
|
16
|
+
会话豁免,三条件缺一不可(fail-closed):① owner_cancelled 死亡证明在
|
|
17
|
+
Supervisor 权威链(operation=lifecycle, gate=owner_cancelled);② 本 Life
|
|
18
|
+
covered 100% 来自继承+历史证据(判定口径:本 round 零新增证据记录,含
|
|
19
|
+
failed/error——OQ-2 加强,不只 passed);③ 本会话无新增 findings(owner
|
|
20
|
+
死亡锚点之后 findings 增量为 0)。豁免动作落专项留痕事件
|
|
21
|
+
``parallel_gate_inherited_closeout``(含三条件逐项快照);非 ``--final``
|
|
22
|
+
收口场景由 post 侧拒绝消费该豁免(D5)。
|
|
23
|
+
* 维度 3【合账语义(2026-11-17 用户裁决"新证据为准 + chain 保留")】:单元
|
|
24
|
+
证据分三层——L1 本轮重派本地记录 / L2 本 Life 历史本地记录 / L3 沿链继承
|
|
25
|
+
(清单行 ``inherited_from`` 备注 + ``resolve_inherited_evidence`` 溯源)。
|
|
26
|
+
判定读取优先级 L1/L2 本地最新 > L3 沿链(R-1,实现在
|
|
27
|
+
``coverage_discovery.inherited_unit_coverage_verdicts`` /
|
|
28
|
+
``recovery_closeout_coverage_census``):本函数消费 verdict 的 ``backing``
|
|
29
|
+
归属字段(supersede 快照可区分凭继承/凭本地证据豁免),维度 1 决策逻辑
|
|
30
|
+
不变——字面只有沿链继承豁免(OQ-1 有意的 fail-closed 浪费);清单行遗留
|
|
31
|
+
备注永不改写(R-3 chain 保留),本地新证据推翻继承时 divergence 随 census
|
|
32
|
+
快照显性化(R-5)。
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from __future__ import annotations
|
|
36
|
+
|
|
37
|
+
import dataclasses
|
|
38
|
+
import re
|
|
39
|
+
import os
|
|
40
|
+
import sys
|
|
41
|
+
import time
|
|
42
|
+
from pathlib import Path
|
|
43
|
+
from typing import Callable, Iterable, Mapping, Sequence
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
ROUND_HEARTBEAT_TIMEOUT_SECONDS = 450.0
|
|
47
|
+
LONG_CALL_MAX_SILENCE_SECONDS = 600.0
|
|
48
|
+
|
|
49
|
+
# 系统级熔断与预算耗尽写入已下沉到 systemic_failure / claim_events(2026-10-26
|
|
50
|
+
# 架构收敛):budget_governor 与 lease_manager 的双向依赖由此消除。这里 re-export,
|
|
51
|
+
# 既有 `from .budget_governor import ...` 调用点保持不变。
|
|
52
|
+
try:
|
|
53
|
+
from .claim_events import append_event
|
|
54
|
+
from .systemic_failure import (
|
|
55
|
+
SYSTEMIC_FAILURE_MARKERS,
|
|
56
|
+
check_and_record_systemic_failure,
|
|
57
|
+
set_budget_exhausted,
|
|
58
|
+
)
|
|
59
|
+
except ImportError: # pragma: no cover
|
|
60
|
+
from core.supervisor.claim_events import append_event
|
|
61
|
+
from core.supervisor.systemic_failure import (
|
|
62
|
+
SYSTEMIC_FAILURE_MARKERS,
|
|
63
|
+
check_and_record_systemic_failure,
|
|
64
|
+
set_budget_exhausted,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
from .supervisor_models import (
|
|
68
|
+
BudgetExhausted,
|
|
69
|
+
InvalidCheckpoint,
|
|
70
|
+
InvalidTransition,
|
|
71
|
+
MAX_LEASE_SECONDS,
|
|
72
|
+
MAX_WORKER_ATTEMPTS,
|
|
73
|
+
TERMINAL_COVERED,
|
|
74
|
+
RunBudget,
|
|
75
|
+
RunState,
|
|
76
|
+
Status,
|
|
77
|
+
WorkerClaim,
|
|
78
|
+
workspace_fingerprint,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
from core.supervisor.lease_manager import (
|
|
82
|
+
eligible_units,
|
|
83
|
+
mark_claim_expired,
|
|
84
|
+
mark_worker_attempts_exhausted,
|
|
85
|
+
record_expiry_accounting,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# ---------------------------------------------------------------------------
|
|
90
|
+
# 第四批缺陷修复(假并发门禁):并发证据只认**真实 worker**。
|
|
91
|
+
#
|
|
92
|
+
# 实证(2026-11-16 zcode 会话 supervisor.json):judge 判读取证电池的记账式
|
|
93
|
+
# claim(provider=judge-collect/judge-flow,core/launch_phases/judge_phase.py)
|
|
94
|
+
# process_pid=None、tokens_consumed=0、心跳零推进、同波 execution_finished_at
|
|
95
|
+
# 逐秒相同——它们是引擎判读取证的记账,不是 LLM worker;但重叠执行窗口曾被
|
|
96
|
+
# 并行门禁当作真实并发证据(parallel_history max_active=6/overlap 787s)。
|
|
97
|
+
#
|
|
98
|
+
# 真实性判据(三选二,与 provider 解耦——记账方未来换名也不失效):
|
|
99
|
+
# 1. process_pid 非空(真实进程被启动);
|
|
100
|
+
# 2. tokens_consumed > 0(LLM 用量被实测);
|
|
101
|
+
# 3. 心跳推进:last_heartbeat_at 晚于 execution_started_at
|
|
102
|
+
# (记账 claim 的 last_heartbeat_at 在 start_worker 时一次性写入,
|
|
103
|
+
# 与 started_at 同值,永不推进——实测字段特征)。
|
|
104
|
+
# ---------------------------------------------------------------------------
|
|
105
|
+
WORKER_AUTHENTICITY_MIN_SIGNALS = 2
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def worker_authenticity_signals(claim: WorkerClaim) -> int:
|
|
109
|
+
"""统计单条 claim 的真实 worker 证据数(0..3)。"""
|
|
110
|
+
signals = 0
|
|
111
|
+
if getattr(claim, "process_pid", None) is not None:
|
|
112
|
+
signals += 1
|
|
113
|
+
try:
|
|
114
|
+
if int(getattr(claim, "tokens_consumed", 0) or 0) > 0:
|
|
115
|
+
signals += 1
|
|
116
|
+
except (TypeError, ValueError):
|
|
117
|
+
pass
|
|
118
|
+
heartbeat_at = getattr(claim, "last_heartbeat_at", None)
|
|
119
|
+
started_at = getattr(claim, "execution_started_at", None)
|
|
120
|
+
if heartbeat_at is not None and (
|
|
121
|
+
started_at is None or float(heartbeat_at) > float(started_at)
|
|
122
|
+
):
|
|
123
|
+
signals += 1
|
|
124
|
+
return signals
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def is_authentic_worker_claim(claim: WorkerClaim) -> bool:
|
|
128
|
+
"""三选二:满足至少两项真实证据才算 LLM worker 的执行证据。"""
|
|
129
|
+
return worker_authenticity_signals(claim) >= WORKER_AUTHENTICITY_MIN_SIGNALS
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def reconcile_parallel(state: RunState, now: float) -> None:
|
|
133
|
+
"""从持久化执行窗口重建本轮真实重叠,跨进程 resume 也不丢失。
|
|
134
|
+
|
|
135
|
+
只有真实 worker(:func:`is_authentic_worker_claim`)的执行窗口才构成
|
|
136
|
+
并发证据;judge 记账式 claim 不再能把 ``round_max_active_workers`` /
|
|
137
|
+
``round_overlap_seconds`` 抬到假达标。
|
|
138
|
+
"""
|
|
139
|
+
intervals: list[tuple[float, float]] = []
|
|
140
|
+
for claim in state.claims.values():
|
|
141
|
+
if claim.round_no != state.round_no or claim.execution_started_at is None:
|
|
142
|
+
continue
|
|
143
|
+
if not is_authentic_worker_claim(claim):
|
|
144
|
+
continue
|
|
145
|
+
start = float(claim.execution_started_at)
|
|
146
|
+
if claim.execution_state == "running":
|
|
147
|
+
# B5:开区间右端必须夹到真实租约边界,否则僵尸 running claim 的
|
|
148
|
+
# 重叠时长会随等待时间线性增长(并发证据可被"等得够久"伪造)。
|
|
149
|
+
boundaries = [now]
|
|
150
|
+
if claim.lease_expires_at is not None:
|
|
151
|
+
boundaries.append(float(claim.lease_expires_at))
|
|
152
|
+
if claim.total_lease_deadline is not None:
|
|
153
|
+
boundaries.append(float(claim.total_lease_deadline))
|
|
154
|
+
end = min(boundaries)
|
|
155
|
+
else:
|
|
156
|
+
end = float(
|
|
157
|
+
claim.execution_finished_at
|
|
158
|
+
or claim.submitted_at
|
|
159
|
+
or claim.lease_expires_at
|
|
160
|
+
)
|
|
161
|
+
if end > start:
|
|
162
|
+
intervals.append((start, end))
|
|
163
|
+
events: dict[float, int] = {}
|
|
164
|
+
for start, end in intervals:
|
|
165
|
+
events[start] = events.get(start, 0) + 1
|
|
166
|
+
events[end] = events.get(end, 0) - 1
|
|
167
|
+
active_count = 0
|
|
168
|
+
peak = sum(
|
|
169
|
+
claim.active and claim.execution_state == "running"
|
|
170
|
+
and is_authentic_worker_claim(claim)
|
|
171
|
+
for claim in state.claims.values()
|
|
172
|
+
if claim.round_no == state.round_no
|
|
173
|
+
)
|
|
174
|
+
overlap = 0.0
|
|
175
|
+
points = sorted(events)
|
|
176
|
+
for index, point in enumerate(points):
|
|
177
|
+
active_count += events[point]
|
|
178
|
+
peak = max(peak, active_count)
|
|
179
|
+
if index + 1 < len(points) and active_count >= 2:
|
|
180
|
+
overlap += max(0.0, points[index + 1] - point)
|
|
181
|
+
state.round_max_active_workers = peak
|
|
182
|
+
state.round_overlap_seconds = round(overlap, 6)
|
|
183
|
+
current_running = sum(
|
|
184
|
+
claim.active and claim.execution_state == "running"
|
|
185
|
+
and is_authentic_worker_claim(claim)
|
|
186
|
+
and claim.round_no == state.round_no
|
|
187
|
+
for claim in state.claims.values()
|
|
188
|
+
)
|
|
189
|
+
# LOG-10:``current_running`` 必须与 ``peak`` / ``round_max_active_workers``
|
|
190
|
+
# 同口径(只统计当前轮)。历史实现跨轮统计,导致上一轮遗留的 running claim
|
|
191
|
+
# 就能把本轮 ``round_parallel_active_since`` 置位,误报「本轮并发达标」。
|
|
192
|
+
state.round_parallel_active_since = now if current_running >= 2 else None
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _record_adaptive_outcome(state: RunState, outcome: str) -> None:
|
|
196
|
+
try:
|
|
197
|
+
from . import task_scheduler
|
|
198
|
+
task_scheduler.AdaptiveConcurrencyController(
|
|
199
|
+
min_concurrency=state.budget.min_concurrency,
|
|
200
|
+
max_concurrency=state.budget.max_concurrency_ceiling,
|
|
201
|
+
).record_outcome(state, outcome)
|
|
202
|
+
except Exception:
|
|
203
|
+
# Scheduling feedback is advisory; never hide the lease/claim state.
|
|
204
|
+
pass
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def _renew_expired_live_claim(
|
|
208
|
+
state: RunState, claim: WorkerClaim, now: float, mono_now: float,
|
|
209
|
+
) -> bool:
|
|
210
|
+
"""到期时保留仍有进展证据的 Worker,并延长原租约时长。
|
|
211
|
+
|
|
212
|
+
A7/B1:活性与上限判定只读单调时钟;``renewal_count`` 不再参与终止判定,
|
|
213
|
+
单 claim 寿命只由 ``total_lease_deadline`` 决定。
|
|
214
|
+
"""
|
|
215
|
+
if claim.execution_state != "running" or claim.last_heartbeat_mono is None:
|
|
216
|
+
return False
|
|
217
|
+
if mono_now - claim.last_heartbeat_mono > ROUND_HEARTBEAT_TIMEOUT_SECONDS:
|
|
218
|
+
return False
|
|
219
|
+
# 只保留总租约截止期这一个寿命上限,杜绝假活无限空转续期
|
|
220
|
+
deadline_mono = claim.total_lease_deadline_mono
|
|
221
|
+
if deadline_mono is not None and mono_now >= deadline_mono:
|
|
222
|
+
claim.preempted_reason = "total_lease_deadline_exceeded"
|
|
223
|
+
return False
|
|
224
|
+
|
|
225
|
+
if claim.process_pid is not None:
|
|
226
|
+
try:
|
|
227
|
+
from . import task_scheduler
|
|
228
|
+
if not task_scheduler.ZombieDetector.is_pid_alive(claim.process_pid):
|
|
229
|
+
return False
|
|
230
|
+
except Exception:
|
|
231
|
+
return False
|
|
232
|
+
previous_expires_at = claim.lease_expires_at
|
|
233
|
+
renewal_seconds = max(1.0, claim.lease_seconds)
|
|
234
|
+
next_expires_at = now + renewal_seconds
|
|
235
|
+
next_expires_mono = mono_now + renewal_seconds
|
|
236
|
+
if claim.total_lease_deadline is not None:
|
|
237
|
+
next_expires_at = min(next_expires_at, claim.total_lease_deadline)
|
|
238
|
+
if deadline_mono is not None:
|
|
239
|
+
next_expires_mono = min(next_expires_mono, deadline_mono)
|
|
240
|
+
if next_expires_mono <= mono_now:
|
|
241
|
+
claim.preempted_reason = "total_lease_deadline_exceeded"
|
|
242
|
+
return False
|
|
243
|
+
claim.lease_expires_at = max(claim.lease_expires_at, next_expires_at)
|
|
244
|
+
claim.lease_expires_mono = max(
|
|
245
|
+
claim.lease_expires_mono or 0.0, next_expires_mono,
|
|
246
|
+
)
|
|
247
|
+
claim.renewal_count += 1
|
|
248
|
+
claim.preempted_reason = None
|
|
249
|
+
append_event(
|
|
250
|
+
state,
|
|
251
|
+
event_type="worker_lease_renewed_after_timeout",
|
|
252
|
+
now=now,
|
|
253
|
+
worker_id=claim.worker_id,
|
|
254
|
+
lease_id=claim.lease_id,
|
|
255
|
+
execution_id=claim.execution_id,
|
|
256
|
+
previous_lease_expires_at=previous_expires_at,
|
|
257
|
+
lease_expires_at=claim.lease_expires_at,
|
|
258
|
+
reason=f"fresh_heartbeat_renewal_{claim.renewal_count}",
|
|
259
|
+
)
|
|
260
|
+
return True
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def _serial_budget_is_legal(state: RunState) -> bool:
|
|
264
|
+
"""Recognize the bounded serial budget used by a single-task host."""
|
|
265
|
+
budget = getattr(state, "budget", None)
|
|
266
|
+
reason = getattr(budget, "serial_reason", None)
|
|
267
|
+
return (
|
|
268
|
+
getattr(budget, "require_parallel", True) is False
|
|
269
|
+
and isinstance(reason, str)
|
|
270
|
+
and bool(reason.strip())
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
_UNIT_PREFIX_RE = re.compile(r"^(?:内部|业务):\d+:")
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
#: 租约自适应下限:与 ``ZombieDetector`` 的心跳断流窗口(450s)对齐。
|
|
278
|
+
#: 低于它没有意义——回收判定本来就以该窗口为最快触发点。
|
|
279
|
+
ADAPTIVE_LEASE_FLOOR_SECONDS = 450.0
|
|
280
|
+
#: 无历史观测时的默认租约(保持历史行为,避免首轮突变)。
|
|
281
|
+
DEFAULT_LEASE_SECONDS = 1800.0
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def adaptive_lease_seconds(state: RunState) -> float:
|
|
285
|
+
"""按**观测到的执行耗时**推导租约长度,替代写死的 1800s。
|
|
286
|
+
|
|
287
|
+
观测源:``SchedulingMetrics``(``total_execution_seconds`` / ``max_execution_seconds``,
|
|
288
|
+
由 checkpoint 侧持续记账)。规则:``3 × max(平均耗时, 最长耗时)``,再夹到
|
|
289
|
+
``[ADAPTIVE_LEASE_FLOOR_SECONDS, MAX_LEASE_SECONDS]``。
|
|
290
|
+
|
|
291
|
+
为什么是「3×」与「下界 450」:租约是 worker 对自身执行时长的申报;不超过 3 倍
|
|
292
|
+
实测峰值就没有容错余量,而低于心跳断流窗口会让「正在干活但没打心跳」的 worker
|
|
293
|
+
被误杀(实测宿主的 Task 子代理常规就不打心跳)。
|
|
294
|
+
|
|
295
|
+
观测不足(已完成 < 2)时返回默认值——自适应只在有事实时生效,不猜。
|
|
296
|
+
"""
|
|
297
|
+
|
|
298
|
+
if not state or state.scheduling_metrics is None:
|
|
299
|
+
return DEFAULT_LEASE_SECONDS
|
|
300
|
+
metrics = state.scheduling_metrics
|
|
301
|
+
completed = int(getattr(metrics, "total_completed", 0) or 0)
|
|
302
|
+
executed = float(getattr(metrics, "total_execution_seconds", 0.0) or 0.0)
|
|
303
|
+
if completed < 2 or executed <= 0:
|
|
304
|
+
return DEFAULT_LEASE_SECONDS
|
|
305
|
+
average = executed / completed
|
|
306
|
+
peak = max(average, float(getattr(metrics, "max_execution_seconds", 0.0) or 0.0))
|
|
307
|
+
return max(ADAPTIVE_LEASE_FLOOR_SECONDS, min(MAX_LEASE_SECONDS, 3.0 * peak))
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def _resource_domains(state: RunState) -> int:
|
|
311
|
+
"""可领取单元能形成的**并发资源域**数量(同文件单元共享一个域)。
|
|
312
|
+
|
|
313
|
+
claim 层给每个单元派生 ``file:<path>`` 互斥键,同一源文件的两个单元因此
|
|
314
|
+
无法同时激活。若全部待领取单元都落在同一个文件里,并发在物理上不可行,
|
|
315
|
+
「要求 peak>=2」就成了不可满足的门禁——实测 2 个 symbol 单元同属
|
|
316
|
+
``probe/app.py`` 时,parallel_gate 必然残留 ``parallel_peak_below_two``,
|
|
317
|
+
整轮被判 FAILED(正确行为应是按串行完成)。
|
|
318
|
+
"""
|
|
319
|
+
|
|
320
|
+
domains: set[str] = set()
|
|
321
|
+
for unit in sorted(eligible_units(state)):
|
|
322
|
+
status = (state.coverage or {}).get(unit)
|
|
323
|
+
if status in TERMINAL_COVERED:
|
|
324
|
+
continue
|
|
325
|
+
# 单元 ID 形如 ``内部:1:probe/app.py::read_app``:先剥掉 ``阶段:N:`` 前缀,
|
|
326
|
+
# 再去 ``::symbol``,剩下的才是 claim 层派生 ``file:`` 互斥键的那个文件路径。
|
|
327
|
+
scope = _UNIT_PREFIX_RE.sub("", unit)
|
|
328
|
+
derived = scope.split("::", 1)[0] if "::" in scope else scope
|
|
329
|
+
domains.add(derived)
|
|
330
|
+
return len(domains)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def parallel_required(state: RunState) -> bool:
|
|
334
|
+
if getattr(state, "life_kind", "mine") == "fix":
|
|
335
|
+
return False
|
|
336
|
+
if _serial_budget_is_legal(state):
|
|
337
|
+
return False
|
|
338
|
+
if _resource_domains(state) < 2:
|
|
339
|
+
# 并发在物理上不可行(单元共享同一资源域):不把 peak>=2 当门禁。
|
|
340
|
+
return False
|
|
341
|
+
return (
|
|
342
|
+
state.budget.require_parallel
|
|
343
|
+
and len(eligible_units(state)) >= 2
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
# ---------------------------------------------------------------------------
|
|
348
|
+
# 恢复会话结算语义(2026-11-17 用户裁决,三维度;语义总纲见模块 docstring)。
|
|
349
|
+
#
|
|
350
|
+
# 门禁侧只做两件事:维度 1 把「单元已 100% 沿链继承覆盖」的 expired 重试债
|
|
351
|
+
# 标记 superseded_by_inheritance 并移出 expired 集合(不重派);维度 2 在
|
|
352
|
+
# 三条件全真时豁免 require_parallel 的并发证明债并落
|
|
353
|
+
# ``parallel_gate_inherited_closeout`` 留痕。fail-closed 红线:
|
|
354
|
+
# * 豁免三条件缺一即拒绝;
|
|
355
|
+
# * 伪造继承覆盖(清单行无 inherited_from 备注 / 沿链溯源失败)不得触发豁免;
|
|
356
|
+
# * 探针/清单/证据任何基础设施故障 → 一律维持原门禁(legacy 行为),
|
|
357
|
+
# 只在快照里留诊断字段,绝不借故障放宽。
|
|
358
|
+
#
|
|
359
|
+
# 定位注记:``parallel_gate_result`` 是无 root 的纯函数,而 manifest/证据文件
|
|
360
|
+
# 与 supervisor.json 同目录(life state 目录)。Supervisor 每次查询/变更都会
|
|
361
|
+
# 先经 :func:`refresh`(携带 workspace_root),这里用**有界**的 run_id→root
|
|
362
|
+
# 提示表把 root 带给门禁(进程内、键为 run_id、容量 32 FIFO 覆盖)。定位
|
|
363
|
+
# 失败/布局不符 → 返回 None → 门禁维持 legacy 行为,绝不猜测路径。
|
|
364
|
+
# ---------------------------------------------------------------------------
|
|
365
|
+
_GATE_WORKSPACE_ROOT_HINTS: dict[str, str] = {}
|
|
366
|
+
_GATE_WORKSPACE_ROOT_HINTS_MAX = 32
|
|
367
|
+
|
|
368
|
+
#: 项目布局 run_id 形态(``lifecycle-<polling_id>-<lifecycle_id>``)。
|
|
369
|
+
_LIFECYCLE_RUN_ID_RE = re.compile(r"^lifecycle-(polling-\d+)-(lifecycle-\d+)$")
|
|
370
|
+
|
|
371
|
+
#: 维度 2 豁免只针对 require_parallel 的并发证明债;串行合法性、active
|
|
372
|
+
#: worker、expired 重试债(维度 1 管辖)不在豁免范围。
|
|
373
|
+
_RECOVERY_PARALLEL_PROOF_REASONS = frozenset({
|
|
374
|
+
"parallel_peak_below_two",
|
|
375
|
+
"parallel_overlap_missing",
|
|
376
|
+
"parallel_workers_missing_checkpoint",
|
|
377
|
+
"bookkeeping_only_no_real_parallel",
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
_EXPIRE_SUPERSEDE_EVENT = "expired_claim_superseded_by_inheritance"
|
|
381
|
+
_CLOSEOUT_EXEMPT_EVENT = "parallel_gate_inherited_closeout"
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
def _remember_gate_workspace_root(run_id: str, workspace_root: object) -> None:
|
|
385
|
+
"""记录 run_id → workspace_root 提示(有界 FIFO;仅供门禁定位 life 目录)。"""
|
|
386
|
+
if not run_id or workspace_root is None:
|
|
387
|
+
return
|
|
388
|
+
try:
|
|
389
|
+
resolved = str(Path(workspace_root).resolve())
|
|
390
|
+
except (OSError, ValueError, RuntimeError):
|
|
391
|
+
return
|
|
392
|
+
_GATE_WORKSPACE_ROOT_HINTS.pop(str(run_id), None)
|
|
393
|
+
_GATE_WORKSPACE_ROOT_HINTS[str(run_id)] = resolved
|
|
394
|
+
while len(_GATE_WORKSPACE_ROOT_HINTS) > _GATE_WORKSPACE_ROOT_HINTS_MAX:
|
|
395
|
+
oldest = next(iter(_GATE_WORKSPACE_ROOT_HINTS))
|
|
396
|
+
_GATE_WORKSPACE_ROOT_HINTS.pop(oldest, None)
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
def _recovery_closeout_probe(state: RunState) -> dict[str, str] | None:
|
|
400
|
+
"""从 run_id + workspace_root 提示定位 life state 目录;失败返回 None。
|
|
401
|
+
|
|
402
|
+
只做路径解析与存在性检查(廉价 stat),不做任何清单解析——解析由
|
|
403
|
+
coverage_discovery 的只读 helper 在确有 expired 债/并行要求时才执行。
|
|
404
|
+
"""
|
|
405
|
+
run_id = str(getattr(state, "run_id", "") or "")
|
|
406
|
+
match = _LIFECYCLE_RUN_ID_RE.match(run_id)
|
|
407
|
+
if match is None:
|
|
408
|
+
return None
|
|
409
|
+
root = _GATE_WORKSPACE_ROOT_HINTS.get(run_id)
|
|
410
|
+
if not root:
|
|
411
|
+
return None
|
|
412
|
+
try:
|
|
413
|
+
import core.bugx_paths as bugx_paths
|
|
414
|
+
|
|
415
|
+
state_dir = (
|
|
416
|
+
bugx_paths.bugx_root(Path(root)) / "pollings"
|
|
417
|
+
/ match.group(1) / "lifecycles" / match.group(2) / "state"
|
|
418
|
+
)
|
|
419
|
+
except Exception: # noqa: BLE001 - 定位失败一律维持 legacy 门禁行为
|
|
420
|
+
return None
|
|
421
|
+
if not state_dir.is_dir():
|
|
422
|
+
return None
|
|
423
|
+
return {
|
|
424
|
+
"project_root": root,
|
|
425
|
+
"polling_id": match.group(1),
|
|
426
|
+
"lifecycle_id": match.group(2),
|
|
427
|
+
"manifest_path": str(state_dir / "module-coverage.md"),
|
|
428
|
+
"evidence_path": str(state_dir / "coverage-evidence.json"),
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
def _owner_cancelled_chain_proof(state: RunState) -> tuple[bool, dict[str, object]]:
|
|
433
|
+
"""条件①:Supervisor 权威链在场 owner_cancelled 死亡证明(post 同口径)。
|
|
434
|
+
|
|
435
|
+
与 ``post_phase._supervisor_owner_cancelled_proof`` 第 3 步同源:
|
|
436
|
+
``operation=lifecycle`` / ``gate=owner_cancelled`` 的 lifecycle_blocked
|
|
437
|
+
事件。链身份绑定(lifecycle/run/session 代际)由 post 的接手门独立
|
|
438
|
+
fail-closed 把关,这里只认本 run 自己链上的死亡证明。
|
|
439
|
+
"""
|
|
440
|
+
last: dict[str, object] | None = None
|
|
441
|
+
for event in getattr(state, "history", []) or []:
|
|
442
|
+
if not isinstance(event, Mapping):
|
|
443
|
+
continue
|
|
444
|
+
if (
|
|
445
|
+
event.get("type") in {"lifecycle_blocked", "lifecycle_blocked_throttled"}
|
|
446
|
+
and event.get("operation") == "lifecycle"
|
|
447
|
+
and event.get("gate") == "owner_cancelled"
|
|
448
|
+
):
|
|
449
|
+
seq = event.get("seq")
|
|
450
|
+
order = seq if isinstance(seq, int) and not isinstance(seq, bool) else 0
|
|
451
|
+
last_seq = (
|
|
452
|
+
last.get("seq") if isinstance(last, dict) else None
|
|
453
|
+
)
|
|
454
|
+
last_order = (
|
|
455
|
+
last_seq if isinstance(last_seq, int) and not isinstance(last_seq, bool) else -1
|
|
456
|
+
)
|
|
457
|
+
if order >= last_order:
|
|
458
|
+
last = event
|
|
459
|
+
if last is None:
|
|
460
|
+
return False, {
|
|
461
|
+
"present": False,
|
|
462
|
+
"reason": "no owner_cancelled death proof in supervisor chain",
|
|
463
|
+
}
|
|
464
|
+
return True, {
|
|
465
|
+
"present": True,
|
|
466
|
+
"last_seq": last.get("seq"),
|
|
467
|
+
"last_at": last.get("at"),
|
|
468
|
+
"event_type": last.get("type"),
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
def _findings_increment_since(
|
|
473
|
+
state: RunState, anchor_at: float | None,
|
|
474
|
+
) -> tuple[bool, dict[str, object]]:
|
|
475
|
+
"""条件③:owner 死亡锚点之后无新增 findings(found_total 增量为 0)。
|
|
476
|
+
|
|
477
|
+
会话归属口径:owner_cancelled 证明事件之后落账的 finding 只能来自
|
|
478
|
+
接手会话的新增挖掘(死亡进程不可能再产 finding),因此以「最后一条
|
|
479
|
+
owner_cancelled 的 at」为会话分界锚点。fail-closed:finding 无
|
|
480
|
+
``origin_receipt.sealed_at``(无法证明早于死亡)视为不可归属,同样
|
|
481
|
+
使条件③不成立——豁免宁可不做,不放行任何可能的新增挖掘。
|
|
482
|
+
"""
|
|
483
|
+
findings = getattr(state, "findings", []) or []
|
|
484
|
+
new_since_anchor = 0
|
|
485
|
+
unattributable = 0
|
|
486
|
+
new_worker_ids: set[str] = set()
|
|
487
|
+
if anchor_at is None:
|
|
488
|
+
return False, {
|
|
489
|
+
"anchor_at": None,
|
|
490
|
+
"total_findings": len(findings),
|
|
491
|
+
"new_since_anchor": 0,
|
|
492
|
+
"unattributable": len(findings),
|
|
493
|
+
"new_worker_ids": [],
|
|
494
|
+
"reason": "no owner_cancelled anchor (condition 1 failed)",
|
|
495
|
+
}
|
|
496
|
+
for item in findings:
|
|
497
|
+
receipt = item.get("origin_receipt") if isinstance(item, Mapping) else None
|
|
498
|
+
sealed_at = (
|
|
499
|
+
receipt.get("sealed_at") if isinstance(receipt, Mapping) else None
|
|
500
|
+
)
|
|
501
|
+
if isinstance(sealed_at, bool) or not isinstance(sealed_at, (int, float)):
|
|
502
|
+
unattributable += 1
|
|
503
|
+
continue
|
|
504
|
+
if float(sealed_at) > float(anchor_at):
|
|
505
|
+
new_since_anchor += 1
|
|
506
|
+
worker_id = receipt.get("worker_id") if isinstance(receipt, Mapping) else None
|
|
507
|
+
if worker_id:
|
|
508
|
+
new_worker_ids.add(str(worker_id))
|
|
509
|
+
return (
|
|
510
|
+
new_since_anchor == 0 and unattributable == 0,
|
|
511
|
+
{
|
|
512
|
+
"anchor_at": float(anchor_at),
|
|
513
|
+
"total_findings": len(findings),
|
|
514
|
+
"new_since_anchor": new_since_anchor,
|
|
515
|
+
"unattributable": unattributable,
|
|
516
|
+
"new_worker_ids": sorted(new_worker_ids),
|
|
517
|
+
},
|
|
518
|
+
)
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
def _has_gate_event(state: RunState, event_type: str, worker_id: str | None = None) -> bool:
|
|
522
|
+
"""幂等守卫:同类留痕事件在本 round 已在场则不重复落账。
|
|
523
|
+
|
|
524
|
+
history 有界裁剪可能移除旧事件,重放只产生语义相同的重复留痕,不影响
|
|
525
|
+
豁免/标记结论(结论按清单状态确定性重算,不依赖事件在场)。
|
|
526
|
+
"""
|
|
527
|
+
for event in getattr(state, "history", []) or []:
|
|
528
|
+
if not isinstance(event, Mapping) or event.get("type") != event_type:
|
|
529
|
+
continue
|
|
530
|
+
if event.get("round_no") != state.round_no:
|
|
531
|
+
continue
|
|
532
|
+
if worker_id is not None and event.get("worker_id") != worker_id:
|
|
533
|
+
continue
|
|
534
|
+
return True
|
|
535
|
+
return False
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
def _supersede_expired_claims_by_inheritance(
|
|
539
|
+
state: RunState,
|
|
540
|
+
expired_claims: list[WorkerClaim],
|
|
541
|
+
probe: dict[str, str],
|
|
542
|
+
now: float,
|
|
543
|
+
) -> tuple[list[WorkerClaim], dict[str, object]]:
|
|
544
|
+
"""维度 1:单元已 100% 沿链继承覆盖的 expired claim 移出重试债。
|
|
545
|
+
|
|
546
|
+
判定粒度是 claim(重派以 claim 任务包为单位):claim 的**全部**单元都
|
|
547
|
+
沿链继承覆盖才标记 superseded_by_inheritance;任一单元未覆盖/伪造/
|
|
548
|
+
溯源失败 → 整包保留在 expired 集合(进入重派路径)。标记 = hash-chain
|
|
549
|
+
事件(幂等守卫:同 round 同 worker 不重复落账)。
|
|
550
|
+
|
|
551
|
+
合账语义(R-1/R-6):verdict 由 coverage_discovery 按「本地最新记录 >
|
|
552
|
+
沿链继承」优先级解析并携带 ``backing`` 归属(local_round/local_historical/
|
|
553
|
+
local_overturns/inherited/unbacked);本函数决策逻辑不变——只有
|
|
554
|
+
``backing == "inherited"``(沿链继承)触发豁免,本地证据覆盖不触发
|
|
555
|
+
(OQ-1 字面 fail-closed);``backing``/``local_record`` 随 verdict 自然
|
|
556
|
+
进入 supersede 事件快照(F-4:快照更富,schema 不变)。
|
|
557
|
+
"""
|
|
558
|
+
scopes: list[str] = []
|
|
559
|
+
for claim in expired_claims:
|
|
560
|
+
for unit in claim.unit_ids:
|
|
561
|
+
scope = _UNIT_PREFIX_RE.sub("", str(unit)).strip()
|
|
562
|
+
if scope:
|
|
563
|
+
scopes.append(scope)
|
|
564
|
+
try:
|
|
565
|
+
from core.coverage.coverage_discovery import inherited_unit_coverage_verdicts
|
|
566
|
+
|
|
567
|
+
verdicts = inherited_unit_coverage_verdicts(
|
|
568
|
+
Path(probe["project_root"]), Path(probe["manifest_path"]), scopes,
|
|
569
|
+
evidence_path=Path(probe["evidence_path"]),
|
|
570
|
+
round_started_epoch=float(
|
|
571
|
+
getattr(state, "round_started_at", 0.0) or 0.0
|
|
572
|
+
),
|
|
573
|
+
)
|
|
574
|
+
except Exception as exc: # noqa: BLE001 - 探针故障 fail-closed:维持原债
|
|
575
|
+
return expired_claims, {
|
|
576
|
+
"available": False,
|
|
577
|
+
"reason": f"inheritance verdict unavailable: {type(exc).__name__}: {exc}"[:200],
|
|
578
|
+
}
|
|
579
|
+
kept: list[WorkerClaim] = []
|
|
580
|
+
superseded: dict[str, dict[str, object]] = {}
|
|
581
|
+
for claim in expired_claims:
|
|
582
|
+
unit_verdicts: list[dict[str, object]] = []
|
|
583
|
+
fully_inherited = bool(claim.unit_ids)
|
|
584
|
+
for unit in claim.unit_ids:
|
|
585
|
+
scope = _UNIT_PREFIX_RE.sub("", str(unit)).strip()
|
|
586
|
+
verdict = verdicts.get(scope) if scope else None
|
|
587
|
+
if verdict is None:
|
|
588
|
+
verdict = {
|
|
589
|
+
"inherited": False, "covered": False, "backing": "unbacked",
|
|
590
|
+
"reference": None, "chain": "",
|
|
591
|
+
"reason": f"unit scope 不可解析或不在请求集: {scope or unit}",
|
|
592
|
+
}
|
|
593
|
+
unit_verdicts.append({"unit": str(unit), **verdict})
|
|
594
|
+
if not verdict.get("inherited"):
|
|
595
|
+
fully_inherited = False
|
|
596
|
+
if fully_inherited:
|
|
597
|
+
superseded[claim.worker_id] = {
|
|
598
|
+
"worker_id": claim.worker_id,
|
|
599
|
+
"unit_ids": list(claim.unit_ids),
|
|
600
|
+
"attempt": claim.attempt,
|
|
601
|
+
"lease_id": claim.lease_id,
|
|
602
|
+
"verdicts": unit_verdicts,
|
|
603
|
+
}
|
|
604
|
+
else:
|
|
605
|
+
kept.append(claim)
|
|
606
|
+
for worker_id, snapshot in superseded.items():
|
|
607
|
+
if not _has_gate_event(state, _EXPIRE_SUPERSEDE_EVENT, worker_id):
|
|
608
|
+
append_event(
|
|
609
|
+
state, _EXPIRE_SUPERSEDE_EVENT, now,
|
|
610
|
+
round_no=state.round_no,
|
|
611
|
+
**snapshot,
|
|
612
|
+
)
|
|
613
|
+
return kept, {"available": True, "claims": superseded}
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
def _recovery_closeout_exemption(
|
|
617
|
+
state: RunState, now: float, probe: dict[str, str],
|
|
618
|
+
) -> dict[str, object]:
|
|
619
|
+
"""维度 2 三条件判定(fail-closed,逐条件快照供留痕事件与门禁快照)。"""
|
|
620
|
+
cancelled, cancelled_snapshot = _owner_cancelled_chain_proof(state)
|
|
621
|
+
anchor = (
|
|
622
|
+
cancelled_snapshot.get("last_at") if cancelled else None
|
|
623
|
+
)
|
|
624
|
+
anchor_at = anchor if isinstance(anchor, (int, float)) and not isinstance(anchor, bool) else None
|
|
625
|
+
findings_ok, findings_snapshot = _findings_increment_since(state, anchor_at)
|
|
626
|
+
try:
|
|
627
|
+
from core.coverage.coverage_discovery import recovery_closeout_coverage_census
|
|
628
|
+
|
|
629
|
+
census = recovery_closeout_coverage_census(
|
|
630
|
+
Path(probe["project_root"]),
|
|
631
|
+
Path(probe["manifest_path"]),
|
|
632
|
+
Path(probe["evidence_path"]),
|
|
633
|
+
float(getattr(state, "round_started_at", 0.0) or 0.0),
|
|
634
|
+
)
|
|
635
|
+
except Exception as exc: # noqa: BLE001 - 基础设施故障 fail-closed
|
|
636
|
+
census = {
|
|
637
|
+
"available": False,
|
|
638
|
+
"covered_all_inherited_or_historical": False,
|
|
639
|
+
"no_new_evidence_records_this_round": False,
|
|
640
|
+
"reason": f"{type(exc).__name__}: {exc}"[:200],
|
|
641
|
+
}
|
|
642
|
+
# 条件②为 OQ-2 加强口径:本轮零新增证据记录(含 failed/error)。
|
|
643
|
+
# 纯 failed 的重派轮不再误获豁免——任何新证据都证明存在真实挖掘/重派。
|
|
644
|
+
census_ok = bool(
|
|
645
|
+
census.get("covered_all_inherited_or_historical")
|
|
646
|
+
and census.get("no_new_evidence_records_this_round")
|
|
647
|
+
)
|
|
648
|
+
eligible = bool(cancelled and census_ok and findings_ok)
|
|
649
|
+
return {
|
|
650
|
+
"eligible": eligible,
|
|
651
|
+
"checked_at": now,
|
|
652
|
+
"conditions": {
|
|
653
|
+
"owner_cancelled_proof": cancelled_snapshot,
|
|
654
|
+
"coverage_census": census,
|
|
655
|
+
"findings_increment": findings_snapshot,
|
|
656
|
+
},
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
def parallel_gate_result(
|
|
661
|
+
state: RunState,
|
|
662
|
+
*,
|
|
663
|
+
now: float | None = None,
|
|
664
|
+
) -> dict[str, object]:
|
|
665
|
+
# An expired claim is a retry debt, not a permanent round failure.
|
|
666
|
+
# Once a later attempt for the same unit is active or submitted, the
|
|
667
|
+
# old expired claim remains in history but must no longer block the
|
|
668
|
+
# round forever. Looking at the latest attempt per unit also handles
|
|
669
|
+
# a second expiry correctly: only that newest expiry remains a gate.
|
|
670
|
+
# DOC-231 A2/D04: 先隔离代际,再在当前代内选最新 attempt,防止旧代的高 attempt 遮蔽当前代的过期债务。
|
|
671
|
+
# 跨代 expired claim 已无法被接手,语义裁定:scheduler_epoch 是调度代际,上一代的过期债由新一代重新派发,
|
|
672
|
+
# 不再作为本代的门禁理由。
|
|
673
|
+
state_epoch = getattr(state, "scheduler_epoch", None)
|
|
674
|
+
latest_by_unit: dict[str, WorkerClaim] = {}
|
|
675
|
+
for claim in state.claims.values():
|
|
676
|
+
if claim.round_no != state.round_no:
|
|
677
|
+
continue
|
|
678
|
+
claim_epoch = getattr(claim, "scheduler_epoch", None)
|
|
679
|
+
if state_epoch is not None and claim_epoch not in (None, state_epoch):
|
|
680
|
+
# 排除非本代的历史 claim,防止旧代的高 attempt 遮蔽当前代债务
|
|
681
|
+
continue
|
|
682
|
+
for unit_id in claim.unit_ids:
|
|
683
|
+
previous = latest_by_unit.get(unit_id)
|
|
684
|
+
if previous is None or (
|
|
685
|
+
claim.attempt, claim.claimed_at
|
|
686
|
+
) > (previous.attempt, previous.claimed_at):
|
|
687
|
+
latest_by_unit[unit_id] = claim
|
|
688
|
+
|
|
689
|
+
# 恢复结算维度 1(继承豁免):在把 expired 报成重试债之前,先检查每个
|
|
690
|
+
# expired claim 的单元是否已 100% 沿链继承覆盖(manifest 行带
|
|
691
|
+
# inherited_from 备注 + 溯源可达 passed)。全继承的 claim 标记
|
|
692
|
+
# superseded_by_inheritance(hash-chain 留痕)并移出 expired 集合,不再
|
|
693
|
+
# 重派;任一单元未覆盖/伪造/溯源失败 → 整包保留(进入重派路径)。
|
|
694
|
+
# 探针不可用(非项目布局 run_id / root 提示缺失)→ 维持 legacy 行为。
|
|
695
|
+
expired_by_worker: dict[str, WorkerClaim] = {}
|
|
696
|
+
for claim in latest_by_unit.values():
|
|
697
|
+
if claim.state == "expired":
|
|
698
|
+
expired_by_worker.setdefault(claim.worker_id, claim)
|
|
699
|
+
closeout_probe = _recovery_closeout_probe(state)
|
|
700
|
+
closeout_event_now = float(now) if now is not None else float(time.time())
|
|
701
|
+
superseded_block: dict[str, object] = {"available": False}
|
|
702
|
+
if closeout_probe is not None and expired_by_worker:
|
|
703
|
+
kept_claims, superseded_block = _supersede_expired_claims_by_inheritance(
|
|
704
|
+
state, list(expired_by_worker.values()), closeout_probe, closeout_event_now,
|
|
705
|
+
)
|
|
706
|
+
expired_by_worker = {claim.worker_id: claim for claim in kept_claims}
|
|
707
|
+
expired = sorted(expired_by_worker)
|
|
708
|
+
superseded_workers = sorted(
|
|
709
|
+
claim.get("worker_id")
|
|
710
|
+
for claim in (
|
|
711
|
+
superseded_block.get("claims", {}).values()
|
|
712
|
+
if isinstance(superseded_block.get("claims"), dict) else []
|
|
713
|
+
)
|
|
714
|
+
if isinstance(claim, Mapping) and claim.get("worker_id")
|
|
715
|
+
)
|
|
716
|
+
active = sorted(state.active_claims)
|
|
717
|
+
running = sorted(
|
|
718
|
+
claim.worker_id for claim in state.claims.values()
|
|
719
|
+
if claim.active and claim.execution_state == "running"
|
|
720
|
+
)
|
|
721
|
+
submitted = sorted(
|
|
722
|
+
claim.worker_id for claim in state.claims.values()
|
|
723
|
+
if claim.round_no == state.round_no
|
|
724
|
+
and claim.state == "submitted"
|
|
725
|
+
and claim.submitted_at is not None
|
|
726
|
+
)
|
|
727
|
+
# Do not trust the mutable summary counters alone. A real parallel proof
|
|
728
|
+
# needs two distinct workers that both completed a non-empty checkpoint,
|
|
729
|
+
# plus overlapping persisted execution windows.
|
|
730
|
+
# 第四批修复(假并发门禁):执行窗口与 checkpoint 进度只统计真实 worker
|
|
731
|
+
# (is_authentic_worker_claim 三选二)。judge 记账式 claim 的重叠窗口
|
|
732
|
+
# 单独留档——若"仅记账 claim 达标"必须如实 FAIL 并注明,绝不放行。
|
|
733
|
+
intervals: list[tuple[float, float]] = []
|
|
734
|
+
bookkeeping_intervals: list[tuple[float, float]] = []
|
|
735
|
+
bookkeeping_workers: set[str] = set()
|
|
736
|
+
observed_peak = sum(
|
|
737
|
+
1
|
|
738
|
+
for claim in state.claims.values()
|
|
739
|
+
if claim.round_no == state.round_no
|
|
740
|
+
and claim.active
|
|
741
|
+
and claim.execution_state == "running"
|
|
742
|
+
and is_authentic_worker_claim(claim)
|
|
743
|
+
)
|
|
744
|
+
progress_workers: list[str] = []
|
|
745
|
+
for claim in state.claims.values():
|
|
746
|
+
if claim.round_no != state.round_no or claim.execution_started_at is None:
|
|
747
|
+
continue
|
|
748
|
+
authentic = is_authentic_worker_claim(claim)
|
|
749
|
+
if claim.state == "submitted" and claim.submitted_at is not None:
|
|
750
|
+
end = claim.execution_finished_at or claim.submitted_at
|
|
751
|
+
if end > claim.execution_started_at:
|
|
752
|
+
(intervals if authentic else bookkeeping_intervals).append(
|
|
753
|
+
(claim.execution_started_at, end)
|
|
754
|
+
)
|
|
755
|
+
if not authentic:
|
|
756
|
+
bookkeeping_workers.add(claim.worker_id)
|
|
757
|
+
if claim.last_checkpoint_digest and authentic:
|
|
758
|
+
progress_workers.append(claim.worker_id)
|
|
759
|
+
elif claim.active and claim.execution_state == "running":
|
|
760
|
+
# A lease expiry is a promise about the future, not evidence that
|
|
761
|
+
# the worker actually ran until that point. Use the observation
|
|
762
|
+
# boundary after refresh when available; direct callers without a
|
|
763
|
+
# clock only get the last persisted heartbeat boundary.
|
|
764
|
+
end = (
|
|
765
|
+
min(now, claim.lease_expires_at)
|
|
766
|
+
if now is not None
|
|
767
|
+
else (claim.last_heartbeat_at or claim.execution_started_at)
|
|
768
|
+
)
|
|
769
|
+
if end > claim.execution_started_at:
|
|
770
|
+
(intervals if authentic else bookkeeping_intervals).append(
|
|
771
|
+
(claim.execution_started_at, end)
|
|
772
|
+
)
|
|
773
|
+
if not authentic:
|
|
774
|
+
bookkeeping_workers.add(claim.worker_id)
|
|
775
|
+
elif claim.execution_finished_at is not None:
|
|
776
|
+
(intervals if authentic else bookkeeping_intervals).append(
|
|
777
|
+
(claim.execution_started_at, claim.execution_finished_at)
|
|
778
|
+
)
|
|
779
|
+
if not authentic:
|
|
780
|
+
bookkeeping_workers.add(claim.worker_id)
|
|
781
|
+
observed_overlap = 0.0
|
|
782
|
+
points: dict[float, int] = {}
|
|
783
|
+
for start, end in intervals:
|
|
784
|
+
if end <= start:
|
|
785
|
+
continue
|
|
786
|
+
points[start] = points.get(start, 0) + 1
|
|
787
|
+
points[end] = points.get(end, 0) - 1
|
|
788
|
+
current = 0
|
|
789
|
+
ordered_points = sorted(points)
|
|
790
|
+
for index, point in enumerate(ordered_points):
|
|
791
|
+
current += points[point]
|
|
792
|
+
observed_peak = max(observed_peak, current)
|
|
793
|
+
if index + 1 < len(ordered_points) and current >= 2:
|
|
794
|
+
observed_overlap += ordered_points[index + 1] - point
|
|
795
|
+
progress_workers = sorted(set(progress_workers))
|
|
796
|
+
# 记账式 claim 的假并发峰值(仅用于如实标注 FAIL,不构成证据)。
|
|
797
|
+
bookkeeping_peak = 0
|
|
798
|
+
bk_points: dict[float, int] = {}
|
|
799
|
+
for start, end in bookkeeping_intervals:
|
|
800
|
+
if end <= start:
|
|
801
|
+
continue
|
|
802
|
+
bk_points[start] = bk_points.get(start, 0) + 1
|
|
803
|
+
bk_points[end] = bk_points.get(end, 0) - 1
|
|
804
|
+
bk_current = 0
|
|
805
|
+
for point in sorted(bk_points):
|
|
806
|
+
bk_current += bk_points[point]
|
|
807
|
+
bookkeeping_peak = max(bookkeeping_peak, bk_current)
|
|
808
|
+
required = parallel_required(state)
|
|
809
|
+
reasons: list[str] = []
|
|
810
|
+
if (
|
|
811
|
+
getattr(state.budget, "require_parallel", True) is False
|
|
812
|
+
and not _serial_budget_is_legal(state)
|
|
813
|
+
):
|
|
814
|
+
reasons.append("serial_budget_invalid")
|
|
815
|
+
if active:
|
|
816
|
+
reasons.append("active_workers_remaining")
|
|
817
|
+
if expired:
|
|
818
|
+
reasons.append("expired_workers_require_retry")
|
|
819
|
+
if required and observed_peak < 2:
|
|
820
|
+
reasons.append("parallel_peak_below_two")
|
|
821
|
+
if required and observed_peak >= 2 and observed_overlap <= 0:
|
|
822
|
+
reasons.append("parallel_overlap_missing")
|
|
823
|
+
if required and observed_peak >= 2 and len(progress_workers) < 2:
|
|
824
|
+
reasons.append("parallel_workers_missing_checkpoint")
|
|
825
|
+
if required and observed_peak < 2 and bookkeeping_peak >= 2:
|
|
826
|
+
# 第四批修复(假并发门禁):被真实性过滤后不足阈值,但记账式 claim
|
|
827
|
+
# 的重叠窗口本可"达标"——如实 FAIL 并注明仅记账 claim、无真实并发,
|
|
828
|
+
# 禁止假并发借记账窗口通过门禁(fail-closed 诚实化)。
|
|
829
|
+
reasons.append("bookkeeping_only_no_real_parallel")
|
|
830
|
+
# 恢复结算维度 2(恢复场景豁免):三条件全真(owner_cancelled 死亡证明
|
|
831
|
+
# 在权威链 + 本 Life covered 100% 继承/历史证据且本 round 零新增证据
|
|
832
|
+
# 记录(含 failed/error,OQ-2)+ owner 死亡锚点后零新增 findings)时,
|
|
833
|
+
# 豁免 require_parallel 的
|
|
834
|
+
# 并发证明债并落 ``parallel_gate_inherited_closeout`` 留痕(含三条件
|
|
835
|
+
# 逐项快照)。fail-closed:任一条件不成立/探针不可用 → 并行证明债原样
|
|
836
|
+
# 保留。串行合法性、active worker、expired 重试债(维度 1 管辖)不在
|
|
837
|
+
# 豁免范围;非 --final 收口由 post 侧拒绝消费该豁免(D5)。
|
|
838
|
+
closeout_exemption: dict[str, object] | None = None
|
|
839
|
+
if required and closeout_probe is not None:
|
|
840
|
+
closeout_exemption = _recovery_closeout_exemption(
|
|
841
|
+
state, closeout_event_now, closeout_probe,
|
|
842
|
+
)
|
|
843
|
+
suppressed = (
|
|
844
|
+
[r for r in reasons if r in _RECOVERY_PARALLEL_PROOF_REASONS]
|
|
845
|
+
if closeout_exemption.get("eligible") else []
|
|
846
|
+
)
|
|
847
|
+
closeout_exemption["suppressed_reasons"] = suppressed
|
|
848
|
+
if suppressed:
|
|
849
|
+
reasons = [r for r in reasons if r not in _RECOVERY_PARALLEL_PROOF_REASONS]
|
|
850
|
+
if not _has_gate_event(state, _CLOSEOUT_EXEMPT_EVENT):
|
|
851
|
+
append_event(
|
|
852
|
+
state, _CLOSEOUT_EXEMPT_EVENT, closeout_event_now,
|
|
853
|
+
round_no=state.round_no,
|
|
854
|
+
conditions=closeout_exemption.get("conditions"),
|
|
855
|
+
suppressed_reasons=list(suppressed),
|
|
856
|
+
)
|
|
857
|
+
return {
|
|
858
|
+
"round": state.round_no,
|
|
859
|
+
"required": required,
|
|
860
|
+
"satisfied": not reasons,
|
|
861
|
+
"max_active_workers": observed_peak,
|
|
862
|
+
"overlap_seconds": round(observed_overlap, 3),
|
|
863
|
+
"active_workers": active,
|
|
864
|
+
"running_workers": running,
|
|
865
|
+
"submitted_workers": submitted,
|
|
866
|
+
"progress_workers": progress_workers,
|
|
867
|
+
"expired_workers": sorted(expired),
|
|
868
|
+
# 恢复结算语义:维度 1 superseded 标记与维度 2 豁免快照(消费方:
|
|
869
|
+
# post 的 D5 守卫与结算留痕;无恢复语义时恒为 []/None)。
|
|
870
|
+
"expired_workers_superseded_by_inheritance": superseded_workers,
|
|
871
|
+
"recovery_closeout_exemption": closeout_exemption,
|
|
872
|
+
"serial_reason": state.budget.serial_reason,
|
|
873
|
+
"reasons": reasons,
|
|
874
|
+
# 第四批修复:并发证据的真实性口径留档(取证与回归用)。
|
|
875
|
+
"bookkeeping_claims_filtered": len(bookkeeping_workers),
|
|
876
|
+
"bookkeeping_workers": sorted(bookkeeping_workers),
|
|
877
|
+
"bookkeeping_only_peak": bookkeeping_peak,
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
def target_gate_result(workspace_root: Path, state: RunState) -> dict[str, object]:
|
|
882
|
+
"""Return a read-only target-drift marker for status/gate consumers."""
|
|
883
|
+
expected = state.target_fingerprint
|
|
884
|
+
if not expected:
|
|
885
|
+
return {"target_drift": False}
|
|
886
|
+
actual = workspace_fingerprint(workspace_root)
|
|
887
|
+
if actual == expected:
|
|
888
|
+
return {"target_drift": False}
|
|
889
|
+
return {
|
|
890
|
+
"target_drift": True,
|
|
891
|
+
"expected_target_fingerprint": expected,
|
|
892
|
+
"actual_target_fingerprint": actual,
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
def close_parallel_round(state: RunState, now: float) -> dict[str, object]:
|
|
897
|
+
reconcile_parallel(state, now)
|
|
898
|
+
result = parallel_gate_result(state, now=now)
|
|
899
|
+
state.parallel_history = [
|
|
900
|
+
*state.parallel_history,
|
|
901
|
+
dict(result),
|
|
902
|
+
][-100:]
|
|
903
|
+
append_event(
|
|
904
|
+
state, "parallel_round_closed", now,
|
|
905
|
+
**{key: value for key, value in result.items() if key != "satisfied"},
|
|
906
|
+
satisfied=result["satisfied"],
|
|
907
|
+
)
|
|
908
|
+
return result
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
def observe_clock(state: RunState, now: float) -> float:
|
|
912
|
+
"""墙钟回拨防护:返回不早于已观测高水位的有效 now (D3)。
|
|
913
|
+
|
|
914
|
+
预算的墙钟锚(``started_at`` / ``round_started_at``)是持久化字段,
|
|
915
|
+
系统时钟回拨会让 ``now - 锚点`` 变小,等于凭空把已耗掉的墙钟预算
|
|
916
|
+
还回来。这里把有效 now 钉在「本 run 曾观测到的最晚时刻」
|
|
917
|
+
(``clock_high_water``,随快照持久化),使已计时长的记账只增不减。
|
|
918
|
+
|
|
919
|
+
下界还包含全部已持久化的墙钟锚:旧快照没有水位字段(升级首读),
|
|
920
|
+
此时至少保证 ``elapsed >= 0``,回拨不可能把计时变成负数再重新开始。
|
|
921
|
+
|
|
922
|
+
这是下界而非权威时钟:``now`` 前跳时照常推进水位(前跳导致预算
|
|
923
|
+
提前耗尽属于 fail-closed 方向,由租约的 mono 权威兜住 Worker 误杀)。
|
|
924
|
+
"""
|
|
925
|
+
effective = float(now)
|
|
926
|
+
high_water = float(getattr(state, "clock_high_water", 0.0) or 0.0)
|
|
927
|
+
for name in ("started_at", "budget_started_at", "round_started_at"):
|
|
928
|
+
anchor = float(getattr(state, name, 0.0) or 0.0)
|
|
929
|
+
if anchor > high_water:
|
|
930
|
+
high_water = anchor
|
|
931
|
+
if effective < high_water:
|
|
932
|
+
effective = high_water
|
|
933
|
+
# 水位只增不减;被锚点抬高的下界同样落盘,供跨进程复核。
|
|
934
|
+
state.clock_high_water = effective
|
|
935
|
+
return effective
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
def deadline_reasons(state: RunState, now: float) -> list[str]:
|
|
939
|
+
now = observe_clock(state, now)
|
|
940
|
+
reasons: list[str] = []
|
|
941
|
+
# max_wall_seconds is the run-wide hard cap. budget_started_at advances
|
|
942
|
+
# for each recoverable epoch, so using it here would let reset_budget
|
|
943
|
+
# restart the global wall clock.
|
|
944
|
+
if now - state.started_at >= state.budget.max_wall_seconds:
|
|
945
|
+
reasons.append("max_wall_seconds")
|
|
946
|
+
if now - state.round_started_at >= state.budget.max_round_wall_seconds:
|
|
947
|
+
# DOC-196: 在标记超时前,尝试双重进展活性续期
|
|
948
|
+
if not _renew_round_budget_if_live(state, now):
|
|
949
|
+
reasons.append("max_round_wall_seconds")
|
|
950
|
+
return reasons
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
def _round_has_live_activity(state: RunState, now: float, now_mono: float | None = None) -> bool:
|
|
954
|
+
"""Return whether the current Round has evidence it is progressing (DOC-196 / DOC-242).
|
|
955
|
+
|
|
956
|
+
A fresh running-worker heartbeat is sufficient liveness evidence. With no
|
|
957
|
+
active claims, a submitted claim means the Round is ready for the host to
|
|
958
|
+
advance, not hung. Expired/claimed-only workers and empty rounds do not
|
|
959
|
+
renew the deadline.
|
|
960
|
+
"""
|
|
961
|
+
if now_mono is None:
|
|
962
|
+
now_mono = time.monotonic()
|
|
963
|
+
active = list(state.active_claims.values())
|
|
964
|
+
if not active:
|
|
965
|
+
return any(
|
|
966
|
+
claim.round_no == state.round_no and claim.state == "submitted"
|
|
967
|
+
for claim in state.claims.values()
|
|
968
|
+
)
|
|
969
|
+
for claim in active:
|
|
970
|
+
if claim.round_no != state.round_no or claim.execution_state != "running":
|
|
971
|
+
continue
|
|
972
|
+
# DOC-203 D3 / L2-Timeout / DOC-242:
|
|
973
|
+
# 若 worker 声明了长调用且租约未到期,长调用窗口在 LONG_CALL_MAX_SILENCE_SECONDS 内视为活跃;
|
|
974
|
+
# 若静默超限,必须具有非零 CPU 活跃度,否则判定死锁不再续期。
|
|
975
|
+
in_long_call = (
|
|
976
|
+
getattr(claim, "long_call_count", 0) > 0
|
|
977
|
+
and claim.lease_expires_mono is not None
|
|
978
|
+
and now_mono < claim.lease_expires_mono
|
|
979
|
+
)
|
|
980
|
+
if in_long_call:
|
|
981
|
+
last_comm_mono = getattr(claim, "last_heartbeat_mono", None) or getattr(claim, "claimed_mono", None)
|
|
982
|
+
if last_comm_mono is not None:
|
|
983
|
+
long_silence = now_mono - last_comm_mono
|
|
984
|
+
else:
|
|
985
|
+
last_comm = claim.last_heartbeat_at or claim.claimed_at
|
|
986
|
+
long_silence = now - last_comm if last_comm else 0.0
|
|
987
|
+
if long_silence > LONG_CALL_MAX_SILENCE_SECONDS:
|
|
988
|
+
process_pid = claim.process_pid
|
|
989
|
+
if process_pid is not None:
|
|
990
|
+
try:
|
|
991
|
+
from . import task_scheduler
|
|
992
|
+
if not task_scheduler.ZombieDetector.is_pid_cpu_active(process_pid):
|
|
993
|
+
continue
|
|
994
|
+
except Exception:
|
|
995
|
+
pass
|
|
996
|
+
else:
|
|
997
|
+
# A7:心跳新鲜度同样只读单调时钟,墙钟跳变不改变活性判定。
|
|
998
|
+
last_heartbeat_mono = claim.last_heartbeat_mono
|
|
999
|
+
is_fresh_heartbeat = (
|
|
1000
|
+
last_heartbeat_mono is not None
|
|
1001
|
+
and (now_mono - last_heartbeat_mono <= ROUND_HEARTBEAT_TIMEOUT_SECONDS)
|
|
1002
|
+
)
|
|
1003
|
+
if not is_fresh_heartbeat:
|
|
1004
|
+
continue
|
|
1005
|
+
process_pid = claim.process_pid
|
|
1006
|
+
if process_pid is not None:
|
|
1007
|
+
try:
|
|
1008
|
+
from . import task_scheduler
|
|
1009
|
+
if not task_scheduler.ZombieDetector.is_pid_alive(process_pid):
|
|
1010
|
+
continue
|
|
1011
|
+
except Exception:
|
|
1012
|
+
continue
|
|
1013
|
+
# B1:只要总截止期未到即视为有效进展(续租次数不参与终止判定)。
|
|
1014
|
+
deadline_mono = claim.total_lease_deadline_mono
|
|
1015
|
+
if deadline_mono is None or now_mono < deadline_mono:
|
|
1016
|
+
return True
|
|
1017
|
+
return False
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
def _renew_round_budget_if_live(
|
|
1021
|
+
state: RunState, now: float, *, now_mono: float | None = None,
|
|
1022
|
+
) -> bool:
|
|
1023
|
+
"""Roll only the single-Round wall clock when progress is still live (DOC-196)."""
|
|
1024
|
+
now = observe_clock(state, now)
|
|
1025
|
+
if now - state.started_at >= state.budget.max_wall_seconds:
|
|
1026
|
+
return False
|
|
1027
|
+
if now - state.round_started_at < state.budget.max_round_wall_seconds:
|
|
1028
|
+
return True
|
|
1029
|
+
if not _round_has_live_activity(state, now, now_mono):
|
|
1030
|
+
return False
|
|
1031
|
+
reasons = set(state.budget_reasons)
|
|
1032
|
+
if reasons - {"max_round_wall_seconds"}:
|
|
1033
|
+
return False
|
|
1034
|
+
previous = state.round_started_at
|
|
1035
|
+
state.round_started_at = now
|
|
1036
|
+
state.budget_reasons = [
|
|
1037
|
+
reason for reason in state.budget_reasons
|
|
1038
|
+
if reason != "max_round_wall_seconds"
|
|
1039
|
+
]
|
|
1040
|
+
state.budget_exhausted = bool(state.budget_reasons)
|
|
1041
|
+
if state.status == Status.BUDGET_EXHAUSTED and not state.budget_exhausted:
|
|
1042
|
+
state.status = Status.RUNNING
|
|
1043
|
+
append_event(
|
|
1044
|
+
state, "budget_round_renewed", now,
|
|
1045
|
+
round_no=state.round_no,
|
|
1046
|
+
previous_round_started_at=previous,
|
|
1047
|
+
next_round_started_at=now,
|
|
1048
|
+
reason="live_worker_or_submitted_progress",
|
|
1049
|
+
)
|
|
1050
|
+
return True
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
def soft_limit_reasons(state: RunState) -> list[str]:
|
|
1054
|
+
reasons: list[str] = []
|
|
1055
|
+
if state.budget_tool_calls >= state.budget.max_tool_calls:
|
|
1056
|
+
reasons.append("max_tool_calls")
|
|
1057
|
+
if state.budget_cost_units >= state.budget.max_cost_units:
|
|
1058
|
+
reasons.append("max_cost_units")
|
|
1059
|
+
return reasons
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
def validate_parallel_capacity(budget: RunBudget, unit_count: int) -> None:
|
|
1063
|
+
"""Reject parallel runs that cannot schedule two eligible units."""
|
|
1064
|
+
if budget.require_parallel and unit_count >= 2 and budget.max_concurrency < 2:
|
|
1065
|
+
raise InvalidCheckpoint(
|
|
1066
|
+
"至少有两个覆盖单元时,max_concurrency 必须 >= 2;"
|
|
1067
|
+
"如确需串行,请提供 serial_reason"
|
|
1068
|
+
)
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
def refresh(
|
|
1075
|
+
state: RunState,
|
|
1076
|
+
now: float,
|
|
1077
|
+
workspace_root: Path | None = None,
|
|
1078
|
+
now_mono: float | None = None,
|
|
1079
|
+
) -> None:
|
|
1080
|
+
# 恢复结算门禁的 root 提示(有界 FIFO,见 _GATE_WORKSPACE_ROOT_HINTS):
|
|
1081
|
+
# parallel_gate_result 是无 root 纯函数,Supervisor 每次查询/变更都先经
|
|
1082
|
+
# 本函数(携带 workspace_root),在这里登记 run_id → root,门禁即可定位
|
|
1083
|
+
# life state 目录(manifest/证据文件与 supervisor.json 同目录)。
|
|
1084
|
+
_remember_gate_workspace_root(
|
|
1085
|
+
str(getattr(state, "run_id", "") or ""), workspace_root,
|
|
1086
|
+
)
|
|
1087
|
+
if now_mono is None:
|
|
1088
|
+
now_mono = time.monotonic()
|
|
1089
|
+
# D3:一次 refresh 内所有墙钟写入(事件时间戳、租约展示期、预算锚)
|
|
1090
|
+
# 都使用回拨防护后的有效 now,避免记账时间倒退。
|
|
1091
|
+
now = observe_clock(state, now)
|
|
1092
|
+
for worker_id, claim in list(state.claims.items()):
|
|
1093
|
+
if not claim.active:
|
|
1094
|
+
continue
|
|
1095
|
+
if claim.is_expired(now_mono=now_mono) and _renew_expired_live_claim(
|
|
1096
|
+
state, claim, now, now_mono,
|
|
1097
|
+
):
|
|
1098
|
+
continue
|
|
1099
|
+
# 租约是否已实际失效,必须在任何状态突变**之前**取样:僵尸分支会把 claim
|
|
1100
|
+
# 标记成 ``expired``(此后 ``claim.active`` 为假,``mark_claim_expired`` 会被
|
|
1101
|
+
# 自身守卫直接吞掉),于是 running 形态的过期记账整条丢失(缺陷 #8)。
|
|
1102
|
+
# A7:过期判定只读单调时钟(mono 是唯一权威),墙钟跳变不改变结论。
|
|
1103
|
+
lease_lapsed = claim.is_expired(now_mono=now_mono)
|
|
1104
|
+
is_zombie = False
|
|
1105
|
+
z_reason = ""
|
|
1106
|
+
try:
|
|
1107
|
+
from . import task_scheduler
|
|
1108
|
+
is_zombie, z_reason = task_scheduler.ZombieDetector.check_zombie_claim(claim, now, now_mono=now_mono)
|
|
1109
|
+
except Exception as exc:
|
|
1110
|
+
# A failed liveness probe is not evidence of health. Fail closed
|
|
1111
|
+
# and reclaim the claim so a broken probe cannot preserve capacity
|
|
1112
|
+
# forever.
|
|
1113
|
+
is_zombie = True
|
|
1114
|
+
z_reason = "zombie_probe_failed"
|
|
1115
|
+
append_event(
|
|
1116
|
+
state, "worker_zombie_probe_failed", now,
|
|
1117
|
+
worker_id=worker_id, lease_id=claim.lease_id,
|
|
1118
|
+
execution_id=claim.execution_id,
|
|
1119
|
+
error=type(exc).__name__,
|
|
1120
|
+
)
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
if is_zombie:
|
|
1124
|
+
terminated = None
|
|
1125
|
+
if z_reason == "heartbeat_timeout" and claim.process_pid is not None:
|
|
1126
|
+
refusal = ""
|
|
1127
|
+
try:
|
|
1128
|
+
from . import task_scheduler
|
|
1129
|
+
# 归属判定收敛在 terminate_claim:命令行证据 + 启动令牌双重
|
|
1130
|
+
# 校验,任一缺失/不匹配即拒绝发信号(进程组投递另有把关)。
|
|
1131
|
+
terminated, refusal = task_scheduler.ZombieDetector.terminate_claim(
|
|
1132
|
+
claim, workspace_root=workspace_root or getattr(state, "workspace_root", None),
|
|
1133
|
+
)
|
|
1134
|
+
except Exception:
|
|
1135
|
+
terminated, refusal = False, "terminate_error"
|
|
1136
|
+
z_reason = (
|
|
1137
|
+
f"{z_reason}_killed" if terminated
|
|
1138
|
+
else f"{z_reason}_kill_failed"
|
|
1139
|
+
)
|
|
1140
|
+
if not terminated:
|
|
1141
|
+
# 拒绝终止必须可观测:Worker 自报的 PID 可能指向无关进程,
|
|
1142
|
+
# 静默拒绝会掩盖「有人试图诱导宿主杀进程」这一事实。
|
|
1143
|
+
append_event(
|
|
1144
|
+
state, "worker_termination_refused", now,
|
|
1145
|
+
worker_id=worker_id, lease_id=claim.lease_id,
|
|
1146
|
+
execution_id=claim.execution_id,
|
|
1147
|
+
process_pid=claim.process_pid,
|
|
1148
|
+
reason=refusal or "unknown",
|
|
1149
|
+
)
|
|
1150
|
+
claim.state = "expired"
|
|
1151
|
+
claim.execution_state = "expired"
|
|
1152
|
+
claim.execution_finished_at = now
|
|
1153
|
+
claim.preempted_reason = z_reason
|
|
1154
|
+
state.scheduling_metrics.total_preempted += 1
|
|
1155
|
+
_record_adaptive_outcome(state, "preempted")
|
|
1156
|
+
append_event(
|
|
1157
|
+
state, "worker_preempted", now, worker_id=worker_id,
|
|
1158
|
+
lease_id=claim.lease_id,
|
|
1159
|
+
execution_id=claim.execution_id,
|
|
1160
|
+
reason=z_reason,
|
|
1161
|
+
process_pid=claim.process_pid,
|
|
1162
|
+
process_terminated=terminated,
|
|
1163
|
+
)
|
|
1164
|
+
if lease_lapsed:
|
|
1165
|
+
# 「租约失效」与「被预占」是两个独立事实,必须同时记账(缺陷 #8:
|
|
1166
|
+
# running 形态此前只记预占,``total_expired`` 系统性少计)。
|
|
1167
|
+
record_expiry_accounting(
|
|
1168
|
+
state, claim, now, include_execution_id=True,
|
|
1169
|
+
)
|
|
1170
|
+
if claim.attempt >= MAX_WORKER_ATTEMPTS:
|
|
1171
|
+
mark_worker_attempts_exhausted(
|
|
1172
|
+
state, now, claim.unit_ids,
|
|
1173
|
+
worker_id=claim.worker_id, attempt=claim.attempt,
|
|
1174
|
+
)
|
|
1175
|
+
elif claim.is_expired(now_mono=now_mono):
|
|
1176
|
+
# LOG-11:过期记账(状态/计数/事件)收敛到 lease_manager 单点。
|
|
1177
|
+
mark_claim_expired(state, claim, now, include_execution_id=True)
|
|
1178
|
+
_record_adaptive_outcome(state, "expired")
|
|
1179
|
+
reconcile_parallel(state, now)
|
|
1180
|
+
if _renew_round_budget_if_live(state, now, now_mono=now_mono):
|
|
1181
|
+
return
|
|
1182
|
+
deadline = deadline_reasons(state, now)
|
|
1183
|
+
# D2:INCOMPLETE 是 finish 已收尾终态,不得被预算刷新改写成 BUDGET_EXHAUSTED。
|
|
1184
|
+
if deadline and state.status not in {
|
|
1185
|
+
Status.COMPLETE, Status.FAILED, Status.INCOMPLETE,
|
|
1186
|
+
}:
|
|
1187
|
+
if not state.budget_exhausted:
|
|
1188
|
+
set_budget_exhausted(state, now, deadline)
|
|
1189
|
+
else:
|
|
1190
|
+
state.budget_reasons = list(dict.fromkeys(
|
|
1191
|
+
[*state.budget_reasons, *deadline]
|
|
1192
|
+
))
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
def apply_status_budget(state: RunState, now: float) -> None:
|
|
1196
|
+
"""Apply status-query budget gates after the caller refreshes leases."""
|
|
1197
|
+
now = observe_clock(state, now)
|
|
1198
|
+
if (
|
|
1199
|
+
state.status not in {
|
|
1200
|
+
Status.COMPLETE, Status.FAILED, Status.INCOMPLETE,
|
|
1201
|
+
Status.BUDGET_EXHAUSTED,
|
|
1202
|
+
}
|
|
1203
|
+
and not state.coverage_complete
|
|
1204
|
+
and (state.budget_exhausted or soft_limit_reasons(state))
|
|
1205
|
+
):
|
|
1206
|
+
set_budget_exhausted(
|
|
1207
|
+
state, now, soft_limit_reasons(state),
|
|
1208
|
+
event_type="status_budget_exhausted",
|
|
1209
|
+
)
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
def refresh_status_budget(state: RunState, now: float) -> None:
|
|
1213
|
+
"""Refresh worker leases and apply status-query budget gates once."""
|
|
1214
|
+
refresh(state, now)
|
|
1215
|
+
apply_status_budget(state, now)
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
def ensure_live_for_work(state: RunState) -> None:
|
|
1219
|
+
# D2:INCOMPLETE 与 COMPLETE/FAILED 同级冻结,claim/next_round 等一切
|
|
1220
|
+
# 工作入口必须拒绝(BUDGET_EXHAUSTED 不在内:它是可续耗尽态)。
|
|
1221
|
+
if state.status in {Status.COMPLETE, Status.FAILED, Status.INCOMPLETE}:
|
|
1222
|
+
raise InvalidTransition(f"run 已结束: {state.status.value}")
|
|
1223
|
+
if state.budget_exhausted:
|
|
1224
|
+
raise BudgetExhausted(
|
|
1225
|
+
"预算已耗尽: " + ", ".join(state.budget_reasons or ["unknown"])
|
|
1226
|
+
)
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
def recalibrate_round_budget(
|
|
1230
|
+
state: RunState,
|
|
1231
|
+
recommended_seconds: float,
|
|
1232
|
+
now: float,
|
|
1233
|
+
*,
|
|
1234
|
+
reason: str = "adaptive_round_complexity",
|
|
1235
|
+
) -> float:
|
|
1236
|
+
"""动态校准当前 Round 的单轮墙钟预算上限 (DOC-150)。
|
|
1237
|
+
|
|
1238
|
+
受全局总预算 max_wall_seconds 约束,校准后立即检查是否满足活性并记录审计事件。
|
|
1239
|
+
"""
|
|
1240
|
+
if recommended_seconds <= 0:
|
|
1241
|
+
return state.budget.max_round_wall_seconds
|
|
1242
|
+
previous = state.budget.max_round_wall_seconds
|
|
1243
|
+
bounded = min(recommended_seconds, state.budget.max_wall_seconds)
|
|
1244
|
+
state.budget = dataclasses.replace(state.budget, max_round_wall_seconds=bounded)
|
|
1245
|
+
append_event(
|
|
1246
|
+
state,
|
|
1247
|
+
"round_budget_recalibrated",
|
|
1248
|
+
now,
|
|
1249
|
+
previous_budget=previous,
|
|
1250
|
+
new_budget=bounded,
|
|
1251
|
+
reason=reason,
|
|
1252
|
+
)
|
|
1253
|
+
_renew_round_budget_if_live(state, now)
|
|
1254
|
+
return bounded
|