feat(fana): fana-store — persistencia del grafo narrativo (sled)
- fana-core: NarrativeAtom + CoherenceState ahora Serialize/Deserialize (serde con feature rc para el Arc<String>; uuid con feature serde). - fana-graph: + atoms() iterator + from_atoms() constructor. - fana-store: GraphStore sobre sled. put/get/remove_atom por Uuid, serialización bincode. save_graph persiste átomo por átomo; load_graph reconstruye el grafo (la adjacency se re-cablea desde las dependencies de cada átomo). 7 tests verdes (roundtrip put/get/remove + save/load_graph preserva estructura). cargo check --workspace verde. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,20 @@ impl NarrativeGraph {
|
||||
self.nodes.get_mut(&id)
|
||||
}
|
||||
|
||||
/// Itera todos los átomos del grafo (orden no determinista).
|
||||
pub fn atoms(&self) -> impl Iterator<Item = &NarrativeAtom> {
|
||||
self.nodes.values()
|
||||
}
|
||||
|
||||
/// Construye un grafo desde una colección de átomos.
|
||||
pub fn from_atoms(atoms: impl IntoIterator<Item = NarrativeAtom>) -> Self {
|
||||
let mut g = Self::new();
|
||||
for a in atoms {
|
||||
g.insert(a);
|
||||
}
|
||||
g
|
||||
}
|
||||
|
||||
/// Inserta un átomo y conecta las aristas desde sus dependencias.
|
||||
pub fn insert(&mut self, atom: NarrativeAtom) {
|
||||
let id = atom.id;
|
||||
|
||||
Reference in New Issue
Block a user