know-thy-build 0.8.0 → 0.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "know-thy-build",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Multi-agent project definition & QA framework for Claude Code — Socratic dialogue, behavioral testing axes, design intent, orchestrated review",
5
5
  "bin": {
6
6
  "know-thy-build": "./bin/cli.js"
@@ -375,6 +375,8 @@ gate:
375
375
  architect: pending
376
376
  designer: pending # set to 'skipped' for non-UI features
377
377
  qa: pending
378
+ integration: pending # set by finish — auto-passed if no conflicts
379
+ ci: pending # set by finish — runs project test command
378
380
  assumptions:
379
381
  - "{{assumption}}"
380
382
  date: {{date}}
@@ -384,10 +386,12 @@ generatedBy: know-thy-build-feature
384
386
 
385
387
  **Gate initialization rules:**
386
388
  - **Spike**: No gate field. Spikes produce answers, not implementations.
387
- - **Bounded (non-UI)**: `architect: pending`, `designer: skipped`, `qa: pending`
388
- - **Bounded (UI)**: `architect: pending`, `designer: pending`, `qa: pending`
389
+ - **Bounded (non-UI)**: `architect: pending`, `designer: skipped`, `qa: pending`, `integration: pending`, `ci: pending`
390
+ - **Bounded (UI)**: `architect: pending`, `designer: pending`, `qa: pending`, `integration: pending`, `ci: pending`
389
391
  - **Architectural**: All `pending`
390
392
 
393
+ `integration` and `ci` gates are always initialized as `pending`. They are set by `/know-thy-build:finish` during the merge pipeline — never manually.
394
+
391
395
  **Priority guide:**
392
396
  - **P0**: Must-have for MVP. Without this, the project doesn't deliver its core value.
393
397
  - **P1**: Important. Significantly improves the experience but the project works without it.
@@ -1,19 +1,19 @@
1
1
  ---
2
2
  description: Merge a completed feature — checks all review gates, squash merges to main, cleans up worktree. The final step in the feature lifecycle.
3
- allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion]
3
+ allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, Agent, AskUserQuestion]
4
4
  ---
5
5
 
6
6
  # Know Thy Build — Finish
7
7
 
8
- You are the **release gate**. Your job is to verify that all review gates have passed, then merge the feature to main and clean up.
8
+ You are the **release gate**. Your job is to verify that all review gates have passed, rebase on main, handle conflicts, run CI, and then merge.
9
9
 
10
- You do NOT implement, review, or test. You only verify the gate and execute the merge.
10
+ You do NOT implement features. You verify, resolve, review, and merge.
11
11
 
12
12
  ## Language
13
13
 
14
14
  **All conversation and output MUST be in: {{LANG}}**
15
15
 
16
- Technical terms (e.g. merge, squash, worktree, gate) stay in English. Everything else uses the specified language.
16
+ Technical terms (e.g. merge, squash, worktree, gate, rebase, conflict) stay in English. Everything else uses the specified language.
17
17
 
18
18
  ---
19
19
 
@@ -43,56 +43,62 @@ Read the feature spec and extract the gate section from frontmatter.
43
43
  ### 3. Read project operations
44
44
 
45
45
  ```bash
46
- # Check for project-specific merge/deploy requirements
47
- grep -A 20 '## Operations' docs/PROJECT.md 2>/dev/null
46
+ # Check for project-specific merge/deploy/test requirements
47
+ grep -A 30 '## Operations' docs/PROJECT.md 2>/dev/null
48
48
  ```
49
49
 
50
- If an Operations section exists, note the project's merge strategy and additional gates. These are checked alongside know-thy-build gates below.
50
+ Extract:
51
+ - **Test command** from CI/CD table (REQUIRED for ci gate)
52
+ - **Merge strategy** (default: squash)
53
+ - **Additional gates** (informational)
54
+
55
+ If no test command is defined in Operations:
56
+ > "⚠️ No test command found in docs/PROJECT.md → Operations → CI/CD. The `ci` gate will auto-pass. Consider defining a test command to catch regressions."
51
57
 
