Skip to content

fix(memory-spaces): decode CLI crash exits and self-check startup - #784

Open
Grivn wants to merge 1 commit into
mainfrom
fix/issue-782-cli-crash-diagnostics
Open

Grivn wants to merge 1 commit into
mainfrom
fix/issue-782-cli-crash-diagnostics

Conversation

@Grivn

@Grivn Grivn commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

提交 PR 前请阅读贡献指南、Contributing Guide与开发和验证指南 / Development and Verification Guide。
Before opening a PR, read the Contributing Guide, 贡献指南, and the Development and Verification Guide / 开发和验证指南。
PR 标题和提交信息必须使用 Conventional Commits(type(scope): subject),且不得包含 emoji。 / PR titles and commits must use Conventional Commits (type(scope): subject) and must not contain emoji.
本仓库接受 Bug 修复、兼容性适配、现有能力增强、性能或体验优化和维护类 PR。全新能力、Provider、持久化格式或安全边界变更必须先提 Issue 并获得维护者确认。 / This repository accepts bug fixes, compatibility work, improvements to existing capabilities, performance or UX optimization, and maintenance. New capabilities, Providers, persistence formats, or security-boundary changes require prior maintainer approval in an Issue.
外部贡献者的仅文档类 PR 不直接接受;请先提 Issue 讨论。维护者的发布说明与文档维护不受此限制。 / Documentation-only PRs from external contributors are not accepted directly; open an Issue first. Maintainer release notes and documentation maintenance are exempt.

摘要 / Summary

为 Mnemon Native CLI 运行器补充原生崩溃与启动失败诊断:在 runProcess 捕获终止信号(signal),解码常见 Windows NTSTATUS 崩溃退出码(如 0xC0000005 STATUS_ACCESS_VIOLATION、0xC0000135 STATUS_DLL_NOT_FOUND、0xC0000409 STATUS_STACK_BUFFER_OVERRUN)和 POSIX 信号,在崩溃或无输出非零退出时执行有界 --version 启动自检并刷新 CLI 发现缓存,在单行错误中给出实际解析到的 CLI 路径、检测到的版本(包含 npm 包清单版本或 --version 输出)及升级与覆盖指引,并同步中英文安装、运维排障与兼容性文档。

Improve Mnemon Native CLI crash and startup-failure diagnostics: capture terminating signals in runProcess, decode common Windows NTSTATUS crash codes (such as 0xC0000005 STATUS_ACCESS_VIOLATION, 0xC0000135 STATUS_DLL_NOT_FOUND, and 0xC0000409 STATUS_STACK_BUFFER_OVERRUN) and POSIX signals, run a bounded --version self-check on crash or empty-output failures, invalidate the CLI discovery cache on crash, include the resolved CLI path, detected version, and upgrade guidance in single-line errors, and synchronize bilingual installation, troubleshooting, and compatibility documentation.

关联 Issue 或背景 / Related Issue or Context

Fixes #782

当本机 PATH 优先命中崩溃的旧版 Windows mnemon 二进制(例如 0.2.9 以 0xC0000005 无输出退出,且与另一全局目录的新版并存)时,原先只报 mnemon store create default exited 3221225477: no output,无法区分 CLI 启动崩溃与子命令错误,也看不出 DSH 实际调用的二进制路径、版本和修复方式。本 PR 完整覆盖 #782 的错误解码、启动自检、路径/版本暴露、缓存失效与双语文档说明。

涉及区域 / Affected Areas

  • Host 激活、Headless 或 bundle / Host activation, Headless, or bundle
  • 运行时记忆 / Runtime Memory
  • 项目档案 / Project Documents
  • 记忆空间或 Provider / Memory Spaces or Providers
  • 子 Agent 或 Agent 工作流 / Subagent or Agent workflow
  • Web UI 或对话交互 / Web UI or conversation interaction
  • 设置、存储或安全 / Settings, storage, or security
  • CLI、RPC、命令或工具 / CLI, RPC, commands, or tools
  • 安装、更新或发布 / Installation, update, or release
  • 测试、构建或文档 / Tests, build, or documentation
  • 其他(请说明)/ Other (explain below)

PR 类型 / PR Type

  • 面向用户的功能或行为变更 / User-facing feature or behavior change
  • Bug 修复 / Bug fix
  • 增强或优化 / Enhancement or optimization
  • 兼容性适配 / Compatibility change
  • 维护或重构 / Maintenance or refactor
  • 测试或构建 / Tests or build

最新代码确认 / Latest Codebase Confirmation

  • 我已基于最新 main 分支开发,或在提交前已 rebase 或合并最新 main。 / I developed from the latest main, or rebased or merged the latest main before submitting.

同步命令 / Sync command:

git fetch origin main && git checkout -b fix/issue-782-cli-crash-diagnostics origin/main

(Base commit 3285154a, latest origin/main after v0.5.61.)

AI 编码披露 / AI Coding Disclosure

  • 完全 AI 编码:全部编程改动由 AI 产出,并由贡献者接受和审查。 / Fully AI-coded: AI produced all programming changes, which the contributor accepted and reviewed.
  • 部分 AI 辅助:AI 帮助编写或修改了部分内容。 / Partially AI-assisted: AI helped write or modify part of the change.
  • 未使用 AI 编码辅助。 / No AI coding assistance was used.

使用的 AI 模型 / AI model used:

