@massu/core 0.4.2 → 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 (125) 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 +1451 -1047
  97. package/dist/hooks/post-tool-use.js +75 -6
  98. package/dist/hooks/user-prompt.js +16 -0
  99. package/package.json +6 -2
  100. package/patterns/build-patterns.md +302 -0
  101. package/patterns/component-patterns.md +246 -0
  102. package/patterns/display-patterns.md +185 -0
  103. package/patterns/form-patterns.md +890 -0
  104. package/patterns/integration-testing-checklist.md +445 -0
  105. package/patterns/security-patterns.md +219 -0
  106. package/patterns/testing-patterns.md +569 -0
  107. package/patterns/tool-routing.md +81 -0
  108. package/patterns/ui-patterns.md +371 -0
  109. package/protocols/plan-implementation.md +267 -0
  110. package/protocols/recovery.md +225 -0
  111. package/protocols/verification.md +404 -0
  112. package/reference/command-taxonomy.md +178 -0
  113. package/reference/cr-rules-reference.md +76 -0
  114. package/reference/hook-execution-order.md +148 -0
  115. package/reference/lessons-learned.md +175 -0
  116. package/reference/patterns-quickref.md +208 -0
  117. package/reference/standards.md +135 -0
  118. package/reference/subagents-reference.md +17 -0
  119. package/reference/vr-verification-reference.md +867 -0
  120. package/src/commands/init.ts +27 -0
  121. package/src/commands/install-commands.ts +149 -53
  122. package/src/hooks/post-tool-use.ts +17 -0
  123. package/src/hooks/user-prompt.ts +21 -0
  124. package/src/memory-file-ingest.ts +127 -0
  125. package/src/memory-tools.ts +34 -1
@@ -1,20 +1,18 @@
1
1
  ---
2
2
  name: massu-hotfix
3
- description: Quick scoped fix workflow with branch, test, commit, push, and PR creation
3
+ description: "When user needs an urgent fix -- 'hotfix', 'emergency fix', 'broken and needs immediate patch'"
4
4
  allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
5
5
  ---
6
6
  name: massu-hotfix
7
7
 
8
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-35 enforced.
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-5, CR-12 enforced.
9
9
 
10
- # CS Hotfix: Quick Scoped Fix Workflow
10
+ # Massu Hotfix: Emergency Fix Protocol
11
11
 
12
12
  ## Objective
13
13
 
14
14
  Apply **minimal, targeted fixes** for production issues with fast verification and safe deployment. Fix the bug, nothing more.
15
15
 
16
- **Usage**: `/massu-hotfix [description of the fix]`
17
-
18
16
  ---
19
17
 
20
18
  ## NON-NEGOTIABLE RULES
@@ -31,20 +29,21 @@ Apply **minimal, targeted fixes** for production issues with fast verification a
31
29
 
32
30
  ## ZERO-GAP AUDIT LOOP
33
31
 
34
- **Even hotfixes do NOT complete until a SINGLE COMPLETE VERIFICATION finds ZERO issues.**
32
+ **Even hotfixes do NOT deploy until a SINGLE COMPLETE VERIFICATION finds ZERO issues.**
35
33
 
36
34
  ### The Rule
37
35
 
38
36
  ```
39
37
  HOTFIX VERIFICATION LOOP:
40
38
  1. Apply minimal fix
41
- 2. Run verification checks (patterns, types, tests)
39
+ 2. Run verification checks (patterns, types, build, tests)
42
40
  3. Count issues found
43
41
  4. IF issues > 0:
44
42
  - Fix ALL issues
45
43
  - Re-run ENTIRE verification from Step 2
46
44
  5. IF issues == 0:
47
45
  - HOTFIX VERIFIED
46
+ - Safe to deploy
48
47
  ```
49
48
 
50
49
  ### Completion Requirement
@@ -53,9 +52,9 @@ HOTFIX VERIFICATION LOOP:
53
52
  |----------|--------|
