musubix 3.4.5 → 3.4.7

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 (95) 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/musubix-adr-generation/SKILL.md +209 -0
  15. package/.github/skills/musubix-best-practices/SKILL.md +315 -0
  16. package/.github/skills/musubix-c4-design/SKILL.md +162 -0
  17. package/.github/skills/musubix-code-generation/SKILL.md +237 -0
  18. package/.github/skills/musubix-domain-inference/SKILL.md +196 -0
  19. package/.github/skills/musubix-ears-validation/SKILL.md +161 -0
  20. package/.github/skills/musubix-sdd-workflow/SKILL.md +217 -0
  21. package/.github/skills/musubix-technical-writing/SKILL.md +444 -0
  22. package/.github/skills/musubix-test-generation/SKILL.md +212 -0
  23. package/.github/skills/musubix-traceability/SKILL.md +141 -0
  24. package/AGENTS.md +1134 -0
  25. package/LICENSE +21 -0
  26. package/README.ja.md +313 -0
  27. package/README.md +315 -50
  28. package/bin/musubix-mcp.js +15 -0
  29. package/bin/musubix.js +9 -1
  30. package/docs/API-REFERENCE.md +1425 -0
  31. package/docs/GITHUB-ACTIONS-NPM-SETUP.md +132 -0
  32. package/docs/INSTALL-GUIDE.ja.md +459 -0
  33. package/docs/INSTALL-GUIDE.md +459 -0
  34. package/docs/MIGRATION-v3.0.md +324 -0
  35. package/docs/MUSUBI-enhancement_roadmap_20260105.md +651 -0
  36. package/docs/MUSUBIX-v3.0-User-Guide.md +1357 -0
  37. package/docs/MUSUBIXv2.2.0-Manual-outline.md +136 -0
  38. package/docs/MUSUBIXv2.2.0-Manual.md +3123 -0
  39. package/docs/MUSUBIXv2.3.5-Refactering.md +1310 -0
  40. package/docs/MUSUBIv1.6.1-enhancement_roadmap_20260105.md +291 -0
  41. package/docs/MUSUBIv2.2.0-USERGUIDE.md +2079 -0
  42. package/docs/ROADMAP-v1.5.md +116 -0
  43. package/docs/SwarmCoding.md +1284 -0
  44. package/docs/Test-prompt.md +105 -0
  45. package/docs/USER-GUIDE-v1.8.0.md +2371 -0
  46. package/docs/USER-GUIDE.ja.md +2147 -0
  47. package/docs/USER-GUIDE.md +3022 -0
  48. package/docs/YATA-GLOBAL-GUIDE.ja.md +750 -0
  49. package/docs/YATA-GLOBAL-GUIDE.md +595 -0
  50. package/docs/YATA-LOCAL-GUIDE.ja.md +989 -0
  51. package/docs/YATA-LOCAL-GUIDE.md +730 -0
  52. package/docs/adr/0001-real-time-pattern-learning-architecture-for-v1-5-0.md +75 -0
  53. package/docs/adr/0002-pattern-sharing-protocol-for-cross-team-collaborat.md +79 -0
  54. package/docs/adr/0003-owl-2-rl-implementation-strategy-for-advanced-infe.md +90 -0
  55. package/docs/adr/ADR-v3.4.0-001-deep-research-architecture.md +217 -0
  56. package/docs/adr/ADR-v3.4.0-002-search-provider-selection.md +308 -0
  57. package/docs/adr/ADR-v3.4.0-003-lm-api-integration.md +475 -0
  58. package/docs/enterprise-knowledge-management.md +1737 -0
  59. package/docs/evolution-from-musubi-to-musubix.md +2170 -0
  60. package/docs/getting-started-with-sdd.md +1602 -0
  61. package/docs/moodle-refactering-codegraph-musubix.md +391 -0
  62. package/docs/moodle-refactering-codegraph.md +278 -0
  63. package/docs/overview/MUSUBIX-CodeGraph.md +322 -0
  64. package/docs/overview/MUSUBIX-Core.md +671 -0
  65. package/docs/overview/MUSUBIX-Decisions.md +494 -0
  66. package/docs/overview/MUSUBIX-FormalVerify.md +566 -0
  67. package/docs/overview/MUSUBIX-Knowledge.md +1231 -0
  68. package/docs/overview/MUSUBIX-Learning.md +837 -0
  69. package/docs/overview/MUSUBIX-MCP-Server.md +535 -0
  70. package/docs/overview/MUSUBIX-Overview.md +264 -0
  71. package/docs/overview/MUSUBIX-Phase1-Complete.md +271 -0
  72. package/docs/overview/MUSUBIX-Phase2-Complete.md +310 -0
  73. package/docs/overview/MUSUBIX-Policy.md +477 -0
  74. package/docs/overview/MUSUBIX-Roadmap-v2.md +399 -0
  75. package/docs/overview/MUSUBIX-Security-Plan.md +939 -0
  76. package/docs/overview/MUSUBIX-Security-v2.1.md +668 -0
  77. package/docs/overview/MUSUBIX-Security.md +891 -0
  78. package/docs/overview/MUSUBIX-YATA.md +666 -0
  79. package/docs/overview/MUSUBIX-v2.2.0-Advanced-Learning.md +513 -0
  80. package/docs/overview/Neuro-SymbolicAI.md +159 -0
  81. package/docs/packages/knowledge.md +594 -0
  82. package/docs/qiita-linux-kernel-knowledge-graph.md +596 -0
  83. package/package.json +58 -51
  84. package/scripts/generate-quality-gate-report.ts +106 -0
  85. package/scripts/postinstall.js +94 -0
  86. package/steering/.musubi-version +1 -0
  87. package/steering/product.ja.md +572 -0
  88. package/steering/project.yml +66 -0
  89. package/steering/rules/constitution.md +491 -0
  90. package/steering/structure.ja.md +503 -0
  91. package/steering/tech.ja.md +208 -0
  92. package/dist/index.d.ts +0 -25
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/index.js +0 -74
  95. package/dist/index.js.map +0 -1
