test: 会话事件写入侧防护回归测试(refs #8) - #12
Open
spacexun2 wants to merge 3 commits into
Open
Conversation
The upstream write-guard (aace29c, lib/events.js) that prevents issue NanmiCoder#8 from recurring has no test coverage. Add scripts/verify-events.mjs, which stubs @deepseek-ai/dsh-session via an ESM loader hook (the repo does not install @deepseek-ai/* packages per .npmrc), so the guard is pinned in a clean checkout with zero dependencies: - all 7 agent-teams/* event types are omitted from the session log - harness-recognized first-party types are still written - unknown custom types are omitted - session.append failures are contained - captainSessionOf falls back / prefers the live captain session Wired into the verify gate as verify:events (refs NanmiCoder#8).
spacexun2
force-pushed
the
test/verify-session-event-write-guard
branch
from
August 15, 2026 13:28
5cec352 to
4335447
Compare
The repo builds lib/ from src/ (PR NanmiCoder#27), so the offline guard tests now document the same convention as scripts/verify.mjs: pnpm build first.
The regression test stays available via pnpm verify:events but is not wired into the publish gate: the repo is pre-release and iterating fast (e.g. the lib/ -> src build change), and keeping internals tests out of the release chain minimizes the maintenance tax on the maintainer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要(Summary)
为 #8 的最终修复(aace29c 写入侧防护,现位于
src/events.ts)补回归测试——此前该防护零测试覆盖。已适配 #27 之后的源码构建结构(lib/ 由pnpm build产出)。改动(Affected)
scripts/verify-events.mjs(新增):离线回归脚本,7 项断言,与scripts/verify.mjs同约定——pnpm build && node scripts/verify-events.mjs(lib/ 缺失时给出明确提示);scripts/mock-dsh-session-loader.mjs(新增):ESM loader 钩子打桩@deepseek-ai/dsh-session——遵守.npmrc的约定(@deepseek-ai/*由 DSH 运行时提供、不安装为依赖),测试逻辑零依赖;package.json:新增独立入口verify:events(不接入发布门禁——仓库处于 pre-release 快速迭代期,如 lib/ → src 构建结构调整;把内部测试留在发布链之外,减少维护税)。测试内容
agent-teams/*事件全部不写入会话日志(session.append 写入不可忽略的自定义事件类型,导致历史会话拒读(SessionFormatUnsupportedError) #8 核心回归:防写入侧防护被回退);tool-workflow/*、agent/*)照常写入;session.append抛错不外溢;captainSessionOf:captain 离线时回退,在线时优先 captain session。设计说明
打桩的
KNOWN_SESSION_EVENT_TYPES模拟"只识别 first-party 类型、不识别agent-teams/*"的 harness——正是 #8 的场景。若未来 harness 补上注册面/ignorable 写入面(见 #7),第 1 组断言会如预期地要求测试更新(即行为契约变更的信号)。本地验证(Local Validation)
(
src/events.ts与测试所加载的 lib 产物防护逻辑经源码逐行比对一致;完整pnpm build需 DSH 运行时提供 peer 类型,与仓库约定一致。)refs #8