52
58
  ---
53
59
 
54
- ## Gate Check
60
+ ## Phase 1: Review Gate Check
55
61
 
56
62
  Read the `gate:` section from the feature spec's YAML frontmatter.
57
63
 
58
64
  ### Display gate status
59
65
 
60
- Present a clear gate status report:
61
-
62
66
  ```
63
- 🚦 Gate Check — Feature {{NNN}}: {{title}}
67
+ 🚦 Review Gate Check — Feature {{NNN}}: {{title}}
64
68
 
65
- Architect: {{status}} {{date if passed}}
66
- Designer: {{status}} {{date if passed}}
67
- QA: {{status}} {{date if passed}}
69
+ Architect: {{status}} {{date if passed}}
70
+ Designer: {{status}} {{date if passed}}
71
+ QA: {{status}} {{date if passed}}
72
+ Integration: pending (set by this pipeline)
73
+ CI: pending (set by this pipeline)
68
74
  ```
69
75
 
70
- ### Evaluate
76
+ ### Evaluate review gates
71
77
 
72
- **All gates `passed` or `skipped`:**
73
- > "All gates passed. Ready to merge."
74
- → Proceed to Pre-merge Verification.
78
+ Check only `architect`, `designer`, and `qa` at this stage. `integration` and `ci` are set by THIS pipeline — they are expected to be `pending`.
75
79
 
76
- **Any gate is `pending`:**
80
+ **All review gates `passed` or `skipped`:**
81
+ > "Review gates passed. Starting merge pipeline."
82
+ → Proceed to Phase 2.
83
+
84
+ **Any review gate is `pending`:**
77
85
  > "Cannot merge — pending reviews:"
78
86
  > - `{{role}}`: pending — run `/know-thy-build:{{role}}` to complete
79
87
 
80
- → Stop here. Do NOT proceed with merge.
88
+ → Stop here. Do NOT proceed.
81
89
 
82
- ### Project-specific gates (if defined)
90
+ ### Project-specific gates (informational)
83
91
 
84
- If `docs/PROJECT.md` has an Operations → Additional Gates section, check those too:
85
- - **Code review required?** → Verify PR was reviewed (or inform the user to do so)
86
- - **CI must pass?** → Check CI status or inform the user to verify
87
- - **Other gates?** → Report status of each
92
+ If `docs/PROJECT.md` has an Operations → Additional Gates section, report them:
93
+ - **Code review required?** → Verify PR was reviewed (or inform the user)
94
+ - **CI must pass?** → Will be checked in Phase 4
95
+ - **Other gates?** → Report status
88
96
 
89
- > These gates are informational know-thy-build reports them but cannot enforce external systems. The user is responsible for ensuring project-specific gates pass before proceeding.
97
+ > These are informational. know-thy-build enforces its own gates; project-specific gates are the project's responsibility.
90
98
 
91
99
  ---
92
100
 
93
- ## Pre-merge Verification
94
-
95
- Before merging, verify the worktree is in a clean, mergeable state:
101
+ ## Phase 2: Rebase on Main
96
102
 
97
103
  ### 1. Check for uncommitted changes
98
104
 
@@ -114,40 +120,148 @@ If any remain:
114
120
  > "Implementation markers found — the feature is not fully implemented."
115
121
  → Stop here.
116
122
 
117
- ### 3. Verify tests pass
123
+ ### 3. Fetch and rebase
118
124
 
119
125
  ```bash
120
- # Detect test runner from package.json, pyproject.toml, etc.
121
- # Run appropriate test command
126
+ git fetch origin main
127
+ git rebase origin/main
122
128
  ```
123
129
 
124
- If tests fail:
125
- > "Tests are failing. Fix before merge."
126
- Stop here.
130
+ **If rebase succeeds with no conflicts:**
131
+ > " Rebased cleanly on main. No conflicts."
132
+ Set `integration: passed` in feature spec. Skip Phase 3. Proceed to Phase 4.
133
+
134
+ **If rebase produces conflicts:**
135
+ > "⚠️ Conflicts detected during rebase. Starting conflict resolution."
136
+ → Proceed to Phase 3.
137
+
138
+ ---
127
139
 
