Skip to content

fix(runtime): cordis 4.0.1 service reads + session-safe injected messages - #1

Open
dracpet wants to merge 1 commit into
hwc66626:mainfrom
dracpet:fix/cordis4-session-message-shape
Open

fix(runtime): cordis 4.0.1 service reads + session-safe injected messages#1
dracpet wants to merge 1 commit into
hwc66626:mainfrom
dracpet:fix/cordis4-session-message-shape

Conversation

@dracpet

@dracpet dracpet commented Aug 21, 2026

Copy link
Copy Markdown

Problem

Two host-contract breaks on DSH desktop 4.0.1 / rc.8, both live-diagnosed on 2026-08-21:

1. Session persistence corruption from injected messages

Messages that powerkit pushes into decision.messages use the bare wire shape { type: 'user', text }. They are persisted verbatim, and the session loader rejects id-less user/message events on resume:

SessionPersistenceCorruptionError: session event at seq N lacks an identified message

Any session where powerkit injected a slash-command reply, a custom-command expansion, or a context pack became unresumable.

Fix: new util.pkUserMessage(text) emits the hybrid wire+canonical shape — type/text for existing wire consumers, plus id/role/content/source so the loader's canonical-message validation passes. All injection points now use it (slash-command replies, custom-command expansion, context pack, agent.steer).

2. cordis 4.0.1 context proxy rejects raw service reads

ctx.agentPresets, ctx.agents, this.host?.agents, caps.tools throw cannot get property without inject on cordis 4.0.1's context proxy. Consequences:

  • /pk doctor showed tools/agents as missing (they exist);
  • the native agentPresets bridge silently degraded to the catch-and-continue path even though the host provides the service;
  • steerAgent / cancelAgent could never reach a real agent.

Fix: route those reads through the existing hostService() helper (ctx.reflect.get), the same pattern tryRegisterTools already uses and documents.

Verification

  • tsc -p tsconfig.json --noEmit clean; tsdown build clean.
  • Running as a local patch on a live desktop profile since 2026-08-21: /pk doctor resolves tools/agents again, previously corrupted sessions resume, and injected messages validate on save.
  • Note: npm test currently requires Node ≤ 24 (--experimental-transform-types was removed in newer Node); tests were not runnable under Node 26 in this environment — typecheck + build + production soak used instead.

Scope note

This PR is intentionally limited to the two functional repairs. (A local English-UI translation of the panel exists in the same deployment but is a preference, not a bug fix — happy to upstream it separately as opt-in i18n if you want it.)

…ages

Two host-contract repairs, both live-diagnosed on DSH desktop 4.0.1
(2026-08-21):

1. Session persistence corruption: messages pushed into decision.messages
   in the bare wire shape { type: 'user', text } are persisted verbatim,
   and rc.8's session loader rejects id-less user/message events on resume
   (SessionPersistenceCorruptionError: "session event at seq N lacks an
   identified message"). Add util.pkUserMessage() emitting the hybrid
   wire+canonical shape (type/text + id/role/content/source) and use it at
   all injection points (slash-command replies, custom-command expansion,
   context pack, agent.steer).

2. cordis 4.0.1 context proxy: raw ctx / this.host property reads throw
   "cannot get property without inject". Route the remaining reads through
   the existing hostService() helper (ctx.reflect.get): /pk doctor
   hostCapabilities, the native agentPresets bridge (now actually binds
   instead of silently degrading), steerAgent, cancelAgent.
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