Repository navigation
fix(storage): match cache keys exactly on every database, like GitHub does - #286
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…river GitHub's cache service compares keys exactly. MySQL's default collation compared `key` and `scope` case- and accent-insensitively, and SQLite's `like` ignored ASCII case, so `foo` could restore or overwrite `Foo`. Closes #284 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
On MySQL, a Cache Entry for
foocould be restored by, or overwritten by, a save ofFoo,fóoorfoo. The default collation compares keys and scopes case-, accent- and trailing-space-insensitively. SQLite'slikealso ignored ASCII case for restore-key prefix matches. Postgres compared exactly, so the same workflow behaved differently depending on the database.A test run against GitHub's own cache service confirmed it matches exactly. Restoring
casefooafter savingCaseFoomisses for both the exact key and the restore-key prefix. RestoringCafeafter savingCafémisses too. SavingcasefoowhileCaseFooexists creates a second, separate entry. This PR makes every driver behave that way:scopeis included because it had the same collation and branch refs are case-sensitive. This PR also renamesCONTEXT.mdtoGLOSSARY.mdto match the domain-modeling naming.✅ Verification
tests/exact-key-matching.test.tsmirrors the GitHub run:VITEST_DB_DRIVER=sqliteandmysql(expected { match: … } to be undefined)After: passes on sqlite, postgres and mysql
pnpm test:matrix: all 12 DB × storage combinations passpnpm type-check,pnpm lint,pnpm build: pass🔍 Reviews
Unfixed findings:
upanddownwas skipped, since every other migration mirrors them inline.completeUploadlooks up uploads byreservationHashis out of scope.case_sensitive_likeis deprecated in SQLite but still supported by better-sqlite3; the new test catches it on the sqlite run if that ever changes.🔗 Issues
Closes #284
💥 Merge danger
Door: two-way
The migration's
downrestores the default collation.Blast Radius: MySQL
MySQL deployments rebuild
cache_entriesanduploadson startup (ALTER TABLE … MODIFY), which can take a while on large tables. After the upgrade, a workflow that only hit because of case, accent or trailing-space differences now misses, matching GitHub.utf8mb4_0900_binrequires MySQL 8.0.17+; MariaDB lacks it.🤖 Generated with Claude Code