musubix 1.8.0 → 1.8.5
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/README.ja.md +10 -4
- package/README.md +22 -4
- package/docs/USER-GUIDE-v1.8.0.md +2371 -0
- package/docs/USER-GUIDE.ja.md +170 -5
- package/docs/USER-GUIDE.md +487 -6
- package/docs/overview/MUSUBIX-Phase1-Complete.md +271 -0
- package/docs/overview/MUSUBIX-Security.md +891 -0
- package/package.json +4 -2
package/docs/USER-GUIDE.ja.md
CHANGED
|
@@ -24,10 +24,11 @@
|
|
|
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
26
|
20. [形式検証](#形式検証) *(v1.7.5)*
|
|
27
|
-
21. [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
21. [セキュリティ分析](#セキュリティ分析) *(v1.8.0)*
|
|
28
|
+
22. [MCPサーバー連携](#mcpサーバー連携)
|
|
29
|
+
23. [YATA知識グラフ](#yata知識グラフ)
|
|
30
|
+
24. [ベストプラクティス](#ベストプラクティス)
|
|
31
|
+
25. [トラブルシューティング](#トラブルシューティング)
|
|
31
32
|
|
|
32
33
|
---
|
|
33
34
|
|
|
@@ -1665,6 +1666,170 @@ console.log(`影響ノード数: ${impact.totalImpacted}`);
|
|
|
1665
1666
|
|
|
1666
1667
|
---
|
|
1667
1668
|
|
|
1669
|
+
## セキュリティ分析
|
|
1670
|
+
|
|
1671
|
+
*(v1.8.0)*
|
|
1672
|
+
|
|
1673
|
+
`@nahisaho/musubix-security` パッケージは、TypeScript/JavaScriptプロジェクト向けの包括的なセキュリティ分析機能を提供します。
|
|
1674
|
+
|
|
1675
|
+
### インストール
|
|
1676
|
+
|
|
1677
|
+
```bash
|
|
1678
|
+
npm install @nahisaho/musubix-security
|
|
1679
|
+
```
|
|
1680
|
+
|
|
1681
|
+
### 脆弱性スキャン
|
|
1682
|
+
|
|
1683
|
+
AST解析によりOWASP Top 10およびCWE Top 25の脆弱性を検出します:
|
|
1684
|
+
|
|
1685
|
+
```typescript
|
|
1686
|
+
import { VulnerabilityScanner, createSecurityService } from '@nahisaho/musubix-security';
|
|
1687
|
+
|
|
1688
|
+
// 単一ファイルのスキャン
|
|
1689
|
+
const scanner = new VulnerabilityScanner();
|
|
1690
|
+
const vulnerabilities = scanner.scanFile('src/api.ts');
|
|
1691
|
+
|
|
1692
|
+
// ディレクトリのスキャン
|
|
1693
|
+
const result = await scanner.scanDirectory('./src');
|
|
1694
|
+
console.log(`検出された脆弱性: ${result.vulnerabilities.length}`);
|
|
1695
|
+
console.log(`スキャンしたファイル: ${result.scannedFiles}`);
|
|
1696
|
+
```
|
|
1697
|
+
|
|
1698
|
+
### 検出可能な脆弱性
|
|
1699
|
+
|
|
1700
|
+
| カテゴリ | CWE | 重要度 |
|
|
1701
|
+
|---------|-----|--------|
|
|
1702
|
+
| SQLインジェクション | CWE-89 | Critical |
|
|
1703
|
+
| コマンドインジェクション | CWE-78 | Critical |
|
|
1704
|
+
| XSS | CWE-79 | High |
|
|
1705
|
+
| パストラバーサル | CWE-22 | High |
|
|
1706
|
+
| コードインジェクション | CWE-94 | Critical |
|
|
1707
|
+
| NoSQLインジェクション | CWE-943 | High |
|
|
1708
|
+
|
|
1709
|
+
### シークレット検出
|
|
1710
|
+
|
|
1711
|
+
ハードコードされた認証情報や機密情報を検出します:
|
|
1712
|
+
|
|
1713
|
+
```typescript
|
|
1714
|
+
import { SecretDetector } from '@nahisaho/musubix-security';
|
|
1715
|
+
|
|
1716
|
+
const detector = new SecretDetector();
|
|
1717
|
+
const secrets = detector.scanContent(content, 'config.ts');
|
|
1718
|
+
const result = await detector.scan('./src');
|
|
1719
|
+
|
|
1720
|
+
console.log(`検出されたシークレット: ${result.summary.total}`);
|
|
1721
|
+
```
|
|
1722
|
+
|
|
1723
|
+
### 検出可能なシークレットタイプ
|
|
1724
|
+
|
|
1725
|
+
| タイプ | パターン |
|
|
1726
|
+
|--------|--------|
|
|
1727
|
+
| AWS Access Key | `AKIA...` |
|
|
1728
|
+
| AWS Secret Key | 40文字のbase64 |
|
|
1729
|
+
| GitHub Token | `ghp_*`, `gho_*`, `ghu_*` |
|
|
1730
|
+
| 秘密鍵 | PEM形式 |
|
|
1731
|
+
| データベースURL | `postgres://`, `mongodb://` |
|
|
1732
|
+
| JWTシークレット | JWT署名シークレット |
|
|
1733
|
+
| Stripe Key | `sk_live_*`, `sk_test_*` |
|
|
1734
|
+
|
|
1735
|
+
### テイント解析
|
|
1736
|
+
|
|
1737
|
+
ユーザー入力(ソース)から危険な関数(シンク)へのデータフローを追跡します:
|
|
1738
|
+
|
|
1739
|
+
```typescript
|
|
1740
|
+
import { TaintAnalyzer } from '@nahisaho/musubix-security';
|
|
1741
|
+
|
|
1742
|
+
const analyzer = new TaintAnalyzer();
|
|
1743
|
+
const result = analyzer.analyze('./src');
|
|
1744
|
+
|
|
1745
|
+
console.log(`ソース: ${result.sources.length}`);
|
|
1746
|
+
console.log(`シンク: ${result.sinks.length}`);
|
|
1747
|
+
console.log(`テイントパス: ${result.paths.length}`);
|
|
1748
|
+
```
|
|
1749
|
+
|
|
1750
|
+
### 依存関係監査
|
|
1751
|
+
|
|
1752
|
+
npm auditと統合して脆弱な依存関係を検出します:
|
|
1753
|
+
|
|
1754
|
+
```typescript
|
|
1755
|
+
import { DependencyAuditor } from '@nahisaho/musubix-security';
|
|
1756
|
+
|
|
1757
|
+
const auditor = new DependencyAuditor();
|
|
1758
|
+
const result = await auditor.audit('./project');
|
|
1759
|
+
|
|
1760
|
+
console.log(`Critical: ${result.summary.critical}`);
|
|
1761
|
+
console.log(`High: ${result.summary.high}`);
|
|
1762
|
+
```
|
|
1763
|
+
|
|
1764
|
+
### 統合セキュリティサービス
|
|
1765
|
+
|
|
1766
|
+
すべてのセキュリティ分析機能を統合:
|
|
1767
|
+
|
|
1768
|
+
```typescript
|
|
1769
|
+
import { createSecurityService } from '@nahisaho/musubix-security';
|
|
1770
|
+
|
|
1771
|
+
const service = createSecurityService();
|
|
1772
|
+
|
|
1773
|
+
// フルセキュリティスキャン
|
|
1774
|
+
const result = await service.scan({
|
|
1775
|
+
target: './src',
|
|
1776
|
+
vulnerabilities: true,
|
|
1777
|
+
taint: true,
|
|
1778
|
+
secrets: true,
|
|
1779
|
+
dependencies: true,
|
|
1780
|
+
generateFixes: true,
|
|
1781
|
+
});
|
|
1782
|
+
|
|
1783
|
+
console.log(`総脆弱性数: ${result.summary.totalVulnerabilities}`);
|
|
1784
|
+
console.log(`総シークレット数: ${result.summary.totalSecrets}`);
|
|
1785
|
+
console.log(`生成された修正: ${result.summary.fixesGenerated}`);
|
|
1786
|
+
```
|
|
1787
|
+
|
|
1788
|
+
### レポート生成
|
|
1789
|
+
|
|
1790
|
+
複数のフォーマットでレポートを生成:
|
|
1791
|
+
|
|
1792
|
+
```typescript
|
|
1793
|
+
// SARIF形式(GitHub Code Scanning対応)
|
|
1794
|
+
const sarifReport = await service.generateReport(result, 'sarif');
|
|
1795
|
+
|
|
1796
|
+
// Markdown形式
|
|
1797
|
+
const mdReport = await service.generateReport(result, 'markdown');
|
|
1798
|
+
|
|
1799
|
+
// HTML形式
|
|
1800
|
+
const htmlReport = await service.generateReport(result, 'html');
|
|
1801
|
+
```
|
|
1802
|
+
|
|
1803
|
+
### CLIの使い方
|
|
1804
|
+
|
|
1805
|
+
```bash
|
|
1806
|
+
# フルセキュリティスキャン
|
|
1807
|
+
npx musubix-security scan ./src
|
|
1808
|
+
|
|
1809
|
+
# 脆弱性スキャンのみ
|
|
1810
|
+
npx musubix-security scan ./src --vulnerabilities-only
|
|
1811
|
+
|
|
1812
|
+
# シークレット検出
|
|
1813
|
+
npx musubix-security secrets ./src
|
|
1814
|
+
|
|
1815
|
+
# テイント解析
|
|
1816
|
+
npx musubix-security taint ./src
|
|
1817
|
+
|
|
1818
|
+
# 依存関係監査
|
|
1819
|
+
npx musubix-security audit ./project
|
|
1820
|
+
|
|
1821
|
+
# SARIFレポート生成
|
|
1822
|
+
npx musubix-security scan ./src --format sarif --output report.sarif
|
|
1823
|
+
```
|
|
1824
|
+
|
|
1825
|
+
### v1.8.0 パッケージ概要
|
|
1826
|
+
|
|
1827
|
+
| パッケージ | 説明 |
|
|
1828
|
+
|-----------|------|
|
|
1829
|
+
| `@nahisaho/musubix-security` | 脆弱性スキャン、シークレット検出、テイント解析、依存関係監査 |
|
|
1830
|
+
|
|
1831
|
+
---
|
|
1832
|
+
|
|
1668
1833
|
## MCPサーバー連携
|
|
1669
1834
|
|
|
1670
1835
|
### MCPサーバーの起動
|
|
@@ -1977,6 +2142,6 @@ const client = createYATAClient({
|
|
|
1977
2142
|
|
|
1978
2143
|
---
|
|
1979
2144
|
|
|
1980
|
-
**バージョン**: 1.
|
|
2145
|
+
**バージョン**: 1.8.0
|
|
1981
2146
|
**最終更新**: 2026-01-06
|
|
1982
2147
|
**MUSUBIX Project**
|
package/docs/USER-GUIDE.md
CHANGED
|
@@ -22,10 +22,14 @@
|
|
|
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
24
|
16. [Formal Verification](#formal-verification) *(v1.7.5)*
|
|
25
|
-
17. [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
17. [Security Analysis](#security-analysis) *(v1.8.0)*
|
|
26
|
+
18. [DFG/CFG Extraction](#dfgcfg-extraction) *(v2.0.0-alpha.1)*
|
|
27
|
+
19. [Lean 4 Integration](#lean-4-integration) *(v2.0.0-alpha.1)*
|
|
28
|
+
20. [YATA Scale](#yata-scale) *(v2.0.0-alpha.1)*
|
|
29
|
+
21. [MCP Server Integration](#mcp-server-integration)
|
|
30
|
+
22. [YATA Integration](#yata-integration)
|
|
31
|
+
23. [Best Practices](#best-practices)
|
|
32
|
+
24. [Troubleshooting](#troubleshooting)
|
|
29
33
|
|
|
30
34
|
---
|
|
31
35
|
|
|
@@ -1207,6 +1211,483 @@ console.log(`Impacted nodes: ${impact.totalImpacted}`);
|
|
|
1207
1211
|
|
|
1208
1212
|
---
|
|
1209
1213
|
|
|
1214
|
+
## Security Analysis
|
|
1215
|
+
|
|
1216
|
+
*(v1.8.0)*
|
|
1217
|
+
|
|
1218
|
+
The `@nahisaho/musubix-security` package provides comprehensive security analysis capabilities for TypeScript/JavaScript projects.
|
|
1219
|
+
|
|
1220
|
+
### Installation
|
|
1221
|
+
|
|
1222
|
+
```bash
|
|
1223
|
+
npm install @nahisaho/musubix-security
|
|
1224
|
+
```
|
|
1225
|
+
|
|
1226
|
+
### Vulnerability Scanning
|
|
1227
|
+
|
|
1228
|
+
Detects OWASP Top 10 and CWE Top 25 vulnerabilities using AST analysis:
|
|
1229
|
+
|
|
1230
|
+
```typescript
|
|
1231
|
+
import { VulnerabilityScanner, createSecurityService } from '@nahisaho/musubix-security';
|
|
1232
|
+
|
|
1233
|
+
// Scan a single file
|
|
1234
|
+
const scanner = new VulnerabilityScanner();
|
|
1235
|
+
const vulnerabilities = scanner.scanFile('src/api.ts');
|
|
1236
|
+
|
|
1237
|
+
// Scan a directory
|
|
1238
|
+
const result = await scanner.scanDirectory('./src');
|
|
1239
|
+
console.log(`Found ${result.vulnerabilities.length} vulnerabilities`);
|
|
1240
|
+
console.log(`Scanned ${result.scannedFiles} files`);
|
|
1241
|
+
```
|
|
1242
|
+
|
|
1243
|
+
### Detected Vulnerabilities
|
|
1244
|
+
|
|
1245
|
+
| Category | CWE | Severity |
|
|
1246
|
+
|----------|-----|----------|
|
|
1247
|
+
| SQL Injection | CWE-89 | Critical |
|
|
1248
|
+
| Command Injection | CWE-78 | Critical |
|
|
1249
|
+
| XSS | CWE-79 | High |
|
|
1250
|
+
| Path Traversal | CWE-22 | High |
|
|
1251
|
+
| Code Injection | CWE-94 | Critical |
|
|
1252
|
+
| NoSQL Injection | CWE-943 | High |
|
|
1253
|
+
|
|
1254
|
+
### Secret Detection
|
|
1255
|
+
|
|
1256
|
+
Detects hardcoded credentials and sensitive information:
|
|
1257
|
+
|
|
1258
|
+
```typescript
|
|
1259
|
+
import { SecretDetector } from '@nahisaho/musubix-security';
|
|
1260
|
+
|
|
1261
|
+
const detector = new SecretDetector();
|
|
1262
|
+
const secrets = detector.scanContent(content, 'config.ts');
|
|
1263
|
+
const result = await detector.scan('./src');
|
|
1264
|
+
|
|
1265
|
+
console.log(`Found ${result.summary.total} secrets`);
|
|
1266
|
+
```
|
|
1267
|
+
|
|
1268
|
+
### Detected Secret Types
|
|
1269
|
+
|
|
1270
|
+
| Type | Pattern |
|
|
1271
|
+
|------|--------|
|
|
1272
|
+
| AWS Access Key | `AKIA...` |
|
|
1273
|
+
| AWS Secret Key | 40-char base64 |
|
|
1274
|
+
| GitHub Token | `ghp_*`, `gho_*`, `ghu_*` |
|
|
1275
|
+
| Private Key | PEM format |
|
|
1276
|
+
| Database URL | `postgres://`, `mongodb://` |
|
|
1277
|
+
| JWT Secret | JWT signing secrets |
|
|
1278
|
+
| Stripe Key | `sk_live_*`, `sk_test_*` |
|
|
1279
|
+
|
|
1280
|
+
### Taint Analysis
|
|
1281
|
+
|
|
1282
|
+
Tracks data flow from user input (sources) to dangerous functions (sinks):
|
|
1283
|
+
|
|
1284
|
+
```typescript
|
|
1285
|
+
import { TaintAnalyzer } from '@nahisaho/musubix-security';
|
|
1286
|
+
|
|
1287
|
+
const analyzer = new TaintAnalyzer();
|
|
1288
|
+
const result = analyzer.analyze('./src');
|
|
1289
|
+
|
|
1290
|
+
console.log(`Sources: ${result.sources.length}`);
|
|
1291
|
+
console.log(`Sinks: ${result.sinks.length}`);
|
|
1292
|
+
console.log(`Taint paths: ${result.paths.length}`);
|
|
1293
|
+
```
|
|
1294
|
+
|
|
1295
|
+
### Dependency Auditing
|
|
1296
|
+
|
|
1297
|
+
Integrates with npm audit to detect vulnerable dependencies:
|
|
1298
|
+
|
|
1299
|
+
```typescript
|
|
1300
|
+
import { DependencyAuditor } from '@nahisaho/musubix-security';
|
|
1301
|
+
|
|
1302
|
+
const auditor = new DependencyAuditor();
|
|
1303
|
+
const result = await auditor.audit('./project');
|
|
1304
|
+
|
|
1305
|
+
console.log(`Critical: ${result.summary.critical}`);
|
|
1306
|
+
console.log(`High: ${result.summary.high}`);
|
|
1307
|
+
```
|
|
1308
|
+
|
|
1309
|
+
### Integrated Security Service
|
|
1310
|
+
|
|
1311
|
+
Combines all security analysis features:
|
|
1312
|
+
|
|
1313
|
+
```typescript
|
|
1314
|
+
import { createSecurityService } from '@nahisaho/musubix-security';
|
|
1315
|
+
|
|
1316
|
+
const service = createSecurityService();
|
|
1317
|
+
|
|
1318
|
+
// Full security scan
|
|
1319
|
+
const result = await service.scan({
|
|
1320
|
+
target: './src',
|
|
1321
|
+
vulnerabilities: true,
|
|
1322
|
+
taint: true,
|
|
1323
|
+
secrets: true,
|
|
1324
|
+
dependencies: true,
|
|
1325
|
+
generateFixes: true,
|
|
1326
|
+
});
|
|
1327
|
+
|
|
1328
|
+
console.log(`Total vulnerabilities: ${result.summary.totalVulnerabilities}`);
|
|
1329
|
+
console.log(`Total secrets: ${result.summary.totalSecrets}`);
|
|
1330
|
+
console.log(`Fixes generated: ${result.summary.fixesGenerated}`);
|
|
1331
|
+
```
|
|
1332
|
+
|
|
1333
|
+
### Report Generation
|
|
1334
|
+
|
|
1335
|
+
Generate reports in multiple formats:
|
|
1336
|
+
|
|
1337
|
+
```typescript
|
|
1338
|
+
// SARIF format (GitHub Code Scanning compatible)
|
|
1339
|
+
const sarifReport = await service.generateReport(result, 'sarif');
|
|
1340
|
+
|
|
1341
|
+
// Markdown format
|
|
1342
|
+
const mdReport = await service.generateReport(result, 'markdown');
|
|
1343
|
+
|
|
1344
|
+
// HTML format
|
|
1345
|
+
const htmlReport = await service.generateReport(result, 'html');
|
|
1346
|
+
```
|
|
1347
|
+
|
|
1348
|
+
### CLI Usage
|
|
1349
|
+
|
|
1350
|
+
```bash
|
|
1351
|
+
# Full security scan
|
|
1352
|
+
npx musubix-security scan ./src
|
|
1353
|
+
|
|
1354
|
+
# Vulnerability scan only
|
|
1355
|
+
npx musubix-security scan ./src --vulnerabilities-only
|
|
1356
|
+
|
|
1357
|
+
# Secret detection
|
|
1358
|
+
npx musubix-security secrets ./src
|
|
1359
|
+
|
|
1360
|
+
# Taint analysis
|
|
1361
|
+
npx musubix-security taint ./src
|
|
1362
|
+
|
|
1363
|
+
# Dependency audit
|
|
1364
|
+
npx musubix-security audit ./project
|
|
1365
|
+
|
|
1366
|
+
# Generate SARIF report
|
|
1367
|
+
npx musubix-security scan ./src --format sarif --output report.sarif
|
|
1368
|
+
```
|
|
1369
|
+
|
|
1370
|
+
### v1.8.0 Package Summary
|
|
1371
|
+
|
|
1372
|
+
| Package | Description |
|
|
1373
|
+
|---------|-------------|
|
|
1374
|
+
| `@nahisaho/musubix-security` | Vulnerability scanning, secret detection, taint analysis, dependency auditing |
|
|
1375
|
+
|
|
1376
|
+
---
|
|
1377
|
+
|
|
1378
|
+
## DFG/CFG Extraction
|
|
1379
|
+
|
|
1380
|
+
*(v2.0.0-alpha.1)*
|
|
1381
|
+
|
|
1382
|
+
The `@nahisaho/musubix-dfg` package provides Data Flow Graph (DFG) and Control Flow Graph (CFG) extraction for TypeScript and JavaScript code analysis.
|
|
1383
|
+
|
|
1384
|
+
### Installation
|
|
1385
|
+
|
|
1386
|
+
```bash
|
|
1387
|
+
npm install @nahisaho/musubix-dfg
|
|
1388
|
+
```
|
|
1389
|
+
|
|
1390
|
+
### DFG Extraction
|
|
1391
|
+
|
|
1392
|
+
Extract data flow graphs from source code:
|
|
1393
|
+
|
|
1394
|
+
```typescript
|
|
1395
|
+
import { extractDFG, DFGExtractor } from '@nahisaho/musubix-dfg';
|
|
1396
|
+
|
|
1397
|
+
// Simple extraction
|
|
1398
|
+
const dfg = extractDFG(sourceCode, 'typescript');
|
|
1399
|
+
|
|
1400
|
+
// With configuration
|
|
1401
|
+
const extractor = new DFGExtractor({
|
|
1402
|
+
includeImplicitFlows: true,
|
|
1403
|
+
trackConstants: true,
|
|
1404
|
+
});
|
|
1405
|
+
const result = extractor.extract(sourceCode);
|
|
1406
|
+
|
|
1407
|
+
console.log(`Nodes: ${result.nodes.length}`);
|
|
1408
|
+
console.log(`Edges: ${result.edges.length}`);
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
### CFG Extraction
|
|
1412
|
+
|
|
1413
|
+
Extract control flow graphs:
|
|
1414
|
+
|
|
1415
|
+
```typescript
|
|
1416
|
+
import { extractCFG, CFGExtractor } from '@nahisaho/musubix-dfg';
|
|
1417
|
+
|
|
1418
|
+
const cfg = extractCFG(sourceCode);
|
|
1419
|
+
|
|
1420
|
+
// Traverse CFG
|
|
1421
|
+
for (const block of cfg.blocks) {
|
|
1422
|
+
console.log(`Block ${block.id}: ${block.statements.length} statements`);
|
|
1423
|
+
console.log(`Successors: ${block.successors.join(', ')}`);
|
|
1424
|
+
}
|
|
1425
|
+
```
|
|
1426
|
+
|
|
1427
|
+
### Def-Use Chain Analysis
|
|
1428
|
+
|
|
1429
|
+
Build definition-use chains for variable tracking:
|
|
1430
|
+
|
|
1431
|
+
```typescript
|
|
1432
|
+
import { analyzeDefUse } from '@nahisaho/musubix-dfg';
|
|
1433
|
+
|
|
1434
|
+
const chains = analyzeDefUse(dfg);
|
|
1435
|
+
|
|
1436
|
+
for (const chain of chains) {
|
|
1437
|
+
console.log(`Variable: ${chain.variable}`);
|
|
1438
|
+
console.log(`Defined at: line ${chain.definition.line}`);
|
|
1439
|
+
console.log(`Used at: ${chain.uses.map(u => u.line).join(', ')}`);
|
|
1440
|
+
}
|
|
1441
|
+
```
|
|
1442
|
+
|
|
1443
|
+
### Data Dependency Analysis
|
|
1444
|
+
|
|
1445
|
+
Analyze data dependencies between statements:
|
|
1446
|
+
|
|
1447
|
+
```typescript
|
|
1448
|
+
import { analyzeDataDependencies } from '@nahisaho/musubix-dfg';
|
|
1449
|
+
|
|
1450
|
+
const deps = analyzeDataDependencies(dfg);
|
|
1451
|
+
|
|
1452
|
+
for (const dep of deps) {
|
|
1453
|
+
console.log(`${dep.from} -> ${dep.to}: ${dep.type}`);
|
|
1454
|
+
}
|
|
1455
|
+
```
|
|
1456
|
+
|
|
1457
|
+
---
|
|
1458
|
+
|
|
1459
|
+
## Lean 4 Integration
|
|
1460
|
+
|
|
1461
|
+
*(v2.0.0-alpha.1)*
|
|
1462
|
+
|
|
1463
|
+
The `@nahisaho/musubix-lean` package provides integration with the Lean 4 theorem prover for formal verification of requirements.
|
|
1464
|
+
|
|
1465
|
+
### Installation
|
|
1466
|
+
|
|
1467
|
+
```bash
|
|
1468
|
+
npm install @nahisaho/musubix-lean
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
### EARS to Lean Conversion
|
|
1472
|
+
|
|
1473
|
+
Convert EARS requirements to Lean 4 theorems:
|
|
1474
|
+
|
|
1475
|
+
```typescript
|
|
1476
|
+
import { EarsToLeanConverter } from '@nahisaho/musubix-lean';
|
|
1477
|
+
|
|
1478
|
+
const converter = new EarsToLeanConverter();
|
|
1479
|
+
|
|
1480
|
+
// Convert EARS requirement
|
|
1481
|
+
const earsRequirement = {
|
|
1482
|
+
id: 'REQ-001',
|
|
1483
|
+
type: 'event-driven',
|
|
1484
|
+
trigger: 'user clicks submit',
|
|
1485
|
+
response: 'system saves form data',
|
|
1486
|
+
};
|
|
1487
|
+
|
|
1488
|
+
const theorem = converter.convert(earsRequirement);
|
|
1489
|
+
console.log(theorem.leanCode);
|
|
1490
|
+
// theorem REQ_001 : ∀ (s : State),
|
|
1491
|
+
// user_clicks_submit s → saves_form_data (next s)
|
|
1492
|
+
```
|
|
1493
|
+
|
|
1494
|
+
### Lean AST Parsing
|
|
1495
|
+
|
|
1496
|
+
Parse and manipulate Lean 4 code:
|
|
1497
|
+
|
|
1498
|
+
```typescript
|
|
1499
|
+
import { LeanParser, LeanAST } from '@nahisaho/musubix-lean';
|
|
1500
|
+
|
|
1501
|
+
const parser = new LeanParser();
|
|
1502
|
+
const ast = parser.parse(leanCode);
|
|
1503
|
+
|
|
1504
|
+
// Traverse AST
|
|
1505
|
+
for (const decl of ast.declarations) {
|
|
1506
|
+
if (decl.type === 'theorem') {
|
|
1507
|
+
console.log(`Theorem: ${decl.name}`);
|
|
1508
|
+
console.log(`Statement: ${decl.statement}`);
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
```
|
|
1512
|
+
|
|
1513
|
+
### Proof Engine
|
|
1514
|
+
|
|
1515
|
+
Execute proofs using Lean 4:
|
|
1516
|
+
|
|
1517
|
+
```typescript
|
|
1518
|
+
import { LeanProofEngine } from '@nahisaho/musubix-lean';
|
|
1519
|
+
|
|
1520
|
+
const engine = new LeanProofEngine({
|
|
1521
|
+
leanPath: '/usr/bin/lean',
|
|
1522
|
+
timeout: 30000,
|
|
1523
|
+
});
|
|
1524
|
+
|
|
1525
|
+
const result = await engine.prove(theorem);
|
|
1526
|
+
|
|
1527
|
+
if (result.success) {
|
|
1528
|
+
console.log('Proof verified!');
|
|
1529
|
+
console.log(`Proof: ${result.proof}`);
|
|
1530
|
+
} else {
|
|
1531
|
+
console.log(`Failed: ${result.error}`);
|
|
1532
|
+
}
|
|
1533
|
+
```
|
|
1534
|
+
|
|
1535
|
+
### ReProver Integration
|
|
1536
|
+
|
|
1537
|
+
Use ReProver for automated proof search:
|
|
1538
|
+
|
|
1539
|
+
```typescript
|
|
1540
|
+
import { ReProverClient } from '@nahisaho/musubix-lean';
|
|
1541
|
+
|
|
1542
|
+
const reprover = new ReProverClient({
|
|
1543
|
+
endpoint: 'http://localhost:8080',
|
|
1544
|
+
maxDepth: 10,
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1547
|
+
const proof = await reprover.searchProof(theorem);
|
|
1548
|
+
|
|
1549
|
+
if (proof.found) {
|
|
1550
|
+
console.log('Proof found!');
|
|
1551
|
+
console.log(proof.tactics);
|
|
1552
|
+
}
|
|
1553
|
+
```
|
|
1554
|
+
|
|
1555
|
+
---
|
|
1556
|
+
|
|
1557
|
+
## YATA Scale
|
|
1558
|
+
|
|
1559
|
+
*(v2.0.0-alpha.1)*
|
|
1560
|
+
|
|
1561
|
+
The `@nahisaho/yata-scale` package provides distributed knowledge graph capabilities with sharding, caching, and synchronization.
|
|
1562
|
+
|
|
1563
|
+
### Installation
|
|
1564
|
+
|
|
1565
|
+
```bash
|
|
1566
|
+
npm install @nahisaho/yata-scale
|
|
1567
|
+
```
|
|
1568
|
+
|
|
1569
|
+
### High-Level API
|
|
1570
|
+
|
|
1571
|
+
Use `YataScaleManager` for simplified access:
|
|
1572
|
+
|
|
1573
|
+
```typescript
|
|
1574
|
+
import { YataScaleManager } from '@nahisaho/yata-scale';
|
|
1575
|
+
|
|
1576
|
+
const yata = new YataScaleManager({
|
|
1577
|
+
shards: 16,
|
|
1578
|
+
cacheConfig: {
|
|
1579
|
+
l1MaxSize: 1000,
|
|
1580
|
+
l2MaxSize: 10000,
|
|
1581
|
+
l3Path: './cache',
|
|
1582
|
+
},
|
|
1583
|
+
});
|
|
1584
|
+
|
|
1585
|
+
// Store entity
|
|
1586
|
+
await yata.putEntity({
|
|
1587
|
+
id: 'entity-1',
|
|
1588
|
+
type: 'Document',
|
|
1589
|
+
properties: { title: 'Example' },
|
|
1590
|
+
});
|
|
1591
|
+
|
|
1592
|
+
// Query
|
|
1593
|
+
const results = await yata.query('SELECT ?s WHERE { ?s rdf:type Document }');
|
|
1594
|
+
```
|
|
1595
|
+
|
|
1596
|
+
### Sharding
|
|
1597
|
+
|
|
1598
|
+
Distribute data across shards using consistent hashing:
|
|
1599
|
+
|
|
1600
|
+
```typescript
|
|
1601
|
+
import { ShardManager, HashPartitionStrategy } from '@nahisaho/yata-scale';
|
|
1602
|
+
|
|
1603
|
+
const shardManager = new ShardManager({
|
|
1604
|
+
shardCount: 16,
|
|
1605
|
+
virtualNodes: 150,
|
|
1606
|
+
strategy: new HashPartitionStrategy(),
|
|
1607
|
+
});
|
|
1608
|
+
|
|
1609
|
+
// Get shard for entity
|
|
1610
|
+
const shard = shardManager.getShardForEntity('entity-id');
|
|
1611
|
+
console.log(`Entity assigned to shard ${shard.id}`);
|
|
1612
|
+
|
|
1613
|
+
// Rebalance on node changes
|
|
1614
|
+
await shardManager.addNode('node-5');
|
|
1615
|
+
```
|
|
1616
|
+
|
|
1617
|
+
### Multi-Tier Caching
|
|
1618
|
+
|
|
1619
|
+
Three-tier caching for optimal performance:
|
|
1620
|
+
|
|
1621
|
+
```typescript
|
|
1622
|
+
import { CacheManager, L1Cache, L2Cache, L3Cache } from '@nahisaho/yata-scale';
|
|
1623
|
+
|
|
1624
|
+
const cache = new CacheManager({
|
|
1625
|
+
l1: new L1Cache({ maxSize: 1000 }), // LRU cache
|
|
1626
|
+
l2: new L2Cache({ maxSize: 10000 }), // LFU cache
|
|
1627
|
+
l3: new L3Cache({ path: './cache' }), // Disk cache
|
|
1628
|
+
});
|
|
1629
|
+
|
|
1630
|
+
// Cache operations
|
|
1631
|
+
await cache.set('key', value, { ttl: 3600 });
|
|
1632
|
+
const result = await cache.get('key');
|
|
1633
|
+
|
|
1634
|
+
// Invalidation
|
|
1635
|
+
await cache.invalidate('key');
|
|
1636
|
+
await cache.invalidatePattern('user:*');
|
|
1637
|
+
```
|
|
1638
|
+
|
|
1639
|
+
### Index Management
|
|
1640
|
+
|
|
1641
|
+
Multiple index types for efficient queries:
|
|
1642
|
+
|
|
1643
|
+
```typescript
|
|
1644
|
+
import { IndexManager, BPlusTreeIndex, FullTextIndex, GraphIndex } from '@nahisaho/yata-scale';
|
|
1645
|
+
|
|
1646
|
+
const indexManager = new IndexManager();
|
|
1647
|
+
|
|
1648
|
+
// B+ Tree for range queries
|
|
1649
|
+
indexManager.addIndex('timestamp', new BPlusTreeIndex());
|
|
1650
|
+
|
|
1651
|
+
// Full-text for search
|
|
1652
|
+
indexManager.addIndex('content', new FullTextIndex());
|
|
1653
|
+
|
|
1654
|
+
// Graph for traversal
|
|
1655
|
+
indexManager.addIndex('relationships', new GraphIndex());
|
|
1656
|
+
```
|
|
1657
|
+
|
|
1658
|
+
### Vector Clock Synchronization
|
|
1659
|
+
|
|
1660
|
+
Distributed synchronization with conflict resolution:
|
|
1661
|
+
|
|
1662
|
+
```typescript
|
|
1663
|
+
import { SyncController, VectorClock, ConflictResolver } from '@nahisaho/yata-scale';
|
|
1664
|
+
|
|
1665
|
+
const sync = new SyncController({
|
|
1666
|
+
nodeId: 'node-1',
|
|
1667
|
+
conflictStrategy: 'last-write-wins',
|
|
1668
|
+
});
|
|
1669
|
+
|
|
1670
|
+
// Synchronize with peers
|
|
1671
|
+
await sync.synchronize();
|
|
1672
|
+
|
|
1673
|
+
// Manual conflict resolution
|
|
1674
|
+
sync.onConflict((conflict) => {
|
|
1675
|
+
console.log(`Conflict on ${conflict.key}`);
|
|
1676
|
+
return conflict.local; // or conflict.remote
|
|
1677
|
+
});
|
|
1678
|
+
```
|
|
1679
|
+
|
|
1680
|
+
### v2.0.0-alpha.1 Package Summary
|
|
1681
|
+
|
|
1682
|
+
| Package | Tests | Description |
|
|
1683
|
+
|---------|-------|-------------|
|
|
1684
|
+
| `@nahisaho/musubix-dfg` | 30 | DFG/CFG extraction, Def-Use analysis |
|
|
1685
|
+
| `@nahisaho/musubix-lean` | 151 | Lean 4 theorem proving, EARS conversion |
|
|
1686
|
+
| `@nahisaho/yata-scale` | 57 | Distributed sharding, caching, sync |
|
|
1687
|
+
| **Total** | **238** | **Phase 1: Deep Symbolic Integration** |
|
|
1688
|
+
|
|
1689
|
+
---
|
|
1690
|
+
|
|
1210
1691
|
## MCP Server Integration
|
|
1211
1692
|
|
|
1212
1693
|
### CLI Startup
|
|
@@ -1817,6 +2298,6 @@ const client = createYATAClient({
|
|
|
1817
2298
|
|
|
1818
2299
|
---
|
|
1819
2300
|
|
|
1820
|
-
**Version**: 1.
|
|
1821
|
-
**Last Updated**: 2026-01-
|
|
2301
|
+
**Version**: 1.8.5
|
|
2302
|
+
**Last Updated**: 2026-01-08
|
|
1822
2303
|
**MUSUBIX Project**
|