Files
weatherreporter/docs/internal/report-registry.md

144 lines
6.2 KiB
Markdown
Raw Normal View History

2026-05-29 17:17:50 +00:00
# Report Registry Internals
2026-06-17 16:11:09 +00:00
This document describes report identity, valid-period resolution, output
naming, artifact grouping, batch command names, and comparison declarations in
2026-05-29 20:49:19 +00:00
`internal/report`.
2026-05-29 17:17:50 +00:00
## Purpose
2026-06-15 12:33:55 +00:00
`internal/report` is the canonical source for report definitions, public
command names, config-key aliases, and batch command names. App, config, state,
module building, and CLI wiring consume report-owned helpers and resolved
definitions instead of owning report identity policy themselves.
2026-05-29 17:17:50 +00:00
2026-05-29 20:49:19 +00:00
## Definition Fields
2026-05-29 17:17:50 +00:00
2026-05-29 20:49:19 +00:00
Each report definition declares:
2026-05-29 17:17:50 +00:00
2026-05-29 20:49:19 +00:00
- report ID and display name
- Scriptorium prompt ID
2026-06-14 04:28:30 +00:00
- generation mode
2026-05-29 20:49:19 +00:00
- valid-period resolver
- comparison strategy
- managed artifact group
- batch output copy filename
- generated-report eligibility
- prior-report compatibility list
- default ordered module composition
2026-05-29 17:17:50 +00:00
2026-06-15 12:33:55 +00:00
Report-owned helpers map public command names and config keys to report IDs.
2026-06-15 14:54:37 +00:00
The generate command names are `daily`, `today`, `tomorrow`, `hourly`,
`three-day`, `weekend`, and `storm`. Config keys also accept selected
underscore and descriptive aliases such as `three_day_outlook`,
2026-06-15 12:33:55 +00:00
`weekend_outlook`, and `storm_report`.
`daily` resolves to the dated Daily Report ID `daily`. `today` resolves to the
independent Today report ID `today`. `reports.today` is not an alias for
2026-06-15 16:49:37 +00:00
`reports.daily`, and retired report keys are not supported.
2026-06-15 15:04:14 +00:00
2026-06-14 05:01:26 +00:00
Markdown report definitions use the `scriptorium_markdown` generation mode.
Their template and structured-text schema identifiers are empty. Daily Report,
Today Report, Tomorrow Report, and Hourly Report declare
`generated_text_template`; the app uses their template and schema identifiers
to validate generated text and render embedded Markdown templates.
2026-06-14 04:28:30 +00:00
2026-06-09 21:42:38 +00:00
## Reports
2026-05-29 17:17:50 +00:00
2026-06-14 04:35:52 +00:00
| Report | ID | Prompt | Generation mode | Artifact group | Batch copy | Prior compatibility |
| --- | --- | --- | --- | --- | --- | --- |
| Daily Report | `daily` | `weather.daily_generated_text` | `generated_text_template` | `daily` | `daily.md` | Daily Report |
2026-06-15 14:54:37 +00:00
| Today Report | `today` | `weather.today_generated_text` | `generated_text_template` | `today` | `today.md` | Today Report |
| Tomorrow Report | `tomorrow` | `weather.tomorrow_generated_text` | `generated_text_template` | `tomorrow` | `tomorrow.md` | Tomorrow Report |
2026-06-14 04:35:52 +00:00
| Hourly Report | `hourly` | `weather.hourly_generated_text` | `generated_text_template` | `hourly` | `hourly.md` | Hourly Report |
| 3-Day Outlook | `three_day` | `weather.three_day_outlook` | `scriptorium_markdown` | `three-day` | `three-day.md` | 3-Day Outlook |
| Weekend Outlook | `weekend` | `weather.weekend_outlook` | `scriptorium_markdown` | `weekend` | `weekend.md` | Weekend Outlook |
| Storm Report | `storm` | `weather.storm_report` | `scriptorium_markdown` | `storm` | `storm.md` | Storm Report |
2026-05-29 17:17:50 +00:00
2026-06-09 21:42:38 +00:00
All report definitions are eligible for generation.
2026-05-29 17:17:50 +00:00
2026-05-29 20:49:19 +00:00
## Valid Periods
2026-05-29 19:54:22 +00:00
- Daily Report covers the selected local civil day and requires an explicit
date.
2026-06-15 14:54:37 +00:00
- Today Report covers the selected local civil day, or the current local civil
day when no date override is supplied.
2026-06-14 23:22:31 +00:00
- Tomorrow Report covers the next local civil day from generation time.
2026-06-14 04:26:05 +00:00
- Hourly Report covers the half-open six-hour period from generation time in
2026-06-12 17:45:37 +00:00
the effective report timezone. The duration is an internal report constant,
not a configuration field.
2026-05-29 20:49:19 +00:00
- 3-Day Outlook covers the interval from generation time through local midnight
three days later.
2026-06-17 16:11:09 +00:00
- Weekend Outlook covers the upcoming weekend window.
2026-05-29 20:49:19 +00:00
- Storm Report covers an explicit event window supplied by the caller.
2026-05-29 19:54:22 +00:00
2026-05-29 20:49:19 +00:00
Storm event windows can be parsed from local `YYYY-MM-DDTHH:MM` timestamps in
the configured timezone or RFC3339 timestamps with explicit offsets. End time
must be after start time.
2026-05-29 19:54:22 +00:00
2026-05-29 20:49:19 +00:00
## Boundaries
2026-05-29 19:54:22 +00:00
2026-06-15 12:33:55 +00:00
`internal/report` defines report metadata, public report names, batch command
names, output naming, and time coverage. It does not collect weather data, plan
2026-06-17 16:11:09 +00:00
batch membership, build module values, compare snapshot contents, write state,
parse CLI flags, or invoke Scriptorium.
2026-05-29 19:54:22 +00:00
2026-06-15 12:33:55 +00:00
The CLI parses flags and command structure, then uses report-owned helpers for
report and batch command names. Config loading uses report-owned helpers for
report override keys.
2026-05-29 19:54:22 +00:00
2026-05-29 20:49:19 +00:00
## Config Fields Used
The app supplies `weather_api.timezone` as a loaded `time.Location`. Batch
2026-06-12 17:45:37 +00:00
output path copying uses batch output names from report definitions. Report
module overrides can use short keys such as `daily`, `today`, `tomorrow`, and
`hourly`, or descriptive names such as `three_day_outlook`.
2026-06-12 17:45:37 +00:00
2026-06-17 16:11:09 +00:00
## Batch Commands
2026-06-12 17:45:37 +00:00
2026-06-17 16:11:09 +00:00
`internal/report` owns the public batch command names `morning` and `evening`
and validates them through `BatchForCommandName`. Data-dependent batch
membership is owned by `internal/app`, because it depends on collected hourly
forecast coverage.
Report definitions still declare default batch output copy filenames. App
batch planning uses those filenames for fixed report entries and supplies
date-qualified names for dynamic Daily entries.
2026-05-29 19:54:22 +00:00
2026-05-29 20:49:19 +00:00
## State And App Usage
2026-05-29 19:54:22 +00:00
2026-05-29 20:49:19 +00:00
- State paths use `ArtifactGroup`.
- Batch output copies use `BatchOutputName`.
- Generation checks `Generated`.
- Module composition defaults use `Modules`.
2026-05-29 20:49:19 +00:00
- Prior lookup checks `CompatiblePriorIDs` and the comparison strategy.
- RunIDs include the resolved report ID.
2026-05-29 17:17:50 +00:00
## Failure Behavior
2026-05-29 20:49:19 +00:00
- Unknown report IDs and batch names return actionable errors.
2026-05-29 19:54:22 +00:00
- Weekend Outlook resolution returns an error when resolved directly on Sunday.
- Storm Report resolution requires start and end, with end after start.
2026-05-29 17:17:50 +00:00
## Tests
Inspect:
- `internal/report/period_test.go`
- `internal/app/app_test.go`
2026-05-29 19:54:22 +00:00
- `internal/cli/root_test.go`
2026-05-29 17:17:50 +00:00
## Invariants
- Report selection goes through the registry.
2026-06-15 12:33:55 +00:00
- Public command names, config-key aliases, and batch command names are owned
by `internal/report`.
- Direct Markdown reports have empty template and generated-text schema IDs.
- Generated-text-template reports declare prompt, template, and schema IDs in
their report definition.
2026-05-29 19:54:22 +00:00
- Valid periods are half-open intervals independent of rendered report text.
2026-05-29 20:28:06 +00:00
- Artifact grouping, batch output filenames, generated-report eligibility,
default module composition, comparison compatibility, and comparison strategy
are declared by report definition.
2026-06-17 16:11:09 +00:00
- App-owned batch planning uses report definitions but does not live in the
report registry.