Repository navigation
feat(core): list_pinned returns pinned memories in one query (#1804) - #1805
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
Store::list_pinned(namespace, limit)incrates/uteke-core/src/memory/crud.rs: one SQL query overmemories WHERE pinned = 1 AND deprecated = 0 [AND namespace = ?],ORDER BY created_at DESC LIMIT ?, selecting throughmemory_columns!()like every otherrow_to_memorypath.Uteke::list_pinned(namespace, limit)incrates/uteke-core/src/operations/listing.rs, next tolist.idx_memories_pinnedpartial index (namespace, created_atwherepinned = 1 AND deprecated = 0): created for fresh stores viaSCHEMA_INDEXES, for existing stores via a new v27 → v28 migration (CURRENT_SCHEMA_VERSION27 → 28).limit(including 0), namespace scoping (Somerestricts,Nonespans all), deprecated exclusion,list_pinned(...).len() == count_pinned(...)consistency, the v28 in-place migration, and anEXPLAIN QUERY PLANtest asserting the per-namespace query is served by the partial index.skill_library_tests::fresh_store_has_the_skill_tables_at_the_current_schemapinned the literal27; it now compares againstCURRENT_SCHEMA_VERSION, which is what its name always meant.[Unreleased].Why
Closes #1804.
count_pinnedexists but nothing returns the pinned set, so consumers page through the whole list and keep pinned rows. The Uteke Mobile FFI does exactly that on every pin change (uteke-mobile#271) — fine at the free cap, reads every row for large stores. One indexed query replaces it.Testing
test_list_pinned_only_pinned_newest_first_and_limit,test_list_pinned_namespace_filter_and_excludes_deprecated,test_migration_v28_adds_list_pinned_index,test_list_pinned_uses_partial_index— all pass.cargo test -p uteke-core --lib: 1311 passed, 0 failed (this is what caught the schema-version pin in the skill-library test).cargo fmt -p uteke-core -- --checkclean;cargo clippy -p uteke-core --all-targets -- -D warningsclean.EXPLAIN QUERY PLANon a 500-row store (250 pinned): plan reportsUSING INDEX idx_memories_pinned, noSCAN memories(asserted in the test, not just observed once).