Skip to content

v1.0.0: switch to TEXT hash primary key and harden sync/model switching#3

Merged
marcobambini merged 6 commits intomainfrom
hash-text-v2
Apr 22, 2026
Merged

v1.0.0: switch to TEXT hash primary key and harden sync/model switching#3
marcobambini merged 6 commits intomainfrom
hash-text-v2

Conversation

@andinux
Copy link
Copy Markdown
Contributor

@andinux andinux commented Apr 21, 2026

Summary

Release 1.0.0. Moves the memory primary key from INTEGER to a hex TEXT hash, makes model/API-key updates robust, and ships several bug fixes.

Breaking: the on-disk schema changed — databases created with <1.0.0 must be rebuilt.

Highlights

  • Hash as TEXT primary keyhash columns (in dbmem_content, dbmem_vault, dbmem_cache) are now 16-char hex strings. memory_delete() takes the hex string, and search results expose
    hash as TEXT.
  • Atomic memory_set_model — model switches run inside a SAVEPOINT and roll back on failure. The previous engine is freed immediately, even when switching across provider classes (custom /
    local / remote).
  • Live memory_set_apikey — updating the API key now takes effect on an already-running remote engine instead of waiting for the next re-init.
  • Transactional directory cleanupmemory_add_directory's "remove entries for deleted files" pass now runs in a single transaction. Per-file ingest transactions continue to isolate
    failures, so one bad file doesn't undo previously-committed files.
  • Bug fixes — reindex loop now propagates errors instead of swallowing them; parser respects heading boundaries when merging sections; FTS context filter dropped a redundant join; local
    embedding engine tightened error paths and fixed a free-on-close leak.
  • Build fix-local and xcframework builds no longer fail to link against the remote engine.
  • Docs — 1.0.0 migration note, corrected .load ./cloudsync example, hex-string memory_delete example.

Test plan

  • make test and make test DEFINES="-DTEST_SQLITE_EXTENSION" pass
  • typeof(hash) = 'text' / length(hash) = 16 in dbmem_content and memory_search; memory_delete('<hex>') works
  • memory_add_directory over a mixed good/bad file set keeps committed files and leaves no partial rows for the failed file
  • memory_set_apikey on a live remote engine takes effect on the next embedding call

marcobambini and others added 6 commits April 20, 2026 09:35
dbmem_set_apikey called dbmem_remote_engine_set_apikey unconditionally,
causing an undefined reference when linking builds compiled with
OMIT_REMOTE_ENGINE=1 (all -local variants and the xcframework target).
Wrap the call in #ifndef DBMEM_OMIT_REMOTE_ENGINE to match the pattern
used elsewhere in the file.
Preserve the transactional behavior added to memory_set_model(), but
release the previous engine after a successful switch even when the new
model uses a different provider class.

Without this, switching between custom, local, and remote providers can
leave the old engine attached to the context until close or until the
same provider class is selected again. For local models this can keep
large model / VRAM allocations resident unnecessarily.

Also add a regression test covering cross-class provider switches to
ensure the previous engine is freed immediately and not double-freed on
database close.
@marcobambini marcobambini merged commit fd4d390 into main Apr 22, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants