diff options
| author | soryu <soryu@soryu.co> | 2026-01-22 22:32:46 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-01-23 01:03:04 +0000 |
| commit | 1ed362424dafec690f919154f5116471951cda9c (patch) | |
| tree | 19c7ca9231887394a791223fe32a8ad335a687a8 /makima/src/db/models.rs | |
| parent | 265f8cf14fec9d7116d09af49e4b48b357faceda (diff) | |
| download | soryu-1ed362424dafec690f919154f5116471951cda9c.tar.gz soryu-1ed362424dafec690f919154f5116471951cda9c.zip | |
Add patch checkpointing
Diffstat (limited to 'makima/src/db/models.rs')
| -rw-r--r-- | makima/src/db/models.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index 6ede268..58f4da1 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -1966,3 +1966,45 @@ pub struct ForkPoint { pub checkpoint: Option<TaskCheckpoint>, pub timestamp: DateTime<Utc>, } + +// ============================================================================ +// Checkpoint Patches (for task recovery when worktrees are lost) +// ============================================================================ + +/// A stored git patch for checkpoint recovery. +/// Enables task recovery when local worktrees are deleted or corrupted. +#[derive(Debug, Clone, FromRow, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct CheckpointPatch { + pub id: Uuid, + pub task_id: Uuid, + /// Optional link to a task_checkpoint record + pub checkpoint_id: Option<Uuid>, + /// The commit SHA that the patch should be applied on top of + pub base_commit_sha: String, + /// Compressed git diff data (gzip) + #[sqlx(rename = "patch_data")] + #[serde(skip)] // Don't serialize binary data to JSON + pub patch_data: Vec<u8>, + /// Size of the compressed patch in bytes + pub patch_size_bytes: i32, + /// Number of files affected by this patch + pub files_count: i32, + pub created_at: DateTime<Utc>, + /// When this patch expires and will be automatically deleted + pub expires_at: DateTime<Utc>, +} + +/// Response for checkpoint patch (without binary data) +#[derive(Debug, Clone, FromRow, Serialize, ToSchema)] +#[serde(rename_all = "camelCase")] +pub struct CheckpointPatchInfo { + pub id: Uuid, + pub task_id: Uuid, + pub checkpoint_id: Option<Uuid>, + pub base_commit_sha: String, + pub patch_size_bytes: i32, + pub files_count: i32, + pub created_at: DateTime<Utc>, + pub expires_at: DateTime<Utc>, +} |
