mindfry 1.9.0

Memory with a Conscience
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
# Changelog


All notable changes to this project will be documented in this file.

## [1.9.0] - 2026-01-25


### šŸ“¦ Sparse Snapshot Format - "Portable Memory"


Snapshot size reduced from 1.5GB to ~100 bytes for empty arenas.

### Changed


- **StrataArena Serialization**: Only non-empty engrams are serialized
  - INVARIANT: `timestamp == 0` means "empty slot" (now part of ABI)
  - Added `StrataArena::set_at()` and `restore_from_sparse()` for restoration
- **zstd Compression**: All strata data compressed with zstd level 3
- **Format v2**: New snapshot format with sparse representation

### Breaking


> [!WARNING]
> v1.9.0 snapshots are NOT backward compatible with v1.8.0.
> v1.9.0 CAN read v1.8.0 snapshots and auto-migrates on save.

### Technical


- 90/90 tests passing (+1 sparse size reduction test)
- Empty 10KƗ64 arena: 15MB → ~100 bytes (>99.99% reduction)

---

## [1.8.0] - 2026-01-25


### 🩹 Crash Recovery - "Trauma-Aware Restart"


MindFry now remembers how it was shut down and adapts accordingly.

### Added


- **`recovery.rs`**: Trauma detection on startup
  - `RecoveryState::Normal` — Clean restart
  - `RecoveryState::Shock` — Unclean shutdown (no graceful marker)
  - `RecoveryState::Coma` — Prolonged downtime (>1 hour)
- **`RecoveryAnalyzer`**: Analyzes shutdown marker on startup
- **`ShutdownMarker`**: Persisted to sled before graceful exit
- **Warmup Enforcement**: Handler rejects ops during resurrection
  - `Ping` and `Stats` always allowed (exempt)
  - Other ops return `ErrorCode::WarmingUp`
- **Stability Benchmark**: 10 new benchmarks, all sub-microsecond
  - `recovery_analyzer_analyze`: 1.21 ns
  - `warmup_tracker_is_ready`: 1.19 ns
  - `exhaustion_level_from_energy`: 715 ps

### Changed


- `CommandHandler` now accepts `WarmupTracker` via `with_warmup()`
- `AkashicStore` has `read_shutdown_marker()` / `write_shutdown_marker()`

### Technical


- 89/89 tests passing (+6 recovery tests)
- Server startup shows recovery state: `(clean)`, `(SHOCK detected)`, `(COMA detected)`

---

## [1.7.0] - 2026-01-24


### šŸ›”ļø Stability Layer - "Self-Healing Infrastructure"


Zero startup delay with async resurrection and progressive availability.

### Added


- **Stability Module** (`src/stability/`):
  - `exhaustion.rs`: Circuit breaker with adaptive thresholds (μ±kσ AutoTuner)
  - `health.rs`: Self-diagnostic pulse monitoring
  - `shutdown.rs`: Shutdown experience recording (graceful/forced/crash/coma)
  - `warmup.rs`: Progressive availability tracking during resurrection
- **System Lineages** (`_system.*`): Reserved namespace for stability tracking
  - `_system.health`, `_system.state`, `_system.shock`, `_system.coma`
- **Background Snapshot Loading**: Server accepts connections immediately
  - Network binds in < 100ms
  - Resurrection runs in async background thread
- **`ErrorCode::WarmingUp` (0x03)**: New error code for clients during resurrection
- **Exhaustion Backpressure**: Write rejection under high load
- **Graceful Shutdown**: Ctrl+C handling with pre-shutdown snapshot

### Technical


- 83/83 tests passing
- 1.5 GB snapshot: ~5.4s async load (verified)

---

## [1.6.0] - 2026-01-17


### 🌱 Phase 5: Auto-Propagation - "Life Has Begun"


When `stimulate(A)` is called, energy automatically propagates through bonds.

### Added


