Skip to content

feat(v1.1): Anthropic SSE streaming replay, zero-network guard, Go SDK, and TracePort v1.1 interop - #2

Merged
aloneangel45 merged 2 commits into
mainfrom
feat/anthropic-sse-streaming-v1.1
Nov 10, 2026
Merged

aloneangel45 merged 2 commits into
mainfrom
feat/anthropic-sse-streaming-v1.1

Conversation

@aloneangel45

Copy link
Copy Markdown
Owner

Closes #1

Summary

Implements v1.1.0 deterministic Anthropic Messages API & OpenAI SSE streaming recording/replay (pkg/cassette/sse.go), zero-network offline socket enforcement, embedded Go testing.T SDK (pkg/agenttest), bidirectional MCP Content-Length + NDJSON framing, sub-millisecond 100KB fuzzy matching, and TracePort v1.1 split .meta.json + .frames.jsonl session ingestion.

Key Engineering Changes

  • Anthropic & OpenAI SSE Streaming Engine (RFC [RFC] Cassette replay support for Anthropic Messages API streaming events #1): Spec-compliant WHATWG SSE decoder/encoder/recorder/replayer in pkg/cassette/sse.go supporting message_start, content_block_start, content_block_delta (text_delta, thinking_delta, signature_delta, input_json_delta, citations_delta), content_block_stop, message_delta, message_stop, ping, error, and OpenAI data: [DONE] streams. Supports instant (0ms CI default), scaled, and exact recorded delta_ms replay modes, plus ReconstructStreamSummary for semantic diffs and exact token accounting.
  • Zero-Network Offline Enforcement & Proxy Fixes: Rejects HTTP CONNECT with 403, exposes proxy.NewOfflineHTTPClient blocking non-loopback TCP dials, fixes agentfixture record -- <cmd> server binding, strips outbound Accept-Encoding so upstream gzip responses decode cleanly prior to redaction, releases server mutex prior to I/O & chunk delays, and prefers unconsumed sequence interactions for multi-turn repeated tool calls.
  • Canonical Matching, Performance & Redaction Hardening: Canonicalizes raw JSON bodies with 64-bit UseNumber() fidelity, normalizes full URLs and query strings, computes StrictHash after secret scrubbing (eliminating secret hash oracles and allowing dummy CI keys to match), expands secret redaction & CheckForUnredactedSecrets across SSE deltas/headers/URLs/tags while masking matched previews, and optimizes 100KB prompt fuzzy matching from ~15s down to ~0.7ms (336 MB/s).
  • Go Testing SDK, MCP Stdio & TracePort v1.1 Interop: Added pkg/agenttest (NewTestServer(t, path)), 16MB MCP StdioRecorder & StdioReplayer with Content-Length + NDJSON framing and automatic initialize/ping/tools/list synthesis, inspect & redact CLI subcommands, -exit-code semantic SSE diffing, and native ingestion of TracePort v1.1 .meta.json + .frames.jsonl sessions.

Benchmark Highlights (CGO_ENABLED=0 go test -bench=. -benchmem ./...)

Benchmark Latency Throughput / Allocs
BenchmarkReplaySSEStream_Instant 1.62 us/op 1,587.6 MB/s (22 allocs/op)
BenchmarkDecodeSSE_AnthropicStream 45.58 us/op 225.1 MB/s
BenchmarkStrictMatcher_JSON 9.22 us/op 79 allocs/op
BenchmarkFuzzyMatcher_100KBDisjointPrompt 0.63 - 0.78 ms/op 336.9 MB/s (3 allocs/op)

Verification

  • CGO_ENABLED=0 go vet ./... & go test -v -count=1 ./... (71/71 test cases passing across all 8 packages, including 10x consecutive SSE replay determinism)

@aloneangel45
aloneangel45 merged commit 5e950cb into main Nov 10, 2026
6 checks passed
@aloneangel45
aloneangel45 deleted the feat/anthropic-sse-streaming-v1.1 branch November 10, 2026 17:58
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.

[RFC] Cassette replay support for Anthropic Messages API streaming events

1 participant