Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(core): refuse DOS device names with spaces or superscript digits
Rudy Celekli13d3ded01434
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fee7fa0b..0d4fdde2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,10 @@ version in [`docs/changelog/`](docs/changelog/):## [Unreleased]### Fixed+- Refused two more DOS device spellings at page-write time: a device name+ followed by spaces before its extension (`notes/con .md`), which Windows+ still opens as the device, and the superscript serial and printer ports+ `COM¹`-`COM³` and `LPT¹`-`LPT³` that Windows also reserves.- Fixed `memory_lint` reporting findings for TTL-expired pages. The lint passnow omits expired pages before evaluating episodic staleness, rule suggestions,duplicate titles, and vector or LLM contradiction candidates, preventingdiff --git a/crates/ai-memory-core/src/ids.rs b/crates/ai-memory-core/src/ids.rsindex c03cdde1..cb880e91 100644--- a/crates/ai-memory-core/src/ids.rs+++ b/crates/ai-memory-core/src/ids.rs@@ -1033,17 +1033,21 @@ mod tests {}/// Names Windows reserves regardless of extension: `CON.md` is still the-/// console device.+/// console device. Windows also treats the superscript digits `¹ ² ³` as+/// port numbers, so `COM¹` is a serial port too.const DOS_DEVICE_NAMES: &[&str] = &["con", "prn", "aux", "nul", "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8",- "com9", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9",+ "com9", "com¹", "com²", "com³", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8",+ "lpt9", "lpt¹", "lpt²", "lpt³",];/// Whether `stem` (a file name without its extension) is a DOS device name/// Windows resolves to a device instead of a file, compared case-insensitively.+/// Spaces between the name and its extension are ignored, as Windows ignores+/// them: `CON .md` is still the console.#[must_use]pub fn is_dos_device_name(stem: &str) -> bool {- DOS_DEVICE_NAMES.contains(&stem.to_ascii_lowercase().as_str())+ DOS_DEVICE_NAMES.contains(&stem.trim_end_matches(' ').to_ascii_lowercase().as_str())}/// Characters Windows refuses in a filename. `/` is the separator and is@@ -1122,6 +1126,10 @@ mod portable_page_path_tests {"notes/NUL.md","notes/com1.md","notes/LPT9.txt",+ "notes/con .md",+ "notes/NUL .txt",+ "notes/COM¹.md",+ "notes/lpt³.md","notes/trailing./x.md","notes/trailing /x.md","notes/end.md.",@@ -1177,6 +1185,8 @@ mod portable_page_path_tests {"sessions/2026-08-22.md","notes/icon.md","notes/console.md",+ "notes/con x.md",+ "notes/com10.md","prn-notes/aux-iliary.md","a/b/c/deep.md","notes/dot.in.middle.md",