KeyStore::get reads a data column that is a BLOB, or TEXT of bytes that are no
UTF-8, as text with the odd bytes replaced. The sign-out's unbind step puts that
text back with the binding removed; REBIND (data = ?3) matches nothing for such
a row, so put fell through to the full write: the lossy string replaced the
original bytes (invalid UTF-8 became U+FFFD, a BLOB became TEXT), and for a
TeamSpeak row the replaced text is no identity, so check_teamspeak refused it
and the sign-out could never finish for that row.
- put() now tries a second statement when REBIND changed nothing:
rebind_stored_bytes reads the stored data raw and, if it reads (lossy_text) as
exactly the blob's JSON, updates only the four binding columns by (kind, uid)
(REBIND_BYTES) and returns without check_teamspeak, so the original bytes are
kept and the TeamSpeak case unsticks. Any other JSON is a new identity for the
uid, checked and stored as before.
- The doc sentences at the top of keystore.rs (what a binding-only put and a
non-text data column mean) and docs/architecture.md are narrowed to what holds:
the bytes are kept for the text get returned, any other text replaces them.
Tests: the gate's probe (a bound voelin row with data x'7b2276223aff317d', two
future-kind rows, one a BLOB and one TEXT of no UTF-8, and two TeamSpeak BLOB
rows, one of a good identity and one of garbage): sign_out(Auto) and
sign_out(Forget) are Ok and every data value is byte-identical afterwards; a put
of what get read changes the binding and keeps the bytes; a put of other data is
checked and replaces them. The three tests fail on the previous code.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>