Skip to content

fix(tools): memory_get 输出 schema 复用 MEMORY_ITEM_SCHEMA——scope 标注行不再被拒收 - #186

Merged
modusensus merged 1 commit into
mainfrom
fix/memory-get-scope-schema-184
Sep 15, 2026
Merged

modusensus merged 1 commit into
mainfrom
fix/memory-get-scope-schema-184

Conversation

@modusensus

@modusensus modusensus commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

根因(与 #184 的三段证据链一致)

0.8.1 的 #171 给 toApiList 增加 scope 来源三键条件展开时,共享的 MEMORY_ITEM_SCHEMA 同步声明了它们,但 memory_get 的输出 schema 是一份内联副本且 additionalProperties: false——被标注行携带新键即被宿主 in-process 校验拒收。

修复

  • memory_get 的 memory 属性直接引用 MEMORY_ITEM_SCHEMA(与 list/search 同源),内联副本删除——键集漂移从此不可能发生;
  • 导出 MEMORY_ITEM_SCHEMA 供回归测试断言同源;
  • 新增 test/tools-memory-get-schema.test.js:
    1. 用生产同款校验器(@deepseek-ai/dsh-tools 的 validateJsonSchemaValue)+ 带全量来源标注的行——修前逐字复现 [Bug] memory_get 输出 schema 漏声明 scope 来源列:命中任何被标注的行必然报 invalid output(0.8.1) #184 的报错(三条 not-a-declared-property,比报告多抓一条 scope_decided_at),修后零违规;
    2. 键集 / required / additionalProperties 防漂移断言(defineTool 编译会克隆,故比对结构而非引用)。

验证

Fixes #184

Summary by CodeRabbit

  • 改进

    • 统一记忆相关工具的输出字段定义,确保 memory_get、memory_search 和 memory_list 返回一致的记忆项信息。
    • 补充 scope 来源等完整字段声明,提升记忆数据展示的一致性。
  • 测试

    • 新增回归验证,确保记忆项输出符合统一格式,并正确包含必填字段。

…#184)

0.8.1 的 #171 给 toApiList 增加了 scope 来源三键的条件展开
(agent_scope_source / workspace_scope_source / scope_decided_at),
共享的 MEMORY_ITEM_SCHEMA 同步声明了它们,但 memory_get 的输出 schema
用的是一份内联副本且 additionalProperties:false——任何被标注过的行
走 memory_get 都会被宿主 in-process 校验拒收(invalid output),
且每写一条新记忆就多一条读不回的行。

- memory_get 的 memory 属性直接引用 MEMORY_ITEM_SCHEMA(与
  list/search 同源),内联副本删除——键集漂移不可能再发生;
- 导出 MEMORY_ITEM_SCHEMA 供回归测试断言同源;
- 新增 test/tools-memory-get-schema.test.js:①生产同款校验器
  (validateJsonSchemaValue)+ 带全量来源标注的行复现 #184(修前
  逐字复现报错三条、修后零违规)②键集/required 防漂移断言。

Fixes #184
Copilot AI lite review requested due to automatic review settings September 15, 2026 09:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: b010d0c7-3c3b-46e7-b167-07bfddbff22d

📥 Commits

Reviewing files that changed from the base of the PR and between 596348f and 14a7d51.

📒 Files selected for processing (3)
  • dsh-mneme/lib/tools.js
  • dsh-mneme/src/tools.js
  • dsh-mneme/test/tools-memory-get-schema.test.js

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

本次修改导出共享的 MEMORY_ITEM_SCHEMA,让 memory_get 与其他记忆工具使用同一输出声明,并新增测试覆盖完整 scope 字段及 schema 一致性。

Changes

memory_get 输出 schema

Layer / File(s) Summary
共享 schema 导出与复用
dsh-mneme/src/tools.js, dsh-mneme/lib/tools.js
导出 MEMORY_ITEM_SCHEMA。memory_get 改为引用该共享 schema,并声明完整的 scope 来源字段。
输出 schema 回归验证
dsh-mneme/test/tools-memory-get-schema.test.js
新增测试,验证带有 agent_scope_source、workspace_scope_source 和 scope_decided_at 的 DTO 可通过 memory_get 输出校验,并验证属性键集、必填字段及 additionalProperties 设置。

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: anans-ivresse

Merge Risk: ⚪ Minimal · up to 14a7d

The shipped memory_get schema now accepts scoped memory DTOs consistently with the shared memory schema; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:修复 memory_get 输出 schema,并复用 MEMORY_ITEM_SCHEMA,以支持带 scope 标注的记忆行。标题具体、简洁,且与变更内容一致。
Linked Issues check ✅ Passed PR 实现了 #184 的编码要求。src/tools.js 和生成后的 lib/tools.js 导出 MEMORY_ITEM_SCHEMA,并让 memory_get.output.schema.properties.memory 直接复用该 schema。该 schema 包含 agent_scope_source、workspace_scope_source 和 `…
Out of Scope Changes check ✅ Passed 变更范围均服务于 #184。schema 导出、memory_get 的 schema 复用、src/lib 同步修改以及回归测试,分别支持同源实现和防止 schema 漂移。未发现与该问题无关的功能变更。
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/memory-get-scope-schema-184

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@modusensus
modusensus merged commit 00c67ea into main Sep 15, 2026
9 checks passed
@modusensus
modusensus deleted the fix/memory-get-scope-schema-184 branch September 15, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] memory_get 输出 schema 漏声明 scope 来源列:命中任何被标注的行必然报 invalid output(0.8.1)

2 participants