@codexstar/bug-hunter 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +151 -0
- package/LICENSE +21 -0
- package/README.md +665 -0
- package/SKILL.md +624 -0
- package/bin/bug-hunter +222 -0
- package/evals/evals.json +362 -0
- package/modes/_dispatch.md +121 -0
- package/modes/extended.md +94 -0
- package/modes/fix-loop.md +115 -0
- package/modes/fix-pipeline.md +384 -0
- package/modes/large-codebase.md +212 -0
- package/modes/local-sequential.md +143 -0
- package/modes/loop.md +125 -0
- package/modes/parallel.md +113 -0
- package/modes/scaled.md +76 -0
- package/modes/single-file.md +38 -0
- package/modes/small.md +86 -0
- package/package.json +56 -0
- package/prompts/doc-lookup.md +44 -0
- package/prompts/examples/hunter-examples.md +131 -0
- package/prompts/examples/skeptic-examples.md +87 -0
- package/prompts/fixer.md +103 -0
- package/prompts/hunter.md +146 -0
- package/prompts/recon.md +159 -0
- package/prompts/referee.md +122 -0
- package/prompts/skeptic.md +143 -0
- package/prompts/threat-model.md +122 -0
- package/scripts/bug-hunter-state.cjs +537 -0
- package/scripts/code-index.cjs +541 -0
- package/scripts/context7-api.cjs +133 -0
- package/scripts/delta-mode.cjs +219 -0
- package/scripts/dep-scan.cjs +343 -0
- package/scripts/doc-lookup.cjs +316 -0
- package/scripts/fix-lock.cjs +167 -0
- package/scripts/init-test-fixture.sh +19 -0
- package/scripts/payload-guard.cjs +197 -0
- package/scripts/run-bug-hunter.cjs +892 -0
- package/scripts/tests/bug-hunter-state.test.cjs +87 -0
- package/scripts/tests/code-index.test.cjs +57 -0
- package/scripts/tests/delta-mode.test.cjs +47 -0
- package/scripts/tests/fix-lock.test.cjs +36 -0
- package/scripts/tests/fixtures/flaky-worker.cjs +63 -0
- package/scripts/tests/fixtures/low-confidence-worker.cjs +73 -0
- package/scripts/tests/fixtures/success-worker.cjs +42 -0
- package/scripts/tests/payload-guard.test.cjs +41 -0
- package/scripts/tests/run-bug-hunter.test.cjs +403 -0
- package/scripts/tests/test-utils.cjs +59 -0
- package/scripts/tests/worktree-harvest.test.cjs +297 -0
- package/scripts/triage.cjs +528 -0
- package/scripts/worktree-harvest.cjs +516 -0
- package/templates/subagent-wrapper.md +109 -0
package/SKILL.md
ADDED
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bug-hunter
|
|
3
|
+
description: "Adversarial bug hunting with a sequential-first pipeline (Recon, Hunter, Skeptic, Referee) that can optionally use safe read-only parallel triage. Finds, verifies, and auto-fixes real bugs by default (with --scan-only opt-out) using checkpointed verification and resume state for large codebases. Use this skill whenever the user wants bug finding, security audits, regression checks, or code review focused on runtime behavior."
|
|
4
|
+
argument-hint: "[path | -b <branch> [--base <base-branch>] | --staged | --scan-only | --fix | --autonomous | --no-loop | --approve | --deps | --threat-model | --dry-run]"
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Bug Hunt - Adversarial Bug Finding
|
|
9
|
+
|
|
10
|
+
Run a sequential-first adversarial bug hunt on your codebase. Use parallelism only for read-only triage and independent verification tasks.
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [Target](#target)
|
|
15
|
+
- [Context Budget](#context-budget)
|
|
16
|
+
- [Execution Steps](#execution-steps)
|
|
17
|
+
- [Step 7: Present the Final Report](#step-7-present-the-final-report)
|
|
18
|
+
- [Self-Test Mode](#self-test-mode)
|
|
19
|
+
- [Error handling](#error-handling)
|
|
20
|
+
|
|
21
|
+
**Phase 1 — Find & Verify:**
|
|
22
|
+
```
|
|
23
|
+
Recon (map) --> Hunter (deep scan) --> Skeptic (challenge) --> Referee (final verdict)
|
|
24
|
+
^ (optional read-only dual-lens triage can run here)
|
|
25
|
+
|
|
|
26
|
+
state + chunk checkpoints
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Phase 2 — Fix & Verify (default when bugs are confirmed):**
|
|
30
|
+
```
|
|
31
|
+
Baseline --> Git branch --> sequential Fixer (single writer) --> targeted verify --> full verify --> report
|
|
32
|
+
^ |
|
|
33
|
+
+------------------------ checkpoint commits + auto-revert -----+
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For small scans (1-10 source files): runs single Hunter + single Skeptic (no parallelism overhead).
|
|
37
|
+
For large scans: process chunks sequentially with persistent state to avoid compaction drift.
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
/bug-hunter # Scan entire project
|
|
43
|
+
/bug-hunter src/ # Scan specific directory
|
|
44
|
+
/bug-hunter lib/auth.ts # Scan specific file
|
|
45
|
+
/bug-hunter -b feature-xyz # Scan files changed in feature-xyz vs main
|
|
46
|
+
/bug-hunter -b feature-xyz --base dev # Scan files changed in feature-xyz vs dev
|
|
47
|
+
/bug-hunter --staged # Scan staged files (pre-commit check)
|
|
48
|
+
/bug-hunter --scan-only src/ # Scan only, no code changes
|
|
49
|
+
/bug-hunter --fix src/ # Find bugs AND auto-fix them
|
|
50
|
+
/bug-hunter --autonomous src/ # Alias for no-intervention auto-fix run
|
|
51
|
+
/bug-hunter --fix -b feature-xyz # Find + fix on branch diff
|
|
52
|
+
/bug-hunter --fix --approve src/ # Find + fix, but ask before each fix
|
|
53
|
+
/bug-hunter src/ # Loops by default: audit until 100% coverage
|
|
54
|
+
/bug-hunter --no-loop src/ # Single-pass only, no iterating
|
|
55
|
+
/bug-hunter --no-loop --scan-only src/ # Single-pass scan, no fixes, no loop
|
|
56
|
+
/bug-hunter --deps src/ # Include dependency CVE scan
|
|
57
|
+
/bug-hunter --threat-model src/ # Generate/use STRIDE threat model
|
|
58
|
+
/bug-hunter --deps --threat-model src/ # Full security audit
|
|
59
|
+
/bug-hunter --fix --dry-run src/ # Preview fixes without editing files
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Target
|
|
63
|
+
|
|
64
|
+
The raw arguments are: $ARGUMENTS
|
|
65
|
+
|
|
66
|
+
**Parse the arguments as follows:**
|
|
67
|
+
|
|
68
|
+
0. Default `LOOP_MODE=true`. If arguments contain `--no-loop`: strip it from the arguments and set `LOOP_MODE=false`. The `--loop` flag is accepted for backwards compatibility but is a no-op (loop is already the default).
|
|
69
|
+
|
|
70
|
+
0b. Default `FIX_MODE=true`.
|
|
71
|
+
0c. If arguments contain `--scan-only`: strip it from the arguments and set `FIX_MODE=false`.
|
|
72
|
+
0d. If arguments contain `--fix`: strip it from the arguments and set `FIX_MODE=true`. The remaining arguments are parsed normally below.
|
|
73
|
+
0e. If arguments contain `--autonomous`: strip it from the arguments, set `AUTONOMOUS_MODE=true`, and force `FIX_MODE=true` (canary-first + confidence-gated).
|
|
74
|
+
0f. If arguments contain `--approve`: strip it from the arguments and set `APPROVE_MODE=true`. When this flag is set, Fixer agents run in `mode: "default"` (user reviews and approves each edit). When not set, `APPROVE_MODE=false` and Fixers run autonomously.
|
|
75
|
+
0g. If arguments contain `--deps`: strip it and set `DEP_SCAN=true`. Dependency scanning runs package manager audit tools and checks if vulnerable APIs are actually called in the codebase.
|
|
76
|
+
0h. If arguments contain `--threat-model`: strip it and set `THREAT_MODEL_MODE=true`. Generates a STRIDE threat model at `.bug-hunter/threat-model.md` if one doesn't exist, then feeds it to Recon + Hunter for targeted security analysis.
|
|
77
|
+
0i. If arguments contain `--dry-run`: strip it and set `DRY_RUN_MODE=true`. Forces `FIX_MODE=true`. In dry-run mode, Phase 2 builds the fix plan and the Fixer reads code and outputs planned changes as unified diff previews, but no file edits, git commits, or lock acquisition occur. Produces `fix-report.json` with `"dry_run": true`.
|
|
78
|
+
|
|
79
|
+
1. If arguments contain `--staged`: this is **staged file mode**.
|
|
80
|
+
- Run `git diff --cached --name-only` using the Bash tool to get the list of staged files.
|
|
81
|
+
- If the command fails, report the error to the user and stop.
|
|
82
|
+
- If no files are staged, tell the user there are no staged changes to scan and stop.
|
|
83
|
+
- The scan target is the list of staged files (scan their full contents, not just the diff).
|
|
84
|
+
|
|
85
|
+
2. If arguments contain `-b <branch>`: this is **branch diff mode**.
|
|
86
|
+
- Extract the branch name after `-b`.
|
|
87
|
+
- If `--base <base-branch>` is also present, use that as the base branch. Otherwise default to `main`.
|
|
88
|
+
- Run `git diff --name-only <base>...<branch>` using the Bash tool to get the list of changed files.
|
|
89
|
+
- If the command fails (e.g. branch not found), report the error to the user and stop.
|
|
90
|
+
- If no files changed, tell the user there are no changes to scan and stop.
|
|
91
|
+
- The scan target is the list of changed files (scan their full contents, not just the diff).
|
|
92
|
+
|
|
93
|
+
3. If arguments do NOT contain `-b` or `--staged`: treat the entire argument string as a **path target** (file or directory). If empty, scan the current working directory.
|
|
94
|
+
|
|
95
|
+
**After resolving the file list (for modes 1 and 2), filter out non-source files:**
|
|
96
|
+
|
|
97
|
+
Remove any files matching these patterns — they are not scannable source code:
|
|
98
|
+
- Docs/text: `*.md`, `*.txt`, `*.rst`, `*.adoc`
|
|
99
|
+
- Config: `*.json`, `*.yaml`, `*.yml`, `*.toml`, `*.ini`, `*.cfg`, `.env*`, `.gitignore`, `.editorconfig`, `.prettierrc*`, `.eslintrc*`, `tsconfig.json`, `jest.config.*`, `vitest.config.*`, `webpack.config.*`, `vite.config.*`, `next.config.*`, `tailwind.config.*`
|
|
100
|
+
- Lockfiles: `*.lock`, `*.sum`
|
|
101
|
+
- Minified/maps: `*.min.js`, `*.min.css`, `*.map`
|
|
102
|
+
- Assets: `*.svg`, `*.png`, `*.jpg`, `*.gif`, `*.ico`, `*.woff*`, `*.ttf`, `*.eot`
|
|
103
|
+
- Project meta: `LICENSE`, `CHANGELOG*`, `CONTRIBUTING*`, `CODE_OF_CONDUCT*`, `Makefile`, `Dockerfile`, `docker-compose*`, `Procfile`
|
|
104
|
+
- Vendor dirs: `node_modules/`, `vendor/`, `dist/`, `build/`, `.next/`, `__pycache__/`, `.venv/`
|
|
105
|
+
|
|
106
|
+
If after filtering there are zero source files left, tell the user: "No scannable source files found — only config/docs/assets were changed." and stop.
|
|
107
|
+
|
|
108
|
+
## Context Budget
|
|
109
|
+
|
|
110
|
+
**FILE_BUDGET is computed by the triage script (Step 1), not by Recon.** The triage script samples 30 files from the codebase, computes average line count, and derives:
|
|
111
|
+
```
|
|
112
|
+
avg_tokens_per_file = average_lines_per_file * 4
|
|
113
|
+
FILE_BUDGET = floor(150000 / avg_tokens_per_file) # capped at 60, floored at 10
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Triage also determines the strategy directly, so Step 3 just reads the triage output — no circular dependency.
|
|
117
|
+
|
|
118
|
+
Then determine partitioning:
|
|
119
|
+
|
|
120
|
+
| Total source files | Strategy | Hunters | Skeptics |
|
|
121
|
+
|--------------------|----------|---------|----------|
|
|
122
|
+
| 1 | Single-file mode | 1 general | 1 |
|
|
123
|
+
| 2-10 | Small mode | 1 general | 1 |
|
|
124
|
+
| 11 to FILE_BUDGET | Parallel mode (hybrid) | 1 deep Hunter (+ optional 2 read-only triage Hunters) | 1-2 by directory |
|
|
125
|
+
| FILE_BUDGET+1 to FILE_BUDGET*2 | Extended mode | Sequential chunked Hunters | 1-2 by directory |
|
|
126
|
+
| FILE_BUDGET*2+1 to FILE_BUDGET*3 | Scaled mode | Sequential chunked Hunters with resume state | 1-2 by directory |
|
|
127
|
+
| > FILE_BUDGET*3 | Large-codebase mode + Loop | Domain-scoped pipelines + boundary audits | Per-domain 1-2 |
|
|
128
|
+
|
|
129
|
+
If triage was not run (e.g., Recon was called directly without the orchestrator), use the default FILE_BUDGET of 40.
|
|
130
|
+
|
|
131
|
+
**File partitioning rules (Extended/Scaled modes):**
|
|
132
|
+
- **Service-aware partitioning (preferred)**: If Recon detected multiple service boundaries (monorepo), partition by service.
|
|
133
|
+
- **Risk-tier partitioning (fallback)**: process CRITICAL then HIGH then MEDIUM.
|
|
134
|
+
- Keep chunk size small (recommended 20-40 files) to avoid context compaction issues.
|
|
135
|
+
- Persist chunk progress in `.bug-hunter/state.json` so restarts do not re-scan done chunks.
|
|
136
|
+
- Test files (CONTEXT-ONLY) are included only when needed for intent.
|
|
137
|
+
|
|
138
|
+
If the triage output shows `needsLoop: true` and `LOOP_MODE=false` (user passed `--no-loop`), warn the user: "This codebase has [N] source files (FILE_BUDGET: [B]). Single-pass mode will only cover a subset. Loop mode is recommended for thorough coverage (remove `--no-loop` to enable). Large codebases use domain-scoped auditing — see `modes/large-codebase.md`."
|
|
139
|
+
|
|
140
|
+
## Execution Steps
|
|
141
|
+
|
|
142
|
+
### Step 0: Preflight checks
|
|
143
|
+
|
|
144
|
+
Before doing anything else, verify the environment:
|
|
145
|
+
|
|
146
|
+
1. **Resolve skill directory**: Determine `SKILL_DIR` dynamically.
|
|
147
|
+
- Preferred: derive it from the absolute path of the current `SKILL.md` (`dirname` of this file).
|
|
148
|
+
- Fallback probe order: `$HOME/.agents/skills/bug-hunter`, `$HOME/.claude/skills/bug-hunter`, `$HOME/.codex/skills/bug-hunter`.
|
|
149
|
+
- Use this path for ALL Read tool calls and shell commands.
|
|
150
|
+
|
|
151
|
+
2. **Verify skill files exist**: Run `ls "$SKILL_DIR/prompts/hunter.md"` via Bash. If this fails, stop and tell the user: "Bug Hunter skill files not found. Reinstall the skill and retry."
|
|
152
|
+
|
|
153
|
+
3. **Node.js available**: Run `node --version` via Bash. If it fails, stop and tell the user: "Node.js is required for doc verification. Please install Node.js to continue."
|
|
154
|
+
|
|
155
|
+
3b. **Create output directory**:
|
|
156
|
+
```bash
|
|
157
|
+
mkdir -p .bug-hunter/payloads .bug-hunter/domains
|
|
158
|
+
```
|
|
159
|
+
This directory stores all pipeline artifacts. Add `.bug-hunter/` to your project's `.gitignore`.
|
|
160
|
+
|
|
161
|
+
4. **Doc lookup availability (optional, non-blocking)**: Run a quick smoke test:
|
|
162
|
+
```
|
|
163
|
+
node "$SKILL_DIR/scripts/doc-lookup.cjs" search "express" "middleware"
|
|
164
|
+
```
|
|
165
|
+
- If it returns results, set `DOC_LOOKUP_AVAILABLE=true`.
|
|
166
|
+
- If it fails, try the fallback: `node "$SKILL_DIR/scripts/context7-api.cjs" search "express" "middleware"`
|
|
167
|
+
- If both fail, warn the user and set `DOC_LOOKUP_AVAILABLE=false`.
|
|
168
|
+
- Missing `CONTEXT7_API_KEY` must NOT block execution; anonymous lookups may still work.
|
|
169
|
+
|
|
170
|
+
5. **Verify helper scripts exist**:
|
|
171
|
+
```
|
|
172
|
+
ls "$SKILL_DIR/scripts/run-bug-hunter.cjs" "$SKILL_DIR/scripts/bug-hunter-state.cjs" "$SKILL_DIR/scripts/delta-mode.cjs" "$SKILL_DIR/scripts/payload-guard.cjs" "$SKILL_DIR/scripts/fix-lock.cjs" "$SKILL_DIR/scripts/triage.cjs" "$SKILL_DIR/scripts/doc-lookup.cjs"
|
|
173
|
+
```
|
|
174
|
+
If any are missing, stop and tell the user to update/reinstall the skill.
|
|
175
|
+
Note: `code-index.cjs` is optional — enables cross-domain dependency analysis for boundary audits in large-codebase mode, but the pipeline works fully without it.
|
|
176
|
+
Note: `context7-api.cjs` is kept as a fallback — `doc-lookup.cjs` is the primary doc verification script.
|
|
177
|
+
Note: `worktree-harvest.cjs` is optional — enables worktree-isolated Fixer dispatch for `subagent`/`teams` backends. Without it, Fixers edit directly on the fix branch (still safe via single-writer lock + auto-revert).
|
|
178
|
+
|
|
179
|
+
5b. **Check Context Hub CLI (recommended, non-blocking)**:
|
|
180
|
+
```bash
|
|
181
|
+
chub --help 2>/dev/null && chub update 2>/dev/null
|
|
182
|
+
```
|
|
183
|
+
- If `chub` is available, set `CHUB_AVAILABLE=true`. Report: `✓ Context Hub available — using curated docs for verification.`
|
|
184
|
+
- If `chub` is NOT installed, set `CHUB_AVAILABLE=false`. **Warn the user visibly:**
|
|
185
|
+
```
|
|
186
|
+
⚠️ Context Hub (chub) is not installed. Doc verification will fall back to Context7 API,
|
|
187
|
+
which has broader coverage but less curated results.
|
|
188
|
+
|
|
189
|
+
For better doc verification accuracy, install Context Hub:
|
|
190
|
+
npm install -g @aisuite/chub
|
|
191
|
+
|
|
192
|
+
More info: https://github.com/andrewyng/context-hub
|
|
193
|
+
```
|
|
194
|
+
- Do NOT block the pipeline — Context7 fallback works, just with less curated results.
|
|
195
|
+
|
|
196
|
+
6. **Select orchestration backend (cross-CLI portability)**:
|
|
197
|
+
|
|
198
|
+
Detect which dispatch tools are available in your runtime. Use the FIRST that works:
|
|
199
|
+
|
|
200
|
+
**Option A — `subagent` tool (Pi agent, preferred for parallel):**
|
|
201
|
+
- Test: call `subagent({ action: "list" })`. If it returns without error, this backend works.
|
|
202
|
+
- Set `AGENT_BACKEND = "subagent"`
|
|
203
|
+
- Dispatch pattern for each phase:
|
|
204
|
+
```
|
|
205
|
+
subagent({
|
|
206
|
+
agent: "<role>-agent",
|
|
207
|
+
task: "<filled subagent-wrapper template with prompt content + assignment>",
|
|
208
|
+
output: ".bug-hunter/<phase>-output.md"
|
|
209
|
+
})
|
|
210
|
+
```
|
|
211
|
+
- Read the output file after the subagent completes.
|
|
212
|
+
|
|
213
|
+
**Option B — `teams` tool (Pi agent teams):**
|
|
214
|
+
- Test: does the `teams` tool exist in your available tools?
|
|
215
|
+
- Set `AGENT_BACKEND = "teams"`
|
|
216
|
+
- Dispatch pattern:
|
|
217
|
+
```
|
|
218
|
+
teams({
|
|
219
|
+
tasks: [{ text: "<filled subagent-wrapper template>" }],
|
|
220
|
+
maxTeammates: 1
|
|
221
|
+
})
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Option C — `interactive_shell` (Claude Code, Codex, other CLI agents):**
|
|
225
|
+
- Set `AGENT_BACKEND = "interactive_shell"`
|
|
226
|
+
- Dispatch pattern:
|
|
227
|
+
```
|
|
228
|
+
interactive_shell({
|
|
229
|
+
command: 'pi "<task prompt>"',
|
|
230
|
+
mode: "dispatch"
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Option D — `local-sequential` (default — always works):**
|
|
235
|
+
- Set `AGENT_BACKEND = "local-sequential"`
|
|
236
|
+
- Read `SKILL_DIR/modes/local-sequential.md` for full instructions.
|
|
237
|
+
- You run all phases (Recon, Hunter, Skeptic, Referee) yourself,
|
|
238
|
+
sequentially, within your own context window.
|
|
239
|
+
- Write phase outputs to `.bug-hunter/` files between phases.
|
|
240
|
+
|
|
241
|
+
**IMPORTANT**: `local-sequential` is NOT a degraded mode. It is the expected
|
|
242
|
+
default for most environments and the skill works fully in this mode. Subagent
|
|
243
|
+
dispatch is an optimization for large codebases, not a requirement.
|
|
244
|
+
|
|
245
|
+
Rules:
|
|
246
|
+
- Use exactly ONE backend for the whole run.
|
|
247
|
+
- If a remote backend launch fails, fall back to the next option.
|
|
248
|
+
- If all remote backends fail, use `local-sequential` and continue.
|
|
249
|
+
|
|
250
|
+
### Step 1: Parse arguments, resolve target, and run triage
|
|
251
|
+
|
|
252
|
+
Follow the rules in the **Target** section above. If in branch diff or staged mode, run the appropriate git command now, collect the file list, and apply the filter.
|
|
253
|
+
|
|
254
|
+
Report to the user:
|
|
255
|
+
- Mode (full project / directory / file / branch diff / staged)
|
|
256
|
+
- Number of source files to scan (after filtering)
|
|
257
|
+
- Number of files filtered out
|
|
258
|
+
|
|
259
|
+
**Then run triage (zero-token strategy decision):**
|
|
260
|
+
|
|
261
|
+
Run the triage script AFTER resolving the target. This is a pure Node.js filesystem scan — no tokens consumed, runs in <2 seconds even on 2,000+ file repos.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
node "$SKILL_DIR/scripts/triage.cjs" scan "<TARGET_PATH>" --output .bug-hunter/triage.json
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Then read `.bug-hunter/triage.json`. It contains:
|
|
268
|
+
- `strategy`: which mode to use ("single-file", "small", "parallel", "extended", "scaled", "large-codebase")
|
|
269
|
+
- `modeFile`: which mode file to read
|
|
270
|
+
- `fileBudget`: computed from actual file sizes (sampled), not a guess
|
|
271
|
+
- `totalFiles` / `scannableFiles`: exact count
|
|
272
|
+
- `domains`: directory-level risk classification (CRITICAL/HIGH/MEDIUM/LOW/CONTEXT-ONLY)
|
|
273
|
+
- `riskMap`: file-level classification (only present when ≤200 files)
|
|
274
|
+
- `domainFileLists`: per-domain file lists (only present for large-codebase strategy)
|
|
275
|
+
- `scanOrder`: priority-ordered list for Hunters
|
|
276
|
+
- `tokenEstimate`: cost estimates for each pipeline phase
|
|
277
|
+
- `needsLoop`: whether loop mode is needed for full coverage (loop is on by default; this indicates `--no-loop` would cause incomplete coverage)
|
|
278
|
+
|
|
279
|
+
**Set these variables from the triage output:**
|
|
280
|
+
```
|
|
281
|
+
STRATEGY = triage.strategy
|
|
282
|
+
FILE_BUDGET = triage.fileBudget
|
|
283
|
+
TOTAL_FILES = triage.totalFiles
|
|
284
|
+
SCANNABLE_FILES = triage.scannableFiles
|
|
285
|
+
NEEDS_LOOP = triage.needsLoop
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Report to the user:**
|
|
289
|
+
```
|
|
290
|
+
Triage: [TOTAL_FILES] source files | FILE_BUDGET: [FILE_BUDGET] | Strategy: [STRATEGY]
|
|
291
|
+
Domains: [N] CRITICAL, [N] HIGH, [N] MEDIUM, [N] LOW
|
|
292
|
+
Token estimate: ~[N] tokens for full pipeline
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**If triage says `needsLoop: true` and `LOOP_MODE=false`** (user passed `--no-loop`), warn:
|
|
296
|
+
```
|
|
297
|
+
⚠️ This codebase has [N] source files (FILE_BUDGET: [B]).
|
|
298
|
+
Single-pass mode will only cover a subset. Remove `--no-loop` to enable iterative coverage.
|
|
299
|
+
Proceeding with partial scan — CRITICAL and HIGH domains only.
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**Triage replaces Recon's FILE_BUDGET computation.** Recon still runs for tech stack identification and pattern-based analysis, but it no longer needs to count files or compute the context budget — triage already did that, for free.
|
|
303
|
+
|
|
304
|
+
### Step 1b: Generate threat model (if --threat-model)
|
|
305
|
+
|
|
306
|
+
If `THREAT_MODEL_MODE=true`:
|
|
307
|
+
1. Check if `.bug-hunter/threat-model.md` already exists.
|
|
308
|
+
- If it exists and was modified within the last 90 days: use it as-is. Set `THREAT_MODEL_AVAILABLE=true`.
|
|
309
|
+
- If it exists but is >90 days old: warn user ("Threat model is N days old — regenerating"), regenerate.
|
|
310
|
+
- If it doesn't exist: generate it.
|
|
311
|
+
2. To generate:
|
|
312
|
+
- Read `$SKILL_DIR/prompts/threat-model.md`.
|
|
313
|
+
- Dispatch the threat model generation agent (or execute locally if local-sequential).
|
|
314
|
+
- Input: triage.json (if available) for file structure, or Glob-based discovery.
|
|
315
|
+
- Wait for `.bug-hunter/threat-model.md` to be written.
|
|
316
|
+
3. Set `THREAT_MODEL_AVAILABLE=true`.
|
|
317
|
+
|
|
318
|
+
If `THREAT_MODEL_MODE=false` but `.bug-hunter/threat-model.md` exists:
|
|
319
|
+
- Load it anyway — free context. Set `THREAT_MODEL_AVAILABLE=true`.
|
|
320
|
+
- Report: "Existing threat model found — loading for enhanced security analysis."
|
|
321
|
+
|
|
322
|
+
### Step 1c: Dependency scan (if --deps)
|
|
323
|
+
|
|
324
|
+
If `DEP_SCAN=true`:
|
|
325
|
+
```bash
|
|
326
|
+
node "$SKILL_DIR/scripts/dep-scan.cjs" --target "<TARGET_PATH>" --output .bug-hunter/dep-findings.json
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Report to user:
|
|
330
|
+
```
|
|
331
|
+
Dependencies: [N] HIGH/CRITICAL CVEs found | [R] reachable, [P] potentially reachable, [U] not reachable
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
If `.bug-hunter/dep-findings.json` exists with REACHABLE findings, include them in Hunter context as "Known Vulnerable Dependencies" — Hunter should verify if vulnerable APIs are called in scanned source files.
|
|
335
|
+
|
|
336
|
+
### Step 2: Read prompt files on demand (context efficiency)
|
|
337
|
+
|
|
338
|
+
**MANDATORY**: You MUST read prompt files using the Read tool before passing them to subagents or executing them yourself. Do NOT skip this or act from memory. Use the absolute SKILL_DIR path resolved in Step 0.
|
|
339
|
+
|
|
340
|
+
**Load only what you need for each phase — do NOT read all files upfront:**
|
|
341
|
+
|
|
342
|
+
| Phase | Read These Files |
|
|
343
|
+
|-------|-----------------|
|
|
344
|
+
| Threat Model (Step 1b) | `prompts/threat-model.md` (only if THREAT_MODEL_MODE=true) |
|
|
345
|
+
| Recon (Step 4) | `prompts/recon.md` (skip for single-file mode) |
|
|
346
|
+
| Hunters (Step 5) | `prompts/hunter.md` + `prompts/doc-lookup.md` + `prompts/examples/hunter-examples.md` |
|
|
347
|
+
| Skeptics (Step 6) | `prompts/skeptic.md` + `prompts/doc-lookup.md` + `prompts/examples/skeptic-examples.md` |
|
|
348
|
+
| Referee (Step 7) | `prompts/referee.md` |
|
|
349
|
+
| Fixers (Phase 2) | `prompts/fixer.md` + `prompts/doc-lookup.md` (only if FIX_MODE=true) |
|
|
350
|
+
|
|
351
|
+
**Concrete examples for each backend:**
|
|
352
|
+
|
|
353
|
+
#### Example A: local-sequential (most common)
|
|
354
|
+
|
|
355
|
+
```
|
|
356
|
+
# Phase B — launching Hunter yourself
|
|
357
|
+
# 1. Read the prompt file:
|
|
358
|
+
read({ path: "$SKILL_DIR/prompts/hunter.md" })
|
|
359
|
+
|
|
360
|
+
# 2. You now have the Hunter's full instructions. Execute them yourself:
|
|
361
|
+
# - Read each file in risk-map order using the Read tool
|
|
362
|
+
# - Apply the security checklist sweep
|
|
363
|
+
# - Write each finding in BUG-N format
|
|
364
|
+
|
|
365
|
+
# 3. Write your findings to disk:
|
|
366
|
+
write({ path: ".bug-hunter/findings.md", content: "<your findings>" })
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
#### Example B: subagent dispatch
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
# Phase B — launching Hunter via subagent
|
|
373
|
+
# 1. Read the prompt:
|
|
374
|
+
read({ path: "$SKILL_DIR/prompts/hunter.md" })
|
|
375
|
+
# 2. Read the wrapper template:
|
|
376
|
+
read({ path: "$SKILL_DIR/templates/subagent-wrapper.md" })
|
|
377
|
+
# 3. Fill the template with:
|
|
378
|
+
# - {ROLE_NAME} = "hunter"
|
|
379
|
+
# - {ROLE_DESCRIPTION} = "Bug Hunter — find behavioral bugs in source code"
|
|
380
|
+
# - {PROMPT_CONTENT} = <full contents of hunter.md>
|
|
381
|
+
# - {TARGET_DESCRIPTION} = "FindCoffee monorepo backend services"
|
|
382
|
+
# - {FILE_LIST} = <files from Recon risk map, CRITICAL first>
|
|
383
|
+
# - {RISK_MAP} = <risk map from .bug-hunter/recon.md>
|
|
384
|
+
# - {TECH_STACK} = <framework, auth, DB from Recon>
|
|
385
|
+
# - {PHASE_SPECIFIC_CONTEXT} = <doc-lookup instructions from doc-lookup.md>
|
|
386
|
+
# - {OUTPUT_FILE_PATH} = ".bug-hunter/findings.md"
|
|
387
|
+
# - {SKILL_DIR} = <absolute path>
|
|
388
|
+
# 4. Dispatch:
|
|
389
|
+
subagent({
|
|
390
|
+
agent: "hunter-agent",
|
|
391
|
+
task: "<the filled template>",
|
|
392
|
+
output: ".bug-hunter/findings.md"
|
|
393
|
+
})
|
|
394
|
+
# 5. Read the output:
|
|
395
|
+
read({ path: ".bug-hunter/findings.md" })
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
When launching subagents, always pass `SKILL_DIR` explicitly in the task context so prompt commands like `node "$SKILL_DIR/scripts/doc-lookup.cjs"` resolve correctly. The `context7-api.cjs` script is kept as a fallback if `doc-lookup.cjs` fails.
|
|
399
|
+
|
|
400
|
+
Before every subagent launch, validate payload shape with:
|
|
401
|
+
```
|
|
402
|
+
node "$SKILL_DIR/scripts/payload-guard.cjs" validate "<role>" "<payload-json-path>"
|
|
403
|
+
```
|
|
404
|
+
If validation fails, do NOT launch the subagent. Fix the payload first.
|
|
405
|
+
|
|
406
|
+
Any mode step that says "launch subagent" means "dispatch an agent task using `AGENT_BACKEND`". For `local-sequential`, "launch" means "execute that phase's instructions yourself."
|
|
407
|
+
|
|
408
|
+
After reading each prompt, extract the key instructions and pass the content to subagents via their system prompts. You do not need to keep the full text in working memory.
|
|
409
|
+
|
|
410
|
+
**Context pruning for subagents:** When passing bug lists to Skeptics, Fixers, or the Referee, only include the bugs assigned to that agent — not the full merged list. For each bug, include: BUG-ID, severity, file, lines, claim, evidence, runtime trigger, cross-references. Omit: the Hunter's internal reasoning, scan coverage stats, and any "FILES SCANNED/SKIPPED" metadata. This keeps subagent prompts lean.
|
|
411
|
+
|
|
412
|
+
### Step 3: Determine execution mode
|
|
413
|
+
|
|
414
|
+
**Use the triage output from Step 1** — the strategy and FILE_BUDGET are already computed. Do NOT wait for Recon to determine the mode.
|
|
415
|
+
|
|
416
|
+
Read the corresponding mode file using `STRATEGY` from the triage JSON:
|
|
417
|
+
- `single-file`: `SKILL_DIR/modes/single-file.md`
|
|
418
|
+
- `small`: `SKILL_DIR/modes/small.md`
|
|
419
|
+
- `parallel`: `SKILL_DIR/modes/parallel.md`
|
|
420
|
+
- `extended`: `SKILL_DIR/modes/extended.md`
|
|
421
|
+
- `scaled`: `SKILL_DIR/modes/scaled.md`
|
|
422
|
+
- `large-codebase`: force `LOOP_MODE=true` and read `SKILL_DIR/modes/large-codebase.md` then `SKILL_DIR/modes/loop.md`
|
|
423
|
+
|
|
424
|
+
**Backend override for local-sequential:** If `AGENT_BACKEND = "local-sequential"`, read `SKILL_DIR/modes/local-sequential.md` instead of the size-based mode file. The local-sequential mode handles all sizes internally with its own chunking logic.
|
|
425
|
+
|
|
426
|
+
If LOOP_MODE=true, also read:
|
|
427
|
+
- `SKILL_DIR/modes/fix-loop.md` when FIX_MODE=true
|
|
428
|
+
- `SKILL_DIR/modes/loop.md` otherwise
|
|
429
|
+
|
|
430
|
+
**CRITICAL — ralph-loop integration:** When `LOOP_MODE=true`, you MUST call the `ralph_start` tool before running the first pipeline iteration. The loop mode files (`loop.md` / `fix-loop.md`) contain the exact `ralph_start` call to make, including the `taskContent` and `maxIterations` parameters. Without calling `ralph_start`, the loop will NOT iterate — it will run once and stop. After each iteration, call `ralph_done` to continue, or output `<promise>COMPLETE</promise>` when done.
|
|
431
|
+
|
|
432
|
+
Report the chosen mode to the user.
|
|
433
|
+
|
|
434
|
+
**Then follow the steps in the loaded mode file.** Each mode file contains the specific steps for running Recon, Hunters, Skeptics, and Referee for that mode. Each mode also references `modes/_dispatch.md` for backend-specific dispatch patterns. Execute them in order.
|
|
435
|
+
|
|
436
|
+
**Branch-diff and staged optimization:** For `-b` and `--staged` modes, if the file count ≤ FILE_BUDGET, always use `small` or `parallel` mode regardless of total codebase size. The triage script already handles this since it only scans the provided target files.
|
|
437
|
+
|
|
438
|
+
For `extended` and `scaled` modes, initialize state before chunk execution:
|
|
439
|
+
```
|
|
440
|
+
node "$SKILL_DIR/scripts/bug-hunter-state.cjs" init ".bug-hunter/state.json" "<mode>" "<files-json-path>" 30
|
|
441
|
+
```
|
|
442
|
+
Then apply hash-based skip filtering before each chunk:
|
|
443
|
+
```
|
|
444
|
+
node "$SKILL_DIR/scripts/bug-hunter-state.cjs" hash-filter ".bug-hunter/state.json" "<chunk-files-json-path>"
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
For full autonomous chunk orchestration with timeouts, retries, and journaling, extended/scaled modes can use:
|
|
448
|
+
```
|
|
449
|
+
node "$SKILL_DIR/scripts/run-bug-hunter.cjs" run --skill-dir "$SKILL_DIR" --files-json "<files-json-path>" --mode "<mode>"
|
|
450
|
+
```
|
|
451
|
+
See `run-bug-hunter.cjs --help` for all options (delta-mode, canary-size, expand-on-low-confidence, etc.).
|
|
452
|
+
|
|
453
|
+
---
|
|
454
|
+
|
|
455
|
+
## Step 7: Present the Final Report
|
|
456
|
+
|
|
457
|
+
After the mode-specific steps complete, display the final report:
|
|
458
|
+
|
|
459
|
+
### 1. Scan metadata
|
|
460
|
+
- Mode (single-file / small / parallel-hybrid / extended / scaled / loop)
|
|
461
|
+
- Files scanned: N source files (N filtered out)
|
|
462
|
+
- Architecture: [summary from Recon]
|
|
463
|
+
- Tech stack: [framework, auth, DB from Recon]
|
|
464
|
+
|
|
465
|
+
### 2. Pipeline summary
|
|
466
|
+
```
|
|
467
|
+
Triage: [N] source files | FILE_BUDGET: [B] | Strategy: [STRATEGY]
|
|
468
|
+
Recon: mapped N files -> CRITICAL: X | HIGH: Y | MEDIUM: Z | Tests: T
|
|
469
|
+
Hunters: [deep scan findings: W | optional triage findings: T | merged: U unique]
|
|
470
|
+
Gap-fill: [N files re-scanned, M additional findings] (or "not needed")
|
|
471
|
+
Skeptics: [challenged X | disproved: D, accepted: A]
|
|
472
|
+
Referee: confirmed N real bugs -> Critical: X | Medium: Y | Low: Z
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### 3. Confirmed bugs table
|
|
476
|
+
(sorted by severity — from Referee output)
|
|
477
|
+
|
|
478
|
+
### 4. Low-confidence items
|
|
479
|
+
Flagged for manual review.
|
|
480
|
+
- Include an **Auto-fix eligibility** field per bug:
|
|
481
|
+
- `ELIGIBLE`: Referee confidence >= 75%
|
|
482
|
+
- `MANUAL_REVIEW`: confidence < 75% or missing confidence
|
|
483
|
+
- If low-confidence items exist, expand scan scope from delta mode using trust-boundary overlays before finalizing report.
|
|
484
|
+
|
|
485
|
+
### 5. Dismissed findings
|
|
486
|
+
In a collapsed `<details>` section (for transparency).
|
|
487
|
+
|
|
488
|
+
### 6. Agent accuracy stats
|
|
489
|
+
- Deep Hunter accuracy: X/Y confirmed (Z%)
|
|
490
|
+
- Optional triage value: N triage-only findings promoted to deep scan
|
|
491
|
+
- Skeptic accuracy: X/Y correct challenges (Z%)
|
|
492
|
+
|
|
493
|
+
### 7. Coverage assessment
|
|
494
|
+
- If ALL CRITICAL/HIGH files scanned: "Full coverage achieved."
|
|
495
|
+
- If any missed: list them with note about `--loop` mode.
|
|
496
|
+
|
|
497
|
+
### 7b. Coverage enforcement (mandatory)
|
|
498
|
+
|
|
499
|
+
If the coverage assessment shows ANY CRITICAL or HIGH files were not scanned, the pipeline is NOT complete:
|
|
500
|
+
|
|
501
|
+
1. If `LOOP_MODE=true` (default): the ralph-loop will automatically continue to the next iteration covering missed files. Call `ralph_done` to proceed to the next iteration. Do NOT output `<promise>COMPLETE</promise>` until all CRITICAL/HIGH files show DONE.
|
|
502
|
+
|
|
503
|
+
2. If `LOOP_MODE=false` (`--no-loop` was specified) AND missed files exist:
|
|
504
|
+
- If total files ≤ FILE_BUDGET × 3: Output the report with a WARNING:
|
|
505
|
+
```
|
|
506
|
+
⚠️ PARTIAL COVERAGE: [N] CRITICAL/HIGH files were not scanned.
|
|
507
|
+
Run `/bug-hunter [path]` for complete coverage (loop is on by default).
|
|
508
|
+
Unscanned files: [list them]
|
|
509
|
+
```
|
|
510
|
+
- If total files > FILE_BUDGET × 3: The report MUST include:
|
|
511
|
+
```
|
|
512
|
+
🚨 LARGE CODEBASE: [N] source files (FILE_BUDGET: [B]).
|
|
513
|
+
Single-pass audit covered [X]% of CRITICAL/HIGH files.
|
|
514
|
+
Use `/bug-hunter [path]` for full coverage (loop is on by default).
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
3. Do NOT claim "audit complete" or "full coverage achieved" unless ALL CRITICAL and HIGH files have status DONE. A partial audit is still valuable — report what you found honestly.
|
|
518
|
+
|
|
519
|
+
If zero bugs were confirmed, say so clearly — a clean report is a good result.
|
|
520
|
+
|
|
521
|
+
**Routing after report:**
|
|
522
|
+
- If confirmed bugs > 0 AND `FIX_MODE=true`:
|
|
523
|
+
- Auto-fix only `ELIGIBLE` bugs.
|
|
524
|
+
- Apply canary-first rollout: fix top critical eligible subset first, verify, then continue remaining eligible fixes.
|
|
525
|
+
- Keep `MANUAL_REVIEW` bugs in report only (do not auto-edit).
|
|
526
|
+
- Run final global consistency pass over merged findings before applying fixes.
|
|
527
|
+
- Read `SKILL_DIR/modes/fix-pipeline.md` and execute Phase 2 on eligible subset.
|
|
528
|
+
- If confirmed bugs > 0 AND `FIX_MODE=false`: stop after report (scan-only mode).
|
|
529
|
+
- If zero bugs confirmed: stop here. The report is the final output.
|
|
530
|
+
|
|
531
|
+
### 8. JSON output (always generated)
|
|
532
|
+
|
|
533
|
+
After the markdown report, write a machine-readable findings file to `.bug-hunter/findings.json`:
|
|
534
|
+
|
|
535
|
+
```json
|
|
536
|
+
{
|
|
537
|
+
"version": "3.0.0",
|
|
538
|
+
"scan_id": "scan-YYYY-MM-DD-HHmmss",
|
|
539
|
+
"scan_date": "<ISO 8601>",
|
|
540
|
+
"mode": "<strategy>",
|
|
541
|
+
"target": "<target path>",
|
|
542
|
+
"files_scanned": 0,
|
|
543
|
+
"threat_model_loaded": false,
|
|
544
|
+
"confirmed": [
|
|
545
|
+
{
|
|
546
|
+
"id": "BUG-1",
|
|
547
|
+
"severity": "CRITICAL",
|
|
548
|
+
"category": "security",
|
|
549
|
+
"stride": "Tampering",
|
|
550
|
+
"cwe": "CWE-89",
|
|
551
|
+
"file": "src/api/users.ts",
|
|
552
|
+
"lines": "45-49",
|
|
553
|
+
"claim": "SQL injection via unsanitized query parameter",
|
|
554
|
+
"reachability": "EXTERNAL",
|
|
555
|
+
"exploitability": "EASY",
|
|
556
|
+
"cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N",
|
|
557
|
+
"cvss_score": 9.1,
|
|
558
|
+
"poc": { "payload": "...", "request": "...", "expected": "...", "actual": "..." }
|
|
559
|
+
}
|
|
560
|
+
],
|
|
561
|
+
"dismissed": [
|
|
562
|
+
{ "id": "BUG-3", "severity": "Medium", "category": "logic", "file": "...", "claim": "...", "reason": "..." }
|
|
563
|
+
],
|
|
564
|
+
"dependencies": [],
|
|
565
|
+
"summary": {
|
|
566
|
+
"total_reported": 0, "confirmed": 0, "dismissed": 0,
|
|
567
|
+
"by_severity": { "CRITICAL": 0, "HIGH": 0, "MEDIUM": 0, "LOW": 0 },
|
|
568
|
+
"by_stride": { "Tampering": 0, "InfoDisclosure": 0, "ElevationOfPrivilege": 0, "Spoofing": 0, "DoS": 0, "Repudiation": 0, "N/A": 0 },
|
|
569
|
+
"by_category": { "security": 0, "logic": 0, "error-handling": 0 }
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
Rules for JSON output:
|
|
575
|
+
- Non-security findings: `stride: "N/A"`, `cwe: "N/A"`, omit reachability/CVSS/PoC fields.
|
|
576
|
+
- Security findings without CRITICAL/HIGH severity: omit CVSS and PoC fields.
|
|
577
|
+
- `dependencies` array: populated only if `--deps` was used and `.bug-hunter/dep-findings.json` exists.
|
|
578
|
+
- This JSON enables CI/CD gating, dashboard ingestion, and downstream patch generation.
|
|
579
|
+
|
|
580
|
+
Also write the final markdown report to `.bug-hunter/report.md` as the canonical human-readable output (in addition to displaying it to the user).
|
|
581
|
+
|
|
582
|
+
---
|
|
583
|
+
|
|
584
|
+
## Self-Test Mode
|
|
585
|
+
|
|
586
|
+
To validate the pipeline works end-to-end, run `/bug-hunter SKILL_DIR/test-fixture/` on the included test fixture. This directory contains a small Express app with 6 intentionally planted bugs (2 Critical, 3 Medium, 1 Low). Expected results:
|
|
587
|
+
- Recon should classify 3 files as CRITICAL, 1 as HIGH
|
|
588
|
+
- Hunters should find all 6 bugs (possibly more false positives)
|
|
589
|
+
- Skeptic should challenge at least 1 false positive
|
|
590
|
+
- Referee should confirm all 6 planted bugs
|
|
591
|
+
|
|
592
|
+
If the pipeline finds fewer than 5 of the 6 planted bugs, the prompts need tuning. If it reports more than 3 false positives that survive to the Referee, the Skeptic prompt needs tightening.
|
|
593
|
+
|
|
594
|
+
The test fixture source files ship with the skill. If using `--fix` mode on the fixture, initialize its git repo first: `bash SKILL_DIR/scripts/init-test-fixture.sh`
|
|
595
|
+
|
|
596
|
+
---
|
|
597
|
+
|
|
598
|
+
## Error handling
|
|
599
|
+
|
|
600
|
+
| Step | Failure | Fallback |
|
|
601
|
+
|------|---------|----------|
|
|
602
|
+
| Triage | script error | Skip triage, Recon does full classification with FILE_BUDGET=40 default |
|
|
603
|
+
| Recon | timeout/error | Skip Recon, Hunters use triage scanOrder (or Glob-based discovery if no triage) |
|
|
604
|
+
| Optional scout pass | timeout/error | Disable scout, continue with deep Hunter |
|
|
605
|
+
| Deep Hunter | timeout/error | Retry once on narrowed chunk, otherwise report partial coverage |
|
|
606
|
+
| Orchestration backend | launch failure | Fall back to next backend (subagent → teams → interactive_shell → local-sequential) |
|
|
607
|
+
| Gap-fill Hunter | timeout/error | Note missed files, continue |
|
|
608
|
+
| Payload guard | validation fails | Do not launch subagent; fix payload and retry |
|
|
609
|
+
| Chunk orchestrator | timeout/error | Retry with exponential backoff, then mark chunk failed |
|
|
610
|
+
| Skeptic | timeout/error | Use single Skeptic or accept all findings as-is |
|
|
611
|
+
| Referee | timeout/error | Use Skeptic's accepted list as final result |
|
|
612
|
+
| Git safety (Step 8a) | not a git repo | Warn user, skip branching |
|
|
613
|
+
| Git safety (Step 8a) | stash/branch fails | Warn, continue without safety net |
|
|
614
|
+
| Fix lock | lock held | Stop Phase 2, report concurrent fixer run |
|
|
615
|
+
| Test baseline (Step 8c) | timeout/not found | Set BASELINE=null, skip test verification |
|
|
616
|
+
| Fixer | timeout/error | Mark unfixed bugs as SKIPPED |
|
|
617
|
+
| Post-fix tests | new failures | Auto-revert failed fix commit, mark FIX_REVERTED |
|
|
618
|
+
| Post-fix re-scan | timeout/error | Skip re-scan, note "fixer output not re-verified" |
|
|
619
|
+
| Worktree prepare | `git worktree add` fails | Fall back to `WORKTREE_MODE=false` (direct edit mode) for this run |
|
|
620
|
+
| Worktree harvest | no commits found, dirty | Stash uncommitted work, mark bugs as `FIX_FAILED` (reason: fixer-did-not-commit) |
|
|
621
|
+
| Worktree harvest | branch switched | Mark all bugs in batch as `FIX_FAILED` (reason: branch-switched) |
|
|
622
|
+
| Worktree cleanup | `git worktree remove` fails | Force-remove directory, run `git worktree prune` |
|
|
623
|
+
| Stale worktrees | from previous crash | `cleanup-all` at Step 8a-wt removes them before starting |
|
|
624
|
+
| Fix lock release | release fails | Warn user to clear `.bug-hunter/fix.lock` manually |
|