Skip to content

feat(ws): add result-channel output streaming, ACK handling, and replay#182

Merged
iAziz786 merged 1 commit intomainfrom
add-ws-result-channel
Apr 27, 2026
Merged

feat(ws): add result-channel output streaming, ACK handling, and replay#182
iAziz786 merged 1 commit intomainfrom
add-ws-result-channel

Conversation

@iAziz786
Copy link
Copy Markdown
Contributor

Summary

Add result-channel capabilities to the existing HTTP-polling task runner and WebSocket client so task output and final results stream over the authenticated agent WebSocket with durable ACK handling. HTTP final reporting is preserved as fallback when WebSocket delivery is unavailable.

New files

  • app/jobs/taskjob/result_channel_test.go — tests for result-channel streaming, HTTP fallback, throttled capture, retryable error handling

Modified files

  • app/jobs/taskjob/taskjob.go — add ResultChannel interface, processTaskWithResultChannel for stdout/stderr pipe capture with interval/byte-threshold flush, final persistence before send, HTTP fallback
  • app/services/wsclient/client.go — add SendOutput/SendFinal methods, replayUnacked after hello_ack, ACK-driven outbox removal, write-mutex serialization
  • app/services/wsclient/client_test.go — tests for ack outbox removal, reconnect replay, retryable error handling
  • domain/task/task.go — add ExecutionAttemptID field to domain task
  • internal/wsprotocol/ack_sequence.go — add HighestAcceptedSequence to ErrorPayload/ErrorOptions
  • internal/wsprotocol/ack_sequence_test.go — update error payload tests
  • main.go — wire local store as result outbox into WebSocket client; pass result channel to task job

Key design decisions

  • Output persists to local outbox before WebSocket send (durable before deliver)
  • Throttle flushed on configurable interval (100ms) or byte threshold (16KB)
  • ACK removes exact message_id from outbox; retryable errors keep messages
  • Replay of unacked output/final messages after agent.hello_ack preserves original IDs/sequences
  • HTTP fallback fires when final persistence fails or WS is not configured
  • Write mutex prevents ping/replay/live-send races on the Gorilla websocket

…play

│
~  - Add ResultChannel interface and integrate into task polling runner for
     stdout/stderr capture with interval/byte-threshold flush
   - Add WS client methods for SendOutput, SendFinal, sendIfActive, replayUnacked
   - Wire result outbox into WS client on startup via newDefaultWebSocketRuntime
   - Extend ErrorPayload with HighestAcceptedSequence for retryable gap errors
   - Add ExecutionAttemptID to domain Task model
   - Add tests for ack-driven outbox removal, reconnect replay, throttled
     capture, retryable error handling, and HTTP fallback
@iAziz786 iAziz786 force-pushed the add-ws-result-channel branch from e0b55b6 to 679819b Compare April 27, 2026 16:19
@iAziz786 iAziz786 merged commit 049f255 into main Apr 27, 2026
1 check passed
@iAziz786 iAziz786 deleted the add-ws-result-channel branch April 27, 2026 16:23
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