Document Tomorrow generated-text workflow
This commit is contained in:
@@ -38,6 +38,10 @@ Outputs:
|
||||
Every registered composition entry has a builder. Unknown or unimplemented
|
||||
module IDs fail validation instead of being skipped.
|
||||
|
||||
Tomorrow Report supports the Daily-style civil-day modules plus
|
||||
`tomorrow_planning` and `hourly_forecast`; those outputs feed the Tomorrow
|
||||
GeneratedText prompt package and embedded Markdown template.
|
||||
|
||||
Hourly Report supports source and valid-period modules that operate over its
|
||||
rolling six-hour period: `metadata`, `current_conditions`, `hourly_forecast`,
|
||||
`precip_timing`, `alert_digest`, `spc_convective_outlooks`,
|
||||
|
||||
@@ -7,21 +7,23 @@ This document describes structured generated-text handling in
|
||||
|
||||
`internal/generatedtext` validates structured text returned for
|
||||
generated-text-template reports and builds curated render contexts for
|
||||
templates. The first implemented contract is the Hourly Report.
|
||||
templates. The implemented contracts are Tomorrow Report and Hourly Report.
|
||||
|
||||
## Inputs And Outputs
|
||||
|
||||
Inputs:
|
||||
|
||||
- raw Hourly Report GeneratedText JSON
|
||||
- raw GeneratedText JSON for Tomorrow Report or Hourly Report
|
||||
- report metadata from `internal/briefing`
|
||||
- a module snapshot from `internal/module`
|
||||
- validated hourly generated text
|
||||
- validated generated text
|
||||
|
||||
Outputs:
|
||||
|
||||
- typed `Tomorrow` generated text
|
||||
- typed `Hourly` generated text
|
||||
- normalized stable JSON for validated hourly generated text
|
||||
- normalized stable JSON for validated generated text
|
||||
- typed `TomorrowRenderContext` values for `internal/reporttemplate`
|
||||
- typed `HourlyRenderContext` values for `internal/reporttemplate`
|
||||
|
||||
The hourly generated text JSON accepts:
|
||||
@@ -39,6 +41,22 @@ The hourly generated text JSON accepts:
|
||||
`precipitation_timing` and `confidence` are optional and omitted from normalized
|
||||
JSON when blank.
|
||||
|
||||
The Tomorrow generated text JSON accepts:
|
||||
|
||||
```json
|
||||
{
|
||||
"summary": "string",
|
||||
"forecast_discussion": ["string"],
|
||||
"precipitation_timing": "string",
|
||||
"confidence": "string"
|
||||
}
|
||||
```
|
||||
|
||||
`summary` is required after trimming whitespace. `forecast_discussion` must
|
||||
contain at least one nonblank paragraph after trimming blank items.
|
||||
`precipitation_timing` and `confidence` are optional and omitted from normalized
|
||||
JSON when blank.
|
||||
|
||||
## Boundaries
|
||||
|
||||
- This package owns typed generated-text validation and render-context shaping.
|
||||
@@ -54,7 +72,8 @@ JSON when blank.
|
||||
|
||||
- Malformed generated-text JSON fails with decode context.
|
||||
- Unknown generated-text JSON fields fail during decoding.
|
||||
- Empty required hourly fields fail after trimming whitespace.
|
||||
- Empty required fields fail after trimming whitespace.
|
||||
- Tomorrow forecast discussion fails when no nonblank paragraphs remain.
|
||||
- Missing optional render-context stanzas become nil module pointers.
|
||||
- Invalid render metadata, including missing timezone, missing generated time,
|
||||
or invalid valid period, fails before template rendering.
|
||||
@@ -64,6 +83,7 @@ JSON when blank.
|
||||
Inspect:
|
||||
|
||||
- `internal/generatedtext/hourly_test.go`
|
||||
- `internal/generatedtext/tomorrow_test.go`
|
||||
- `internal/generatedtext/render_context_test.go`
|
||||
|
||||
## Invariants
|
||||
|
||||
@@ -47,6 +47,28 @@ The registry recognizes these IDs:
|
||||
Every registered module has a builder. Report composition entries that refer to
|
||||
unknown or unimplemented module IDs fail validation instead of being skipped.
|
||||
|
||||
## Tomorrow Composition
|
||||
|
||||
The default Tomorrow Report module order is:
|
||||
|
||||
1. `metadata`
|
||||
2. `current_conditions`
|
||||
3. `narrative_forecast`
|
||||
4. `derived_daily_summary`
|
||||
5. `derived_daypart_summaries`
|
||||
6. `precip_timing`
|
||||
7. `alert_digest`
|
||||
8. `spc_convective_outlooks`
|
||||
9. `area_forecast_discussion`
|
||||
10. `spc_convective_discussion`
|
||||
11. `weather_story`
|
||||
12. `outdoor_windows`
|
||||
13. `tomorrow_planning`
|
||||
14. `hourly_forecast`
|
||||
|
||||
The embedded Tomorrow template uses selected deterministic fields from these
|
||||
module outputs after GeneratedText validation.
|
||||
|
||||
## Hourly Composition
|
||||
|
||||
The default Hourly Report module order is:
|
||||
|
||||
@@ -68,8 +68,9 @@ Prompt-facing module intervals use local `period_begins` and `period_ends`
|
||||
labels; canonical report metadata and source timestamps remain structured
|
||||
timestamps where applicable.
|
||||
|
||||
Hourly Report module snapshots use the same package schema and categories when
|
||||
converted into prompt input. The default hourly module list places
|
||||
Tomorrow Report and Hourly Report module snapshots use the same package schema
|
||||
and categories when converted into prompt input. The default hourly module list
|
||||
places
|
||||
`precip_timing` under `derived_summaries`, alert and SPC outlooks under
|
||||
`applicable_risk_products`, AFD/SPC discussion/weather story under
|
||||
`narrative_products`, and current/hourly data under `raw_data`. It does not
|
||||
@@ -77,6 +78,10 @@ include civil-day summary stanzas. Generated-text and render context artifacts
|
||||
are produced later in app orchestration and are not part of the YAML data
|
||||
package.
|
||||
|
||||
The default Tomorrow module list includes civil-day summary stanzas,
|
||||
`tomorrow_planning`, and `hourly_forecast` in the data package before
|
||||
structured GeneratedText is requested from Scriptorium.
|
||||
|
||||
Current categories are:
|
||||
|
||||
- `applicable_risk_products`: location-applicable alerts, warnings, outlooks,
|
||||
|
||||
@@ -27,17 +27,17 @@ Each report definition declares:
|
||||
- default ordered module composition
|
||||
|
||||
Markdown report definitions use the `scriptorium_markdown` generation mode.
|
||||
Their template and structured-text schema identifiers are empty. Hourly Report
|
||||
declares `generated_text_template` with template ID `hourly` and schema ID
|
||||
`hourly`; the app uses those identifiers to validate generated text and render
|
||||
the embedded hourly template.
|
||||
Their template and structured-text schema identifiers are empty. 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.
|
||||
|
||||
## Reports
|
||||
|
||||
| Report | ID | Prompt | Generation mode | Artifact group | Batch copy | Prior compatibility |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| Daily Today | `daily_today` | `weather.daily_report` | `scriptorium_markdown` | `daily` | `daily.md` | Daily Today |
|
||||
| Tomorrow Report | `tomorrow` | `weather.daily_report` | `scriptorium_markdown` | `tomorrow` | `tomorrow.md` | Tomorrow Report |
|
||||
| Tomorrow Report | `tomorrow` | `weather.tomorrow_generated_text` | `generated_text_template` | `tomorrow` | `tomorrow.md` | Tomorrow Report |
|
||||
| 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 |
|
||||
@@ -76,7 +76,8 @@ IDs, then uses the registry for report policy.
|
||||
|
||||
The app supplies `weather_api.timezone` as a loaded `time.Location`. Batch
|
||||
output path copying uses batch output names from report definitions. Report
|
||||
module overrides can use the `hourly` key for Hourly Report.
|
||||
module overrides can use short keys such as `tomorrow` and `hourly`, or
|
||||
canonical report IDs such as `daily_today`.
|
||||
|
||||
## Batch Membership
|
||||
|
||||
@@ -110,7 +111,9 @@ Inspect:
|
||||
## Invariants
|
||||
|
||||
- Report selection goes through the registry.
|
||||
- Daily Today and Tomorrow Report both use `weather.daily_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.
|
||||
- Valid periods are half-open intervals independent of rendered report text.
|
||||
- Artifact grouping, batch output filenames, generated-report eligibility,
|
||||
default module composition, comparison compatibility, and comparison strategy
|
||||
|
||||
@@ -6,8 +6,8 @@ in `internal/reporttemplate`.
|
||||
## Purpose
|
||||
|
||||
`internal/reporttemplate` owns repository-native report templates and companion
|
||||
GeneratedText JSON schemas. The first implemented template contract is the
|
||||
Hourly Report.
|
||||
GeneratedText JSON schemas. The implemented template contracts are Tomorrow
|
||||
Report and Hourly Report.
|
||||
|
||||
The package embeds assets from:
|
||||
|
||||
@@ -27,8 +27,9 @@ Outputs:
|
||||
- GeneratedText schema bytes for prompt/schema configuration
|
||||
- rendered Markdown bytes for app orchestration to persist
|
||||
|
||||
The implemented template ID is `hourly`. The implemented schema ID is also
|
||||
`hourly`, backed by `hourly.generated_text.schema.json`.
|
||||
The implemented template IDs are `tomorrow` and `hourly`. The implemented
|
||||
schema IDs are also `tomorrow` and `hourly`, backed by
|
||||
`tomorrow.generated_text.schema.json` and `hourly.generated_text.schema.json`.
|
||||
|
||||
## Boundaries
|
||||
|
||||
@@ -41,31 +42,37 @@ GeneratedText validation is owned by `internal/generatedtext`. App
|
||||
orchestration decides which template and schema IDs apply to a report through
|
||||
`internal/report` definitions.
|
||||
|
||||
## Template Contract
|
||||
## Template Contracts
|
||||
|
||||
Hourly rendering uses a typed render context with:
|
||||
Tomorrow and Hourly rendering use typed render contexts with:
|
||||
|
||||
- report metadata labels such as title, location, valid period, and generation
|
||||
time
|
||||
- validated hourly GeneratedText prose slots
|
||||
- validated GeneratedText prose slots
|
||||
- deterministic labels derived from module outputs, including current
|
||||
conditions, hourly forecast rows, precipitation timing, alerts, SPC outlooks,
|
||||
forecast discussion, SPC discussion, and weather story
|
||||
|
||||
Tomorrow additionally exposes forecast-date labels, ordered daypart forecast
|
||||
rows, daily/daypart summaries, tomorrow planning facts, and a multi-paragraph
|
||||
forecast discussion generated-text slot. The ordered daypart slice is built in
|
||||
Go so templates do not range over maps.
|
||||
|
||||
Templates use `text/template` with `missingkey=error`, so missing context fields
|
||||
fail rendering instead of producing incomplete Markdown.
|
||||
|
||||
## Schema Contract
|
||||
|
||||
The hourly GeneratedText schema describes the structured prose Scriptorium is
|
||||
expected to write for the prompt. It requires:
|
||||
The GeneratedText schemas describe the structured prose Scriptorium is expected
|
||||
to write for each generated-text prompt. Hourly requires:
|
||||
|
||||
- `summary`
|
||||
- `forecast_discussion`
|
||||
|
||||
It allows optional `precipitation_timing` and `confidence`, and rejects
|
||||
additional properties. Weather truth remains in module outputs; GeneratedText is
|
||||
limited to prose slots consumed by the template.
|
||||
Tomorrow requires `summary` and a nonempty `forecast_discussion` array. Both
|
||||
schemas allow optional `precipitation_timing` and `confidence`, and reject
|
||||
additional properties. Weather truth remains in module outputs; GeneratedText
|
||||
is limited to prose slots consumed by the template.
|
||||
|
||||
## Failure Behavior
|
||||
|
||||
|
||||
Reference in New Issue
Block a user