Skip to content

fix: register fallbacks/switch session event type at startup (issue #52) - #53

Merged
btspoony merged 4 commits into
mainfrom
feature/llm-fallbacks-session-event-fix
Aug 16, 2026
Merged

fix: register fallbacks/switch session event type at startup (issue #52)#53
btspoony merged 4 commits into
mainfrom
feature/llm-fallbacks-session-event-fix

Conversation

@btspoony

Copy link
Copy Markdown
Collaborator

What

Fixes #52 — sessions containing a fallbacks/switch event refuse to load after a dsh restart (SessionFormatUnsupportedError: ... unknown to this harness and not marked ignorable).

Root cause: the plugin appends a custom session event type (src/index.ts agent.session.append('fallbacks/switch', …)) that is only TS-augmented (src/events.ts declare module), never registered at runtime. dsh's persistence read path (assertEventsSupported) hard-refuses types outside the build-time KNOWN_SESSION_EVENT_TYPES unless the envelope carries ignorable: true — which Session.append cannot write. Out-of-repo plugins have no official registration surface yet (tracked: .mstar/plans/llm-fallbacks-session-event-format/UPSTREAM-ISSUE.md).

Change (user-approved B1 stopgap)

  • src/index.ts: in apply(), register fallbacks/switch into the ROOT-exported KNOWN_SESSION_EVENT_TYPES Set (namespace import from package root — not the ./types subpath copy; idempotent, no module-level side effects; apply-time registration precedes all lazy session loads, so already-persisted logs heal retroactively). commit() gains an append guard: if registration is unavailable, the durable event is skipped (rate-limited warn) — a session log is never written with an unregistered type.
  • Tests: tests/session-event-registration.spec.ts (pins the root Set mutability + the exact read-path predicate pre/post registration + idempotency) and tests/session-event-registration-guard.spec.ts (registration-unavailable path: decision intact, no event, no throw, one warn).
  • Docs: corrected the false "persisted / unaffected by uninstall" claims in README×2, docs/install.md, docs/consumer-api.md, docs/verification.md + knowledge docs; .changes/unreleased/session-event-registration.md fragment.
  • peerDependencies: @deepseek-ai/dsh-session declared (now a runtime value import).

Verification

  • pnpm test: 600/600 (incl. peer-deps contract test)
  • pnpm typecheck + pnpm build: clean
  • QC single review + targeted re-review: Approve (0C/0W; S-001/S-002 tracked as residuals)
  • Manual L4 (real host): restart dsh with the plugin installed and reopen an affected session — expected to load.

Note

Stopgap until the upstream runtime registration surface lands (issue draft kept at .mstar/plans/llm-fallbacks-session-event-format/UPSTREAM-ISSUE.md); the same event type then switches to the official register call with zero surface changes.

Sessions containing a fallbacks/switch event refused to load after a dsh
restart: the persistence read path (assertEventsSupported) only accepts
types in the host's baked KNOWN_SESSION_EVENT_TYPES catalog or events
marked ignorable, and Session.append cannot write ignorable. Register the
type into the root-exported catalog from apply() (lazy session loads
always follow composition start), and guard the commit() append: when
registration is unavailable, skip the durable event with a rate-limited
warn instead of writing one the read path would refuse. Stopgap until the
upstream registration surface lands (UPSTREAM-ISSUE.md).
…#52)

Pin 1/2: the root-exported KNOWN_SESSION_EVENT_TYPES is a mutable Set that
accepts fallbacks/switch (the exact assertEventsSupported predicate), and
an appended switch event carries no ignorable marker, so the mirrored
refusal condition is true pre-registration and false post-registration.
Pin 3: with the dsh-session catalog export unavailable (vi.mock), commit()
skips the durable event, does not throw, keeps the switch bookkeeping, and
warns exactly once per apply.
…t (issue #52)

The events only load across a restart while the plugin registers their type
at startup (rc.6 runtime registration stopgap; upstream registration surface
pending) — uninstalling the plugin makes affected sessions refuse to load
again until the upstream surface lands. Corrected README.md + README.zh-CN.md
(Verify + Features), docs/install.md uninstall claim, docs/consumer-api.md
cross-plugin advice, docs/verification.md matrix note (the reload gap that
shipped #52), and the two knowledge docs; added the Fixed changelog fragment.
@btspoony
btspoony merged commit be73e49 into main Aug 16, 2026
1 check passed
@btspoony
btspoony deleted the feature/llm-fallbacks-session-event-fix branch August 16, 2026 16:29
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.

[Bug]在关闭了dsh重新打开后,原有的session无法成功加载

1 participant