diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-16 15:57:20 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-16 15:57:20 +0000 |
| commit | 4e3a785e6aec4f8b2eafad82cb35524359751946 (patch) | |
| tree | 0f38a5033228046d65d9ad8d356bbb9998d073ac /scripts | |
| parent | 345dccb3ea63ac6aa0d9c7d17132bc5e614e545f (diff) | |
| download | ai-memory-4e3a785e6aec4f8b2eafad82cb35524359751946.tar.gz | |
db: never lower the schema stamp, and refuse a store a newer binary wrote
Two failures found by using the store from more than one binary at once.
A stale ai-memory opened a version 5 store and left it stamped version 3.
SQLite cannot drop a column, so the data survived (gist_source was still
there), but the stamp lied -- and the next newer binary then re-ran data
steps it believed were pending. The migration chain ends at the version the
*binary* knows and wrote that number unconditionally, which is what did it.
So: schema_version() reads the version out of the SCHEMA the binary embeds,
so the number lives in schema.sql alone and the two cannot disagree; the
stamp only ever moves forward (`if version > started_at`); and a store whose
version is greater than this binary's is refused before anything is touched:
ai-memory: this store is schema v9; this binary knows v5
ai-memory: it was written by a newer ai-memory -- upgrade this binary
(scripts/install.sh). Nothing was changed.
The second failure was the migration order: a store at version 3 that a
newer binary had already written gists into died on every command with
"no such column: gist_source", because the version 3 -> 4 backfill referenced
a column the version 4 -> 5 step adds. The gist columns are now ensured
(guarded by the table existing, so a fresh store still gets them from SCHEMA)
before any backfill runs, and the skew hint fires on any "no such column" or
"no such table", not only on an empty error message.
Verified: a v9 store is refused with the stamp untouched; a store the stale
binary knocked back to v3 upgrades to v5 with its assessed gists intact; the
gist immutability test still passes; and all six stores on this box are now at
v5 after the new binary opened them. schema_version() needed care in Odin:
SCHEMA is a compile-time constant, so it is copied to a string before being
walked by index.
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions
