Files
meshcore-analyzer/cmd
Kpa-clawbot e96f0f9f9f fix(#1694): port extended ACK decoder to server (ackLen/ackAttempt/ackRand parity) (#1695)
## Summary

Ports the firmware-1.16.0 extended ACK decoding from the ingestor (PR
#1618, issue #1610) into the server-side re-decoder. Previously
`cmd/server/decoder.go` silently dropped `ackLen`, `ackAttempt`, and
`ackRand` (and the multipart inner equivalents) — the server emitted
plain 4-byte ACKs even when the wire carried the 5/6-byte extended form.
Now both decoders agree byte-for-byte.

Closes #1694.

## What changed

- `cmd/server/decoder.go::decodeAck`: sets `AckLen` (capped at 6),
`AckAttempt` (`buf[4]` when `len>=5`), `AckRand` (`buf[5]` when
`len>=6`). Mirrors `cmd/ingestor/decoder.go:279-305`.
- `cmd/server/decoder.go::decodeMultipart` ACK branch: sets `InnerAckLen
= len(buf)-1` (capped at 6), `InnerAckAttempt`, `InnerAckRand`. Mirrors
`cmd/ingestor/decoder.go:696-714`.
- `Payload` struct gains six `*int` fields tagged `omitempty`: `AckLen`,
`AckAttempt`, `AckRand`, `InnerAckLen`, `InnerAckAttempt`,
`InnerAckRand`. Backward-compatible JSON — legacy 4-byte ACKs leave
attempt/rand nil and the fields are omitted from the output.

No other decoder consumer is touched. Routes / store auto-surface the
new fields via JSON marshaling.

## Test layout

`cmd/server/decoder_ack_extended_test.go` drives `decodeAck`
table-driven across the three wire shapes:

| Buffer | AckLen | AckAttempt | AckRand |
|---|---|---|---|
| `EF BE AD DE` (CRC only) | 4 | nil | nil |
| `EF BE AD DE 07` | 5 | 7 | nil |
| `EF BE AD DE 07 42` | 6 | 7 | 0x42 |

Plus `TestDecodeMultipartAckExtendedInner` for a 7-byte multipart buffer
(`0x33` header + 6-byte inner ACK), asserting `InnerAckLen=6`,
`InnerAckAttempt=7`, `InnerAckRand=0x42`.

## TDD trail

- **Red commit** (test + struct stubs only,
`decodeAck`/`decodeMultipart` unchanged) → assertions fail on
`AckLen=nil`.
- **Green commit** (port implementation) → all assertions pass.

Full `cd cmd/server && go test ./...` passes locally.

## Firmware refs

- `firmware/src/helpers/BaseChatMesh.cpp:218-234` (extended ACK layout)
- firmware commit `f6e6fdaa` (attempt counter)
- firmware commit `a130a95a` (RNG byte)

---------

Co-authored-by: Kpa-clawbot <bot@kpa-clawbot>
2026-06-12 19:10:44 -07:00
..