The memory-write path builds directories from unvalidated variables. Observed corruption classes in real workspaces:
- An absolute file path used as a subdirectory chain:
.agents/memory/<squad>/Users/<user>/.../<agent>.md/executions.md (a .md FILE name becoming a directory).
- Falsy values as directory names:
.agents/memory/0/, .agents/memory/null/ — created as recently as today.
Fix: validate path segments before mkdir/write — reject absolute-path fragments, empty/falsy stringifications (0, null, undefined, None), and any segment ending in .md; fail loud instead of writing. Add a unit test per corruption class.
15+ corrupt trees found in a corpus audit; they will be purged, but the writer must stop producing them or the cleanup is Sisyphean.
The memory-write path builds directories from unvalidated variables. Observed corruption classes in real workspaces:
.agents/memory/<squad>/Users/<user>/.../<agent>.md/executions.md(a.mdFILE name becoming a directory)..agents/memory/0/,.agents/memory/null/— created as recently as today.Fix: validate path segments before mkdir/write — reject absolute-path fragments, empty/falsy stringifications (
0,null,undefined,None), and any segment ending in.md; fail loud instead of writing. Add a unit test per corruption class.15+ corrupt trees found in a corpus audit; they will be purged, but the writer must stop producing them or the cleanup is Sisyphean.