Skip to content

feat(memory): 支持 Portal 查看经验记忆 - #734

Open
openjiuwen-sync-bot[bot] wants to merge 1 commit into
openJiuwen-ai:release/0.2.2from
openjiuwenai:sync/pr-523
Open

openjiuwen-sync-bot[bot] wants to merge 1 commit into
openJiuwen-ai:release/0.2.2from
openjiuwenai:sync/pr-523

Conversation

@openjiuwen-sync-bot

@openjiuwen-sync-bot openjiuwen-sync-bot Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Paired: GitHub #734 ↔ GitCode !523

What type of PR is this?

/kind

Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)

    • 设计:PR对应的方案是否已经经过Maintainer评审,方案检视意见是否均已答复并完成方案修改
    • 测试:PR中的代码是否已有UT/ST测试用例进行充分的覆盖,新增测试用例是否随本PR一并上库或已经上库
    • 验证:PR描述信息中是否已包含对该PR对应的Feature、Refactor、Bugfix的预期目标达成情况的详细验证结果描述
    • 接口:是否涉及对外接口变更,相应变更已得到接口评审组织的通过,API对应的注释信息已经刷新正确
    • 文档:是否涉及官网文档修改,如果涉及请及时提交资料到Doc仓

Linked Closing Issues:

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 11604cb65f415d14d20e0b0c8ddf61f24b0e46a2

变更摘要

本 PR 为 Portal 增加“经验记忆”只读查看能力:宿主可通过 experience_space 在打开页面时绑定经验空间,Portal 会话据此读取该空间内当前用户有权查看的有效经验(memory_type=experience),并支持查看详情、关联技能、经验来源以及个人评价。新增的 experience_list、experience_get、experience_rate 三个浏览器侧接口与数据面查询、会话绑定、共享 Portal 分发链路一并打通,前端新增经验详情抽屉与筛选交互。

主要改动

  • 新增 Portal 经验接口与只读约束:jiuwen_memory_entry/portal/requests.py 新增 EXPERIENCE_VERBS、portal_experience_space、_list_experiences、_read_experience、_related_skills 等,invoke_browser_api 增加 experience_space 参数并按经验空间构造 Scope;_require_active_record 对经验记录直接返回 PermissionDeniedError,使 Portal 侧经验不可纠正/遗忘。
  • 数据面支持经验来源与个人评价:query_ops.py 新增 experience_task_sources(仅披露当前用户有权限的会话/任务引用)与 experience_feedback(以 sha256 派生的 KV 键保存个人 helpful/neutral/harmful 评价,支持 read/clear);common/experience.py 增加 UtilityStore.reproduction_sources 读取跨版本的来源坐标;space_roles.py 注册 experience_source 入口规则为内容轴读权限。
  • 经验空间与会话绑定:sessions.py 的 issue 增加 page_bound,新增 redeem_for_page 并在 bootstrap 响应中返回 experience_bound;http_server/__main__.py、portal/hosting.py、portal/shared.py 在 launch 载荷中携带并校验 experience_space,将其随 _BrowserAccess 与运行时请求向下传递,共享 Portal 对经验动词限制在同一 Provider 上分发。
  • Adapter 打开 Portal 时传参:agent_memory_provider.py 抽出 _portal_launch_options,在经验能力开启时附加 experience_space;_HttpClient.open_portal 新增 experience_space 关键字参数并写入 /portal/api/launch 请求体。
  • Portal 前端新增经验视图:portal/index.html 新增经验分类筛选、经验卡片(评价计数、技能标记)、experience-dialog 详情抽屉与评价按钮、来源/技能跳转,并对经验记录隐藏新增、纠正、遗忘入口;同时补充中英文文案与对应测试。

测试覆盖:新增/扩展了 test_document_portal.py、test_http_server_security.py、test_entry_rules.py 与 portal_frontend_test.cjs,覆盖经验列表/详情/评价、空间绑定与未绑定返回 404、只读限制及前端交互。

@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

head_sha: 11604cb65f415d14d20e0b0c8ddf61f24b0e46a2

代码审查

审查结论

发现汇总(共 4 条)

优先级 数量 位置
P0 0 —
P1 0 —
P2 1 jiuwen_memory/api/memory_api_impl/query_ops.py:991-999(经验来源披露鉴权路径缺运行期覆盖)
P3 3 requests.py:130-137(全量扫描 + N+1 反馈查询)、agent_memory_provider.py:1117-1122(失效的 if/else 与同步阻塞)、requests.py:31-35(portal_experience_space 边界与 _label 不一致)

逐文件复核情况

