Skip to content

test: 会话事件写入侧防护回归测试 (refs #8) - #140

Open
spacexun2 wants to merge 1 commit into
NanmiCoder:mainfrom
spacexun2:rebuild/pr-12
Open

spacexun2 wants to merge 1 commit into
NanmiCoder:mainfrom
spacexun2:rebuild/pr-12

Conversation

@spacexun2

@spacexun2 spacexun2 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Note: re-opening the original PR #12

This PR re-submits the original [#12]. It was auto-closed by GitHub with "head repository deleted" on 2026-09-04 when the author's head fork (spacexun2/dsh-agent-teams) was deleted by accident — not a rejection on the merits. The fork has been rebuilt and the branch is replayed on top of the current main (426024f).

What it does

An offline regression test for the session event write-guard from issue #8, plus a standalone pnpm verify:events entry:

  • scripts/verify-events.mjs: drives the built lib/events.js against a stubbed @deepseek-ai/dsh-session and pins four behaviors: (1) agent-teams/* event types the harness does not recognize are never written to the session log; (2) recognized first-party types (e.g. tool-workflow/run-started) are written as usual; (3) a throwing session.append is contained inside appendTeamEvent; (4) the captainSessionOf fallback semantics (offline captain falls back to the caller session; a live captain session wins).
  • scripts/mock-dsh-session-loader.mjs: an ESM loader stub that pins the issue session.append 写入不可忽略的自定义事件类型,导致历史会话拒读(SessionFormatUnsupportedError) #8 scenario deterministically (a harness that only knows first-party tool-workflow/* / agent/* vocabulary), so the test does not drift with the locally installed harness version.
  • package.json: adds "verify:events": "node scripts/verify-events.mjs". As decided earlier, it stays out of the aggregate verify gate; the rest of the chain is untouched.

Fit to the current write path (post-alpha.2)

The original PR targeted the 0.1.10-era write path. After the alpha.2 refactor (bf50b49 and follow-ups) the guard contract is intact: appendTeamEvent in src/events.ts still decides write/skip by the harness KNOWN_SESSION_EVENT_TYPES, still wraps session.append in try/catch, and captainSessionOf keeps its signature and fallback semantics. The conversationEvents → uiConversation rename happened on the client side and does not touch this test surface. Adaptation in this replay: the event vocabulary now covers the 10 agent-teams/* types in the current src/event-types.ts (including the newer team-halted, team-resumed, plan-discarded), with the stub comments updated; since rc.1 the @deepseek-ai/* packages are installed as devDependencies and the stub is kept anyway to pin the scenario.

Local verification (current main + this branch, Windows / Node v24.16.0)

pnpm build (clean-build.mjs && tsc -p tsconfig.json && tsc -p tsconfig.client.json && tsdown) → ok
node scripts/verify-events.mjs
  1/4 out-of-repo event types are never written
    PASS  all 10 agent-teams/* types are omitted from the session log
  2/4 harness-recognized types are still written
    PASS  known first-party type is written
    PASS  unknown custom type is omitted too
  3/4 session write failures are contained
    PASS  append failure does not escape appendTeamEvent
  4/4 captain session resolution
    PASS  offline captain falls back to the caller session
    PASS  live captain session wins over the fallback
  all checks passed  (exit 0)

Refs #8

…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
WhiteWh added a commit to WhiteWh/dsh-agent-teams that referenced this pull request Sep 19, 2026
…ontract message, event guard)

Transfers reviewed open PRs from NanmiCoder/dsh-agent-teams into this branch.
None of them was merged upstream; each was re-verified locally first.

NanmiCoder#186 (xwchris) Harness 0.1.5-rc.2 support:
- compatibility.json adds 0.1.5-rc.2 on the preview track; recommendedHost
  stays 0.1.5-rc.1, so the release toolchain and README pair are unchanged.
- package.json: 21 @deepseek-ai/* peer ranges gain 0.1.5-rc.2.
- docs/harness-0.1.5-rc.2-acceptance.md records the host diff and the scope
  the upstream author actually exercised.
- npm serves 0.1.5-rc.2 as latest; peer warnings disappear for those users.

NanmiCoder#169 (chenkai2) stop writing a bespoke message source kind (NanmiCoder#160):
- src/command.ts injected source { kind: 'agent-teams-command' } for the
  /agent-teams activation directive and the unknown-profile directive.
- The installed host keeps a closed whitelist in
  @deepseek-ai/dsh-session-format-v2-to-v3/lib/index.js: SOURCE_KINDS holds
  plugin but not agent-teams-command, and line 125 throws
  SessionFormatUnsupportedMigrationError("cannot safely transform unclassified
  message source"), so every historical session containing one became
  impossible to open after a host upgrade.
- Both directives now emit the plugin source shape the delivery paths already
  use: kind plugin, plugin dsh-agent-teams; the module augmentation that
  declared the removed kind is gone too.
- scripts/command-source.test.mjs pins all three cases (activation, unknown
  profile, untouched ordinary turn) and is wired as verify:command-source.

NanmiCoder#177 (Tonited) name the colliding lists when a contract contradicts itself:
- classifyChangedPath consults outOfScope before inScope, so a path listed in
  both was rejected with a bare "is out_of_scope", which blames the path and
  sends the member hunting for a scope violation that is really a contract
  defect. evaluateQualityCompletion now names both lists.
- The upstream test half was rewritten onto this branch's harness (the upstream
  file is 1233 lines, ours is 1791 and grew by this step) as section I.

NanmiCoder#140 (spacexun2) session event write-guard regression test (NanmiCoder#8):
- scripts/verify-events.mjs plus scripts/mock-dsh-session-loader.mjs pin the
  guard in src/events.ts: out-of-repo agent-teams/* types are never written to
  the session log, recognised types still are, append failures stay contained,
  and captain resolution prefers a live session over the fallback.
- Wired as verify:events, deliberately not inside the aggregate verify chain,
  matching the upstream PR.

NanmiCoder#141 (spacexun2) align the module export name with the package name:
- src/index.ts exported name = 'agent-teams' while package.json declares
  @nanmicoder/dsh-agent-teams and cordis.patch.yml mounts that package name.

Verification: tsc -p tsconfig.json and tsconfig.client.json --noEmit both
clean; full build (clean-build + tsc + tsdown) clean; every server-side suite
in the verify chain green, including quality-gates-tdd with the new section I
check, command-source (3/3), verify-events (7/7), lifecycle, stress,
harness-contract, stability, capabilities, member-spawn-recovery, compatibility
and doctor (231 package identities). scripts/verify.mjs and node --test files
cannot run in this confined pwsh sandbox (spawn EPERM on named pipes) - the
same failure reproduces on the untouched parent commit, verified in a throwaway
worktree, so it is an environment limit, not a regression.
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.

1 participant