54
53
  | Fix introduces type error | Fix it, re-verify ENTIRELY |
55
54
  | Re-verify finds pattern violation | Fix it, re-verify ENTIRELY |
56
- | Re-verify finds 0 issues | **NOW** hotfix verified |
55
+ | Re-verify finds 0 issues | **NOW** hotfix can deploy |
57
56
 
58
- **Partial verification is NOT valid. ALL checks must pass in a SINGLE run.**
57
+ **Partial verification is NOT valid. ALL checks must pass in a SINGLE run before deploy.**
59
58
 
60
59
  ---
61
60
 
@@ -92,15 +91,45 @@ IF scope_check_fails:
92
91
 
93
92
  ## DOMAIN-SPECIFIC PATTERN LOADING
94
93
 
95
- Based on the hotfix area, load relevant patterns from CLAUDE.md:
94
+ Based on the hotfix area, load relevant pattern files:
95
+
96
+ | Domain | Pattern File | Load When |
97
+ |--------|--------------|-----------|
98
+ | Tool modules | `.claude/patterns/tool-patterns.md` | Tool handler/registration bugs |
99
+ | Config | `.claude/patterns/config-patterns.md` | Config parsing/access bugs |
100
+ | Hooks | `.claude/patterns/hook-patterns.md` | Hook compilation/runtime bugs |
101
+ | Build issues | `.claude/patterns/build-patterns.md` | Build/deploy issues |
102
+
103
+ ---
104
+
105
+ ## MANDATORY VERIFICATION (For Database Hotfixes)
106
+
107
+ ### VR-SCHEMA-PRE: Verify Schema BEFORE Applying Database Hotfix
108
+
109
+ **WHEN hotfixing database-related issues, ALWAYS verify schema first.**
96
110
 
97
- | Domain | Section | Load When |
98
- |--------|---------|-----------|
99
- | Tool modules | Tool Registration Pattern | Tool handler/registration bugs |
100
- | Config | Config Access Pattern | Config parsing/access bugs |
101
- | Hooks | Hook stdin/stdout Pattern | Hook compilation/runtime bugs |
102
- | Database | SQLite Database Pattern | DB access/schema bugs |
103
- | Build | Build & Test Commands | Build/compilation issues |
111
+ ```sql
112
+ -- VR-SCHEMA-PRE: Query ACTUAL columns (even in emergency)
113
+ SELECT column_name, data_type, is_nullable
114
+ FROM information_schema.columns
115
+ WHERE table_name = '[AFFECTED_TABLE]'
116
+ ORDER BY ordinal_position;
117
+ ```
118
+
119
+ **Why This Is Mandatory (Even for Emergencies):**
120
+ - Wrong column name in hotfix = 500 error = makes things WORSE
121
+ - Take 30 seconds to verify schema, save hours of debugging
122
+ - Schema mismatch is a common root cause of bugs
123
+
124
+ ### VR-CONFIG: Verify Config for "Not Working" Hotfixes
125
+
126
+ **If hotfixing "tool not found" or config issues, verify config-code alignment FIRST.**
127
+
128
+ ```bash
129
+ # VR-CONFIG: Verify config values match code expectations
130
+ cat massu.config.yaml
131
+ grep -rn "getConfig()" packages/core/src/ | head -10
132
+ ```
104
133
 
105
134
  ---
106
135
 
@@ -166,8 +195,8 @@ Before implementing, verify fix follows CLAUDE.md:
166
195
  - [ ] Uses ESM imports (not require())
167
196
  - [ ] Uses getConfig() (not direct YAML parse)
168
197
  - [ ] Tool handlers follow 3-function pattern
169
- - [ ] memDb closed in try/finally
170
198
  - [ ] No hardcoded secrets
199
+ - [ ] Error handling present
171
200
 
172
201
  ---
173
202
 
@@ -178,7 +207,7 @@ Before implementing, verify fix follows CLAUDE.md:
178
207
  # Ensure clean working tree
