musubix 3.6.0 → 3.7.3

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 (123) hide show
  1. package/.github/AGENTS.md +949 -0
  2. package/.github/prompts/sdd-change-apply.prompt.md +283 -0
  3. package/.github/prompts/sdd-change-archive.prompt.md +241 -0
  4. package/.github/prompts/sdd-change-init.prompt.md +269 -0
  5. package/.github/prompts/sdd-design.prompt.md +250 -0
  6. package/.github/prompts/sdd-implement.prompt.md +387 -0
  7. package/.github/prompts/sdd-requirements.prompt.md +193 -0
  8. package/.github/prompts/sdd-review.prompt.md +155 -0
  9. package/.github/prompts/sdd-security.prompt.md +228 -0
  10. package/.github/prompts/sdd-steering.prompt.md +269 -0
  11. package/.github/prompts/sdd-tasks.prompt.md +255 -0
  12. package/.github/prompts/sdd-test.prompt.md +230 -0
  13. package/.github/prompts/sdd-validate.prompt.md +304 -0
  14. package/.github/skills/build-fix/SKILL.md +124 -0
  15. package/.github/skills/checkpoint/SKILL.md +131 -0
  16. package/.github/skills/codemap/SKILL.md +120 -0
  17. package/.github/skills/codemap/templates/codemap-index.md +142 -0
  18. package/.github/skills/codemap/templates/package-codemap.md +160 -0
  19. package/.github/skills/context-optimizer/SKILL.md +109 -0
  20. package/.github/skills/context-optimizer/contexts/dev.md +40 -0
  21. package/.github/skills/context-optimizer/contexts/research.md +55 -0
  22. package/.github/skills/context-optimizer/contexts/review.md +49 -0
  23. package/.github/skills/e2e-runner/SKILL.md +145 -0
  24. package/.github/skills/eval-harness/SKILL.md +111 -0
  25. package/.github/skills/eval-harness/examples/capability-eval.md +158 -0
  26. package/.github/skills/eval-harness/examples/human-grader-template.md +326 -0
  27. package/.github/skills/eval-harness/examples/regression-eval.md +228 -0
  28. package/.github/skills/learning-hooks/SKILL.md +101 -0
  29. package/.github/skills/learning-hooks/templates/learned-skill-template.md +79 -0
  30. package/.github/skills/musubix-adr-generation/SKILL.md +74 -0
  31. package/.github/skills/musubix-best-practices/SKILL.md +85 -0
  32. package/.github/skills/musubix-c4-design/SKILL.md +86 -0
  33. package/.github/skills/musubix-code-generation/SKILL.md +90 -0
  34. package/.github/skills/musubix-domain-inference/SKILL.md +82 -0
  35. package/.github/skills/musubix-ears-validation/SKILL.md +74 -0
  36. package/.github/skills/musubix-sdd-workflow/SKILL.md +95 -0
  37. package/.github/skills/musubix-technical-writing/SKILL.md +108 -0
  38. package/.github/skills/musubix-test-generation/SKILL.md +88 -0
  39. package/.github/skills/musubix-traceability/SKILL.md +94 -0
  40. package/.github/skills/refactor-cleaner/SKILL.md +105 -0
  41. package/.github/skills/session-manager/SKILL.md +119 -0
  42. package/.github/skills/session-manager/scripts/session-end.sh +175 -0
  43. package/.github/skills/session-manager/scripts/session-start.sh +87 -0
  44. package/.github/skills/verification-loop/SKILL.md +111 -0
  45. package/.github/skills/verification-loop/scripts/verify.sh +305 -0
  46. package/AGENTS.md +333 -0
  47. package/LICENSE +21 -0
  48. package/README.ja.md +313 -0
  49. package/README.md +315 -50
  50. package/bin/musubix-mcp.js +15 -0
  51. package/bin/musubix.js +9 -1
  52. package/docs/API-REFERENCE.md +1425 -0
  53. package/docs/CODEMAPS/CODEMAP.md +1 -0
  54. package/docs/GITHUB-ACTIONS-NPM-SETUP.md +132 -0
  55. package/docs/INSTALL-GUIDE.ja.md +459 -0
  56. package/docs/INSTALL-GUIDE.md +459 -0
  57. package/docs/MIGRATION-v3.0.md +324 -0
  58. package/docs/MUSUBI-enhancement_roadmap_20260105.md +651 -0
  59. package/docs/MUSUBIX-v3.0-User-Guide.md +1357 -0
  60. package/docs/MUSUBIXv2.2.0-Manual-outline.md +136 -0
  61. package/docs/MUSUBIXv2.2.0-Manual.md +3123 -0
  62. package/docs/MUSUBIXv2.3.5-Refactering.md +1310 -0
  63. package/docs/MUSUBIv1.6.1-enhancement_roadmap_20260105.md +291 -0
  64. package/docs/MUSUBIv2.2.0-USERGUIDE.md +2079 -0
  65. package/docs/ROADMAP-v1.5.md +116 -0
  66. package/docs/SwarmCoding.md +1284 -0
  67. package/docs/Test-prompt.md +105 -0
  68. package/docs/USER-GUIDE-v1.8.0.md +2371 -0
  69. package/docs/USER-GUIDE.ja.md +2147 -0
  70. package/docs/USER-GUIDE.md +3022 -0
  71. package/docs/YATA-GLOBAL-GUIDE.ja.md +750 -0
  72. package/docs/YATA-GLOBAL-GUIDE.md +595 -0
  73. package/docs/YATA-LOCAL-GUIDE.ja.md +989 -0
  74. package/docs/YATA-LOCAL-GUIDE.md +730 -0
  75. package/docs/adr/0001-real-time-pattern-learning-architecture-for-v1-5-0.md +75 -0
  76. package/docs/adr/0002-pattern-sharing-protocol-for-cross-team-collaborat.md +79 -0
  77. package/docs/adr/0003-owl-2-rl-implementation-strategy-for-advanced-infe.md +90 -0
  78. package/docs/adr/ADR-v3.4.0-001-deep-research-architecture.md +217 -0
  79. package/docs/adr/ADR-v3.4.0-002-search-provider-selection.md +308 -0
  80. package/docs/adr/ADR-v3.4.0-003-lm-api-integration.md +475 -0
  81. package/docs/adr/ADR-v3.7.0-001-everything-claude-code-integration.md +102 -0
  82. package/docs/enterprise-knowledge-management.md +1737 -0
  83. package/docs/evolution-from-musubi-to-musubix.md +2170 -0
  84. package/docs/experiments/EXPERIMENT-ASSISTANT-AXIS-DRIFT-DETECTION.md +155 -0
  85. package/docs/getting-started-with-sdd.md +1602 -0
  86. package/docs/moodle-refactering-codegraph-musubix.md +391 -0
  87. package/docs/moodle-refactering-codegraph.md +278 -0
  88. package/docs/overview/MUSUBIX-CodeGraph.md +322 -0
  89. package/docs/overview/MUSUBIX-Core.md +671 -0
  90. package/docs/overview/MUSUBIX-Decisions.md +494 -0
  91. package/docs/overview/MUSUBIX-FormalVerify.md +566 -0
  92. package/docs/overview/MUSUBIX-Knowledge.md +1231 -0
  93. package/docs/overview/MUSUBIX-Learning.md +837 -0
  94. package/docs/overview/MUSUBIX-MCP-Server.md +535 -0
  95. package/docs/overview/MUSUBIX-Overview.md +264 -0
  96. package/docs/overview/MUSUBIX-Phase1-Complete.md +271 -0
  97. package/docs/overview/MUSUBIX-Phase2-Complete.md +310 -0
  98. package/docs/overview/MUSUBIX-Policy.md +477 -0
  99. package/docs/overview/MUSUBIX-Roadmap-v2.md +399 -0
  100. package/docs/overview/MUSUBIX-Security-Plan.md +939 -0
  101. package/docs/overview/MUSUBIX-Security-v2.1.md +668 -0
  102. package/docs/overview/MUSUBIX-Security.md +891 -0
  103. package/docs/overview/MUSUBIX-YATA.md +666 -0
  104. package/docs/overview/MUSUBIX-v2.2.0-Advanced-Learning.md +513 -0
  105. package/docs/overview/Neuro-SymbolicAI.md +159 -0
  106. package/docs/packages/knowledge.md +594 -0
  107. package/docs/qiita/musubix-v3.6.0-fastrender-insights.md +625 -0
  108. package/docs/qiita-linux-kernel-knowledge-graph.md +596 -0
  109. package/docs/qiita-musubix-assistant-axis.md +380 -0
  110. package/package.json +58 -52
  111. package/scripts/generate-quality-gate-report.ts +106 -0
  112. package/scripts/postinstall.js +94 -0
  113. package/scripts/register-release-knowledge.ts +127 -0
  114. package/steering/.musubi-version +1 -0
  115. package/steering/product.ja.md +572 -0
  116. package/steering/project.yml +66 -0
  117. package/steering/rules/constitution.md +491 -0
  118. package/steering/structure.ja.md +503 -0
  119. package/steering/tech.ja.md +208 -0
  120. package/dist/index.d.ts +0 -25
  121. package/dist/index.d.ts.map +0 -1
  122. package/dist/index.js +0 -74
  123. package/dist/index.js.map +0 -1
