test: 会话事件写入侧防护回归测试 (refs #8) - #140
Open
spacexun2 wants to merge 1 commit into
Open
Conversation
…standalone verify:events) Rebased onto main (1caff61, 0.1.16-rc.1): the alpha.2+ write path kept the guard contract (appendTeamEvent checking the harness KNOWN_SESSION_EVENT_TYPES, containment of session write failures, captainSessionOf fallback), so the coverage carries over with the event vocabulary updated to the current 10 agent-teams/* types (adds team-halted, team-resumed, plan-discarded). The loader stub is kept so the NanmiCoder#8 scenario stays pinned regardless of the installed harness build; verify:events stays out of the aggregate gate per the earlier decision. Refs NanmiCoder#8
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.
说明:重提原 PR #12
本 PR 重新提交原 [#12]。原 PR 于 2026-09-04 因作者的 head fork(spacexun2/dsh-agent-teams)被意外删除,被 GitHub 以 "head repository deleted" 自动关闭——并非内容被否决。现 fork 已重建,分支基于最新 main(1caff61)重放。
改动概述
为 issue #8 的会话事件写入侧防护(session event write-guard)提供离线回归测试,新增独立的
pnpm verify:events入口:scripts/verify-events.mjs:以 stub 掉的@deepseek-ai/dsh-session驱动构建产物lib/events.js,固化四组行为:①harness 未识别的agent-teams/*事件一律不写入 session log;②harness 已识别的第一方类型(如tool-workflow/run-started)照常写入;③session.append抛错被appendTeamEvent吸收,不外溢;④captainSessionOf的 fallback 语义(离线 captain 回退到调用者 session,在线 captain 的 live session 优先)。scripts/mock-dsh-session-loader.mjs:ESM loader stub,把 issue session.append 写入不可忽略的自定义事件类型,导致历史会话拒读(SessionFormatUnsupportedError) #8 的场景(只认第一方tool-workflow/*/agent/*词汇的 harness)确定性地钉住,不随本地安装的 harness 版本漂移。package.json:新增"verify:events": "node scripts/verify-events.mjs";按此前决定继续不入聚合verify门,其余 verify 链未动。对当前写入路径的适配(alpha.2 之后)
原 PR 基于 0.1.10 时代写入路径。上游 alpha.2 重构(commit bf50b49 及后续)后,guard 契约保留:
src/events.ts的appendTeamEvent仍按 harnessKNOWN_SESSION_EVENT_TYPES决定写入/省略、仍 try/catch 包住session.append,captainSessionOf签名与 fallback 语义不变;conversationEvents → uiConversation的改名发生在 client 侧,不影响本测试面。适配点:事件词汇表更新为当前src/event-types.ts的 10 个agent-teams/*类型(新增team-halted、team-resumed、plan-discarded),stub 注释同步(rc.1 起 devDependencies 已安装@deepseek-ai/*,stub 保留以钉死场景)。本地验证证据(最新 main + 本分支,Windows / Node v24.16.0)
Refs #8