@massu/core 0.5.0 → 0.6.1

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.
Files changed (119) hide show
  1. package/README.md +40 -0
  2. package/agents/massu-architecture-reviewer.md +104 -0
  3. package/agents/massu-blast-radius-analyzer.md +84 -0
  4. package/agents/massu-competitive-scorer.md +126 -0
  5. package/agents/massu-help-sync.md +73 -0
  6. package/agents/massu-migration-writer.md +94 -0
  7. package/agents/massu-output-scorer.md +87 -0
  8. package/agents/massu-pattern-reviewer.md +84 -0
  9. package/agents/massu-plan-auditor.md +170 -0
  10. package/agents/massu-schema-sync-verifier.md +70 -0
  11. package/agents/massu-security-reviewer.md +98 -0
  12. package/agents/massu-ux-reviewer.md +106 -0
  13. package/commands/_shared-preamble.md +53 -23
  14. package/commands/_shared-references/auto-learning-protocol.md +71 -0
  15. package/commands/_shared-references/blast-radius-protocol.md +76 -0
  16. package/commands/_shared-references/security-pre-screen.md +64 -0
  17. package/commands/_shared-references/test-first-protocol.md +87 -0
  18. package/commands/_shared-references/verification-table.md +55 -0
  19. package/commands/massu-article-review.md +343 -0
  20. package/commands/massu-autoresearch/references/eval-runner.md +84 -0
  21. package/commands/massu-autoresearch/references/safety-rails.md +125 -0
  22. package/commands/massu-autoresearch/references/scoring-protocol.md +151 -0
  23. package/commands/massu-autoresearch.md +258 -0
  24. package/commands/massu-batch.md +44 -12
  25. package/commands/massu-bearings.md +42 -8
  26. package/commands/massu-checkpoint.md +588 -0
  27. package/commands/massu-ci-fix.md +2 -2
  28. package/commands/massu-command-health.md +132 -0
  29. package/commands/massu-command-improve.md +232 -0
  30. package/commands/massu-commit.md +205 -44
  31. package/commands/massu-create-plan.md +239 -57
  32. package/commands/massu-data/references/common-queries.md +79 -0
  33. package/commands/massu-data/references/table-guide.md +50 -0
  34. package/commands/massu-data.md +66 -0
  35. package/commands/massu-dead-code.md +29 -34
  36. package/commands/massu-debug/references/auto-learning.md +61 -0
  37. package/commands/massu-debug/references/codegraph-tracing.md +80 -0
  38. package/commands/massu-debug/references/common-shortcuts.md +98 -0
  39. package/commands/massu-debug/references/investigation-phases.md +294 -0
  40. package/commands/massu-debug/references/report-format.md +107 -0
  41. package/commands/massu-debug.md +105 -386
  42. package/commands/massu-docs.md +1 -1
  43. package/commands/massu-full-audit.md +61 -0
  44. package/commands/massu-gap-enhancement-analyzer.md +276 -16
  45. package/commands/massu-golden-path/references/approval-points.md +216 -0
  46. package/commands/massu-golden-path/references/competitive-mode.md +273 -0
  47. package/commands/massu-golden-path/references/error-handling.md +121 -0
  48. package/commands/massu-golden-path/references/phase-0-requirements.md +53 -0
  49. package/commands/massu-golden-path/references/phase-1-plan-creation.md +168 -0
  50. package/commands/massu-golden-path/references/phase-2-implementation.md +403 -0
  51. package/commands/massu-golden-path/references/phase-2.5-gap-analyzer.md +170 -0
  52. package/commands/massu-golden-path/references/phase-3-simplify.md +40 -0
  53. package/commands/massu-golden-path/references/phase-3.5-security-audit.md +108 -0
  54. package/commands/massu-golden-path/references/phase-4-commit.md +94 -0
  55. package/commands/massu-golden-path/references/phase-5-push.md +116 -0
  56. package/commands/massu-golden-path/references/phase-5.5-production-verify.md +170 -0
  57. package/commands/massu-golden-path/references/phase-6-completion.md +113 -0
  58. package/commands/massu-golden-path/references/qa-evaluator-spec.md +137 -0
  59. package/commands/massu-golden-path/references/sprint-contract-protocol.md +117 -0
  60. package/commands/massu-golden-path/references/vr-visual-calibration.md +73 -0
  61. package/commands/massu-golden-path.md +121 -844
  62. package/commands/massu-guide.md +72 -69
  63. package/commands/massu-hooks.md +27 -12
  64. package/commands/massu-hotfix.md +221 -144
  65. package/commands/massu-incident.md +49 -20
  66. package/commands/massu-infra-audit.md +187 -0
  67. package/commands/massu-learning-audit.md +211 -0
  68. package/commands/massu-loop/references/auto-learning.md +49 -0
  69. package/commands/massu-loop/references/checkpoint-audit.md +40 -0
  70. package/commands/massu-loop/references/guardrails.md +17 -0
  71. package/commands/massu-loop/references/iteration-structure.md +115 -0
  72. package/commands/massu-loop/references/loop-controller.md +188 -0
  73. package/commands/massu-loop/references/plan-extraction.md +78 -0
  74. package/commands/massu-loop/references/vr-plan-spec.md +140 -0
  75. package/commands/massu-loop-playwright.md +9 -9
  76. package/commands/massu-loop.md +115 -670
  77. package/commands/massu-new-pattern.md +423 -0
  78. package/commands/massu-perf.md +422 -0
  79. package/commands/massu-plan-audit.md +1 -1
  80. package/commands/massu-plan.md +389 -122
  81. package/commands/massu-production-verify.md +433 -0
  82. package/commands/massu-push.md +62 -378
  83. package/commands/massu-recap.md +29 -3
  84. package/commands/massu-rollback.md +613 -0
  85. package/commands/massu-scaffold-hook.md +2 -4
  86. package/commands/massu-scaffold-page.md +2 -3
  87. package/commands/massu-scaffold-router.md +1 -2
  88. package/commands/massu-security.md +619 -0
  89. package/commands/massu-simplify.md +115 -85
  90. package/commands/massu-squirrels.md +2 -2
  91. package/commands/massu-tdd.md +38 -22
  92. package/commands/massu-test.md +3 -3
  93. package/commands/massu-type-mismatch-audit.md +469 -0
  94. package/commands/massu-ui-audit.md +587 -0
  95. package/commands/massu-verify-playwright.md +287 -32
  96. package/commands/massu-verify.md +150 -46
  97. package/dist/cli.js +146 -95
  98. package/package.json +6 -2
  99. package/patterns/build-patterns.md +302 -0
  100. package/patterns/component-patterns.md +246 -0
  101. package/patterns/display-patterns.md +185 -0
  102. package/patterns/form-patterns.md +890 -0
  103. package/patterns/integration-testing-checklist.md +445 -0
  104. package/patterns/security-patterns.md +219 -0
  105. package/patterns/testing-patterns.md +569 -0
  106. package/patterns/tool-routing.md +81 -0
  107. package/patterns/ui-patterns.md +371 -0
  108. package/protocols/plan-implementation.md +267 -0
  109. package/protocols/recovery.md +225 -0
  110. package/protocols/verification.md +404 -0
  111. package/reference/command-taxonomy.md +178 -0
  112. package/reference/cr-rules-reference.md +76 -0
  113. package/reference/hook-execution-order.md +148 -0
  114. package/reference/lessons-learned.md +175 -0
  115. package/reference/patterns-quickref.md +208 -0
  116. package/reference/standards.md +135 -0
  117. package/reference/subagents-reference.md +17 -0
  118. package/reference/vr-verification-reference.md +867 -0
  119. package/src/commands/install-commands.ts +149 -53
