Skip to content

fix(memorylake): config 不再宣称 actor 默认取机器名 - #25

Open
fasdwcx wants to merge 1 commit into
mainfrom
fix/config-actor-help-text
Open

fasdwcx wants to merge 1 commit into
mainfrom
fix/config-actor-help-text

Conversation

@fasdwcx

@fasdwcx fasdwcx commented Aug 27, 2026

Copy link
Copy Markdown

问题

engram memorylake config 在 actor 未设置时仍打印:

  actor:     (unset — defaults to this machine's hostname)

这句话自 v0.7.0(#22 / PR #23)起就不成立了。真实解析是三级:cfg.Actor → /defaults/my-actor(API key 所属用户)→ 机器名。机器名是最后兜底,不是默认值。

DOCS.md 里两处相关说明在 PR #23 中已更新,唯独漏了这个 CLI 字符串 —— 于是文档和命令行对同一件事各说各话。

措辞本身也有实际后果:"defaults to hostname" 读起来就是"不配 actor 你的会话就不会归到自己名下",而这恰恰是 v0.7.0 已经取消的手工步骤,也恰恰是来跑这条命令的人想弄清楚的问题。

改动

-		actor = "(unset — defaults to this machine's hostname)"
+		actor = "(unset — resolved from the API key's owner, else this machine's hostname)"

修复后的输出:

Effective MemoryLake config (env var > saved config > default):
  base_url:  https://app.memorylake.cn/openapi/memorylake
  workspace: engram
  actor:     (unset — resolved from the API key's owner, else this machine's hostname)
  api_key:   sk-…1024

仍然只是描述解析顺序,而不去真的解析。 这条命令是"配置从哪来"的本地读取;真去解析 actor 就得发一次 MemoryLake 往返,让它在离线时变慢或失败。实时探测属于 engram doctor,代码里也留了注释说明这个取舍。

测试

cmdMemorylakeConfig 此前完全没有测试(grep cmdMemorylakeConfig 在 *_test.go 里零命中),这正是文案漂移能跨过一整个发布没被发现的原因。两个分支都补上了:

用例 断言
TestCmdMemorylakeConfig_UnsetActorDescribesRealResolution 不再出现 "defaults to this machine's hostname",且同时提到真正决定顺序的两个来源
TestCmdMemorylakeConfig_SetActorIsShownVerbatim 已配置的 actor 原样打印,不掺解析说明

先红后绿。go test ./... 剩余 8 个失败与 git stash baseline 逐条相同(cmd/engram 2 个、plugin 5 个 + 1 个子用例),与本 PR 无关。

Closes #24

`engram memorylake config` still printed

    actor:     (unset — defaults to this machine's hostname)

which stopped being true in v0.7.0: the actor now resolves from cfg.Actor, then
from the API key's owner via /defaults/my-actor, and only then from the
hostname. DOCS.md was updated for that; this string was missed, so the docs and
the command disagreed about the same thing.

The wording matters beyond accuracy. "Defaults to hostname" reads as "set an
actor or your sessions will not be attributed to you" — precisely the manual
step v0.7.0 removed, and precisely the wrong conclusion someone reaching for
this command is trying to settle.

It keeps describing the resolution rather than performing it: this command is a
local read of where configuration comes from, and resolving the actor for real
would put a MemoryLake round trip behind it, making it slow or failing when
offline. Live checks belong in `engram doctor`.

cmdMemorylakeConfig had no test at all, which is why the drift went unnoticed
through a release. Both branches are covered now — unset describes the real
order, and a configured actor prints verbatim with no commentary.

Closes #24
@fasdwcx fasdwcx added the type:bug Bug fixes label Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engram memorylake config 仍称 actor 默认取机器名,与 v0.7.0 的实际解析顺序不符

1 participant