[GH-ISSUE #2415] [Issue]: 11-PROV-RUNTIME-stream-event-contract embedded stream errors bypass event contract #1184

Closed
opened 2026-10-21 05:28:29 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2415

Originally assigned to: @Xelvanis on GitHub.

Summary

11-PROV-RUNTIME-stream-event-contract has embedded-vs-remote drift: remote /api/llm/stream sends an error stream event on Rust failure, but embedded Tauri channel streaming rejects the command and the shared API throws instead of yielding an error chunk.

Expected behavior

Streaming should expose the same stable event contract across embedded Tauri and remote runtime: start, token, thinking, usage, tool_call, error, and done. Provider/Rust failures should surface through the documented stream event contract before the stream terminates.

Actual behavior

The refactor declares error as part of LlmChunk, and remote runtime emits type: "error" SSE on llm_stream_events failure. Embedded Tauri uses llm_stream_channel; if the native command rejects, src/shared/api/llm-api.ts stores the failure and throws from the async generator instead of yielding an error event.

Steps to reproduce

  1. Use an embedded Tauri LLM stream path that causes llm_stream_events to return an AppError.
  2. Observe llmApi.stream(...).
  3. Compare with remote /api/llm/stream for the same Rust failure path.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor parityscan for #2410
  • Run mode: Tauri desktop and remote runtime
  • OS + version: not relevant; static trace
  • Node + pnpm versions: not relevant; static trace
  • Rust version, if relevant: not relevant; static trace
  • Remote Runtime URL configured? yes for remote comparison
  • Provider, model, or integration, if relevant: LLM streaming provider transport

Logs, screenshots, or video

Static proof:

  • Refactor event contract declares error: src/engine/capabilities/llm.ts:31
  • Embedded Tauri wrapper throws on native command rejection: src/shared/api/llm-api.ts:121
  • Embedded stream command passes events through a Tauri channel: src-tauri/src/commands/storage/llm.rs:171
  • Remote stream emits type: "error" when Rust streaming returns an error: src-tauri/src/http_server.rs:1216
  • Legacy SSE emitted error events from /api/generate: packages/server/src/routes/generate.routes.ts:11143 on main
  • Legacy SSE envelope helper: packages/server/src/routes/generate/sse.ts:14 on main

Regression notes

Legacy /api/generate used SSE error events for generation failures. The refactor contract still includes error, but embedded Tauri does not preserve the same stream-event envelope for native command failures.

Source surface: #2410, 11-PROV-RUNTIME-stream-event-contract.

Additional context

Acceptance criteria:

  • Embedded Tauri and remote LLM streaming expose provider/Rust failures through a consistent stream error contract.
  • Existing callers that expect thrown AbortError for cancellation keep working.
  • Add focused proof for embedded and remote stream failure behavior.
  • Keep the surface ID 11-PROV-RUNTIME-stream-event-contract visible in the fix notes.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2415 Originally assigned to: @Xelvanis on GitHub. ## Summary `11-PROV-RUNTIME-stream-event-contract` has embedded-vs-remote drift: remote `/api/llm/stream` sends an `error` stream event on Rust failure, but embedded Tauri channel streaming rejects the command and the shared API throws instead of yielding an `error` chunk. ## Expected behavior Streaming should expose the same stable event contract across embedded Tauri and remote runtime: `start`, `token`, `thinking`, `usage`, `tool_call`, `error`, and `done`. Provider/Rust failures should surface through the documented stream event contract before the stream terminates. ## Actual behavior The refactor declares `error` as part of `LlmChunk`, and remote runtime emits `type: "error"` SSE on `llm_stream_events` failure. Embedded Tauri uses `llm_stream_channel`; if the native command rejects, `src/shared/api/llm-api.ts` stores the failure and throws from the async generator instead of yielding an `error` event. ## Steps to reproduce 1. Use an embedded Tauri LLM stream path that causes `llm_stream_events` to return an `AppError`. 2. Observe `llmApi.stream(...)`. 3. Compare with remote `/api/llm/stream` for the same Rust failure path. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor parityscan for #2410 - Run mode: Tauri desktop and remote runtime - OS + version: not relevant; static trace - Node + pnpm versions: not relevant; static trace - Rust version, if relevant: not relevant; static trace - Remote Runtime URL configured? yes for remote comparison - Provider, model, or integration, if relevant: LLM streaming provider transport ## Logs, screenshots, or video Static proof: - Refactor event contract declares `error`: `src/engine/capabilities/llm.ts:31` - Embedded Tauri wrapper throws on native command rejection: `src/shared/api/llm-api.ts:121` - Embedded stream command passes events through a Tauri channel: `src-tauri/src/commands/storage/llm.rs:171` - Remote stream emits `type: "error"` when Rust streaming returns an error: `src-tauri/src/http_server.rs:1216` - Legacy SSE emitted `error` events from `/api/generate`: `packages/server/src/routes/generate.routes.ts:11143` on `main` - Legacy SSE envelope helper: `packages/server/src/routes/generate/sse.ts:14` on `main` ## Regression notes Legacy `/api/generate` used SSE `error` events for generation failures. The refactor contract still includes `error`, but embedded Tauri does not preserve the same stream-event envelope for native command failures. Source surface: #2410, `11-PROV-RUNTIME-stream-event-contract`. ## Additional context Acceptance criteria: - Embedded Tauri and remote LLM streaming expose provider/Rust failures through a consistent stream error contract. - Existing callers that expect thrown `AbortError` for cancellation keep working. - Add focused proof for embedded and remote stream failure behavior. - Keep the surface ID `11-PROV-RUNTIME-stream-event-contract` visible in the fix notes. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:28:29 +07:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1184
No description provided.