@harness-engineering/cli 1.6.2 → 1.8.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/dist/agents/personas/documentation-maintainer.yaml +3 -1
- package/dist/agents/personas/performance-guardian.yaml +23 -0
- package/dist/agents/personas/planner.yaml +27 -0
- package/dist/agents/personas/verifier.yaml +30 -0
- package/dist/agents/skills/claude-code/align-documentation/SKILL.md +13 -0
- package/dist/agents/skills/claude-code/cleanup-dead-code/SKILL.md +25 -1
- package/dist/agents/skills/claude-code/cleanup-dead-code/skill.yaml +5 -2
- package/dist/agents/skills/claude-code/detect-doc-drift/SKILL.md +12 -0
- package/dist/agents/skills/claude-code/enforce-architecture/SKILL.md +67 -1
- package/dist/agents/skills/claude-code/enforce-architecture/skill.yaml +5 -2
- package/dist/agents/skills/claude-code/harness-accessibility/SKILL.md +281 -0
- package/dist/agents/skills/claude-code/harness-accessibility/skill.yaml +51 -0
- package/dist/agents/skills/claude-code/harness-autopilot/SKILL.md +119 -72
- package/dist/agents/skills/claude-code/harness-autopilot/skill.yaml +4 -2
- package/dist/agents/skills/claude-code/harness-brainstorming/SKILL.md +76 -4
- package/dist/agents/skills/claude-code/harness-brainstorming/skill.yaml +2 -0
- package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +487 -234
- package/dist/agents/skills/claude-code/harness-code-review/skill.yaml +15 -2
- package/dist/agents/skills/claude-code/harness-codebase-cleanup/SKILL.md +226 -0
- package/dist/agents/skills/claude-code/harness-codebase-cleanup/skill.yaml +64 -0
- package/dist/agents/skills/claude-code/harness-dependency-health/SKILL.md +35 -6
- package/dist/agents/skills/claude-code/harness-dependency-health/skill.yaml +1 -1
- package/dist/agents/skills/claude-code/harness-design/SKILL.md +265 -0
- package/dist/agents/skills/claude-code/harness-design/skill.yaml +53 -0
- package/dist/agents/skills/claude-code/harness-design-mobile/SKILL.md +336 -0
- package/dist/agents/skills/claude-code/harness-design-mobile/skill.yaml +49 -0
- package/dist/agents/skills/claude-code/harness-design-system/SKILL.md +282 -0
- package/dist/agents/skills/claude-code/harness-design-system/skill.yaml +50 -0
- package/dist/agents/skills/claude-code/harness-design-web/SKILL.md +360 -0
- package/dist/agents/skills/claude-code/harness-design-web/skill.yaml +52 -0
- package/dist/agents/skills/claude-code/harness-docs-pipeline/SKILL.md +460 -0
- package/dist/agents/skills/claude-code/harness-docs-pipeline/skill.yaml +69 -0
- package/dist/agents/skills/claude-code/harness-execution/SKILL.md +73 -8
- package/dist/agents/skills/claude-code/harness-execution/skill.yaml +1 -0
- package/dist/agents/skills/claude-code/harness-hotspot-detector/SKILL.md +32 -6
- package/dist/agents/skills/claude-code/harness-hotspot-detector/skill.yaml +1 -1
- package/dist/agents/skills/claude-code/harness-i18n/SKILL.md +484 -0
- package/dist/agents/skills/claude-code/harness-i18n/skill.yaml +54 -0
- package/dist/agents/skills/claude-code/harness-i18n-process/SKILL.md +388 -0
- package/dist/agents/skills/claude-code/harness-i18n-process/skill.yaml +43 -0
- package/dist/agents/skills/claude-code/harness-i18n-workflow/SKILL.md +512 -0
- package/dist/agents/skills/claude-code/harness-i18n-workflow/skill.yaml +53 -0
- package/dist/agents/skills/claude-code/harness-impact-analysis/SKILL.md +51 -6
- package/dist/agents/skills/claude-code/harness-integrity/SKILL.md +35 -1
- package/dist/agents/skills/claude-code/harness-knowledge-mapper/SKILL.md +46 -5
- package/dist/agents/skills/claude-code/harness-knowledge-mapper/skill.yaml +1 -1
- package/dist/agents/skills/claude-code/harness-onboarding/SKILL.md +19 -1
- package/dist/agents/skills/claude-code/harness-perf/SKILL.md +37 -8
- package/dist/agents/skills/claude-code/harness-perf/skill.yaml +3 -0
- package/dist/agents/skills/claude-code/harness-perf-tdd/SKILL.md +17 -4
- package/dist/agents/skills/claude-code/harness-planning/SKILL.md +57 -3
- package/dist/agents/skills/claude-code/harness-planning/skill.yaml +2 -0
- package/dist/agents/skills/claude-code/harness-release-readiness/SKILL.md +29 -9
- package/dist/agents/skills/claude-code/harness-roadmap/SKILL.md +562 -0
- package/dist/agents/skills/claude-code/harness-roadmap/skill.yaml +43 -0
- package/dist/agents/skills/claude-code/harness-security-review/SKILL.md +36 -2
- package/dist/agents/skills/claude-code/harness-security-review/skill.yaml +8 -6
- package/dist/agents/skills/claude-code/harness-security-scan/skill.yaml +1 -1
- package/dist/agents/skills/claude-code/harness-soundness-review/SKILL.md +1267 -0
- package/dist/agents/skills/claude-code/harness-soundness-review/skill.yaml +48 -0
- package/dist/agents/skills/claude-code/harness-test-advisor/SKILL.md +35 -6
- package/dist/agents/skills/claude-code/harness-verification/SKILL.md +66 -0
- package/dist/agents/skills/claude-code/harness-verification/skill.yaml +1 -0
- package/dist/agents/skills/claude-code/harness-verify/SKILL.md +37 -0
- package/dist/agents/skills/claude-code/initialize-harness-project/SKILL.md +15 -1
- package/dist/agents/skills/claude-code/validate-context-engineering/SKILL.md +12 -0
- package/dist/agents/skills/gemini-cli/harness-accessibility/SKILL.md +281 -0
- package/dist/agents/skills/gemini-cli/harness-accessibility/skill.yaml +51 -0
- package/dist/agents/skills/gemini-cli/harness-autopilot/SKILL.md +119 -72
- package/dist/agents/skills/gemini-cli/harness-autopilot/skill.yaml +4 -2
- package/dist/agents/skills/gemini-cli/harness-codebase-cleanup/SKILL.md +226 -0
- package/dist/agents/skills/gemini-cli/harness-codebase-cleanup/skill.yaml +64 -0
- package/dist/agents/skills/gemini-cli/harness-dependency-health/SKILL.md +35 -6
- package/dist/agents/skills/gemini-cli/harness-dependency-health/skill.yaml +1 -1
- package/dist/agents/skills/gemini-cli/harness-design/SKILL.md +265 -0
- package/dist/agents/skills/gemini-cli/harness-design/skill.yaml +53 -0
- package/dist/agents/skills/gemini-cli/harness-design-mobile/SKILL.md +336 -0
- package/dist/agents/skills/gemini-cli/harness-design-mobile/skill.yaml +49 -0
- package/dist/agents/skills/gemini-cli/harness-design-system/SKILL.md +282 -0
- package/dist/agents/skills/gemini-cli/harness-design-system/skill.yaml +50 -0
- package/dist/agents/skills/gemini-cli/harness-design-web/SKILL.md +360 -0
- package/dist/agents/skills/gemini-cli/harness-design-web/skill.yaml +52 -0
- package/dist/agents/skills/gemini-cli/harness-docs-pipeline/SKILL.md +460 -0
- package/dist/agents/skills/gemini-cli/harness-docs-pipeline/skill.yaml +69 -0
- package/dist/agents/skills/gemini-cli/harness-hotspot-detector/SKILL.md +32 -6
- package/dist/agents/skills/gemini-cli/harness-hotspot-detector/skill.yaml +1 -1
- package/dist/agents/skills/gemini-cli/harness-i18n/SKILL.md +484 -0
- package/dist/agents/skills/gemini-cli/harness-i18n/skill.yaml +54 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-process/SKILL.md +388 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-process/skill.yaml +43 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-workflow/SKILL.md +512 -0
- package/dist/agents/skills/gemini-cli/harness-i18n-workflow/skill.yaml +53 -0
- package/dist/agents/skills/gemini-cli/harness-impact-analysis/SKILL.md +51 -6
- package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/SKILL.md +46 -5
- package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/skill.yaml +1 -1
- package/dist/agents/skills/gemini-cli/harness-perf/SKILL.md +37 -8
- package/dist/agents/skills/gemini-cli/harness-perf/skill.yaml +3 -0
- package/dist/agents/skills/gemini-cli/harness-perf-tdd/SKILL.md +17 -4
- package/dist/agents/skills/gemini-cli/harness-release-readiness/SKILL.md +29 -9
- package/dist/agents/skills/gemini-cli/harness-roadmap/SKILL.md +562 -0
- package/dist/agents/skills/gemini-cli/harness-roadmap/skill.yaml +43 -0
- package/dist/agents/skills/gemini-cli/harness-security-review/skill.yaml +8 -6
- package/dist/agents/skills/gemini-cli/harness-security-scan/skill.yaml +1 -1
- package/dist/agents/skills/gemini-cli/harness-soundness-review/SKILL.md +1267 -0
- package/dist/agents/skills/gemini-cli/harness-soundness-review/skill.yaml +48 -0
- package/dist/agents/skills/gemini-cli/harness-test-advisor/SKILL.md +35 -6
- package/dist/agents/skills/node_modules/.bin/vitest +2 -2
- package/dist/agents/skills/shared/design-knowledge/anti-patterns/color.yaml +106 -0
- package/dist/agents/skills/shared/design-knowledge/anti-patterns/layout.yaml +109 -0
- package/dist/agents/skills/shared/design-knowledge/anti-patterns/motion.yaml +109 -0
- package/dist/agents/skills/shared/design-knowledge/anti-patterns/typography.yaml +112 -0
- package/dist/agents/skills/shared/design-knowledge/industries/creative.yaml +80 -0
- package/dist/agents/skills/shared/design-knowledge/industries/ecommerce.yaml +80 -0
- package/dist/agents/skills/shared/design-knowledge/industries/emerging-tech.yaml +83 -0
- package/dist/agents/skills/shared/design-knowledge/industries/fintech.yaml +80 -0
- package/dist/agents/skills/shared/design-knowledge/industries/healthcare.yaml +80 -0
- package/dist/agents/skills/shared/design-knowledge/industries/lifestyle.yaml +80 -0
- package/dist/agents/skills/shared/design-knowledge/industries/saas.yaml +80 -0
- package/dist/agents/skills/shared/design-knowledge/industries/services.yaml +80 -0
- package/dist/agents/skills/shared/design-knowledge/palettes/curated.yaml +234 -0
- package/dist/agents/skills/shared/design-knowledge/platform-rules/android.yaml +125 -0
- package/dist/agents/skills/shared/design-knowledge/platform-rules/flutter.yaml +144 -0
- package/dist/agents/skills/shared/design-knowledge/platform-rules/ios.yaml +106 -0
- package/dist/agents/skills/shared/design-knowledge/platform-rules/web.yaml +102 -0
- package/dist/agents/skills/shared/design-knowledge/typography/pairings.yaml +274 -0
- package/dist/agents/skills/shared/i18n-knowledge/accessibility/intersection.yaml +142 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/encoding.yaml +67 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/formatting.yaml +106 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/layout.yaml +80 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/pluralization.yaml +80 -0
- package/dist/agents/skills/shared/i18n-knowledge/anti-patterns/string-handling.yaml +106 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/android-resources.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/apple-strings.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/backend-patterns.yaml +50 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/flutter-intl.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/i18next.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/react-intl.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/frameworks/vue-i18n.yaml +47 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/ecommerce.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/fintech.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/gaming.yaml +69 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/healthcare.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/industries/legal.yaml +66 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ar.yaml +41 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/de.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/en.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/es.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/fi.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/fr.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/he.yaml +41 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/hi.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/it.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ja.yaml +38 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ko.yaml +38 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/nl.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/pl.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/pt.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/ru.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/sv.yaml +32 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/th.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/tr.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hans.yaml +38 -0
- package/dist/agents/skills/shared/i18n-knowledge/locales/zh-Hant.yaml +35 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/i18next-mcp.yaml +56 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lingo-dev.yaml +56 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/lokalise.yaml +60 -0
- package/dist/agents/skills/shared/i18n-knowledge/mcp-interop/tolgee.yaml +60 -0
- package/dist/agents/skills/shared/i18n-knowledge/testing/locale-testing.yaml +107 -0
- package/dist/agents/skills/shared/i18n-knowledge/testing/pseudo-localization.yaml +86 -0
- package/dist/bin/harness.js +64 -4
- package/dist/{chunk-UDWGSL3T.js → chunk-3JWCBVUZ.js} +3 -3
- package/dist/{chunk-IUFFBBYV.js → chunk-LNI4T7R6.js} +179 -61
- package/dist/{chunk-USEYPS7F.js → chunk-SJECMKSS.js} +2250 -40
- package/dist/{dist-4MYPT3OE.js → dist-BDO5GFEM.js} +295 -14
- package/dist/{dist-RBZXXJHG.js → dist-NT3GXHQZ.js} +95 -1
- package/dist/index.d.ts +266 -7
- package/dist/index.js +7 -3
- package/dist/validate-cross-check-2OPGCGGU.js +7 -0
- package/package.json +7 -7
- package/dist/validate-cross-check-CPEPNLOD.js +0 -7
|
@@ -1,123 +1,164 @@
|
|
|
1
1
|
# Harness Code Review
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Multi-phase code review pipeline — mechanical checks, graph-scoped context, parallel review agents, cross-agent deduplication, and structured output with technical rigor over social performance.
|
|
4
4
|
|
|
5
5
|
## When to Use
|
|
6
6
|
|
|
7
|
-
- When
|
|
8
|
-
- When
|
|
9
|
-
- When responding to review feedback
|
|
10
|
-
- When `on_review` or `on_pr` triggers fire
|
|
7
|
+
- When performing a code review (manual invocation or triggered by `on_pr` / `on_review`)
|
|
8
|
+
- When requesting a review of completed work (see Role A at the end of this document)
|
|
9
|
+
- When responding to review feedback (see Role C at the end of this document)
|
|
11
10
|
- NOT for in-progress work (complete the feature first)
|
|
12
11
|
- NOT for rubber-stamping (if you cannot find issues, look harder or state confidence level)
|
|
13
|
-
- NOT for style-only feedback (leave that to linters)
|
|
12
|
+
- NOT for style-only feedback (leave that to linters and mechanical checks)
|
|
14
13
|
|
|
15
|
-
##
|
|
14
|
+
## Process
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
The review runs as a 7-phase pipeline. Each phase has a clear input, output, and exit condition.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
```
|
|
19
|
+
Phase 1: GATE ──→ Phase 2: MECHANICAL ──→ Phase 3: CONTEXT ──→ Phase 4: FAN-OUT
|
|
20
|
+
│
|
|
21
|
+
Phase 7: OUTPUT ←── Phase 6: DEDUP+MERGE ←── Phase 5: VALIDATE ←──────┘
|
|
22
|
+
```
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
| Phase | Tier | Purpose | Exit Condition |
|
|
25
|
+
| -------------- | ----- | -------------------------------------------------- | ----------------------------------------------------- |
|
|
26
|
+
| 1. GATE | fast | Skip ineligible PRs (CI mode only) | PR is eligible, or exit with reason |
|
|
27
|
+
| 2. MECHANICAL | none | Lint, typecheck, test, security scan | All pass → continue; any fail → report and stop |
|
|
28
|
+
| 3. CONTEXT | fast | Scope context per review domain | Context bundles assembled for each subagent |
|
|
29
|
+
| 4. FAN-OUT | mixed | Parallel review subagents | All subagents return findings in ReviewFinding schema |
|
|
30
|
+
| 5. VALIDATE | none | Exclude mechanical duplicates, verify reachability | Unvalidated findings discarded |
|
|
31
|
+
| 6. DEDUP+MERGE | none | Group, merge, assign final severity | Deduplicated finding list with merged evidence |
|
|
32
|
+
| 7. OUTPUT | none | Text output or inline GitHub comments | Review delivered, exit code set |
|
|
33
|
+
|
|
34
|
+
### Finding Schema
|
|
35
|
+
|
|
36
|
+
Each review agent produces findings in this common format:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
interface ReviewFinding {
|
|
40
|
+
id: string; // unique, for dedup
|
|
41
|
+
file: string; // file path
|
|
42
|
+
lineRange: [number, number]; // start, end
|
|
43
|
+
domain: 'compliance' | 'bug' | 'security' | 'architecture';
|
|
44
|
+
severity: 'critical' | 'important' | 'suggestion';
|
|
45
|
+
title: string; // one-line summary
|
|
46
|
+
rationale: string; // why this is an issue
|
|
47
|
+
suggestion?: string; // fix, if available
|
|
48
|
+
evidence: string[]; // supporting context from agent
|
|
49
|
+
validatedBy: 'mechanical' | 'graph' | 'heuristic';
|
|
50
|
+
}
|
|
51
|
+
```
|
|
22
52
|
|
|
23
|
-
|
|
24
|
-
- **Medium diffs (20-200 lines):** Target 1:1 ratio. Read the full files containing changes, plus immediate dependencies.
|
|
25
|
-
- **Large diffs (>200 lines):** 1:1 ratio is the floor, but prioritize ruthlessly using the priority order below. Flag large diffs as a review concern — they are harder to review correctly.
|
|
53
|
+
### Flags
|
|
26
54
|
|
|
27
|
-
|
|
55
|
+
| Flag | Effect |
|
|
56
|
+
| ----------------- | ------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `--comment` | Post inline comments to GitHub PR via `gh` CLI or GitHub MCP |
|
|
58
|
+
| `--deep` | Pass `--deep` to `harness-security-review` for threat modeling in the security fan-out slot |
|
|
59
|
+
| `--no-mechanical` | Skip mechanical checks (useful if already run in CI) |
|
|
60
|
+
| `--ci` | Enable eligibility gate, non-interactive output |
|
|
28
61
|
|
|
29
|
-
|
|
62
|
+
### Model Tiers
|
|
30
63
|
|
|
31
|
-
|
|
32
|
-
2. **Corresponding test files** — find tests for the changed code. If tests exist, read them to understand expected behavior. If tests are missing, note this as a finding.
|
|
33
|
-
3. **Spec/design docs mentioning changed components** — search `docs/specs/`, `docs/design-docs/`, and `docs/plans/` for references to the changed files or features. The spec defines "correct."
|
|
34
|
-
4. **Type definitions used by changed code** — read interfaces, types, and schemas that the changed code consumes or produces. Type mismatches are high-severity bugs.
|
|
35
|
-
5. **Recent commits touching the same files** — see Commit History below.
|
|
64
|
+
Tiers are abstract labels resolved at runtime from project config. If no config exists, all phases use the current model (no tiering).
|
|
36
65
|
|
|
37
|
-
|
|
66
|
+
| Tier | Default | Used By |
|
|
67
|
+
| ---------- | ------------ | ------------------------------------ |
|
|
68
|
+
| `fast` | haiku-class | GATE, CONTEXT |
|
|
69
|
+
| `standard` | sonnet-class | Compliance agent, Architecture agent |
|
|
70
|
+
| `strong` | opus-class | Bug Detection agent, Security agent |
|
|
38
71
|
|
|
39
|
-
|
|
40
|
-
# 1. Get the diff and measure its size
|
|
41
|
-
git diff --stat HEAD~1 # or the relevant commit range
|
|
42
|
-
git diff HEAD~1 -- <file> # per-file diff
|
|
72
|
+
### Review Learnings Calibration
|
|
43
73
|
|
|
44
|
-
|
|
45
|
-
grep -n "import\|require\|from " <changed-file>
|
|
74
|
+
Before starting the pipeline, check for a project-specific calibration file:
|
|
46
75
|
|
|
47
|
-
|
|
48
|
-
|
|
76
|
+
```bash
|
|
77
|
+
cat .harness/review-learnings.md 2>/dev/null
|
|
78
|
+
```
|
|
49
79
|
|
|
50
|
-
|
|
51
|
-
grep -rl "<component-name>" docs/specs/ docs/design-docs/ docs/plans/
|
|
80
|
+
If `.harness/review-learnings.md` exists:
|
|
52
81
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
82
|
+
1. **Read the Useful Findings section.** Prioritize these categories during review — they have historically caught real issues in this project.
|
|
83
|
+
2. **Read the Noise / False Positives section.** De-prioritize or skip these categories — flagging them wastes the author's time and erodes trust in the review process.
|
|
84
|
+
3. **Read the Calibration Notes section.** Apply these project-specific overrides to your review judgment. These represent deliberate team decisions, not oversights.
|
|
56
85
|
|
|
57
|
-
|
|
86
|
+
If the file does not exist, proceed with default review focus areas. After completing the review, consider suggesting that the team create `.harness/review-learnings.md` if you notice patterns that would benefit from calibration.
|
|
58
87
|
|
|
59
|
-
|
|
88
|
+
## Pipeline Phases
|
|
60
89
|
|
|
61
|
-
|
|
62
|
-
- `get_impact` — find all affected tests, docs, and downstream code that may break from the change
|
|
63
|
-
- `find_context_for` — assemble review context for changed files within token budget, ranked by relevance
|
|
90
|
+
### Phase 1: GATE
|
|
64
91
|
|
|
65
|
-
|
|
92
|
+
**Tier:** fast
|
|
93
|
+
**Mode:** CI only (`--ci` flag). When invoked manually, skip this phase entirely.
|
|
66
94
|
|
|
67
|
-
|
|
95
|
+
Check whether the PR should be reviewed at all. This prevents wasted compute in CI pipelines.
|
|
68
96
|
|
|
69
|
-
|
|
97
|
+
**Checks:**
|
|
98
|
+
|
|
99
|
+
1. **PR state:** Is the PR closed or merged? → Skip with reason "PR is closed."
|
|
100
|
+
2. **Draft status:** Is the PR marked as draft? → Skip with reason "PR is draft."
|
|
101
|
+
3. **Trivial change:** Is the diff documentation-only (all changed files are `.md`)? → Skip with reason "Documentation-only change."
|
|
102
|
+
4. **Already reviewed:** Has this exact commit range been reviewed before (check for prior review comment from this tool)? → Skip with reason "Already reviewed at {sha}."
|
|
70
103
|
|
|
71
104
|
```bash
|
|
72
|
-
#
|
|
73
|
-
|
|
105
|
+
# Check PR state
|
|
106
|
+
gh pr view --json state,isDraft,files
|
|
74
107
|
|
|
75
|
-
#
|
|
76
|
-
|
|
108
|
+
# Check if documentation-only
|
|
109
|
+
gh pr diff --name-only | grep -v '\.md$' | wc -l # 0 means docs-only
|
|
77
110
|
```
|
|
78
111
|
|
|
79
|
-
|
|
112
|
+
**Exit:** If any check triggers a skip, output the reason and exit with code 0. Otherwise, continue to Phase 2.
|
|
80
113
|
|
|
81
|
-
|
|
82
|
-
- **Was this recently refactored?** If recent commits include "refactor" or "restructure," check whether the current change aligns with or contradicts the refactoring direction.
|
|
83
|
-
- **Who has been working here?** If multiple authors touched the file recently, there may be conflicting assumptions. Look for consistency.
|
|
84
|
-
- **What was the last change?** The most recent commit gives context on the file's trajectory. A bugfix followed by another change to the same area is a yellow flag.
|
|
114
|
+
---
|
|
85
115
|
|
|
86
|
-
###
|
|
116
|
+
### Phase 2: MECHANICAL
|
|
87
117
|
|
|
88
|
-
|
|
118
|
+
**Tier:** none (no LLM)
|
|
119
|
+
**Mode:** Skipped if `--no-mechanical` flag is set.
|
|
89
120
|
|
|
90
|
-
|
|
91
|
-
# Check if review learnings file exists
|
|
92
|
-
cat .harness/review-learnings.md 2>/dev/null
|
|
93
|
-
```
|
|
121
|
+
Run mechanical checks to establish an exclusion boundary. Any issue caught mechanically is excluded from AI review (Phase 4) to prevent duplicate findings.
|
|
94
122
|
|
|
95
|
-
|
|
123
|
+
**Checks:**
|
|
96
124
|
|
|
97
|
-
1. **
|
|
98
|
-
|
|
99
|
-
|
|
125
|
+
1. **Harness validation:**
|
|
126
|
+
```bash
|
|
127
|
+
harness validate
|
|
128
|
+
harness check-deps
|
|
129
|
+
harness check-docs
|
|
130
|
+
```
|
|
131
|
+
2. **Security scan:** Run `run_security_scan` MCP tool on changed files. Record findings with rule ID, file, line, and remediation.
|
|
132
|
+
3. **Type checking:** Run the project's type checker (e.g., `tsc --noEmit`). Record any type errors.
|
|
133
|
+
4. **Linting:** Run the project's linter (e.g., `eslint`). Record any lint violations.
|
|
134
|
+
5. **Tests:** Run the project's test suite. Record any failures.
|
|
100
135
|
|
|
101
|
-
|
|
136
|
+
**Output:** A set of mechanical findings (file, line, tool, message). This set becomes the exclusion list for Phase 5.
|
|
137
|
+
|
|
138
|
+
**Exit:** If any mechanical check fails (harness validate, typecheck, or tests), report the mechanical failures in Strengths/Issues/Assessment format and stop the pipeline. The code has fundamental issues that must be fixed before AI review adds value. Lint warnings and security scan findings do not stop the pipeline — they are recorded for exclusion only.
|
|
139
|
+
|
|
140
|
+
---
|
|
102
141
|
|
|
103
|
-
|
|
142
|
+
### Phase 3: CONTEXT
|
|
104
143
|
|
|
105
|
-
|
|
144
|
+
**Tier:** fast
|
|
145
|
+
**Purpose:** Assemble scoped context bundles for each review domain. Each subagent in Phase 4 receives only the context relevant to its domain, not the full diff.
|
|
106
146
|
|
|
107
|
-
|
|
147
|
+
#### Change-Type Detection
|
|
108
148
|
|
|
109
|
-
|
|
110
|
-
|
|
149
|
+
Before scoping context, determine the change type. This shapes which review focus areas apply.
|
|
150
|
+
|
|
151
|
+
1. **Commit message prefix:** Parse the most recent commit message for conventional commit prefixes:
|
|
111
152
|
- `feat:` or `feature:` → **feature**
|
|
112
153
|
- `fix:` or `bugfix:` → **bugfix**
|
|
113
154
|
- `refactor:` → **refactor**
|
|
114
155
|
- `docs:` or `doc:` → **docs**
|
|
115
|
-
|
|
156
|
+
2. **Diff pattern heuristic:** If no prefix is found, examine the diff:
|
|
116
157
|
- New files added + tests added → likely **feature**
|
|
117
158
|
- Small changes to existing files + test added → likely **bugfix**
|
|
118
159
|
- File renames, moves, or restructuring with no behavior change → likely **refactor**
|
|
119
160
|
- Only `.md` files or comments changed → likely **docs**
|
|
120
|
-
|
|
161
|
+
3. **Default:** If detection is ambiguous, treat as **feature** (the most thorough review).
|
|
121
162
|
|
|
122
163
|
```bash
|
|
123
164
|
# Parse commit message prefix
|
|
@@ -127,266 +168,480 @@ git log --oneline -1 | head -1
|
|
|
127
168
|
git diff --name-status HEAD~1 | grep "^A"
|
|
128
169
|
|
|
129
170
|
# Check if only docs changed
|
|
130
|
-
git diff --name-only HEAD~1 | grep -v
|
|
171
|
+
git diff --name-only HEAD~1 | grep -v '\.md$' | wc -l # 0 means docs-only
|
|
131
172
|
```
|
|
132
173
|
|
|
133
|
-
|
|
174
|
+
#### Context Scoping
|
|
134
175
|
|
|
135
|
-
|
|
176
|
+
Scope context per review domain. When a knowledge graph exists at `.harness/graph/`, use graph queries. Otherwise, fall back to file-based heuristics.
|
|
136
177
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
178
|
+
| Domain | With Graph | Without Graph (Fallback) |
|
|
179
|
+
| ----------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
|
|
180
|
+
| **Compliance** | Convention files (`CLAUDE.md`, `AGENTS.md`, `.harness/`) + changed files | Convention files + changed files (same — no graph needed) |
|
|
181
|
+
| **Bug Detection** | Changed files + direct dependencies via `query_graph` | Changed files + files imported by changed files (`grep import`) |
|
|
182
|
+
| **Security** | Security-relevant paths + data flow traversal via `query_graph` | Changed files + files containing security-sensitive patterns (auth, crypto, SQL, shell) |
|
|
183
|
+
| **Architecture** | Layer boundaries + import graph via `query_graph` + `get_impact` | Changed files + `harness check-deps` output |
|
|
184
|
+
|
|
185
|
+
#### 1:1 Context Ratio Rule
|
|
186
|
+
|
|
187
|
+
For every N lines of diff, gather approximately N lines of surrounding context:
|
|
188
|
+
|
|
189
|
+
- **Small diffs (<20 lines):** Gather proportionally more context — aim for 3:1 context-to-diff.
|
|
190
|
+
- **Medium diffs (20-200 lines):** Target 1:1 ratio. Read full files containing changes, plus immediate dependencies.
|
|
191
|
+
- **Large diffs (>200 lines):** 1:1 ratio is the floor. Prioritize ruthlessly. Flag large diffs as a review concern.
|
|
192
|
+
|
|
193
|
+
#### Context Gathering Priority Order
|
|
194
|
+
|
|
195
|
+
Gather context in this order until the ratio is met:
|
|
196
|
+
|
|
197
|
+
1. **Files directly imported/referenced by changed files** — read the modules the changed code calls or depends on.
|
|
198
|
+
2. **Corresponding test files** — find tests for changed code. If tests are missing, note this as a finding.
|
|
199
|
+
3. **Spec/design docs mentioning changed components** — search `docs/specs/`, `docs/design-docs/`, `docs/plans/`.
|
|
200
|
+
4. **Type definitions used by changed code** — read interfaces, types, schemas consumed or produced.
|
|
201
|
+
5. **Recent commits touching the same files** — see Commit History below.
|
|
202
|
+
|
|
203
|
+
#### Graph-Enhanced Context (when available)
|
|
204
|
+
|
|
205
|
+
When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate context:
|
|
145
206
|
|
|
146
|
-
|
|
207
|
+
- `query_graph` — traverse dependency chain from changed files to find all imports and transitive dependencies
|
|
208
|
+
- `get_impact` — find all affected tests, docs, and downstream code
|
|
209
|
+
- `find_context_for` — assemble review context within token budget, ranked by relevance
|
|
147
210
|
|
|
148
|
-
|
|
211
|
+
Graph queries replace manual grep/find commands and discover transitive dependencies that file search misses. Fall back to file-based commands if no graph is available.
|
|
212
|
+
|
|
213
|
+
#### Context Assembly Commands
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# 1. Get the diff and measure its size
|
|
217
|
+
git diff --stat HEAD~1 # or the relevant commit range
|
|
218
|
+
git diff HEAD~1 -- <file> # per-file diff
|
|
219
|
+
|
|
220
|
+
# 2. Find imports/references in changed files
|
|
221
|
+
grep -n "import\|require\|from " <changed-file>
|
|
222
|
+
|
|
223
|
+
# 3. Find corresponding test files
|
|
224
|
+
find . -name "*<module-name>*test*" -o -name "*<module-name>*spec*"
|
|
225
|
+
|
|
226
|
+
# 4. Search for spec/design references
|
|
227
|
+
grep -rl "<component-name>" docs/specs/ docs/design-docs/ docs/plans/
|
|
228
|
+
|
|
229
|
+
# 5. Find type definitions
|
|
230
|
+
grep -rn "interface\|type\|schema" <changed-file> | head -20
|
|
231
|
+
```
|
|
149
232
|
|
|
150
|
-
|
|
233
|
+
#### Commit History Context
|
|
151
234
|
|
|
152
|
-
|
|
235
|
+
Retrieve recent commit history for every affected file:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# Recent commits touching affected files (5 per file)
|
|
239
|
+
git log --oneline -5 -- <affected-file>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Use commit history to answer:
|
|
243
|
+
|
|
244
|
+
- **Is this a hotspot?** Changed 3+ times in last 5 commits → volatile, pay extra attention.
|
|
245
|
+
- **Was this recently refactored?** Recent "refactor" commits → check alignment with refactoring direction.
|
|
246
|
+
- **Who has been working here?** Multiple authors → look for conflicting assumptions.
|
|
247
|
+
- **What was the last change?** Bugfix followed by change in same area → yellow flag.
|
|
248
|
+
|
|
249
|
+
**Exit:** Context bundles are assembled for each of the four review domains. Continue to Phase 4.
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### Phase 4: FAN-OUT
|
|
254
|
+
|
|
255
|
+
**Tier:** mixed (see per-agent tiers below)
|
|
256
|
+
**Purpose:** Run four parallel review subagents, each with domain-scoped context from Phase 3. Each agent produces findings in the `ReviewFinding` schema.
|
|
257
|
+
|
|
258
|
+
#### Compliance Agent (standard tier)
|
|
259
|
+
|
|
260
|
+
Reviews adherence to project conventions, standards, and documentation requirements.
|
|
261
|
+
|
|
262
|
+
**Input:** Compliance context bundle (convention files + changed files + change type)
|
|
263
|
+
|
|
264
|
+
**Focus by change type:**
|
|
265
|
+
|
|
266
|
+
_Feature:_
|
|
153
267
|
|
|
154
268
|
- [ ] **Spec alignment:** Does the implementation match the spec/design doc? Are all specified behaviors present?
|
|
155
|
-
- [ ] **Edge cases:** Are boundary conditions handled (empty input, max values, null, concurrent access)?
|
|
156
|
-
- [ ] **Test coverage:** Are there tests for happy path, error paths, and edge cases? Is coverage meaningful, not just present?
|
|
157
269
|
- [ ] **API surface:** Are new public interfaces minimal and well-named? Could any new export be kept internal?
|
|
158
270
|
- [ ] **Backward compatibility:** Does this break existing callers? If so, is the migration path documented?
|
|
159
271
|
|
|
160
|
-
|
|
272
|
+
_Bugfix:_
|
|
161
273
|
|
|
162
|
-
- [ ] **Root cause identified:** Does the fix address the root cause, not just the symptom?
|
|
163
|
-
- [ ] **Regression test added:** Is there a test that would have caught this bug before the fix? Does it fail without the fix and pass with it?
|
|
164
|
-
- [ ] **No collateral changes:** Does the fix change only what is necessary? Unrelated changes in a bugfix PR are a red flag.
|
|
274
|
+
- [ ] **Root cause identified:** Does the fix address the root cause, not just the symptom?
|
|
165
275
|
- [ ] **Original issue referenced:** Does the commit or PR reference the bug report or issue number?
|
|
276
|
+
- [ ] **No collateral changes:** Does the fix change only what is necessary?
|
|
166
277
|
|
|
167
|
-
|
|
278
|
+
_Refactor:_
|
|
168
279
|
|
|
169
|
-
- [ ] **Behavioral equivalence:** Do all existing tests still pass without modification?
|
|
170
|
-
- [ ] **No functionality changes:** Does the refactor introduce any new behavior
|
|
171
|
-
- [ ] **Performance preserved:** Could the restructuring introduce performance regressions (e.g., extra allocations, changed query patterns)?
|
|
172
|
-
- [ ] **Improved clarity:** Is the code demonstrably clearer after the refactor? If not, the refactor may not be justified.
|
|
280
|
+
- [ ] **Behavioral equivalence:** Do all existing tests still pass without modification?
|
|
281
|
+
- [ ] **No functionality changes:** Does the refactor introduce any new behavior?
|
|
173
282
|
|
|
174
|
-
|
|
283
|
+
_Docs:_
|
|
175
284
|
|
|
176
|
-
- [ ] **Accuracy vs. current code:** Do
|
|
177
|
-
- [ ] **Completeness:** Are all public interfaces documented?
|
|
178
|
-
- [ ] **Consistency:** Does
|
|
179
|
-
- [ ] **Links valid:** Do all internal links resolve?
|
|
285
|
+
- [ ] **Accuracy vs. current code:** Do documented behaviors match what the code actually does?
|
|
286
|
+
- [ ] **Completeness:** Are all public interfaces documented?
|
|
287
|
+
- [ ] **Consistency:** Does new documentation follow existing style and terminology?
|
|
288
|
+
- [ ] **Links valid:** Do all internal links resolve?
|
|
180
289
|
|
|
181
|
-
|
|
290
|
+
**Output:** `ReviewFinding[]` with `domain: 'compliance'`
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
#### Bug Detection Agent (strong tier)
|
|
295
|
+
|
|
296
|
+
Reviews for logic errors, edge cases, and correctness issues.
|
|
297
|
+
|
|
298
|
+
**Input:** Bug detection context bundle (changed files + dependencies)
|
|
299
|
+
|
|
300
|
+
**Focus areas:**
|
|
182
301
|
|
|
183
|
-
|
|
302
|
+
- [ ] **Edge cases:** Boundary conditions (empty input, max values, null, concurrent access)
|
|
303
|
+
- [ ] **Error handling:** Errors handled at appropriate level, helpful messages, no silent swallowing
|
|
304
|
+
- [ ] **Logic errors:** Off-by-one, incorrect boolean logic, missing early returns
|
|
305
|
+
- [ ] **Race conditions:** Concurrent access to shared state, missing locks or atomic operations
|
|
306
|
+
- [ ] **Resource leaks:** Unclosed handles, missing cleanup in error paths
|
|
307
|
+
- [ ] **Type safety:** Type mismatches, unsafe casts, missing null checks
|
|
308
|
+
- [ ] **Test coverage:** Tests for happy path, error paths, and edge cases. Coverage meaningful, not just present.
|
|
309
|
+
- [ ] **Regression tests:** For bugfixes — test that would have caught the bug before the fix
|
|
310
|
+
|
|
311
|
+
**Output:** `ReviewFinding[]` with `domain: 'bug'`
|
|
184
312
|
|
|
185
313
|
---
|
|
186
314
|
|
|
187
|
-
|
|
315
|
+
#### Security Agent (strong tier) -- via harness-security-review
|
|
316
|
+
|
|
317
|
+
Invokes `harness-security-review` in changed-files mode as the security slot in the fan-out.
|
|
318
|
+
|
|
319
|
+
**Input:** Security context bundle (security-relevant paths + data flows)
|
|
320
|
+
|
|
321
|
+
**Invocation:** The pipeline invokes `harness-security-review` with scope `changed-files`. The skill:
|
|
322
|
+
|
|
323
|
+
- Skips its own Phase 1 (SCAN) -- reads mechanical findings from PipelineContext (Phase 2 already ran `run_security_scan`)
|
|
324
|
+
- Runs Phase 2 (REVIEW) -- OWASP baseline + stack-adaptive on changed files and their direct imports
|
|
325
|
+
- Skips Phase 3 (THREAT-MODEL) unless `--deep` was passed to code review
|
|
326
|
+
- Returns `ReviewFinding[]` with populated security fields (`cweId`, `owaspCategory`, `confidence`, `remediation`, `references`)
|
|
188
327
|
|
|
189
|
-
|
|
328
|
+
If `--deep` flag is set on code review, additionally pass `--deep` to `harness-security-review` for threat modeling.
|
|
190
329
|
|
|
191
|
-
|
|
330
|
+
**Focus areas:**
|
|
192
331
|
|
|
193
|
-
|
|
332
|
+
1. **Semantic security review** (issues mechanical scanners cannot catch):
|
|
333
|
+
- User input flowing through multiple functions to dangerous sinks (SQL, shell, HTML)
|
|
334
|
+
- Missing authorization checks on new or modified endpoints
|
|
335
|
+
- Sensitive data exposed in logs, error messages, or API responses
|
|
336
|
+
- Authentication bypass paths introduced by the change
|
|
337
|
+
- Insecure defaults in new configuration options
|
|
194
338
|
|
|
195
|
-
|
|
196
|
-
-
|
|
197
|
-
-
|
|
198
|
-
-
|
|
199
|
-
-
|
|
339
|
+
2. **Stack-adaptive focus:** Based on the project's tech stack:
|
|
340
|
+
- Node.js: prototype pollution, ReDoS, path traversal
|
|
341
|
+
- React: XSS, dangerouslySetInnerHTML, state injection
|
|
342
|
+
- Go: race conditions, integer overflow, unsafe pointer
|
|
343
|
+
- Python: pickle deserialization, SSTI, command injection
|
|
200
344
|
|
|
201
|
-
|
|
345
|
+
3. **CWE/OWASP references:** All security findings include `cweId`, `owaspCategory`, and `remediation` fields.
|
|
202
346
|
|
|
203
|
-
|
|
204
|
-
- **Provide the context package** (SHAs, description, plan reference, test evidence, harness results). Do not make the reviewer hunt for context.
|
|
205
|
-
- **State what kind of feedback you want.** "Full review" vs "architecture only" vs "test coverage check" — be specific.
|
|
347
|
+
Security findings with confirmed vulnerabilities are always `severity: 'critical'`.
|
|
206
348
|
|
|
207
|
-
|
|
349
|
+
**Dedup with mechanical scan:** The pipeline's Phase 5 (VALIDATE) uses the exclusion set from Phase 2 mechanical findings to discard any security-review finding that overlaps with an already-reported mechanical finding. This prevents duplicate reporting of the same issue.
|
|
208
350
|
|
|
209
|
-
|
|
351
|
+
**Output:** `ReviewFinding[]` with `domain: 'security'`
|
|
210
352
|
|
|
211
353
|
---
|
|
212
354
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
When you are reviewing someone else's code.
|
|
355
|
+
#### Architecture Agent (standard tier)
|
|
216
356
|
|
|
217
|
-
|
|
357
|
+
Reviews for architectural violations, dependency direction, and design pattern compliance.
|
|
218
358
|
|
|
219
|
-
|
|
220
|
-
- **Read the full diff.** Do not skim. Read every changed file. If the diff is large (>500 lines), note this as a concern — large diffs are harder to review correctly.
|
|
221
|
-
- **Check the commit history.** Are commits atomic and well-described? Or is it one giant squash with "updates"?
|
|
359
|
+
**Input:** Architecture context bundle (layer boundaries + import graph)
|
|
222
360
|
|
|
223
|
-
|
|
361
|
+
**Focus areas:**
|
|
224
362
|
|
|
225
|
-
|
|
363
|
+
- [ ] **Layer compliance:** Does the code respect the project's architectural layers? Are imports flowing in the correct direction?
|
|
364
|
+
- [ ] **Dependency direction:** Do modules depend on abstractions, not concretions? (Dependency Inversion)
|
|
365
|
+
- [ ] **Single Responsibility:** Does each module have one reason to change?
|
|
366
|
+
- [ ] **Open/Closed:** Can behavior be extended without modifying existing code?
|
|
367
|
+
- [ ] **Pattern consistency:** Does the code follow established codebase patterns? If introducing a new pattern, is it justified?
|
|
368
|
+
- [ ] **Separation of concerns:** Business logic separated from infrastructure? Each function/module does one thing?
|
|
369
|
+
- [ ] **DRY violations:** Duplicated logic that should be extracted — but NOT intentional duplication of things that will diverge.
|
|
370
|
+
- [ ] **Performance preserved:** Could restructuring introduce regressions (extra allocations, changed query patterns)?
|
|
226
371
|
|
|
227
|
-
|
|
228
|
-
harness validate # Full project health check
|
|
229
|
-
harness check-deps # Dependency boundary verification
|
|
230
|
-
harness check-docs # Documentation drift detection
|
|
231
|
-
```
|
|
372
|
+
**Output:** `ReviewFinding[]` with `domain: 'architecture'`
|
|
232
373
|
|
|
233
|
-
|
|
374
|
+
**Exit:** All four agents have returned their findings. Continue to Phase 5.
|
|
234
375
|
|
|
235
|
-
|
|
376
|
+
---
|
|
236
377
|
|
|
237
|
-
|
|
378
|
+
### Phase 5: VALIDATE
|
|
238
379
|
|
|
239
|
-
**
|
|
380
|
+
**Tier:** none (mechanical)
|
|
381
|
+
**Purpose:** Remove false positives by cross-referencing AI findings against mechanical results and graph reachability.
|
|
240
382
|
|
|
241
|
-
|
|
242
|
-
- Are responsibilities clearly divided between files?
|
|
243
|
-
- Is business logic separated from infrastructure?
|
|
383
|
+
**Steps:**
|
|
244
384
|
|
|
245
|
-
**
|
|
385
|
+
1. **Mechanical exclusion:** For each finding from Phase 4, check if the same file + line range was already flagged by a mechanical check in Phase 2. If so, discard the AI finding — the mechanical check is authoritative and the issue is already reported.
|
|
246
386
|
|
|
247
|
-
|
|
248
|
-
- Are error messages helpful for debugging?
|
|
249
|
-
- Are edge cases handled (null, empty, boundary values)?
|
|
250
|
-
- Do errors propagate correctly (not swallowed silently)?
|
|
387
|
+
2. **Graph reachability validation (if graph available):** For findings that claim an issue affects other parts of the system (e.g., "this change breaks callers"), verify via `query_graph` that the claimed dependency path exists. Discard findings with invalid reachability claims.
|
|
251
388
|
|
|
252
|
-
**
|
|
389
|
+
3. **Import-chain heuristic (fallback, no graph):** Follow imports 2 levels deep from the flagged file. If the finding claims impact on a file not reachable within 2 import hops, downgrade severity to `suggestion` rather than discarding.
|
|
253
390
|
|
|
254
|
-
|
|
255
|
-
- Are there copy-pasted blocks with minor variations?
|
|
256
|
-
- BUT: do not flag intentional duplication (sometimes two similar things should remain separate because they will diverge).
|
|
391
|
+
**Exit:** Validated finding set. Continue to Phase 6.
|
|
257
392
|
|
|
258
|
-
|
|
393
|
+
---
|
|
259
394
|
|
|
260
|
-
|
|
261
|
-
- Are abbreviations explained or avoided?
|
|
262
|
-
- Can you understand the code without reading the implementation of every called function?
|
|
395
|
+
### Phase 6: DEDUP + MERGE
|
|
263
396
|
|
|
264
|
-
|
|
397
|
+
**Tier:** none (mechanical)
|
|
398
|
+
**Purpose:** Eliminate redundant findings across agents and produce the final finding list.
|
|
265
399
|
|
|
266
|
-
**
|
|
400
|
+
**Steps:**
|
|
267
401
|
|
|
268
|
-
|
|
269
|
-
- Open/Closed: Can behavior be extended without modifying existing code?
|
|
270
|
-
- Dependency Inversion: Do modules depend on abstractions, not concretions?
|
|
402
|
+
1. **Group by location:** Group findings by `file` + overlapping `lineRange`. Two findings overlap if their line ranges intersect or are within 3 lines of each other.
|
|
271
403
|
|
|
272
|
-
**
|
|
404
|
+
2. **Merge overlapping findings:** When multiple agents flag the same location:
|
|
405
|
+
- Keep the highest `severity` from any agent
|
|
406
|
+
- Combine `evidence` arrays from all agents
|
|
407
|
+
- Preserve the `rationale` with the strongest justification
|
|
408
|
+
- Merge `domain` tags (a finding can be both `bug` and `security`)
|
|
409
|
+
- Generate a single merged `id`
|
|
273
410
|
|
|
274
|
-
|
|
275
|
-
-
|
|
276
|
-
-
|
|
411
|
+
3. **Assign final severity:**
|
|
412
|
+
- **Critical** — Must fix before merge. Bugs, security vulnerabilities, failing harness checks, architectural violations that break boundaries.
|
|
413
|
+
- **Important** — Should fix before merge. Missing error handling, missing tests for critical paths, unclear naming.
|
|
414
|
+
- **Suggestion** — Consider for improvement. Style preferences, minor optimizations, alternative approaches. Does not block merge.
|
|
277
415
|
|
|
278
|
-
**
|
|
416
|
+
**Exit:** Deduplicated, severity-assigned finding list. Continue to Phase 7.
|
|
279
417
|
|
|
280
|
-
|
|
281
|
-
- If introducing a new pattern, is it justified and documented?
|
|
418
|
+
---
|
|
282
419
|
|
|
283
|
-
|
|
420
|
+
### Phase 7: OUTPUT
|
|
284
421
|
|
|
285
|
-
**
|
|
422
|
+
**Tier:** none
|
|
423
|
+
**Purpose:** Deliver the review in the requested format.
|
|
286
424
|
|
|
287
|
-
|
|
288
|
-
- Do tests make meaningful assertions (not just "does not throw")?
|
|
289
|
-
- Are tests deterministic (no flaky timing, network, or randomness)?
|
|
425
|
+
#### Text Output (default)
|
|
290
426
|
|
|
291
|
-
|
|
427
|
+
When rendering the review output, use conventional markdown patterns:
|
|
292
428
|
|
|
293
|
-
|
|
294
|
-
- Are error paths tested (invalid input, network failures, permission errors)?
|
|
429
|
+
For strengths:
|
|
295
430
|
|
|
296
|
-
|
|
431
|
+
```
|
|
432
|
+
**[STRENGTH]** Clean separation between route handler and service logic
|
|
433
|
+
```
|
|
297
434
|
|
|
298
|
-
|
|
299
|
-
- Are critical paths covered (not just happy paths)?
|
|
435
|
+
For issues by severity:
|
|
300
436
|
|
|
301
|
-
|
|
437
|
+
```
|
|
438
|
+
**[CRITICAL]** api/routes/users.ts:12-15 — Direct import from db/queries.ts bypasses service layer
|
|
439
|
+
**[IMPORTANT]** services/user-service.ts:45 — createUser does not handle duplicate email
|
|
440
|
+
**[SUGGESTION]** Consider extracting validation into a shared utility
|
|
441
|
+
```
|
|
302
442
|
|
|
303
|
-
Structure
|
|
443
|
+
Structure the review as:
|
|
304
444
|
|
|
305
445
|
**Strengths:** What is done well. Be specific. "Clean separation between X and Y" is useful. "Looks good" is not.
|
|
306
446
|
|
|
307
|
-
**Issues:**
|
|
447
|
+
**Issues:** List each finding from Phase 6, grouped by severity:
|
|
308
448
|
|
|
309
|
-
- **Critical
|
|
310
|
-
- **Important
|
|
311
|
-
- **Suggestion
|
|
449
|
+
- **Critical:** [findings with severity 'critical']
|
|
450
|
+
- **Important:** [findings with severity 'important']
|
|
451
|
+
- **Suggestion:** [findings with severity 'suggestion']
|
|
312
452
|
|
|
313
453
|
For each issue, provide:
|
|
314
454
|
|
|
315
|
-
1. The specific location (file and line
|
|
316
|
-
2. What the problem is
|
|
317
|
-
3. Why it matters
|
|
318
|
-
4. A suggested fix (if
|
|
455
|
+
1. The specific location (file and line range)
|
|
456
|
+
2. What the problem is (title)
|
|
457
|
+
3. Why it matters (rationale)
|
|
458
|
+
4. A suggested fix (if available)
|
|
319
459
|
|
|
320
460
|
**Assessment:** One of:
|
|
321
461
|
|
|
322
462
|
- **Approve** — No critical or important issues. Ready to merge.
|
|
323
|
-
- **Request Changes** — Critical or important issues must be addressed.
|
|
324
|
-
- **Comment** — Observations only, no blocking issues
|
|
463
|
+
- **Request Changes** — Critical or important issues must be addressed.
|
|
464
|
+
- **Comment** — Observations only, no blocking issues.
|
|
465
|
+
|
|
466
|
+
**Exit code:** 0 for Approve/Comment, 1 for Request Changes.
|
|
467
|
+
|
|
468
|
+
#### Inline GitHub Comments (`--comment` flag)
|
|
469
|
+
|
|
470
|
+
When `--comment` is set, post findings as inline PR comments via `gh` CLI or GitHub MCP:
|
|
471
|
+
|
|
472
|
+
- **Small fixes** (suggestion is < 10 lines): Post as committable suggestion block using GitHub's suggestion syntax.
|
|
473
|
+
- **Large fixes** (suggestion is >= 10 lines or no concrete suggestion): Post description + rationale as a regular comment.
|
|
474
|
+
- **Summary comment:** Post the Strengths/Issues/Assessment as a top-level PR review comment.
|
|
475
|
+
|
|
476
|
+
```bash
|
|
477
|
+
# Post a review with inline comments
|
|
478
|
+
gh pr review --event APPROVE|REQUEST_CHANGES|COMMENT --body "<summary>"
|
|
479
|
+
|
|
480
|
+
# Post inline comment with suggestion
|
|
481
|
+
gh api repos/{owner}/{repo}/pulls/{pr}/comments \
|
|
482
|
+
--field body="<rationale>\n\`\`\`suggestion\n<fix>\n\`\`\`" \
|
|
483
|
+
--field path="<file>" --field line=<line>
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### Review Acceptance
|
|
487
|
+
|
|
488
|
+
After delivering the review output, request acceptance:
|
|
489
|
+
|
|
490
|
+
```json
|
|
491
|
+
emit_interaction({
|
|
492
|
+
path: "<project-root>",
|
|
493
|
+
type: "confirmation",
|
|
494
|
+
confirmation: {
|
|
495
|
+
text: "Review complete: <Assessment>. Accept review?",
|
|
496
|
+
context: "<N critical, N important, N suggestion findings>"
|
|
497
|
+
}
|
|
498
|
+
})
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
#### Handoff and Transition
|
|
502
|
+
|
|
503
|
+
After delivering the review output, write the handoff and conditionally transition:
|
|
504
|
+
|
|
505
|
+
Write `.harness/handoff.json`:
|
|
506
|
+
|
|
507
|
+
```json
|
|
508
|
+
{
|
|
509
|
+
"fromSkill": "harness-code-review",
|
|
510
|
+
"phase": "OUTPUT",
|
|
511
|
+
"summary": "<assessment summary>",
|
|
512
|
+
"assessment": "approve | request-changes | comment",
|
|
513
|
+
"findingCount": { "critical": 0, "important": 0, "suggestion": 0 },
|
|
514
|
+
"artifacts": ["<reviewed files>"]
|
|
515
|
+
}
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
**If assessment is "approve":**
|
|
519
|
+
|
|
520
|
+
Call `emit_interaction`:
|
|
521
|
+
|
|
522
|
+
```json
|
|
523
|
+
{
|
|
524
|
+
"type": "transition",
|
|
525
|
+
"transition": {
|
|
526
|
+
"completedPhase": "review",
|
|
527
|
+
"suggestedNext": "merge",
|
|
528
|
+
"reason": "Review approved with no blocking issues",
|
|
529
|
+
"artifacts": ["<reviewed files>"],
|
|
530
|
+
"requiresConfirmation": true,
|
|
531
|
+
"summary": "Review approved. <N> suggestions noted. Ready to create PR or merge."
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
If the user confirms: proceed to create PR or merge.
|
|
537
|
+
If the user declines: stop. The handoff is written for future invocation.
|
|
538
|
+
|
|
539
|
+
**If assessment is "request-changes":**
|
|
540
|
+
|
|
541
|
+
Do NOT emit a transition. Surface the critical and important findings to the user for resolution. After fixes are applied, re-run the review pipeline.
|
|
542
|
+
|
|
543
|
+
**If assessment is "comment":**
|
|
544
|
+
|
|
545
|
+
Do NOT emit a transition. Observations have been delivered. No further action is implied.
|
|
325
546
|
|
|
326
547
|
---
|
|
327
548
|
|
|
328
|
-
|
|
549
|
+
## Role A: Requesting a Review
|
|
329
550
|
|
|
330
|
-
|
|
551
|
+
_This section is not part of the pipeline. It documents the process for requesting a review from others._
|
|
331
552
|
|
|
332
|
-
|
|
553
|
+
When you have completed work and need it reviewed:
|
|
333
554
|
|
|
334
|
-
|
|
555
|
+
1. **Prepare the review context:**
|
|
556
|
+
- Commit range (exact SHAs or branch diff)
|
|
557
|
+
- Description (WHAT changed and WHY — not a commit-by-commit retelling)
|
|
558
|
+
- Plan reference (link to spec/plan if applicable)
|
|
559
|
+
- Test evidence (`harness validate` and test suite results)
|
|
560
|
+
- Harness check results (`harness validate`, `harness check-deps`)
|
|
335
561
|
|
|
336
|
-
|
|
562
|
+
2. **Dispatch the review:** Identify the right reviewer, provide the context package, state what kind of feedback you want.
|
|
337
563
|
|
|
338
|
-
|
|
564
|
+
3. **Wait.** Do not modify code under review. Note issues but do not push fixes until review is complete.
|
|
339
565
|
|
|
340
|
-
|
|
341
|
-
- **Is it correct?** Verify the reviewer's claim. Read the code they reference. Run the scenario they describe. Reviewers make mistakes too.
|
|
342
|
-
- **Is it actionable?** Vague feedback ("this could be better") requires clarification. Ask for specific suggestions.
|
|
566
|
+
---
|
|
343
567
|
|
|
344
|
-
|
|
568
|
+
## Role C: Responding to Review Feedback
|
|
345
569
|
|
|
346
|
-
|
|
347
|
-
- **Do NOT implement every suggestion.** Apply the YAGNI check to every suggestion: Does this change serve a current, concrete need? If it is speculative ("you might need this later"), push back.
|
|
348
|
-
- **Do NOT make changes you do not understand.** If a reviewer suggests a change and you cannot explain why it is better, do not make it. Ask them to explain.
|
|
349
|
-
- **DO acknowledge when feedback is correct.** "Good catch, fixing" is appropriate when the reviewer found a real issue.
|
|
350
|
-
- **DO push back when feedback contradicts the plan or spec.** The plan was approved. If review feedback wants to change the plan, that is a scope discussion, not a code review issue.
|
|
570
|
+
_This section is not part of the pipeline. It documents the process for responding to review feedback._
|
|
351
571
|
|
|
352
|
-
|
|
572
|
+
1. **Read all feedback first.** Understand the full picture before responding.
|
|
353
573
|
|
|
354
|
-
For each
|
|
574
|
+
2. **Verify before implementing.** For each piece of feedback:
|
|
575
|
+
- Do you understand it? If not, ask for clarification.
|
|
576
|
+
- Is it correct? Verify the claim — reviewers make mistakes too.
|
|
577
|
+
- Is it actionable? Vague feedback requires clarification.
|
|
355
578
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
579
|
+
3. **Technical rigor over social performance:**
|
|
580
|
+
- Do NOT agree with feedback just to be agreeable. Push back with evidence if wrong.
|
|
581
|
+
- Do NOT implement every suggestion. Apply YAGNI.
|
|
582
|
+
- Do NOT make changes you do not understand. Ask for explanation.
|
|
583
|
+
- DO acknowledge when feedback is correct.
|
|
584
|
+
- DO push back when feedback contradicts the approved plan/spec.
|
|
360
585
|
|
|
361
|
-
|
|
586
|
+
4. **Implement fixes:** For each accepted piece of feedback: make the change, run tests, run `harness validate` and `harness check-deps`, commit with a message referencing the review feedback.
|
|
362
587
|
|
|
363
|
-
|
|
588
|
+
5. **Re-request review** with summary of changes, which feedback was addressed vs. pushed back on, and fresh harness check results.
|
|
364
589
|
|
|
365
|
-
|
|
366
|
-
- Which feedback was addressed and which was pushed back on (with reasons)
|
|
367
|
-
- Fresh harness check results
|
|
590
|
+
---
|
|
368
591
|
|
|
369
592
|
## Harness Integration
|
|
370
593
|
|
|
371
|
-
- **`harness validate`** — Run
|
|
372
|
-
- **`harness check-deps`** — Run
|
|
373
|
-
- **`harness check-docs`** — Run
|
|
374
|
-
- **`harness cleanup`** — Optional during
|
|
594
|
+
- **`harness validate`** — Run in Phase 2 (MECHANICAL). Must pass for the pipeline to continue to AI review.
|
|
595
|
+
- **`harness check-deps`** — Run in Phase 2 (MECHANICAL). Failures are Critical issues that stop the pipeline.
|
|
596
|
+
- **`harness check-docs`** — Run in Phase 2 (MECHANICAL). Documentation drift findings are recorded for the exclusion set.
|
|
597
|
+
- **`harness cleanup`** — Optional check during Phase 2 for entropy accumulation in changed files.
|
|
598
|
+
- **Graph queries** — Used in Phase 3 (CONTEXT) for dependency-scoped context and in Phase 5 (VALIDATE) for reachability verification. Graceful fallback when no graph exists.
|
|
599
|
+
- **`emit_interaction`** -- Call after review approval to suggest transitioning to merge/PR creation. Only emitted on APPROVE assessment. Uses confirmed transition (waits for user approval).
|
|
375
600
|
|
|
376
601
|
## Success Criteria
|
|
377
602
|
|
|
378
|
-
-
|
|
379
|
-
-
|
|
380
|
-
-
|
|
381
|
-
-
|
|
603
|
+
- The pipeline runs all 7 phases in order when invoked manually (skipping GATE)
|
|
604
|
+
- The pipeline runs all 7 phases including GATE when invoked with `--ci`
|
|
605
|
+
- Mechanical failures in Phase 2 stop the pipeline before AI review (Phase 4)
|
|
606
|
+
- Each Phase 4 subagent receives only its domain-scoped context, not the full diff
|
|
607
|
+
- All findings use the ReviewFinding schema
|
|
608
|
+
- Mechanical findings from Phase 2 are excluded from Phase 4 output in Phase 5
|
|
609
|
+
- Cross-agent duplicate findings are merged in Phase 6
|
|
610
|
+
- Text output uses Strengths/Issues/Assessment format with Critical/Important/Suggestion severity
|
|
611
|
+
- `--comment` posts inline GitHub comments with committable suggestion blocks for small fixes
|
|
612
|
+
- `--deep` adds threat modeling to the Security agent
|
|
382
613
|
- No code merges with Critical issues unresolved
|
|
383
614
|
- No code merges with failing harness checks
|
|
384
|
-
- Response to feedback is verified before implementation
|
|
615
|
+
- Response to feedback (Role C) is verified before implementation
|
|
385
616
|
- Pushback on incorrect feedback is evidence-based
|
|
386
617
|
|
|
387
618
|
## Examples
|
|
388
619
|
|
|
389
|
-
### Example:
|
|
620
|
+
### Example: Pipeline Review of a New API Endpoint
|
|
621
|
+
|
|
622
|
+
**Phase 1 (GATE):** Skipped — manual invocation.
|
|
623
|
+
|
|
624
|
+
**Phase 2 (MECHANICAL):** `harness validate` passes. `harness check-deps` passes. Security scan finds no issues. `tsc --noEmit` passes. Lint passes.
|
|
625
|
+
|
|
626
|
+
**Phase 3 (CONTEXT):** Change type detected as `feature` (commit prefix `feat:`). Context bundles assembled:
|
|
627
|
+
|
|
628
|
+
- Compliance: `CLAUDE.md` + changed files
|
|
629
|
+
- Bug detection: `api/routes/users.ts`, `services/user-service.ts`, `db/queries.ts`
|
|
630
|
+
- Security: `api/routes/users.ts` (endpoint), `services/user-service.ts` (data flow)
|
|
631
|
+
- Architecture: import graph showing `routes → services → db` layers
|
|
632
|
+
|
|
633
|
+
**Phase 4 (FAN-OUT):** Four agents run in parallel:
|
|
634
|
+
|
|
635
|
+
- Compliance agent: 0 findings (spec alignment confirmed)
|
|
636
|
+
- Bug detection agent: 1 finding (missing duplicate email handling in createUser)
|
|
637
|
+
- Security agent: 0 findings (no vulnerabilities detected)
|
|
638
|
+
- Architecture agent: 1 finding (routes/users.ts imports directly from db/queries.ts)
|
|
639
|
+
|
|
640
|
+
**Phase 5 (VALIDATE):** No mechanical exclusions apply. Architecture finding validated by `check-deps` output showing layer violation.
|
|
641
|
+
|
|
642
|
+
**Phase 6 (DEDUP+MERGE):** No overlaps — 2 distinct findings in different files.
|
|
643
|
+
|
|
644
|
+
**Phase 7 (OUTPUT):**
|
|
390
645
|
|
|
391
646
|
**Strengths:**
|
|
392
647
|
|
|
@@ -398,22 +653,19 @@ After addressing all feedback, re-request review with:
|
|
|
398
653
|
|
|
399
654
|
**Critical:**
|
|
400
655
|
|
|
401
|
-
- `
|
|
656
|
+
- `api/routes/users.ts:12-15` — Direct import from `db/queries.ts` bypasses service layer. Must route through `services/user-service.ts`. (domain: architecture, validatedBy: heuristic)
|
|
402
657
|
|
|
403
658
|
**Important:**
|
|
404
659
|
|
|
405
|
-
- `services/user-service.ts:45` — `createUser` does not handle duplicate email.
|
|
406
|
-
- Missing test for concurrent creation with same email.
|
|
407
|
-
|
|
408
|
-
**Suggestion:**
|
|
660
|
+
- `services/user-service.ts:45` — `createUser` does not handle duplicate email. Database will throw constraint violation surfacing as 500. Should catch and return 409. (domain: bug, validatedBy: heuristic)
|
|
409
661
|
|
|
410
|
-
|
|
662
|
+
**Suggestion:** (none)
|
|
411
663
|
|
|
412
664
|
**Assessment:** Request Changes — one critical layer violation and one important missing error handler.
|
|
413
665
|
|
|
414
666
|
## Gates
|
|
415
667
|
|
|
416
|
-
- **Never skip
|
|
668
|
+
- **Never skip mechanical checks without `--no-mechanical`.** If mechanical checks have not run (in CI or locally), they must run in Phase 2 before AI review.
|
|
417
669
|
- **Never merge with failing harness checks.** `harness validate` and `harness check-deps` must pass. This is a Critical issue, always.
|
|
418
670
|
- **Never implement feedback without verification.** Before changing code based on review feedback, verify the feedback is correct. Run the scenario. Read the code. Do not blindly comply.
|
|
419
671
|
- **Never agree performatively.** "Sure, I'll change that" without understanding why is forbidden. Every change must be understood.
|
|
@@ -421,8 +673,9 @@ After addressing all feedback, re-request review with:
|
|
|
421
673
|
|
|
422
674
|
## Escalation
|
|
423
675
|
|
|
424
|
-
- **When reviewers disagree:** If two reviewers give contradictory feedback, escalate to the human or tech lead.
|
|
425
|
-
- **When review feedback changes the plan:** If feedback requires
|
|
426
|
-
- **When you cannot reproduce a reported issue:** Ask the reviewer for exact reproduction steps.
|
|
427
|
-
- **When review is taking more than 2 rounds:**
|
|
428
|
-
- **When harness checks fail and you believe the check is wrong:** Do not override or skip
|
|
676
|
+
- **When reviewers disagree:** If two reviewers give contradictory feedback, escalate to the human or tech lead.
|
|
677
|
+
- **When review feedback changes the plan:** If feedback requires altering the approved plan or spec, pause the review. The plan must be updated first.
|
|
678
|
+
- **When you cannot reproduce a reported issue:** Ask the reviewer for exact reproduction steps.
|
|
679
|
+
- **When review is taking more than 2 rounds:** Something is fundamentally misaligned. Stop and discuss the approach synchronously.
|
|
680
|
+
- **When harness checks fail and you believe the check is wrong:** Do not override or skip. File an issue against the harness configuration.
|
|
681
|
+
- **When the pipeline produces a false positive after validation:** Add the pattern to `.harness/review-learnings.md` in the Noise / False Positives section for future calibration.
|