purge
Each function returns a count plus the list of eligible IDs/paths, scoped to
either a single project or all projects. Functions are side-effect-free: no
writes, no file modifications. Suitable for use by --dry-run.
enum Scope
pub enum ScopeScope for purge selectors: either a single project or all projects.
| Variant | Description |
|---|---|
AllProjects |
Restrict to all projects. |
Project(Id) |
Restrict to a single project. |
struct TerminalTasks
pub struct TerminalTasksTerminal tasks grouped by status.
| Field | Type | Description |
|---|---|---|
cancelled |
usize | Number of tasks in the cancelled state. |
done |
usize | Number of tasks in the done state. |
ids |
Vec<Id> | IDs of all terminal tasks. |
Implements Clone, Debug, Default.
TerminalTasks::total
pub fn total(&self) -> usizeTotal number of terminal tasks.
struct TerminalIterations
pub struct TerminalIterationsTerminal iterations grouped by status.
| Field | Type | Description |
|---|---|---|
cancelled |
usize | Number of iterations in the cancelled state. |
completed |
usize | Number of iterations in the completed state. |
ids |
Vec<Id> | IDs of all terminal iterations. |
Implements Clone, Debug, Default.
TerminalIterations::total
pub fn total(&self) -> usizeTotal number of terminal iterations.
struct ArchivedArtifacts
pub struct ArchivedArtifactsArchived artifacts.
| Field | Type | Description |
|---|---|---|
count |
usize | Number of archived artifacts. |
ids |
Vec<Id> | IDs of all archived artifacts. |
struct ArchivedProjects
pub struct ArchivedProjectsArchived projects.
| Field | Type | Description |
|---|---|---|
count |
usize | Number of archived projects. |
ids |
Vec<Id> | IDs of all archived projects. |
struct DanglingRelationships
pub struct DanglingRelationshipsA relationship row whose source or target no longer resolves to a live entity.
| Field | Type | Description |
|---|---|---|
count |
usize | Number of dangling relationship rows. |
ids |
Vec<Id> | IDs of all dangling relationship rows. |
struct OrphanTombstones
pub struct OrphanTombstonesOn-disk tombstone files with no matching DB row.
| Field | Type | Description |
|---|---|---|
count |
usize | Number of orphan tombstone files. |
paths |
Vec<PathBuf> | Filesystem paths of all orphan tombstone files. |
fn terminal_tasks
pub async fn terminal_tasks(conn: &Connection, scope: &Scope) -> Result<TerminalTasks, Error>Return tasks in terminal status (done or cancelled).
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
scope |
&Scope | one project, or all projects |
| returns | Result<TerminalTasks, Error> | The counts by status and the ids of the tasks. It is Error::InvalidValue when a stored id does not parse, or a database error. |
fn terminal_iterations
pub async fn terminal_iterations(
conn: &Connection,
scope: &Scope,
) -> Result<TerminalIterations, Error>Return iterations in terminal status (completed or cancelled).
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
scope |
&Scope | one project, or all projects |
| returns | Result<TerminalIterations, Error> | The counts by status and the ids of the iterations. It is Error::InvalidValue when a stored id does not parse, or a database error. |
fn archived_artifacts
pub async fn archived_artifacts(
conn: &Connection,
scope: &Scope,
) -> Result<ArchivedArtifacts, Error>Return artifacts with archived_at IS NOT NULL.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
scope |
&Scope | one project, or all projects |
| returns | Result<ArchivedArtifacts, Error> | The count and ids of the archived artifacts. It is Error::InvalidValue when a stored id does not parse, or a database error. |
fn archived_projects
pub async fn archived_projects(conn: &Connection, scope: &Scope) -> Result<ArchivedProjects, Error>Return projects with archived_at IS NOT NULL.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
scope |
&Scope | all projects, or one project, which is then the only one that can match |
| returns | Result<ArchivedProjects, Error> | The count and ids of the archived projects. It is Error::InvalidValue when a stored id does not parse, or a database error. |
fn dangling_relationships
pub async fn dangling_relationships(
conn: &Connection,
scope: &Scope,
) -> Result<DanglingRelationships, Error>Return relationship rows whose source_id or target_id no longer
resolves to a live entity (task, iteration or artifact) in the DB.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
scope |
&Scope | all projects, or one project; for one project, only relationships with an endpoint in that project, or with neither endpoint left anywhere, count |
| returns | Result<DanglingRelationships, Error> | The count and ids of the dangling relationships. It is Error::InvalidValue when a stored id does not parse, or a database error. |
fn orphan_tombstones
pub async fn orphan_tombstones(
conn: &Connection,
scope: &Scope,
gest_dirs: &[(Id, PathBuf)],
) -> Result<OrphanTombstones, Error>Return on-disk tombstone files (files with a deleted_at field) that have
no matching DB row.
This scans the .gest/ directories for YAML/markdown files that contain a
deleted_at field, then checks whether the corresponding entity still
exists in the database. Files that have been tombstoned but whose entity
row has already been removed are considered orphans.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
scope |
&Scope | all projects, or one project, which picks its entries of gest_dirs |
gest_dirs |
&[(Id, PathBuf)] | each project’s id with the path of its .gest/ directory |
| returns | Result<OrphanTombstones, Error> | The count and paths of the orphan tombstone files, or an I/O or database error. |
fn collect_orphan_tombstones_in_dir
async fn collect_orphan_tombstones_in_dir(
conn: &Connection,
gest_dir: &Path,
result: &mut OrphanTombstones,
) -> Result<(), Error>Add the orphan tombstones of one .gest/ directory’s tasks, iterations and artifacts to result.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
gest_dir |
&Path | the project’s .gest/ directory |
result |
&mut OrphanTombstones | the tally that each orphan is added to |
| returns | Result<(), Error> | Ok(()) once the three folders are scanned, or an I/O or database error. |
fn scan_yaml_tombstones
async fn scan_yaml_tombstones(
conn: &Connection,
dir: &Path,
table: &str,
result: &mut OrphanTombstones,
) -> Result<(), Error>Add each .yaml file in dir that mentions deleted_at and whose id has no row in table to result.
A missing dir adds nothing. A file whose stem is not a valid id is skipped.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
dir |
&Path | the entity folder to scan, not recursively |
table |
&str | the table to look the id up in, such as tasks |
result |
&mut OrphanTombstones | the tally that each orphan is added to |
| returns | Result<(), Error> | Ok(()) once the folder is scanned, or an I/O or database error. |
fn scan_artifact_tombstones
async fn scan_artifact_tombstones(
conn: &Connection,
dir: &Path,
result: &mut OrphanTombstones,
) -> Result<(), Error>Add each .md artifact file in dir that mentions deleted_at and has no artifacts row to result.
A missing dir adds nothing. A file whose stem is not a valid id is skipped.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
dir |
&Path | the artifact folder to scan, not recursively |
result |
&mut OrphanTombstones | the tally that each orphan is added to |
| returns | Result<(), Error> | Ok(()) once the folder is scanned, or an I/O or database error. |
fn entity_exists_in_table
async fn entity_exists_in_table(conn: &Connection, table: &str, id: &Id) -> Result<bool, Error>Check whether table has a row with this id.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the connection to query |
table |
&str | the table name, put into the SQL as is |
id |
&Id | the id to look for |
| returns | Result<bool, Error> | true when a row exists, or a database error. |