musubix 1.7.0 → 1.8.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.
- package/AGENTS.md +8 -4
- package/README.ja.md +3 -2
- package/README.md +3 -2
- package/docs/API-REFERENCE.md +238 -0
- package/docs/INSTALL-GUIDE.ja.md +2 -2
- package/docs/INSTALL-GUIDE.md +2 -2
- package/docs/USER-GUIDE.ja.md +115 -1
- package/docs/USER-GUIDE.md +115 -1
- package/docs/overview/MUSUBIX-Core.md +671 -0
- package/docs/overview/MUSUBIX-FormalVerify.md +566 -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-Roadmap-v2.md +399 -0
- package/docs/overview/MUSUBIX-Security-Plan.md +939 -0
- package/docs/overview/MUSUBIX-YATA.md +666 -0
- package/docs/overview/Neuro-SymbolicAI.md +159 -0
- package/package.json +6 -5
package/AGENTS.md
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
| 項目 | 詳細 |
|
|
10
10
|
|------|------|
|
|
11
|
-
| **バージョン** | 1.
|
|
11
|
+
| **バージョン** | 1.8.0 (Security Analysis Edition) |
|
|
12
12
|
| **言語** | TypeScript |
|
|
13
13
|
| **ランタイム** | Node.js >= 20.0.0 |
|
|
14
14
|
| **パッケージマネージャ** | npm >= 10.0.0 |
|
|
15
15
|
| **ビルドシステム** | モノレポ(npm workspaces) |
|
|
16
16
|
| **テストフレームワーク** | Vitest |
|
|
17
|
-
| **テスト数** |
|
|
17
|
+
| **テスト数** | 1586 (全合格) |
|
|
18
18
|
| **コンポーネント数** | 249 (62ドメイン対応) |
|
|
19
19
|
| **Agent Skills** | 12 (Claude Code対応) |
|
|
20
20
|
|
|
@@ -28,10 +28,12 @@
|
|
|
28
28
|
packages/
|
|
29
29
|
├── core/ # @nahisaho/musubix-core
|
|
30
30
|
├── mcp-server/ # @nahisaho/musubix-mcp-server
|
|
31
|
+
├── security/ # @nahisaho/musubix-security (NEW!)
|
|
32
|
+
├── formal-verify/ # @nahisaho/musubix-formal-verify
|
|
31
33
|
├── yata-client/ # @nahisaho/musubix-yata-client
|
|
32
34
|
├── yata-local/ # @nahisaho/yata-local
|
|
33
35
|
├── yata-global/ # @nahisaho/yata-global
|
|
34
|
-
├── yata-ui/ # @nahisaho/yata-ui
|
|
36
|
+
├── yata-ui/ # @nahisaho/yata-ui
|
|
35
37
|
├── pattern-mcp/ # @nahisaho/musubix-pattern-mcp
|
|
36
38
|
├── ontology-mcp/ # @nahisaho/musubix-ontology-mcp
|
|
37
39
|
├── wake-sleep/ # @nahisaho/musubix-wake-sleep
|
|
@@ -42,10 +44,12 @@ packages/
|
|
|
42
44
|
|-----------|-----|------|
|
|
43
45
|
| `packages/core/` | `@nahisaho/musubix-core` | コアライブラリ - CLI、EARS検証、コード生成、設計パターン |
|
|
44
46
|
| `packages/mcp-server/` | `@nahisaho/musubix-mcp-server` | MCPサーバー - 19ツール、3プロンプト |
|
|
47
|
+
| `packages/security/` | `@nahisaho/musubix-security` | **セキュリティ分析** - 脆弱性検出、シークレット検出、テイント解析 (NEW!) |
|
|
48
|
+
| `packages/formal-verify/` | `@nahisaho/musubix-formal-verify` | 形式検証 - Z3統合、Hoare検証、EARS→SMT変換 |
|
|
45
49
|
| `packages/yata-client/` | `@nahisaho/musubix-yata-client` | YATAクライアント - 知識グラフ連携 |
|
|
46
50
|
| `packages/yata-local/` | `@nahisaho/yata-local` | **YATA Local** - SQLiteベースローカル知識グラフ |
|
|
47
51
|
| `packages/yata-global/` | `@nahisaho/yata-global` | **YATA Global** - 分散型知識グラフプラットフォーム |
|
|
48
|
-
| `packages/yata-ui/` | `@nahisaho/yata-ui` | **YATA UI** - Web可視化・管理インターフェース
|
|
52
|
+
| `packages/yata-ui/` | `@nahisaho/yata-ui` | **YATA UI** - Web可視化・管理インターフェース |
|
|
49
53
|
| `packages/pattern-mcp/` | `@nahisaho/musubix-pattern-mcp` | パターン学習 - 抽出・圧縮・ライブラリ |
|
|
50
54
|
| `packages/ontology-mcp/` | `@nahisaho/musubix-ontology-mcp` | オントロジー - N3Store・推論エンジン |
|
|
51
55
|
| `packages/wake-sleep/` | `@nahisaho/musubix-wake-sleep` | Wake-Sleep学習サイクル |
|
package/README.ja.md
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
[](https://nodejs.org/)
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
[](https://www.typescriptlang.org/)
|
|
9
|
-
[](https://github.com/nahisaho/MUSUBIX)
|
|
10
10
|
|
|
11
11
|
> MUSUBI × YATA 統合による次世代AIコーディングシステム
|
|
12
12
|
>
|
|
13
|
-
> **v1.7.
|
|
13
|
+
> **v1.7.5** - 形式検証エディション
|
|
14
14
|
|
|
15
15
|
## 概要
|
|
16
16
|
|
|
@@ -36,6 +36,7 @@ MUSUBIXは、**ニューラル(LLM)** と **シンボリック(知識グ
|
|
|
36
36
|
- 🌐 **YATA Global** - オフライン同期対応分散型知識プラットフォーム *(v1.6.3)*
|
|
37
37
|
- 📤 **KGPR** - 安全な知識共有のためのKnowledge Graph Pull Request *(v1.6.4)*
|
|
38
38
|
- 🚀 **YATAプラットフォーム拡張** - インデックス最適化、拡張エクスポート、グローバル同期、コード生成、Web UI *(v1.7.0)*
|
|
39
|
+
- 🔬 **形式検証** - Z3 SMTソルバー統合、Hoareトリプル検証、EARS→SMT変換 *(v1.7.5)*
|
|
39
40
|
|
|
40
41
|
## アーキテクチャ
|
|
41
42
|
|
package/README.md
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](https://www.typescriptlang.org/)
|
|
10
|
-
[](https://github.com/nahisaho/MUSUBIX)
|
|
11
11
|
|
|
12
12
|
> Next-generation AI Coding System powered by MUSUBI × YATA Integration
|
|
13
13
|
>
|
|
14
|
-
> **v1.7.
|
|
14
|
+
> **v1.7.5** - Formal Verification Edition
|
|
15
15
|
|
|
16
16
|
**[日本語版 README](README.ja.md)**
|
|
17
17
|
|
|
@@ -39,6 +39,7 @@ MUSUBIX is an innovative AI coding system that integrates **Neural (LLM)** and *
|
|
|
39
39
|
- 🌐 **YATA Global** - Distributed knowledge platform with offline sync *(v1.6.3)*
|
|
40
40
|
- 📤 **KGPR** - Knowledge Graph Pull Request for safe knowledge sharing *(v1.6.4)*
|
|
41
41
|
- 🚀 **YATA Platform Enhancements** - Index optimization, enhanced export, global sync, code generation, web UI *(v1.7.0)*
|
|
42
|
+
- 🔬 **Formal Verification** - Z3 SMT solver integration, Hoare triple verification, EARS-to-SMT conversion *(v1.7.5)*
|
|
42
43
|
|
|
43
44
|
## Architecture
|
|
44
45
|
|
package/docs/API-REFERENCE.md
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
- [YATA Global](#yata-global) *(v1.6.3)*
|
|
19
19
|
- [KGPR](#kgpr) *(v1.6.4)*
|
|
20
20
|
- [YATA Platform](#yata-platform) *(v1.7.0)*
|
|
21
|
+
- [Formal Verification](#formal-verification) *(v1.7.5)*
|
|
21
22
|
- [Validation](#validation)
|
|
22
23
|
- [Utils](#utils)
|
|
23
24
|
- [MCP Server](#mcp-server)
|
|
@@ -885,6 +886,243 @@ await server.start();
|
|
|
885
886
|
|
|
886
887
|
---
|
|
887
888
|
|
|
889
|
+
### Formal Verification (v1.7.5)
|
|
890
|
+
|
|
891
|
+
The formal verification module provides Z3 SMT solver integration for verifying code correctness.
|
|
892
|
+
|
|
893
|
+
#### Z3Adapter
|
|
894
|
+
|
|
895
|
+
Unified interface for Z3 backends (WASM or Process).
|
|
896
|
+
|
|
897
|
+
```typescript
|
|
898
|
+
import { Z3Adapter } from '@nahisaho/musubix-formal-verify';
|
|
899
|
+
|
|
900
|
+
// Create adapter (auto-selects best backend)
|
|
901
|
+
const z3 = await Z3Adapter.create();
|
|
902
|
+
|
|
903
|
+
// Check satisfiability
|
|
904
|
+
const result = await z3.checkSat('(declare-const x Int) (assert (> x 0))');
|
|
905
|
+
console.log(result); // 'sat' | 'unsat' | 'unknown'
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
**Methods:**
|
|
909
|
+
|
|
910
|
+
| Method | Parameters | Returns | Description |
|
|
911
|
+
|--------|------------|---------|-------------|
|
|
912
|
+
| `create()` | - | `Promise<Z3Adapter>` | Create adapter instance |
|
|
913
|
+
| `checkSat(smtLib2)` | `smtLib2: string` | `Promise<string>` | Check satisfiability |
|
|
914
|
+
| `dispose()` | - | `Promise<void>` | Cleanup resources |
|
|
915
|
+
|
|
916
|
+
---
|
|
917
|
+
|
|
918
|
+
#### PreconditionVerifier
|
|
919
|
+
|
|
920
|
+
Verifies preconditions for functions and methods.
|
|
921
|
+
|
|
922
|
+
```typescript
|
|
923
|
+
import { PreconditionVerifier } from '@nahisaho/musubix-formal-verify';
|
|
924
|
+
|
|
925
|
+
const verifier = new PreconditionVerifier(z3Adapter);
|
|
926
|
+
|
|
927
|
+
const result = await verifier.verify({
|
|
928
|
+
condition: { expression: 'amount > 0 && balance >= amount', format: 'javascript' },
|
|
929
|
+
variables: [
|
|
930
|
+
{ name: 'amount', type: 'Int' },
|
|
931
|
+
{ name: 'balance', type: 'Int' }
|
|
932
|
+
]
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
console.log(result.status); // 'valid' | 'invalid' | 'unknown' | 'error'
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
**Methods:**
|
|
939
|
+
|
|
940
|
+
| Method | Parameters | Returns | Description |
|
|
941
|
+
|--------|------------|---------|-------------|
|
|
942
|
+
| `verify(spec)` | `PreconditionSpec` | `Promise<VerificationResult>` | Verify precondition |
|
|
943
|
+
|
|
944
|
+
**PreconditionSpec:**
|
|
945
|
+
|
|
946
|
+
| Property | Type | Description |
|
|
947
|
+
|----------|------|-------------|
|
|
948
|
+
| `condition` | `Condition` | The precondition to verify |
|
|
949
|
+
| `variables` | `Variable[]` | Variables with types |
|
|
950
|
+
|
|
951
|
+
**VerificationResult:**
|
|
952
|
+
|
|
953
|
+
| Property | Type | Description |
|
|
954
|
+
|----------|------|-------------|
|
|
955
|
+
| `status` | `'valid' \| 'invalid' \| 'unknown' \| 'error'` | Verification status |
|
|
956
|
+
| `counterexample?` | `Record<string, any>` | Counterexample if invalid |
|
|
957
|
+
| `message?` | `string` | Additional message |
|
|
958
|
+
|
|
959
|
+
---
|
|
960
|
+
|
|
961
|
+
#### PostconditionVerifier
|
|
962
|
+
|
|
963
|
+
Verifies Hoare triples {P} C {Q}.
|
|
964
|
+
|
|
965
|
+
```typescript
|
|
966
|
+
import { PostconditionVerifier } from '@nahisaho/musubix-formal-verify';
|
|
967
|
+
|
|
968
|
+
const verifier = new PostconditionVerifier(z3Adapter);
|
|
969
|
+
|
|
970
|
+
const result = await verifier.verify({
|
|
971
|
+
precondition: { expression: 'balance >= amount', format: 'javascript' },
|
|
972
|
+
postcondition: { expression: 'balance_new == balance - amount', format: 'javascript' },
|
|
973
|
+
preVariables: [
|
|
974
|
+
{ name: 'balance', type: 'Int' },
|
|
975
|
+
{ name: 'amount', type: 'Int' }
|
|
976
|
+
],
|
|
977
|
+
postVariables: [
|
|
978
|
+
{ name: 'balance_new', type: 'Int' }
|
|
979
|
+
],
|
|
980
|
+
transition: 'balance_new == balance - amount'
|
|
981
|
+
});
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
**PostconditionSpec:**
|
|
985
|
+
|
|
986
|
+
| Property | Type | Description |
|
|
987
|
+
|----------|------|-------------|
|
|
988
|
+
| `precondition` | `Condition` | Pre-state condition |
|
|
989
|
+
| `postcondition` | `Condition` | Post-state condition |
|
|
990
|
+
| `preVariables` | `Variable[]` | Pre-state variables |
|
|
991
|
+
| `postVariables` | `Variable[]` | Post-state variables |
|
|
992
|
+
| `transition` | `string` | State transition expression |
|
|
993
|
+
|
|
994
|
+
---
|
|
995
|
+
|
|
996
|
+
#### EarsToSmtConverter
|
|
997
|
+
|
|
998
|
+
Converts EARS requirements to SMT-LIB2 formulas.
|
|
999
|
+
|
|
1000
|
+
```typescript
|
|
1001
|
+
import { EarsToSmtConverter } from '@nahisaho/musubix-formal-verify';
|
|
1002
|
+
|
|
1003
|
+
const converter = new EarsToSmtConverter();
|
|
1004
|
+
|
|
1005
|
+
// Single conversion
|
|
1006
|
+
const result = converter.convert('THE system SHALL validate inputs');
|
|
1007
|
+
|
|
1008
|
+
// Multiple conversions
|
|
1009
|
+
const results = converter.convertMultiple([
|
|
1010
|
+
'THE system SHALL validate inputs', // ubiquitous
|
|
1011
|
+
'WHEN error, THE system SHALL notify user', // event-driven
|
|
1012
|
+
'WHILE busy, THE system SHALL queue requests', // state-driven
|
|
1013
|
+
'THE system SHALL NOT expose secrets', // unwanted
|
|
1014
|
+
'IF admin, THEN THE system SHALL allow edit' // optional
|
|
1015
|
+
]);
|
|
1016
|
+
```
|
|
1017
|
+
|
|
1018
|
+
**Methods:**
|
|
1019
|
+
|
|
1020
|
+
| Method | Parameters | Returns | Description |
|
|
1021
|
+
|--------|------------|---------|-------------|
|
|
1022
|
+
| `convert(ears)` | `ears: string` | `ConversionResult` | Convert single requirement |
|
|
1023
|
+
| `convertMultiple(ears[])` | `ears: string[]` | `ConversionResult[]` | Convert multiple requirements |
|
|
1024
|
+
|
|
1025
|
+
**EARS Patterns:**
|
|
1026
|
+
|
|
1027
|
+
| Pattern | Syntax | SMT Encoding |
|
|
1028
|
+
|---------|--------|--------------|
|
|
1029
|
+
| Ubiquitous | `THE system SHALL [action]` | `(assert action)` |
|
|
1030
|
+
| Event-driven | `WHEN [event], THE system SHALL [response]` | `(assert (=> event response))` |
|
|
1031
|
+
| State-driven | `WHILE [state], THE system SHALL [response]` | `(assert (=> state response))` |
|
|
1032
|
+
| Unwanted | `THE system SHALL NOT [behavior]` | `(assert (not behavior))` |
|
|
1033
|
+
| Optional | `IF [condition], THEN THE system SHALL [response]` | `(assert (=> condition response))` |
|
|
1034
|
+
|
|
1035
|
+
---
|
|
1036
|
+
|
|
1037
|
+
#### TraceabilityDB
|
|
1038
|
+
|
|
1039
|
+
SQLite-based traceability database.
|
|
1040
|
+
|
|
1041
|
+
```typescript
|
|
1042
|
+
import { TraceabilityDB } from '@nahisaho/musubix-formal-verify';
|
|
1043
|
+
|
|
1044
|
+
const db = new TraceabilityDB('./trace.db');
|
|
1045
|
+
|
|
1046
|
+
// Add nodes
|
|
1047
|
+
await db.addNode({ id: 'REQ-001', type: 'requirement', title: 'User Auth' });
|
|
1048
|
+
await db.addNode({ id: 'DES-001', type: 'design', title: 'AuthService' });
|
|
1049
|
+
await db.addNode({ id: 'CODE-001', type: 'code', title: 'auth.ts' });
|
|
1050
|
+
|
|
1051
|
+
// Add links
|
|
1052
|
+
await db.addLink({ source: 'DES-001', target: 'REQ-001', type: 'satisfies' });
|
|
1053
|
+
await db.addLink({ source: 'CODE-001', target: 'DES-001', type: 'implements' });
|
|
1054
|
+
|
|
1055
|
+
// Query
|
|
1056
|
+
const node = await db.getNode('REQ-001');
|
|
1057
|
+
const stats = await db.getStatistics();
|
|
1058
|
+
```
|
|
1059
|
+
|
|
1060
|
+
**Methods:**
|
|
1061
|
+
|
|
1062
|
+
| Method | Parameters | Returns | Description |
|
|
1063
|
+
|--------|------------|---------|-------------|
|
|
1064
|
+
| `addNode(node)` | `TraceNode` | `Promise<void>` | Add traceability node |
|
|
1065
|
+
| `getNode(id)` | `id: string` | `Promise<TraceNode \| undefined>` | Get node by ID |
|
|
1066
|
+
| `addLink(link)` | `TraceLink` | `Promise<void>` | Add traceability link |
|
|
1067
|
+
| `getStatistics()` | - | `Promise<TraceStats>` | Get database statistics |
|
|
1068
|
+
| `query(nodeId, options?)` | `nodeId: string, QueryOptions` | `Promise<QueryResult>` | Query related nodes |
|
|
1069
|
+
| `close()` | - | `void` | Close database |
|
|
1070
|
+
|
|
1071
|
+
**Node Types:**
|
|
1072
|
+
|
|
1073
|
+
| Type | Description |
|
|
1074
|
+
|------|-------------|
|
|
1075
|
+
| `requirement` | Requirements (REQ-*) |
|
|
1076
|
+
| `design` | Design artifacts (DES-*) |
|
|
1077
|
+
| `code` | Code files |
|
|
1078
|
+
| `test` | Test cases |
|
|
1079
|
+
|
|
1080
|
+
**Link Types:**
|
|
1081
|
+
|
|
1082
|
+
| Type | Description |
|
|
1083
|
+
|------|-------------|
|
|
1084
|
+
| `satisfies` | Design satisfies requirement |
|
|
1085
|
+
| `implements` | Code implements design |
|
|
1086
|
+
| `verifies` | Test verifies requirement |
|
|
1087
|
+
| `traces-to` | Generic traceability |
|
|
1088
|
+
|
|
1089
|
+
---
|
|
1090
|
+
|
|
1091
|
+
#### ImpactAnalyzer
|
|
1092
|
+
|
|
1093
|
+
Analyzes change impact across traceability graph.
|
|
1094
|
+
|
|
1095
|
+
```typescript
|
|
1096
|
+
import { ImpactAnalyzer } from '@nahisaho/musubix-formal-verify';
|
|
1097
|
+
|
|
1098
|
+
const analyzer = new ImpactAnalyzer(traceabilityDB);
|
|
1099
|
+
|
|
1100
|
+
// Analyze impact of changing REQ-001
|
|
1101
|
+
const impact = await analyzer.analyze('REQ-001');
|
|
1102
|
+
|
|
1103
|
+
console.log(`Total impacted: ${impact.totalImpacted}`);
|
|
1104
|
+
console.log(`Direct: ${impact.directImpact.length}`);
|
|
1105
|
+
console.log(`Indirect: ${impact.indirectImpact.length}`);
|
|
1106
|
+
```
|
|
1107
|
+
|
|
1108
|
+
**Methods:**
|
|
1109
|
+
|
|
1110
|
+
| Method | Parameters | Returns | Description |
|
|
1111
|
+
|--------|------------|---------|-------------|
|
|
1112
|
+
| `analyze(nodeId)` | `nodeId: string` | `Promise<ImpactResult>` | Analyze change impact |
|
|
1113
|
+
|
|
1114
|
+
**ImpactResult:**
|
|
1115
|
+
|
|
1116
|
+
| Property | Type | Description |
|
|
1117
|
+
|----------|------|-------------|
|
|
1118
|
+
| `sourceId` | `string` | Source node ID |
|
|
1119
|
+
| `directImpact` | `ImpactedNode[]` | Directly impacted nodes |
|
|
1120
|
+
| `indirectImpact` | `ImpactedNode[]` | Transitively impacted nodes |
|
|
1121
|
+
| `totalImpacted` | `number` | Total number of impacted nodes |
|
|
1122
|
+
| `maxDepth` | `number` | Maximum impact depth |
|
|
1123
|
+
|
|
1124
|
+
---
|
|
1125
|
+
|
|
888
1126
|
### Utils
|
|
889
1127
|
|
|
890
1128
|
#### I18nManager
|
package/docs/INSTALL-GUIDE.ja.md
CHANGED
package/docs/INSTALL-GUIDE.md
CHANGED
package/docs/USER-GUIDE.ja.md
CHANGED
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
17. [YATA Global](#yata-global) *(v1.6.3)*
|
|
24
24
|
18. [KGPR - Knowledge Graph Pull Request](#kgpr---knowledge-graph-pull-request) *(v1.6.4)*
|
|
25
25
|
19. [YATA プラットフォーム拡張](#yata-プラットフォーム拡張) *(v1.7.0)*
|
|
26
|
-
20. [
|
|
26
|
+
20. [形式検証](#形式検証) *(v1.7.5)*
|
|
27
|
+
21. [MCPサーバー連携](#mcpサーバー連携)
|
|
27
28
|
21. [YATA知識グラフ](#yata知識グラフ)
|
|
28
29
|
22. [ベストプラクティス](#ベストプラクティス)
|
|
29
30
|
23. [トラブルシューティング](#トラブルシューティング)
|
|
@@ -1551,6 +1552,119 @@ console.log(`UI: ${server.getUrl()}`);
|
|
|
1551
1552
|
|
|
1552
1553
|
---
|
|
1553
1554
|
|
|
1555
|
+
## 形式検証
|
|
1556
|
+
|
|
1557
|
+
*(v1.7.5)*
|
|
1558
|
+
|
|
1559
|
+
`@nahisaho/musubix-formal-verify` パッケージは、Z3 SMTソルバーを使用した形式検証機能を提供します。
|
|
1560
|
+
|
|
1561
|
+
### インストール
|
|
1562
|
+
|
|
1563
|
+
```bash
|
|
1564
|
+
npm install @nahisaho/musubix-formal-verify
|
|
1565
|
+
# オプション: WebAssemblyサポート用にz3-solverをインストール
|
|
1566
|
+
npm install z3-solver
|
|
1567
|
+
```
|
|
1568
|
+
|
|
1569
|
+
### Z3 SMTソルバー統合
|
|
1570
|
+
|
|
1571
|
+
```typescript
|
|
1572
|
+
import { Z3Adapter, PreconditionVerifier, PostconditionVerifier } from '@nahisaho/musubix-formal-verify';
|
|
1573
|
+
|
|
1574
|
+
// Z3アダプター作成(バックエンド自動選択)
|
|
1575
|
+
const z3 = await Z3Adapter.create();
|
|
1576
|
+
|
|
1577
|
+
// 事前条件検証
|
|
1578
|
+
const preVerifier = new PreconditionVerifier(z3);
|
|
1579
|
+
const result = await preVerifier.verify({
|
|
1580
|
+
condition: { expression: 'amount > 0 && balance >= amount', format: 'javascript' },
|
|
1581
|
+
variables: [
|
|
1582
|
+
{ name: 'amount', type: 'Int' },
|
|
1583
|
+
{ name: 'balance', type: 'Int' },
|
|
1584
|
+
],
|
|
1585
|
+
});
|
|
1586
|
+
|
|
1587
|
+
console.log(result.status); // 'valid' | 'invalid' | 'unknown' | 'error'
|
|
1588
|
+
```
|
|
1589
|
+
|
|
1590
|
+
### Hoareトリプル検証
|
|
1591
|
+
|
|
1592
|
+
```typescript
|
|
1593
|
+
// {P} C {Q} の検証
|
|
1594
|
+
const postVerifier = new PostconditionVerifier(z3);
|
|
1595
|
+
const hoareResult = await postVerifier.verify({
|
|
1596
|
+
precondition: { expression: 'balance >= amount', format: 'javascript' },
|
|
1597
|
+
postcondition: { expression: 'balance_new == balance - amount', format: 'javascript' },
|
|
1598
|
+
preVariables: [{ name: 'balance', type: 'Int' }, { name: 'amount', type: 'Int' }],
|
|
1599
|
+
postVariables: [{ name: 'balance_new', type: 'Int' }],
|
|
1600
|
+
transition: 'balance_new == balance - amount',
|
|
1601
|
+
});
|
|
1602
|
+
```
|
|
1603
|
+
|
|
1604
|
+
### EARS→SMT変換
|
|
1605
|
+
|
|
1606
|
+
```typescript
|
|
1607
|
+
import { EarsToSmtConverter } from '@nahisaho/musubix-formal-verify';
|
|
1608
|
+
|
|
1609
|
+
const converter = new EarsToSmtConverter();
|
|
1610
|
+
|
|
1611
|
+
// EARS要件をSMT-LIB2に変換
|
|
1612
|
+
const results = converter.convertMultiple([
|
|
1613
|
+
'THE system SHALL validate inputs', // ubiquitous
|
|
1614
|
+
'WHEN error, THE system SHALL notify user', // event-driven
|
|
1615
|
+
'WHILE busy, THE system SHALL queue requests', // state-driven
|
|
1616
|
+
'THE system SHALL NOT expose secrets', // unwanted
|
|
1617
|
+
'IF admin, THEN THE system SHALL allow edit', // optional
|
|
1618
|
+
]);
|
|
1619
|
+
|
|
1620
|
+
results.forEach(r => {
|
|
1621
|
+
console.log(`パターン: ${r.formula?.metadata.earsPattern.type}`);
|
|
1622
|
+
console.log(`SMT: ${r.formula?.smtLib2}`);
|
|
1623
|
+
});
|
|
1624
|
+
```
|
|
1625
|
+
|
|
1626
|
+
### トレーサビリティデータベース
|
|
1627
|
+
|
|
1628
|
+
```typescript
|
|
1629
|
+
import { TraceabilityDB, ImpactAnalyzer } from '@nahisaho/musubix-formal-verify';
|
|
1630
|
+
|
|
1631
|
+
// SQLiteベースのトレーサビリティDB作成
|
|
1632
|
+
const db = new TraceabilityDB('./trace.db');
|
|
1633
|
+
|
|
1634
|
+
// ノード追加
|
|
1635
|
+
await db.addNode({ id: 'REQ-001', type: 'requirement', title: 'ユーザー認証' });
|
|
1636
|
+
await db.addNode({ id: 'DES-001', type: 'design', title: 'AuthService' });
|
|
1637
|
+
await db.addNode({ id: 'CODE-001', type: 'code', title: 'auth.ts' });
|
|
1638
|
+
|
|
1639
|
+
// トレーサビリティリンク追加
|
|
1640
|
+
await db.addLink({ source: 'DES-001', target: 'REQ-001', type: 'satisfies' });
|
|
1641
|
+
await db.addLink({ source: 'CODE-001', target: 'DES-001', type: 'implements' });
|
|
1642
|
+
|
|
1643
|
+
// 影響分析
|
|
1644
|
+
const analyzer = new ImpactAnalyzer(db);
|
|
1645
|
+
const impact = await analyzer.analyze('REQ-001');
|
|
1646
|
+
console.log(`影響ノード数: ${impact.totalImpacted}`);
|
|
1647
|
+
```
|
|
1648
|
+
|
|
1649
|
+
### v1.7.5 パッケージ概要
|
|
1650
|
+
|
|
1651
|
+
| パッケージ | 説明 |
|
|
1652
|
+
|-----------|------|
|
|
1653
|
+
| `@nahisaho/musubix-formal-verify` | Z3統合、Hoare検証、EARS→SMT、トレーサビリティDB |
|
|
1654
|
+
|
|
1655
|
+
### サポートされる変数型
|
|
1656
|
+
|
|
1657
|
+
| 型 | 説明 |
|
|
1658
|
+
|----|------|
|
|
1659
|
+
| `Int` | 整数値 |
|
|
1660
|
+
| `Real` | 実数 |
|
|
1661
|
+
| `Bool` | 真偽値 |
|
|
1662
|
+
| `String` | 文字列 |
|
|
1663
|
+
| `Array` | 配列型 |
|
|
1664
|
+
| `BitVec` | ビットベクトル |
|
|
1665
|
+
|
|
1666
|
+
---
|
|
1667
|
+
|
|
1554
1668
|
## MCPサーバー連携
|
|
1555
1669
|
|
|
1556
1670
|
### MCPサーバーの起動
|
package/docs/USER-GUIDE.md
CHANGED
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
13. [YATA Global](#yata-global) *(v1.6.3)*
|
|
22
22
|
14. [KGPR - Knowledge Graph Pull Request](#kgpr---knowledge-graph-pull-request) *(v1.6.4)*
|
|
23
23
|
15. [YATA Platform Enhancements](#yata-platform-enhancements) *(v1.7.0)*
|
|
24
|
-
16. [
|
|
24
|
+
16. [Formal Verification](#formal-verification) *(v1.7.5)*
|
|
25
|
+
17. [MCP Server Integration](#mcp-server-integration)
|
|
25
26
|
17. [YATA Integration](#yata-integration)
|
|
26
27
|
18. [Best Practices](#best-practices)
|
|
27
28
|
19. [Troubleshooting](#troubleshooting)
|
|
@@ -1093,6 +1094,119 @@ console.log(`UI available at ${server.getUrl()}`);
|
|
|
1093
1094
|
|
|
1094
1095
|
---
|
|
1095
1096
|
|
|
1097
|
+
## Formal Verification
|
|
1098
|
+
|
|
1099
|
+
*(v1.7.5)*
|
|
1100
|
+
|
|
1101
|
+
The `@nahisaho/musubix-formal-verify` package provides formal verification capabilities using the Z3 SMT solver.
|
|
1102
|
+
|
|
1103
|
+
### Installation
|
|
1104
|
+
|
|
1105
|
+
```bash
|
|
1106
|
+
npm install @nahisaho/musubix-formal-verify
|
|
1107
|
+
# Optional: Install z3-solver for WebAssembly support
|
|
1108
|
+
npm install z3-solver
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
### Z3 SMT Solver Integration
|
|
1112
|
+
|
|
1113
|
+
```typescript
|
|
1114
|
+
import { Z3Adapter, PreconditionVerifier, PostconditionVerifier } from '@nahisaho/musubix-formal-verify';
|
|
1115
|
+
|
|
1116
|
+
// Create Z3 adapter (auto-selects backend)
|
|
1117
|
+
const z3 = await Z3Adapter.create();
|
|
1118
|
+
|
|
1119
|
+
// Precondition verification
|
|
1120
|
+
const preVerifier = new PreconditionVerifier(z3);
|
|
1121
|
+
const result = await preVerifier.verify({
|
|
1122
|
+
condition: { expression: 'amount > 0 && balance >= amount', format: 'javascript' },
|
|
1123
|
+
variables: [
|
|
1124
|
+
{ name: 'amount', type: 'Int' },
|
|
1125
|
+
{ name: 'balance', type: 'Int' },
|
|
1126
|
+
],
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
console.log(result.status); // 'valid' | 'invalid' | 'unknown' | 'error'
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
### Hoare Triple Verification
|
|
1133
|
+
|
|
1134
|
+
```typescript
|
|
1135
|
+
// Verify {P} C {Q}
|
|
1136
|
+
const postVerifier = new PostconditionVerifier(z3);
|
|
1137
|
+
const hoareResult = await postVerifier.verify({
|
|
1138
|
+
precondition: { expression: 'balance >= amount', format: 'javascript' },
|
|
1139
|
+
postcondition: { expression: 'balance_new == balance - amount', format: 'javascript' },
|
|
1140
|
+
preVariables: [{ name: 'balance', type: 'Int' }, { name: 'amount', type: 'Int' }],
|
|
1141
|
+
postVariables: [{ name: 'balance_new', type: 'Int' }],
|
|
1142
|
+
transition: 'balance_new == balance - amount',
|
|
1143
|
+
});
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
### EARS to SMT Conversion
|
|
1147
|
+
|
|
1148
|
+
```typescript
|
|
1149
|
+
import { EarsToSmtConverter } from '@nahisaho/musubix-formal-verify';
|
|
1150
|
+
|
|
1151
|
+
const converter = new EarsToSmtConverter();
|
|
1152
|
+
|
|
1153
|
+
// Convert EARS requirements to SMT-LIB2
|
|
1154
|
+
const results = converter.convertMultiple([
|
|
1155
|
+
'THE system SHALL validate inputs', // ubiquitous
|
|
1156
|
+
'WHEN error, THE system SHALL notify user', // event-driven
|
|
1157
|
+
'WHILE busy, THE system SHALL queue requests', // state-driven
|
|
1158
|
+
'THE system SHALL NOT expose secrets', // unwanted
|
|
1159
|
+
'IF admin, THEN THE system SHALL allow edit', // optional
|
|
1160
|
+
]);
|
|
1161
|
+
|
|
1162
|
+
results.forEach(r => {
|
|
1163
|
+
console.log(`Pattern: ${r.formula?.metadata.earsPattern.type}`);
|
|
1164
|
+
console.log(`SMT: ${r.formula?.smtLib2}`);
|
|
1165
|
+
});
|
|
1166
|
+
```
|
|
1167
|
+
|
|
1168
|
+
### Traceability Database
|
|
1169
|
+
|
|
1170
|
+
```typescript
|
|
1171
|
+
import { TraceabilityDB, ImpactAnalyzer } from '@nahisaho/musubix-formal-verify';
|
|
1172
|
+
|
|
1173
|
+
// Create SQLite-based traceability database
|
|
1174
|
+
const db = new TraceabilityDB('./trace.db');
|
|
1175
|
+
|
|
1176
|
+
// Add nodes
|
|
1177
|
+
await db.addNode({ id: 'REQ-001', type: 'requirement', title: 'User Auth' });
|
|
1178
|
+
await db.addNode({ id: 'DES-001', type: 'design', title: 'AuthService' });
|
|
1179
|
+
await db.addNode({ id: 'CODE-001', type: 'code', title: 'auth.ts' });
|
|
1180
|
+
|
|
1181
|
+
// Add traceability links
|
|
1182
|
+
await db.addLink({ source: 'DES-001', target: 'REQ-001', type: 'satisfies' });
|
|
1183
|
+
await db.addLink({ source: 'CODE-001', target: 'DES-001', type: 'implements' });
|
|
1184
|
+
|
|
1185
|
+
// Impact analysis
|
|
1186
|
+
const analyzer = new ImpactAnalyzer(db);
|
|
1187
|
+
const impact = await analyzer.analyze('REQ-001');
|
|
1188
|
+
console.log(`Impacted nodes: ${impact.totalImpacted}`);
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
### v1.7.5 Package Summary
|
|
1192
|
+
|
|
1193
|
+
| Package | Description |
|
|
1194
|
+
|---------|-------------|
|
|
1195
|
+
| `@nahisaho/musubix-formal-verify` | Z3 integration, Hoare verification, EARS→SMT, TraceabilityDB |
|
|
1196
|
+
|
|
1197
|
+
### Supported Variable Types
|
|
1198
|
+
|
|
1199
|
+
| Type | Description |
|
|
1200
|
+
|------|-------------|
|
|
1201
|
+
| `Int` | Integer values |
|
|
1202
|
+
| `Real` | Real numbers |
|
|
1203
|
+
| `Bool` | Boolean values |
|
|
1204
|
+
| `String` | String values |
|
|
1205
|
+
| `Array` | Array types |
|
|
1206
|
+
| `BitVec` | Bit vectors |
|
|
1207
|
+
|
|
1208
|
+
---
|
|
1209
|
+
|
|
1096
1210
|
## MCP Server Integration
|
|
1097
1211
|
|
|
1098
1212
|
### CLI Startup
|