Skip to content

feat(deps): migrate replay state to dsh-llm rc.8's ReplayEnvelope - #54

Merged
stuffbucket merged 1 commit into
mainfrom
feat/dsh-llm-rc8-replay-envelope
Sep 6, 2026
Merged

stuffbucket merged 1 commit into
mainfrom
feat/dsh-llm-rc8-replay-envelope

Conversation

@stuffbucket

Copy link
Copy Markdown
Owner

Supersedes #39, which cannot land as a plain bump.

The break

rc.8 types the terminal finish chunk's replayState, which rc.6 left as
unknown:

interface ReplayEnvelope {
  response: unknown
  blocks?: readonly unknown[]
}

This workspace filled that slot with its own { content, type: "anthropic-message-v1" }.

Why the per-block array goes in blocks

Not cosmetic. dsh-llm's assembler prunes blocks at the same positions as any
block it drops — a max_tokens finish drops tool calls that were cut off and
cannot safely be executed — so the envelope keeps describing the content that
survived. Anything under response is opaque to the assembler, cannot be
pruned, and drifts out of step on the first truncation.

Drift is silent. When blocks.length disagrees with the emitted block
count, the assembler discards the envelope whole and reports nothing. The
reasoning block just arrives without its signature, and the first visible
symptom is a provider rejecting the replayed history much later.

So the alignment is what the tests pin, against the real BlockAssembler
rather than against our beliefs about it:

  • one blocks entry per emitted block — asserted as the invariant, since a
    literal would still pass if both sides drifted together;
  • a max_tokens finish drops the unexecutable tool call and prunes the
    envelope at the same position, with the surviving reasoning block keeping its
    signature;
  • a misaligned envelope is discarded with no error — pinning the hazard itself,
    so reintroducing it fails a test instead of going quiet.

Plus a host-side test: the host reads the finish chunk directly rather than
using the assembler, which makes it the one place a mismatch can still become a
502 instead of a silence.

Migrated in step

Producers and consumers move together. The envelope never leaves the workspace
— no on-disk persistence, and bridge.ts rebuilds replay from request content
rather than reading a stored envelope — so no compatibility shim is needed.

Package Producer Consumer
omlx replay.ts (type + helper) serialize.ts
anthropic-provider translate.ts wire.ts
maximal-dsh-host bridge.ts bridge.ts

Two fixture pins the bump exposed

The host's synthetic provider profiles and the oMLX integration profile declare
dsh-llm as an exact version, and profile validation rejects a mismatch
against what is installed — every host test failed with The external provider profile is invalid until they tracked the bump.

Only the hoisted dsh-llm actually moved. dsh-attachment, dsh-brand,
dsh-invariants and dsh-timeout still resolve to rc.6 there, so those pins
are deliberately unchanged.

Verification

  • Container suite 15/15 tasks green, including all four new tests.
  • tsc --noEmit and eslint clean across the three changed packages.
  • verify:workspace passes; lockfile re-resolved and stripped of rotating
    shard hosts per SOURCES.md.

One structural note: the new host test pushed host.test.ts past its 800-line
max-lines ceiling, so it lives in tests/replay-alignment.test.ts. Only the
new test moved — relocating the existing replay tests would be a larger diff
than this PR warrants.

@deepseek-ai/dsh-llm 0.1.0-rc.8 types the terminal finish chunk's
replayState, which rc.6 left as `unknown`:

    interface ReplayEnvelope { response: unknown; blocks?: readonly unknown[] }

This workspace filled that slot with its own `{ content, type }`, so the
bump is an API break rather than a version change and could not land as
a plain Dependabot bump.

Put the per-block array in `blocks` and the discriminator in `response`.
The placement is the whole point. dsh-llm's assembler prunes `blocks` at
the same positions as any block it drops -- a max-tokens finish drops
tool calls that were cut off and cannot safely be executed -- so the
envelope keeps describing the content that survived. State kept anywhere
under `response` is opaque to the assembler, so it cannot be pruned, and
falls out of step on the first truncation.

Falling out of step is not a loud failure. An envelope whose `blocks`
length disagrees with the emitted block count is discarded whole, with no
error: the reasoning block simply arrives without its signature, and the
first visible symptom is a provider rejecting the replayed history much
later. Three new tests in anthropic-provider pin the behaviour against
the real assembler -- one entry per emitted block, correct pruning under
a max-tokens finish, and the silent discard itself -- and a new host test
covers the one place a mismatch can still be turned into an error, since
the host reads the finish chunk rather than using the assembler.

Migrated in step, producers and consumers together; the envelope never
leaves the workspace, so no compatibility shim is needed:

  omlx              replay.ts (type + helper), serialize.ts (reader)
  anthropic-provider translate.ts (producer), wire.ts (reader)
  maximal-dsh-host   bridge.ts (both directions)

Two fixture pins had to follow the bump. The host's synthetic provider
profiles and the oMLX integration profile declare dsh-llm as an exact
version, and profile validation rejects a mismatch against what is
installed. Only the hoisted dsh-llm moved: dsh-attachment, dsh-brand,
dsh-invariants and dsh-timeout still resolve to rc.6 there, so those pins
are unchanged.

The new host test pushed host.test.ts past its 800-line max-lines
ceiling, so it lives in tests/replay-alignment.test.ts.

Supersedes #39
@stuffbucket
stuffbucket merged commit 708d5a2 into main Sep 6, 2026
6 checks passed
@stuffbucket
stuffbucket deleted the feat/dsh-llm-rc8-replay-envelope branch September 6, 2026 10:01
stuffbucket added a commit that referenced this pull request Sep 7, 2026
#79)

## What

The dsh-host test fixture hardcodes the versions it writes into the
fixture profile's `package.json`:

```js
dependencies: {
  "@deepseek-ai/cordis": "4.0.1",
  "@deepseek-ai/dsh-llm": "0.1.0-rc.8",
  ...
}
```

but it symlinks the *actually installed* packages next to it.
`resolveExternalProfile` requires the two to agree (`profile.ts:766`),
so any bump of cordis, dsh-llm or schemastery breaks every test in the
package.

## Why it matters

The failure surfaces as the generic

```
Error [DshHostStartError]: The external provider profile is invalid.
```

which names neither the package nor the version — it reads like a
regression in the bumped dependency. This is exactly what happened on
#71 (cordis 4.0.1 → 4.0.2), and #54 had already had to hand-bump these
strings once for dsh-llm rc.6 → rc.8.

## The fix

Derive the versions from the same `require.resolve` that `packageRoot`
already uses, so the manifest can never disagree with what is linked.

No production code changes — `tests/fixture.ts` only.

## Verification

- 44/44 on main (cordis 4.0.1)
- 44/44 with #71's bumps applied (cordis 4.0.2, schemastery 3.18.2),
**with no pins** — confirming there is no cordis regression
- `pnpm run lint` and `pnpm run typecheck` clean across the workspace
- lockfile untouched, 0 shard hosts
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