iteration
- Iteration definitions live at
iteration/<id>.yamlwith their tags andphases:membership embedded at the top level (per ADR-0016 §3 — the iteration owns the phase ordering). - Iteration notes are individual files at
iteration/notes/<note_id>.yaml.
const UPSERT_ITERATION_SQL
const UPSERT_ITERATION_SQL: &str = "INSERT INTO iterations \
(id, project_id, completed_at, created_at, description, metadata, status, title, updated_at) \
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9) \
ON CONFLICT(id) DO UPDATE SET \
completed_at = ?3, description = ?5, metadata = ?6, status = ?7, title = ?8, updated_at = ?9";Upsert SQL for the iterations table.
struct IterationFile
struct IterationFileOn-disk wrapper for .gest/iteration/<id>.yaml.
| Field | Type | Description |
|---|---|---|
deleted_at |
Option<DateTime<Utc>> | Tombstone instant; when set, import deletes the iteration and its phase rows. |
id |
Id | Stable iteration identifier; also the file’s name stem. |
title |
String | Short human-readable name of the iteration. |
status |
String | Lifecycle status, as stored in the status column. |
description |
String | Free-form description; omitted from the file when empty. |
tags |
Vec<String> | Labels of the tags attached to the iteration, sorted; omitted when empty. |
phases |
Vec<PhaseGroup> | Tasks of the iteration grouped by phase, in phase order; omitted when empty. |
metadata |
Value | Arbitrary JSON metadata; omitted when null. |
created_at |
DateTime<Utc> | When the iteration was created. |
updated_at |
DateTime<Utc> | When the iteration was last modified. |
completed_at |
Option<DateTime<Utc>> | When the iteration was completed, if it has been. |
Implements Clone, Debug, Deserialize<'de>, Eq, PartialEq, Serialize.
struct PhaseGroup
struct PhaseGroupThe tasks of one phase of an iteration, as written under phases: in its file.
| Field | Type | Description |
|---|---|---|
phase |
u32 | Phase number within the iteration, from the phase column of iteration_tasks. |
tasks |
Vec<Id> | Ids of the tasks in this phase, sorted by id on export. |
Implements Clone, Debug, Deserialize<'de>, Eq, PartialEq, Serialize.
struct IterationNoteFile
struct IterationNoteFileOn-disk wrapper for .gest/iteration/notes/<note_id>.yaml.
| Field | Type | Description |
|---|---|---|
deleted_at |
Option<DateTime<Utc>> | Tombstone instant; when set, import deletes the note row instead of upserting it. |
id |
Id | Stable note identifier; also the file’s name stem. |
entity_id |
Id | The iteration the note belongs to. |
author_id |
Option<Id> | The author of the note, if one was recorded. |
body |
String | The note’s text. |
created_at |
DateTime<Utc> | When the note was created. |
updated_at |
DateTime<Utc> | When the note was last edited. |
Implements Clone, Debug, Deserialize<'de>, Eq, PartialEq, Serialize.
fn read_all
pub async fn read_all(conn: &Connection, project_id: &Id, gest_dir: &Path) -> Result<(), Error>Import every iteration and iteration-note file into SQLite.
Each iteration file is upserted with its tags and phases. A tombstone file deletes the iteration and its
iteration_tasks rows, and a note tombstone deletes the note.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the open database connection |
project_id |
&Id | the project that new iteration rows belong to |
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
pub async fn write_all(conn: &Connection, project_id: &Id, gest_dir: &Path) -> Result<(), Error>Export every iteration and iteration-note row to per-entity files.
Files for iterations and notes that no longer exist are removed afterwards, except tombstone files.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the open database connection |
project_id |
&Id | the project whose iterations are exported, and 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. |
fn load_iteration_tag_labels
async fn load_iteration_tag_labels(
conn: &Connection,
iteration_id: &Id,
) -> Result<Vec<String>, Error>Read the labels of the tags attached to an iteration.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the open database connection |
iteration_id |
&Id | the iteration whose tags are read |
| returns | Result<Vec<String>, Error> | The labels sorted alphabetically, or the database error. |
fn load_phases
async fn load_phases(conn: &Connection, iteration_id: &Id) -> Result<Vec<PhaseGroup>, Error>Read an iteration’s tasks from iteration_tasks, grouped by phase.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the open database connection |
iteration_id |
&Id | the iteration whose tasks are read |
| returns | Result<Vec<PhaseGroup>, Error> | One group per phase in ascending phase order, each with its task ids sorted, or a database or id-parse error. |
fn parse_dt
fn parse_dt(s: &str) -> Result<DateTime<Utc>, Error>Parse an RFC 3339 timestamp from a database column.
| Parameter | Type | Description |
|---|---|---|
s |
&str | the timestamp text |
| returns | Result<DateTime<Utc>, Error> | The instant in UTC, or an Error::Io holding the parse error. |
fn sync_phases
async fn sync_phases(conn: &Connection, file: &IterationFile) -> Result<(), Error>Replace an iteration’s iteration_tasks rows with the phases in its file.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the open database connection |
file |
&IterationFile | the parsed iteration file |
| returns | Result<(), Error> | () on success, or the database error. |
fn upsert_iteration
async fn upsert_iteration(
conn: &Connection,
project_id: &Id,
file: &IterationFile,
) -> Result<(), Error>Insert an iteration from its file, or update the existing row with the same id.
On conflict project_id and created_at keep their stored values.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the open database connection |
project_id |
&Id | the project a new row belongs to |
file |
&IterationFile | the parsed iteration file |
| returns | Result<(), Error> | () on success, or the database error. |
fn upsert_note
async fn upsert_note(conn: &Connection, file: &IterationNoteFile) -> Result<(), Error>Insert an iteration note from its file, or update the body and updated_at of the existing row.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the open database connection |
file |
&IterationNoteFile | the parsed note file |
| returns | Result<(), Error> | () on success, or the database error. |