- **SynapseEngine Integration**: Handler wires synapse.propagate() on stimulate
- **StimulateFlags**: Control propagation behavior
  - `0x00` (default): Auto-propagate through bonds
  - `0x01` `NO_PROPAGATE`: Surgical mode (direct update only)
- **The Domino Test**: A→B→C chain verification
  - A: +0.9 (direct)
  - B: +0.625 (hop 1, damped)
  - C: +0.250 (hop 2, damped) āœ“

### Technical


- Used raw pointer trick to bypass RwLockWriteGuard borrow checker limitation
- SAFETY: bonds are read-only during propagate, psyche is mutated

---

## [1.5.0] - 2026-01-17


### āš ļø Breaking Change: Response Framing


`LINEAGE.GET` response now includes status header for unambiguous client parsing.

### Changed


- **Response Format**: `[status:u8] + [payload?]`
  - `0x00` (Found): Full `LineageInfo` payload follows
  - `0x01` (NotFound): No payload, lineage doesn't exist
  - `0x02` (Repressed): No payload, hidden by Antagonism
  - `0x03` (Dormant): No payload, in retention buffer
- **`ResponseData::Lineage`** → **`ResponseData::LineageResult`**
- **`LineageResult`** struct: `{ status: LineageStatus, info: Option<LineageInfo> }`

### Why Breaking?


Previously, NotFound returned `Response::Error`. Now returns `Response::Ok(LineageResult { status: NotFound })`.
This enables richer client-side handling (distinguish "doesn't exist" from "hidden by system").

---

## [1.4.1] - 2026-01-17


### šŸ‘‘ Executive Override


User authority layer above cognitive filters for reliable data access.

### Added


- **`QueryFlags`**: Bitmask for access control
  - `BYPASS_FILTERS` (0x01): Skip Cortex/Antagonism filters
  - `INCLUDE_REPRESSED` (0x02): Reveal hidden data with REPRESSED status
  - `NO_SIDE_EFFECTS` (0x04): Read without observer effect
  - `FORENSIC` (0x07): All flags combined (god mode)
- **`LineageStatus`**: Rich result states
  - `Found` (0): Normal success
  - `NotFound` (1): Doesn't exist
  - `Repressed` (2): Hidden by Antagonism
  - `Dormant` (3): In retention buffer
- **Observer Effect**: `LINEAGE.GET` now stimulates memory on read (+0.01)

### Protocol


- `LINEAGE.GET` now accepts optional `flags:u8` (backward compat: default 0)

---

## [1.4.0] - 2026-01-17


### 🧠 Synaptic Evolution


Bonds now have polarity for biologically-inspired signal propagation.

### Added


- **`Bond.polarity`**: Ternary bond type (+1/0/-1)
  - `Trit::True` (+1): Synergy (excitatory) - both stimulate
  - `Trit::Unknown` (0): Neutral (insulator) - no propagation
  - `Trit::False` (-1): Antagonism (inhibitory) - suppression
- **`SynapseEngine`**: Damped signal propagation
  - Resistance: 0.5 (50% energy loss per hop)
  - Cutoff: 0.1 (noise floor)
  - Max depth: ~3 hops (mathematically bounded)
  - Loop protection via visited set

### Internal


- 74/74 tests passing (+4 synapse tests)
- Backward compatible: old bonds default to `polarity: Trit::True`

---

## [1.3.0] - 2026-01-17


### 🧬 Cortex Persistence


Nabu's identity (mood, personality) now survives server restarts.

### Added


- **Serde derives**: `Trit`, `Octet`, `Quantizer`, `Cortex`, `RetentionBuffer` now serializable
- **`cortex_data` in Snapshot**: Optional Cortex state preserved in snapshots
- **Mood-Coupled Sensitivity**: Consciousness sensitivity now varies with mood (0.5x-1.5x)
- **`LineageIndexer`**: O(1) key-to-id lookup via sled tree
  - `insert()`, `get()`, `remove()`, `rebuild()` methods
  - Integrated into `AkashicStore` with `indexer()` accessor
