OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: Experience URIs containing "#" are written and readable but can never receive lineage attribution

Open za8209 opened this issue 2 weeks ago • 1 comments

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:

  1. # 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.
  2. Reading such a URI works: GET /api/v1/content/read?uri=<percent-encoded uri> returns 200 with the body, and ov read '<uri>' returns rc=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

  1. Have (or create) an Experience whose name contains #, e.g. viking://user/default/memories/experiences/合并前abort出口#24诊断覆盖规则.md.
  2. 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 → 200 with the body.
  3. Read it from a session that also produces a trajectory, then check the trajectory record's search_tags in the vector index.
  4. Actual: no <experience uri>=1 tag is ever written — is_experience_uri_for_user() returns False before the URI reaches tag construction.
  5. 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 on 127.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.

za8209 avatar Nov 14 '26 11:11 za8209

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.

123XieC avatar Nov 14 '26 13:11 123XieC