179
208
  git status --short
180
209
 
181
- # From main branch
210
+ # From main/production branch
182
211
  git checkout main
183
212
  git pull origin main
184
213
  git checkout -b hotfix/[issue-name]
@@ -194,24 +223,34 @@ git checkout -b hotfix/[issue-name]
194
223
  - Do NOT fix "while we're at it" issues
195
224
  - Add comment if fix is non-obvious
196
225
 
226
+ ### 3.3 Verify Fix Locally
227
+ ```bash
228
+ # Quick verification
229
+ npx tsc --noEmit
230
+ npm run build
231
+
232
+ # Pattern check
233
+ bash scripts/massu-pattern-scanner.sh
234
+ ```
235
+
197
236
  ---
198
237
 
199
238
  ## PHASE 4: FAST VERIFICATION (5 minutes)
200
239
 
201
- ### 4.1 Essential Checks
240
+ ### 4.1 Essential Checks Only
202
241
  ```bash
203
242
  # Type safety
204
- cd packages/core && npx tsc --noEmit
243
+ npx tsc --noEmit
244
+
245
+ # Build integrity
246
+ npm run build
205
247
 
206
248
  # Pattern scanner
207
249
  bash scripts/massu-pattern-scanner.sh
208
250
 
209
- # Run tests
251
+ # Tests
210
252
  npm test
211
253
 
212
- # Hook build (if hooks modified)
213
- cd packages/core && npm run build:hooks
214
-
215
254
  # Security check
216
255
  git diff --cached --name-only | grep -E '\.(env|pem|key)' && echo "FAIL" || echo "PASS"
217
256
  ```
@@ -223,6 +262,7 @@ git diff --cached --name-only | grep -E '\.(env|pem|key)' && echo "FAIL" || echo
223
262
  | Check | Command | Result | Status |
224
263
  |-------|---------|--------|--------|
225
264
  | Types | npx tsc --noEmit | 0 errors | PASS |
265
+ | Build | npm run build | Exit 0 | PASS |
226
266
  | Patterns | massu-pattern-scanner.sh | Exit 0 | PASS |
227
267
  | Tests | npm test | All pass | PASS |
228
268
  | Secrets | git diff check | 0 files | PASS |
@@ -230,19 +270,13 @@ git diff --cached --name-only | grep -E '\.(env|pem|key)' && echo "FAIL" || echo
230
270
  **ALL CRITICAL CHECKS: PASS/FAIL**
231
271
  ```
232
272
 
233
- **If ANY check fails:**
234
- 1. Fix the issue
235
- 2. Re-run ALL checks (zero-gap loop)
236
- 3. Repeat until clean
237
-
238
273
  ---
239
274
 
240
- ## PHASE 5: COMMIT & PUSH
275
+ ## PHASE 5: COMMIT & DEPLOY
241
276
 
242
277
  ### 5.1 Commit with Hotfix Format
243
278
  ```bash
244
279
  git add [specific files only]
245
-
246
280
  git commit -m "$(cat <<'EOF'
247
281
  hotfix: [brief description]
248
282
 
@@ -251,7 +285,7 @@ Root cause: [what was wrong]
251
285
  Fix: [what was changed]
252
286
 
253
287
  Severity: P0/P1/P2
254
- Verified: types, patterns, tests
288
+ Verified: types, build, patterns, tests
255
289
 
256
290
  Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
257
291
  EOF
@@ -259,9 +293,6 @@ EOF
259
293
  ```
260
294
 
261
295
  ### 5.2 Create PR (If Required)
262
-
263
- Ask user before pushing:
264
-
265
296
  ```bash
266
297
  git push -u origin hotfix/[issue-name]
267
298
 
@@ -279,6 +310,7 @@ gh pr create --title "hotfix: [description]" --body "$(cat <<'EOF'
279
310
 
280
311
  ### Verification
281
312
  - [ ] Types pass
