Add configurable memory versions with isolated storage (#43797)

## What changed

- Add `memories.version` with `v1` as the default and `v2` as an opt-in selection.
- Route memory generation, summaries, and retrieval tools through the selected version. Store `v2` artifacts in `memories_v2` and lazily create a separate SQLite database, keeping jobs and outputs isolated while sharing the thread catalog.
- Preserve the initial memory version across extension config updates so summaries and retrieval tools use the same namespace.
- Clear both versions on memory reset and remove thread memory from both stores on thread deletion. Recognize both artifact roots in shell usage telemetry.

## Testing

Add regression coverage for version defaults and validation, independent job claims and outputs, deletion and reset across versions, and shell usage classification for both memory roots.

GitOrigin-RevId: aa799bf87ab6ec10c8f5668213931e57547d080b
This commit is contained in:
jif
2026-09-08 10:55:48 +00:00
committed by copyberry
parent 35d9e4bc4d
commit 3f76e88a48
27 changed files with 422 additions and 119 deletions
+21 -1
View File
@@ -80,6 +80,12 @@ const MEMORIES_DB: RuntimeDbSpec = RuntimeDbSpec {
migrate_phase: "migrate_memories",
};
const MEMORIES_V2_DB: RuntimeDbSpec = RuntimeDbSpec {
label: "memories v2 DB",
filename: "memories_v2_1.sqlite",
..MEMORIES_DB
};
const QUEUE_DB: RuntimeDbSpec = RuntimeDbSpec {
label: "queue DB",
filename: QUEUE_DB_FILENAME,
@@ -96,11 +102,12 @@ const THREAD_HISTORY_DB: RuntimeDbSpec = RuntimeDbSpec {
migrate_phase: "migrate_thread_history",
};
const RUNTIME_DBS: [RuntimeDbSpec; 6] = [
const RUNTIME_DBS: [RuntimeDbSpec; 7] = [
STATE_DB,
LOGS_DB,
GOALS_DB,
MEMORIES_DB,
MEMORIES_V2_DB,
QUEUE_DB,
THREAD_HISTORY_DB,
];
@@ -150,6 +157,19 @@ impl SqliteConfig {
MEMORIES_DB.path(self.home())
}
pub(crate) fn memories_v2_db_path(&self) -> PathBuf {
MEMORIES_V2_DB.path(self.home())
}
pub(crate) async fn open_memories_v2_db(&self) -> anyhow::Result<SqlitePool> {
self.open_runtime_db(
MEMORIES_V2_DB,
&crate::migrations::runtime_memories_migrator(),
/*telemetry_override*/ None,
)
.await
}
/// Return the path to the durable user-message queue database.
pub fn queue_db_path(&self) -> PathBuf {
QUEUE_DB.path(self.home())