Skip to content

fix(expiry-guardian): 声明 hostLogger,插件能真正启动 - #204

Merged
MyPrototypeWhat merged 1 commit into
MiniMax-AI:mainfrom
Apageoflove:fix/expiry-guardian-start
Dec 4, 2026
Merged

MyPrototypeWhat merged 1 commit into
MiniMax-AI:mainfrom
Apageoflove:fix/expiry-guardian-start

Conversation

@Apageoflove

@Apageoflove Apageoflove commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

插件从合入的第一天起就没能启动过。

start() 的第一条语句是 hostLogger = context.logger ?? null;,而 hostLogger 在整个文件里从未声明。这个包是 ESM(package.json 里 "type": "module"),严格模式下给未声明的标识符赋值会抛 ReferenceError —— 宿主加载它必然失败,面板、MCP 端点、定时判定全部不存在。

实测(未改的代码):

START THREW: ReferenceError | hostLogger is not defined
AT: at Module.start (file:///.../expiry-guardian/miniapp/node/server.mjs:1018:14)

git log -S hostLogger 显示这行从第一次提交(5664d58 / PR #47)起就在。没人发现是因为没有测试调用过 start() —— 现有测试只覆盖纯函数 decide()。

改的是在模块作用域声明 hostLogger(放在 inflightSnapshot / lastGoodSnapshot 那一段旁边),start() 里那次注入保留 —— 注释写明它是给模块级重试辅助函数用的 Host 日志出口。

新增 tests/start-lifecycle.test.mjs:真的调用 start(context),要求它 resolve、真的监听端口(logger 收到 expiryGuardian.listening)、dispose 跑完;另加一条根因守卫,检查 hostLogger 是顶格声明的模块级变量、且 start() 里那次注入还在。未改的代码上 1/5 通过(ReferenceError),改完 6/6。

插件自带测试 85/85,仓库根 npm run check 0 error。

版本号 2.0.1。

验证范围:只有 Node 22 上的测试是实测的。真实 Host 和 Electron 我没跑过 —— 这一层是仅个人判断。


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Copy link
Copy Markdown
Collaborator

这次提交里带上了两份 Mimosa 本地会话文件:

plugins/hylouis233/expiry-guardian/.mimosa/hook-state/sess_56067fc3-3d82-44a7-a5f9-78269aad4e9f.json

plugins/hylouis233/expiry-guardian/.mimosa/hook-status/sess_56067fc3-3d82-44a7-a5f9-78269aad4e9f-14bf3730a4.json

它们是本地工具的会话状态,不是插件功能代码,也不在运行时 payload 里。当前 main 和这个插件目录里都没有 .mimosa。我打开看过,里面没有绝对路径、密钥或个人敏感信息。合入前请把它们从提交里删掉后再推。启动修复本身没有问题,我们会在新 head 上继续看。这个分支目前和 main 没有真实合并冲突,不必仅为落后的那几个提交 rebase。

start() 的第一条语句给 hostLogger 赋值,而这个标识符全文件从未声明。本包是
ESM,严格模式下给未声明的标识符赋值会抛 ReferenceError,宿主加载插件必然
失败 —— 面板、MCP 端点、定时判定全部不存在。

这条从插件合入的第一次提交(MiniMax-AI#47)起就在,也就是它从第一天起就没能启动过。
没有测试调用过 start(),所以没人发现。

新增 tests/start-lifecycle.test.mjs:真的调用 start(context),要求它
resolve、真的监听端口、dispose 跑完;另加一条根因守卫,检查 hostLogger 是
模块级已声明的变量、且 start() 里那次注入还在。在未改的代码上红(1/5),
改完绿(6/6)。

版本号 2.0.1。一致性脚本里加上新测试。
@Apageoflove
Apageoflove force-pushed the fix/expiry-guardian-start branch from 9264b79 to ea34273 Compare December 4, 2026 04:56
@MyPrototypeWhat
MyPrototypeWhat merged commit 94b2bf4 into MiniMax-AI:main Dec 4, 2026
2 checks passed
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