Document active alert filtering behavior

This commit is contained in:
2026-06-12 14:10:16 +00:00
parent 8d0bc90f9d
commit cdfe8881d9
4 changed files with 23 additions and 7 deletions

View File

@@ -9,7 +9,7 @@ This document describes the internal HTTP adapter under
The HTTP adapter turns feedapi route definitions into calls on the application
service boundary. It owns route registration, query binding, request validation,
forecast day-slice filtering, outlook active/location filter construction,
response envelopes, and template names.
alert active-time selection, response envelopes, and template names.
## Inputs and Outputs
@@ -35,6 +35,7 @@ The adapter may:
- call the `Service` interface;
- choose the presenter function for an endpoint;
- filter forecast copies for `/today` and `/tomorrow`;
- pass the current UTC instant to active-alert application filtering;
- construct outlook active/location filters.
The adapter must not:
@@ -61,9 +62,9 @@ declared in endpoint definitions, but `templates.base_dir` is loaded by feedapi.
## State
The adapter has no durable state. `forecastNow` and `outlookNow` are
package-level state only to make time-dependent endpoint tests deterministic.
Do not add request caches or cross-request mutable state here.
The adapter has no durable state. `forecastNow`, `alertNow`, and `outlookNow`
are package-level state only to make time-dependent endpoint tests
deterministic. Do not add request caches or cross-request mutable state here.
## Route Registry
@@ -131,6 +132,12 @@ Filtering behavior:
The package variable `forecastNow` exists so endpoint tests can make day-slice
behavior deterministic.
## Alert Active Time
`/alerts/active` uses the shared `format` and `units` binder. The handler calls
the application service with `alertNow().UTC()` so active alert filtering uses
the request-time instant while remaining deterministic in endpoint tests.
## Outlook Filters
Outlook route filters are built at the HTTP boundary and passed to the

View File

@@ -79,7 +79,8 @@ successful responses with `data: null`.
- `CurrentConditions`: aggregates recent rows from `observations` using the
application-provided observation window.
- `LatestAlertRun`: latest row from `alert_runs`, then child `alerts` and
`alert_references`.
`alert_references`. This is the latest stored alert snapshot; active-time
filtering is performed by the application service.
- `LatestHourlyForecast`: latest `forecasts` row where `product = 'hourly'`,
then child `forecast_periods`.
- `LatestNarrativeForecast`: latest `forecasts` row where