Skip to content

heat 注入侧拆独立开关 injectHeatEnabled(E5 裁决落地,默认关) - #362

Open
modusensus wants to merge 1 commit into
mainfrom
feat/inject-heat-enabled
Open

modusensus wants to merge 1 commit into
mainfrom
feat/inject-heat-enabled

Conversation

@modusensus

@modusensus modusensus commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

背景

队列计划书(mneme-research notes/queue-plans-2026-10.md)计划一 + 计划二。E5 效用考卷(讨论 #339)裁决:heat 乘进注入排序在真实年龄混合下饿死老约束(现行量级 ≡ 拟合参数,注入集逐条相同,importance-only 遵从 +12.7pp)。

Commit 1:injectHeatEnabled(opt-in 默认关)

探查确认 heat 的唯一排序参与点是 injectCandidates 比较器——召回融合打分不含 heat(searchMemories 只用 heat 碰时钟 touchLastAccess),sleep 降级联判(sleep.js)是独立机制。因此这是一次自包含摘除:

  • 新键 injectHeatEnabled 默认 false:heatEnabled 开启时注入乘数恒 1,与 heat 关闭逐字节一致(平价锁测试);显式开启恢复层内乘 heat 旧序(老用户回滚口);
  • 召回侧时钟(touchLastAccess)与 sleep 降级联判不受影响——它们不参与注入排序;
  • inject-heat.test.js 重写为双断言结构(默认关平价 / 开启恢复旧序 / λ=0 免疫 / 不跨层),计数锁 +1,CONFIGURATION/README/CHANGELOG 同步。

Commit 1 附带:autoSummarize 行补 E10 结论(计划二)

E10 EdgeMem 考卷(#361)实测:对「未来才问的具体值」类细节,零 LLM 原样写入保真 100% 而蒸馏丢 17/120——autoSummarize 的 CONFIGURATION 行补注「并存而非替代」口径。原样写入并存的产品化(宿主事件镜像)按计划书触发条件立项(真实负载出现可归因的丢细节案例),不在本 PR。

门禁

全量 1530 tests 全绿;npm run sync 后 check-sync 过。

Summary by CodeRabbit

  • 新功能
    • 新增独立的注入热度排序开关,默认关闭。关闭时,注入排序不受热度影响;开启后恢复按热度排序。
    • 热度字段、睡眠降级保护及召回侧行为不受新开关影响。
  • 文档
    • 更新配置说明,补充新开关的行为及默认值,并记录一项记忆保真度测试结果。

E5 实测 heat 乘进注入排序在真实年龄混合下饿死老约束(现行量级 ≡ 拟合参数,
importance-only 遵从 +12.7pp),且 heat 的唯一排序参与点就是 injectCandidates
比较器(召回融合打分不含 heat,sleep 降级联判是独立机制)——自包含摘除:

- 新键 injectHeatEnabled 默认关:heatEnabled 开启时注入乘数恒 1,与 heat
  关闭逐字节一致(平价锁);显式开启恢复层内乘 heat 旧序(老用户回滚口)
- 召回侧时钟(touchLastAccess)与 sleep 降级联判不受影响
- inject-heat.test.js 重写为双断言结构(默认关平价 + 开启恢复旧序 + λ=0
  免疫 + 不跨层),计数锁 +1,CONFIGURATION/README 同步
Copilot AI lite review requested due to automatic review settings October 3, 2026 22:04

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 Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: slow-stack/mneme/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c50aa05e-4741-402c-b6d3-2b9fd574c7e7
📥 Commits

Reviewing files that changed from the base of the PR and between 59029fe and d5004d7.

📒 Files selected for processing (11)
  • dsh-mneme/CHANGELOG.md
  • dsh-mneme/README.md
  • dsh-mneme/docs/CONFIGURATION.md
  • dsh-mneme/lib/config.js
  • dsh-mneme/lib/service.js
  • dsh-mneme/lib/settings.js
  • dsh-mneme/src/config.js
  • dsh-mneme/src/service.js
  • dsh-mneme/src/settings.js
  • dsh-mneme/test/api.test.js
  • dsh-mneme/test/inject-heat.test.js

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

新增默认关闭的 injectHeatEnabled,将注入排序的热度控制与 heatEnabled 分开。两个开关同时开启时,注入排序才应用热度权重;相关测试和配置说明也已更新。

Changes

注入排序热度开关

Layer / File(s) Summary
配置与开关注册
dsh-mneme/lib/config.js, dsh-mneme/src/config.js, dsh-mneme/lib/settings.js, dsh-mneme/src/settings.js
新增默认值为 false 的 injectHeatEnabled,并将其加入布尔特性开关白名单。
注入排序门控
dsh-mneme/lib/service.js, dsh-mneme/src/service.js
只有 heatEnabled 和 injectHeatEnabled 同时开启时,注入排序才计算并应用热度权重;否则权重为 1。
行为验证与配置说明
dsh-mneme/test/api.test.js, dsh-mneme/test/inject-heat.test.js, dsh-mneme/README.md, dsh-mneme/docs/CONFIGURATION.md, dsh-mneme/CHANGELOG.md
测试覆盖默认关闭、显式开启及排序边界。文档说明新增开关及其与现有热度功能的关系。

EdgeMem 测试结果说明

Layer / File(s) Summary
测试结果记录
dsh-mneme/docs/CONFIGURATION.md
新增 E10 EdgeMem 测试结果:具体值类记忆原样写入的保真率为 100%,蒸馏中有 17/120 项丢失,并说明两种方式并存。

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: heptaspirit

Merge Risk: ⚪ Minimal · up to d5004

The change limits heat-based injection ordering to an explicit opt-in and preserves the existing recall and sleep behavior. No material merge-blocking risk is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d5004

The change is bounded and reversible. It separates ranking preferences without changing memory-access controls or granting new privileges. No introduced security issue was established, but deployed API exposure and configuration recovery behavior are not fully verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The new control affects injection ordering in the configured service instance. It does not add an identity transition or an exception to scope eligibility; enabling heat weighting can reorder candidates but does not itself bypass the existing strictScope filter.

Trust Boundaries and Controls

  • observed — Feature-write requests pass through the existing authorization guard and centralized boolean validation. The guard requires the configured token when present but permits writes when no token is configured. Reads remain open. These authority rules predate the PR; the new flag does not strengthen or weaken them.

Resilience and Maintainability Implications

  • inferred — Repeated opt-in or revert updates reuse the existing persisted override and startup reconstruction, without stranding external resources. Concurrent writers can still lose unrelated updates because the shared JSON record uses read-modify-write without compare-and-swap; that limitation predates this flag and is not established as a PR-introduced security concern.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 8 files. (3 skipped: 3… 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 标题准确概括了主要变更:新增默认关闭的 injectHeatEnabled 开关,独立控制 heat 对注入排序的影响。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 8 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

2 participants