Skip to content

feat(core): UUID record ids for synced kinds - #4587

Merged
datlechin merged 11 commits into
mainfrom
feat/core-uuid-record-ids
Nov 26, 2026
Merged

datlechin merged 11 commits into
mainfrom
feat/core-uuid-record-ids

Conversation

@datlechin

@datlechin datlechin commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Saved queries, saved query folders and query history get a record_id, a random UUIDv4 kept as lower-case text (core ADR 0052). The integer id stays as the rowid the full-text index, pages, pins and upgrade copies use.
  • New migration 20261126000000_record_ids.sql rebuilds saved_queries, saved_query_folders and history, keeping rowids and sqlite_sequence, and recreates the FTS and store-sequence triggers. Linux beta.1 to beta.5 databases upgrade through it, with the ADR 0012 copy made first.
  • A folder's parent and a query's folder are record ids with no foreign key; no synced table has ON DELETE CASCADE or SET NULL. Deleting a folder deletes its subfolders and moves its queries to the top in the store's code, and a connection delete lifts other connections' records out of its folders.
  • connection_id is optional: a query or folder with no connection shows in every connection. Uniqueness follows 0052: names per connection or none, folder names per connection and parent, a keyword unique wherever its query expands.
  • SavedQueries::put and SavedQueryFolders::put write records a pull or another store brings under their own ids and settle name and keyword collisions by created_at (now milliseconds), then id bytes, renaming to <name> (2) or clearing the keyword. They store names and keywords in the form the indexes compare, cap names at 200 characters, break folder cycles and lift folders past 64 levels.
  • Upgrade-copy trimming maps record ids back to rowids for copies in the old format, settles names its projection lifts to one place, and trims a deleted connection's queries and folders by rowid.
  • The store API names queries and folders by Uuid; history entries gain record_id; FolderCycle carries a Uuid.
  • FFI: saved query and folder ids, folder references and the draft's connection are UUID text, infos carry connection_id, history entries carry record_id. Windows bindings regenerated.
  • Callers: tablepro-records maps the history rowid as device-only and record_id as the id; foreign import, MCP; the Linux sidebar, saved queries dialog and quick open; the Windows interop and app (Guid ids; the edit dialog keeps a folder it cannot show).
  • Tests changed on purpose: favourites_migration_tests and the copy tests in backup_folders compare by name or build old-format copies through a real beta upgrade, since the API no longer gives rowids. On Linux, malformed_hierarchies_are_refused_instead_of_hiding_queries_or_recursing drops its orphan case and new_folder_requires_a_successful_read_and_an_invalid_graph_keeps_the_last_good_rows uses a cycle as its invalid graph, since a missing folder now reads as the top level per 0052. Migration counts move to 6.
  • Docs: linux/docs/storage.md; Linux changelog fragment.

Test plan

  • cargo test -p tablepro-storage: migration fixtures from Linux beta.3 and beta.5 databases (ids are distinct v4, filing, keywords, times, pins, FTS search, sequences and the copy), folders nested past the cascade limit, no foreign key or referential action, collision rules (created in one second, ids that sort the other way, any batch order, keywords across connections and none, swaps), put normalization, caps and cycles, copy trimming of both formats.
  • cargo test -p tablepro-ffi --test saved_queries --test history --test foreign_import --test library --test library_details --test cloud_library, -p tablepro-records -p tablepro-foreign-import -p tablepro-mcp -p tablepro-cli.
  • Linux dev container: verify.sh --platform linux test (8 of 8 suites, 9372 passed, the copy tests on Linux's SQLite included) and lint (rustfmt, clippy with and without default features).
  • Windows on macOS: verify.sh --platform windows bindings (no diff after regeneration) and test (2506 passed) on the rebased tree; later commits change only core storage internals, Linux and docs.
  • On macOS 27 the system SQLite 3.54 refuses VACUUM INTO the pre-created copy file, so the copy tests fail locally there, as on main; they pass on Linux.
  • Review: Codex review rounds 1 and 2 and a Codex security pass, then Claude (fresh agent) review and Claude (fresh agent) security pass while Codex was at its limit; every finding is fixed with a test.

@datlechin
datlechin enabled auto-merge (squash) November 25, 2026 22:10
@datlechin
datlechin merged commit b055e28 into main Nov 26, 2026
34 checks passed
datlechin added a commit that referenced this pull request Nov 26, 2026
@datlechin
datlechin deleted the feat/core-uuid-record-ids branch November 27, 2026 16:37
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.

1 participant