@massu/core 0.5.0 → 0.6.0

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 (118) 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 +52 -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 +397 -0
  51. package/commands/massu-golden-path/references/phase-2.5-gap-analyzer.md +156 -0
  52. package/commands/massu-golden-path/references/phase-3-simplify.md +40 -0
  53. package/commands/massu-golden-path/references/phase-4-commit.md +94 -0
  54. package/commands/massu-golden-path/references/phase-5-push.md +116 -0
  55. package/commands/massu-golden-path/references/phase-5.5-production-verify.md +170 -0
  56. package/commands/massu-golden-path/references/phase-6-completion.md +113 -0
  57. package/commands/massu-golden-path/references/qa-evaluator-spec.md +137 -0
  58. package/commands/massu-golden-path/references/sprint-contract-protocol.md +117 -0
  59. package/commands/massu-golden-path/references/vr-visual-calibration.md +73 -0
  60. package/commands/massu-golden-path.md +114 -848
  61. package/commands/massu-guide.md +72 -69
  62. package/commands/massu-hooks.md +27 -12
  63. package/commands/massu-hotfix.md +221 -144
  64. package/commands/massu-incident.md +49 -20
  65. package/commands/massu-infra-audit.md +187 -0
  66. package/commands/massu-learning-audit.md +211 -0
  67. package/commands/massu-loop/references/auto-learning.md +49 -0
  68. package/commands/massu-loop/references/checkpoint-audit.md +40 -0
  69. package/commands/massu-loop/references/guardrails.md +17 -0
  70. package/commands/massu-loop/references/iteration-structure.md +115 -0
  71. package/commands/massu-loop/references/loop-controller.md +188 -0
  72. package/commands/massu-loop/references/plan-extraction.md +78 -0
  73. package/commands/massu-loop/references/vr-plan-spec.md +140 -0
  74. package/commands/massu-loop-playwright.md +9 -9
  75. package/commands/massu-loop.md +115 -670
  76. package/commands/massu-new-pattern.md +423 -0
  77. package/commands/massu-perf.md +422 -0
  78. package/commands/massu-plan-audit.md +1 -1
  79. package/commands/massu-plan.md +389 -122
  80. package/commands/massu-production-verify.md +433 -0
  81. package/commands/massu-push.md +62 -378
  82. package/commands/massu-recap.md +29 -3
  83. package/commands/massu-rollback.md +613 -0
  84. package/commands/massu-scaffold-hook.md +2 -4
  85. package/commands/massu-scaffold-page.md +2 -3
  86. package/commands/massu-scaffold-router.md +1 -2
  87. package/commands/massu-security.md +619 -0
  88. package/commands/massu-simplify.md +115 -85
  89. package/commands/massu-squirrels.md +2 -2
  90. package/commands/massu-tdd.md +38 -22
  91. package/commands/massu-test.md +3 -3
  92. package/commands/massu-type-mismatch-audit.md +469 -0
  93. package/commands/massu-ui-audit.md +587 -0
  94. package/commands/massu-verify-playwright.md +287 -32
  95. package/commands/massu-verify.md +150 -46
  96. package/dist/cli.js +146 -95
  97. package/package.json +6 -2
  98. package/patterns/build-patterns.md +302 -0
  99. package/patterns/component-patterns.md +246 -0
  100. package/patterns/display-patterns.md +185 -0
  101. package/patterns/form-patterns.md +890 -0
  102. package/patterns/integration-testing-checklist.md +445 -0
  103. package/patterns/security-patterns.md +219 -0
  104. package/patterns/testing-patterns.md +569 -0
  105. package/patterns/tool-routing.md +81 -0
  106. package/patterns/ui-patterns.md +371 -0
  107. package/protocols/plan-implementation.md +267 -0
  108. package/protocols/recovery.md +225 -0
  109. package/protocols/verification.md +404 -0
  110. package/reference/command-taxonomy.md +178 -0
  111. package/reference/cr-rules-reference.md +76 -0
  112. package/reference/hook-execution-order.md +148 -0
  113. package/reference/lessons-learned.md +175 -0
  114. package/reference/patterns-quickref.md +208 -0
  115. package/reference/standards.md +135 -0
  116. package/reference/subagents-reference.md +17 -0
  117. package/reference/vr-verification-reference.md +867 -0
  118. package/src/commands/install-commands.ts +149 -53
@@ -1,66 +1,53 @@
1
1
  ---
2
2
  name: massu-golden-path
3
- description: Complete end-to-end workflow from requirements to production push with minimal pause points
3
+ description: "When user wants full autonomous implementation: 'build this', 'implement this feature', 'golden path', or provides a plan file to execute end-to-end"
4
4
  allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*), Task(*), mcp__plugin_playwright_playwright__*, mcp__playwright__*
5
5
  ---
6
6
  name: massu-golden-path
7
7
 
8
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9 enforced.
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-12, CR-9 enforced.
9
9
 
10
10
  # Massu Golden Path: Requirements to Production Push
11
11
 
12
12
  ## Objective
13
13
 
14
14
  Execute the COMPLETE development workflow in one continuous run:
15
- **Requirements --> Plan Creation --> Plan Audit --> Implementation --> Browser Verification --> Simplification --> Commit --> Push**
15
+ **Requirements -> Plan Creation -> Plan Audit -> Implementation -> Gap Analysis -> Simplification -> Commit -> Push**
16
16
 
17
17
  This command has FULL FEATURE PARITY with the individual commands it replaces:
18
- `/massu-create-plan` --> `/massu-plan` --> `/massu-loop` --> `/massu-loop-playwright` --> `/massu-simplify` --> `/massu-commit` --> `/massu-push`
18
+ `/massu-create-plan` -> `/massu-plan` -> `/massu-loop` -> `/massu-loop-playwright` -> `/massu-simplify` -> `/massu-commit` -> `/massu-push`
19
19
 
20
20
  ---
21
21
 
22
22
  ## NON-NEGOTIABLE RULES
23
23
 
24
- - **Complete workflow** -- ALL phases must execute, no skipping
24
+ - **Complete workflow (CR-11)** -- ALL phases must execute, no skipping. 100% plan coverage required
25
25
  - **Zero failures** -- Each phase gate must pass before proceeding
26
- - **Proof required** -- Show output of each phase gate
26
+ - **Proof required (CR-1)** -- VR-* output pasted, not summarized. "I verified" without output = invalid
27
27
  - **FIX ALL ISSUES ENCOUNTERED (CR-9)** -- Whether from current changes or pre-existing
28
28
  - **MEMORY IS MANDATORY (CR-38)** -- Persist ALL learnings before session ends
29
+ - **Stagnation bail-out (CR-37)** -- If same item fails 3+ times, replan instead of grinding
29
30
 
30
31
  ---
31
32
 
32
- ## APPROVAL POINTS (Max 4 Pauses)
33
+ ## APPROVAL POINTS (Max 4 Pauses, 5 with --competitive)
33
34
 
