feat(core): 支持用户和 peer 级内容目标#2564
Open
qin-ctx wants to merge 2 commits into
Open
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
本 PR 将 OpenViking 的资源、技能、记忆等用户内容目标统一到更明确的
viking://user/...命名空间规则下,并补齐 API、Python SDK、Rust CLI 与检索路径之间的行为一致性。核心目标是让“写入到哪里”和“从哪里检索”不再依赖各调用点各自推断,而是通过统一的内容目标解析规则完成:
viking://resources/...。viking://user/resources、viking://user/skills,服务端会按当前身份 canonicalize 到viking://user/<current_user>/resources或viking://user/<current_user>/skills。viking://user/<user_id>/...或viking://user/<user_id>/peers/<peer_id>/...。peer_id、user_id等路径身份片段统一走共享校验,避免冒号、路径分隔、.、..等不适合作为 URI path segment 的值进入存储路径。举例:
兼容性影响:
peer_id现在必须是安全的单段标识,例如web-visitor-alice;类似web:visitor:alice的值会被拒绝,因为它不符合共享 path segment 校验规则。viking://user/resources、viking://user/skills等短写法现在明确表示“当前请求用户的内容根”,不会被误解为 user_id 等于resources或skills。root_uri后,list/show/find/update/remove可以操作非默认 skills 根,例如 peer skills 根。Related Issue
无关联 issue。
Type of Change
Changes Made
ContentTargetSpec,统一处理to、parent、create_parent的互斥关系、路径变量解析、URI canonicalization 与权限校验,资源和技能写入都复用这一入口。account_id、user_id、peer_id等身份片段的安全规则,并在 namespace、session、CLI 用户标识和 peer 检索路径中复用,避免路径语义漂移。viking://user/...命名空间解析能力,支持当前用户短写内容根、用户级 resources/skills、peer 级 memories/resources/skills,并让 URI 分类、owner 推导、ovpack、VikingFS 路径转换等共享同一套规则。list/show/find/update/remove支持root_uri,add_skill支持to、parent、create_parent,并保证 skill 内容名必须和目标 URI leaf 一致。ovCLI:add-skill支持--to、--parent、--parent-auto-create;ov skills list/show/find/update/remove支持--root-uri,方便管理用户或 peer 的独立 skills 根。peer_id时只额外加入指定 peer 的内容根,不再隐式扫所有 peers。Testing
按前序验证结果,单测已经跑过;本轮创建 PR 时未重复执行完整单测。
已覆盖的关键验证包括:
pytest tests/server/test_api_resources.py tests/server/test_api_skills.py tests/server/test_peer_id_compat.py tests/unit/test_namespace_uri_classification.py tests/cli/test_user_identifier.py tests/client/test_http_client_config.py tests/session/test_session_messages.py tests/session/test_session_commit.py tests/session/test_tool_result_externalization.py tests/session/memory/test_memory_isolation_handler.py tests/session/memory/test_memory_react_system_prompt.py tests/session/memory/test_memory_timestamp_parsing.py cargo test -p ov_cli本轮提交前额外执行过:
Checklist
Screenshots (if applicable)
不涉及 UI 截图。
Additional Notes
这个 PR 主要是收敛底层规则,不是只在单个 API 上加参数。后续如果继续扩展 team/project 级命名空间,建议也沿用
ContentTargetSpec和validate_content_target_uri作为写入入口,避免各调用点重新推断目标路径。