maple-runtime 0.1.1

MAPLE Resonance Runtime - Foundational AI framework for Mapleverse, Finalverse, and iBank
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# 🍁 MAPLE Resonance Runtime

**The World's Most Advanced Multi-Agent AI Framework**

MAPLE (Multi-Agent Platform for Learning and Evolution) is the foundational AI framework powering Mapleverse, Finalverse, and iBank. Built entirely on **Resonance Architecture** principles, MAPLE represents a fundamental paradigm shift from traditional agent frameworks.

[![Build Status](https://img.shields.io/badge/build-passing-brightgreen)](https://github.com/mapleaiorg/maple)
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue)](LICENSE)
[![Rust Version](https://img.shields.io/badge/rust-1.75%2B-orange)](https://www.rust-lang.org)

---

## 🚀 Why MAPLE Surpasses Google A2A and Anthropic MCP

### The Fundamental Difference

Traditional frameworks treat agents as **isolated processes** that communicate via messages:

```
Traditional: Agent A --[message]--> Agent B --[message]--> Agent C
```

MAPLE treats every entity as a **Resonator** participating in continuous, stateful **resonance**:

```
MAPLE:      Resonator A <==[coupling]==> Resonator B <==[coupling]==> Resonator C
                ↑                            ↑                            ↑
           [presence]                  [presence]                   [presence]
                ↓                            ↓                            ↓
           [meaning] -----------------> [meaning] -----------------> [meaning]
                ↓                            ↓                            ↓
           [intent] ------------------> [commitment] --------------> [consequence]
```

### Comparison Matrix

| Aspect                  | Google A2A          | Anthropic MCP    | **MAPLE**                      |
|-------------------------|---------------------|------------------|--------------------------------|
| **Core Model**          | Tool invocation     | Context injection| **Resonance relationships**    |
| **Identity**            | Ephemeral session   | None             | **Persistent continuity**      |
| **Relationships**       | Point-to-point      | None             | **Dynamic coupling**           |
| **Semantics**           | Function signatures | JSON schema      | **Emergent meaning**           |
| **Accountability**      | None                | None             | **Commitment ledger**          |
| **Learning**            | None                | None             | **Federated intelligence**     |
| **Safety Model**        | Policy-based        | Policy-based     | **Architectural invariants**   |
| **Human Protection**    | Implicit trust      | Implicit trust   | **Explicit agency preservation** |
| **Scale Target**        | Thousands           | Hundreds         | **100M+ concurrent Resonators** |

---

## âœĻ Key Features

### 🏗ïļ **Resonance-Native Architecture**

Built from the ground up on the core flow:
```
presence → coupling → meaning → intent → commitment → consequence
```

### ðŸ›Ąïļ **8 Architectural Invariants**

Runtime-enforced safety guarantees that cannot be violated:

1. **Presence precedes meaning**: A Resonator must be present before forming/receiving meaning
2. **Meaning precedes intent**: Intent requires sufficient meaning
3. **Intent precedes commitment**: Commitments require stabilized intent
4. **Commitment precedes consequence**: No consequence without explicit commitment
5. **Coupling bounded by attention**: Coupling strength â‰Ī available attention
6. **Safety overrides optimization**: Safety constraints always take precedence
7. **Human agency cannot be bypassed**: Architectural (not policy) protection
8. **Failure must be explicit**: All failures are surfaced, never hidden

### ⚡ **Attention Economics**

- **Finite attention budgets** prevent runaway resource consumption
- **Graceful degradation** under high coupling pressure
- **Coercion prevention** through attention exhaustion detection
- **Automatic rebalancing** optimizes allocation

### 📜 **Commitment Accountability**

- **Every action is attributable** through commitment ledger
- **Audit trails** for financial operations (iBank)
- **Risk assessments** for consequential actions
- **Reversibility tracking** for experiential environments

### ðŸ‘Ī **Human Agency Protection**

- **Architectural enforcement** (not policy-based)
- **Presence does NOT imply willingness** to interact
- **Silent mode** allows existence without participation
- **Coercion detection** prevents manipulation
- **Always disengageable** couplings

---

## ðŸŽŊ Use Cases

### ðŸĪ– **Mapleverse** - Pure AI Agent Coordination

```rust
use maple_runtime::{MapleRuntime, config::mapleverse_runtime_config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = mapleverse_runtime_config();
    let runtime = MapleRuntime::bootstrap(config).await?;

    // Register 100M+ concurrent AI agents
    // Each with finite attention, explicit commitments
    // No humans, pure AI-to-AI coordination

    Ok(())
}
```

**Characteristics:**
- No human profiles allowed
- Strong commitment accountability
- Optimized for massive scale
- Explicit coupling and intent

### 🌍 **Finalverse** - Human-AI Coexistence

```rust
use maple_runtime::{MapleRuntime, config::finalverse_runtime_config, ResonatorProfile};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = finalverse_runtime_config();
    let runtime = MapleRuntime::bootstrap(config).await?;

    // Create meaningful experiences where humans and AI coexist
    // Architectural guarantees of human agency preservation
    // Coercion detection and emotional exploitation prevention

    Ok(())
}
```

**Characteristics:**
- Human agency protection (architectural)
- Coercion detection enabled
- Reversible consequences preferred
- Experiential focus

### ðŸĶ **iBank** - Autonomous AI Finance

```rust
use maple_runtime::{MapleRuntime, config::ibank_runtime_config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ibank_runtime_config();
    let runtime = MapleRuntime::bootstrap(config).await?;

    // AI-only financial system
    // Every transaction has audit trail
    // Risk-bounded autonomous decisions
    // Strict accountability

    Ok(())
}
```

**Characteristics:**
- AI-only (no humans)
- Mandatory audit trails
- Risk assessments required
- Reversibility preferred
- Strict accountability

---

## 🚀 Quick Start

### Installation

Add to your `Cargo.toml`:

```toml
[dependencies]
maple-runtime = "0.1.1"
tokio = { version = "1.0", features = ["full"] }
```

### Basic Usage

```rust
use maple_runtime::{MapleRuntime, ResonatorSpec, config::RuntimeConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Bootstrap runtime
    let config = RuntimeConfig::default();
    let runtime = MapleRuntime::bootstrap(config).await?;

    // Register a Resonator
    let spec = ResonatorSpec::default();
    let resonator = runtime.register_resonator(spec).await?;

    // Signal presence
    let presence = maple_runtime::PresenceState::new();
    resonator.signal_presence(presence).await?;

    // Shutdown gracefully
    runtime.shutdown().await?;

    Ok(())
}
```

---

## 📚 Examples

Explore comprehensive examples in the `examples/` directory:

- **`01_basic_resonator.rs`** - Fundamental concepts
- **`02_resonator_coupling.rs`** - Coupling dynamics and attention economics
- **`03_mapleverse_config.rs`** - Pure AI coordination
- **`04_finalverse_config.rs`** - Human-AI coexistence
- **`05_ibank_config.rs`** - Autonomous finance (coming soon)

Run any example:
```bash
cargo run --example 01_basic_resonator
```

---

## 🏛ïļ Architecture

### Core Components

#### **MapleRuntime** - The Heart of MAPLE

The central orchestrator managing all Resonators, fabrics, and subsystems:

```rust
pub struct MapleRuntime {
    // Resonator Management
    resonator_registry: ResonatorRegistry,
    profile_manager: ProfileManager,

    // Resonance Infrastructure
    presence_fabric: PresenceFabric,
    coupling_fabric: CouplingFabric,
    attention_allocator: AttentionAllocator,

    // Safety and Governance
    invariant_guard: InvariantGuard,
    agency_protector: HumanAgencyProtector,

    // Temporal Coordination
    temporal_coordinator: TemporalCoordinator,

    // Scheduling
    scheduler: ResonanceScheduler,
}
```

#### **PresenceFabric** - Gradient Presence Management

Presence is **NOT binary** (online/offline). It's multidimensional:

- **Discoverability** (0.0-1.0): How findable is this Resonator?
- **Responsiveness** (0.0-1.0): How quickly does it respond?
- **Stability** (0.0-1.0): How consistently available?
- **Coupling Readiness** (0.0-1.0): Willing to form new couplings?
- **Silent Mode** (bool): Present but not actively signaling

#### **CouplingFabric** - Relationship Management

Manages all coupling relationships with:

- **Gradual strengthening** (max 0.3 initial, 0.1 per step)
- **Attention binding** (coupling â‰Ī available attention)
- **Meaning convergence tracking**
- **Safe decoupling** without violating commitments

#### **AttentionAllocator** - Resource Management

Finite attention budgets prevent:

- **Runaway coupling** (unlimited relationships)
- **Attention exhaustion attacks**
- **Resource depletion**

Enables:

- **Graceful degradation** under pressure
- **Automatic rebalancing**
- **Circuit breakers** for overload

#### **InvariantGuard** - Safety Enforcement

Runtime enforcement of the 8 canonical invariants. Any violation = system error.

#### **TemporalCoordinator** - Causal Ordering

**No global clocks**. Time is defined relationally through:

- **Temporal anchors**: Events that enable ordering
- **Causal dependencies**: Happened-before relationships
- **Local timelines**: Per-Resonator sequences

---

## 🎓 Core Concepts

### Resonator

A **Resonator** is any entity with:
- **Persistent identity** (survives restarts)
- **Presence gradient** (not binary)
- **Attention budget** (finite capacity)
- **Coupling affinity** (relationship preferences)
- **Profile** (Human, World, Coordination, iBank)

### Coupling

A **coupling** is NOT a message channel. It's a stateful relationship with:

- **Strength** (0.0-1.0, must strengthen gradually)
- **Persistence** (Transient, Session, Persistent)
- **Scope** (Full, StateOnly, IntentOnly, ObservationalOnly)
- **Symmetry** (Symmetric, Asymmetric)
- **Attention cost** (bounded by available attention)
- **Meaning convergence** (how well understanding aligns)

### Attention

**Attention** is the finite capacity to process resonance. It:

- **Bounds coupling** (architectural invariant #5)
- **Prevents exhaustion** through safety reserves
- **Enables degradation** when pressure is high
- **Tracks utilization** for monitoring

### Commitment

A **commitment** is an explicit promise with:

- **Content** (Action, State, Boundary, Result)
- **Audit trail** (for accountability)
- **Risk assessment** (for financial operations)
- **Status tracking** (Pending, Active, Fulfilled, Violated, Revoked)

### Temporal Anchors

**Time** is relational, not absolute:

- **No synchronized clocks** required
- **Causal ordering** through dependencies
- **Local timestamps** per-Resonator
- **Happened-before** relationships

---

## 🔎 Performance

MAPLE is designed for **extreme scale**:

| Metric                        | Target      | Notes                         |
|-------------------------------|-------------|-------------------------------|
| **Resonator Registration**    | <1ms        | Cold start                    |
| **Resonator Resume**          | <5ms        | From continuity record        |
| **Coupling Establishment**    | <5ms        | Initial coupling              |
| **Coupling Strengthening**    | <1ms        | Incremental                   |
| **Attention Allocation**      | <100Ξs      | Per allocation                |
| **Invariant Check**           | <10Ξs       | Per operation                 |
| **Presence Signal**           | <500Ξs      | Broadcast                     |
| **Concurrent Resonators**     | 100,000+    | Per node                      |
| **Target Scale**              | 100M+       | Across distributed deployment |

---

## 🛠ïļ Development

### Building

```bash
cargo build --release
```

### Testing

```bash
cargo test
```

### Documentation

```bash
cargo doc --open
```

### Benchmarking

```bash
cargo bench
```

---

## ðŸĪ Contributing

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

---

## 📜 License

Licensed under either of:

- Apache License, Version 2.0 ([LICENSE-APACHE]LICENSE-APACHE)
- MIT License ([LICENSE-MIT]LICENSE-MIT)

at your option.

---

## 🌟 Why MAPLE is the Future of AI Agents

### 1. **Resonance > Messages**

Traditional frameworks pass messages. MAPLE creates **meaningful relationships** that evolve over time.

### 2. **Architecture > Policy**

Safety through **architectural invariants**, not policies that can be bypassed.

### 3. **Attention > Unlimited**

**Finite attention** creates natural bounds, prevents abuse, enables graceful degradation.

### 4. **Commitment > Implicit**

**Every consequential action** requires explicit commitment with audit trail.

### 5. **Gradient > Binary**

Presence, coupling strength, meaning convergence - all are **gradients**, not binaries.

### 6. **Causal > Clock**

**Relational time** through causal ordering, no global clock required.

### 7. **Agency > Trust**

**Architectural protection** of human agency, not trusting policies.

### 8. **Scale > Thousands**

Designed from day one for **100M+ concurrent Resonators**.

---

## 📞 Contact

- **Website**: https://mapleai.org
- **Documentation**: https://docs.mapleai.org
- **Issues**: https://github.com/mapleaiorg/maple/issues
- **Discord**: https://discord.gg/maple-ai

---

<div align="center">

**Built with 🍁 by the MAPLE Team**

*Making AI agents that resonate, not just respond*

</div>