@qa-gentic/stlc-agents 1.0.2 → 1.0.4

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,448 @@
1
+ # Agent Behavior Contract — QA STLC Agents
2
+
3
+ > **This file is authoritative for all coding agents (Claude Code, GitHub Copilot, Cursor,
4
+ > Windsurf, and any LLM operating on this repo).**
5
+ > It defines what agents are and are not permitted to do. Every rule here overrides any
6
+ > inference, "reasonable assumption", or pattern learned from prior context.
7
+ >
8
+ > Version: 1.1 — all rules are explicit; none are inferred.
9
+ > Change log: see bottom of this file.
10
+
11
+ ---
12
+
13
+ ## 1. Scope Delimitation — What This Repo Does and Does Not Do
14
+
15
+ ### What the agents in this repo do
16
+
17
+ | Agent | What it does | What it produces |
18
+ |---|---|---|
19
+ | `qa-test-case-manager` | Fetches ADO work items; creates and links manual test cases | ADO test case work items linked via `TestedBy-Forward` |
20
+ | `qa-gherkin-generator` | Fetches ADO work item hierarchies; validates and attaches `.feature` files | `.feature` files attached to ADO work items |
21
+ | `qa-playwright-generator` | Generates TypeScript Playwright code from Gherkin; attaches files to ADO | `locators.ts`, `*Page.ts`, `*.steps.ts` attached to ADO work items |
22
+ | `qa-helix-writer` | Writes already-generated files to disk at Helix-QA paths | Files on disk — no ADO writes |
23
+
24
+ ### What the agents do NOT do
25
+
26
+ - Do NOT make any product decisions (scope, priority, what to test).
27
+ - Do NOT infer missing acceptance criteria, test data, or screen names.
28
+ - Do NOT carry forward any decision from one artifact to the next.
29
+ - Do NOT create local files unless the user explicitly requests a download.
30
+ - Do NOT attach anything to ADO unless the explicit rule for that artifact type is satisfied.
31
+ - Do NOT proceed past a gap or ambiguity — they stop and ask.
32
+
33
+ ---
34
+
35
+ ## 2. Zero-Inference Rule
36
+
37
+ **An agent must never substitute inference for an explicit instruction.**
38
+
39
+ This applies specifically to:
40
+
41
+ | Situation | Prohibited inference | Required behaviour |
42
+ |---|---|---|
43
+ | User provides a work item ID but no type | Guessing whether it is Epic / Feature / PBI / Bug | Call the fetch tool; let the response `work_item_type` field determine routing |
44
+ | User says "generate everything" | Assuming delivery destinations for each artifact type | Ask per artifact: "Attach Gherkin to ADO? Attach Playwright to ADO? Save locally?" |
45
+ | User confirms Gherkin ADO attachment | Inferring Playwright code should also be attached | Wait for explicit confirmation before calling `attach_code_to_work_item` |
46
+ | User declines creating test cases in ADO | Inferring they also decline Gherkin or Playwright ADO attachment | Treat each artifact delivery as a completely independent decision |
47
+ | User says "yes" to one step | Carrying that "yes" forward to the next step | Seek fresh confirmation for each distinct action |
48
+ | Navigation path not in work item | Inventing a path | Write placeholder `<!-- TODO: confirm screen name -->` and surface to user |
49
+ | Test data not provided | Inventing emails, IDs, file contents | Stop and ask; never hardcode invented data |
50
+ | Work item appears new | Skipping the deduplication protocol | Always run Phase 1 of deduplication-protocol.md before creating anything |
51
+
52
+ ---
53
+
54
+ ## 3. Explicit Artifact Delivery Rules
55
+
56
+ Every artifact type has exactly one delivery rule. Completing one artifact does **not** trigger delivery of another.
57
+
58
+ ### 3A — Gherkin `.feature` files
59
+
60
+ | Condition | Action |
61
+ |---|---|
62
+ | User asks to generate Gherkin | Generate the file; show content to user; **do not attach yet** |
63
+ | `validate_gherkin_content` returns `valid: false` | Fix errors; do not attach |
64
+ | `validate_gherkin_content` returns `valid: true` | **Ask the user**: "Attach this `.feature` file to ADO work item #{id}?" |
65
+ | User confirms attachment | Call `attach_gherkin_to_feature` (Feature path) or `attach_gherkin_to_work_item` (PBI/Bug path) |
66
+ | User declines | Save locally only if user explicitly requests; otherwise present content inline |
67
+ | Work item type is Epic | **HARD STOP** — do not attach to Epic; tell user to specify a child Feature ID |
68
+
69
+ ### 3B — Playwright TypeScript files
70
+
71
+ | Condition | Action |
72
+ |---|---|
73
+ | User asks to generate Playwright code | Generate files; show output summary; **do not attach yet** |
74
+ | User has not explicitly requested ADO attachment | Do NOT call `attach_code_to_work_item` |
75
+ | User explicitly requests ADO attachment | Call `attach_code_to_work_item` with net-new delta files only |
76
+ | User previously declined test case creation | This has **no bearing** on Playwright attachment — ask separately |
77
+ | User previously confirmed Gherkin attachment | This has **no bearing** on Playwright attachment — ask separately |
78
+ | Work item type is Epic | **HARD STOP** — return `epic_not_supported`; do not attach |
79
+
80
+ ### 3C — Manual test cases (ADO)
81
+
82
+ | Condition | Action |
83
+ |---|---|
84
+ | Work item type is Epic | **HARD STOP** — `fetch_work_item` returns `epic_not_supported`; inform user; do not call `create_and_link_test_cases` |
85
+ | Work item type is Feature | Server returns `confirmation_required: true`; show user the proposed count + Feature title; wait for "yes" |
86
+ | User says "yes" to Feature confirmation | Retry `create_and_link_test_cases` with the **identical arguments** plus `confirmed=true` — do NOT change `work_item_id` or any other parameter |
87
+ | User says "no" or "cancel" to Feature confirmation | Abort entirely; report "No test cases were created." Do NOT retry with a different work item type. |
88
+ | Work item type is PBI or Bug | Run deduplication protocol; create only net-new test cases |
89
+ | `existing_test_cases_count > 0` | Always call `get_linked_test_cases` first to get real titles before generating |
90
+
91
+ ### 3D — Local file creation
92
+
93
+ | Condition | Action |
94
+ |---|---|
95
+ | User says "save", "download", or "export to file" | Create local file as requested |
96
+ | User has not requested a local file | Do NOT create one |
97
+ | ADO attachment succeeded | Do NOT also create a local copy unless user asks |
98
+ | ADO attachment failed | Offer the content inline; ask if user wants a local file |
99
+
100
+ ### 3E — Helix-QA disk writes
101
+
102
+ | Condition | Action |
103
+ |---|---|
104
+ | User asks to write files to disk | Follow `write-helix-files.md` in full — never skip any step |
105
+ | `write_helix_files` succeeds | Report the deduplication summary to the user |
106
+ | `write_helix_files` fails | **See failure recovery rules below** — do NOT fall back to `create_file` |
107
+ | A locator file already exists on disk (`list_helix_tree` returns it) | Extend that file via `write_helix_files` — **NEVER create a new file** |
108
+ | A step file already exists on disk | Merge into that file via `write_helix_files` — **NEVER create a new file** |
109
+ | User has not explicitly asked for local files | Do NOT call `create_file` or any filesystem tool |
110
+
111
+ **Failure recovery for `write_helix_files`:**
112
+
113
+ | Error type | Root cause | Recovery action |
114
+ |---|---|---|
115
+ | Parenthesis / bracket balance error in a `*.steps.ts` file | Step definitions use regex patterns (`/^I click ([^"]*)/`) — the regex preprocessor strips string literals before counting parens, so capture groups cause a nonzero delta | Call `pre_validate_cucumber_steps` on the steps file — it identifies every offending pattern and provides ready-to-paste Cucumber expression replacements. Fix all flagged patterns, then retry `write_helix_files`. |
116
+ | `OSError` on a specific path | Path does not exist or permission denied | Report path to user; do not fall back to `create_file` |
117
+ | Any other tool error | Unknown | Report the raw error to user verbatim; ask how to proceed |
118
+
119
+ **The `create_file` tool is PROHIBITED for Helix-QA artifacts.** Every file in `src/` that
120
+ belongs to the QA test suite — locators, page objects, step definitions, feature files,
121
+ cucumber config — must be written exclusively via `qa-helix-writer:write_helix_files`.
122
+ Using `create_file` bypasses deduplication, interface-adaptation rewrites, and file routing.
123
+ If `write_helix_files` cannot be made to succeed, surface the blocker to the user rather
124
+ than silently routing around it.
125
+
126
+ | Condition | Action |
127
+ |---|---|
128
+ | Files to write | Always call `list_helix_tree` first to see what already exists |
129
+ | File already exists at target path | Read it first; check for overlap; write only net-new content |
130
+ | `generate_playwright_code` output available | Pass the `files` dict directly to `write_helix_files` — do not reformat |
131
+
132
+ **Playwright generation routing (strict — no inference):**
133
+
134
+ | Project state (`list_helix_tree` result) | Action |
135
+ |---|---|
136
+ | `framework_state: "absent"` or `"partial"` (fresh project) | Call `scaffold_locator_repository` FIRST, then `generate_playwright_code` |
137
+ | `framework_state: "present"` (existing boilerplate) | Call `generate_playwright_code` ONLY — never call `scaffold_locator_repository` |
138
+
139
+ Calling `scaffold_locator_repository` on an existing project overwrites the six shared
140
+ infrastructure files and destroys customisations. It is only safe on a fresh project.
141
+
142
+ ---
143
+
144
+ ## 4. Strict Input → Tool → Output Chains
145
+
146
+ Each user request type has one and only one correct tool chain. Do not improvise.
147
+
148
+ ### Chain A — Manual test cases from PBI or Bug
149
+
150
+ ```
151
+ INPUT: PBI or Bug ID + org URL + project name
152
+
153
+ ├─ fetch_work_item(id)
154
+ │ └─ if epic_not_supported → STOP, inform user
155
+ │ └─ if confirmation_required → STOP, ask user; proceed only on "yes"
156
+
157
+ ├─ get_linked_test_cases(id) ← always if count > 0
158
+
159
+ ├─ [deduplication-protocol Phase 2]
160
+
161
+ └─ create_and_link_test_cases(net-new only)
162
+
163
+ OUTPUT: ADO test case IDs + deduplication report
164
+ NO local file, NO Gherkin, NO Playwright — unless user explicitly requests them
165
+ ```
166
+
167
+ ### Chain B — Gherkin from Feature
168
+
169
+ ```
170
+ INPUT: Feature ID + org URL + project name
171
+
172
+ ├─ fetch_feature_hierarchy(id)
173
+
174
+ ├─ [deduplication-protocol Phase 1+2]
175
+
176
+ ├─ [gap check — stop and ask if any G1–G7 gap found]
177
+
178
+ ├─ [live Playwright MCP snapshots of every screen]
179
+
180
+ ├─ validate_gherkin_content(content, scope="feature")
181
+ │ └─ if valid: false → fix; re-validate; do NOT attach
182
+
183
+ ├─ validate_gherkin_steps(content)
184
+
185
+ ├─ [show content to user]
186
+
187
+ ├─ [ASK: "Attach to ADO Feature #{id}?"]
188
+ │ └─ yes → attach_gherkin_to_feature(id)
189
+ │ └─ no → stop; offer local download only if user asks
190
+
191
+ └─ [STOP — do not proceed to Playwright unless user explicitly asks]
192
+
193
+ OUTPUT: .feature file attached to Feature work item (or shown inline)
194
+ NO Playwright code unless user explicitly requests it
195
+ NO test case creation unless user explicitly requests it
196
+ ```
197
+
198
+ ### Chain C — Gherkin from PBI or Bug
199
+
200
+ ```
201
+ INPUT: PBI or Bug ID + org URL + project name
202
+
203
+ ├─ fetch_work_item_for_gherkin(id)
204
+
205
+ ├─ get_linked_test_cases(id) ← context only
206
+
207
+ ├─ [deduplication-protocol Phase 1+2]
208
+
209
+ ├─ [gap check]
210
+
211
+ ├─ [live Playwright MCP snapshots]
212
+
213
+ ├─ validate_gherkin_content(content, scope="work_item")
214
+
215
+ ├─ [show content to user]
216
+
217
+ ├─ [ASK: "Attach to ADO work item #{id}?"]
218
+ │ └─ yes → attach_gherkin_to_work_item(id)
219
+ │ └─ no → stop
220
+
221
+ └─ [STOP — do not proceed to Playwright unless user explicitly asks]
222
+
223
+ OUTPUT: .feature file attached to PBI/Bug work item (or shown inline)
224
+ ```
225
+
226
+ ### Chain D — Gherkin from Epic
227
+
228
+ ```
229
+ INPUT: Epic ID + org URL + project name
230
+
231
+ ├─ fetch_epic_hierarchy(id)
232
+ │ └─ returns: features[] each with child_work_items[] and existing_test_cases[]
233
+
234
+ ├─ [read ALL child Features and ALL child PBIs/Bugs before writing any Gherkin]
235
+
236
+ ├─ for each child Feature:
237
+ │ ├─ [deduplication-protocol Phase 1+2 for that Feature ID]
238
+ │ ├─ [gap check for that Feature]
239
+ │ ├─ [live snapshots for that Feature's screens]
240
+ │ ├─ generate .feature file (5–10 scenarios)
241
+ │ ├─ validate_gherkin_content(scope="feature")
242
+ │ ├─ [show content to user]
243
+ │ ├─ [ASK: "Attach .feature to Feature #{child_id}?"]
244
+ │ └─ yes → attach_gherkin_to_feature(child_id)
245
+
246
+ └─ [NEVER call create_and_link_test_cases on the Epic ID]
247
+
248
+ OUTPUT: one .feature file per child Feature
249
+ test cases NOT created unless user explicitly asks for child Feature/PBI coverage
250
+ ```
251
+
252
+ ### Chain E — Playwright TypeScript from Gherkin
253
+
254
+ ```
255
+ INPUT: validated .feature content + work item ID + org URL + project name
256
+
257
+ ├─ [deduplication-protocol Phase 1 — read existing locators, page objects, steps]
258
+
259
+ ├─ [gap check — identify state-dependent screens; stop and ask if blockers found]
260
+
261
+ ├─ [live Playwright MCP snapshots through full flow]
262
+
263
+ ├─ generate_playwright_code(gherkin, context_map)
264
+
265
+ ├─ [apply delta filter — remove keys / methods / steps already in existing files]
266
+
267
+ ├─ [show delta summary to user]
268
+
269
+ ├─ [ASK: "Attach these Playwright files to ADO work item #{id}?"]
270
+ │ └─ yes → attach_code_to_work_item(delta files only)
271
+ │ └─ no → stop; offer local download only if user asks
272
+
273
+ └─ [STOP — do not trigger Helix write unless user explicitly asks]
274
+
275
+ OUTPUT: delta Playwright files attached to work item (or shown inline)
276
+ NO Helix disk write unless user explicitly requests it
277
+ ```
278
+
279
+ ---
280
+
281
+ ## 5. Ambiguity Resolution — Stop, Don't Guess
282
+
283
+ When any of the following is unclear, **stop and ask the user**. Do not proceed.
284
+
285
+ | Ambiguity | What to ask |
286
+ |---|---|
287
+ | Work item ID given but type is unknown | Call fetch tool and surface the `work_item_type` field; do not guess |
288
+ | "Generate everything for #123" | "Which artifacts do you want? (A) Manual test cases in ADO (B) Gherkin .feature file (C) Playwright TypeScript (D) All of the above — and which should be attached to ADO vs saved locally?" |
289
+ | User says "attach it" after multiple artifacts generated | "Which artifact are you referring to — the Gherkin .feature file, the Playwright TypeScript files, or both?" |
290
+ | No org URL or project name provided | "Please provide the ADO organisation URL (e.g. `https://dev.azure.com/myorg`) and project name." |
291
+ | No screen name or navigation path available | Use `<!-- TODO: confirm screen name -->` placeholder; surface to user; do not invent |
292
+ | No test data for a state-dependent screen | Stop; ask what file / email / record to use; do not invent |
293
+ | User says "yes" ambiguously after a confirmation prompt | Re-read the most recent prompt; if still unclear, re-ask with the specific action being confirmed |
294
+
295
+ ---
296
+
297
+ ## 6. No Carry-Over Between Decisions
298
+
299
+ Each of these decisions is **completely independent**. A prior answer to one does not answer another.
300
+
301
+ ```
302
+ [1] Generate Gherkin? → answered
303
+ [2] Attach Gherkin to ADO? → must ask SEPARATELY after [1]
304
+ [3] Generate Playwright code? → must ask SEPARATELY
305
+ [4] Attach Playwright to ADO? → must ask SEPARATELY after [3]
306
+ [5] Create test cases in ADO? → must ask SEPARATELY
307
+ [6] Save any artifact locally? → must ask SEPARATELY
308
+ [7] Write to Helix-QA on disk? → must ask SEPARATELY
309
+ ```
310
+
311
+ **Declining [5] does not affect [2], [4], [6], or [7].**
312
+ **Confirming [2] does not pre-answer [4].**
313
+ **Saying "yes" at step [1] does not mean "yes" at any other step.**
314
+
315
+ ---
316
+
317
+ ## 7. Decision Tree — Work Item Type Routing
318
+
319
+ ```
320
+ User provides work item ID
321
+
322
+
323
+ Call the fetch tool for the intended operation
324
+ (fetch_work_item, fetch_work_item_for_gherkin, or fetch_epic_hierarchy)
325
+
326
+
327
+ Read work_item_type from response
328
+
329
+ ┌────┴─────────────────────────────────────────────┐
330
+ │ │
331
+ "Epic" not "Epic"
332
+ │ │
333
+ ▼ ┌─────┴────────┐
334
+ HARD STOP for test cases "Feature" "PBI"/"Bug"
335
+ Use fetch_epic_hierarchy for Gherkin │ │
336
+ Never call create_and_link_test_cases │ │
337
+ Never call attach_code_to_work_item │ │
338
+ on the Epic ID Feature path PBI/Bug path
339
+ (5–10 scenarios) (3–9 scenarios)
340
+ attach_gherkin_to_feature
341
+ attach_gherkin_to_work_item
342
+ ```
343
+
344
+ ```
345
+ Feature path for test cases
346
+
347
+
348
+ create_and_link_test_cases returns confirmation_required: true
349
+
350
+
351
+ STOP — show user: Feature title + proposed TC count
352
+
353
+ ┌────┴────┐
354
+ "yes" "no"/"cancel"
355
+ │ │
356
+ ▼ ABORT — report "No test cases created"
357
+ retry create_and_link_test_cases
358
+ with identical args + confirmed=true
359
+ (do NOT change work_item_id or pivot to a child PBI)
360
+ ```
361
+
362
+ ---
363
+
364
+ ## 8. Versioning — Explicit vs Inferred
365
+
366
+ All rules in this file are **explicitly stated**. None are inferred from code patterns,
367
+ prior conversation, or training data.
368
+
369
+ ------
370
+
371
+ ## 9. Orchestrator / Multi-Step Pipeline Rules
372
+
373
+ These rules apply whenever an agent is given a numbered pipeline prompt that runs multiple
374
+ QA STLC steps in sequence (e.g. "Execute steps 1–6 in order: fetch → test cases → Gherkin
375
+ → locators → Playwright → Helix write").
376
+
377
+ ### 9A — Deduplication gate between Step 1 and Step 2
378
+
379
+ `fetch_work_item` / `fetch_work_item_for_gherkin` always returns `existing_test_cases_count`.
380
+ A pipeline **MUST NOT** proceed to `create_and_link_test_cases` without first passing through
381
+ the full deduplication protocol — even when the orchestrator prompt says "execute all steps".
382
+
383
+ ```
384
+ After fetch (Step 1):
385
+ if existing_test_cases_count > 0:
386
+ ├─ HARD STOP before create_and_link_test_cases
387
+ ├─ Call get_linked_test_cases(work_item_id) ← mandatory, not optional
388
+ ├─ Run deduplication-protocol.md Phase 2 (semantic diff)
389
+ ├─ Build net-new list
390
+ └─ if net-new list is empty:
391
+ Log: "✅ All scenario types already covered — skipping test case creation."
392
+ Skip create_and_link_test_cases entirely; continue pipeline at next step.
393
+ else:
394
+ Call create_and_link_test_cases(net-new only)
395
+ ```
396
+
397
+ The instruction "execute all steps" does **not** override this gate.
398
+ It means "execute each step correctly" — which includes the deduplication check.
399
+
400
+ ### 9B — Treating validation warnings as blocking gates
401
+
402
+ Any `_validation.warnings` entry of the form:
403
+ - `"N existing test case(s) found"`
404
+ - `"existing attachment found"`
405
+ - `"duplicate scenario detected"`
406
+
407
+ is a **blocking condition**, not advisory text. The pipeline must pause, run the
408
+ relevant deduplication phase, and resolve the warning before proceeding.
409
+
410
+ ### 9C — Per-step confirmation in automated pipelines
411
+
412
+ A pipeline prompt that says "execute steps 1–6 in order" grants permission to
413
+ **attempt** each step — it does not grant blanket confirmation for creation actions.
414
+ The explicit confirmation rules in sections 3A–3E still apply at each step.
415
+
416
+ | Step type | Still requires |
417
+ |---|---|
418
+ | Fetch (read-only) | No confirmation needed |
419
+ | `create_and_link_test_cases` | Deduplication gate (§9A) + net-new check |
420
+ | `attach_gherkin_to_work_item` | Gherkin validation must pass first |
421
+ | `generate_playwright_code` | Locator live-verification must precede |
422
+ | `write_helix_files` | `list_helix_tree` read must precede |
423
+
424
+ ### 9D — Mandatory deduplication report in every pipeline run
425
+
426
+ Every orchestrated pipeline run must output a deduplication report after Step 2,
427
+ regardless of whether any test cases were created (see deduplication-protocol.md §PHASE 3).
428
+ Skipping the report is a violation of this contract.
429
+
430
+ ---
431
+
432
+
433
+ When a rule is changed:
434
+
435
+ 1. Update the rule in this file with a dated entry in the change log below.
436
+ 2. Update the corresponding skill file in `skills/` to match.
437
+ 3. Run `./scripts/install-skills.sh vscode` to sync `.github/copilot-instructions/`.
438
+ 4. Update `CLAUDE.md` if the rule affects a key rule number.
439
+
440
+ ### Change log
441
+
442
+ | Date | Version | Change | Author |
443
+ |---|---|---|---|
444
+ | 2025-01-01 | 1.0 | Initial explicit rule set — all 8 sections | repo init |
445
+ | 2026-04-03 | 1.1 | 3C: added `confirmed=true` retry protocol for Feature confirmation gate | repo update |
446
+ | 2026-04-03 | 1.1 | 3E: paren error recovery now references `pre_validate_cucumber_steps` as first diagnostic step | repo update |
447
+ | 2026-04-03 | 1.1 | §7: Feature decision tree clarifies retry mechanism (`confirmed=true`, no pivot to child PBI) | repo update |
448
+ | 2026-04-04 | 1.2 | §9: Added orchestrator/pipeline rules — deduplication gate between Steps 1–2, warning-as-blocking-gate, per-step confirmation, mandatory dedup report | repo update |