Memory titles containing "/" create an unintended directory and truncate the filename
Summary
When memory extraction produces a memory whose title contains a forward slash, the slash is treated as a path separator while the memory is being written. Instead of a single file named after the title, OpenViking creates an extra directory level and keeps only the part of the title after the slash as the filename.
Reported by a user.
Steps to reproduce
- Run memory extraction on content that leads the extractor to emit a memory title containing
/— for example a title of the formA/B experiment guidelines. - Inspect where that memory was written under the memories tree.
Actual behaviour
The title is interpolated into the memory URI without escaping, so the / is consumed as a path separator:
.../memories/<...>/A/B experiment guidelines.md
^ unintended directory level
The segment before the slash (A) becomes a directory, and only the segment after it (B experiment guidelines) survives as the filename. The title is effectively truncated, and one memory ends up nested one level deeper than its siblings.
Expected behaviour
A title should be sanitized before it is used as a path segment: / (and other path separators) should be escaped or replaced so that one memory always maps to one file at the intended level, e.g.
.../memories/<...>/A_B experiment guidelines.md
The original title should stay unchanged in the memory fields; only the generated path should be sanitized.
Notes
Possibly related to #4517, which recently addressed Windows-unsafe characters in generated memory URIs — the escaping mechanism introduced there may be reusable here.
Thanks to @FQYQC for reporting.
Closing this in favor of #4551, which appears to track the same underlying issue (path segments are derived after template rendering, so / in dynamic values creates extra hierarchy). Thanks again @FQYQC for the report.
https://github.com/volcengine/OpenViking/pull/4587
Additional evidence: new entries created directly as empty directories during batch memory writes
Relation to this issue: #4558 covered titles containing /. The cases below are the same class of failure — a memory entry ends up as a directory instead of a file — but with names that contain neither / nor spaces, so the fix for #4558 does not cover them. In the last case the body never reached storage at all.
Observed cases (all under viking://user/<ns>/memories/experiences/)
| # | entry | directory modTime (UTC) |
name has / or space |
recoverable from backup |
|---|---|---|---|---|
| 1 | v2 operation content verification.md |
2026-10-07T03:48:05Z | space | yes |
| 2 | v2 operation white list verification.md |
2026-10-07T03:48:05Z | space | yes |
| 3 | v2 operation white list verification.md (recurrence) |
2026-10-09T03:07:41Z | space | yes |
| 4 | 步骤XML字节解码.md |
2026-10-11T10:03:19Z | neither | yes |
| 5 | v2 operation content verification.md (recurrence) |
2026-10-11T16:21:19Z | space | yes |
| 6 | SQL契约文档一致性审查.md |
2026-10-15T22:05:57Z | neither | no — body never stored |
Hardest case (#6): created as an empty directory, body never stored
stat on the damaged entry:
name = SQL契约文档一致性审查.md
isDir = true
count = 0
size = 4096
mode = 493
isLocked = false
modTime = 2026-10-15T22:05:57Z
Same-second control — two entries written in the same batch are normal files:
| entry | modTime (UTC) |
isDir |
size |
|---|---|---|---|
DHR V2审查前置核对.md |
2026-10-15T22:05:58Z | false | 6792 |
V2设计包状态核验.md |
2026-10-15T22:05:58Z | false | 2799 |
SQL契约文档一致性审查.md |
2026-10-15T22:05:57Z | true | 4096 |
Proof the body never existed: 10 consecutive .ovpack backups of the parent directory (spanning 2026-10-06 → 2026-10-16, including one taken after the timestamp above) contain no size > 0 entry for this name — only a 0-byte directory placeholder (experiences/files/SQL契约文档一致性审查.md/). If the entry had ever been written as a file, the 2026-10-16 backup would contain it.
Common pattern
Every case falls inside a batch memory write (session_commit / memory extraction). In each case, other entries written in the same second landed correctly as files, while one became an empty directory.
- Cases 1–5: "file → directory" (body lost, but recoverable from backup)
- Case 6: "created as directory" (body never stored, unrecoverable)
This distinction matters: it suggests the defect may be in the entry-creation stage of the write path, not only in a later normalization step.
Expected behaviour
- A memory entry must map to exactly one file. Title/path segments should be sanitized — including
/, path separators, spaces, and any character the storage layer treats as a directory boundary — before being interpolated into a URI. - If an entry cannot be written as a file, the write should fail loudly rather than silently produce an empty directory that still occupies the URI and hides the missing content.
Acceptance criteria
- Writing a memory whose title contains
/, a space, or CJK characters yields exactly one file at the intended level, with the original title preserved in the memory fields. - A failed or partial entry write surfaces a failed job (not
Completed), and leaves no empty directory holding the URI. - A regression test that runs the semantic worker over a batch write and asserts
isDir=falseandsize > 0for every entry in the batch.
Environment
- Server: v0.4.20.6 (hosted deployment)
- Client:
ovCLI v0.4.23 - Scope:
viking://user/<ns>/memories/experiences/ - Observed on 6 entries between 2026-10-07 and 2026-10-15, all during batch memory writes