pub struct Chronicle {
pub graph: StableGraph<Entity, Relationship>,
pub index: HashMap<String, NodeIndex>,
pub config: ValidationConfig,
}Expand description
The core chronicle graph.
Holds a heterogeneous StableGraph of Entity nodes connected by
Relationship edges, plus a string-to-index lookup map and a
ValidationConfig that governs policy decisions such as which statuses
are considered terminal.
Construct via Chronicle::from_directory (default config) or
Chronicle::from_directory_with_config (custom config). Both load every
.ron file under the conventional subdirectory layout (actors/, places/,
events/, concepts/, accounts/), insert nodes, and wire up edges in a
single pass.
Fields§
§graph: StableGraph<Entity, Relationship>The underlying directed graph. Nodes are Entity variants; edges are
Relationship variants that encode the kind and, where applicable,
the payload (role, sentiment, state-change) of each connection.
index: HashMap<String, NodeIndex>Maps every entity’s string id to its NodeIndex in the graph,
providing O(1) lookup by id.
config: ValidationConfigPolicy configuration used during validation — controls which
Status values are treated as terminal (e.g. Dead, Destroyed).
Implementations§
Source§impl Chronicle
impl Chronicle
Sourcepub fn from_directory(path: &Path) -> Result<Self, ChronicleError>
pub fn from_directory(path: &Path) -> Result<Self, ChronicleError>
Load all RON files from a directory, build the graph with default config.
Equivalent to calling from_directory_with_config
with ValidationConfig::default().
§Errors
Returns ChronicleError on I/O failures, RON parse errors, or
duplicate entity ids across files.
Sourcepub fn from_directory_with_config(
path: &Path,
config: ValidationConfig,
) -> Result<Self, ChronicleError>
pub fn from_directory_with_config( path: &Path, config: ValidationConfig, ) -> Result<Self, ChronicleError>
Load all RON files from a directory with a custom ValidationConfig.
Walks the conventional subdirectories (actors/, places/, events/,
concepts/, accounts/), deserialises every .ron file into the
corresponding entity type, inserts nodes, and then builds all edges in
a separate pass via build_edges.
§Errors
Returns ChronicleError on I/O failures, RON parse errors, or
duplicate entity ids.
Sourcepub fn validate(&self) -> ValidationReport
pub fn validate(&self) -> ValidationReport
Run all validation passes and return a ValidationReport.
The report aggregates referential-integrity, temporal-consistency, state-validity, and orphan-detection errors found in the graph.
Sourcepub fn can_add_event(&self, event: &Event) -> Result<(), Vec<ValidationError>>
pub fn can_add_event(&self, event: &Event) -> Result<(), Vec<ValidationError>>
Check whether a proposed Event is consistent with the existing graph.
Returns Ok(()) if the event can be inserted without violating any
temporal or state constraints. Returns Err with a list of
ValidationErrors describing every conflict found.
Source§impl Chronicle
impl Chronicle
Sourcepub fn actor(&self, id: &str) -> Option<ActorQuery<'_>>
pub fn actor(&self, id: &str) -> Option<ActorQuery<'_>>
Look up an actor by id and return a query handle for it.
Returns None if the id does not exist or does not refer to an Actor.
Sourcepub fn event(&self, id: &str) -> Option<EventQuery<'_>>
pub fn event(&self, id: &str) -> Option<EventQuery<'_>>
Look up an event by id and return a query handle for it.
Returns None if the id does not exist or does not refer to an Event.
Sourcepub fn place(&self, id: &str) -> Option<PlaceQuery<'_>>
pub fn place(&self, id: &str) -> Option<PlaceQuery<'_>>
Look up a place by id and return a query handle for it.
Returns None if the id does not exist or does not refer to a Place.
Sourcepub fn concept(&self, id: &str) -> Option<ConceptQuery<'_>>
pub fn concept(&self, id: &str) -> Option<ConceptQuery<'_>>
Look up a concept by id and return a query handle for it.
Returns None if the id does not exist or does not refer to a Concept.
Sourcepub fn mentions(&self, entity_id: &str) -> Vec<&Account>
pub fn mentions(&self, entity_id: &str) -> Vec<&Account>
All accounts whose text contains a {entity_id} reference to this entity.
Sourcepub fn accounts_of(&self, event_id: &str) -> Vec<&Account>
pub fn accounts_of(&self, event_id: &str) -> Vec<&Account>
All accounts that reference this event (via AccountOf edges).
Sourcepub fn accounts_by(&self, source_id: &str) -> Vec<&Account>
pub fn accounts_by(&self, source_id: &str) -> Vec<&Account>
All accounts authored by a given source.