Conversation
Greptile SummaryThis PR replaces the two-pass encode/truncation design (build full packet, then re-encode with Confidence Score: 5/5Safe to merge — logic is correct, edge cases are well-covered by the new tests, and all three previously flagged concerns are resolved. No P0 or P1 findings. The single-pass approach is cleaner and more efficient than the original two-pass design. TC preservation, AA clearing for NODATA/NXDOMAIN authority drops, and the SOA-validation TC bypass are all implemented correctly and covered by dedicated tests. No files require special attention. Important Files Changed
Reviews (4): Last reviewed commit: "Preserve inbound TC=1 flag when re-encod..." | Re-trigger Greptile |
Collapse encode() and encodeWithTruncation() into a single linear pass that streams answers with partial truncation, then attempts authority and additional all-or-nothing, and only rebuilds the header when counts or the TC flag actually change. Add tests covering section priority, answer-truncation clearing populated non-answer sections, TC preservation on re-encode, the exact maxSize boundary, and NODATA-style drops.
f2d932e to
4e72b66
Compare
Check the original message's answer set (not the post-encoding count) when deciding whether to clear AA — a TC=1 response that merely encoded zero answers isn't semantically NODATA, and TC already signals the client to retry over TCP for the full authoritative answer. Relax the Message constructor's SOA-in-authority invariant for truncated responses so those packets remain decodable.
When a source message already has truncated=true (e.g. a forwarded packet) and encode() drops the additional or authority section under maxSize, the rebuilt header must keep TC=1 so downstream clients still know to retry over TCP. OR the original flag into the rebuilt header's truncated bit instead of always using the locally-computed value.
No description provided.