313
+ - [ ] Build passes
282
314
  - [ ] Pattern scanner passes
283
315
  - [ ] All tests pass
284
316
  - [ ] Tested fix locally
@@ -289,6 +321,138 @@ EOF
289
321
  )"
290
322
  ```
291
323
 
324
+ ### 5.3 Deploy
325
+ ```bash
326
+ # After PR approval (or direct push if P0)
327
+ git checkout main
328
+ git merge hotfix/[issue-name]
329
+ git push origin main
330
+
331
+ # Monitor deployment
332
+ ```
333
+
334
+ ---
335
+
336
+ ## PHASE 6: POST-DEPLOY VERIFICATION
337
+
338
+ ### 6.1 Verify Fix
339
+ ```markdown
340
+ ### Post-Deploy Verification
341
+
342
+ | Check | Result | Status |
343
+ |-------|--------|--------|
344
+ | Issue reproduced? | NO | PASS |
345
+ | Feature working? | YES | PASS |
346
+ | No new errors? | YES | PASS |
347
+ | Logs clean? | YES | PASS |
348
+ ```
349
+
350
+ ### 6.2 Monitor for Regressions
351
+ ```bash
352
+ # Check for new errors in output/logs
353
+ # Run tests again post-deploy
354
+ npm test
355
+ ```
356
+
357
+ ---
358
+
359
+ ## HOTFIX REPORT FORMAT
360
+
361
+ ```markdown
362
+ ## MASSU HOTFIX REPORT
363
+
364
+ ### Summary
365
+ - **Date**: [timestamp]
366
+ - **Severity**: P0/P1/P2
367
+ - **Time to Fix**: [duration]
368
+ - **Status**: RESOLVED
369
+
370
+ ### Issue
371
+ - **Symptom**: [what was broken]
372
+ - **Impact**: [who was affected]
373
+ - **Root Cause**: [technical cause]
374
+
375
+ ### Fix Applied
376
+ - **File(s)**: [paths]
377
+ - **Change**: [description]
378
+ - **Commit**: [hash]
379
+
380
+ ### Verification
381
+ | Check | Result |
382
+ |-------|--------|
383
+ | Types | PASS |
384
+ | Build | PASS |
385
+ | Patterns | PASS |
386
+ | Tests | PASS |
387
+
388
+ ### Rollback Plan
389
+ ```bash
390
+ git revert [commit-hash]
391
+ ```
392
+
393
+ ### Follow-up Required
394
+ - [ ] Add test coverage
395
+ - [ ] Review related code
396
+ - [ ] Root cause analysis
397
+
398
+ **HOTFIX COMPLETE**
399
+ ```
400
+
401
+ ---
402
+
403
+ ## SESSION STATE UPDATE
404
+
405
+ After hotfix, update `session-state/CURRENT.md`:
406
+
407
+ ```markdown
408
+ ## HOTFIX SESSION
409
+
410
+ ### Issue
411
+ - **Severity**: P0/P1/P2
412
+ - **Symptom**: [description]
413
+
414
+ ### Fix
415
+ - **File**: [path]
416
+ - **Change**: [description]
417
+ - **Commit**: [hash]
418
+
419
+ ### Status
420
+ - Applied: YES
421
+ - Verified: YES
422
+
423
+ ### Follow-up
424
+ [Any additional work needed]
425
+ ```
426
+
427
+ ---
428
+
429
+ ## MANDATORY PLAN DOCUMENT UPDATE (If Hotfix From Plan)
430
+
431
+ **If hotfix was derived from a plan document, update the plan with completion status.**
432
+
433
+ ### Plan Document Update (Add to TOP of plan if applicable)
434
+
435
+ ```markdown
436
+ # IMPLEMENTATION STATUS
437
+
438
+ **Plan**: [Plan Name]
439
+ **Status**: HOTFIX APPLIED
440
+ **Last Updated**: [YYYY-MM-DD HH:MM]
441
+
442
+ ## Hotfix Applied
443
+
444
+ | # | Fix Description | Status | Verification | Date |
445
+ |---|-----------------|--------|--------------|------|
446
+ | 1 | [Hotfix description] | COMPLETE | VR-TEST: Pass | [date] |
447
+
448
+ ## Verification Evidence
449
+
450
+ ### Hotfix: [Name]
451
+ - Command: `npm run build && npm test`
452
+ - Result: Exit 0
453
+ - Status: VERIFIED COMPLETE
454
+ ```
455
+
292
456
  ---
293
457
 
294
458
  ## ROLLBACK PROCEDURE
@@ -306,7 +470,7 @@ git push origin main
306
470
  ```bash
