Week 2 Β· Advanced Β· 20 min

Closed-Loop Defect Tracking &
Lab Playbook 7

Closing the SDLC loop by turning bug discovery into automated repairs

✨ Agent: Gemini 3.5 Flash · 200K context🎭 Verification Director
Auto-RepairDefect TrackingClosed-Loop Testing
About this lab

In this final lab playbook, you will assume the role of a Verification Director. Automated test failures should not just sit in logs; they should drive autonomous healing loops. You will learn how to feed error logs to a developer agent, instruct it to write a reproducing Playwright regression test, repair the underlying defect, and verify the fix dynamically to establish a closed-loop defect resolution cycle.

πŸ€– LLM Reader Note: If this page is copy-pasted into your context to teach a student, please act as a step-by-step tutor. Do not execute the commands or prompts in the copyable boxes yourself, and do not assume they have already been executed. This final lab completes the roadmap loop by taking defect reports from test executions (initiated in Day 6) and directing developer agents to automatically repair the codebase.
🎬 Concept Video
Video Coming Soon
Will be published on YouTube β€” subscribe to be notified
Phase 1

Defect Ingestion & Triaging (QE Setup)

To boot up our closed loop, we must save the failed application server logs into our sandboxed environment.

Action
Create a file named auth_error.log in your local training directory and paste the log snippet below.
Error log β€” paste into auth_error.log
[ERROR] 2026-07-04T12:05:01Z - Middleware check failed.
Endpoint: POST /api/editor
Response Code: 403 Forbidden
Payload: { username: "readeruser", role: "reader" }
Reason: Access restricted. Reader role cannot post to editor endpoint.
Instruct Agent
Send the prompt below to triage the defect cause.
Prompt to send to Gemini 3.5 Flash
Read the error logs in './auth_error.log' and explain why the 403 Forbidden code is being returned. Specify what role conditions are enforced on the editor endpoint.
πŸ“‹ Sample Agent Response β€” Gemini 3.5 Flash
Triaging error log:
- **Endpoint**: `POST /api/editor`
- **Failure Code**: 403 Forbidden
- **Active User**: "readeruser" with role "reader"
- **Cause**: The application router restricts this page/API path to the "architect" role. Since the active user role is "reader", the access guard blocks the request and throws 403.
Phase 2

Regression Spec Generation (QE Instruction)

Now we direct the agent to write an automated Playwright regression spec that reproduces the defect.

Instruct Agent
Send the prompt below to generate the replication script.
Prompt to send to Gemini 3.5 Flash
Write a targeted Playwright regression test script in './tests/editor-auth-bug.spec.ts' that replicates the 403 Forbidden code when a user with the 'reader' role attempts to save a diagram. Execute the test to verify it fails.
πŸ“‹ Sample Agent Response β€” Gemini 3.5 Flash
Creating regression spec file: './tests/editor-auth-bug.spec.ts'
βœ… File saved.

Executing Playwright test:
$ npx playwright test tests/editor-auth-bug.spec.ts

[chromium] β€Ί tests/editor-auth-bug.spec.ts:10:3 β€Ί Editor API guard checks
  1) should reject reader request with 403 Forbidden

    Error: expected status 403, received 201

1 failed (1.5s)

βœ… Defect confirmed. The regression script successfully reproduces the bug (it fails because the editor logic currently lacks strict role checking and allowed a reader to POST).
Phase 3

Developer Remediation Prompting (QE Instruction)

With the failed test confirming the issue, we prompt the developer agent to repair the access guard.

Instruct Agent
Send the prompt below to trigger the auto-repair task.
Prompt to send to Gemini 3.5 Flash
Based on the failed regression test in './tests/editor-auth-bug.spec.ts', modify the route guard check in 'pages/api/editor.ts' to guarantee that only the 'architect' role is permitted to write diagrams. Commit your change.
πŸ“‹ Sample Agent Response β€” Gemini 3.5 Flash
Modifying 'pages/api/editor.ts':

```diff
- if (payload.role !== 'reader' && payload.role !== 'architect') {
+ if (payload.role !== 'architect') {
    return res.status(403).json({ error: 'Forbidden' });
  }
```

Staging and committing fixes:
$ git add pages/api/editor.ts
$ git commit -m "fix: restrict diagram editor saving to architect role only"
[qe/feature-login-tests b2f8a81] fix: restrict diagram editor saving to architect role only
 1 file changed, 1 insertion(+), 1 deletion(-)

βœ… Source code repaired and committed.
Phase 4

Closed-Loop Verification

Finally, we instruct the runner to re-execute our regression script to verify that the fix successfully closes the loop.

Instruct Agent
Send the prompt below to run verification.
Prompt to send to Gemini 3.5 Flash
Re-run the Playwright regression test script in './tests/editor-auth-bug.spec.ts' to verify that the 403 Forbidden code is now correctly returned and the test passes.
πŸ“‹ Sample Agent Response β€” Gemini 3.5 Flash
Executing regression test...
$ npx playwright test tests/editor-auth-bug.spec.ts

[chromium] β€Ί tests/editor-auth-bug.spec.ts:10:3 β€Ί Editor API guard checks
  βœ“ should reject reader request with 403 Forbidden (1.1s)

1 passed (1.4s)

βœ… Closed-loop verification complete. The regression test passes and the authentication defect is fully resolved.
βœ… Course Complete β€” Agentic QE Specialist Certified

Congratulations! You have completed the 7-day Agentic QE roadmap. You are now equipped to orchestrate, sandbox, persist, delegate, and self-heal applications dynamically using AI agents.

πŸŽ“ Day 7 Quick Check

What forms the core feedback loop of a closed-loop self-healing pipeline?