Repository navigation
Saves no longer fail on stray non-UTF-8 bytes - #351
Merged
Merged
Conversation
…hat are not UTF-8 The embedding worker answers on its stdout in JSON lines. A model library that writes to the same file descriptor (a warning in the console's legacy code page, a progress line) put raw bytes into that channel. The parent read the pipe as strict UTF-8 in the locale's default encoding, so: - on the thread reader (Windows pipes) the read raised "'utf-8' codec can't decode byte 0x81 in position 2: invalid start byte" out of embed(); the materializer stored that as the save's error on every attempt and dead-lettered it; - on POSIX the same bytes were swallowed as a timeout, the worker was killed and the save failed on its missing embedding. The worker now keeps the parent's pipe for replies only: it replies on a private copy of the descriptor and points descriptor 1 and sys.stdout at stderr, which the parent discards, before any model library loads. Its stdin is read as UTF-8. The parent opens both pipes as UTF-8 with replacement, so a stray byte is a malformed line handled by the existing respawn path, never an exception. Only the vector channel is decoded tolerantly; memory content is sent as ASCII-escaped JSON and is stored unchanged. A save that dead-lettered with this error completes on an operator retry (slm ops resolve <id> --action retry) and its dead-letter row clears. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ds bytes that are not text SQLite keeps whatever a writer binds: a bytes value lands in a TEXT column as a BLOB and comes back as bytes, and json.loads(bytes) decodes strictly. One such row in atomic_facts (entities_json, canonical_entities_json, source_turn_ids_json, langevin_position, shared_with), memory_scenes (entity_ids_json), entity_profiles (fact_ids_json) or memories (metadata_json) made every later save whose enrichment read the row fail with "'utf-8' codec can't decode byte 0x81 in position 2: invalid start byte", and dead-lettered it after ten attempts. This is the only path found that gives that exact text on macOS and Linux. storage/json_columns.load_json_column reads a BLOB holding UTF-8 JSON as before; one that is not text reads as the column's empty value and is reported once per column with a query to find such rows. The damaged row is left as it is: nothing is rewritten or invented. Text values behave exactly as before. Used by the fact, scene, entity-profile and memory readers on the enrichment path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d a non-text body is refused, not a crash The recall and reranker workers had the embedding worker's flaw: a library printing on file descriptor 1 put bytes that are not UTF-8 into the reply pipe, and the parent decoded it strictly. On the thread reader that raised a decode error out of the request; on POSIX the reply was lost as a timeout and the worker was killed. core/worker_stdio.claim_protocol_channel, now shared by all three workers, sends replies on a private copy of the descriptor and points descriptor 1 and sys.stdout at stderr before any model library loads; stdin is UTF-8. The recall pool and the reranker open their pipes as UTF-8 with replacement. outbound_http.outbound_content decoded a request body before its guard, so a body that is not UTF-8, bound for another machine, raised a bare decode error instead of the intended OutboundBlocked. The decode is inside the guard now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…perator retry A store whose older facts hold non-UTF-8 bytes in entities_json and whose scenes hold them in entity_ids_json: with the reader as it was, a related save fails every automatic attempt and is dead-lettered with the codec error. With the tolerant reader, `slm ops resolve <id> --action retry` completes it with its text unchanged and clears the dead-letter row, and the damaged rows are left as they were. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…le and column A JSON text column holding bytes that are not text used to fail every save that read its row. The readers now treat such a value as empty; doctor's new "Stored JSON values" row (also in `slm doctor --json`) counts BLOB values in each column those readers cover, as table.column -> count. It warns, never fails, says the rows are read safely and nothing is changed, and prints the read-only query that lists them. It opens the store read-only and repairs nothing. The column list lives beside the reader (TOLERATED_COLUMNS), so the two cannot drift apart. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y pipe is flushed when it is stopped Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… tells readable ones from unreadable ones Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…are kept, and saving the same text again no longer fails on it An entity profile, scene, fact entity column or langevin position that holds bytes which are not text used to be replaced by a value built from empty, and the bytes were lost. Writers now rebuild from the facts and keep the original bytes in a version row or the change ledger. A source row with damaged metadata is never merged into on a re-save, and is not a same-context candidate. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…st a damaged stored value instead of failing Every reader of a stored JSON column that decoded it strictly now reads it tolerantly, so one value holding bytes that are not text no longer fails a dashboard listing or an export. A damaged audience or member list still fails closed where it guards visibility. A ratchet test fails if a strict decode of such a column returns. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…copies Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ontext hides sources or media Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…het follows a column value through a local name Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… facts, so erasing one removes it Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…and undo of the damaged-values run restores them Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…r the platform; doc_pages.fact_ids_json is read tolerantly and counted from the media store Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…le table Saving a scene or an entity profile asked `damaged_ids`, which runs `typeof(col)='blob'` over every row of the profile: no index can serve it, so each save paid a full scan of memory_scenes or entity_profiles on a mature store. `row_is_damaged` looks the one row up by its id. Batch passes keep `damaged_ids`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Saves were dead-lettered with
'utf-8' codec can't decode byte 0x81 in position 2.slm doctorgains a read-only "Stored JSON values" row that counts such values per column and says what happens to each.slm ops resolve <id> --action retry.🤖 Generated with Claude Code