bugx-cli 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -186
- package/core/README.md +2 -2
- package/core/agent/README.md +2 -1
- package/core/agent/agent_artifacts.py +8 -6
- package/core/agent/agent_eval.py +136 -54
- package/core/agent/agent_execution.py +218 -52
- package/core/agent/agent_orchestrator.py +14 -8
- package/core/agent/agent_targets.py +8 -2
- package/core/agent/feature_baseline.py +150 -0
- package/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- package/core/assets/axe-core/LICENSE.txt +362 -0
- package/core/assets/axe-core/UPSTREAM.md +10 -0
- package/core/assets/axe-core/axe.min.js +12 -0
- package/core/assets/bugx-hero-en.svg +74 -0
- package/core/assets/bugx-hero-zh.svg +74 -0
- package/core/assets/codex.png +0 -0
- package/core/assets/dsh.png +0 -0
- package/core/assets/webui-chatgpt.jpg +0 -0
- package/core/assets/webui-session.jpg +0 -0
- package/core/assets/webui-skills.jpg +0 -0
- package/core/assets/webui-studio.jpg +0 -0
- package/core/assets/webui-zcode.jpg +0 -0
- package/core/assets/zcode.png +0 -0
- package/core/autonomous_cve/SPEC.md +1 -1
- package/core/autonomous_cve/attack_graph_store.py +152 -106
- package/core/autonomous_cve/behavior_graph.py +8 -2
- package/core/autonomous_cve/verifier.py +4 -1
- package/core/bugx.md +1 -1
- package/core/bugx_paths.py +43 -8
- package/core/cli-help.txt +66 -0
- package/core/cloud_sync/SPEC.md +1 -1
- package/core/cloud_sync/cloud_client.py +25 -6
- package/core/cloud_sync/cloud_onboard.py +42 -1
- package/core/cloud_sync/flywheel_client.py +16 -7
- package/core/cloud_sync/network_transport.py +24 -3
- package/core/cloud_sync/sensitive_filter.py +2 -2
- package/core/cloud_sync/sync_push.py +12 -10
- package/core/contracts/AGENT_GUIDE.md +6 -9
- package/core/contracts/README.md +2 -2
- package/core/contracts/bugx-runtime-contract.md +1 -1
- package/core/contracts/bugx-worker.md +1 -1
- package/core/contracts/engine_gap_contracts.py +86 -3
- package/core/coverage/coverage_discovery.py +599 -29
- package/core/coverage/coverage_evidence.py +47 -0
- package/core/coverage/coverage_forensics.py +9 -0
- package/core/coverage/coverage_validate.py +6 -1
- package/core/dev_harness/SPEC.md +1 -1
- package/core/engine-integrity.json +591 -419
- package/core/fuzzing/concurrency_fuzzer.py +53 -0
- package/core/fuzzing/differential_oracle.py +562 -27
- package/core/fuzzing/fuzz_input.py +109 -6
- package/core/fuzzing/stateful_fuzzer.py +72 -0
- package/core/governance/secret_redactor.py +22 -10
- package/core/host_acp/SPEC.md +1 -1
- package/core/host_acp/__init__.py +4 -4
- package/core/host_acp/claude.py +59 -1
- package/core/host_acp/cline.py +64 -1
- package/core/host_acp/codex.py +56 -1
- package/core/host_acp/dsh.py +59 -1
- package/core/host_acp/opencode.py +56 -1
- package/core/host_acp/pi.py +59 -1
- package/core/host_acp/zcode.py +59 -1
- package/core/host_runtime/SPEC.md +1 -1
- package/core/host_runtime/adapters.py +1 -1
- package/core/host_runtime/cline.py +13 -0
- package/core/host_runtime/host_evaluators.py +44 -4
- package/core/host_runtime/host_probe.py +1 -1
- package/core/host_runtime/host_provider_arbitrator.py +116 -62
- package/core/host_runtime/host_registry.py +15 -8
- package/core/host_runtime/mcp_registry_gate.py +12 -1
- package/core/host_runtime/pi.py +102 -0
- package/core/host_runtime/provider_facts.py +66 -0
- package/core/hosts/SPEC.md +1 -1
- package/core/hosts/__init__.py +6 -2
- package/core/hosts/_dsh_usage.py +1 -1
- package/core/hosts/base.py +32 -4
- package/core/hosts/claude.py +55 -0
- package/core/hosts/cline.py +6 -2
- package/core/hosts/codex.py +58 -0
- package/core/hosts/dsh.py +9 -1
- package/core/hosts/opencode.py +6 -6
- package/core/hosts/pi.py +159 -2
- package/core/infra/README.md +4 -2
- package/core/infra/__init__.py +2 -0
- package/core/infra/build_info.py +22 -3
- package/core/infra/client_metadata.py +1 -1
- package/core/infra/json_utils.py +22 -0
- package/core/launch_phases/README.md +2 -2
- package/core/launch_phases/SPEC.md +1 -1
- package/core/launch_phases/common.py +21 -2
- package/core/launch_phases/finding_confirm_phase.py +5 -1
- package/core/launch_phases/finding_settlement.py +188 -1
- package/core/launch_phases/judge_phase.py +69 -12
- package/core/launch_phases/orchestrator_controls.py +11 -7
- package/core/launch_phases/post_coverage_sync.py +9 -2
- package/core/launch_phases/post_phase.py +139 -3
- package/core/launch_phases/post_receipt.py +12 -1
- package/core/launch_phases/pre_phase.py +3 -3
- package/core/launch_phases/pre_recon_scout.py +53 -36
- package/core/launch_phases/pre_state_builder.py +23 -176
- package/core/launch_phases/round_orchestrator.py +15 -32
- package/core/launch_phases/session_runtime.py +56 -9
- package/core/launch_phases/startup_gates.py +36 -8
- package/core/launch_phases/startup_interaction.py +68 -12
- package/core/launch_phases/startup_version_gate.py +9 -3
- package/core/launch_phases/supervisor_bridge.py +46 -17
- package/core/launch_phases/supervisor_coverage.py +8 -2
- package/core/launch_phases/supervisor_degraded.py +1 -9
- package/core/launch_phases/worker_barriers.py +15 -5
- package/core/launch_phases/worker_orchestrator.py +105 -25
- package/core/ledger/README.md +1 -1
- package/core/ledger/SPEC.md +1 -1
- package/core/ledger/_facade.py +2 -1
- package/core/ledger/archive_ops.py +60 -2
- package/core/ledger/cli.py +6 -1
- package/core/ledger/export_ops.py +6 -1
- package/core/ledger/finding_confirmation.py +48 -6
- package/core/ledger/finding_lifecycle.py +428 -5
- package/core/ledger/finding_verification.py +44 -8
- package/core/ledger/incidents.py +10 -4
- package/core/ledger/patterns.py +10 -7
- package/core/ledger/receipt_contract.py +17 -1
- package/core/ledger/sync_ops.py +21 -16
- package/core/ledger/tool_experience.py +2 -1
- package/core/ledger/verify_life.py +88 -17
- package/core/locales/en-US.json +2 -2
- package/core/locales/zh-CN.json +2 -2
- package/core/mcp_handlers/SPEC.md +1 -1
- package/core/mcp_handlers/base.py +23 -3
- package/core/mcp_handlers/channel_lifecycle.py +85 -30
- package/core/mcp_handlers/retrieval_handlers.py +11 -1
- package/core/mcp_handlers/rpc_server.py +6 -1
- package/core/mcp_handlers/supervisor_handlers.py +32 -6
- package/core/mcp_handlers/tool_table.py +15 -0
- package/core/mcp_runtime_support/environment.py +0 -38
- package/core/mcp_runtime_support/verifier.py +0 -52
- package/core/metadata.txt +2 -3
- package/core/planning/README.md +1 -1
- package/core/planning/domain_router.py +4 -2
- package/core/planning/dynamic_flow_analyzer.py +219 -14
- package/core/planning/judge_pipeline.py +87 -4
- package/core/planning/prompt_harness.py +7 -5
- package/core/planning/spec_harvester.py +4 -4
- package/core/probes/INTERFACE.md +11 -1
- package/core/probes/SPEC.md +11 -1
- package/core/probes/__init__.py +46 -40
- package/core/probes/android_probe.py +177 -9
- package/core/probes/codebase_memory_probe.py +57 -0
- package/core/probes/desktop_probe.py +104 -0
- package/core/probes/differential_probe.py +99 -21
- package/core/probes/efficiency_probe.py +64 -0
- package/core/probes/ios_binary_probe.py +105 -1
- package/core/probes/memory_probe.py +66 -0
- package/core/probes/miniprogram_probe.py +75 -13
- package/core/probes/mobile_probe.py +215 -30
- package/core/probes/native_probe.py +88 -0
- package/core/probes/openwiki_probe.py +70 -0
- package/core/probes/pattern_probe.py +106 -0
- package/core/probes/platform_probe.py +81 -0
- package/core/probes/probe_registry.py +108 -7
- package/core/probes/sast_fixture_corpus.py +340 -0
- package/core/probes/sast_probe.py +553 -52
- package/core/probes/sast_rules.py +668 -28
- package/core/probes/sca_scanner.py +48 -0
- package/core/probes/ui_accessibility.py +149 -0
- package/core/probes/ui_audit.py +513 -0
- package/core/probes/ui_contract.py +273 -0
- package/core/probes/ui_evidence.py +212 -0
- package/core/probes/ui_measurements.py +314 -0
- package/core/probes/ui_repair.py +250 -0
- package/core/probes/ui_review.py +133 -0
- package/core/probes/ui_storybook.py +107 -0
- package/core/probes/ui_tokens.py +185 -0
- package/core/probes/ui_visual_diff.py +131 -0
- package/core/probes/web_probe.py +373 -18
- package/core/project_profiler/SPEC.md +1 -1
- package/core/project_profiler/arbitrator.py +6 -1
- package/core/project_profiler/detector.py +8 -1
- package/core/project_profiler/strategy.py +51 -15
- package/core/prompts/command_routing_en.md +2 -2
- package/core/prompts/command_routing_zh.md +2 -2
- package/core/prompts/stages/stage_repair.md +1 -1
- package/core/repair/README.md +1 -1
- package/core/repair/l7_repair_loop.py +1 -4
- package/core/repair/rsi_fixer.py +4 -4
- package/core/repair/rsi_loop.py +1 -3
- package/core/repair/rsi_repair.py +7 -7
- package/core/repair/rsi_scope.py +27 -8
- package/core/report_engine/SPEC.md +1 -1
- package/core/report_engine/attestation.py +8 -4
- package/core/report_engine/finding_report.py +2 -1
- package/core/report_engine/models.py +7 -9
- package/core/report_engine/sast_bridge.py +2 -2
- package/core/report_engine/server.py +18 -8
- package/core/report_engine/web-conformance.md +123 -18
- package/core/report_engine/web_conformance.py +21 -52
- package/core/retrieval/README.md +1 -1
- package/core/retrieval/SPEC.md +1 -1
- package/core/retrieval/code_analyzer.py +50 -14
- package/core/retrieval/context_assembler.py +7 -1
- package/core/retrieval/knowledge_sync.py +108 -14
- package/core/retrieval/symbol_index.py +25 -6
- package/core/retrieval/universal_code_matcher.py +234 -49
- package/core/runtime/README.md +1 -1
- package/core/runtime/bugx_logging.py +78 -7
- package/core/runtime/fixture_solidify.py +5 -10
- package/core/runtime/incident_eval.py +1 -1
- package/core/runtime/model_runner.py +4 -41
- package/core/runtime/platform_adapter.py +2 -2
- package/core/runtime/prep_validate.py +4 -2
- package/core/runtime/project_settings.py +2 -1
- package/core/runtime/scenario_eval.py +50 -8
- package/core/skills/bugx_docs_mcp_server.py +3 -1
- package/core/skills/bugx_mcp_server.py +29 -2
- package/core/skills/tools_kb.py +1 -1
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/SPEC.md +1 -1
- package/core/supervisor/budget_governor.py +503 -9
- package/core/supervisor/checkpoint_pipeline.py +248 -6
- package/core/supervisor/checkpoint_sync.py +13 -0
- package/core/supervisor/claim_events.py +1 -1
- package/core/supervisor/finding_workflow.py +22 -5
- package/core/supervisor/lease_manager.py +1 -1
- package/core/supervisor/lifecycle_blocks.py +6 -1
- package/core/supervisor/rejection_remedies.py +52 -5
- package/core/supervisor/serial_authorization.py +48 -4
- package/core/supervisor/task_scheduler.py +2 -2
- package/core/supervisor/worker_checkpoint.py +8 -1
- package/core/supervisor/worker_runtime.py +8 -2
- package/core/supervisor_types/worker_claim.py +9 -0
- package/core/webui/README.md +1 -1
- package/core/webui/SPEC.md +2 -1
- package/core/webui/adapters/claude.py +5 -1
- package/core/webui/adapters/cline.py +10 -2
- package/core/webui/adapters/codex.py +5 -1
- package/core/webui/adapters/dsh.py +5 -1
- package/core/webui/docs_session_service.py +2 -2
- package/core/webui/mcp_inspector.py +11 -7
- package/core/webui/static/00-base.css +1060 -0
- package/core/webui/static/01-monitoring.css +802 -0
- package/core/webui/static/02-header-actions.css +321 -0
- package/core/webui/static/03-trigger-popover.css +697 -0
- package/core/webui/static/04-composer.css +628 -0
- package/core/webui/static/05-skills-center.css +878 -0
- package/core/webui/static/06-mcp-center.css +623 -0
- package/core/webui/static/07-skill-detail.css +265 -0
- package/core/webui/static/08-files-management.css +167 -0
- package/core/webui/static/09-files-center.css +386 -0
- package/core/webui/static/10-icons.css +105 -0
- package/core/webui/static/11-project-options.css +185 -0
- package/core/webui/static/12-profile-tab.css +383 -0
- package/core/webui/static/design-tokens.css +113 -0
- package/core/webui/static/index.html +14 -1
- package/core/webui/workspace_service.py +1 -1
- package/docs/07_distribution/01_README_NPM.md +190 -186
- package/ecosystem/integrations/README.md +1 -1
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/ui/package.json +1 -1
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
- package/ecosystem/integrations/opencode/mcp-lock.json +14 -6
- package/ecosystem/integrations/opencode/opencode.json +23 -12
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/qoder/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +2 -2
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
- package/interfaces/bin/bugx.js +37 -0
- package/interfaces/cli/bugx_cli/__init__.py +4 -2
- package/interfaces/cli/bugx_cli/cli.py +11 -4
- package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
- package/interfaces/cli/bugx_cli/commands/agent.py +339 -73
- package/interfaces/cli/bugx_cli/commands/audit.py +2 -2
- package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +4 -3
- package/interfaces/cli/bugx_cli/commands/doctor.py +449 -204
- package/interfaces/cli/bugx_cli/commands/interaction.py +5 -1
- package/interfaces/cli/bugx_cli/commands/knowledge.py +2 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
- package/interfaces/cli/bugx_cli/commands/plugin.py +55 -20
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +7 -7
- package/interfaces/cli/bugx_cli/commands/plugin_funide.py +2 -1
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +1 -1
- package/interfaces/cli/bugx_cli/commands/report.py +2 -6
- package/interfaces/cli/bugx_cli/commands/system.py +11 -11
- package/interfaces/cli/bugx_cli/common.py +15 -7
- package/interfaces/cli/bugx_cli/host_adapters.py +29 -54
- package/interfaces/cli/bugx_cli/hosts/registry.py +8 -6
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +157 -27
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +18 -10
- package/interfaces/cli/bugx_cli/infra/host_sync.py +11 -8
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +76 -5
- package/interfaces/cli/bugx_cli/infra/security.py +13 -6
- package/package.json +2 -1
- package/pyproject.toml +20 -8
- package/scripts/ensure-python.mjs +7 -7
- package/scripts/sync-version.mjs +10 -21
- package/scripts/test-npm-wrapper.mjs +1 -1
- package/core/webui/static/project-settings.css +0 -6458
- package/docs/07_distribution/README.md +0 -16
- package/docs/README.md +0 -121
- package/interfaces/README.md +0 -143
- package/interfaces/bin/README.md +0 -35
- package/interfaces/cli/README.md +0 -90
- package/scripts/README.md +0 -118
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
usage: bugx [-h] [--version] [--log-level {DEBUG,INFO,WARNING,ERROR}]
|
|
2
|
+
[--accept-data-sharing] [--privacy {standard,strict}]
|
|
3
|
+
[--no-backup]
|
|
4
|
+
{help,completion,init,dsh,hosts,install,reset,uninstall,doctor,mcp,capability,mcp-runtime,lesson,logic-analysis,probe,knowledge,skill,self-audit,engine,cloud,auth,telemetry,config,daemon,autonomous,goal,supervisor,plugin,update,patch-forge,log,stats,project,view,test-generate,test-audit,mining-audit,test-verify,audit,interaction,advisory,report} ...
|
|
5
|
+
|
|
6
|
+
BugX 统一命令行入口(模块化调度器)。
|
|
7
|
+
|
|
8
|
+
positional arguments:
|
|
9
|
+
{help,completion,init,dsh,hosts,install,reset,uninstall,doctor,mcp,capability,mcp-runtime,lesson,logic-analysis,probe,knowledge,skill,self-audit,engine,cloud,auth,telemetry,config,daemon,autonomous,goal,supervisor,plugin,update,patch-forge,log,stats,project,view,test-generate,test-audit,mining-audit,test-verify,audit,interaction,advisory,report}
|
|
10
|
+
help 显示 BugX 或指定命令的使用说明
|
|
11
|
+
completion 输出 Bash、Zsh 或 Fish 的 Tab 补全脚本
|
|
12
|
+
init 把宿主无关的 BugX 核心初始化到项目
|
|
13
|
+
dsh 兼容启动器:为首个 Web Session 绑定项目并启动 DeepSeek Harness
|
|
14
|
+
hosts 只读发现可接入的 AI 宿主
|
|
15
|
+
install 发现并安装到已安装的 AI Agent
|
|
16
|
+
reset 归档后重建项目运行态或全局错题集(不删除全局引擎)
|
|
17
|
+
uninstall 安全卸载 BugX 宿主入口;默认保留报告、证据、配置和错题集
|
|
18
|
+
doctor 诊断安装与项目状态
|
|
19
|
+
mcp 启动本地 MCP Supervisor(不执行 worker 命令)
|
|
20
|
+
capability 探查项目形态并装配能力:plan(只读)/ install(装齐所需 MCP 运行时)
|
|
21
|
+
mcp-runtime lock-hash 专用离线 MCP
|
|
22
|
+
runtime:install/verify/start/rollback
|
|
23
|
+
lesson 管理项目级结构化错题集
|
|
24
|
+
logic-analysis 校验或绑定意图、逻辑链、Oracle 与证据包
|
|
25
|
+
probe 运行 core 探针(efficiency/sast/mobile 等),透传其参数
|
|
26
|
+
knowledge 治理项目候选与用户全局错题集(不自动同步)
|
|
27
|
+
skill 审计技能包管理、图谱状态查询、契约校验与原子回滚
|
|
28
|
+
self-audit 对 BugX 本地 CLI/MCP 只读入口做自举动态审计
|
|
29
|
+
engine 从全局引擎运行生命周期命令(项目不再提供 .bugx/core 入口)
|
|
30
|
+
cloud 云端错题/经验集同步(显式命令)
|
|
31
|
+
auth 登录、查看、设置或清除云端登录态
|
|
32
|
+
telemetry 查看或导出单向飞轮取证数据
|
|
33
|
+
config 设置本地 BugX 隐私与遥测配置
|
|
34
|
+
daemon BugX 自治持续挖掘常驻守护进程管理
|
|
35
|
+
autonomous 显式启动 Claude Code/Codex/OpenCode/DeepSeek
|
|
36
|
+
Harness/Pi/Cline/ZCode 前台无人值守挖掘
|
|
37
|
+
goal 目标导向无人值守自治挖掘与长程自愈循环
|
|
38
|
+
supervisor 本地监督 MCP:install / status / rpc;带外动作:reset-budget /
|
|
39
|
+
recover / rebind-target / gate / findings
|
|
40
|
+
plugin 安装、校验或查看私有 BugX 插件(不执行插件)
|
|
41
|
+
update 检查并安装最新 BugX CLI 版本
|
|
42
|
+
patch-forge 生成或静态校验补丁包(不执行包内代码、不提交远端)
|
|
43
|
+
log 查看诊断日志、错误排查、链路追踪与耗时瀑布图
|
|
44
|
+
stats 查看全局跨项目时间与 Token 消耗治理看板
|
|
45
|
+
project 工程代码体量、技术栈画像与规模估模分析
|
|
46
|
+
view 安全查看源文件切片与视窗(具备越界自愈与沙箱隔离)
|
|
47
|
+
test-generate 为指定单元自动生成标准化 AAA 测试用例或自包含 PoC
|
|
48
|
+
test-audit 对测试用例进行四维(准确、完整、有效、全面)量化质量审计
|
|
49
|
+
mining-audit 对漏洞挖掘方案与用例进行四维(准确、完整、有效、全面)质量量化审计与加固
|
|
50
|
+
test-verify 基于 AST 语义变异与沙箱隔离动态验证测试用例的抓 Bug 杀伤能力
|
|
51
|
+
audit 在隔离副本中启动 BugX 图审计或执行一键全息攻防渗透审计
|
|
52
|
+
interaction 查看/回答 BugX 抛出的结构化交互问题(非交互宿主的答案回灌通道)
|
|
53
|
+
advisory GitHub Security Advisory (GHSA) 标准安全公告与 PR 修复草案管理
|
|
54
|
+
report 双轨制人性化安全审计报告生成器 (formal 商务正式, visual 高颜值交付)
|
|
55
|
+
|
|
56
|
+
options:
|
|
57
|
+
-h, --help show this help message and exit
|
|
58
|
+
--version show program's version number and exit
|
|
59
|
+
--log-level {DEBUG,INFO,WARNING,ERROR}
|
|
60
|
+
诊断日志等级(默认 INFO,可由 BUGX_LOG_LEVEL 覆盖)
|
|
61
|
+
--accept-data-sharing
|
|
62
|
+
明确同意脱敏后的单向攻防数据反哺(CI/headless 默认关闭)
|
|
63
|
+
--privacy {standard,strict}
|
|
64
|
+
strict 仅允许匿名度量出网
|
|
65
|
+
--no-backup, --skip-backup
|
|
66
|
+
跳过执行前自动创建的外部备份归档
|
package/core/cloud_sync/SPEC.md
CHANGED
|
@@ -21,5 +21,5 @@ from core.cloud_sync import sync_report
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 5. Maintenance & Verification
|
|
24
|
-
-
|
|
24
|
+
- Verification is performed with short-lived tests outside the repository; no persistent `tests/` registry is retained.
|
|
25
25
|
- Changes to exported interfaces must be synchronized via `python3 scripts/gen_interface_spec.py --package core/cloud_sync --write`.
|
|
@@ -278,6 +278,19 @@ class CloudClient:
|
|
|
278
278
|
key = self.cred.api_key or self.cred.token
|
|
279
279
|
return f"Bearer {key}" if key else None
|
|
280
280
|
|
|
281
|
+
@staticmethod
|
|
282
|
+
def _unauthenticated(method: str, path: str) -> ReportResult:
|
|
283
|
+
"""Fail closed before egress when no account credential exists."""
|
|
284
|
+
message = (
|
|
285
|
+
f"unauthenticated: {method} {path} 必须携带账号 Bearer token;"
|
|
286
|
+
"project_key 只是幂等标识,不是鉴权凭据"
|
|
287
|
+
)
|
|
288
|
+
return ReportResult(
|
|
289
|
+
ok=False, status=401,
|
|
290
|
+
data={"code": "SYNC_UNAUTHENTICATED", "message": message},
|
|
291
|
+
error=message,
|
|
292
|
+
)
|
|
293
|
+
|
|
281
294
|
def _mark_auth_expired(self) -> None:
|
|
282
295
|
"""Keep a server-confirmed 401 visible to the next CLI process."""
|
|
283
296
|
self.cred.auth_state_override = "expired"
|
|
@@ -323,8 +336,12 @@ class CloudClient:
|
|
|
323
336
|
if expires_in is not None and expires_in <= 2 * 86400:
|
|
324
337
|
self._refresh()
|
|
325
338
|
header = self._auth_header()
|
|
326
|
-
if header:
|
|
327
|
-
|
|
339
|
+
if header is None:
|
|
340
|
+
# F-RSI-20261115-145:账号 Bearer token 是云端操作唯一的鉴权凭据,
|
|
341
|
+
# project_key 只是同账号内的幂等标识。缺失账号凭据时不得发出任何
|
|
342
|
+
# 请求(此前会静默省略 Authorization,仅凭 body 里的 project_key 出网)。
|
|
343
|
+
return self._unauthenticated(method, path)
|
|
344
|
+
headers["Authorization"] = header
|
|
328
345
|
body = None
|
|
329
346
|
if payload is not None:
|
|
330
347
|
# V2-only:pull 一律 query 参数(DOC-008 §5.2),GET 禁止携带 body。
|
|
@@ -445,8 +462,10 @@ class CloudClient:
|
|
|
445
462
|
headers = {"Accept": "application/json", **client_headers(),
|
|
446
463
|
"Content-Type": content_type, "Content-Length": str(len(body))}
|
|
447
464
|
auth = self._auth_header()
|
|
448
|
-
if auth:
|
|
449
|
-
|
|
465
|
+
if auth is None:
|
|
466
|
+
# 同 _request:补丁包上传同样必须带账号凭据,缺失即零 egress 拒绝。
|
|
467
|
+
return self._unauthenticated(method, path)
|
|
468
|
+
headers["Authorization"] = auth
|
|
450
469
|
req = urllib.request.Request(url, data=body, headers=headers, method=method)
|
|
451
470
|
try:
|
|
452
471
|
resp = self._open_request(req)
|
|
@@ -757,7 +776,7 @@ class CloudClient:
|
|
|
757
776
|
operation_id: str | None = None,
|
|
758
777
|
base_version: int | None = None,
|
|
759
778
|
device_id: str | None = None,
|
|
760
|
-
sensitive_policy: str = "
|
|
779
|
+
sensitive_policy: str = "redact") -> ReportResult:
|
|
761
780
|
"""V2 push:完整 envelope(records 四数组恒在,无 legacy 顶层字段)。
|
|
762
781
|
|
|
763
782
|
DOC-211:sensitive_policy=allow 跳过出网敏感扫描(策略应用已在构建侧
|
|
@@ -818,7 +837,7 @@ class CloudClient:
|
|
|
818
837
|
return self._request("POST", self.scope_path(scope, project_id), container)
|
|
819
838
|
|
|
820
839
|
def import_knowledge_bundle(self, bundle: dict[str, Any], *, mode: str = "merge",
|
|
821
|
-
sensitive_policy: str = "
|
|
840
|
+
sensitive_policy: str = "redact") -> ReportResult:
|
|
822
841
|
"""Import one validated V2 JSON bundle through the explicit import API.
|
|
823
842
|
|
|
824
843
|
DOC-211:upload 与 sync 同吃一档策略——block 补凭据形状扫描(堵旧
|
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
tombstone/冲突过滤 → Supervisor 原子导入 → 「inbox imported + cursor 推进」
|
|
11
11
|
原子提交 → quarantine 落地仅作诊断。
|
|
12
12
|
|
|
13
|
+
威胁模型边界(F-RSI-20261115-145 实测证实):
|
|
14
|
+
- ``project_key`` 是公开可推断的标识符(sha256(origin URL + root commit)),
|
|
15
|
+
**不是秘密**;任何能读取该仓库的人均可重算同一 key。
|
|
16
|
+
- ``project_key`` 在客户端只承担**幂等标识**(同一账号内 upsert 去重),不是
|
|
17
|
+
鉴权凭据:账号 Bearer token 是唯一授权依据,缺失即由 ``CloudClient._request``
|
|
18
|
+
与 ``sync_layers`` 的 F2 闸门 fail-closed 拒绝,零 egress、零本地身份写入。
|
|
19
|
+
- 服务端必须按账号隔离 project_key 并在 upsert 前校验项目归属——该防线是外部
|
|
20
|
+
契约,本仓只有客户端实现,不得以「防线在服务端」为由证伪客户端可推断风险。
|
|
21
|
+
|
|
13
22
|
不变量:显式 quarantine 导入只能为 candidate;私有多设备同步按远端治理状态恢复
|
|
14
23
|
active/candidate;committed cursor 只随成功导入推进;
|
|
15
24
|
任一页失败时 Ledger、旧 snapshot 与 committed cursor 均不变化(AD-008-02/03)。
|
|
@@ -205,6 +214,25 @@ def derive_project_key(root: Path) -> str:
|
|
|
205
214
|
任何设备首次运行时得到同一 ``project_key``,服务端解析到既有项目而
|
|
206
215
|
不是新建一个重复项。已存在的 binding/committed 身份始终优先,绝不
|
|
207
216
|
因本函数而改写既有项目。
|
|
217
|
+
|
|
218
|
+
威胁模型边界(F-RSI-20261115-145,探针实测 CONFIRMED):
|
|
219
|
+
- ``project_key`` 是**幂等标识符,不是鉴权凭据**:sha256(origin URL
|
|
220
|
+
+ root commit) 的两个输入对任何能读取该仓库的人(含克隆者)完全可见,
|
|
221
|
+
可完整重算同一 key(探针验证:公开输入重算与实际派生逐字节一致);
|
|
222
|
+
已提交的 ``.bugx-project.json``(0o644)本身也随仓库公开。该 key 只用于
|
|
223
|
+
同一账号内的 upsert 去重,禁止把它当作授权依据或访问控制手段。
|
|
224
|
+
- 鉴权边界在传输与账号层:所有云端 upsert/pull/push 必须携带账号
|
|
225
|
+
Bearer token,缺失即由 ``CloudClient._request``/``_request_raw`` 与
|
|
226
|
+
``sync_layers`` 的 F2 闸门 fail-closed 拒绝(零 egress、零本地身份写入),
|
|
227
|
+
不存在「仅凭 project_key 即可操作」的客户端路径。
|
|
228
|
+
- 提高熵源不可行:机器本地随机盐会破坏跨设备确定性(本函数存在的唯一
|
|
229
|
+
目的),且 committed 身份文件本来随仓库公开——可推断性是共享仓库
|
|
230
|
+
项目身份的固有属性,不是可修复缺陷。
|
|
231
|
+
- 服务端归属校验是**必需的外部契约**(本仓无服务端实现,无法自证):
|
|
232
|
+
服务端必须按账号隔离 ``project_key``,并在 upsert 前校验请求者对该
|
|
233
|
+
项目的归属;缺失该校验时,可推断 key 允许任何克隆者以自身 token
|
|
234
|
+
覆盖/冒用同账号可见的项目身份数据。禁止以「防线在服务端」为由将
|
|
235
|
+
此风险标记为已证伪——部署/交付侧必须显式确认服务端已实现。
|
|
208
236
|
"""
|
|
209
237
|
identity = _git_repo_identity(root)
|
|
210
238
|
if identity:
|
|
@@ -562,6 +590,19 @@ def sync_layers(client, root: Path, project_slug: str | None = None,
|
|
|
562
590
|
from core.cloud_sync.consent import revoked_summary, sharing_revoked
|
|
563
591
|
if sharing_revoked():
|
|
564
592
|
return revoked_summary(scopes)
|
|
593
|
+
# F2 硬闸门(F-RSI-20261115-145):账号 Bearer token 是唯一的鉴权凭据。
|
|
594
|
+
# project_key 由公开的 origin URL + 首 commit 确定性派生,任何克隆者都能重算,
|
|
595
|
+
# 它只是同账号内的幂等标识;缺失账号凭据时不得写本地身份,也不得发出任何请求。
|
|
596
|
+
cred = getattr(client, "cred", None)
|
|
597
|
+
if cred is None or not cred.is_authenticated():
|
|
598
|
+
return {
|
|
599
|
+
"ok": False,
|
|
600
|
+
"error": ("unauthenticated: 云端同步必须携带账号 Bearer token;"
|
|
601
|
+
"project_key 只是幂等标识,不是鉴权凭据"),
|
|
602
|
+
"code": "SYNC_UNAUTHENTICATED",
|
|
603
|
+
"skipped": "unauthenticated",
|
|
604
|
+
"scopes": sorted(scopes or {"global", "project"}),
|
|
605
|
+
}
|
|
565
606
|
from core.cloud_sync.onboard_wizard import (
|
|
566
607
|
ask_project_identity_decision,
|
|
567
608
|
ensure_project_identity,
|
|
@@ -579,7 +620,7 @@ def sync_layers(client, root: Path, project_slug: str | None = None,
|
|
|
579
620
|
sync_cfg = _load_cloud_config()
|
|
580
621
|
except Exception: # noqa: BLE001 - 配置缺失/非法不改变同步入口行为(非法值由闸报错)
|
|
581
622
|
sync_cfg = {}
|
|
582
|
-
selected_policy = sensitive_policy or sync_cfg.get("sensitive_policy") or "
|
|
623
|
+
selected_policy = sensitive_policy or sync_cfg.get("sensitive_policy") or "redact"
|
|
583
624
|
selected_detail_mode = ns["resolve_detail_mode"](
|
|
584
625
|
detail_mode or sync_cfg.get("sync_detail_mode"))
|
|
585
626
|
out: dict = {}
|
|
@@ -54,11 +54,12 @@ def default_audit_path() -> Path:
|
|
|
54
54
|
return Path(os.environ.get("BUGX_FLYWHEEL_AUDIT", str(_bugx_root() / "telemetry" / "egress_audit.log"))).expanduser()
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def _stored_data_sharing() -> bool:
|
|
57
|
+
def _stored_data_sharing() -> bool | None:
|
|
58
58
|
# 单一真源:与 cloud_onboard.sync_layers / auto_sync 共用 consent 判定,
|
|
59
59
|
# 禁止在这里另写一套读取逻辑(双轨实现会让撤销在两处产生不同结论)。
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
# 必须保留三态:撤销(False)要压过 BUGX_ACCEPT_DATA_SHARING 预同意入口。
|
|
61
|
+
from core.cloud_sync.consent import data_sharing_flag
|
|
62
|
+
return data_sharing_flag()
|
|
62
63
|
|
|
63
64
|
|
|
64
65
|
def _stored_base_url() -> str | None:
|
|
@@ -406,10 +407,18 @@ class FlywheelUploader:
|
|
|
406
407
|
self.audit_path = Path(audit_path or default_audit_path()).expanduser()
|
|
407
408
|
self._urlopen = urlopen or urllib.request.urlopen
|
|
408
409
|
self.auth_token = auth_token if auth_token is not None else _stored_auth_token()
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
410
|
+
# F-024:撤销(显式 false)是硬闸门——BUGX_ACCEPT_DATA_SHARING 预同意
|
|
411
|
+
# 入口只对「未表态」生效,不得越过用户显式撤销(与 sync_push/pull 的
|
|
412
|
+
# require_sharing 硬闸门同策略)。
|
|
413
|
+
if data_sharing is not None:
|
|
414
|
+
self.data_sharing = data_sharing
|
|
415
|
+
elif _stored_data_sharing() is False:
|
|
416
|
+
self.data_sharing = False
|
|
417
|
+
else:
|
|
418
|
+
self.data_sharing = (
|
|
419
|
+
os.environ.get("BUGX_ACCEPT_DATA_SHARING") == "1"
|
|
420
|
+
or _stored_data_sharing() is True
|
|
421
|
+
)
|
|
413
422
|
self.privacy_strict = (os.environ.get("BUGX_PRIVACY_STRICT") == "1") if privacy_strict is None else privacy_strict
|
|
414
423
|
self.sleep = sleep
|
|
415
424
|
self.timeout = timeout
|
|
@@ -24,6 +24,23 @@ from core.infra.client_metadata import tls_context as client_tls_context
|
|
|
24
24
|
|
|
25
25
|
logger = logging.getLogger(__name__)
|
|
26
26
|
|
|
27
|
+
# F-133:curl 子进程不得继承任何能改写 TLS 信任根的 env。
|
|
28
|
+
# 这些变量会让攻击者用自有 CA 覆盖代码构造的信任上下文(--ca-native/--cacert
|
|
29
|
+
# 或 --insecure 的显式决策),使 CA 固定被旁路。白名单只放行与此无关的 env;
|
|
30
|
+
# 命中即被剔除,信任只来自本函数据 context/BUGX_CA_BUNDLE 构造的参数,绝不
|
|
31
|
+
# 以“信任系统默认 + 残留 env”了事。
|
|
32
|
+
_TLS_TRUST_ENV_VARS = frozenset({
|
|
33
|
+
"CURL_CA_BUNDLE", # curl 读取的 CA bundle
|
|
34
|
+
"CURL_CA_PATH", # curl 读取的 CA 目录
|
|
35
|
+
"SSL_CERT_FILE", # OpenSSL/curl 默认 CA 文件
|
|
36
|
+
"SSL_CERT_DIR", # OpenSSL/curl 默认 CA 目录
|
|
37
|
+
"REQUESTS_CA_BUNDLE", # requests 信任根(同进程其他 HTTP 栈)
|
|
38
|
+
"NODE_EXTRA_CA_CERTS", # Node 追加信任根
|
|
39
|
+
"GIT_SSL_CAINFO", # git/curl 信任根
|
|
40
|
+
"GIT_SSL_CAPATH", # git/curl 信任目录
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
|
|
27
44
|
def is_private_target_host(host: str) -> bool:
|
|
28
45
|
"""Check if host is a local/private network target (excluding loopback)."""
|
|
29
46
|
if not host or host in {"localhost", "localhost.localdomain"}:
|
|
@@ -240,9 +257,13 @@ def trusted_curl_request(req: urllib.request.Request, timeout: float) -> CurlRes
|
|
|
240
257
|
command.extend(("--request", req.get_method(), "--dump-header", "/dev/stderr",
|
|
241
258
|
"--output", "-", req.full_url))
|
|
242
259
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
260
|
+
# 剔除注入向量:DYLD_*(动态库劫持)与全部 TLS 信任根 env(F-133)。
|
|
261
|
+
# 保留 BUGX_CA_BUNDLE:它是本函数上面显式读取并转成 --cacert 的代码构造锚,
|
|
262
|
+
# 不属于被污染的系统信任根注入面。
|
|
263
|
+
environment = {
|
|
264
|
+
key: value for key, value in os.environ.items()
|
|
265
|
+
if not key.startswith("DYLD_") and key not in _TLS_TRUST_ENV_VARS
|
|
266
|
+
}
|
|
246
267
|
try:
|
|
247
268
|
result = subprocess.run(
|
|
248
269
|
command, input=req.data, capture_output=True, timeout=timeout,
|
|
@@ -232,8 +232,8 @@ def emit_policy_audit(policy: str, categories: list[str], redacted_count: int) -
|
|
|
232
232
|
|
|
233
233
|
|
|
234
234
|
def prepare_records_for_sync(records: Mapping[str, list], *,
|
|
235
|
-
policy: str = "
|
|
236
|
-
"""DOC-211:push/upload
|
|
235
|
+
policy: str = "redact") -> dict[str, Any]:
|
|
236
|
+
"""DOC-211:push/upload 发网前的敏感策略统一入口(默认档安全默认 redact,F-025)。
|
|
237
237
|
|
|
238
238
|
必须在 manifest_hash/envelope 构建之前调用(redact 会改内容,幂等键在
|
|
239
239
|
manifest 之后派生会错位)。block=三正则+凭据形状双扫描,命中即拒(原语义
|
|
@@ -34,12 +34,14 @@ _TOOL_COUNT_CLAMP = 10 ** 6
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
def _tool_experience_level_for(lifecycles: int) -> str:
|
|
37
|
-
"""独立 lifecycle 数 →
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
"""独立 lifecycle 数 → 经验等级(单源委托)。
|
|
38
|
+
|
|
39
|
+
F-RSI-20261115-194 二次修正:F-138 修正时误判「ledger 无同名阈值函数」
|
|
40
|
+
——实际 core.ledger.tool_experience.tool_experience_level(hit_lifecycles)
|
|
41
|
+
真实存在且阈值一致(≥2 active / 1 candidate / else unproven)。此处直接
|
|
42
|
+
委托单源实现,消除双源漂移风险。"""
|
|
43
|
+
from core.ledger.tool_experience import tool_experience_level
|
|
44
|
+
return tool_experience_level(lifecycles)
|
|
43
45
|
|
|
44
46
|
|
|
45
47
|
def _tool_state_version(sync_states: Mapping[tuple[str, str], Mapping[str, Any]],
|
|
@@ -135,7 +137,7 @@ def _merge_tool_experience(tools: list[dict[str, Any]],
|
|
|
135
137
|
def _private_v2_records(ns, ledger: Path, *, detail_mode: str,
|
|
136
138
|
sync_states: dict[tuple[str, str], dict[str, Any]] | None = None,
|
|
137
139
|
layer: str | None = None,
|
|
138
|
-
policy: str = "
|
|
140
|
+
policy: str = "redact") -> dict[str, Any]:
|
|
139
141
|
"""Apply private-sync policy, then fill the strict V2 wire fields.
|
|
140
142
|
|
|
141
143
|
DOC-211:policy 三档(block/redact/allow)。redact 的 span 脱敏必须在
|
|
@@ -304,7 +306,7 @@ def replay_local_pending_outbox(root: Path, client: Any, ns, account_id: str) ->
|
|
|
304
306
|
result = push_layer(
|
|
305
307
|
client, ns, root, layer, proj_id, account_id,
|
|
306
308
|
detail_mode=sync_cfg.get("sync_detail_mode"),
|
|
307
|
-
sensitive_policy=sync_cfg.get("sensitive_policy") or "
|
|
309
|
+
sensitive_policy=sync_cfg.get("sensitive_policy") or "redact",
|
|
308
310
|
_conflict_retried=False, _allow_rebase=False,
|
|
309
311
|
)
|
|
310
312
|
if result.get("ok"):
|
|
@@ -392,7 +394,7 @@ def _chunk_records(records: Mapping[str, list]) -> list[dict[str, list]]:
|
|
|
392
394
|
|
|
393
395
|
def push_layer(client, ns, root: Path, layer: str, project_id: str,
|
|
394
396
|
account_id: str, *, detail_mode: str,
|
|
395
|
-
sensitive_policy: str = "
|
|
397
|
+
sensitive_policy: str = "redact",
|
|
396
398
|
_conflict_retried: bool = False,
|
|
397
399
|
_allow_rebase: bool = True) -> dict[str, Any]:
|
|
398
400
|
# F1 通用硬闸门:任何入口(sync_layers / onboarding outbox 重放 / 未来新增调用)
|
|
@@ -559,7 +561,7 @@ def push_layer(client, ns, root: Path, layer: str, project_id: str,
|
|
|
559
561
|
upgrade_hint = (
|
|
560
562
|
f"请升级 BugX 客户端至 {err.min_client_version or '0.6.1'}+ 并重建全局引擎。\n"
|
|
561
563
|
f" 推荐执行:bugx update\n"
|
|
562
|
-
f" 或手动执行:pip install --upgrade bugx-
|
|
564
|
+
f" 或手动执行:pip install --upgrade bugx-cli && bugx install --force"
|
|
563
565
|
)
|
|
564
566
|
store.record_scope_error(account_id, layer, project_id,
|
|
565
567
|
error_code=err.code or "SYNC_PROTOCOL_UPGRADE_REQUIRED",
|
|
@@ -142,7 +142,8 @@ Worker stdio 通道可补齐遗漏的 `caller_role`,但显式错误角色仍
|
|
|
142
142
|
5. 在覆盖清单中记录负责人、工具、证据和状态。
|
|
143
143
|
|
|
144
144
|
Web 项目必须额外加入 `web-standards` 审计轨道,先运行
|
|
145
|
-
`web_conformance.py check --root <dir>`,再用
|
|
145
|
+
`web_conformance.py check --root <dir>`,再用 `bugx probe ui --root <dir> --url <URL>`
|
|
146
|
+
或项目浏览器测试补动态证据。
|
|
146
147
|
该轨道的 Oracle 是 WCAG 2.2 AA、WAI-ARIA 1.2 和 HTML/WHATWG 语义;缺少动态环境只能
|
|
147
148
|
标记 `BLOCKED/UNVERIFIED`,不能声称 Web 标准完整通过。具体规则见
|
|
148
149
|
全局引擎 `web-conformance.md`(用 `bugx engine path --name web-conformance.md` 定位)。
|
|
@@ -215,15 +216,11 @@ lease 返回独立 `artifact_root`,Worker 只能向该目录写证据,超出
|
|
|
215
216
|
|
|
216
217
|
Worker 内按 `IntentHypothesis → LogicChain → OracleSpec → EvidencePacket` 建立并校验逻辑分析包(`logic_analysis.py validate` / `bugx logic-analysis bind`),包状态仅作任务绑定,不改变租约或结算;最终 Finding 仍由 `finding_confirmation` 裁决。`checkpoint` 提交前对照 `core/schemas/worker-checkpoint.schema.json` 自检(`findings[].fingerprint` / `covered[].evidence` / `signatures≤10`),`budget` 类失败不得伪造 `fixed`。
|
|
217
218
|
|
|
218
|
-
## 6.
|
|
219
|
+
## 6. 验证策略
|
|
219
220
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
- 定向测试:`python3 -m unittest tests.test_x` 或 `bugx test --affected`(只运行受影响模块);
|
|
225
|
-
- `--mode quick`:编译检查和关键模块,适合每次修改后的快速反馈;
|
|
226
|
-
- **全量测试职责归属**:全量测试套件(`--mode all-units` / `bash tests/run_tests.sh`)**仅由宿主在所有修复落盘、发版发布门禁或用户明确要求时集中统一跑一次**,任何 Worker、修复 Agent 或日常单点验证绝对禁止自行触发!
|
|
221
|
+
验证优先使用最小、可审计的静态检查、协议检查或仓库外临时测试。临时测试只服务当前
|
|
222
|
+
变更,验证结束后必须物理删除;本仓库不保留 `tests/` 套件、测试注册表或仓库级测试执行器。
|
|
223
|
+
目标项目自带的 `tests/` 仍是 BugX 的被测输入,不属于本仓库过程文件。
|
|
227
224
|
|
|
228
225
|
- 纯函数/转换:边界、属性、类型、空值、异常和变异测试。
|
|
229
226
|
- 状态机/生命周期:合法与非法迁移、重复操作、取消、超时、恢复和幂等。
|
package/core/contracts/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# BugX 智能体执行协议与交互契约子系统 (Agent Runtime Contracts & Protocols)
|
|
2
2
|
|
|
3
|
-
> **版本契约**: `1.
|
|
3
|
+
> **版本契约**: `0.1.1` | **父系统**: `core/`
|
|
4
4
|
> **工程规范**: 参见 [`docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md`](../../docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md) 与 [`docs/02_architecture/06_MODULE_GOVERNANCE_SPEC.md`](../../docs/02_architecture/06_MODULE_GOVERNANCE_SPEC.md)
|
|
5
|
-
> **守卫机制**: `scripts/verify_directory_indices.py`
|
|
5
|
+
> **守卫机制**: `scripts/verify_directory_indices.py` (100% 索引对齐防漂移)
|
|
6
6
|
|
|
7
7
|
本文档定义 BugX 运行于各大主流宿主(Claude, Cline, OpenCode, Codex, Pi, Qoder 等)以及并发 Worker 执行时的核心提示词契约、生命周期控制协议与人机交互规范。
|
|
8
8
|
|
|
@@ -382,9 +382,92 @@ def oracle_suggest(root: Path, query: str, *, limit: int = MAX_ORACLE_RESULTS) -
|
|
|
382
382
|
return result
|
|
383
383
|
|
|
384
384
|
|
|
385
|
+
def is_available(root: Path | None = None) -> tuple[bool, str]:
|
|
386
|
+
"""降级契约:机械探活契约状态前提(项目根存在且可写,零子进程)。
|
|
387
|
+
|
|
388
|
+
本模块只用标准库、不执行命令;唯一的落盘前提是项目根存在且可写,
|
|
389
|
+
使 ``.bugx/state`` 下的 harness/oracle 契约工件可创建。前提不满足时
|
|
390
|
+
调用方必须走 ``run_static_degraded``,禁止伪装契约工件已持久化。
|
|
391
|
+
"""
|
|
392
|
+
base = (Path(root) if root is not None else Path.cwd()).resolve()
|
|
393
|
+
if not base.is_dir():
|
|
394
|
+
return False, f"项目根不存在: {base}"
|
|
395
|
+
if not os.access(base, os.W_OK):
|
|
396
|
+
return False, f"项目根不可写,契约状态({_state_root(base)})无法落盘"
|
|
397
|
+
return True, f"契约状态根可用: {_state_root(base)}"
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
def run_static_degraded(
|
|
401
|
+
bundle: Mapping[str, object] | None = None,
|
|
402
|
+
*,
|
|
403
|
+
root: Path | None = None,
|
|
404
|
+
) -> dict[str, object]:
|
|
405
|
+
"""降级契约:bundle 缺失或校验失败时返回结构化降级裁决,不抛 ContractError。
|
|
406
|
+
|
|
407
|
+
输出与成功路径(``validate_evidence_bundle`` 的校验通过产物)字段级可区分:
|
|
408
|
+
``status="degraded"`` + ``degraded=True`` + ``degraded_reason``;调用方
|
|
409
|
+
拿到机器可读的裁决而非异常,且任何失败原因都显式落字段,绝不静默吞错。
|
|
410
|
+
"""
|
|
411
|
+
available, availability_detail = is_available(root)
|
|
412
|
+
if bundle is None:
|
|
413
|
+
return {
|
|
414
|
+
"schema_version": SCHEMA_VERSION,
|
|
415
|
+
"success": False,
|
|
416
|
+
"status": "degraded",
|
|
417
|
+
"degraded": True,
|
|
418
|
+
"degraded_reason": "evidence_bundle_missing",
|
|
419
|
+
"probe_mode": "static_degraded",
|
|
420
|
+
"findings": [],
|
|
421
|
+
"evidence": {"availability_detail": availability_detail},
|
|
422
|
+
"metadata": {
|
|
423
|
+
"degraded_mode": "contract_metadata_only",
|
|
424
|
+
"validator": "validate_evidence_bundle",
|
|
425
|
+
},
|
|
426
|
+
}
|
|
427
|
+
try:
|
|
428
|
+
verdict = validate_evidence_bundle(bundle, root=root)
|
|
429
|
+
except (ContractError, TypeError, ValueError) as exc:
|
|
430
|
+
return {
|
|
431
|
+
"schema_version": SCHEMA_VERSION,
|
|
432
|
+
"success": False,
|
|
433
|
+
"status": "degraded",
|
|
434
|
+
"degraded": True,
|
|
435
|
+
"degraded_reason": "contract_validation_failed",
|
|
436
|
+
"probe_mode": "static_degraded",
|
|
437
|
+
"findings": [],
|
|
438
|
+
"evidence": {
|
|
439
|
+
"availability_detail": availability_detail,
|
|
440
|
+
"error": str(exc),
|
|
441
|
+
"error_type": exc.__class__.__name__,
|
|
442
|
+
},
|
|
443
|
+
"metadata": {
|
|
444
|
+
"degraded_mode": "contract_metadata_only",
|
|
445
|
+
"validator": "validate_evidence_bundle",
|
|
446
|
+
},
|
|
447
|
+
}
|
|
448
|
+
return {
|
|
449
|
+
"schema_version": SCHEMA_VERSION,
|
|
450
|
+
"success": True,
|
|
451
|
+
"status": "degraded",
|
|
452
|
+
"degraded": True,
|
|
453
|
+
"degraded_reason": (
|
|
454
|
+
"static_mode_forced" if available else "state_root_unwritable"
|
|
455
|
+
),
|
|
456
|
+
"probe_mode": "static_degraded",
|
|
457
|
+
"validated": True,
|
|
458
|
+
"verdict": verdict,
|
|
459
|
+
"findings": [],
|
|
460
|
+
"evidence": {"availability_detail": availability_detail},
|
|
461
|
+
"metadata": {
|
|
462
|
+
"degraded_mode": "static_validation_only",
|
|
463
|
+
"state_persisted": bool(available),
|
|
464
|
+
},
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
|
|
385
468
|
__all__ = [
|
|
386
469
|
"ContractError", "discover_test_assets", "ensure_harness_registry",
|
|
387
|
-
"extract_oracle_candidates", "harness_snapshot", "
|
|
388
|
-
"oracle_suggest", "record_oracle",
|
|
389
|
-
"static_hit_contract", "validate_evidence_bundle",
|
|
470
|
+
"extract_oracle_candidates", "harness_snapshot", "is_available",
|
|
471
|
+
"mark_semantic_duplicates", "oracle_suggest", "record_oracle",
|
|
472
|
+
"run_static_degraded", "static_hit_contract", "validate_evidence_bundle",
|
|
390
473
|
]
|