Skip to main content

GraphOp

Enum GraphOp 

Source
pub enum GraphOp {
    AddNode {
        id: Uuid,
        kind: String,
        name: String,
        summary: String,
        attrs: Value,
        group_id: String,
    },
    AddEdge {
        id: Uuid,
        src: Uuid,
        dst: Uuid,
        rel: String,
        fact: String,
        attrs: Value,
        group_id: String,
        valid_at: Option<TimestampMs>,
        invalid_at: Option<TimestampMs>,
    },
    AddEpisode {
        id: Uuid,
        source: String,
        kind: String,
        content: String,
        occurred_at: TimestampMs,
        group_id: String,
        mentions: Vec<Uuid>,
    },
    UpdateNode {
        id: Uuid,
        name: Option<String>,
        summary: Option<String>,
        kind: Option<String>,
        attrs: Option<Value>,
    },
    InvalidateEdge {
        edge_id: Uuid,
        invalid_at: TimestampMs,
    },
    MergeNodes {
        from: Uuid,
        into: Uuid,
    },
    Purge {
        ids: Vec<Uuid>,
    },
}
Expand description

A single append-only write. See module docs.

Variants§

§

AddNode

Create an entity node.

Fields

§id: Uuid

UUIDv7 identity, minted by the caller (crate::Grit::new_id).

§kind: String

Entity kind, free-form (e.g. "person", "concept").

§name: String

Display name; FTS-indexed.

§summary: String

One-paragraph summary; FTS-indexed.

§attrs: Value

Arbitrary JSON attributes.

§group_id: String

Namespace; filtered in every query.

§

AddEdge

Create a fact edge between two nodes (“fat edge”: the fact sentence lives on the edge).

Fields

§id: Uuid

UUIDv7 identity.

§src: Uuid

Source node id.

§dst: Uuid

Destination node id.

§rel: String

Relation label (e.g. "WORKS_AT").

§fact: String

Natural-language fact sentence; FTS-indexed.

§attrs: Value

Arbitrary JSON attributes.

§group_id: String

Namespace.

§valid_at: Option<TimestampMs>

Event time the fact became true; None = unknown / always.

§invalid_at: Option<TimestampMs>

Event time the fact stopped being true, when already known at creation (e.g. the source text states the end). Unlike GraphOp::InvalidateEdge this is NOT a belief retraction and sets no expired_at — the fact was recorded with a bounded interval from the start.

§

AddEpisode

Record raw provenance (a chat turn, a document chunk, a sensor-event summary) and link it to the nodes/edges it mentions.

Fields

§id: Uuid

UUIDv7 identity.

§source: String

Where this came from (e.g. "chat", "doc:notes.md").

§kind: String

Free-form source-kind tag (e.g. "message", "text", "json"). Opaque to grit — callers filter on it.

§content: String

Raw text; FTS-indexed.

§occurred_at: TimestampMs

Event time of the episode.

§group_id: String

Namespace.

§mentions: Vec<Uuid>

Node/edge ids this episode is provenance for.

§

UpdateNode

Revise a node’s entity metadata (Layer 2 decides the new values — summary refresh, name/label promotion; grit executes). None fields are untouched.

Each provided field is a last-writer-wins register: concurrent updates converge to the highest HLC per field, independently of apply order (recorded append-only in node_updates, folded into the node row — the same out-of-order machinery as edge invalidations). Prior values remain in the oplog; this is metadata revision with an audit trail, not fact mutation — facts live on edges and stay append-only (Design Invariant 4).

Deliberately cannot touch identity (id, group_id), lifecycle (expired_at, merged_into), or anything on edges.

Fields

§id: Uuid

Node to update.

§name: Option<String>

New display name, if changing.

§summary: Option<String>

New summary, if changing.

§kind: Option<String>

New entity kind, if changing.

§attrs: Option<Value>

New attributes (whole-value replace — grit does not deep-merge; the caller composes the full object), if changing.

§

InvalidateEdge

Close an edge’s event-time interval: the fact stopped being true at invalid_at. Never deletes; concurrent invalidations converge to the minimum (earliest) time. The edge row’s expired_at is untouched (that means full belief retraction in grit’s read model); when the invalidation itself was learned is edge_invalidations.recorded_at.

Fields

§edge_id: Uuid

Edge to invalidate.

§invalid_at: TimestampMs

Event time the fact stopped holding.

§

MergeNodes

Fold node from into node into. Layer 2 decides whether (an LLM judgment); grit only executes. Re-points edges and mentions, marks from expired with a merged_into audit pointer.

Fields

§from: Uuid

The node that disappears.

§into: Uuid

The node that absorbs it.

§

Purge

Explicit, audited right-to-forget. The ONLY destructive op: hard-deletes and permanently tombstones exactly the listed ids (a tombstoned id can never be re-added, which is what makes purge commute with concurrent adds). List incident edge ids explicitly — their fact sentences carry the content being forgotten; crate::Grit::node_history enumerates them. The purge op itself stays in the oplog as the audit record.

Fields

§ids: Vec<Uuid>

Node/edge/episode ids to erase.

Trait Implementations§

Source§

impl Clone for GraphOp

Source§

fn clone(&self) -> GraphOp

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GraphOp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for GraphOp

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for GraphOp

Source§

fn eq(&self, other: &GraphOp) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for GraphOp

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for GraphOp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.