fix: atomic ingestion persist with task reclaim and shared cleanup.

One transaction per task replaces prior artifact rows; workers skip the pipeline when content already exists, eval seeding reuses persist_artifacts, and deletes clear graph children via shared SQL.
This commit is contained in:
Per Stark
2026-06-12 16:27:07 +02:00
parent cf69cb7b05
commit 1013035731
15 changed files with 794 additions and 487 deletions
+2 -7
View File
@@ -5,10 +5,7 @@ use axum::{
use axum_htmx::{HxBoosted, HxRequest, HxTarget};
use serde::{Deserialize, Serialize};
use common::storage::types::{
file_info::FileInfo, knowledge_entity::KnowledgeEntity, text_chunk::TextChunk,
text_content::TextContent, user::User,
};
use common::storage::types::{file_info::FileInfo, text_content::TextContent, user::User};
use crate::{
html_state::HtmlState,
@@ -180,9 +177,7 @@ pub async fn delete_text_content(
}
}
// Delete related knowledge entities and text chunks
KnowledgeEntity::delete_by_source_id(&id, &state.db).await?;
TextChunk::delete_by_source_id(&id, &state.db).await?;
TextContent::clear_ingested_children(&id, &user.id, &state.db).await?;
// Delete the text content
state.db.delete_item::<TextContent>(&id).await?;
+2 -8
View File
@@ -23,9 +23,7 @@ use common::storage::types::user::DashboardStats;
use common::{
error::AppError,
storage::types::{
file_info::FileInfo, ingestion_task::IngestionTask, knowledge_entity::KnowledgeEntity,
knowledge_relationship::KnowledgeRelationship, text_chunk::TextChunk,
text_content::TextContent, user::User,
file_info::FileInfo, ingestion_task::IngestionTask, text_content::TextContent, user::User,
},
};
@@ -81,11 +79,7 @@ pub async fn delete_text_content(
}
}
// Delete the text content and any related data
TextChunk::delete_by_source_id(&text_content.id, &state.db).await?;
KnowledgeEntity::delete_by_source_id(&text_content.id, &state.db).await?;
KnowledgeRelationship::delete_relationships_by_source_id(&text_content.id, &user.id, &state.db)
.await?;
TextContent::clear_ingested_children(&text_content.id, &user.id, &state.db).await?;
state
.db
.delete_item::<TextContent>(&text_content.id)