v1.0.4 — Guard: Prevent Regressions While Optimizing
What's New in v1.0.4
Guard — Optional Regression Prevention
When optimizing a metric (e.g., benchmark time), the loop can break existing behavior. Guard is an optional safety net — a command that must ALWAYS pass for a change to be kept.
Usage
```
/autoresearch
Goal: Reduce API response time to under 100ms
Metric: p95 response time in ms (lower is better)
Verify: npm run bench:api | grep "p95"
Guard: npm test
Scope: src/api/**/*.ts
```
How It Works
- Verify = "Did the metric improve?" (the goal)
- Guard = "Did anything else break?" (the safety net)
If the metric improves but the guard fails:
- Revert the change
- Read guard output to understand what broke
- Rework the optimization to avoid the regression (max 2 attempts)
- If still failing → discard and move on
Guard/test files are NEVER modified. The optimization must adapt to the tests, not the other way around.
When to Use Guard
| Scenario | Verify | Guard |
|---|---|---|
| Reduce bundle size | `npm run build | grep size` | `npm test` |
| Optimize Lighthouse | `npx lighthouse --output json` | `npm test` |
| Reduce LOC (refactoring) | `wc -l src/**/*.ts` | `npm test && npm run typecheck` |
| Improve benchmark time | `npm run bench` | `npm test` |
| Increase coverage | `jest --coverage` | (no guard needed) |
Guard is optional — if not specified, the loop works exactly as before. Fully backward compatible.
Plan Wizard Integration
`/autoresearch:plan` now asks about Guard during setup:
- Suggests test command as guard when metric is performance/bundle/lighthouse
- Suggests "No guard needed" when metric IS tests (coverage)
- Validates guard passes on current codebase before proceeding
- Includes Guard in the generated config output
Results Log Updated
TSV log now includes a `guard` column:
```tsv
iteration commit metric delta guard status description
0 a1b2c3d 85.2 0.0 pass baseline initial state
4 - 88.9 +1.8 fail discard inline hot-path (guard: 3 tests broke)
5 c3d4e5f 88.3 +1.2 pass keep refactored with preserved interface
```
Pull Requests
| PR | Author | Title |
|---|---|---|
| #7 | @pronskiy (JetBrains) | Core Guard implementation |
| #8 | @uditgoenka | Version fix, README docs, plan wizard integration |
Files Changed
| File | Change |
|---|---|
| `SKILL.md` | Guard in setup phase + loop pseudocode, domain table with Guard column, v1.0.4 |
| `references/autonomous-loop-protocol.md` | Phase 5.5 (Guard), rework logic, updated decide pseudocode |
| `references/results-logging.md` | Guard column in TSV format + examples |
| `references/plan-workflow.md` | Phase 4.5 (Define Guard), guard in config output |
| `README.md` | Guard section, commands table, version badge, credit |
Installation
```bash
git clone https://github.com/uditgoenka/autoresearch.git
cp -r autoresearch/skills/autoresearch ~/.claude/skills/autoresearch
```
Full Changelog: v1.0.3...v1.0.4