34
35
  ```
35
36
  +-----------------------------------------------------------------------------+
36
37
  | THIS COMMAND RUNS STRAIGHT THROUGH THE ENTIRE GOLDEN PATH. |
37
- | IT ONLY PAUSES FOR THESE APPROVAL POINTS: |
38
- | |
39
- | 1. PLAN APPROVAL - After plan creation + audit (user reviews plan) |
40
- | 2. NEW PATTERN APPROVAL - If a new pattern is needed (during any phase) |
41
- | 3. COMMIT APPROVAL - Before creating the commit |
42
- | 4. PUSH APPROVAL - Before pushing to remote |
43
- | |
38
+ | IT ONLY PAUSES FOR THESE APPROVAL POINTS: |
39
+ | |
40
+ | 1. PLAN APPROVAL - After plan creation + audit (user reviews plan) |
41
+ | 2. NEW PATTERN APPROVAL - If a new pattern is needed (during any phase) |
42
+ | 3. COMMIT APPROVAL - Before creating the commit |
43
+ | 4. PUSH APPROVAL - Before pushing to remote |
44
+ | 5. WINNER SELECTION - After competitive scoring (--competitive only) |
45
+ | |
44
46
  | EVERYTHING ELSE RUNS AUTOMATICALLY WITHOUT STOPPING. |
45
47
  +-----------------------------------------------------------------------------+
46
48
  ```
47
49
 
48
- ### Approval Point Format
49
-
50
- ```
51
- ===============================================================================
52
- APPROVAL REQUIRED: [TYPE]
53
- ===============================================================================
54
-
55
- [Details]
56
-
57
- OPTIONS:
58
- - "approve" / "yes" to continue
59
- - "modify" to request changes
60
- - "abort" to stop the golden path
61
-
62
- ===============================================================================
63
- ```
50
+ Read `references/approval-points.md` for the exact format and options for each approval point.
64
51
 
65
52
  After receiving approval, immediately continue. Do NOT ask "shall I continue?" -- just proceed.
66
53
 
@@ -73,888 +60,165 @@ After receiving approval, immediately continue. Do NOT ask "shall I continue?" -
73
60
  | **Task Description** | `/massu-golden-path "Implement feature X"` | Full flow from Phase 0 |
74
61
  | **Plan File** | `/massu-golden-path /path/to/plan.md` | Skip to Phase 1C (audit) |
75
62
  | **Continue** | `/massu-golden-path "Continue [feature]"` | Resume from session state |
63
+ | **Competitive** | `/massu-golden-path --competitive "task"` | Spawn 2-3 competing implementations with bias presets, score, select winner |
64
+ | **Competitive (3 agents)** | `/massu-golden-path --competitive --agents 3 "task"` | 3 agents with quality/ux/robust biases (default: 2 agents = quality + robust) |
65
+ | **External Loop** | `/massu-golden-path --external /path/to/plan.md` | Phase 2 uses `scripts/loop-external.sh` for context-fresh iterations |
76
66
 
77
67
  ---
78
68
 
79
- ## PHASE 0: REQUIREMENTS & CONTEXT LOADING
80
-
81
- ### 0.1 Session Context Loading
82
-
83
- ```
84
- [GOLDEN PATH -- PHASE 0: REQUIREMENTS & CONTEXT]
85
- ```
69
+ ## PHASE OVERVIEW
86
70
 
87
- - Read `session-state/CURRENT.md` for any prior state
88
- - Read `massu.config.yaml` for project configuration
89
- - Search memory files for relevant prior context
90
-
91
- ### 0.2 Requirements Coverage Map
92
-
93
- Initialize ALL dimensions as `pending`:
94
-
95
- | # | Dimension | Status | Resolved By |
96
- |---|-----------|--------|-------------|
97
- | D1 | Problem & Scope | pending | User request + interview |
98
- | D2 | Users & Personas | pending | Interview |
99
- | D3 | Data Model | pending | Phase 1A (Config/Schema Reality Check) |
100
- | D4 | Backend / API | pending | Phase 1A (Codebase Reality Check) |
101
- | D5 | Frontend / UX | pending | Interview + Phase 1A |
102
- | D6 | Auth & Permissions | pending | Phase 1A (Security Pre-Screen) |
103
- | D7 | Error Handling | pending | Phase 1A (Pattern Compliance) |
104
- | D8 | Security | pending | Phase 1A (Security Pre-Screen) |
105
- | D9 | Edge Cases | pending | Phase 1A (Question Filtering) |
106
- | D10 | Performance | pending | Phase 1A (Pattern Compliance) |
107
-
108
- ### 0.3 Ambiguity Detection (7 Signals)
109
-
110
- | Signal | Description |
111
- |--------|-------------|
112
- | A1 | Vague scope -- no clear boundary |
113
- | A2 | No success criteria -- no measurable outcome |
114
- | A3 | Implicit requirements -- unstated but necessary |
115
- | A4 | Multi-domain -- spans 3+ domains |
116
- | A5 | Contradictions -- conflicting constraints |
117
- | A6 | No persona -- unclear who benefits |
118
- | A7 | New integration -- external service not yet in codebase |
119
-
120
- **Score >= 2**: Enter interview loop (0.4). **Score 0-1**: Fast-track to Phase 1A.
121
-
122
- ### 0.4 Interview Loop (When Triggered)
123
-
124
- Ask via AskUserQuestion, one question at a time:
125
- 1. Show compact coverage status: `Coverage: D1:done D2:pending ...`
126
- 2. Provide 2-4 curated options (never open-ended)
127
- 3. Push back on contradictions and over-engineering
128
- 4. Self-terminate when D1, D2, D5 covered
129
- 5. Escape hatch: user says "skip" / "enough" / "just do it" --> mark remaining as `n/a`
71
+ | Phase | Name | Key Actions | Approval Gate |
72
+ |-------|------|-------------|---------------|
73
+ | 0 | Requirements & Context | Session context, ambiguity detection, interview loop | -- |
74
+ | 1 | Plan Creation & Audit | Research, plan generation, audit loop | PLAN APPROVAL |
75
+ | 2 | Implementation | Item loop, multi-perspective review, verification audit, browser testing | NEW PATTERN (if needed) |
76
+ | 2-COMP | Competitive Implementation | Spawn N agents with bias presets, score, select winner (`--competitive` only) | WINNER SELECTION |
77
+ | 2.5 | Gap & Enhancement Analysis | Find+fix gaps, UX issues, security, pattern compliance; loop until zero | -- |
78
+ | 3 | Simplification | Pattern scanner, parallel semantic review, apply findings | -- |
79
+ | 4 | Pre-Commit Verification | Verification gates, quality scoring | COMMIT APPROVAL |
80
+ | 5 | Push Verification | `scripts/push-verify.sh`, CI monitoring via `scripts/ci-status.sh` | PUSH APPROVAL |
81
+ | 6 | Completion | Final report, plan update, auto-learning, feature registration | -- |
130
82
 
131
83
  ---
132
84
 
