Skip to content

feat(memory): add conversation_id to compression_guidelines for per-conversation scoping#1835

Merged
bug-ops merged 5 commits intomainfrom
feat-memory-add-conversation-id
Mar 15, 2026
Merged

feat(memory): add conversation_id to compression_guidelines for per-conversation scoping#1835
bug-ops merged 5 commits intomainfrom
feat-memory-add-conversation-id

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

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

Summary

Closes #1806.

Adds conversation_id column to the compression_guidelines table via a new migration (034), enabling per-conversation scoping of ACON compression guidelines.

  • New migration 034_compression_guidelines_conversation_id.sql: ALTER TABLE compression_guidelines ADD COLUMN conversation_id INTEGER REFERENCES conversations(id) ON DELETE CASCADE + index
  • load_compression_guidelines(conversation_id: Option<ConversationId>): when Some(cid), returns conversation-specific guidelines (preferred) with global fallback; when None, returns only global guidelines
  • save_compression_guidelines accepts optional conversation_id — background updater passes None (global scope), summarization path passes per-conversation id
  • Version numbers remain globally sequential (existing UNIQUE(version) constraint preserved)
  • 6 new unit tests covering: preference ordering, global fallback, scope isolation, FK violation, CASCADE delete

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features full -- -D warnings — 0 warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 5799 passed, 12 skipped
  • Security audit: parameterized queries, FK enforcement verified, no cross-scope leakage
  • Backwards compatible: existing NULL rows treated as global scope

bug-ops added 2 commits March 15, 2026 16:23
…onversation scoping

Adds migration 034 with ALTER TABLE to add nullable conversation_id column
(FK to conversations with CASCADE delete) to compression_guidelines table.

Updates load_compression_guidelines to accept Option<ConversationId>:
- Some(cid): returns conversation-specific guidelines (preferred) + global fallback
- None: returns only global guidelines

Updates save_compression_guidelines to accept and bind conversation_id.
Summarization path passes self.memory_state.conversation_id; background
updater uses None (global scope). Version numbers remain globally sequential.

Closes #1806
@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 enhancement New feature or request size/L Large PR (201-500 lines) labels Mar 15, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 15, 2026 15:38
@bug-ops bug-ops merged commit 8c955dc into main Mar 15, 2026
19 checks passed
@bug-ops bug-ops deleted the feat-memory-add-conversation-id branch March 15, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(memory): add conversation_id column to compression_guidelines table

1 participant