The answered-query event carries the opcode, where the answer came from, the upstream, the elapsed time, the block detail and an answer summary #101

Open
opened 2026-10-31 12:42:06 -04:00 by claude · 0 comments
Owner
  • Draft: PQ-3
  • Priority: high
  • Agent: coder
  • Depends on: #100
  • Decisions: Q-PQ-4

Why

  • DnsQueryProcessingPipeline publishes DnsQueryAnsweredEvent with seven fields (src/dotnet/src/Ninlil.Dns.Server.Core/Pipeline/DnsQueryProcessingPipeline.cs:848-858).
  • Resolvers return only Handled(response) (src/dotnet/src/Ninlil.Dns.Server.Core/Resolution/DnsQueryResolution.cs:16-43), so the pipeline cannot tell an authoritative answer from a forwarded, cached or recursive one.
  • An RFC 2136 UPDATE is logged as an SOA query because the event has no opcode (bughunt-plan B20-3). The query log is fed by this event (src/dotnet/src/Ninlil.Dns.Server.QueryLog/DnsQueryLogSubscriber.cs:81).

What changes

  • Ninlil.Dns.Server.Core/Resolution/: add a mutable per-query DnsQueryOutcome class, carried as an init property on the DnsQueryContext record (DnsQueryContext.cs:39). It has these fields:
    • AnswerSource (new DnsAnswerSourceEnum: Authoritative, Cache, Forwarder, Recursive, Rewrite, Blocked, Server for REFUSED/FORMERR/NOTIMP/cookie/TSIG replies and hygiene answers, ZoneTransfer)
    • Upstream (forwarder name; recursive for recursive resolution, so the upstream set stays bounded for #112)
  • Each resolver sets the outcome: AuthoritativeQueryResolver, ForwarderQueryResolver plus Caching/ForwardedResponseCache (a cache hit sets Cache), RecursiveQueryResolver (its cache too), and RewriteTargetChaser/the rewrite branch (DnsQueryProcessingPipeline.cs:743-768).
  • Pipeline:
    • Take Stopwatch.GetTimestamp() at entry.
    • Set the outcome to Blocked with the #100 decision at :703-713, :727-737 and :784-793.
  • DnsQueryAnsweredEvent gains these fields, added at the end with defaults so existing callers compile and an older broker consumer still reads the payload:
    • Opcode, AnswerSource, Upstream, ElapsedMicroseconds, IsAuthenticData
    • BlockKind (from DnsFilterMatchKindEnum plus the schedule kinds), BlockListId, BlockListName, BlockRule
    • AnswerSummary: presentation text of the Answer RRs, cut at 512 characters. Build it only when a subscriber needs it (the query log is enabled), so the cost is not paid when logging is off.
  • Ninlil.Dns.Server.Authoritative/Transfer/ZoneTransferRequestRunner.cs:120 sets ZoneTransfer.
  • Update the benchmark and test constructors (EventBusBenchmarks.cs:91, DnsServerEventBusTests.cs:250,288,622).

Acceptance

  • Test fails first in src/dotnet/tests/Ninlil.Dns.Server.Core.Tests. A blocked domain publishes AnswerSource == Blocked and BlockListName == "Ads". An UPDATE publishes Opcode == Update. A second identical forwarded query publishes AnswerSource == Cache (src/dotnet/tests/Ninlil.Dns.Server.Forwarding.Tests).
  • An answer with 40 A records publishes an AnswerSummary of at most 512 characters.
  • ElapsedMicroseconds > 0 for every published event.
  • Pipeline benchmark before and after, numbers in the PR. The "100 warm queries run zero database commands" check in the Pipeline benchmarks still passes.
  • Whole solution passes (shared library changed).
  • No schema, API or option change. The SignalR live feed payload gains the fields, which is accepted.

Source

  • audit-feature-parity.md §2A #2; bughunt-plan.md:539 (B20-3; absorbs BUG-36).
  • Owner decision 2026-10-31 (Q-PQ-4): "yes, capped 512 chars".
- **Draft:** PQ-3 - **Priority:** high - **Agent:** coder - **Depends on:** #100 - **Decisions:** Q-PQ-4 ### Why - `DnsQueryProcessingPipeline` publishes `DnsQueryAnsweredEvent` with seven fields (`src/dotnet/src/Ninlil.Dns.Server.Core/Pipeline/DnsQueryProcessingPipeline.cs:848-858`). - Resolvers return only `Handled(response)` (`src/dotnet/src/Ninlil.Dns.Server.Core/Resolution/DnsQueryResolution.cs:16-43`), so the pipeline cannot tell an authoritative answer from a forwarded, cached or recursive one. - An RFC 2136 UPDATE is logged as an SOA query because the event has no opcode (bughunt-plan B20-3). The query log is fed by this event (`src/dotnet/src/Ninlil.Dns.Server.QueryLog/DnsQueryLogSubscriber.cs:81`). ### What changes - `Ninlil.Dns.Server.Core/Resolution/`: add a mutable per-query `DnsQueryOutcome` class, carried as an init property on the `DnsQueryContext` record (`DnsQueryContext.cs:39`). It has these fields: - `AnswerSource` (new `DnsAnswerSourceEnum`: `Authoritative`, `Cache`, `Forwarder`, `Recursive`, `Rewrite`, `Blocked`, `Server` for REFUSED/FORMERR/NOTIMP/cookie/TSIG replies and hygiene answers, `ZoneTransfer`) - `Upstream` (forwarder name; `recursive` for recursive resolution, so the upstream set stays bounded for #112) - Each resolver sets the outcome: `AuthoritativeQueryResolver`, `ForwarderQueryResolver` plus `Caching/ForwardedResponseCache` (a cache hit sets `Cache`), `RecursiveQueryResolver` (its cache too), and `RewriteTargetChaser`/the rewrite branch (`DnsQueryProcessingPipeline.cs:743-768`). - Pipeline: - Take `Stopwatch.GetTimestamp()` at entry. - Set the outcome to `Blocked` with the #100 decision at `:703-713`, `:727-737` and `:784-793`. - `DnsQueryAnsweredEvent` gains these fields, added at the end with defaults so existing callers compile and an older broker consumer still reads the payload: - `Opcode`, `AnswerSource`, `Upstream`, `ElapsedMicroseconds`, `IsAuthenticData` - `BlockKind` (from `DnsFilterMatchKindEnum` plus the schedule kinds), `BlockListId`, `BlockListName`, `BlockRule` - `AnswerSummary`: presentation text of the Answer RRs, cut at 512 characters. Build it only when a subscriber needs it (the query log is enabled), so the cost is not paid when logging is off. - `Ninlil.Dns.Server.Authoritative/Transfer/ZoneTransferRequestRunner.cs:120` sets `ZoneTransfer`. - Update the benchmark and test constructors (`EventBusBenchmarks.cs:91`, `DnsServerEventBusTests.cs:250,288,622`). ### Acceptance - [ ] Test fails first in `src/dotnet/tests/Ninlil.Dns.Server.Core.Tests`. A blocked domain publishes `AnswerSource == Blocked` and `BlockListName == "Ads"`. An UPDATE publishes `Opcode == Update`. A second identical forwarded query publishes `AnswerSource == Cache` (`src/dotnet/tests/Ninlil.Dns.Server.Forwarding.Tests`). - [ ] An answer with 40 A records publishes an `AnswerSummary` of at most 512 characters. - [ ] `ElapsedMicroseconds > 0` for every published event. - [ ] Pipeline benchmark before and after, numbers in the PR. The "100 warm queries run zero database commands" check in the Pipeline benchmarks still passes. - [ ] Whole solution passes (shared library changed). - [ ] No schema, API or option change. The SignalR live feed payload gains the fields, which is accepted. ### Source - `audit-feature-parity.md` §2A #2; bughunt-plan.md:539 (B20-3; absorbs BUG-36). - Owner decision 2026-10-31 (Q-PQ-4): "yes, capped 512 chars".
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#101
No description provided.