Skip to content

fix(knowledge): make rollback atomic across all three tables#5055

Merged
bug-ops merged 1 commit into
mainfrom
5054-knowledge-rollback-atomic
Jun 8, 2026
Merged

fix(knowledge): make rollback atomic across all three tables#5055
bug-ops merged 1 commit into
mainfrom
5054-knowledge-rollback-atomic

Conversation

@bug-ops

@bug-ops bug-ops commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wraps graph_edges, graph_entity, and knowledge_ingest_ledger DELETEs in a single BEGIN IMMEDIATE transaction in both the CLI path (handle_rollback) and the agent path (knowledge_rollback).
  • Adds delete_batch_in_tx helper methods on GraphStore and IngestLedger so SQL is defined once and shared across both call sites.
  • Propagates ledger delete_batch error in agent_access_impl::knowledge_rollback instead 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 — PASS
  • cargo clippy --workspace -- -D warnings — PASS
  • cargo nextest run --config-file .github/nextest.toml --workspace --lib --bins — 10792 passed, 0 failed

Closes #5054

@github-actions github-actions Bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate bug Something isn't working size/M Medium PR (51-200 lines) labels Jun 8, 2026
@bug-ops
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
bug-ops force-pushed the 5054-knowledge-rollback-atomic branch from e38d34b to 431273a Compare June 8, 2026 14:07
@bug-ops
bug-ops merged commit 6405fed into main Jun 8, 2026
35 checks passed
@bug-ops
bug-ops deleted the 5054-knowledge-rollback-atomic branch June 8, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

knowledge rollback is not atomic: three SQL operations without a transaction

1 participant