forget
Remove a memory on either client — soft tombstone with a grace period, or immediate hard erase.
Forget a memory
use brain_db_sdk::BrainHttpClient;
use brain_db_sdk::http::ForgetInput;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = BrainHttpClient::localhost("my-api-key");
let out = client
.forget(&ForgetInput {
memory_id: "some-memory-id".to_string(),
hard: false, // soft tombstone
})
.await?;
println!("forgot {} (already forgotten: {})", out.memory_id, out.was_already_forgotten);
println!("{} edges removed", out.edges_removed);
Ok(())
}use std::net::SocketAddr;
use brain_db_sdk::{Auth, BrainClient, EncodeBuilder, ForgetBuilder};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr: SocketAddr = "127.0.0.1:9090".parse()?;
let client = BrainClient::connect(addr, Auth::Token(b"my-token".to_vec())).await?;
// memory_id is the numeric id returned by encode.
let stored = client.encode(&EncodeBuilder::new("a note to remove").build()).await?;
let out = client.forget(&ForgetBuilder::new(stored.memory_id).build()).await?;
println!("forgot {} ({} edges removed)", out.memory_id, out.edges_removed);
Ok(())
}Soft vs. hard
ForgetInput has a hard flag:
// Soft tombstone (recoverable during the grace period):
let soft = ForgetInput { memory_id: id.clone(), hard: false };
// Hard erase (zeroed immediately, no grace period):
let hard = ForgetInput { memory_id: id, hard: true };ForgetBuilder defaults to a soft forget; .hard() switches to immediate zeroing:
use brain_db_sdk::ForgetBuilder;
// Soft tombstone (the default):
let soft = ForgetBuilder::new(memory_id).build();
// Hard erase:
let hard = ForgetBuilder::new(memory_id).hard().build();The builder mints a fresh request_id. memory_id is the numeric u128 id from EncodeResponse.
A soft forget tombstones the memory: it stops answering reads but survives a grace period (7 days by default) during which it can be recovered. A hard forget zeroes the memory's bytes immediately — there is no recovery. Use hard only when the data must genuinely be scrubbed.
The result
Both clients return the same shape (ForgetResult over HTTP, ForgetResponse over the wire):
memory_idString / u128optionalThe memory that was forgotten. String over HTTP, numeric on the wire.
was_already_forgottenbooloptionaltrue if the memory was already tombstoned before this call.
edges_removedu32optionalHow many edges were removed as part of the forget.
forget is lenient: forgetting a missing or stale memory id is a no-op success, not an error — so a retry after a partial failure is safe.
Was this page helpful?