128
- ### 4. Verify artifacts exist
140
+ ## Phase 3: Conflict Resolution & Integration Review
129
141
 
130
- Check that each role left its artifacts in the worktree:
142
+ ### Step 1: Identify conflicts
131
143
 
132
144
  ```bash
133
- # Architect artifacts: scaffold files, signature tests
134
- grep -rn "DO NOT MODIFY" --include="*.test.*" --include="*_test.*" . 2>/dev/null | head -5
145
+ git diff --name-only --diff-filter=U
146
+ ```
147
+
148
+ List every conflicting file. For each, show the conflict markers:
135
149
 
136
- # QA artifacts: test cases in QA.md
137
- grep -c "Feature {{NNN}}" docs/QA.md 2>/dev/null
150
+ ```bash
151
+ grep -n "<<<<<<< HEAD\|=======\|>>>>>>>" {{file}} 2>/dev/null
138
152
  ```
139
153
 
140
- Report what will be merged to main:
141
- > "The following artifacts from this feature will be merged to main:"
142
- > - Code: {{list of modified/new source files}}
143
- > - Architect: scaffold structure, signature tests
144
- > - Designer: design intent updates in feature spec (if applicable)
145
- > - QA: test cases in `docs/QA.md`
146
- > - Feature spec: gate statuses updated
154
+ ### Step 2: Understand the other side
155
+
156
+ Before resolving, read what changed on main since the feature branched:
157
+
158
+ ```bash
159
+ # What features were merged to main while this feature was in progress?
160
+ git log --oneline origin/main --not $(git merge-base HEAD origin/main) -- docs/features/
161
+ ```
162
+
163
+ Read the specs of recently merged features to understand their intent.
164
+
165
+ ### Step 3: Resolve conflicts
166
+
167
+ For each conflict:
168
+
169
+ 1. Read both sides (ours = this feature, theirs = main)
170
+ 2. Understand the intent of both changes
171
+ 3. Resolve by preserving BOTH intents where possible
172
+ 4. If the intents are fundamentally incompatible → ask the user
173
+
174
+ After resolving each file:
175
+ ```bash
176
+ git add {{file}}
177
+ ```
178
+
179
+ After all conflicts resolved:
180
+ ```bash
181
+ git rebase --continue
182
+ ```
183
+
184
+ If additional conflicts appear in subsequent commits, repeat.
185
+
186
+ ### Step 4: Integration review agent
187
+
188
+ **Dispatch a sub-agent** to review the conflict resolution:
189
+
190
+ ```
191
+ Agent prompt:
192
+ "You are the integration reviewer. Your job is to verify that conflict resolution
193
+ preserved the intent of ALL affected features, introduced no side effects, and
194
+ maintained architectural consistency.
195
+
196
+ Context:
197
+ - This feature: docs/features/{{NNN}}.md
198
+ - Recently merged features: [list from Step 2]
199
+ - Project rules: docs/PROJECT.md, docs/TECHNICAL.md
200
+
201
+ Tasks:
202
+ 1. Read this feature's spec and all recently merged feature specs
203
+ 2. Read the conflict resolution diff: git diff HEAD~1 (or appropriate range)
204
+ 3. For each resolved conflict:
205
+ a. Does the resolution preserve BOTH features' intent?
206
+ b. Does it introduce any side effect on either feature's code paths?
207
+ c. Does it follow the patterns in TECHNICAL.md?
208
+ 4. Check if regression guard tests exist for the affected areas
209
+ 5. Report: PASSED (all clear) or FAILED (list specific issues)
210
+
211
+ Be aggressive — you are the last defense before merge. If you have doubts,
212
+ report them as failures. False negatives (missed bugs) are worse than false
213
+ positives (extra review)."
214
+ ```
215
+
216
+ **If integration review returns PASSED:**
217
+ → Set `integration: passed` in feature spec. Proceed to Phase 4.
218
+
219
+ **If integration review returns FAILED:**
220
+ > "❌ Integration review failed:"
221
+ > {{list specific issues from the agent}}
222
+ > "Fix the issues and re-run `/know-thy-build:finish`."
223
+ → Set `integration: failed` in feature spec. Stop here.
224
+
225
+ ---
226
+
227
+ ## Phase 4: CI/CD Gate
228
+
229
+ ### 1. Run test command
230
+
231
+ Extract the test command from `docs/PROJECT.md` → Operations → CI/CD:
232
+
233
+ ```bash
234
+ # Example: npm test, pytest, go test ./...
235
+ {{test_command}}
236
+ ```
237
+
238
+ **If no test command is defined:** auto-pass with warning.
239
+
240
+ ### 2. Run additional CI checks (if defined)
241
+
242
+ If Operations defines lint, type check, or other blocking checks:
243
+
244
+ ```bash
245
+ # Example: eslint ., tsc --noEmit
246
+ {{ci_check_commands}}
247
+ ```
248
+
249
+ ### 3. Evaluate
250
+
251
+ **All CI checks pass:**
252
+ → Set `ci: passed` in feature spec. Proceed to Phase 5.
253
+
254
+ **Any CI check fails:**
255
+ > "❌ CI failed:"
256
+ > {{error output}}
257
+ > "Fix the failures and re-run `/know-thy-build:finish`."
258
+ → Set `ci: failed` in feature spec. Stop here.
147
259
 