307
471
  # Confirm no new issues from hotfix revert
308
472
  npm test
309
- cd packages/core && npx tsc --noEmit
473
+ npx tsc --noEmit
310
474
  ```
311
475
 
312
476
  ---
@@ -338,9 +502,9 @@ echo "Hotfix aborted. Reason: [reason]"
338
502
  2. [ ] Check recent commits
339
503
  3. [ ] Find root cause
340
504
  4. [ ] Apply minimal fix
341
- 5. [ ] Type check + tests
342
- 6. [ ] Commit and push
343
- 7. [ ] Verify fix
505
+ 5. [ ] Type check + build + tests
506
+ 6. [ ] Deploy immediately
507
+ 7. [ ] Verify
344
508
  8. [ ] Document
345
509
 
346
510
  ### P1 Checklist (Feature Broken)
@@ -350,131 +514,44 @@ echo "Hotfix aborted. Reason: [reason]"
350
514
  4. [ ] Verify patterns
351
515
  5. [ ] Full verification
352
516
  6. [ ] PR + review
353
- 7. [ ] Push
517
+ 7. [ ] Deploy
354
518
  8. [ ] Verify + document
355
519
 
356
520
  ---
357
521
 
358
522
  ## START NOW
359
523
 
360
- **Step 0: Write AUTHORIZED_COMMAND to session state (CR-35)**
524
+ **Step 0: Write AUTHORIZED_COMMAND to session state (CR-12)**
361
525
 
362
- Update `session-state/CURRENT.md` to include `AUTHORIZED_COMMAND: massu-hotfix`.
526
+ Before any other work, update `session-state/CURRENT.md` to include:
527
+ ```
528
+ AUTHORIZED_COMMAND: massu-hotfix
529
+ ```
530
+ This ensures that if the session compacts, the recovery protocol knows only `/massu-hotfix` was authorized.
363
531
 
364
- Then:
365
532
  1. Triage: Assess severity and impact
366
533
  2. Investigate: Find root cause quickly
367
534
  3. Plan: Design minimal fix with rollback
368
535
  4. Implement: Make only the necessary change
369
536
  5. Verify: Run essential checks
370
- 6. Commit: Commit and push
371
- 7. Document: Update session state and report
537
+ 6. Deploy: Commit and push
538
+ 7. Confirm: Verify fix
539
+ 8. Document: Update session state and report
372
540
 
373
541
  **Remember: Fix the bug, only the bug, nothing but the bug.**
374
542
 
375
543
  ---
376
544
 
377
- ## MANDATORY PLAN DOCUMENT UPDATE (If Hotfix From Plan)
378
-
379
- **If hotfix was derived from a plan document, update the plan with completion status.**
380
-
381
- ```markdown
382
- # IMPLEMENTATION STATUS
383
-
384
- **Plan**: [Plan Name]
385
- **Status**: HOTFIX APPLIED
386
- **Last Updated**: [YYYY-MM-DD HH:MM]
387
-
388
- ## Hotfix Applied
389
-
390
- | # | Fix Description | Status | Verification | Date |
391
- |---|-----------------|--------|--------------|------|
392
- | 1 | [Hotfix description] | COMPLETE | VR-TEST: Pass | [date] |
393
- ```
394
-
395
- ---
396
-
397
- ## SESSION STATE UPDATE
398
-
399
- After hotfix, update `session-state/CURRENT.md`:
400
-
401
- ```markdown
402
- ## HOTFIX SESSION
403
-
404
- ### Issue
405
- - **Severity**: P0/P1/P2
406
- - **Symptom**: [description]
407
-
408
- ### Fix
409
- - **File**: [path]
410
- - **Change**: [description]
411
- - **Commit**: [hash]
412
-
413
- ### Status
414
- - Applied: YES
415
- - Verified: YES
416
-
417
- ### Follow-up
418
- [Any additional work needed]
419
- ```
420
-
421
- ---
422
-
423
545
  ## AUTO-LEARNING PROTOCOL (MANDATORY after every hotfix)
424
546
 
425
547
  **Every hotfix represents a failure that MUST be recorded so the system learns.**
426
548
 
427
- ### After Fix is Verified:
549
+ ### After Fix is Deployed and Verified:
428
550
 
429
- 1. **Record in session state**: Update `.claude/session-state/CURRENT.md` with the wrong pattern and correct pattern
430
- 2. **Add to pattern scanner**: If the bad pattern is grep-able, add detection to `scripts/massu-pattern-scanner.sh`
431
- 3. **Search codebase-wide**: `grep -rn "[bad_pattern]" packages/core/src/ --include="*.ts"` and fix ALL instances (CR-9)
432
- 4. **Consider new CR rule**: If this is a class of bug (not one-off), propose a new CR rule for CLAUDE.md
433
-
434
- **Hotfixes without learning are wasted crises. Every failure teaches something -- capture it.**
435
-
436
- ---
551
+ 1. **Ingest into massu memory**: Use `mcp__massu-codegraph__massu_memory_ingest` with type="bugfix", importance=5 (hotfixes are always high importance), description of root cause + fix
552
+ 2. **Record in session state**: Add the wrong pattern and correct pattern to `.claude/session-state/CURRENT.md`
553
+ 3. **Add to pattern scanner**: If the bad pattern is grep-able, add detection to `scripts/massu-pattern-scanner.sh`
554
+ 4. **Search codebase-wide**: `grep -rn "[bad_pattern]" packages/core/src/` and fix ALL instances (CR-9)
555
+ 5. **Consider new CR rule**: If this is a class of bug (not one-off), propose a new CR rule for CLAUDE.md
437
556
 
438
- ## COMPLETION REPORT
439
-
440
- ```markdown
441
- ## CS HOTFIX COMPLETE
442
-
443
- ### Summary
444
- - **Date**: [timestamp]
445
- - **Severity**: P0/P1/P2
446
- - **Time to Fix**: [duration]
447
- - **Status**: RESOLVED
448
-
449
- ### Issue
450
- - **Symptom**: [what was broken]
451
- - **Impact**: [what was affected]
452
- - **Root Cause**: [technical cause]
453
-
454
- ### Fix Applied
455
- - **File(s)**: [paths]
456
- - **Change**: [description]
457
- - **Branch**: hotfix/[description]
458
- - **Commit**: [hash]
459
-
460
- ### Verification
461
- | Check | Status |
462
- |-------|--------|
463
- | Type Safety | PASS |
464
- | Pattern Scanner | PASS |
465
- | Tests | PASS ([N] passed) |
466
-
467
- ### Rollback Plan
468
- git revert [commit-hash]
469
-
470
- ### PR (if created)
471
- - **URL**: [PR URL]
472
- - **Status**: Open
473
-
474
- ### Follow-up Required
475
- - [ ] Add test coverage for the bug
476
- - [ ] Review related code
477
- - [ ] Root cause analysis
478
-
479
- **HOTFIX COMPLETE**
480
- ```
557
+ **Hotfixes without learning are wasted crises. Every outage teaches something -- capture it.**
@@ -1,22 +1,23 @@
1
1
  ---
2
2
  name: massu-incident
3
3
  description: "When a bug is confirmed, a production issue is found, or user reports 'this broke', 'incident', 'production error' — triggers incident documentation protocol"
4
- allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*), mcp__massu-codegraph__massu_memory_ingest
5
5
  ---
6
6
  name: massu-incident
7
7
 
8
- # Massu Incident: Automated Post-Mortem & Prevention Pipeline
9
-
10
8
  > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding.
11
9
 
10
+ # Massu Incident: Automated Post-Mortem & Prevention Pipeline
11
+
12
12
  ## Objective
13
13
 
14
14
  When a bug is discovered that an audit should have caught, execute a
15
15
  structured post-mortem that AUTOMATICALLY:
16
16
  1. Logs the incident to INCIDENT-LOG.md
17
- 2. Proposes a new CR rule or VR-* check
18
- 3. Proposes a pattern-scanner addition
19
- 4. Updates relevant protocol files with incident reminder
17
+ 2. Ingests it into massu memory (high importance)
18
+ 3. Proposes a new CR rule or VR-* check
19
+ 4. Proposes a pattern-scanner addition
20
+ 5. Updates relevant protocol files with incident reminder
20
21
 
21
22
  ## INPUT
22
23
 
@@ -64,32 +65,54 @@ Append to `.claude/incidents/INCIDENT-LOG.md`:
64
65
  **Lesson**: [one-line lesson]
65
66
  ```
