From 04c48dd0fe74e0db801304604b7029b2a914d846 Mon Sep 17 00:00:00 2001 From: igorls <4753812+igorls@users.noreply.github.com> Date: Mon, 27 Apr 2026 03:01:41 -0300 Subject: [PATCH] fix(chroma): write blob-fix marker even when narrowing skips all rows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The narrowed _fix_blob_seq_ids returned early when safe_rows was empty, but #1177's marker contract requires the marker to be written on every successful pass — even no-op — so subsequent opens skip the sqlite3 connection entirely. Without this, palaces that have no genuine 0.6.x BLOBs but DO have sysdb-10-prefixed rows would re-open sqlite3 on every call, defeating the #1090 corruption guard. Restructured the conditional so the marker write is unconditional after a successful sqlite scan, regardless of whether any rows were updated. Surfaced by test_fix_blob_seq_ids_writes_marker_when_already_integer during the develop-rebase of this PR. The author's branch predates the marker contract from #1177 (merged 2026-04-26), so this is a rebase-edge fix-up rather than a logic change to their narrowing behaviour. --- mempalace/backends/chroma.py | 13 +++++++------ tests/test_backends.py | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mempalace/backends/chroma.py b/mempalace/backends/chroma.py index 5f3540e..ac28f0b 100644 --- a/mempalace/backends/chroma.py +++ b/mempalace/backends/chroma.py @@ -561,12 +561,13 @@ def _fix_blob_seq_ids(palace_path: str) -> None: "Skipped %d sysdb-10-format BLOB seq_id(s) in embeddings (not converting)", skipped, ) - if not safe_rows: - return - updates = [(int.from_bytes(blob, byteorder="big"), rowid) for rowid, blob in safe_rows] - conn.executemany("UPDATE embeddings SET seq_id = ? WHERE rowid = ?", updates) - logger.info("Fixed %d BLOB seq_ids in embeddings", len(updates)) - conn.commit() + if safe_rows: + updates = [ + (int.from_bytes(blob, byteorder="big"), rowid) for rowid, blob in safe_rows + ] + conn.executemany("UPDATE embeddings SET seq_id = ? WHERE rowid = ?", updates) + logger.info("Fixed %d BLOB seq_ids in embeddings", len(updates)) + conn.commit() except Exception: logger.exception("Could not fix BLOB seq_ids in %s", db_path) return diff --git a/tests/test_backends.py b/tests/test_backends.py index 9a609d1..7ff24f9 100644 --- a/tests/test_backends.py +++ b/tests/test_backends.py @@ -507,6 +507,7 @@ def test_fix_blob_seq_ids_skips_sqlite_when_marker_present(tmp_path): mock_connect.assert_not_called() + # ── quarantine_stale_hnsw ─────────────────────────────────────────────────