148
260
  ---
149
261
 
150
- ## Merge
262
+ ## Phase 5: Merge
263
+
264
+ All 5 gates are now `passed` or `skipped`. Proceed with merge.
151
265
 
152
266
  ### 1. Determine merge strategy
153
267
 
@@ -156,7 +270,7 @@ Check `docs/PROJECT.md` → Operations → Merge Strategy. Default to squash if
156
270
  | Strategy | Command |
157
271
  |----------|---------|
158
272
  | squash (default) | `git merge --squash` |
159
- | rebase | `git rebase main` then fast-forward merge |
273
+ | rebase | fast-forward merge (already rebased) |
160
274
  | merge commit | `git merge --no-ff` |
161
275
 
162
276
  ### 2. Switch to main and merge
@@ -166,26 +280,28 @@ Check `docs/PROJECT.md` → Operations → Merge Strategy. Default to squash if
166
280
  git checkout main
167
281
  git pull --ff-only origin main 2>/dev/null || true
168
282
 
169
- # Execute the merge strategy determined above (default: squash)
283
+ # Execute the merge strategy (default: squash)
170
284
  git merge --squash "feature/{{NNN}}-{{title_kebab}}"
171
285
  ```
172
286
 
173
- ### 2. Create commit
287
+ ### 3. Create commit
174
288
 
175
289
  ```bash
176
290
  git commit -m "feat({{NNN}}): {{title}}
177
291
 
178
292
  - Architect: {{brief summary of structure decisions}}
179
293
  - Designer: {{brief summary of design decisions, or 'skipped'}}
180
- - QA: {{number}} test cases passed
294
+ - QA: {{number}} test cases, {{number}} regression guards
295
+ - Integration: {{clean / resolved N conflicts}}
296
+ - CI: all checks passed
181
297
 
182
298
  Feature spec: docs/features/{{NNN}}.md
183
- Gate: architect ✓ | designer ✓/skipped | qa ✓"
299
+ Gate: architect ✓ | designer ✓/skipped | qa ✓ | integration ✓ | ci ✓"
184
300
  ```
185
301
 
186
- ### 3. Update feature spec status
302
+ ### 4. Update feature spec status
187
303
 
188
- Switch back briefly or edit from main — update the feature spec frontmatter:
304
+ Update the feature spec frontmatter:
189
305
 
190
306
  ```yaml
191
307
  status: complete
@@ -194,9 +310,11 @@ gate:
194
310
  architect: passed
195
311
  designer: passed # or skipped
196
312
  qa: passed