66
67
 
67
- ## STEP 4: PROPOSE PREVENTION
68
+ ## STEP 4: INGEST INTO MASSU MEMORY
69
+
70
+ Use `mcp__massu-codegraph__massu_memory_ingest` to record:
71
+ ```json
72
+ {
73
+ "type": "failed_attempt",
74
+ "title": "INCIDENT #[N]: [short title]",
75
+ "detail": "[root cause and lesson]",
76
+ "importance": 5,
77
+ "cr_rule": "[relevant CR]",
78
+ "files_involved": "[file list]"
79
+ }
80
+ ```
81
+
82
+ This ensures the incident surfaces automatically in future sessions
83
+ via the session-start hook's failed_attempt query.
84
+
85
+ ## STEP 5: PROPOSE PREVENTION
68
86
 
69
- ### 4a: New CR Rule (if pattern is new)
87
+ ### 5a: New CR Rule (if pattern is new)
70
88
  If the failure mode isn't covered by existing CRs:
71
89
  - Propose CR-[N+1] with rule text
72
90
  - Add to CLAUDE.md CR table
91
+ - Add to Zero Tolerance table
73
92
 
74
- ### 4b: New VR-* Check (always)
93
+ ### 5b: New VR-* Check (always)
75
94
  Every incident MUST produce a verifiable check:
