Skip to content

feat(#275): 容量预警——库体积/归档规模过线在 /health 与面板上报(空间维度) - #623

Open
modusensus wants to merge 1 commit into
mainfrom
feat/275-capacity-warning
Open

modusensus wants to merge 1 commit into
mainfrom
feat/275-capacity-warning

Conversation

@modusensus

Copy link
Copy Markdown
Member

做什么

#275 维护者 2026-10-21 现状盘点「还缺什么」第 2 条:容量预警。保留期(retentionDays)给了时间维度,空间维度一直缺着——库在涨、归档区在涨,没有任何地方会说过线。接手口径点得很直白:「/health 已经有镜像健康卡,加一个库体积卡是同一条路径」。

Closes #275 的容量预警项(#275 主议题的归档迁出/周期处理两批不在本车)。

设计口径

三道阈值,全是观察口(src/config.js 的 capacityWarning):

检查 键 默认 过线含义
db_size dbSizeWarnMb 256 磁盘足迹(主文件+WAL+SHM)到线——VACUUM 的 O(库大小) 代价开始值得先看数字(议题实测 55 MB 时 0.8s)
archived_rows archivedRowsWarn 5000 归档区到「数千条这个量级」的上沿(议题实测 2,400 时还没坏)
archived_ratio archivedRatioWarn 0.95 归档占比到「归档区吞掉活跃区」——健康形态本身在 0.8~0.9(议题实测 0.90),预警线刻意不放那里
  • 没有 enabled 总开关:预警没有周期性消费者(/health 被读到才算一次),也永不自动归档/删除([Feature] 存储生命周期:归档区出口 + 审计表保留(容量治理议题) #275 拍板:真删由人显式确认)——数字恒在,某条检查不要就把阈值设 0(0 = 显式关)。
  • 判级 fail-safe(service.getCapacityHealth,与镜像健康同款):读失败显式 status:"unknown",绝不伪装 ok;:memory: 库的体积检查缺席而不是 ok(「量不到」≠「零体积」)。
  • 答复不带路径:storageStats 里有 path,/health 是半张对外面——容量块只有数字,回归锁断言响应不含库文件路径。未鉴权的 standalone /health 零改动,容量不进那张面。
  • 增速不算两遍:归档净增速率是 recall-stats archive 块的第五指标(已有),容量卡刻意不算速率。
  • 键三件套成对:settings 白名单(2×INT_RANGES + 1×NUMBER_RANGES)+ NESTED_FLAG_PATHS 三个点号键 + 计数锁 121→124 + 往返测试。
  • 面板:「库内一览」组新增「库体积」卡——大数字磁盘足迹,行给活跃/归档(含占比)/可回收空闲页,过线检查逐条列出值/阈值并走 --mneme-warn 语义色;fetch 失败/老宿主/后端 unknown 三种情况全部 fail-closed 渲染「未知」。StatusCard 加可选 numWarn/逐行 warn,不传的卡渲染逐字节不变。

验证

  • npm test:3164 用例 / 3163 通过 / 0 失败 / 1 跳过(skip 为既有基线);check-sync 通过(118 文件)。
  • 新增 test/capacity-warning.test.js 9 例(行数口径、schema 边界、三道检查判级与关闭、fail-safe、/health 挂载与不泄露路径、没接线显式 null);test/api.test.js 计数锁与往返、test/client.test.js 面板形状锁、test/contrast.test.js 新 CSS 色 5/5。
  • 文档:docs/CONFIGURATION.md 新节(docs-config-keys 全键闸通过)、docs/STORAGE.md 补「容量预警([Feature] 存储生命周期:归档区出口 + 审计表保留(容量治理议题) #275 空间维度)」节、README 键表、CHANGELOG。
  • euthyna 审计已过:audit + history --pickaxe + coverage 三次测量,产出器报出的 10 条事实逐条走阶段 C 六门禁,裁定 0 TRUE POSITIVE / 10 FALSE POSITIVE / 0 INCONCLUSIVE(全部是「就地改写、原行逐字保留」的删除行误报);报告经 euthyna gate 校验 10/10 通过(exit 0)。审计报告在车道本地(.worktrees/275-capacity/MNEME_EUTHYNA_AUDIT_2026-11-10.md),不入库。

Copilot AI lite review requested due to automatic review settings November 9, 2026 19:01
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 514d238 and f990dab.

Files selected for processing: 18

  • dsh-mneme/CHANGELOG.md
  • dsh-mneme/README.md
  • dsh-mneme/docs/CONFIGURATION.md
  • dsh-mneme/docs/STORAGE.md
  • dsh-mneme/lib/api.js
  • dsh-mneme/lib/client.js
  • dsh-mneme/lib/config.js
  • dsh-mneme/lib/service.js
  • dsh-mneme/lib/settings.js
  • dsh-mneme/lib/store.js
  • dsh-mneme/src/api.js
  • dsh-mneme/src/config.js
  • dsh-mneme/src/service.js
  • dsh-mneme/src/settings.js
  • dsh-mneme/src/store.js
  • dsh-mneme/test/api.test.js
  • dsh-mneme/test/capacity-warning.test.js
  • dsh-mneme/test/client.test.js
  • Autofix · 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

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 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

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.67550% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
dsh-mneme/src/api.js 91.30% 2 Missing ⚠️

📢 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.

[Feature] 存储生命周期:归档区出口 + 审计表保留(容量治理议题)

2 participants