Skip to content

fix(memory): close maintenance CLI resources on every exit - #242

Merged
lyyzka merged 2 commits into
mainfrom
fix/issue216-memory-cli-cleanup
Oct 20, 2026
Merged

lyyzka merged 2 commits into
mainfrom
fix/issue216-memory-cli-cleanup

Conversation

@lyyzka

@lyyzka lyyzka commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

memory:maintain can finish its public API operation yet remain alive because importing the product runtime opens business Redis clients that the CLI never closes. Its previous shutdown also closed only the primary PostgreSQL pool, and a control shutdown error skipped the remaining cleanup.

Close native control, both business Redis clients and both PostgreSQL pools on every exit, including argument validation failures. Attempt all cleanup steps, preserve the operation's existing error when it fails, and report cleanup failures using fixed stage names without printing underlying connection errors. Maintenance authorization, API arguments and normal result payloads are unchanged.

Validation: seven real CLI child-process cases first timed out against the old code, then passed without forced exit after the fix. They cover success, operation/argument failure, each failed disposer, cleanup order and sensitive-error sentinel suppression. npm run server:lint and npm run server:typecheck pass.

Related to #216. This is a CLI lifecycle defect, not a claim about the original memory recall cause. No production deployment or operator-script change is included.

lyyzka commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Root 独立审查 exact 80ec72a2cb6f451507fe71b05111a04a8abfe585:无P1/P2,可交下一发布候选协调。

独立复跑7/7生命周期子进程测试通过;另3/3组合异常反例通过(业务失败+四项清理失败保留原异常对象、成功+四项失败仅固定stage、usage失败+四项失败保留usage)。四项清理均按序尝试,私有sentinel不进入新清理错误输出,无process.exit强制结束。作者server lint/typecheck通过。本review未安装依赖或操作生产。

这是公开memory:maintain CLI的资源收尾修复,不是原始对话记忆召回延迟的归因,也不需要重做已完成的生产内容迁移。#216实际5条迁移及授权20/20索引已由独立operator v2完成并验收;此PR尚未合并或部署。挂起disposer的额外超时机制及真实服务CLI复验不在这次最小异常/退出修复的测试覆盖中。

独立报告SHA256 fc80f5809875f10e28ef7e43ed1266fdd96a7ee6759e6cb2080ee2f12968b4f2,本地 /tmp/issue216-cli-cleanup/independent-review.md。

@lyyzka
lyyzka marked this pull request as ready for review October 20, 2026 16:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T16:31:28.151747Z a6f0961 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6f0961c63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

['redis',() => redis.disconnect()],
['database',closeDatabasePools],
] as const) {
try {await close()}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound cleanup stages before advancing

When any disposer never settles, this unbounded await prevents every later disposer from running, so a hung stopLingxiOSControl() leaves both Redis clients and the database pools open and the one-shot CLI still never exits. This is a concrete lifecycle case already covered by docs/evidence/release-215-216-219/memory-maintenance-20261020/v2/lifecycle-budget.test.mjs, where a never-resolving control stop must time out and still allow database cleanup; apply a per-stage deadline and continue recording the failed stage. The new regression only exercises disposers that return or throw, so it misses this path.

AGENTS.md reference: AGENTS.md:L35-L35

Useful? React with 👍 / 👎.

@lyyzka
lyyzka merged commit 329366d into main Oct 20, 2026
8 checks passed
@lyyzka
lyyzka deleted the fix/issue216-memory-cli-cleanup branch October 29, 2026 02:40
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