From 5547d0a3c38412e23ebf796ca8a33adcf763c768 Mon Sep 17 00:00:00 2001 From: Steven Enamakel <31011319+senamakel@users.noreply.github.com> Date: Sat, 4 Jul 2026 21:33:41 -0700 Subject: [PATCH] =?UTF-8?q?feat(memory):=20W3=20connection=20foundation=20?= =?UTF-8?q?=E2=80=94=20route=20chunks.db=20through=20the=20TinyCortex=20co?= =?UTF-8?q?nnection=20manager=20(#4534)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/openhuman/memory_store/chunks/connection.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/openhuman/memory_store/chunks/connection.rs b/src/openhuman/memory_store/chunks/connection.rs index fb7d0ea81..df8bbfcf8 100644 --- a/src/openhuman/memory_store/chunks/connection.rs +++ b/src/openhuman/memory_store/chunks/connection.rs @@ -593,9 +593,18 @@ pub(crate) fn clear_connection_cache() { /// downstream crates should treat it as internal. #[doc(hidden)] pub fn with_connection(config: &Config, f: impl FnOnce(&Connection) -> Result) -> Result { - let conn_arc = get_or_init_connection(config)?; - let guard = conn_arc.lock(); - f(&guard) + // W3 connection foundation: route ALL production access to + // `/memory_tree/chunks.db` through the TinyCortex connection + // manager. The crate opens the SAME file (its `db_path_for` derives the + // identical `/memory_tree/chunks.db`), applies the identical + // schema + version-gated migrations (`TREE_EMBEDDING`=1, `GLOBAL_TOPIC_PURGE` + // =2 — matched on both sides, so an already-migrated DB is a no-op), and + // migrates any pre-existing WAL database to the TRUNCATE rollback journal in + // place on first open. The former host connection cache below is retired in + // the deletion-ledger follow-up (it is now only referenced by cache-behaviour + // unit tests, which move upstream into the crate). + let mc = crate::openhuman::tinycortex::memory_config_from(config, config.workspace_dir.clone()); + tinycortex::memory::chunks::with_connection(&mc, f) } /// Append `suffix` to the *file name* of `path` (so `chunks.db` + `-wal`