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 authored and copyberry committed 2026-09-08 10:55:48 +00:00
1 parent 35d9e4bc4d
commit 3f76e88a48
27 files changed
+422 -119

No files matched your search

+5
View File
@@ -44,6 +44,7 @@ pub fn memories_usage_kinds_from_command(command: &str) -> Vec<MemoriesUsageKind
}
fn get_memory_kind(path: String) -> Option<MemoriesUsageKind> {
let path = path.replace("memories_v2/", "memories/");
if path.contains("memories/MEMORY.md") {
Some(MemoriesUsageKind::MemoryMd)
} else if path.contains("memories/memory_summary.md") {
@@ -58,3 +59,7 @@ fn get_memory_kind(path: String) -> Option<MemoriesUsageKind> {
None
}
}
#[cfg(test)]
#[path = "usage_tests.rs"]
mod tests;
+22
View File
@@ -0,0 +1,22 @@
//! Regression coverage for versioned memory paths in shell usage telemetry.
use super::MemoriesUsageKind;
use super::memories_usage_kinds_from_command;
use pretty_assertions::assert_eq;
#[test]
fn classifies_reads_in_both_memory_versions() {
for root in ["memories", "memories_v2"] {
let command = format!(
"cat /tmp/.codex/{root}/memory_summary.md && cat /tmp/.codex/{root}/rollout_summaries/thread.md"
);
assert_eq!(
memories_usage_kinds_from_command(&command),
vec![
MemoriesUsageKind::MemorySummary,
MemoriesUsageKind::RolloutSummaries,
],
"memory root: {root}"
);
}
}