pub struct PenroseMemory { /* private fields */ }Expand description
Aperiodic memory palace navigated by dead reckoning.
Embeddings are projected to 2D Penrose coordinates using golden-ratio hashing. The Fibonacci word determines tile bits. Recall walks from query toward stored memories via dead reckoning.
Implementations§
Source§impl PenroseMemory
impl PenroseMemory
Sourcepub fn new(embedding_dim: usize) -> Self
pub fn new(embedding_dim: usize) -> Self
Create a new PenroseMemory with the given embedding dimension.
Sourcepub fn store(&mut self, embedding: &[f64], content: u64) -> u64
pub fn store(&mut self, embedding: &[f64], content: u64) -> u64
Store an embedding with associated content.
Projects the embedding to 2D Penrose coordinates and stores it. Returns the tile_id.
Sourcepub fn recall(&self, query: &[f64], max_steps: usize) -> Vec<RecallResult>
pub fn recall(&self, query: &[f64], max_steps: usize) -> Vec<RecallResult>
Recall memories by dead reckoning from a query embedding.
Projects the query to 2D, then finds the closest stored tiles. Dead reckoning: we walk from the query point toward stored memories, measuring distance and confidence at each step.
max_steps controls how many intermediate waypoints to check along
the path to each candidate.
Navigate from a tile by distance and heading.
Dead reckoning navigation: start from the given tile, walk the specified distance at the given heading, and find tiles near the destination. Returns tile IDs of tiles found within the arrival radius.
Sourcepub fn consolidate(&mut self)
pub fn consolidate(&mut self)
Consolidate (deflate) old memories using golden hierarchy.
Tiles at level 0 that are close together (within φ^1 distance) are merged into a single tile at level 1. The merged content is XOR’d. Returns the number of tiles removed.
Sourcepub fn matching_rule_holds(&self, qx: i64, qy: i64) -> bool
pub fn matching_rule_holds(&self, qx: i64, qy: i64) -> bool
Check matching rules at a lattice position. A tile matches if it has at least one neighbor of the opposite type.
Sourcepub fn get_tile_bit(&self, qx: i64, qy: i64) -> bool
pub fn get_tile_bit(&self, qx: i64, qy: i64) -> bool
Get the golden-ratio hash bit for a position.
Sourcepub fn supersede_tile(&mut self, tile_id: u64) -> Option<u64>
pub fn supersede_tile(&mut self, tile_id: u64) -> Option<u64>
Supersede a tile — mark old as Superseded, return its content.
Sourcepub fn retract_tile(&mut self, tile_id: u64) -> bool
pub fn retract_tile(&mut self, tile_id: u64) -> bool
Retract a tile — mark as Retracted with reason.
Sourcepub fn active_tile_ids(&self) -> Vec<u64>
pub fn active_tile_ids(&self) -> Vec<u64>
Get only active tile IDs.
Sourcepub fn lifecycle_stats(&self) -> (usize, usize, usize)
pub fn lifecycle_stats(&self) -> (usize, usize, usize)
Count tiles by lifecycle state.
Sourcepub fn predict_recall(
&self,
query: &[f64],
clock: &mut LamportClock,
) -> MemoryPrediction
pub fn predict_recall( &self, query: &[f64], clock: &mut LamportClock, ) -> MemoryPrediction
Predict where a memory will be found before walking there. Uses the same projection as recall but without executing the walk.
Sourcepub fn confirm_prediction(
&self,
prediction: &mut MemoryPrediction,
actual: &[RecallResult],
) -> bool
pub fn confirm_prediction( &self, prediction: &mut MemoryPrediction, actual: &[RecallResult], ) -> bool
Confirm a prediction against actual recall results.