133
- ## PHASE 1: PLAN CREATION & AUDIT
134
-
135
- ### Phase 1A: Research & Reality Check
136
-
137
- ```
138
- [GOLDEN PATH -- PHASE 1A: RESEARCH & REALITY CHECK]
139
- ```
140
-
141
- **If plan file was provided**: Skip to Phase 1C.
142
-
143
- #### 1A.1 Feature Understanding
144
-
145
- - Document: exact user request, feature type, affected domains
146
- - Search codebase for similar features, tool modules, existing patterns
147
- - Read `massu.config.yaml` for relevant config sections
148
-
149
- #### 1A.2 Config & Schema Reality Check
150
-
151
- For features touching config or databases:
152
-
153
- - Parse `massu.config.yaml` and verify all referenced config keys exist
154
- - Check SQLite schema for affected tables (`getCodeGraphDb`, `getDataDb`, `getMemoryDb`)
155
- - Verify tool definitions in `tools.ts` for any tools being modified
156
-
157
- Document: existing config keys, required new keys, required schema changes.
158
-
159
- #### 1A.3 Config-Code Alignment (VR-CONFIG)
160
-
161
- If feature uses config-driven values:
162
-
163
- ```bash
164
- # Check config keys used in code
165
- grep -rn "getConfig()" packages/core/src/ | grep -oP 'config\.\w+' | sort -u
166
- # Compare to massu.config.yaml structure
167
- ```
168
-
169
- #### 1A.4 Codebase Reality Check
170
-
171
- - Verify target directories/files exist
172
- - Read similar tool modules and handlers
173
- - Load relevant pattern files (build/testing/security/database/mcp)
174
-
175
- #### 1A.5 Blast Radius Analysis (CR-10)
176
-
177
- **MANDATORY when plan changes any constant, export name, config key, or tool name.**
178
-
179
- 1. Identify ALL changed values (old --> new)
180
- 2. Codebase-wide grep for EACH value
181
- 3. If plan deletes files: verify no remaining imports or references
182
- 4. Categorize EVERY occurrence: CHANGE / KEEP (with reason) / INVESTIGATE
183
- 5. Resolve ALL INVESTIGATE to 0. Add ALL CHANGE items as plan deliverables.
184
-
185
- #### 1A.6 Pattern Compliance Check
186
-
187
- Check applicable patterns: ESM imports (.ts extensions), config access (getConfig()), tool registration (3-function pattern), hook compilation (esbuild), SQLite DB access (getCodeGraphDb/getDataDb/getMemoryDb), memDb lifecycle (try/finally close).
188
-
189
- Read most similar tool module for patterns used.
190
-
191
- #### 1A.7 Tool Registration Check (CR-11)
192
-
193
- For EVERY new MCP tool planned -- verify a corresponding registration item exists in the plan (definitions + routing + handler in `tools.ts`). If NOT, ADD IT.
194
-
195
- #### 1A.8 Question Filtering
196
-
197
- 1. List all open questions
198
- 2. Self-answer anything answerable by reading code or config
199
- 3. Surface only business logic / UX / scope / priority questions to user via AskUserQuestion
200
- 4. If all self-answerable, skip user prompt
201
-
202
- #### 1A.9 Security Pre-Screen (5 Dimensions)
203
-
204
- | Dim | Check | If Triggered |
205
- |-----|-------|-------------|
206
- | S1 | PII / Sensitive Data | Add access controls |
207
- | S2 | Authentication | Verify auth checks |
208
- | S3 | Authorization | Add permission checks |
209
- | S4 | Injection Surfaces | Add input validation, parameterized queries |
210
- | S5 | Rate Limiting | Add rate limiting considerations |
211
-
212
- **BLOCKS_REMAINING must = 0 before proceeding.**
213
-
214
- Mark all coverage dimensions as `done` or `n/a`.
215
-
216
- ### Phase 1B: Plan Generation
217
-
218
- ```
219
- [GOLDEN PATH -- PHASE 1B: PLAN GENERATION]
220
- ```
221
-
222
- Write plan to: `docs/plans/[YYYY-MM-DD]-[feature-name].md`
223
-
224
- **Plan structure** (P-XXX numbered items):
225
- - Overview (feature, complexity, domains, item count)
226
- - Requirements Coverage Map (D1-D10 all resolved)
227
- - Phase 1: Configuration Changes (massu.config.yaml)
228
- - Phase 2: Backend Implementation (tool modules, handlers, SQLite schema)
229
- - Phase 3: Frontend/Hook Implementation (hooks, plugin code)
230
- - Phase 4: Testing & Verification
231
- - Phase 5: Documentation
232
- - Verification Commands table
233
- - Item Summary table
234
- - Risk Assessment
235
- - Dependencies
236
-
237
- **Item numbering**: P1-XXX (config), P2-XXX (backend), P3-XXX (frontend/hooks), P4-XXX (testing), P5-XXX (docs).
85
+ ## PHASE 0: REQUIREMENTS & CONTEXT LOADING
238
86
 
239
- **Implementation Specificity Check**: Every item MUST have exact file path, exact content, insertion point, format matches target, verification command.
87
+ Read `references/phase-0-requirements.md` for full details.
240
88
 
241
- ### Phase 1C: Plan Audit Loop
89
+ **Summary**: Load session context via memory tools. Build a 10-dimension requirements coverage map (D1-D10). Run ambiguity detection (7 signals). If ambiguity score >= 2, enter interview loop. Fast-track to Phase 1 when D1, D2, D5 covered or user says "skip" / "just do it".
242
90
 
243
- ```
244
- [GOLDEN PATH -- PHASE 1C: PLAN AUDIT LOOP]
245
- ```
246
-
247
- Run audit loop using subagent architecture (prevents early termination):
91
+ ---
248
92
 
249
- ```
250
- iteration = 0
251
- WHILE true:
252
- iteration += 1
253
-
254
- result = Task(subagent_type="massu-plan-auditor", model="opus", prompt="
255
- Audit iteration {iteration} for plan: {PLAN_PATH}
256
- Execute ONE complete audit pass. Verify ALL deliverables.
257
- Check: VR-PLAN-FEASIBILITY, VR-PLAN-SPECIFICITY, Pattern Alignment, Config Reality.
258
- Fix any plan document gaps you find.
259
-
260
- CRITICAL: Report GAPS_DISCOVERED as total gaps FOUND, EVEN IF you fixed them.
261
- Finding N gaps and fixing all N = GAPS_DISCOVERED: N.
262
- A clean pass finding nothing = GAPS_DISCOVERED: 0.
263
- ")
264
-
265
- gaps = parse GAPS_DISCOVERED from result
266
- IF gaps == 0: BREAK (clean pass)
267
- ELSE: CONTINUE (re-audit)
268
-
269
- IF iteration >= 10: Report to user, ask how to proceed
270
- END WHILE
271
- ```
93
+ ## PHASE 1: PLAN CREATION & AUDIT
272
94
 