76
95
  - Define the verification command
77
96
  - Add to VR table in CLAUDE.md
78
97
  - Specify when to run it
79
98
 
80
- ### 4c: Pattern Scanner Rule (if automatable)
99
+ ### 5c: Pattern Scanner Rule (if automatable)
81
100
  If the failure can be caught by grep:
82
101
  - Add rule to `scripts/pattern-scanner.sh`
83
102
  - Test it catches the original failure
84
103
  - Verify it doesn't false-positive
85
104
 
86
- ### 4d: Protocol Update (always)
105
+ ### 5d: Protocol Update (always)
87
106
  Add incident reminder to the protocol that should have caught it:
88
107
  - Add `## INCIDENT #[N] REMINDER` section
89
108
  - Explain the failure mode
90
109
  - Explain what to check for
91
110
 
92
- ## STEP 5: VERIFY PREVENTION WORKS
111
+ ## STEP 6: UPDATE CLAUDE.md INCIDENT SUMMARY
112
+
113
+ Update the incident count and add the new row to the incident table.
114
+
115
+ ## STEP 7: VERIFY PREVENTION WORKS
93
116
 
94
117
  ```bash
95
118
  # If pattern-scanner rule added:
@@ -97,6 +120,9 @@ Add incident reminder to the protocol that should have caught it:
97
120
 
98
121
  # If VR-* check added, run it:
99
122
  [verification command]
123
+
124
+ # Confirm incident is in memory:
125
+ # (will surface at next session start automatically)
100
126
  ```
