Default fresh memory profiles to v2 (#56211)

## Why

Profiles without a v1 memory workspace have no legacy context to preserve or consolidate before using v2.

## What changed

- Select v2 when memories are enabled and the `memories` directory is absent. Preserve explicit `memories.version` settings, the `memories.dual_write = false` opt-out, and the v1 default for existing workspaces or filesystem check errors.
- Report `v2_ready` immediately for profiles without a v1 workspace. Keep the consolidation count and valid-summary requirements for profiles with a v1 workspace.
- Make resetting an absent memory workspace a no-op so it does not create an unused v1 directory.

## Testing

Extend coverage for default and explicit version selection, opt-outs, version-specific memory reads, fresh-profile readiness and reset behavior, and running only the v2 pipeline for fresh profiles.

GitOrigin-RevId: a8fb0844962ae9266ffbe88af97e8dc4a99ac15f
This commit is contained in:
jif
2026-10-22 16:26:03 +00:00
committed by copyberry
parent 8ba7aed55f
commit a390571745
9 changed files with 131 additions and 29 deletions
@@ -35,10 +35,19 @@ impl ThreadRequestProcessor {
let summary = tokio::fs::read_to_string(root.join("memory_summary.md"))
.await
.ok();
let ready = count >= minimum
&& summary
.as_deref()
.is_some_and(codex_memories_write::workspace::is_valid_v2_summary);
let has_v1_workspace = tokio::fs::try_exists(
self.config
.codex_home
.join(MemoryVersion::V1.directory_name()),
)
.await
.map_err(|error| internal_error(format!("failed to check v1 memory workspace: {error}")))?;
// Fresh profiles can start on V2 without consolidating any V1 history first.
let ready = !has_v1_workspace
|| count >= minimum
&& summary
.as_deref()
.is_some_and(codex_memories_write::workspace::is_valid_v2_summary);
Ok(Some(
MemoryStatusResponse {
v2_consolidated_threads: count,