Files
weatherreporter/docs/internal/forecast-derivation.md

77 lines
2.0 KiB
Markdown
Raw Normal View History

2026-05-29 17:12:20 +00:00
# Forecast Derivation Internals
2026-05-29 19:54:22 +00:00
This document describes deterministic forecast summarization in
`internal/forecast`.
2026-05-29 17:12:20 +00:00
## Purpose
`internal/forecast` converts normalized weather data into daily and period
2026-06-09 21:37:28 +00:00
summaries used by fact builders and module builders.
2026-05-29 17:12:20 +00:00
2026-05-29 19:54:22 +00:00
## Inputs And Outputs
2026-05-29 17:12:20 +00:00
Inputs:
- `weatherdata.Bundle`
2026-05-29 19:54:22 +00:00
- local date or resolved report period
- timezone
- configured daypart definitions
2026-05-29 17:12:20 +00:00
2026-05-29 19:54:22 +00:00
Outputs:
2026-05-29 17:12:20 +00:00
2026-05-29 19:54:22 +00:00
- `forecast.DailySummary` for one local civil day
- one clipped daily summary per local day or partial day from
`BuildPeriodDailySummaries`
- daypart summaries with selected hourly periods, ranges, timed maximums,
conditions, indicators, and alert overlaps
2026-05-29 17:12:20 +00:00
## Boundaries
2026-05-29 19:54:22 +00:00
- This package groups, selects, and summarizes already-normalized forecast
data.
- It does not perform HTTP calls, parse CLI flags, resolve report definitions,
compare prior snapshots, build prompt input packages, or invoke Scriptorium.
## Config Fields Used
- `dayparts[].name`
- `dayparts[].start`
- `dayparts[].end`
Threshold constants for basic indicators live in forecast code rather than
configuration.
## External Adapters Used
None directly. Forecast data arrives through `weatherdata.Bundle`.
2026-05-29 19:54:22 +00:00
## State Or Manifest Behavior
None. Source warnings and provenance from the bundle are carried into summaries
2026-06-09 21:37:28 +00:00
for later metadata and module output.
2026-05-29 19:54:22 +00:00
## Skip And Resume Behavior
None. Missing optional source context can produce empty selections, but missing
required hourly data fails summarization.
2026-05-29 17:12:20 +00:00
## Failure Behavior
2026-05-29 19:54:22 +00:00
- A nil bundle or missing hourly forecast data returns an error.
- Invalid daypart definitions return parse errors with context.
- Alert records without parseable RFC3339 timing are skipped.
- Empty selected periods produce empty summaries rather than generated prose.
2026-05-29 17:12:20 +00:00
## Tests
Inspect:
- `internal/forecast/derive_test.go`
- `internal/timeutil/periods_test.go`
## Invariants
2026-05-29 19:54:22 +00:00
- Go owns report-period selection and meteorological summarization.
- Weather facts come from normalized source data.
- Outputs remain JSON-inspectable and independent of CLI, state, and adapters.