Repository navigation
feat(macos): saved queries and history on the core stores - #4611
Merged
Merged
Conversation
… favourites, table folders and history
… before validation
…ied into the core's history.db
…ry-profiles # Conflicts: # windows/src/TablePro.Interop/Generated/tablepro_ffi.cs
…index and leaves other TablePro apps running
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.
Summary
Mac stores, lane M3 (core ADR 0010, slices 3 and 9): the saved queries and folders, favourite tables and databases, table folders and the query history get a core copy in
Application Support/TablePro/Core/state/history.db, every record under the Mac's own id.Core (additive, C# regenerated), one API for the Mac and iOS:
SavedQueryStore.contents,write_records,replace_records: every connection's queries and folders with their ids, times, place and keyword, and a digest; a removed folder changes no other row.FavouriteStore.contents,write_records,replace_tables,replace_databases, one digest per kind.TableFolderStore.contents,write_records,replace_records.QueryHistoryStore.put_entries(runs an app recorded, with outcome and error text, or moved in, no core session),record_ids,remove_entries,delete_for_connection.replace_*takes the digest it was based on and refuses withstorage.import_outdated, writing nothing, when the store moved since; the check runs before any validation.Mac:
CoreMirrorcopies a Swift store into the core after every write and at launch. It keeps a digest per record of what both sides held when they last agreed (com.TablePro.coreMirror.<store>):<name> (2), a second keyword is cleared) is written back intosql_favorites.dband marked dirty, so the rename syncs over iCloud.QueryHistoryCoreMirrorputs each run into the core as it is recorded. Its agreement is acore_mirrortable insidequery_history.db, so a damaged file set aside takes it along and the core keeps its runs. A delete, filtered clear or connection delete removes those runs from the core and reports a failure while the core still holds them; Clear History clears the core whole; a retention pass reaches the core.SQLFavoriteManager.applyRemotechecks the policy on the saved-queries store's actor right before each pulled write, through a lock-protected stop count fromSyncCoordinator, so a stop that lands while a write waits for the store commits nothing after it..claude/rules/data-sync-storage.md: rows for the saved queries, favourite databases, table folders, the core's copy and both agreement records.apple/scripts/probes/check-history-downgrade.sh: T-DWN with this build and the previous stable in one sandbox.apple/changelog.d/4611.changed.md: two saved queries of one name in one connection.Not here:
connections.json, which the slice 2 lane moves.Test plan
cargo test -p tablepro-storage --lib: 434 passed, including whole-store writes and replaces, a stale digest refused, two names settled, history put and remove, the journal's ids.cargo test -p tablepro-ffi --no-default-features --test host_stores: 4 passed.SavedQueryCoreMirrorTests,FavoriteCoreMirrorTests,QueryHistoryCoreMirrorTests, including both P1-M4 stops, deletions on both sides after a crash, unreadable favourites, a set-aside history file and a settlement of a record already agreed.verify.sh --jobs 4 buildfor macOS on the MacBook build host: PASS.verify.sh --jobs 4 test, the whole Unit plan: 34,135 executed, 34,134 passed, 1 failed, 2 skipped. The one failure isTableProEditorKitTests/TreeSitterClientTests/test_cancelAllEditsUntilFinalOne(), in the editor package this PR does not touch; run alone it passed andtest_editsDuringSetup()failed instead, both cancellation timing under a load average of 45 to 64 on 10 cores.check-history-downgrade.shwith this build's Debug app and TablePro 0.88.0: PASS.