Repository navigation
fix(#692): 两个默认开的开关改按 !== false 读(记忆护栏 / 模型下载韧性) - #695
Conversation
dreamMergeGuard(dream 主链路与 sleep 链路各一处)与 resilientModelDownload 的默认值只写在 zod schema 里:经 Config 的调用方拿得到,绕过 Config 的调用方 (测试、第三方程序化 createService)拿到 undefined,被 `=== true` 当 false, 于是「默认开」等于默认关。两处统一改成 `!== false`。 resilientModelDownload 的判据收成 `resilientDownloadEnabled(cfg)` 放在装配层 (src/semantic.js):LocalEmbedder / Reranker 的构造函数刻意保持「只在显式 true 时启用」(issue #194 的直连构造契约,test/local-embedder.test.js 锁着), 默认值只在装配层落定。 第三处 memoryQualityFilter.enabled 本批不动——它挂在自身带 .default({}) 的 对象里,经 Config 的调用方一直是开的;翻裸配置等于重定义程序化契约,实测牵动 421 条既有断言,留在 issue 里单独拍板。 测试 3,496 → 3,499;变异自证:两处各自改回 `=== true` → 2 红。 用户 2026-11-13 反馈
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…read # Conflicts: # dsh-mneme/CHANGELOG.md
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
问题
「默认开」的开关,默认值只写在 zod schema(
src/config.js)里。经Config(config)的调用方(宿主src/index.js)拿得到默认值;绕过 Config 的调用方——测试、第三方程序化createService、直接 import 单元的装配——拿到的是undefined。而这些开关的读法是=== true,undefined === true为 false,于是「默认开」实际上等于默认关。这类不一致很隐蔽:宿主里一切正常,只有程序化接入的人踩,而且现象是「开关好像没生效」,不会报错。
改了哪两处
src/dream.jsmergeGuardconfig?.dreamMergeGuard === trueconfig?.dreamMergeGuard !== falsesrc/dream/sleep.jsmergeGuardsrc/semantic.js(装配层)cfg.resilientModelDownload(裸传,构造里=== true)resilientDownloadEnabled(cfg)→cfg?.resilientModelDownload !== falseresilientModelDownload的判据不进构造函数:LocalEmbedder/Reranker刻意保持「只有显式 true 才启用」,这是 issue #194 定下的直连构造契约(test/local-embedder.test.js:79锁着「直连构造不显式给 true = 保持现状」)。默认值在装配层落定,两条装配路径共用同一个 helper。第三处为什么不在这个 PR 里
memoryQualityFilter.enabled也是=== true,但它挂在一个自身带.default({})的对象里:只要经过 Config,对象一定存在,过滤器一直是开的。=== true与!== false的差别只出现在整个对象都不传的裸配置调用方身上。把那半边也翻过来,等于重定义「程序化
createService的默认契约」。实测代价:全量 421 条断言变红——大量 fixture 用两三字短正文("入门"、"喜欢猫"),靠过滤器默认关才能留在库里被检索到,一旦默认开就被质量分档归档。这是接口决定,不该混在两处读法修正里悄悄发生,留在 #692 里单独拍板。测试
test/issue-692-default-on-reads.test.js3 条:裸配置下 guarded 类型(constraint,在ARCHIVE_GUARDED_TYPES里)的 merge 被 skip 且理由点名dreamMergeGuard;显式dreamMergeGuard: false时同一条 merge 落库;resilientDownloadEnabled三态。=== true→ 2 红(默认开那两条),还原 → 3/3 绿;「改成恒真」会被两条反向对照分别抓住。文档
dsh-mneme/CHANGELOG.md的[Unreleased]记录了这两处、落点选择,以及第三处为什么单独处理(含 421 条的数字)。Ref #692
Summary by CodeRabbit
false可关闭。