Skip to content

feat(core): list_pinned returns pinned memories in one query (#1804) - #1805

Merged
ajianaz merged 1 commit into
developfrom
feat/list-pinned
Nov 25, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/list-pinned

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

What

  • Store::list_pinned(namespace, limit) in crates/uteke-core/src/memory/crud.rs: one SQL query over memories WHERE pinned = 1 AND deprecated = 0 [AND namespace = ?], ORDER BY created_at DESC LIMIT ?, selecting through memory_columns!() like every other row_to_memory path.
  • Uteke::list_pinned(namespace, limit) in crates/uteke-core/src/operations/listing.rs, next to list.
  • idx_memories_pinned partial index (namespace, created_at where pinned = 1 AND deprecated = 0): created for fresh stores via SCHEMA_INDEXES, for existing stores via a new v27 → v28 migration (CURRENT_SCHEMA_VERSION 27 → 28).
  • Store tests: pin filter + newest-first ordering, limit (including 0), namespace scoping (Some restricts, None spans all), deprecated exclusion, list_pinned(...).len() == count_pinned(...) consistency, the v28 in-place migration, and an EXPLAIN QUERY PLAN test asserting the per-namespace query is served by the partial index.
  • skill_library_tests::fresh_store_has_the_skill_tables_at_the_current_schema pinned the literal 27; it now compares against CURRENT_SCHEMA_VERSION, which is what its name always meant.
  • CHANGELOG entry under [Unreleased].

Why

Closes #1804. count_pinned exists 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

  • New tests: 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.
  • Full 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 -- --check clean; cargo clippy -p uteke-core --all-targets -- -D warnings clean.
  • EXPLAIN QUERY PLAN on a 500-row store (250 pinned): plan reports USING INDEX idx_memories_pinned, no SCAN memories (asserted in the test, not just observed once).

@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 53e9895 into develop Nov 25, 2026
15 checks passed
@ajianaz
ajianaz deleted the feat/list-pinned branch November 25, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core): list_pinned — return pinned memories in one query instead of paging the whole store

1 participant