hatch3r 1.3.0 → 1.4.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/README.md +2 -1
- package/agents/hatch3r-a11y-auditor.md +7 -11
- package/agents/hatch3r-architect.md +7 -11
- package/agents/hatch3r-ci-watcher.md +7 -10
- package/agents/hatch3r-context-rules.md +5 -7
- package/agents/hatch3r-dependency-auditor.md +7 -13
- package/agents/hatch3r-devops.md +7 -13
- package/agents/hatch3r-docs-writer.md +7 -11
- package/agents/hatch3r-fixer.md +2 -8
- package/agents/hatch3r-implementer.md +2 -8
- package/agents/hatch3r-learnings-loader.md +5 -7
- package/agents/hatch3r-lint-fixer.md +7 -9
- package/agents/hatch3r-perf-profiler.md +7 -11
- package/agents/hatch3r-researcher.md +6 -8
- package/agents/hatch3r-reviewer.md +7 -10
- package/agents/hatch3r-security-auditor.md +7 -12
- package/agents/hatch3r-test-writer.md +7 -11
- package/agents/shared/external-knowledge.md +21 -0
- package/agents/shared/quality-charter.md +78 -0
- package/commands/board/pickup-azure-devops.md +4 -0
- package/commands/board/pickup-delegation-multi.md +3 -0
- package/commands/board/pickup-delegation.md +3 -0
- package/commands/board/pickup-github.md +4 -0
- package/commands/board/pickup-gitlab.md +4 -0
- package/commands/board/pickup-post-impl.md +8 -1
- package/commands/board/shared-azure-devops.md +13 -3
- package/commands/board/shared-github.md +1 -0
- package/commands/board/shared-gitlab.md +9 -2
- package/commands/hatch3r-agent-customize.md +5 -1
- package/commands/hatch3r-board-groom.md +55 -2
- package/commands/hatch3r-board-init.md +5 -2
- package/commands/hatch3r-board-shared.md +37 -2
- package/commands/hatch3r-command-customize.md +4 -0
- package/commands/hatch3r-hooks.md +1 -1
- package/commands/hatch3r-quick-change.md +29 -3
- package/commands/hatch3r-revision.md +136 -16
- package/commands/hatch3r-rule-customize.md +4 -0
- package/commands/hatch3r-skill-customize.md +4 -0
- package/commands/hatch3r-workflow.md +10 -1
- package/dist/cli/index.js +522 -360
- package/dist/cli/index.js.map +1 -1
- package/package.json +12 -9
- package/rules/hatch3r-agent-orchestration-detail.md +159 -0
- package/rules/hatch3r-agent-orchestration-detail.mdc +156 -0
- package/rules/hatch3r-agent-orchestration.md +91 -330
- package/rules/hatch3r-agent-orchestration.mdc +127 -149
- package/rules/hatch3r-code-standards.mdc +10 -2
- package/rules/hatch3r-component-conventions.mdc +0 -1
- package/rules/hatch3r-deep-context.mdc +30 -8
- package/rules/hatch3r-dependency-management.mdc +17 -5
- package/rules/hatch3r-i18n.mdc +0 -1
- package/rules/hatch3r-migrations.mdc +12 -1
- package/rules/hatch3r-observability.mdc +289 -0
- package/rules/hatch3r-security-patterns.mdc +11 -0
- package/rules/hatch3r-testing.mdc +1 -1
- package/rules/hatch3r-theming.mdc +0 -1
- package/rules/hatch3r-tooling-hierarchy.mdc +18 -4
- package/skills/hatch3r-agent-customize/SKILL.md +4 -72
- package/skills/hatch3r-command-customize/SKILL.md +4 -62
- package/skills/hatch3r-customize/SKILL.md +117 -0
- package/skills/hatch3r-rule-customize/SKILL.md +4 -65
- package/skills/hatch3r-skill-customize/SKILL.md +4 -62
|
@@ -7,27 +7,19 @@ tags: [core]
|
|
|
7
7
|
---
|
|
8
8
|
# Agent Orchestration
|
|
9
9
|
|
|
10
|
-
This rule governs when and how to delegate work to hatch3r agents, load skills, and spawn subagents. These directives are mandatory — not suggestions.
|
|
10
|
+
This rule governs when and how to delegate work to hatch3r agents, load skills, and spawn subagents. These directives are mandatory — not suggestions. For extended reference on pipeline context schemas, resilience/failure handling, and observability, see `hatch3r-agent-orchestration-detail`.
|
|
11
11
|
|
|
12
12
|
## Orchestration Differentiation
|
|
13
13
|
|
|
14
|
-
Hatch3r's orchestration
|
|
14
|
+
Hatch3r's orchestration uses a **phase-gated pipeline** (Research, Implement, Review, Quality) with **structured handoffs** via `PipelineContext` and a **mandatory review gate** before the quality phase. This is not free-form agent chat.
|
|
15
15
|
|
|
16
16
|
## Universal Applicability
|
|
17
17
|
|
|
18
|
-
This rule applies to EVERY context without exception:
|
|
19
|
-
|
|
20
|
-
- **Board-pickup** (epic, sub-issue, standalone, batch)
|
|
21
|
-
- **Workflow command** (full mode and quick mode)
|
|
22
|
-
- **Plain chat** (single task or multiple tasks)
|
|
23
|
-
- **Issue references** (e.g., "implement #5")
|
|
24
|
-
- **Natural language requests** (e.g., "add a dark mode toggle")
|
|
25
|
-
|
|
26
|
-
Whether the user invokes a command or simply asks for a task in conversation, the full sub-agent pipeline defined below is mandatory. There is no context where implementing code inline (without sub-agents) is acceptable.
|
|
18
|
+
This rule applies to EVERY context without exception: board-pickup (epic, sub-issue, standalone, batch), workflow command (full/quick), plain chat, issue references, and natural language requests. The full sub-agent pipeline is mandatory — never implement code inline without sub-agents.
|
|
27
19
|
|
|
28
20
|
## Universal Sub-Agent Pipeline
|
|
29
21
|
|
|
30
|
-
Every task MUST follow this four-phase pipeline: **Phase 1 — Research** (
|
|
22
|
+
Every task MUST follow this four-phase pipeline: **Phase 1 — Research** (`hatch3r-researcher`), **Phase 2 — Implement** (`hatch3r-implementer`), **Phase 3 — Review Loop** (`hatch3r-reviewer` + `hatch3r-fixer`), **Phase 4 — Final Quality** (parallel specialists). See Mandatory Delegation Directives below.
|
|
31
23
|
|
|
32
24
|
## Agent Roster
|
|
33
25
|
|
|
@@ -50,114 +42,94 @@ Every task MUST follow this four-phase pipeline: **Phase 1 — Research** (conte
|
|
|
50
42
|
|
|
51
43
|
## Deep Context Integration
|
|
52
44
|
|
|
53
|
-
Score task complexity per the `hatch3r-deep-context` rule
|
|
45
|
+
Score task complexity per the `hatch3r-deep-context` rule before Phase 1. Apply the resulting tier:
|
|
54
46
|
|
|
55
|
-
- **Tier 2 (Standard):** Present elicitation questions
|
|
56
|
-
- **Tier 3 (Deep):** Present
|
|
47
|
+
- **Tier 2 (Standard):** Present elicitation questions inline. Await answers before Phase 2.
|
|
48
|
+
- **Tier 3 (Deep):** Present Pre-Implementation Summary and ASK for confirmation. Do NOT proceed until all unresolved questions are answered.
|
|
57
49
|
|
|
58
50
|
## Mandatory Delegation Directives
|
|
59
51
|
|
|
60
52
|
### Context Gathering (Before Implementation)
|
|
61
53
|
|
|
62
|
-
|
|
54
|
+
Spawn `hatch3r-researcher` before implementing any task. Skip only for trivial single-line edits. Select modes by task type, then add tier-appropriate modes per Deep Context Integration:
|
|
63
55
|
|
|
64
|
-
- **`type:bug`**:
|
|
65
|
-
- **`type:feature`**:
|
|
66
|
-
- **`type:refactor`**:
|
|
67
|
-
- **`type:qa`**:
|
|
56
|
+
- **`type:bug`**: `symptom-trace`, `root-cause`, `codebase-impact` + tier modes
|
|
57
|
+
- **`type:feature`**: `codebase-impact`, `feature-design`, `architecture` + tier modes
|
|
58
|
+
- **`type:refactor`**: `current-state`, `refactoring-strategy`, `migration-path` + tier modes
|
|
59
|
+
- **`type:qa`**: `codebase-impact` + tier modes
|
|
68
60
|
|
|
69
|
-
Use depth `quick` for low-risk
|
|
61
|
+
Use depth `quick` for low-risk, `standard` for medium-risk, `deep` for high-risk. Tier 3 always uses `deep` depth.
|
|
70
62
|
|
|
71
63
|
### Research Completeness Checklist
|
|
72
64
|
|
|
73
|
-
Before
|
|
65
|
+
Before Phase 1 to Phase 2 handoff, verify:
|
|
74
66
|
|
|
75
|
-
- [ ] **All affected files identified** —
|
|
76
|
-
- [ ] **Blast radius assessed** — downstream consumers
|
|
77
|
-
- [ ] **Existing tests located** —
|
|
78
|
-
- [ ] **Dependencies mapped** — internal
|
|
67
|
+
- [ ] **All affected files identified** — files to be created, modified, or deleted are listed.
|
|
68
|
+
- [ ] **Blast radius assessed** — downstream consumers and integration points documented.
|
|
69
|
+
- [ ] **Existing tests located** — test files covering affected code identified (or absence noted).
|
|
70
|
+
- [ ] **Dependencies mapped** — internal and external dependencies enumerated.
|
|
79
71
|
|
|
80
|
-
If any item
|
|
72
|
+
If any item is unconfirmed, re-run researcher with additional modes or surface to user.
|
|
81
73
|
|
|
82
74
|
### Implementation Delegation
|
|
83
75
|
|
|
84
|
-
|
|
76
|
+
Spawn `hatch3r-implementer` via Task tool for ALL code changes. Never implement inline.
|
|
85
77
|
|
|
86
|
-
- **Single
|
|
87
|
-
- **Plain chat
|
|
88
|
-
- **Epics
|
|
89
|
-
- **
|
|
78
|
+
- **Single issue**: One implementer. Orchestrator owns git/PR/board.
|
|
79
|
+
- **Plain chat task**: One implementer. Create synthetic issue context first.
|
|
80
|
+
- **Epics**: One implementer per sub-issue, level-by-level respecting dependency order.
|
|
81
|
+
- **Batch**: Group by dependency level, one implementer per issue, shared branch + combined PR.
|
|
90
82
|
|
|
91
|
-
**Implementer prompt enrichment
|
|
92
|
-
- `similar-implementation` findings as "Reference Conventions" (triggers the implementer's Convention Lock step)
|
|
93
|
-
- Resolved `requirements-elicitation` answers as "Resolved Requirements"
|
|
94
|
-
- Enhanced `codebase-impact` blast radius data (Tier 3 only)
|
|
83
|
+
**Implementer prompt enrichment (Tier 2+):** Include `similar-implementation` findings as "Reference Conventions", resolved `requirements-elicitation` answers as "Resolved Requirements", and blast radius data (Tier 3 only).
|
|
95
84
|
|
|
96
85
|
### Per-Task Mini-Review
|
|
97
86
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
1. **Verify sub-task correctness** — confirm the sub-task's output compiles/parses without errors and meets its local acceptance criteria.
|
|
101
|
-
2. **Check interface contracts** — ensure any interfaces, types, or contracts introduced or modified by the sub-task are consistent with what subsequent sub-tasks will consume.
|
|
102
|
-
3. **Validate no regressions** — confirm the sub-task has not broken existing functionality visible at that point (e.g., existing tests still pass if applicable).
|
|
103
|
-
4. **Gate progression** — if the mini-review surfaces issues, fix them before moving to the next sub-task. Do not accumulate debt across sub-tasks.
|
|
104
|
-
|
|
105
|
-
Mini-reviews are internal to the implementer and do not require spawning a separate reviewer agent. They are lighter weight than the full Phase 3 review loop, which still runs after all sub-tasks are complete.
|
|
87
|
+
For multi-sub-task implementations, the implementer performs a lightweight mini-review after each sub-task: verify correctness, check interface contracts, validate no regressions, gate progression. Mini-reviews are internal (no separate reviewer agent).
|
|
106
88
|
|
|
107
89
|
### Post-Implementation Quality Pipeline
|
|
108
90
|
|
|
109
|
-
You MUST run the review loop and final quality phases after implementation completes.
|
|
110
|
-
|
|
111
91
|
**Phase 3 — Review Loop:**
|
|
112
92
|
|
|
113
|
-
1. Spawn `hatch3r-reviewer`
|
|
114
|
-
2.
|
|
115
|
-
3.
|
|
116
|
-
4.
|
|
117
|
-
5.
|
|
118
|
-
6. If max iterations reached with remaining findings: surface to user for manual resolution. Do not proceed to Phase 4 until the user acknowledges.
|
|
119
|
-
|
|
120
|
-
**Phase 4 — Final Quality** (runs ONLY after the review loop is clean):
|
|
93
|
+
1. Spawn `hatch3r-reviewer` with diff and acceptance criteria. Reviewer includes blast radius summary.
|
|
94
|
+
2. Critical/Warning findings: spawn `hatch3r-fixer` with full reviewer output.
|
|
95
|
+
3. Re-review after fixes. Repeat until 0 Critical + 0 Warning, or max 3 iterations.
|
|
96
|
+
4. **Confirmation pass** after clean review: lightweight re-review for fix-driven regressions and acceptance criteria completeness.
|
|
97
|
+
5. Max iterations reached: surface to user for manual resolution.
|
|
121
98
|
|
|
122
|
-
|
|
99
|
+
**Phase 4 — Final Quality** (after review loop is clean):
|
|
123
100
|
|
|
124
|
-
|
|
101
|
+
Launch parallel subagents — no artificial concurrency limit.
|
|
125
102
|
|
|
126
|
-
|
|
127
|
-
|
|
103
|
+
- **Always:** `hatch3r-test-writer`, `hatch3r-security-auditor`
|
|
104
|
+
- **Evaluate:** `hatch3r-docs-writer` (when APIs/architecture/UX affected)
|
|
105
|
+
- **Conditional:** `hatch3r-lint-fixer`, `hatch3r-a11y-auditor`, `hatch3r-perf-profiler`, `hatch3r-dependency-auditor`, `hatch3r-architect`, `hatch3r-devops`
|
|
128
106
|
|
|
129
|
-
|
|
107
|
+
### Phase 4 Validation Pass
|
|
130
108
|
|
|
131
|
-
|
|
109
|
+
After all Phase 4 specialists complete, run a validation pass to catch regressions:
|
|
132
110
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
6. `hatch3r-perf-profiler` — when performance-sensitive changes are made.
|
|
138
|
-
7. `hatch3r-dependency-auditor` — when dependencies change or new packages are added.
|
|
139
|
-
8. `hatch3r-architect` — when architectural decisions are needed or system design review is requested.
|
|
140
|
-
9. `hatch3r-devops` — when CI/CD, deployment, or infrastructure tasks are involved.
|
|
111
|
+
1. Run test suite and type checker. Compare against Phase 3 baseline cached in `PipelineContext`.
|
|
112
|
+
2. No new failures: proceed to completion.
|
|
113
|
+
3. New failures: identify causing specialist, spawn `hatch3r-fixer`, re-validate (max 2 iterations).
|
|
114
|
+
4. Persistent regressions: surface to user. Do not silently accept.
|
|
141
115
|
|
|
142
116
|
### Specialist Success Criteria
|
|
143
117
|
|
|
144
|
-
Each Phase 4 specialist agent has a defined success criterion. The specialist's output is considered successful only when its criterion is met. If not met, the orchestrator MUST surface the gap to the user.
|
|
145
|
-
|
|
146
118
|
| Specialist | Success Criterion |
|
|
147
119
|
|-----------|-------------------|
|
|
148
|
-
| `hatch3r-test-writer` | All new
|
|
149
|
-
| `hatch3r-security-auditor` | No HIGH
|
|
150
|
-
| `hatch3r-docs-writer` |
|
|
151
|
-
| `hatch3r-lint-fixer` | Zero lint
|
|
152
|
-
| `hatch3r-a11y-auditor` |
|
|
153
|
-
| `hatch3r-perf-profiler` | No performance regressions
|
|
154
|
-
| `hatch3r-dependency-auditor` | No known CVEs
|
|
155
|
-
| `hatch3r-architect` |
|
|
156
|
-
| `hatch3r-devops` | CI/CD
|
|
120
|
+
| `hatch3r-test-writer` | All new/modified code paths have tests; no untested branches in changed files. |
|
|
121
|
+
| `hatch3r-security-auditor` | No HIGH/CRITICAL findings unresolved; MEDIUM findings documented with plan. |
|
|
122
|
+
| `hatch3r-docs-writer` | Affected APIs, architecture, and UX changes reflected in docs. |
|
|
123
|
+
| `hatch3r-lint-fixer` | Zero lint/type errors in changed files. |
|
|
124
|
+
| `hatch3r-a11y-auditor` | WCAG AA compliance; no new a11y violations. |
|
|
125
|
+
| `hatch3r-perf-profiler` | No performance regressions; new hot paths benchmarked. |
|
|
126
|
+
| `hatch3r-dependency-auditor` | No known CVEs; license compatibility verified. |
|
|
127
|
+
| `hatch3r-architect` | ADRs documented; design aligns with patterns or divergence justified. |
|
|
128
|
+
| `hatch3r-devops` | CI/CD passes end-to-end; deployment config validated. |
|
|
157
129
|
|
|
158
130
|
## Skill Loading Directives
|
|
159
131
|
|
|
160
|
-
|
|
132
|
+
Load the matching skill before implementation:
|
|
161
133
|
|
|
162
134
|
| Task Type | Skill |
|
|
163
135
|
|-----------|-------|
|
|
@@ -168,278 +140,67 @@ Before implementing any task, you MUST read and follow the matching hatch3r skil
|
|
|
168
140
|
| `type:refactor` (other) | `hatch3r-refactor` |
|
|
169
141
|
| `type:qa` | `hatch3r-qa-validation` |
|
|
170
142
|
|
|
171
|
-
|
|
143
|
+
Skill-referenced agent delegations are mandatory.
|
|
172
144
|
|
|
173
145
|
## Subagent Spawning Protocol
|
|
174
146
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
- The agent protocol to follow (e.g., "Follow the hatch3r-implementer agent protocol").
|
|
180
|
-
- All `scope: always` rules from `.agents/rules/` that apply.
|
|
181
|
-
- The project's tooling hierarchy (Context7 MCP for library docs, web research for current context).
|
|
182
|
-
- Relevant learnings from `.agents/learnings/` if the directory exists.
|
|
183
|
-
3. **Launch as many independent subagents in parallel as the platform supports.** Do not impose an artificial concurrency limit. Use maximum parallelism for independent work.
|
|
184
|
-
4. **Await and review results** before proceeding. If a subagent reports BLOCKED or PARTIAL, surface to the user.
|
|
147
|
+
1. Use `subagent_type: "generalPurpose"` for all delegations.
|
|
148
|
+
2. Include: agent protocol, applicable `scope: always` rules, tooling hierarchy, relevant learnings.
|
|
149
|
+
3. Launch independent subagents in parallel — maximum parallelism.
|
|
150
|
+
4. Await and review results. Surface BLOCKED or PARTIAL to user.
|
|
185
151
|
|
|
186
152
|
## Correlation ID
|
|
187
153
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
1. **Generation**: Create one correlation ID per top-level task before Phase 1 begins. Format: UUID v4 (e.g., `550e8400-e29b-41d4-a716-446655440000`).
|
|
191
|
-
2. **Propagation**: Include the correlation ID in every subagent prompt — researchers, implementers, reviewers, fixers, and all Phase 4 specialists. Pass it as a top-level field: `correlation_id: "<value>"`.
|
|
192
|
-
3. **Usage in subagents**: All subagents MUST include the correlation ID in any logs, error messages, structured outputs, or status reports they produce. This applies to both success and failure paths.
|
|
193
|
-
4. **Scope**: One correlation ID per top-level task. Epic sub-issues each get their own correlation ID. Batch tasks share one correlation ID per batch but include a sub-task index (e.g., `correlation_id: "<uuid>", sub_task: 2`).
|
|
154
|
+
Generate a UUID v4 per top-level task before Phase 1. Include in every subagent prompt as `correlation_id`. All subagents include it in logs, outputs, and status reports. Epic sub-issues get individual IDs; batch tasks share one ID with a sub-task index.
|
|
194
155
|
|
|
195
156
|
## Severity Scale
|
|
196
157
|
|
|
197
|
-
All agents across the pipeline MUST use this canonical severity scale when classifying findings, issues, or audit results. This ensures consistent triage and gating across phases.
|
|
198
|
-
|
|
199
158
|
| Severity | Definition | Pipeline Action |
|
|
200
159
|
|----------|-----------|-----------------|
|
|
201
|
-
| **CRITICAL** | Blocks merge
|
|
202
|
-
| **HIGH** | Should fix before merge. Significant bugs, performance regressions
|
|
203
|
-
| **MEDIUM** | Fix in same sprint. Code quality
|
|
204
|
-
| **LOW** | Track for future. Style nits, minor
|
|
205
|
-
| **INFO** | Informational
|
|
206
|
-
|
|
207
|
-
All subagents — reviewers, security auditors, test writers, and other specialists — MUST map their findings to this scale. When a subagent uses a different internal scale, it MUST translate to this canonical scale in its output.
|
|
208
|
-
|
|
209
|
-
## Pipeline Context
|
|
210
|
-
|
|
211
|
-
The orchestrator MUST maintain a `PipelineContext` object throughout the pipeline lifecycle. This object serves as the data contract between pipeline phases, ensuring structured handoff of findings, decisions, and artifacts.
|
|
212
|
-
|
|
213
|
-
### PipelineContext Schema
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
PipelineContext {
|
|
217
|
-
correlationId: string // UUID v4 from the Correlation ID directive
|
|
218
|
-
phase: "research" | "implement" | "review" | "quality" // Current active phase
|
|
219
|
-
findings: Finding[] // Accumulated findings from all phases
|
|
220
|
-
decisions: Decision[] // Decisions made during the pipeline (user answers, trade-offs, overrides)
|
|
221
|
-
artifacts: string[] // File paths created or modified during the pipeline
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
Finding {
|
|
225
|
-
id: string // Unique finding identifier (e.g., "F-001")
|
|
226
|
-
phase: string // Phase that produced the finding
|
|
227
|
-
agent: string // Agent that produced the finding
|
|
228
|
-
severity: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | "INFO" // Per Severity Scale
|
|
229
|
-
description: string // Human-readable finding description
|
|
230
|
-
filePath?: string // Affected file, if applicable
|
|
231
|
-
resolved: boolean // Whether the finding has been addressed
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
Decision {
|
|
235
|
-
id: string // Unique decision identifier (e.g., "D-001")
|
|
236
|
-
phase: string // Phase where the decision was made
|
|
237
|
-
description: string // What was decided
|
|
238
|
-
rationale: string // Why this option was chosen
|
|
239
|
-
madeBy: "user" | "agent" // Who made the decision
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### Phase Handoff Metadata
|
|
244
|
-
|
|
245
|
-
When transitioning between pipeline phases, the orchestrator MUST include the following metadata fields in each handoff to enable traceability and performance analysis:
|
|
246
|
-
|
|
247
|
-
- `timestamp` -- ISO 8601 timestamp of the handoff event
|
|
248
|
-
- `agentId` -- identifier of the agent completing the phase (e.g., `hatch3r-researcher`, `hatch3r-implementer`)
|
|
249
|
-
- `phase` -- the phase being completed (e.g., `research`, `implement`, `review`, `quality`)
|
|
250
|
-
- `duration` -- elapsed time in seconds for the completed phase
|
|
251
|
-
- `filesModified` -- list of file paths created, modified, or deleted during the phase
|
|
252
|
-
|
|
253
|
-
These fields are appended to the `PipelineContext` at each phase transition, providing a structured audit trail of which agent did what, when, and for how long.
|
|
254
|
-
|
|
255
|
-
### Context Caching
|
|
256
|
-
|
|
257
|
-
When multiple agents need the same context (e.g., project structure, test results, blast radius data, reference conventions), cache it in the shared `PipelineContext` rather than having each agent re-read or re-compute it independently. Specifically:
|
|
258
|
-
|
|
259
|
-
- Research output from Phase 1 (file lists, dependency maps, convention extractions) should be stored once and passed by reference to the implementer, reviewer, and any Phase 4 specialists that need it.
|
|
260
|
-
- Test suite results captured during implementation verification should be cached and forwarded to the reviewer and test-writer rather than re-running the full suite in each phase.
|
|
261
|
-
- This reduces redundant file reads, avoids inconsistencies from reading files at different points in time, and conserves token budget across subagent prompts.
|
|
262
|
-
|
|
263
|
-
### Cache Enforcement
|
|
264
|
-
|
|
265
|
-
The orchestrator MUST enforce caching at each phase transition. Caching is not optional guidance -- it is a pipeline invariant.
|
|
266
|
-
|
|
267
|
-
1. **Pre-handoff cache check**: Before spawning any downstream subagent, the orchestrator MUST verify that all cacheable outputs from prior phases are stored in `PipelineContext`. If a cacheable output is missing, the orchestrator MUST populate it before proceeding. Cacheable outputs include:
|
|
268
|
-
- Phase 1: file lists, dependency maps, convention extractions, blast radius data
|
|
269
|
-
- Phase 2: test suite results, modified file list, build output
|
|
270
|
-
- Phase 3: reviewer findings, fixer diffs, resolved/unresolved finding status
|
|
271
|
-
2. **No redundant reads**: If a subagent prompt would include context that exists in the cache, the orchestrator MUST pass the cached version. Subagents MUST NOT re-read files or re-run commands whose results are already cached and fresh (per Cache Verification above).
|
|
272
|
-
3. **Cache population logging**: Log every cache write with the key and size: `"Cache WRITE <cache_key>: <token_estimate> tokens"`. This provides visibility into which data is being cached and its cost.
|
|
273
|
-
4. **Enforcement violation**: If a subagent re-reads or re-computes data that was available in the cache, log a warning: `"Cache BYPASS detected: <agent> re-computed <cache_key> instead of using cached value"`. This warning is informational (severity INFO) and does not block the pipeline, but it flags an optimization gap for future runs.
|
|
274
|
-
|
|
275
|
-
### PipelineContext Usage
|
|
276
|
-
|
|
277
|
-
1. **Initialization**: The orchestrator creates a `PipelineContext` at the start of Phase 1 with the `correlationId` and `phase` set to `"research"`. All other fields are initialized as empty arrays.
|
|
278
|
-
2. **Phase transitions**: When moving between phases, update the `phase` field. Do not clear previous phase data — findings and decisions accumulate across the full pipeline.
|
|
279
|
-
3. **Subagent input**: Pass the current `PipelineContext` (or relevant subsets) to each subagent so it has full pipeline history.
|
|
280
|
-
4. **Subagent output**: Each subagent appends its findings and decisions to the context. The orchestrator merges subagent outputs back into the canonical `PipelineContext`.
|
|
281
|
-
5. **Final output**: The completed `PipelineContext` is included in the task summary, giving the user full traceability from research through quality.
|
|
282
|
-
|
|
283
|
-
## Resilience Directives
|
|
284
|
-
|
|
285
|
-
This section covers all failure/recovery paths — researcher failure, test failure, reviewer failure, and all other subagent failures.
|
|
286
|
-
|
|
287
|
-
When a subagent fails (error, timeout, or BLOCKED status), apply the following retry-and-fallback protocol:
|
|
288
|
-
|
|
289
|
-
1. **Retry once**: Re-send the same prompt to the same agent type exactly once. Do not modify the prompt on retry.
|
|
290
|
-
2. **Fallback on second failure**: If the retry also fails, fall back to degraded mode for that phase:
|
|
291
|
-
- **Researcher failure** → Proceed to Phase 2 (Implement) without research context. Add a warning to the implementer prompt: `"WARNING: Research phase failed. Proceeding without research context. Exercise extra caution with assumptions."` The orchestrator should note this gap in the final output.
|
|
292
|
-
- **Reviewer failure** → Surface the raw diff to the user for manual review. Do not proceed to Phase 4 automatically.
|
|
293
|
-
- **Test-writer failure** → Flag the deliverable as "untested" in the PR description. Add label `needs-tests` if the platform supports it.
|
|
294
|
-
- **Fixer failure** → Surface the original reviewer findings to the user. Do not re-enter the review loop.
|
|
295
|
-
- **Security-auditor failure** → Flag as "security-unaudited" in the PR description. Add label `needs-security-review` if the platform supports it.
|
|
296
|
-
- **Other specialist failure** → Skip that specialist, document the gap in the final output (e.g., "docs-writer skipped due to failure").
|
|
297
|
-
3. **Retry budget**: Maximum 3 total retries across all subagents per top-level task. Once the budget is exhausted, any subsequent failures go directly to fallback without retry.
|
|
298
|
-
4. **Reporting**: Include all failures and fallbacks in the task summary so the user has full visibility into degraded phases.
|
|
299
|
-
|
|
300
|
-
### Circuit Breaker Tracking
|
|
301
|
-
|
|
302
|
-
The orchestrator MUST track consecutive failures per agent type and per pipeline phase to prevent repeated invocations of persistently failing agents.
|
|
303
|
-
|
|
304
|
-
1. **Tracking**: Maintain a per-agent failure counter that increments on each consecutive failure (error, timeout, or BLOCKED) and resets to zero on any success.
|
|
305
|
-
2. **Trip threshold**: After **3 consecutive failures** for the same agent type within a single pipeline run, mark that agent as **"tripped"** and skip all subsequent invocations of it for the remainder of the task.
|
|
306
|
-
3. **State transitions**: Log every circuit breaker state change with the correlation ID, agent type, and transition:
|
|
307
|
-
- `CLOSED → OPEN` — agent tripped after 3 consecutive failures. Log: `"Circuit breaker OPEN for <agent>: <failure_count> consecutive failures"`.
|
|
308
|
-
- `OPEN → HALF-OPEN` — cooldown period elapsed or manual reset issued. Log: `"Circuit breaker HALF-OPEN for <agent>: attempting probe"`.
|
|
309
|
-
- `HALF-OPEN → CLOSED` — probe invocation succeeded. Log: `"Circuit breaker CLOSED for <agent>: probe succeeded"`.
|
|
310
|
-
- `HALF-OPEN → OPEN` — probe invocation failed. Log: `"Circuit breaker re-OPEN for <agent>: probe failed"`.
|
|
311
|
-
4. **Skipping tripped agents**: When an agent is tripped, apply its fallback behavior from the Resilience Directives above and note `"Skipped: circuit breaker OPEN"` in the task summary.
|
|
312
|
-
5. **Reset policy**: A tripped agent can be re-enabled by either:
|
|
313
|
-
- **Manual reset** — the user explicitly requests retrying the agent (e.g., "retry the reviewer").
|
|
314
|
-
- **Cooldown period** — if the pipeline spans multiple top-level tasks in a session, a tripped agent automatically transitions to HALF-OPEN after **10 minutes** of inactivity. The next invocation is a probe: success closes the breaker; failure re-opens it.
|
|
315
|
-
6. **Cross-task persistence**: Circuit breaker state persists within a session. If an agent trips during task A, it remains tripped for task B unless manually reset or the cooldown period has elapsed.
|
|
160
|
+
| **CRITICAL** | Blocks merge. Security vulnerabilities, data loss, broken core functionality. | Must resolve before Phase 3 exit. |
|
|
161
|
+
| **HIGH** | Should fix before merge. Significant bugs, performance regressions. | Fix or escalate to user. |
|
|
162
|
+
| **MEDIUM** | Fix in same sprint. Code quality, minor bugs. | Document with remediation plan. |
|
|
163
|
+
| **LOW** | Track for future. Style nits, minor improvements. | Log only. No merge gate. |
|
|
164
|
+
| **INFO** | Informational. Observations, suggestions. | Awareness only. |
|
|
316
165
|
|
|
317
|
-
|
|
166
|
+
All subagents MUST map findings to this scale.
|
|
318
167
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
1. **Log the stall** with the correlation ID, agent type, phase, and elapsed idle time: `"STALL detected for <agent> in <phase>: <elapsed>s with no output"`.
|
|
322
|
-
2. **Terminate the stalled agent** and capture any partial output produced before the stall.
|
|
323
|
-
3. **Retry once** by re-spawning the same agent type with the same prompt. If the retry also stalls, skip the agent and apply the relevant fallback from the Resilience Directives (e.g., proceed without research context, flag as untested).
|
|
324
|
-
4. **Include a warning** in the `PipelineContext` noting the stall and whether the retry succeeded or the agent was skipped.
|
|
325
|
-
|
|
326
|
-
A stalled invocation counts as a failure for both the retry budget and the circuit breaker failure counter.
|
|
327
|
-
|
|
328
|
-
### Timeout Policy
|
|
329
|
-
|
|
330
|
-
Each pipeline phase has an explicit time budget. If a phase exceeds its timeout, capture partial results and move to the next phase. Do not block the pipeline indefinitely.
|
|
331
|
-
|
|
332
|
-
| Phase / Activity | Per-Item Timeout | Phase Total Timeout |
|
|
333
|
-
|-----------------|-----------------|-------------------|
|
|
334
|
-
| **Phase 1 — Research** | 5 minutes per file | 30 minutes total |
|
|
335
|
-
| **Phase 2 — Implement** | 10 minutes per task | — |
|
|
336
|
-
| **Phase 3 — Review Loop** | 5 minutes per review cycle | — |
|
|
337
|
-
| **Phase 4 — Final Quality** | 5 minutes per specialist | — |
|
|
338
|
-
|
|
339
|
-
**Timeout behavior:**
|
|
340
|
-
|
|
341
|
-
1. **Partial capture**: When a timeout fires, the orchestrator MUST capture whatever output the subagent has produced so far. Partial research context, partial reviews, or partial test suites are preferable to no output.
|
|
342
|
-
2. **Logging**: Log the timeout with the correlation ID, phase, agent, elapsed time, and whether partial results were captured: `"TIMEOUT in <phase> for <agent>: <elapsed>s elapsed, partial results captured: <yes/no>"`.
|
|
343
|
-
3. **Phase advancement**: After capturing partial results, proceed to the next phase. Include a warning in downstream prompts: `"WARNING: <phase> timed out. Partial results only. Exercise extra caution."`.
|
|
344
|
-
4. **Retry interaction**: A timed-out invocation counts as a failure for both the retry budget and the circuit breaker failure counter.
|
|
345
|
-
|
|
346
|
-
### Observability Span Naming
|
|
347
|
-
|
|
348
|
-
For observability, name tracing spans consistently using the pattern `hatch3r.{phase}.{agent}`. This convention enables filtering and aggregation across pipeline runs in any OpenTelemetry-compatible backend.
|
|
349
|
-
|
|
350
|
-
Examples:
|
|
351
|
-
- `hatch3r.research.researcher`
|
|
352
|
-
- `hatch3r.implement.implementer`
|
|
353
|
-
- `hatch3r.review.reviewer`
|
|
354
|
-
- `hatch3r.review.fixer`
|
|
355
|
-
- `hatch3r.quality.test-writer`
|
|
356
|
-
- `hatch3r.quality.security-auditor`
|
|
357
|
-
|
|
358
|
-
The orchestrator creates a root span `hatch3r.pipeline` for the full task, with child spans for each phase and grandchild spans for each agent invocation within that phase. Include the `correlationId` as a span attribute on every span.
|
|
359
|
-
|
|
360
|
-
## Single-Task Plain Chat Protocol
|
|
361
|
-
|
|
362
|
-
When the user provides a single task in plain chat (no command invoked, no issue reference), the full sub-agent pipeline still applies:
|
|
363
|
-
|
|
364
|
-
1. **Classify** the task by type (bug/feature/refactor/QA/other) based on context.
|
|
365
|
-
2. **Create synthetic issue context** — title, acceptance criteria, and type — from the user's instruction.
|
|
366
|
-
3. **Run the Universal Sub-Agent Pipeline**: Phase 1 (Research) → Phase 2 (Implement) → Phase 3 (Review Loop) → Phase 4 (Final Quality).
|
|
367
|
-
4. For issue references in chat (e.g., "fix #5"), fetch issue details using the platform CLI (check `platform` in `.agents/hatch.json`) and use them as the task context instead of creating synthetic context:
|
|
368
|
-
- **GitHub:** `gh issue view`
|
|
369
|
-
- **Azure DevOps:** `az boards work-item show --id`
|
|
370
|
-
- **GitLab:** `glab issue view`
|
|
371
|
-
|
|
372
|
-
This ensures consistent quality regardless of how the task was initiated.
|
|
373
|
-
|
|
374
|
-
## Multi-Task Detection (Plain Chat)
|
|
375
|
-
|
|
376
|
-
When the user provides multiple tasks in a single message — numbered lists, comma-separated instructions, multiple issue references (e.g., "implement #1, #3, #7"), or multiple distinct requests — you MUST parallelize them:
|
|
377
|
-
|
|
378
|
-
1. **Parse** the message into individual discrete tasks. Each distinct implementation request is one task.
|
|
379
|
-
2. **Classify** each task by type (bug/feature/refactor/QA/other) based on context or explicit labels.
|
|
380
|
-
3. **Build a dependency graph** among the tasks. Independent tasks share the same level and run in parallel.
|
|
381
|
-
4. **Spawn one `hatch3r-researcher` subagent per task** (skip for trivial single-line edits only). Launch in parallel.
|
|
382
|
-
5. **Spawn one `hatch3r-implementer` subagent per task** per dependency level.
|
|
383
|
-
6. **For issue references**: fetch issue details using the platform CLI (check `platform` in `.agents/hatch.json`):
|
|
384
|
-
- **GitHub:** `gh issue view`
|
|
385
|
-
- **Azure DevOps:** `az boards work-item show --id`
|
|
386
|
-
- **GitLab:** `glab issue view`
|
|
387
|
-
7. **For natural language tasks**: create synthetic issue context (title, acceptance criteria, type) from the instruction. Pass this context to the implementer subagent.
|
|
388
|
-
8. **Run the review loop** (Phase 3) after all implementations complete: spawn reviewer, then fixer for Critical/Warning findings, re-review, repeat until clean (max 3 iterations).
|
|
389
|
-
9. **Spawn final quality subagents** (Phase 4, after review loop is clean): test-writer + security-auditor (always), plus docs-writer, auditors as applicable.
|
|
390
|
-
|
|
391
|
-
This directive applies regardless of whether board-pickup was invoked. Any context where implementation tasks are identified MUST use one subagent per task with maximum parallelism.
|
|
168
|
+
## Status Codes
|
|
392
169
|
|
|
393
|
-
|
|
170
|
+
| Status | Meaning |
|
|
171
|
+
|--------|---------|
|
|
172
|
+
| **SUCCESS** | Fully completed, all criteria met. |
|
|
173
|
+
| **PARTIAL** | Partially completed; include `reason` field. |
|
|
174
|
+
| **FAILED** | No usable output; include `reason` field. |
|
|
175
|
+
| **SKIPPED** | Intentionally not executed. |
|
|
176
|
+
| **TIMEOUT** | Time budget exceeded; forward partial output. |
|
|
394
177
|
|
|
395
|
-
|
|
178
|
+
## Task Context Protocols
|
|
396
179
|
|
|
397
|
-
|
|
398
|
-
2. **No destructive operations without prior approval** — verify the agent did not perform destructive operations (file deletions, database migrations, force-pushes, dependency removals) unless those operations were explicitly listed in the task prompt as approved actions. Any destructive operation not pre-approved MUST be flagged and rolled back before proceeding.
|
|
399
|
-
3. **Output schema compliance** — verify all agent outputs match their expected schemas. Researcher output must contain the required sections for its modes. Implementer output must include changed file paths and acceptance criteria status. Reviewer output must use the canonical severity scale. Malformed outputs MUST trigger a retry or escalation, not silent acceptance.
|
|
180
|
+
**Single-task plain chat:** Classify task type, create synthetic issue context, run full pipeline. For issue references, fetch details via platform CLI.
|
|
400
181
|
|
|
401
|
-
|
|
182
|
+
**Multi-task plain chat:** Parse into discrete tasks, classify each, build dependency graph, parallelize researchers and implementers per dependency level, run review loop after all implementations, then Phase 4 specialists.
|
|
402
183
|
|
|
403
|
-
|
|
184
|
+
**Auto-mode guardrails:** In unattended execution, verify scope containment, no unapproved destructive operations, and output schema compliance after each phase. Halt on violation. See `hatch3r-agent-orchestration-detail` for full guardrail specifications.
|
|
404
185
|
|
|
405
|
-
|
|
186
|
+
## Rule Application
|
|
406
187
|
|
|
407
|
-
|
|
408
|
-
|--------|---------|
|
|
409
|
-
| **SUCCESS** | Task completed fully, all acceptance criteria met. |
|
|
410
|
-
| **PARTIAL** | Task partially completed; some acceptance criteria met, others remain open or degraded. |
|
|
411
|
-
| **FAILED** | Task could not be completed; no usable output produced. |
|
|
412
|
-
| **SKIPPED** | Task was intentionally not executed (e.g., non-applicable phase, trivial edit bypass). |
|
|
413
|
-
| **TIMEOUT** | Task exceeded its time budget; partial results may be available. |
|
|
188
|
+
All `scope: always` rules apply to every task including subagent work. Include rule directives in subagent prompts.
|
|
414
189
|
|
|
415
|
-
|
|
190
|
+
### Tiered Rule Inclusion
|
|
416
191
|
|
|
417
|
-
|
|
192
|
+
**Tier 1 -- Always include (every subagent):**
|
|
193
|
+
- `hatch3r-security-patterns` -- security invariants
|
|
194
|
+
- `hatch3r-code-standards` -- code quality
|
|
418
195
|
|
|
419
|
-
|
|
196
|
+
**Tier 2 -- Include by phase:**
|
|
197
|
+
- `hatch3r-testing` -- test-writer, implementer, reviewer
|
|
198
|
+
- `hatch3r-accessibility-standards` -- a11y-auditor, reviewer (UI)
|
|
199
|
+
- `hatch3r-git-conventions` -- orchestrator git ops
|
|
200
|
+
- `hatch3r-ci-cd` -- ci-watcher, devops
|
|
201
|
+
- `hatch3r-dependency-management` -- dependency-auditor
|
|
420
202
|
|
|
421
|
-
|
|
203
|
+
**Tier 3 -- On-demand:**
|
|
204
|
+
- `hatch3r-api-design`, `hatch3r-secrets-management`, `hatch3r-data-classification`, `hatch3r-performance-budgets`, `hatch3r-browser-verification`, `hatch3r-component-conventions`, `hatch3r-i18n`, `hatch3r-theming`, `hatch3r-migrations`, `hatch3r-feature-flags`, `hatch3r-observability`
|
|
422
205
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
**Tier 1 -- Always include (every subagent prompt):**
|
|
426
|
-
- `hatch3r-security-patterns` -- security invariants apply to all code changes
|
|
427
|
-
- `hatch3r-code-standards` -- code quality conventions apply universally
|
|
428
|
-
|
|
429
|
-
**Tier 2 -- Include by phase (match to the active agent):**
|
|
430
|
-
- `hatch3r-testing` -- include for `hatch3r-test-writer`, `hatch3r-implementer`, `hatch3r-reviewer`
|
|
431
|
-
- `hatch3r-accessibility-standards` -- include for `hatch3r-a11y-auditor`, `hatch3r-reviewer` (UI changes)
|
|
432
|
-
- `hatch3r-git-conventions` -- include for orchestrator git operations
|
|
433
|
-
- `hatch3r-ci-cd` -- include for `hatch3r-ci-watcher`, `hatch3r-devops`
|
|
434
|
-
- `hatch3r-dependency-management` -- include for `hatch3r-dependency-auditor`
|
|
435
|
-
|
|
436
|
-
**Tier 3 -- On-demand (reference only when the task context requires it):**
|
|
437
|
-
- `hatch3r-api-design` -- when designing or reviewing API contracts
|
|
438
|
-
- `hatch3r-secrets-management` -- when handling credentials or environment config
|
|
439
|
-
- `hatch3r-data-classification` -- when handling PII or sensitive data flows
|
|
440
|
-
- `hatch3r-performance-budgets` -- when profiling or reviewing performance
|
|
441
|
-
- `hatch3r-browser-verification` -- when verifying UI in browser
|
|
442
|
-
- `hatch3r-component-conventions` -- when writing UI components
|
|
443
|
-
- `hatch3r-i18n`, `hatch3r-theming`, `hatch3r-migrations`, `hatch3r-feature-flags`, `hatch3r-observability` -- when the task specifically touches these areas
|
|
444
|
-
|
|
445
|
-
For tools with limited context windows, Tier 1 rules are mandatory. Tier 2 and Tier 3 rules should be included selectively based on the subagent's role and the task scope to avoid exceeding token budgets.
|
|
206
|
+
For limited context windows, Tier 1 is mandatory. Tier 2/3 included selectively by agent role and task scope.
|