Phase 1: Discovery (Automated)
Inputs: Codebase root directory
Actions:
- Find all test files using Glob:
- */.test.* (Jest, Vitest)
- */.spec.* (Mocha, Jasmine)
- /__tests__//* (Jest convention)
- Parse test file structure (test names, assertions count)
- Auto-discover Team ID from [docs/tasks/kanban_board.md](../docs/tasks/kanban_board.md)
Output: testFilesMetadata β list of test files with basic stats
Phase 2: Research Best Practices (ONCE)
Goal: Gather testing best practices context ONCE, share with all workers
Actions:
- Use MCP Ref/Context7 to research testing best practices for detected tech stack
- Load [../ln-350-story-test-planner/references/risk_based_testing_guide.md](../ln-350-story-test-planner/references/risk_based_testing_guide.md)
- Build
contextStore with:
- Testing philosophy (E2E primary, Unit supplementary)
- Usefulness Score formulas (Impact Γ Probability)
- Anti-patterns catalog
- Framework detection patterns
Output: contextStore β shared context for all workers
Key Benefit: Context gathered ONCE β passed to all workers β token-efficient
Phase 3: Domain Discovery (NEW)
Purpose: Detect project domains from production code folder structure for domain-aware coverage analysis.
Algorithm: (same as ln-360-codebase-auditor)
- Priority 1: Explicit domain folders
- Check for: src/domains//, src/features//, src/modules/*/
- Monorepo patterns: packages//, libs//, apps/*/
- If found (>1 match) β use as domains
- *Priority 2: Top-level src/ folders**
- List folders: src/users/, src/orders/, src/payments/
- Exclude infrastructure: utils, shared, common, lib, helpers, config, types, interfaces, constants, middleware, infrastructure, core
- If remaining >1 β use as domains
- Priority 3: Fallback to global mode
- If <2 domains detected β domain_mode = "global"
- All workers scan entire codebase (backward-compatible behavior)
Heuristics for domain detection:
| Heuristic | Indicator | Example |
|-----------|-----------|---------|
| File count | >5 files in folder | src/users/ with 12 files |
| Structure | controllers/, services/, models/ present | MVC/Clean Architecture |
| Barrel export | index.ts/index.js exists | Module pattern |
| README | README.md describes domain | Domain documentation |
Output:
```json
{
"domain_mode": "domain-aware",
"all_domains": [
{"name": "users", "path": "src/users", "file_count": 45},
{"name": "orders", "path": "src/orders", "file_count": 32},
{"name": "shared", "path": "src/shared", "file_count": 15, "is_shared": true}
]
}
```
Shared folder handling:
- Folders named
shared, common, utils, lib, core β mark is_shared: true - Shared code audited but grouped separately in report
Phase 4: Delegate to Workers
> CRITICAL: All delegations use Task tool with subagent_type: "general-purpose" for context isolation.
Prompt template:
```
Task(description: "Test audit via ln-63X",
prompt: "Execute ln-63X-{worker}. Read skill from ln-63X-{worker}/SKILL.md. Context: {contextStore}",
subagent_type: "general-purpose")
```
Anti-Patterns:
- β Direct Skill tool invocation without Task wrapper
- β Any execution bypassing subagent context isolation
#### Phase 4a: Global Workers (PARALLEL)
Global workers scan entire test suite (not domain-aware):
| # | Worker | Category | What It Audits |
|---|--------|----------|----------------|
| 1 | [ln-631-test-business-logic-auditor](../ln-631-test-business-logic-auditor/) | Business Logic Focus | Framework/Library tests (Prisma, Express, bcrypt, JWT, axios, React hooks) β REMOVE |
| 2 | [ln-632-test-e2e-priority-auditor](../ln-632-test-e2e-priority-auditor/) | E2E Priority | E2E baseline (2/endpoint), Pyramid validation, Missing E2E tests |
| 3 | [ln-633-test-value-auditor](../ln-633-test-value-auditor/) | Risk-Based Value | Usefulness Score = Impact Γ Probability
Decisions: β₯15 KEEP, 10-14 REVIEW, <10 REMOVE |
| 5 | [ln-635-test-isolation-auditor](../ln-635-test-isolation-auditor/) | Isolation + Anti-Patterns | Isolation (6 categories), Determinism, Anti-Patterns (6 types) |
Invocation (4 workers in PARALLEL):
```javascript
FOR EACH worker IN [ln-631, ln-632, ln-633, ln-635]:
Task(description: "Test audit via " + worker,
prompt: "Execute " + worker + ". Read skill. Context: " + JSON.stringify(contextStore),
subagent_type: "general-purpose")
```
#### Phase 4b: Domain-Aware Worker (PARALLEL per domain)
Domain-aware worker runs once per domain:
| # | Worker | Category | What It Audits |
|---|--------|----------|----------------|
| 4 | [ln-634-test-coverage-auditor](../ln-634-test-coverage-auditor/) | Coverage Gaps | Missing tests for critical paths per domain (Money 20+, Security 20+, Data 15+, Core Flows 15+) |
Invocation:
```javascript
IF domain_mode == "domain-aware":
FOR EACH domain IN all_domains:
domain_context = {
...contextStore,
domain_mode: "domain-aware",
current_domain: { name: domain.name, path: domain.path }
}
Skill(skill="ln-634-test-coverage-auditor", args=JSON.stringify(domain_context))
ELSE:
// Fallback: invoke once for entire codebase (global mode)
Skill(skill="ln-634-test-coverage-auditor", args=JSON.stringify(contextStore))
```
Parallelism strategy:
- Phase 4a: All 4 global workers run in PARALLEL
- Phase 4b: All N domain-aware invocations run in PARALLEL
- Example: 3 domains β 3 ln-374 invocations in single message
Each worker returns structured JSON:
```json
{
"category": "Business Logic Focus",
"score": 7,
"total_issues": 12,
"findings": [
{
"severity": "MEDIUM",
"test_file": "auth.test.ts",
"test_name": "bcrypt hashes password",
"decision": "REMOVE",
"usefulness_score": 3,
"reason": "Tests library behavior, not OUR code",
"effort": "S"
}
]
}
```
Phase 5: Aggregate Results
Goal: Merge all worker results into unified Test Suite Audit Report with domain grouping
Actions:
- Collect results from all workers (global + domain-aware)
- Global workers (ln-371, ln-372, ln-373, ln-375) β merge findings (as before)
- Domain-aware worker (ln-374) β group by domain.name:
- Aggregate coverage gaps per domain
- Build Domain Coverage Summary table
- Merge findings into decision categories:
- Tests to REMOVE (Usefulness Score <10)
- Tests to REVIEW (Usefulness Score 10-14)
- Tests to KEEP (Usefulness Score β₯15)
- Missing Tests (Priority/Justification) β grouped by domain if domain_mode="domain-aware"
- Anti-Patterns Found (counts + examples)
- Calculate compliance scores (6 categories, each /10)
- Build decision summary (KEEP/REVIEW/REMOVE counts)
- Generate Executive Summary (2-3 sentences)
- Create Linear task in Epic 0 with full report (see Output Format below)
- Return summary to user
Findings grouping:
- Categories 1-3, 5-6 (Business Logic, E2E, Value, Isolation, Anti-Patterns) β single tables (global)
- Category 4 (Coverage Gaps) β subtables per domain (if domain_mode="domain-aware")