remove hardcoded skip lists, prune orphan edges in fsck
All nodes in the store are memory — none should be excluded from knowledge extraction, search, or graph algorithms by name. Removed the MEMORY/where-am-i/work-queue/work-state skip lists entirely. Deleted where-am-i and work-queue nodes from the store (ephemeral scratchpads that don't belong). Added orphan edge pruning to fsck so broken links get cleaned up automatically. Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
parent
70c0276fa0
commit
fd5591653d
4 changed files with 23 additions and 26 deletions
25
src/main.rs
25
src/main.rs
|
|
@ -416,18 +416,31 @@ fn cmd_fsck() -> Result<(), String> {
|
|||
store::fsck()?;
|
||||
store::strip_md_keys()?;
|
||||
|
||||
// Check for broken links
|
||||
let store = store::Store::load()?;
|
||||
let mut orphans = 0usize;
|
||||
// Prune broken links (relations referencing deleted/missing nodes)
|
||||
let mut store = store::Store::load()?;
|
||||
let mut to_tombstone = Vec::new();
|
||||
for rel in &store.relations {
|
||||
if rel.deleted { continue; }
|
||||
if !store.nodes.contains_key(&rel.source_key)
|
||||
|| !store.nodes.contains_key(&rel.target_key) {
|
||||
orphans += 1;
|
||||
let mut tombstone = rel.clone();
|
||||
tombstone.deleted = true;
|
||||
tombstone.version += 1;
|
||||
to_tombstone.push(tombstone);
|
||||
}
|
||||
}
|
||||
if orphans > 0 {
|
||||
eprintln!("{} broken links (run `health` for details)", orphans);
|
||||
if !to_tombstone.is_empty() {
|
||||
let count = to_tombstone.len();
|
||||
store.append_relations(&to_tombstone)?;
|
||||
for t in &to_tombstone {
|
||||
if let Some(r) = store.relations.iter_mut().find(|r|
|
||||
r.source == t.source && r.target == t.target && !r.deleted) {
|
||||
r.deleted = true;
|
||||
r.version = t.version;
|
||||
}
|
||||
}
|
||||
store.save()?;
|
||||
eprintln!("Pruned {} broken links", count);
|
||||
} else {
|
||||
eprintln!("No broken links");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue