DoH probe-outcomes summary with now-vs-prior-run delta (D-0059) #140

Merged
hannah-vernon merged 1 commit from feature/doh-probe-outcomes-summary into dev 2026-09-25 12:41:30 -05:00
Owner

What does this PR do?

Adds a DoH probe-outcomes summary so an operator can see, at a glance, how many DoH candidate addresses sit in each probe outcome, with a delta comparing the most recent probe cycle against the previous one (D-0059).

A "Probe outcomes" panel on /configuration#doh-blocklist renders a Now / Prior run / Delta table across the five outcomes (Confirmed, RespondedNonCompliant, Refused, Timeout, Unprobed). The Refused row is split into indented sub-rows by the HTTP status the resolver returned (or "no HTTP response" for a transport-level refusal). The same data is exposed read-only at GET /api/v1/doh/probes/summary.

The per-address probe results already persisted in doh_probe_results, but nothing aggregated them. IDohProbeResultStore.CountByStatusAsync returns per-(status, HTTP-status) tallies (a SQL GROUP BY on Postgres, not a full-row load). DohProbeWorker folds those into a DohProbeOutcomeSummary at each cycle end and saves it through the new IDohProbeSummaryStore. Because the probe worker runs in the PipelineHost while the Admin UI/API run in the AdminApi, the summary is persisted so the two share it through Postgres, following the D-0055 single-row reconciliation-proposal pattern: a single-row doh_probe_summary table (fixed id 1, check constraint id = 1, detail_json snapshot), in-memory and Postgres stores, and EF migration AddDohProbeSummary that auto-applies on deploy.

Delta semantics: "prior run" is the previous completed probe cycle (an on-demand probe-now cycle counts as a run). Both summaries are captured at cycle end so they are directly comparable snapshots; the delta is Now minus Prior per category and is stable across page reloads. The stored snapshot keeps exactly two summaries, Current and Prior, rolled on each save, so there is no history growth. Until a second cycle completes, Prior is null and the delta column shows a placeholder.

This is read-only status data, not a behaviour-controlling value, so the standing "expose in both the Admin UI and the API" rule is satisfied by the panel plus the endpoint; no new configuration value is introduced.

Fixes #

How was this tested?

  • dotnet build - 0 errors, 0 warnings
  • dotnet test - all tests pass (Application 594, AdminApi 230)
  • Manually tested on ___ (not yet exercised against live hardware; a real probe cycle is needed to populate Current, and a second to populate Prior/deltas)

New tests: FromCounts aggregation and refused-split ordering, in-memory summary-store roll (Prior = old Current), and the endpoint's null-snapshot and populated current/prior/deltas shapes.

Assumptions

  • "Prior run" means the previous completed probe cycle, not a rolling time window. Confirmed with the project owner ("delta column comparing 'now' with the 'prior run'").
  • The summary is a snapshot-vs-snapshot comparison captured at cycle end, so the delta is stable across page reloads rather than recomputed live.
  • The delta and prior columns show a placeholder until a second cycle has completed; there is no historical trend view (out of scope for a now-vs-prior comparison).
  • Total counts probed addresses only; feed CIDR ranges are never probed and carry no probe record, so they are excluded from the counts.

Checklist

  • I have read the Contributing Guide
  • Changes are focused - one logical change per PR
  • Documentation updated (DECISIONS.md D-0059, AGENT-README.md, ARCHITECTURE.md, docs/read-only-api.md)
  • New dependencies are MIT/Apache-2.0/BSD, security-vetted, and recorded in THIRD-PARTY-NOTICES.md (none added)
  • No secrets, credentials, or real infrastructure identifiers in the diff
  • No commented-out code or debug leftovers
