Skip to content

feat(middleware): implement LIVE=1 smoke test for Claude CLI runtime#35

Merged
alexey-pelykh merged 1 commit intomainfrom
feat/middleware-claude-live-smoke-test
Feb 26, 2026
Merged

feat(middleware): implement LIVE=1 smoke test for Claude CLI runtime#35
alexey-pelykh merged 1 commit intomainfrom
feat/middleware-claude-live-smoke-test

Conversation

@alexey-pelykh
Copy link
Copy Markdown

@alexey-pelykh alexey-pelykh commented Feb 26, 2026

Summary

  • End-to-end smoke test validating the full middleware pipeline with a real Claude CLI subprocess
  • Exercises: message → ChannelBridge → ClaudeCliRuntime → claude -p --output-format stream-json → NDJSON streaming → AgentDeliveryResult
  • Gated behind LIVE=1 environment variable so CI skips it by default
  • Validates single-turn response (payloads, text, sessionId, aborted, durationMs) and session resumption
  • Clears all Claude Code env vars (CLAUDECODE, CLAUDE_CODE_ENTRYPOINT, CLAUDE_CODE_MAX_OUTPUT_TOKENS) in beforeAll to prevent nesting rejection

Bug fix: Claude CLI NDJSON stream source

During smoke test development, discovered that claude -p --output-format stream-json emits NDJSON to stderr, not stdout. Added a configurable ndjsonStream getter to CLIRuntimeBase (defaults to "stdout") and overrode to "stderr" in ClaudeCliRuntime. The non-NDJSON stream is captured as diagnostics.

Closes #34

Test plan

  • pnpm check passes (format + typecheck + lint)
  • pnpm vitest run src/middleware/ — all 367 unit tests pass
  • pnpm vitest run --config vitest.live.config.ts finds the test and skips it without LIVE=1
  • LIVE=1 pnpm vitest run --config vitest.live.config.ts src/middleware/__smoke__/claude.live.test.ts runs both tests with a real Claude CLI (must be run from a normal terminal, not from within Claude Code due to nesting restrictions)

🤖 Generated with Claude Code

…34)

Add a two-case live smoke test gated behind LIVE=1 that validates the
full middleware pipeline: message → ChannelBridge → ClaudeCliRuntime →
claude -p → NDJSON streaming → AgentDeliveryResult.

- Single-turn "2+2" response with assertions on payloads, text,
  sessionId, aborted flag, and durationMs
- Session resumption verifying the same sessionId is reused

Also fix CLIRuntimeBase to support configurable NDJSON stream selection:
Claude CLI emits stream-json output on stderr (not stdout), so add a
protected ndjsonStream getter overridden in ClaudeCliRuntime.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-pelykh alexey-pelykh force-pushed the feat/middleware-claude-live-smoke-test branch from 7d6025f to 831f5da Compare February 26, 2026 10:12
@alexey-pelykh alexey-pelykh enabled auto-merge (squash) February 26, 2026 10:19
@alexey-pelykh alexey-pelykh merged commit 668168c into main Feb 26, 2026
2 checks passed
@alexey-pelykh alexey-pelykh deleted the feat/middleware-claude-live-smoke-test branch February 26, 2026 10:22
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.

Implement LIVE=1 smoke test for Claude CLI runtime

1 participant