Skip to content

fix(memory): use source conversation_id in AOI tier promotion#2105

Merged
bug-ops merged 1 commit intomainfrom
fix-2102-aoi-fk-sentinel
Mar 22, 2026
Merged

fix(memory): use source conversation_id in AOI tier promotion#2105
bug-ops merged 1 commit intomainfrom
fix-2102-aoi-fk-sentinel

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 22, 2026

Closes #2102

Summary

  • ConversationId(0) sentinel in promote_to_semantic() caused FK violations on every promotion attempt — SQLite autoincrement starts at 1, so id=0 never exists
  • Replace with cluster[0].0.conversation_id (highest-ranked candidate by session_count DESC)
  • Add conversation_id: ConversationId field to PromotionCandidate struct and propagate through find_promotion_candidates() SELECT query
  • No schema migration required

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features full -- -D warnings — clean (0 warnings)
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 6365 passed (+2 new)
  • promote_to_semantic_with_sentinel_zero_fails — FK regression guard confirms ConversationId(0) fails
  • find_promotion_candidates_returns_conversation_id — verifies correct conversation_id propagation through real SQLite store

ConversationId(0) sentinel was used as FK reference for promoted
semantic-tier messages, but SQLite autoincrement starts at 1 so id=0
never exists in the conversations table. Every promotion attempt
resulted in a FOREIGN KEY constraint error and promoted=0 indefinitely.

Replace the sentinel with the conversation_id of the highest-ranked
candidate in the cluster (cluster[0].0.conversation_id, ordered by
session_count DESC). Add conversation_id field to PromotionCandidate
and propagate it through find_promotion_candidates().

Closes #2102
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes labels Mar 22, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 22, 2026 00:31
@github-actions github-actions bot added bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 22, 2026
@bug-ops bug-ops merged commit ea66a88 into main Mar 22, 2026
25 checks passed
@bug-ops bug-ops deleted the fix-2102-aoi-fk-sentinel branch March 22, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 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.

fix(memory): AOI tier promotion fails with FOREIGN KEY constraint — ConversationId(0) sentinel not in conversations table

1 participant