relationship

Per-entity sync adapter for relationships.

Relationships are symmetric edges between two entities. Each row gets its own file at relationship/<id>.yaml so that adding or removing a relationship touches no other file (per ADR-0016 §3 — “per-edge files”).

struct RelationshipFile

source

struct RelationshipFile

On-disk wrapper for .gest/relationship/<id>.yaml.

Field Type Description
deleted_at Option<DateTime<Utc>> Tombstone instant; when set, import deletes the relationship row instead of upserting it.
id Id Stable relationship identifier; also the file’s name stem.
rel_type String The kind of edge, as stored in the rel_type column.
source_type String The entity type of the source end.
source_id Id The id of the source entity.
target_type String The entity type of the target end.
target_id Id The id of the target entity.

Implements Clone, Debug, Deserialize<'de>, Eq, PartialEq, Serialize.

fn read_all

source

pub async fn read_all(conn: &Connection, _project_id: &Id, gest_dir: &Path) -> Result<(), Error>

Import every relationship/*.yaml file into SQLite.

A file with deleted_at set deletes its relationship row; any other file is upserted by id.

Parameter Type Description
conn &Connection the open database connection
_project_id &Id unused: relationships have no project_id column
gest_dir &Path the project’s .gest/ directory
returns Result<(), Error> () once every file is imported, or the first read, parse or database error.

fn write_all

source

pub async fn write_all(conn: &Connection, project_id: &Id, gest_dir: &Path) -> Result<(), Error>

Export every relationship row scoped to this project’s entities to disk.

Relationships have no project_id column, so we export every relationship whose source or target is a known entity in this project. Two collaborators adding edges to the same project produce different files and merge cleanly.

Parameter Type Description
conn &Connection the open database connection
project_id &Id the project, whose sync_digests cache records the writes
gest_dir &Path the project’s .gest/ directory
returns Result<(), Error> () once every file is written and orphans are cleaned up, or the first database, parse or I/O error.