Skip to content

fix(standalone-api): /status 返回真实包版本(去掉硬编码常量) - #367

Merged
modusensus merged 1 commit into
mainfrom
fix/standalone-version
Oct 5, 2026
Merged

modusensus merged 1 commit into
mainfrom
fix/standalone-version

Conversation

@modusensus

@modusensus modusensus commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

问题

GET /status 返回的版本号来自 src/api-standalone.js 内的字面量常量,而它不会随发版 bump(注释自己写着「package.json 在发布时会 bump」)。实测:一个运行 0.8.13 的实例对外报 0.7.12——第三方集成拿这个字段判版本,读到的是假数据。

修法

复用既有的 PACKAGE_VERSION(src/version-check.js,运行时读 package.json)——宿主侧的 /api/dsh-mneme/status 早就在用它,standalone 面反而是唯一的第二真源。删掉重复常量,/status 与宿主状态页从此同源。

回归锁

test/standalone-api.test.js 原本断言 body.version === "0.7.12"——锁字面量正是漏 bump 没被 CI 拦下的原因:测试只证明「常量和它自己一致」。改为断言等于 PACKAGE_VERSION,版本漂移从此必红。

变异检验:把实现改回字面量,该用例变红(1 fail);还原后 21/21 绿。全量 npm test 1537 通过 / 0 失败(与双 README 徽章计数一致,无需刷徽章)。

范围

一行实现 + 一条断言改写,不触及其他端点与配置面。附带把文件头注释里的过时版本号 (v0.7.12) 去掉。

Summary by CodeRabbit

  • Bug Fixes
    • /status 端点现在返回与当前软件包版本一致的版本号,不再显示过时的固定版本。

The endpoint returned a module-local literal that release bumps never
touched, so a running 0.8.13 answered /status with 0.7.12 — third-party
integrations reading it got a stale version. Reuse PACKAGE_VERSION from
version-check.js (the same source the host-side status route already
reads) and drop the duplicate constant.

The regression lock moves from the literal to PACKAGE_VERSION: pinning
the string is what let the drift ship with a green CI.
Copilot AI lite review requested due to automatic review settings October 5, 2026 13:19

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 5, 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: 3d344447-1cbc-47d2-ab08-deb32c639e19
📥 Commits

Reviewing files that changed from the base of the PR and between b517b11 and edaae5a.

📒 Files selected for processing (4)
  • dsh-mneme/CHANGELOG.md
  • dsh-mneme/lib/api-standalone.js
  • dsh-mneme/src/api-standalone.js
  • dsh-mneme/test/standalone-api.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

Standalone API 的 /status 响应改为使用 version-check.js 中的 PACKAGE_VERSION。对应测试和变更日志也已更新。

Changes

Standalone API 状态版本号

Layer / File(s) Summary
状态接口版本来源与验证
dsh-mneme/src/api-standalone.js, dsh-mneme/lib/api-standalone.js, dsh-mneme/test/standalone-api.test.js, dsh-mneme/CHANGELOG.md
/status 的版本值改为 PACKAGE_VERSION。测试改为校验该常量,变更日志记录此调整;文件头注释移除了固定版本标记。

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: heptaspirit

Merge Risk: ⚪ Minimal · up to edaae

The standalone status version now follows package metadata in both source and distributable code. No actionable merge-blocking risk remains.

Architecture Summary

Architecture risk: 🔵 Low · up to edaae

The change affects 1 system.

Changed systems: dsh-mneme

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — dsh-mneme (service) was modified; 4 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in dsh-mneme/CHANGELOG.md: 新增 standalone API /status 版本号修正记录,说明其版本值现复用 PACKAGE_VERSION,并将测试断言改为锁定该常量,而非硬编码字面量。
  • observed — Modified behavior in dsh-mneme/lib/api-standalone.js: 文件头注释移除了固定版本号 (v0.7.12);其余注释内容未变。
  • observed — Modified behavior in dsh-mneme/lib/api-standalone.js: 新增 PACKAGE_VERSION 导入;删除硬编码常量 VERSION = "0.7.12"。默认端口和主机常量保持不变。
  • observed — Modified behavior in dsh-mneme/lib/api-standalone.js: /status 响应的 version 值从硬编码的 VERSION 改为导入的 PACKAGE_VERSION。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:移除硬编码版本号,使 standalone API 的 /status 返回真实包版本。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1 …
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.
✨ Finishing Touches
📝 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 5, 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 4a927da into main Oct 5, 2026
11 checks passed
@modusensus
modusensus deleted the fix/standalone-version branch October 5, 2026 13:25
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