Gnosis
Distributed knowledge graph storing (subject, predicate, object) triples on a Strand log.
What Gnosis is
Gnosis is an RDF-style triple store: every fact is a (subject, predicate, object) triple of UTF-8 strings. Triples are appended to a Strand and indexed on each of the three positions for fast pattern matching.
Three DashMap<String, Vec<u64>> indices are maintained in memory — one for subjects, one for predicates, one for objects. A query that fixes any subset of the three positions performs an intersection of the matching sequence number sets, then fetches each triple from the Strand.
Gnosis is the right primitive when:
- You need durable, replicable facts with a clean query model.
- Facts are short strings and the graph is read-heavy.
- You want graph reasoning composable with other Weave primitives (Strand for audit, Basis for semantic recall, Forum for fact pickup).
When to use Gnosis
| Workload | Gnosis fit |
|---|---|
| Agent memory of typed relationships ("Alice trusts Bob") | Strong |
| Local-first knowledge graph for RAG | Strong |
| Lineage/provenance audit | Strong |
| OWL/SPARQL-grade reasoning | Out of scope; combine with an external reasoner |
| Numeric facts (use floats, ranges) | Weak — strings only; encode at the caller |
Triple model
pub struct Triple {
pub subject: String,
pub predicate: String,
pub object: String,
}All three fields are owned Strings. The Strand block for a triple is the serde_json encoding of this struct.
Query model
pub struct QueryPattern {
pub subject: Option<String>,
pub predicate: Option<String>,
pub object: Option<String>,
}None is a wildcard. Some(s) is an exact match on that position. An all-None pattern returns every triple — useful for diagnostics, not for production.
At a glance
| Field | Value |
|---|---|
| Crate/package | weave-gnosis |
| Version | 0.1.0 |
| Source | models/gnosis |
| Backing log | One strand::Strand |
| Indices | Three DashMap<String, Vec<u64>> (S, P, O) |
| Encoding | serde_json |
| Async | tokio |
Page map
Insert (subject, predicate, object) triples.
Match patterns across the triple store.
Walk relationships across triples.
Best practices for triple schemas.
Compose this primitive through WeaveNode.
Implementation notes and design rationale.
Complete ledger of exported types, traits, and functions.
Source modules
src/lib.rs— models/gnosis/src/lib.rs