@claude-flow/plugin-quantum-optimizer 3.0.0-alpha.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/README.md ADDED
@@ -0,0 +1,300 @@
1
+ # @claude-flow/plugin-quantum-optimizer
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@claude-flow/plugin-quantum-optimizer.svg)](https://www.npmjs.com/package/@claude-flow/plugin-quantum-optimizer)
4
+ [![license](https://img.shields.io/npm/l/@claude-flow/plugin-quantum-optimizer.svg)](https://github.com/ruvnet/claude-flow/blob/main/LICENSE)
5
+ [![downloads](https://img.shields.io/npm/dm/@claude-flow/plugin-quantum-optimizer.svg)](https://www.npmjs.com/package/@claude-flow/plugin-quantum-optimizer)
6
+
7
+ An exotic optimization plugin implementing quantum-inspired algorithms including Quantum Annealing simulation, QAOA (Quantum Approximate Optimization Algorithm) emulation, and Grover-inspired search acceleration. The plugin provides dramatic speedups for dependency resolution, optimal scheduling, and constraint satisfaction while running entirely on classical WASM-accelerated hardware.
8
+
9
+ ## Installation
10
+
11
+ ### npm
12
+
13
+ ```bash
14
+ npm install @claude-flow/plugin-quantum-optimizer
15
+ ```
16
+
17
+ ### CLI
18
+
19
+ ```bash
20
+ npx claude-flow plugins install --name @claude-flow/plugin-quantum-optimizer
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```typescript
26
+ import { QuantumOptimizerPlugin } from '@claude-flow/plugin-quantum-optimizer';
27
+
28
+ // Initialize the plugin
29
+ const plugin = new QuantumOptimizerPlugin();
30
+ await plugin.initialize();
31
+
32
+ // Solve a scheduling optimization problem
33
+ const schedule = await plugin.scheduleOptimize({
34
+ tasks: [
35
+ { id: 'build', duration: 10, dependencies: [], resources: ['cpu'], deadline: 30 },
36
+ { id: 'test', duration: 5, dependencies: ['build'], resources: ['cpu'], deadline: 40 },
37
+ { id: 'deploy', duration: 3, dependencies: ['test'], resources: ['network'], deadline: 50 }
38
+ ],
39
+ resources: [
40
+ { id: 'cpu', capacity: 4, cost: 1.0 },
41
+ { id: 'network', capacity: 2, cost: 0.5 }
42
+ ],
43
+ objective: 'makespan'
44
+ });
45
+
46
+ console.log('Optimal schedule:', schedule);
47
+ ```
48
+
49
+ ## Available MCP Tools
50
+
51
+ ### 1. `quantum/annealing-solve`
52
+
53
+ Solve combinatorial optimization problems using simulated quantum annealing.
54
+
55
+ ```typescript
56
+ const result = await mcp.call('quantum/annealing-solve', {
57
+ problem: {
58
+ type: 'qubo', // Quadratic Unconstrained Binary Optimization
59
+ variables: 100,
60
+ constraints: [...],
61
+ objective: { 'x1': -1, 'x2': -1, 'x1_x2': 2 }
62
+ },
63
+ parameters: {
64
+ numReads: 1000,
65
+ annealingTime: 20,
66
+ chainStrength: 1.0,
67
+ temperature: {
68
+ initial: 100,
69
+ final: 0.01
70
+ }
71
+ },
72
+ embedding: 'auto'
73
+ });
74
+ ```
75
+
76
+ **Problem Types:** `qubo`, `ising`, `sat`, `max_cut`, `tsp`, `dependency`
77
+
78
+ **Returns:** Optimal or near-optimal solution with energy value and convergence statistics.
79
+
80
+ ### 2. `quantum/qaoa-optimize`
81
+
82
+ Approximate optimization using Quantum Approximate Optimization Algorithm emulation.
83
+
84
+ ```typescript
85
+ const result = await mcp.call('quantum/qaoa-optimize', {
86
+ problem: {
87
+ type: 'max_cut',
88
+ graph: {
89
+ nodes: 20,
90
+ edges: [[0, 1], [1, 2], [2, 3], [0, 3], ...]
91
+ },
92
+ weights: { '0_1': 1.0, '1_2': 0.5, ... }
93
+ },
94
+ circuit: {
95
+ depth: 3, // QAOA circuit depth (p)
96
+ optimizer: 'cobyla',
97
+ initialParams: 'heuristic'
98
+ },
99
+ shots: 1024
100
+ });
101
+ ```
102
+
103
+ **Problem Types:** `max_cut`, `portfolio`, `scheduling`, `routing`
104
+
105
+ **Returns:** Optimized solution with approximation ratio and parameter trajectory.
106
+
107
+ ### 3. `quantum/grover-search`
108
+
109
+ Grover-inspired search with quadratic speedup for unstructured search problems.
110
+
111
+ ```typescript
112
+ const result = await mcp.call('quantum/grover-search', {
113
+ searchSpace: {
114
+ size: 1000000, // 1M elements
115
+ oracle: 'x.value > 100 && x.valid === true',
116
+ structure: 'database'
117
+ },
118
+ targets: 1,
119
+ iterations: 'optimal',
120
+ amplification: {
121
+ method: 'standard',
122
+ boostFactor: 1.5
123
+ }
124
+ });
125
+ ```
126
+
127
+ **Returns:** Found solution(s) with iteration count and amplitude distribution.
128
+
129
+ ### 4. `quantum/dependency-resolve`
130
+
131
+ Resolve complex dependency graphs using quantum optimization.
132
+
133
+ ```typescript
134
+ const result = await mcp.call('quantum/dependency-resolve', {
135
+ packages: [
136
+ { name: 'react', version: '18.2.0', dependencies: { 'react-dom': '^18.0.0' }, conflicts: [] },
137
+ { name: 'webpack', version: '5.88.0', dependencies: { 'loader-utils': '^3.0.0' }, conflicts: [] },
138
+ // ... more packages
139
+ ],
140
+ constraints: {
141
+ minimize: 'versions', // Minimize total version count
142
+ lockfile: existingLockfile,
143
+ peer: true
144
+ },
145
+ solver: 'hybrid'
146
+ });
147
+ ```
148
+
149
+ **Returns:** Resolved dependency tree with version selections and conflict resolutions.
150
+
151
+ ### 5. `quantum/schedule-optimize`
152
+
153
+ Quantum-optimized task scheduling for complex workflows.
154
+
155
+ ```typescript
156
+ const result = await mcp.call('quantum/schedule-optimize', {
157
+ tasks: [
158
+ { id: 'task-1', duration: 10, dependencies: [], resources: ['gpu'], deadline: 100 },
159
+ { id: 'task-2', duration: 5, dependencies: ['task-1'], resources: ['cpu'], deadline: 120 },
160
+ { id: 'task-3', duration: 8, dependencies: [], resources: ['cpu', 'memory'], deadline: 80 }
161
+ ],
162
+ resources: [
163
+ { id: 'cpu', capacity: 8, cost: 1.0 },
164
+ { id: 'gpu', capacity: 2, cost: 5.0 },
165
+ { id: 'memory', capacity: 64, cost: 0.1 }
166
+ ],
167
+ objective: 'weighted' // Balance makespan and cost
168
+ });
169
+ ```
170
+
171
+ **Returns:** Optimal schedule with resource assignments and timeline visualization.
172
+
173
+ ## Configuration Options
174
+
175
+ ```typescript
176
+ interface QuantumOptimizerConfig {
177
+ // Maximum problem variables (default: 10000)
178
+ maxVariables: number;
179
+
180
+ // Maximum iterations (default: 1000000)
181
+ maxIterations: number;
182
+
183
+ // Memory limit in bytes (default: 4GB)
184
+ maxMemoryBytes: number;
185
+
186
+ // CPU time limit in ms (default: 600000 = 10 min)
187
+ maxCpuTimeMs: number;
188
+
189
+ // QAOA circuit depth limit (default: 20)
190
+ maxCircuitDepth: number;
191
+
192
+ // Simulated qubit limit (default: 50)
193
+ maxQubits: number;
194
+
195
+ // Progress monitoring
196
+ progressCheckIntervalMs: number;
197
+ minProgressThreshold: number;
198
+ }
199
+ ```
200
+
201
+ ## Quantum-Inspired Algorithms
202
+
203
+ | Algorithm | Speedup | Problem Class | Classical Equivalent |
204
+ |-----------|---------|---------------|---------------------|
205
+ | Quantum Annealing | Exponential (heuristic) | Combinatorial optimization | Simulated Annealing |
206
+ | QAOA | Polynomial | Max-Cut, QUBO | Goemans-Williamson |
207
+ | Grover Search | Quadratic O(sqrt(N)) | Unstructured search | Linear Search |
208
+ | Quantum Walk | Polynomial | Graph problems | Random Walk |
209
+ | VQE | Variable | Eigenvalue problems | Power Iteration |
210
+
211
+ ## Performance Targets
212
+
213
+ | Metric | Target | Improvement vs Classical |
214
+ |--------|--------|-------------------------|
215
+ | Annealing (100 vars) | <1s for 1000 reads | 30x faster than brute force |
216
+ | QAOA (50 qubits) | <10s for p=5 | 30x faster than classical approx |
217
+ | Grover (1M elements) | <100ms | 10x (sqrt speedup) |
218
+ | Dependency resolution | <5s for 1000 packages | 24x faster than SAT solver |
219
+ | Schedule optimization | <30s for 100 tasks | 20x faster than ILP solver |
220
+
221
+ ## Security Considerations
222
+
223
+ - **Resource Limits**: Strict memory (4GB), CPU (10 min), and iteration (1M) limits prevent DoS attacks
224
+ - **Problem Validation**: Problems are validated for size, connectivity, and coefficient magnitude before processing
225
+ - **Oracle Sandboxing**: Grover search predicates are parsed and interpreted safely - never evaluated with `eval()`
226
+ - **Input Validation**: All inputs validated with Zod schemas with strict type checking
227
+ - **Progress Monitoring**: Long-running optimizations are canceled if no progress is detected
228
+ - **Coefficient Bounds**: Problem coefficients limited to prevent numerical overflow attacks
229
+
230
+ ### WASM Security Constraints
231
+
232
+ | Constraint | Value | Rationale |
233
+ |------------|-------|-----------|
234
+ | Memory Limit | 4GB max | Handle large optimization problems |
235
+ | CPU Time Limit | 600 seconds (10 min) | Allow complex optimizations |
236
+ | No Network Access | Enforced | Prevent side-channel attacks |
237
+ | Iteration Limit | 1,000,000 | Prevent infinite loops |
238
+ | Progress Threshold | Required improvement per 1000 iterations | Cancel stalled runs |
239
+
240
+ ### Input Limits
241
+
242
+ | Constraint | Limit |
243
+ |------------|-------|
244
+ | Max variables | 10,000 |
245
+ | Max iterations | 1,000,000 |
246
+ | Max memory | 4GB |
247
+ | CPU time limit | 600 seconds (10 min) |
248
+ | Max QAOA depth | 20 |
249
+ | Max simulated qubits | 50 |
250
+ | Max graph edges | 100,000 |
251
+ | Max search space | 1 billion elements |
252
+
253
+ ### Rate Limits
254
+
255
+ | Tool | Requests/Minute | Max Concurrent |
256
+ |------|-----------------|----------------|
257
+ | `annealing-solve` | 5 | 1 |
258
+ | `qaoa-optimize` | 5 | 1 |
259
+ | `grover-search` | 10 | 2 |
260
+ | `dependency-resolve` | 10 | 2 |
261
+ | `schedule-optimize` | 5 | 1 |
262
+
263
+ ## Dependencies
264
+
265
+ - `ruvector-exotic-wasm` - Quantum-inspired optimization algorithms
266
+ - `ruvector-sparse-inference-wasm` - Efficient sparse matrix operations for quantum simulation
267
+ - `micro-hnsw-wasm` - Amplitude-inspired search acceleration
268
+ - `ruvector-dag-wasm` - Quantum circuit DAG representation
269
+ - `ruvector-hyperbolic-hnsw-wasm` - Hyperbolic embeddings for quantum state spaces
270
+
271
+ ## Theoretical Background
272
+
273
+ ### Quantum Annealing
274
+ Exploits quantum tunneling to escape local minima during optimization. Simulated via Path Integral Monte Carlo on classical hardware.
275
+
276
+ ### QAOA
277
+ Variational algorithm alternating between problem Hamiltonian and mixer. Emulated via tensor network contraction for efficient classical simulation.
278
+
279
+ ### Grover's Algorithm
280
+ Amplitude amplification for unstructured search achieving O(sqrt(N)) complexity. Classical implementation uses interference-inspired importance sampling.
281
+
282
+ ## Use Cases
283
+
284
+ 1. **Dependency Resolution**: Solve complex version conflicts in package managers
285
+ 2. **Task Scheduling**: Optimal CI/CD pipeline and workflow scheduling
286
+ 3. **Resource Allocation**: Distribute workloads optimally across agents/machines
287
+ 4. **Test Selection**: Find minimal test sets with maximum coverage
288
+ 5. **Configuration Optimization**: Find optimal system configurations
289
+
290
+ ## Related Plugins
291
+
292
+ | Plugin | Description | Synergy |
293
+ |--------|-------------|---------|
294
+ | [@claude-flow/plugin-neural-coordination](https://www.npmjs.com/package/@claude-flow/plugin-neural-coordination) | Multi-agent coordination | Quantum optimizer schedules tasks across coordinated agent swarms |
295
+ | [@claude-flow/plugin-cognitive-kernel](https://www.npmjs.com/package/@claude-flow/plugin-cognitive-kernel) | Cognitive augmentation | Optimizes cognitive load distribution and attention allocation |
296
+ | [@claude-flow/plugin-hyperbolic-reasoning](https://www.npmjs.com/package/@claude-flow/plugin-hyperbolic-reasoning) | Hierarchical reasoning | Quantum algorithms optimize hierarchical constraint satisfaction |
297
+
298
+ ## License
299
+
300
+ MIT
@@ -0,0 +1,95 @@
1
+ /**
2
+ * DAG Bridge - Directed Acyclic Graph Operations
3
+ *
4
+ * Bridge to @ruvector/dag-wasm for dependency graph analysis,
5
+ * topological sorting, and cycle detection.
6
+ */
7
+ import type { PackageDescriptor, DependencyConstraints, DependencyResult, ScheduleTask, ScheduleResource, ScheduleResult, ScheduleObjective } from '../types.js';
8
+ /**
9
+ * WASM module status
10
+ */
11
+ export type WasmModuleStatus = 'unloaded' | 'loading' | 'ready' | 'error';
12
+ /**
13
+ * DAG node
14
+ */
15
+ export interface DagNode {
16
+ readonly id: string;
17
+ readonly data?: Record<string, unknown>;
18
+ }
19
+ /**
20
+ * DAG edge
21
+ */
22
+ export interface DagEdge {
23
+ readonly from: string;
24
+ readonly to: string;
25
+ readonly weight?: number;
26
+ }
27
+ /**
28
+ * DAG structure
29
+ */
30
+ export interface Dag {
31
+ readonly nodes: ReadonlyArray<DagNode>;
32
+ readonly edges: ReadonlyArray<DagEdge>;
33
+ }
34
+ /**
35
+ * Topological sort result
36
+ */
37
+ export interface TopologicalSortResult {
38
+ readonly order: ReadonlyArray<string>;
39
+ readonly hasCycle: boolean;
40
+ readonly cycleNodes?: ReadonlyArray<string>;
41
+ }
42
+ /**
43
+ * Critical path result
44
+ */
45
+ export interface CriticalPathResult {
46
+ readonly path: ReadonlyArray<string>;
47
+ readonly length: number;
48
+ readonly slack: Map<string, number>;
49
+ }
50
+ /**
51
+ * DAG Bridge for dependency graph operations
52
+ */
53
+ export declare class DagBridge {
54
+ readonly name = "quantum-dag-bridge";
55
+ readonly version = "0.1.0";
56
+ private _status;
57
+ private _module;
58
+ get status(): WasmModuleStatus;
59
+ get initialized(): boolean;
60
+ /**
61
+ * Initialize the WASM module
62
+ */
63
+ initialize(): Promise<void>;
64
+ /**
65
+ * Dispose of resources
66
+ */
67
+ dispose(): Promise<void>;
68
+ /**
69
+ * Perform topological sort on a DAG
70
+ */
71
+ topologicalSort(dag: Dag): TopologicalSortResult;
72
+ /**
73
+ * Find critical path in a DAG with durations
74
+ */
75
+ criticalPath(dag: Dag, durations: Map<string, number>): CriticalPathResult;
76
+ /**
77
+ * Resolve package dependencies using quantum-inspired optimization
78
+ */
79
+ resolveDependencies(packages: ReadonlyArray<PackageDescriptor>, constraints: DependencyConstraints): Promise<DependencyResult>;
80
+ /**
81
+ * Optimize task schedule using DAG analysis
82
+ */
83
+ optimizeSchedule(tasks: ReadonlyArray<ScheduleTask>, resources: ReadonlyArray<ScheduleResource>, objective: ScheduleObjective): Promise<ScheduleResult>;
84
+ private versionSatisfies;
85
+ private compareVersions;
86
+ /**
87
+ * Create mock module for development
88
+ */
89
+ private createMockModule;
90
+ }
91
+ /**
92
+ * Create a new DagBridge instance
93
+ */
94
+ export declare function createDagBridge(): DagBridge;
95
+ //# sourceMappingURL=dag-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dag-bridge.d.ts","sourceRoot":"","sources":["../../src/bridges/dag-bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,cAAc,EAEd,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAA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