Gemini

使用的编码 Agent 工具 / Coding Agent tool used:

Antigravity

仓库规范检查 / Repository Rules

  • 未修改 DSH 官方源码,未让 tsconfig 指向 DSH 源码 checkout,仅使用正式的 @deepseek-ai/* NPM 契约。 / I did not modify DSH source or point tsconfig at a DSH source checkout, and used only published @deepseek-ai/* NPM contracts.
  • Client 与 Host 边界仍以浏览器安全的 src/host/protocol.ts 为准,没有在两侧重复定义 wire DTO。 / The Client and Host boundary still uses browser-safe src/host/protocol.ts as the source for wire DTOs.
  • 持久化格式、RPC 权限、路径或凭据处理的变更包含兼容或拒绝路径、安全分析和相应测试。 / Changes to persistence formats, RPC authority, paths, or credentials include compatibility or rejection paths, security analysis, and tests.
  • 没有提交 token、密钥、私有记忆、未脱敏日志或生成的 lib/ 文件。 / I did not commit tokens, credentials, private memory, unredacted logs, or generated lib/ files.
  • 用户可见文案和长期文档已同步维护中文与英文版本,命令、配置键和路径保持一致。 / User-facing copy and long-lived documentation are synchronized in Chinese and English, with matching commands, configuration keys, and paths.
  • 会改变发布制品或其元数据的 PR 已添加 changeset;仅测试、CI 或站点文档变更可不添加。 / A PR that changes a published artifact or its metadata includes a changeset; test-only, CI-only, and site-documentation-only changes may omit one.
  • 新增和修改的代码、注释、文档、提交信息不含 emoji。 / New and modified code, comments, documentation, and commits contain no emoji.

兼容性与数据安全 / Compatibility and Data Safety

  • 向后兼容 / Backwards compatibility:带非空输出且非崩溃退出码的普通 CLI 失败保持原有 mnemon <args> exited <code>: <detail> 错误格式,不触发额外 --version 探测,不影响 --verbose 回退或现有调用方解析。ProcessResult.signal 仅在进程因信号终止时附带,正常退出结构不变。CLI 发现优先级保持确定性不变(显式 cliPath > MNEMON_CLI_PATH > PATH > 常见目录),不会静默切换到未授权二进制。
  • 凭据与数据安全 / Credentials & data safety:--version 自检探测不向子进程传递嵌入配置凭据环境变量,且所有进程与探测输出均经过 safeError 脱敏(移除 MNEMON_EMBED_API_KEY)并截断为单行,防止凭据泄漏。存储格式、RPC 授权、持久化注册表及升级/回滚路径均无变更;创建空间在 CLI 崩溃时仍保持零残留写入。

本地验证 / Local Validation

执行的命令 / Commands run:

pnpm --filter dsh-mnemon-source-memory-spaces exec vitest run tests/process.spec.ts tests/runner.spec.ts -t "#782"
pnpm --filter dsh-mnemon-source-memory-spaces run verify
pnpm run verify
node scripts/check-release-intent.mjs
git diff --check origin/main..HEAD

结果摘要 / Result summary:

  • Regression check before fix: 9/9 new targeted tests in tests/process.spec.ts and tests/runner.spec.ts failed as expected (missing signal capture, missing reason: 'crash', undecoded Windows NTSTATUS exit codes 3221225477 / -1073741819 / 3221225781 / 3221226505 / 3221225999, missing --version startup self-check and CLI path/version/upgrade guidance).
  • pnpm --filter dsh-mnemon-source-memory-spaces run verify: passed (typecheck, 17 passed / 1 skipped test files, 364 passed / 2 skipped tests including all 11 new #782 regression cases across process.spec.ts, runner.spec.ts, and memory-spaces.spec.ts, plus full build).
  • pnpm run verify: passed completely (verify:docs: 1047 local links and 313 Markdown anchors; root and workspace typecheck; deterministic verify:build; workspace -r build / -r typecheck / -r test; test:root: 83 passed / 2 skipped files, 3032 passed / 22 skipped tests; verify:headless: 38 total / 8 representative Mnemon tools; verify:package: 92 files, publint --strict, attw --pack . --profile esm-only).
  • node scripts/check-release-intent.mjs: passed (Verified changeset coverage for dsh-mnemon-source-memory-spaces.).
  • git diff --check origin/main..HEAD: passed with zero whitespace, emoji, or narrative-comment issues.

用户可见变更证据 / Local Feature Evidence

证据 / Evidence:

N/A — Host/CLI runner error-diagnostic and documentation fix inside dsh-mnemon-source-memory-spaces with no WebUI layout, component, style, or locale template changes. Existing WebUI error banners and Memory Space creation alerts render the improved single-line MnemonCliError message directly; behavior is verified end-to-end across tests/process.spec.ts, tests/runner.spec.ts, and tests/memory-spaces.spec.ts (including Windows 0xC0000005 / 3221225477 and -1073741819, 0xC0000135, 0xC0000409, POSIX SIGSEGV, redacted --version startup probe failures, non-crash empty-output exits, zero-residue store creation failures, and post-crash PATH cache invalidation).

This branch has not been deployed

No deployments
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.

[Bug]: 记忆空间建不出来——本机 mnemon CLI 0.2.9 的 win32 二进制以 0xC0000005 崩掉,插件只报 exited 3221225477: no output

1 participant