Skip to content

Commit ffdfa4f

Browse files
committed
fix(test-driven-development): address round-4 findings — graph labels, comment, emoji, type annotation
Finding 1+5 (Important/Minor): verify_green diamond had unlabeled third edge causing ambiguity about when to exit to next vs verify_invariant. Labeled the exit as 'done (post-refactor)' and first-pass edge as 'yes (first pass)'. Added prose note in REFACTOR: invariant check applies once per bug fix, not after each refactor cycle. Finding 2 (Important): Comment 'New methods MUST include the same arg' overstated the enforcement — the table only gates methods explicitly listed. Updated comment to instruct maintainers to add a row when adding a new method. Finding 3 (Minor): Emoji checkmarks (✓) in new-flow.md violated workspace convention (no emoji without user request). Replaced with [confirmed: ...] text. Finding 4 (Minor): spy.lastArgs type unspecified; map[string]any silently returns wrong comparison without type assertion. Updated comment to specify map[string]string or explicit type assertion.
1 parent 70c4967 commit ffdfa4f

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

skills/test-driven-development/SKILL.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ digraph tdd_cycle {
6161
verify_red -> green [label="yes"];
6262
verify_red -> red [label="wrong\nfailure"];
6363
green -> verify_green;
64-
verify_green -> verify_invariant [label="yes"];
64+
verify_green -> verify_invariant [label="yes\n(first pass)"];
6565
verify_green -> green [label="no"];
66+
verify_green -> next [label="done\n(post-refactor)"];
6667
verify_invariant -> refactor [label="proven"];
6768
verify_invariant -> red [label="test\ndoesn't\ncatch bug"];
6869
refactor -> verify_green [label="stay\ngreen"];
69-
verify_green -> next;
7070
next -> red;
7171
}
7272
```
@@ -225,6 +225,8 @@ After green only:
225225

226226
Keep tests green. Don't add behavior.
227227

228+
**Note:** The Verify Regression Invariant step applies once per bug fix (after the initial GREEN), not after each refactor cycle. Refactoring must not change the fix path — if it does, that's a new production code change requiring a new test.
229+
228230
### Repeat
229231

230232
Next failing test for next feature.
@@ -307,7 +309,9 @@ A `Dispatcher` struct has methods `Create`, `Read`, `Update`, `Delete`, `Inspect
307309

308310
```go
309311
// Regression gate for the class invariant: every Dispatcher method must
310-
// include "kind" in its Send args. New methods MUST include the same arg.
312+
// include "kind" in its Send args.
313+
// IMPORTANT: add a new row to cases whenever a new method is added —
314+
// the test only gates methods explicitly listed here.
311315
func TestDispatcher_AllMethods_IncludeKind(t *testing.T) {
312316
req := Request{Name: "test-resource"} // illustrative; use your actual Request type
313317
cases := []struct {
@@ -322,7 +326,7 @@ func TestDispatcher_AllMethods_IncludeKind(t *testing.T) {
322326
}
323327
for _, tc := range cases {
324328
t.Run(tc.name, func(t *testing.T) {
325-
spy := &spyClient{} // spyClient is a test double; implement lastArgs capture for your client type
329+
spy := &spyClient{} // spyClient is a test double; implement lastArgs as map[string]string (or use a type assertion if map[string]any)
326330
d := &Dispatcher{client: spy, kind: "widget"}
327331
if err := tc.call(d); err != nil {
328332
t.Fatalf("unexpected error: %v", err)

skills/test-driven-development/test-fixtures/narrow-regression/new-flow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
- **RED**: `TestSum_HandlesSingleElement` written, runs, FAILs.
44
- **GREEN**: fix applied, test PASSES.
55
- **Verify Regression Invariant**:
6-
- Revert fix. Run `TestSum_HandlesSingleElement`. Must FAIL. FAILS.
7-
- Restore fix. Must PASS. PASSES.
6+
- Revert fix. Run `TestSum_HandlesSingleElement`. Must FAIL. [confirmed: FAILS]
7+
- Restore fix. Must PASS. [confirmed: PASSES]
88
- Proof pasted in PR body:
99
```
1010
With fix reverted:

0 commit comments

Comments
 (0)