ucm-graph-core
Core graph types, entity model, and confidence math for the Unified Context Management (UCM) engine.
ucm-graph-core is the foundation crate of the UCM workspace. It defines the
identity scheme, the relationship model, the probabilistic confidence functions,
and the in-memory graph that every other crate builds on. It has no I/O and no
async — it is pure data structures and math, so it stays fast and easy to test.
What it does
- Stable entity identity —
EntityIduses a SCIP-style scheme (scheme:package:descriptor) so an entity keeps the same identity across re-indexing runs, enabling independent file re-ingestion without rewriting the graph. - Typed entities & relationships —
UcmEntity/EntityKind(Function, ApiEndpoint, DataModel, Feature, TestCase, Requirement, Module, …) andUcmEdge/RelationType(Imports, Calls, TestedBy, Implements, DependsOn, CoChanged, …). - Calibrated confidence — every edge carries a confidence score fused from multiple
EvidenceSources via Noisy-OR, with temporal decay so stale evidence loses weight. - Mutable graph —
UcmGraphwraps a petgraphStableGraphwith an entity index and Glean-style file ownership tracking, so a single file can be invalidated and re-added.
Quick example
use ;
let mut graph = new;
let token_id = new;
let pay_id = new;
graph.upsert_entity;
graph.upsert_entity;
// Link them with an evidence-backed, confidence-scored edge.
let edge = new;
graph.add_relationship.unwrap;
println!;
Confidence math
use ;
// Two independent sources confirming the same edge compound, not cancel.
let fused = noisy_or; // ≈ 0.94, not 0.56
// Evidence decays exponentially with time since it was last verified.
// temporal_decay(base_confidence, lambda, days_since_verification)
let decayed = temporal_decay;
Where it fits
ucm-graph-core ← you are here (types + math, no I/O)
├── ucm-events event sourcing / projection
├── ucm-ingest parsers & adapters that produce entities/edges
├── ucm-reason impact analysis & test intent over the graph
├── ucm-observe decision traces & replay
└── ucm-api HTTP surface
Research foundations
- Calibrated trust — Google Knowledge Vault (KDD 2014): multi-source fusion where agreement compounds confidence.
- Stable identity — Sourcegraph SCIP code-intelligence protocol.
- Ownership tracking — Meta Glean incremental indexing.
License
MIT — see LICENSE.