@qa-gentic/stlc-agents 1.0.1 → 1.0.3

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.
@@ -0,0 +1,303 @@
1
+ ---
2
+ name: deduplication-protocol
3
+ description: >
4
+ MANDATORY pre-flight protocol for every QA STLC agent run. Must be read and applied BEFORE
5
+ creating any test cases, Gherkin feature files, Playwright locators, page objects, or step
6
+ definitions in Azure DevOps. Prevents duplicate test cases, duplicate feature file attachments,
7
+ and duplicate Playwright code being created across multiple runs or agents on the same work item.
8
+ Triggers on any task involving: ADO work items, test cases, feature files, Gherkin BDD, Playwright
9
+ automation, locators, page objects, step definitions, qa-gherkin-generator, qa-test-case-manager,
10
+ qa-playwright-generator tools.
11
+ compatibility:
12
+ tools:
13
+ - qa-test-case-manager:get_linked_test_cases
14
+ - qa-test-case-manager:fetch_work_item
15
+ - qa-test-case-manager:create_and_link_test_cases
16
+ - qa-gherkin-generator:fetch_feature_hierarchy
17
+ - qa-gherkin-generator:attach_gherkin_to_feature
18
+ - qa-playwright-generator:generate_playwright_code
19
+ - qa-playwright-generator:attach_code_to_work_item
20
+ - qa-playwright-generator:validate_gherkin_steps
21
+ ---
22
+
23
+ # QA Deduplication Protocol
24
+
25
+ > **Read `AGENT-BEHAVIOR.md` before this protocol.**
26
+ > This protocol is a pre-flight gate only — it does not authorise creating anything.
27
+ > All creation decisions require separate explicit user confirmation per artifact type.
28
+
29
+ > **This protocol is mandatory. No artifact may be created or attached to ADO without completing
30
+ > the READ → DIFF → CREATE-ONLY-WHAT-IS-MISSING pipeline below.**
31
+ >
32
+ > Any agent that skips this protocol and creates duplicates has violated the QA STLC workflow.
33
+
34
+ ---
35
+
36
+ ## Why This Exists
37
+
38
+ When QA STLC agents run more than once on the same work item — or when multiple agents run in
39
+ sequence on the same item — they have no memory of what previous runs created. Without this
40
+ protocol every run blindly creates new test cases, attaches new feature files, and generates new
41
+ Playwright code that duplicates existing artifacts. This produces:
42
+
43
+ - 2–5× the intended number of ADO test cases per work item
44
+ - Multiple `.feature` files on the same work item covering identical scenarios
45
+ - Multiple versions of `locators.ts` / `PageObject.ts` / `steps.ts` that diverge silently
46
+ - Test suites that fail because the same step definition is registered twice
47
+
48
+ This skill codifies the fix as a durable, enforceable protocol that any agent can read and follow.
49
+
50
+ ---
51
+
52
+ ## The Three-Phase Mandatory Workflow
53
+
54
+ ```
55
+ ┌───────────────────────────────────────────────────────────────┐
56
+ │ PHASE 1 — READ (always first, no exceptions) │
57
+ │ PHASE 2 — DIFF (semantic matching, not just string equality) │
58
+ │ PHASE 3 — CREATE only what has no existing coverage │
59
+ └───────────────────────────────────────────────────────────────┘
60
+ ```
61
+
62
+ ---
63
+
64
+ ## PHASE 1 — READ Everything That Already Exists
65
+
66
+ Before touching any artifact, make all of the following calls **in this order**.
67
+
68
+ This protocol handles **any work item type** — PBI, Bug, or Feature — as follows:
69
+
70
+ | Work item type passed | Step 1A | Step 1B |
71
+ |---|---|---|
72
+ | **PBI or Bug** | `fetch_work_item(id)` → get parent Feature id | `fetch_feature_hierarchy(parent_feature_id)` |
73
+ | **Feature** | Skip `fetch_work_item` | `fetch_feature_hierarchy(id)` directly |
74
+
75
+ ### 1A — Fetch the work item (PBI or Bug only)
76
+
77
+ ```
78
+ qa-test-case-manager:fetch_work_item(
79
+ organization_url, project_name, work_item_id
80
+ )
81
+ ```
82
+
83
+ Extract and store:
84
+ - Title, description, acceptance_criteria
85
+ - **Parent Feature ID** — used in Step 1B
86
+ - Story points, priority, state
87
+
88
+ Skip this step if the ID passed is already a Feature.
89
+
90
+ ### 1B — Fetch the parent Feature hierarchy
91
+
92
+ ```
93
+ qa-gherkin-generator:fetch_feature_hierarchy(
94
+ organization_url, project_name, feature_id ← parent Feature ID from 1A, or the ID itself if Feature
95
+ )
96
+ ```
97
+
98
+ Extract and store:
99
+ - Feature title, description, acceptance criteria
100
+ - **All child PBIs and Bugs** with their titles + acceptance criteria
101
+ - All existing test cases across the whole feature
102
+ - All `.feature` file attachments already on the feature
103
+ - Build the **flow map** from sibling work items (see generate-gherkin.md Step 1D)
104
+
105
+ > **Why sibling PBIs matter:** A PBI is one slice of a larger flow defined across multiple
106
+ > work items. Siblings often represent prerequisite or downstream steps. Without reading all
107
+ > of them the agent invents navigation steps and test data already defined elsewhere.
108
+
109
+ ### 1C — get_linked_test_cases on the specific work item
110
+
111
+ ```
112
+ qa-test-case-manager:get_linked_test_cases(
113
+ organization_url, project_name, work_item_id ← the original ID (PBI, Bug, or Feature)
114
+ )
115
+ ```
116
+
117
+ Extract and store:
118
+ - All existing test case IDs, titles (normalised), priority values
119
+
120
+ ### 1D — Check for existing Playwright attachments
121
+
122
+ From the feature hierarchy response, check for:
123
+ - `locators.ts` — extract all locator keys already defined
124
+ - `*Page.ts` — extract all method names already defined
125
+ - `*.steps.ts` — extract all step definition strings already registered
126
+
127
+ > If you cannot read an attachment's content, treat it as fully covering its domain and
128
+ > produce NO new file of that type unless you can prove a gap.
129
+
130
+ ---
131
+
132
+ ## PHASE 2 — DIFF Using Semantic Matching
133
+
134
+ String equality is not enough. Two test cases are **semantically equivalent** (duplicates)
135
+ if they test the same condition on the same subject, even when worded differently.
136
+
137
+ ### Normalisation algorithm (apply before comparing)
138
+
139
+ 1. Lowercase the full title
140
+ 2. Strip tag prefixes: `[smoke]`, `[regression]`, `[a11y]`, `[negative]`, `[boundary]`, etc.
141
+ 3. Strip filler words: `the`, `a`, `an`, `is`, `are`, `should`, `will`, `when`, `after`, `during`
142
+ 4. Extract the **subject noun** (what is being tested: button, CSV, backend, upload, template…)
143
+ 5. Extract the **condition** (visible, absent, downloaded, cleared, rejected, correct…)
144
+ 6. If subject + condition match an existing case → **DUPLICATE**, do not create
145
+
146
+ ### Semantic coverage matrix
147
+
148
+ ```
149
+ For each proposed test case:
150
+ normalise(proposed.title) → (subject, condition)
151
+ for each existing test case:
152
+ normalise(existing.title) → (subject, condition)
153
+ if subject matches AND condition matches → DUPLICATE → skip
154
+ if no match found → NET-NEW → add to creation list
155
+ ```
156
+
157
+ Only pass the **net-new** list to `create_and_link_test_cases`.
158
+
159
+ ### Gherkin scenario deduplication
160
+
161
+ For each proposed Gherkin scenario:
162
+ 1. Extract the scenario title
163
+ 2. Apply the same normalisation algorithm
164
+ 3. Compare against all scenario titles in existing `.feature` attachments AND existing ADO test case titles
165
+ 4. Semantic match → skip; zero net-new → do not attach; some net-new → attach delta file only
166
+
167
+ ### Playwright code deduplication
168
+
169
+ - `locators.ts`: only emit keys not already in existing file; if delta empty → skip; if non-empty → attach as `locators.delta.ts`
170
+ - `*Page.ts`: only emit methods not already present; if delta empty → skip; if non-empty → attach as `*Page.delta.ts`
171
+ - `*.steps.ts`: only emit step strings not already registered; NEVER re-register an existing step (causes `Ambiguous step definition` runtime error)
172
+
173
+ ---
174
+
175
+ ## PHASE 3 — CREATE Only What Is Missing
176
+
177
+ | Diff result | Action |
178
+ |---|---|
179
+ | Zero net-new | **Skip.** Log: `✅ Already fully covered — nothing to create.` |
180
+ | Some net-new, some duplicates | **Create only net-new.** Log which were skipped and why. |
181
+ | All net-new (first run) | **Create all.** Normal flow. |
182
+
183
+ ### Mandatory deduplication report
184
+
185
+ Output after every run regardless of whether anything was created:
186
+
187
+ ```
188
+ ## Deduplication Report — Work Item #<id>
189
+
190
+ ### Test Cases
191
+ - Existing: <count> linked
192
+ - Proposed: <count>
193
+ - Duplicates skipped: <count> (<titles>)
194
+ - Net-new created: <count> (<IDs if created>)
195
+
196
+ ### Gherkin Feature File
197
+ - Existing attachments: <filenames or "none">
198
+ - Proposed scenarios: <count>
199
+ - Duplicate scenarios skipped: <count> (<titles>)
200
+ - Net-new scenarios: <count>
201
+ - Action: <"Skipped — fully covered" | "Attached delta" | "Attached full (first run)">
202
+
203
+ ### Playwright Code
204
+ - Existing locators.ts: <"found — N keys" | "not found">
205
+ - Net-new locator keys: <count> (<list or "none">)
206
+ - Existing page object: <"found — N methods" | "not found">
207
+ - Net-new page methods: <count> (<list or "none">)
208
+ - Existing steps file: <"found — N steps" | "not found">
209
+ - Net-new step definitions: <count> (<list or "none">)
210
+ - Action per file: <"Skipped" | "Attached delta" | "Attached full (first run)">
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Hard Rules — Never Violate These
216
+
217
+ 1. **NEVER call `create_and_link_test_cases` without first calling `get_linked_test_cases`** on the same work item.
218
+ 2. **NEVER attach a `.feature` file without first checking for existing feature file attachments.**
219
+ 3. **NEVER attach a `steps.ts` that re-registers an existing step string** — causes `Ambiguous step definition` at runtime.
220
+ 4. **NEVER treat tag differences as meaningful.** `[REGRESSION] Export List downloads CSV` is a duplicate of `[SMOKE] Clicking Export List downloads a valid CSV file`.
221
+ 5. **NEVER create more than one test case covering the same (subject, condition) pair.**
222
+ 6. **NEVER skip this protocol because the work item appears new.** `existing_test_cases_count: 0` in the hierarchy can still have cases via `get_linked_test_cases` — always call both.
223
+
224
+ ---
225
+
226
+ ## Integration With Other QA Skills
227
+
228
+ This protocol is a **work-item-scoped pre-flight gate**.
229
+
230
+ - **Each unique `work_item_id` gets exactly one PHASE 1 run.** Findings are cached and reused by every subsequent agent operating on the same item.
231
+ - **A different `work_item_id` always triggers a fresh PHASE 1.** Cache from item A must never be used for item B.
232
+
233
+ ```
234
+ work_item_id = 111 → PHASE 1 runs in full → CACHE[111] populated
235
+ generate-gherkin on 111 → reads CACHE[111], skips PHASE 1
236
+ generate-playwright on 111 → reads CACHE[111], skips PHASE 1
237
+
238
+ work_item_id = 222 → PHASE 1 runs in full → CACHE[222] populated (CACHE[111] untouched)
239
+ ```
240
+
241
+ Skills that delegate here:
242
+ ```
243
+ skills/generate-gherkin.md → delegates here; reads work-item cache
244
+ skills/generate-playwright-code.md → delegates here; reads work-item cache
245
+ ```
246
+
247
+ ### Work-Item Cache Schema
248
+
249
+ ```
250
+ CACHE[work_item_id] = {
251
+ work_item: { id, type, title, acceptance_criteria }, # PBI/Bug/Feature
252
+ parent_feature: { id, title, description },
253
+ sibling_pbis: [{ id, type, title, acceptance_criteria, state }],
254
+ flow_map: <assembled string describing the full user journey>,
255
+ existing_test_cases: [{ id, title, priority }],
256
+ existing_attachments: {
257
+ feature_files: [{ name, content }],
258
+ locators_ts: { found: bool, keys: [] },
259
+ page_objects: [{ name, methods: [] }],
260
+ steps_files: [{ name, step_strings: [] }],
261
+ },
262
+ gap_check_completed: bool, # set true after generate-gherkin Step 2 passes
263
+ phase1_completed: true,
264
+ }
265
+ ```
266
+
267
+ **Before running PHASE 1**, check `CACHE[work_item_id].phase1_completed`:
268
+ - If **true** → skip PHASE 1 entirely; use cached data for PHASE 2.
269
+ - If **false / not set** → run PHASE 1 in full and populate the cache.
270
+
271
+ ---
272
+
273
+ ## Examples
274
+
275
+ ### Multiple work items in one session
276
+
277
+ ```
278
+ ► PBI #111 processed:
279
+ CACHE[111] not found → PHASE 1 in full → CACHE[111].phase1_completed = true
280
+ generate-gherkin on 111 → reads CACHE[111]
281
+ generate-playwright on 111 → reads CACHE[111], skips all ADO reads
282
+
283
+ ► Bug #222 processed:
284
+ CACHE[222] not found → PHASE 1 in full → CACHE[222].phase1_completed = true
285
+ (CACHE[111] untouched — completely independent)
286
+ ```
287
+
288
+ ### Second run on a fully covered item
289
+
290
+ ```
291
+ PHASE 1: get_linked_test_cases(273440) → 35 cases; fetch_feature_hierarchy → .feature attached
292
+ PHASE 2: 14 proposed → 14/14 duplicates; 0 net-new locators, methods, steps
293
+ PHASE 3: Skip all
294
+ REPORT: ✅ Work item #273440 fully covered. Nothing to create.
295
+ ```
296
+
297
+ ### Partial gap run
298
+
299
+ ```
300
+ PHASE 1: 3 cases found, no .feature, no Playwright attachments
301
+ PHASE 2: 5 proposed → 3 duplicates → 2 net-new
302
+ PHASE 3: create 2 test cases; attach full .feature (first run); attach full Playwright files
303
+ ```