test(memory): add rollback and orchestration tests for consolidation#2383
Merged
test(memory): add rollback and orchestration tests for consolidation#2383
Conversation
d93a05d to
b53ef82
Compare
…2359, #2360) Adds 6 unit tests in consolidation.rs covering: - apply_consolidation_merge_rollback_on_mid_tx_error: verifies transaction rollback on mid-tx FK violation — memory_consolidation_sources has 0 rows and source messages remain consolidated=false after error (#2359) - run_consolidation_sweep_single_candidate_skips: embedded.len() < 2 guard exits with all counters at zero (#2360) - run_consolidation_sweep_merge_increments_counter: result.merges==1 on successful Merge op (#2360) - run_consolidation_sweep_update_increments_counter: result.updates==1 on successful Update op (#2360) - run_consolidation_sweep_skipped_below_threshold: result.skipped==1 when confidence < threshold (#2360) - run_consolidation_sweep_update_db_state: Update op persists consolidated message and marks sources as consolidated=1 in DB (#2360) Note: INSERT OR IGNORE on memory_consolidation_sources does not suppress FK violations in SQLite (foreign_keys=ON). Rollback is triggered via FK violation on messages.conversation_id instead, which fires earlier in the transaction and exercises the same rollback semantics.
b53ef82 to
3c9c800
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
apply_consolidation_mergeon mid-transaction error (test(memory): add rollback test for apply_consolidation_merge on mid-tx error #2359)run_consolidation_sweeporchestration logic (test(memory): add unit tests for run_consolidation_sweep orchestration #2360)Tests added (6)
apply_consolidation_merge_rollback_on_mid_tx_errorconsolidated=0, function returnsErrrun_consolidation_sweep_single_candidate_skipsembedded.len() < 2guard exits with all counters at zerorun_consolidation_sweep_merge_increments_counterresult.merges == 1on successful Merge oprun_consolidation_sweep_update_increments_counterresult.updates == 1on successful Update oprun_consolidation_sweep_skipped_below_thresholdresult.skipped == 1when confidence < thresholdrun_consolidation_sweep_update_db_stateconsolidated=1in DBImplementation note
INSERT OR IGNOREonmemory_consolidation_sourcesdoes not suppress FK violations in SQLite whenforeign_keys = ON(only suppresses UNIQUE/CHECK/NOT NULL). The rollback test uses an invalidConversationId(99999)to trigger FK failure onINSERT INTO messages— the first statement in the transaction — which exercises the same rollback semantics and satisfies the acceptance criteria.Checklist
cargo +nightly fmt --check— cleancargo clippy --workspace -- -D warnings— 0 warningscargo nextest run --workspace --lib --bins— 6614 passedCloses #2359
Closes #2360