- **Resurrection Protocol**: Server boot restores from latest snapshot
  - `MindFry::resurrect()` - restore Cortex + Lineages + Bonds
  - `MindFry::with_store()` - attach persistent storage
  - Graceful degradation on corrupted snapshots

### Changed


- `take_snapshot()` now accepts optional `Cortex` parameter
- Base consciousness sensitivity reduced from 10.0 to 5.0 for mood modulation

### Internal


- 70/70 tests passing
- Backward compatible: old snapshots load with `cortex_data: None`

---

## [1.2.1] - 2026-01-17


### šŸ”§ Bug Fix: Consciousness Threshold Tuning


Fixed edge case where energy 0.95 with threshold 0.8 was classified as "Dreaming" instead of "Lucid".

### Added


- **`SysMoodSet` OpCode (0x46)**: External mood injection from NABU
  - Payload: `[mood: f32]` (-1.0 to +1.0)
  - Enables real-time emotional state control

### Fixed


- **Consciousness amplification**: Delta now multiplied by 10x for clearer Lucid/Dreaming/Dormant decisions
  - `>3% above threshold` → Lucid (+1)
  - `<3% above threshold` → Dreaming (0)
  - `Below threshold` → Dormant (-1)

### Internal


- 66/66 tests passing
- E2E verified: 0.95 energy → LUCID

---

## [1.2.0] - 2026-01-17


### 🧠 NEW: Tri-Cortex Decision Engine (Setun Module)


Introduces balanced ternary logic primitives for organic decision-making.

### Added


- **`Trit` Primitive**: Balanced ternary digit (`-1 / 0 / +1`)
  - Biological semantics: Inhibition / Latent / Excitation
  - Operations: `consensus()` (AND), `invert()`, `weight()` (as i8)
  - Full conversions: `From<i8>`, `From<bool>`

- **`Octet` Vector**: 8-dimensional personality/event vector
  - Fixed dimensions: Curiosity, Preservation, Efficiency, Empathy, Rigidity, Volatility, Aggression, Latency
  - `resonance(&other)` → f64: Compatibility score (-1.0 to +1.0)
  - `dissonance(&other)` → f64: Conflict intensity (0.0 to 1.0)
  - `pack() / unpack()`: 8-bit binary serialization

- **`Quantizer` Struct**: Analog-to-Trit converter
  - Dynamic thresholds via `mood_modifier` (-1.0 to +1.0)
  - Positive mood → easier True; Negative mood → easier True=harder
  - `set_mood()` for external modulation (future NABU integration)

- **`Cortex` Struct**: The decision-making brain
  - Encapsulates system personality (Octet DNA)
  - Mood state with internal shift and external override
  - `consciousness_state()`: Ternary consciousness evaluation (Lucid/Dreaming/Dormant)
  - `decide()`: Mood-modulated analog-to-Trit conversion
  - `evaluate()`: Event resonance calculation
  - Integrated `RetentionBuffer` for safe garbage collection

- **`RetentionBuffer` Struct**: TTL-based data lifecycle management
  - Prevents mass extinction by debouncing deletion decisions
  - `mark_or_tick(id)`: Add to buffer or decrement TTL
  - `restore(id)`: Remove from buffer (data recovered)
  - Configurable TTL (default: 3 ticks)

- **`DecayEngine::process_gc()`**: Cortex-aware garbage collection
  - Ternary viability assessment (Stable/Unstable/Obsolete)
  - Personality-influenced preservation bias
  - Safe deletion via RetentionBuffer TTL

### Fixed


- Clippy warnings in `psyche.rs`, `decay.rs`, `bond.rs`, `handler.rs`

### Internal


- 27 new unit tests (Trit, Octet, Quantizer, Cortex, RetentionBuffer, GC)
- 66/66 total tests passing

---

## [1.0.0] - 2026-01-17


### šŸ¦€ MAJOR: Rust Pivot


MindFry has been rewritten in Rust as a standalone Cognitive Database Engine.

### Added


