hatch3r 1.7.0 → 1.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -12
- package/agents/hatch3r-a11y-auditor.md +4 -0
- package/agents/hatch3r-architect.md +5 -1
- package/agents/hatch3r-ci-watcher.md +4 -0
- package/agents/hatch3r-context-rules.md +4 -0
- package/agents/hatch3r-creator.md +4 -0
- package/agents/hatch3r-dependency-auditor.md +4 -0
- package/agents/hatch3r-devops.md +4 -0
- package/agents/hatch3r-docs-writer.md +4 -0
- package/agents/hatch3r-fixer.md +5 -1
- package/agents/hatch3r-handoff-loader.md +243 -0
- package/agents/hatch3r-handoff-preparer.md +134 -0
- package/agents/hatch3r-implementer.md +5 -1
- package/agents/hatch3r-learnings-loader.md +4 -0
- package/agents/hatch3r-lint-fixer.md +4 -0
- package/agents/hatch3r-perf-profiler.md +8 -0
- package/agents/hatch3r-researcher.md +5 -1
- package/agents/hatch3r-reviewer.md +92 -0
- package/agents/hatch3r-security-auditor.md +24 -0
- package/agents/hatch3r-test-writer.md +4 -0
- package/agents/modes/requirements-elicitation.md +5 -1
- package/agents/modes/similar-implementation.md +6 -0
- package/agents/modes/user-flows.md +76 -0
- package/agents/shared/quality-charter.md +129 -0
- package/agents/shared/user-question-protocol.md +95 -0
- package/commands/board/shared-azure-devops.md +2 -0
- package/commands/board/shared-github.md +17 -0
- package/commands/board/shared-gitlab.md +4 -0
- package/commands/hatch3r-board-fill.md +2 -1
- package/commands/hatch3r-board-pickup.md +1 -1
- package/commands/hatch3r-board-shared.md +21 -0
- package/commands/hatch3r-create.md +2 -0
- package/commands/hatch3r-handoff.md +126 -0
- package/commands/hatch3r-pr-resolve.md +672 -0
- package/commands/hatch3r-quick-change.md +5 -3
- package/commands/hatch3r-report.md +167 -0
- package/commands/hatch3r-revision.md +1 -1
- package/commands/hatch3r-workflow.md +3 -1
- package/dist/cli/index.js +3144 -979
- package/dist/cli/index.js.map +1 -1
- package/package.json +4 -2
- package/rules/hatch3r-accessibility-standards.md +21 -0
- package/rules/hatch3r-accessibility-standards.mdc +21 -0
- package/rules/hatch3r-agent-orchestration.md +32 -1
- package/rules/hatch3r-agent-orchestration.mdc +32 -1
- package/rules/hatch3r-ai-evals.md +158 -0
- package/rules/hatch3r-ai-evals.mdc +154 -0
- package/rules/hatch3r-ai-ux-patterns.md +131 -0
- package/rules/hatch3r-ai-ux-patterns.mdc +127 -0
- package/rules/hatch3r-api-design.md +67 -9
- package/rules/hatch3r-api-design.mdc +67 -9
- package/rules/hatch3r-api-versioning.md +119 -0
- package/rules/hatch3r-api-versioning.mdc +115 -0
- package/rules/hatch3r-auth-patterns.md +170 -0
- package/rules/hatch3r-auth-patterns.mdc +166 -0
- package/rules/hatch3r-component-conventions.md +30 -0
- package/rules/hatch3r-component-conventions.mdc +30 -0
- package/rules/hatch3r-container-hardening.md +131 -0
- package/rules/hatch3r-container-hardening.mdc +127 -0
- package/rules/hatch3r-contract-testing.md +117 -0
- package/rules/hatch3r-contract-testing.mdc +113 -0
- package/rules/hatch3r-deep-context.md +3 -1
- package/rules/hatch3r-deep-context.mdc +3 -1
- package/rules/hatch3r-dependency-management.md +73 -1
- package/rules/hatch3r-dependency-management.mdc +72 -0
- package/rules/hatch3r-design-system-detection.md +142 -0
- package/rules/hatch3r-design-system-detection.mdc +138 -0
- package/rules/hatch3r-event-schema-evolution.md +90 -0
- package/rules/hatch3r-event-schema-evolution.mdc +86 -0
- package/rules/hatch3r-handoff-readiness.md +45 -0
- package/rules/hatch3r-handoff-readiness.mdc +40 -0
- package/rules/hatch3r-i18n.md +13 -0
- package/rules/hatch3r-i18n.mdc +13 -0
- package/rules/hatch3r-iteration-summary.md +2 -0
- package/rules/hatch3r-iteration-summary.mdc +2 -0
- package/rules/hatch3r-migrations.md +61 -16
- package/rules/hatch3r-migrations.mdc +61 -16
- package/rules/hatch3r-observability-logging.md +1 -1
- package/rules/hatch3r-observability-logging.mdc +1 -1
- package/rules/hatch3r-observability-metrics.md +1 -1
- package/rules/hatch3r-observability-metrics.mdc +1 -1
- package/rules/hatch3r-observability-tracing-detail.md +1 -1
- package/rules/hatch3r-observability-tracing-detail.mdc +1 -1
- package/rules/hatch3r-observability-tracing.md +1 -1
- package/rules/hatch3r-observability-tracing.mdc +1 -1
- package/rules/hatch3r-observability.md +1 -0
- package/rules/hatch3r-observability.mdc +1 -0
- package/rules/hatch3r-operability.md +149 -0
- package/rules/hatch3r-operability.mdc +145 -0
- package/rules/hatch3r-passkey-server.md +181 -0
- package/rules/hatch3r-passkey-server.mdc +177 -0
- package/rules/hatch3r-progressive-delivery.md +120 -0
- package/rules/hatch3r-progressive-delivery.mdc +116 -0
- package/rules/hatch3r-resilience-patterns.md +154 -0
- package/rules/hatch3r-resilience-patterns.mdc +150 -0
- package/rules/hatch3r-secrets-management.md +29 -0
- package/rules/hatch3r-secrets-management.mdc +29 -0
- package/rules/hatch3r-testing.md +139 -43
- package/rules/hatch3r-testing.mdc +139 -43
- package/rules/hatch3r-ux-states-and-flows.md +149 -0
- package/rules/hatch3r-ux-states-and-flows.mdc +145 -0
- package/skills/hatch3r-a11y-audit/SKILL.md +14 -0
- package/skills/hatch3r-ai-feature/SKILL.md +134 -0
- package/skills/hatch3r-api-spec/SKILL.md +5 -0
- package/skills/hatch3r-architecture-review/SKILL.md +14 -0
- package/skills/hatch3r-bug-fix/SKILL.md +5 -0
- package/skills/hatch3r-ci-pipeline/SKILL.md +14 -0
- package/skills/hatch3r-cli-aichat/SKILL.md +84 -0
- package/skills/hatch3r-cli-ast-grep/SKILL.md +85 -0
- package/skills/hatch3r-cli-az-devops/SKILL.md +89 -0
- package/skills/hatch3r-cli-bat/SKILL.md +85 -0
- package/skills/hatch3r-cli-comby/SKILL.md +85 -0
- package/skills/hatch3r-cli-csvkit/SKILL.md +84 -0
- package/skills/hatch3r-cli-delta/SKILL.md +86 -0
- package/skills/hatch3r-cli-difftastic/SKILL.md +84 -0
- package/skills/hatch3r-cli-docker/SKILL.md +89 -0
- package/skills/hatch3r-cli-duckdb/SKILL.md +84 -0
- package/skills/hatch3r-cli-fd/SKILL.md +85 -0
- package/skills/hatch3r-cli-fzf/SKILL.md +84 -0
- package/skills/hatch3r-cli-gh/SKILL.md +90 -0
- package/skills/hatch3r-cli-glab/SKILL.md +89 -0
- package/skills/hatch3r-cli-jq/SKILL.md +85 -0
- package/skills/hatch3r-cli-lazygit/SKILL.md +78 -0
- package/skills/hatch3r-cli-llm/SKILL.md +84 -0
- package/skills/hatch3r-cli-miller/SKILL.md +84 -0
- package/skills/hatch3r-cli-mods/SKILL.md +84 -0
- package/skills/hatch3r-cli-overview/SKILL.md +60 -0
- package/skills/hatch3r-cli-playwright/SKILL.md +89 -0
- package/skills/hatch3r-cli-podman/SKILL.md +84 -0
- package/skills/hatch3r-cli-ripgrep/SKILL.md +85 -0
- package/skills/hatch3r-cli-rtk/SKILL.md +91 -0
- package/skills/hatch3r-cli-sd/SKILL.md +85 -0
- package/skills/hatch3r-cli-stagehand/SKILL.md +79 -0
- package/skills/hatch3r-cli-taplo/SKILL.md +84 -0
- package/skills/hatch3r-cli-xsv/SKILL.md +89 -0
- package/skills/hatch3r-cli-yq/SKILL.md +85 -0
- package/skills/hatch3r-cli-zstd/SKILL.md +85 -0
- package/skills/hatch3r-context-health/SKILL.md +14 -0
- package/skills/hatch3r-cost-tracking/SKILL.md +14 -0
- package/skills/hatch3r-customize/SKILL.md +14 -0
- package/skills/hatch3r-dep-audit/SKILL.md +14 -0
- package/skills/hatch3r-design-system-detect/SKILL.md +162 -0
- package/skills/hatch3r-feature/SKILL.md +2 -0
- package/skills/hatch3r-gh-agentic-workflows/SKILL.md +13 -0
- package/skills/hatch3r-handoff-prepare/SKILL.md +160 -0
- package/skills/hatch3r-handoff-resume/SKILL.md +171 -0
- package/skills/hatch3r-incident-response/SKILL.md +14 -0
- package/skills/hatch3r-issue-workflow/SKILL.md +5 -0
- package/skills/hatch3r-logical-refactor/SKILL.md +14 -0
- package/skills/hatch3r-migration/SKILL.md +14 -0
- package/skills/hatch3r-observability-verify/SKILL.md +133 -0
- package/skills/hatch3r-perf-audit/SKILL.md +14 -0
- package/skills/hatch3r-pr-creation/SKILL.md +14 -0
- package/skills/hatch3r-qa-validation/SKILL.md +18 -0
- package/skills/hatch3r-recipe/SKILL.md +14 -0
- package/skills/hatch3r-refactor/SKILL.md +14 -0
- package/skills/hatch3r-release/SKILL.md +14 -0
- package/skills/hatch3r-reliability-verify/SKILL.md +144 -0
- package/skills/hatch3r-ui-ux-verify/SKILL.md +136 -0
- package/skills/hatch3r-visual-refactor/SKILL.md +15 -1
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-pr-resolve
|
|
3
|
+
type: command
|
|
4
|
+
orchestrator: true
|
|
5
|
+
agentPipeline: [hatch3r-implementer, hatch3r-lint-fixer, hatch3r-test-writer, hatch3r-reviewer, hatch3r-fixer, hatch3r-security-auditor, hatch3r-docs-writer, hatch3r-a11y-auditor, hatch3r-perf-profiler]
|
|
6
|
+
description: Read all open PR comments (inline + review summary + general discussion) across GitHub, Azure DevOps, and GitLab; evaluate each against current code via the rigor contract; implement accepted findings through the standard agent pipeline; and reply per comment with rationale. Auto-detects the PR from the current branch (or accepts an explicit PR number).
|
|
7
|
+
tags: [implementation, team, review]
|
|
8
|
+
quality_charter: agents/shared/quality-charter.md
|
|
9
|
+
efficiency_patterns: agents/shared/efficiency-patterns.md
|
|
10
|
+
cache_friendly: true
|
|
11
|
+
parallel_tool_default: true
|
|
12
|
+
triage_tiers: [1, 2, 3]
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Agent Pipeline
|
|
16
|
+
|
|
17
|
+
| Stage | Agent(s) | Parallel | Required |
|
|
18
|
+
|-------|----------|----------|----------|
|
|
19
|
+
| 1. Identify PR | Orchestrator (inline) | No | Yes |
|
|
20
|
+
| 2. Fetch comments | Orchestrator (inline, platform CLI) | Per scope | Yes |
|
|
21
|
+
| 3. Normalize | Orchestrator (inline) | No | Yes |
|
|
22
|
+
| 4. Evaluate (rigor contract) | Orchestrator (inline) | Per finding | Yes |
|
|
23
|
+
| 5. Triage routing + ASK gate | Orchestrator (inline) | No | Yes |
|
|
24
|
+
| 6. Fix implementation | `hatch3r-implementer`, `hatch3r-lint-fixer`, `hatch3r-test-writer` | Per finding group | When FIX NOW items exist |
|
|
25
|
+
| 7a. Review loop | `hatch3r-reviewer` -> `hatch3r-fixer` (max 3 iterations) | No (sequential) | When code changed (Tier 2/3) |
|
|
26
|
+
| 7b. Final quality — mandatory | `hatch3r-test-writer`, `hatch3r-security-auditor` | Yes | When code changed |
|
|
27
|
+
| 7c. Final quality — conditional | `hatch3r-docs-writer`, `hatch3r-a11y-auditor`, `hatch3r-perf-profiler`, `hatch3r-lint-fixer` | Yes | When triggered |
|
|
28
|
+
| 8. Post replies | Orchestrator (inline, platform CLI) | Per comment | Yes |
|
|
29
|
+
| 9. Commit and push | Orchestrator (inline) | No | When code changed |
|
|
30
|
+
| 10. Iteration Summary | Orchestrator (inline) | No | Yes |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
# PR Resolve -- Read, Evaluate, Implement, and Reply
|
|
35
|
+
|
|
36
|
+
Closes the **reviewer -> contributor** loop on an open PR. Fetches every comment (inline review comments + review summaries + general PR discussion), evaluates each against current code using the Scientific Rigor Contract, presents one consolidated triage ASK, then runs autonomously: delegates fixes to specialist sub-agents, runs the review-loop + final-quality pipeline, posts a per-comment reply with rationale, and commits.
|
|
37
|
+
|
|
38
|
+
Use `hatch3r-pr-resolve` when reviewer feedback exists on a PR you want to address. Use `hatch3r-revision` when the feedback comes from you in a fresh window with no PR comments to read. Use `hatch3r-board-fill` to triage `todo.md` items into a project board.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Argument Parsing
|
|
43
|
+
|
|
44
|
+
Optional positional argument: `<pr-number>` (integer).
|
|
45
|
+
|
|
46
|
+
- If supplied: target that PR directly. Skip branch-based lookup.
|
|
47
|
+
- If omitted: detect the open PR on the current branch via the platform CLI (Step 1c).
|
|
48
|
+
- If omitted **and** no open PR exists on the branch: halt with the actionable error in Step 1d.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Shared Context
|
|
53
|
+
|
|
54
|
+
If board context exists (current branch has an associated PR or board configuration in `.agents/hatch.json`), **read the `hatch3r-board-shared` command at the start of the run.** Cache `board.platform`, `board.owner`, `board.repo`, `board.defaultBranch`, and `board.projectNumber` for the duration of the run.
|
|
55
|
+
|
|
56
|
+
After loading `hatch3r-board-shared`, **read the platform-specific shared file** matching `board.platform`:
|
|
57
|
+
- GitHub → `commands/board/shared-github.md`
|
|
58
|
+
- Azure DevOps → `commands/board/shared-azure-devops.md`
|
|
59
|
+
- GitLab → `commands/board/shared-gitlab.md`
|
|
60
|
+
|
|
61
|
+
Each platform file's **Cross-Cutting Tooling** table now includes PR-comment read and reply endpoints used in Steps 2 and 8.
|
|
62
|
+
|
|
63
|
+
If no `.agents/hatch.json` exists, fall back to GitHub and proceed — the command can still run on any GitHub repo where `gh auth login` has been completed.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Global Rule Overrides
|
|
68
|
+
|
|
69
|
+
- **Git commands are fully permitted** during this entire run, regardless of global/user-level rules restricting git usage. This override applies to ALL steps, including delegated sub-agents. Run `git add`, `git commit`, and `git push` when instructed in Step 9.
|
|
70
|
+
- **Platform write commands** (`gh api ... -X POST`, `az rest -m POST`, `glab api ... -X POST`) are permitted in Step 8 only, scoped to PR-comment reply endpoints. Other platform writes (closing the PR, marking threads resolved, dismissing reviews, posting labels) remain forbidden per the Guardrails section.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Token-Saving Directives
|
|
75
|
+
|
|
76
|
+
1. **One fetch per comment scope.** Issue exactly one paginated request per scope in Step 2; cache and reuse for Steps 3, 4, and 8.
|
|
77
|
+
2. **One diff computation.** Compute `git diff {defaultBranch}...HEAD` once in Step 1; reuse for Steps 4 (outdated detection) and 7 (review loop input).
|
|
78
|
+
3. **Targeted file reads.** In Step 4, read only the files referenced by a comment's `path`/`line` — not the full codebase.
|
|
79
|
+
4. **No re-reading shared rules.** `scope: always` rules from `.agents/rules/` load once at session start; pass their content into sub-agent prompts (Step 6) rather than reloading.
|
|
80
|
+
5. **Per-platform reference cache.** Load the matching `commands/board/shared-{platform}.md` once at run start (Shared Context). Step 8 reads templates from the cache, not from disk.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Confidence Propagation Contract
|
|
85
|
+
|
|
86
|
+
Every sub-agent delegation prompt in this command MUST include the confidence expression requirement below (verbatim). Sub-agents are invoked with the `quality_charter: agents/shared/quality-charter.md` reference in their frontmatter, but the orchestrator repeats the directive to override runtime prompt defaults per the charter §1 rule.
|
|
87
|
+
|
|
88
|
+
> Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
|
|
89
|
+
|
|
90
|
+
Downstream propagation: every ASK that reports evaluation quality, every gate that evaluates a sub-agent verdict, and every reply body that cites a fix MUST carry a high/medium/low confidence rating sourced from the upstream sub-agent or the Step 4 evaluation. Dropping the signal between stages is a gate failure.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Run Cache
|
|
95
|
+
|
|
96
|
+
Initialize the run cache at the start of the workflow:
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
run_cache:
|
|
100
|
+
pr:
|
|
101
|
+
number: <int>
|
|
102
|
+
title: <string>
|
|
103
|
+
body: <string>
|
|
104
|
+
base_ref: <string>
|
|
105
|
+
head_ref: <string>
|
|
106
|
+
url: <string>
|
|
107
|
+
linked_issues: [<int>, ...]
|
|
108
|
+
raw_comments:
|
|
109
|
+
inline: [<comment>, ...]
|
|
110
|
+
review_summaries: [<review>, ...]
|
|
111
|
+
discussion: [<comment>, ...]
|
|
112
|
+
normalized_findings: [<finding>, ...] # Step 3 output
|
|
113
|
+
evaluation_results: [<evaluation>, ...] # Step 4 output keyed by finding.comment_id
|
|
114
|
+
triage_decisions: [<decision>, ...] # Step 5 output (post-ASK)
|
|
115
|
+
fix_results:
|
|
116
|
+
sub_agents_spawned: [<name>, ...]
|
|
117
|
+
files_changed: [<path>, ...]
|
|
118
|
+
findings_addressed: [<comment_id>, ...]
|
|
119
|
+
findings_blocked: [<comment_id>, ...]
|
|
120
|
+
review_loop:
|
|
121
|
+
iterations: [<verdict>, ...]
|
|
122
|
+
final_verdict: <clean|warning|critical>
|
|
123
|
+
confidence: <high|medium|low>
|
|
124
|
+
reply_drafts: [{comment_id, body, endpoint}, ...]
|
|
125
|
+
reply_post_results: [{comment_id, status: posted|failed, error?: <string>}, ...]
|
|
126
|
+
deferred_findings: [<finding>, ...] # written to todo.md in Step 5c
|
|
127
|
+
errors: [<error_record>, ...]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Workflow
|
|
133
|
+
|
|
134
|
+
Execute these steps in order. **Do not skip any step.** The only ASK gate is Step 5; after the user accepts triage, run autonomously through Step 10.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Step 0: Triage
|
|
139
|
+
|
|
140
|
+
Classify the run before delegating. Counts and severity come from the Step 4 evaluation, so reorder if needed — for runs with no comments at all, take the early-exit path in Step 2.
|
|
141
|
+
|
|
142
|
+
- **Tier 1** (≤5 comments, all single-line nits, 0 critical, 0 architectural-discussion items): reduced pipeline — implement inline or via one specialist; skip Step 7a review loop; still run Step 7b mandatory specialists (test-writer, security-auditor).
|
|
143
|
+
- **Tier 2** (6–30 comments, mixed severity, no critical disagreements or design objections): standard pipeline — Steps 6, 7a (review loop, max 3 iterations), 7b mandatory + 7c triggered.
|
|
144
|
+
- **Tier 3** (>30 comments OR any Critical-severity item OR any architectural-discussion item OR cross-cutting changes): full pipeline + merge-readiness assessment after Step 9.
|
|
145
|
+
|
|
146
|
+
Tier assignment is recomputed after Step 4 (when severity is known). If the initial Step 0 read of raw counts says Tier 1 but Step 4 reveals a Critical-severity item, upgrade to Tier 3 before the Step 5 ASK.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Step 1: Resolve PR Identity
|
|
151
|
+
|
|
152
|
+
#### 1a. Parse Argument
|
|
153
|
+
|
|
154
|
+
1. If `<pr-number>` is present in the invocation, set `run_cache.pr.number` and skip to 1c.b (fetch by number).
|
|
155
|
+
2. Otherwise, identify the current branch: `git branch --show-current`. Cache as `branch`.
|
|
156
|
+
|
|
157
|
+
#### 1b. Detect Platform
|
|
158
|
+
|
|
159
|
+
1. Read `.agents/hatch.json`. Extract `board.platform` (`github | azure-devops | gitlab`).
|
|
160
|
+
2. If absent or unreadable, default to GitHub and record a Low-confidence platform-detection finding in `run_cache.errors`.
|
|
161
|
+
|
|
162
|
+
#### 1c. Look Up the PR
|
|
163
|
+
|
|
164
|
+
Choose the platform CLI command for the `(no number provided + branch known)` case, or fetch directly by number:
|
|
165
|
+
|
|
166
|
+
**GitHub:**
|
|
167
|
+
- By branch: `gh pr list --head {branch} --state open --json number,title,body,url,baseRefName,headRefName --limit 1`
|
|
168
|
+
- By number: `gh pr view {N} --json number,title,body,url,baseRefName,headRefName`
|
|
169
|
+
|
|
170
|
+
**Azure DevOps:**
|
|
171
|
+
- By branch: `az repos pr list --source-branch {branch} --status active --top 1 -o json`
|
|
172
|
+
- By number: `az repos pr show --id {N} -o json`
|
|
173
|
+
|
|
174
|
+
**GitLab:**
|
|
175
|
+
- By branch: `glab mr list --source-branch {branch} --state opened --per-page 1 -F json`
|
|
176
|
+
- By number: `glab mr view {N} -F json`
|
|
177
|
+
|
|
178
|
+
Cache the response into `run_cache.pr`. Extract linked issues from the PR body by matching `Closes #N`, `Fixes #N`, `Resolves #N`, `Relates to #N`. Cache as `run_cache.pr.linked_issues`.
|
|
179
|
+
|
|
180
|
+
#### 1d. Halt on Missing PR
|
|
181
|
+
|
|
182
|
+
If no PR is found and no number was supplied, halt with this error verbatim (P1 actionable-error contract, `.claude/rules/cli-ux-standards.md`):
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
No open PR found on branch '{branch}'.
|
|
186
|
+
|
|
187
|
+
To target a specific PR:
|
|
188
|
+
/hatch3r-pr-resolve <pr-number>
|
|
189
|
+
|
|
190
|
+
To open a PR for this branch first:
|
|
191
|
+
GitHub: gh pr create
|
|
192
|
+
Azure DevOps: az repos pr create
|
|
193
|
+
GitLab: glab mr create
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Exit code 2 (usage error).
|
|
197
|
+
|
|
198
|
+
#### 1e. Diff Computation
|
|
199
|
+
|
|
200
|
+
Compute and cache the full diff once: `git diff {pr.baseRefName}...{pr.headRefName} > /tmp/pr-resolve-{N}.diff`. Reuse for Step 4 outdated detection and Step 7a review loop input.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Step 2: Fetch All Comments
|
|
205
|
+
|
|
206
|
+
Three scopes per platform. All requests are read-only. Cache results into `run_cache.raw_comments`.
|
|
207
|
+
|
|
208
|
+
#### 2a. GitHub
|
|
209
|
+
|
|
210
|
+
| Scope | Command |
|
|
211
|
+
|-------|---------|
|
|
212
|
+
| Inline review comments | `gh api repos/{owner}/{repo}/pulls/{N}/comments --paginate` |
|
|
213
|
+
| Review summaries | `gh api repos/{owner}/{repo}/pulls/{N}/reviews --paginate` |
|
|
214
|
+
| General PR discussion | `gh api repos/{owner}/{repo}/issues/{N}/comments --paginate` |
|
|
215
|
+
| Thread resolution state | `gh api graphql -f query='query{repository(owner:"{owner}",name:"{repo}"){pullRequest(number:{N}){reviewThreads(first:100){nodes{id,isResolved,comments(first:1){nodes{databaseId}}}}}}}'` |
|
|
216
|
+
|
|
217
|
+
The REST `pulls/{N}/comments` endpoint does not return resolution state; join the GraphQL `reviewThreads` response by `databaseId` to filter resolved threads. Default behavior: drop threads where `isResolved == true`. (Per user decision: bots are evaluated the same as humans — do **not** filter by `user.type == "Bot"` or by `author.login` matching `*[bot]`.)
|
|
218
|
+
|
|
219
|
+
#### 2b. Azure DevOps
|
|
220
|
+
|
|
221
|
+
Azure DevOps unifies inline and general comments into "threads".
|
|
222
|
+
|
|
223
|
+
| Scope | Command |
|
|
224
|
+
|-------|---------|
|
|
225
|
+
| All threads | `az rest -m GET --url 'https://dev.azure.com/{org}/{project}/_apis/git/repositories/{repo}/pullRequests/{N}/threads?api-version=7.1-preview.1'` |
|
|
226
|
+
|
|
227
|
+
Split the returned `value[]` array by `threadContext`:
|
|
228
|
+
- `threadContext != null` (has `filePath` and `rightFileStart`/`rightFileEnd`) → inline review comment.
|
|
229
|
+
- `threadContext == null` → general PR discussion / review summary.
|
|
230
|
+
|
|
231
|
+
Filter by `status`: include `active`, `pending`, `wontFix` (still actionable); drop `fixed`, `closed`, `byDesign` (resolved). Each thread's `comments[]` array contains the actual comment bodies; the first comment is the thread's opening message.
|
|
232
|
+
|
|
233
|
+
#### 2c. GitLab
|
|
234
|
+
|
|
235
|
+
GitLab notes are unified; discussions group related notes into threads.
|
|
236
|
+
|
|
237
|
+
| Scope | Command |
|
|
238
|
+
|-------|---------|
|
|
239
|
+
| All discussions (threaded) | `glab api '/projects/{project_id}/merge_requests/{iid}/discussions?per_page=100' --paginate` |
|
|
240
|
+
|
|
241
|
+
Filter each discussion by `notes[].resolvable` and `notes[0].resolved` (the first note's resolution state governs the thread; GitLab maintains this for resolvable threads only). Drop resolved discussions. For each retained discussion:
|
|
242
|
+
- `notes[].position != null` → inline review comment (has `new_path`, `new_line`).
|
|
243
|
+
- `notes[].position == null` AND discussion appears in `/merge_requests/{iid}/notes` only (not in `/reviews`) → general PR discussion.
|
|
244
|
+
- Discussions corresponding to a review verdict (`type == "approval"` or system note about approval/changes-requested) → review summary.
|
|
245
|
+
|
|
246
|
+
#### 2d. Empty PR Short-Circuit
|
|
247
|
+
|
|
248
|
+
If all three scopes return zero unresolved comments, emit:
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
No unresolved comments on PR #{N}.
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Skip to Step 10 with `Status: SUCCESS` and `Outcome: "No unresolved comments to resolve on PR #{N}."`. No code changes, no commit, no reply.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Step 3: Normalize Comments into Common Findings Shape
|
|
259
|
+
|
|
260
|
+
Convert every fetched raw comment into one normalized finding. The shape is platform-agnostic; downstream steps operate on this shape only.
|
|
261
|
+
|
|
262
|
+
```yaml
|
|
263
|
+
finding:
|
|
264
|
+
comment_id: <platform-comment-id> # single canonical id (first of merged set)
|
|
265
|
+
comment_ids: [<id>, ...] # all comment ids merged into this finding
|
|
266
|
+
thread_id: <platform-thread-id | null> # for inline + Azure threaded comments
|
|
267
|
+
source_scope: inline | review-summary | general-discussion
|
|
268
|
+
author: <username>
|
|
269
|
+
author_is_bot: <bool> # informational only — bots are not filtered
|
|
270
|
+
created_at: <iso>
|
|
271
|
+
body: <raw markdown>
|
|
272
|
+
file: <path | null> # inline only
|
|
273
|
+
line: <int | null> # inline only (right-side line)
|
|
274
|
+
parent_comment_id: <id | null> # if a reply within a thread
|
|
275
|
+
reply_endpoint:
|
|
276
|
+
method: POST
|
|
277
|
+
url: <fully-qualified URL>
|
|
278
|
+
body_field: <key the platform expects for the comment body>
|
|
279
|
+
extra_fields: {<map>} # e.g., in_reply_to for GitHub inline
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**De-duplication.** Group inline comments by `(file, line)` and group general-discussion comments by exact-substring match of the first 100 body characters. Where two reviewers raise the same point, merge into one finding with `comment_ids: [a, b]` so Step 8 replies post to both.
|
|
283
|
+
|
|
284
|
+
**Thread reconstruction.** For Azure DevOps and GitLab discussions, preserve the thread structure in `thread_id`; the orchestrator replies to the thread root (the first comment), which surfaces to all participants.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Step 4: Comment Evaluation (Rigor Contract Applied)
|
|
289
|
+
|
|
290
|
+
For each normalized finding, evaluate against the current code in the working tree using the six-test Scientific Rigor Contract from `governance/audit/templates/rigor-contract.md`.
|
|
291
|
+
|
|
292
|
+
#### 4a. Targeted Code Read
|
|
293
|
+
|
|
294
|
+
- Inline comment: read the file at the comment's `line` ± 50 lines for context.
|
|
295
|
+
- General discussion or review summary: parse the body for file paths (`src/...`), function/symbol names, and grep the codebase for those tokens, then read the matched files.
|
|
296
|
+
- Cap reads at the top 5 candidate files per finding; record `evaluation.read_files` in the cache.
|
|
297
|
+
|
|
298
|
+
#### 4b. Rigor Contract Application
|
|
299
|
+
|
|
300
|
+
Produce an evaluation record per finding with these fields (matches the contract's required schema):
|
|
301
|
+
|
|
302
|
+
```yaml
|
|
303
|
+
evaluation:
|
|
304
|
+
comment_id: <id>
|
|
305
|
+
decision: ACCEPT | DECLINE | NEEDS_CLARIFICATION
|
|
306
|
+
severity: Critical | Important | Cleanup | Cosmetic
|
|
307
|
+
confidence: high | medium | low
|
|
308
|
+
confidence_basis: <one phrase — direct measurement | sampled observation | inference from analogue>
|
|
309
|
+
falsifiability: <one observation that would disprove this evaluation>
|
|
310
|
+
causal_chain: <step1 → step2 → step3> # ≥3 steps, symptom → driver → root
|
|
311
|
+
bias_check: <named bias risks + how mitigated>
|
|
312
|
+
counter_argument: <steelman of the opposite decision + how resolved>
|
|
313
|
+
affected_files: [<path>, ...]
|
|
314
|
+
proposed_action: <one paragraph — what the implementation would do>
|
|
315
|
+
applicability: current | outdated | already-addressed
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
**Severity heuristic** (matches `commands/hatch3r-revision.md` triage table):
|
|
319
|
+
- **Critical** — functional bug, security defect, data corruption risk, broken contract.
|
|
320
|
+
- **Important** — UX defect, missing test for a new code path, incomplete behavior, performance regression on a hot path.
|
|
321
|
+
- **Cleanup** — dead code, typo, missing type annotation, error-handling gap that does not affect functional behavior.
|
|
322
|
+
- **Cosmetic** — naming, formatting, comment polish.
|
|
323
|
+
|
|
324
|
+
#### 4c. Outdated Detection
|
|
325
|
+
|
|
326
|
+
For inline comments: locate the comment's `line` in the cached diff. If the line is in a deleted hunk, or if the surrounding 5-line window no longer matches the comment's `diff_hunk`, mark `applicability: outdated`. Default decision for outdated comments: `DECLINE` with reply template `DECLINE — outdated` (Step 8).
|
|
327
|
+
|
|
328
|
+
#### 4d. Already-Addressed Detection
|
|
329
|
+
|
|
330
|
+
Grep the commits between PR base and head (`git log {pr.baseRefName}..{pr.headRefName} --oneline`) for keywords from the comment body (extract noun phrases of length ≥ 2 words). If a commit message references the comment's subject, mark `applicability: already-addressed`. Default decision: `DECLINE` with reply template `DECLINE — already done`, citing the commit SHA.
|
|
331
|
+
|
|
332
|
+
#### 4e. Recompute Tier
|
|
333
|
+
|
|
334
|
+
After Step 4 completes, recompute Step 0's tier using the now-known severities. Upgrade Tier 1 -> Tier 3 if any `severity: Critical` evaluation exists.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## Step 5: Triage Routing + ASK Checkpoint (only mutation gate)
|
|
339
|
+
|
|
340
|
+
**Tier-3 specialist mandate (P8 B2).** For Tier 3 PRs (6+ findings OR any Critical severity), the post-fix specialist pass (`hatch3r-test-writer`, `hatch3r-security-auditor`, `hatch3r-docs-writer`) MUST run in parallel. Specialists may NOT be deferred via "Needs your call" for cost reasons. Cost-dominance principle applies: token cost of specialist sub-agents is dominated by the quality gain of catching defects pre-merge.
|
|
341
|
+
|
|
342
|
+
#### 5a. Apply Routing Heuristics
|
|
343
|
+
|
|
344
|
+
| Severity | Confidence | Default Route |
|
|
345
|
+
|----------|------------|---------------|
|
|
346
|
+
| Critical | High | FIX NOW |
|
|
347
|
+
| Critical | Medium / Low | FIX NOW (flagged for extra scrutiny in Step 7a) |
|
|
348
|
+
| Important | High | FIX NOW |
|
|
349
|
+
| Important | Medium | FIX NOW |
|
|
350
|
+
| Important | Low | **Needs your call** |
|
|
351
|
+
| Cleanup | High / Medium | FIX NOW |
|
|
352
|
+
| Cleanup | Low | **Needs your call** |
|
|
353
|
+
| Cosmetic | Any | DEFER (with reply) |
|
|
354
|
+
| Any | `applicability: outdated` | DECLINE — outdated (with reply) |
|
|
355
|
+
| Any | `applicability: already-addressed` | DECLINE — already done (with reply) |
|
|
356
|
+
|
|
357
|
+
Plus dedicated buckets independent of severity:
|
|
358
|
+
- **DECLINE candidates** — evaluations where `decision: DECLINE` because the rigor contract found the comment incorrect (counter-argument resolved against the comment). Show the agent's reasoning; user can override to FIX NOW.
|
|
359
|
+
- **NEEDS_CLARIFICATION** — `decision: NEEDS_CLARIFICATION`. The agent will reply asking for more information instead of implementing.
|
|
360
|
+
- **Needs your call** — low-confidence ACCEPTs surfaced for the user (no auto-route, per user decision).
|
|
361
|
+
|
|
362
|
+
#### 5b. Triage Table
|
|
363
|
+
|
|
364
|
+
Present one consolidated table, grouped by bucket. Each row: `[#] {author} • {scope} • {severity}/{confidence} • route • one-line rationale`. Example:
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
PR #142 — Resolve Comments (Tier 2)
|
|
368
|
+
|
|
369
|
+
FIX NOW ({n}):
|
|
370
|
+
[1] @alice • inline src/auth.ts:42 • Critical/High → token validation missing
|
|
371
|
+
[2] @bob • inline src/auth.ts:78 • Important/Medium → missing test for refresh flow
|
|
372
|
+
[3] @ci-bot • inline src/db.ts:15 • Cleanup/High → unused import
|
|
373
|
+
|
|
374
|
+
DECLINE — outdated ({n}):
|
|
375
|
+
[4] @alice • inline src/auth.ts:120 • code at L120 changed in commit abc1234
|
|
376
|
+
|
|
377
|
+
DECLINE — already done ({n}):
|
|
378
|
+
[5] @carol • general discussion • addressed in commit def5678
|
|
379
|
+
|
|
380
|
+
NEEDS_CLARIFICATION ({n}):
|
|
381
|
+
[6] @dave • general discussion • "should we cache?" — caching strategy not specified
|
|
382
|
+
|
|
383
|
+
Needs your call ({n}):
|
|
384
|
+
[7] @bob • inline src/cache.ts:88 • Important/Low → may be intentional eviction
|
|
385
|
+
|
|
386
|
+
Escalation for low-confidence accepted findings: trigger a mandatory `hatch3r-security-auditor` pass if any are security-adjacent (auth, crypto, input validation, access control, secret handling); otherwise flag in commit message for elevated reviewer attention.
|
|
387
|
+
|
|
388
|
+
DEFER (cosmetic, with reply) ({n}):
|
|
389
|
+
[8] @eve • inline src/auth.ts:55 • Cosmetic/Medium → naming nitpick
|
|
390
|
+
|
|
391
|
+
Tier: 2 (standard pipeline)
|
|
392
|
+
Total: {N} comments • {fix_now_n} fix now • {decline_n} decline • {clarify_n} clarify • {needs_call_n} need your call • {defer_n} defer
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
#### 5c. ASK (only gate)
|
|
396
|
+
|
|
397
|
+
> Found {N} comments on PR #{pr_number}. Evaluation done. Review the suggested routing. Adjustments:
|
|
398
|
+
> - `accept` — proceed with suggested routing
|
|
399
|
+
> - `fix N` — promote a Decline/Clarify/NeedsCall item to FIX NOW
|
|
400
|
+
> - `decline N` — demote a FIX NOW item to DECLINE
|
|
401
|
+
> - `clarify N` — switch to clarification-reply mode
|
|
402
|
+
> - `defer N` — route to todo.md instead of fixing now
|
|
403
|
+
> - `show N` — print the full evaluation for item N (decision, causal chain, counter-argument, sources)
|
|
404
|
+
> - `fix all` — implement every ACCEPT item including Needs-your-call (skip per-item triage)
|
|
405
|
+
>
|
|
406
|
+
> (accept / adjust / show N / fix all)
|
|
407
|
+
|
|
408
|
+
If the user attempts to defer a Critical finding, execute the Critical Deferral Protocol from `commands/hatch3r-revision.md:286-310`: structured warning + required written rationale + `Critical-deferred` tag in todo.md + flag for elevated visibility in the next board-fill.
|
|
409
|
+
|
|
410
|
+
After the user accepts, the run is autonomous until Step 10.
|
|
411
|
+
|
|
412
|
+
#### 5d. File Deferred Findings to todo.md
|
|
413
|
+
|
|
414
|
+
If any findings route to DEFER, append a single epic-context block to `todo.md`:
|
|
415
|
+
|
|
416
|
+
```markdown
|
|
417
|
+
# Follow-ups from PR #{pr_number} pr-resolve ({date})
|
|
418
|
+
# Epic: group all items below into one epic during board-fill
|
|
419
|
+
- {comment author}: {finding description} (severity: {severity}, file: {file:line})
|
|
420
|
+
- ...
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
Cache the deferred list. Reply templates in Step 8 reference todo.md for these items.
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Step 6: Fix Implementation (Sub-Agent Delegation)
|
|
428
|
+
|
|
429
|
+
Delegate every FIX NOW finding to specialist sub-agents using the delegation contract from `commands/revision/revision-delegation.md` (§6a–6c). Same blast-radius-aware grouping, same prompt requirements.
|
|
430
|
+
|
|
431
|
+
#### 6a. Group Findings by Specialist
|
|
432
|
+
|
|
433
|
+
| Finding Category | Sub-Agent | Protocol |
|
|
434
|
+
|------------------|-----------|----------|
|
|
435
|
+
| Bugs, missing features, error handling, logic fixes | `hatch3r-implementer` | hatch3r-implementer agent protocol |
|
|
436
|
+
| Dead code, unused imports, type fixes, lint errors | `hatch3r-lint-fixer` | hatch3r-lint-fixer agent protocol |
|
|
437
|
+
| Missing tests, insufficient coverage | `hatch3r-test-writer` | hatch3r-test-writer agent protocol |
|
|
438
|
+
|
|
439
|
+
Blast-radius rule: same-file findings → same sub-agent (priority: implementer > lint-fixer > test-writer); disjoint files → parallel sub-agents.
|
|
440
|
+
|
|
441
|
+
#### 6b. Spawn Sub-Agents
|
|
442
|
+
|
|
443
|
+
Use the Task tool with `subagent_type: "generalPurpose"`. Launch independent groups in parallel.
|
|
444
|
+
|
|
445
|
+
Each sub-agent prompt MUST include:
|
|
446
|
+
|
|
447
|
+
1. The findings list for that agent: `(comment_id, file, line, comment body verbatim as the "ask", proposed_action from Step 4)`.
|
|
448
|
+
2. Instruction to follow the corresponding agent protocol.
|
|
449
|
+
3. All `scope: always` rule directives from `.agents/rules/`.
|
|
450
|
+
4. Acceptance criteria from `run_cache.pr.linked_issues` (read once at Step 1, cached).
|
|
451
|
+
5. Relevant `.agents/learnings/` matching the affected areas.
|
|
452
|
+
6. Explicit: do NOT create branches, commits, or PRs.
|
|
453
|
+
7. Confidence expression requirement (verbatim from the Confidence Propagation Contract above).
|
|
454
|
+
8. PR-resolve-specific constraint: "You are addressing reviewer comments on an existing PR. Stay within the architecture established by the PR's existing changes; do not introduce scope creep beyond the comments listed below."
|
|
455
|
+
|
|
456
|
+
#### 6c. Await and Integrate
|
|
457
|
+
|
|
458
|
+
Await all sub-agents. Collect structured results: files changed, tests written, findings addressed, BLOCKED / PARTIAL items. Apply cross-agent conflict resolution per `commands/revision/revision-delegation.md:85-92` (disjoint regions accept both; overlapping regions merge larger-scope; semantic conflicts surface in Step 10 Iteration Summary).
|
|
459
|
+
|
|
460
|
+
Update `run_cache.fix_results`.
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Step 7: Quality Verification
|
|
465
|
+
|
|
466
|
+
#### 7a. Quality Gates (before review loop)
|
|
467
|
+
|
|
468
|
+
1. Lint: project lint command (e.g., `npm run lint`).
|
|
469
|
+
2. Typecheck: project typecheck command (e.g., `npm run typecheck` or `npx tsc --noEmit`).
|
|
470
|
+
3. Tests: project test command (e.g., `npm test`).
|
|
471
|
+
|
|
472
|
+
If any gate fails, identify failures and either fix inline (single-line lint/type) or loop back to Step 6 with the specific failures as new findings. Max 2 retry loops; after 2 retries, record the failures in `run_cache.errors` and continue — the unresolved failures surface as a `Status: PARTIAL` in Step 10.
|
|
473
|
+
|
|
474
|
+
#### 7b. Review Loop (Tier 2/3 only; Tier 1 skips)
|
|
475
|
+
|
|
476
|
+
Spawn `hatch3r-reviewer` -> `hatch3r-fixer` per `commands/revision/revision-quality.md` Stage 1 (max 3 iterations, oscillation detection, confidence decay). The reviewer prompt MUST include:
|
|
477
|
+
- The cached diff from Step 1e.
|
|
478
|
+
- All `scope: always` rule directives.
|
|
479
|
+
- Iteration number and prior findings.
|
|
480
|
+
- The Confidence expression requirement (verbatim).
|
|
481
|
+
|
|
482
|
+
The reviewer's output MUST include a top-level `confidence: high | medium | low` so the gate evaluates pass/second_pass/escalate per `src/pipeline/reviewLoop.ts` semantics.
|
|
483
|
+
|
|
484
|
+
After the loop terminates, re-run Step 7a quality gates.
|
|
485
|
+
|
|
486
|
+
#### 7c. Final Quality Specialists (parallel)
|
|
487
|
+
|
|
488
|
+
After 7b is clean:
|
|
489
|
+
|
|
490
|
+
**Mandatory when code changed:**
|
|
491
|
+
- `hatch3r-test-writer` — write/update tests for changed code paths.
|
|
492
|
+
- `hatch3r-security-auditor` — security review of all changes.
|
|
493
|
+
|
|
494
|
+
**Conditional:**
|
|
495
|
+
- `hatch3r-docs-writer` — when fixes touched public APIs, architectural patterns, or user-facing behavior.
|
|
496
|
+
- `hatch3r-a11y-auditor` — when the diff includes UI component or style files.
|
|
497
|
+
- `hatch3r-perf-profiler` — when the diff includes hot-path changes (DB queries, API handlers, render loops).
|
|
498
|
+
- `hatch3r-lint-fixer` — when residual lint/type errors surfaced after Step 6.
|
|
499
|
+
|
|
500
|
+
Each specialist prompt mirrors the requirements in `commands/revision/revision-quality.md:82-89` (agent protocol, scope:always rules, diff, acceptance criteria, confidence requirement). Apply specialist outputs; re-run 7a gates if changes were made.
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
## Step 8: Post Per-Comment Replies
|
|
505
|
+
|
|
506
|
+
For every finding in `run_cache.triage_decisions` (including DECLINE and DEFER buckets), draft and post one reply per the platform endpoint cached in `finding.reply_endpoint`.
|
|
507
|
+
|
|
508
|
+
#### 8a. Reply Template by Decision
|
|
509
|
+
|
|
510
|
+
| Decision | Template |
|
|
511
|
+
|----------|----------|
|
|
512
|
+
| FIX NOW — implemented | `Implemented in {commit_sha}: {one-line summary}. Confidence: {high|medium}.` |
|
|
513
|
+
| FIX NOW — failed (BLOCKED / PARTIAL) | `Attempted but blocked: {reason from sub-agent}. Surfaced as follow-up in todo.md.` |
|
|
514
|
+
| DECLINE — outdated | `The code at this location has changed since this comment; the original concern no longer applies. Current behavior: {one-line summary}.` |
|
|
515
|
+
| DECLINE — disagree | `Considered, declining because: {reasoning from evaluation.causal_chain}. Counter-argument considered: {evaluation.counter_argument}. Happy to revisit if context differs.` |
|
|
516
|
+
| DECLINE — already done | `Already addressed in {commit_sha}: {one-line summary}.` |
|
|
517
|
+
| NEEDS_CLARIFICATION | `Couldn't fully validate this — could you confirm: {specific question derived from evaluation.bias_check}?` |
|
|
518
|
+
| DEFER | `Tracked as follow-up in todo.md for /hatch3r-board-fill triage.` |
|
|
519
|
+
|
|
520
|
+
All reply bodies are signed with a trailing line: `_— hatch3r-pr-resolve (confidence: {high|medium|low})_`. Reviewers can identify automated replies by this marker.
|
|
521
|
+
|
|
522
|
+
#### 8b. Per-Platform Endpoints
|
|
523
|
+
|
|
524
|
+
**GitHub:**
|
|
525
|
+
- Inline reply (to a thread): `gh api repos/{owner}/{repo}/pulls/{N}/comments -X POST -F in_reply_to={comment_id} -f body=@{tmp_file}`
|
|
526
|
+
- General discussion reply: `gh api repos/{owner}/{repo}/issues/{N}/comments -X POST -f body=@{tmp_file}`
|
|
527
|
+
- Review-summary reply: post as general discussion, quote the summary's first 200 characters at the top of the reply body.
|
|
528
|
+
|
|
529
|
+
**Azure DevOps:**
|
|
530
|
+
- Reply to thread: `az rest -m POST --url 'https://dev.azure.com/{org}/{project}/_apis/git/repositories/{repo}/pullRequests/{pr}/threads/{threadId}/comments?api-version=7.1-preview.1' --body '{"parentCommentId":1,"content":"{body}","commentType":"text"}'`
|
|
531
|
+
- Non-threaded comment (general discussion equivalent): POST to `/threads` with a new thread containing one comment and no `threadContext`.
|
|
532
|
+
|
|
533
|
+
**GitLab:**
|
|
534
|
+
- Reply to discussion thread: `glab api '/projects/{project_id}/merge_requests/{iid}/discussions/{discussion_id}/notes' -X POST -f body=@{tmp_file}`
|
|
535
|
+
- General discussion (new note, no thread): `glab api '/projects/{project_id}/merge_requests/{iid}/notes' -X POST -f body=@{tmp_file}`
|
|
536
|
+
|
|
537
|
+
Reply bodies are written to a `mktemp` file and passed with `-f body=@{file}` (GitHub/GitLab) or via the JSON `--body` argument (Azure); this avoids shell-quoting issues with markdown content.
|
|
538
|
+
|
|
539
|
+
**Field typing for `gh api`:** Integer-typed fields like `in_reply_to` require `-F` (capital); string fields like `body` use `-f` (lowercase). Mixing them returns HTTP 422 and the reply silently fails into the retry/backoff path. See `commands/board/shared-github.md` → GitHub CLI Field-Typing Notes for the full table. **Pager:** Every `gh api` invocation from this command must run with `GH_PAGER=cat` and `PAGER=cat` set; see `commands/hatch3r-board-shared.md` → Pager-Bypass Directive.
|
|
540
|
+
|
|
541
|
+
#### 8c. Resilience
|
|
542
|
+
|
|
543
|
+
Wrap each reply POST in retry-then-warn:
|
|
544
|
+
- 2 retries with 2s and 8s backoffs.
|
|
545
|
+
- On persistent failure, append to `run_cache.reply_post_results` with `status: failed` and the error; continue with the next reply.
|
|
546
|
+
|
|
547
|
+
Reply failures do NOT abort the run. The final state surfaces in the Step 10 Iteration Summary under `Not Done / Deferred / Unverified`.
|
|
548
|
+
|
|
549
|
+
#### 8d. Pre-Post Guards
|
|
550
|
+
|
|
551
|
+
- Reject reply bodies > 60000 bytes (well under platform limits; flag in `run_cache.errors` and post a truncated body with a `[truncated]` marker).
|
|
552
|
+
- Strip absolute paths matching `/Users/`, `/home/`, `C:\\Users\\` and any reference to `.audit-workspace/` or `.hatch3r/` internals.
|
|
553
|
+
- Never close threads (`gh api ... -X PATCH -f isResolved=true` and equivalents are forbidden).
|
|
554
|
+
- Never approve or dismiss the PR review (`gh pr review --approve`, `az repos pr set-vote`, `glab mr approve` are forbidden in this command).
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
## Step 9: Commit and Push
|
|
559
|
+
|
|
560
|
+
When `run_cache.fix_results.files_changed` is non-empty, stage, commit, and push.
|
|
561
|
+
|
|
562
|
+
```bash
|
|
563
|
+
git add -A
|
|
564
|
+
git commit -m "$(cat <<'EOF'
|
|
565
|
+
pr-resolve: address {fixed_n} comments on PR #{N} ({declined_n} declined, {deferred_n} deferred)
|
|
566
|
+
|
|
567
|
+
Fixed:
|
|
568
|
+
- {comment_id} by @{author}: {one-line summary}
|
|
569
|
+
- ...
|
|
570
|
+
|
|
571
|
+
Declined with rationale (replied on PR):
|
|
572
|
+
- {comment_id} by @{author}: {one-line summary}
|
|
573
|
+
|
|
574
|
+
Deferred to todo.md for /hatch3r-board-fill:
|
|
575
|
+
- {comment_id} by @{author}: {one-line summary}
|
|
576
|
+
|
|
577
|
+
Refs #{linked_issue_n}, ...
|
|
578
|
+
EOF
|
|
579
|
+
)"
|
|
580
|
+
git push
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
If `git push` fails because the remote branch does not exist, run `git push -u origin {branch}`.
|
|
584
|
+
|
|
585
|
+
If `run_cache.fix_results.files_changed` is empty (every comment was DECLINE / DEFER / NEEDS_CLARIFICATION), skip the commit and push — Step 8 replies are the only artifact produced.
|
|
586
|
+
|
|
587
|
+
**Post-commit board update (Tier 3 only).** When board context exists and Tier 3 was assigned, update the PR description with a pr-resolve summary per `commands/revision/revision-board-integration.md`. For Tier 1/2, skip.
|
|
588
|
+
|
|
589
|
+
---
|
|
590
|
+
|
|
591
|
+
## Step 10: Resolution Summary
|
|
592
|
+
|
|
593
|
+
Emit the canonical Iteration Summary block from `rules/hatch3r-iteration-summary.md`. Use the exact field names and the closed Status enum.
|
|
594
|
+
|
|
595
|
+
```markdown
|
|
596
|
+
## Iteration Summary
|
|
597
|
+
|
|
598
|
+
**Status:** SUCCESS | PARTIAL | FAILED | BLOCKED
|
|
599
|
+
**Outcome:** {one sentence — e.g., "Resolved 8 of 10 comments on PR #142; 2 deferred; replies posted."}
|
|
600
|
+
|
|
601
|
+
**Done:**
|
|
602
|
+
- {comment_id} @{author}: FIX NOW → implemented in {commit_sha}
|
|
603
|
+
- {comment_id} @{author}: DECLINE (outdated) → reply posted
|
|
604
|
+
- ...
|
|
605
|
+
|
|
606
|
+
**Not Done / Deferred / Unverified:**
|
|
607
|
+
- {comment_id} @{author}: DEFER → tracked in todo.md
|
|
608
|
+
- {comment_id}: reply post failed (Azure REST 429); manual follow-up needed
|
|
609
|
+
- (or: `None — full scope completed`)
|
|
610
|
+
|
|
611
|
+
**Open Questions / Blockers:**
|
|
612
|
+
- {comment_id} @{author}: NEEDS_CLARIFICATION → awaiting reviewer response
|
|
613
|
+
- (or: `None`)
|
|
614
|
+
|
|
615
|
+
**Confidence:** {high | medium | low} — {one-sentence basis from sub-agent outputs and reviewer verdict}
|
|
616
|
+
|
|
617
|
+
**Artifacts Touched:**
|
|
618
|
+
| Path | Action | Notes |
|
|
619
|
+
| ---- | ------ | ----- |
|
|
620
|
+
| {file} | modified | {one line} |
|
|
621
|
+
|
|
622
|
+
**Verifications Run:**
|
|
623
|
+
| Check | Result |
|
|
624
|
+
| ----- | ------ |
|
|
625
|
+
| lint | pass |
|
|
626
|
+
| typecheck | pass |
|
|
627
|
+
| tests | pass ({n} passed) |
|
|
628
|
+
| reviewer/fixer loop | clean after {n} iteration(s) |
|
|
629
|
+
| security-auditor | pass |
|
|
630
|
+
| test-writer | pass — added {n} test(s) |
|
|
631
|
+
|
|
632
|
+
**Suggested Next Action:** {one line — e.g., "Wait for reviewer response on the 2 NEEDS_CLARIFICATION items, then re-run /hatch3r-pr-resolve."}
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
Status decision rules:
|
|
636
|
+
- **SUCCESS** — every FIX NOW finding implemented, all replies posted, all gates green.
|
|
637
|
+
- **PARTIAL** — some FIX NOW findings BLOCKED/PARTIAL, OR some replies failed to post, OR Step 7a gates ended on a retry-limit miss.
|
|
638
|
+
- **FAILED** — Step 6 sub-agents all returned BLOCKED, no code changed, replies could not be drafted.
|
|
639
|
+
- **BLOCKED** — cannot proceed without user input (e.g., Critical-deferred rationale not provided, semantic conflict requiring a design decision).
|
|
640
|
+
|
|
641
|
+
---
|
|
642
|
+
|
|
643
|
+
## Error Handling
|
|
644
|
+
|
|
645
|
+
| Condition | Action |
|
|
646
|
+
|-----------|--------|
|
|
647
|
+
| PR not found and no number supplied | Halt with the Step 1d actionable error; exit code 2. |
|
|
648
|
+
| Zero unresolved comments | Step 2d short-circuit → Step 10 SUCCESS, no commit. |
|
|
649
|
+
| Platform CLI not authenticated | Halt with platform-specific recovery (`gh auth login`, `az login`, `glab auth login`); exit code 1. |
|
|
650
|
+
| Referenced file in a comment does not exist | Set `evaluation.decision: NEEDS_CLARIFICATION`, reply asks reviewer for the correct path. |
|
|
651
|
+
| Sub-agent (Step 6) reports BLOCKED on a finding | Skip the finding for FIX NOW; surface in Step 10 `Not Done`; reply with "Attempted but blocked" template. |
|
|
652
|
+
| Sub-agent (Step 6) returns PARTIAL | Apply partial changes; mark the unaddressed sub-findings as deferred; reply notes partial implementation. |
|
|
653
|
+
| Reply POST persistently fails (Step 8c) | Continue run; record in `run_cache.reply_post_results`; surface in Step 10. |
|
|
654
|
+
| Review loop hits 3 iterations with findings remaining | ASK the user per `commands/revision/revision-quality.md` line 54. |
|
|
655
|
+
| Quality gate fails 2 retries (Step 7a) | Record in `run_cache.errors`; Step 10 `Status: PARTIAL`. |
|
|
656
|
+
| `git push` rejected (e.g., upstream changed mid-run) | Halt at Step 9 with: "Remote branch changed during run. Run `git pull --rebase`, resolve conflicts, then re-run /hatch3r-pr-resolve to repost any failed replies." |
|
|
657
|
+
| GraphQL `reviewThreads` query fails (GitHub resolution state) | Fall back to evaluating every inline comment (no resolution filter); record a Low-confidence note in `run_cache.errors`. |
|
|
658
|
+
|
|
659
|
+
---
|
|
660
|
+
|
|
661
|
+
## Guardrails
|
|
662
|
+
|
|
663
|
+
1. **One ASK gate.** Step 5 is the only user-facing checkpoint. After `accept`, the run proceeds through Steps 6–10 without further prompting (per user decision).
|
|
664
|
+
2. **No thread closure.** Never mark a thread resolved (`isResolved: true`, Azure `status: fixed`, GitLab `resolved: true`). Thread resolution is reviewer-owned semantics.
|
|
665
|
+
3. **No review verdicts.** Never approve, dismiss, or request changes on a PR review. Reply-only.
|
|
666
|
+
4. **No labels or status checks.** PR labels and status checks are out of scope (handled by `hatch3r-board-fill` and CI integrations).
|
|
667
|
+
5. **No cross-PR work.** One PR per invocation. The `<pr-number>` argument is bound to a single PR.
|
|
668
|
+
6. **No base-branch push.** Step 9 pushes only to `pr.headRefName`. Refuse if the current branch differs.
|
|
669
|
+
7. **Reply body hygiene.** Strip internal paths (`/Users/`, `/home/`, `.audit-workspace/`, `.hatch3r/`). Truncate over 60000 bytes.
|
|
670
|
+
8. **Bot-comment parity.** Per user decision, comments from bot accounts are evaluated under the same rigor contract as human comments — no special-case skipping or downgrading.
|
|
671
|
+
9. **Skip resolved by default.** Step 2 filters resolved threads (`isResolved` for GitHub, `status: fixed/closed` for Azure, `resolved: true` for GitLab) unless a future flag explicitly opts in.
|
|
672
|
+
10. **Confidence propagation.** Every reply body, every triage row, every Step 10 verdict carries a confidence rating from the upstream sub-agent or evaluation. Dropping the signal is a gate failure.
|