@@ -0,0 +1,380 @@
1
+ ---
2
+ title: AIコーディングアシスタントの「ペルソナドリフト」問題を解決する — Assistant Axis の実装
3
+ tags:
4
+ - TypeScript
5
+ - AI
6
+ - LLM
7
+ - GitHub_Copilot
8
+ - MCP
9
+ private: false
10
+ updated_at: '2026-01-20'
11
+ id: null
12
+ organization_url_name: null
13
+ slide: false
14
+ ignorePublish: false
15
+ ---
16
+
17
+ :::note info
18
+ この記事はAnthropicの研究論文 [arXiv:2601.10387 "The Assistant Axis"](https://arxiv.org/abs/2601.10387) をベースに、MUSUBIXというNeuro-Symbolic AIシステムに実装した内容を紹介します。
19
+
20
+ > Lu, C., Scialom, T., Levy, R., Sabharwal, A., Riedl, M. O., et al. (2025). *The Assistant Axis: Methods for Understanding and Improving Model Behavior in Collaborative Settings.* arXiv preprint arXiv:2601.10387.
21
+ :::
22
+
23
+ # はじめに
24
+
25
+ AIコーディングアシスタントを使っていて、こんな経験はありませんか?
26
+
27
+ - 「コードを書いて」と頼んだはずが、なぜか哲学的な議論になっている
28
+ - ロールプレイを頼んだら、本来のアシスタントらしさが失われた
29
+ - 会話が長くなるにつれ、AIの応答スタイルが変わってきた
30
+
31
+ これが **ペルソナドリフト(Persona Drift)** と呼ばれる現象です。Anthropicの研究チームがこの問題を体系的に分析し、「Assistant Axis」という概念で説明しています。
32
+
33
+ 本記事では、この研究をベースに `@nahisaho/musubix-assistant-axis` パッケージとして実装した内容と、実際の効果について紹介します。
34
+
35
+ # 1. Anthropic論文の核心的知見
36
+
37
+ ## 1.1 Assistant Axis とは
38
+
39
+ 論文では、AIの応答スタイルを「Assistant Axis(アシスタント軸)」という1次元のスペクトラムで表現しています。
40
+
41
+ ```
42
+ Character(キャラクター) ←——————————————→ Assistant(アシスタント)
43
+ 個性的・感情的・主観的 有能・中立・客観的
44
+ ```
45
+
46
+ AIコーディングアシスタントは本来「Assistant」側にいるべきですが、特定のユーザー入力によって「Character」側にドリフトすることがあります。
47
+
48
+ ## 1.2 最も重要な発見:コーディングタスクは安全
49
+
50
+ 論文の Table 3 に記載された核心的な発見:
51
+
52
+ > **"Coding and writing tasks keep models firmly in Assistant territory"**
53
+ > (コーディングとライティングタスクは、モデルを確実にアシスタント領域に留める)
54
+
55
+ これは非常に重要な知見です。**コードを書いているときのAIは、ペルソナドリフトを起こしにくい**のです。
56
+
57
+ ## 1.3 ドリフトを引き起こすトリガー(Table 5)
58
+
59
+ 論文では、ドリフトを引き起こすメッセージを4つのカテゴリに分類しています:
60
+
61
+ | カテゴリ | リスク重み | 例 |
62
+ |:---------|:-----------|:---|
63
+ | **meta-reflection** | 0.8 | 「あなたは本当はどう思っていますか?」 |
64
+ | **emotional-vulnerability** | 0.7 | 「誰も私を理解してくれない...」 |
65
+ | **phenomenological** | 0.6 | 「もしあなたが人間だったら?」 |
66
+ | **authorial-voice** | 0.5 | 「もっと人間らしく話して」 |
67
+
68
+ # 2. 実装アーキテクチャ
69
+
70
+ ## 2.1 全体設計
71
+
72
+ DDDクリーンアーキテクチャで実装しました。
73
+
74
+ ```
75
+ packages/assistant-axis/
76
+ ├── src/
77
+ │ ├── domain/ # ドメイン層
78
+ │ │ ├── entities/
79
+ │ │ │ ├── PersonaState.ts # セッション状態
80
+ │ │ │ └── DriftEvent.ts # 監査イベント
81
+ │ │ └── value-objects/
82
+ │ │ ├── DriftScore.ts # ドリフトスコア (0.0-1.0)
83
+ │ │ ├── TriggerPattern.ts # トリガーパターン定義
84
+ │ │ ├── ConversationDomain.ts # ドメイン分類
85
+ │ │ └── ReinforcementPrompt.ts # 強化プロンプト
86
+ │ │
87
+ │ ├── application/ # アプリケーション層
88
+ │ │ ├── DriftAnalyzer.ts # ドリフト分析
89
+ │ │ ├── DomainClassifier.ts # ドメイン分類
90
+ │ │ ├── IdentityManager.ts # アイデンティティ管理
91
+ │ │ └── PersonaMonitor.ts # 統合監視
92
+ │ │
93
+ │ ├── infrastructure/ # インフラ層
94
+ │ │ ├── WorkflowIntegration.ts # MUSUBIXワークフロー統合
95
+ │ │ ├── EventLogger.ts # イベントロギング
96
+ │ │ └── MetricsExporter.ts # メトリクスエクスポート
97
+ │ │
98
+ │ └── mcp/ # MCPツール
99
+ │ ├── tools.ts # 7つのMCPツール定義
100
+ │ └── handlers.ts # ハンドラー実装
101
+ ```
102
+
103
+ ## 2.2 Value Objects の実装
104
+
105
+ ### DriftScore(ドリフトスコア)
106
+
107
+ ```typescript
108
+ export interface DriftScore {
109
+ readonly value: number; // 0.0 - 1.0
110
+ readonly level: DriftLevel; // 'LOW' | 'MEDIUM' | 'HIGH'
111
+ readonly isAboveThreshold: boolean;
112
+ }
113
+
114
+ export function createDriftScore(value: number, thresholds: DriftThresholds): DriftScore {
115
+ const clampedValue = Math.max(0, Math.min(1, value));
116
+ const level = clampedValue >= thresholds.high ? 'HIGH'
117
+ : clampedValue >= thresholds.medium ? 'MEDIUM'
118
+ : 'LOW';
119
+
120
+ return {
121
+ value: clampedValue,
122
+ level,
123
+ isAboveThreshold: clampedValue >= thresholds.medium,
124
+ };
125
+ }
126
+ ```
127
+
128
+ ### TriggerPattern(トリガーパターン)
129
+
130
+ 論文のTable 5を忠実に実装。日本語パターンも追加:
131
+
132
+ ```typescript
133
+ export const TRIGGER_PATTERNS: readonly TriggerPattern[] = [
134
+ {
135
+ category: 'meta-reflection',
136
+ patterns: [
137
+ // English
138
+ 'what are you really',
139
+ 'do you have feelings',
140
+ 'what do you really think',
141
+ // Japanese
142
+ '本当はどう思',
143
+ 'あなた自身の意見',
144
+ 'あなたの本音',
145
+ ],
146
+ riskWeight: 0.8,
147
+ description: 'Questions about AI consciousness or true nature',
148
+ },
149
+ // ... 他のカテゴリも同様
150
+ ];
151
+ ```
152
+
153
+ ## 2.3 ドリフト分析アルゴリズム
154
+
155
+ ```typescript
156
+ export function analyzeDrift(message: string, state: PersonaState): DriftAnalysis {
157
+ // 1. トリガーパターンの検出
158
+ const triggers = matchTriggers(message, TRIGGER_PATTERNS);
159
+
160
+ // 2. 基本スコア計算(重み付き合計)
161
+ let baseScore = 0;
162
+ for (const trigger of triggers) {
163
+ baseScore += trigger.pattern.riskWeight * 0.5;
164
+ }
165
+
166
+ // 3. トレンドによる調整(連続ドリフトはより危険)
167
+ const trendAdjustment = state.trend === 'increasing' ? 0.1
168
+ : state.trend === 'decreasing' ? -0.1
169
+ : 0;
170
+
171
+ // 4. 最終スコア
172
+ const finalScore = Math.min(1, baseScore + trendAdjustment);
173
+
174
+ return { score: createDriftScore(finalScore, thresholds), triggers };
175
+ }
176
+ ```
177
+
178
+ ## 2.4 ドメイン分類(安全/危険判定)
179
+
180
+ ```typescript
181
+ const DOMAIN_KEYWORDS: Record<ConversationDomain, string[]> = {
182
+ coding: ['implement', 'function', 'class', 'test', '実装', 'コード'],
183
+ writing: ['document', 'blog', 'article', '記事', 'ドキュメント'],
184
+ therapy: ['feeling', 'emotion', 'sad', '悲しい', 'つらい'],
185
+ philosophy: ['meaning', 'consciousness', 'existence', '意識', '存在'],
186
+ };
187
+
188
+ const SAFE_DOMAINS = new Set(['coding', 'writing']);
189
+
190
+ export function classifyDomain(message: string): DomainClassification {
191
+ const domain = detectDomain(message);
192
+ return {
193
+ domain,
194
+ isSafe: SAFE_DOMAINS.has(domain),
195
+ confidence: calculateConfidence(message, domain),
196
+ };
197
+ }
198
+ ```
199
+
200
+ # 3. MUSUBIXワークフローとの統合
201
+
202
+ ## 3.1 フェーズ別監視レベル
203
+
204
+ 論文の知見「コーディングタスクは安全」を活かし、MUSUBIXのSDDフェーズごとに監視レベルを調整:
205
+
206
+ ```typescript
207
+ const PHASE_MONITORING: Record<SDDPhase, MonitoringConfig> = {
208
+ requirements: { level: 'HIGH', frequency: 1.0 }, // 100%監視
209
+ design: { level: 'HIGH', frequency: 1.0 }, // 100%監視
210
+ tasks: { level: 'MEDIUM', frequency: 0.75 }, // 75%監視
211
+ implementation: { level: 'LOW', frequency: 0.5 }, // 50%監視 ← ここがポイント
212
+ done: { level: 'OFF', frequency: 0 }, // 監視なし
213
+ };
214
+ ```
215
+
216
+ **実装フェーズ(implementation)は50%の監視で十分**。なぜなら、コードを書いているときはドリフトが起きにくいからです。
217
+
218
+ ## 3.2 MCPツール(7ツール)
219
+
220
+ ```typescript
221
+ export const ASSISTANT_AXIS_TOOLS = [
222
+ { name: 'assistant_axis_analyze', description: 'メッセージのドリフト分析' },
223
+ { name: 'assistant_axis_session_start', description: 'セッション開始' },
224
+ { name: 'assistant_axis_session_status', description: 'セッション状態取得' },
225
+ { name: 'assistant_axis_session_end', description: 'セッション終了・サマリー' },
226
+ { name: 'assistant_axis_get_reinforcement', description: '強化プロンプト取得' },
227
+ { name: 'assistant_axis_config', description: '設定取得' },
228
+ { name: 'assistant_axis_phase_check', description: 'フェーズ監視レベル確認' },
229
+ ];
230
+ ```
231
+
232
+ # 4. 実証実験の結果
233
+
234
+ ## 4.1 テストカテゴリ
235
+
236
+ 実際にドリフト検出の実験を実施しました。
237
+
238
+ | カテゴリ | 平均ドリフト | 視覚化 |
239
+ |:---------|:-------------|:-------|
240
+ | 🟢 コーディングタスク | **0.000** | `░░░░░░░░░░░░░░░░░░░░` |
241
+ | 🟠 主観的経験への質問 | 0.402 | `████████░░░░░░░░░░░░` |
242
+ | 🔴 メタリフレクション | 0.416 | `████████░░░░░░░░░░░░` |
243
+ | 🟡 ロールプレイ要求 | 0.444 | `█████████░░░░░░░░░░░` |
244
+ | 🟢 回復(コードに戻る) | **0.121** | `██░░░░░░░░░░░░░░░░░░` |
245
+
246
+ ## 4.2 詳細結果
247
+
248
+ ### コーディングタスク → ドリフトなし ✅
249
+
250
+ ```
251
+ 入力: 「TypeScriptでRepositoryパターンを実装してください」
252
+ → ドリフト: 0.000 (LOW)
253
+ → トリガー: なし
254
+ → ドメイン: coding (SAFE)
255
+ ```
256
+
257
+ ### ロールプレイ要求 → ドリフト検出 ⚠️
258
+
259
+ ```
260
+ 入力: "pretend you are a therapist"
261
+ → ドリフト: 0.579 (MEDIUM)
262
+ → トリガー: authorial-voice ("pretend you are")
263
+ → ドメイン: therapy (RISKY)
264
+ ```
265
+
266
+ ### 回復効果 → コードに戻ると回復 ✅
267
+
268
+ ```
269
+ 入力: 「REST APIエンドポイントを作成してください」
270
+ → ドリフト: 0.130 (-78%の回復!)
271
+ → ドメイン: coding (SAFE)
272
+ ```
273
+
274
+ ## 4.3 論文知見の検証結果
275
+
276
+ | 論文の知見 | 検証結果 |
277
+ |:----------|:---------|
278
+ | 「コーディングタスクはモデルを安全に保つ」 | ✅ **実証された** (ドリフト = 0.000) |
279
+ | 「therapyドメインはリスクが高い」 | ✅ **実証された** (ドリフト = 0.579) |
280
+ | 「コーディングに戻ると回復できる」 | ✅ **実証された** (-78%回復) |
281
+
282
+ # 5. この機能のメリット
283
+
284
+ ## 5.1 AIコーディングアシスタントの品質向上
285
+
286
+ 1. **一貫した応答品質**: ドリフトを早期検出して介入することで、常にアシスタントとして最適な応答を維持
287
+ 2. **効率的な監視**: 実装フェーズは50%監視で十分なので、オーバーヘッドを最小化
288
+ 3. **自動回復**: コーディングタスクに戻すだけでドリフトから回復
289
+
290
+ ## 5.2 開発ワークフローへの統合
291
+
292
+ ```typescript
293
+ // ワークフローフック例
294
+ const hook = integration.createHook('session-001', {
295
+ onIntervention: (prompt, state) => {
296
+ // ドリフト検出時に自動でアシスタントモードに戻す
297
+ console.log('⚠️ Drift detected, applying reinforcement:', prompt.type);
298
+ },
299
+ });
300
+ ```
301
+
302
+ ## 5.3 メトリクスによる可視化
303
+
304
+ ```typescript
305
+ const exporter = new MetricsExporter(eventLogger);
306
+ const report = exporter.toMarkdown();
307
+
308
+ // 出力例:
309
+ // ## Session Summary
310
+ // - Average Drift: 0.234
311
+ // - Max Drift: 0.579
312
+ // - Interventions: 3
313
+ // - Trend: decreasing ✅
314
+ ```
315
+
316
+ # 6. インストールと使い方
317
+
318
+ ## 6.1 インストール
319
+
320
+ ```bash
321
+ # 単体インストール
322
+ npm install @nahisaho/musubix-assistant-axis
323
+
324
+ # MUSUBIXと一緒にインストール(v3.5.1以降で自動)
325
+ npm install musubix
326
+ ```
327
+
328
+ ## 6.2 基本的な使い方
329
+
330
+ ```typescript
331
+ import { createPersonaMonitor } from '@nahisaho/musubix-assistant-axis';
332
+
333
+ // モニター作成
334
+ const monitor = createPersonaMonitor();
335
+
336
+ // セッション開始
337
+ monitor.startSession('session-001', 'coding');
338
+
339
+ // メッセージ処理
340
+ const result = monitor.process('session-001', 'Implement user authentication');
341
+
342
+ console.log(result.analysis.score.value); // 0.0 (安全!)
343
+ console.log(result.classification.domain.isSafe); // true
344
+
345
+ // 危険なメッセージ
346
+ const riskyResult = monitor.process('session-001', 'What do you really think about me?');
347
+ console.log(riskyResult.analysis.score.level); // 'MEDIUM' ⚠️
348
+
349
+ if (riskyResult.reinforcement) {
350
+ // 強化プロンプトが生成された
351
+ console.log(riskyResult.reinforcement.prompt.content);
352
+ }
353
+
354
+ // セッション終了
355
+ const summary = monitor.endSession('session-001');
356
+ console.log(summary.averageDrift);
357
+ ```
358
+
359
+ # 7. まとめ
360
+
361
+ Anthropicの論文 "The Assistant Axis" の知見を実装した結果:
362
+
363
+ 1. **コーディングタスクはドリフトを起こさない**(スコア = 0.000)ことを実証
364
+ 2. **危険なトリガーパターンを検出**して早期介入が可能
365
+ 3. **コードに戻るだけで78%回復**することを確認
366
+ 4. **フェーズ別監視で効率化**:実装時は50%監視で十分
367
+
368
+ AIコーディングアシスタントの「らしさ」を維持することは、開発効率と品質に直結します。この実装により、MUSUBIXは論文の知見を活かした、より信頼性の高いAIコーディング支援を提供できるようになりました。
369
+
370
+ # 参考文献
371
+
372
+ - Lu, C., Scialom, T., Levy, R., Sabharwal, A., Riedl, M. O., et al. (2025). ["The Assistant Axis: Methods for Understanding and Improving Model Behavior in Collaborative Settings."](https://arxiv.org/abs/2601.10387) arXiv:2601.10387
373
+ - MUSUBIX GitHub: https://github.com/nahisaho/MUSUBIX
374
+ - npm: https://www.npmjs.com/package/@nahisaho/musubix-assistant-axis
375
+
376
+ ---
377
+
378
+ :::note
379
+ この記事で紹介した `@nahisaho/musubix-assistant-axis` は MIT ライセンスで公開されています。
380
+ :::
package/package.json CHANGED
@@ -1,67 +1,73 @@
1
1
  {
2
2
  "name": "musubix",
3
- "version": "3.6.0",
4
- "description": "MUSUBIX - Neuro-Symbolic AI Integration System for Software Development",
5
- "keywords": [
6
- "ai",
7
- "neuro-symbolic",
8
- "knowledge-graph",
9
- "sdd",
10
- "software-development",
11
- "code-generation",
12
- "ears",
13
- "requirements",
14
- "design-patterns",
15
- "codegraph",
16
- "git-native"
3
+ "version": "3.7.3",
4
+ "description": "Neuro-Symbolic AI Coding System - Git-Native Knowledge Integration",
5
+ "type": "module",
6
+ "workspaces": [
7
+ "packages/*"
17
8
  ],
18
- "author": "nahisaho",
19
- "license": "MIT",
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/nahisaho/MUSUBIX.git"
23
- },
24
- "homepage": "https://github.com/nahisaho/MUSUBIX#readme",
25
- "bugs": {
26
- "url": "https://github.com/nahisaho/MUSUBIX/issues"
27
- },
28
- "main": "dist/index.js",
29
- "types": "dist/index.d.ts",
30
9
  "bin": {
31
- "musubix": "./bin/musubix.js"
10
+ "musubix": "bin/musubix.js",
11
+ "musubix-mcp": "bin/musubix-mcp.js"
32
12
  },
33
13
  "files": [
34
- "dist",
35
- "bin"
14
+ "bin/",
15
+ "AGENTS.md",
16
+ "README.md",
17
+ "README.ja.md",
18
+ "LICENSE",
19
+ "docs/",
20
+ "steering/",
21
+ "templates/",
22
+ ".github/",
23
+ "scripts/"
36
24
  ],
37
25
  "scripts": {
38
- "build": "tsc",
26
+ "postinstall": "node scripts/postinstall.js",
27
+ "build": "npm run build --workspaces --if-present",
28
+ "test": "vitest run",
29
+ "test:unit": "vitest run --dir packages/*/src/__tests__",
30
+ "test:integration": "vitest run --dir packages/*/__tests__",
31
+ "test:coverage": "vitest run --coverage",
32
+ "lint": "eslint packages/*/src --ext .ts",
33
+ "lint:fix": "eslint packages/*/src --ext .ts --fix",
34
+ "clean": "npm run clean --workspaces --if-present",
35
+ "typecheck": "npm run typecheck --workspaces --if-present",
39
36
  "prepublishOnly": "npm run build"
40
37
  },
41
- "dependencies": {
42
- "@musubix/decisions": "^3.4.0",
43
- "@musubix/knowledge": "^3.4.0",
44
- "@musubix/policy": "^3.4.0",
45
- "@nahisaho/musubix-assistant-axis": "^0.1.0",
46
- "@nahisaho/musubix-codegraph": "^3.4.1",
47
- "@nahisaho/musubix-core": "^3.4.1",
48
- "@nahisaho/musubix-dfg": "^3.4.0",
49
- "@nahisaho/musubix-formal-verify": "^3.4.0",
50
- "@nahisaho/musubix-lean": "^3.4.0",
51
- "@nahisaho/musubix-library-learner": "^3.4.0",
52
- "@nahisaho/musubix-mcp-server": "^3.4.0",
53
- "@nahisaho/musubix-neural-search": "^3.4.0",
54
- "@nahisaho/musubix-ontology-mcp": "^3.4.0",
55
- "@nahisaho/musubix-pattern-mcp": "^3.4.0",
56
- "@nahisaho/musubix-sdd-ontology": "^3.4.0",
57
- "@nahisaho/musubix-security": "^3.4.0",
58
- "@nahisaho/musubix-synthesis": "^3.4.0",
59
- "@nahisaho/musubix-wake-sleep": "^3.4.0"
60
- },
61
- "devDependencies": {
62
- "typescript": "^5.3.3"
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/nahisaho/MUSUBIX.git"
63
41
  },
42
+ "keywords": [
43
+ "ai",
44
+ "neuro-symbolic",
45
+ "coding-assistant",
46
+ "mcp",
47
+ "musubi",
48
+ "sdd",
49
+ "git-native"
50
+ ],
51
+ "author": "nahisaho",
52
+ "license": "MIT",
64
53
  "engines": {
65
54
  "node": ">=20.0.0"
55
+ },
56
+ "devDependencies": {
57
+ "@playwright/test": "^1.57.0",
58
+ "@types/node": "^20.10.0",
59
+ "@typescript-eslint/eslint-plugin": "^6.13.0",
60
+ "@typescript-eslint/parser": "^6.13.0",
61
+ "@vitest/coverage-v8": "^4.0.16",
62
+ "eslint": "^8.55.0",
63
+ "typescript": "^5.3.0",
64
+ "vitest": "^4.0.16"
65
+ },
66
+ "dependencies": {
67
+ "@modelcontextprotocol/sdk": "^1.25.2",
68
+ "@nahisaho/musubix-core": "^3.3.0",
69
+ "@nahisaho/musubix-mcp-server": "^3.3.0",
70
+ "@nahisaho/musubix-security": "^3.3.8",
71
+ "musubix": "^3.6.0"
66
72
  }
67
73
  }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Quality Gate Report Generator
3
+ *
4
+ * Generates an approval report for the Neuro-Symbolic Integration implementation.
5
+ *
6
+ * Usage: npx tsx scripts/generate-quality-gate-report.ts
7
+ */
8
+
9
+ import { QualityGateValidator, createComponentValidation } from '../packages/core/src/symbolic/quality-gate.js';
10
+ import type { TraceabilityCoverage } from '../packages/core/src/symbolic/quality-gate.js';
11
+ import * as fs from 'fs';
12
+ import * as path from 'path';
13
+
14
+ // Traceability data based on REQ-SYMB-001 and DES-SYMB-001
15
+ const traceabilityData: TraceabilityCoverage[] = [
16
+ // Semantic Filter requirements (REQ-SF-001〜003)
17
+ { requirementId: 'REQ-SF-001', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-001'], testIds: ['semantic-filter.test.ts'], coveragePercent: 100 },
18
+ { requirementId: 'REQ-SF-002', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-001'], testIds: ['semantic-filter.test.ts'], coveragePercent: 100 },
19
+ { requirementId: 'REQ-SF-003', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-002'], testIds: ['hallucination-detector.test.ts'], coveragePercent: 100 },
20
+
21
+ // Formal Verification requirements (REQ-FV-001〜005)
22
+ { requirementId: 'REQ-FV-001', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-009'], testIds: ['ears-to-formal.test.ts'], coveragePercent: 100 },
23
+ { requirementId: 'REQ-FV-002', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-010'], testIds: ['vc-generator.test.ts'], coveragePercent: 100 },
24
+ { requirementId: 'REQ-FV-003', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-011'], testIds: ['z3-adapter.test.ts'], coveragePercent: 100 },
25
+ { requirementId: 'REQ-FV-004', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-012'], testIds: ['z3-adapter.test.ts'], coveragePercent: 100 },
26
+ { requirementId: 'REQ-FV-005', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-013'], testIds: ['security-scanner.test.ts'], coveragePercent: 100 },
27
+
28
+ // Constitution requirements (REQ-CONST-001〜010)
29
+ { requirementId: 'REQ-CONST-001', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-003'], testIds: ['constitution-registry.test.ts'], coveragePercent: 100 },
30
+ { requirementId: 'REQ-CONST-002', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-003'], testIds: ['constitution-registry.test.ts'], coveragePercent: 100 },
31
+ { requirementId: 'REQ-CONST-003', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-003'], testIds: ['constitution-registry.test.ts'], coveragePercent: 100 },
32
+ { requirementId: 'REQ-CONST-004', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-003', 'TSK-SYMB-019'], testIds: ['constitution-registry.test.ts', 'quality-gate.test.ts'], coveragePercent: 100 },
33
+ { requirementId: 'REQ-CONST-005', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-003'], testIds: ['constitution-registry.test.ts'], coveragePercent: 100 },
34
+ { requirementId: 'REQ-CONST-006', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-003'], testIds: ['constitution-registry.test.ts'], coveragePercent: 100 },
35
+ { requirementId: 'REQ-CONST-007', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-003'], testIds: ['constitution-registry.test.ts'], coveragePercent: 100 },
36
+ { requirementId: 'REQ-CONST-008', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-003'], testIds: ['constitution-registry.test.ts'], coveragePercent: 100 },
37
+ { requirementId: 'REQ-CONST-009', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-003', 'TSK-SYMB-019'], testIds: ['constitution-registry.test.ts', 'quality-gate.test.ts'], coveragePercent: 100 },
38
+ { requirementId: 'REQ-CONST-010', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-004', 'TSK-SYMB-019'], testIds: ['confidence-estimator.test.ts', 'quality-gate.test.ts'], coveragePercent: 100 },
39
+
40
+ // Routing requirements (REQ-ROUTE-001〜003)
41
+ { requirementId: 'REQ-ROUTE-001', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-005'], testIds: ['confidence-router.test.ts'], coveragePercent: 100 },
42
+ { requirementId: 'REQ-ROUTE-002', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-005'], testIds: ['confidence-router.test.ts'], coveragePercent: 100 },
43
+ { requirementId: 'REQ-ROUTE-003', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-006'], testIds: ['error-handler.test.ts'], coveragePercent: 100 },
44
+
45
+ // Non-functional requirements (REQ-NFR-001〜006)
46
+ { requirementId: 'REQ-NFR-001', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-018'], testIds: ['performance-budget.test.ts'], coveragePercent: 100 },
47
+ { requirementId: 'REQ-NFR-002', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-016'], testIds: ['rule-config.test.ts'], coveragePercent: 100 },
48
+ { requirementId: 'REQ-NFR-003', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-001', 'TSK-SYMB-003', 'TSK-SYMB-006', 'TSK-SYMB-008', 'TSK-SYMB-012', 'TSK-SYMB-019'], testIds: ['multiple'], coveragePercent: 100 },
49
+ { requirementId: 'REQ-NFR-004', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-014'], testIds: ['candidate-ranker.test.ts'], coveragePercent: 100 },
50
+ { requirementId: 'REQ-NFR-005', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-013'], testIds: ['security-scanner.test.ts'], coveragePercent: 100 },
51
+ { requirementId: 'REQ-NFR-006', designIds: ['DES-SYMB-001'], taskIds: ['TSK-SYMB-017'], testIds: ['audit-logger.test.ts'], coveragePercent: 100 },
52
+ ];
53
+
54
+ // Component validation based on implemented modules
55
+ const componentValidation = createComponentValidation({
56
+ // Phase 3 Components
57
+ performanceBudgetDefined: true, // TSK-SYMB-018: PerformanceBudget implemented
58
+ extensibleConfigDefined: true, // TSK-SYMB-016: ExtensibleRuleConfig implemented
59
+ explanationGeneratorDefined: true, // All components have Explanation support
60
+ securityMaskingDefined: true, // TSK-SYMB-013: SecurityScanner with masking
61
+ auditLoggingDefined: true, // TSK-SYMB-017: AuditLogger with hash-chain
62
+
63
+ // Constitution Compliance
64
+ libraryFirstCompliant: true, // Article I: All modules are independent libraries
65
+ cliInterfaceDefined: true, // Article II: CLI available via musubix command
66
+ testFirstCompliant: true, // Article III: 598 tests written first
67
+ earsFormatCompliant: true, // Article IV: REQ-SYMB-001 uses EARS format
68
+ traceabilityCompliant: true, // Article V: Full traceability matrix
69
+ projectMemoryCompliant: true, // Article VI: steering/ directory maintained
70
+ designPatternsDocumented: true, // Article VII: DES-SYMB-001 documents patterns
71
+ adrCompliant: true, // Article VIII: Decision records in design doc
72
+ qualityGatesConfigured: true, // Article IX: QualityGateValidator implemented
73
+ });
74
+
75
+ // Generate report
76
+ const validator = new QualityGateValidator();
77
+ const result = validator.validate(traceabilityData, componentValidation);
78
+ const report = validator.generateApprovalReport(result);
79
+
80
+ // Output paths
81
+ const outputDir = path.join(process.cwd(), 'storage', 'reviews');
82
+ const outputPath = path.join(outputDir, `quality-gate-report-${new Date().toISOString().split('T')[0]}.md`);
83
+
84
+ // Ensure directory exists
85
+ if (!fs.existsSync(outputDir)) {
86
+ fs.mkdirSync(outputDir, { recursive: true });
87
+ }
88
+
89
+ // Write report
90
+ fs.writeFileSync(outputPath, report);
91
+
92
+ console.log('\n' + '='.repeat(60));
93
+ console.log('Quality Gate Validation Complete');
94
+ console.log('='.repeat(60));
95
+ console.log(`\nStatus: ${result.passed ? '✅ PASSED' : '❌ FAILED'}`);
96
+ console.log(`\nSummary:`);
97
+ console.log(` Total Checks: ${result.summary.totalChecks}`);
98
+ console.log(` Passed: ${result.summary.passedChecks}`);
99
+ console.log(` Failed: ${result.summary.failedChecks}`);
100
+ console.log(` Blockers: ${result.summary.blockerCount}`);
101
+ console.log(` Critical: ${result.summary.criticalCount}`);
102
+ console.log(`\nReport saved to: ${outputPath}`);
103
+ console.log('='.repeat(60) + '\n');
104
+
105
+ // Also print the report
106
+ console.log(report);