Sanitize text as it enters the analytics cache, preserve valid text and
NULLs, report repair operations after successful builds, and explain the
repair path when fast search encounters an older invalid cache, including
conversation freshness fingerprints.
Identity attribution keys — account identity addresses, participant
emails, identifier types and values, and recipient envelope addresses and
types — are excluded instead of repaired when their stored bytes are
invalid UTF-8: they never match and export as unknown. A U+FFFD
placeholder would let two distinct invalid byte sequences collide onto
one key and mis-attribute messages to the owner, and DuckDB's CSV
snapshot fallback cannot carry invalid bytes, so it writes NULL for those
columns and both snapshot paths apply the same collision-free rule.
A recorded From envelope stays authoritative even when its bytes are
damaged: envelope presence is byte-level (SQLite TRIM semantics over raw
bytes on the sqlite_scanner path; an envelope_present column computed by
SQLite on the CSV path), so a present-but-invalid envelope never matches
an identity, still suppresses the participant fallback, and the
recipients export leaves both address columns NULL instead of
substituting the participant's current address. 'msgvault
repair-encoding' followed by a full rebuild restores attribution for
damaged archives.
- test(vector): satisfy test sleep checks after rebase
The rebased test suite uses synctest for in-process usage accounting and
documents the real delay needed by the external SQLite worker.
Generated with Codex
Co-authored-by: Wes McKinney <wesmckinn+git@gmail.com>
Co-authored-by: Codex <noreply@openai.com>
What changed
Why
One malformed archived text value can make a cache build or fast search fail when DuckDB reads the exported data. The cache should remain usable while showing the operator how to repair the source archive.
Usage
Existing
msgvault build-cacheand fast search commands work as before. If a build reports repairs, runmsgvault repair-encodingand thenmsgvault build-cache --full-rebuildto repair the archive and replace the cache.