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

138 lines
5.9 KiB
Markdown
Raw Normal View History

2026-05-29 17:17:50 +00:00
# Report Registry Internals
2026-05-29 19:54:22 +00:00
This document describes report identity, valid-period resolution, batch
2026-05-29 20:49:19 +00:00
membership, output naming, artifact grouping, and comparison declarations in
`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
- morning or evening batch membership
- 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.
- Weekend Outlook covers the upcoming weekend window and is not scheduled for
Sunday morning batch resolution.
- 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, and time coverage. It does not fetch weather data, 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
## Batch Membership
2026-06-15 14:54:37 +00:00
Morning batches include Today Report, 3-Day Outlook, and Weekend Outlook
except on Sunday. Evening batches include Tomorrow Report. Daily Report and
2026-06-15 14:54:37 +00:00
Hourly Report are not part of a scheduled batch.
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.