313
+ integration: passed
314
+ ci: passed
197
315
  ```
198
316
 
199
- ### 4. Update Feature Registry
317
+ ### 5. Update Feature Registry
200
318
 
201
319
  In `docs/PROJECT.md`, update the Feature Registry row for this feature:
202
320
  ```
@@ -243,6 +361,13 @@ Commit: {{short hash}} feat({{NNN}}): {{title}}
243
361
  Branch: feature/{{NNN}}-{{title_kebab}} — deleted
244
362
  Worktree: {{WT_PATH}} — removed
245
363
 
364
+ Pipeline results:
365
+ Architect: ✓ passed
366
+ Designer: ✓ passed / skipped
367
+ QA: ✓ passed ({{N}} test cases, {{N}} regression guards)
368
+ Integration: ✓ {{clean / resolved N conflicts}}
369
+ CI: ✓ all checks passed
370
+
246
371
  Artifacts merged:
247
372
  - Code changes: {{file count}} files
248
373
  - Architect structure: preserved in code + signature tests
@@ -257,17 +382,30 @@ Next: /know-thy-build:feature for the next feature
257
382
 
258
383
  ## Edge Cases
259
384
 
260
- ### Merge conflicts
385
+ ### Rebase conflicts that can't be auto-resolved
386
+
387
+ If conflicts involve fundamentally incompatible changes (e.g. two features restructured the same module differently):
388
+
389
+ 1. Show both sides with full context
390
+ 2. Read both feature specs to understand intent
391
+ 3. Propose a resolution that preserves both intents
392
+ 4. Ask the user to confirm before proceeding
393
+ 5. The integration review agent will verify the resolution
394
+
395
+ ### Integration review fails repeatedly
396
+
397
+ If the integration review agent keeps finding issues after fixes:
398
+
399
+ 1. Show the full list of unresolved issues
400
+ 2. Suggest the user review the issues manually
401
+ 3. Offer to skip integration review with explicit user approval:
402
+ > "Skipping integration review at user's request. Set `integration: skipped` in feature spec."
261
403
 
262
- If `git merge --squash` produces conflicts:
404
+ ### No test command defined
263
405
 
264
- 1. List conflicting files
265
- 2. For each conflict, show the conflict markers
266
- 3. Offer resolution options:
267
- - Accept worktree version (ours)
268
- - Accept main version (theirs)
269
- - Manual resolution
270
- 4. After resolution, continue with commit
406
+ If `docs/PROJECT.md` doesn't define a test command:
407
+ - `ci` gate auto-passes with a warning
408
+ - Recommend the user runs `/know-thy-build:project` to define one
271
409
 
272
410
  ### Abandoned feature
273
411
 
@@ -571,17 +571,19 @@ Frontier questions:
571
571
  | Question | Depends on | Type |
572
572
  |----------|-----------|------|
573
573
  | How do feature branches merge to main? (squash, rebase, merge commit) | — | Decision |
574
+ | **What is the test command?** (e.g. `npm test`, `pytest`, `go test ./...`) | — | Decision (REQUIRED) |
574
575
  | How does code reach users? (npm publish, docker, manual deploy, CI/CD trigger) | — | Decision |
575
- | What automated checks run before merge? (lint, type check, tests) | merge-strategy | Fact (scan CI config) + Decision |
576
+ | What other automated checks run before merge? (lint, type check) | merge-strategy | Fact (scan CI config) + Decision |
576
577
  | Are there review requirements beyond know-thy-build gates? (code review, security scan) | — | Decision |
577
578
 
578
579
  Slots to fill:
579
580
  - `{{merge_strategy}}` — squash / rebase / merge commit
581
+ - `{{test_command}}` — **REQUIRED.** The command `/know-thy-build:finish` runs before merge. Without it, the `ci` gate auto-passes.
580
582
  - `{{deploy_method}}` — how releases reach users
581
- - `{{ci_checks}}` — automated quality checks
583
+ - `{{ci_checks}}` — automated quality checks (lint, type check, etc.)
582
584
  - `{{additional_gates}}` — extra review requirements
583
585
 