101
127
 
102
128
  ## OUTPUT
@@ -106,21 +132,23 @@ Add incident reminder to the protocol that should have caught it:
106
132
 
107
133
  ### Incident #[N]: [Title]
108
134
  - Logged to: INCIDENT-LOG.md
135
+ - Ingested to: massu memory (importance: 5)
109
136
  - CR rule: [CR-XX added/updated]
110
137
  - VR check: [VR-XX added]
111
138
  - Pattern scanner: [rule added / not automatable]
112
139
  - Protocol updated: [which protocol]
113
140
 
114
141
  ### Prevention Chain
115
- 1. Pattern scanner: Will catch at pre-push
116
- 2. Protocol: Explicit reminder in [protocol name]
117
- 3. CR rule: Documented in CLAUDE.md
118
- 4. MEMORY.md: Wrong vs correct pattern recorded for all future sessions
142
+ 1. Memory: Will surface at session start in related domains
143
+ 2. Pattern scanner: Will catch at pre-push
144
+ 3. Protocol: Explicit reminder in [protocol name]
145
+ 4. CR rule: Documented in CLAUDE.md
146
+ 5. MEMORY.md: Wrong vs correct pattern recorded for all future sessions
119
147
 
120
- **This failure mode is now prevented at 4 levels.**
148
+ **This failure mode is now prevented at 5 levels.**
121
149
  ```
122
150
 
123
- ## STEP 6: UPDATE MEMORY.md (MANDATORY)
151
+ ## STEP 8: UPDATE MEMORY.md (MANDATORY)
124
152
 
125
153
  Every incident MUST be recorded in `memory/MEMORY.md` with the wrong vs correct pattern:
126
154
 
@@ -134,7 +162,7 @@ Every incident MUST be recorded in `memory/MEMORY.md` with the wrong vs correct
134
162
  This ensures that even without accessing the incident log, future sessions
135
163
  will have the pattern in their system prompt via MEMORY.md.
136
164
 
137
- ## STEP 7: CODEBASE-WIDE SEARCH (CR-9)
165
+ ## STEP 9: CODEBASE-WIDE SEARCH (CR-9)
138
166
 
139
167
  Search the ENTIRE codebase for the same bad pattern that caused the incident:
140
168
  ```bash
@@ -143,7 +171,7 @@ grep -rn "[bad_pattern]" src/ --include="*.ts" --include="*.tsx"
143
171
  Fix ALL instances found. The incident that triggered this post-mortem
144
172
  may not be the only occurrence.
145
173
 
146
- ## STEP 8: COUPLING CHECK
174
+ ## STEP 10: VR-COUPLING CHECK
147
175
 
148
176
  If the incident involved a feature that was implemented but not exposed in the UI, run the coupling check to verify all backend procedures have UI exposure:
149
177
 
@@ -156,6 +184,7 @@ If the incident involved a feature that was implemented but not exposed in the U
156
184
 
157
185
  ## Gotchas
158
186
 
187
+ - **Ingest to memory immediately** — every incident MUST be saved to `.claude/memory/` files BEFORE the session ends. Lost incident knowledge = repeated incidents
159
188
  - **Update INCIDENT-LOG.md** — every incident gets a numbered entry in `incidents/INCIDENT-LOG.md` with root cause, prevention, and CR reference
160
189
  - **Add CR if pattern emerges** — if the incident reveals a repeatable failure pattern, add a new Canonical Rule to CLAUDE.md
161
190
  - **Update pattern scanner** — if the incident could be caught by static analysis, add a check to `scripts/pattern-scanner.sh`