Skip to content

feat(wsprotocol): implement shared phase-1 WebSocket protocol structs and validation#179

Merged
iAziz786 merged 1 commit intomainfrom
protocol-contract
Apr 27, 2026
Merged

feat(wsprotocol): implement shared phase-1 WebSocket protocol structs and validation#179
iAziz786 merged 1 commit intomainfrom
protocol-contract

Conversation

@iAziz786
Copy link
Copy Markdown
Contributor

Summary

Implement the Go side of the shared phase-1 WebSocket protocol contract. Pure structs, validators, and helpers — no transport or behaviour changes to existing HTTP polling/result reporting.

Changes

  • internal/wsprotocol/message.goEnvelope struct with JSON tags (protocol_version, message_id, type, agent_id, task_id, execution_attempt_id, sequence, sent_at, payload), OutputPayload and FinalPayload structs, all type/stream/status constants, Validate() methods on each, DecodePayload[T] generic helper, IsSupportedType helpers
  • internal/wsprotocol/ack_sequence.goAckPayload/ErrorPayload structs with builders, MessageTracker (dedup by message_id), OutputSequenceTracker (per-stream monotonic sequencing — accepts contiguous, re-ACKs duplicates, rejects gaps as retryable)
  • Testsmessage_test.go (8 tests: JSON round-trip, type catalog, envelope validations, payload validations) and ack_sequence_test.go (8 tests: ack/error shapes, duplicate IDs, contiguous/duplicate/gap sequences, stream independence, canonical field-name locking)

Validation

go test ./internal/wsprotocol  -> ok

… and validation

Go protocol package with:
- Envelope, OutputPayload, FinalPayload structs and JSON tags
- Envelope.Validate(), OutputPayload.Validate(), FinalPayload.Validate()
- AckPayload/ErrorPayload builders and MessageTracker/OutputSequenceTracker for dedup and gap handling
- DecodePayload generic helper for typed payload extraction
- IsSupportedType, isTaskType, isExecutionType helpers

Test: message_test.go and ack_sequence_test.go
@iAziz786 iAziz786 merged commit 9127a4a into main Apr 27, 2026
1 check passed
@iAziz786 iAziz786 deleted the protocol-contract branch April 27, 2026 06:47
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