Skip to content

feat: CRUD delete() + bulk_delete_*() — soft-delete when soft_delete_only=true #932

Closed

Description

@ajianaz

Overview

Semua delete operation di CRUD layer saat ini melakukan HARD DELETE langsung. Ubah ke soft-delete (deprecate) ketika soft_delete_only=true.

Exception: forget() tetap hard-delete — itu adalah explicit user action.

Current Operations (ALL HARD DELETE)

Method File Impact
delete(id) crud.rs:197 1 row DELETE FROM
delete_by_ids(&[ids]) bulk.rs:169 N rows
bulk_delete_by_tag(tag) bulk.rs:13 All with tag
bulk_delete_cold(ns, days) bulk.rs:41 All cold in namespace
bulk_delete_all(ns) bulk.rs:70 ⚠️ ENTIRE NAMESPACE — no confirmation

Target Behavior

// crud.rs
pub fn delete(&self, id: &str) -> Result<(), Error> {
    if self.lifecycle_config.soft_delete_only {
        // SOFT DELETE
        self.deprecate_with_reason(id, "manual_delete")?;
    } else {
        // OLD BEHAVIOR: hard delete
        self.store.delete(id)?;
    }
    Ok(())
}

// bulk.rs
pub fn bulk_delete_by_tag(&self, tag: &str) -> Result<usize, Error> {
    if self.lifecycle_config.soft_delete_only {
        // SOFT DELETE: bulk deprecate
        let ids = self.store.find_ids_by_tag(tag)?;
        for id in &ids {
            self.deprecate_with_reason(id, "bulk_delete_by_tag")?;
        }
        Ok(ids.len())
    } else {
        // OLD BEHAVIOR
        self.store.bulk_delete_by_tag(tag)
    }
}

Same pattern for bulk_delete_cold and bulk_delete_all.

forget() — STAYS HARD DELETE

/// Explicit permanent deletion. The ONLY hard-delete path when soft_delete_only=true.
/// This is intentional user action — cannot be undone.
pub fn forget(&self, id: &str) -> Result<(), Error> {
    self.store.delete(id)?;  // Always hard delete
    // ...
}

Files Changed

File Change
crates/uteke-core/src/memory/crud.rs delete() — conditional soft/hard
crates/uteke-core/src/memory/bulk.rs bulk_delete_by_tag/cold/all — conditional
crates/uteke-core/src/operations.rs forget() — document as only hard-delete path

Acceptance Criteria

  • delete() deprecates when soft_delete_only=true
  • bulk_delete_*() deprecates when soft_delete_only=true
  • forget() ALWAYS hard-deletes (regardless of config)
  • forget() logs warning: "This is permanent and cannot be undone"
  • Old behavior preserved when soft_delete_only=false
  • All operations log timeline events
  • Integration tests for both paths (soft + hard)

Dependencies

Activity

  1. added this to the milestone on Aug 8, 2026
  2. added
    enhancement
    scope:core
    rust
    priority:high
    scope:db
    epic:memory-lifecycle
    lifecycle
    safety
    on Aug 8, 2026
  3. modified the milestones: , v0.13.0 on Aug 8, 2026
  4. ajianaz commented on Aug 8, 2026

    @ajianaz
    CollaboratorAuthor

    Implemented in PR #938 (merged). Closing as completed.

  5. added a commit that references this issue on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementepic:memory-lifecyclelifecyclepriority:highrustsafetyscope:corescope:db

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions