musubix 3.3.10 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/AGENTS.md +949 -0
- package/.github/prompts/sdd-change-apply.prompt.md +283 -0
- package/.github/prompts/sdd-change-archive.prompt.md +241 -0
- package/.github/prompts/sdd-change-init.prompt.md +269 -0
- package/.github/prompts/sdd-design.prompt.md +250 -0
- package/.github/prompts/sdd-implement.prompt.md +387 -0
- package/.github/prompts/sdd-requirements.prompt.md +193 -0
- package/.github/prompts/sdd-review.prompt.md +155 -0
- package/.github/prompts/sdd-security.prompt.md +228 -0
- package/.github/prompts/sdd-steering.prompt.md +269 -0
- package/.github/prompts/sdd-tasks.prompt.md +255 -0
- package/.github/prompts/sdd-test.prompt.md +230 -0
- package/.github/prompts/sdd-validate.prompt.md +304 -0
- package/.github/skills/musubix-adr-generation/SKILL.md +209 -0
- package/.github/skills/musubix-best-practices/SKILL.md +315 -0
- package/.github/skills/musubix-c4-design/SKILL.md +162 -0
- package/.github/skills/musubix-code-generation/SKILL.md +237 -0
- package/.github/skills/musubix-domain-inference/SKILL.md +196 -0
- package/.github/skills/musubix-ears-validation/SKILL.md +161 -0
- package/.github/skills/musubix-sdd-workflow/SKILL.md +217 -0
- package/.github/skills/musubix-technical-writing/SKILL.md +444 -0
- package/.github/skills/musubix-test-generation/SKILL.md +212 -0
- package/.github/skills/musubix-traceability/SKILL.md +141 -0
- package/AGENTS.md +1134 -0
- package/LICENSE +21 -0
- package/README.ja.md +313 -0
- package/README.md +315 -50
- package/bin/musubix-mcp.js +15 -0
- package/bin/musubix.js +9 -1
- package/docs/API-REFERENCE.md +1425 -0
- package/docs/GITHUB-ACTIONS-NPM-SETUP.md +132 -0
- package/docs/INSTALL-GUIDE.ja.md +459 -0
- package/docs/INSTALL-GUIDE.md +459 -0
- package/docs/MIGRATION-v3.0.md +324 -0
- package/docs/MUSUBI-enhancement_roadmap_20260105.md +651 -0
- package/docs/MUSUBIX-v3.0-User-Guide.md +1357 -0
- package/docs/MUSUBIXv2.2.0-Manual-outline.md +136 -0
- package/docs/MUSUBIXv2.2.0-Manual.md +3123 -0
- package/docs/MUSUBIXv2.3.5-Refactering.md +1310 -0
- package/docs/MUSUBIv1.6.1-enhancement_roadmap_20260105.md +291 -0
- package/docs/MUSUBIv2.2.0-USERGUIDE.md +2079 -0
- package/docs/ROADMAP-v1.5.md +116 -0
- package/docs/SwarmCoding.md +1284 -0
- package/docs/Test-prompt.md +105 -0
- package/docs/USER-GUIDE-v1.8.0.md +2371 -0
- package/docs/USER-GUIDE.ja.md +2147 -0
- package/docs/USER-GUIDE.md +3022 -0
- package/docs/YATA-GLOBAL-GUIDE.ja.md +750 -0
- package/docs/YATA-GLOBAL-GUIDE.md +595 -0
- package/docs/YATA-LOCAL-GUIDE.ja.md +989 -0
- package/docs/YATA-LOCAL-GUIDE.md +730 -0
- package/docs/adr/0001-real-time-pattern-learning-architecture-for-v1-5-0.md +75 -0
- package/docs/adr/0002-pattern-sharing-protocol-for-cross-team-collaborat.md +79 -0
- package/docs/adr/0003-owl-2-rl-implementation-strategy-for-advanced-infe.md +90 -0
- package/docs/adr/ADR-v3.4.0-001-deep-research-architecture.md +217 -0
- package/docs/adr/ADR-v3.4.0-002-search-provider-selection.md +308 -0
- package/docs/adr/ADR-v3.4.0-003-lm-api-integration.md +475 -0
- package/docs/enterprise-knowledge-management.md +1737 -0
- package/docs/evolution-from-musubi-to-musubix.md +2170 -0
- package/docs/getting-started-with-sdd.md +1602 -0
- package/docs/moodle-refactering-codegraph-musubix.md +391 -0
- package/docs/moodle-refactering-codegraph.md +278 -0
- package/docs/overview/MUSUBIX-CodeGraph.md +322 -0
- package/docs/overview/MUSUBIX-Core.md +671 -0
- package/docs/overview/MUSUBIX-Decisions.md +494 -0
- package/docs/overview/MUSUBIX-FormalVerify.md +566 -0
- package/docs/overview/MUSUBIX-Knowledge.md +1231 -0
- package/docs/overview/MUSUBIX-Learning.md +837 -0
- package/docs/overview/MUSUBIX-MCP-Server.md +535 -0
- package/docs/overview/MUSUBIX-Overview.md +264 -0
- package/docs/overview/MUSUBIX-Phase1-Complete.md +271 -0
- package/docs/overview/MUSUBIX-Phase2-Complete.md +310 -0
- package/docs/overview/MUSUBIX-Policy.md +477 -0
- package/docs/overview/MUSUBIX-Roadmap-v2.md +399 -0
- package/docs/overview/MUSUBIX-Security-Plan.md +939 -0
- package/docs/overview/MUSUBIX-Security-v2.1.md +668 -0
- package/docs/overview/MUSUBIX-Security.md +891 -0
- package/docs/overview/MUSUBIX-YATA.md +666 -0
- package/docs/overview/MUSUBIX-v2.2.0-Advanced-Learning.md +513 -0
- package/docs/overview/Neuro-SymbolicAI.md +159 -0
- package/docs/packages/knowledge.md +594 -0
- package/docs/qiita-linux-kernel-knowledge-graph.md +596 -0
- package/package.json +55 -49
- package/scripts/generate-quality-gate-report.ts +106 -0
- package/scripts/postinstall.js +94 -0
- package/steering/.musubi-version +1 -0
- package/steering/product.ja.md +572 -0
- package/steering/project.yml +66 -0
- package/steering/rules/constitution.md +491 -0
- package/steering/structure.ja.md +503 -0
- package/steering/tech.ja.md +208 -0
- package/dist/index.d.ts +0 -25
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -74
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# ADR-0001: Real-time Pattern Learning Architecture for v1.5.0
|
|
2
|
+
|
|
3
|
+
- **Date**: 2026-01-05
|
|
4
|
+
- **Status**: accepted
|
|
5
|
+
- **Deciders**: Architecture Team
|
|
6
|
+
- **Categories**: Learning, Performance
|
|
7
|
+
|
|
8
|
+
## Context
|
|
9
|
+
|
|
10
|
+
MUSUBIX v1.4.xではバッチ学習方式を採用しているが、ユーザーのコード変更をリアルタイムで学習する要求がある。
|
|
11
|
+
|
|
12
|
+
### 要件
|
|
13
|
+
- REQ-LEARN-011: ファイル変更時500ms以内に分析
|
|
14
|
+
- REQ-LEARN-013: フィードバック収集レイテンシ100ms以内
|
|
15
|
+
- REQ-LEARN-014: ストリーム処理1000 events/sec以上
|
|
16
|
+
|
|
17
|
+
### 検討した選択肢
|
|
18
|
+
1. **Polling方式**: 定期的にファイル変更をチェック
|
|
19
|
+
2. **fs.watch + EventEmitter**: Node.js標準のファイル監視
|
|
20
|
+
3. **chokidar + RxJS**: サードパーティライブラリによるリアクティブストリーム
|
|
21
|
+
|
|
22
|
+
## Decision
|
|
23
|
+
|
|
24
|
+
**選択肢 2: fs.watch + EventEmitter** を採用する。
|
|
25
|
+
|
|
26
|
+
### 理由
|
|
27
|
+
- 外部依存なしで実現可能
|
|
28
|
+
- Node.js標準APIで十分な性能
|
|
29
|
+
- メモリフットプリントが小さい
|
|
30
|
+
|
|
31
|
+
### アーキテクチャ
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
FileWatcher (fs.watch)
|
|
35
|
+
│
|
|
36
|
+
▼
|
|
37
|
+
StreamProcessor (EventEmitter)
|
|
38
|
+
│
|
|
39
|
+
├─▼ FeedbackQueue (Non-blocking)
|
|
40
|
+
│
|
|
41
|
+
└─▼ PatternExtractor (AST)
|
|
42
|
+
│
|
|
43
|
+
▼
|
|
44
|
+
IncrementalUpdater (Delta)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### パフォーマンス目標
|
|
48
|
+
| メトリクス | 目標 | 測定方法 |
|
|
49
|
+
|------------|------|----------|
|
|
50
|
+
| 分析レイテンシ | < 500ms | StreamProcessor.getLatency() |
|
|
51
|
+
| フィードバック収集 | < 100ms | FeedbackQueue timing |
|
|
52
|
+
| スループット | ≥ 1000/sec | EventStream.getThroughput() |
|
|
53
|
+
|
|
54
|
+
## Consequences
|
|
55
|
+
|
|
56
|
+
### Positive
|
|
57
|
+
- リアルタイム学習によるユーザー体験向上
|
|
58
|
+
- 外部依存なしで軽量
|
|
59
|
+
- 段階的な実装が可能
|
|
60
|
+
|
|
61
|
+
### Negative
|
|
62
|
+
- fs.watchのクロスプラットフォーム差異への対応が必要
|
|
63
|
+
- 大規模プロジェクトでのスケーラビリティ検証が必要
|
|
64
|
+
|
|
65
|
+
### Risks
|
|
66
|
+
- macOS/Linux/Windowsでのfs.watchの挙動差異
|
|
67
|
+
- 軽減策: chokidarへのフォールバック機構を用意
|
|
68
|
+
|
|
69
|
+
## Related Requirements
|
|
70
|
+
|
|
71
|
+
- REQ-LEARN-010: Real-time pattern learning
|
|
72
|
+
- REQ-LEARN-011: 500ms analysis latency
|
|
73
|
+
- REQ-LEARN-012: Incremental update
|
|
74
|
+
- REQ-LEARN-013: Non-blocking feedback
|
|
75
|
+
- REQ-LEARN-014: Stream processing
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# ADR-0002: Pattern Sharing Protocol for cross-team collaboration
|
|
2
|
+
|
|
3
|
+
- **Date**: 2026-01-05
|
|
4
|
+
- **Status**: accepted
|
|
5
|
+
- **Deciders**: Architecture Team
|
|
6
|
+
- **Categories**: Sharing, Security
|
|
7
|
+
|
|
8
|
+
## Context
|
|
9
|
+
|
|
10
|
+
チーム間で学習済みパターンを共有する要求がある。プライバシーとセキュリティを考慮したプロトコルが必要。
|
|
11
|
+
|
|
12
|
+
### 要件
|
|
13
|
+
- REQ-SHARE-001: JSON形式でエクスポート
|
|
14
|
+
- REQ-SHARE-003: インポート時のオントロジー検証
|
|
15
|
+
- REQ-SHARE-004: 機密データの除去
|
|
16
|
+
- REQ-SHARE-005: 競合解決戦略
|
|
17
|
+
|
|
18
|
+
### 検討した選択肢
|
|
19
|
+
1. **Git-based sharing**: Gitリポジトリでパターンを共有
|
|
20
|
+
2. **REST API**: 中央サーバー経由の共有
|
|
21
|
+
3. **File-based export/import**: JSONファイルの直接交換
|
|
22
|
+
|
|
23
|
+
## Decision
|
|
24
|
+
|
|
25
|
+
**選択肢 3: File-based export/import** を採用する。
|
|
26
|
+
|
|
27
|
+
### 理由
|
|
28
|
+
- インフラ不要で即座に利用可能
|
|
29
|
+
- オフライン環境でも利用可能
|
|
30
|
+
- 将来的にGit連携への拡張が容易
|
|
31
|
+
|
|
32
|
+
### ファイルフォーマット
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"version": "1.0",
|
|
37
|
+
"exportedAt": "2026-01-05T12:00:00Z",
|
|
38
|
+
"patterns": [
|
|
39
|
+
{
|
|
40
|
+
"id": "PAT-001",
|
|
41
|
+
"name": "Repository Pattern",
|
|
42
|
+
"category": "design",
|
|
43
|
+
"confidence": 0.95,
|
|
44
|
+
"template": "...",
|
|
45
|
+
"metadata": {
|
|
46
|
+
"author": "[REDACTED]",
|
|
47
|
+
"domain": "data-access"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"checksum": "sha256:..."
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### セキュリティ対策
|
|
56
|
+
| 対策 | 実装 |
|
|
57
|
+
|------|------|
|
|
58
|
+
| 機密データ除去 | DataSanitizerによる自動マスキング |
|
|
59
|
+
| 改ざん検出 | SHA-256チェックサム |
|
|
60
|
+
| スキーマ検証 | JSON Schemaによるバリデーション |
|
|
61
|
+
|
|
62
|
+
## Consequences
|
|
63
|
+
|
|
64
|
+
### Positive
|
|
65
|
+
- シンプルで即座に利用可能
|
|
66
|
+
- プライバシー保護が容易
|
|
67
|
+
- バージョン管理が明確
|
|
68
|
+
|
|
69
|
+
### Negative
|
|
70
|
+
- 自動同期機能なし(将来拡張)
|
|
71
|
+
- 大規模チームでの管理が煩雑になる可能性
|
|
72
|
+
|
|
73
|
+
## Related Requirements
|
|
74
|
+
|
|
75
|
+
- REQ-SHARE-001: JSON export format
|
|
76
|
+
- REQ-SHARE-002: External import
|
|
77
|
+
- REQ-SHARE-003: Ontology validation
|
|
78
|
+
- REQ-SHARE-004: Privacy protection
|
|
79
|
+
- REQ-SHARE-005: Conflict resolution
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# ADR-0003: OWL 2 RL Implementation Strategy for advanced inference
|
|
2
|
+
|
|
3
|
+
- **Date**: 2026-01-05
|
|
4
|
+
- **Status**: accepted
|
|
5
|
+
- **Deciders**: Architecture Team
|
|
6
|
+
- **Categories**: Ontology, Inference
|
|
7
|
+
|
|
8
|
+
## Context
|
|
9
|
+
|
|
10
|
+
MUSUBIX v1.4.xではN3.jsによる基本的なRDF処理を実装済み。OWL 2 RLプロファイルの推論機能を追加する必要がある。
|
|
11
|
+
|
|
12
|
+
### 要件
|
|
13
|
+
- REQ-ONTO-010: OWL 2 RLプロファイル対応
|
|
14
|
+
- REQ-ONTO-011: 200ms以内の推論(10,000トリプルまで)
|
|
15
|
+
- REQ-ONTO-014: Datalogルール統合(最大100ルール)
|
|
16
|
+
|
|
17
|
+
### 検討した選択肢
|
|
18
|
+
1. **完全なOWL 2推論器(HermiT等)**: Javaベース、高機能だが重い
|
|
19
|
+
2. **N3.js + カスタムルール**: 既存実装を拡張
|
|
20
|
+
3. **RDFox / Stardog**: 商用推論エンジン
|
|
21
|
+
|
|
22
|
+
## Decision
|
|
23
|
+
|
|
24
|
+
**選択肢 2: N3.js + カスタムOWL 2 RLルール** を採用する。
|
|
25
|
+
|
|
26
|
+
### 理由
|
|
27
|
+
- 既存のN3Store実装を活用可能
|
|
28
|
+
- 軽量でNode.js環境に最適
|
|
29
|
+
- 必要なルールセットのみ実装(段階的拡張)
|
|
30
|
+
|
|
31
|
+
### 実装するOWL 2 RLルール(Phase 1)
|
|
32
|
+
|
|
33
|
+
| ルールID | 説明 | 優先度 |
|
|
34
|
+
|----------|------|--------|
|
|
35
|
+
| prp-dom | rdfs:domain推論 | P0 |
|
|
36
|
+
| prp-rng | rdfs:range推論 | P0 |
|
|
37
|
+
| prp-spo1 | rdfs:subPropertyOf推論 | P0 |
|
|
38
|
+
| cax-sco | rdfs:subClassOf推論 | P0 |
|
|
39
|
+
| prp-trp | owl:TransitiveProperty | P1 |
|
|
40
|
+
| prp-symp | owl:SymmetricProperty | P1 |
|
|
41
|
+
| prp-inv1/2 | owl:inverseOf | P1 |
|
|
42
|
+
|
|
43
|
+
### アーキテクチャ
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
QueryEngine
|
|
47
|
+
│
|
|
48
|
+
▼
|
|
49
|
+
RuleEngine (OWL 2 RL)
|
|
50
|
+
│
|
|
51
|
+
├── BuiltInRules (prp-*, cax-*)
|
|
52
|
+
│
|
|
53
|
+
└── DatalogIntegrator (最大100ルール)
|
|
54
|
+
│
|
|
55
|
+
▼
|
|
56
|
+
InferenceExecutor (200ms SLA)
|
|
57
|
+
│
|
|
58
|
+
▼
|
|
59
|
+
ExplanationGenerator
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### パフォーマンス目標
|
|
63
|
+
| グラフサイズ | 目標レイテンシ |
|
|
64
|
+
|-------------|---------------|
|
|
65
|
+
| 1,000 triples | < 50ms |
|
|
66
|
+
| 5,000 triples | < 100ms |
|
|
67
|
+
| 10,000 triples | < 200ms |
|
|
68
|
+
|
|
69
|
+
## Consequences
|
|
70
|
+
|
|
71
|
+
### Positive
|
|
72
|
+
- 既存実装との統合が容易
|
|
73
|
+
- 軽量で高速
|
|
74
|
+
- 段階的な機能追加が可能
|
|
75
|
+
|
|
76
|
+
### Negative
|
|
77
|
+
- OWL 2 RL全機能のサポートには時間がかかる
|
|
78
|
+
- 複雑な推論には限界あり
|
|
79
|
+
|
|
80
|
+
### Risks
|
|
81
|
+
- 10,000トリプル超での性能劣化
|
|
82
|
+
- 軽減策: インデックス最適化、マテリアライズドビュー
|
|
83
|
+
|
|
84
|
+
## Related Requirements
|
|
85
|
+
|
|
86
|
+
- REQ-ONTO-010: OWL 2 RL support
|
|
87
|
+
- REQ-ONTO-011: 200ms inference latency
|
|
88
|
+
- REQ-ONTO-012: Progress feedback
|
|
89
|
+
- REQ-ONTO-013: Explanation generation
|
|
90
|
+
- REQ-ONTO-014: Datalog integration
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# ADR-v3.4.0-001: Deep Research Architecture Decision
|
|
2
|
+
|
|
3
|
+
**Status**: Accepted
|
|
4
|
+
**Date**: 2026-01-16
|
|
5
|
+
**Authors**: AI Agent
|
|
6
|
+
**Context**: MUSUBIX v3.4.0 Deep Research Integration
|
|
7
|
+
**Traces To**: REQ-DR-CORE-001, DES-DR-v3.4.0
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Context
|
|
12
|
+
|
|
13
|
+
MUSUBIX v3.4.0でDeep Research機能を追加するにあたり、以下の技術的決定が必要となった:
|
|
14
|
+
|
|
15
|
+
1. **アーキテクチャパターン**: どのように反復的調査サイクルを実現するか
|
|
16
|
+
2. **既存システム統合**: 7つの既存パッケージとどのように統合するか
|
|
17
|
+
3. **状態管理**: イテレーション間の知識をどのように蓄積・管理するか
|
|
18
|
+
|
|
19
|
+
### 要件からの制約
|
|
20
|
+
|
|
21
|
+
- REQ-DR-CORE-001: 最大10イテレーションの反復サイクル
|
|
22
|
+
- REQ-DR-INT-001〜009: 7パッケージとのシームレス統合必須
|
|
23
|
+
- 憲法Article I: Library-First(独立パッケージとして実装)
|
|
24
|
+
- 憲法Article V: 完全なトレーサビリティ
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Decision
|
|
29
|
+
|
|
30
|
+
**Template Method Pattern**を中心としたアーキテクチャを採用する。
|
|
31
|
+
|
|
32
|
+
### 採用パターン
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// ResearchEngine: Template Method Pattern
|
|
36
|
+
class ResearchEngine {
|
|
37
|
+
async research(): Promise<ResearchReport> {
|
|
38
|
+
this.initialize();
|
|
39
|
+
|
|
40
|
+
while (!this.shouldStop()) {
|
|
41
|
+
// 固定フロー(Template Method)
|
|
42
|
+
const questions = await this.generateQuestions();
|
|
43
|
+
const searchResults = await this.search(questions);
|
|
44
|
+
const contents = await this.read(searchResults);
|
|
45
|
+
const knowledge = await this.reason(contents);
|
|
46
|
+
|
|
47
|
+
this.knowledge.addAll(knowledge);
|
|
48
|
+
this.iteration++;
|
|
49
|
+
|
|
50
|
+
if (await this.isAnswerDefinitive()) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return this.generateReport();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// フックメソッド(拡張可能)
|
|
59
|
+
protected async generateQuestions(): Promise<ReflectiveQuestion[]> { /* ... */ }
|
|
60
|
+
protected async search(questions: ReflectiveQuestion[]): Promise<SearchResult[]> { /* ... */ }
|
|
61
|
+
protected async read(results: SearchResult[]): Promise<WebContent[]> { /* ... */ }
|
|
62
|
+
protected async reason(contents: WebContent[]): Promise<KnowledgeItem[]> { /* ... */ }
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### アーキテクチャレイヤー
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
┌─────────────────────────────────────────────────────┐
|
|
70
|
+
│ CLI / MCP Tools (Interface Layer) │
|
|
71
|
+
│ - deepResearchCommand() │
|
|
72
|
+
│ - deep_research_start tool │
|
|
73
|
+
├─────────────────────────────────────────────────────┤
|
|
74
|
+
│ ResearchEngine (Application Layer) │
|
|
75
|
+
│ - Template Method: research() │
|
|
76
|
+
│ - State Management: KnowledgeBase │
|
|
77
|
+
├─────────────────────────────────────────────────────┤
|
|
78
|
+
│ Core Services (Domain Layer) │
|
|
79
|
+
│ - SearchProviderFactory (Strategy) │
|
|
80
|
+
│ - LMReasoning (Adapter) │
|
|
81
|
+
│ - ReportGenerator (Builder) │
|
|
82
|
+
├─────────────────────────────────────────────────────┤
|
|
83
|
+
│ Integrations (Infrastructure Layer) │
|
|
84
|
+
│ - ExpertIntegration │
|
|
85
|
+
│ - KnowledgeStoreIntegration │
|
|
86
|
+
│ - WorkflowIntegration │
|
|
87
|
+
└─────────────────────────────────────────────────────┘
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Rationale
|
|
93
|
+
|
|
94
|
+
### なぜTemplate Method Patternか
|
|
95
|
+
|
|
96
|
+
**✅ 採用理由**:
|
|
97
|
+
|
|
98
|
+
1. **固定フローの明確化**: search → read → reason → evaluateの順序が不変
|
|
99
|
+
2. **拡張性**: 各ステップをフックメソッドとして実装し、サブクラスで拡張可能
|
|
100
|
+
3. **トレーサビリティ**: 各ステップが明示的で、ログ・デバッグが容易
|
|
101
|
+
4. **テスト容易性**: 各フックメソッドを独立してテスト可能
|
|
102
|
+
|
|
103
|
+
**比較した代替案**:
|
|
104
|
+
|
|
105
|
+
| パターン | メリット | デメリット | 判定 |
|
|
106
|
+
|---------|---------|-----------|------|
|
|
107
|
+
| **Template Method** | フロー固定、拡張可能 | 継承ベース | ✅ 採用 |
|
|
108
|
+
| **Strategy Pattern** | 柔軟な切り替え | フロー全体を切り替える必要 | ❌ 不適 |
|
|
109
|
+
| **Pipeline Pattern** | 関数型、シンプル | エラーハンドリングが複雑 | ❌ 不適 |
|
|
110
|
+
| **State Machine** | 状態遷移明確 | オーバーエンジニアリング | ❌ 不適 |
|
|
111
|
+
|
|
112
|
+
### 既存システム統合戦略
|
|
113
|
+
|
|
114
|
+
**Adapter + Bridge Pattern**で統合:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// Adapter Pattern: 外部システムの抽象化
|
|
118
|
+
class ExpertIntegration {
|
|
119
|
+
constructor(private delegation: DelegationEngine) {}
|
|
120
|
+
|
|
121
|
+
async convertToEARS(finding: string): Promise<string> {
|
|
122
|
+
return (await this.delegation.delegate({ ... })).content;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Bridge Pattern: 実装の切り替え
|
|
127
|
+
interface KnowledgePersistence {
|
|
128
|
+
save(item: KnowledgeItem): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
class InMemoryPersistence implements KnowledgePersistence { /* ... */ }
|
|
132
|
+
class KnowledgeStorePersistence implements KnowledgePersistence { /* ... */ }
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 状態管理: KnowledgeBase
|
|
136
|
+
|
|
137
|
+
**Repository Pattern**でデータアクセスを抽象化:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
class KnowledgeBase {
|
|
141
|
+
private items: Map<string, KnowledgeItem> = new Map();
|
|
142
|
+
private iterationIndex: Map<number, string[]> = new Map();
|
|
143
|
+
|
|
144
|
+
add(item: KnowledgeItem): void { /* ... */ }
|
|
145
|
+
getFindings(): KnowledgeItem[] { /* ... */ }
|
|
146
|
+
getByIteration(iteration: number): KnowledgeItem[] { /* ... */ }
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**将来の永続化移行が容易**:
|
|
151
|
+
- 現在: In-Memory (Map)
|
|
152
|
+
- 将来: @musubix/knowledge統合 → JSON永続化
|
|
153
|
+
- 将来: Database統合 → PostgreSQL/MongoDB
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Consequences
|
|
158
|
+
|
|
159
|
+
### Positive
|
|
160
|
+
|
|
161
|
+
✅ **明確なフロー**: research()メソッドでイテレーションロジックが一目瞭然
|
|
162
|
+
✅ **拡張性**: 各フックメソッドをオーバーライドして特定ドメインに特化可能
|
|
163
|
+
✅ **テスト容易性**: 各ステップを独立してMock/Stubでテスト
|
|
164
|
+
✅ **トレーサビリティ**: 各イテレーションでログ出力、デバッグ容易
|
|
165
|
+
✅ **憲法準拠**: Library-First、Design Patterns適用
|
|
166
|
+
|
|
167
|
+
### Negative
|
|
168
|
+
|
|
169
|
+
⚠️ **継承の制約**: Template Methodは継承ベースなので、多重継承不可
|
|
170
|
+
⚠️ **フック数**: フックメソッドが増えすぎると保守性低下
|
|
171
|
+
⚠️ **状態管理**: KnowledgeBaseが肥大化する可能性
|
|
172
|
+
|
|
173
|
+
### Mitigations
|
|
174
|
+
|
|
175
|
+
- **Composition over Inheritance**: 必要に応じてStrategyパターンと組み合わせ
|
|
176
|
+
- **フック数制限**: 5フックメソッド(generate, search, read, reason, evaluate)に限定
|
|
177
|
+
- **KnowledgeBase分割**: イテレーション数が50を超える場合は永続化層に移行
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Compliance
|
|
182
|
+
|
|
183
|
+
### 憲法準拠
|
|
184
|
+
|
|
185
|
+
| 条項 | 準拠状況 |
|
|
186
|
+
|-----|---------|
|
|
187
|
+
| I. Library-First | ✅ packages/deep-research/ |
|
|
188
|
+
| V. Traceability | ✅ 各コンポーネントにREQ-ID紐付け |
|
|
189
|
+
| VII. Design Patterns | ✅ Template Method, Strategy, Adapter等適用 |
|
|
190
|
+
|
|
191
|
+
### SOLID原則
|
|
192
|
+
|
|
193
|
+
| 原則 | 適用 |
|
|
194
|
+
|------|------|
|
|
195
|
+
| **S**RP | ✅ ResearchEngine(調整)、KnowledgeBase(データ)、ReportGenerator(出力)で分離 |
|
|
196
|
+
| **O**CP | ✅ フックメソッドで拡張、Template Method本体は変更不要 |
|
|
197
|
+
| **L**SP | ✅ サブクラスでフックメソッドをオーバーライド可能 |
|
|
198
|
+
| **I**SP | ✅ 各インターフェースは単一責任(SearchProvider、LMProvider等) |
|
|
199
|
+
| **D**IP | ✅ 抽象(インターフェース)に依存、具象クラスに依存しない |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## References
|
|
204
|
+
|
|
205
|
+
- [Design Patterns: Elements of Reusable Object-Oriented Software](https://en.wikipedia.org/wiki/Design_Patterns) - Template Method Pattern
|
|
206
|
+
- [jina-ai/node-DeepResearch](https://github.com/jina-ai/node-DeepResearch) - 参照実装
|
|
207
|
+
- REQ-MUSUBIX-v3.4.0.md - 要件定義書
|
|
208
|
+
- DES-DR-v3.4.0.md - 設計書
|
|
209
|
+
- steering/structure.ja.md - プロジェクト構造
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Approval
|
|
214
|
+
|
|
215
|
+
- **Author**: AI Agent (2026-01-16)
|
|
216
|
+
- **Reviewer**: -
|
|
217
|
+
- **Status**: Accepted
|