Memory Arenas
Memory Arenas
Section titled “Memory Arenas”MindFry uses arenas — pre-allocated memory pools — for zero-GC performance.
Psyche Arena
Section titled “Psyche Arena”The Psyche Arena stores active lineages in a contiguous memory block.
pub struct PsycheArena { data: Vec<Lineage>, generations: Vec<u32>, free_list: Vec<usize>,}Operations
Section titled “Operations”| Operation | Complexity | Description |
|---|---|---|
create | O(1) | Pop from free list |
get | O(1) | Direct index access |
remove | O(1) | Push to free list |
Generational IDs
Section titled “Generational IDs”To prevent use-after-free bugs, IDs include a generation:
pub struct LineageId { index: u32, generation: u32,}Strata Arena
Section titled “Strata Arena”The Strata Arena stores historical engrams in ring buffers.
pub struct StrataArena { rings: Vec<RingBuffer<Engram>>, depth: usize, // Default: 64}Each lineage has a fixed-depth history. When full, oldest entries are overwritten.
Bond Graph
Section titled “Bond Graph”The Bond Graph uses Compressed Sparse Row (CSR) format for efficient traversal.
Adjacency Matrix (dense): CSR (sparse): A B C D values: [0.8, 0.6, 0.5]A [ 0 .8 0 0 ] col_idx: [1, 2, 3]B [ 0 0 .6 0 ] row_ptr: [0, 1, 2, 3]C [ 0 0 0 .5 ]D [ 0 0 0 0 ]See Dynamics for how decay and propagation work.