bugx-cli 0.1.3 → 0.1.5
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/core/README.md +5 -3
- package/core/agent/agent_execution.py +7 -0
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/bugx.md +2 -2
- package/core/bugx_paths.py +10 -2
- package/core/bundled_docs/OVERVIEW.md +311 -0
- package/core/bundled_docs/README.md +10 -0
- package/core/bundled_docs/README_EN.md +278 -0
- package/core/bundled_docs/ai/01_AI_REFERENCE.md +838 -0
- package/core/bundled_docs/ai/02_AI_USAGE.md +161 -0
- package/core/bundled_docs/ai/03_AI_COMMANDS.md +322 -0
- package/core/bundled_docs/guides/01_USER_GUIDE.md +887 -0
- package/core/bundled_docs/guides/02_COMMANDS.md +935 -0
- package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +763 -0
- package/core/bundled_docs/guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md +48 -0
- package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +25 -0
- package/core/bundled_docs/guides/06_PROBES_AND_POC_COOKBOOK.md +49 -0
- package/core/bundled_docs/guides/07_LIFECYCLE_AND_RECOVERY_STATES.md +46 -0
- package/core/bundled_docs/guides/08_LESSONS_AND_PRIVACY_BOUNDARY.md +35 -0
- package/core/bundled_docs/hosts/bugx-claude_SKILL.md +326 -0
- package/core/bundled_docs/hosts/bugx-dsh_SKILL.md +229 -0
- package/core/bundled_docs/hosts/bugx-opencode_SKILL.md +129 -0
- package/core/bundled_docs/hosts/bugx-zcode_SKILL.md +459 -0
- package/core/bundled_docs/hosts/bugx_SKILL.md +118 -0
- package/core/bundled_docs/hosts/cline_bugx_SKILL.md +69 -0
- package/core/bundled_docs/hosts/platform_bugx_SKILL.md +50 -0
- package/core/bundled_docs/manifest.json +140 -0
- package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +422 -0
- package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +180 -0
- package/core/cli-help.txt +7 -3
- package/core/cloud_sync/cloud_client.py +81 -2
- package/core/cloud_sync/endpoint_router.py +22 -9
- package/core/cloud_sync/issue_uploader.py +297 -0
- package/core/cloud_sync/sensitive_filter.py +77 -7
- package/core/contracts/AGENT_GUIDE.md +3 -9
- package/core/contracts/README.md +1 -1
- package/core/contracts/bugx-runtime-contract.md +10 -20
- package/core/contracts/bugx-worker.md +1 -1
- package/core/coverage/coverage_ai_review.py +15 -11
- package/core/coverage/coverage_bootstrap.py +18 -13
- package/core/coverage/coverage_discovery.py +1 -1
- package/core/dev_harness/interaction_preset.py +1 -1
- package/core/engine-integrity.json +283 -159
- package/core/host_acp/README.md +4 -0
- package/core/host_acp/agnescode.py +128 -0
- package/core/host_acp/antigravity.py +153 -0
- package/core/host_runtime/README.md +3 -0
- package/core/host_runtime/adapters.py +5 -1
- package/core/host_runtime/antigravity.py +162 -0
- package/core/host_runtime/host_bootstrap.py +18 -7
- package/core/host_runtime/host_evaluators.py +4 -4
- package/core/host_runtime/host_registry.py +3 -1
- package/core/host_runtime/mcp_process_tracker.py +30 -3
- package/core/host_runtime/mcp_registry_gate.py +34 -11
- package/core/hosts/README.md +4 -0
- package/core/hosts/agnescode.py +415 -0
- package/core/hosts/antigravity.py +115 -0
- package/core/hosts/codex.py +3 -0
- package/core/hosts/dsh.py +42 -23
- package/core/hosts/minimax.py +5 -4
- package/core/hosts/opencode.py +11 -3
- package/core/i18n.py +94 -5
- package/core/infra/README.md +1 -1
- package/core/infra/build_info.py +2 -2
- package/core/infra/python_runtime.py +4 -1
- package/core/launch_phases/README.md +2 -2
- package/core/launch_phases/finding_confirm_phase.py +1 -1
- package/core/launch_phases/semantic_recon.py +3 -19
- package/core/launch_phases/startup_version_gate.py +2 -2
- package/core/launch_phases/supervisor_bridge.py +2 -0
- package/core/launch_phases/supervisor_degraded.py +7 -5
- package/core/launch_phases/verify_loop.py +3 -19
- package/core/ledger/README.md +1 -1
- package/core/ledger/finding_confirmation.py +1 -1
- package/core/ledger/finding_verification.py +2 -20
- package/core/ledger/fp_ledger.py +3 -19
- package/core/ledger/life_ledger.py +7 -33
- package/core/ledger/schema.py +1 -1
- package/core/locales/en-US.json +3 -3
- package/core/locales/zh-CN.json +3 -3
- package/core/mcp_handlers/supervisor_handlers.py +1 -1
- package/core/mcp_runtime_support/common.py +6 -0
- package/core/mcp_runtime_support/environment.py +88 -24
- package/core/metadata.txt +1 -1
- package/core/planning/README.md +1 -1
- package/core/planning/prompt_harness.py +2 -2
- package/core/planning/target_sandbox_manager.py +2 -0
- package/core/probes/codebase_memory_probe.py +43 -24
- package/core/probes/mobile_probe.py +1 -0
- package/core/probes/probe_registry.py +10 -7
- package/core/probes/sast_probe.py +1 -1
- package/core/probes/sca_scanner.py +1 -1
- package/core/project_profiler/constants.py +1 -1
- package/core/prompts/command_routing_en.md +6 -5
- package/core/prompts/command_routing_zh.md +6 -5
- package/core/repair/rsi_rounds.py +3 -0
- package/core/repair/self_heal.py +160 -6
- package/core/retrieval/README.md +1 -1
- package/core/retrieval/symbol_index.py +227 -52
- package/core/runtime/README.md +1 -1
- package/core/runtime/daemon_runner.py +3 -2
- package/core/runtime/project_init.py +1 -1
- package/core/runtime/scenario_eval.py +5 -1
- package/core/runtime/tool_install_targets.py +12 -2
- package/core/skills/README.md +4 -2
- package/core/skills/bugx_docs_cloud_sync.py +658 -0
- package/core/skills/bugx_docs_mcp_server.py +966 -140
- package/core/skills/bugx_mcp_server.py +9 -0
- package/core/skills/mcp_session_proof.py +3 -31
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/finding_commit.py +3 -24
- package/core/supervisor/task_scheduler.py +5 -2
- package/core/supervisor/worker_execution.py +16 -3
- package/core/supervisor/worker_handoff.py +2 -2
- package/core/webui/docs_session_service.py +40 -2
- package/core/webui/mcp_inspector.py +6 -6
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
- package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +5 -5
- 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 +1 -1
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +5 -5
- package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
- 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 +8 -7
- 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/agents/bugx-worker.md +14 -18
- package/ecosystem/plugins/bugx/agents/bugx.md +45 -49
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +7 -7
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +2 -2
- package/interfaces/cli/bugx_cli/__init__.py +1 -1
- package/interfaces/cli/bugx_cli/cli.py +153 -8
- package/interfaces/cli/bugx_cli/commands/agent.py +376 -69
- package/interfaces/cli/bugx_cli/commands/audit.py +2 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
- package/interfaces/cli/bugx_cli/commands/doctor.py +650 -223
- package/interfaces/cli/bugx_cli/commands/guide.py +143 -0
- package/interfaces/cli/bugx_cli/commands/issue.py +262 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +56 -26
- package/interfaces/cli/bugx_cli/commands/patch.py +5 -1
- package/interfaces/cli/bugx_cli/commands/plugin.py +306 -56
- package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +2 -2
- package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +154 -62
- package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +308 -108
- package/interfaces/cli/bugx_cli/commands/system.py +11 -1
- package/interfaces/cli/bugx_cli/common.py +39 -8
- package/interfaces/cli/bugx_cli/host_adapters.py +46 -3
- package/interfaces/cli/bugx_cli/hosts/registry.py +3 -2
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +21 -2
- package/interfaces/cli/bugx_cli/infra/__init__.py +4 -0
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +14 -12
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +76 -10
- package/interfaces/cli/bugx_cli/infra/host_sync.py +66 -1
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +240 -50
- package/package.json +3 -2
- package/pyproject.toml +22 -2
- package/scripts/sync-version.mjs +1 -1
- package/skills/README.md +1 -2
- package/skills/platform/bugx/SKILL.md +50 -0
- package/skills/platform/bugx-user/SKILL.md +0 -92
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# BugX 云端鉴权、同步与文档实时更新速查卡
|
|
2
|
+
|
|
3
|
+
> 适用场景:云端登录阻塞超时、非阻塞设备码授权、多scope同步失败、本地文档库同步与离线隔离。
|
|
4
|
+
|
|
5
|
+
## 1. 云端极速鉴权(推荐两种无阻塞方式)
|
|
6
|
+
|
|
7
|
+
### 方式一:API Key 瞬时鉴权(0.1s 零交互,适合 CI / Agent / 无头环境)
|
|
8
|
+
```bash
|
|
9
|
+
bugx auth set-key --api-key "<KEY>"
|
|
10
|
+
# 或环境变量注入:export BUGX_CLOUD_API_KEY="<KEY>"
|
|
11
|
+
bugx auth status --root . --verify --json # 确认 auth_verified=true
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### 方式二:非阻塞 Device Code 登录(彻底告别 600s 轮询卡死)
|
|
15
|
+
Agent 通过工具执行云端登录时,**必须加 `--non-blocking`**(或 CLI 检测到非 TTY 时自动非阻塞):
|
|
16
|
+
```bash
|
|
17
|
+
# 1. 立即获取 verification_uri 与 user_code(< 500ms 返回,pending 状态落盘 .bugx/cloud-auth-pending.json)
|
|
18
|
+
bugx auth login --root . --non-blocking --json
|
|
19
|
+
|
|
20
|
+
# 2. 展示授权链接和用户码给用户点击确认后,执行单次核验保存凭据:
|
|
21
|
+
bugx auth verify --device-code "<DEVICE_CODE>" --root .
|
|
22
|
+
# 若不传 --device-code,自动读取最近未过期的 cloud-auth-pending.json
|
|
23
|
+
|
|
24
|
+
# 3. 核验登录与路由状态:
|
|
25
|
+
bugx auth status --root . --verify --json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 2. 标准云同步流程与作用域
|
|
29
|
+
* **检查状态**:`bugx cloud status --root . --scope all --json`(纯本地只读,不联网)
|
|
30
|
+
* **全量授权同步**(仅当用户授权项目登记 + 项目知识 + 全局知识时):
|
|
31
|
+
```bash
|
|
32
|
+
bugx cloud projects add --root .
|
|
33
|
+
bugx cloud sync --root . --scope all
|
|
34
|
+
```
|
|
35
|
+
* **显式本地离线模式**:`bugx cloud onboard off --root .` 或 `bugx init --root . --cloud-sync local`
|
|
36
|
+
|
|
37
|
+
## 3. `bugx-docs` 实时同步与防污染策略
|
|
38
|
+
* **手动强制更新官方文档缓存**:`bugx mcp docs sync --root . --force --json`
|
|
39
|
+
* **缓存目录**:官方文档按 `contract_version`(如 `0.1.3`)落盘 `~/.bugx/cache/docs/<version>/<sha256>.sqlite3`,只换不改、切完物理删除旧库;项目私有文档严格留在 `<ROOT>/.bugx/knowledge/docs.sqlite3`,**绝不上云**。
|
|
40
|
+
* **严格离线/空气隔离**:设置 `export BUGX_DOCS_OFFLINE=1` 或传 `--offline`,将仅使用随包离线基线,零出网连接。
|
|
41
|
+
|
|
42
|
+
## 4. 高频报错对照处置
|
|
43
|
+
| 症状/错误 | 根因 | 标准处置 |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `SYNC_UNAUTHENTICATED` / `401` | 无有效 Bearer Token 或已过期 | 运行 `bugx auth login --root . --non-blocking` 重新授权后 `auth verify` |
|
|
46
|
+
| `429` Provider Rate Limit | 宿主模型或网关限流(`.bugx/state/provider-window.json`) | 等待窗口结束再重试,禁止删除限制文件绕过 |
|
|
47
|
+
| Darwin 私网 `Errno 65/51` | macOS 本地网络权限 (TCC) 拦截 Python 直连 | 查看 `bugx doctor --root .` 的 `/usr/bin/curl` 影子探活结果,授予定期权限 |
|
|
48
|
+
| `ack_pending=true` | 本地导入已提交但远端 ACK 未完成 | 保留本地 ledger 与 cursor,排查网络认证后重新执行原 scope 的 `cloud sync` |
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# BugX 主流 AI 宿主接入与派发避坑速查卡
|
|
2
|
+
|
|
3
|
+
> 适用场景:安装配置宿主、MCP 未加载、Worker 派发方式选择、各宿主交互原语与常见报错。
|
|
4
|
+
|
|
5
|
+
## 1. 主流宿主配置与原语矩阵
|
|
6
|
+
|
|
7
|
+
| 宿主 (`--agent`) | MCP 配置文件位置与作用域 | 交互单选工具 | Worker 并发方式 | 核心注意与坑位 |
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
| **Agnes Code** | 项目根 `agnescode.json` (`mcp.servers`) / 镜像 `.agnescode/` | `question` (`multiple=false`) | `subagent` (`bugx.md`, `background=false`) | 终端原生 TUI;支持 `--agent agnescode` 一键安装与 ACP 无头探活,`AGNESCODE_CONFIG_DIR` 隔离 |
|
|
10
|
+
| **Google Antigravity** | 工作区 `.agents/mcp_config.json` | Agent selector | 串行多进程会话 | 插件本体位于用户级 `~/.gemini/config/plugins`,项目级 MCP 须与插件隔离 |
|
|
11
|
+
| **OpenCode** | 项目根 `opencode.json` (`mcp.servers`) | `question` (`multiple=false`) | `subagent` (`bugx-worker`, `background=false`) | 必须在项目根启动;`pre` 需同步前台跑 (`timeout=300000`);禁止从 shell 另起 `bugx mcp serve`(会触发 `session_occupied`) |
|
|
12
|
+
| **Claude Code** | 项目根 `.mcp.json` + `.claude/mcp.json` (`mcpServers`) | `AskUserQuestion` (`tooling:batch` 用多选) | `Task(subagent_type="bugx-worker")` | **勿传 `process_pid`**;上游无 ACP(`claude -p` 走 headless);确保探针输出非空 stdout/stderr 满足双独立证据通道 |
|
|
13
|
+
| **Codex** | `.codex/config.toml` + `$CODEX_HOME/config.toml` (`mcp_servers`) | `request_user_input_async` | 原生子智能体(`fork_turns="none"`) | 须具备项目信任表 `[projects]`;支持 `command` (`stdio`) 或 `url` (Remote HTTP MCP) |
|
|
14
|
+
| **ZCode** | 用户级全局 `~/.zcode/cli/config.json` (`mcp.servers`) | 原生交互选择 | 小中项目 `collect(--all) -> bugx-judge`;大项目 `workers` | 配置为全局单例(切项目需 `bugx install --root <新项目>` 重绑);开发验证走 `BUGX_DEV_MODE=1`,**严禁用 `pip install -e`** |
|
|
15
|
+
| **Cline** | 全局 `<CLINE_DATA_DIR>/settings/cline_mcp_settings.json` | `ask_question` | 交互会话单 Claim 串行;自治跑 `autonomous --workers N` | 无项目级 MCP,`.cline/mcp.json` 不会被加载 |
|
|
16
|
+
| **DSH / Pi / Kimi / MiniMax / Qoder / WorkBuddy** | DSH (`dsh-patch.yml`) / Pi (`.pi/mcp.json`) / Kimi (`.kimi-code/mcp.json`) 等 | 各自宿主单选或回落 `bugx interaction` | `workers --count` 或 `autonomous --host <HOST>` | 运行 `bugx hosts --root . --json` 查看本机检测状态 |
|
|
17
|
+
|
|
18
|
+
## 2. 默认接入与远程优先通道
|
|
19
|
+
* **默认方式(100% 全宿主兼容)**:所有宿主均注册 `bugx-supervisor`(Host 本地 stdio)、`bugx-supervisor-worker`(Worker 本地 stdio)。
|
|
20
|
+
* **远程优先官档通道(Remote-First)**:`bugx-docs` 默认采用「远程优先」策略直连云端官档(如 `https://bugx.dev/api/v1/mcp/docs?contract_version=0.1.5`),零本地常驻进程;在断网环境或传入 `--docs-transport stdio` 时自动无感降级为本地 `stdio` 进程与随包离线快照。`mcp_process_tracker` 会自动识别 URL 形态,不会误报“缺少本地进程”。
|
|
21
|
+
|
|
22
|
+
## 3. 通用高代价避坑(实证复盘)
|
|
23
|
+
1. **静默 `sys.exit(1)` 导致双证据通道校验失败**:正例探针失败退出时,引擎依赖非空 stdout/stderr 构造第二验证通道;纯静默退出会被 Confirmation Gate 拒收。务必打印具体可观测差分值(如 `SENTINEL=True` / `ACTUAL=...`)。
|
|
24
|
+
2. **新装/更新 MCP 后工具目录未刷新**:宿主通常不热加载 stdio MCP;执行 `bugx install` 后按提示重开宿主会话,并用 `bugx doctor --root .` 验证绿灯。
|
|
25
|
+
3. **开发调试禁止 `pip install -e`**:会破坏生产 console script 与全局引擎契约;统一使用 `BUGX_DEV_MODE=1 python3 -m bugx_cli.cli ...`。
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# BugX 探针选择、单点 PoC 与变异验证速查卡
|
|
2
|
+
|
|
3
|
+
> 适用场景:单文件敏捷漏洞复现(分支 A)、11 类专精探针选用、AST 变异测试杀伤率验证。
|
|
4
|
+
|
|
5
|
+
## 1. 分支 A:单点敏捷排查与最小复现闭环
|
|
6
|
+
当仅需定位/复现特定文件、函数或异常堆栈时,**严禁启动重型全库 `engine pre` 生命周期**,按四步极速收敛:
|
|
7
|
+
```bash
|
|
8
|
+
# 1. 安全读取目标源码切片(UTF-8 容错 + 越界自愈)
|
|
9
|
+
bugx view --root . src/auth.py --lines 1-120
|
|
10
|
+
|
|
11
|
+
# 2. 为目标符号生成标准化测试或最小自包含 PoC 草稿
|
|
12
|
+
bugx test-generate --root . --scope "src/auth.py::verify_token" --out "$TMPDIR/poc_auth.py"
|
|
13
|
+
|
|
14
|
+
# 3. 审计现有测试资产的断言与覆盖质量(四维量化)
|
|
15
|
+
bugx test-audit --scope "src/auth.py::verify_token" tests/test_auth.py --json
|
|
16
|
+
|
|
17
|
+
# 4. 沙箱变异杀伤力验证(mutate 仅预览变异体;verify 在隔离沙箱真实执行)
|
|
18
|
+
bugx test-verify mutate --root . --scope "src/auth.py::verify_token"
|
|
19
|
+
bugx test-verify verify --root . --scope "src/auth.py::verify_token"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 2. 全量 11 类专项探针(`bugx probe <KIND>`)
|
|
23
|
+
调用格式:`bugx probe [--root ROOT] [--timeout-seconds 120..1800] <KIND> [probe_args ...]`
|
|
24
|
+
|
|
25
|
+
| `probe_kind` | 专项覆盖能力 | 典型触发场景与注意 |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `sast` | 多语言 AST/正则静态危险汇扫描 | 全库初筛或 PR 增量静态扫描 |
|
|
28
|
+
| `differential` | 双输入行为差分对比(BASE vs PAYLOAD) | 逻辑越权、解析差异、安全绕过 (`SENTINEL=True`) |
|
|
29
|
+
| `pattern` | 高危已知反模式特征扫描 | 快速命中同类已知脆弱模式 |
|
|
30
|
+
| `codebase-memory` | 图谱调用链、影响面与未覆盖盲区 | 验证 `codebase-memory-mcp` 必装就绪状态 |
|
|
31
|
+
| `memory` | 内存泄漏/UAF/PSS 趋势专项 | 原生 C/C++/Rust(ASan/Valgrind)、Python/JVM/Android RSS |
|
|
32
|
+
| `ui` | 真实无头浏览器 Web UI 视觉、无障碍与键盘流 | 依赖 `bugx-cli[ui]` + Chromium;自带随包 `axe-core` |
|
|
33
|
+
| `mobile` | Android 组件暴露面、DeepLink、Intent 劫持 | 需配好 APK/设备证据边界 |
|
|
34
|
+
| `ios_binary` | Apple IPA/Mach-O/Plist 二进制安全检查 | iOS/macOS 原生二进制目标 |
|
|
35
|
+
| `platform` | 宿主与运行平台环境/权限探测 | 跨平台路径、符号链接、工具链路体检 |
|
|
36
|
+
| `efficiency` | 运行时热点与执行性能回归基线 | 性能瓶颈定位与吞吐验证 |
|
|
37
|
+
| `openwiki` | 外部参考知识辅助查证 | 仅授权公开语义查证 |
|
|
38
|
+
|
|
39
|
+
### Web UI 严格巡检示例
|
|
40
|
+
```bash
|
|
41
|
+
bugx probe ui --root . --url http://127.0.0.1:8080 --journeys --strict
|
|
42
|
+
# 支持 --color-scheme dark、--viewport NAME=WIDTHxHEIGHT、--reference-url <对比图>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 3. Finding 立案四项铁律
|
|
46
|
+
1. 必须绑定真实文件与精确行号,禁止猜测函数名。
|
|
47
|
+
2. 必须同时运行正例输入(稳定触发缺陷)+ 负例对照(正常输入通过)。
|
|
48
|
+
3. `evidence.status` 只能填 `passed | failed | error | skipped | blocked`;`coverage` 才能填 `covered | blocked`。
|
|
49
|
+
4. 验证过程中创建的临时脚本统一置于 `$TMPDIR/bugx-tests-*`,验证完毕立即物理删除,**绝不遗留进项目生产源码**。
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# BugX 全生命周期状态机、门禁与故障恢复速查卡
|
|
2
|
+
|
|
3
|
+
> 适用场景:全库深度审计调度、`engine pre` 退出码 `2` 交互、Worker 并发监督、常见阻断(`FATAL_BLOCKED` / `RECOVERY_REQUIRED` / `WinError 32`)与报告生成。
|
|
4
|
+
|
|
5
|
+
## 1. 全库审计五步状态机
|
|
6
|
+
```text
|
|
7
|
+
1. bugx engine --root <ROOT> status --json
|
|
8
|
+
├─ UNINITIALIZED ──────────────────────────▶ 可运行 engine pre 安全建局
|
|
9
|
+
├─ FATAL_BLOCKED / CORRUPTED / 未定阻断 ───▶ 严禁 init / reset / --force 掩盖,先保留现场与 logs
|
|
10
|
+
└─ READY / ACTIVE ─────────────────────────▶ 恢复或进入下一阶段
|
|
11
|
+
|
|
12
|
+
2. bugx engine --root <ROOT> pre
|
|
13
|
+
├─ Exit 2 (BUGX_INTERACTION_REQUEST) ──────▶ 原样调用宿主单选控件(无原生控件走 bugx interaction answer)
|
|
14
|
+
└─ Exit 0 ─────────────────────────────────▶ 仅表示启动门禁通过,尚未完成挖掘
|
|
15
|
+
|
|
16
|
+
3. bugx engine --root <ROOT> workers → 派发 Worker(claim → worker-start → heartbeat → probe → checkpoint)
|
|
17
|
+
4. bugx supervisor status / findings / gate / finish --root <ROOT>
|
|
18
|
+
5. bugx engine --root <ROOT> post → bugx report both --root <ROOT> --format both
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 2. 非交互环境交互回灌通道(`bugx interaction`)
|
|
22
|
+
当 CI / 无原生界面宿主导致 `engine pre` 阻塞等待单选确认时:
|
|
23
|
+
```bash
|
|
24
|
+
bugx interaction list --root . --json
|
|
25
|
+
bugx interaction show <QUESTION_ID> --root . --json
|
|
26
|
+
bugx interaction answer <QUESTION_ID> --value <OPTION_VALUE> --root . --json
|
|
27
|
+
# 仅取消陈旧问题:bugx interaction cancel <QUESTION_ID> --root . --reason "..." --json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 3. 高频故障与安全自愈速查
|
|
31
|
+
| 故障态 / 错误码 | 真实原因 | 唯一授权恢复动作 | 禁止误操作 |
|
|
32
|
+
|---|---|---|---|
|
|
33
|
+
| `FATAL_BLOCKED` / `identity mismatch` | `.bugx/manifest.json` 绑错项目路径或损坏 | `bugx project rebind --root . --json`(迁移需显式确认);查看 `bugx log --root . --errors` | 禁止手删 `.bugx/` 或硬加 `--force` / `reset` |
|
|
34
|
+
| `WinError 32` / 文件占用 | Windows 下历史 Worker 或编辑器句柄锁定旧文件 | 等待只读句柄释放或关闭残留子进程;新版 `docs.sqlite3` 采用不可变切换 + `.gc-pending` 延迟清理,自动绕过占用崩溃 | 禁止破坏性 `taskkill` 无关用户进程 |
|
|
35
|
+
| `MissingAgentAssetError` (exit 2) | 缺失安装资产或旧全局引擎不完整 | 生产态执行 `bugx update --repair-assets`;源码开发显式使用 `BUGX_DEV_MODE=1` | 禁止在生产目录套用开发仓库补丁 |
|
|
36
|
+
| `session_occupied` / 租约失效 | 双开 `bugx-supervisor` 或 Worker 超过 heartbeat 窗口 | 复用当前会话已挂载 MCP;确认无活动工作后运行 `bugx supervisor recover --root .` | 禁止直接编辑 `supervisor.json` |
|
|
37
|
+
| `MCP_RUNTIME_CORRUPT` | 离线 runtime 安装半成品或锁哈希校验不通过 | `bugx mcp-runtime verify --json` 后执行 `bugx mcp-runtime rollback --json` 再重装 | 禁止跳过哈希锁强制运行 |
|
|
38
|
+
|
|
39
|
+
## 4. 终态判定与双轨报告交付
|
|
40
|
+
* 唯一合法审计完成标志:`COMPLETE`(覆盖清单全部 `covered` 且 `open_findings` 清空),绝不能仅靠模型总结文字或单个脚本 exit 0 宣布完成。
|
|
41
|
+
* 报告交付:
|
|
42
|
+
```bash
|
|
43
|
+
bugx report both --root . --out .bugx/reports --format both # formal(商务正式) + visual(可视化)
|
|
44
|
+
bugx report serve --root . --port 8080 # 启动 BugX Studio 本地预览台
|
|
45
|
+
bugx advisory export --cve CVE-2026-9001 --format markdown # 生成本地 GHSA 草案(不主动发布)
|
|
46
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# BugX 错题经验治理、先验语料与隐私红线速查卡
|
|
2
|
+
|
|
3
|
+
> 适用场景:复用历史经验防重复误判、区分 `bugx-docs` 与 `lesson-ledger` 职责、排查遥测/隐私拦截。
|
|
4
|
+
|
|
5
|
+
## 1. 三套知识系统的正交边界(勿混淆)
|
|
6
|
+
|
|
7
|
+
| 子系统 | 底层载体 | 写入机制与隐私作用域 | 典型查询入口 |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| **文档检索 (`bugx-docs`)** | `~/.bugx/cache/docs/<ver>/`(官档) + `<ROOT>/.bugx/knowledge/docs.sqlite3`(项目文档) | 只读 Markdown RAG 索引;项目库**绝不上云**,官档可热同步 | MCP `search_docs` / `fetch_doc` / `list_sections` 或 `bugx guide "<关键词>"` |
|
|
10
|
+
| **错题经验集 (`lesson-ledger`)** | `.bugx/knowledge/lesson-ledger.sqlite3` + `~/.bugx/knowledge/global.sqlite3` | 18 张强状态关系表(`hit_count`、误报源码防线 `fp_ledger`、V2 双向云同步) | MCP `bugx_knowledge_route` / `bugx_lesson_retrieve` 或 `bugx lesson retrieve|incident-lookup` |
|
|
11
|
+
| **冷启动数据集 (`seed_corpus` & `pitfall_packs`)** | `core/seed_corpus/*.txt` & `core/audit_packs/pitfalls/*.json` | 随核心引擎签名静态分发,按项目语言/框架过滤 + 双路 RRF 装配先验 | `engine pre` 与 Worker `worker_prior` 自动注入(高危 API 与误报防线) |
|
|
12
|
+
|
|
13
|
+
> **工程红线**:经验集支持状态反馈、因果指纹与 V2 游标同步;数据集按编程语言硬隔离。两者均**不迁移合并**进无状态全文文档库 `bugx-docs`,确保各自召回信噪比与安全性。
|
|
14
|
+
|
|
15
|
+
## 2. 日常错题检索与复盘闭环
|
|
16
|
+
```bash
|
|
17
|
+
# 按故障/模块查同类历史模式
|
|
18
|
+
bugx lesson retrieve --root . --query "SQLite lock concurrency" --json
|
|
19
|
+
# 查某报错签名的完整事故上下文
|
|
20
|
+
bugx lesson incident-lookup --root . --query "WinError 32" --json
|
|
21
|
+
# 查哪款工具在该类问题命中率最高
|
|
22
|
+
bugx lesson tool-lookup --root . --query "sast python" --json
|
|
23
|
+
# 检查账本健康与知识包状态
|
|
24
|
+
bugx lesson validate --root . --deep --json
|
|
25
|
+
bugx knowledge status --root . --json
|
|
26
|
+
```
|
|
27
|
+
* **禁止误用**:当 marker 存在但 SQLite 损坏缺失时,先备份恢复,**禁止直接跑 `rebuild --from-seed --confirm-data-loss`** 抹除历史状态。`promote*` 修改全局账本,不等价于 `cloud sync`。
|
|
28
|
+
|
|
29
|
+
## 3. 隐私、遥测与敏感到网红线(Hard Gates)
|
|
30
|
+
| 控制维度 | 设置项 / 环境变量 | 行为与绝对禁止边界 |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| **遥测与数据分享门禁** | `bugx config set telemetry.data_sharing false`<br>`BUGX_TELEMETRY_ENABLED=0`(进程级) | 设 `false` 将**物理清空本地飞轮 outbox** 并**强硬阻断 `cloud sync` push/pull**,不可用 env 绕过。AI 不得擅自传入 `--accept-data-sharing`。 |
|
|
33
|
+
| **敏感文本策略** | `bugx config set cloud.sensitive_policy block|redact|allow` | 缺省为 `redact`(安全默认脱敏);`block` 命中秘钥立即阻断;**原样上云需显式 `allow`**。 |
|
|
34
|
+
| **匿名文档拉取隔离** | `BUGX_DOCS_OFFLINE=1` / `cloud.docs_remote_enabled=false` | 启用后 `bugx-docs` 出网请求归零;联网拉取官档仅传递版本号与语种,**严禁外发任何被测项目路径、源码或密钥**。 |
|
|
35
|
+
| **报告与日志严禁泄露凭据** | `auth status` / `log` / `export` | 严禁把 API Key、Token、JWT 写入日志、Chat 输出或 GHSA 报告。 |
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bugx-claude
|
|
3
|
+
description: BugX 自主代码审查与智能测试在 Claude Code 宿主下的专属使用手册——开工前必读协议清单、宿主能力映射(AskUserQuestion/Task/MCP)、finding confirmation 与 reproduction 契约、本机实证过的坑位与对策(证据通道、claim 粒度、指纹漂移自锁、大响应体、worker MCP 断线回退)。当用户要在 Claude Code 里启动/排障/收尾 BugX 审查、解释 BugX 门禁报错、或问「为什么审查跑了这么久」时使用本 skill。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# BugX × Claude Code 使用手册(实证复盘版)
|
|
7
|
+
|
|
8
|
+
本手册由 2026-11-09 在 `bugx-audit-claude` 靶场的整轮审计复盘提炼。
|
|
9
|
+
所有坑位都在本机实证过;标注【源码已修】的条目已在引擎侧修复。
|
|
10
|
+
|
|
11
|
+
与通用 `bugx` skill 的关系:通用版承载生命周期协议;本手册是 Claude Code 宿主增补,
|
|
12
|
+
**不替代门禁交互纪律**。两者冲突时以通用协议为准。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 〇、开工前必读(这一节能省掉一半时间)
|
|
17
|
+
|
|
18
|
+
**强制执行**,不要跳过:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bugx engine path --name AGENT_GUIDE.md # 362 行,收尾 checklist
|
|
22
|
+
bugx engine path --name bugx.md # 1299 行,读「工作流程」第 5 条「举证与确认」
|
|
23
|
+
bugx engine path --name contracts/bugx-runtime-contract.md # 342 行,claim/rebind 状态机
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**只读后两份也没关系,但必须读。** 2026-11-09 那次审计里,这些坑在文档里全都写着,
|
|
27
|
+
却因为「靶场答案已知、看起来简单」而跳过了,结果多花 45 分钟。
|
|
28
|
+
|
|
29
|
+
读不下 1299 行就只读这三段:
|
|
30
|
+
- `bugx.md:1098-1112` —— 举证与确认:confirmed 的六个硬条件
|
|
31
|
+
- `bugx.md:584-586` —— commit_policy 与提交时机
|
|
32
|
+
- `bugx.md:875-880` —— cycle-review 契约
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 一、Claude Code 宿主能力映射
|
|
37
|
+
|
|
38
|
+
| BugX 需要 | Claude Code 对应能力 | 注意 |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| 门禁单选 | `AskUserQuestion` | 生命周期门禁 `multiSelect=false`;`question_id=tooling:batch` 必须 `multiSelect=true` |
|
|
41
|
+
| Worker 并发 | `Task` / 原生 subagent | `subagent_type="bugx-worker"`;**不要传 `process_pid`** |
|
|
42
|
+
| 协议通道 | `bugx-supervisor` MCP(host)+ `bugx-supervisor-worker` MCP(worker) | 两个 server 角色分离,host 持 `controller.lock` 单例 |
|
|
43
|
+
| MCP 配置 | `.mcp.json`(项目级)+ `.claude/mcp.json`(镜像) | `container_key=mcpServers` |
|
|
44
|
+
| 无头调用 | `claude -p <prompt>` | 自治加 `--output-format json --permission-mode bypassPermissions` |
|
|
45
|
+
| 断点续跑 | `claude --resume <session>` | |
|
|
46
|
+
|
|
47
|
+
**ACP 面:Claude Code 上游不存在**(`claude --help` 无 `acp` 子命令/flag)。
|
|
48
|
+
`core/host_acp/claude.py` 显式声明 `status="unavailable"`。不要试图走 ACP,
|
|
49
|
+
受支持通道是无头 `claude -p` 与插件机制。
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 二、实证坑位(按代价从高到低)
|
|
54
|
+
|
|
55
|
+
### 坑 1:两个独立证据通道 —— 最贵的一个
|
|
56
|
+
|
|
57
|
+
**症状**
|
|
58
|
+
```
|
|
59
|
+
确认门禁失败,拒绝写入不可收敛的 confirmed:
|
|
60
|
+
缺两个独立证据通道(engine-verify 只从 receipt 的 stdout/stderr 派生第二通道)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**根因**:引擎从 verification receipt 派生通道:
|
|
64
|
+
- `engine-verify:exit-code` —— 永远有
|
|
65
|
+
- `engine-verify:stdout` / `engine-verify:stderr` —— **仅当摘要非空时才有**
|
|
66
|
+
|
|
67
|
+
纯静默 `sys.exit(1)` 的 stdout/stderr 都是空串(sha256 = `e3b0c442...`),
|
|
68
|
+
所以只有 **1 个通道**,门禁拒绝。
|
|
69
|
+
|
|
70
|
+
**正确写法**:正例探针在退出前**必须打印非空失败观测**:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
print(f"DEFECT REPRODUCED: connect_calls={n} thread_errors={errs}")
|
|
74
|
+
sys.exit(1)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
负对照保持安静 `exit 0` 即可。
|
|
78
|
+
|
|
79
|
+
**判断口诀**:正例 exit 1 **且** stdout 非空;负例 exit 0 且可静默。
|
|
80
|
+
着急时记这句就够。
|
|
81
|
+
|
|
82
|
+
### 坑 2:claim 粒度 —— 一个 worker 一次只能领一个 unit
|
|
83
|
+
|
|
84
|
+
**症状**
|
|
85
|
+
```
|
|
86
|
+
每个 Worker 只能领取一个 coverage unit;请由调度器拆分任务后再次 claim
|
|
87
|
+
```
|
|
88
|
+
传了 `allow_bundle=true` 还会撞:
|
|
89
|
+
```
|
|
90
|
+
Worker MCP claim 禁止 allow_bundle=true;批量 claim 只能由本地 orchestrator core 调用
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**正确做法**:一个 worker_id ↔ 一个 unit_id。15 个单元就派 15 次 claim。
|
|
94
|
+
批量只能由引擎内部 orchestrator 做,MCP 通道不给。
|
|
95
|
+
|
|
96
|
+
**推论**:别写"批量领取脚本",直接循环单发。
|
|
97
|
+
|
|
98
|
+
### 坑 3:worker 启动不传 PID
|
|
99
|
+
|
|
100
|
+
**症状**
|
|
101
|
+
```
|
|
102
|
+
process_pid 999999 不存活:Task 子代理请省略 process_pid,以心跳作为活性证据
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**正确**:`worker_start(caller_role="worker", worker_id=..., provider="claude-code")`,
|
|
106
|
+
**不传 `process_pid`**。原生子 Agent 由心跳证明活性。
|
|
107
|
+
|
|
108
|
+
### 坑 4:中途 commit 触发指纹漂移自锁 —— 20 分钟白跑
|
|
109
|
+
|
|
110
|
+
**症状**
|
|
111
|
+
```
|
|
112
|
+
审计目标已变化;请重新生成当前覆盖计划后再继续
|
|
113
|
+
```
|
|
114
|
+
随后 `post` 报:
|
|
115
|
+
```
|
|
116
|
+
并发门禁未满足:Life 未满足(target_drift)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**根因**:`workspace_fingerprint = SHA256(manifest单元集 + git HEAD)`。
|
|
120
|
+
|
|
121
|
+
你在审计中途 `git commit` 修复 → **git HEAD 变了** → 指纹漂移。
|
|
122
|
+
更糟的是 `post` 自己也会重写 `module-coverage.md`(重扫发现新函数),
|
|
123
|
+
又一次改变指纹 —— **写完清单再校验指纹,自己判自己漂移**。
|
|
124
|
+
|
|
125
|
+
**正确姿势**:
|
|
126
|
+
- **全程不切 git 状态**。要么一直对着漏洞版,最后一次性 commit;要么开 worktree。
|
|
127
|
+
- 已经提交了:立刻 `bugx_supervisor_rebind_target`(需要 `reason`)。它把证据
|
|
128
|
+
不再匹配新目标的已覆盖单元迁为 stale;证据仍可复算的单元会被自动恢复
|
|
129
|
+
(`_reinstate_covered_by_evidence`)。**最坏情况仍需重做覆盖**,所以能不做就别做。
|
|
130
|
+
|
|
131
|
+
【源码已修】坑 4 的自动重绑在 `core/launch_phases/post_phase.py:242` 的
|
|
132
|
+
`_reconcile_additive_plan_drift()`,判据在
|
|
133
|
+
`core/supervisor/finding_workflow.py`:哪些单元的旧证据还能沿用,看**本轮重扫
|
|
134
|
+
结果** `inventory-diff.json`——`changed`/`removed`/`renamed` 列出的单元作废重验,
|
|
135
|
+
其余沿用覆盖结论;没有这份文件就退回严格模式,全部重新覆盖。
|
|
136
|
+
|
|
137
|
+
为什么不能只看指纹:指纹只含「单元 ID + git HEAD」,**不含源码字节**,而 post 是
|
|
138
|
+
修复模式、改动的源码此刻尚未提交。也不能拿「清单 sha256 == 当前文件哈希」当证据:
|
|
139
|
+
`module_coverage` 门禁本轮会用新字节重写清单里的 sha256,那是自证循环。
|
|
140
|
+
|
|
141
|
+
### 坑 5:大响应体打爆上下文
|
|
142
|
+
|
|
143
|
+
**症状**:`confirm_finding` / `verify_finding` / `next_round` 返回 17-25 万字符,
|
|
144
|
+
宿主工具层直接拒绝并落盘。注意这是**宿主侧**行为——引擎自身没有响应体上限
|
|
145
|
+
(MCP 层只限制请求 512 KiB/行,并截断 `history`/`findings` 等长列表)。
|
|
146
|
+
|
|
147
|
+
**绕行**(立即采用):
|
|
148
|
+
```bash
|
|
149
|
+
# CLI rpc 绕过宿主 framing,输出可控
|
|
150
|
+
bugx supervisor rpc --root . --role worker --tool bugx_supervisor_status --args '{}'
|
|
151
|
+
```
|
|
152
|
+
或直接读权威状态(`open()` 不做通配符展开,必须自己 glob):
|
|
153
|
+
```bash
|
|
154
|
+
python3 -c "
|
|
155
|
+
import json, pathlib
|
|
156
|
+
d = json.load(open(next(pathlib.Path('.bugx/pollings').glob('*/lifecycles/*/state/supervisor.json'))))
|
|
157
|
+
print(d['revision'], d['status'], d['confirmation_gate']['ready'])"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**别做的**:每次 confirm 后读一遍 200KB 响应。永远读 `supervisor.json`。
|
|
161
|
+
|
|
162
|
+
### 坑 6:worker MCP 断线 → 走 CLI rpc 回退
|
|
163
|
+
|
|
164
|
+
**症状**:`bugx-supervisor-worker` server disconnected,`bugx_supervisor_claim` 不可用。
|
|
165
|
+
|
|
166
|
+
**回退通道**(实测完全等价):
|
|
167
|
+
```bash
|
|
168
|
+
bugx supervisor rpc --root . --role worker --tool bugx_supervisor_claim \
|
|
169
|
+
--args '{"caller_role":"worker","worker_id":"w1","worker_role":"recon","unit_ids":["内部:1:main.py"],"lease_seconds":900}'
|
|
170
|
+
```
|
|
171
|
+
顺序:`claim` → `worker_start` → `run_sandboxed_probe` → `checkpoint`。
|
|
172
|
+
`run_sandboxed_probe` 必须原样带 claim 返回的 `lease_id` + `execution_id`。
|
|
173
|
+
|
|
174
|
+
**注意**:`--role host` 拿不到主控租约(fail-closed,非缺陷),host 写操作走宿主 MCP。
|
|
175
|
+
|
|
176
|
+
### 坑 7:cycle-review 字段格式
|
|
177
|
+
|
|
178
|
+
`bugx lesson review --input <json>` 必填:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"lifecycle_id": "life-1",
|
|
183
|
+
"round": 1,
|
|
184
|
+
"finding_count": 9,
|
|
185
|
+
"credited_count": 9,
|
|
186
|
+
"finding_fingerprints": ["<与 credited_count 等长且唯一>"],
|
|
187
|
+
"new_patterns": [{
|
|
188
|
+
"category": "...", "title": "...", "root_cause": "...",
|
|
189
|
+
"reflection": "...", "probes": ["..."], "source_refs": ["src/x.py:3"]
|
|
190
|
+
}]
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
两条硬约束(都是撞出来的):
|
|
195
|
+
1. **`pattern_id` 建议一律省略** —— 省略时引擎派生
|
|
196
|
+
`L-<sha256(category\0title\0root_cause)[:12]>`。若手写,必须是
|
|
197
|
+
`^L-[0-9a-f]{12}$`,否则报 `pattern_id 格式无效`;手写的不规则 ID
|
|
198
|
+
不会与既有 pattern 自动去重(`core/ledger/patterns.py:144-147`)。
|
|
199
|
+
2. `title` 非空,`finding_fingerprints` 数量必须等于 `credited_count`
|
|
200
|
+
|
|
201
|
+
输入文件必须落在项目根内(`/tmp` 会被拒)。
|
|
202
|
+
|
|
203
|
+
### 坑 8:探针自包含
|
|
204
|
+
|
|
205
|
+
探针里不要依赖 cwd / 环境变量 / shell:
|
|
206
|
+
```python
|
|
207
|
+
import os, sys
|
|
208
|
+
_root = os.path.dirname(os.path.abspath(__file__))
|
|
209
|
+
while not os.path.isdir(os.path.join(_root, "src")):
|
|
210
|
+
_root = os.path.dirname(_root)
|
|
211
|
+
sys.path.insert(0, _root)
|
|
212
|
+
```
|
|
213
|
+
`run_sandboxed_probe` 只接受 argv 数组,**拒绝 `bash`**。
|
|
214
|
+
另外探针失败常来自:用 `$p` 变量但 shell 未展开、`cd /tmp` 破坏相对路径。
|
|
215
|
+
|
|
216
|
+
### 坑 9:覆盖率是怎么锁死的
|
|
217
|
+
|
|
218
|
+
- `covered` 是**单调**的,但 worker 自己写 `upgrade_tier=deep` 的 note 会被引擎映射成 `stale`
|
|
219
|
+
- stale 单元若仍被本轮 active/submitted claim 占用则领不到;跑 `next-round`
|
|
220
|
+
释放占用后可重新 claim,或用 `post` 结算本轮
|
|
221
|
+
- **内部单元 100% 之前领不到业务 unit**(`内部单元未完成前不能领取业务 unit`)
|
|
222
|
+
|
|
223
|
+
### 坑 10:`post --dry-run` 的 identity 门禁
|
|
224
|
+
|
|
225
|
+
`runtime.json` 的 `round` 与 `supervisor.json` 的 `round_no` 必须一致。
|
|
226
|
+
更了 round 之后没重跑 `pre`,就会看到 `supervisor_round_mismatch`。
|
|
227
|
+
先 `bugx engine --root . status --json` 对齐,再 dry-run。
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## 三、Claude Code 专属提速纪律
|
|
232
|
+
|
|
233
|
+
1. **先读文档再 claim**(见第〇节)。报错信息是结论不是解释,别靠试错反推。
|
|
234
|
+
2. **门禁报错先读源码**。`~/.bugx/core/ledger/finding_confirmation.py` 的
|
|
235
|
+
`confirmation_issues()` 就是证据通道的唯一真源,60 行,比跑一轮便宜。
|
|
236
|
+
3. **全程一次 commit**。审计期间把修复留在工作区,`post` 通过后再提交。
|
|
237
|
+
4. **大响应走 `supervisor rpc`**,状态读 `supervisor.json`。
|
|
238
|
+
5. **探针先写对形态,再谈内容**。argv、自包含路径、正例打印失败标记。
|
|
239
|
+
6. **别用 `Task` 派 worker 之外的探索**。BugX 的 claim 与 Task 不是一回事;
|
|
240
|
+
派 Task 之前必须先有 claim 返回的 lease。
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 四、Finding 确认协议与 reproduction 契约(缺这节,finding 会永久卡在 pending)
|
|
245
|
+
|
|
246
|
+
L7-6 引擎自检要求**每个宿主 skill 都必须写明** `confirmation` 与 `reproduction`
|
|
247
|
+
契约——不是形式要求:这两个字段不齐,`finding_confirmation.py` 的 `confirmation_issues()`
|
|
248
|
+
会拒绝把候选晋级为 confirmed,整轮结算卡死。
|
|
249
|
+
|
|
250
|
+
### 4.1 finding 必备结构
|
|
251
|
+
|
|
252
|
+
```jsonc
|
|
253
|
+
{
|
|
254
|
+
"id": "...", "fingerprint": "...", "title": "...", "severity": "...",
|
|
255
|
+
"confidence": "...", "root_cause": "...", "path": "...", "line": 0,
|
|
256
|
+
"reproducible": true,
|
|
257
|
+
"reproduction": "<最小复现步骤,可多行>", // ← 必须非空
|
|
258
|
+
"confirmation": { // ← 必须齐备,见 4.2
|
|
259
|
+
"state": "reproduced",
|
|
260
|
+
"oracle": { "...": "..." }
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### 4.2 confirmation 块的硬条件(`bugx.md:1101-1106`)
|
|
266
|
+
|
|
267
|
+
1. `state: "reproduced"`;
|
|
268
|
+
2. `oracle.tier` 非 heuristic(`differential` / runtime-invariant 等);
|
|
269
|
+
3. oracle 的 `provenance.independent_from_change: true`(证明不依赖待修代码);
|
|
270
|
+
4. 负对照通过(同一配方在干净基线上不触发);
|
|
271
|
+
5. 根因已验证(非"症状描述");
|
|
272
|
+
6. `reproduction` 可被第三方独立执行。
|
|
273
|
+
|
|
274
|
+
### 4.3 两个独立证据通道(与第二节坑 1 同源)
|
|
275
|
+
|
|
276
|
+
引擎从 verification receipt 派生 `engine-verify:exit-code`(恒有)与
|
|
277
|
+
`engine-verify:stdout|stderr`(仅摘要非空时)。所以:
|
|
278
|
+
|
|
279
|
+
- 正例复现脚本 **必须打印非空失败观测**再 `sys.exit(1)`;
|
|
280
|
+
- 负对照安静 `exit 0` 即可;
|
|
281
|
+
- 只 silent `sys.exit(1)` ⇒ 单通道 ⇒ 门禁拒绝(错在第 1 条件之外,报错文案是
|
|
282
|
+
"缺两个独立证据通道")。
|
|
283
|
+
|
|
284
|
+
### 4.4 落地顺序(照做即可)
|
|
285
|
+
|
|
286
|
+
1. 写复现脚本 → 实跑,确认 exit code 与输出;
|
|
287
|
+
2. `confirm_finding`(host)写入 confirmation 块;
|
|
288
|
+
3. `verify_finding`(host)做修复后复验:`status` 应从 `CONFIRMED` 翻转为
|
|
289
|
+
`CANDIDATE`(缺陷不再复现);
|
|
290
|
+
4. 写回 lifecycle `findings.json` → `post` 自动结算。
|
|
291
|
+
|
|
292
|
+
> 不要手改 `findings.json` 里的 `reproduction` 为单行再 post;直接走
|
|
293
|
+
> `confirm_finding` / `verify_finding`,引擎自己落盘。
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## 五、验收基线(做对了应该看到什么)
|
|
298
|
+
|
|
299
|
+
```text
|
|
300
|
+
confirmation_gate:
|
|
301
|
+
ready: true
|
|
302
|
+
confirmed: N # = findings 数
|
|
303
|
+
pending: 0
|
|
304
|
+
assurance.average_score: 110 # 画像满分;缺 observation_artifacts 加分时 100
|
|
305
|
+
|
|
306
|
+
coverage:
|
|
307
|
+
covered: 全部
|
|
308
|
+
stale/pending: 0
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
修复后同配方复验:`status` 从 `CONFIRMED` 翻转为 `CANDIDATE`(缺陷不再复现),
|
|
312
|
+
而负对照仍 `exit 0` —— 这就是 Live 复验通过的判据。
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## 六、常见门禁报错速查
|
|
317
|
+
|
|
318
|
+
| 报错 | 真正含义 | 下一步 |
|
|
319
|
+
|---|---|---|
|
|
320
|
+
| 缺两个独立证据通道 | 正例没打印失败观测 | 正例加 `print("DEFECT REPRODUCED: ...")` |
|
|
321
|
+
| 每个 Worker 只能领取一个 coverage unit | claim 粒度 | 一个 unit 一次 claim |
|
|
322
|
+
| process_pid 不存活 | 传了 PID | 省略 `process_pid` |
|
|
323
|
+
| 审计目标已变化 | git HEAD/manifest 变了 | `rebind_target`(代价:全单元 stale) |
|
|
324
|
+
| 仍有 active worker | claim 未释放 | `next_round` 或等租约过期 |
|
|
325
|
+
| 覆盖清单无效 | 行结构坏了 | `module_coverage.py check` 定位 |
|
|
326
|
+
| Finding 确认门禁未通过 | gate 未 ready | 读 `confirmation_gate.findings[].issues` |
|