Skip to content

refactor(core): share one column list between memory SELECTs and row_to_memory - #1346

Merged
ajianaz merged 1 commit into
developfrom
refactor/memory-column-list
Oct 7, 2026
Merged

ajianaz merged 1 commit into
developfrom
refactor/memory-column-list

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

What

  • Add memory_columns!() / memory_columns_m!() (alias m.) next to row_to_memory in memory/store.rs: one definition of the 22-column order the decoder reads by position. They expand to string literals, so SQL stays a compile-time constant (concat!), no runtime format! of column lists.
  • Convert the 26 SELECTs that feed row_to_memory (crud ×17, fts5 ×4, bulk ×2, dream ×2, rooms, aging, orphans).
  • Tests: a round-trip through every reader (get_by_id, get_by_ids, get_by_id_in_namespace, load_all, list ±tag, search_content, list_at_time ±tag, find_similar, find_aged, deprecated_at) and a test that the two macros agree.

Why

Architecture review item "one column list" — see #1339 (tracked in #1345). row_to_memory reads columns by index and silently defaults the tail, so a SELECT that drifts or stops short corrupts data without an error (the FTS5 bug in #1333 was this). It was not limited to FTS5: list, search_content, list_at_time, find_aged, find_similar, find_deprecated_for_prune, room-scoped recall, dream and orphans all stopped at content_type/slug, so memories read through them lost source, source_type, author_type and deprecated_at.

Testing

  • Written test-first: the new round-trip test failed before the conversion (list: source was None) and passes after.
  • cargo fmt --check, cargo clippy --workspace --all-targets clean; cargo test --workspace green; vecq-only core build green.
  • Behaviour change (intended): read paths that used to return default slug/source/source_type/author_type now return the stored values.
  • Not covered: recall_room_scoped, find_deprecated_for_prune, dream load_recent_memories, find_orphans are converted mechanically but not individually round-tripped.

Refs #1339

🤖 Generated with Claude Code

…to_memory

row_to_memory decodes 22 columns by position, but ~26 hand-written SELECTs
repeated (or truncated) the list. Queries that stopped at content_type silently
returned default slug/source/source_type/author_type (e.g. list, search_content,
list_at_time lost them). Add memory_columns!/memory_columns_m! macros that expand
to string literals and compose with concat! into compile-time SQL.

- convert all SELECTs feeding row_to_memory (crud, fts5, bulk, rooms, aging, dream, orphans)
- round-trip test through every reader; macro agreement test

Refs #1339

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@ajianaz ajianaz added enhancement New feature or request scope:core Core engine work labels Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

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 81189ef into develop Oct 7, 2026
15 checks passed
@ajianaz
ajianaz deleted the refactor/memory-column-list branch October 13, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request scope:core Core engine work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant