dsh-memu-memory 1.3.5 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/docs/troubleshooting.md +10 -0
- package/lib/engine.js +55 -5
- package/lib/managed-runtime.js +10 -0
- package/package.json +1 -1
- package/tests/engine.test.mjs +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# 更新日志 / Changelog
|
|
2
2
|
|
|
3
|
+
## [1.3.6] - 2026-11-15
|
|
4
|
+
|
|
5
|
+
> 修复 macOS 一键安装 MemU 引擎失败(issue #1):受管 Python(python-build-standalone)带 Developer ID 签名 + hardened runtime,macOS 库校验拒绝加载 PyPI wheel 里 ad-hoc 签名的 `pydantic_core` 二进制(dlopen 报 "different Team IDs"),所有候选解释器连环失败。
|
|
6
|
+
|
|
7
|
+
### 引擎安装
|
|
8
|
+
|
|
9
|
+
- **macOS 签名校验自修复**:`installEngine` / `switchEngineVersion` / `ensureEngine` 的 verify 统一走 `verifyEngineRepaired`——错误文本命中签名校验形状时(`isMacOSLibraryValidationError`),对 venv 解释器的 realpath 执行 `codesign --force --sign -` ad-hoc 重签(去掉 hardened runtime 标志)并重试一次,仅 darwin 生效;已有安装下次 ensure 时同样自愈。
|
|
10
|
+
- **受管 Python 主动重签**:`ensureManagedPython` 装好自己的受管解释器后立即 ad-hoc 重签,在任何 venv 创建之前摘掉 hardened runtime。
|
|
11
|
+
- **可读的失败出口**:全部候选失败且错误呈签名形状时,错误末尾附用户侧旁路提示(`DSH_MEMU_PYTHON` 指向 Homebrew/官方 Python,或手动 codesign)。空目录说明:失败的 tmp venv 会被清理,属预期,不是数据丢失。
|
|
12
|
+
|
|
13
|
+
### 文档与测试
|
|
14
|
+
|
|
15
|
+
- `docs/troubleshooting.md` 新增 §3.31(症状 / 落点 / 守卫)与症状速查入口。
|
|
16
|
+
- `tests/engine.test.mjs` 新增签名错误识别用例(issue #1 原文命中、普通 ImportError 不误触发重签)。
|
|
17
|
+
|
|
3
18
|
## [1.3.5] - 2026-11-14
|
|
4
19
|
|
|
5
20
|
> 修复宿主对同一条用户消息给出两次 `agent/pre-step` 时的重复注入:第二次召回会把已投候选全去重、注入 0 条,还多推一格 memoryClock。现在按真实用户消息 id 幂等,一条消息只注入一次;回合回滚时清标记,真重试仍会重投。
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ It is **local-first by default**. The default `agent` backend stores full text i
|
|
|
30
30
|
> [!WARNING]
|
|
31
31
|
> **Early-stage software.** This plugin is still early and may contain unforeseen errors, bugs or breaking changes. Back up your data, and please [report an issue](https://github.com/Tkingxiao/dsh-memu-memory/issues) or send a pull request — feedback helps the project improve.
|
|
32
32
|
|
|
33
|
-
> **Status:** 1.3.
|
|
33
|
+
> **Status:** 1.3.6. The first public release was 1.0.0. The manual now lives in [`docs/`](docs/), with [`AGENTS.md`](AGENTS.md) as a short index. Back up `~/.dsh/dsh-memu-memory` before upgrades, and read [Compatibility & limits](#compatibility--limits) before storing data you cannot re-create.
|
|
34
34
|
|
|
35
35
|
## Screenshots
|
|
36
36
|
|
package/README.zh.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
> [!WARNING]
|
|
31
31
|
> **早期版本提示。** 本插件仍处于早期阶段,可能存在无法预见的错误、bug 或不兼容变更。请先备份数据;欢迎[提交 Issue](https://github.com/Tkingxiao/dsh-memu-memory/issues) 或 PR 帮助改进。
|
|
32
32
|
|
|
33
|
-
> **状态:** 1.3.
|
|
33
|
+
> **状态:** 1.3.6。首个公开发布版本为 1.0.0。细节文档已迁到 [`docs/`](docs/),[`AGENTS.md`](AGENTS.md) 只做索引。升级前请备份 `~/.dsh/dsh-memu-memory`;如果要存无法重建的数据,请先读[兼容性与边界](#兼容性与边界)。
|
|
34
34
|
|
|
35
35
|
## 界面
|
|
36
36
|
|
package/docs/troubleshooting.md
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
WebUI 开着 GPU 占用高 / 时钟钉高档 → §3.28
|
|
40
40
|
长链跑批库不增长 / 考试大面积「不知道」→ §3.29
|
|
41
41
|
同一条用户消息每轮注入两次 / 第二次召回 0 条 → §3.30
|
|
42
|
+
mac 一键安装引擎报 dlopen 签名错 / 事后引擎目录是空的 → §3.31
|
|
42
43
|
```
|
|
43
44
|
|
|
44
45
|
## 3. 出过的问题:症状 → 落点 → 守卫
|
|
@@ -393,6 +394,7 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
|
|
|
393
394
|
| §3.27 | 图谱改了没生效 / 缩到最小打架 / 导航被掰竖 | `npm run check` 的 `graph bundle`(源码与 bundle 逐字节比对);`tests/graph-view.test.mjs` 的 relayout 收敛、冷启动零帧、最小缩放命中迟滞;`tests/client-render.test.mjs` 的独立外壳归属。 |
|
|
394
395
|
| §3.28 | WebUI 开着 GPU 占用高 / 时钟钉高档 | `tests/webui.test.mjs` 的 `the shell keeps no always-on compositor drivers`(无限动画只许 boot、ambient 静态、模糊只许小 chrome、缩略图不轮询);`scripts/check-idle-compositing.mjs` 真机数帧(空闲 fps > 2 即 FAIL)。 |
|
|
395
396
|
| §3.30 | 同一条用户消息每轮注入两次 | `tests/injection-rollback.test.mjs` 的 one-pass 幂等与回滚清标记两条(同一消息 id 只注入一次;回滚后重试重投)。 |
|
|
397
|
+
| §3.31 | mac 引擎装不上(dlopen 签名错) | `tests/engine.test.mjs` 断言 `isMacOSLibraryValidationError` 认得 issue #1 的原文错误、不误报普通 ImportError;真机验收:mac 上安装成功,install.log 出现 `re-signing interpreter ad-hoc`。 |
|
|
396
398
|
|
|
397
399
|
## 附录 A · 模块地图(原 §2.1)
|
|
398
400
|
|
|
@@ -586,3 +588,11 @@ section 的 `text(context)` 能拿到 `context.agent`,所以 system prompt **
|
|
|
586
588
|
**现在**:`registerInjection` 按真实用户消息 id 幂等(`binding.lastInjectedUserMessageId`)——一条消息只跑一次注入;`turn/end` 失败且注入没进转录时,`rollbackInjectionForTurn` 清掉标记,真重试仍会重投;压缩后的 reinject(`reinjectPending`)不受影响。
|
|
587
589
|
|
|
588
590
|
**守卫**:`tests/injection-rollback.test.mjs` 的 `the same real user message gets one injection pass when the host emits two enter decisions`、`a rolled-back turn clears the one-pass marker so a real retry injects again`。
|
|
591
|
+
|
|
592
|
+
### 3.31 macOS 一键安装引擎失败:dlopen 报「different Team IDs」(引擎安装 → macOS 签名校验)
|
|
593
|
+
|
|
594
|
+
**症状**:mac 上一键安装 MemU 引擎,安装日志里 `import memu` 在 `import pydantic_core` 处崩:`dlopen(..._pydantic_core.cpython-312-darwin.so): code signature ... not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs`,最终 `no Python candidate could install MemU`。事后按网上教程想去 `engine/0.11.0b3/` 手动 codesign,却发现目录是空的。
|
|
595
|
+
|
|
596
|
+
**落点,可能的原因**:uv 受管 Python 与 DSH 自带 runtime 都是 python-build-standalone 构建,macOS 上带 **Developer ID 签名 + hardened runtime**;macOS 库校验因此拒绝加载 PyPI wheel 里 ad-hoc 签名的 `.so`——pydantic_core 是纯二进制扩展,必撞。修复对象不是 `.so` 而是解释器本身:`codesign --force --sign -` 重签会同时去掉 hardened runtime 标志,之后所有 wheel 都能加载(Homebrew / python.org 官方安装器没有这个签名组合,所以多数 mac 用户遇不到)。**空目录是正常现象**:verify 失败后 `installEngine` 会清掉失败的 tmp venv(`cleanupDir`),所以“到那个目录里 codesign”无从下手,只能靠插件自己修。修法:`installEngine` / `switchEngineVersion` / `ensureEngine` 的 verify 统一走 `verifyEngineRepaired`——错误文本命中 `isMacOSLibraryValidationError` 时,对 venv 解释器的 realpath 做 ad-hoc 重签并重试一次;`ensureManagedPython` 对自己的受管解释器装完即主动重签(是插件下载的产物,随便签)。所有候选都失败时,错误末尾带用户侧旁路提示:`DSH_MEMU_PYTHON` 指向 Homebrew/官方 Python。
|
|
597
|
+
|
|
598
|
+
**守卫**:`tests/engine.test.mjs` 的 `the macOS library-validation dlopen error is recognized for the signing repair`(issue #1 原文错误命中、普通 ImportError 不误触发重签);真机验收项:mac + 受管 Python 安装成功,install.log 里出现 `re-signing interpreter ad-hoc` 一行。
|
package/lib/engine.js
CHANGED
|
@@ -150,6 +150,52 @@ function isWindows() {
|
|
|
150
150
|
return process.platform === 'win32'
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
function isMac() {
|
|
154
|
+
return process.platform === 'darwin'
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// macOS library validation rejects the ad-hoc-signed `.so` files inside PyPI
|
|
158
|
+
// wheels when the running interpreter itself is Developer-ID signed with the
|
|
159
|
+
// hardened runtime (python-build-standalone: the uv-managed Python and the DSH
|
|
160
|
+
// bundled runtime). The dlopen error names "different Team IDs"; ad-hoc
|
|
161
|
+
// re-signing the interpreter drops the hardened runtime flag and lets every
|
|
162
|
+
// wheel load. Matched against verifyEngine's error text so the repair only
|
|
163
|
+
// fires on real signature failures, never on unrelated import errors.
|
|
164
|
+
export function isMacOSLibraryValidationError(text) {
|
|
165
|
+
return /code signature|different Team IDs|SignatureInvalid|library validation/i.test(String(text || ''))
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Best-effort: codesign always exists on macOS, but re-signing an interpreter
|
|
169
|
+
// we don't own (Homebrew, python.org) may fail on permissions; callers treat
|
|
170
|
+
// `false` as "repair unavailable" and let the normal error path report.
|
|
171
|
+
async function resignDarwinInterpreter(python, log) {
|
|
172
|
+
if (!isMac()) return false
|
|
173
|
+
let target = python
|
|
174
|
+
try { target = fs.realpathSync(python) } catch {}
|
|
175
|
+
logLine(`re-signing interpreter ad-hoc (macOS library validation): ${target}`, log)
|
|
176
|
+
const res = await run('/usr/bin/codesign', ['--force', '--sign', '-', target], { timeoutMs: 60_000 })
|
|
177
|
+
if (res.code !== 0) {
|
|
178
|
+
logLine(`codesign failed: ${(res.stderr || res.stdout || '').trim().slice(-200)}`, log)
|
|
179
|
+
return false
|
|
180
|
+
}
|
|
181
|
+
// Files written by other tools can carry a quarantine xattr that would break
|
|
182
|
+
// the next exec even with a valid signature; clearing it is harmless if absent.
|
|
183
|
+
await run('/usr/bin/xattr', ['-d', 'com.apple.quarantine', target], { timeoutMs: 15_000 })
|
|
184
|
+
return true
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// verifyEngine plus the macOS signature repair: on a signature-shaped failure,
|
|
188
|
+
// re-sign the venv's base interpreter once and verify again before declaring
|
|
189
|
+
// the candidate broken. Every verify site goes through here so existing
|
|
190
|
+
// installs self-heal on the next ensure/install too.
|
|
191
|
+
async function verifyEngineRepaired(python, { log, expectedVersion = null } = {}) {
|
|
192
|
+
const verified = await verifyEngine(python, { log, expectedVersion })
|
|
193
|
+
if (verified.ok || !isMac() || !isMacOSLibraryValidationError(verified.error)) return verified
|
|
194
|
+
logLine(`verify failed with a macOS code-signature error; repairing and retrying`, log)
|
|
195
|
+
await resignDarwinInterpreter(python, log)
|
|
196
|
+
return verifyEngine(python, { log, expectedVersion })
|
|
197
|
+
}
|
|
198
|
+
|
|
153
199
|
export function venvPython(venv) {
|
|
154
200
|
return isWindows()
|
|
155
201
|
? path.join(venv, 'Scripts', 'python.exe')
|
|
@@ -525,7 +571,7 @@ export async function switchEngineVersion(version, { log = null, beforeSwitch =
|
|
|
525
571
|
|
|
526
572
|
if (!acquireLock()) return { ok: false, status: 'installing', error: 'another install is already running' }
|
|
527
573
|
try {
|
|
528
|
-
const verified = await
|
|
574
|
+
const verified = await verifyEngineRepaired(target.python, { log, expectedVersion: version })
|
|
529
575
|
// Record what the probe saw, so the version list can say "usable" or "broken"
|
|
530
576
|
// instead of guessing from the presence of a venv directory.
|
|
531
577
|
recordProbe(version, verified)
|
|
@@ -864,7 +910,7 @@ export function readInstallLogTail(maxLines = 14, maxBytes = 24 * 1024) {
|
|
|
864
910
|
export async function installEngine({ force = false, log = null, beforeSwitch = null } = {}) {
|
|
865
911
|
const current = readCurrent()
|
|
866
912
|
if (!force && current?.version === ENGINE_VERSION) {
|
|
867
|
-
const verified = await
|
|
913
|
+
const verified = await verifyEngineRepaired(current.python, { log })
|
|
868
914
|
if (verified.ok) return { ok: true, current, verified }
|
|
869
915
|
}
|
|
870
916
|
|
|
@@ -918,7 +964,7 @@ export async function installEngine({ force = false, log = null, beforeSwitch =
|
|
|
918
964
|
|
|
919
965
|
stateInstalling(`verifying:${base.source}`)
|
|
920
966
|
const python = venvPython(tmpVenv)
|
|
921
|
-
const verified = await
|
|
967
|
+
const verified = await verifyEngineRepaired(python, { log, expectedVersion: ENGINE_VERSION })
|
|
922
968
|
if (!verified.ok) throw new Error(`verify failed: ${verified.error}`)
|
|
923
969
|
|
|
924
970
|
if (typeof beforeSwitch === 'function') {
|
|
@@ -959,7 +1005,11 @@ export async function installEngine({ force = false, log = null, beforeSwitch =
|
|
|
959
1005
|
}
|
|
960
1006
|
}
|
|
961
1007
|
|
|
962
|
-
|
|
1008
|
+
let message = `no Python candidate could install MemU:\n${errors.join('\n')}`
|
|
1009
|
+
if (isMac() && errors.some((e) => isMacOSLibraryValidationError(e))) {
|
|
1010
|
+
message += '\n(macOS 签名校验拒绝了依赖包的 .so;可对 Python 解释器执行 `codesign --force --sign - <python路径>` 后重试,或在设置里用 DSH_MEMU_PYTHON 指定 Homebrew/官方 Python)'
|
|
1011
|
+
}
|
|
1012
|
+
throw new Error(message)
|
|
963
1013
|
} catch (error) {
|
|
964
1014
|
stateError(error)
|
|
965
1015
|
await cleanupDownloads()
|
|
@@ -973,7 +1023,7 @@ export async function installEngine({ force = false, log = null, beforeSwitch =
|
|
|
973
1023
|
export async function ensureEngine({ force = false, log = null, beforeSwitch = null } = {}) {
|
|
974
1024
|
const current = readCurrent()
|
|
975
1025
|
if (!force && current?.version === ENGINE_VERSION) {
|
|
976
|
-
const verified = await
|
|
1026
|
+
const verified = await verifyEngineRepaired(current.python, { log })
|
|
977
1027
|
if (verified.ok) {
|
|
978
1028
|
writeState({ status: 'ready', version: ENGINE_VERSION, step: 'ready', error: null })
|
|
979
1029
|
return { ok: true, current, verified }
|
package/lib/managed-runtime.js
CHANGED
|
@@ -104,5 +104,15 @@ export async function ensureManagedPython({ run, log = () => {}, fetcher = fetch
|
|
|
104
104
|
const found = await run(executable, ['python', 'find', '--no-python-downloads', MANAGED_PYTHON], { env, timeoutMs: 20_000 })
|
|
105
105
|
const python = path.resolve(found.stdout.trim())
|
|
106
106
|
if (found.code !== 0 || !python.startsWith(path.resolve(env.UV_PYTHON_INSTALL_DIR) + path.sep) || !fs.existsSync(python)) throw new Error('managed Python escaped its engine directory')
|
|
107
|
+
if (process.platform === 'darwin') {
|
|
108
|
+
// python-build-standalone interpreters ship Developer-ID-signed with the
|
|
109
|
+
// hardened runtime, so macOS library validation rejects the ad-hoc-signed
|
|
110
|
+
// .so files inside PyPI wheels ("different Team IDs" dlopen failure). Our
|
|
111
|
+
// own managed interpreter is safe to re-sign ad-hoc, which drops the
|
|
112
|
+
// hardened runtime flag before any venv is created from it.
|
|
113
|
+
const resign = await run('/usr/bin/codesign', ['--force', '--sign', '-', python], { env, timeoutMs: 60_000 })
|
|
114
|
+
if (resign.code !== 0) log(`ad-hoc re-sign of managed Python failed (continuing): ${(resign.stderr || resign.stdout || '').trim()}`)
|
|
115
|
+
else log('managed Python re-signed ad-hoc to avoid macOS library validation errors')
|
|
116
|
+
}
|
|
107
117
|
return { kind: 'python', cmd: python, prefix: [], version: { major: 3, minor: 12, raw: MANAGED_PYTHON }, hasPip: false, uvPath: executable, uvEnv: env, source: 'managed-uv' }
|
|
108
118
|
}
|
package/package.json
CHANGED
package/tests/engine.test.mjs
CHANGED
|
@@ -33,3 +33,16 @@ test('a release sorts above its pre-releases', () => {
|
|
|
33
33
|
assert.ok(engine.compareVersions('0.11.0b3', '0.11.0b2') > 0)
|
|
34
34
|
assert.ok(engine.compareVersions('0.11.0b1', '0.10.0') > 0)
|
|
35
35
|
})
|
|
36
|
+
|
|
37
|
+
test('the macOS library-validation dlopen error is recognized for the signing repair', () => {
|
|
38
|
+
// Verbatim shape from GitHub issue #1 (macOS one-click install failure).
|
|
39
|
+
const issue = "ImportError: dlopen(/Users/best/.dsh/dsh-memu-memory/engine/0.11.0b3/venv.tmp-47668/lib/python3.12/site-packages/pydantic_core/_pydantic_core.cpython-312-darwin.so, 0x0002): code signature in <path> not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs"
|
|
40
|
+
assert.ok(engine.isMacOSLibraryValidationError(issue))
|
|
41
|
+
assert.ok(engine.isMacOSLibraryValidationError('list-files smoke failed: library validation failed to load _pydantic_core'))
|
|
42
|
+
assert.ok(engine.isMacOSLibraryValidationError('pip install failed: SignatureInvalid'))
|
|
43
|
+
// Unrelated failures must not trigger an interpreter re-sign.
|
|
44
|
+
assert.equal(engine.isMacOSLibraryValidationError('ImportError: No module named memu'), false)
|
|
45
|
+
assert.equal(engine.isMacOSLibraryValidationError('verify failed: memu-cli version mismatch'), false)
|
|
46
|
+
assert.equal(engine.isMacOSLibraryValidationError(''), false)
|
|
47
|
+
assert.equal(engine.isMacOSLibraryValidationError(null), false)
|
|
48
|
+
})
|