Skip to content

test(core): cover send / execute / sendStream (close TS↔Python coverage gap) - #52

Closed
AndreLFSMartins wants to merge 7 commits into
codespar:mainfrom
AndreLFSMartins:test/core-send-execute-stream-coverage
Closed

AndreLFSMartins wants to merge 7 commits into
codespar:mainfrom
AndreLFSMartins:test/core-send-execute-stream-coverage

Conversation

@AndreLFSMartins

@AndreLFSMartins AndreLFSMartins commented May 19, 2026

Copy link
Copy Markdown
Contributor

What

Adds Vitest coverage for session.send, session.execute, and session.sendStream in @codespar/sdk. These surfaces were untested on the TS side while the Python package already covers them. Test-only — no production source changed.

Coverage added

src/__tests__/send-stream.test.ts — SSE parsed end to end through the real parseSseStream (mock fetch returning a real ReadableStream<Uint8Array>):

  • HTTP contract: POST /v1/sessions/:id/send, Authorization, Accept: text/event-stream, serialized {message} body
  • typed-event parity for the flat (no-envelope) events assistant_text and tool_use
  • frame split across chunk boundaries reassembled (parser buffer-split path)
  • unknown event types skipped; typed error event
  • sendStream throws sendStream failed: <status> on a non-ok response

src/__tests__/send-execute.test.ts:

  • HTTP contract for execute (/execute, {tool,input}) and send (/send, Accept: application/json, {message}), incl. auth/content-type headers
  • execute returns ToolResult on success; soft-fails (success:false, status-prefixed error) on non-ok
  • send returns SendResult with tool_calls; throws send failed: <status> <body> on non-ok

Scope note — two TS↔Python drifts escalated, deliberately out of scope here

Porting the Python streaming tests surfaced one systemic parseSseChunk drift, escalated as separate issues:

The parser fix and the real Python-parity assertions for tool_result / done / malformed handling land together in the parser-alignment PR (those changes are a public-contract behavior change). This PR stays strictly test-only and drift-free; it does not ship tests that pin the current defective behavior.

Verification

  • packages/core: npx vitest run → 45 passing
  • npx tsc --noEmit → no errors
  • No wire shape changed; no Python/backend edit required

…sult/done/malformed tripwires; codespar#51/codespar#53 fully deferred to parser-alignment PR
@AndreLFSMartins

Copy link
Copy Markdown
Contributor Author

Closing: the test-only approach for the SSE parser drift was not the right vehicle. The parser fix + real Python-parity tests will land together in a follow-up alignment PR. Drift escalations remain tracked in #51 and #53.

@AndreLFSMartins
AndreLFSMartins deleted the test/core-send-execute-stream-coverage branch May 19, 2026 20:13
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