## What does this PR do? Adds a **DoH probe-outcomes summary** so an operator can see, at a glance, how many DoH candidate addresses sit in each probe outcome, with a delta comparing the most recent probe cycle against the previous one (D-0059). A "Probe outcomes" panel on `/configuration#doh-blocklist` renders a Now / Prior run / Delta table across the five outcomes (Confirmed, RespondedNonCompliant, Refused, Timeout, Unprobed). The Refused row is split into indented sub-rows by the HTTP status the resolver returned (or "no HTTP response" for a transport-level refusal). The same data is exposed read-only at `GET /api/v1/doh/probes/summary`. The per-address probe results already persisted in `doh_probe_results`, but nothing aggregated them. `IDohProbeResultStore.CountByStatusAsync` returns per-(status, HTTP-status) tallies (a SQL `GROUP BY` on Postgres, not a full-row load). `DohProbeWorker` folds those into a `DohProbeOutcomeSummary` at each cycle end and saves it through the new `IDohProbeSummaryStore`. Because the probe worker runs in the PipelineHost while the Admin UI/API run in the AdminApi, the summary is persisted so the two share it through Postgres, following the D-0055 single-row reconciliation-proposal pattern: a single-row `doh_probe_summary` table (fixed id 1, check constraint `id = 1`, `detail_json` snapshot), in-memory and Postgres stores, and EF migration `AddDohProbeSummary` that auto-applies on deploy. **Delta semantics:** "prior run" is the previous completed probe cycle (an on-demand probe-now cycle counts as a run). Both summaries are captured at cycle end so they are directly comparable snapshots; the delta is Now minus Prior per category and is stable across page reloads. The stored snapshot keeps exactly two summaries, Current and Prior, rolled on each save, so there is no history growth. Until a second cycle completes, Prior is null and the delta column shows a placeholder. This is read-only status data, not a behaviour-controlling value, so the standing "expose in both the Admin UI and the API" rule is satisfied by the panel plus the endpoint; no new configuration value is introduced. Fixes # ## How was this tested? - [x] `dotnet build` - 0 errors, 0 warnings - [x] `dotnet test` - all tests pass (Application 594, AdminApi 230) - [ ] Manually tested on ___ (not yet exercised against live hardware; a real probe cycle is needed to populate Current, and a second to populate Prior/deltas) New tests: `FromCounts` aggregation and refused-split ordering, in-memory summary-store roll (Prior = old Current), and the endpoint's null-snapshot and populated current/prior/deltas shapes. ## Assumptions - "Prior run" means the previous completed probe cycle, not a rolling time window. Confirmed with the project owner ("delta column comparing 'now' with the 'prior run'"). - The summary is a snapshot-vs-snapshot comparison captured at cycle end, so the delta is stable across page reloads rather than recomputed live. - The delta and prior columns show a placeholder until a second cycle has completed; there is no historical trend view (out of scope for a now-vs-prior comparison). - `Total` counts probed addresses only; feed CIDR ranges are never probed and carry no probe record, so they are excluded from the counts. ## Checklist - [x] I have read the Contributing Guide - [x] Changes are focused - one logical change per PR - [x] Documentation updated (DECISIONS.md D-0059, AGENT-README.md, ARCHITECTURE.md, docs/read-only-api.md) - [x] New dependencies are MIT/Apache-2.0/BSD, security-vetted, and recorded in THIRD-PARTY-NOTICES.md (none added) - [x] No secrets, credentials, or real infrastructure identifiers in the diff - [x] No commented-out code or debug leftovers
Aggregate the per-address doh_probe_results into a per-category probe-outcome
summary (Confirmed, RespondedNonCompliant, Refused, Timeout, Unprobed), with the
Refused row split by HTTP status, and show a delta comparing the most recent
probe cycle against the previous one.

- IDohProbeResultStore.CountByStatusAsync: per-(status, HTTP-status) tallies
  (SQL GROUP BY on Postgres, GroupBy in-memory).
- DohProbeSummary domain: DohProbeOutcomeSummary.FromCounts, two-snapshot
  DohProbeSummarySnapshot (Current + Prior), IDohProbeSummaryStore.
- Single-row doh_probe_summary store (in-memory + Postgres, fixed id 1, check
  constraint id = 1), rolling the old Current into Prior on each save. EF
  migration AddDohProbeSummary. Follows the D-0055 reconciliation-proposal
  pattern.
- DohProbeWorker saves a summary at each cycle end; DI registered in both hosts.
- Read-only GET /api/v1/doh/probes/summary returning current/prior/deltas.
- "Probe outcomes" Now / Prior run / Delta panel on /configuration#doh-blocklist.
- Tests: FromCounts aggregation and refused-split ordering, in-memory store roll,
  endpoint null and populated shapes.
- Docs: DECISIONS D-0059, AGENT-README, ARCHITECTURE, docs/read-only-api.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Dependencies

No dependencies set

Reference
hannah-vernon/viegard-sentinel!140
No description provided.