@@ -0,0 +1,837 @@
1
+ # MUSUBIX 学習システム パッケージ群
2
+
3
+ **関連パッケージ**:
4
+ - `@nahisaho/musubix-pattern-mcp`
5
+ - `@nahisaho/musubix-ontology-mcp`
6
+ - `@nahisaho/musubix-wake-sleep`
7
+ - `@nahisaho/musubix-sdd-ontology`
8
+
9
+ **バージョン**: 1.7.5
10
+ **最終更新**: 2026-01-06
11
+
12
+ ---
13
+
14
+ ## 1. 学習システム概要
15
+
16
+ MUSUBIXの学習システムは、AIエージェントの継続的な改善を実現します。Wake-Sleepサイクル、パターン学習、オントロジー管理を統合した自律学習機能を提供します。
17
+
18
+ ### 1.1 学習アーキテクチャ
19
+
20
+ ```
21
+ ┌─────────────────────────────────────────────────────────────┐
22
+ │ Wake-Sleep Cycle │
23
+ │ ┌──────────────────────┐ ┌──────────────────────┐ │
24
+ │ │ Wake Phase │ │ Sleep Phase │ │
25
+ │ │ ・コード観察 │ │ ・パターン統合 │ │
26
+ │ │ ・パターン抽出 │ │ ・類似パターン圧縮 │ │
27
+ │ │ ・知識グラフ更新 │ │ ・メモリ最適化 │ │
28
+ │ └──────────┬───────────┘ └───────────┬──────────┘ │
29
+ │ │ │ │
30
+ │ └────────────┬───────────────┘ │
31
+ │ ▼ │
32
+ │ ┌───────────────────────────────────────────────────────┐ │
33
+ │ │ Pattern Library │ │
34
+ │ │ ・抽出パターン ・圧縮パターン ・信頼度スコア │ │
35
+ │ └───────────────────────────────────────────────────────┘ │
36
+ │ │ │
37
+ │ ▼ │
38
+ │ ┌───────────────────────────────────────────────────────┐ │
39
+ │ │ Ontology Store (N3) │ │
40
+ │ │ ・RDF/OWL知識 ・推論ルール ・ドメインオントロジー │ │
41
+ │ └───────────────────────────────────────────────────────┘ │
42
+ └─────────────────────────────────────────────────────────────┘
43
+ ```
44
+
45
+ ### 1.2 パッケージ構成
46
+
47
+ | パッケージ | 役割 |
48
+ |-----------|------|
49
+ | **pattern-mcp** | パターン抽出・圧縮・ライブラリ管理 |
50
+ | **ontology-mcp** | N3Store・推論エンジン・オントロジー管理 |
51
+ | **wake-sleep** | Wake-Sleep学習サイクル制御 |
52
+ | **sdd-ontology** | SDD方法論のオントロジー定義 |
53
+
54
+ ---
55
+
56
+ ## 2. Pattern MCP
57
+
58
+ ### 2.1 概要
59
+
60
+ `@nahisaho/musubix-pattern-mcp` は、コードからパターンを抽出・圧縮し、再利用可能な形式で管理します。
61
+
62
+ ### 2.2 アーキテクチャ
63
+
64
+ ```
65
+ packages/pattern-mcp/src/
66
+ ├── extractor/
67
+ │ ├── ast-analyzer.ts # AST解析
68
+ │ ├── pattern-detector.ts # パターン検出
69
+ │ └── feature-extractor.ts # 特徴抽出
70
+ ├── compressor/
71
+ │ ├── similarity.ts # 類似度計算
72
+ │ ├── merger.ts # パターン統合
73
+ │ └── abstractor.ts # 抽象化
74
+ ├── library/
75
+ │ ├── pattern-store.ts # パターンストア
76
+ │ ├── indexer.ts # インデックス
77
+ │ └── search.ts # 検索
78
+ ├── tools/
79
+ │ └── pattern-tools.ts # MCPツール
80
+ └── index.ts
81
+ ```
82
+
83
+ ### 2.3 主要機能
84
+
85
+ #### 2.3.1 パターン抽出
86
+
87
+ コードからパターンを自動抽出します。
88
+
89
+ ```typescript
90
+ import { PatternExtractor } from '@nahisaho/musubix-pattern-mcp';
91
+
92
+ const extractor = new PatternExtractor();
93
+
94
+ const patterns = await extractor.extract(`
95
+ class UserService {
96
+ constructor(private readonly userRepo: UserRepository) {}
97
+
98
+ async findUser(id: string): Promise<User | null> {
99
+ return this.userRepo.findById(id);
100
+ }
101
+ }
102
+ `);
103
+
104
+ // 抽出結果
105
+ // {
106
+ // patterns: [
107
+ // {
108
+ // name: 'repository-pattern',
109
+ // type: 'design-pattern',
110
+ // confidence: 0.95,
111
+ // features: ['dependency-injection', 'async-method', 'repository-access']
112
+ // }
113
+ // ]
114
+ // }
115
+ ```
116
+
117
+ #### 2.3.2 パターン圧縮
118
+
119
+ 類似パターンを統合・抽象化します。
120
+
121
+ ```typescript
122
+ import { PatternCompressor } from '@nahisaho/musubix-pattern-mcp';
123
+
124
+ const compressor = new PatternCompressor();
125
+
126
+ // 類似パターンの統合
127
+ const compressed = await compressor.compress(patterns, {
128
+ similarityThreshold: 0.8,
129
+ minOccurrences: 3,
130
+ });
131
+
132
+ // 抽象化
133
+ const abstracted = await compressor.abstract(pattern, {
134
+ level: 'high', // 'low' | 'medium' | 'high'
135
+ });
136
+ ```
137
+
138
+ #### 2.3.3 パターンライブラリ
139
+
140
+ 学習したパターンを永続化・検索します。
141
+
142
+ ```typescript
143
+ import { PatternLibrary } from '@nahisaho/musubix-pattern-mcp';
144
+
145
+ const library = new PatternLibrary({
146
+ storagePath: './patterns.db',
147
+ });
148
+
149
+ // パターン保存
150
+ await library.store(pattern);
151
+
152
+ // パターン検索
153
+ const matches = await library.search({
154
+ type: 'design-pattern',
155
+ domain: 'authentication',
156
+ minConfidence: 0.9,
157
+ });
158
+
159
+ // パターン推奨
160
+ const recommendations = await library.recommend({
161
+ context: 'user-service-implementation',
162
+ maxResults: 5,
163
+ });
164
+ ```
165
+
166
+ ### 2.4 パターンスキーマ
167
+
168
+ ```typescript
169
+ interface Pattern {
170
+ id: string;
171
+ name: string;
172
+ type: PatternType;
173
+ description: string;
174
+
175
+ // 構造情報
176
+ structure: {
177
+ ast: ASTNode;
178
+ features: string[];
179
+ relationships: Relationship[];
180
+ };
181
+
182
+ // メタデータ
183
+ metadata: {
184
+ domain: string;
185
+ language: string;
186
+ framework?: string;
187
+ };
188
+
189
+ // 品質情報
190
+ quality: {
191
+ confidence: number; // 0-1
192
+ occurrences: number;
193
+ successRate: number; // 適用成功率
194
+ lastUsed: Date;
195
+ };
196
+
197
+ // 抽象化レベル
198
+ abstraction: {
199
+ level: 'concrete' | 'semi-abstract' | 'abstract';
200
+ generalizedFrom: string[]; // 元パターンID
201
+ };
202
+ }
203
+
204
+ type PatternType =
205
+ | 'design-pattern'
206
+ | 'code-idiom'
207
+ | 'architecture-pattern'
208
+ | 'test-pattern'
209
+ | 'error-handling';
210
+ ```
211
+
212
+ ---
213
+
214
+ ## 3. Ontology MCP
215
+
216
+ ### 3.1 概要
217
+
218
+ `@nahisaho/musubix-ontology-mcp` は、N3Store基盤のオントロジー管理と推論エンジンを提供します。
219
+
220
+ ### 3.2 アーキテクチャ
221
+
222
+ ```
223
+ packages/ontology-mcp/src/
224
+ ├── store/
225
+ │ ├── n3-store.ts # N3Store実装
226
+ │ ├── graph-manager.ts # グラフ管理
227
+ │ └── namespace.ts # 名前空間管理
228
+ ├── inference/
229
+ │ ├── reasoner.ts # 推論エンジン
230
+ │ ├── rules.ts # 推論ルール
231
+ │ └── forward-chain.ts # 前向き連鎖
232
+ ├── validation/
233
+ │ ├── consistency.ts # 整合性検証
234
+ │ ├── circular.ts # 循環検出
235
+ │ └── schema-validator.ts # スキーマ検証
236
+ ├── tools/
237
+ │ └── ontology-tools.ts # MCPツール
238
+ └── index.ts
239
+ ```
240
+
241
+ ### 3.3 主要機能
242
+
243
+ #### 3.3.1 N3Store
244
+
245
+ RDF/OWLデータを格納・操作します。
246
+
247
+ ```typescript
248
+ import { N3Store } from '@nahisaho/musubix-ontology-mcp';
249
+
250
+ const store = new N3Store();
251
+
252
+ // トリプル追加
253
+ store.addQuad(
254
+ namedNode('http://example.org/User'),
255
+ namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
256
+ namedNode('http://www.w3.org/2002/07/owl#Class')
257
+ );
258
+
259
+ // クエリ
260
+ const results = store.getQuads(
261
+ null, // 任意のsubject
262
+ namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
263
+ null // 任意のobject
264
+ );
265
+ ```
266
+
267
+ #### 3.3.2 推論エンジン
268
+
269
+ オントロジーに基づく推論を実行します。
270
+
271
+ ```typescript
272
+ import { Reasoner } from '@nahisaho/musubix-ontology-mcp';
273
+
274
+ const reasoner = new Reasoner(store);
275
+
276
+ // 組み込みルールで推論
277
+ await reasoner.infer({
278
+ rules: ['rdfs', 'owl-lite'],
279
+ });
280
+
281
+ // カスタムルール追加
282
+ reasoner.addRule({
283
+ name: 'transitivity-rule',
284
+ condition: '?a sdd:dependsOn ?b . ?b sdd:dependsOn ?c',
285
+ conclusion: '?a sdd:transitivelyDependsOn ?c',
286
+ });
287
+
288
+ // 推論実行
289
+ const inferred = await reasoner.query({
290
+ subject: 'comp:UserService',
291
+ predicate: 'sdd:transitivelyDependsOn',
292
+ });
293
+ ```
294
+
295
+ #### 3.3.3 整合性検証
296
+
297
+ オントロジーの整合性をチェックします。
298
+
299
+ ```typescript
300
+ import { ConsistencyValidator } from '@nahisaho/musubix-ontology-mcp';
301
+
302
+ const validator = new ConsistencyValidator(store);
303
+
304
+ // 整合性検証
305
+ const result = await validator.validate();
306
+
307
+ // 結果
308
+ // {
309
+ // valid: false,
310
+ // violations: [
311
+ // {
312
+ // type: 'domain-violation',
313
+ // subject: 'req:REQ-001',
314
+ // predicate: 'sdd:implements',
315
+ // message: 'sdd:implements requires subject of type sdd:Design'
316
+ // }
317
+ // ]
318
+ // }
319
+
320
+ // 循環依存検出
321
+ const circular = await validator.checkCircular({
322
+ predicate: 'sdd:dependsOn',
323
+ });
324
+ ```
325
+
326
+ ### 3.4 MCPツール
327
+
328
+ | ツール名 | 説明 |
329
+ |---------|------|
330
+ | `ontology_query` | オントロジーグラフへのクエリ |
331
+ | `ontology_infer` | 推論実行 |
332
+ | `consistency_validate` | 整合性検証 |
333
+ | `validate_triple` | トリプル事前検証 |
334
+ | `check_circular` | 循環依存検出 |
335
+
336
+ ---
337
+
338
+ ## 4. Wake-Sleep
339
+
340
+ ### 4.1 概要
341
+
342
+ `@nahisaho/musubix-wake-sleep` は、Wake-Sleepアルゴリズムに基づく継続的学習サイクルを実装します。
343
+
344
+ ### 4.2 アーキテクチャ
345
+
346
+ ```
347
+ packages/wake-sleep/src/
348
+ ├── cycle/
349
+ │ ├── wake-sleep-cycle.ts # メインサイクル
350
+ │ ├── scheduler.ts # スケジューラー
351
+ │ └── state-machine.ts # 状態管理
352
+ ├── wake/
353
+ │ ├── observer.ts # コード観察
354
+ │ ├── extractor.ts # パターン抽出
355
+ │ └── updater.ts # 知識更新
356
+ ├── sleep/
357
+ │ ├── consolidator.ts # パターン統合
358
+ │ ├── compressor.ts # 圧縮処理
359
+ │ └── optimizer.ts # メモリ最適化
360
+ ├── bridge/
361
+ │ └── pattern-ontology-bridge.ts # パターン↔オントロジー変換
362
+ └── index.ts
363
+ ```
364
+
365
+ ### 4.3 Wake-Sleepサイクル
366
+
367
+ ```
368
+ ┌─────────────────────────────────────────────────────────────┐
369
+ │ Wake-Sleep Cycle │
370
+ └─────────────────────────────────────────────────────────────┘
371
+
372
+ ┌─────────────┐
373
+ │ Idle │
374
+ └──────┬──────┘
375
+ │ trigger
376
+
377
+ ┌──────────────────────────┐
378
+ │ Wake Phase │
379
+ │ ┌────────────────────┐ │
380
+ │ │ Observe │ │
381
+ │ └─────────┬──────────┘ │
382
+ │ ▼ │
383
+ │ ┌────────────────────┐ │
384
+ │ │ Extract │ │
385
+ │ └─────────┬──────────┘ │
386
+ │ ▼ │
387
+ │ ┌────────────────────┐ │
388
+ │ │ Update KG │ │
389
+ │ └────────────────────┘ │
390
+ └────────────┬─────────────┘
391
+
392
+
393
+ ┌──────────────────────────┐
394
+ │ Sleep Phase │
395
+ │ ┌────────────────────┐ │
396
+ │ │ Consolidate │ │
397
+ │ └─────────┬──────────┘ │
398
+ │ ▼ │
399
+ │ ┌────────────────────┐ │
400
+ │ │ Compress │ │
401
+ │ └─────────┬──────────┘ │
402
+ │ ▼ │
403
+ │ ┌────────────────────┐ │
404
+ │ │ Optimize │ │
405
+ │ └────────────────────┘ │
406
+ └────────────┬─────────────┘
407
+
408
+
409
+ ┌─────────────┐
410
+ │ Idle │
411
+ └─────────────┘
412
+ ```
413
+
414
+ ### 4.4 主要機能
415
+
416
+ #### 4.4.1 サイクル制御
417
+
418
+ ```typescript
419
+ import { WakeSleepCycle } from '@nahisaho/musubix-wake-sleep';
420
+
421
+ const cycle = new WakeSleepCycle({
422
+ patternLibrary: patternLib,
423
+ ontologyStore: ontologyStore,
424
+ schedule: {
425
+ wakeInterval: 3600, // 1時間ごとにWake
426
+ sleepAfterWake: true, // Wake後に自動Sleep
427
+ },
428
+ });
429
+
430
+ // サイクル開始
431
+ await cycle.start();
432
+
433
+ // 手動トリガー
434
+ await cycle.triggerWake();
435
+ await cycle.triggerSleep();
436
+
437
+ // 状態確認
438
+ const status = cycle.getStatus();
439
+ // { phase: 'idle', lastWake: '...', lastSleep: '...' }
440
+ ```
441
+
442
+ #### 4.4.2 Wakeフェーズ
443
+
444
+ ```typescript
445
+ import { WakePhase } from '@nahisaho/musubix-wake-sleep';
446
+
447
+ const wake = new WakePhase({
448
+ observers: ['file-system', 'git-changes', 'test-results'],
449
+ });
450
+
451
+ // コード観察
452
+ const observations = await wake.observe({
453
+ paths: ['./src'],
454
+ since: lastWakeTime,
455
+ });
456
+
457
+ // パターン抽出
458
+ const patterns = await wake.extractPatterns(observations);
459
+
460
+ // 知識グラフ更新
461
+ await wake.updateKnowledge(patterns);
462
+ ```
463
+
464
+ #### 4.4.3 Sleepフェーズ
465
+
466
+ ```typescript
467
+ import { SleepPhase } from '@nahisaho/musubix-wake-sleep';
468
+
469
+ const sleep = new SleepPhase({
470
+ compressionThreshold: 0.8,
471
+ retentionPolicy: {
472
+ minConfidence: 0.5,
473
+ minOccurrences: 2,
474
+ },
475
+ });
476
+
477
+ // パターン統合
478
+ const consolidated = await sleep.consolidate();
479
+
480
+ // 圧縮
481
+ const compressed = await sleep.compress(consolidated);
482
+
483
+ // メモリ最適化
484
+ await sleep.optimize({
485
+ pruneUnused: true,
486
+ defragment: true,
487
+ });
488
+ ```
489
+
490
+ ### 4.5 パターン-オントロジーブリッジ
491
+
492
+ パターンとオントロジー間の相互変換を行います。
493
+
494
+ ```typescript
495
+ import { PatternOntologyBridge } from '@nahisaho/musubix-wake-sleep';
496
+
497
+ const bridge = new PatternOntologyBridge({
498
+ patternLibrary,
499
+ ontologyStore,
500
+ });
501
+
502
+ // パターン → オントロジー
503
+ const triples = bridge.patternToTriples(pattern);
504
+ await ontologyStore.addQuads(triples);
505
+
506
+ // オントロジー → パターン
507
+ const pattern = bridge.triplesToPattern(triples);
508
+ await patternLibrary.store(pattern);
509
+ ```
510
+
511
+ ---
512
+
513
+ ## 5. SDD Ontology
514
+
515
+ ### 5.1 概要
516
+
517
+ `@nahisaho/musubix-sdd-ontology` は、SDD(Symbolic-Driven Development)方法論のオントロジー定義を提供します。
518
+
519
+ ### 5.2 オントロジー構造
520
+
521
+ ```
522
+ packages/sdd-ontology/src/
523
+ ├── schema/
524
+ │ ├── sdd.ttl # SDDコアオントロジー
525
+ │ ├── requirements.ttl # 要件オントロジー
526
+ │ ├── design.ttl # 設計オントロジー
527
+ │ ├── code.ttl # コードオントロジー
528
+ │ └── traceability.ttl # トレーサビリティオントロジー
529
+ ├── rules/
530
+ │ ├── ears-rules.ttl # EARS推論ルール
531
+ │ ├── c4-rules.ttl # C4推論ルール
532
+ │ └── quality-rules.ttl # 品質推論ルール
533
+ ├── loader.ts # オントロジーローダー
534
+ └── index.ts
535
+ ```
536
+
537
+ ### 5.3 SDDコアオントロジー
538
+
539
+ ```turtle
540
+ @prefix sdd: <http://musubix.dev/sdd#> .
541
+ @prefix owl: <http://www.w3.org/2002/07/owl#> .
542
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
543
+
544
+ # === クラス定義 ===
545
+
546
+ sdd:Artifact a owl:Class ;
547
+ rdfs:label "Software Artifact" ;
548
+ rdfs:comment "Base class for all SDD artifacts" .
549
+
550
+ sdd:Requirement a owl:Class ;
551
+ rdfs:subClassOf sdd:Artifact ;
552
+ rdfs:label "Requirement" .
553
+
554
+ sdd:Design a owl:Class ;
555
+ rdfs:subClassOf sdd:Artifact ;
556
+ rdfs:label "Design" .
557
+
558
+ sdd:Code a owl:Class ;
559
+ rdfs:subClassOf sdd:Artifact ;
560
+ rdfs:label "Code" .
561
+
562
+ sdd:Test a owl:Class ;
563
+ rdfs:subClassOf sdd:Artifact ;
564
+ rdfs:label "Test" .
565
+
566
+ # === EARSパターン ===
567
+
568
+ sdd:EARSPattern a owl:Class ;
569
+ rdfs:label "EARS Pattern" .
570
+
571
+ sdd:UbiquitousPattern a owl:Class ;
572
+ rdfs:subClassOf sdd:EARSPattern ;
573
+ rdfs:label "Ubiquitous Pattern" .
574
+
575
+ sdd:EventDrivenPattern a owl:Class ;
576
+ rdfs:subClassOf sdd:EARSPattern ;
577
+ rdfs:label "Event-Driven Pattern" .
578
+
579
+ sdd:StateDrivenPattern a owl:Class ;
580
+ rdfs:subClassOf sdd:EARSPattern ;
581
+ rdfs:label "State-Driven Pattern" .
582
+
583
+ sdd:UnwantedPattern a owl:Class ;
584
+ rdfs:subClassOf sdd:EARSPattern ;
585
+ rdfs:label "Unwanted Pattern" .
586
+
587
+ sdd:OptionalPattern a owl:Class ;
588
+ rdfs:subClassOf sdd:EARSPattern ;
589
+ rdfs:label "Optional Pattern" .
590
+
591
+ # === プロパティ定義 ===
592
+
593
+ sdd:implements a owl:ObjectProperty ;
594
+ rdfs:domain sdd:Design ;
595
+ rdfs:range sdd:Requirement ;
596
+ rdfs:label "implements" .
597
+
598
+ sdd:realizedBy a owl:ObjectProperty ;
599
+ rdfs:domain sdd:Requirement ;
600
+ rdfs:range sdd:Code ;
601
+ rdfs:label "realizedBy" .
602
+
603
+ sdd:testedBy a owl:ObjectProperty ;
604
+ rdfs:domain sdd:Code ;
605
+ rdfs:range sdd:Test ;
606
+ rdfs:label "testedBy" .
607
+
608
+ sdd:hasPattern a owl:ObjectProperty ;
609
+ rdfs:domain sdd:Requirement ;
610
+ rdfs:range sdd:EARSPattern ;
611
+ rdfs:label "hasPattern" .
612
+
613
+ sdd:priority a owl:DatatypeProperty ;
614
+ rdfs:domain sdd:Requirement ;
615
+ rdfs:range xsd:string ;
616
+ rdfs:label "priority" .
617
+ ```
618
+
619
+ ### 5.4 推論ルール
620
+
621
+ ```turtle
622
+ @prefix sdd: <http://musubix.dev/sdd#> .
623
+ @prefix rule: <http://musubix.dev/rules#> .
624
+
625
+ # トレーサビリティ推論
626
+ rule:TraceabilityInference a rule:Rule ;
627
+ rule:condition """
628
+ ?req a sdd:Requirement .
629
+ ?des sdd:implements ?req .
630
+ ?code sdd:realizes ?des .
631
+ """ ;
632
+ rule:conclusion """
633
+ ?req sdd:realizedBy ?code .
634
+ """ .
635
+
636
+ # テストカバレッジ推論
637
+ rule:TestCoverageInference a rule:Rule ;
638
+ rule:condition """
639
+ ?code a sdd:Code .
640
+ ?test sdd:tests ?code .
641
+ ?code sdd:realizes ?des .
642
+ ?des sdd:implements ?req .
643
+ """ ;
644
+ rule:conclusion """
645
+ ?req sdd:hasCoverage true .
646
+ """ .
647
+
648
+ # 依存関係推移閉包
649
+ rule:TransitiveDependency a rule:Rule ;
650
+ rule:condition """
651
+ ?a sdd:dependsOn ?b .
652
+ ?b sdd:dependsOn ?c .
653
+ """ ;
654
+ rule:conclusion """
655
+ ?a sdd:transitivelyDependsOn ?c .
656
+ """ .
657
+ ```
658
+
659
+ ### 5.5 使用例
660
+
661
+ ```typescript
662
+ import { SDDOntology } from '@nahisaho/musubix-sdd-ontology';
663
+
664
+ const ontology = new SDDOntology();
665
+
666
+ // オントロジーをN3Storeにロード
667
+ const store = await ontology.load();
668
+
669
+ // 推論ルールを適用
670
+ await ontology.applyRules(store);
671
+
672
+ // 要件に対するトレーサビリティ検証
673
+ const coverage = await ontology.checkTraceability(store, 'REQ-001');
674
+ ```
675
+
676
+ ---
677
+
678
+ ## 6. 学習フロー統合
679
+
680
+ ### 6.1 全体フロー
681
+
682
+ ```
683
+ ┌─────────────────────────────────────────────────────────────┐
684
+ │ Complete Learning Flow │
685
+ └─────────────────────────────────────────────────────────────┘
686
+
687
+ 1. [Input] Code Changes
688
+
689
+
690
+ 2. [Pattern MCP] Extract patterns from code
691
+
692
+ ├─── AST Analysis
693
+ ├─── Feature Extraction
694
+ └─── Pattern Detection
695
+
696
+
697
+ 3. [Ontology MCP] Map patterns to ontology
698
+
699
+ ├─── Triple Generation
700
+ ├─── Schema Validation
701
+ └─── Consistency Check
702
+
703
+
704
+ 4. [Wake-Sleep] Consolidate and optimize
705
+
706
+ ├─── Wake: Update Knowledge
707
+ └─── Sleep: Compress & Prune
708
+
709
+
710
+ 5. [SDD Ontology] Apply inference rules
711
+
712
+ ├─── Traceability Inference
713
+ ├─── Coverage Analysis
714
+ └─── Quality Metrics
715
+
716
+
717
+ 6. [Output] Updated Knowledge Graph
718
+ ```
719
+
720
+ ### 6.2 統合API
721
+
722
+ ```typescript
723
+ import { LearningSystem } from '@nahisaho/musubix-core';
724
+
725
+ const learningSystem = new LearningSystem({
726
+ patternMCP: patternMCP,
727
+ ontologyMCP: ontologyMCP,
728
+ wakeSleep: wakeSleepCycle,
729
+ sddOntology: sddOntology,
730
+ });
731
+
732
+ // コード変更から学習
733
+ await learningSystem.learnFromCode({
734
+ files: ['src/user-service.ts'],
735
+ context: 'user-authentication',
736
+ });
737
+
738
+ // フィードバックから学習
739
+ await learningSystem.learnFromFeedback({
740
+ patternId: 'pattern-123',
741
+ feedback: 'accept', // 'accept' | 'reject' | 'modify'
742
+ comment: 'Good pattern for DI',
743
+ });
744
+
745
+ // 推奨パターン取得
746
+ const recommendations = await learningSystem.getRecommendations({
747
+ context: 'implementing-user-service',
748
+ maxResults: 5,
749
+ });
750
+ ```
751
+
752
+ ---
753
+
754
+ ## 7. CLI コマンド
755
+
756
+ ```bash
757
+ # 学習ダッシュボード
758
+ npx musubix learn status
759
+
760
+ # パターン操作
761
+ npx musubix learn patterns
762
+ npx musubix learn add-pattern <name>
763
+ npx musubix learn remove-pattern <id>
764
+
765
+ # フィードバック
766
+ npx musubix learn feedback <id>
767
+
768
+ # 推奨
769
+ npx musubix learn recommend
770
+
771
+ # Wake-Sleepサイクル
772
+ npx musubix learn wake
773
+ npx musubix learn sleep
774
+ npx musubix learn decay
775
+
776
+ # データ管理
777
+ npx musubix learn export --output patterns.json
778
+ npx musubix learn import patterns.json
779
+
780
+ # オントロジー
781
+ npx musubix ontology validate -f knowledge.ttl
782
+ npx musubix ontology check-circular -f knowledge.ttl
783
+ npx musubix ontology stats -f knowledge.ttl
784
+ ```
785
+
786
+ ---
787
+
788
+ ## 8. 設定
789
+
790
+ ### 8.1 環境変数
791
+
792
+ | 変数名 | 説明 | デフォルト |
793
+ |--------|------|-----------|
794
+ | `MUSUBIX_LEARNING_PATH` | 学習データパス | `~/.musubix/learning` |
795
+ | `MUSUBIX_PATTERN_THRESHOLD` | パターン登録閾値 | `0.8` |
796
+ | `MUSUBIX_WAKE_INTERVAL` | Wake間隔(秒) | `3600` |
797
+ | `MUSUBIX_SLEEP_AFTER_WAKE` | Wake後自動Sleep | `true` |
798
+
799
+ ### 8.2 設定ファイル
800
+
801
+ `learning.config.json`:
802
+
803
+ ```json
804
+ {
805
+ "patterns": {
806
+ "extractionThreshold": 0.7,
807
+ "compressionThreshold": 0.8,
808
+ "minOccurrences": 3,
809
+ "retentionDays": 90
810
+ },
811
+ "wakeSleep": {
812
+ "wakeInterval": 3600,
813
+ "sleepAfterWake": true,
814
+ "observers": ["file-system", "git-changes"]
815
+ },
816
+ "ontology": {
817
+ "schemaPath": "./schema",
818
+ "rulesPath": "./rules",
819
+ "inferenceEnabled": true
820
+ }
821
+ }
822
+ ```
823
+
824
+ ---
825
+
826
+ ## 9. 関連ドキュメント
827
+
828
+ | ドキュメント | 説明 |
829
+ |-------------|------|
830
+ | [MUSUBIX-Overview.md](MUSUBIX-Overview.md) | 全体概要 |
831
+ | [MUSUBIX-Core.md](MUSUBIX-Core.md) | Coreパッケージ |
832
+ | [MUSUBIX-YATA.md](MUSUBIX-YATA.md) | YATAシステム |
833
+ | [API-REFERENCE.md](API-REFERENCE.md) | APIリファレンス |
834
+
835
+ ---
836
+
837
+ **© 2026 MUSUBIX Project**