You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Phase 3.D PR 5a — adds the v2 receipt-handle layout that **PR 5b's
send/receive partitioned fanout will consume**. Pure scaffold: the v2
encoder is added but never called by any production path until PR 5b
lifts the §11 PR 2 dormancy gate. Splitting the codec out as a small
isolated PR keeps PR 5b's review focused on the gate-and-lift atomic
sequence — codec correctness and gate-lift correctness are independent
concerns.
## Wire format
| | v1 (legacy, single partition) | v2 (partitioned) |
|---|---|---|
| `[ 0 ]` | byte version = `0x01` | byte version = `0x02` |
| `[ 1..5 ]` | _(none)_ | `uint32 partition (BE)` ← NEW |
| `[ ?..? ]` | `uint64 queue_gen (BE)` | `uint64 queue_gen (BE)` |
| `[ ?..? ]` | 16 bytes message_id | 16 bytes message_id |
| `[ ?..? ]` | 16 bytes receipt_token | 16 bytes receipt_token |
| **Total** | **41 bytes** | **45 bytes** |
`decodedReceiptHandle` gains `Version` (byte) and `Partition` (uint32)
fields. `decodeReceiptHandle` dispatches on the version byte; v1 keeps
`Partition=0` by definition.
## What does NOT change yet
- `encodeReceiptHandleV2` is **dormant** until PR 5b's SendMessage
fanout dispatch wires it (gated by `meta.PartitionCount > 1`).
Production traffic continues to use the v1 encoder verbatim — no
behaviour change.
- DeleteMessage / ChangeMessageVisibility still consume
`decodedReceiptHandle` without inspecting `Version` or `Partition`. PR
5b adds the cross-version rejection contract (a v1 handle against a
partitioned queue → `ReceiptHandleIsInvalid`, and vice-versa).
## Test plan
- [x] `TestEncodeReceiptHandleV2_RoundTrip` — every `(partition,
queue_gen, message_id, token)` tuple round-trips.
- [x] `TestEncodeReceiptHandleV1_StillReportsV1` — regression: v1
encoder still produces v1-decodable handles with `Partition=0`.
- [x] `TestDecodeReceiptHandle_VersionDispatch` — v1 and v2 produce
distinct on-wire bytes (different version + 4-byte size delta); decoder
picks the right layout.
- [x] `TestDecodeReceiptHandle_RejectsLengthMismatch` — 5 cases (v1 byte
/ v2 length, v2 byte / v1 length, v1 truncated, v2 truncated, empty) all
fail with the same opaque error.
- [x] `TestDecodeReceiptHandle_RejectsUnknownVersion` — `0x00`, `0x03`,
`0x42`, `0xFF` all reject.
- [x] `TestEncodeReceiptHandleV2_RejectsBadInputs` — short/long token,
non-hex/short/empty id all error.
- [x] `TestReceiptHandleVersionConstants_Distinct` — pins `v1 != v2`,
`v1 == 0x01`, `v2 == 0x02`, legacy alias points at v1, on-wire size
constants match.
- [x] `TestDecodeReceiptHandle_RejectsBase64Garbage` — base64 error
surfaces correctly.
- [x] Existing `TestSQSServer_ReceiptHandleCodecRoundTrip` continues to
pass (v1 path).
- [x] `go test -race ./adapter/...` pass.
- [x] `golangci-lint ./adapter/...` clean.
## Self-review (per CLAUDE.md)
1. **Data loss** — codec only; no FSM/Pebble path. No issue.
2. **Concurrency / distributed failures** — no shared state; pure
encode/decode. No issue.
3. **Performance** — encode/decode are O(handle size) ≤ 45 bytes.
Version-byte dispatch is one switch. No issue.
4. **Data consistency** — v1 and v2 are length-distinct,
version-byte-distinct, decoder rejects wrong-length blobs. A v1 client
parsing a v2 handle (or vice versa) fails closed at the length check —
pinned by the 5-case rejection test. No issue.
5. **Test coverage** — 8 new tests covering the codec contract surface;
existing v1 round-trip test continues to pass.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* SQS message receipt handles now support versioned encoding format,
enabling compatibility with partitioned FIFO queues while maintaining
backward compatibility.
* **Tests**
* Added validation tests for receipt handle encoding and decoding
wire-format contract across format versions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
0 commit comments