mirror of
https://github.com/openai/codex.git
synced 2026-10-23 18:08:45 +00:00
## Why Memory usage telemetry identifies artifact kinds but does not distinguish reads from `memories` and `memories_v2`. ## What changed Return each artifact's memory version from shell command classification and add a `memory_version` tag (`v1` or `v2`) to usage counters. Normalize Windows path separators before classifying memory paths. ## Testing Extend regression coverage for both memory versions with Unix and PowerShell reads, and add a test for commands that read artifacts from both roots. GitOrigin-RevId: 68eaab3af0317613e4969e8c4e5478b18255ca52
47 lines
1.7 KiB
Rust
47 lines
1.7 KiB
Rust
//! Regression coverage for versioned memory paths in shell usage telemetry.
|
|
|
|
use super::MemoriesUsageKind;
|
|
use super::memories_usage_from_command;
|
|
use codex_protocol::MemoryVersion;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn classifies_reads_in_both_memory_versions() {
|
|
for version in [MemoryVersion::V1, MemoryVersion::V2] {
|
|
let root = version.directory_name();
|
|
for (reader, root) in [
|
|
("cat", format!("/tmp/.codex/{root}")),
|
|
("Get-Content", format!(r"C:\Users\test\.codex\{root}")),
|
|
] {
|
|
let command = format!(
|
|
"{reader} '{root}/memory_summary.md' && {reader} '{root}/rollout_summaries/thread.md'"
|
|
);
|
|
assert_eq!(
|
|
memories_usage_from_command(&command),
|
|
vec![
|
|
(MemoriesUsageKind::MemorySummary, version),
|
|
(MemoriesUsageKind::RolloutSummaries, version),
|
|
],
|
|
"memory root: {root}"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn attributes_mixed_version_reads_to_their_roots() {
|
|
let command = "cat /tmp/.codex/memories/MEMORY.md \
|
|
&& sed -n '1,20p' /tmp/.codex/memories_v2/rollout_summaries/thread.md \
|
|
&& cat /tmp/.codex/memories/raw_memories.md \
|
|
&& cat /tmp/.codex/memories_v2/skills/testing/SKILL.md";
|
|
assert_eq!(
|
|
memories_usage_from_command(command),
|
|
vec![
|
|
(MemoriesUsageKind::MemoryMd, MemoryVersion::V1),
|
|
(MemoriesUsageKind::RolloutSummaries, MemoryVersion::V2),
|
|
(MemoriesUsageKind::RawMemories, MemoryVersion::V1),
|
|
(MemoriesUsageKind::Skills, MemoryVersion::V2),
|
|
],
|
|
);
|
|
}
|