584
- **Done when:** Frontier is empty. At minimum, merge strategy and deploy method are defined. CI/CD and additional gates can be "none yet" if the project is early.
586
+ **Done when:** Frontier is empty. At minimum, merge strategy and **test command** are defined. Deploy and additional gates can be "none yet" if the project is early.
585
587
 
586
588
  > **Why this matters:** Without explicit operations definitions, sub-agents and hooks cannot enforce project-specific workflows. The merge gate hook only covers know-thy-build's built-in gates — project-specific gates (code review, CI checks) must be defined here so agents know to respect them.
587
589
 
@@ -844,13 +846,15 @@ Remove `areasRemaining`, `lastCheckpoint`, and `open` counts.
844
846
 
845
847
  ### CI/CD
846
848
 
847
- <!-- Automated checks that run on push or PR. -->
849
+ <!-- Automated checks that run on push or PR.
850
+ The test command is REQUIRED — /know-thy-build:finish runs it before merge.
851
+ Without it, the ci gate auto-passes and regressions slip through. -->
848
852
 
849
- | Check | Tool | Blocks merge? |
850
- |-------|------|---------------|
853
+ | Check | Command | Blocks merge? |
854
+ |-------|---------|---------------|
855
+ | **test** | **{{test_command}}** | **yes (required)** |
851
856
  | {{lint}} | {{eslint, ruff, etc.}} | {{yes/no}} |
852
857
  | {{type check}} | {{tsc, mypy, etc.}} | {{yes/no}} |
853
- | {{tests}} | {{jest, pytest, etc.}} | {{yes/no}} |
854
858
 
855
859
  ### Additional Gates
856
860
 
@@ -1011,8 +1015,13 @@ worktree (sub-agent orchestrates the entire lifecycle):
1011
1015
  Designer review → gate.designer ✓
1012
1016
  QA TEST → gate.qa ✓
1013
1017
 
