KeiSeiKit-1.0/_primitives/_rust/kei-curator/src/orphans.rs
Parfii-bot 0be354a920 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

22 lines
773 B
Rust

//! Prune orphan URIs — those that appear in `cross_edges` but have no in-edges.
//! Conservative: only removes edges where the tail URI has no other incoming edge.
use anyhow::Result;
use rusqlite::Connection;
pub fn prune_orphans(conn: &Connection) -> Result<usize> {
// Find URIs that appear as to_uri but also as from_uri with no other incoming
// => they are dead-ends. We remove edges where the outgoing side is orphan.
let deleted = conn.execute(
"DELETE FROM cross_edges
WHERE to_uri IN (
SELECT e1.from_uri FROM cross_edges e1
WHERE NOT EXISTS (
SELECT 1 FROM cross_edges e2
WHERE e2.to_uri = e1.from_uri
)
)",
[],
)?;
Ok(deleted)
}