@@ -0,0 +1,170 @@
1
+ # Phase 2.5: Gap & Enhancement Analyzer Loop
2
+
3
+ > Reference doc for `/massu-golden-path`. Return to main file for overview.
4
+
5
+ ```
6
+ [GOLDEN PATH -- PHASE 2.5: GAP & ENHANCEMENT ANALYSIS]
7
+ ```
8
+
9
+ ## Purpose
10
+
11
+ After implementation (Phase 2) completes successfully, run a continuous gap and enhancement analysis loop. This phase catches everything implementation missed: incomplete features, missing edge cases, UX gaps, untested paths, accessibility issues, and enhancement opportunities.
12
+
13
+ **This phase loops until a FULL PASS discovers ZERO gaps/enhancements.**
14
+
15
+ ---
16
+
17
+ ## LOOP CONTROLLER
18
+
19
+ ```
20
+ iteration = 0
21
+ MAX_ITERATIONS = 10
22
+
23
+ WHILE iteration < MAX_ITERATIONS:
24
+ iteration += 1
25
+
26
+ result = Task(subagent_type="gap-analyzer", prompt="
27
+ Gap & Enhancement Analysis — Iteration {iteration}
28
+
29
+ CONTEXT:
30
+ - Plan file: {PLAN_PATH}
31
+ - Implementation is COMPLETE (Phase 2 passed)
32
+ - Your job: find gaps and enhancements the implementation missed
33
+
34
+ INSTRUCTIONS:
35
+ 1. Read the plan from disk
36
+ 2. Read CLAUDE.md and relevant patterns
37
+ 3. Review ALL files changed in this session: git diff origin/main --name-only
38
+ 4. Run the analysis categories below
39
+ 5. For each gap/enhancement found: FIX IT immediately
40
+ 6. Report GAPS_DISCOVERED as total found (even if fixed)
41
+
42
+ ANALYSIS CATEGORIES:
43
+
44
+ A. FUNCTIONAL GAPS
45
+ - Missing error handling (try/catch, error boundaries, toast notifications)
46
+ - Missing loading states (Skeleton, Spinner, disabled buttons during submit)
47
+ - Missing empty states ('No items found' messaging)
48
+ - Missing null guards on nullable fields
49
+ - Missing form validation (required fields, format validation)
50
+ - Incomplete CRUD (create exists but no edit/delete, or vice versa)
51
+
52
+ B. UX GAPS
53
+ - Missing success feedback after mutations (toast.success)
54
+ - Missing confirmation for destructive actions (AlertDialog)
55
+ - Missing keyboard navigation (tabIndex, onKeyDown for Enter)
56
+ - Missing responsive behavior (sm:/md:/lg: breakpoints)
57
+ - Inconsistent spacing (page-container class, gap values)
58
+ - Missing breadcrumbs or navigation context
59
+ - VR-VISUAL weighted score < 3.0 on affected routes
60
+
61
+ C. DATA INTEGRITY GAPS
62
+ - Optimistic updates without rollback
63
+ - Missing query invalidation after mutations
64
+ - Stale data after navigation (missing refetch)
65
+ - Missing pagination for large datasets
66
+ - Unhandled BigInt/Decimal serialization
67
+
68
+ D. SECURITY GAPS
69
+ - Missing protectedProcedure on mutations
70
+ - Missing input validation on router inputs
71
+ - Missing RLS policies on new tables
72
+ - Exposed sensitive data in client responses
73
+
74
+ E. PATTERN COMPLIANCE
75
+ - Run ./scripts/pattern-scanner.sh on changed files
76
+ - Check for pattern violations
77
+ - Check for hardcoded colors (should use design tokens)
78
+
79
+ F. ENHANCEMENT OPPORTUNITIES
80
+ - Type safety improvements (replace 'any' with proper types)
81
+ - Code deduplication (extract shared logic)
82
+ - Performance (unnecessary re-renders, missing useMemo/useCallback)
83
+ - Accessibility (aria-labels, alt text, focus management)
84
+
85
+ G. E2E WIRING GAPS
86
+ - For each data flow in changed files, verify VR-ROUNDTRIP:
87
+ WRITE: mutation/action reachable from UI or cron
88
+ STORE: data persists in a real table
89
+ READ: query reads from that same table
90
+ DISPLAY: component renders the query data (or cron logs output)
91
+ - Background-only features (crons, webhooks): WRITE->STORE->READ sufficient
92
+ - Query-only features (read views): READ->DISPLAY sufficient
93
+
94
+ I. RUNTIME & BOOT VERIFICATION (CR-44, Incident 2026-03-29)
95
+ - For EACH service that was created, modified, or registered in this session:
96
+ 1. VR-DEPS: Verify .venv/bin/python3 exists (if plist references it)
97
+ 2. VR-DEPS: Parse imports from main.py, verify each is installed in the venv
98
+ 3. VR-COMPAT: Check for Python 3.10+ syntax (x | None, match/case) on Python 3.9 systems
99
+ 4. VR-BOOT: Actually start the service (launchctl bootstrap or direct python), wait 5s, verify:
100
+ - Process is still alive (pgrep)
101
+ - Exit code is 0 (launchctl list | grep service)
102
+ - stderr log has no import errors or crashes
103
+ 5. If boot fails: read stderr log, diagnose (missing package? wrong path? syntax error?), fix, retry
104
+ - Skip condition: plan has NO service/daemon/LaunchAgent items
105
+ - This category exists because static verification (VR-SYNTAX, VR-GREP) cannot catch:
106
+ missing venvs, missing pip packages, Python version incompatibilities, or runtime import errors
107
+
108
+ H. SPRINT CONTRACT COMPLIANCE (if contracts exist from Phase 2A.5)
109
+ - Read the sprint contracts from the Phase 2A tracking table
110
+ - For EACH plan item with a sprint contract:
111
+ 1. List all acceptance criteria from the contract
112
+ 2. Verify EACH criterion with specific evidence (grep, screenshot, DOM state, network response)
113
+ 3. Any unmet criterion = GAP (P1 severity minimum)
114
+ - Contract criteria are IN ADDITION TO categories A-G — both must pass
115
+ - Skip condition: items marked `Contract: N/A` in the tracking table
116
+ - If no sprint contracts were negotiated (Phase 2A.5 skipped), skip this category
117
+
118
+ FOR EACH FINDING:
119
+ 1. Classify: GAP (must fix) or ENHANCEMENT (should fix)
120
+ 2. Severity: P0 (broken) / P1 (incorrect) / P2 (polish)
121
+ 3. Fix it immediately
122
+ 4. Verify the fix
123
+
124
+ RETURN STRUCTURED RESULT:
125
+ ```
126
+ GAPS_DISCOVERED: [N]
127
+ ENHANCEMENTS_APPLIED: [N]
128
+ ITEMS_FIXED: [N]
129
+
130
+ | # | Type | Severity | Description | File | Fixed |
131
+ |---|------|----------|-------------|------|-------|
132
+ | 1 | GAP | P0 | Missing error boundary | src/app/.../page.tsx | YES |
133
+ ```
134
+ ")
135
+
136
+ gaps = parse GAPS_DISCOVERED from result
137
+
138
+ IF gaps == 0:
139
+ Output: "Gap analysis clean in iteration {iteration} — zero gaps found"
140
+ BREAK
141
+ ELSE:
142
+ Output: "Iteration {iteration}: {gaps} gaps found and fixed, re-analyzing..."
143
+ CONTINUE
144
+
145
+ IF iteration == MAX_ITERATIONS AND gaps > 0:
146
+ Output: "WARNING: Gap analyzer did not converge after {MAX_ITERATIONS} iterations. {gaps} gaps remain."
147
+ ```
148
+
149
+ ---
150
+
151
+ ## RULES
152
+
153
+ | Rule | Meaning |
154
+ |------|---------|
155
+ | **Fix during analysis** | The analyzer fixes gaps as it finds them, not just reports |
156
+ | **Full re-pass required** | After fixes, a fresh pass must find ZERO to exit |
157
+ | **P0 gaps block** | Any P0 gap that can't be fixed stops the golden path |
158
+ | **Enhancements are mandatory** | Enhancements found MUST be applied (this is golden path, not quick fix) |
159
+ | **Pattern scanner gates** | `./scripts/pattern-scanner.sh` must exit 0 after each iteration |
160
+ | **No new files without reason** | Don't create helper files that aren't needed |
161
+
162
+ ---
163
+
164
+ ## WHEN TO SKIP
165
+
166
+ This phase can be skipped ONLY if:
167
+ - The implementation was documentation-only (no source files changed)
168
+ - User explicitly says "skip gap analysis"
169
+
170
+ Otherwise, it runs automatically as part of the golden path.
@@ -0,0 +1,40 @@
1
+ # Phase 3: Simplification
2
+
3
+ > Reference doc for `/massu-golden-path`. Return to main file for overview.
4
+
5
+ ```
6
+ [GOLDEN PATH -- PHASE 3: SIMPLIFICATION]
7
+ ```
8
+
9
+ ## 3.1 Fast Gate
10
+
11
+ ```bash
12
+ ./scripts/pattern-scanner.sh # Fix ALL violations before semantic analysis
13
+ ```
14
+
15
+ ## 3.1.5 Dead Code Detection
16
+
17
+ ```bash
18
+ npx knip --no-exit-code --reporter compact 2>/dev/null | head -50
19
+ # OR use /massu-dead-code for full analysis
20
+ ```
21
+
22
+ Review output for unused exports, files, and dependencies. Remove dead code before semantic review. Skip if knip is not installed (advisory gate, not blocking).
23
+
24
+ ## 3.2 Parallel Semantic Review (3 Agents)
25
+
26
+ Spawn IN PARALLEL (Principle #20 -- one task per agent):
27
+
28
+ **Efficiency Reviewer** (haiku): Query inefficiency (findMany.length -> SQL COUNT, N+1, unbounded queries), React inefficiency (useState for derived, useEffect->setState, missing useMemo/useCallback), algorithmic inefficiency (O(n^2), repeated sort/filter).
29
+
30
+ **Reuse Reviewer** (haiku): Known utilities (formatFileSize, serializeUnifiedProduct, mergeWhereWithTenant, emptyToNull, PhoneInputField, sanitizeContentHtml), component duplication against src/components/shared/ and ui/, pattern duplication across new files.
31
+
32
+ **Pattern Compliance Reviewer** (haiku): React Query v5 (no onSuccess in useQuery), DB patterns (Object.assign->mergeWhereWithTenant, include:->3-step, BigInt Number()), UI patterns (Select value="", missing states, Suspense), security (z.string()->z.enum() for orderBy, CR-5 precedence, CRON_SECRET guard), architecture (link table scoping, SQL aggregates, client/server boundary).
33
+
34
+ ## 3.3 Apply ALL Findings
35
+
36
+ Sort by SEVERITY (CRITICAL -> LOW). Fix ALL (CR-9). Re-run pattern scanner.
37
+
38
+ ```
39
+ SIMPLIFY_GATE: PASS (N findings, N fixed, 0 remaining)
40
+ ```
@@ -0,0 +1,108 @@
1
+ # Phase 3.5: Deep Security Audit
2
+
3
+ > Reference doc for `/massu-golden-path`. Return to main file for overview.
4
+
5
+ ```
6
+ [GOLDEN PATH -- PHASE 3.5: DEEP SECURITY AUDIT]
7
+ ```
8
+
9
+ ## Purpose
10
+
11
+ Run a full adversarial security audit loop against ALL files changed in this golden path run. This is a deep, iterative audit with parallel red-team agents that converges to zero findings. It runs AFTER simplification (Phase 3) so the audit targets the final, cleaned-up code -- and BEFORE pre-commit verification (Phase 4) so all security fixes are included in the verification gates.
12
+
13
+ **This phase is NEVER skipped.** Security is non-negotiable regardless of change size, type, or scope.
14
+
15
+ ---
16
+
17
+ ## 3.5.1 Determine Audit Scope
18
+
19
+ Collect ALL files changed during this golden path run:
20
+
21
+ ```bash
22
+ git diff --name-only HEAD
23
+ ```
24
+
25
+ If files were already committed in earlier phases, also include:
26
+ ```bash
27
+ git diff --name-only main...HEAD
28
+ ```
29
+
30
+ The audit scope is the union of all changed files. Do NOT narrow scope -- every changed file gets audited.
31
+
32
+ **Output:**
33
+ ```
34
+ SECURITY AUDIT SCOPE:
35
+ Files: [N]
36
+ [list of files]
37
+ ```
38
+
39
+ ---
40
+
41
+ ## 3.5.2 Execute Deep Security Audit
42
+
43
+ Run the full security audit protocol against the scoped files:
44
+
45
+ 1. **Launch 2-4 parallel adversarial reviewer agents** adapted to the codebase area:
46
+ - Backend/API code: 4 agents (Injection, Network/Leakage, DoS/Resources, Red Team Bypass)
47
+ - Frontend code: 3 agents (XSS/Injection, Auth/Data Exposure, Input Validation/Logic)
48
+ - Infrastructure/config: 2 agents (Secrets/Config, Dependencies/Supply Chain)
49
+
50
+ 2. **Consolidate findings** -- deduplicate across agents, take higher severity on disagreements
51
+
52
+ 3. **Fix ALL findings** -- CRITICAL first, then HIGH, MEDIUM, LOW. INFO documented only.
53
+
54
+ 4. **Verify fixes** -- import checks, input validation tests, functionality preserved
55
+
56
+ 5. **Loop until zero findings** -- max 5 iterations, escalate to user if still failing after 5
57
+
58
+ ---
59
+
60
+ ## 3.5.3 Attack Vector Coverage
61
+
62
+ Every audit iteration MUST verify the complete attack vector checklist:
63
+
64
+ ### Universal
65
+ - Hardcoded secrets / API keys / credentials
66
+ - Error messages leaking internal details
67
+ - Dependency vulnerabilities
68
+ - Input validation on ALL external boundaries
69
+
70
+ ### Backend / API
71
+ - SQL injection, command injection, path traversal
72
+ - SSRF, authentication bypass, authorization bypass
73
+ - DoS via unbounded inputs, memory leaks, race conditions
74
+ - Response validation, type confusion
75
+
76
+ ### Frontend
77
+ - XSS, open redirects, sensitive data in client state
78
+ - CSRF, client-side auth bypass
79
+
80
+ ### LLM / AI Specific
81
+ - Prompt injection, model output trust
82
+ - Tool argument injection, vision/multimodal injection
83
+
84
+ ---
85
+
86
+ ## 3.5.4 Completion Gate
87
+
88
+ The phase completes ONLY when the audit loop achieves a clean pass with zero findings.
89
+
90
+ ```
91
+ SECURITY_AUDIT_GATE: PASS
92
+ Iterations: [N]
93
+ Total findings fixed: [N]
94
+ Breakdown: [X] CRITICAL, [X] HIGH, [X] MEDIUM, [X] LOW fixed
95
+ Clean pass: Iteration [N]
96
+ ```
97
+
98
+ **Do NOT proceed to Phase 4 until SECURITY_AUDIT_GATE = PASS.**
99
+
100
+ ---
101
+
102
+ ## Rules
103
+
104
+ 1. **NEVER skip this phase** -- not for small changes, not for docs, not for config
105
+ 2. **NEVER proceed with findings unfixed** -- zero means zero
106
+ 3. **ALL severity levels get fixed** -- CRITICAL through LOW
107
+ 4. **No commit prompt** -- unlike standalone security audit commands, do NOT offer to commit here (Phase 4 handles commits)
108
+ 5. **Findings feed Phase 4** -- security fixes are verified by Phase 4's type check, build, lint, and secrets gates automatically
@@ -0,0 +1,94 @@
1
+ # Phase 4: Pre-Commit Verification
2
+
3
+ > Reference doc for `/massu-golden-path`. Return to main file for overview.
4
+
5
+ ```
6
+ [GOLDEN PATH -- PHASE 4: PRE-COMMIT VERIFICATION]
7
+ ```
8
+
9
+ ## 4.1 Auto-Verification Gates (ALL must pass in SINGLE run)
10
+
11
+ | Gate | Command | Expected |
12
+ |------|---------|----------|
13
+ | 1. Pattern Scanner | `./scripts/pattern-scanner.sh` | Exit 0 |
14
+ | 2. Type Safety (VR-TYPE) | `NODE_OPTIONS="--max-old-space-size=8192" npx tsc --noEmit` | 0 errors |
15
+ | 3. Build (VR-BUILD) | `npm run build` | Exit 0 |
16
+ | 4. Lint | `npm run lint` | Exit 0 |
17
+ | 5. Prisma Validate | `npx prisma validate` | Exit 0 |
18
+ | 6. Secrets Staged | `git diff --cached --name-only \| grep -E '\.(env\|pem\|key\|secret)'` | 0 files |
19
+ | 7. Credentials in Code | `grep -rn "sk-\|password.*=.*['\"]" --include="*.ts" --include="*.tsx" src/ \| grep -v "process.env" \| wc -l` | 0 |
20
+ | 8. Schema Mismatch | Extract tables from staged routers -> query columns via MCP | All exist |
21
+ | 9. VR-RENDER | For EACH staged component: `grep "<ComponentName" src/app/**/page.tsx` | Match found |
22
+ | 9.5. VR-COLOR | `git diff --cached \| grep "text-red-\|bg-green-\|..."` | 0 matches |
23
+ | 9.6. VR-COUPLING | `massu_coupling_check` or `./scripts/check-coupling.sh` | Exit 0 |
24
+ | 10. Plan Coverage | Verify ALL plan items with VR-* proof | 100% |
25
+ | 11. VR-PLAN-STATUS | `grep "IMPLEMENTATION STATUS" [plan]` | Match |
26
+ | 12. Dependency Security | `npm audit --audit-level=high` | 0 high/crit |
27
+ | 13. Test Coverage | Check test files exist for new code | WARN level |
28
+ | 14. VR-VISUAL | `bash scripts/ui-review.sh [route]` (if UI files changed) | VR_VISUAL_STATUS: PASS |
29
+
30
+ For each modified file: `massu_validate_file`, `massu_security_score`, `massu_security_heatmap`. If any file scores > 7/10 risk, flag for review.
31
+
32
+ Spawn `massu-pattern-reviewer` agent for deep CR rule checks, import chain validation, semantic pattern matching.
33
+
34
+ ## 4.2 Database Verification (All Environments)
35
+
36
+ For EACH affected table, query all configured environments via MCP:
37
+
38
+ | Env | MCP Prefix | Verify |
39
+ |-----|-----------|--------|
40
+ | DEV | `mcp__supabase__DEV__execute_sql` | Table, columns, RLS, grants |
41
+ | PROD | `mcp__supabase__PROD__execute_sql` | Table, columns, RLS, grants |
42
+
43
+ VR-DATA: If config-driven features, query actual config values and compare to code expectations.
44
+
45
+ ## 4.3 Help Site Auto-Sync
46
+
47
+ 1. Get staged files -> pass to `massu_docs_audit`
48
+ 2. For STALE/NEW pages: update MDX, set `lastVerified`, add changelog
49
+ 3. Commit to help site repo (separate git)
50
+ 4. Return to main app repo
51
+
52
+ ## 4.4 Quality Scoring Gate
53
+
54
+ Spawn `massu-output-scorer` (sonnet): Code Clarity, Pattern Compliance, Error Handling, UX Quality, Test Coverage (1-5 each). All >= 3: PASS. Any < 3: FAIL.
55
+
56
+ ## 4.5 If ANY Gate Fails
57
+
58
+ **DO NOT PAUSE** -- Fix automatically, re-run ALL gates, repeat until all pass.
59
+
60
+ ## 4.6 Auto-Learning Protocol
61
+
62
+ - For each bug fixed: `massu_memory_ingest` type="bugfix", update MEMORY.md
63
+ - For new patterns: `massu_memory_ingest` type="pattern"
64
+ - Add detection to `scripts/pattern-scanner.sh` if grep-able
65
+ - Codebase-wide search: no other instances of same bad pattern (CR-9)
66
+ - Record user corrections to `memory/corrections.md`
67
+
68
+ ---
69
+
70
+ ## Phase 4 Complete -> APPROVAL POINT #3: COMMIT
71
+
72
+ See `approval-points.md` for the exact format.
73
+
74
+ ### Commit Format
75
+
76
+ ```bash
77
+ git commit -m "$(cat <<'EOF'
78
+ [type]: [description]
79
+
80
+ [Body]
81
+
82
+ Changes:
83
+ - [Change 1]
84
+ - [Change 2]
85
+
86
+ Verified:
87
+ - Pattern scanner: PASS | Type check: 0 errors | Build: PASS
88
+ - DB: All environments verified
89
+ - Help site: UP TO DATE
90
+
91
+ Co-Authored-By: Claude <noreply@anthropic.com>
92
+ EOF
93
+ )"
94
+ ```
@@ -0,0 +1,116 @@
1
+ # Phase 5: Push Verification & Push
2
+
3
+ > Reference doc for `/massu-golden-path`. Return to main file for overview.
4
+
5
+ ```
6
+ [GOLDEN PATH -- PHASE 5: PUSH VERIFICATION]
7
+ ```
8
+
9
+ ## 5.1 Pre-Flight
10
+
11
+ ```bash
12
+ git log origin/main..HEAD --oneline # Commits to push
13
+ ```
14
+
15
+ ## 5.2 Tier 1: Quick Re-Verification
16
+
17
+ Run in parallel where possible:
18
+
19
+ | Check | Command |
20
+ |-------|---------|
21
+ | Pattern Scanner | `./scripts/pattern-scanner.sh` |
22
+ | VR-COUPLING | `./scripts/check-coupling.sh` |
23
+ | VR-UX | `./scripts/check-ux-quality.sh` |
24
+ | TypeScript | `NODE_OPTIONS="--max-old-space-size=8192" npx tsc --noEmit` |
25
+ | Build | `npm run build` |
26
+ | Prisma | `npx prisma validate` |
27
+ | Schema Mismatch | `./scripts/check-schema-mismatches.sh` |
28
+
29
+ ## 5.3 Tier 2: Test Suite (CRITICAL)
30
+
31
+ ### 5.3.0 Regression Detection (MANDATORY FIRST)
32
+
33
+ ```bash
34
+ # Establish baseline on main
35
+ git stash && git checkout main -q
36
+ npm run test:run 2>&1 | tee /tmp/baseline-tests.txt
37
+ git checkout - -q && git stash pop -q
38
+
39
+ # Run on current branch
40
+ npm run test:run 2>&1 | tee /tmp/current-tests.txt
41
+
42
+ # Compare: any test passing on main but failing now = REGRESSION
43
+ # Regressions MUST be fixed before push
44
+ ```
45
+
46
+ ### 5.3.1-5.3.5 Test Execution
47
+
48
+ Use **parallel Task agents** for independent checks:
49
+
50
+ ```
51
+ Agent Group A (parallel):
52
+ - Agent 1: npm run test:run (unit tests)
53
+ - Agent 2: npm audit --audit-level=high
54
+ - Agent 3: npx tsx scripts/detect-secrets.ts
55
+
56
+ Agent Group B (parallel, after A):
57
+ - Agent 1: npm run test:e2e (E2E tests)
58
+ - Agent 2: npm run test:visual:run (visual regression)
59
+
60
+ Sequential:
61
+ - ./scripts/validate-router-contracts.sh
62
+ - VR-RENDER: verify ALL new components rendered in pages
63
+ ```
64
+
65
+ ## 5.4 Tier 3: Security & Compliance
66
+
67
+ | Check | Command |
68
+ |-------|---------|
69
+ | npm audit | `npm audit --audit-level=high` |
70
+ | Secrets scan | `npx tsx scripts/detect-secrets.ts` |
71
+ | Accessibility | `./scripts/verify-accessibility.sh` |
72
+ | DB sync | Verify schema match across all environments |
73
+
74
+ ### VR-STORED-PROC (If migrations in push)
75
+
76
+ ```sql
77
+ SELECT proname, prosrc FROM pg_proc
78
+ JOIN pg_namespace n ON n.oid = pronamespace
79
+ WHERE n.nspname = 'public' AND prosrc LIKE '%old_table_name%';
80
+ -- Run on all environments. Expected: 0 rows.
81
+ ```
82
+
83
+ ### VR-RLS-AUDIT (CR-33)
84
+
85
+ ```sql
86
+ SELECT c.relname FROM pg_class c
87
+ JOIN pg_namespace n ON c.relnamespace = n.oid
88
+ WHERE n.nspname = 'public' AND c.relkind = 'r' AND c.relrowsecurity = false;
89
+ -- Run on all environments. Expected: 0 rows.
90
+ ```
91
+
92
+ ### VR-DATA (Config-Code Alignment)
93
+
94
+ If push includes config-driven features, verify config keys match code expectations.
95
+
96
+ ### Compliance Audit Trail
97
+
98
+ Generate: `massu_audit_log`, `massu_audit_report`, `massu_validation_report`.
99
+
100
+ ## 5.5 Tier 4: Final Gate
101
+
102
+ All tiers must pass:
103
+
104
+ | Tier | Status |
105
+ |------|--------|
106
+ | Tier 1: Quick Checks | PASS/FAIL |
107
+ | Tier 2: Test Suite + Regression | PASS/FAIL |
108
+ | Tier 3: Security & Compliance | PASS/FAIL |
109
+
110
+ ---
111
+
112
+ ## Phase 5 Gate -> APPROVAL POINT #4: PUSH
113
+
114
+ See `approval-points.md` for the exact format.
115
+
116
+ After approval: `git push origin [branch]`, then monitor CI with `./scripts/ci-status.sh --wait --max-wait 300`. If CI fails, auto-run `/massu-ci-fix` protocol.
@@ -0,0 +1,170 @@
1
+ # Phase 5.5: Production Verification
2
+
3
+ > Reference doc for `/massu-golden-path`. Return to main file for overview.
4
+
5
+ ```
6
+ [GOLDEN PATH -- PHASE 5.5: PRODUCTION VERIFICATION]
7
+ ```
8
+
9
+ **Core Principle**: A feature is NOT complete until it is verified working in production with real data. "Deployed" and "working" are two completely different things.
10
+
11
+ ---
12
+
13
+ ## 5.5.1 Wait for Deployment
14
+
15
+ After push and CI success, verify the deployment landed:
16
+
17
+ ```bash
18
+ # Check Vercel deployment status via MCP
19
+ # list_deployments — confirm latest is READY state
20
+ # get_runtime_logs — check for startup errors
21
+ ```
22
+
23
+ If deployment failed or errored: diagnose, fix, and re-push (loop back to Phase 5).
24
+
25
+ ---
26
+
27
+ ## 5.5.2 Auto-Detect Changed Routes
28
+
29
+ Before categorizing, auto-detect which production routes were affected:
30
+
31
+ ```bash
32
+ # Extract changed app routes from git diff
33
+ git diff origin/main --name-only -- 'src/app/' | grep -E 'page\.tsx|route\.ts' | \
34
+ sed 's|src/app/||; s|/page\.tsx||; s|/route\.ts||; s|\[([^]]*)\]|:$1|g'
35
+
36
+ # Extract changed routers (for API verification)
37
+ git diff origin/main --name-only -- 'src/server/api/routers/' | \
38
+ sed 's|src/server/api/routers/||; s|\.ts||'
39
+
40
+ # Extract changed cron jobs
41
+ git diff origin/main --name-only -- 'src/app/api/cron/'
42
+ ```
43
+
44
+ Each detected route becomes a verification target. UI routes get Playwright checks, API routers get data-flow checks, crons get deferred verification entries.
45
+
46
+ ---
47
+
48
+ ## 5.5.3 Categorize Verifications
49
+
50
+ Review ALL plan items and changed files. Categorize each into:
51
+
52
+ | Category | Timing | Examples |
53
+ |----------|--------|---------|
54
+ | **Immediate** | Verify now | UI pages, API endpoints, DB schema+data, feature flags, env vars |
55
+ | **Deferred** | Verify later | Cron jobs (wait for cycle), webhooks (wait for trigger), external API syncs, email delivery |
56
+
57
+ Build a verification matrix:
58
+
59
+ ```markdown
60
+ | # | Feature/Change | Category | Method | Expected Result | Status |
61
+ |---|----------------|----------|--------|-----------------|--------|
62
+ | PV-001 | [desc] | Immediate | Playwright | Page loads, data visible | PENDING |
63
+ | PV-002 | [desc] | Immediate | DB query (PROD) | Row count > 0 | PENDING |
64
+ | DV-001 | [desc] | Deferred | DB query after cron | New rows after deploy | PENDING |
65
+ ```
66
+
67
+ ---
68
+
69
+ ## 5.5.4 Run Immediate Verifications
70
+
71
+ For each immediate item, verify with proof:
72
+
73
+ ### UI Changes
74
+ Use Playwright MCP against production URL:
75
+ 1. `browser_navigate` to production page
76
+ 2. `browser_snapshot` — verify renders correctly
77
+ 3. `browser_console_messages` — check for JS errors
78
+ 4. `browser_click` / `browser_fill_form` — test interactions
79
+ 5. Verify data displays (not empty, not placeholder, not "undefined")
80
+
81
+ ### API/tRPC Changes
82
+ - Hit production endpoints or navigate to pages that use them
83
+ - Verify data loads and mutations work
84
+
85
+ ### Database Changes
86
+ Query PROD (`mcp__supabase__PROD__execute_sql`):
87
+ ```sql
88
+ -- Verify data flows, not just schema
89
+ SELECT COUNT(*), MAX(created_at) FROM [table]
90
+ WHERE created_at > '[deploy_timestamp]';
91
+ ```
92
+
93
+ ### Feature Flags / Config
94
+ ```sql
95
+ -- Verify flags are set correctly
96
+ SELECT key, enabled FROM feature_flags WHERE key IN ('[flags]');
97
+ ```
98
+
99
+ ### Integration Chains
100
+ Trace the full chain: trigger -> process -> store -> display
101
+
102
+ ```markdown
103
+ | Step | System | Verification | Status |
104
+ |------|--------|-------------|--------|
105
+ | Trigger | [source] | [how verified] | PASS/FAIL |
106
+ | Process | [handler] | [how verified] | PASS/FAIL |
107
+ | Store | [database] | [query result] | PASS/FAIL |
108
+ | Display | [UI page] | [screenshot] | PASS/FAIL |
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 5.5.5 Generate Deferred Checklist
114
+
115
+ For items that can't be verified immediately, write to `session-state/deferred-verifications.md`:
116
+
117
+ ```markdown
118
+ # Deferred Production Verifications
119
+
120
+ **Generated**: [YYYY-MM-DD HH:MM PST]
121
+ **Deploy Commit**: [hash]
122
+ **Feature**: [name]
123
+
124
+ ## Pending
125
+
126
+ ### DV-001: [Description]
127
+ - **Type**: Cron / Webhook / External API / Background Job
128
+ - **Expected By**: [YYYY-MM-DD HH:MM PST]
129
+ - **Query**:
130
+ ```sql
131
+ SELECT COUNT(*) FROM [table] WHERE [condition] AND created_at > '[deploy_time]';
132
+ ```
133
+ - **Expected Result**: [specific condition]
134
+ - **Status**: PENDING
135
+ ```
136
+
137
+ These are surfaced by `/massu-bearings` in the next session and verified by `/massu-production-verify --deferred`.
138
+
139
+ ---
140
+
141
+ ## 5.5.6 Phase 5.5 Gate
142
+
143
+ | Condition | Result |
144
+ |-----------|--------|
145
+ | All immediate verifications PASS, no deferred items | **PRODUCTION VERIFIED** — proceed to Phase 6 |
146
+ | All immediate verifications PASS, deferred items exist | **VERIFIED + DEFERRED** — proceed to Phase 6, deferred items tracked |
147
+ | Any immediate verification FAILS | **BLOCKED** — diagnose, fix, re-push, re-verify |
148
+
149
+ **If BLOCKED**: Loop back. Fix the issue, commit, push (Phase 5 again), then re-run Phase 5.5.
150
+
151
+ ---
152
+
153
+ ## 5.5.7 Report Format
154
+
155
+ ```
156
+ PHASE 5.5: PRODUCTION VERIFICATION
157
+ --------------------------------------------------------------------------
158
+ Deploy: [hash] — READY on Vercel
159
+ Production URL: [url]
160
+
161
+ Immediate Verifications: [X]/[Y] PASSED
162
+ PV-001: [feature] — PASS (proof: [detail])
163
+ PV-002: [feature] — PASS (proof: [detail])
164
+
165
+ Deferred Verifications: [N] pending
166
+ DV-001: [feature] — check after [time] (saved to deferred-verifications.md)
167
+
168
+ Status: VERIFIED / VERIFIED + DEFERRED / BLOCKED
169
+ --------------------------------------------------------------------------
170
+ ```