@ruvector/edge-net 0.5.0 → 0.5.3
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 +281 -10
- package/core-invariants.js +942 -0
- package/models/adapter-hub.js +1008 -0
- package/models/adapter-security.js +792 -0
- package/models/benchmark.js +688 -0
- package/models/distribution.js +791 -0
- package/models/index.js +109 -0
- package/models/integrity.js +753 -0
- package/models/loader.js +725 -0
- package/models/microlora.js +1298 -0
- package/models/model-loader.js +922 -0
- package/models/model-optimizer.js +1245 -0
- package/models/model-registry.js +696 -0
- package/models/model-utils.js +548 -0
- package/models/models-cli.js +914 -0
- package/models/registry.json +214 -0
- package/models/training-utils.js +1418 -0
- package/models/wasm-core.js +1025 -0
- package/network-genesis.js +2847 -0
- package/onnx-worker.js +462 -8
- package/package.json +33 -3
- package/plugins/SECURITY-AUDIT.md +654 -0
- package/plugins/cli.js +43 -3
- package/plugins/implementations/e2e-encryption.js +57 -12
- package/plugins/plugin-loader.js +610 -21
- package/tests/model-optimizer.test.js +644 -0
- package/tests/network-genesis.test.js +562 -0
- package/tests/plugin-benchmark.js +1239 -0
- package/tests/plugin-system-test.js +163 -0
- package/tests/wasm-core.test.js +368 -0
package/README.md
CHANGED
|
@@ -1,35 +1,51 @@
|
|
|
1
1
|
# @ruvector/edge-net
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**The Decentralized AI Compute Network - Private, Modular, Unstoppable**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
> *Cogito, Creo, Codex* — I think, I create, I code.
|
|
6
|
+
|
|
7
|
+
Transform idle browser compute into a globally distributed AI infrastructure. Edge-net combines WebRTC P2P networking, WASM-accelerated cryptography, and a modular plugin architecture to create a self-sustaining collective intelligence network.
|
|
8
|
+
|
|
9
|
+
> **v0.5.1** - Now with hardened plugin system featuring Ed25519 verification, rate limiting, and HKDF key derivation.
|
|
6
10
|
|
|
7
11
|
```
|
|
8
12
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
9
|
-
│ EDGE-NET:
|
|
13
|
+
│ EDGE-NET: DECENTRALIZED AI COMPUTE NETWORK │
|
|
10
14
|
├─────────────────────────────────────────────────────────────────────────────┤
|
|
11
15
|
│ │
|
|
12
16
|
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
13
|
-
│ │
|
|
14
|
-
│ │
|
|
15
|
-
│ │ (
|
|
17
|
+
│ │ Browser │ │ Global P2P │ │ AI Tasks │ │
|
|
18
|
+
│ │ Nodes │◄─────►│ Mesh │◄─────►│ Executed │ │
|
|
19
|
+
│ │ (WASM) │ WebRTC│ (Genesis) │ │ Privately │ │
|
|
16
20
|
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
17
21
|
│ │ │ │ │
|
|
18
22
|
│ ▼ ▼ ▼ │
|
|
19
23
|
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
20
|
-
│ │ Contribute │ │ Earn rUv │ │
|
|
21
|
-
│ │
|
|
22
|
-
│ │
|
|
24
|
+
│ │ Contribute │ │ Earn rUv │ │ Extend via │ │
|
|
25
|
+
│ │ Idle CPU │ ───► │ Credits │ ───► │ Plugins │ │
|
|
26
|
+
│ │ Securely │ │ Privately │ │ Modularly │ │
|
|
23
27
|
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
24
28
|
│ │
|
|
25
|
-
│ Vector Search │ Embeddings │
|
|
29
|
+
│ Vector Search │ Embeddings │ E2E Encryption │ Federated ML │ Swarm AI │
|
|
26
30
|
│ │
|
|
27
31
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
28
32
|
```
|
|
29
33
|
|
|
34
|
+
## Why Edge-Net?
|
|
35
|
+
|
|
36
|
+
| Problem | Edge-Net Solution |
|
|
37
|
+
|---------|-------------------|
|
|
38
|
+
| **Centralized AI** requires sending your data to cloud providers | **Local-first** - your data never leaves your browser |
|
|
39
|
+
| **GPU scarcity** makes AI expensive and inaccessible | **Collective compute** - thousands of browsers working together |
|
|
40
|
+
| **Monolithic systems** force all-or-nothing adoption | **Plugin architecture** - enable only what you need |
|
|
41
|
+
| **Closed networks** lock you into vendor ecosystems | **Open P2P** - WebRTC mesh with no central authority |
|
|
42
|
+
| **Opaque AI** - you can't verify what's running | **Transparent WASM** - auditable, reproducible compute |
|
|
43
|
+
|
|
30
44
|
## Table of Contents
|
|
31
45
|
|
|
32
46
|
- [WebRTC P2P Networking](#webrtc-p2p-networking)
|
|
47
|
+
- [Plugin System](#plugin-system)
|
|
48
|
+
- [Core Invariants](#core-invariants)
|
|
33
49
|
- [What is Edge-Net?](#what-is-edge-net)
|
|
34
50
|
- [Key Features](#key-features)
|
|
35
51
|
- [Quick Start](#quick-start)
|
|
@@ -165,6 +181,259 @@ const channel = pc.createDataChannel('edge-net');
|
|
|
165
181
|
|
|
166
182
|
---
|
|
167
183
|
|
|
184
|
+
## Plugin System
|
|
185
|
+
|
|
186
|
+
Edge-net features a **modular plugin architecture** that lets you enable only the capabilities you need. Plugins are cryptographically verified, sandboxed, and rate-limited for security.
|
|
187
|
+
|
|
188
|
+
### Plugin Architecture
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
192
|
+
│ EDGE-NET PLUGIN ARCHITECTURE │
|
|
193
|
+
├─────────────────────────────────────────────────────────────────────────────┤
|
|
194
|
+
│ │
|
|
195
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
196
|
+
│ │ Plugin Loader (Secure) │ │
|
|
197
|
+
│ │ • Ed25519 signature verification • Rate limiting (100 req/min) │ │
|
|
198
|
+
│ │ • SHA-256 integrity checks • Capability-based sandbox │ │
|
|
199
|
+
│ │ • Lazy loading with cache • Frozen manifest objects │ │
|
|
200
|
+
│ └─────────────────────────────────────────────────────────────────────┘ │
|
|
201
|
+
│ │
|
|
202
|
+
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
|
|
203
|
+
│ │ CORE │ │ NETWORK │ │ CRYPTO │ │ PRIVACY │ │ AI │ │
|
|
204
|
+
│ │ │ │ │ │ │ │ │ │ │ │
|
|
205
|
+
│ │ Compress │ │ Mesh Opt │ │ ZK-Proofs │ │ Onion │ │ Federated │ │
|
|
206
|
+
│ │ Metrics │ │ Gossip │ │ MPC │ │ Mixnet │ │ Swarm │ │
|
|
207
|
+
│ │ Logging │ │ DHT │ │ Threshold │ │ PIR │ │ RL Agent │ │
|
|
208
|
+
│ └───────────┘ └───────────┘ └───────────┘ └───────────┘ └───────────┘ │
|
|
209
|
+
│ │
|
|
210
|
+
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
|
|
211
|
+
│ │ ECONOMIC │ │ STORAGE │ │ EXOTIC │ │
|
|
212
|
+
│ │ │ │ │ │ │ │
|
|
213
|
+
│ │ Staking │ │ IPFS │ │ Time │ │
|
|
214
|
+
│ │ AMM │ │ Arweave │ │ Crystal │ │
|
|
215
|
+
│ │ Auction │ │ Filecoin │ │ Morpho │ │
|
|
216
|
+
│ └───────────┘ └───────────┘ └───────────┘ │
|
|
217
|
+
│ │
|
|
218
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Plugin Categories
|
|
222
|
+
|
|
223
|
+
| Category | Description | Example Plugins |
|
|
224
|
+
|----------|-------------|-----------------|
|
|
225
|
+
| **core** | Essential functionality | compression, metrics, logging |
|
|
226
|
+
| **network** | Network topology & routing | mesh-optimization, gossip-protocol, dht-routing |
|
|
227
|
+
| **crypto** | Cryptographic features | zk-proofs, mpc-compute, threshold-signatures, e2e-encryption |
|
|
228
|
+
| **privacy** | Privacy-enhancing tech | onion-routing, mixnet, pir (private info retrieval) |
|
|
229
|
+
| **ai** | AI/ML capabilities | federated-learning, swarm-intelligence, rl-agents, onnx-inference |
|
|
230
|
+
| **economic** | Incentive mechanisms | reputation-staking, amm-pricing, auction-mechanism |
|
|
231
|
+
| **storage** | Data persistence | ipfs-storage, arweave-persist, filecoin-deals |
|
|
232
|
+
| **exotic** | Experimental features | time-crystal, morphogenetic-net, quantum-sim |
|
|
233
|
+
|
|
234
|
+
### Plugin Tiers
|
|
235
|
+
|
|
236
|
+
| Tier | Badge | Description |
|
|
237
|
+
|------|-------|-------------|
|
|
238
|
+
| **stable** | 🟢 | Production-ready, security audited |
|
|
239
|
+
| **beta** | 🟡 | Feature complete, needs testing |
|
|
240
|
+
| **experimental** | 🟠 | Works but may change |
|
|
241
|
+
| **research** | 🔴 | Academic/research only |
|
|
242
|
+
|
|
243
|
+
### Capability Permissions
|
|
244
|
+
|
|
245
|
+
Plugins declare required capabilities. The loader enforces these at runtime:
|
|
246
|
+
|
|
247
|
+
| Capability | Permission | Description |
|
|
248
|
+
|------------|------------|-------------|
|
|
249
|
+
| `network:connect` | Network | Outbound connections |
|
|
250
|
+
| `network:listen` | Network | Accept connections |
|
|
251
|
+
| `network:relay` | Network | Relay for other nodes |
|
|
252
|
+
| `crypto:sign` | Crypto | Digital signatures |
|
|
253
|
+
| `crypto:encrypt` | Crypto | Encryption/decryption |
|
|
254
|
+
| `crypto:keygen` | Crypto | Key generation |
|
|
255
|
+
| `storage:read` | Storage | Read local data |
|
|
256
|
+
| `storage:write` | Storage | Write local data |
|
|
257
|
+
| `storage:delete` | Storage | Delete local data |
|
|
258
|
+
| `compute:cpu` | Compute | CPU-intensive work |
|
|
259
|
+
| `compute:gpu` | Compute | WebGPU acceleration |
|
|
260
|
+
| `compute:wasm` | Compute | WASM module execution |
|
|
261
|
+
| `system:env` | System | Environment variables |
|
|
262
|
+
| `system:fs` | System | Filesystem access |
|
|
263
|
+
| `system:exec` | System | Execute commands (denied by default) |
|
|
264
|
+
|
|
265
|
+
### Quick Start with Plugins
|
|
266
|
+
|
|
267
|
+
```javascript
|
|
268
|
+
import { PluginManager } from '@ruvector/edge-net/plugins';
|
|
269
|
+
|
|
270
|
+
// Get plugin manager instance
|
|
271
|
+
const plugins = PluginManager.getInstance({
|
|
272
|
+
allowedTiers: ['stable', 'beta'],
|
|
273
|
+
verifySignatures: true,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// Load individual plugins
|
|
277
|
+
const compression = await plugins.load('core.compression');
|
|
278
|
+
const encryption = await plugins.load('crypto.e2e-encryption');
|
|
279
|
+
|
|
280
|
+
// Or load a bundle
|
|
281
|
+
await plugins.loadBundle('privacy-focused');
|
|
282
|
+
// Loads: compression, e2e-encryption, onion-routing, zk-proofs, pir
|
|
283
|
+
|
|
284
|
+
// Use plugins
|
|
285
|
+
const compressed = compression.compress(data);
|
|
286
|
+
const encrypted = encryption.encrypt('peer-123', sensitiveData);
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Available Bundles
|
|
290
|
+
|
|
291
|
+
| Bundle | Plugins | Use Case |
|
|
292
|
+
|--------|---------|----------|
|
|
293
|
+
| **minimal** | (none) | Bare-bones, maximum control |
|
|
294
|
+
| **standard** | compression, metrics, e2e-encryption | Typical usage |
|
|
295
|
+
| **privacy-focused** | compression, e2e-encryption, onion-routing, zk-proofs, pir | Maximum privacy |
|
|
296
|
+
| **ai-compute** | compression, federated-learning, swarm-intelligence, onnx-inference | AI workloads |
|
|
297
|
+
| **experimental** | All experimental tier plugins | Research & testing |
|
|
298
|
+
|
|
299
|
+
### CLI Commands
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
# List all plugins
|
|
303
|
+
edge-net plugins list
|
|
304
|
+
|
|
305
|
+
# Filter by category or tier
|
|
306
|
+
edge-net plugins list privacy
|
|
307
|
+
edge-net plugins list experimental
|
|
308
|
+
|
|
309
|
+
# Get plugin details
|
|
310
|
+
edge-net plugins info crypto.zk-proofs
|
|
311
|
+
|
|
312
|
+
# List bundles
|
|
313
|
+
edge-net plugins bundles
|
|
314
|
+
|
|
315
|
+
# Create custom plugin
|
|
316
|
+
edge-net plugins create my-plugin --category ai --tier experimental
|
|
317
|
+
|
|
318
|
+
# Validate plugin
|
|
319
|
+
edge-net plugins validate ./my-plugin/index.js
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Creating Custom Plugins
|
|
323
|
+
|
|
324
|
+
```javascript
|
|
325
|
+
import { BasePlugin, PluginCategory, PluginTier, Capability } from '@ruvector/edge-net/plugins/sdk';
|
|
326
|
+
|
|
327
|
+
class MyCustomPlugin extends BasePlugin {
|
|
328
|
+
static manifest = {
|
|
329
|
+
id: 'custom.my-plugin',
|
|
330
|
+
name: 'My Custom Plugin',
|
|
331
|
+
version: '1.0.0',
|
|
332
|
+
description: 'Does amazing things',
|
|
333
|
+
category: PluginCategory.AI,
|
|
334
|
+
tier: PluginTier.EXPERIMENTAL,
|
|
335
|
+
capabilities: [Capability.COMPUTE_WASM, Capability.NETWORK_CONNECT],
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
async onInit(config, sandbox) {
|
|
339
|
+
sandbox.require(Capability.COMPUTE_WASM);
|
|
340
|
+
this.ready = true;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
async process(data) {
|
|
344
|
+
// Your plugin logic
|
|
345
|
+
return { processed: true, data };
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Register with the plugin system
|
|
350
|
+
import { getRegistry } from '@ruvector/edge-net/plugins/sdk';
|
|
351
|
+
getRegistry().register(MyCustomPlugin);
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Security Features
|
|
355
|
+
|
|
356
|
+
| Feature | Implementation |
|
|
357
|
+
|---------|----------------|
|
|
358
|
+
| **Ed25519 Signatures** | All non-stable plugins must be cryptographically signed |
|
|
359
|
+
| **SHA-256 Checksums** | Verify plugin integrity before loading |
|
|
360
|
+
| **Rate Limiting** | 100 requests/minute per plugin to prevent DoS |
|
|
361
|
+
| **Capability Sandbox** | Plugins can only access declared capabilities |
|
|
362
|
+
| **Frozen Manifests** | Plugin metadata immutable after load |
|
|
363
|
+
| **HKDF Key Derivation** | Secure key generation with proper entropy |
|
|
364
|
+
| **Path Validation** | Prevent directory traversal attacks |
|
|
365
|
+
| **Trusted Authors** | Public key registry for verified developers |
|
|
366
|
+
|
|
367
|
+
### Plugin Failure Semantics
|
|
368
|
+
|
|
369
|
+
Plugins operate under explicit failure constraints to prevent ecosystem fragility:
|
|
370
|
+
|
|
371
|
+
- **Silent degradation**: Plugins may fail, be unloaded, or be rate-limited without warning to the caller
|
|
372
|
+
- **Core isolation**: Network liveness, task routing, and credit settlement never depend on plugin success
|
|
373
|
+
- **No blocking**: Plugins cannot block core operations; timeouts are enforced at the sandbox level
|
|
374
|
+
|
|
375
|
+
### Built-in Plugin Implementations
|
|
376
|
+
|
|
377
|
+
| Plugin | Description | Performance |
|
|
378
|
+
|--------|-------------|-------------|
|
|
379
|
+
| **compression** | LZ4/Zstd compression | 354 MB/s |
|
|
380
|
+
| **e2e-encryption** | AES-256-GCM with HKDF | 54K ops/sec |
|
|
381
|
+
| **federated-learning** | Byzantine-tolerant FL | 12.7M samples/sec |
|
|
382
|
+
| **reputation-staking** | Stake-weighted trust | Instant |
|
|
383
|
+
| **swarm-intelligence** | PSO/GA/DE/ACO optimization | 19K iter/sec |
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Core Invariants
|
|
388
|
+
|
|
389
|
+
> *Cogito, Creo, Codex* — The system thinks collectively, creates through contribution, and codifies trust in cryptographic proof.
|
|
390
|
+
|
|
391
|
+
These rules are not configurable. They define what Edge-net *is*.
|
|
392
|
+
|
|
393
|
+
| Invariant | Constraint |
|
|
394
|
+
|-----------|------------|
|
|
395
|
+
| **Network liveness without plugins** | The network must route tasks, settle credits, and maintain connections with zero plugins loaded. Plugins extend; they never enable. |
|
|
396
|
+
| **Economic settlement isolation** | rUv minting, burning, and settlement are core-only operations. Economic plugins may observe, suggest, or model—but never execute settlement. |
|
|
397
|
+
| **Identity persistence and decay** | Identities are permanent once created, but reputation decays without activity. New identities face a warm-up curve before full participation. |
|
|
398
|
+
| **Verifiable work or no reward** | Credit issuance requires cryptographic proof of work completion. Unverifiable claims are rejected, not trusted. |
|
|
399
|
+
| **Degradation over halt** | The system degrades gracefully under load, attack, or partial failure. It never halts. Consistency is sacrificed before availability. |
|
|
400
|
+
|
|
401
|
+
### Economic Boundaries
|
|
402
|
+
|
|
403
|
+
The credit system is explicitly **not extensible**:
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
407
|
+
│ ECONOMIC SETTLEMENT BOUNDARY │
|
|
408
|
+
├─────────────────────────────────────────────────────────────────────────────┤
|
|
409
|
+
│ │
|
|
410
|
+
│ CORE (immutable) PLUGINS (observable only) │
|
|
411
|
+
│ ┌─────────────────────────┐ ┌─────────────────────────┐ │
|
|
412
|
+
│ │ • rUv minting │ │ • Pricing suggestions │ │
|
|
413
|
+
│ │ • rUv burning │ ──► │ • Reputation scoring │ │
|
|
414
|
+
│ │ • Credit settlement │ read │ • Economic modeling │ │
|
|
415
|
+
│ │ • Balance enforcement │ only │ • Auction mechanisms │ │
|
|
416
|
+
│ │ • Slashing execution │ │ • AMM simulations │ │
|
|
417
|
+
│ └─────────────────────────┘ └─────────────────────────┘ │
|
|
418
|
+
│ │
|
|
419
|
+
│ Plugins CANNOT: mint, burn, transfer, or settle credits directly │
|
|
420
|
+
│ │
|
|
421
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Identity Anti-Sybil Measures
|
|
425
|
+
|
|
426
|
+
New identities face friction to prevent plugin marketplace Sybil attacks:
|
|
427
|
+
|
|
428
|
+
| Mechanism | Description |
|
|
429
|
+
|-----------|-------------|
|
|
430
|
+
| **Delayed activation** | 24-hour window before full task execution privileges |
|
|
431
|
+
| **Reputation warm-up** | Linear ramp from 0.1 to 1.0 reputation over first 100 tasks |
|
|
432
|
+
| **Stake requirement** | Optional stake to unlock higher task priority (slashable) |
|
|
433
|
+
| **Witness diversity** | Task results require confirmation from identities with independent creation times |
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
168
437
|
## What is Edge-Net?
|
|
169
438
|
|
|
170
439
|
Edge-net creates a **collective computing network** where participants share idle browser resources to power distributed AI workloads. Think of it as a cooperative where:
|
|
@@ -1433,6 +1702,8 @@ Edge-net is a **research platform** for collective computing. The rUv units are:
|
|
|
1433
1702
|
- Used for balancing contribution and consumption
|
|
1434
1703
|
- Not redeemable for money or goods outside the network
|
|
1435
1704
|
|
|
1705
|
+
**Edge-net makes no correctness claims. All results are challengeable.** The system optimizes for coherence and availability, not guaranteed correctness. Disputes are resolved through cryptographic evidence and stake-weighted arbitration, not authority.
|
|
1706
|
+
|
|
1436
1707
|
---
|
|
1437
1708
|
|
|
1438
1709
|
## Links
|