Systematic root cause analysis using Toyota's 5 Whys with multi-causal investigation and evidence-based validation. Investigates multiple cause branches at each level|validates solutions against all identified root causes.
Agent Invocation
@nw-troubleshooter
Execute *investigate-root-cause for {problem-statement}.
Configuration:
investigation_depth: 5
multi_causal: true
evidence_required: true
Usage: DELIVER Wave Retrospective (Phase 3.5)
When invoked as part of /nw:deliver Phase 3.5, analyze across 4 categories:
What worked well (and why — preserve these practices)
What worked better than before (and why — reinforce improvements)
What worked badly (5 Whys root cause, actionable fix)
What worked worse than before (5 Whys root cause, prevent regression)
Inputs: Evolution document|execution-log.yaml|mutation results|git log.
Output: Retrospective section appended to evolution document.
Skip: If clean execution (no skips|no failures|no tooling issues), generate brief summary only.
Tag items requiring nWave framework changes as meta-improvements.
Success Criteria
All 5 WHY levels investigated with evidence
Multi-causal branches explored at each level
Root causes identified and validated
Solutions address all identified root causes
Backward chain validation performed
Next Wave
Handoff To: {invoking-agent-returns-to-workflow}
Deliverables: Root cause analysis report with solutions
Examples
Example 1: Investigate test flakiness
code
/nw:root-why "Integration tests fail intermittently on CI but pass locally"
Rex investigates 5 WHY levels with multi-causal branches, discovers race condition in database cleanup, proposes transaction-isolated test fixtures.
Expected Outputs
code
docs/analysis/root-cause-analysis-{problem}.md
User
[Request interrupted by user]
User
nw:root-why
/nw:root-why
"brain init" fails in consent ui with {
"error_description": "missing oauth query",
"error": "invalid_request"
}
User
NW-ROOT-WHY: Toyota 5 Whys Root Cause Analysis
Wave: CROSS_WAVE
Agent: Rex (nw-troubleshooter)
Overview
Systematic root cause analysis using Toyota's 5 Whys with multi-causal investigation and evidence-based validation. Investigates multiple cause branches at each level|validates solutions against all identified root causes.
Agent Invocation
@nw-troubleshooter
Execute *investigate-root-cause for {problem-statement}.
Configuration:
investigation_depth: 5
multi_causal: true
evidence_required: true
Usage: DELIVER Wave Retrospective (Phase 3.5)
When invoked as part of /nw:deliver Phase 3.5, analyze across 4 categories:
What worked well (and why — preserve these practices)
What worked better than before (and why — reinforce improvements)
What worked badly (5 Whys root cause, actionable fix)
What worked worse than before (5 Whys root cause, prevent regression)
Inputs: Evolution document|execution-log.yaml|mutation results|git log.
Output: Retrospective section appended to evolution document.
Skip: If clean execution (no skips|no failures|no tooling issues), generate brief summary only.
Tag items requiring nWave framework changes as meta-improvements.
Success Criteria
All 5 WHY levels investigated with evidence
Multi-causal branches explored at each level
Root causes identified and validated
Solutions address all identified root causes
Backward chain validation performed
Next Wave
Handoff To: {invoking-agent-returns-to-workflow}
Deliverables: Root cause analysis report with solutions
Examples
Example 1: Investigate test flakiness
code
/nw:root-why "Integration tests fail intermittently on CI but pass locally"
Rex investigates 5 WHY levels with multi-causal branches, discovers race condition in database cleanup, proposes transaction-isolated test fixtures.
Expected Outputs
code
docs/analysis/root-cause-analysis-{problem}.md
ARGUMENTS: "brain init" fails in consent ui with {
"error_description": "missing oauth query",
"error": "invalid_request"
}
Assistant
The root cause analysis is complete. Let me read the report for a summary.
Assistant
Root Cause Analysis Complete
Root cause:consent-page.tsx doesn't send oauth_query in the POST body to /api/auth/oauth2/consent.
Mechanism: The @better-auth/oauth-provider uses per-request AsyncLocalStorage for OAuth state. The authorize endpoint redirects to the consent page with signed query params in the URL. The library expects the consent page to echo these back as oauth_query in the POST body so a before hook can restore the state. Without it, oAuthState.get() returns null → "missing oauth query" error.
Fix location:app/src/client/routes/consent-page.tsx — add oauth_query: new URLSearchParams(search).toString() to the POST body.
Why it was missed: The smoke test sets skipConsent = true, bypassing consent entirely.
Full analysis written to docs/analysis/root-cause-analysis-brain-init-oauth.md.
Want me to apply the fix?
User
yes
Assistant
Fixed. Added oauth_query: new URLSearchParams(search).toString() to the POST body at consent-page.tsx:49. This round-trips the signed OAuth params back to the server so the before hook can restore the OAuth state.
User
commit and push
Assistant
Pushed. Now looking at the next error — token exchange returns {"error_description":"requested resource invalid","error":"invalid_request"}. The consent redirect is working now but the CLI's token exchange is failing.
Assistant
Root cause: The CLI sends resource: "http://localhost:3000" but the server's validAudiences contains "http://localhost:3000/api/auth". The Set.has() check fails on the mismatch.
Let me fix the CLI to use the correct resource URL.
Assistant
Pushed. The CLI now sends resource: "${serverUrl}/api/auth" in both the authorize URL and token exchange, matching the server's validAudiences. Try brain init again.
User
perfect
Assistant
Great, glad it's working now. Two fixes shipped:
Consent page — round-trip oauth_query in POST body (78a3606)
CLI token exchange — use ${serverUrl}/api/auth as resource to match validAudiences (0f87589)
The pre-commit hook is trying to run brain which isn't in PATH. Let me check the hook.
Assistant
The pre-commit hook calls brain check-commit but brain isn't in PATH. The hook is failing and blocking the commit. Should I skip the hook for this commit, or would you prefer to fix the hook / add brain to PATH first?