文件 结论
docs/en/Agent Integration Guide/Portal User Guide.md 无问题(新增段落与实现、launch_url//portal/api/launch 行为一致)
docs/features/F05-personal-memory-portal.md 无问题(列表/详情/个人评价的描述与前后端实现一致)
docs/features/common/F04-security-interfaces-and-encryption.md 无问题(“先查条目读取权限,再按来源 Scope 查内容 READ”与 experience_task_sources 一致)
docs/specs/S02-memory-api.md 无问题(三个经验接口的参数集与 _list_experiences/_read_experience 的 allow-list 一致)
docs/specs/S10-security.md 无问题(会话票据存 history state、共享 Provider 绑定、401 语义均已实现)
docs/zh/Agent接入指导/Portal使用指南.md 无问题
jiuwen_memory/api/memory_api_impl/query_ops.py P2:experience_task_sources 的 experience_source 鉴权分支无任何测试触达;reproduction_sources 与写入端键布局漂移不会被告警
jiuwen_memory/common/AGENTS.md 无问题(新增约束与 ENTRY_RULES 登记一致)
jiuwen_memory/common/experience.py 无问题(reproduction_sources 前缀/五元组/trajectory_id 对齐与 reproduction_event_key、appraiser 写入一致)
jiuwen_memory/common/security/space_roles.py 无问题(新入口落内容轴 READ,不在 OWNER_ENTRY_* 治理清单内,与并行登记表无冲突)
jiuwen_memory_adapter/jiuwenswarm/agent_memory_provider.py P3:open_portal 两分支参数已无差异,identity 场景仍同步阻塞
jiuwen_memory_entry/http_server/main.py 无问题(会话四元组 issue/lookup 对称;未绑定会话路径无法调用 EXPERIENCE_VERBS)
jiuwen_memory_entry/portal/hosting.py 无问题(launch_url(page_bound=…) 与 dispatch 传参一致)
jiuwen_memory_entry/portal/index.html 无问题(新内容全部经 node()/setText() 写入,无内联事件/innerHTML;新增 dialog id 唯一、关闭按钮有 data-i18n-label;聚焦陷阱已登记;时间标签函数经 textOf 惰性求值)
jiuwen_memory_entry/portal/requests.py P3 ×2:列表 N+1 全量扫描;portal_experience_space 边界不一致
jiuwen_memory_entry/portal/sessions.py 无问题(page_bound 强制 embedded、三元 grant 与 _prune/revoke 下标一致、cookie 分支仍返回 (cookie, False))
jiuwen_memory_entry/portal/shared.py 无问题(provider_bound 只在经验动词上收紧为 opening instance,配置动词分支未受影响)
tests/integration/portal/test_document_portal.py 无问题(导入齐全,Browser/document_config 用法与新链路一致)
tests/unit/common/security/test_entry_rules.py 无问题(表项断言与实现相符)
tests/unit/jiuwen_memory_entry/portal_frontend_test.cjs 无问题(断言与 cards()/renderExperienceFeedback 的真实 DOM 层级一致)
tests/unit/jiuwen_memory_entry/test_http_server_security.py 无问题(fixture param 间接参数化不影响未参数化的既有用例;Role/Scope 已导入)

总体风险判断

改动方向清晰、防线基本闭合:组织取自认证身份、空间由宿主签发时绑定、浏览器不能自带 Scope、经验条目在 Portal 侧统一只读(含 _require_active_record 新增的拒绝),来源任务/会话按来源 Scope 二次鉴权且失败即隐藏,未绑定空间统一 404。未发现可触发的权限绕过、注入或数据破坏问题;主要风险集中在两处:一是新增的跨 Scope 来源披露鉴权路径完全没有运行期测试(P2,回归会以“永远不显示来源”或整条 experience_get 报错的形式出现而无人察觉),二是经验列表每次请求全量物化并逐条追加鉴权+读(P3,随条目数线性恶化)。建议合入前至少补上来源披露与 Markdown 模式下个人评价的往返用例,并把列表的反馈计数改为一次批量读取。

类型 数量
🔴 阻塞 0
🟡 建议 2

💬 仅评论

try:
self._authorize(security, target, Action.READ, "experience_source")
except (NotFoundError, PermissionDeniedError):
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head_sha: 11604cb65f415d14d20e0b0c8ddf61f24b0e46a2

🟡 Medium Priority

改动行(query_ops.py 983-1007):新增的 experience_task_sources 是本 PR 唯一新增的跨 Scope 鉴权路径——它按复现事件里的五元组重建来源 Scope,再用新登记的入口 experience_source 逐条做内容轴 READ 鉴权(space_roles.py 212),失败才跳过。

证据链与未被覆盖的失效模式:

建议:在 tests 中构造一条带 repro 事件(write_reproduction_event,source_scope 五元组与轨迹同用户)的经验,断言同用户可见来源、跨用户或来源空间无读权限时 sources 为空;并在 write_document 参数化分支里补一次 experience_rate + experience_get 的往返断言。

if(name==='search'){await switchTab('memories');setSearchMode('semantic');$('memory-filter').focus();return;}
notice('');closeDetail();clearTimeout(filterTimer);renderNavigation(name);
if(name==='experience')await browserReady;
if(activeTab!==name)return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

head_sha: 11604cb65f415d14d20e0b0c8ddf61f24b0e46a2

🟡 Medium Priority

建议:把 await browserReady 包在 try/catch 中:失败时显示提示(notice/bootstrapFailed)并 return,避免未处理拒绝与残留弹窗;或改为不在 switchTab 中 await,让 loadMemories→request() 现有的错误处理负责提示。

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 10efa7c215d4cbaacd29b70dd76b2b02f89e220d

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ❌FAILED 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 ✅SUCCESS N/A
pr size检查 N/A N/A

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 10efa7c215d4cbaacd29b70dd76b2b02f89e220d

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 ✅SUCCESS N/A
pr size检查 N/A N/A

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: b055f4954f068061b5d3b23353aa5d1d517edfc7

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 ✅SUCCESS N/A
pr size检查 N/A N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants