Files
amethyst/cli/tests/marmot
Claude 7014d88b2e feat(marmot): wire agent text streams end to end, both directions
The transport was there and the codecs were there; nothing joined them to
a group. Now `amy marmot stream start|send|watch|finish` does: a hidden
kind:1200 anchors the stream over MLS, records ride raw QUIC through a
broker, and a kind:9 closes it carrying the transcript a receiver checks
its own fold against.

`AgentTextStreamSubscriber` is the receive discipline the binding spells
out, and it matters because a preview that quietly diverges is worse than
no preview: `seq` accepted at most once and never folded out of order, a
replayed record (which a broker WILL send from the start of its replay
window on reconnect) discarded silently and never stream-fatal, a gap
that cannot be backfilled marking the preview unverifiable because the
transcript hash can no longer complete. Only TextDelta and Checkpoint
reach the answer text — progress and status are chrome the spec forbids
from ever reaching notifications, indexes or automation input.

The start payload also grew the tags it was missing: `stream-type`,
`final-kind` and the optional `parent`, plus the rule that a final
payload whose kind disagrees with `final-kind` is ignored.

Verified in both directions against MDK in harness tests 18 and 19: `wn
stream verify` confirms our transcript from our own kind:1200 + kind:9,
and our subscriber folds MDK's stream to a transcript hash identical to
the one `wn stream send` computed. That equality is the key schedule, key
context, AEAD, framing and transcript construction all agreeing with an
implementation that is not ours. 19 of 19 harness tests pass, twice.

Two defects only that exercise could have found:

  - The epoch belongs to the stream, not to the clock. The record key
    context binds mls_epoch, and both sides were resolving it as "the
    group's current epoch" at each command, so a commit landing between
    the start and the send put them on different keys and produced an
    empty preview. The epoch that DELIVERED the kind:1200 is the
    stream's; it is persisted with the message now and read back by
    publisher and receiver alike.

  - close() dropped the tail of a stream. enqueue only fills the send
    buffer, so tearing the connection down before the driver flushed it
    lost records silently — the publisher had already counted them. QUIC
    ACKs a FIN only once everything ahead of it arrived, so finish() now
    waits for finAcked. This is exactly why the test passed alone and
    failed inside a full run.

The `send` (0xF2D2) and `fanout` (0xF2D4) role capabilities stay
unadvertised: a role is a promise to the whole group, and only the CLI
originates a stream so far.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016kCuA6tc4JQzHPCDd39GHq
2026-09-09 12:43:44 +00:00
..