[Bug]: Experience URIs containing "#" are written and readable but can never receive lineage attribution
Issue Origin
Observed or reproduced in a real environment
Bug Description
Experiences whose file name contains # (or ?) can be written, listed and read, but can never receive an Experience-lineage tag, so they are permanently invisible in Studio → Agent Experience → 「应用效果」.
openviking/session/memory/experience_lineage.py (main, still present in 0.5.5):
def is_experience_uri_for_user(uri: str, user_id: str) -> bool:
"""Return whether ``uri`` identifies an Experience owned by ``user_id``."""
if not uri or "?" in uri or "#" in uri:
return False
Two facts turn this into an inconsistency rather than an intentional restriction:
#has been a legal character in file paths since #4926 (content writes + Markdown references were fixed to support it). Extraction can therefore create.../memories/experiences/<name with #>.md.- Reading such a URI works:
GET /api/v1/content/read?uri=<percent-encoded uri>returns200with the body, andov read '<uri>'returnsrc=0. Only the lineage guard refuses it.
So the write path, the read path and the attribution path disagree about what a valid Experience URI is.
Steps to Reproduce
- Have (or create) an Experience whose name contains
#, e.g.viking://user/default/memories/experiences/合并前abort出口#24诊断覆盖规则.md. - Read it — both succeed:
ov read 'viking://user/default/memories/experiences/合并前abort出口#24诊断覆盖规则.md'→rc=0, body printed.GET /api/v1/content/read?uri=viking%3A%2F%2Fuser%2Fdefault%2Fmemories%2Fexperiences%2F%E5%90%88...%2324...md→200with the body.
- Read it from a session that also produces a trajectory, then check the trajectory record's
search_tagsin the vector index. - Actual: no
<experience uri>=1tag is ever written —is_experience_uri_for_user()returnsFalsebefore the URI reaches tag construction. - Expected: the tag is written, and the Experience appears in
GET /api/v1/agent-evolution/experiences/trajectories?experience_uri=....
Environment
- macOS arm64, OpenViking 0.5.5 (
uv tool install 'openviking[bot]==0.5.5'), server on127.0.0.1:1933,auth_mode=dev, single-node file store. - Corpus when observed: 10,740 Experience files, 13,029 trajectory records, 76,674 indexed records with
search_tags. - 2 of the 10,740 Experience names contain
#(e.g.合并前abort出口#24诊断覆盖规则.md,abort出口#24诊断覆盖规则.md); none contain?.
Expected Behavior
Either reject # / ? at write time (and migrate the existing files), or percent-escape the name before this guard so that attribution keeps working. Today the write path accepts and the attribution path silently drops.
Notes
- Related: #4926 (hash support in file paths), #3727 / #5646 (lineage and attribution), #6540 (failed-read attribution).
- Impact is small (0.02% of names here), but it is a silent one: nothing logs, the Experience simply never shows application trajectories.
I can take the literal # filename case. I’ll trace it through the same Viking URI normalization used by content reads and add a read-attribution and trajectory-query regression. I’ll keep query-parameter handling and the existing ownership checks in place.