273
- **VR-PLAN-FEASIBILITY**: Files exist, config keys valid, dependencies available, patterns documented.
274
- **VR-PLAN-SPECIFICITY**: Every item has exact path, exact content, insertion point, verification command.
275
- **Pattern Alignment**: Cross-reference ALL applicable patterns from CLAUDE.md and patterns/*.md.
95
+ Read `references/phase-1-plan-creation.md` for full details.
276
96
 
277
- ### Phase 1 Complete --> APPROVAL POINT #1: PLAN
97
+ **Summary**: Three sub-phases:
98
+ - **1A: Research & Reality Check** -- Feature understanding, codebase check, blast radius analysis (CR-25), pattern compliance, backend-frontend coupling (CR-12), question filtering, security pre-screen (6 dimensions).
99
+ - **1B: Plan Generation** -- Write plan to `docs/plans/[YYYY-MM-DD]-[feature-name].md` with P-XXX numbered items across 6 phases.
100
+ - **1C: Plan Audit Loop** -- Subagent architecture. Iterate until GAPS_DISCOVERED = 0. Max 10 iterations.
278
101
 
279
- ```
280
- ===============================================================================
281
- APPROVAL REQUIRED: PLAN
282
- ===============================================================================
283
-
284
- Plan created and audited ({iteration} audit passes, 0 gaps).
285
-
286
- PLAN SUMMARY:
287
- -------------------------------------------------------------------------------
288
- Feature: [name]
289
- File: [plan path]
290
- Total Items: [N]
291
- Phases: [list]
292
-
293
- Requirements Coverage: [X]/10 dimensions resolved
294
- Feasibility: VERIFIED (config, files, patterns, security)
295
- Audit Passes: {iteration} (final pass: 0 gaps)
296
- -------------------------------------------------------------------------------
297
-
298
- OPTIONS:
299
- - "approve" to begin implementation
300
- - "modify: [changes]" to adjust plan
301
- - "abort" to stop
302
-
303
- ===============================================================================
304
- ```
102
+ **Gate**: APPROVAL POINT #1: PLAN
305
103
 
306
104
  ---
307
105
 
308
106
  ## PHASE 2: IMPLEMENTATION
309
107
 
310
- ### Phase 2A: Plan Item Extraction & Setup
311
-
312
- ```
313
- [GOLDEN PATH -- PHASE 2: IMPLEMENTATION]
314
- ```
315
-
316
- 1. Read plan from disk (NOT memory -- CR-5)
317
- 2. Extract ALL deliverables into tracking table:
318
-
319
- | Item # | Type | Description | Location | Verification | Status |
320
- |--------|------|-------------|----------|--------------|--------|
321
- | P1-001 | CONFIG | ... | ... | VR-CONFIG | PENDING |
322
-
323
- 3. Create VR-PLAN verification strategy:
324
-
325
- | # | VR-* Check | Target | Why Applicable | Status |
326
- |---|-----------|--------|----------------|--------|
327
- | 1 | VR-BUILD | Full project | Always | PENDING |
328
-
329
- 4. Initialize session state with AUTHORIZED_COMMAND: massu-golden-path
330
-
331
- ### Phase 2B: Implementation Loop
332
-
333
- For each plan item:
334
- 1. **Pre-check**: Verify file exists, read current state
335
- 2. **Execute**: Implement the item following established patterns
336
- 3. **Guardrail**: Run `bash scripts/massu-pattern-scanner.sh` (ABORT if fails)
337
- 4. **Verify**: Run applicable VR-* checks with proof
338
- 5. **Update**: Mark item complete in tracking table
339
-
340
- **DO NOT STOP between items** unless:
341
- - New pattern needed (Approval Point #2)
342
- - True blocker (external service, credentials)
343
- - Critical error after 3 retries
344
-
345
- **Checkpoint Audit at phase boundaries** (after all P1-XXX, after all P2-XXX, etc.):
346
-
347
- ```
348
- CHECKPOINT:
349
- [1] READ plan section [2] GREP tool registrations [3] LS modules
350
- [4] VR-CONFIG check [5] VR-TOOL-REG check [6] VR-HOOK-BUILD check
351
- [7] Pattern scanner [8] npm run build [9] cd packages/core && npx tsc --noEmit
352
- [10] npm test [11] VR-GENERIC check [12] Security scanner
353
- [13] COUNT gaps --> IF > 0: FIX and return to [1]
354
- ```
355
-
356
- ### Phase 2C: Multi-Perspective Review
357
-
358
- After implementation, BEFORE verification loop -- spawn 3 review agents **IN PARALLEL**:
359
-
360
- ```
361
- security_result = Task(subagent_type="massu-security-reviewer", model="opus", prompt="
362
- Review implementation for plan: {PLAN_PATH}
363
- Focus: Security vulnerabilities, auth gaps, input validation, data exposure.
364
- Return structured result with SECURITY_GATE: PASS/FAIL.
365
- ")
366
-
367
- architecture_result = Task(subagent_type="massu-architecture-reviewer", model="opus", prompt="
368
- Review implementation for plan: {PLAN_PATH}
369
- Focus: Design issues, coupling, pattern compliance, scalability.
370
- Return structured result with ARCHITECTURE_GATE: PASS/FAIL.
371
- ")
372
-
373
- quality_result = Task(subagent_type="massu-quality-reviewer", model="sonnet", prompt="
374
- Review implementation for plan: {PLAN_PATH}
375
- Focus: Code quality, ESM compliance, config-driven patterns, TypeScript strict mode, test coverage.
376
- Return structured result with QUALITY_GATE: PASS/FAIL.
377
- ")
378
- ```
379
-
380
- Fix ALL CRITICAL/HIGH findings before proceeding. WARN findings = document and proceed.
381
-
382
- ### Phase 2D: Verification Audit Loop
383
-
384
- ```
385
- iteration = 0
386
- WHILE true:
387
- iteration += 1
388
-
389
- # Circuit breaker (CR-37)
390
- IF iteration >= 3 AND same gaps as previous iteration:
391
- AskUserQuestion: "Loop stalled after {iteration} passes. Re-plan / Continue / Stop?"
392
-
393
- result = Task(subagent_type="massu-plan-auditor", model="opus", prompt="
394
- Audit iteration {iteration} for plan: {PLAN_PATH}
395
- Verify ALL deliverables with VR-* proof.
396
- Check code quality (patterns, build, types, tests).
397
- Check plan coverage (every item verified).
398
- Fix any gaps you find.
399
-
400
- CRITICAL: GAPS_DISCOVERED = total FOUND, even if fixed.
401
- Finding 5 + fixing 5 = GAPS_DISCOVERED: 5 (NOT 0).
402
- ")
403
-
404
- gaps = parse GAPS_DISCOVERED from result
405
- Output: "Verification iteration {iteration}: {gaps} gaps"
406
-
407
- IF gaps == 0: BREAK
408
- IF iteration >= 10: Report remaining gaps, ask user
409
- END WHILE
410
- ```
411
-
412
- ### Phase 2E: Post-Build Reflection + Memory Persist (CR-38)
413
-
414
- **MANDATORY -- reflection + memory write = ONE atomic action.**
415
-
416
- Answer these questions:
417
- 1. "Now that I've built this, what would I have done differently?"
418
- 2. "What should be refactored before moving on?"
419
- 3. "Did we over-build? Is there a simpler way?"
420
- 4. "Would a staff engineer approve this?" (Core Principle #9)
421
-
422
- **IMMEDIATELY write ALL learnings to memory/ files** -- failed approaches, new patterns, tool gotchas, architectural insights. DO NOT output reflections as text without writing to memory.
423
-
424
- Apply any low-risk refactors immediately. Log remaining suggestions in plan under `## Post-Build Reflection`.
425
-
426
- ### Phase 2F: Documentation Sync (User-Facing Features)
427
-
428
- If plan includes ANY user-facing features (new MCP tools, config changes, hook changes):
429
-
430
- 1. Update relevant documentation (README, API docs, config docs)
431
- 2. Ensure tool descriptions match implementation
432
- 3. Update config schema documentation if config keys changed
433
-
434
- Skip ONLY if purely internal refactoring with zero user-facing changes.
435
-
436
- ### Phase 2G: Browser Verification & Fix Loop (`/massu-loop-playwright`)
437
-
438
- ```
439
- [GOLDEN PATH -- PHASE 2G: BROWSER VERIFICATION]
440
- ```
441
-
442
- **This phase executes the full `/massu-loop-playwright` protocol inline.** See `massu-loop-playwright.md` for the standalone version.
443
-
444
- **Auto-trigger condition**: If plan touches ANY UI/demo files or produces visual output, this phase runs automatically. If purely backend/MCP/config with zero visual output, skip with log note: `Browser verification: SKIPPED (no UI files changed)`.
445
-
446
- #### 2G.1 Determine Target Pages
447
-
448
- Map changed features to testable URLs:
449
- - If Massu has a demo page or documentation site: test affected pages
450
- - If testing MCP tool output: use a test harness or verify tool responses
451
- - Component changes: identify ALL pages that render the component
452
-
453
- #### 2G.2 Browser Setup & Authentication
454
-
455
- Use Playwright MCP plugin tools (`mcp__plugin_playwright_playwright__*`). Fallback: `mcp__playwright__*`.
456
-
457
- 1. `browser_navigate` to target URL ($TARGET_URL)
458
- 2. `browser_snapshot` to check page status
459
- 3. If authentication required: STOP and request manual login
460
-
461
- ```
462
- AUTHENTICATION REQUIRED
463
-
464
- The Playwright browser is not logged in to the target application.
465
- Please log in manually in the open browser window, then re-run the golden path.
466
- ```
467
-
468
- **NEVER type credentials. NEVER hardcode passwords. NEVER proceed without authentication.**
469
-
470
- #### 2G.3 Load Audit (Per Page)
471
-
472
- For EACH target page:
108
+ Read `references/phase-2-implementation.md` for full details.
473
109
 
474
- | Check | Tool | Captures |
475
- |-------|------|----------|
476
- | Console errors/warnings | `browser_console_messages` | React errors, TypeError, CSP violations |
477
- | Network failures | `browser_network_requests` | 500s, 404s, CORS failures, timeouts |
110
+ **Summary**: Nine sub-phases (or external loop via `--external` flag using `scripts/loop-external.sh` for context-fresh iterations):
111
+ - **2A**: Extract plan items into tracking table, initialize session state
112
+ - **2A.5**: Sprint contracts -- negotiate definition-of-done per plan item before implementation (scope boundary, acceptance criteria, VR-* mapping). See `references/sprint-contract-protocol.md`
113
+ - **2B**: Implementation loop (pre-check, execute, guardrail, verify, update per item)
114
+ - **2C**: Multi-perspective review (3 parallel agents: security, architecture, UX) + **QA evaluator** (conditional, UI plans only -- adversarial Playwright-based acceptance testing against sprint contracts). See `references/qa-evaluator-spec.md`
115
+ - **2D**: Verification audit loop (subagent, circuit breaker CR-37, refine-or-pivot at 3+ iterations, sprint contract verification, max 10 iterations)
116
+ - **2E**: Post-build reflection + memory persist (CR-38)
117
+ - **2F**: Documentation sync (if user-facing features)
118
+ - **2G**: Browser verification & fix loop (auto-triggers if UI files changed, Playwright MCP)
478
119
 
479
- Categorize findings:
480
-
481
- | Category | Severity |
482
- |----------|----------|
483
- | Crash, 500 error, data exposure | **P0 -- CRITICAL** |
484
- | Network failure, broken interaction | **P1 -- HIGH** |
485
- | Visual issues, performance warnings | **P2 -- MEDIUM** |
486
- | Console warnings, deprecations | **P3 -- LOW** |
487
-
488
- #### 2G.4 Interactive Testing (Per Page)
489
-
490
- 1. `browser_snapshot` --> inventory ALL interactive elements (buttons, links, forms, selects, tabs, modals, data tables)
491
- 2. For EACH testable element:
492
- - Capture console state BEFORE interaction (`browser_console_messages`)
493
- - Perform interaction (`browser_click`, `browser_select_option`, `browser_fill_form`)
494
- - Wait 2-3 seconds for async operations
495
- - Capture console state AFTER interaction
496
- - Record any NEW errors introduced
497
- - `browser_snapshot` to verify DOM state after interaction
498
- - If interaction opened modal/sheet: test elements inside, then close
499
-
500
- **SAFETY**: Never submit forms, click Delete/Send/Submit, or create real records on production.
501
-
502
- #### 2G.5 Visual & Performance Audit
503
-
504
- **Visual checks**:
505
- - Broken images: `browser_evaluate` to find `img` elements with `naturalWidth === 0`
506
- - Layout issues: overflow, overlapping, missing content, broken alignment
507
- - Responsive: `browser_resize` at 1440x900 (desktop), 768x1024 (tablet), 375x812 (mobile)
508
- - Screenshot evidence: `browser_take_screenshot` at each breakpoint if issues found
509
-
510
- **Performance checks**:
511
- - Page load timing via `browser_evaluate` (`performance.getEntriesByType('navigation')`)
512
- - Resources > 500KB via `browser_evaluate` (`performance.getEntriesByType('resource')`)
513
- - Slow API calls > 3s, duplicate requests via `browser_network_requests`
514
-
515
- | Metric | Good | Needs Work | Critical |
516
- |--------|------|------------|----------|
517
- | DOM Content Loaded | < 2s | 2-5s | > 5s |
518
- | Full Load | < 4s | 4-8s | > 8s |
519
- | TTFB | < 500ms | 500ms-1.5s | > 1.5s |
520
-
521
- #### 2G.6 Fix Loop
522
-
523
- ```
524
- issues = ALL findings from 2G.3-2G.5, sorted by priority (P0 first)
525
-
526
- FOR EACH issue WHERE priority <= P2:
527
- 1. IDENTIFY root cause (Grep/Read source files)
528
- 2. APPLY fix (follow CLAUDE.md patterns)
529
- 3. VERIFY fix (VR-GREP, VR-NEGATIVE, VR-BUILD, VR-TYPE)
530
- 4. LOG fix in report
531
-
532
- Zero-issue standard: ALL P0/P1 fixed, ALL P2 fixed or documented with justification.
533
- Circuit breaker: 5 iterations on same page --> ask user.
534
- ```
535
-
536
- Post-fix: reload target URLs, re-run load audit + interactive testing for elements that had failures. If new errors appear, add to issues list and continue fix loop.
537
-
538
- #### 2G.7 Report
539
-
540
- Save to `.claude/playwright-reports/{TIMESTAMP}-{SLUG}.md`.
541
-
542
- Report includes: summary table, console errors, network failures, interactive element failures, visual issues, performance issues, fix log with files changed and VR checks, unfixed issues with justification, screenshots.
543
-
544
- #### 2G.8 Auto-Learning Protocol
545
-
546
- For EACH browser-discovered fix:
547
- 1. Update memory files with symptom/root cause/fix/files
548
- 2. Add to `scripts/massu-pattern-scanner.sh` if the bad pattern is grep-able
549
- 3. Codebase-wide search for same bad pattern (CR-9) -- fix ALL instances
550
-
551
- ```
552
- [GOLDEN PATH -- PHASE 2 COMPLETE]
553
- - All plan items implemented
554
- - Multi-perspective review: PASSED (security, architecture, quality)
555
- - Verification audit: PASSED (Loop #{iteration}, 0 gaps)
556
- - Post-build reflection: PERSISTED to memory
557
- - Documentation sync: COMPLETE / N/A
558
- - Browser verification: PASSED ({N} pages tested, {M} issues fixed) / SKIPPED (no UI files)
559
- ```
120
+ **Gate**: APPROVAL POINT #2: NEW PATTERN (if needed, any sub-phase)
560
121
 
561
122
  ---
562
123
 
563
- ## PHASE 3: SIMPLIFICATION (`/massu-simplify`)
564
-
565
- ```
566
- [GOLDEN PATH -- PHASE 3: SIMPLIFICATION]
567
- ```
568
-
569
- **This phase executes the full `/massu-simplify` protocol inline.** See `massu-simplify.md` for the standalone version.
570
-
571
- ### 3.1 Fast Gate
124
+ ## PHASE 2.5: GAP & ENHANCEMENT ANALYSIS
572
125
 
573
- ```bash
574
- bash scripts/massu-pattern-scanner.sh # Fix ALL violations before semantic analysis
575
- ```
576
-
577
- ### 3.2 Parallel Semantic Review (3 Agents)
578
-
579
- Spawn IN PARALLEL (Core Principle #10 -- one task per agent):
580
-
581
- **Efficiency Reviewer** (haiku): Query inefficiency (findMany equivalent vs SQL COUNT, N+1 queries, unbounded queries), algorithmic inefficiency (O(n^2), repeated sort/filter), unnecessary allocations, missing caching opportunities.
126
+ Read `references/phase-2.5-gap-analyzer.md` for full details.
582
127
 
583
- **Reuse Reviewer** (haiku): Known utilities (getConfig(), stripPrefix(), tool registration patterns, memDb lifecycle pattern), module duplication against existing tool modules, pattern duplication across new files, config values that should be in massu.config.yaml.
128
+ **Summary**: After implementation completes, run a continuous gap and enhancement analysis loop. A subagent analyzes all changed files across 7 categories (functional gaps, UX gaps, data integrity, security, pattern compliance, enhancements, sprint contract compliance). VR-VISUAL uses weighted 4-dimension scoring (threshold >= 3.0). Every gap/enhancement found is fixed immediately. The loop re-runs until a full pass discovers ZERO gaps. Max 10 iterations. Skippable only for documentation-only changes or explicit user request.
584
129
 
585
- **Pattern Compliance Reviewer** (haiku): ESM compliance (.ts import extensions, no require()), config-driven patterns (no hardcoded project-specific values -- CR-38/VR-GENERIC), TypeScript strict mode compliance, tool registration (3-function pattern preferred -- CR-11), hook compilation (esbuild compatible -- CR-12), memDb lifecycle (try/finally close), security (input validation, no eval/exec).
130
+ ---
586
131
 
587
- ### 3.3 Apply ALL Findings
132
+ ## PHASE 3: SIMPLIFICATION
588
133
 
589
- Sort by SEVERITY (CRITICAL --> LOW). Fix ALL (CR-9). Re-run pattern scanner.
134
+ Read `references/phase-3-simplify.md` for full details.
590
135
 
591
- ```
592
- SIMPLIFY_GATE: PASS (N findings, N fixed, 0 remaining)
593
- ```
136
+ **Summary**: Fast gate (pattern scanner), then 3 parallel semantic review agents (efficiency, reuse, pattern compliance). Apply ALL findings sorted by severity. Re-run pattern scanner.
594
137
 
595
138
  ---
596
139
 
597
140
  ## PHASE 4: PRE-COMMIT VERIFICATION
598
141
 
599
- ```
600
- [GOLDEN PATH -- PHASE 4: PRE-COMMIT VERIFICATION]
601
- ```
602
-
603
- ### 4.1 Auto-Verification Gates (ALL must pass in SINGLE run)
604
-
605
- | Gate | Command | Expected |
606
- |------|---------|----------|
607
- | 1. Pattern Scanner | `bash scripts/massu-pattern-scanner.sh` | Exit 0 |
608
- | 2. Type Safety (VR-TYPE) | `cd packages/core && npx tsc --noEmit` | 0 errors |
609
- | 3. Build (VR-BUILD) | `npm run build` | Exit 0 |
610
- | 4. Tests (VR-TEST) | `npm test` | ALL pass |
611
- | 5. Hook Compilation (VR-HOOK-BUILD) | `cd packages/core && npm run build:hooks` | Exit 0 |
612
- | 6. Generalization (VR-GENERIC) | `bash scripts/massu-generalization-scanner.sh` | Exit 0 |
613
- | 7. Security Scanner | `bash scripts/massu-security-scanner.sh` | Exit 0 |
614
- | 8. Secrets Staged | `git diff --cached --name-only \| grep -E '\.(env\|pem\|key\|secret)'` | 0 files |
615
- | 9. Credentials in Code | `grep -rn "sk-\|password.*=.*['\"]" --include="*.ts" packages/ \| grep -v "process.env" \| wc -l` | 0 |
616
- | 10. VR-TOOL-REG | For EACH new tool: verify definitions + handler wired in tools.ts | All wired |
617
- | 11. Plan Coverage | Verify ALL plan items with VR-* proof | 100% |
618
- | 12. VR-PLAN-STATUS | `grep "IMPLEMENTATION STATUS" [plan]` | Match |
619
- | 13. Dependency Security | `npm audit --audit-level=high` | 0 high/crit |
620
-
621
- ### 4.2 Quality Scoring Gate
622
-
623
- Spawn `massu-output-scorer` (sonnet): Code Clarity, Pattern Compliance, Error Handling, Test Coverage, Config-Driven Design (1-5 each). All >= 3: PASS. Any < 3: FAIL.
624
-
625
- ### 4.3 If ANY Gate Fails
142
+ Read `references/phase-4-commit.md` for full details.
626
143
 
627
- **DO NOT PAUSE** -- Fix automatically, re-run ALL gates, repeat until all pass.
144
+ **Summary**: Verification gates (pattern scanner, tsc, build, lint, secrets, VR-RENDER, VR-COUPLING, plan coverage, plan status, dep security). Quality scoring gate. Auto-fix on failure.
628
145
 
629
- ### 4.4 Auto-Learning Protocol
630
-
631
- - For each bug fixed: update memory files
632
- - For new patterns: record in memory
633
- - Add detection to `scripts/massu-pattern-scanner.sh` if grep-able
634
- - Codebase-wide search: no other instances of same bad pattern (CR-9)
635
- - Record user corrections to `memory/corrections.md`
636
-
637
- ### Phase 4 Complete --> APPROVAL POINT #3: COMMIT
638
-
639
- ```
640
- ===============================================================================
641
- APPROVAL REQUIRED: COMMIT
642
- ===============================================================================
643
-
644
- All verification checks passed. Ready to commit.
645
-
646
- VERIFICATION RESULTS:
647
- -------------------------------------------------------------------------------
648
- - Pattern scanner: Exit 0
649
- - Type check: 0 errors
650
- - Build: Exit 0
651
- - Tests: ALL pass
652
- - Hook compilation: Exit 0
653
- - Generalization: Exit 0
654
- - Security: No secrets staged, no credentials in code
655
- - Tool registration: All new tools wired
656
- - Plan Coverage: [X]/[X] = 100%
657
- - Quality Score: [X.X]/5.0
658
- -------------------------------------------------------------------------------
659
-
660
- FILES TO BE COMMITTED:
661
- [list]
662
-
663
- PROPOSED COMMIT MESSAGE:
664
- -------------------------------------------------------------------------------
665
- [type]: [description]
666
-
667
- [body]
668
-
669
- Co-Authored-By: Claude <noreply@anthropic.com>
670
- -------------------------------------------------------------------------------
671
-
672
- OPTIONS:
673
- - "approve" to commit and continue to push
674
- - "message: [new message]" to change commit message
675
- - "abort" to stop (changes remain staged)
676
-
677
- ===============================================================================
678
- ```
679
-
680
- ### Commit Format
681
-
682
- ```bash
683
- git commit -m "$(cat <<'EOF'
684
- [type]: [description]
685
-
686
- [Body]
687
-
688
- Changes:
689
- - [Change 1]
690
- - [Change 2]
691
-
692
- Verified:
693
- - Pattern scanner: PASS | Type check: 0 errors | Build: PASS
694
- - Tests: ALL pass | Hooks: compiled | Generalization: PASS
695
-
696
- Co-Authored-By: Claude <noreply@anthropic.com>
697
- EOF
698
- )"
699
- ```
146
+ **Gate**: APPROVAL POINT #3: COMMIT
700
147
 
701
148
  ---
702
149
 
703
150
  ## PHASE 5: PUSH VERIFICATION & PUSH
704
151
 
705
- ```
706
- [GOLDEN PATH -- PHASE 5: PUSH VERIFICATION]
707
- ```
708
-
709
- ### 5.1 Pre-Flight
710
-
711
- ```bash
712
- git log origin/main..HEAD --oneline # Commits to push
713
- ```
714
-
715
- ### 5.2 Tier 1: Quick Re-Verification
716
-
717
- Run in parallel where possible:
718
-
719
- | Check | Command |
720
- |-------|---------|
721
- | Pattern Scanner | `bash scripts/massu-pattern-scanner.sh` |
722
- | Generalization | `bash scripts/massu-generalization-scanner.sh` |
723
- | TypeScript | `cd packages/core && npx tsc --noEmit` |
724
- | Build | `npm run build` |
725
- | Hook Compilation | `cd packages/core && npm run build:hooks` |
726
-
727
- ### 5.3 Tier 2: Test Suite (CRITICAL)
728
-
729
- #### 5.3.0 Regression Detection (MANDATORY FIRST)
730
-
731
- ```bash
732
- # Establish baseline on main
733
- git stash && git checkout main -q
734
- npm test 2>&1 | tee /tmp/baseline-tests.txt
735
- git checkout - -q && git stash pop -q
736
-
737
- # Run on current branch
738
- npm test 2>&1 | tee /tmp/current-tests.txt
739
-
740
- # Compare: any test passing on main but failing now = REGRESSION
741
- # Regressions MUST be fixed before push
742
- ```
743
-
744
- #### 5.3.1-5.3.3 Test Execution
745
-
746
- Use **parallel Task agents** for independent checks:
747
-
748
- ```
749
- Agent Group A (parallel):
750
- - Agent 1: npm test (unit tests)
751
- - Agent 2: npm audit --audit-level=high
752
- - Agent 3: bash scripts/massu-security-scanner.sh
753
-
754
- Sequential:
755
- - VR-TOOL-REG: verify ALL new tools registered in tools.ts
756
- - VR-GENERIC: verify ALL files pass generalization scanner
757
- ```
758
-
759
- ### 5.4 Tier 3: Security & Compliance
760
-
761
- | Check | Command |
762
- |-------|---------|
763
- | npm audit | `npm audit --audit-level=high` |
764
- | Security scan | `bash scripts/massu-security-scanner.sh` |
765
- | Config validation | Parse massu.config.yaml without errors |
766
-
767
- ### 5.5 Tier 4: Final Gate
768
-
769
- All tiers must pass:
770
-
771
- | Tier | Status |
772
- |------|--------|
773
- | Tier 1: Quick Checks | PASS/FAIL |
774
- | Tier 2: Test Suite + Regression | PASS/FAIL |
775
- | Tier 3: Security & Compliance | PASS/FAIL |
776
-
777
- ### Phase 5 Gate --> APPROVAL POINT #4: PUSH
778
-
779
- ```
780
- ===============================================================================
781
- APPROVAL REQUIRED: PUSH TO REMOTE
782
- ===============================================================================
783
-
784
- All verification tiers passed. Ready to push.
785
-
786
- PUSH GATE SUMMARY:
787
- -------------------------------------------------------------------------------
788
- Commit: [hash]
789
- Message: [message]
790
- Files changed: [N] | +[N] / -[N]
791
- Branch: [branch] --> origin
792
-
793
- Tier 1 (Quick): PASS
794
- Tier 2 (Tests): PASS -- Unit: X/X, Regression: 0
795
- Tier 3 (Security): PASS -- Audit: 0 high/crit, Secrets: clean
796
- -------------------------------------------------------------------------------
152
+ Read `references/phase-5-push.md` for full details.
797
153
 
798
- OPTIONS:
799
- - "approve" / "push" to push to remote
800
- - "abort" to stop (commit remains local)
154
+ **Summary**: Pre-flight (commits to push). Tier 1: quick re-verification. Tier 2: test suite with mandatory regression detection. Tier 3: security & compliance (npm audit, secrets scan). Tier 4: final gate.
801
155
 
802
- ===============================================================================
803
- ```
804
-
805
- After approval: `git push origin [branch]`, then verify with `gh run list --limit 3`.
156
+ **Gate**: APPROVAL POINT #4: PUSH
806
157
 
807
158
  ---
808
159
 
809
160
  ## PHASE 6: COMPLETION
810
161
 
811
- ### 6.1 Final Report
812
-
813
- ```
814
- ===============================================================================
815
- GOLDEN PATH COMPLETE
816
- ===============================================================================
817
-
818
- SUMMARY:
819
- -------------------------------------------------------------------------------
820
- Phase 0: Requirements & Context - D1-D10 resolved
821
- Phase 1: Plan Creation & Audit - [N] items, [M] audit passes
822
- Phase 2: Implementation - [N] audit loops, 3 reviewers passed
823
- Phase 2G: Browser Verification - [N] pages tested, [M] issues fixed / SKIPPED
824
- Phase 3: Simplification - [N] findings fixed
825
- Phase 4: Pre-Commit Verification - All gates passed
826
- Phase 5: Push Verification - 3 tiers passed, 0 regressions
827
- -------------------------------------------------------------------------------
828
-
829
- DELIVERABLES:
830
- - Plan: [plan path]
831
- - Commit: [hash]
832
- - Branch: [branch]
833
- - Pushed: YES
834
- - Files changed: [N]
835
-
836
- ===============================================================================
837
- ```
838
-
839
- ### 6.2 Plan Document Update (MANDATORY)
840
-
841
- Add to TOP of plan document:
842
-
843
- ```markdown
844
- # IMPLEMENTATION STATUS
845
-
846
- **Plan**: [Name]
847
- **Status**: COMPLETE -- PUSHED
848
- **Last Updated**: [YYYY-MM-DD HH:MM]
849
- **Push Commit**: [hash]
850
- **Completed By**: Claude Code (Massu Golden Path)
851
-
852
- ## Task Completion Summary
853
- | # | Task/Phase | Status | Verification | Date |
854
- |---|------------|--------|--------------|------|
855
- | 1 | [description] | 100% COMPLETE | VR-BUILD: Pass | [date] |
856
- ```
857
-
858
- ### 6.3 Auto-Learning Protocol (MANDATORY)
859
-
860
- 1. Review ALL fixes: `git diff origin/main..HEAD`
861
- 2. For each fix: verify memory files updated
862
- 3. For each new pattern: verify recorded
863
- 4. For each failed approach: verify recorded
864
- 5. Record user corrections to `memory/corrections.md`
865
- 6. Consider new CR rule if a class of bug was found
866
-
867
- ### 6.4 Update Session State
162
+ Read `references/phase-6-completion.md` for full details.
868
163
 
869
- Update `session-state/CURRENT.md` with completion status.
164
+ **Summary**: Final report with phase-by-phase status. Plan document update (IMPLEMENTATION STATUS at top). Auto-learning protocol (memory ingest for all fixes/patterns). Quality & observability report. Feature registration. Session state update.
870
165
 
871
166
  ---
872
167
 
873
- ## NEW PATTERN APPROVAL (APPROVAL POINT #2 -- Any Phase)
168
+ ## Skill Contents
874
169
 
875
- If a new pattern is needed during ANY phase:
170
+ This skill is a folder. The following files are available for reference:
876
171
 
877
- ```
878
- ===============================================================================
879
- APPROVAL REQUIRED: NEW PATTERN
880
- ===============================================================================
881
-
882
- A new pattern is needed for: [functionality]
883
-
884
- Existing patterns checked:
885
- - [pattern 1]: Not suitable because [reason]
886
-
887
- PROPOSED NEW PATTERN:
888
- -------------------------------------------------------------------------------
889
- Name: [Pattern Name]
890
- Domain: [Config/MCP/Hook/etc.]
891
-
892
- WRONG: ```[code]```
893
- CORRECT: ```[code]```
894
- Error if violated: [What breaks]
895
- -------------------------------------------------------------------------------
896
-
897
- OPTIONS:
898
- - "approve" to save and continue
899
- - "modify: [changes]" to adjust
900
- - "abort" to stop
901
-
902
- ===============================================================================
903
- ```
172
+ | File | Purpose | Read When |
173
+ |------|---------|-----------|
174
+ | `references/phase-0-requirements.md` | Requirements interview, ambiguity detection, 10-dimension coverage map | Starting a new implementation from a task description |
175
+ | `references/phase-1-plan-creation.md` | Blast radius analysis, plan generation, audit loop | Writing or auditing a plan |
176
+ | `references/phase-2-implementation.md` | Item loop, sprint contracts, multi-perspective review, QA evaluator, verification audit, browser testing | Executing implementation; any Phase 2 sub-phase |
177
+ | `references/sprint-contract-protocol.md` | Sprint contract template, quality bar, negotiation rules, skip conditions | Phase 2A.5 sprint contract negotiation |
178
+ | `references/qa-evaluator-spec.md` | Adversarial QA evaluator: 4 dimensions, anti-leniency rules, known failure patterns | Phase 2C.2 QA evaluation (UI plans only) |
179
+ | `references/vr-visual-calibration.md` | Score 5/3/1 calibration examples for VR-VISUAL weighted dimensions | Calibrating VR-VISUAL evaluator scoring |
180
+ | `references/phase-2.5-gap-analyzer.md` | Gap/enhancement analysis loop, 7 categories (incl. sprint contract compliance), fix-and-repass until zero | After implementation, before simplification |
181
+ | `references/phase-3-simplify.md` | Pattern scanner fast gate, dead code detection, parallel semantic review agents | Running simplification after implementation |
182
+ | `references/phase-4-commit.md` | Verification gates, quality scoring, commit format | Preparing a commit |
183
+ | `references/phase-5-push.md` | Pre-flight, push verification, regression detection | Preparing to push to remote |
184
+ | `references/phase-6-completion.md` | Final report, plan status update, auto-learning, feature registration | After all verification; completing the golden path |
185
+ | `references/approval-points.md` | Exact format and options for all 4 approval points (5 with --competitive: Plan, New Pattern, Winner Selection, Commit, Push) | Presenting any approval gate to the user |
186
+ | `references/competitive-mode.md` | Competitive mode protocol: agent spawning, scoring, winner selection | Using --competitive flag |
187
+ | `references/error-handling.md` | Abort handling, non-recoverable errors, post-compaction re-verification, competitive mode errors | On user abort, blocker error, or after context compaction |
904
188
 
905
189
  ---
906
190
 
907
- ## ABORT HANDLING
191
+ ## Gotchas
908
192
 
909
- ```
910
- ===============================================================================
911
- GOLDEN PATH ABORTED
912
- ===============================================================================
913
-
914
- Stopped at: [Phase N -- Approval Point]
915
-
916
- CURRENT STATE:
917
- - Completed phases: [list]
918
- - Pending phases: [list]
919
- - Plan file: [path]
920
- - Files changed: [list]
921
- - Commit created: YES/NO
922
- - Pushed: NO
923
-
924
- TO RESUME:
925
- Run /massu-golden-path again with the same plan
926
- Or run individual commands:
927
- /massu-loop -- Continue implementation
928
- /massu-commit -- Run commit verification
929
- /massu-push -- Run push verification
930
-
931
- ===============================================================================
932
- ```
193
+ - **Compaction mid-loop loses plan state** -- if context compaction occurs during implementation, the plan file path and current item must be recoverable from session-state/CURRENT.md
194
+ - **UI items need browser verification (CR-41)** -- any plan item touching UI files must be verified with Playwright before claiming done
195
+ - **Approval points must not be skipped** -- there are 4 approval gates (5 with --competitive: Plan, New Pattern, Winner Selection, Commit, Push)
196
+ - **Plan file must be re-read from disk, not memory (CR-5)** -- after compaction, always re-read the plan file. Memory of plan contents drifts from reality
197
+ - **100% coverage required (CR-11)** -- never stop early. "Most items done" is not "all items done"
198
+ - **--competitive increases token cost ~2-3x for Phase 2** -- use for high-stakes features only
199
+ - **Competing agents do NOT run database migrations** -- DB changes must be applied separately before competitive mode
200
+ - **Worktree branches must be mergeable** -- competing agents edit different files from the same plan, but shared files may conflict
201
+ - **Bias presets are suggestions, not constraints** -- agents may deviate if the plan requires a specific approach
933
202
 
934
203
  ---
935
204
 
936
- ## ERROR HANDLING
205
+ ## Quality Scoring Criteria
937
206
 
938
- **Recoverable**: Fix automatically --> re-run failed step --> if fixed, continue without pausing --> if not fixable after 3 attempts, pause and report.
207
+ | Dimension | Weight | Measured By |
208
+ |-----------|--------|-------------|
209
+ | Code Clarity | 1-5 | Naming, structure, comments |
210
+ | Pattern Compliance | 1-5 | CLAUDE.md patterns followed |
211
+ | Error Handling | 1-5 | Edge cases, validation, fallbacks |
212
+ | UX Quality | 1-5 | Loading/error/empty states, accessibility |
213
+ | Test Coverage | 1-5 | Test files exist for new code |
939
214
 
940
- **Non-Recoverable**:
941
- ```
942
- ===============================================================================
943
- GOLDEN PATH BLOCKED
944
- ===============================================================================
945
-
946
- BLOCKER: [Description]
947
- Required: [Steps to resolve]
948
- After resolving, run /massu-golden-path again.
949
-
950
- ===============================================================================
951
- ```
215
+ All >= 3: PASS. Any < 3: FAIL.
952
216
 
953
217
  ---
954
218
 
955
219
  ## START NOW
956
220
 
957
- **Step 0: Write AUTHORIZED_COMMAND to session state (CR-35)**
221
+ **Step 0: Write AUTHORIZED_COMMAND to session state (CR-12)**
958
222
 
959
223
  Update `session-state/CURRENT.md`:
960
224
  ```
@@ -963,11 +227,13 @@ AUTHORIZED_COMMAND: massu-golden-path
963
227
 
964
228
  1. **Determine input**: Task description, plan file, or continue
965
229
  2. **Phase 0**: Requirements & context (if task description)
966
- 3. **Phase 1**: Plan creation & audit --> **PAUSE: Plan Approval**
230
+ 3. **Phase 1**: Plan creation & audit -> **PAUSE: Plan Approval**
967
231
  4. **Phase 2**: Implementation with verification loops + browser verification (UI changes)
968
- 5. **Phase 3**: Simplification (efficiency, reuse, patterns)
969
- 6. **Phase 4**: Pre-commit verification --> **PAUSE: Commit Approval**
970
- 7. **Phase 5**: Push verification --> **PAUSE: Push Approval**
971
- 8. **Phase 6**: Completion, learning, quality metrics
232
+ 4a. **Phase 2-COMP**: Competitive implementation (if --competitive) -> **PAUSE: Winner Selection**
233
+ 5. **Phase 2.5**: Gap & enhancement analysis loop (until zero gaps)
234
+ 6. **Phase 3**: Simplification (efficiency, reuse, patterns)
235
+ 7. **Phase 4**: Pre-commit verification -> **PAUSE: Commit Approval**
236
+ 8. **Phase 5**: Push verification via `scripts/push-verify.sh` -> **PAUSE: Push Approval**
237
+ 9. **Phase 6**: Completion, learning, quality metrics
972
238
 
973
239
  **This command does NOT stop to ask "should I continue?" -- it runs straight through.**