fix(knowledge): make rollback atomic across all three tables#5055
Merged
Conversation
bug-ops
enabled auto-merge (squash)
June 8, 2026 14:07
Wrap graph_edges, graph_entities, and knowledge_ingest_ledger DELETEs in a single BEGIN IMMEDIATE transaction so that a mid-operation failure rolls back all three atomically instead of leaving the store inconsistent. Add delete_batch_in_tx helper methods on GraphStore and IngestLedger so the SQL is defined once and reused by both the CLI path (handle_rollback) and the agent path (knowledge_rollback). Propagate the ledger delete_batch error in agent_access_impl instead of silently discarding it via let _ = . Closes #5054
bug-ops
force-pushed
the
5054-knowledge-rollback-atomic
branch
from
June 8, 2026 14:07
e38d34b to
431273a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BEGIN IMMEDIATEtransaction in both the CLI path (handle_rollback) and the agent path (knowledge_rollback).delete_batch_in_txhelper methods onGraphStoreandIngestLedgerso SQL is defined once and shared across both call sites.delete_batcherror inagent_access_impl::knowledge_rollbackinstead of silently discarding it.Root cause
Three separate autocommit SQL operations. A mid-operation failure left graph rows deleted but the ledger row intact (or vice versa), making the knowledge store inconsistent.
Test plan
cargo +nightly fmt --check— PASScargo clippy --workspace -- -D warnings— PASScargo nextest run --config-file .github/nextest.toml --workspace --lib --bins— 10792 passed, 0 failedCloses #5054