- **Core Engine**
  - `PsycheArena`: 32-byte cache-aligned Lineage storage with O(1) access
  - `StrataArena`: Ring buffer Engram history per lineage
  - `BondGraph`: Living bonds with Hebbian learning and decay
  - `DecayEngine`: Pre-computed LUT (256Ɨ32) for O(1) decay calculation
- **MFBP Protocol v1.0**: Binary wire protocol (22 OpCodes)
  - Lineage: `CREATE`, `GET`, `STIMULATE`, `FORGET`, `TOUCH`
  - Bond: `CONNECT`, `REINFORCE`, `SEVER`, `NEIGHBORS`
  - Query: `CONSCIOUS`, `TOP_K`, `TRAUMA`, `PATTERN`
  - System: `PING`, `STATS`, `SNAPSHOT`, `RESTORE`, `FREEZE`, `PHYSICS_TUNE`
  - Stream: `SUBSCRIBE`, `UNSUBSCRIBE`
- **Akashic Records**: sled-based persistence layer
  - Snapshot/Restore with bincode serialization
  - Named snapshots for Time Travel
- **TCP Server** (`mindfry-server`): Async Tokio server
- **CLI Client** (`mfcli`): Command-line interface for testing
- **Benchmarks**: Criterion benchmarks for decay and graph operations
- **CEREBRO Design Doc**: GUI visualization specification (commercial - separate repo)

### Changed


- **Technology**: TypeScript → Rust
- **Architecture**: Library → Database Engine
- **Structure**: Flattened repo (no more `mindfry-core/` subfolder)
- **Package**: Renamed `mindfry-core` → `mindfry`

### Removed


- Legacy TypeScript implementation

### Technical Decisions


| Decision    | Choice                   |
| ----------- | ------------------------ |
| Protocol    | Custom TCP Binary (MFBP) |
| Persistence | sled (Rust-native)       |
| Target      | Dual (Server + WASM)     |
| Integration | Network (TCP)            |

---

## [0.3.0] - 2026-01-14 [Legacy TypeScript]


### Added


- **Morpheus** (God of Dreams): Background maintenance layer
  - Event-hinted execution (not clock-driven)
  - Self-managed queue (no external enqueue API)
  - Atomic tasks: prune, transfer, consolidate (stub)
- **AkashicRecords**: Cold storage persistence
  - `inscribe()`: Memory → Archive
  - `retrieve()`: Archive → Memory (with accessScore decay)
  - MemoryAkashicBackend for testing
- Shell layer stats in demo (Morpheus state, Akashic count, Pressure)

### Changed


- **Mind → Psyche**: Main class renamed (backwards compat alias kept)
- Demo updated with mythological branding

## [0.2.1] - 2026-01-14 [Legacy TypeScript]


### Added


- **Decay Lookup Table**: Pre-computed exp() values (32 time buckets Ɨ 256 rates)
- **Epoch-bounded TopK Cache**: Only recomputes when state changes
- **Bond Density Cap**: Max 20 bonds per node
- **Performance metrics** in demo (JS Heap, Store Memory, Render Time)

### Changed


- `getEnergy()` now uses LUT instead of `Math.exp()`
- `topKConscious()` cached and invalidated on epoch change
- `createBond()` returns `null` if density cap exceeded

## [0.2.0] - 2026-01-14 [Legacy TypeScript]


### Added


- **Uint8Array Storage**: 4 bytes per memory (25x reduction)
- **Priming-based Auto-Association**: Automatic bonds on `remember()`
- **MemoryStore class**: Low-level typed array backend

### Changed


- Lazy decay model: energy computed on-demand
- `recall()` switched from async to sync iterator
- API: `remember(id, content, energy)` instead of object config

### Removed


- `tick()` method (no longer needed)
- Object-based Memory/Bond primitives

## [0.1.0] - 2026-01-14 [Legacy TypeScript]


### Added


- Initial implementation
- Memory/Bond primitives with object storage
- Mind core with conscious/subconscious layers
- Priming propagation
- Time skip demo