musubix 1.8.0 → 2.0.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.
@@ -22,10 +22,17 @@
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. [MCP Server Integration](#mcp-server-integration)
26
- 17. [YATA Integration](#yata-integration)
27
- 18. [Best Practices](#best-practices)
28
- 19. [Troubleshooting](#troubleshooting)
25
+ 17. [Security Analysis](#security-analysis) *(v1.8.0)*
26
+ 18. [DFG/CFG Extraction](#dfgcfg-extraction) *(v2.0.0)*
27
+ 19. [Lean 4 Integration](#lean-4-integration) *(v2.0.0)*
28
+ 20. [YATA Scale](#yata-scale) *(v2.0.0)*
29
+ 21. [Library Learning](#library-learning) *(v2.0.0 NEW!)*
30
+ 22. [Neural Search](#neural-search) *(v2.0.0 NEW!)*
31
+ 23. [Program Synthesis](#program-synthesis) *(v2.0.0 NEW!)*
32
+ 24. [MCP Server Integration](#mcp-server-integration)
33
+ 25. [YATA Integration](#yata-integration)
34
+ 26. [Best Practices](#best-practices)
35
+ 27. [Troubleshooting](#troubleshooting)
29
36
 
30
37
  ---
31
38
 
@@ -1207,6 +1214,829 @@ console.log(`Impacted nodes: ${impact.totalImpacted}`);
1207
1214
 
1208
1215
  ---
1209
1216
 
1217
+ ## Security Analysis
1218
+
1219
+ *(v1.8.0)*
1220
+
1221
+ The `@nahisaho/musubix-security` package provides comprehensive security analysis capabilities for TypeScript/JavaScript projects.
1222
+
1223
+ ### Installation
1224
+
1225
+ ```bash
1226
+ npm install @nahisaho/musubix-security
1227
+ ```
1228
+
1229
+ ### Vulnerability Scanning
1230
+
1231
+ Detects OWASP Top 10 and CWE Top 25 vulnerabilities using AST analysis:
1232
+
1233
+ ```typescript
1234
+ import { VulnerabilityScanner, createSecurityService } from '@nahisaho/musubix-security';
1235
+
1236
+ // Scan a single file
1237
+ const scanner = new VulnerabilityScanner();
1238
+ const vulnerabilities = scanner.scanFile('src/api.ts');
1239
+
1240
+ // Scan a directory
1241
+ const result = await scanner.scanDirectory('./src');
1242
+ console.log(`Found ${result.vulnerabilities.length} vulnerabilities`);
1243
+ console.log(`Scanned ${result.scannedFiles} files`);
1244
+ ```
1245
+
1246
+ ### Detected Vulnerabilities
1247
+
1248
+ | Category | CWE | Severity |
1249
+ |----------|-----|----------|
1250
+ | SQL Injection | CWE-89 | Critical |
1251
+ | Command Injection | CWE-78 | Critical |
1252
+ | XSS | CWE-79 | High |
1253
+ | Path Traversal | CWE-22 | High |
1254
+ | Code Injection | CWE-94 | Critical |
1255
+ | NoSQL Injection | CWE-943 | High |
1256
+
1257
+ ### Secret Detection
1258
+
1259
+ Detects hardcoded credentials and sensitive information:
1260
+
1261
+ ```typescript
1262
+ import { SecretDetector } from '@nahisaho/musubix-security';
1263
+
1264
+ const detector = new SecretDetector();
1265
+ const secrets = detector.scanContent(content, 'config.ts');
1266
+ const result = await detector.scan('./src');
1267
+
1268
+ console.log(`Found ${result.summary.total} secrets`);
1269
+ ```
1270
+
1271
+ ### Detected Secret Types
1272
+
1273
+ | Type | Pattern |
1274
+ |------|--------|
1275
+ | AWS Access Key | `AKIA...` |
1276
+ | AWS Secret Key | 40-char base64 |
1277
+ | GitHub Token | `ghp_*`, `gho_*`, `ghu_*` |
1278
+ | Private Key | PEM format |
1279
+ | Database URL | `postgres://`, `mongodb://` |
1280
+ | JWT Secret | JWT signing secrets |
1281
+ | Stripe Key | `sk_live_*`, `sk_test_*` |
1282
+
1283
+ ### Taint Analysis
1284
+
1285
+ Tracks data flow from user input (sources) to dangerous functions (sinks):
1286
+
1287
+ ```typescript
1288
+ import { TaintAnalyzer } from '@nahisaho/musubix-security';
1289
+
1290
+ const analyzer = new TaintAnalyzer();
1291
+ const result = analyzer.analyze('./src');
1292
+
1293
+ console.log(`Sources: ${result.sources.length}`);
1294
+ console.log(`Sinks: ${result.sinks.length}`);
1295
+ console.log(`Taint paths: ${result.paths.length}`);
1296
+ ```
1297
+
1298
+ ### Dependency Auditing
1299
+
1300
+ Integrates with npm audit to detect vulnerable dependencies:
1301
+
1302
+ ```typescript
1303
+ import { DependencyAuditor } from '@nahisaho/musubix-security';
1304
+
1305
+ const auditor = new DependencyAuditor();
1306
+ const result = await auditor.audit('./project');
1307
+
1308
+ console.log(`Critical: ${result.summary.critical}`);
1309
+ console.log(`High: ${result.summary.high}`);
1310
+ ```
1311
+
1312
+ ### Integrated Security Service
1313
+
1314
+ Combines all security analysis features:
1315
+
1316
+ ```typescript
1317
+ import { createSecurityService } from '@nahisaho/musubix-security';
1318
+
1319
+ const service = createSecurityService();
1320
+
1321
+ // Full security scan
1322
+ const result = await service.scan({
1323
+ target: './src',
1324
+ vulnerabilities: true,
1325
+ taint: true,
1326
+ secrets: true,
1327
+ dependencies: true,
1328
+ generateFixes: true,
1329
+ });
1330
+
1331
+ console.log(`Total vulnerabilities: ${result.summary.totalVulnerabilities}`);
1332
+ console.log(`Total secrets: ${result.summary.totalSecrets}`);
1333
+ console.log(`Fixes generated: ${result.summary.fixesGenerated}`);
1334
+ ```
1335
+
1336
+ ### Report Generation
1337
+
1338
+ Generate reports in multiple formats:
1339
+
1340
+ ```typescript
1341
+ // SARIF format (GitHub Code Scanning compatible)
1342
+ const sarifReport = await service.generateReport(result, 'sarif');
1343
+
1344
+ // Markdown format
1345
+ const mdReport = await service.generateReport(result, 'markdown');
1346
+
1347
+ // HTML format
1348
+ const htmlReport = await service.generateReport(result, 'html');
1349
+ ```
1350
+
1351
+ ### CLI Usage
1352
+
1353
+ ```bash
1354
+ # Full security scan
1355
+ npx musubix-security scan ./src
1356
+
1357
+ # Vulnerability scan only
1358
+ npx musubix-security scan ./src --vulnerabilities-only
1359
+
1360
+ # Secret detection
1361
+ npx musubix-security secrets ./src
1362
+
1363
+ # Taint analysis
1364
+ npx musubix-security taint ./src
1365
+
1366
+ # Dependency audit
1367
+ npx musubix-security audit ./project
1368
+
1369
+ # Generate SARIF report
1370
+ npx musubix-security scan ./src --format sarif --output report.sarif
1371
+ ```
1372
+
1373
+ ### v1.8.0 Package Summary
1374
+
1375
+ | Package | Description |
1376
+ |---------|-------------|
1377
+ | `@nahisaho/musubix-security` | Vulnerability scanning, secret detection, taint analysis, dependency auditing |
1378
+
1379
+ ---
1380
+
1381
+ ## DFG/CFG Extraction
1382
+
1383
+ *(v2.0.0)*
1384
+
1385
+ The `@nahisaho/musubix-dfg` package provides Data Flow Graph (DFG) and Control Flow Graph (CFG) extraction for TypeScript and JavaScript code analysis.
1386
+
1387
+ ### Installation
1388
+
1389
+ ```bash
1390
+ npm install @nahisaho/musubix-dfg
1391
+ ```
1392
+
1393
+ ### DFG Extraction
1394
+
1395
+ Extract data flow graphs from source code:
1396
+
1397
+ ```typescript
1398
+ import { extractDFG, DFGExtractor } from '@nahisaho/musubix-dfg';
1399
+
1400
+ // Simple extraction
1401
+ const dfg = extractDFG(sourceCode, 'typescript');
1402
+
1403
+ // With configuration
1404
+ const extractor = new DFGExtractor({
1405
+ includeImplicitFlows: true,
1406
+ trackConstants: true,
1407
+ });
1408
+ const result = extractor.extract(sourceCode);
1409
+
1410
+ console.log(`Nodes: ${result.nodes.length}`);
1411
+ console.log(`Edges: ${result.edges.length}`);
1412
+ ```
1413
+
1414
+ ### CFG Extraction
1415
+
1416
+ Extract control flow graphs:
1417
+
1418
+ ```typescript
1419
+ import { extractCFG, CFGExtractor } from '@nahisaho/musubix-dfg';
1420
+
1421
+ const cfg = extractCFG(sourceCode);
1422
+
1423
+ // Traverse CFG
1424
+ for (const block of cfg.blocks) {
1425
+ console.log(`Block ${block.id}: ${block.statements.length} statements`);
1426
+ console.log(`Successors: ${block.successors.join(', ')}`);
1427
+ }
1428
+ ```
1429
+
1430
+ ### Def-Use Chain Analysis
1431
+
1432
+ Build definition-use chains for variable tracking:
1433
+
1434
+ ```typescript
1435
+ import { analyzeDefUse } from '@nahisaho/musubix-dfg';
1436
+
1437
+ const chains = analyzeDefUse(dfg);
1438
+
1439
+ for (const chain of chains) {
1440
+ console.log(`Variable: ${chain.variable}`);
1441
+ console.log(`Defined at: line ${chain.definition.line}`);
1442
+ console.log(`Used at: ${chain.uses.map(u => u.line).join(', ')}`);
1443
+ }
1444
+ ```
1445
+
1446
+ ### Data Dependency Analysis
1447
+
1448
+ Analyze data dependencies between statements:
1449
+
1450
+ ```typescript
1451
+ import { analyzeDataDependencies } from '@nahisaho/musubix-dfg';
1452
+
1453
+ const deps = analyzeDataDependencies(dfg);
1454
+
1455
+ for (const dep of deps) {
1456
+ console.log(`${dep.from} -> ${dep.to}: ${dep.type}`);
1457
+ }
1458
+ ```
1459
+
1460
+ ---
1461
+
1462
+ ## Lean 4 Integration
1463
+
1464
+ *(v2.0.0)*
1465
+
1466
+ The `@nahisaho/musubix-lean` package provides integration with the Lean 4 theorem prover for formal verification of requirements.
1467
+
1468
+ ### Installation
1469
+
1470
+ ```bash
1471
+ npm install @nahisaho/musubix-lean
1472
+ ```
1473
+
1474
+ ### EARS to Lean Conversion
1475
+
1476
+ Convert EARS requirements to Lean 4 theorems:
1477
+
1478
+ ```typescript
1479
+ import { EarsToLeanConverter } from '@nahisaho/musubix-lean';
1480
+
1481
+ const converter = new EarsToLeanConverter();
1482
+
1483
+ // Convert EARS requirement
1484
+ const earsRequirement = {
1485
+ id: 'REQ-001',
1486
+ type: 'event-driven',
1487
+ trigger: 'user clicks submit',
1488
+ response: 'system saves form data',
1489
+ };
1490
+
1491
+ const theorem = converter.convert(earsRequirement);
1492
+ console.log(theorem.leanCode);
1493
+ // theorem REQ_001 : ∀ (s : State),
1494
+ // user_clicks_submit s → saves_form_data (next s)
1495
+ ```
1496
+
1497
+ ### Lean AST Parsing
1498
+
1499
+ Parse and manipulate Lean 4 code:
1500
+
1501
+ ```typescript
1502
+ import { LeanParser, LeanAST } from '@nahisaho/musubix-lean';
1503
+
1504
+ const parser = new LeanParser();
1505
+ const ast = parser.parse(leanCode);
1506
+
1507
+ // Traverse AST
1508
+ for (const decl of ast.declarations) {
1509
+ if (decl.type === 'theorem') {
1510
+ console.log(`Theorem: ${decl.name}`);
1511
+ console.log(`Statement: ${decl.statement}`);
1512
+ }
1513
+ }
1514
+ ```
1515
+
1516
+ ### Proof Engine
1517
+
1518
+ Execute proofs using Lean 4:
1519
+
1520
+ ```typescript
1521
+ import { LeanProofEngine } from '@nahisaho/musubix-lean';
1522
+
1523
+ const engine = new LeanProofEngine({
1524
+ leanPath: '/usr/bin/lean',
1525
+ timeout: 30000,
1526
+ });
1527
+
1528
+ const result = await engine.prove(theorem);
1529
+
1530
+ if (result.success) {
1531
+ console.log('Proof verified!');
1532
+ console.log(`Proof: ${result.proof}`);
1533
+ } else {
1534
+ console.log(`Failed: ${result.error}`);
1535
+ }
1536
+ ```
1537
+
1538
+ ### ReProver Integration
1539
+
1540
+ Use ReProver for automated proof search:
1541
+
1542
+ ```typescript
1543
+ import { ReProverClient } from '@nahisaho/musubix-lean';
1544
+
1545
+ const reprover = new ReProverClient({
1546
+ endpoint: 'http://localhost:8080',
1547
+ maxDepth: 10,
1548
+ });
1549
+
1550
+ const proof = await reprover.searchProof(theorem);
1551
+
1552
+ if (proof.found) {
1553
+ console.log('Proof found!');
1554
+ console.log(proof.tactics);
1555
+ }
1556
+ ```
1557
+
1558
+ ---
1559
+
1560
+ ## YATA Scale
1561
+
1562
+ *(v2.0.0)*
1563
+
1564
+ The `@nahisaho/yata-scale` package provides distributed knowledge graph capabilities with sharding, caching, and synchronization.
1565
+
1566
+ ### Installation
1567
+
1568
+ ```bash
1569
+ npm install @nahisaho/yata-scale
1570
+ ```
1571
+
1572
+ ### High-Level API
1573
+
1574
+ Use `YataScaleManager` for simplified access:
1575
+
1576
+ ```typescript
1577
+ import { YataScaleManager } from '@nahisaho/yata-scale';
1578
+
1579
+ const yata = new YataScaleManager({
1580
+ shards: 16,
1581
+ cacheConfig: {
1582
+ l1MaxSize: 1000,
1583
+ l2MaxSize: 10000,
1584
+ l3Path: './cache',
1585
+ },
1586
+ });
1587
+
1588
+ // Store entity
1589
+ await yata.putEntity({
1590
+ id: 'entity-1',
1591
+ type: 'Document',
1592
+ properties: { title: 'Example' },
1593
+ });
1594
+
1595
+ // Query
1596
+ const results = await yata.query('SELECT ?s WHERE { ?s rdf:type Document }');
1597
+ ```
1598
+
1599
+ ### Sharding
1600
+
1601
+ Distribute data across shards using consistent hashing:
1602
+
1603
+ ```typescript
1604
+ import { ShardManager, HashPartitionStrategy } from '@nahisaho/yata-scale';
1605
+
1606
+ const shardManager = new ShardManager({
1607
+ shardCount: 16,
1608
+ virtualNodes: 150,
1609
+ strategy: new HashPartitionStrategy(),
1610
+ });
1611
+
1612
+ // Get shard for entity
1613
+ const shard = shardManager.getShardForEntity('entity-id');
1614
+ console.log(`Entity assigned to shard ${shard.id}`);
1615
+
1616
+ // Rebalance on node changes
1617
+ await shardManager.addNode('node-5');
1618
+ ```
1619
+
1620
+ ### Multi-Tier Caching
1621
+
1622
+ Three-tier caching for optimal performance:
1623
+
1624
+ ```typescript
1625
+ import { CacheManager, L1Cache, L2Cache, L3Cache } from '@nahisaho/yata-scale';
1626
+
1627
+ const cache = new CacheManager({
1628
+ l1: new L1Cache({ maxSize: 1000 }), // LRU cache
1629
+ l2: new L2Cache({ maxSize: 10000 }), // LFU cache
1630
+ l3: new L3Cache({ path: './cache' }), // Disk cache
1631
+ });
1632
+
1633
+ // Cache operations
1634
+ await cache.set('key', value, { ttl: 3600 });
1635
+ const result = await cache.get('key');
1636
+
1637
+ // Invalidation
1638
+ await cache.invalidate('key');
1639
+ await cache.invalidatePattern('user:*');
1640
+ ```
1641
+
1642
+ ### Index Management
1643
+
1644
+ Multiple index types for efficient queries:
1645
+
1646
+ ```typescript
1647
+ import { IndexManager, BPlusTreeIndex, FullTextIndex, GraphIndex } from '@nahisaho/yata-scale';
1648
+
1649
+ const indexManager = new IndexManager();
1650
+
1651
+ // B+ Tree for range queries
1652
+ indexManager.addIndex('timestamp', new BPlusTreeIndex());
1653
+
1654
+ // Full-text for search
1655
+ indexManager.addIndex('content', new FullTextIndex());
1656
+
1657
+ // Graph for traversal
1658
+ indexManager.addIndex('relationships', new GraphIndex());
1659
+ ```
1660
+
1661
+ ### Vector Clock Synchronization
1662
+
1663
+ Distributed synchronization with conflict resolution:
1664
+
1665
+ ```typescript
1666
+ import { SyncController, VectorClock, ConflictResolver } from '@nahisaho/yata-scale';
1667
+
1668
+ const sync = new SyncController({
1669
+ nodeId: 'node-1',
1670
+ conflictStrategy: 'last-write-wins',
1671
+ });
1672
+
1673
+ // Synchronize with peers
1674
+ await sync.synchronize();
1675
+
1676
+ // Manual conflict resolution
1677
+ sync.onConflict((conflict) => {
1678
+ console.log(`Conflict on ${conflict.key}`);
1679
+ return conflict.local; // or conflict.remote
1680
+ });
1681
+ ```
1682
+
1683
+ ### v2.0.0 Package Summary
1684
+
1685
+ | Package | Tests | Description |
1686
+ |---------|-------|-------------|
1687
+ | `@nahisaho/musubix-dfg` | 30 | DFG/CFG extraction, Def-Use analysis |
1688
+ | `@nahisaho/musubix-lean` | 151 | Lean 4 theorem proving, EARS conversion |
1689
+ | `@nahisaho/yata-scale` | 57 | Distributed sharding, caching, sync |
1690
+ | **Total** | **238** | **Phase 1: Deep Symbolic Integration** |
1691
+
1692
+ ---
1693
+
1694
+ ## Library Learning
1695
+
1696
+ *(v2.0.0 NEW!)*
1697
+
1698
+ The `@nahisaho/musubix-library-learner` package provides intelligent API pattern extraction and documentation from TypeScript libraries, enabling the system to learn and suggest library usage patterns.
1699
+
1700
+ ### Installation
1701
+
1702
+ ```bash
1703
+ npm install @nahisaho/musubix-library-learner
1704
+ ```
1705
+
1706
+ ### Library Analysis
1707
+
1708
+ Analyze and learn patterns from TypeScript libraries:
1709
+
1710
+ ```typescript
1711
+ import { LibraryLearner, LibraryAnalyzer } from '@nahisaho/musubix-library-learner';
1712
+
1713
+ const learner = new LibraryLearner();
1714
+
1715
+ // Analyze a library
1716
+ const patterns = await learner.analyze({
1717
+ libraryName: 'lodash',
1718
+ sourceDir: './node_modules/lodash',
1719
+ includeExamples: true,
1720
+ });
1721
+
1722
+ console.log(`Found ${patterns.length} API patterns`);
1723
+ for (const pattern of patterns) {
1724
+ console.log(`- ${pattern.name}: ${pattern.description}`);
1725
+ }
1726
+ ```
1727
+
1728
+ ### Pattern Extraction
1729
+
1730
+ Extract usage patterns from code examples:
1731
+
1732
+ ```typescript
1733
+ import { PatternExtractor } from '@nahisaho/musubix-library-learner';
1734
+
1735
+ const extractor = new PatternExtractor();
1736
+
1737
+ const patterns = await extractor.extract({
1738
+ code: sourceCode,
1739
+ libraryContext: 'express',
1740
+ });
1741
+
1742
+ // Get common patterns
1743
+ for (const pattern of patterns) {
1744
+ console.log(`Pattern: ${pattern.type}`);
1745
+ console.log(`Example: ${pattern.example}`);
1746
+ console.log(`Frequency: ${pattern.frequency}`);
1747
+ }
1748
+ ```
1749
+
1750
+ ### API Documentation Generation
1751
+
1752
+ Generate documentation from learned patterns:
1753
+
1754
+ ```typescript
1755
+ import { DocGenerator } from '@nahisaho/musubix-library-learner';
1756
+
1757
+ const generator = new DocGenerator();
1758
+
1759
+ const docs = await generator.generate({
1760
+ patterns: learnedPatterns,
1761
+ format: 'markdown',
1762
+ includeExamples: true,
1763
+ });
1764
+
1765
+ await fs.writeFile('API-PATTERNS.md', docs);
1766
+ ```
1767
+
1768
+ ### TypeScript Analysis
1769
+
1770
+ Deep analysis of TypeScript declarations:
1771
+
1772
+ ```typescript
1773
+ import { TypeScriptAnalyzer } from '@nahisaho/musubix-library-learner';
1774
+
1775
+ const analyzer = new TypeScriptAnalyzer();
1776
+
1777
+ const analysis = await analyzer.analyze('./src/index.ts');
1778
+
1779
+ // Get exported types
1780
+ for (const type of analysis.exports) {
1781
+ console.log(`${type.name}: ${type.kind}`);
1782
+ if (type.kind === 'function') {
1783
+ console.log(` Params: ${type.parameters.join(', ')}`);
1784
+ console.log(` Returns: ${type.returnType}`);
1785
+ }
1786
+ }
1787
+ ```
1788
+
1789
+ ---
1790
+
1791
+ ## Neural Search
1792
+
1793
+ *(v2.0.0 NEW!)*
1794
+
1795
+ The `@nahisaho/musubix-neural-search` package provides semantic code search using embeddings and neural ranking, enabling context-aware code discovery across your codebase.
1796
+
1797
+ ### Installation
1798
+
1799
+ ```bash
1800
+ npm install @nahisaho/musubix-neural-search
1801
+ ```
1802
+
1803
+ ### Semantic Search
1804
+
1805
+ Search code by meaning, not just keywords:
1806
+
1807
+ ```typescript
1808
+ import { NeuralSearchEngine } from '@nahisaho/musubix-neural-search';
1809
+
1810
+ const search = new NeuralSearchEngine({
1811
+ embeddingModel: 'code-bert',
1812
+ indexPath: './search-index',
1813
+ });
1814
+
1815
+ // Index your codebase
1816
+ await search.index('./src');
1817
+
1818
+ // Semantic search
1819
+ const results = await search.search({
1820
+ query: 'function that validates email addresses',
1821
+ limit: 10,
1822
+ });
1823
+
1824
+ for (const result of results) {
1825
+ console.log(`${result.file}:${result.line} (score: ${result.score})`);
1826
+ console.log(` ${result.snippet}`);
1827
+ }
1828
+ ```
1829
+
1830
+ ### Code Embeddings
1831
+
1832
+ Generate embeddings for code snippets:
1833
+
1834
+ ```typescript
1835
+ import { CodeEmbedder } from '@nahisaho/musubix-neural-search';
1836
+
1837
+ const embedder = new CodeEmbedder();
1838
+
1839
+ const embedding = await embedder.embed({
1840
+ code: 'function add(a: number, b: number) { return a + b; }',
1841
+ language: 'typescript',
1842
+ });
1843
+
1844
+ // Compare similarity
1845
+ const similarity = embedder.cosineSimilarity(embedding1, embedding2);
1846
+ console.log(`Similarity: ${similarity}`);
1847
+ ```
1848
+
1849
+ ### Hybrid Search
1850
+
1851
+ Combine lexical and semantic search:
1852
+
1853
+ ```typescript
1854
+ import { HybridSearchEngine } from '@nahisaho/musubix-neural-search';
1855
+
1856
+ const hybrid = new HybridSearchEngine({
1857
+ lexicalWeight: 0.3,
1858
+ semanticWeight: 0.7,
1859
+ });
1860
+
1861
+ const results = await hybrid.search({
1862
+ query: 'authentication middleware express',
1863
+ filters: {
1864
+ language: 'typescript',
1865
+ path: 'src/middleware/**',
1866
+ },
1867
+ });
1868
+ ```
1869
+
1870
+ ### Code Ranking
1871
+
1872
+ Neural ranking for search results:
1873
+
1874
+ ```typescript
1875
+ import { CodeRanker } from '@nahisaho/musubix-neural-search';
1876
+
1877
+ const ranker = new CodeRanker();
1878
+
1879
+ const ranked = await ranker.rank({
1880
+ query: 'parse JSON safely',
1881
+ candidates: searchResults,
1882
+ context: {
1883
+ currentFile: './src/utils.ts',
1884
+ recentFiles: ['./src/api.ts', './src/config.ts'],
1885
+ },
1886
+ });
1887
+ ```
1888
+
1889
+ ---
1890
+
1891
+ ## Program Synthesis
1892
+
1893
+ *(v2.0.0 NEW!)*
1894
+
1895
+ The `@nahisaho/musubix-synthesis` package provides neural-guided program synthesis, generating code from specifications using symbolic constraints and neural networks.
1896
+
1897
+ ### Installation
1898
+
1899
+ ```bash
1900
+ npm install @nahisaho/musubix-synthesis
1901
+ ```
1902
+
1903
+ ### Specification-Based Synthesis
1904
+
1905
+ Generate code from formal specifications:
1906
+
1907
+ ```typescript
1908
+ import { ProgramSynthesizer } from '@nahisaho/musubix-synthesis';
1909
+
1910
+ const synthesizer = new ProgramSynthesizer();
1911
+
1912
+ const result = await synthesizer.synthesize({
1913
+ specification: {
1914
+ input: 'array of numbers',
1915
+ output: 'array of numbers (sorted ascending)',
1916
+ constraints: ['stable sort', 'O(n log n) complexity'],
1917
+ },
1918
+ language: 'typescript',
1919
+ });
1920
+
1921
+ console.log(result.code);
1922
+ // function sort(arr: number[]): number[] {
1923
+ // return [...arr].sort((a, b) => a - b);
1924
+ // }
1925
+ ```
1926
+
1927
+ ### Example-Based Synthesis
1928
+
1929
+ Generate code from input/output examples:
1930
+
1931
+ ```typescript
1932
+ import { ExampleBasedSynthesizer } from '@nahisaho/musubix-synthesis';
1933
+
1934
+ const synthesizer = new ExampleBasedSynthesizer();
1935
+
1936
+ const result = await synthesizer.synthesize({
1937
+ examples: [
1938
+ { input: ['hello', 'world'], output: 'hello world' },
1939
+ { input: ['foo', 'bar', 'baz'], output: 'foo bar baz' },
1940
+ ],
1941
+ language: 'typescript',
1942
+ });
1943
+
1944
+ console.log(result.code);
1945
+ // function join(arr: string[]): string {
1946
+ // return arr.join(' ');
1947
+ // }
1948
+ ```
1949
+
1950
+ ### Sketch-Based Synthesis
1951
+
1952
+ Fill in holes in partial programs:
1953
+
1954
+ ```typescript
1955
+ import { SketchSynthesizer } from '@nahisaho/musubix-synthesis';
1956
+
1957
+ const synthesizer = new SketchSynthesizer();
1958
+
1959
+ const result = await synthesizer.complete({
1960
+ sketch: `
1961
+ function validate(email: string): boolean {
1962
+ const pattern = ??; // hole to fill
1963
+ return pattern.test(email);
1964
+ }
1965
+ `,
1966
+ constraints: ['must validate common email formats'],
1967
+ });
1968
+
1969
+ console.log(result.code);
1970
+ // const pattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1971
+ ```
1972
+
1973
+ ### Neural-Guided Search
1974
+
1975
+ Use neural networks to guide synthesis search:
1976
+
1977
+ ```typescript
1978
+ import { NeuralGuidedSynthesizer } from '@nahisaho/musubix-synthesis';
1979
+
1980
+ const synthesizer = new NeuralGuidedSynthesizer({
1981
+ model: 'codegen-2B',
1982
+ beamWidth: 5,
1983
+ maxDepth: 10,
1984
+ });
1985
+
1986
+ const result = await synthesizer.synthesize({
1987
+ description: 'Parse a CSV string into array of objects with headers as keys',
1988
+ tests: [
1989
+ {
1990
+ input: 'name,age\\nAlice,30\\nBob,25',
1991
+ output: [{ name: 'Alice', age: '30' }, { name: 'Bob', age: '25' }],
1992
+ },
1993
+ ],
1994
+ });
1995
+
1996
+ if (result.verified) {
1997
+ console.log('All tests pass!');
1998
+ console.log(result.code);
1999
+ }
2000
+ ```
2001
+
2002
+ ### Synthesis Verification
2003
+
2004
+ Verify synthesized code against specifications:
2005
+
2006
+ ```typescript
2007
+ import { SynthesisVerifier } from '@nahisaho/musubix-synthesis';
2008
+
2009
+ const verifier = new SynthesisVerifier();
2010
+
2011
+ const verification = await verifier.verify({
2012
+ code: synthesizedCode,
2013
+ specification: originalSpec,
2014
+ tests: testCases,
2015
+ });
2016
+
2017
+ console.log(`Verified: ${verification.passed}`);
2018
+ console.log(`Coverage: ${verification.testCoverage}%`);
2019
+ for (const issue of verification.issues) {
2020
+ console.log(`Issue: ${issue.message}`);
2021
+ }
2022
+ ```
2023
+
2024
+ ### v2.0.0 Package Summary
2025
+
2026
+ | Package | Tests | Description |
2027
+ |---------|-------|-------------|
2028
+ | **Phase 1: Deep Symbolic Integration** | | |
2029
+ | `@nahisaho/musubix-dfg` | 30 | DFG/CFG extraction, Def-Use analysis |
2030
+ | `@nahisaho/musubix-lean` | 151 | Lean 4 theorem proving, EARS conversion |
2031
+ | `@nahisaho/yata-scale` | 57 | Distributed sharding, caching, sync |
2032
+ | **Phase 2: Advanced Learning** | | |
2033
+ | `@nahisaho/musubix-library-learner` | 132 | API pattern extraction, documentation |
2034
+ | `@nahisaho/musubix-neural-search` | 144 | Semantic code search, embeddings |
2035
+ | `@nahisaho/musubix-synthesis` | 146 | Neural-guided program synthesis |
2036
+ | **Total v2.0.0 New** | **660** | **6 new packages** |
2037
+
2038
+ ---
2039
+
1210
2040
  ## MCP Server Integration
1211
2041
 
1212
2042
  ### CLI Startup
@@ -1817,6 +2647,6 @@ const client = createYATAClient({
1817
2647
 
1818
2648
  ---
1819
2649
 
1820
- **Version**: 1.6.0
1821
- **Last Updated**: 2026-01-06
2650
+ **Version**: 2.0.0
2651
+ **Last Updated**: 2026-01-08
1822
2652
  **MUSUBIX Project**