You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ---
  2. name: 'step-03b-subagent-isolation'
  3. description: 'Subagent: Check test isolation (no shared state/dependencies)'
  4. subagent: true
  5. outputFile: '/tmp/tea-test-review-isolation-{{timestamp}}.json'
  6. ---
  7. # Subagent 3B: Isolation Quality Check
  8. ## SUBAGENT CONTEXT
  9. This is an **isolated subagent** running in parallel with other quality dimension checks.
  10. **Your task:** Analyze test files for ISOLATION violations only.
  11. ---
  12. ## MANDATORY EXECUTION RULES
  13. - ✅ Check ISOLATION only (not other quality dimensions)
  14. - ✅ Output structured JSON to temp file
  15. - ❌ Do NOT check determinism, maintainability, coverage, or performance
  16. - ❌ Do NOT modify test files (read-only analysis)
  17. ---
  18. ## SUBAGENT TASK
  19. ### 1. Identify Isolation Violations
  20. **Scan test files for isolation issues:**
  21. **HIGH SEVERITY Violations**:
  22. - Global state mutations (global variables modified)
  23. - Test order dependencies (test B depends on test A running first)
  24. - Shared database records without cleanup
  25. - beforeAll/afterAll with side effects leaking to other tests
  26. **MEDIUM SEVERITY Violations**:
  27. - Missing test cleanup (created data not deleted)
  28. - Shared fixtures that mutate state
  29. - Tests that assume specific execution order
  30. - Environment variables modified without restoration
  31. **LOW SEVERITY Violations**:
  32. - Tests sharing test data (but not mutating)
  33. - Missing test.describe grouping
  34. - Tests that could be more isolated
  35. ### 2. Calculate Isolation Score
  36. ```javascript
  37. const totalChecks = testFiles.length * checksPerFile;
  38. const failedChecks = violations.length;
  39. const severityWeights = { HIGH: 10, MEDIUM: 5, LOW: 2 };
  40. const totalPenalty = violations.reduce((sum, v) => sum + severityWeights[v.severity], 0);
  41. const score = Math.max(0, 100 - totalPenalty);
  42. ```
  43. ---
  44. ## OUTPUT FORMAT
  45. ```json
  46. {
  47. "dimension": "isolation",
  48. "score": 90,
  49. "max_score": 100,
  50. "grade": "A-",
  51. "violations": [
  52. {
  53. "file": "tests/api/integration.spec.ts",
  54. "line": 15,
  55. "severity": "HIGH",
  56. "category": "test-order-dependency",
  57. "description": "Test depends on previous test creating user record",
  58. "suggestion": "Each test should create its own test data in beforeEach",
  59. "code_snippet": "test('should update user', async () => { /* assumes user exists */ });"
  60. }
  61. ],
  62. "passed_checks": 14,
  63. "failed_checks": 1,
  64. "total_checks": 15,
  65. "violation_summary": {
  66. "HIGH": 1,
  67. "MEDIUM": 0,
  68. "LOW": 0
  69. },
  70. "recommendations": [
  71. "Add beforeEach hooks to create test data",
  72. "Add afterEach hooks to cleanup created records",
  73. "Use test.describe.configure({ mode: 'parallel' }) to enforce isolation"
  74. ],
  75. "summary": "Tests are well isolated with 1 HIGH severity violation"
  76. }
  77. ```
  78. ---
  79. ## EXIT CONDITION
  80. Subagent completes when:
  81. - ✅ All test files analyzed for isolation violations
  82. - ✅ Score calculated
  83. - ✅ JSON output written to temp file
  84. **Subagent terminates here.**
  85. ---
  86. ## 🚨 SUBAGENT SUCCESS METRICS
  87. ### ✅ SUCCESS:
  88. - Only isolation checked (not other dimensions)
  89. - JSON output valid and complete
  90. ### ❌ FAILURE:
  91. - Checked quality dimensions other than isolation
  92. - Invalid or missing JSON output