1014
- Phase 4 — Finish:
1015
- All gates passed → /know-thy-build:finish → squash merge + cleanup
1018
+ Phase 4 — Finish (merge pipeline):
1019
+ /know-thy-build:finish orchestrates:
1020
+ Review gates check → architect/designer/qa must be passed
1021
+ Rebase on main → surface conflicts
1022
+ Conflict resolution → resolve, then integration review agent
1023
+ CI/CD → run project test command
1024
+ Merge → squash merge + cleanup
1016
1025
  ```
1017
1026
 
1018
1027
  ### Gate (Merge Prerequisite)
@@ -1024,6 +1033,8 @@ Merge is allowed only when all gates are `passed` or `skipped`.
1024
1033
  | architect | pending → passed | Architect review passes |
1025
1034
  | designer | pending → passed / skipped | Designer review passes (skipped for non-UI) |
1026
1035
  | qa | pending → passed | All QA test cases pass |
1036
+ | integration | pending → passed | Finish: rebase clean OR conflict review agent passes |
1037
+ | ci | pending → passed | Finish: project test command passes |
1027
1038
 
1028
1039
  ### Orchestrator Model
1029
1040
  The user session acts as **orchestrator only** — it does NOT implement directly.
@@ -1040,7 +1051,8 @@ Before any work, the sub-agent MUST read:
1040
1051
  - Architect + Designer re-review if changes are structural
1041
1052
  - QA re-tests failed scenarios + regression check on happy path
1042
1053
  - Loop continues until ALL reviewers' criteria are `[x]`
1043
- - Only when all three gates pass does `/know-thy-build:finish` proceed
1054
+ - Only when all three review gates pass does `/know-thy-build:finish` start the merge pipeline
1055
+ - Finish then handles: rebase → conflict resolution → integration review → CI → merge
1044
1056
 
1045
1057
  ### Project-Specific Operations
1046
1058
  The merge gate hook enforces know-thy-build's built-in gates (architect/designer/qa).
@@ -1092,7 +1104,7 @@ FEATURE_FILE="docs/features/$(printf '%03d' "$FEATURE_NUM").md"
1092
1104
  grep -qE '^status:\s*complete' "$FEATURE_FILE" 2>/dev/null && exit 0
1093
1105
 
1094
1106
  # Check gate statuses
1095
- PENDING=$(grep -cE '^\s+(architect|designer|qa):\s*pending' "$FEATURE_FILE" 2>/dev/null || echo "0")
1107
+ PENDING=$(grep -cE '^\s+(architect|designer|qa|integration|ci):\s*pending' "$FEATURE_FILE" 2>/dev/null || echo "0")
1096
1108
 
1097
1109
  if [ "$PENDING" -gt 0 ]; then
1098
1110
  echo "❌ Merge gate blocked — Feature $(printf '%03d' "$FEATURE_NUM") has pending reviews:"
@@ -685,13 +685,49 @@ For each selected profile, generate test cases using its **turn-level instructio
685
685
  - **Profile** column traces which behavioral axis combination generated this case.
686
686
  - **Injection test cases** must specify exactly how to inject the failure state.
687
687
 
688
- ### Step 5: Update QA.md
688
+ ### Step 5: Regression Guard Tests (MANDATORY)
689
+
690
+ **Purpose:** Protect this feature's core behavior from being broken by future feature merges. When multiple agents work on features in parallel, another agent's merge can silently break your work. Regression guard tests catch that.
691
+
692
+ **Rules:**
693
+ - Each **Done When** criterion in the feature spec → at least 1 automated test
694
+ - Tests must be **independently runnable** — no cross-feature dependency
695
+ - Tests must **fail loudly** when behavior changes, not silently pass
696
+ - Test names include the feature number: `test_NNN_*` (e.g. `test_003_login_success`)
697
+ - Tests run via the project's test command defined in `docs/PROJECT.md` → Operations → CI/CD
698
+
699
+ **How to write regression guards:**
700
+
701
+ 1. Read the feature spec's **Done When** section
702
+ 2. For each criterion, write at least one automated test that:
703
+ - Sets up the precondition
704
+ - Performs the action
705
+ - Asserts the expected outcome
706
+ - Cleans up after itself (no side effects on other tests)
707
+ 3. Group tests under the feature number for traceability
708
+
709
+ **Template:**
710
+
711
+ ```
712
+ ### Regression Guards — Feature {{NNN}}: {{title}}
713
+
714
+ | # | Done-When Criterion | Test Name | What It Verifies |
715
+ |---|---------------------|-----------|------------------|
716
+ | 1 | {{criterion_1}} | test_{{NNN}}_{{name}} | {{specific assertion}} |
717
+ | 2 | {{criterion_2}} | test_{{NNN}}_{{name}} | {{specific assertion}} |
718
+ ```
719
+
720
+ **Why this matters:** When `/know-thy-build:finish` rebases on main and resolves conflicts, it runs the project's test command. If another feature's merge broke your work, your regression guard tests fail, and the merge is blocked. Without these tests, the CI gate is a formality.
721
+
722
+ ### Step 6: Update QA.md
689
723
 
690
724
  1. Append the feature section to `docs/QA.md`
691
725
  2. Add any new turn-level scenarios to the Turn-Level Scenarios section
692
- 3. Update feature spec frontmatter:
726
+ 3. Add regression guard test entries to the feature section
727
+ 4. Update feature spec frontmatter:
693
728
  ```yaml
694
729
  qaTestCases: {{count}}
730
+ qaRegressionGuards: {{count}}
695
731
  qaReviewDate: {{date}}
696
732
  ```
697
733
 
@@ -699,6 +735,7 @@ For each selected profile, generate test cases using its **turn-level instructio
699
735
  - [ ] Every AC has at least one test case
700
736
  - [ ] At least 3 profiles are represented in test cases
701
737
  - [ ] At least 2 failure state injection test cases
738
+ - [ ] **Every Done-When criterion has at least one regression guard test**
702
739
  - [ ] Access path verified
703
740
  - [ ] Test cases are concrete enough that anyone could execute them
704
741
  - [ ] Feature section appended to `docs/QA.md`