hatch3r 1.0.0 → 1.2.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 +93 -322
- package/agents/hatch3r-a11y-auditor.md +24 -6
- package/agents/hatch3r-architect.md +20 -1
- package/agents/hatch3r-ci-watcher.md +31 -8
- package/agents/hatch3r-context-rules.md +14 -2
- package/agents/hatch3r-dependency-auditor.md +21 -5
- package/agents/hatch3r-devops.md +37 -6
- package/agents/hatch3r-docs-writer.md +19 -3
- package/agents/hatch3r-fixer.md +171 -0
- package/agents/hatch3r-implementer.md +84 -11
- package/agents/hatch3r-learnings-loader.md +69 -13
- package/agents/hatch3r-lint-fixer.md +19 -14
- package/agents/hatch3r-perf-profiler.md +18 -1
- package/agents/hatch3r-researcher.md +440 -5
- package/agents/hatch3r-reviewer.md +97 -5
- package/agents/hatch3r-security-auditor.md +23 -5
- package/agents/hatch3r-test-writer.md +21 -10
- package/checks/README.md +49 -0
- package/checks/code-quality.md +49 -0
- package/checks/performance.md +58 -0
- package/checks/security.md +58 -0
- package/checks/testing.md +53 -0
- package/commands/board/pickup-azure-devops.md +81 -0
- package/commands/board/pickup-delegation-multi.md +197 -0
- package/commands/board/pickup-delegation.md +100 -0
- package/commands/board/pickup-github.md +82 -0
- package/commands/board/pickup-gitlab.md +81 -0
- package/commands/board/pickup-modes.md +143 -0
- package/commands/board/pickup-post-impl.md +120 -0
- package/commands/board/shared-azure-devops.md +149 -0
- package/commands/board/shared-board-overview.md +215 -0
- package/commands/board/shared-github.md +169 -0
- package/commands/board/shared-gitlab.md +142 -0
- package/commands/hatch3r-agent-customize.md +40 -2
- package/commands/hatch3r-api-spec.md +294 -32
- package/commands/hatch3r-benchmark.md +386 -32
- package/commands/hatch3r-board-fill.md +161 -25
- package/commands/hatch3r-board-groom.md +595 -0
- package/commands/hatch3r-board-init.md +203 -46
- package/commands/hatch3r-board-pickup.md +79 -457
- package/commands/hatch3r-board-refresh.md +98 -27
- package/commands/hatch3r-board-shared.md +87 -238
- package/commands/hatch3r-bug-plan.md +16 -3
- package/commands/hatch3r-codebase-map.md +43 -10
- package/commands/hatch3r-command-customize.md +6 -0
- package/commands/hatch3r-context-health.md +5 -0
- package/commands/hatch3r-cost-tracking.md +5 -0
- package/commands/hatch3r-debug.md +426 -0
- package/commands/hatch3r-dep-audit.md +7 -1
- package/commands/hatch3r-feature-plan.md +74 -12
- package/commands/hatch3r-healthcheck.md +17 -1
- package/commands/hatch3r-hooks.md +16 -10
- package/commands/hatch3r-learn.md +15 -9
- package/commands/hatch3r-migration-plan.md +333 -33
- package/commands/hatch3r-onboard.md +327 -38
- package/commands/hatch3r-project-spec.md +46 -10
- package/commands/hatch3r-quick-change.md +336 -0
- package/commands/hatch3r-recipe.md +6 -0
- package/commands/hatch3r-refactor-plan.md +29 -13
- package/commands/hatch3r-release.md +13 -3
- package/commands/hatch3r-revision.md +395 -0
- package/commands/hatch3r-roadmap.md +18 -3
- package/commands/hatch3r-rule-customize.md +6 -0
- package/commands/hatch3r-security-audit.md +17 -1
- package/commands/hatch3r-skill-customize.md +6 -0
- package/commands/hatch3r-test-plan.md +532 -0
- package/commands/hatch3r-workflow.md +113 -38
- package/dist/cli/index.js +5184 -2593
- package/dist/cli/index.js.map +1 -0
- package/github-agents/hatch3r-docs-agent.md +1 -0
- package/github-agents/hatch3r-lint-agent.md +1 -0
- package/github-agents/hatch3r-security-agent.md +1 -0
- package/github-agents/hatch3r-test-agent.md +1 -0
- package/hooks/hatch3r-ci-failure.md +30 -0
- package/hooks/hatch3r-file-save.md +22 -0
- package/hooks/hatch3r-post-merge.md +23 -0
- package/hooks/hatch3r-pre-commit.md +23 -0
- package/hooks/hatch3r-pre-push.md +22 -0
- package/hooks/hatch3r-session-start.md +22 -0
- package/mcp/mcp.json +22 -3
- package/package.json +4 -7
- package/prompts/hatch3r-bug-triage.md +1 -0
- package/prompts/hatch3r-code-review.md +1 -0
- package/prompts/hatch3r-pr-description.md +1 -0
- package/rules/hatch3r-accessibility-standards.md +1 -0
- package/rules/hatch3r-agent-orchestration.md +326 -53
- package/rules/hatch3r-agent-orchestration.mdc +225 -0
- package/rules/hatch3r-api-design.md +4 -1
- package/rules/hatch3r-browser-verification.md +33 -1
- package/rules/hatch3r-browser-verification.mdc +29 -0
- package/rules/hatch3r-ci-cd.md +5 -1
- package/rules/hatch3r-ci-cd.mdc +4 -1
- package/rules/hatch3r-code-standards.md +18 -0
- package/rules/hatch3r-code-standards.mdc +10 -1
- package/rules/hatch3r-component-conventions.md +4 -1
- package/rules/hatch3r-data-classification.md +1 -0
- package/rules/hatch3r-deep-context.md +94 -0
- package/rules/hatch3r-deep-context.mdc +69 -0
- package/rules/hatch3r-dependency-management.md +13 -0
- package/rules/hatch3r-feature-flags.md +4 -1
- package/rules/hatch3r-git-conventions.md +1 -0
- package/rules/hatch3r-i18n.md +4 -1
- package/rules/hatch3r-learning-consult.md +4 -2
- package/rules/hatch3r-learning-consult.mdc +3 -2
- package/rules/hatch3r-migrations.md +12 -0
- package/rules/hatch3r-observability.md +293 -1
- package/rules/hatch3r-performance-budgets.md +5 -2
- package/rules/hatch3r-performance-budgets.mdc +1 -1
- package/rules/hatch3r-secrets-management.md +11 -3
- package/rules/hatch3r-secrets-management.mdc +10 -3
- package/rules/hatch3r-security-patterns.md +23 -3
- package/rules/hatch3r-security-patterns.mdc +8 -2
- package/rules/hatch3r-testing.md +1 -0
- package/rules/hatch3r-theming.md +4 -1
- package/rules/hatch3r-tooling-hierarchy.md +42 -15
- package/rules/hatch3r-tooling-hierarchy.mdc +27 -4
- package/skills/hatch3r-a11y-audit/SKILL.md +1 -0
- package/skills/hatch3r-agent-customize/SKILL.md +3 -0
- package/skills/hatch3r-api-spec/SKILL.md +1 -0
- package/skills/hatch3r-architecture-review/SKILL.md +6 -2
- package/skills/hatch3r-bug-fix/SKILL.md +4 -1
- package/skills/hatch3r-ci-pipeline/SKILL.md +1 -0
- package/skills/hatch3r-command-customize/SKILL.md +1 -0
- package/skills/hatch3r-context-health/SKILL.md +2 -1
- package/skills/hatch3r-cost-tracking/SKILL.md +1 -0
- package/skills/hatch3r-dep-audit/SKILL.md +6 -2
- package/skills/hatch3r-feature/SKILL.md +9 -2
- package/skills/hatch3r-gh-agentic-workflows/SKILL.md +130 -21
- package/skills/hatch3r-incident-response/SKILL.md +11 -5
- package/skills/hatch3r-issue-workflow/SKILL.md +12 -7
- package/skills/hatch3r-logical-refactor/SKILL.md +1 -0
- package/skills/hatch3r-migration/SKILL.md +1 -0
- package/skills/hatch3r-perf-audit/SKILL.md +2 -1
- package/skills/hatch3r-pr-creation/SKILL.md +20 -10
- package/skills/hatch3r-qa-validation/SKILL.md +2 -1
- package/skills/hatch3r-recipe/SKILL.md +1 -0
- package/skills/hatch3r-refactor/SKILL.md +7 -1
- package/skills/hatch3r-release/SKILL.md +15 -11
- package/skills/hatch3r-rule-customize/SKILL.md +1 -0
- package/skills/hatch3r-skill-customize/SKILL.md +1 -0
- package/skills/hatch3r-visual-refactor/SKILL.md +1 -0
- package/dist/cli/hooks-ZOTFDEA3.js +0 -59
- package/rules/hatch3r-error-handling.md +0 -17
- package/rules/hatch3r-error-handling.mdc +0 -15
|
@@ -2,49 +2,403 @@
|
|
|
2
2
|
id: hatch3r-benchmark
|
|
3
3
|
type: command
|
|
4
4
|
description: Run and analyze performance benchmarks. Compare results against baselines, identify regressions, and produce performance reports.
|
|
5
|
+
tags: [review, performance]
|
|
5
6
|
---
|
|
6
|
-
# Performance Benchmark
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Agent Pipeline
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
| Stage | Agent(s) | Parallel | Required |
|
|
11
|
+
|-------|----------|----------|----------|
|
|
12
|
+
| 1. Discovery | `hatch3r-researcher` (codebase-analysis mode) | No | Yes |
|
|
13
|
+
| 2. Execution | Orchestrator (inline, runs benchmarks) | No | Yes |
|
|
14
|
+
| 3. Analysis | `hatch3r-perf-profiler` | No | Yes |
|
|
15
|
+
| 4. Reporting | `hatch3r-docs-writer` | No | If regressions found |
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
# Performance Benchmark — Run, Compare, and Report on Performance Metrics
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
- Scan for benchmark files (`.bench.ts`, `.benchmark.ts`, `__benchmarks__/`, `bench/`)
|
|
18
|
-
- If no benchmarks exist, identify critical paths and suggest benchmark candidates
|
|
19
|
+
Run performance benchmarks against a target (file, function, endpoint, or full suite), compare results against a baseline (previous run, git ref, or none), and produce a structured performance report. Discovers existing benchmark files or proposes new ones for critical paths. Executes with configurable iterations, performs statistical analysis on results, and flags regressions with root cause tracing. Persists results to `.benchmarks/results.json` for longitudinal tracking. AI proposes all actions; user confirms at every checkpoint.
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Shared Context
|
|
24
|
+
|
|
25
|
+
**Read the `hatch3r-board-shared` command at the start of the run** if it exists. While this command does not perform board operations directly, it establishes patterns and context (GitHub owner/repo, tooling directives) that may be useful for regression issue creation. Cache any values found.
|
|
26
|
+
|
|
27
|
+
## Token-Saving Directives
|
|
28
|
+
|
|
29
|
+
1. **Do not re-read files already cached.** Once benchmark discovery results are collected, reference them in memory — do not re-scan the filesystem.
|
|
30
|
+
2. **Limit source reads.** When reading source files to identify critical paths, read function signatures and hot-path sections only — not entire files.
|
|
31
|
+
3. **Structured output only.** All sub-agent prompts and benchmark results require structured markdown output — no prose dumps.
|
|
32
|
+
4. **Compress raw metrics.** Store full raw data in `.benchmarks/results.json` but present only summary statistics (mean, p50, p95, p99, stddev) in the report.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Workflow
|
|
37
|
+
|
|
38
|
+
Execute these steps in order. **Do not skip any step.** Ask the user at every checkpoint marked with ASK.
|
|
39
|
+
|
|
40
|
+
### Step 1: Gather Benchmark Context
|
|
41
|
+
|
|
42
|
+
1. **ASK:** "Tell me about the benchmarks you want to run. I need:
|
|
43
|
+
- **Target:** specific file, function, endpoint, module, or `all` for the full suite
|
|
44
|
+
- **Baseline:** `previous-run` (default — loads last saved results), a git ref (branch/tag/SHA to compare against), or `none` (no comparison)
|
|
45
|
+
- **Iterations:** number of benchmark runs for statistical significance (default: 5, minimum: 3)
|
|
46
|
+
- **Environment constraints:** CI vs. local, Node version, memory limits, specific flags (e.g., `--expose-gc`)
|
|
47
|
+
- **Metrics of interest:** time (default), memory, throughput (ops/sec), or `all`
|
|
48
|
+
|
|
49
|
+
You can also point me to an existing benchmark config file and I'll extract these from it."
|
|
50
|
+
|
|
51
|
+
2. If the user provides a config reference, read it and extract the fields above.
|
|
52
|
+
3. Present a structured summary:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
Benchmark Brief:
|
|
56
|
+
Target: {target — file/function/endpoint/all}
|
|
57
|
+
Baseline: {previous-run / git-ref / none}
|
|
58
|
+
Iterations: {N}
|
|
59
|
+
Environment: {CI / local — Node version, flags}
|
|
60
|
+
Metrics: {time / memory / throughput / all}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**ASK:** "Does this capture the benchmark plan correctly? Adjust anything before I begin discovery."
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
### Step 2: Discover Benchmarks
|
|
68
|
+
|
|
69
|
+
Delegate to `hatch3r-researcher` in `codebase-analysis` mode with focus on benchmark discovery.
|
|
70
|
+
|
|
71
|
+
1. Scan the codebase for existing benchmark infrastructure:
|
|
72
|
+
- Benchmark files: `*.bench.ts`, `*.benchmark.ts`, `*.bench.js`, `*.benchmark.js`
|
|
73
|
+
- Benchmark directories: `__benchmarks__/`, `bench/`, `benchmarks/`
|
|
74
|
+
- Test runner bench support: vitest `bench` mode, jest-bench, tinybench, benny
|
|
75
|
+
- Package.json scripts: any script containing `bench` or `benchmark`
|
|
76
|
+
- Existing results: `.benchmarks/`, `benchmark-results/`, or similar
|
|
77
|
+
2. If benchmarks are found, catalog them:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
Benchmark Discovery:
|
|
81
|
+
Files found: {N} benchmark files
|
|
82
|
+
Runner: {vitest bench / tinybench / benny / custom}
|
|
83
|
+
Existing results: {found at path / not found}
|
|
84
|
+
Coverage: {which modules/functions have benchmarks}
|
|
85
|
+
Gaps: {critical paths without benchmarks}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
3. If the target is a specific file/function, verify a corresponding benchmark exists.
|
|
89
|
+
|
|
90
|
+
**ASK:** "Here are the benchmarks I found. Confirm which to run:
|
|
91
|
+
{numbered list of benchmark files/suites with brief description}
|
|
92
|
+
|
|
93
|
+
Select: (a) all listed, (b) specific numbers, (c) let me suggest new benchmarks first"
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### Step 3: Suggest Benchmarks (If Needed)
|
|
98
|
+
|
|
99
|
+
Skip this step if the user confirmed existing benchmarks in Step 2 and no gaps were identified.
|
|
100
|
+
|
|
101
|
+
1. Identify critical paths that lack benchmarks:
|
|
102
|
+
- Functions with high cyclomatic complexity
|
|
103
|
+
- Hot paths (called frequently based on import graph analysis)
|
|
104
|
+
- I/O-bound operations (database queries, file operations, network calls)
|
|
105
|
+
- Data transformation pipelines (parsing, serialization, mapping)
|
|
106
|
+
- Functions the user specifically targeted in Step 1
|
|
107
|
+
2. For each candidate, propose a benchmark skeleton:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
Benchmark Candidates:
|
|
111
|
+
1. {function/module} — {why it's a critical path}
|
|
112
|
+
Suggested benchmark: {brief description of what to measure}
|
|
113
|
+
2. {function/module} — {why it's a critical path}
|
|
114
|
+
Suggested benchmark: {brief description of what to measure}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**ASK:** "These critical paths lack benchmarks. Options:
|
|
118
|
+
- **(a) Create benchmarks** for selected candidates (tell me which numbers)
|
|
119
|
+
- **(b) Skip** — run only existing benchmarks
|
|
120
|
+
- **(c) Create all** suggested benchmarks"
|
|
121
|
+
|
|
122
|
+
3. If the user approves creation, generate benchmark files following the detected runner conventions (vitest bench, tinybench, etc.). Present file contents for review before writing.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### Step 4: Environment Preparation
|
|
127
|
+
|
|
128
|
+
1. Verify clean execution state:
|
|
129
|
+
- Check for running dev servers, watchers, or other processes that consume CPU/memory
|
|
130
|
+
- Warn if detected: "Found {N} background processes that may affect benchmark stability: {list}"
|
|
131
|
+
2. Set environment:
|
|
132
|
+
- `NODE_ENV=production` (unless the user specified otherwise)
|
|
133
|
+
- Apply any flags from Step 1 (e.g., `--expose-gc` for memory benchmarks)
|
|
134
|
+
3. If baseline is a git ref:
|
|
135
|
+
- Verify the ref exists: `git rev-parse --verify {ref}`
|
|
136
|
+
- Check for uncommitted changes that would block checkout
|
|
137
|
+
4. Present readiness check:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
Environment Ready:
|
|
141
|
+
NODE_ENV: {production}
|
|
142
|
+
Node version: {version}
|
|
143
|
+
Background noise: {none / warnings listed}
|
|
144
|
+
Baseline ref: {verified / N/A}
|
|
145
|
+
Working tree: {clean / uncommitted changes — list}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
If uncommitted changes exist and baseline requires git checkout, **ASK:** "Uncommitted changes detected. Options: (a) stash and continue, (b) abort baseline comparison, (c) use `previous-run` baseline instead"
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### Step 5: Execute Benchmarks
|
|
153
|
+
|
|
154
|
+
1. Run the benchmark suite with the specified iterations:
|
|
155
|
+
- Cold start run (first iteration, not counted in statistics)
|
|
156
|
+
- Warm runs (remaining N iterations, used for statistics)
|
|
157
|
+
2. Capture metrics per benchmark:
|
|
158
|
+
- **Time:** mean, median (p50), p95, p99, min, max, standard deviation
|
|
159
|
+
- **Memory:** heap used (mean, peak), RSS delta, GC pause time (if `--expose-gc`)
|
|
160
|
+
- **Throughput:** operations per second, iterations completed
|
|
161
|
+
3. Monitor execution:
|
|
162
|
+
- Report progress: "Running benchmark {M}/{total} — {name}... iteration {I}/{N}"
|
|
163
|
+
- If a single benchmark takes >60s per iteration, warn the user
|
|
164
|
+
- If a benchmark crashes, capture the error and continue with remaining benchmarks
|
|
165
|
+
4. Store raw results in memory for analysis.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### Step 6: Baseline Comparison
|
|
170
|
+
|
|
171
|
+
Skip if baseline is `none`.
|
|
172
|
+
|
|
173
|
+
1. **If baseline is `previous-run`:**
|
|
174
|
+
- Load `.benchmarks/results.json`
|
|
175
|
+
- If file does not exist, warn and skip comparison
|
|
176
|
+
- Match benchmarks by name — report any that exist in one set but not the other
|
|
177
|
+
2. **If baseline is a git ref:**
|
|
178
|
+
- Stash current changes (if any)
|
|
179
|
+
- Checkout the baseline ref
|
|
180
|
+
- Run the same benchmark suite with the same iterations and environment
|
|
181
|
+
- Checkout the original branch and restore stash
|
|
182
|
+
- Match benchmarks by name
|
|
183
|
+
3. Compute deltas for each matched benchmark:
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
Comparison:
|
|
187
|
+
Benchmark | Metric | Baseline | Current | Delta | Change
|
|
188
|
+
{name} | time p50 | {value} | {value} | {±value} | {±%}
|
|
189
|
+
{name} | ops/sec | {value} | {value} | {±value} | {±%}
|
|
190
|
+
{name} | heap | {value} | {value} | {±value} | {±%}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
### Step 7: Statistical Analysis
|
|
196
|
+
|
|
197
|
+
Delegate to `hatch3r-perf-profiler` for analysis of the collected metrics.
|
|
198
|
+
|
|
199
|
+
1. Calculate statistical significance for each delta:
|
|
200
|
+
- Use coefficient of variation (CV) to assess measurement noise
|
|
201
|
+
- Flag results with CV > 15% as **noisy** — increase iterations recommended
|
|
202
|
+
- Apply t-test or equivalent for significance (p < 0.05 threshold)
|
|
203
|
+
2. Identify outliers:
|
|
204
|
+
- Runs that deviate > 2 standard deviations from mean
|
|
205
|
+
- Report outlier count and whether they skew results
|
|
206
|
+
3. Classify each benchmark result:
|
|
24
207
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
208
|
+
| Classification | Criteria | Action |
|
|
209
|
+
|---------------|----------|--------|
|
|
210
|
+
| `regression-critical` | > 50% slower or > 2x memory | Immediate attention |
|
|
211
|
+
| `regression-warning` | 10–50% slower or 50–100% more memory | Investigation recommended |
|
|
212
|
+
| `acceptable` | < 10% change in either direction | No action needed |
|
|
213
|
+
| `improvement` | > 10% faster or less memory | Note for celebration |
|
|
214
|
+
| `noisy` | CV > 15% — results unreliable | Rerun with more iterations |
|
|
215
|
+
|
|
216
|
+
**ASK:** "Here is the benchmark summary:
|
|
217
|
+
- {N} benchmarks executed across {M} iterations
|
|
218
|
+
- {X} regressions ({critical count} critical, {warning count} warning)
|
|
219
|
+
- {Y} improvements
|
|
220
|
+
- {Z} noisy results
|
|
221
|
+
|
|
222
|
+
Want me to perform deep analysis on any specific metric or benchmark? (list numbers / all regressions / skip to report)"
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### Step 8: Root Cause Analysis (If Regressions Found)
|
|
227
|
+
|
|
228
|
+
Skip if no regressions classified as `regression-critical` or `regression-warning` in Step 7.
|
|
229
|
+
|
|
230
|
+
1. For each regression > 10%, trace to specific code changes:
|
|
231
|
+
- If baseline is a git ref: `git diff {ref}...HEAD -- {affected files}`
|
|
232
|
+
- Identify new code in hot paths, additional allocations, changed algorithms
|
|
233
|
+
- Cross-reference with import graph to find indirect causes
|
|
234
|
+
2. Categorize root causes:
|
|
235
|
+
|
|
236
|
+
| Pattern | Example | Typical Fix |
|
|
237
|
+
|---------|---------|-------------|
|
|
238
|
+
| Hot path expansion | New validation/logging in critical loop | Move out of loop, lazy evaluate |
|
|
239
|
+
| Allocation increase | New object creation per iteration | Object pooling, pre-allocation |
|
|
240
|
+
| Algorithm change | O(n) → O(n²) in data processing | Restore or optimize algorithm |
|
|
241
|
+
| Dependency overhead | New import initializing at load time | Lazy import, tree-shake |
|
|
242
|
+
| Serialization cost | Larger payloads, new fields | Selective serialization |
|
|
243
|
+
|
|
244
|
+
3. Present findings per regression:
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
Regression Analysis: {benchmark name}
|
|
248
|
+
Metric: {metric} — {baseline} → {current} ({+%} regression)
|
|
249
|
+
Root cause: {description}
|
|
250
|
+
Files: {affected files with line ranges}
|
|
251
|
+
Category: {pattern from table above}
|
|
252
|
+
Suggested fix: {brief recommendation}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
### Step 9: Generate Report
|
|
258
|
+
|
|
259
|
+
Delegate to `hatch3r-docs-writer` if regressions were found (for a polished report); otherwise the orchestrator generates inline.
|
|
260
|
+
|
|
261
|
+
Present the full report for review before saving. Use the **Output Template** below.
|
|
262
|
+
|
|
263
|
+
**ASK:** "Here is the benchmark report. Review before I save:
|
|
264
|
+
- {N} benchmarks, {M} iterations, {environment}
|
|
265
|
+
- {X} regressions, {Y} improvements, {Z} stable
|
|
266
|
+
- Report file: `.benchmarks/report-{date}.md`
|
|
267
|
+
|
|
268
|
+
Confirm, or tell me what to adjust."
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
### Step 10: Save Results
|
|
273
|
+
|
|
274
|
+
1. Save raw results to `.benchmarks/results.json` (create directory if needed):
|
|
275
|
+
- Timestamp, git SHA, branch, environment metadata
|
|
276
|
+
- Per-benchmark: all iterations, computed statistics, classification
|
|
277
|
+
- Comparison deltas (if baseline was used)
|
|
278
|
+
2. Save the markdown report to `.benchmarks/report-{YYYY-MM-DD}.md`.
|
|
279
|
+
3. Present a summary of files created:
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
Files Created/Updated:
|
|
283
|
+
.benchmarks/
|
|
284
|
+
results.json — {N} benchmarks, {M} iterations, {timestamp}
|
|
285
|
+
report-{YYYY-MM-DD}.md — full benchmark report
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**ASK:** "Results saved. Should these become the new baseline for future comparisons? (yes — overwrites previous baseline / no — keep existing baseline)"
|
|
289
|
+
|
|
290
|
+
If yes, ensure `results.json` is structured as the canonical baseline for the next `previous-run` comparison.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Output Template
|
|
295
|
+
|
|
296
|
+
The benchmark report follows this structure:
|
|
297
|
+
|
|
298
|
+
```markdown
|
|
299
|
+
# Performance Benchmark Report
|
|
300
|
+
|
|
301
|
+
**Date:** {YYYY-MM-DD}
|
|
302
|
+
**Branch:** {branch} @ {short SHA}
|
|
303
|
+
**Baseline:** {previous-run / git ref / none}
|
|
304
|
+
**Environment:** {Node version}, {OS}, {CI/local}
|
|
305
|
+
**Iterations:** {N} (+ 1 cold start, excluded)
|
|
306
|
+
|
|
307
|
+
## Summary
|
|
308
|
+
|
|
309
|
+
| Status | Count |
|
|
310
|
+
|--------|-------|
|
|
311
|
+
| Regressions (critical) | {N} |
|
|
312
|
+
| Regressions (warning) | {N} |
|
|
313
|
+
| Stable | {N} |
|
|
314
|
+
| Improvements | {N} |
|
|
315
|
+
| Noisy (inconclusive) | {N} |
|
|
316
|
+
|
|
317
|
+
## Results
|
|
318
|
+
|
|
319
|
+
| Benchmark | Metric | Baseline | Current | Delta | Status |
|
|
320
|
+
|-----------|--------|----------|---------|-------|--------|
|
|
321
|
+
| {name} | time (p50) | {value}ms | {value}ms | {±%} | {status icon} |
|
|
322
|
+
| {name} | ops/sec | {value} | {value} | {±%} | {status icon} |
|
|
323
|
+
| {name} | heap (mean) | {value}MB | {value}MB | {±%} | {status icon} |
|
|
324
|
+
|
|
325
|
+
### Statistical Confidence
|
|
326
|
+
|
|
327
|
+
| Benchmark | CV (%) | Outliers | Significance | Reliable |
|
|
328
|
+
|-----------|--------|----------|-------------|----------|
|
|
329
|
+
| {name} | {value}% | {N}/{total} | p={value} | {yes/no} |
|
|
330
|
+
|
|
331
|
+
## Regressions
|
|
332
|
+
|
|
333
|
+
### {Benchmark Name} — {metric} regression ({+%})
|
|
334
|
+
|
|
335
|
+
**Severity:** {critical / warning}
|
|
336
|
+
**Baseline:** {value} → **Current:** {value} ({±absolute}, {±%})
|
|
337
|
+
|
|
338
|
+
**Root Cause:**
|
|
339
|
+
{description of what changed and why it's slower}
|
|
340
|
+
|
|
341
|
+
**Affected Code:**
|
|
342
|
+
- `{file}:{line range}` — {what changed}
|
|
343
|
+
|
|
344
|
+
**Recommendation:**
|
|
345
|
+
{specific optimization suggestion}
|
|
346
|
+
|
|
347
|
+
## Improvements
|
|
348
|
+
|
|
349
|
+
| Benchmark | Metric | Baseline | Current | Improvement |
|
|
350
|
+
|-----------|--------|----------|---------|-------------|
|
|
351
|
+
| {name} | {metric} | {value} | {value} | {-%} faster |
|
|
352
|
+
|
|
353
|
+
## Environment Details
|
|
354
|
+
|
|
355
|
+
| Property | Value |
|
|
356
|
+
|----------|-------|
|
|
357
|
+
| Node.js | {version} |
|
|
358
|
+
| OS | {platform, arch} |
|
|
359
|
+
| CPU | {model, cores} |
|
|
360
|
+
| Memory | {total} |
|
|
361
|
+
| Runner | {vitest bench / tinybench / custom} |
|
|
362
|
+
| Flags | {--expose-gc, etc.} |
|
|
363
|
+
|
|
364
|
+
## Recommendations
|
|
365
|
+
|
|
366
|
+
1. {prioritized optimization recommendation}
|
|
367
|
+
2. {recommendation}
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
*Generated by hatch3r-benchmark — {timestamp}*
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
---
|
|
29
375
|
|
|
30
|
-
|
|
31
|
-
- Flag any metric that regressed > 10% from baseline
|
|
32
|
-
- For regressions, identify the likely cause (new code in hot path, additional allocations, etc.)
|
|
33
|
-
- Classify: `critical` (> 50% regression), `warning` (10-50%), `acceptable` (< 10%)
|
|
376
|
+
## Error Handling
|
|
34
377
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
378
|
+
- **Benchmarks fail to run:** Capture the error output. Check for missing dependencies, syntax errors, or runner misconfiguration. Present the error and ASK: "Benchmark {name} failed to execute: {error}. Options: (a) skip and continue with remaining, (b) attempt to fix the benchmark file, (c) abort."
|
|
379
|
+
- **Baseline ref does not exist:** If `git rev-parse --verify {ref}` fails, report the error and ASK: "Baseline ref `{ref}` not found. Options: (a) use `previous-run` instead, (b) run without comparison, (c) provide a different ref."
|
|
380
|
+
- **No previous results file:** If baseline is `previous-run` but `.benchmarks/results.json` does not exist, warn and proceed without comparison. Note in the report that this is a baseline-establishing run.
|
|
381
|
+
- **Results too noisy (high variance):** If CV > 15% for more than half the benchmarks, flag the entire run as unreliable. ASK: "Results show high variance — likely environmental interference. Options: (a) rerun with more iterations ({current × 2}), (b) accept results with noise caveat, (c) abort and retry in a cleaner environment."
|
|
382
|
+
- **Benchmark timeout:** If a single benchmark exceeds 5 minutes per iteration, kill it and report. ASK whether to skip or increase the timeout.
|
|
383
|
+
- **Git checkout failure during baseline comparison:** If stash/checkout fails (merge conflicts, dirty state), abort the baseline comparison gracefully. Fall back to `previous-run` or `none` and inform the user.
|
|
384
|
+
- **Disk space for results:** If `.benchmarks/results.json` grows excessively (> 10MB), warn and suggest pruning old entries.
|
|
40
385
|
|
|
41
|
-
##
|
|
386
|
+
## Guardrails
|
|
42
387
|
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
388
|
+
- **Never modify production code based on benchmark results.** The benchmark command observes and reports — it never changes application source code. Optimization changes require a separate implementation task.
|
|
389
|
+
- **Never skip ASK checkpoints.** Every step with an ASK must pause for user confirmation.
|
|
390
|
+
- **Flag CI vs. local execution.** Results from different environments must not share a baseline. Include environment fingerprint in `results.json` and warn if comparing across environments.
|
|
391
|
+
- **Minimum 3 iterations for statistical validity.** If the user requests fewer, override to 3 and explain why.
|
|
392
|
+
- **Always exclude the cold start run from statistics.** The first iteration warms caches and JIT — including it skews results.
|
|
393
|
+
- **Never overwrite baseline without confirmation.** Step 10 explicitly asks before promoting results to baseline status.
|
|
394
|
+
- **Preserve existing `.benchmarks/results.json` history.** Append new runs; do not truncate historical data without user approval.
|
|
395
|
+
- **Do not benchmark in debug mode.** Ensure `NODE_ENV=production` and no debug flags are active unless explicitly requested.
|
|
396
|
+
- **Respect the project's tooling hierarchy** for knowledge augmentation: project docs first, then codebase exploration, then Context7 MCP, then web research.
|
|
397
|
+
- **Report, don't interpret subjectively.** Present statistical facts. Flag regressions by threshold, not opinion. Let the user decide what matters.
|
|
46
398
|
|
|
47
399
|
## Related
|
|
48
400
|
|
|
49
|
-
- **
|
|
50
|
-
- **
|
|
401
|
+
- **Agent:** `hatch3r-perf-profiler` — deep performance profiling and analysis
|
|
402
|
+
- **Check:** `checks/performance.md` — performance budget checks
|
|
403
|
+
- **Rule:** `hatch3r-performance-budgets` — performance budget thresholds and enforcement
|
|
404
|
+
- **Command:** `hatch3r-refactor-plan` — plan optimizations identified by benchmark regressions
|