tombstone
When a project is in local sync mode, deleting an entity in SQLite must
also mark its on-disk file as tombstoned so the next import does not
resurrect the row. These helpers locate the per-entity file under the
gest folder layout (ADR-0016), parse it generically via
yaml_serde::Value so that unknown or non-scalar fields are preserved
verbatim, inject deleted_at, and rewrite the file in place.
The file itself is never removed — it is the tombstone and is what downstream clones will read to learn about the deletion.
const FRONTMATTER_DELIM
const FRONTMATTER_DELIM: &str = "---\n";The line that opens and closes the YAML frontmatter of an artifact’s markdown file.
fn tombstone_artifact
pub fn tombstone_artifact(
gest_dir: Option<&Path>,
id: &Id,
deleted_at: DateTime<Utc>,
) -> Result<(), Error>Tombstone the on-disk file for an artifact by setting deleted_at in its
YAML frontmatter. No-op if gest_dir is None or the file is missing.
The markdown body after the frontmatter is kept.
| Parameter | Type | Description |
|---|---|---|
gest_dir |
Option<&Path> | the project’s .gest/ directory, or None when the project does not sync |
id |
&Id | the artifact’s id, which locates artifact/<id>.md |
deleted_at |
DateTime<Utc> | the deletion time, written as RFC 3339 |
| returns | Result<(), Error> | Ok(()), or an error when the frontmatter delimiters are missing, or an I/O or YAML error when the file cannot be read, parsed or rewritten. |
fn tombstone_iteration
pub fn tombstone_iteration(
gest_dir: Option<&Path>,
id: &Id,
deleted_at: DateTime<Utc>,
) -> Result<(), Error>Tombstone the on-disk file for an iteration. No-op if gest_dir is
None or the file is missing.
| Parameter | Type | Description |
|---|---|---|
gest_dir |
Option<&Path> | the project’s .gest/ directory, or None when the project does not sync |
id |
&Id | the iteration’s id, which locates iteration/<id>.yaml |
deleted_at |
DateTime<Utc> | the deletion time, written as RFC 3339 |
| returns | Result<(), Error> | Ok(()), or an I/O or YAML error when the file cannot be read, parsed or rewritten. |
fn tombstone_project
pub fn tombstone_project(gest_dir: Option<&Path>, deleted_at: DateTime<Utc>) -> Result<(), Error>Tombstone the on-disk project.yaml file. No-op if gest_dir is None
or the file is missing.
| Parameter | Type | Description |
|---|---|---|
gest_dir |
Option<&Path> | the project’s .gest/ directory, or None when the project does not sync |
deleted_at |
DateTime<Utc> | the deletion time, written as RFC 3339 |
| returns | Result<(), Error> | Ok(()), or an I/O or YAML error when the file cannot be read, parsed or rewritten. |
fn tombstone_task
pub fn tombstone_task(
gest_dir: Option<&Path>,
id: &Id,
deleted_at: DateTime<Utc>,
) -> Result<(), Error>Tombstone the on-disk file for a task. No-op if gest_dir is None or
the file is missing.
| Parameter | Type | Description |
|---|---|---|
gest_dir |
Option<&Path> | the project’s .gest/ directory, or None when the project does not sync |
id |
&Id | the task’s id, which locates task/<id>.yaml |
deleted_at |
DateTime<Utc> | the deletion time, written as RFC 3339 |
| returns | Result<(), Error> | Ok(()), or an I/O or YAML error when the file cannot be read, parsed or rewritten. |
fn compose_frontmatter
fn compose_frontmatter(front: &str, body: &str) -> StringRebuild a markdown file from its frontmatter and its body.
| Parameter | Type | Description |
|---|---|---|
front |
&str | the YAML frontmatter, without its --- lines |
body |
&str | the markdown after the closing --- line |
| returns | String | ---, the frontmatter, --- and the body, with a newline added after the frontmatter and the body when either lacks one. |
fn set_deleted_at
fn set_deleted_at(value: &mut Value, deleted_at: DateTime<Utc>) -> Result<(), Error>Insert or overwrite the deleted_at key of a YAML document.
A document that is not a mapping is replaced by a mapping that holds only deleted_at.
| Parameter | Type | Description |
|---|---|---|
value |
&mut Value | the parsed YAML document to change in place |
deleted_at |
DateTime<Utc> | the deletion time, stored as an RFC 3339 string |
| returns | Result<(), Error> | Always Ok(()). |
fn split_frontmatter
fn split_frontmatter(raw: &str) -> Result<(&str, &str), Error>Split a markdown file into its YAML frontmatter and its body.
| Parameter | Type | Description |
|---|---|---|
raw |
&str | the whole file, which must start with a --- line |
| returns | Result<(&str, &str), Error> | The frontmatter, with its final newline, and the body after the first closing --- and one newline; an I/O error when the opening or closing delimiter is missing. |
fn tombstone_yaml
fn tombstone_yaml(path: Option<&Path>, deleted_at: DateTime<Utc>) -> Result<(), Error>Set deleted_at in a plain YAML entity file and rewrite it.
Other keys are kept. No-op when path is None or the file is missing.
| Parameter | Type | Description |
|---|---|---|
path |
Option<&Path> | the entity’s YAML file, or None when the project does not sync |
deleted_at |
DateTime<Utc> | the deletion time, written as RFC 3339 |
| returns | Result<(), Error> | Ok(()), or an I/O or YAML error when the file cannot be read, parsed or rewritten. |